From 1e31b4f929c564f426c6b51ab954eae8cc1e547d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:19:43 -0400 Subject: [PATCH 001/708] Added base rend2 files --- codemp/rd-rend2/glsl/bokeh_fp.glsl | 70 + codemp/rd-rend2/glsl/bokeh_vp.glsl | 13 + codemp/rd-rend2/glsl/calclevels4x_fp.glsl | 55 + codemp/rd-rend2/glsl/calclevels4x_vp.glsl | 13 + codemp/rd-rend2/glsl/depthblur_fp.glsl | 58 + codemp/rd-rend2/glsl/depthblur_vp.glsl | 12 + codemp/rd-rend2/glsl/dlight_fp.glsl | 12 + codemp/rd-rend2/glsl/dlight_vp.glsl | 92 + codemp/rd-rend2/glsl/down4x_fp.glsl | 34 + codemp/rd-rend2/glsl/down4x_vp.glsl | 13 + codemp/rd-rend2/glsl/fogpass_fp.glsl | 9 + codemp/rd-rend2/glsl/fogpass_vp.glsl | 117 + codemp/rd-rend2/glsl/generic_fp.glsl | 43 + codemp/rd-rend2/glsl/generic_vp.glsl | 251 ++ codemp/rd-rend2/glsl/lightall_fp.glsl | 429 +++ codemp/rd-rend2/glsl/lightall_vp.glsl | 245 ++ codemp/rd-rend2/glsl/pshadow_fp.glsl | 98 + codemp/rd-rend2/glsl/pshadow_vp.glsl | 17 + codemp/rd-rend2/glsl/shadowfill_fp.glsl | 41 + codemp/rd-rend2/glsl/shadowfill_vp.glsl | 89 + codemp/rd-rend2/glsl/shadowmask_fp.glsl | 127 + codemp/rd-rend2/glsl/shadowmask_vp.glsl | 18 + codemp/rd-rend2/glsl/ssao_fp.glsl | 86 + codemp/rd-rend2/glsl/ssao_vp.glsl | 12 + codemp/rd-rend2/glsl/texturecolor_fp.glsl | 12 + codemp/rd-rend2/glsl/texturecolor_vp.glsl | 15 + codemp/rd-rend2/glsl/tonemap_fp.glsl | 48 + codemp/rd-rend2/glsl/tonemap_vp.glsl | 13 + codemp/rd-rend2/tr_animation.c | 656 ++++ codemp/rd-rend2/tr_backend.c | 1786 ++++++++++ codemp/rd-rend2/tr_bsp.c | 3555 +++++++++++++++++++ codemp/rd-rend2/tr_cmds.c | 581 ++++ codemp/rd-rend2/tr_curve.c | 806 +++++ codemp/rd-rend2/tr_extensions.c | 667 ++++ codemp/rd-rend2/tr_extramath.c | 240 ++ codemp/rd-rend2/tr_extramath.h | 105 + codemp/rd-rend2/tr_extratypes.h | 40 + codemp/rd-rend2/tr_fbo.c | 861 +++++ codemp/rd-rend2/tr_fbo.h | 64 + codemp/rd-rend2/tr_flares.c | 532 +++ codemp/rd-rend2/tr_glsl.c | 1833 ++++++++++ codemp/rd-rend2/tr_image.c | 3358 ++++++++++++++++++ codemp/rd-rend2/tr_init.c | 1570 +++++++++ codemp/rd-rend2/tr_light.c | 451 +++ codemp/rd-rend2/tr_local.h | 2677 +++++++++++++++ codemp/rd-rend2/tr_main.c | 2876 ++++++++++++++++ codemp/rd-rend2/tr_marks.c | 466 +++ codemp/rd-rend2/tr_mesh.c | 401 +++ codemp/rd-rend2/tr_model.c | 1569 +++++++++ codemp/rd-rend2/tr_model_iqm.c | 1110 ++++++ codemp/rd-rend2/tr_postprocess.c | 503 +++ codemp/rd-rend2/tr_postprocess.h | 33 + codemp/rd-rend2/tr_scene.c | 532 +++ codemp/rd-rend2/tr_shade.c | 1670 +++++++++ codemp/rd-rend2/tr_shade_calc.c | 1339 ++++++++ codemp/rd-rend2/tr_shader.c | 3787 +++++++++++++++++++++ codemp/rd-rend2/tr_shadows.c | 343 ++ codemp/rd-rend2/tr_sky.c | 912 +++++ codemp/rd-rend2/tr_subs.c | 48 + codemp/rd-rend2/tr_surface.c | 1657 +++++++++ codemp/rd-rend2/tr_vbo.c | 928 +++++ codemp/rd-rend2/tr_world.c | 848 +++++ 62 files changed, 40846 insertions(+) create mode 100644 codemp/rd-rend2/glsl/bokeh_fp.glsl create mode 100644 codemp/rd-rend2/glsl/bokeh_vp.glsl create mode 100644 codemp/rd-rend2/glsl/calclevels4x_fp.glsl create mode 100644 codemp/rd-rend2/glsl/calclevels4x_vp.glsl create mode 100644 codemp/rd-rend2/glsl/depthblur_fp.glsl create mode 100644 codemp/rd-rend2/glsl/depthblur_vp.glsl create mode 100644 codemp/rd-rend2/glsl/dlight_fp.glsl create mode 100644 codemp/rd-rend2/glsl/dlight_vp.glsl create mode 100644 codemp/rd-rend2/glsl/down4x_fp.glsl create mode 100644 codemp/rd-rend2/glsl/down4x_vp.glsl create mode 100644 codemp/rd-rend2/glsl/fogpass_fp.glsl create mode 100644 codemp/rd-rend2/glsl/fogpass_vp.glsl create mode 100644 codemp/rd-rend2/glsl/generic_fp.glsl create mode 100644 codemp/rd-rend2/glsl/generic_vp.glsl create mode 100644 codemp/rd-rend2/glsl/lightall_fp.glsl create mode 100644 codemp/rd-rend2/glsl/lightall_vp.glsl create mode 100644 codemp/rd-rend2/glsl/pshadow_fp.glsl create mode 100644 codemp/rd-rend2/glsl/pshadow_vp.glsl create mode 100644 codemp/rd-rend2/glsl/shadowfill_fp.glsl create mode 100644 codemp/rd-rend2/glsl/shadowfill_vp.glsl create mode 100644 codemp/rd-rend2/glsl/shadowmask_fp.glsl create mode 100644 codemp/rd-rend2/glsl/shadowmask_vp.glsl create mode 100644 codemp/rd-rend2/glsl/ssao_fp.glsl create mode 100644 codemp/rd-rend2/glsl/ssao_vp.glsl create mode 100644 codemp/rd-rend2/glsl/texturecolor_fp.glsl create mode 100644 codemp/rd-rend2/glsl/texturecolor_vp.glsl create mode 100644 codemp/rd-rend2/glsl/tonemap_fp.glsl create mode 100644 codemp/rd-rend2/glsl/tonemap_vp.glsl create mode 100644 codemp/rd-rend2/tr_animation.c create mode 100644 codemp/rd-rend2/tr_backend.c create mode 100644 codemp/rd-rend2/tr_bsp.c create mode 100644 codemp/rd-rend2/tr_cmds.c create mode 100644 codemp/rd-rend2/tr_curve.c create mode 100644 codemp/rd-rend2/tr_extensions.c create mode 100644 codemp/rd-rend2/tr_extramath.c create mode 100644 codemp/rd-rend2/tr_extramath.h create mode 100644 codemp/rd-rend2/tr_extratypes.h create mode 100644 codemp/rd-rend2/tr_fbo.c create mode 100644 codemp/rd-rend2/tr_fbo.h create mode 100644 codemp/rd-rend2/tr_flares.c create mode 100644 codemp/rd-rend2/tr_glsl.c create mode 100644 codemp/rd-rend2/tr_image.c create mode 100644 codemp/rd-rend2/tr_init.c create mode 100644 codemp/rd-rend2/tr_light.c create mode 100644 codemp/rd-rend2/tr_local.h create mode 100644 codemp/rd-rend2/tr_main.c create mode 100644 codemp/rd-rend2/tr_marks.c create mode 100644 codemp/rd-rend2/tr_mesh.c create mode 100644 codemp/rd-rend2/tr_model.c create mode 100644 codemp/rd-rend2/tr_model_iqm.c create mode 100644 codemp/rd-rend2/tr_postprocess.c create mode 100644 codemp/rd-rend2/tr_postprocess.h create mode 100644 codemp/rd-rend2/tr_scene.c create mode 100644 codemp/rd-rend2/tr_shade.c create mode 100644 codemp/rd-rend2/tr_shade_calc.c create mode 100644 codemp/rd-rend2/tr_shader.c create mode 100644 codemp/rd-rend2/tr_shadows.c create mode 100644 codemp/rd-rend2/tr_sky.c create mode 100644 codemp/rd-rend2/tr_subs.c create mode 100644 codemp/rd-rend2/tr_surface.c create mode 100644 codemp/rd-rend2/tr_vbo.c create mode 100644 codemp/rd-rend2/tr_world.c diff --git a/codemp/rd-rend2/glsl/bokeh_fp.glsl b/codemp/rd-rend2/glsl/bokeh_fp.glsl new file mode 100644 index 0000000000..d08816aeff --- /dev/null +++ b/codemp/rd-rend2/glsl/bokeh_fp.glsl @@ -0,0 +1,70 @@ +uniform sampler2D u_TextureMap; + +uniform vec4 u_Color; + +uniform vec2 u_InvTexRes; +varying vec2 var_TexCoords; + +void main() +{ + vec4 color; + vec2 tc; + +#if 0 + float c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0); + + tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture2D(u_TextureMap, tc); + + gl_FragColor = color * 0.04166667 * u_Color; +#endif + + float c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0); + + tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture2D(u_TextureMap, tc); + + gl_FragColor = color * 0.0625 * u_Color; +} diff --git a/codemp/rd-rend2/glsl/bokeh_vp.glsl b/codemp/rd-rend2/glsl/bokeh_vp.glsl new file mode 100644 index 0000000000..5ca4160080 --- /dev/null +++ b/codemp/rd-rend2/glsl/bokeh_vp.glsl @@ -0,0 +1,13 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * attr_Position; + var_TexCoords = attr_TexCoord0.st; +} diff --git a/codemp/rd-rend2/glsl/calclevels4x_fp.glsl b/codemp/rd-rend2/glsl/calclevels4x_fp.glsl new file mode 100644 index 0000000000..c8cf06c710 --- /dev/null +++ b/codemp/rd-rend2/glsl/calclevels4x_fp.glsl @@ -0,0 +1,55 @@ +uniform sampler2D u_TextureMap; + +uniform vec4 u_Color; + +uniform vec2 u_InvTexRes; +varying vec2 var_TexCoords; + +const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); + +vec3 GetValues(vec2 offset, vec3 current) +{ + vec3 minAvgMax; + vec2 tc = var_TexCoords + u_InvTexRes * offset; minAvgMax = texture2D(u_TextureMap, tc).rgb; + +#ifdef FIRST_PASS + float lumi = max(dot(LUMINANCE_VECTOR, minAvgMax), 0.000001); + float loglumi = clamp(log2(lumi), -10.0, 10.0); + minAvgMax = vec3(loglumi * 0.05 + 0.5); +#endif + + return vec3(min(current.x, minAvgMax.x), current.y + minAvgMax.y, max(current.z, minAvgMax.z)); +} + +void main() +{ + vec3 current = vec3(1.0, 0.0, 0.0); + +#ifdef FIRST_PASS + current = GetValues(vec2( 0.0, 0.0), current); +#else + current = GetValues(vec2(-1.5, -1.5), current); + current = GetValues(vec2(-0.5, -1.5), current); + current = GetValues(vec2( 0.5, -1.5), current); + current = GetValues(vec2( 1.5, -1.5), current); + + current = GetValues(vec2(-1.5, -0.5), current); + current = GetValues(vec2(-0.5, -0.5), current); + current = GetValues(vec2( 0.5, -0.5), current); + current = GetValues(vec2( 1.5, -0.5), current); + + current = GetValues(vec2(-1.5, 0.5), current); + current = GetValues(vec2(-0.5, 0.5), current); + current = GetValues(vec2( 0.5, 0.5), current); + current = GetValues(vec2( 1.5, 0.5), current); + + current = GetValues(vec2(-1.5, 1.5), current); + current = GetValues(vec2(-0.5, 1.5), current); + current = GetValues(vec2( 0.5, 1.5), current); + current = GetValues(vec2( 1.5, 1.5), current); + + current.y *= 0.0625; +#endif + + gl_FragColor = vec4(current, 1.0f); +} diff --git a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl new file mode 100644 index 0000000000..5ca4160080 --- /dev/null +++ b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl @@ -0,0 +1,13 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * attr_Position; + var_TexCoords = attr_TexCoord0.st; +} diff --git a/codemp/rd-rend2/glsl/depthblur_fp.glsl b/codemp/rd-rend2/glsl/depthblur_fp.glsl new file mode 100644 index 0000000000..93895b4e17 --- /dev/null +++ b/codemp/rd-rend2/glsl/depthblur_fp.glsl @@ -0,0 +1,58 @@ +uniform sampler2D u_ScreenImageMap; +uniform sampler2D u_ScreenDepthMap; + +uniform vec4 u_ViewInfo; // zfar / znear, zfar +varying vec2 var_ScreenTex; + +//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033); +float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); +//float gauss[3] = float[3](0.60, 0.19, 0.0066); +#define GAUSS_SIZE 4 + +float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) +{ + float sampleZDivW = texture2D(depthMap, tex).r; + return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); +} + +vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar) +{ + float scale = 1.0 / 256.0; + +#if defined(USE_HORIZONTAL_BLUR) + vec2 direction = vec2(1.0, 0.0) * scale; +#else // if defined(USE_VERTICAL_BLUR) + vec2 direction = vec2(0.0, 1.0) * scale; +#endif + + float depthCenter = zFar * getLinearDepth(depthMap, tex, zFarDivZNear); + vec2 centerSlope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y)); + + vec4 result = texture2D(imageMap, tex) * gauss[0]; + float total = gauss[0]; + + int i, j; + for (i = 0; i < 2; i++) + { + for (j = 1; j < GAUSS_SIZE; j++) + { + vec2 offset = direction * j; + float depthSample = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear); + float depthExpected = depthCenter + dot(centerSlope, offset); + if(abs(depthSample - depthExpected) < 5.0) + { + result += texture2D(imageMap, tex + offset) * gauss[j]; + total += gauss[j]; + } + } + + direction = -direction; + } + + return result / total; +} + +void main() +{ + gl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); +} diff --git a/codemp/rd-rend2/glsl/depthblur_vp.glsl b/codemp/rd-rend2/glsl/depthblur_vp.glsl new file mode 100644 index 0000000000..9c46a79f26 --- /dev/null +++ b/codemp/rd-rend2/glsl/depthblur_vp.glsl @@ -0,0 +1,12 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +varying vec2 var_ScreenTex; + +void main() +{ + gl_Position = attr_Position; + var_ScreenTex = attr_TexCoord0.xy; + //vec2 screenCoords = gl_Position.xy / gl_Position.w; + //var_ScreenTex = screenCoords * 0.5 + 0.5; +} diff --git a/codemp/rd-rend2/glsl/dlight_fp.glsl b/codemp/rd-rend2/glsl/dlight_fp.glsl new file mode 100644 index 0000000000..8ffca5b98d --- /dev/null +++ b/codemp/rd-rend2/glsl/dlight_fp.glsl @@ -0,0 +1,12 @@ +uniform sampler2D u_DiffuseMap; + +varying vec2 var_Tex1; +varying vec4 var_Color; + + +void main() +{ + vec4 color = texture2D(u_DiffuseMap, var_Tex1); + + gl_FragColor = color * var_Color; +} diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl new file mode 100644 index 0000000000..d9fd71d061 --- /dev/null +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -0,0 +1,92 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; +attribute vec3 attr_Normal; + +uniform vec4 u_DlightInfo; + +#if defined(USE_DEFORM_VERTEXES) +uniform int u_DeformGen; +uniform float u_DeformParams[5]; +uniform float u_Time; +#endif + +uniform vec4 u_Color; +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_Tex1; +varying vec4 var_Color; + +#if defined(USE_DEFORM_VERTEXES) +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + if (u_DeformGen == 0) + { + return pos; + } + + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + if (u_DeformGen == DGEN_BULGE) + { + phase *= M_PI * 0.25 * st.x; + } + else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) + { + phase += dot(pos.xyz, vec3(spread)); + } + + float value = phase + (u_Time * frequency); + float func; + + if (u_DeformGen == DGEN_WAVE_SIN) + { + func = sin(value * 2.0 * M_PI); + } + else if (u_DeformGen == DGEN_WAVE_SQUARE) + { + func = sign(sin(value * 2.0 * M_PI)); + } + else if (u_DeformGen == DGEN_WAVE_TRIANGLE) + { + func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + } + else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) + { + func = fract(value); + } + else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) + { + func = (1.0 - fract(value)); + } + else if (u_DeformGen == DGEN_BULGE) + { + func = sin(value); + } + + return pos + normal * (base + func * amplitude); +} +#endif + +void main() +{ + vec4 position = attr_Position; + vec3 normal = attr_Normal; + +#if defined(USE_DEFORM_VERTEXES) + position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); +#endif + + gl_Position = u_ModelViewProjectionMatrix * position; + + vec3 dist = u_DlightInfo.xyz - position.xyz; + + var_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5); + float dlightmod = step(0.0, dot(dist, normal)); + dlightmod *= clamp(2.0 * (1.0 - abs(dist.z) * u_DlightInfo.a), 0.0, 1.0); + + var_Color = u_Color * dlightmod; +} diff --git a/codemp/rd-rend2/glsl/down4x_fp.glsl b/codemp/rd-rend2/glsl/down4x_fp.glsl new file mode 100644 index 0000000000..0f88fb2e34 --- /dev/null +++ b/codemp/rd-rend2/glsl/down4x_fp.glsl @@ -0,0 +1,34 @@ +uniform sampler2D u_TextureMap; + +uniform vec2 u_InvTexRes; +varying vec2 var_TexCoords; + +void main() +{ + vec4 color; + vec2 tc; + + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture2D(u_TextureMap, tc); + + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture2D(u_TextureMap, tc); + + color *= 0.0625; + + gl_FragColor = color; +} diff --git a/codemp/rd-rend2/glsl/down4x_vp.glsl b/codemp/rd-rend2/glsl/down4x_vp.glsl new file mode 100644 index 0000000000..5ca4160080 --- /dev/null +++ b/codemp/rd-rend2/glsl/down4x_vp.glsl @@ -0,0 +1,13 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * attr_Position; + var_TexCoords = attr_TexCoord0.st; +} diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl new file mode 100644 index 0000000000..91884304d5 --- /dev/null +++ b/codemp/rd-rend2/glsl/fogpass_fp.glsl @@ -0,0 +1,9 @@ +uniform vec4 u_Color; + +varying float var_Scale; + +void main() +{ + gl_FragColor = u_Color; + gl_FragColor.a *= sqrt(clamp(var_Scale, 0.0, 1.0)); +} diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl new file mode 100644 index 0000000000..f18bc7078c --- /dev/null +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -0,0 +1,117 @@ +attribute vec4 attr_Position; +attribute vec3 attr_Normal; +attribute vec4 attr_TexCoord0; + +//#if defined(USE_VERTEX_ANIMATION) +attribute vec4 attr_Position2; +attribute vec3 attr_Normal2; +//#endif + +uniform vec4 u_FogDistance; +uniform vec4 u_FogDepth; +uniform float u_FogEyeT; + +//#if defined(USE_DEFORM_VERTEXES) +uniform int u_DeformGen; +uniform float u_DeformParams[5]; +//#endif + +uniform float u_Time; +uniform mat4 u_ModelViewProjectionMatrix; + +//#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +//#endif + +varying float var_Scale; + +#if defined(USE_DEFORM_VERTEXES) +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + if (u_DeformGen == 0) + { + return pos; + } + + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + if (u_DeformGen == DGEN_BULGE) + { + phase *= M_PI * 0.25 * st.x; + } + else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) + { + phase += dot(pos.xyz, vec3(spread)); + } + + float value = phase + (u_Time * frequency); + float func; + + if (u_DeformGen == DGEN_WAVE_SIN) + { + func = sin(value * 2.0 * M_PI); + } + else if (u_DeformGen == DGEN_WAVE_SQUARE) + { + func = sign(sin(value * 2.0 * M_PI)); + } + else if (u_DeformGen == DGEN_WAVE_TRIANGLE) + { + func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + } + else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) + { + func = fract(value); + } + else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) + { + func = (1.0 - fract(value)); + } + else if (u_DeformGen == DGEN_BULGE) + { + func = sin(value); + } + + return pos + normal * (base + func * amplitude); +} +#endif + +float CalcFog(vec4 position) +{ + float s = dot(position, u_FogDistance) * 8.0; + float t = dot(position, u_FogDepth); + + if (t < 1.0) + { + t = step(step(0.0, -u_FogEyeT), t); + } + else + { + t /= t - min(u_FogEyeT, 0.0); + } + + return s * t; +} + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); +#else + vec4 position = attr_Position; + vec3 normal = attr_Normal; +#endif + +#if defined(USE_DEFORM_VERTEXES) + position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); +#endif + + gl_Position = u_ModelViewProjectionMatrix * position; + + var_Scale = CalcFog(position); +} diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl new file mode 100644 index 0000000000..dea52e06a4 --- /dev/null +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -0,0 +1,43 @@ +uniform sampler2D u_DiffuseMap; + +#if defined(USE_LIGHTMAP) +uniform sampler2D u_LightMap; + +uniform int u_Texture1Env; +#endif + +varying vec2 var_DiffuseTex; + +#if defined(USE_LIGHTMAP) +varying vec2 var_LightTex; +#endif + +varying vec4 var_Color; + + +void main() +{ + vec4 color = texture2D(u_DiffuseMap, var_DiffuseTex); +#if defined(USE_LIGHTMAP) + vec4 color2 = texture2D(u_LightMap, var_LightTex); + #if defined(RGBE_LIGHTMAP) + color2.rgb *= exp2(color2.a * 255.0 - 128.0); + color2.a = 1.0; + #endif + + if (u_Texture1Env == TEXENV_MODULATE) + { + color *= color2; + } + else if (u_Texture1Env == TEXENV_ADD) + { + color += color2; + } + else if (u_Texture1Env == TEXENV_REPLACE) + { + color = color2; + } +#endif + + gl_FragColor = color * var_Color; +} diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl new file mode 100644 index 0000000000..67360b1bfc --- /dev/null +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -0,0 +1,251 @@ +attribute vec4 attr_Position; +attribute vec3 attr_Normal; + +#if defined(USE_VERTEX_ANIMATION) +attribute vec4 attr_Position2; +attribute vec3 attr_Normal2; +#endif + +attribute vec4 attr_Color; +attribute vec4 attr_TexCoord0; + +#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) +attribute vec4 attr_TexCoord1; +#endif + +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; + +#if defined(USE_TCGEN) || defined(USE_RGBAGEN) +uniform vec3 u_ViewOrigin; +#endif + +#if defined(USE_TCGEN) +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; +#endif + +#if defined(USE_FOG) +uniform vec4 u_FogDistance; +uniform vec4 u_FogDepth; +uniform float u_FogEyeT; +uniform vec4 u_FogColorMask; +#endif + +#if defined(USE_DEFORM_VERTEXES) +uniform int u_DeformGen; +uniform float u_DeformParams[5]; +uniform float u_Time; +#endif + +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; + +#if defined(USE_RGBAGEN) +uniform int u_ColorGen; +uniform int u_AlphaGen; +uniform vec3 u_AmbientLight; +uniform vec3 u_DirectedLight; +uniform vec4 u_LightOrigin; +uniform float u_PortalRange; +#endif + +#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +#endif + +varying vec2 var_DiffuseTex; +#if defined(USE_LIGHTMAP) +varying vec2 var_LightTex; +#endif +varying vec4 var_Color; + +#if defined(USE_DEFORM_VERTEXES) +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + if (u_DeformGen == DGEN_BULGE) + { + phase *= M_PI * 0.25 * st.x; + } + else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) + { + phase += dot(pos.xyz, vec3(spread)); + } + + float value = phase + (u_Time * frequency); + float func; + + if (u_DeformGen == DGEN_WAVE_SIN) + { + func = sin(value * 2.0 * M_PI); + } + else if (u_DeformGen == DGEN_WAVE_SQUARE) + { + func = sign(sin(value * 2.0 * M_PI)); + } + else if (u_DeformGen == DGEN_WAVE_TRIANGLE) + { + func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + } + else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) + { + func = fract(value); + } + else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) + { + func = (1.0 - fract(value)); + } + else if (u_DeformGen == DGEN_BULGE) + { + func = sin(value); + } + + return pos + normal * (base + func * amplitude); +} +#endif + +#if defined(USE_TCGEN) +vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) +{ + vec2 tex = attr_TexCoord0.st; + + if (TCGen == TCGEN_LIGHTMAP) + { + tex = attr_TexCoord1.st; + } + else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) + { + vec3 viewer = normalize(u_ViewOrigin - position); + tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; + } + else if (TCGen == TCGEN_VECTOR) + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + + return tex; +} +#endif + +#if defined(USE_TCMOD) +vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) +{ + float amplitude = offTurb.z; + float phase = offTurb.w; + vec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy; + + vec3 offsetPos = position / 1024.0; + offsetPos.x += offsetPos.z; + + vec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI); + + return st2 + texOffset * amplitude; +} +#endif + +#if defined(USE_RGBAGEN) +vec4 CalcColor(vec3 position, vec3 normal) +{ + vec4 color = u_VertColor * attr_Color + u_BaseColor; + + if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) + { + float incoming = clamp(dot(normal, u_LightOrigin.xyz), 0.0, 1.0); + + color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); + } + + vec3 toView = u_ViewOrigin - position; + vec3 viewer = normalize(u_ViewOrigin - position); + + if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) + { + vec3 lightDir = normalize(vec3(-960.0, -1980.0, 96.0) - position.xyz); + vec3 halfangle = normalize(lightDir + viewer); + + color.a = pow(max(dot(normal, halfangle), 0.0), 8.0); + } + else if (u_AlphaGen == AGEN_PORTAL) + { + float alpha = length(toView) / u_PortalRange; + + color.a = clamp(alpha, 0.0, 1.0); + } + else if (u_AlphaGen == AGEN_FRESNEL) + { + color.a = 0.10 + 0.90 * pow(1.0 - dot(normal, viewer), 5); + } + + return color; +} +#endif + +#if defined(USE_FOG) +float CalcFog(vec4 position) +{ + float s = dot(position, u_FogDistance) * 8.0; + float t = dot(position, u_FogDepth); + + if (t < 1.0) + { + t = step(step(0.0, -u_FogEyeT), t); + } + else + { + t /= t - min(u_FogEyeT, 0.0); + } + + return s * t; +} +#endif + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); +#else + vec4 position = attr_Position; + vec3 normal = attr_Normal; +#endif + +#if defined(USE_DEFORM_VERTEXES) + position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); +#endif + + gl_Position = u_ModelViewProjectionMatrix * position; + +#if defined(USE_TCGEN) + vec2 tex = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); +#else + vec2 tex = attr_TexCoord0.st; +#endif + +#if defined(USE_TCMOD) + var_DiffuseTex = ModTexCoords(tex, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); +#else + var_DiffuseTex = tex; +#endif + +#if defined(USE_LIGHTMAP) + var_LightTex = attr_TexCoord1.st; +#endif + +#if defined(USE_RGBAGEN) + var_Color = CalcColor(position.xyz, normal); +#else + var_Color = u_VertColor * attr_Color + u_BaseColor; +#endif + +#if defined(USE_FOG) + var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0)); +#endif +} diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl new file mode 100644 index 0000000000..0b455dd66f --- /dev/null +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -0,0 +1,429 @@ +uniform sampler2D u_DiffuseMap; + +#if defined(USE_LIGHTMAP) +uniform sampler2D u_LightMap; +#endif + +#if defined(USE_NORMALMAP) +uniform sampler2D u_NormalMap; +#endif + +#if defined(USE_DELUXEMAP) +uniform sampler2D u_DeluxeMap; +#endif + +#if defined(USE_SPECULARMAP) +uniform sampler2D u_SpecularMap; +#endif + +#if defined(USE_SHADOWMAP) +uniform sampler2D u_ShadowMap; +#endif + +uniform vec3 u_ViewOrigin; + +#if defined(USE_TCGEN) +uniform int u_TCGen0; +#endif + +#if defined(USE_LIGHT_VECTOR) +uniform vec4 u_LightOrigin; +uniform vec3 u_DirectedLight; +uniform vec3 u_AmbientLight; +uniform float u_LightRadius; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +uniform vec3 u_PrimaryLightColor; +uniform vec3 u_PrimaryLightAmbient; +uniform float u_PrimaryLightRadius; +#endif + + +#if defined(USE_LIGHT) +uniform vec2 u_MaterialInfo; +#endif + +varying vec2 var_DiffuseTex; +#if defined(USE_LIGHTMAP) +varying vec2 var_LightTex; +#endif +varying vec4 var_Color; + +#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) +varying vec3 var_Position; +#endif + +#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) +varying vec3 var_SampleToView; +#endif + +#if !defined(USE_FAST_LIGHT) +varying vec3 var_Normal; +#endif + +#if defined(USE_VERT_TANGENT_SPACE) +varying vec3 var_Tangent; +varying vec3 var_Bitangent; +#endif + +varying vec3 var_VertLight; + +#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) +varying vec3 var_LightDirection; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +varying vec3 var_PrimaryLightDirection; +#endif + + +#define EPSILON 0.00000001 + +#if defined(USE_PARALLAXMAP) +float SampleHeight(sampler2D normalMap, vec2 t) +{ + #if defined(SWIZZLE_NORMALMAP) + return texture2D(normalMap, t).r; + #else + return texture2D(normalMap, t).a; + #endif +} + +float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) +{ + const int linearSearchSteps = 16; + const int binarySearchSteps = 6; + + float depthStep = 1.0 / float(linearSearchSteps); + + // current size of search window + float size = depthStep; + + // current depth position + float depth = 0.0; + + // best match found (starts with last position 1.0) + float bestDepth = 1.0; + + // search front to back for first point inside object + for(int i = 0; i < linearSearchSteps - 1; ++i) + { + depth += size; + + float t = 1.0 - SampleHeight(normalMap, dp + ds * depth); + + if(bestDepth > 0.996) // if no depth found yet + if(depth >= t) + bestDepth = depth; // store best depth + } + + depth = bestDepth; + + // recurse around first point (depth) for closest match + for(int i = 0; i < binarySearchSteps; ++i) + { + size *= 0.5; + + float t = 1.0 - SampleHeight(normalMap, dp + ds * depth); + + if(depth >= t) + { + bestDepth = depth; + depth -= 2.0 * size; + } + + depth += size; + } + + return bestDepth; +} +#endif + +vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, float shininess) +{ + #if defined(USE_OREN_NAYAR) || defined(USE_TRIACE_OREN_NAYAR) + float gamma = dot(E, L) - NE * NL; + float B = 2.22222 + 0.1 * shininess; + + #if defined(USE_OREN_NAYAR) + float A = 1.0 - 1.0 / (2.0 + 0.33 * shininess); + gamma = clamp(gamma, 0.0, 1.0); + #endif + + #if defined(USE_TRIACE_OREN_NAYAR) + float A = 1.0 - 1.0 / (2.0 + 0.65 * shininess); + + if (gamma >= 0.0) + #endif + { + B *= max(max(NL, NE), EPSILON); + } + + return diffuseAlbedo * (A + gamma / B); + #else + return diffuseAlbedo; + #endif +} + +#if defined(USE_SPECULARMAP) +vec3 CalcSpecular(vec3 specularReflectance, float NH, float NL, float NE, float EH, float shininess) +{ + #if defined(USE_BLINN) || defined(USE_TRIACE) || defined(USE_TORRANCE_SPARROW) + float blinn = pow(NH, shininess); + #endif + + #if defined(USE_BLINN) + return specularReflectance * blinn; + #endif + + #if defined(USE_COOK_TORRANCE) || defined (USE_TRIACE) || defined (USE_TORRANCE_SPARROW) + vec3 fresnel = specularReflectance + (vec3(1.0) - specularReflectance) * pow(1.0 - EH, 5); + #endif + + #if defined(USE_COOK_TORRANCE) || defined(USE_TORRANCE_SPARROW) + float geo = 2.0 * NH * min(NE, NL); + geo /= max(EH, geo); + #endif + + #if defined(USE_COOK_TORRANCE) + float m_sq = 2.0 / max(shininess, EPSILON); + float NH_sq = NH * NH; + float m_NH_sq = m_sq * NH_sq; + float beckmann = exp((NH_sq - 1.0) / max(m_NH_sq, EPSILON)) / max(4.0 * m_NH_sq * NH_sq, EPSILON); + + return fresnel * geo * beckmann / max(NE, EPSILON); + #endif + + #if defined(USE_TRIACE) + float scale = 0.1248582 * shininess + 0.2691817; + + return fresnel * scale * blinn / max(max(NL, NE), EPSILON); + #endif + + #if defined(USE_TORRANCE_SPARROW) + float scale = 0.125 * shininess + 1.0; + + return fresnel * geo * scale * blinn / max(NE, EPSILON); + #endif +} +#endif + +void main() +{ +#if !defined(USE_FAST_LIGHT) && (defined(USE_LIGHT) || defined(USE_NORMALMAP)) + vec3 surfN = normalize(var_Normal); +#endif + +#if defined(USE_DELUXEMAP) + vec3 L = 2.0 * texture2D(u_DeluxeMap, var_LightTex).xyz - vec3(1.0); + //L += var_LightDirection * 0.0001; +#elif defined(USE_LIGHT) + vec3 L = var_LightDirection; +#endif + +#if defined(USE_LIGHTMAP) + vec4 lightSample = texture2D(u_LightMap, var_LightTex).rgba; + #if defined(RGBE_LIGHTMAP) + lightSample.rgb *= exp2(lightSample.a * 255.0 - 128.0); + #endif + vec3 lightColor = lightSample.rgb; +#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) + #if defined(USE_INVSQRLIGHT) + float intensity = 1.0 / dot(L, L); + #else + float intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0); + #endif + + vec3 lightColor = u_DirectedLight * intensity; + vec3 ambientColor = u_AmbientLight; +#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) + vec3 lightColor = var_VertLight; +#endif + +#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) + vec3 E = normalize(var_SampleToView); +#endif + vec2 texCoords = var_DiffuseTex; + + float ambientDiff = 1.0; + +#if defined(USE_NORMALMAP) + #if defined(USE_VERT_TANGENT_SPACE) + mat3 tangentToWorld = mat3(var_Tangent, var_Bitangent, var_Normal); + #else + vec3 q0 = dFdx(var_Position); + vec3 q1 = dFdy(var_Position); + vec2 st0 = dFdx(texCoords); + vec2 st1 = dFdy(texCoords); + float dir = sign(st1.t * st0.s - st0.t * st1.s); + + vec3 tangent = normalize(q0 * st1.t - q1 * st0.t) * dir; + vec3 bitangent = -normalize(q0 * st1.s - q1 * st0.s) * dir; + + mat3 tangentToWorld = mat3(tangent, bitangent, var_Normal); + #endif + + #if defined(USE_PARALLAXMAP) + vec3 offsetDir = normalize(E * tangentToWorld); + offsetDir.xy *= -0.05 / offsetDir.z; + + texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); + #endif + vec3 texN; + #if defined(SWIZZLE_NORMALMAP) + texN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - 1.0; + #else + texN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - 1.0; + #endif + texN.z = sqrt(clamp(1.0 - dot(texN.xy, texN.xy), 0.0, 1.0)); + vec3 N = tangentToWorld * texN; + #if defined(r_normalAmbient) + ambientDiff = 0.781341 * texN.z + 0.218659; + #endif +#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 N = surfN; +#endif + +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || (defined(USE_TCGEN) && defined(USE_NORMALMAP)) + N = normalize(N); +#endif + +#if defined(USE_TCGEN) && defined(USE_NORMALMAP) + if (u_TCGen0 == TCGEN_ENVIRONMENT_MAPPED) + { + texCoords = -reflect(E, N).yz * vec2(0.5, -0.5) + 0.5; + } +#endif + + vec4 diffuseAlbedo = texture2D(u_DiffuseMap, texCoords); +#if defined(USE_LIGHT) && defined(USE_GAMMA2_TEXTURES) + diffuseAlbedo.rgb *= diffuseAlbedo.rgb; +#endif + +#if defined(USE_LIGHT) && defined(USE_FAST_LIGHT) + gl_FragColor = diffuse.rgb; + #if defined(USE_LIGHTMAP) + gl_FragColor *= lightColor; + #endif +#elif defined(USE_LIGHT) + L = normalize(L); + + float surfNL = clamp(dot(surfN, L), 0.0, 1.0); + + #if defined(USE_SHADOWMAP) + vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; + float shadowValue = texture2D(u_ShadowMap, shadowTex).r; + + // surfaces not facing the light are always shadowed + shadowValue *= step(0.0, dot(surfN, var_PrimaryLightDirection)); + + #if defined(SHADOWMAP_MODULATE) + //vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor); + vec3 shadowColor = u_PrimaryLightAmbient * lightColor; + + #if 0 + // Only shadow when the world light is parallel to the primary light + shadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDirection), 0.0, 1.0); + #endif + lightColor = mix(shadowColor, lightColor, shadowValue); + #endif + #endif + + #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) + #if defined(USE_STANDARD_DELUXEMAP) + // Standard deluxe mapping treats the light sample as fully directed + // and doesn't compensate for light angle attenuation. + vec3 ambientColor = vec3(0.0); + #else + // Separate the light sample into directed and ambient parts. + // + // ambientMax - if the cosine of the angle between the surface + // normal and the light is below this value, the light + // is fully ambient. + // directedMax - if the cosine of the angle between the surface + // normal and the light is above this value, the light + // is fully directed. + const float ambientMax = 0.25; + const float directedMax = 0.5; + + float directedScale = clamp((surfNL - ambientMax) / (directedMax - ambientMax), 0.0, 1.0); + + // Scale the directed portion to compensate for the baked-in + // light angle attenuation. + directedScale /= max(surfNL, ambientMax); + + #if defined(r_normalAmbient) + directedScale *= 1.0 - r_normalAmbient; + #endif + + // Recover any unused light as ambient + vec3 ambientColor = lightColor; + lightColor *= directedScale; + ambientColor -= lightColor * surfNL; + #endif + #endif + + float NL = clamp(dot(N, L), 0.0, 1.0); + float NE = clamp(dot(N, E), 0.0, 1.0); + + float maxReflectance = u_MaterialInfo.x; + float shininess = u_MaterialInfo.y; + + #if defined(USE_SPECULARMAP) + vec4 specularReflectance = texture2D(u_SpecularMap, texCoords); + specularReflectance.rgb *= maxReflectance; + shininess *= specularReflectance.a; + // adjust diffuse by specular reflectance, to maintain energy conservation + diffuseAlbedo.rgb *= vec3(1.0) - specularReflectance.rgb; + #endif + + gl_FragColor.rgb = lightColor * NL * CalcDiffuse(diffuseAlbedo.rgb, N, L, E, NE, NL, shininess); + gl_FragColor.rgb += ambientDiff * ambientColor * diffuseAlbedo.rgb; + #if defined(USE_PRIMARY_LIGHT) + vec3 L2 = var_PrimaryLightDirection; + float NL2 = clamp(dot(N, L2), 0.0, 1.0); + + #if defined(USE_SHADOWMAP) + gl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess); + #else + gl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess); + #endif + #endif + + #if defined(USE_SPECULARMAP) + vec3 H = normalize(L + E); + + float EH = clamp(dot(E, H), 0.0, 1.0); + float NH = clamp(dot(N, H), 0.0, 1.0); + + gl_FragColor.rgb += lightColor * NL * CalcSpecular(specularReflectance.rgb, NH, NL, NE, EH, shininess); + + #if defined(r_normalAmbient) + vec3 ambientHalf = normalize(surfN + E); + float ambientSpec = max(dot(ambientHalf, N) + 0.5, 0.0); + ambientSpec *= ambientSpec * 0.44; + gl_FragColor.rgb += specularReflectance.rgb * ambientSpec * ambientColor; + #endif + + #if defined(USE_PRIMARY_LIGHT) + vec3 H2 = normalize(L2 + E); + float EH2 = clamp(dot(E, H2), 0.0, 1.0); + float NH2 = clamp(dot(N, H2), 0.0, 1.0); + + + #if defined(USE_SHADOWMAP) + gl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess); + #else + gl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess); + #endif + #endif + #endif +#else + gl_FragColor.rgb = diffuseAlbedo.rgb; +#endif + + gl_FragColor.a = diffuseAlbedo.a; + + gl_FragColor *= var_Color; +} diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl new file mode 100644 index 0000000000..03775caf42 --- /dev/null +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -0,0 +1,245 @@ +attribute vec4 attr_TexCoord0; +#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) +attribute vec4 attr_TexCoord1; +#endif +attribute vec4 attr_Color; + +attribute vec4 attr_Position; +attribute vec3 attr_Normal; + +#if defined(USE_VERT_TANGENT_SPACE) +attribute vec3 attr_Tangent; +attribute vec3 attr_Bitangent; +#endif + +#if defined(USE_VERTEX_ANIMATION) +attribute vec4 attr_Position2; +attribute vec3 attr_Normal2; + #if defined(USE_VERT_TANGENT_SPACE) +attribute vec3 attr_Tangent2; +attribute vec3 attr_Bitangent2; + #endif +#endif + +#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) +attribute vec3 attr_LightDirection; +#endif + +#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +uniform vec3 u_ViewOrigin; +#endif + +#if defined(USE_TCGEN) +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; +#endif + +#if defined(USE_TCMOD) +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; +#endif + +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; + +#if defined(USE_MODELMATRIX) +uniform mat4 u_ModelMatrix; +#endif + +#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +#endif + +#if defined(USE_LIGHT_VECTOR) +uniform vec4 u_LightOrigin; + #if defined(USE_FAST_LIGHT) +uniform vec3 u_DirectedLight; +uniform vec3 u_AmbientLight; +uniform float u_LightRadius; + #endif +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +uniform vec4 u_PrimaryLightOrigin; +#endif + +varying vec2 var_DiffuseTex; + +#if defined(USE_LIGHTMAP) +varying vec2 var_LightTex; +#endif + +#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) +varying vec3 var_SampleToView; +#endif + +varying vec4 var_Color; + +#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) +varying vec3 var_Position; +#endif + + +#if !defined(USE_FAST_LIGHT) +varying vec3 var_Normal; + #if defined(USE_VERT_TANGENT_SPACE) +varying vec3 var_Tangent; +varying vec3 var_Bitangent; + #endif +#endif + +#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) +varying vec3 var_VertLight; +#endif + +#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) +varying vec3 var_LightDirection; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +varying vec3 var_PrimaryLightDirection; +#endif + +#if defined(USE_TCGEN) +vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) +{ + vec2 tex = attr_TexCoord0.st; + + if (TCGen == TCGEN_LIGHTMAP) + { + tex = attr_TexCoord1.st; + } + else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) + { + vec3 viewer = normalize(u_ViewOrigin - position); + tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; + } + else if (TCGen == TCGEN_VECTOR) + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + + return tex; +} +#endif + +#if defined(USE_TCMOD) +vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) +{ + float amplitude = offTurb.z; + float phase = offTurb.w; + vec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy; + + vec3 offsetPos = vec3(0); //position / 1024.0; + offsetPos.x += offsetPos.z; + + vec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI); + + return st2 + texOffset * amplitude; +} +#endif + + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); + #if defined(USE_VERT_TANGENT_SPACE) + vec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp)); + vec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp)); + #endif +#else + vec4 position = attr_Position; + vec3 normal = attr_Normal; + #if defined(USE_VERT_TANGENT_SPACE) + vec3 tangent = attr_Tangent; + vec3 bitangent = attr_Bitangent; + #endif +#endif + + gl_Position = u_ModelViewProjectionMatrix * position; + +#if (defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) + vec3 L = attr_LightDirection; +#endif + +#if defined(USE_MODELMATRIX) + position = u_ModelMatrix * position; + normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; + #if defined(USE_VERT_TANGENT_SPACE) + tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; + bitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz; + #endif + + #if defined(USE_LIGHTMAP) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) + L = (u_ModelMatrix * vec4(L, 0.0)).xyz; + #endif +#endif + +#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) + var_Position = position.xyz; +#endif + +#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) + var_SampleToView = u_ViewOrigin - position.xyz; +#endif + +#if defined(USE_TCGEN) + vec2 texCoords = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); +#else + vec2 texCoords = attr_TexCoord0.st; +#endif + +#if defined(USE_TCMOD) + var_DiffuseTex = ModTexCoords(texCoords, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); +#else + var_DiffuseTex = texCoords; +#endif + +#if defined(USE_LIGHTMAP) + var_LightTex = attr_TexCoord1.st; +#endif + +#if !defined(USE_FAST_LIGHT) + var_Normal = normal; + #if defined(USE_VERT_TANGENT_SPACE) + var_Tangent = tangent; + var_Bitangent = bitangent; + #endif +#endif + +#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) + #if defined(USE_LIGHT_VECTOR) + vec3 L = u_LightOrigin.xyz - (position.xyz * u_LightOrigin.w); + #endif + #if !defined(USE_FAST_LIGHT) + var_LightDirection = L; + #endif +#endif + +#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) + var_VertLight = u_VertColor.rgb * attr_Color.rgb; + var_Color.rgb = vec3(1.0); + var_Color.a = u_VertColor.a * attr_Color.a + u_BaseColor.a; +#else + var_Color = u_VertColor * attr_Color + u_BaseColor; +#endif + +#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) + #if defined(USE_INVSQRLIGHT) + float intensity = 1.0 / dot(L, L); + #else + float intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0); + #endif + float NL = clamp(dot(normal, normalize(L)), 0.0, 1.0); + + var_Color.rgb *= u_DirectedLight * intensity * NL + u_AmbientLight; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) + var_PrimaryLightDirection = u_PrimaryLightOrigin.xyz - (position.xyz * u_PrimaryLightOrigin.w); +#endif +} diff --git a/codemp/rd-rend2/glsl/pshadow_fp.glsl b/codemp/rd-rend2/glsl/pshadow_fp.glsl new file mode 100644 index 0000000000..b152971af6 --- /dev/null +++ b/codemp/rd-rend2/glsl/pshadow_fp.glsl @@ -0,0 +1,98 @@ +uniform sampler2D u_ShadowMap; + +uniform vec3 u_LightForward; +uniform vec3 u_LightUp; +uniform vec3 u_LightRight; +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; +varying vec3 var_Position; +varying vec3 var_Normal; + +float sampleDistMap(sampler2D texMap, vec2 uv, float scale) +{ + vec3 distv = texture2D(texMap, uv).xyz; + return dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0)) * scale; +} + +void main() +{ + vec3 lightToPos = var_Position - u_LightOrigin.xyz; + vec2 st = vec2(-dot(u_LightRight, lightToPos), dot(u_LightUp, lightToPos)); + + float fade = length(st); + +#if defined(USE_DISCARD) + if (fade >= 1.0) + { + discard; + } +#endif + + fade = clamp(8.0 - fade * 8.0, 0.0, 1.0); + + st = st * 0.5 + vec2(0.5); + +#if defined(USE_SOLID_PSHADOWS) + float intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0); +#else + float intensity = clamp((1.0 - dot(lightToPos, lightToPos) / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0); +#endif + + float lightDist = length(lightToPos); + float dist; + +#if defined(USE_DISCARD) + if (dot(u_LightForward, lightToPos) <= 0.0) + { + discard; + } + + if (dot(var_Normal, lightToPos) > 0.0) + { + discard; + } +#else + intensity *= max(sign(dot(u_LightForward, lightToPos)), 0.0); + intensity *= max(sign(-dot(var_Normal, lightToPos)), 0.0); +#endif + + intensity *= fade; +#if defined(USE_PCF) + float part; + + dist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, -1.0/512.0), u_LightRadius); + part = max(sign(lightDist - dist), 0.0); + + dist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, -1.0/512.0), u_LightRadius); + part += max(sign(lightDist - dist), 0.0); + + dist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, 1.0/512.0), u_LightRadius); + part += max(sign(lightDist - dist), 0.0); + + dist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, 1.0/512.0), u_LightRadius); + part += max(sign(lightDist - dist), 0.0); + + #if defined(USE_DISCARD) + if (part <= 0.0) + { + discard; + } + #endif + + intensity *= part * 0.25; +#else + dist = sampleDistMap(u_ShadowMap, st, u_LightRadius); + + #if defined(USE_DISCARD) + if (lightDist - dist <= 0.0) + { + discard; + } + #endif + + intensity *= max(sign(lightDist - dist), 0.0); +#endif + + gl_FragColor.rgb = vec3(0); + gl_FragColor.a = clamp(intensity, 0.0, 0.75); +} diff --git a/codemp/rd-rend2/glsl/pshadow_vp.glsl b/codemp/rd-rend2/glsl/pshadow_vp.glsl new file mode 100644 index 0000000000..0e0e3b3d3d --- /dev/null +++ b/codemp/rd-rend2/glsl/pshadow_vp.glsl @@ -0,0 +1,17 @@ +attribute vec4 attr_Position; +attribute vec3 attr_Normal; + +uniform mat4 u_ModelViewProjectionMatrix; +varying vec3 var_Position; +varying vec3 var_Normal; + + +void main() +{ + vec4 position = attr_Position; + + gl_Position = u_ModelViewProjectionMatrix * position; + + var_Position = position.xyz; + var_Normal = attr_Normal; +} diff --git a/codemp/rd-rend2/glsl/shadowfill_fp.glsl b/codemp/rd-rend2/glsl/shadowfill_fp.glsl new file mode 100644 index 0000000000..150f3d1229 --- /dev/null +++ b/codemp/rd-rend2/glsl/shadowfill_fp.glsl @@ -0,0 +1,41 @@ +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; + +varying vec3 var_Position; + +void main() +{ +#if defined(USE_DEPTH) + float depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius; + #if 0 + // 32 bit precision + const vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1); + const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + + vec4 comp; + comp = depth * bitSh; + comp.xyz = fract(comp.xyz); + comp -= comp.xxyz * bitMsk; + gl_FragColor = comp; + #endif + + #if 1 + // 24 bit precision + const vec3 bitSh = vec3( 256 * 256, 256, 1); + const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); + + vec3 comp; + comp = depth * bitSh; + comp.xy = fract(comp.xy); + comp -= comp.xxy * bitMsk; + gl_FragColor = vec4(comp, 1.0); + #endif + + #if 0 + // 8 bit precision + gl_FragColor = vec4(depth, depth, depth, 1); + #endif +#else + gl_FragColor = vec4(0, 0, 0, 1); +#endif +} diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl new file mode 100644 index 0000000000..10802ecaf7 --- /dev/null +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -0,0 +1,89 @@ +attribute vec4 attr_Position; +attribute vec3 attr_Normal; +attribute vec4 attr_TexCoord0; + +//#if defined(USE_VERTEX_ANIMATION) +attribute vec4 attr_Position2; +attribute vec3 attr_Normal2; +//#endif + +//#if defined(USE_DEFORM_VERTEXES) +uniform int u_DeformGen; +uniform float u_DeformParams[5]; +//#endif + +uniform float u_Time; +uniform mat4 u_ModelViewProjectionMatrix; + +uniform mat4 u_ModelMatrix; + +//#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +//#endif + +varying vec3 var_Position; + +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + if (u_DeformGen == 0) + { + return pos; + } + + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + if (u_DeformGen == DGEN_BULGE) + { + phase *= M_PI * 0.25 * st.x; + } + else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) + { + phase += dot(pos.xyz, vec3(spread)); + } + + float value = phase + (u_Time * frequency); + float func; + + if (u_DeformGen == DGEN_WAVE_SIN) + { + func = sin(value * 2.0 * M_PI); + } + else if (u_DeformGen == DGEN_WAVE_SQUARE) + { + func = sign(sin(value * 2.0 * M_PI)); + } + else if (u_DeformGen == DGEN_WAVE_TRIANGLE) + { + func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + } + else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) + { + func = fract(value); + } + else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) + { + func = (1.0 - fract(value)); + } + else if (u_DeformGen == DGEN_BULGE) + { + func = sin(value); + } + + return pos + normal * (base + func * amplitude); +} + +void main() +{ + vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); + + position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); + + gl_Position = u_ModelViewProjectionMatrix * position; + + var_Position = (u_ModelMatrix * position).xyz; +} diff --git a/codemp/rd-rend2/glsl/shadowmask_fp.glsl b/codemp/rd-rend2/glsl/shadowmask_fp.glsl new file mode 100644 index 0000000000..4bac5ccdd8 --- /dev/null +++ b/codemp/rd-rend2/glsl/shadowmask_fp.glsl @@ -0,0 +1,127 @@ +uniform sampler2D u_ScreenDepthMap; + +uniform sampler2D u_ShadowMap; +#if defined(USE_SHADOW_CASCADE) +uniform sampler2D u_ShadowMap2; +uniform sampler2D u_ShadowMap3; +#endif + +uniform mat4 u_ShadowMvp; +#if defined(USE_SHADOW_CASCADE) +uniform mat4 u_ShadowMvp2; +uniform mat4 u_ShadowMvp3; +#endif + +uniform vec3 u_ViewOrigin; +uniform vec4 u_ViewInfo; // zfar / znear, zfar + +varying vec2 var_DepthTex; +varying vec3 var_ViewDir; + +// Input: It uses texture coords as the random number seed. +// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. +// Author: Michael Pohoreski +// Copyright: Copyleft 2012 :-) +// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader + +float random( const vec2 p ) +{ + // We need irrationals for pseudo randomness. + // Most (all?) known transcendental numbers will (generally) work. + const vec2 r = vec2( + 23.1406926327792690, // e^pi (Gelfond's constant) + 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) + //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); +} + +float PCF(const sampler2D shadowmap, const vec2 st, const float dist) +{ + float mult; + float scale = 2.0 / r_shadowMapSize; + +#if defined(USE_SHADOW_FILTER) + float r = random(var_DepthTex.xy); + float sinr = sin(r) * scale; + float cosr = cos(r) * scale; + mat2 rmat = mat2(cosr, sinr, -sinr, cosr); + + mult = step(dist, texture2D(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r); + #if defined(USE_SHADOW_FILTER2) + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r); + mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r); + + mult *= 0.11111; + #else + mult *= 0.33333; + #endif +#else + mult = step(dist, texture2D(shadowmap, st).r); +#endif + + return mult; +} + +float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear) +{ + float sampleZDivW = texture2D(depthMap, tex).r; + return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); +} + +void main() +{ + float result; + + float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x); + float sampleZ = u_ViewInfo.y * depth; + + vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * depth * 0.99, 1.0); + + vec4 shadowpos = u_ShadowMvp * biasPos; + +#if defined(USE_SHADOW_CASCADE) + const float fadeTo = 1.0; + result = fadeTo; +#else + result = 0.0; +#endif + + if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + { + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z); + } +#if defined(USE_SHADOW_CASCADE) + else + { + shadowpos = u_ShadowMvp2 * biasPos; + + if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + { + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z); + } + else + { + shadowpos = u_ShadowMvp3 * biasPos; + + if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + { + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z); + + float fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0); + result = mix(result, fadeTo, fade); + } + } + } +#endif + + gl_FragColor = vec4(vec3(result), 1.0); +} diff --git a/codemp/rd-rend2/glsl/shadowmask_vp.glsl b/codemp/rd-rend2/glsl/shadowmask_vp.glsl new file mode 100644 index 0000000000..13166a2400 --- /dev/null +++ b/codemp/rd-rend2/glsl/shadowmask_vp.glsl @@ -0,0 +1,18 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform vec3 u_ViewForward; +uniform vec3 u_ViewLeft; +uniform vec3 u_ViewUp; +uniform vec4 u_ViewInfo; // zfar / znear + +varying vec2 var_DepthTex; +varying vec3 var_ViewDir; + +void main() +{ + gl_Position = attr_Position; + vec2 screenCoords = gl_Position.xy / gl_Position.w; + var_DepthTex = attr_TexCoord0.xy; + var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; +} diff --git a/codemp/rd-rend2/glsl/ssao_fp.glsl b/codemp/rd-rend2/glsl/ssao_fp.glsl new file mode 100644 index 0000000000..6263284c56 --- /dev/null +++ b/codemp/rd-rend2/glsl/ssao_fp.glsl @@ -0,0 +1,86 @@ +uniform sampler2D u_ScreenDepthMap; + +uniform vec4 u_ViewInfo; // zfar / znear, zfar + +varying vec2 var_ScreenTex; + +vec2 poissonDisc[9] = vec2[9]( +vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386), +vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417), +vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181), +vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854), +vec2(0.7320465, 0.6317794) +); + +// Input: It uses texture coords as the random number seed. +// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. +// Author: Michael Pohoreski +// Copyright: Copyleft 2012 :-) +// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader + +float random( const vec2 p ) +{ + // We need irrationals for pseudo randomness. + // Most (all?) known transcendental numbers will (generally) work. + const vec2 r = vec2( + 23.1406926327792690, // e^pi (Gelfond's constant) + 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) + //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); +} + +mat2 randomRotation( const vec2 p ) +{ + float r = random(p); + float sinr = sin(r); + float cosr = cos(r); + return mat2(cosr, sinr, -sinr, cosr); +} + +float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) +{ + float sampleZDivW = texture2D(depthMap, tex).r; + return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); +} + +float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar) +{ + float result = 0; + + float sampleZ = zFar * getLinearDepth(depthMap, tex, zFarDivZNear); + + vec2 expectedSlope = vec2(dFdx(sampleZ), dFdy(sampleZ)) / vec2(dFdx(tex.x), dFdy(tex.y)); + + if (length(expectedSlope) > 5000.0) + return 1.0; + + vec2 offsetScale = vec2(3.0 / sampleZ); + + mat2 rmat = randomRotation(tex); + + int i; + for (i = 0; i < 3; i++) + { + vec2 offset = rmat * poissonDisc[i] * offsetScale; + float sampleZ2 = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear); + + if (abs(sampleZ - sampleZ2) > 20.0) + result += 1.0; + else + { + float expectedZ = sampleZ + dot(expectedSlope, offset); + result += step(expectedZ - 1.0, sampleZ2); + } + } + + result *= 0.33333; + + return result; +} + +void main() +{ + float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); + + gl_FragColor = vec4(vec3(result), 1.0); +} diff --git a/codemp/rd-rend2/glsl/ssao_vp.glsl b/codemp/rd-rend2/glsl/ssao_vp.glsl new file mode 100644 index 0000000000..9c46a79f26 --- /dev/null +++ b/codemp/rd-rend2/glsl/ssao_vp.glsl @@ -0,0 +1,12 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +varying vec2 var_ScreenTex; + +void main() +{ + gl_Position = attr_Position; + var_ScreenTex = attr_TexCoord0.xy; + //vec2 screenCoords = gl_Position.xy / gl_Position.w; + //var_ScreenTex = screenCoords * 0.5 + 0.5; +} diff --git a/codemp/rd-rend2/glsl/texturecolor_fp.glsl b/codemp/rd-rend2/glsl/texturecolor_fp.glsl new file mode 100644 index 0000000000..5646b511c7 --- /dev/null +++ b/codemp/rd-rend2/glsl/texturecolor_fp.glsl @@ -0,0 +1,12 @@ +#version 120 + +uniform sampler2D u_DiffuseMap; +uniform vec4 u_Color; + +varying vec2 var_Tex1; + + +void main() +{ + gl_FragColor = texture2D(u_DiffuseMap, var_Tex1) * u_Color; +} diff --git a/codemp/rd-rend2/glsl/texturecolor_vp.glsl b/codemp/rd-rend2/glsl/texturecolor_vp.glsl new file mode 100644 index 0000000000..ae26a18e84 --- /dev/null +++ b/codemp/rd-rend2/glsl/texturecolor_vp.glsl @@ -0,0 +1,15 @@ +#version 120 + +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_Tex1; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * attr_Position; + var_Tex1 = attr_TexCoord0.st; +} diff --git a/codemp/rd-rend2/glsl/tonemap_fp.glsl b/codemp/rd-rend2/glsl/tonemap_fp.glsl new file mode 100644 index 0000000000..9b18de8a1c --- /dev/null +++ b/codemp/rd-rend2/glsl/tonemap_fp.glsl @@ -0,0 +1,48 @@ +uniform sampler2D u_TextureMap; +uniform sampler2D u_LevelsMap; + +uniform vec4 u_Color; + +uniform vec2 u_AutoExposureMinMax; +uniform vec3 u_ToneMinAvgMaxLinear; + +varying vec2 var_TexCoords; + +const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); + +vec3 FilmicTonemap(vec3 x) +{ + const float SS = 0.22; // Shoulder Strength + const float LS = 0.30; // Linear Strength + const float LA = 0.10; // Linear Angle + const float TS = 0.20; // Toe Strength + const float TAN = 0.01; // Toe Angle Numerator + const float TAD = 0.30; // Toe Angle Denominator + + vec3 SSxx = SS * x * x; + vec3 LSx = LS * x; + vec3 LALSx = LSx * LA; + + return ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD; + + //return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD; + +} + +void main() +{ + vec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color; + vec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb; + vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); + + float avgLum = exp2(logMinAvgMaxLum.y); + //float maxLum = exp2(logMinAvgMaxLum.z); + + color.rgb *= u_ToneMinAvgMaxLinear.y / avgLum; + color.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x)); + + vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x)); + color.rgb = FilmicTonemap(color.rgb) * fWhite; + + gl_FragColor = clamp(color, 0.0, 1.0); +} diff --git a/codemp/rd-rend2/glsl/tonemap_vp.glsl b/codemp/rd-rend2/glsl/tonemap_vp.glsl new file mode 100644 index 0000000000..5ca4160080 --- /dev/null +++ b/codemp/rd-rend2/glsl/tonemap_vp.glsl @@ -0,0 +1,13 @@ +attribute vec4 attr_Position; +attribute vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +varying vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * attr_Position; + var_TexCoords = attr_TexCoord0.st; +} diff --git a/codemp/rd-rend2/tr_animation.c b/codemp/rd-rend2/tr_animation.c new file mode 100644 index 0000000000..c4c9debb32 --- /dev/null +++ b/codemp/rd-rend2/tr_animation.c @@ -0,0 +1,656 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "tr_local.h" + +/* + +All bones should be an identity orientation to display the mesh exactly +as it is specified. + +For all other frames, the bones represent the transformation from the +orientation of the bone in the base frame to the orientation in this +frame. + +*/ + +/* +============== +R_AddAnimSurfaces +============== +*/ +void R_AddAnimSurfaces( trRefEntity_t *ent ) { + md4Header_t *header; + md4Surface_t *surface; + md4LOD_t *lod; + shader_t *shader; + int i; + + header = (md4Header_t *) tr.currentModel->modelData; + lod = (md4LOD_t *)( (byte *)header + header->ofsLODs ); + + surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces ); + for ( i = 0 ; i < lod->numSurfaces ; i++ ) { + shader = R_GetShaderByHandle( surface->shaderIndex ); + R_AddDrawSurf( (void *)surface, shader, 0 /*fogNum*/, qfalse, qfalse ); + surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd ); + } +} + +/* +============== +RB_SurfaceAnim +============== +*/ +void RB_SurfaceAnim( md4Surface_t *surface ) { + int i, j, k; + float frontlerp, backlerp; + int *triangles; + int indexes; + int baseIndex, baseVertex; + int numVerts; + md4Vertex_t *v; + md4Bone_t bones[MD4_MAX_BONES]; + md4Bone_t *bonePtr, *bone; + md4Header_t *header; + md4Frame_t *frame; + md4Frame_t *oldFrame; + int frameSize; + + + if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) { + backlerp = 0; + frontlerp = 1; + } else { + backlerp = backEnd.currentEntity->e.backlerp; + frontlerp = 1.0f - backlerp; + } + header = (md4Header_t *)((byte *)surface + surface->ofsHeader); + + frameSize = (size_t)( &((md4Frame_t *)0)->bones[ header->numBones ] ); + + frame = (md4Frame_t *)((byte *)header + header->ofsFrames + + backEnd.currentEntity->e.frame * frameSize ); + oldFrame = (md4Frame_t *)((byte *)header + header->ofsFrames + + backEnd.currentEntity->e.oldframe * frameSize ); + + RB_CheckOverflow( surface->numVerts, surface->numTriangles * 3 ); + + triangles = (int *) ((byte *)surface + surface->ofsTriangles); + indexes = surface->numTriangles * 3; + baseIndex = tess.numIndexes; + baseVertex = tess.numVertexes; + for (j = 0 ; j < indexes ; j++) { + tess.indexes[baseIndex + j] = baseIndex + triangles[j]; + } + tess.numIndexes += indexes; + + // + // lerp all the needed bones + // + if ( !backlerp ) { + // no lerping needed + bonePtr = frame->bones; + } else { + bonePtr = bones; + for ( i = 0 ; i < header->numBones*12 ; i++ ) { + ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] + + backlerp * ((float *)oldFrame->bones)[i]; + } + } + + // + // deform the vertexes by the lerped bones + // + numVerts = surface->numVerts; + // FIXME + // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left + // in for reference. + //v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts + 12); + v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts); + for ( j = 0; j < numVerts; j++ ) { + vec3_t tempVert, tempNormal; + md4Weight_t *w; + + VectorClear( tempVert ); + VectorClear( tempNormal ); + w = v->weights; + for ( k = 0 ; k < v->numWeights ; k++, w++ ) { + bone = bonePtr + w->boneIndex; + + tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] ); + tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); + tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); + + tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); + tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); + tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal ); + } + + tess.xyz[baseVertex + j][0] = tempVert[0]; + tess.xyz[baseVertex + j][1] = tempVert[1]; + tess.xyz[baseVertex + j][2] = tempVert[2]; + + tess.normal[baseVertex + j][0] = tempNormal[0]; + tess.normal[baseVertex + j][1] = tempNormal[1]; + tess.normal[baseVertex + j][2] = tempNormal[2]; + + tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; + tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; + + // FIXME + // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left + // in for reference. + //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 ); + v = (md4Vertex_t *)&v->weights[v->numWeights]; + } + + tess.numVertexes += surface->numVerts; +} + + + +// copied and adapted from tr_mesh.c + +/* +============= +R_MDRCullModel +============= +*/ + +static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { + vec3_t bounds[2]; + mdrFrame_t *oldFrame, *newFrame; + int i, frameSize; + + frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); + + // compute frame pointers + newFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); + oldFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.oldframe); + + // cull bounding sphere ONLY if this is not an upscaled entity + if ( !ent->e.nonNormalizedAxes ) + { + if ( ent->e.frame == ent->e.oldframe ) + { + switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) + { + // Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend + // we do. After all, the purpose of md4s are not that different, are they? + + case CULL_OUT: + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + + case CULL_IN: + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + + case CULL_CLIP: + tr.pc.c_sphere_cull_md3_clip++; + break; + } + } + else + { + int sphereCull, sphereCullB; + + sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); + if ( newFrame == oldFrame ) { + sphereCullB = sphereCull; + } else { + sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); + } + + if ( sphereCull == sphereCullB ) + { + if ( sphereCull == CULL_OUT ) + { + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + } + else if ( sphereCull == CULL_IN ) + { + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + } + else + { + tr.pc.c_sphere_cull_md3_clip++; + } + } + } + } + + // calculate a bounding box in the current coordinate system + for (i = 0 ; i < 3 ; i++) { + bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; + bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; + } + + switch ( R_CullLocalBox( bounds ) ) + { + case CULL_IN: + tr.pc.c_box_cull_md3_in++; + return CULL_IN; + case CULL_CLIP: + tr.pc.c_box_cull_md3_clip++; + return CULL_CLIP; + case CULL_OUT: + default: + tr.pc.c_box_cull_md3_out++; + return CULL_OUT; + } +} + +/* +================= +R_MDRComputeFogNum + +================= +*/ + +int R_MDRComputeFogNum( mdrHeader_t *header, trRefEntity_t *ent ) { + int i, j; + fog_t *fog; + mdrFrame_t *mdrFrame; + vec3_t localOrigin; + int frameSize; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); + + // FIXME: non-normalized axis issues + mdrFrame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); + VectorAdd( ent->e.origin, mdrFrame->localOrigin, localOrigin ); + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( localOrigin[j] - mdrFrame->radius >= fog->bounds[1][j] ) { + break; + } + if ( localOrigin[j] + mdrFrame->radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + + +/* +============== +R_MDRAddAnimSurfaces +============== +*/ + +// much stuff in there is just copied from R_AddMd3Surfaces in tr_mesh.c + +void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { + mdrHeader_t *header; + mdrSurface_t *surface; + mdrLOD_t *lod; + shader_t *shader; + skin_t *skin; + int i, j; + int lodnum = 0; + int fogNum = 0; + int cull; + qboolean personalModel; + + header = (mdrHeader_t *) tr.currentModel->modelData; + + personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; + + if ( ent->e.renderfx & RF_WRAP_FRAMES ) + { + ent->e.frame %= header->numFrames; + ent->e.oldframe %= header->numFrames; + } + + // + // Validate the frames so there is no chance of a crash. + // This will write directly into the entity structure, so + // when the surfaces are rendered, they don't need to be + // range checked again. + // + if ((ent->e.frame >= header->numFrames) + || (ent->e.frame < 0) + || (ent->e.oldframe >= header->numFrames) + || (ent->e.oldframe < 0) ) + { + ri.Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", + ent->e.oldframe, ent->e.frame, tr.currentModel->name ); + ent->e.frame = 0; + ent->e.oldframe = 0; + } + + // + // cull the entire model if merged bounding box of both frames + // is outside the view frustum. + // + cull = R_MDRCullModel (header, ent); + if ( cull == CULL_OUT ) { + return; + } + + // figure out the current LOD of the model we're rendering, and set the lod pointer respectively. + lodnum = R_ComputeLOD(ent); + // check whether this model has as that many LODs at all. If not, try the closest thing we got. + if(header->numLODs <= 0) + return; + if(header->numLODs <= lodnum) + lodnum = header->numLODs - 1; + + lod = (mdrLOD_t *)( (byte *)header + header->ofsLODs); + for(i = 0; i < lodnum; i++) + { + lod = (mdrLOD_t *) ((byte *) lod + lod->ofsEnd); + } + + // set up lighting + if ( !personalModel || r_shadows->integer > 1 ) + { + R_SetupEntityLighting( &tr.refdef, ent ); + } + + // fogNum? + fogNum = R_MDRComputeFogNum( header, ent ); + + surface = (mdrSurface_t *)( (byte *)lod + lod->ofsSurfaces ); + + for ( i = 0 ; i < lod->numSurfaces ; i++ ) + { + + if(ent->e.customShader) + shader = R_GetShaderByHandle(ent->e.customShader); + else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) + { + skin = R_GetSkinByHandle(ent->e.customSkin); + shader = tr.defaultShader; + + for(j = 0; j < skin->numSurfaces; j++) + { + if (!strcmp(skin->surfaces[j]->name, surface->name)) + { + shader = skin->surfaces[j]->shader; + break; + } + } + } + else if(surface->shaderIndex > 0) + shader = R_GetShaderByHandle( surface->shaderIndex ); + else + shader = tr.defaultShader; + + // we will add shadows even if the main object isn't visible in the view + + // stencil shadows can't do personal models unless I polyhedron clip + if ( !personalModel + && r_shadows->integer == 2 + && fogNum == 0 + && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) + && shader->sort == SS_OPAQUE ) + { + R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse, qfalse ); + } + + // projection shadows work fine with personal models + if ( r_shadows->integer == 3 + && fogNum == 0 + && (ent->e.renderfx & RF_SHADOW_PLANE ) + && shader->sort == SS_OPAQUE ) + { + R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse, qfalse ); + } + + if (!personalModel) + R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse, qfalse ); + + surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); + } +} + +/* +============== +RB_MDRSurfaceAnim +============== +*/ +void RB_MDRSurfaceAnim( md4Surface_t *surface ) +{ + int i, j, k; + float frontlerp, backlerp; + int *triangles; + int indexes; + int baseIndex, baseVertex; + int numVerts; + mdrVertex_t *v; + mdrHeader_t *header; + mdrFrame_t *frame; + mdrFrame_t *oldFrame; + mdrBone_t bones[MD4_MAX_BONES], *bonePtr, *bone; + + int frameSize; + + // don't lerp if lerping off, or this is the only frame, or the last frame... + // + if (backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame) + { + backlerp = 0; // if backlerp is 0, lerping is off and frontlerp is never used + frontlerp = 1; + } + else + { + backlerp = backEnd.currentEntity->e.backlerp; + frontlerp = 1.0f - backlerp; + } + + header = (mdrHeader_t *)((byte *)surface + surface->ofsHeader); + + frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); + + frame = (mdrFrame_t *)((byte *)header + header->ofsFrames + + backEnd.currentEntity->e.frame * frameSize ); + oldFrame = (mdrFrame_t *)((byte *)header + header->ofsFrames + + backEnd.currentEntity->e.oldframe * frameSize ); + + RB_CheckOverflow( surface->numVerts, surface->numTriangles ); + + triangles = (int *) ((byte *)surface + surface->ofsTriangles); + indexes = surface->numTriangles * 3; + baseIndex = tess.numIndexes; + baseVertex = tess.numVertexes; + + // Set up all triangles. + for (j = 0 ; j < indexes ; j++) + { + tess.indexes[baseIndex + j] = baseVertex + triangles[j]; + } + tess.numIndexes += indexes; + + // + // lerp all the needed bones + // + if ( !backlerp ) + { + // no lerping needed + bonePtr = frame->bones; + } + else + { + bonePtr = bones; + + for ( i = 0 ; i < header->numBones*12 ; i++ ) + { + ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] + backlerp * ((float *)oldFrame->bones)[i]; + } + } + + // + // deform the vertexes by the lerped bones + // + numVerts = surface->numVerts; + v = (mdrVertex_t *) ((byte *)surface + surface->ofsVerts); + for ( j = 0; j < numVerts; j++ ) + { + vec3_t tempVert, tempNormal; + mdrWeight_t *w; + + VectorClear( tempVert ); + VectorClear( tempNormal ); + w = v->weights; + for ( k = 0 ; k < v->numWeights ; k++, w++ ) + { + bone = bonePtr + w->boneIndex; + + tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] ); + tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); + tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); + + tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); + tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); + tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal ); + } + + tess.xyz[baseVertex + j][0] = tempVert[0]; + tess.xyz[baseVertex + j][1] = tempVert[1]; + tess.xyz[baseVertex + j][2] = tempVert[2]; + + tess.normal[baseVertex + j][0] = tempNormal[0]; + tess.normal[baseVertex + j][1] = tempNormal[1]; + tess.normal[baseVertex + j][2] = tempNormal[2]; + + tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; + tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; + + v = (mdrVertex_t *)&v->weights[v->numWeights]; + } + + tess.numVertexes += surface->numVerts; +} + + +#define MC_MASK_X ((1<<(MC_BITS_X))-1) +#define MC_MASK_Y ((1<<(MC_BITS_Y))-1) +#define MC_MASK_Z ((1<<(MC_BITS_Z))-1) +#define MC_MASK_VECT ((1<<(MC_BITS_VECT))-1) + +#define MC_SCALE_VECT (1.0f/(float)((1<<(MC_BITS_VECT-1))-2)) + +#define MC_POS_X (0) +#define MC_SHIFT_X (0) + +#define MC_POS_Y ((((MC_BITS_X))/8)) +#define MC_SHIFT_Y ((((MC_BITS_X)%8))) + +#define MC_POS_Z ((((MC_BITS_X+MC_BITS_Y))/8)) +#define MC_SHIFT_Z ((((MC_BITS_X+MC_BITS_Y)%8))) + +#define MC_POS_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z))/8)) +#define MC_SHIFT_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z)%8))) + +#define MC_POS_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT))/8)) +#define MC_SHIFT_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT)%8))) + +#define MC_POS_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2))/8)) +#define MC_SHIFT_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2)%8))) + +#define MC_POS_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3))/8)) +#define MC_SHIFT_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3)%8))) + +#define MC_POS_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4))/8)) +#define MC_SHIFT_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4)%8))) + +#define MC_POS_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5))/8)) +#define MC_SHIFT_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5)%8))) + +#define MC_POS_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6))/8)) +#define MC_SHIFT_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6)%8))) + +#define MC_POS_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7))/8)) +#define MC_SHIFT_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7)%8))) + +#define MC_POS_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8))/8)) +#define MC_SHIFT_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8)%8))) + +void MC_UnCompress(float mat[3][4],const unsigned char * comp) +{ + int val; + + val=(int)((unsigned short *)(comp))[0]; + val-=1<<(MC_BITS_X-1); + mat[0][3]=((float)(val))*MC_SCALE_X; + + val=(int)((unsigned short *)(comp))[1]; + val-=1<<(MC_BITS_Y-1); + mat[1][3]=((float)(val))*MC_SCALE_Y; + + val=(int)((unsigned short *)(comp))[2]; + val-=1<<(MC_BITS_Z-1); + mat[2][3]=((float)(val))*MC_SCALE_Z; + + val=(int)((unsigned short *)(comp))[3]; + val-=1<<(MC_BITS_VECT-1); + mat[0][0]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[4]; + val-=1<<(MC_BITS_VECT-1); + mat[0][1]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[5]; + val-=1<<(MC_BITS_VECT-1); + mat[0][2]=((float)(val))*MC_SCALE_VECT; + + + val=(int)((unsigned short *)(comp))[6]; + val-=1<<(MC_BITS_VECT-1); + mat[1][0]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[7]; + val-=1<<(MC_BITS_VECT-1); + mat[1][1]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[8]; + val-=1<<(MC_BITS_VECT-1); + mat[1][2]=((float)(val))*MC_SCALE_VECT; + + + val=(int)((unsigned short *)(comp))[9]; + val-=1<<(MC_BITS_VECT-1); + mat[2][0]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[10]; + val-=1<<(MC_BITS_VECT-1); + mat[2][1]=((float)(val))*MC_SCALE_VECT; + + val=(int)((unsigned short *)(comp))[11]; + val-=1<<(MC_BITS_VECT-1); + mat[2][2]=((float)(val))*MC_SCALE_VECT; +} diff --git a/codemp/rd-rend2/tr_backend.c b/codemp/rd-rend2/tr_backend.c new file mode 100644 index 0000000000..de05f53b75 --- /dev/null +++ b/codemp/rd-rend2/tr_backend.c @@ -0,0 +1,1786 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "tr_local.h" + +backEndData_t *backEndData; +backEndState_t backEnd; + + +static float s_flipMatrix[16] = { + // convert from our coordinate system (looking down X) + // to OpenGL's coordinate system (looking down -Z) + 0, 0, -1, 0, + -1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 +}; + + +/* +** GL_Bind2 +*/ +void GL_Bind2( image_t *image, GLenum type ) { + int texnum; + + if ( !image ) { + ri.Printf( PRINT_WARNING, "GL_Bind2: NULL image\n" ); + texnum = tr.defaultImage->texnum; + } else { + texnum = image->texnum; + } + + if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option + texnum = tr.dlightImage->texnum; + } + + if ( glState.currenttextures[glState.currenttmu] != texnum ) { + if ( image ) { + image->frameUsed = tr.frameCount; + } + glState.currenttextures[glState.currenttmu] = texnum; + qglBindTexture (type, texnum); + } +} + +/* +** GL_Bind2 +*/ +void GL_Bind( image_t *image ) +{ + GL_Bind2( image, GL_TEXTURE_2D ); +} + +/* +** GL_BindCubemap +*/ +void GL_BindCubemap( image_t *image ) +{ + GL_Bind2( image, GL_TEXTURE_CUBE_MAP ); +} + +/* +** GL_SelectTexture +*/ +void GL_SelectTexture( int unit ) +{ + if ( glState.currenttmu == unit ) + { + return; + } + + if (!(unit >= 0 && unit <= 31)) + ri.Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); + + qglActiveTextureARB( GL_TEXTURE0_ARB + unit ); + + glState.currenttmu = unit; +} + + +/* +** GL_BindMultitexture +*/ +void GL_BindMultitexture( image_t *image0, GLuint env0, image_t *image1, GLuint env1 ) { + int texnum0, texnum1; + + texnum0 = image0->texnum; + texnum1 = image1->texnum; + + if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option + texnum0 = texnum1 = tr.dlightImage->texnum; + } + + if ( glState.currenttextures[1] != texnum1 ) { + GL_SelectTexture( 1 ); + image1->frameUsed = tr.frameCount; + glState.currenttextures[1] = texnum1; + qglBindTexture( GL_TEXTURE_2D, texnum1 ); + } + if ( glState.currenttextures[0] != texnum0 ) { + GL_SelectTexture( 0 ); + image0->frameUsed = tr.frameCount; + glState.currenttextures[0] = texnum0; + qglBindTexture( GL_TEXTURE_2D, texnum0 ); + } +} + +/* +** GL_BindToTMU +*/ +void GL_BindToTMU( image_t *image, int tmu ) +{ + int texnum; + int oldtmu = glState.currenttmu; + + if (!image) + texnum = 0; + else + texnum = image->texnum; + + if ( glState.currenttextures[tmu] != texnum ) { + GL_SelectTexture( tmu ); + if (image) + image->frameUsed = tr.frameCount; + glState.currenttextures[tmu] = texnum; + qglBindTexture( GL_TEXTURE_2D, texnum ); + GL_SelectTexture( oldtmu ); + } +} + + +/* +** GL_Cull +*/ +void GL_Cull( int cullType ) { + if ( glState.faceCulling == cullType ) { + return; + } + + glState.faceCulling = cullType; + + if ( cullType == CT_TWO_SIDED ) + { + qglDisable( GL_CULL_FACE ); + } + else + { + qboolean cullFront; + qglEnable( GL_CULL_FACE ); + + cullFront = (cullType == CT_FRONT_SIDED); + if ( backEnd.viewParms.isMirror ) + { + cullFront = !cullFront; + } + + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + { + cullFront = !cullFront; + } + + qglCullFace( cullFront ? GL_FRONT : GL_BACK ); + } +} + +/* +** GL_TexEnv +*/ +void GL_TexEnv( int env ) +{ + if ( env == glState.texEnv[glState.currenttmu] ) + { + return; + } + + glState.texEnv[glState.currenttmu] = env; + + + switch ( env ) + { + case GL_MODULATE: + qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); + break; + case GL_REPLACE: + qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); + break; + case GL_DECAL: + qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); + break; + case GL_ADD: + qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); + break; + default: + ri.Error( ERR_DROP, "GL_TexEnv: invalid env '%d' passed", env ); + break; + } +} + +/* +** GL_State +** +** This routine is responsible for setting the most commonly changed state +** in Q3. +*/ +void GL_State( unsigned long stateBits ) +{ + unsigned long diff = stateBits ^ glState.glStateBits; + + if ( !diff ) + { + return; + } + + // + // check depthFunc bits + // + if ( diff & GLS_DEPTHFUNC_BITS ) + { + if ( stateBits & GLS_DEPTHFUNC_EQUAL ) + { + qglDepthFunc( GL_EQUAL ); + } + else if ( stateBits & GLS_DEPTHFUNC_GREATER) + { + qglDepthFunc( GL_GREATER ); + } + else + { + qglDepthFunc( GL_LEQUAL ); + } + } + + // + // check blend bits + // + if ( diff & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) + { + GLenum srcFactor = GL_ONE, dstFactor = GL_ONE; + + if ( stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) + { + switch ( stateBits & GLS_SRCBLEND_BITS ) + { + case GLS_SRCBLEND_ZERO: + srcFactor = GL_ZERO; + break; + case GLS_SRCBLEND_ONE: + srcFactor = GL_ONE; + break; + case GLS_SRCBLEND_DST_COLOR: + srcFactor = GL_DST_COLOR; + break; + case GLS_SRCBLEND_ONE_MINUS_DST_COLOR: + srcFactor = GL_ONE_MINUS_DST_COLOR; + break; + case GLS_SRCBLEND_SRC_ALPHA: + srcFactor = GL_SRC_ALPHA; + break; + case GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA: + srcFactor = GL_ONE_MINUS_SRC_ALPHA; + break; + case GLS_SRCBLEND_DST_ALPHA: + srcFactor = GL_DST_ALPHA; + break; + case GLS_SRCBLEND_ONE_MINUS_DST_ALPHA: + srcFactor = GL_ONE_MINUS_DST_ALPHA; + break; + case GLS_SRCBLEND_ALPHA_SATURATE: + srcFactor = GL_SRC_ALPHA_SATURATE; + break; + default: + ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); + break; + } + + switch ( stateBits & GLS_DSTBLEND_BITS ) + { + case GLS_DSTBLEND_ZERO: + dstFactor = GL_ZERO; + break; + case GLS_DSTBLEND_ONE: + dstFactor = GL_ONE; + break; + case GLS_DSTBLEND_SRC_COLOR: + dstFactor = GL_SRC_COLOR; + break; + case GLS_DSTBLEND_ONE_MINUS_SRC_COLOR: + dstFactor = GL_ONE_MINUS_SRC_COLOR; + break; + case GLS_DSTBLEND_SRC_ALPHA: + dstFactor = GL_SRC_ALPHA; + break; + case GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA: + dstFactor = GL_ONE_MINUS_SRC_ALPHA; + break; + case GLS_DSTBLEND_DST_ALPHA: + dstFactor = GL_DST_ALPHA; + break; + case GLS_DSTBLEND_ONE_MINUS_DST_ALPHA: + dstFactor = GL_ONE_MINUS_DST_ALPHA; + break; + default: + ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); + break; + } + + qglEnable( GL_BLEND ); + qglBlendFunc( srcFactor, dstFactor ); + } + else + { + qglDisable( GL_BLEND ); + } + } + + // + // check depthmask + // + if ( diff & GLS_DEPTHMASK_TRUE ) + { + if ( stateBits & GLS_DEPTHMASK_TRUE ) + { + qglDepthMask( GL_TRUE ); + } + else + { + qglDepthMask( GL_FALSE ); + } + } + + // + // fill/line mode + // + if ( diff & GLS_POLYMODE_LINE ) + { + if ( stateBits & GLS_POLYMODE_LINE ) + { + qglPolygonMode( GL_FRONT_AND_BACK, GL_LINE ); + } + else + { + qglPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); + } + } + + // + // depthtest + // + if ( diff & GLS_DEPTHTEST_DISABLE ) + { + if ( stateBits & GLS_DEPTHTEST_DISABLE ) + { + qglDisable( GL_DEPTH_TEST ); + } + else + { + qglEnable( GL_DEPTH_TEST ); + } + } + + // + // alpha test + // + if ( diff & GLS_ATEST_BITS ) + { + switch ( stateBits & GLS_ATEST_BITS ) + { + case 0: + qglDisable( GL_ALPHA_TEST ); + break; + case GLS_ATEST_GT_0: + qglEnable( GL_ALPHA_TEST ); + qglAlphaFunc( GL_GREATER, 0.0f ); + break; + case GLS_ATEST_LT_80: + qglEnable( GL_ALPHA_TEST ); + qglAlphaFunc( GL_LESS, 0.5f ); + break; + case GLS_ATEST_GE_80: + qglEnable( GL_ALPHA_TEST ); + qglAlphaFunc( GL_GEQUAL, 0.5f ); + break; + default: + assert( 0 ); + break; + } + } + + glState.glStateBits = stateBits; +} + + +void GL_SetProjectionMatrix(matrix_t matrix) +{ + Matrix16Copy(matrix, glState.projection); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); +} + + +void GL_SetModelviewMatrix(matrix_t matrix) +{ + Matrix16Copy(matrix, glState.modelview); + Matrix16Multiply(glState.projection, glState.modelview, glState.modelviewProjection); +} + + +/* +================ +RB_Hyperspace + +A player has predicted a teleport, but hasn't arrived yet +================ +*/ +static void RB_Hyperspace( void ) { + float c; + + if ( !backEnd.isHyperspace ) { + // do initialization shit + } + + c = ( backEnd.refdef.time & 255 ) / 255.0f; + qglClearColor( c, c, c, 1 ); + qglClear( GL_COLOR_BUFFER_BIT ); + + backEnd.isHyperspace = qtrue; +} + + +static void SetViewportAndScissor( void ) { + GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); + + // set the window clipping + qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, + backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); + qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, + backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); +} + +/* +================= +RB_BeginDrawingView + +Any mirrored or portaled views have already been drawn, so prepare +to actually render the visible surfaces for this view +================= +*/ +void RB_BeginDrawingView (void) { + int clearBits = 0; + + // sync with gl if needed + if ( r_finish->integer == 1 && !glState.finishCalled ) { + qglFinish (); + glState.finishCalled = qtrue; + } + if ( r_finish->integer == 0 ) { + glState.finishCalled = qtrue; + } + + // we will need to change the projection matrix before drawing + // 2D images again + backEnd.projection2D = qfalse; + + if (glRefConfig.framebufferObject) + { + // FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world + // drawing more world check is in case of double renders, such as skyportals + if (backEnd.viewParms.targetFbo == NULL) + { + if (!tr.renderFbo || (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + else + { + FBO_Bind(backEnd.viewParms.targetFbo); + } + } + + // + // set the modelview matrix for the viewer + // + SetViewportAndScissor(); + + // ensures that depth writes are enabled for the depth clear + GL_State( GLS_DEFAULT ); + // clear relevant buffers + clearBits = GL_DEPTH_BUFFER_BIT; + + if ( r_measureOverdraw->integer || r_shadows->integer == 2 ) + { + clearBits |= GL_STENCIL_BUFFER_BIT; + } + if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) + { + clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used +#ifdef _DEBUG + qglClearColor( 0.8f, 0.7f, 0.4f, 1.0f ); // FIXME: get color of sky +#else + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); // FIXME: get color of sky +#endif + } + + // clear to white for shadow maps + if (backEnd.viewParms.flags & VPF_SHADOWMAP) + { + clearBits |= GL_COLOR_BUFFER_BIT; + qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); + } + + qglClear( clearBits ); + + if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) ) + { + RB_Hyperspace(); + return; + } + else + { + backEnd.isHyperspace = qfalse; + } + + glState.faceCulling = -1; // force face culling to set next time + + // we will only draw a sun if there was sky rendered in this view + backEnd.skyRenderedThisView = qfalse; + + // clip to the plane of the portal + if ( backEnd.viewParms.isPortal ) { +#if 0 + float plane[4]; + double plane2[4]; + + plane[0] = backEnd.viewParms.portalPlane.normal[0]; + plane[1] = backEnd.viewParms.portalPlane.normal[1]; + plane[2] = backEnd.viewParms.portalPlane.normal[2]; + plane[3] = backEnd.viewParms.portalPlane.dist; + + plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane); + plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane); + plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane); + plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3]; +#endif + GL_SetModelviewMatrix( s_flipMatrix ); + } +} + + +#define MAC_EVENT_PUMP_MSEC 5 + +/* +================== +RB_RenderDrawSurfList +================== +*/ +void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { + shader_t *shader, *oldShader; + int fogNum, oldFogNum; + int entityNum, oldEntityNum; + int dlighted, oldDlighted; + int pshadowed, oldPshadowed; + qboolean depthRange, oldDepthRange, isCrosshair, wasCrosshair; + int i; + drawSurf_t *drawSurf; + int oldSort; + float originalTime; + FBO_t* fbo = NULL; + qboolean inQuery = qfalse; + + float depth[2]; + + + // save original time for entity shader offsets + originalTime = backEnd.refdef.floatTime; + + fbo = glState.currentFBO; + + // draw everything + oldEntityNum = -1; + backEnd.currentEntity = &tr.worldEntity; + oldShader = NULL; + oldFogNum = -1; + oldDepthRange = qfalse; + wasCrosshair = qfalse; + oldDlighted = qfalse; + oldPshadowed = qfalse; + oldSort = -1; + + depth[0] = 0.f; + depth[1] = 1.f; + + backEnd.pc.c_surfaces += numDrawSurfs; + + for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { + if ( drawSurf->sort == oldSort ) { + if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) + continue; + + // fast path, same as previous sort + rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + continue; + } + oldSort = drawSurf->sort; + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + + // + // change the tess parameters if needed + // a "entityMergable" shader is a shader that can have surfaces from seperate + // entities merged into a single batch, like smoke and blood puff sprites + if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed + || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { + if (oldShader != NULL) { + RB_EndSurface(); + } + RB_BeginSurface( shader, fogNum ); + backEnd.pc.c_surfBatches++; + oldShader = shader; + oldFogNum = fogNum; + oldDlighted = dlighted; + oldPshadowed = pshadowed; + } + + if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) + continue; + + // + // change the modelview matrix if needed + // + if ( entityNum != oldEntityNum ) { + qboolean sunflare = qfalse; + depthRange = isCrosshair = qfalse; + + if ( entityNum != REFENTITYNUM_WORLD ) { + backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; + backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; + // we have to reset the shaderTime as well otherwise image animations start + // from the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + + // set up the transformation matrix + R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or ); + + // set up the dynamic lighting if needed + if ( backEnd.currentEntity->needDlights ) { + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); + } + + if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) + { + // hack the depth range to prevent view model from poking into walls + depthRange = qtrue; + + if(backEnd.currentEntity->e.renderfx & RF_CROSSHAIR) + isCrosshair = qtrue; + } + } else { + backEnd.currentEntity = &tr.worldEntity; + backEnd.refdef.floatTime = originalTime; + backEnd.or = backEnd.viewParms.world; + // we have to reset the shaderTime as well otherwise image animations on + // the world (like water) continue with the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); + } + + GL_SetModelviewMatrix( backEnd.or.modelMatrix ); + + // + // change depthrange. Also change projection matrix so first person weapon does not look like coming + // out of the screen. + // + if (oldDepthRange != depthRange || wasCrosshair != isCrosshair) + { + if (depthRange) + { + if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + { + if(isCrosshair) + { + if(oldDepthRange) + { + // was not a crosshair but now is, change back proj matrix + GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); + } + } + else + { + viewParms_t temp = backEnd.viewParms; + + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + + GL_SetProjectionMatrix( temp.projectionMatrix ); + } + } + + if(!oldDepthRange) + { + depth[0] = 0; + depth[1] = 0.3f; + qglDepthRange (depth[0], depth[1]); + } + } + else + { + if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER) + { + GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); + } + + if (!sunflare) + qglDepthRange (0, 1); + + depth[0] = 0; + depth[1] = 1; + } + + oldDepthRange = depthRange; + wasCrosshair = isCrosshair; + } + + oldEntityNum = entityNum; + } + + // add the triangles for this surface + rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + } + + backEnd.refdef.floatTime = originalTime; + + // draw the contents of the last shader batch + if (oldShader != NULL) { + RB_EndSurface(); + } + + if (inQuery) { + qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + } + + if (glRefConfig.framebufferObject) + FBO_Bind(fbo); + + // go back to the world modelview matrix + + GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); + + qglDepthRange (0, 1); +} + + +/* +============================================================================ + +RENDER BACK END FUNCTIONS + +============================================================================ +*/ + +/* +================ +RB_SetGL2D + +================ +*/ +void RB_SetGL2D (void) { + matrix_t matrix; + int width, height; + + if (backEnd.projection2D && backEnd.last2DFBO == glState.currentFBO) + return; + + backEnd.projection2D = qtrue; + backEnd.last2DFBO = glState.currentFBO; + + if (glState.currentFBO) + { + width = glState.currentFBO->width; + height = glState.currentFBO->height; + } + else + { + width = glConfig.vidWidth; + height = glConfig.vidHeight; + } + + // set 2D virtual screen size + qglViewport( 0, 0, width, height ); + qglScissor( 0, 0, width, height ); + + Matrix16Ortho(0, width, height, 0, 0, 1, matrix); + GL_SetProjectionMatrix(matrix); + Matrix16Identity(matrix); + GL_SetModelviewMatrix(matrix); + + GL_State( GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + + qglDisable( GL_CULL_FACE ); + qglDisable( GL_CLIP_PLANE0 ); + + // set time for 2D shaders + backEnd.refdef.time = ri.Milliseconds(); + backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f; + + // reset color scaling + backEnd.refdef.colorScale = 1.0f; +} + + +/* +============= +RE_StretchRaw + +FIXME: not exactly backend +Stretches a raw 32 bit power of 2 bitmap image over the given screen rectangle. +Used for cinematics. +============= +*/ +void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) { + int i, j; + int start, end; + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + + if ( !tr.registered ) { + return; + } + R_IssuePendingRenderCommands(); + + // we definately want to sync every frame for the cinematics + qglFinish(); + + start = 0; + if ( r_speeds->integer ) { + start = ri.Milliseconds(); + } + + // make sure rows and cols are powers of 2 + for ( i = 0 ; ( 1 << i ) < cols ; i++ ) { + } + for ( j = 0 ; ( 1 << j ) < rows ; j++ ) { + } + if ( ( 1 << i ) != cols || ( 1 << j ) != rows) { + ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); + } + + RE_UploadCinematic (w, h, cols, rows, data, client, dirty); + + if ( r_speeds->integer ) { + end = ri.Milliseconds(); + ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); + } + + // FIXME: HUGE hack + if (glRefConfig.framebufferObject) + { + if (!tr.renderFbo || backEnd.framePostProcessed) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + + RB_SetGL2D(); + + VectorSet4(quadVerts[0], x, y, 0.0f, 1.0f); + VectorSet4(quadVerts[1], x + w, y, 0.0f, 1.0f); + VectorSet4(quadVerts[2], x + w, y + h, 0.0f, 1.0f); + VectorSet4(quadVerts[3], x, y + h, 0.0f, 1.0f); + + VectorSet2(texCoords[0], 0.5f / cols, 0.5f / rows); + VectorSet2(texCoords[1], (cols - 0.5f) / cols, 0.5f / rows); + VectorSet2(texCoords[2], (cols - 0.5f) / cols, (rows - 0.5f) / rows); + VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows); + + GLSL_BindProgram(&tr.textureColorShader); + + GLSL_SetUniformMatrix16(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); + + RB_InstantQuad2(quadVerts, texCoords); +} + +void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) { + + GL_Bind( tr.scratchImage[client] ); + + // if the scratchImage isn't in the format we want, specify it as a new texture + if ( cols != tr.scratchImage[client]->width || rows != tr.scratchImage[client]->height ) { + tr.scratchImage[client]->width = tr.scratchImage[client]->uploadWidth = cols; + tr.scratchImage[client]->height = tr.scratchImage[client]->uploadHeight = rows; + qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + } else { + if (dirty) { + // otherwise, just subimage upload it so that drivers can tell we are going to be changing + // it and don't try and do a texture compression + qglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_RGBA, GL_UNSIGNED_BYTE, data ); + } + } +} + + +/* +============= +RB_SetColor + +============= +*/ +const void *RB_SetColor( const void *data ) { + const setColorCommand_t *cmd; + + cmd = (const setColorCommand_t *)data; + + backEnd.color2D[0] = cmd->color[0] * 255; + backEnd.color2D[1] = cmd->color[1] * 255; + backEnd.color2D[2] = cmd->color[2] * 255; + backEnd.color2D[3] = cmd->color[3] * 255; + + return (const void *)(cmd + 1); +} + +/* +============= +RB_StretchPic +============= +*/ +const void *RB_StretchPic ( const void *data ) { + const stretchPicCommand_t *cmd; + shader_t *shader; + int numVerts, numIndexes; + + cmd = (const stretchPicCommand_t *)data; + + // FIXME: HUGE hack + if (glRefConfig.framebufferObject) + { + if (!tr.renderFbo || backEnd.framePostProcessed) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + + RB_SetGL2D(); + + shader = cmd->shader; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); + } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0 ); + } + + RB_CHECKOVERFLOW( 4, 6 ); + numVerts = tess.numVertexes; + numIndexes = tess.numIndexes; + + tess.numVertexes += 4; + tess.numIndexes += 6; + + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; + + { + vec4_t color; + + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); + } + + tess.xyz[ numVerts ][0] = cmd->x; + tess.xyz[ numVerts ][1] = cmd->y; + tess.xyz[ numVerts ][2] = 0; + + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; + + tess.xyz[ numVerts + 1 ][0] = cmd->x + cmd->w; + tess.xyz[ numVerts + 1 ][1] = cmd->y; + tess.xyz[ numVerts + 1 ][2] = 0; + + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + + tess.xyz[ numVerts + 2 ][0] = cmd->x + cmd->w; + tess.xyz[ numVerts + 2 ][1] = cmd->y + cmd->h; + tess.xyz[ numVerts + 2 ][2] = 0; + + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + + tess.xyz[ numVerts + 3 ][0] = cmd->x; + tess.xyz[ numVerts + 3 ][1] = cmd->y + cmd->h; + tess.xyz[ numVerts + 3 ][2] = 0; + + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + + return (const void *)(cmd + 1); +} + + +/* +============= +RB_DrawSurfs + +============= +*/ +const void *RB_DrawSurfs( const void *data ) { + const drawSurfsCommand_t *cmd; + + // finish any 2D drawing if needed + if ( tess.numIndexes ) { + RB_EndSurface(); + } + + cmd = (const drawSurfsCommand_t *)data; + + backEnd.refdef = cmd->refdef; + backEnd.viewParms = cmd->viewParms; + + // clear the z buffer, set the modelview, etc + RB_BeginDrawingView (); + + if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) + { + qglEnable(GL_DEPTH_CLAMP); + } + + if (glRefConfig.framebufferObject && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW))) + { + FBO_t *oldFbo = glState.currentFBO; + + backEnd.depthFill = qtrue; + qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); + qglColorMask(!backEnd.colorMask[0], !backEnd.colorMask[1], !backEnd.colorMask[2], !backEnd.colorMask[3]); + backEnd.depthFill = qfalse; + + if (tr.msaaResolveFbo) + { + // If we're using multisampling, resolve the depth first + FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } + else if (tr.renderFbo == NULL) + { + // If we're rendering directly to the screen, copy the depth to a texture + GL_BindToTMU(tr.renderDepthImage, 0); + qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 0, 0, glConfig.vidWidth, glConfig.vidHeight, 0); + } + + if (r_ssao->integer) + { + // need the depth in a texture we can do GL_LINEAR sampling on, so copy it to an HDR image + FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0); + } + + if (backEnd.viewParms.flags & VPF_USESUNLIGHT) + { + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + vec4_t box; + + FBO_Bind(tr.screenShadowFbo); + + box[0] = backEnd.viewParms.viewportX * tr.screenShadowFbo->width / (float)glConfig.vidWidth; + box[1] = backEnd.viewParms.viewportY * tr.screenShadowFbo->height / (float)glConfig.vidHeight; + box[2] = backEnd.viewParms.viewportWidth * tr.screenShadowFbo->width / (float)glConfig.vidWidth; + box[3] = backEnd.viewParms.viewportHeight * tr.screenShadowFbo->height / (float)glConfig.vidHeight; + + qglViewport(box[0], box[1], box[2], box[3]); + qglScissor(box[0], box[1], box[2], box[3]); + + box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; + box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; + box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; + box[3] = box[1] + backEnd.viewParms.viewportHeight / (float)glConfig.vidHeight; + + texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; + texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; + texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; + texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; + + box[0] = -1.0f; + box[1] = -1.0f; + box[2] = 1.0f; + box[3] = 1.0f; + + VectorSet4(quadVerts[0], box[0], box[3], 0, 1); + VectorSet4(quadVerts[1], box[2], box[3], 0, 1); + VectorSet4(quadVerts[2], box[2], box[1], 0, 1); + VectorSet4(quadVerts[3], box[0], box[1], 0, 1); + + GL_State( GLS_DEPTHTEST_DISABLE ); + + GLSL_BindProgram(&tr.shadowmaskShader); + + GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); + GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP); + GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); + GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); + + GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]); + GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]); + GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]); + + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); + { + vec4_t viewInfo; + vec3_t viewVector; + + float zmax = backEnd.viewParms.zFar; + float ymax = zmax * tan(backEnd.viewParms.fovY * M_PI / 360.0f); + float xmax = zmax * tan(backEnd.viewParms.fovX * M_PI / 360.0f); + + float zmin = r_znear->value; + + VectorScale(backEnd.refdef.viewaxis[0], zmax, viewVector); + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWFORWARD, viewVector); + VectorScale(backEnd.refdef.viewaxis[1], xmax, viewVector); + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWLEFT, viewVector); + VectorScale(backEnd.refdef.viewaxis[2], ymax, viewVector); + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWUP, viewVector); + + VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + + GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); + } + + + RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + } + + if (r_ssao->integer) + { + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + + FBO_Bind(tr.quarterFbo[0]); + + qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + + VectorSet4(quadVerts[0], -1, 1, 0, 1); + VectorSet4(quadVerts[1], 1, 1, 0, 1); + VectorSet4(quadVerts[2], 1, -1, 0, 1); + VectorSet4(quadVerts[3], -1, -1, 0, 1); + + texCoords[0][0] = 0; texCoords[0][1] = 1; + texCoords[1][0] = 1; texCoords[1][1] = 1; + texCoords[2][0] = 1; texCoords[2][1] = 0; + texCoords[3][0] = 0; texCoords[3][1] = 0; + + GL_State( GLS_DEPTHTEST_DISABLE ); + + GLSL_BindProgram(&tr.ssaoShader); + + GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); + + { + vec4_t viewInfo; + + float zmax = backEnd.viewParms.zFar; + float zmin = r_znear->value; + + VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + + GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); + } + + RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + + + FBO_Bind(tr.quarterFbo[1]); + + qglViewport(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); + qglScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); + + GLSL_BindProgram(&tr.depthBlurShader[0]); + + GL_BindToTMU(tr.quarterImage[0], TB_COLORMAP); + GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + + { + vec4_t viewInfo; + + float zmax = backEnd.viewParms.zFar; + float zmin = r_znear->value; + + VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + + GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); + } + + RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + + + FBO_Bind(tr.screenSsaoFbo); + + qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); + qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); + + GLSL_BindProgram(&tr.depthBlurShader[1]); + + GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP); + GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + + { + vec4_t viewInfo; + + float zmax = backEnd.viewParms.zFar; + float zmin = r_znear->value; + + VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + + GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); + } + + + RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + } + + // reset viewport and scissor + FBO_Bind(oldFbo); + SetViewportAndScissor(); + } + + if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) + { + qglDisable(GL_DEPTH_CLAMP); + } + + if (!(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + { + RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); + + if (r_drawSun->integer) + { + RB_DrawSun(0.1, tr.sunShader); + } + + if (r_drawSunRays->integer) + { + FBO_t *oldFbo = glState.currentFBO; + FBO_Bind(tr.sunRaysFbo); + + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClear( GL_COLOR_BUFFER_BIT ); + + if (glRefConfig.occlusionQuery) + { + tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; + qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); + } + + RB_DrawSun(0.3, tr.sunFlareShader); + + if (glRefConfig.occlusionQuery) + { + qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + } + + FBO_Bind(oldFbo); + } + + // darken down any stencil shadows + RB_ShadowFinish(); + + // add light flares on lights that aren't obscured + RB_RenderFlares(); + } + + //if (glRefConfig.framebufferObject) + //FBO_Bind(NULL); + + return (const void *)(cmd + 1); +} + + +/* +============= +RB_DrawBuffer + +============= +*/ +const void *RB_DrawBuffer( const void *data ) { + const drawBufferCommand_t *cmd; + + cmd = (const drawBufferCommand_t *)data; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + if (glRefConfig.framebufferObject) + FBO_Bind(NULL); + + qglDrawBuffer( cmd->buffer ); + + // clear screen for debugging + if ( r_clear->integer ) { + qglClearColor( 1, 0, 0.5, 1 ); + qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + } + + return (const void *)(cmd + 1); +} + +/* +=============== +RB_ShowImages + +Draw all the images to the screen, on top of whatever +was there. This is used to test for texture thrashing. + +Also called by RE_EndRegistration +=============== +*/ +void RB_ShowImages( void ) { + int i; + image_t *image; + float x, y, w, h; + int start, end; + + RB_SetGL2D(); + + qglClear( GL_COLOR_BUFFER_BIT ); + + qglFinish(); + + start = ri.Milliseconds(); + + for ( i=0 ; iinteger == 2 ) { + w *= image->uploadWidth / 512.0f; + h *= image->uploadHeight / 512.0f; + } + + { + vec4_t quadVerts[4]; + + GL_Bind(image); + + VectorSet4(quadVerts[0], x, y, 0, 1); + VectorSet4(quadVerts[1], x + w, y, 0, 1); + VectorSet4(quadVerts[2], x + w, y + h, 0, 1); + VectorSet4(quadVerts[3], x, y + h, 0, 1); + + RB_InstantQuad(quadVerts); + } + } + + qglFinish(); + + end = ri.Milliseconds(); + ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); + +} + +/* +============= +RB_ColorMask + +============= +*/ +const void *RB_ColorMask(const void *data) +{ + const colorMaskCommand_t *cmd = data; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + if (glRefConfig.framebufferObject) + { + // reverse color mask, so 0 0 0 0 is the default + backEnd.colorMask[0] = !cmd->rgba[0]; + backEnd.colorMask[1] = !cmd->rgba[1]; + backEnd.colorMask[2] = !cmd->rgba[2]; + backEnd.colorMask[3] = !cmd->rgba[3]; + } + + qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); + + return (const void *)(cmd + 1); +} + +/* +============= +RB_ClearDepth + +============= +*/ +const void *RB_ClearDepth(const void *data) +{ + const clearDepthCommand_t *cmd = data; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + // texture swapping test + if (r_showImages->integer) + RB_ShowImages(); + + if (glRefConfig.framebufferObject) + { + if (!tr.renderFbo || backEnd.framePostProcessed) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + + qglClear(GL_DEPTH_BUFFER_BIT); + + // if we're doing MSAA, clear the depth texture for the resolve buffer + if (tr.msaaResolveFbo) + { + FBO_Bind(tr.msaaResolveFbo); + qglClear(GL_DEPTH_BUFFER_BIT); + } + + + return (const void *)(cmd + 1); +} + + +/* +============= +RB_SwapBuffers + +============= +*/ +const void *RB_SwapBuffers( const void *data ) { + const swapBuffersCommand_t *cmd; + + // finish any 2D drawing if needed + if ( tess.numIndexes ) { + RB_EndSurface(); + } + + // texture swapping test + if ( r_showImages->integer ) { + RB_ShowImages(); + } + + cmd = (const swapBuffersCommand_t *)data; + + // we measure overdraw by reading back the stencil buffer and + // counting up the number of increments that have happened + if ( r_measureOverdraw->integer ) { + int i; + long sum = 0; + unsigned char *stencilReadback; + + stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); + qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); + + for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { + sum += stencilReadback[i]; + } + + backEnd.pc.c_overDraw += sum; + ri.Hunk_FreeTempMemory( stencilReadback ); + } + + if (glRefConfig.framebufferObject) + { + if (!backEnd.framePostProcessed) + { + if (tr.msaaResolveFbo && r_hdr->integer) + { + // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first + FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + FBO_FastBlit(tr.msaaResolveFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + else if (tr.renderFbo) + { + FBO_FastBlit(tr.renderFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + } + + if (tr.screenScratchFbo) + { + vec4_t color; + + color[0] = + color[1] = + color[2] = pow(2, tr.overbrightBits); //exp2(tr.overbrightBits); + color[3] = 1.0f; + + // turn off colormask when copying final image + if (backEnd.colorMask[0] || backEnd.colorMask[1] || backEnd.colorMask[2] || backEnd.colorMask[3]) + qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + FBO_Blit(tr.screenScratchFbo, NULL, NULL, NULL, NULL, NULL, color, 0); + + if (backEnd.colorMask[0] || backEnd.colorMask[1] || backEnd.colorMask[2] || backEnd.colorMask[3]) + qglColorMask(!backEnd.colorMask[0], !backEnd.colorMask[1], !backEnd.colorMask[2], !backEnd.colorMask[3]); + } + } + + if ( !glState.finishCalled ) { + qglFinish(); + } + + GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); + + GLimp_EndFrame(); + + backEnd.framePostProcessed = qfalse; + backEnd.projection2D = qfalse; + + return (const void *)(cmd + 1); +} + +/* +============= +RB_CapShadowMap + +============= +*/ +const void *RB_CapShadowMap(const void *data) +{ + const capShadowmapCommand_t *cmd = data; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + if (cmd->map != -1) + { + GL_SelectTexture(0); + if (cmd->cubeSide != -1) + { + GL_BindCubemap(tr.shadowCubemaps[cmd->map]); + qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + } + else + { + GL_Bind(tr.pshadowMaps[cmd->map]); + qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + } + } + + return (const void *)(cmd + 1); +} + + +/* +============= +RB_PostProcess + +============= +*/ +const void *RB_PostProcess(const void *data) +{ + const postProcessCommand_t *cmd = data; + FBO_t *srcFbo; + vec4i_t srcBox, dstBox; + qboolean autoExposure; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + if (!glRefConfig.framebufferObject || !r_postProcess->integer) + { + // do nothing + return (const void *)(cmd + 1); + } + + if (cmd) + { + backEnd.refdef = cmd->refdef; + backEnd.viewParms = cmd->viewParms; + } + + srcFbo = tr.renderFbo; + if (tr.msaaResolveFbo) + { + // Resolve the MSAA before anything else + // Can't resolve just part of the MSAA FBO, so multiple views will suffer a performance hit here + FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); + srcFbo = tr.msaaResolveFbo; + } + + dstBox[0] = backEnd.viewParms.viewportX; + dstBox[1] = backEnd.viewParms.viewportY; + dstBox[2] = backEnd.viewParms.viewportWidth; + dstBox[3] = backEnd.viewParms.viewportHeight; + + if (r_ssao->integer) + { + srcBox[0] = backEnd.viewParms.viewportX * tr.screenSsaoImage->width / (float)glConfig.vidWidth; + srcBox[1] = backEnd.viewParms.viewportY * tr.screenSsaoImage->height / (float)glConfig.vidHeight; + srcBox[2] = backEnd.viewParms.viewportWidth * tr.screenSsaoImage->width / (float)glConfig.vidWidth; + srcBox[3] = backEnd.viewParms.viewportHeight * tr.screenSsaoImage->height / (float)glConfig.vidHeight; + + FBO_BlitFromTexture(tr.screenSsaoImage, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + } + + srcBox[0] = backEnd.viewParms.viewportX; + srcBox[1] = backEnd.viewParms.viewportY; + srcBox[2] = backEnd.viewParms.viewportWidth; + srcBox[3] = backEnd.viewParms.viewportHeight; + + if (srcFbo) + { + if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) + { + autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer; + RB_ToneMap(srcFbo, srcBox, tr.screenScratchFbo, dstBox, autoExposure); + } + else if (r_cameraExposure->value == 0.0f) + { + FBO_FastBlit(srcFbo, srcBox, tr.screenScratchFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + else + { + vec4_t color; + + color[0] = + color[1] = + color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); + color[3] = 1.0f; + + FBO_Blit(srcFbo, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, color, 0); + } + } + + if (r_drawSunRays->integer) + RB_SunRays(tr.screenScratchFbo, srcBox, tr.screenScratchFbo, dstBox); + + if (1) + RB_BokehBlur(tr.screenScratchFbo, srcBox, tr.screenScratchFbo, dstBox, backEnd.refdef.blurFactor); + else + RB_GaussianBlur(backEnd.refdef.blurFactor); + + if (0) + { + vec4i_t dstBox; + VectorSet4(dstBox, 0, 0, 128, 128); + FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + VectorSet4(dstBox, 128, 0, 128, 128); + FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + VectorSet4(dstBox, 256, 0, 128, 128); + FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + } + + if (0) + { + vec4i_t dstBox; + VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); + FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256); + FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + } + + if (0) + { + vec4i_t dstBox; + VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); + FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + } + + backEnd.framePostProcessed = qtrue; + + return (const void *)(cmd + 1); +} + + +/* +==================== +RB_ExecuteRenderCommands +==================== +*/ +void RB_ExecuteRenderCommands( const void *data ) { + int t1, t2; + + t1 = ri.Milliseconds (); + + while ( 1 ) { + data = PADP(data, sizeof(void *)); + + switch ( *(const int *)data ) { + case RC_SET_COLOR: + data = RB_SetColor( data ); + break; + case RC_STRETCH_PIC: + data = RB_StretchPic( data ); + break; + case RC_DRAW_SURFS: + data = RB_DrawSurfs( data ); + break; + case RC_DRAW_BUFFER: + data = RB_DrawBuffer( data ); + break; + case RC_SWAP_BUFFERS: + data = RB_SwapBuffers( data ); + break; + case RC_SCREENSHOT: + data = RB_TakeScreenshotCmd( data ); + break; + case RC_VIDEOFRAME: + data = RB_TakeVideoFrameCmd( data ); + break; + case RC_COLORMASK: + data = RB_ColorMask(data); + break; + case RC_CLEARDEPTH: + data = RB_ClearDepth(data); + break; + case RC_CAPSHADOWMAP: + data = RB_CapShadowMap(data); + break; + case RC_POSTPROCESS: + data = RB_PostProcess(data); + break; + case RC_END_OF_LIST: + default: + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + // stop rendering + t2 = ri.Milliseconds (); + backEnd.pc.msec = t2 - t1; + return; + } + } + +} diff --git a/codemp/rd-rend2/tr_bsp.c b/codemp/rd-rend2/tr_bsp.c new file mode 100644 index 0000000000..01556cdd93 --- /dev/null +++ b/codemp/rd-rend2/tr_bsp.c @@ -0,0 +1,3555 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_map.c + +#include "tr_local.h" + +/* + +Loads and prepares a map file for scene rendering. + +A single entry point: + +void RE_LoadWorldMap( const char *name ); + +*/ + +static world_t s_worldData; +static byte *fileBase; + +int c_subdivisions; +int c_gridVerts; + +//=============================================================================== + +static void HSVtoRGB( float h, float s, float v, float rgb[3] ) +{ + int i; + float f; + float p, q, t; + + h *= 5; + + i = floor( h ); + f = h - i; + + p = v * ( 1 - s ); + q = v * ( 1 - s * f ); + t = v * ( 1 - s * ( 1 - f ) ); + + switch ( i ) + { + case 0: + rgb[0] = v; + rgb[1] = t; + rgb[2] = p; + break; + case 1: + rgb[0] = q; + rgb[1] = v; + rgb[2] = p; + break; + case 2: + rgb[0] = p; + rgb[1] = v; + rgb[2] = t; + break; + case 3: + rgb[0] = p; + rgb[1] = q; + rgb[2] = v; + break; + case 4: + rgb[0] = t; + rgb[1] = p; + rgb[2] = v; + break; + case 5: + rgb[0] = v; + rgb[1] = p; + rgb[2] = q; + break; + } +} + +/* +=============== +R_ColorShiftLightingBytes + +=============== +*/ +static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { + int shift, r, g, b; + + // shift the color data based on overbright range + shift = r_mapOverBrightBits->integer - tr.overbrightBits; + + // shift the data based on overbright range + r = in[0] << shift; + g = in[1] << shift; + b = in[2] << shift; + + // normalize by color instead of saturating to white + if ( ( r | g | b ) > 255 ) { + int max; + + max = r > g ? r : g; + max = max > b ? max : b; + r = r * 255 / max; + g = g * 255 / max; + b = b * 255 / max; + } + + out[0] = r; + out[1] = g; + out[2] = b; + out[3] = in[3]; +} + + +/* +=============== +R_ColorShiftLightingBytes + +=============== +*/ +static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) +{ + scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); + + out[0] = in[0] * scale; + out[1] = in[1] * scale; + out[2] = in[2] * scale; + out[3] = in[3]; +} + + +void ColorToRGBE(const vec3_t color, unsigned char rgbe[4]) +{ + vec3_t sample; + float maxComponent; + int e; + + VectorCopy(color, sample); + + maxComponent = sample[0]; + if(sample[1] > maxComponent) + maxComponent = sample[1]; + if(sample[2] > maxComponent) + maxComponent = sample[2]; + + if(maxComponent < 1e-32) + { + rgbe[0] = 0; + rgbe[1] = 0; + rgbe[2] = 0; + rgbe[3] = 0; + } + else + { +#if 0 + maxComponent = frexp(maxComponent, &e) * 255.0 / maxComponent; + rgbe[0] = (unsigned char) (sample[0] * maxComponent); + rgbe[1] = (unsigned char) (sample[1] * maxComponent); + rgbe[2] = (unsigned char) (sample[2] * maxComponent); + rgbe[3] = (unsigned char) (e + 128); +#else + e = ceil(log(maxComponent) / log(2.0f));//ceil(log2(maxComponent)); + VectorScale(sample, 1.0 / pow(2.0f, e)/*exp2(e)*/, sample); + + rgbe[0] = (unsigned char) (sample[0] * 255); + rgbe[1] = (unsigned char) (sample[1] * 255); + rgbe[2] = (unsigned char) (sample[2] * 255); + rgbe[3] = (unsigned char) (e + 128); +#endif + } +} + + +void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4]) +{ + rgba16f[0] = FloatToHalf(color[0]); + rgba16f[1] = FloatToHalf(color[1]); + rgba16f[2] = FloatToHalf(color[2]); + rgba16f[3] = FloatToHalf(1.0f); +} + + +/* +=============== +R_LoadLightmaps + +=============== +*/ +#define DEFAULT_LIGHTMAP_SIZE 128 +#define MAX_LIGHTMAP_PAGES 2 +static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { + byte *buf, *buf_p; + dsurface_t *surf; + int len; + byte *image; + int i, j, numLightmaps, textureInternalFormat = 0; + float maxIntensity = 0; + double sumIntensity = 0; + + len = l->filelen; + if ( !len ) { + return; + } + buf = fileBase + l->fileofs; + + // we are about to upload textures + R_IssuePendingRenderCommands(); + + tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; + numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); + + // check for deluxe mapping + if (numLightmaps <= 1) + { + tr.worldDeluxeMapping = qfalse; + } + else + { + tr.worldDeluxeMapping = qtrue; + for( i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); + i < surfs->filelen / sizeof(dsurface_t); i++, surf++ ) { + int lightmapNum = LittleLong( surf->lightmapNum ); + + if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { + tr.worldDeluxeMapping = qfalse; + break; + } + } + } + + image = ri.Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); + + if (tr.worldDeluxeMapping) + numLightmaps >>= 1; + + if(numLightmaps == 1) + { + //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason. + //this avoids this, but isn't the correct solution. + numLightmaps++; + } + else if (r_mergeLightmaps->integer && numLightmaps >= 1024 ) + { + // FIXME: fat light maps don't support more than 1024 light maps + ri.Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n"); + numLightmaps = 1024; + } + + // use fat lightmaps of an appropriate size + if (r_mergeLightmaps->integer) + { + tr.fatLightmapSize = 512; + tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize; + + // at most MAX_LIGHTMAP_PAGES + while (tr.fatLightmapStep * tr.fatLightmapStep * MAX_LIGHTMAP_PAGES < numLightmaps && tr.fatLightmapSize != glConfig.maxTextureSize ) + { + tr.fatLightmapSize <<= 1; + tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize; + } + + tr.numLightmaps = numLightmaps / (tr.fatLightmapStep * tr.fatLightmapStep); + + if (numLightmaps % (tr.fatLightmapStep * tr.fatLightmapStep) != 0) + tr.numLightmaps++; + } + else + { + tr.numLightmaps = numLightmaps; + } + + tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + + if (tr.worldDeluxeMapping) + { + tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + } + + if (r_hdr->integer && glRefConfig.textureFloat && glRefConfig.halfFloatPixel) + textureInternalFormat = GL_RGBA16F_ARB; + + if (r_mergeLightmaps->integer) + { + for (i = 0; i < tr.numLightmaps; i++) + { + tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat ); + + if (tr.worldDeluxeMapping) + { + tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); + } + } + } + + for(i = 0; i < numLightmaps; i++) + { + int xoff = 0, yoff = 0; + int lightmapnum = i; + // expand the 24 bit on-disk to 32 bit + + if (r_mergeLightmaps->integer) + { + int lightmaponpage = i % (tr.fatLightmapStep * tr.fatLightmapStep); + xoff = (lightmaponpage % tr.fatLightmapStep) * tr.lightmapSize; + yoff = (lightmaponpage / tr.fatLightmapStep) * tr.lightmapSize; + + lightmapnum /= (tr.fatLightmapStep * tr.fatLightmapStep); + } + + // if (tr.worldLightmapping) + { + char filename[MAX_QPATH]; + byte *hdrLightmap = NULL; + float lightScale = 1.0f; + int size = 0; + + // look for hdr lightmaps + if (r_hdr->integer) + { + Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", s_worldData.baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + + size = ri.FS_ReadFile(filename, (void **)&hdrLightmap); + } + + if (hdrLightmap) + { + byte *p = hdrLightmap; + //ri.Printf(PRINT_ALL, "found!\n"); + + /* FIXME: don't just skip over this header and actually parse it */ + while (size && !(*p == '\n' && *(p+1) == '\n')) + { + size--; + p++; + } + + if (!size) + ri.Error(ERR_DROP, "Bad header for %s!", filename); + + size -= 2; + p += 2; + + while (size && !(*p == '\n')) + { + size--; + p++; + } + + size--; + p++; + + buf_p = (byte *)p; + +#if 0 // HDRFILE_RGBE + if (size != tr.lightmapSize * tr.lightmapSize * 4) + ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); +#else // HDRFILE_FLOAT + if (size != tr.lightmapSize * tr.lightmapSize * 12) + ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); +#endif + } + else + { + if (tr.worldDeluxeMapping) + buf_p = buf + (i * 2) * tr.lightmapSize * tr.lightmapSize * 3; + else + buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3; + } + + lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits - 8); + + for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) + { + if (r_hdr->integer) + { + float color[3]; + + if (hdrLightmap) + { +#if 0 // HDRFILE_RGBE + float exponent = exp2(buf_p[j*4+3] - 128); + + color[0] = buf_p[j*4+0] * exponent; + color[1] = buf_p[j*4+1] * exponent; + color[2] = buf_p[j*4+2] * exponent; +#else // HDRFILE_FLOAT + memcpy(color, &buf_p[j*12], 12); + + color[0] = LittleFloat(color[0]); + color[1] = LittleFloat(color[1]); + color[2] = LittleFloat(color[2]); +#endif + } + else + { + //hack: convert LDR lightmap to HDR one + color[0] = (buf_p[j*3+0] + 1.0f); + color[1] = (buf_p[j*3+1] + 1.0f); + color[2] = (buf_p[j*3+2] + 1.0f); + + // if under an arbitrary value (say 12) grey it out + // this prevents weird splotches in dimly lit areas + if (color[0] + color[1] + color[2] < 12.0f) + { + float avg = (color[0] + color[1] + color[2]) * 0.3333f; + color[0] = avg; + color[1] = avg; + color[2] = avg; + } + } + + VectorScale(color, lightScale, color); + + if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel) + ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); + else + ColorToRGBE(color, &image[j*4]); + } + else + { + if ( r_lightmap->integer == 2 ) + { // color code by intensity as development tool (FIXME: check range) + float r = buf_p[j*3+0]; + float g = buf_p[j*3+1]; + float b = buf_p[j*3+2]; + float intensity; + float out[3] = {0.0, 0.0, 0.0}; + + intensity = 0.33f * r + 0.685f * g + 0.063f * b; + + if ( intensity > 255 ) + intensity = 1.0f; + else + intensity /= 255.0f; + + if ( intensity > maxIntensity ) + maxIntensity = intensity; + + HSVtoRGB( intensity, 1.00, 0.50, out ); + + image[j*4+0] = out[0] * 255; + image[j*4+1] = out[1] * 255; + image[j*4+2] = out[2] * 255; + image[j*4+3] = 255; + + sumIntensity += intensity; + } + else + { + R_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] ); + image[j*4+3] = 255; + } + } + } + + if (r_mergeLightmaps->integer) + R_UpdateSubImage(tr.lightmaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize); + else + tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat ); + + if (hdrLightmap) + ri.FS_FreeFile(hdrLightmap); + } + + if (tr.worldDeluxeMapping) + { + buf_p = buf + (i * 2 + 1) * tr.lightmapSize * tr.lightmapSize * 3; + + for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) { + image[j*4+0] = buf_p[j*3+0]; + image[j*4+1] = buf_p[j*3+1]; + image[j*4+2] = buf_p[j*3+2]; + + // make 0,0,0 into 127,127,127 + if ((image[j*4+0] == 0) && (image[j*4+0] == 0) && (image[j*4+2] == 0)) + { + image[j*4+0] = + image[j*4+1] = + image[j*4+2] = 127; + } + + image[j*4+3] = 255; + } + + if (r_mergeLightmaps->integer) + { + R_UpdateSubImage(tr.deluxemaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize ); + } + else + { + tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); + } + } + } + + if ( r_lightmap->integer == 2 ) { + ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); + } + + ri.Free(image); +} + + +static float FatPackU(float input, int lightmapnum) +{ + if (lightmapnum < 0) + return input; + + if (tr.worldDeluxeMapping) + lightmapnum >>= 1; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + if(tr.fatLightmapSize > 0) + { + int x = lightmapnum % tr.fatLightmapStep; + + return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x); + } + + return input; +} + +static float FatPackV(float input, int lightmapnum) +{ + if (lightmapnum < 0) + return input; + + if (tr.worldDeluxeMapping) + lightmapnum >>= 1; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + if(tr.fatLightmapSize > 0) + { + int y = lightmapnum / tr.fatLightmapStep; + + return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y); + } + + return input; +} + + +static int FatLightmap(int lightmapnum) +{ + if (lightmapnum < 0) + return lightmapnum; + + if (tr.worldDeluxeMapping) + lightmapnum >>= 1; + + if (tr.fatLightmapSize > 0) + { + return lightmapnum / (tr.fatLightmapStep * tr.fatLightmapStep); + } + + return lightmapnum; +} + +/* +================= +RE_SetWorldVisData + +This is called by the clipmodel subsystem so we can share the 1.8 megs of +space in big maps... +================= +*/ +void RE_SetWorldVisData( const byte *vis ) { + tr.externalVisData = vis; +} + + +/* +================= +R_LoadVisibility +================= +*/ +static void R_LoadVisibility( lump_t *l ) { + int len; + byte *buf; + + len = ( s_worldData.numClusters + 63 ) & ~63; + s_worldData.novis = ri.Hunk_Alloc( len, h_low ); + Com_Memset( s_worldData.novis, 0xff, len ); + + len = l->filelen; + if ( !len ) { + return; + } + buf = fileBase + l->fileofs; + + s_worldData.numClusters = LittleLong( ((int *)buf)[0] ); + s_worldData.clusterBytes = LittleLong( ((int *)buf)[1] ); + + // CM_Load should have given us the vis data to share, so + // we don't need to allocate another copy + if ( tr.externalVisData ) { + s_worldData.vis = tr.externalVisData; + } else { + byte *dest; + + dest = ri.Hunk_Alloc( len - 8, h_low ); + Com_Memcpy( dest, buf + 8, len - 8 ); + s_worldData.vis = dest; + } +} + +//=============================================================================== + + +/* +=============== +ShaderForShaderNum +=============== +*/ +static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { + shader_t *shader; + dshader_t *dsh; + + int _shaderNum = LittleLong( shaderNum ); + if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) { + ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); + } + dsh = &s_worldData.shaders[ _shaderNum ]; + + if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) { + lightmapNum = LIGHTMAP_BY_VERTEX; + } + + if ( r_fullbright->integer ) { + lightmapNum = LIGHTMAP_WHITEIMAGE; + } + + shader = R_FindShader( dsh->shader, lightmapNum, qtrue ); + + // if the shader had errors, just use default shader + if ( shader->defaultShader ) { + return tr.defaultShader; + } + + return shader; +} + +/* +=============== +ParseFace +=============== +*/ +static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { + int i, j; + srfSurfaceFace_t *cv; + srfTriangle_t *tri; + int numVerts, numTriangles, badTriangles; + int realLightmapNum; + + realLightmapNum = LittleLong( ds->lightmapNum ); + + // get fog volume + surf->fogIndex = LittleLong( ds->fogNum ) + 1; + + // get shader value + surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); + if ( r_singleShader->integer && !surf->shader->isSky ) { + surf->shader = tr.defaultShader; + } + + numVerts = LittleLong(ds->numVerts); + if (numVerts > MAX_FACE_POINTS) { + ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); + numVerts = MAX_FACE_POINTS; + surf->shader = tr.defaultShader; + } + + numTriangles = LittleLong(ds->numIndexes) / 3; + + //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); + cv = (void *)surf->data; + cv->surfaceType = SF_FACE; + + cv->numTriangles = numTriangles; + cv->triangles = ri.Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + + cv->numVerts = numVerts; + cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + + // copy vertexes + surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; + ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); + verts += LittleLong(ds->firstVert); + for(i = 0; i < numVerts; i++) + { + vec4_t color; + + for(j = 0; j < 3; j++) + { + cv->verts[i].xyz[j] = LittleFloat(verts[i].xyz[j]); + cv->verts[i].normal[j] = LittleFloat(verts[i].normal[j]); + } + AddPointToBounds(cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); + for(j = 0; j < 2; j++) + { + cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); + //cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); + } + cv->verts[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0]), realLightmapNum); + cv->verts[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[1]), realLightmapNum); + + if (hdrVertColors) + { + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + } + else + { + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[0] + 1.0f; + color[1] = verts[i].color[1] + 1.0f; + color[2] = verts[i].color[2] + 1.0f; + } + else + { + color[0] = verts[i].color[0]; + color[1] = verts[i].color[1]; + color[2] = verts[i].color[2]; + } + + } + color[3] = verts[i].color[3] / 255.0f; + + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); + } + + // copy triangles + badTriangles = 0; + indexes += LittleLong(ds->firstIndex); + for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + tri->indexes[j] = LittleLong(indexes[i * 3 + j]); + + if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) + { + ri.Error(ERR_DROP, "Bad index in face surface"); + } + } + + if ((tri->indexes[0] == tri->indexes[1]) || (tri->indexes[1] == tri->indexes[2]) || (tri->indexes[0] == tri->indexes[2])) + { + tri--; + badTriangles++; + } + } + + if (badTriangles) + { + ri.Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); + cv->numTriangles -= badTriangles; + } + + // take the plane information from the lightmap vector + for ( i = 0 ; i < 3 ; i++ ) { + cv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); + } + cv->plane.dist = DotProduct( cv->verts[0].xyz, cv->plane.normal ); + SetPlaneSignbits( &cv->plane ); + cv->plane.type = PlaneTypeForNormal( cv->plane.normal ); + surf->cullinfo.plane = cv->plane; + + surf->data = (surfaceType_t *)cv; + +#ifdef USE_VERT_TANGENT_SPACE + // Calculate tangent spaces + { + srfVert_t *dv[3]; + + for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + { + dv[0] = &cv->verts[tri->indexes[0]]; + dv[1] = &cv->verts[tri->indexes[1]]; + dv[2] = &cv->verts[tri->indexes[2]]; + + R_CalcTangentVectors(dv); + } + } +#endif +} + + +/* +=============== +ParseMesh +=============== +*/ +static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { + srfGridMesh_t *grid; + int i, j; + int width, height, numPoints; + srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE]; + vec3_t bounds[2]; + vec3_t tmpVec; + static surfaceType_t skipData = SF_SKIP; + int realLightmapNum; + + realLightmapNum = LittleLong( ds->lightmapNum ); + + // get fog volume + surf->fogIndex = LittleLong( ds->fogNum ) + 1; + + // get shader value + surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); + if ( r_singleShader->integer && !surf->shader->isSky ) { + surf->shader = tr.defaultShader; + } + + // we may have a nodraw surface, because they might still need to + // be around for movement clipping + if ( s_worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) { + surf->data = &skipData; + return; + } + + width = LittleLong( ds->patchWidth ); + height = LittleLong( ds->patchHeight ); + + if(width < 0 || width > MAX_PATCH_SIZE || height < 0 || height > MAX_PATCH_SIZE) + ri.Error(ERR_DROP, "ParseMesh: bad size"); + + verts += LittleLong( ds->firstVert ); + numPoints = width * height; + for(i = 0; i < numPoints; i++) + { + vec4_t color; + + for(j = 0; j < 3; j++) + { + points[i].xyz[j] = LittleFloat(verts[i].xyz[j]); + points[i].normal[j] = LittleFloat(verts[i].normal[j]); + } + + for(j = 0; j < 2; j++) + { + points[i].st[j] = LittleFloat(verts[i].st[j]); + //points[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); + } + points[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0]), realLightmapNum); + points[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[1]), realLightmapNum); + + if (hdrVertColors) + { + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + } + else + { + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[0] + 1.0f; + color[1] = verts[i].color[1] + 1.0f; + color[2] = verts[i].color[2] + 1.0f; + } + else + { + color[0] = verts[i].color[0]; + color[1] = verts[i].color[1]; + color[2] = verts[i].color[2]; + } + } + color[3] = verts[i].color[3] / 255.0f; + + R_ColorShiftLightingFloats( color, points[i].vertexColors, 1.0f / 255.0f ); + } + + // pre-tesseleate + grid = R_SubdividePatchToGrid( width, height, points ); + surf->data = (surfaceType_t *)grid; + + // copy the level of detail origin, which is the center + // of the group of all curves that must subdivide the same + // to avoid cracking + for ( i = 0 ; i < 3 ; i++ ) { + bounds[0][i] = LittleFloat( ds->lightmapVecs[0][i] ); + bounds[1][i] = LittleFloat( ds->lightmapVecs[1][i] ); + } + VectorAdd( bounds[0], bounds[1], bounds[1] ); + VectorScale( bounds[1], 0.5f, grid->lodOrigin ); + VectorSubtract( bounds[0], grid->lodOrigin, tmpVec ); + grid->lodRadius = VectorLength( tmpVec ); +} + +/* +=============== +ParseTriSurf +=============== +*/ +static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { + srfTriangles_t *cv; + srfTriangle_t *tri; + int i, j; + int numVerts, numTriangles, badTriangles; + + // get fog volume + surf->fogIndex = LittleLong( ds->fogNum ) + 1; + + // get shader + surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); + if ( r_singleShader->integer && !surf->shader->isSky ) { + surf->shader = tr.defaultShader; + } + + numVerts = LittleLong(ds->numVerts); + numTriangles = LittleLong(ds->numIndexes) / 3; + + //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); + cv = (void *)surf->data; + cv->surfaceType = SF_TRIANGLES; + + cv->numTriangles = numTriangles; + cv->triangles = ri.Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + + cv->numVerts = numVerts; + cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + + surf->data = (surfaceType_t *) cv; + + // copy vertexes + surf->cullinfo.type = CULLINFO_BOX; + ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); + verts += LittleLong(ds->firstVert); + for(i = 0; i < numVerts; i++) + { + vec4_t color; + + for(j = 0; j < 3; j++) + { + cv->verts[i].xyz[j] = LittleFloat(verts[i].xyz[j]); + cv->verts[i].normal[j] = LittleFloat(verts[i].normal[j]); + } + + AddPointToBounds( cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1] ); + + for(j = 0; j < 2; j++) + { + cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); + cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); + } + + if (hdrVertColors) + { + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + } + else + { + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[0] + 1.0f; + color[1] = verts[i].color[1] + 1.0f; + color[2] = verts[i].color[2] + 1.0f; + } + else + { + color[0] = verts[i].color[0]; + color[1] = verts[i].color[1]; + color[2] = verts[i].color[2]; + } + } + color[3] = verts[i].color[3] / 255.0f; + + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); + } + + // copy triangles + badTriangles = 0; + indexes += LittleLong(ds->firstIndex); + for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + tri->indexes[j] = LittleLong(indexes[i * 3 + j]); + + if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) + { + ri.Error(ERR_DROP, "Bad index in face surface"); + } + } + + if ((tri->indexes[0] == tri->indexes[1]) || (tri->indexes[1] == tri->indexes[2]) || (tri->indexes[0] == tri->indexes[2])) + { + tri--; + badTriangles++; + } + } + + if (badTriangles) + { + ri.Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); + cv->numTriangles -= badTriangles; + } + +#ifdef USE_VERT_TANGENT_SPACE + // Calculate tangent spaces + { + srfVert_t *dv[3]; + + for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + { + dv[0] = &cv->verts[tri->indexes[0]]; + dv[1] = &cv->verts[tri->indexes[1]]; + dv[2] = &cv->verts[tri->indexes[2]]; + + R_CalcTangentVectors(dv); + } + } +#endif +} + +/* +=============== +ParseFlare +=============== +*/ +static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes ) { + srfFlare_t *flare; + int i; + + // get fog volume + surf->fogIndex = LittleLong( ds->fogNum ) + 1; + + // get shader + surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); + if ( r_singleShader->integer && !surf->shader->isSky ) { + surf->shader = tr.defaultShader; + } + + //flare = ri.Hunk_Alloc( sizeof( *flare ), h_low ); + flare = (void *)surf->data; + flare->surfaceType = SF_FLARE; + + surf->data = (surfaceType_t *)flare; + + for ( i = 0 ; i < 3 ; i++ ) { + flare->origin[i] = LittleFloat( ds->lightmapOrigin[i] ); + flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] ); + flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); + } +} + + +/* +================= +R_MergedWidthPoints + +returns true if there are grid points merged on a width edge +================= +*/ +int R_MergedWidthPoints(srfGridMesh_t *grid, int offset) { + int i, j; + + for (i = 1; i < grid->width-1; i++) { + for (j = i + 1; j < grid->width-1; j++) { + if ( fabs(grid->verts[i + offset].xyz[0] - grid->verts[j + offset].xyz[0]) > .1) continue; + if ( fabs(grid->verts[i + offset].xyz[1] - grid->verts[j + offset].xyz[1]) > .1) continue; + if ( fabs(grid->verts[i + offset].xyz[2] - grid->verts[j + offset].xyz[2]) > .1) continue; + return qtrue; + } + } + return qfalse; +} + +/* +================= +R_MergedHeightPoints + +returns true if there are grid points merged on a height edge +================= +*/ +int R_MergedHeightPoints(srfGridMesh_t *grid, int offset) { + int i, j; + + for (i = 1; i < grid->height-1; i++) { + for (j = i + 1; j < grid->height-1; j++) { + if ( fabs(grid->verts[grid->width * i + offset].xyz[0] - grid->verts[grid->width * j + offset].xyz[0]) > .1) continue; + if ( fabs(grid->verts[grid->width * i + offset].xyz[1] - grid->verts[grid->width * j + offset].xyz[1]) > .1) continue; + if ( fabs(grid->verts[grid->width * i + offset].xyz[2] - grid->verts[grid->width * j + offset].xyz[2]) > .1) continue; + return qtrue; + } + } + return qfalse; +} + +/* +================= +R_FixSharedVertexLodError_r + +NOTE: never sync LoD through grid edges with merged points! + +FIXME: write generalized version that also avoids cracks between a patch and one that meets half way? +================= +*/ +void R_FixSharedVertexLodError_r( int start, srfGridMesh_t *grid1 ) { + int j, k, l, m, n, offset1, offset2, touch; + srfGridMesh_t *grid2; + + for ( j = start; j < s_worldData.numsurfaces; j++ ) { + // + grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data; + // if this surface is not a grid + if ( grid2->surfaceType != SF_GRID ) continue; + // if the LOD errors are already fixed for this patch + if ( grid2->lodFixed == 2 ) continue; + // grids in the same LOD group should have the exact same lod radius + if ( grid1->lodRadius != grid2->lodRadius ) continue; + // grids in the same LOD group should have the exact same lod origin + if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue; + if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue; + if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue; + // + touch = qfalse; + for (n = 0; n < 2; n++) { + // + if (n) offset1 = (grid1->height-1) * grid1->width; + else offset1 = 0; + if (R_MergedWidthPoints(grid1, offset1)) continue; + for (k = 1; k < grid1->width-1; k++) { + for (m = 0; m < 2; m++) { + + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + if (R_MergedWidthPoints(grid2, offset2)) continue; + for ( l = 1; l < grid2->width-1; l++) { + // + if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue; + if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue; + if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue; + // ok the points are equal and should have the same lod error + grid2->widthLodError[l] = grid1->widthLodError[k]; + touch = qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (m) offset2 = grid2->width-1; + else offset2 = 0; + if (R_MergedHeightPoints(grid2, offset2)) continue; + for ( l = 1; l < grid2->height-1; l++) { + // + if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue; + if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue; + if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue; + // ok the points are equal and should have the same lod error + grid2->heightLodError[l] = grid1->widthLodError[k]; + touch = qtrue; + } + } + } + } + for (n = 0; n < 2; n++) { + // + if (n) offset1 = grid1->width-1; + else offset1 = 0; + if (R_MergedHeightPoints(grid1, offset1)) continue; + for (k = 1; k < grid1->height-1; k++) { + for (m = 0; m < 2; m++) { + + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + if (R_MergedWidthPoints(grid2, offset2)) continue; + for ( l = 1; l < grid2->width-1; l++) { + // + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue; + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue; + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue; + // ok the points are equal and should have the same lod error + grid2->widthLodError[l] = grid1->heightLodError[k]; + touch = qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (m) offset2 = grid2->width-1; + else offset2 = 0; + if (R_MergedHeightPoints(grid2, offset2)) continue; + for ( l = 1; l < grid2->height-1; l++) { + // + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue; + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue; + if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue; + // ok the points are equal and should have the same lod error + grid2->heightLodError[l] = grid1->heightLodError[k]; + touch = qtrue; + } + } + } + } + if (touch) { + grid2->lodFixed = 2; + R_FixSharedVertexLodError_r ( start, grid2 ); + //NOTE: this would be correct but makes things really slow + //grid2->lodFixed = 1; + } + } +} + +/* +================= +R_FixSharedVertexLodError + +This function assumes that all patches in one group are nicely stitched together for the highest LoD. +If this is not the case this function will still do its job but won't fix the highest LoD cracks. +================= +*/ +void R_FixSharedVertexLodError( void ) { + int i; + srfGridMesh_t *grid1; + + for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + // + grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data; + // if this surface is not a grid + if ( grid1->surfaceType != SF_GRID ) + continue; + // + if ( grid1->lodFixed ) + continue; + // + grid1->lodFixed = 2; + // recursively fix other patches in the same LOD group + R_FixSharedVertexLodError_r( i + 1, grid1); + } +} + + +/* +=============== +R_StitchPatches +=============== +*/ +int R_StitchPatches( int grid1num, int grid2num ) { + float *v1, *v2; + srfGridMesh_t *grid1, *grid2; + int k, l, m, n, offset1, offset2, row, column; + + grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data; + grid2 = (srfGridMesh_t *) s_worldData.surfaces[grid2num].data; + for (n = 0; n < 2; n++) { + // + if (n) offset1 = (grid1->height-1) * grid1->width; + else offset1 = 0; + if (R_MergedWidthPoints(grid1, offset1)) + continue; + for (k = 0; k < grid1->width-2; k += 2) { + + for (m = 0; m < 2; m++) { + + if ( grid2->width >= MAX_GRID_SIZE ) + break; + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + for ( l = 0; l < grid2->width-1; l++) { + // + v1 = grid1->verts[k + offset1].xyz; + v2 = grid2->verts[l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[k + 2 + offset1].xyz; + v2 = grid2->verts[l + 1 + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[l + offset2].xyz; + v2 = grid2->verts[l + 1 + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert column into grid2 right after after column l + if (m) row = grid2->height-1; + else row = 0; + grid2 = R_GridInsertColumn( grid2, l+1, row, + grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (grid2->height >= MAX_GRID_SIZE) + break; + if (m) offset2 = grid2->width-1; + else offset2 = 0; + for ( l = 0; l < grid2->height-1; l++) { + // + v1 = grid1->verts[k + offset1].xyz; + v2 = grid2->verts[grid2->width * l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[k + 2 + offset1].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[grid2->width * l + offset2].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert row into grid2 right after after row l + if (m) column = grid2->width-1; + else column = 0; + grid2 = R_GridInsertRow( grid2, l+1, column, + grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + } + } + for (n = 0; n < 2; n++) { + // + if (n) offset1 = grid1->width-1; + else offset1 = 0; + if (R_MergedHeightPoints(grid1, offset1)) + continue; + for (k = 0; k < grid1->height-2; k += 2) { + for (m = 0; m < 2; m++) { + + if ( grid2->width >= MAX_GRID_SIZE ) + break; + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + for ( l = 0; l < grid2->width-1; l++) { + // + v1 = grid1->verts[grid1->width * k + offset1].xyz; + v2 = grid2->verts[l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz; + v2 = grid2->verts[l + 1 + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[l + offset2].xyz; + v2 = grid2->verts[(l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert column into grid2 right after after column l + if (m) row = grid2->height-1; + else row = 0; + grid2 = R_GridInsertColumn( grid2, l+1, row, + grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (grid2->height >= MAX_GRID_SIZE) + break; + if (m) offset2 = grid2->width-1; + else offset2 = 0; + for ( l = 0; l < grid2->height-1; l++) { + // + v1 = grid1->verts[grid1->width * k + offset1].xyz; + v2 = grid2->verts[grid2->width * l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[grid2->width * l + offset2].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert row into grid2 right after after row l + if (m) column = grid2->width-1; + else column = 0; + grid2 = R_GridInsertRow( grid2, l+1, column, + grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + } + } + for (n = 0; n < 2; n++) { + // + if (n) offset1 = (grid1->height-1) * grid1->width; + else offset1 = 0; + if (R_MergedWidthPoints(grid1, offset1)) + continue; + for (k = grid1->width-1; k > 1; k -= 2) { + + for (m = 0; m < 2; m++) { + + if ( grid2->width >= MAX_GRID_SIZE ) + break; + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + for ( l = 0; l < grid2->width-1; l++) { + // + v1 = grid1->verts[k + offset1].xyz; + v2 = grid2->verts[l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[k - 2 + offset1].xyz; + v2 = grid2->verts[l + 1 + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[l + offset2].xyz; + v2 = grid2->verts[(l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert column into grid2 right after after column l + if (m) row = grid2->height-1; + else row = 0; + grid2 = R_GridInsertColumn( grid2, l+1, row, + grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (grid2->height >= MAX_GRID_SIZE) + break; + if (m) offset2 = grid2->width-1; + else offset2 = 0; + for ( l = 0; l < grid2->height-1; l++) { + // + v1 = grid1->verts[k + offset1].xyz; + v2 = grid2->verts[grid2->width * l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[k - 2 + offset1].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[grid2->width * l + offset2].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert row into grid2 right after after row l + if (m) column = grid2->width-1; + else column = 0; + grid2 = R_GridInsertRow( grid2, l+1, column, + grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); + if (!grid2) + break; + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + } + } + for (n = 0; n < 2; n++) { + // + if (n) offset1 = grid1->width-1; + else offset1 = 0; + if (R_MergedHeightPoints(grid1, offset1)) + continue; + for (k = grid1->height-1; k > 1; k -= 2) { + for (m = 0; m < 2; m++) { + + if ( grid2->width >= MAX_GRID_SIZE ) + break; + if (m) offset2 = (grid2->height-1) * grid2->width; + else offset2 = 0; + for ( l = 0; l < grid2->width-1; l++) { + // + v1 = grid1->verts[grid1->width * k + offset1].xyz; + v2 = grid2->verts[l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz; + v2 = grid2->verts[l + 1 + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[l + offset2].xyz; + v2 = grid2->verts[(l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert column into grid2 right after after column l + if (m) row = grid2->height-1; + else row = 0; + grid2 = R_GridInsertColumn( grid2, l+1, row, + grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + for (m = 0; m < 2; m++) { + + if (grid2->height >= MAX_GRID_SIZE) + break; + if (m) offset2 = grid2->width-1; + else offset2 = 0; + for ( l = 0; l < grid2->height-1; l++) { + // + v1 = grid1->verts[grid1->width * k + offset1].xyz; + v2 = grid2->verts[grid2->width * l + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + + v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) > .1) + continue; + if ( fabs(v1[1] - v2[1]) > .1) + continue; + if ( fabs(v1[2] - v2[2]) > .1) + continue; + // + v1 = grid2->verts[grid2->width * l + offset2].xyz; + v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz; + if ( fabs(v1[0] - v2[0]) < .01 && + fabs(v1[1] - v2[1]) < .01 && + fabs(v1[2] - v2[2]) < .01) + continue; + // + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + // insert row into grid2 right after after row l + if (m) column = grid2->width-1; + else column = 0; + grid2 = R_GridInsertRow( grid2, l+1, column, + grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); + grid2->lodStitched = qfalse; + s_worldData.surfaces[grid2num].data = (void *) grid2; + return qtrue; + } + } + } + } + return qfalse; +} + +/* +=============== +R_TryStitchPatch + +This function will try to stitch patches in the same LoD group together for the highest LoD. + +Only single missing vertice cracks will be fixed. + +Vertices will be joined at the patch side a crack is first found, at the other side +of the patch (on the same row or column) the vertices will not be joined and cracks +might still appear at that side. +=============== +*/ +int R_TryStitchingPatch( int grid1num ) { + int j, numstitches; + srfGridMesh_t *grid1, *grid2; + + numstitches = 0; + grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data; + for ( j = 0; j < s_worldData.numsurfaces; j++ ) { + // + grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data; + // if this surface is not a grid + if ( grid2->surfaceType != SF_GRID ) continue; + // grids in the same LOD group should have the exact same lod radius + if ( grid1->lodRadius != grid2->lodRadius ) continue; + // grids in the same LOD group should have the exact same lod origin + if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue; + if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue; + if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue; + // + while (R_StitchPatches(grid1num, j)) + { + numstitches++; + } + } + return numstitches; +} + +/* +=============== +R_StitchAllPatches +=============== +*/ +void R_StitchAllPatches( void ) { + int i, stitched, numstitches; + srfGridMesh_t *grid1; + + numstitches = 0; + do + { + stitched = qfalse; + for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + // + grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data; + // if this surface is not a grid + if ( grid1->surfaceType != SF_GRID ) + continue; + // + if ( grid1->lodStitched ) + continue; + // + grid1->lodStitched = qtrue; + stitched = qtrue; + // + numstitches += R_TryStitchingPatch( i ); + } + } + while (stitched); + ri.Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); +} + +/* +=============== +R_MovePatchSurfacesToHunk +=============== +*/ +void R_MovePatchSurfacesToHunk(void) { + int i, size; + srfGridMesh_t *grid, *hunkgrid; + + for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + // + grid = (srfGridMesh_t *) s_worldData.surfaces[i].data; + // if this surface is not a grid + if ( grid->surfaceType != SF_GRID ) + continue; + // + size = sizeof(*grid); + hunkgrid = ri.Hunk_Alloc(size, h_low); + Com_Memcpy(hunkgrid, grid, size); + + hunkgrid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low ); + Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 ); + + hunkgrid->heightLodError = ri.Hunk_Alloc( grid->height * 4, h_low ); + Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 ); + + hunkgrid->numTriangles = grid->numTriangles; + hunkgrid->triangles = ri.Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); + Com_Memcpy(hunkgrid->triangles, grid->triangles, grid->numTriangles * sizeof(srfTriangle_t)); + + hunkgrid->numVerts = grid->numVerts; + hunkgrid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + Com_Memcpy(hunkgrid->verts, grid->verts, grid->numVerts * sizeof(srfVert_t)); + + R_FreeSurfaceGridMesh( grid ); + + s_worldData.surfaces[i].data = (void *) hunkgrid; + } +} + + +/* +================= +BSPSurfaceCompare +compare function for qsort() +================= +*/ +static int BSPSurfaceCompare(const void *a, const void *b) +{ + msurface_t *aa, *bb; + + aa = *(msurface_t **) a; + bb = *(msurface_t **) b; + + // shader first + if(aa->shader->sortedIndex < bb->shader->sortedIndex) + return -1; + + else if(aa->shader->sortedIndex > bb->shader->sortedIndex) + return 1; + + // by fogIndex + if(aa->fogIndex < bb->fogIndex) + return -1; + + else if(aa->fogIndex > bb->fogIndex) + return 1; + + return 0; +} + + +static void CopyVert(const srfVert_t * in, srfVert_t * out) +{ + int j; + + for(j = 0; j < 3; j++) + { + out->xyz[j] = in->xyz[j]; +#ifdef USE_VERT_TANGENT_SPACE + out->tangent[j] = in->tangent[j]; + out->bitangent[j] = in->bitangent[j]; +#endif + out->normal[j] = in->normal[j]; + out->lightdir[j] = in->lightdir[j]; + } + + for(j = 0; j < 2; j++) + { + out->st[j] = in->st[j]; + out->lightmap[j] = in->lightmap[j]; + } + + for(j = 0; j < 4; j++) + { + out->vertexColors[j] = in->vertexColors[j]; + } +} + + +/* +=============== +R_CreateWorldVBO +=============== +*/ +static void R_CreateWorldVBO(void) +{ + int i, j, k; + + int numVerts; + srfVert_t *verts; + + int numTriangles; + srfTriangle_t *triangles; + + int numSurfaces; + msurface_t *surface; + msurface_t **surfacesSorted; + + int startTime, endTime; + + startTime = ri.Milliseconds(); + + numVerts = 0; + numTriangles = 0; + numSurfaces = 0; + for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) + { + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data; + + if(face->numVerts) + numVerts += face->numVerts; + + if(face->numTriangles) + numTriangles += face->numTriangles; + + numSurfaces++; + } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *grid = (srfGridMesh_t *) surface->data; + + if(grid->numVerts) + numVerts += grid->numVerts; + + if(grid->numTriangles) + numTriangles += grid->numTriangles; + + numSurfaces++; + } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *tri = (srfTriangles_t *) surface->data; + + if(tri->numVerts) + numVerts += tri->numVerts; + + if(tri->numTriangles) + numTriangles += tri->numTriangles; + + numSurfaces++; + } + } + + if(!numVerts || !numTriangles) + return; + + ri.Printf(PRINT_ALL, "...calculating world VBO ( %i verts %i tris )\n", numVerts, numTriangles); + + // create arrays + + verts = ri.Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + + triangles = ri.Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); + + // presort surfaces + surfacesSorted = ri.Malloc(numSurfaces * sizeof(*surfacesSorted)); + + j = 0; + for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces; k++, surface++) + { + if(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES) + { + surfacesSorted[j++] = surface; + } + } + + qsort(surfacesSorted, numSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); + + // set up triangle indices + numVerts = 0; + numTriangles = 0; + for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) + { + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + + srf->firstIndex = numTriangles * 3; + + if(srf->numTriangles) + { + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } + } + + numTriangles += srf->numTriangles; + } + + if(srf->numVerts) + numVerts += srf->numVerts; + } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + + srf->firstIndex = numTriangles * 3; + + if(srf->numTriangles) + { + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } + } + + numTriangles += srf->numTriangles; + } + + if(srf->numVerts) + numVerts += srf->numVerts; + } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *srf = (srfTriangles_t *) surface->data; + + srf->firstIndex = numTriangles * 3; + + if(srf->numTriangles) + { + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } + } + + numTriangles += srf->numTriangles; + } + + if(srf->numVerts) + numVerts += srf->numVerts; + } + } + + // build vertices + numVerts = 0; + for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) + { + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + + srf->firstVert = numVerts; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } + + numVerts += srf->numVerts; + } + } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + + srf->firstVert = numVerts; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } + + numVerts += srf->numVerts; + } + } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *srf = (srfTriangles_t *) surface->data; + + srf->firstVert = numVerts; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } + + numVerts += srf->numVerts; + } + } + } + +#ifdef USE_VERT_TANGENT_SPACE + s_worldData.vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", 0), numVerts, verts, + ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_TANGENT | ATTR_BITANGENT | + ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); +#else + s_worldData.vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", 0), numVerts, verts, + ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | + ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); +#endif + + s_worldData.ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", 0), numTriangles, triangles, VBO_USAGE_STATIC); + + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "world VBO calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); + + // point triangle surfaces to world VBO + for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) + { + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = s_worldData.vbo; + srf->ibo = s_worldData.ibo; + } + } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = s_worldData.vbo; + srf->ibo = s_worldData.ibo; + } + } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *srf = (srfTriangles_t *) surface->data; + + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = s_worldData.vbo; + srf->ibo = s_worldData.ibo; + } + } + } + + + ri.Free(surfacesSorted); + + ri.Hunk_FreeTempMemory(triangles); + ri.Hunk_FreeTempMemory(verts); +} + +/* +=============== +R_LoadSurfaces +=============== +*/ +static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { + dsurface_t *in; + msurface_t *out; + drawVert_t *dv; + int *indexes; + int count; + int numFaces, numMeshes, numTriSurfs, numFlares; + int i; + float *hdrVertColors = NULL; + + numFaces = 0; + numMeshes = 0; + numTriSurfs = 0; + numFlares = 0; + + if (surfs->filelen % sizeof(*in)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + count = surfs->filelen / sizeof(*in); + + dv = (void *)(fileBase + verts->fileofs); + if (verts->filelen % sizeof(*dv)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + + indexes = (void *)(fileBase + indexLump->fileofs); + if ( indexLump->filelen % sizeof(*indexes)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + + out = ri.Hunk_Alloc ( count * sizeof(*out), h_low ); + + s_worldData.surfaces = out; + s_worldData.numsurfaces = count; + s_worldData.surfacesViewCount = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); + s_worldData.surfacesDlightBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); + s_worldData.surfacesPshadowBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); + + // load hdr vertex colors + if (r_hdr->integer) + { + char filename[MAX_QPATH]; + int size; + + Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", s_worldData.baseName); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + + size = ri.FS_ReadFile(filename, (void **)&hdrVertColors); + + if (hdrVertColors) + { + //ri.Printf(PRINT_ALL, "Found!\n"); + if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv))) + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); + } + } + + + // Two passes, allocate surfaces first, then load them full of data + // This ensures surfaces are close together to reduce L2 cache misses when using VBOs, + // which don't actually use the verts and tris + in = (void *)(fileBase + surfs->fileofs); + out = s_worldData.surfaces; + for ( i = 0 ; i < count ; i++, in++, out++ ) { + switch ( LittleLong( in->surfaceType ) ) { + case MST_PATCH: + // FIXME: do this + break; + case MST_TRIANGLE_SOUP: + out->data = ri.Hunk_Alloc( sizeof(srfTriangles_t), h_low); + break; + case MST_PLANAR: + out->data = ri.Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); + break; + case MST_FLARE: + out->data = ri.Hunk_Alloc( sizeof(srfFlare_t), h_low); + break; + default: + break; + } + } + + in = (void *)(fileBase + surfs->fileofs); + out = s_worldData.surfaces; + for ( i = 0 ; i < count ; i++, in++, out++ ) { + switch ( LittleLong( in->surfaceType ) ) { + case MST_PATCH: + ParseMesh ( in, dv, hdrVertColors, out ); + { + srfGridMesh_t *surface = (srfGridMesh_t *)out->data; + + out->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE; + VectorCopy(surface->meshBounds[0], out->cullinfo.bounds[0]); + VectorCopy(surface->meshBounds[1], out->cullinfo.bounds[1]); + VectorCopy(surface->localOrigin, out->cullinfo.localOrigin); + out->cullinfo.radius = surface->meshRadius; + } + numMeshes++; + break; + case MST_TRIANGLE_SOUP: + ParseTriSurf( in, dv, hdrVertColors, out, indexes ); + numTriSurfs++; + break; + case MST_PLANAR: + ParseFace( in, dv, hdrVertColors, out, indexes ); + numFaces++; + break; + case MST_FLARE: + ParseFlare( in, dv, out, indexes ); + { + out->cullinfo.type = CULLINFO_NONE; + } + numFlares++; + break; + default: + ri.Error( ERR_DROP, "Bad surfaceType" ); + } + } + + if (hdrVertColors) + { + ri.FS_FreeFile(hdrVertColors); + } + +#ifdef PATCH_STITCHING + R_StitchAllPatches(); +#endif + + R_FixSharedVertexLodError(); + +#ifdef PATCH_STITCHING + R_MovePatchSurfacesToHunk(); +#endif + + ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", + numFaces, numMeshes, numTriSurfs, numFlares ); +} + + + +/* +================= +R_LoadSubmodels +================= +*/ +static void R_LoadSubmodels( lump_t *l ) { + dmodel_t *in; + bmodel_t *out; + int i, j, count; + + in = (void *)(fileBase + l->fileofs); + if (l->filelen % sizeof(*in)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + count = l->filelen / sizeof(*in); + + s_worldData.numBModels = count; + s_worldData.bmodels = out = ri.Hunk_Alloc( count * sizeof(*out), h_low ); + + for ( i=0 ; itype = MOD_BRUSH; + model->bmodel = out; + Com_sprintf( model->name, sizeof( model->name ), "*%d", i ); + + for (j=0 ; j<3 ; j++) { + out->bounds[0][j] = LittleFloat (in->mins[j]); + out->bounds[1][j] = LittleFloat (in->maxs[j]); + } + + out->firstSurface = LittleLong( in->firstSurface ); + out->numSurfaces = LittleLong( in->numSurfaces ); + + if(i == 0) + { + // Add this for limiting VBO surface creation + s_worldData.numWorldSurfaces = out->numSurfaces; + } + } +} + + + +//================================================================== + +/* +================= +R_SetParent +================= +*/ +static void R_SetParent (mnode_t *node, mnode_t *parent) +{ + node->parent = parent; + if (node->contents != -1) + return; + R_SetParent (node->children[0], node); + R_SetParent (node->children[1], node); +} + +/* +================= +R_LoadNodesAndLeafs +================= +*/ +static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { + int i, j, p; + dnode_t *in; + dleaf_t *inLeaf; + mnode_t *out; + int numNodes, numLeafs; + + in = (void *)(fileBase + nodeLump->fileofs); + if (nodeLump->filelen % sizeof(dnode_t) || + leafLump->filelen % sizeof(dleaf_t) ) { + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + } + numNodes = nodeLump->filelen / sizeof(dnode_t); + numLeafs = leafLump->filelen / sizeof(dleaf_t); + + out = ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); + + s_worldData.nodes = out; + s_worldData.numnodes = numNodes + numLeafs; + s_worldData.numDecisionNodes = numNodes; + + // load nodes + for ( i=0 ; imins[j] = LittleLong (in->mins[j]); + out->maxs[j] = LittleLong (in->maxs[j]); + } + + p = LittleLong(in->planeNum); + out->plane = s_worldData.planes + p; + + out->contents = CONTENTS_NODE; // differentiate from leafs + + for (j=0 ; j<2 ; j++) + { + p = LittleLong (in->children[j]); + if (p >= 0) + out->children[j] = s_worldData.nodes + p; + else + out->children[j] = s_worldData.nodes + numNodes + (-1 - p); + } + } + + // load leafs + inLeaf = (void *)(fileBase + leafLump->fileofs); + for ( i=0 ; imins[j] = LittleLong (inLeaf->mins[j]); + out->maxs[j] = LittleLong (inLeaf->maxs[j]); + } + + out->cluster = LittleLong(inLeaf->cluster); + out->area = LittleLong(inLeaf->area); + + if ( out->cluster >= s_worldData.numClusters ) { + s_worldData.numClusters = out->cluster + 1; + } + + out->firstmarksurface = LittleLong(inLeaf->firstLeafSurface); + out->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces); + } + + // chain decendants + R_SetParent (s_worldData.nodes, NULL); +} + +//============================================================================= + +/* +================= +R_LoadShaders +================= +*/ +static void R_LoadShaders( lump_t *l ) { + int i, count; + dshader_t *in, *out; + + in = (void *)(fileBase + l->fileofs); + if (l->filelen % sizeof(*in)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + count = l->filelen / sizeof(*in); + out = ri.Hunk_Alloc ( count*sizeof(*out), h_low ); + + s_worldData.shaders = out; + s_worldData.numShaders = count; + + Com_Memcpy( out, in, count*sizeof(*out) ); + + for ( i=0 ; ifileofs); + if (l->filelen % sizeof(*in)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + count = l->filelen / sizeof(*in); + out = ri.Hunk_Alloc ( count*sizeof(*out), h_low); + + s_worldData.marksurfaces = out; + s_worldData.nummarksurfaces = count; + + for ( i=0 ; ifileofs); + if (l->filelen % sizeof(*in)) + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + count = l->filelen / sizeof(*in); + out = ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); + + s_worldData.planes = out; + s_worldData.numplanes = count; + + for ( i=0 ; inormal[j] = LittleFloat (in->normal[j]); + if (out->normal[j] < 0) { + bits |= 1<dist = LittleFloat (in->dist); + out->type = PlaneTypeForNormal( out->normal ); + out->signbits = bits; + } +} + +/* +================= +R_LoadFogs + +================= +*/ +static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { + int i; + fog_t *out; + dfog_t *fogs; + dbrush_t *brushes, *brush; + dbrushside_t *sides; + int count, brushesCount, sidesCount; + int sideNum; + int planeNum; + shader_t *shader; + float d; + int firstSide; + + fogs = (void *)(fileBase + l->fileofs); + if (l->filelen % sizeof(*fogs)) { + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + } + count = l->filelen / sizeof(*fogs); + + // create fog strucutres for them + s_worldData.numfogs = count + 1; + s_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); + out = s_worldData.fogs + 1; + + if ( !count ) { + return; + } + + brushes = (void *)(fileBase + brushesLump->fileofs); + if (brushesLump->filelen % sizeof(*brushes)) { + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + } + brushesCount = brushesLump->filelen / sizeof(*brushes); + + sides = (void *)(fileBase + sidesLump->fileofs); + if (sidesLump->filelen % sizeof(*sides)) { + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + } + sidesCount = sidesLump->filelen / sizeof(*sides); + + for ( i=0 ; ioriginalBrushNumber = LittleLong( fogs->brushNum ); + + if ( (unsigned)out->originalBrushNumber >= brushesCount ) { + ri.Error( ERR_DROP, "fog brushNumber out of range" ); + } + brush = brushes + out->originalBrushNumber; + + firstSide = LittleLong( brush->firstSide ); + + if ( (unsigned)firstSide > sidesCount - 6 ) { + ri.Error( ERR_DROP, "fog brush sideNumber out of range" ); + } + + // brushes are always sorted with the axial sides first + sideNum = firstSide + 0; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist; + + sideNum = firstSide + 1; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][0] = s_worldData.planes[ planeNum ].dist; + + sideNum = firstSide + 2; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist; + + sideNum = firstSide + 3; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][1] = s_worldData.planes[ planeNum ].dist; + + sideNum = firstSide + 4; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist; + + sideNum = firstSide + 5; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][2] = s_worldData.planes[ planeNum ].dist; + + // get information from the shader for fog parameters + shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue ); + + out->parms = shader->fogParms; + + out->colorInt = ColorBytes4 ( shader->fogParms.color[0] * tr.identityLight, + shader->fogParms.color[1] * tr.identityLight, + shader->fogParms.color[2] * tr.identityLight, 1.0 ); + + d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; + out->tcScale = 1.0f / ( d * 8 ); + + // set the gradient vector + sideNum = LittleLong( fogs->visibleSide ); + + if ( sideNum == -1 ) { + out->hasSurface = qfalse; + } else { + out->hasSurface = qtrue; + planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum ); + VectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface ); + out->surface[3] = -s_worldData.planes[ planeNum ].dist; + } + + out++; + } + +} + + +/* +================ +R_LoadLightGrid + +================ +*/ +void R_LoadLightGrid( lump_t *l ) { + int i; + vec3_t maxs; + int numGridPoints; + world_t *w; + float *wMins, *wMaxs; + + w = &s_worldData; + + w->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0]; + w->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1]; + w->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2]; + + wMins = w->bmodels[0].bounds[0]; + wMaxs = w->bmodels[0].bounds[1]; + + for ( i = 0 ; i < 3 ; i++ ) { + w->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] ); + maxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] ); + w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1; + } + + numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; + + if ( l->filelen != numGridPoints * 8 ) { + ri.Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" ); + w->lightGridData = NULL; + return; + } + + w->lightGridData = ri.Hunk_Alloc( l->filelen, h_low ); + Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); + + // deal with overbright bits + for ( i = 0 ; i < numGridPoints ; i++ ) { + R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] ); + R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] ); + } + + // load hdr lightgrid + if (r_hdr->integer) + { + char filename[MAX_QPATH]; + float *hdrLightGrid; + int size; + + Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", s_worldData.baseName); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + + size = ri.FS_ReadFile(filename, (void **)&hdrLightGrid); + + if (hdrLightGrid) + { + float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits); + + //ri.Printf(PRINT_ALL, "found!\n"); + + if (size != sizeof(float) * 6 * numGridPoints) + { + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); + } + + w->hdrLightGrid = ri.Hunk_Alloc(size, h_low); + + for (i = 0; i < numGridPoints ; i++) + { + w->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale; + w->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale; + w->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] * lightScale; + w->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] * lightScale; + w->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] * lightScale; + w->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] * lightScale; + } + } + + if (hdrLightGrid) + ri.FS_FreeFile(hdrLightGrid); + } +} + +/* +================ +R_LoadEntities +================ +*/ +void R_LoadEntities( lump_t *l ) { + char *p, *token, *s; + char keyname[MAX_TOKEN_CHARS]; + char value[MAX_TOKEN_CHARS]; + world_t *w; + + w = &s_worldData; + w->lightGridSize[0] = 64; + w->lightGridSize[1] = 64; + w->lightGridSize[2] = 128; + + p = (char *)(fileBase + l->fileofs); + + // store for reference by the cgame + w->entityString = ri.Hunk_Alloc( l->filelen + 1, h_low ); + strcpy( w->entityString, p ); + w->entityParsePoint = w->entityString; + + token = COM_ParseExt( &p, qtrue ); + if (!*token || *token != '{') { + return; + } + + // only parse the world spawn + while ( 1 ) { + // parse key + token = COM_ParseExt( &p, qtrue ); + + if ( !*token || *token == '}' ) { + break; + } + Q_strncpyz(keyname, token, sizeof(keyname)); + + // parse value + token = COM_ParseExt( &p, qtrue ); + + if ( !*token || *token == '}' ) { + break; + } + Q_strncpyz(value, token, sizeof(value)); + + // check for remapping of shaders for vertex lighting + s = "vertexremapshader"; + if (!Q_strncmp(keyname, s, strlen(s)) ) { + s = strchr(value, ';'); + if (!s) { + ri.Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); + break; + } + *s++ = 0; + if (r_vertexLight->integer) { + R_RemapShader(value, s, "0"); + } + continue; + } + // check for remapping of shaders + s = "remapshader"; + if (!Q_strncmp(keyname, s, strlen(s)) ) { + s = strchr(value, ';'); + if (!s) { + ri.Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); + break; + } + *s++ = 0; + R_RemapShader(value, s, "0"); + continue; + } + // check for a different grid size + if (!Q_stricmp(keyname, "gridsize")) { + sscanf(value, "%f %f %f", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] ); + continue; + } + + // check for auto exposure + if (!Q_stricmp(keyname, "autoExposureMinMax")) { + sscanf(value, "%f %f", &tr.autoExposureMinMax[0], &tr.autoExposureMinMax[1]); + continue; + } + } +} + +/* +================= +R_GetEntityToken +================= +*/ +qboolean R_GetEntityToken( char *buffer, int size ) { + const char *s; + + s = COM_Parse( &s_worldData.entityParsePoint ); + Q_strncpyz( buffer, s, size ); + if ( !s_worldData.entityParsePoint || !s[0] ) { + s_worldData.entityParsePoint = s_worldData.entityString; + return qfalse; + } else { + return qtrue; + } +} + + +/* +================= +R_MergeLeafSurfaces + +Merges surfaces that share a common leaf +================= +*/ +void R_MergeLeafSurfaces(void) +{ + int i, j, k; + int numWorldSurfaces; + int mergedSurfIndex; + int numMergedSurfaces; + int numUnmergedSurfaces; + IBO_t *ibo; + + msurface_t *mergedSurf; + + glIndex_t *iboIndexes, *outIboIndexes; + int numIboIndexes; + + int startTime, endTime; + + startTime = ri.Milliseconds(); + + numWorldSurfaces = s_worldData.numWorldSurfaces; + + // use viewcount to keep track of mergers + for (i = 0; i < numWorldSurfaces; i++) + { + s_worldData.surfacesViewCount[i] = -1; + } + + // create ibo + ibo = tr.ibos[tr.numIBOs++] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + memset(ibo, 0, sizeof(*ibo)); + Q_strncpyz(ibo->name, "staticWorldMesh_IBO_mergedSurfs", sizeof(ibo->name)); + + // allocate more than we need + iboIndexes = outIboIndexes = ri.Malloc(s_worldData.ibo->indexesSize); + + // mark matching surfaces + for (i = 0; i < s_worldData.numnodes - s_worldData.numDecisionNodes; i++) + { + mnode_t *leaf = s_worldData.nodes + s_worldData.numDecisionNodes + i; + + for (j = 0; j < leaf->nummarksurfaces; j++) + { + msurface_t *surf1; + shader_t *shader1; + int fogIndex1; + int surfNum1; + + surfNum1 = *(s_worldData.marksurfaces + leaf->firstmarksurface + j); + + if (s_worldData.surfacesViewCount[surfNum1] != -1) + continue; + + surf1 = s_worldData.surfaces + surfNum1; + + if ((*surf1->data != SF_GRID) && (*surf1->data != SF_TRIANGLES) && (*surf1->data != SF_FACE)) + continue; + + shader1 = surf1->shader; + + if(shader1->isSky) + continue; + + if(shader1->isPortal) + continue; + + if(ShaderRequiresCPUDeforms(shader1)) + continue; + + fogIndex1 = surf1->fogIndex; + + s_worldData.surfacesViewCount[surfNum1] = surfNum1; + + for (k = j + 1; k < leaf->nummarksurfaces; k++) + { + msurface_t *surf2; + shader_t *shader2; + int fogIndex2; + int surfNum2; + + surfNum2 = *(s_worldData.marksurfaces + leaf->firstmarksurface + k); + + if (s_worldData.surfacesViewCount[surfNum2] != -1) + continue; + + surf2 = s_worldData.surfaces + surfNum2; + + if ((*surf2->data != SF_GRID) && (*surf2->data != SF_TRIANGLES) && (*surf2->data != SF_FACE)) + continue; + + shader2 = surf2->shader; + + if (shader1 != shader2) + continue; + + fogIndex2 = surf2->fogIndex; + + if (fogIndex1 != fogIndex2) + continue; + + s_worldData.surfacesViewCount[surfNum2] = surfNum1; + } + } + } + + // don't add surfaces that don't merge to any others to the merged list + for (i = 0; i < numWorldSurfaces; i++) + { + qboolean merges = qfalse; + + if (s_worldData.surfacesViewCount[i] != i) + continue; + + for (j = 0; j < numWorldSurfaces; j++) + { + if (j == i) + continue; + + if (s_worldData.surfacesViewCount[j] == i) + { + merges = qtrue; + break; + } + } + + if (!merges) + s_worldData.surfacesViewCount[i] = -1; + } + + // count merged/unmerged surfaces + numMergedSurfaces = 0; + numUnmergedSurfaces = 0; + for (i = 0; i < numWorldSurfaces; i++) + { + if (s_worldData.surfacesViewCount[i] == i) + { + numMergedSurfaces++; + } + else if (s_worldData.surfacesViewCount[i] == -1) + { + numUnmergedSurfaces++; + } + } + + // Allocate merged surfaces + s_worldData.mergedSurfaces = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesViewCount = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesDlightBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesPshadowBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + s_worldData.numMergedSurfaces = numMergedSurfaces; + + // view surfaces are like mark surfaces, except negative ones represent merged surfaces + // -1 represents 0, -2 represents 1, and so on + s_worldData.viewSurfaces = ri.Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); + + // copy view surfaces into mark surfaces + for (i = 0; i < s_worldData.nummarksurfaces; i++) + { + s_worldData.viewSurfaces[i] = s_worldData.marksurfaces[i]; + } + + // actually merge surfaces + numIboIndexes = 0; + mergedSurfIndex = 0; + mergedSurf = s_worldData.mergedSurfaces; + for (i = 0; i < numWorldSurfaces; i++) + { + msurface_t *surf1; + + vec3_t bounds[2]; + + int numSurfsToMerge; + int numTriangles; + int numVerts; + int firstIndex; + + srfVBOMesh_t *vboSurf; + + if (s_worldData.surfacesViewCount[i] != i) + continue; + + surf1 = s_worldData.surfaces + i; + + // count verts, indexes, and surfaces + numSurfsToMerge = 0; + numTriangles = 0; + numVerts = 0; + for (j = 0; j < numWorldSurfaces; j++) + { + msurface_t *surf2; + + if (s_worldData.surfacesViewCount[j] != i) + continue; + + surf2 = s_worldData.surfaces + j; + + switch(*surf2->data) + { + case SF_FACE: + { + srfSurfaceFace_t *face; + + face = (srfSurfaceFace_t *) surf2->data; + numTriangles += face->numTriangles; + numVerts += face->numVerts; + } + break; + + case SF_GRID: + { + srfGridMesh_t *grid; + + grid = (srfGridMesh_t *) surf2->data; + numTriangles += grid->numTriangles; + numVerts += grid->numVerts; + } + break; + + case SF_TRIANGLES: + { + srfTriangles_t *tris; + + tris = (srfTriangles_t *) surf2->data; + numTriangles += tris->numTriangles; + numVerts += tris->numVerts; + } + break; + + default: + break; + } + + numSurfsToMerge++; + } + + if (numVerts == 0 || numTriangles == 0 || numSurfsToMerge < 2) + { + continue; + } + + // Merge surfaces (indexes) and calculate bounds + ClearBounds(bounds[0], bounds[1]); + firstIndex = numIboIndexes; + for (j = 0; j < numWorldSurfaces; j++) + { + msurface_t *surf2; + + if (s_worldData.surfacesViewCount[j] != i) + continue; + + surf2 = s_worldData.surfaces + j; + + AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]); + AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]); + + switch(*surf2->data) + { + case SF_FACE: + { + srfSurfaceFace_t *face; + + face = (srfSurfaceFace_t *) surf2->data; + + for (k = 0; k < face->numTriangles; k++) + { + *outIboIndexes++ = face->triangles[k].indexes[0] + face->firstVert; + *outIboIndexes++ = face->triangles[k].indexes[1] + face->firstVert; + *outIboIndexes++ = face->triangles[k].indexes[2] + face->firstVert; + numIboIndexes += 3; + } + } + break; + + case SF_GRID: + { + srfGridMesh_t *grid; + + grid = (srfGridMesh_t *) surf2->data; + + for (k = 0; k < grid->numTriangles; k++) + { + *outIboIndexes++ = grid->triangles[k].indexes[0] + grid->firstVert; + *outIboIndexes++ = grid->triangles[k].indexes[1] + grid->firstVert; + *outIboIndexes++ = grid->triangles[k].indexes[2] + grid->firstVert; + numIboIndexes += 3; + } + } + break; + + case SF_TRIANGLES: + { + srfTriangles_t *tris; + + tris = (srfTriangles_t *) surf2->data; + + for (k = 0; k < tris->numTriangles; k++) + { + *outIboIndexes++ = tris->triangles[k].indexes[0] + tris->firstVert; + *outIboIndexes++ = tris->triangles[k].indexes[1] + tris->firstVert; + *outIboIndexes++ = tris->triangles[k].indexes[2] + tris->firstVert; + numIboIndexes += 3; + } + } + break; + + // never happens, but silences a compile warning + default: + break; + } + } + + vboSurf = ri.Hunk_Alloc(sizeof(*vboSurf), h_low); + memset(vboSurf, 0, sizeof(*vboSurf)); + vboSurf->surfaceType = SF_VBO_MESH; + + vboSurf->vbo = s_worldData.vbo; + vboSurf->ibo = ibo; + + vboSurf->numIndexes = numTriangles * 3; + vboSurf->numVerts = numVerts; + vboSurf->firstIndex = firstIndex; + + vboSurf->minIndex = *(iboIndexes + firstIndex); + vboSurf->maxIndex = *(iboIndexes + firstIndex); + + for (j = 1; j < numTriangles * 3; j++) + { + vboSurf->minIndex = MIN(vboSurf->minIndex, *(iboIndexes + firstIndex + j)); + vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j)); + } + + vboSurf->shader = surf1->shader; + vboSurf->fogIndex = surf1->fogIndex; + + VectorCopy(bounds[0], vboSurf->bounds[0]); + VectorCopy(bounds[1], vboSurf->bounds[1]); + + VectorCopy(bounds[0], mergedSurf->cullinfo.bounds[0]); + VectorCopy(bounds[1], mergedSurf->cullinfo.bounds[1]); + + mergedSurf->cullinfo.type = CULLINFO_BOX; + mergedSurf->data = (surfaceType_t *)vboSurf; + mergedSurf->fogIndex = surf1->fogIndex; + mergedSurf->shader = surf1->shader; + + // redirect view surfaces to this surf + for (j = 0; j < numWorldSurfaces; j++) + { + if (s_worldData.surfacesViewCount[j] != i) + continue; + + for (k = 0; k < s_worldData.nummarksurfaces; k++) + { + int *mark = s_worldData.marksurfaces + k; + int *view = s_worldData.viewSurfaces + k; + + if (*mark == j) + *view = -(mergedSurfIndex + 1); + } + } + + mergedSurfIndex++; + mergedSurf++; + } + + // finish up the ibo + R_IssuePendingRenderCommands(); + + qglGenBuffersARB(1, &ibo->indexesVBO); + + R_BindIBO(ibo); + + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); + + R_BindNullIBO(); + + GL_CheckErrors(); + + ri.Free(iboIndexes); + + endTime = ri.Milliseconds(); + + ri.Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", + numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); + + // reset viewcounts + for (i = 0; i < numWorldSurfaces; i++) + { + s_worldData.surfacesViewCount[i] = -1; + } +} + + +void R_CalcVertexLightDirs( void ) +{ + int i, k; + msurface_t *surface; + + for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) + { + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); + } + } + } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); + } + } + } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *srf = (srfTriangles_t *) surface->data; + + if(srf->numVerts) + { + for(i = 0; i < srf->numVerts; i++) + { + R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); + } + } + } + } +} + + +/* +================= +RE_LoadWorldMap + +Called directly from cgame +================= +*/ +void RE_LoadWorldMap( const char *name ) { + int i; + dheader_t *header; + union { + byte *b; + void *v; + } buffer; + byte *startMarker; + + if ( tr.worldMapLoaded ) { + ri.Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); + } + + // set default map light scale + tr.mapLightScale = 1.0f; + tr.sunShadowScale = 0.5f; + + // set default sun direction to be used if it isn't + // overridden by a shader + tr.sunDirection[0] = 0.45f; + tr.sunDirection[1] = 0.3f; + tr.sunDirection[2] = 0.9f; + + VectorNormalize( tr.sunDirection ); + + // set default autoexposure settings + tr.autoExposureMinMax[0] = -2.0f; + tr.autoExposureMinMax[1] = 2.0f; + + // set default tone mapping settings + tr.toneMinAvgMaxLevel[0] = -8.0f; + tr.toneMinAvgMaxLevel[1] = -2.0f; + tr.toneMinAvgMaxLevel[2] = 0.0f; + + tr.worldMapLoaded = qtrue; + + // load it + ri.FS_ReadFile( name, &buffer.v ); + if ( !buffer.b ) { + ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); + } + + // clear tr.world so if the level fails to load, the next + // try will not look at the partially loaded version + tr.world = NULL; + + Com_Memset( &s_worldData, 0, sizeof( s_worldData ) ); + Q_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) ); + + Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); + COM_StripExtension(s_worldData.baseName, s_worldData.baseName, sizeof(s_worldData.baseName)); + + startMarker = ri.Hunk_Alloc(0, h_low); + c_gridVerts = 0; + + header = (dheader_t *)buffer.b; + fileBase = (byte *)header; + + i = LittleLong (header->version); + if ( i != BSP_VERSION ) { + ri.Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", + name, i, BSP_VERSION); + } + + // swap all the lumps + for (i=0 ; ilumps[LUMP_ENTITIES] ); + R_LoadShaders( &header->lumps[LUMP_SHADERS] ); + R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES] ); + R_LoadPlanes (&header->lumps[LUMP_PLANES]); + R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); + R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); + R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]); + R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); + R_LoadSubmodels (&header->lumps[LUMP_MODELS]); + R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); + R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); + + // determine vertex light directions + R_CalcVertexLightDirs(); + + // determine which parts of the map are in sunlight + if (0) + { + world_t *w; + + w = &s_worldData; + uint8_t *primaryLightGrid, *data; + int lightGridSize; + int i; + + lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; + primaryLightGrid = ri.Malloc(lightGridSize * sizeof(*primaryLightGrid)); + + memset(primaryLightGrid, 0, lightGridSize * sizeof(*primaryLightGrid)); + + data = w->lightGridData; + for (i = 0; i < lightGridSize; i++, data += 8) + { + int lat, lng; + vec3_t gridLightDir, gridLightCol; + + // skip samples in wall + if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) + continue; + + gridLightCol[0] = ByteToFloat(data[3]); + gridLightCol[1] = ByteToFloat(data[4]); + gridLightCol[2] = ByteToFloat(data[5]); + (void)gridLightCol; // Suppress unused-but-set-variable warning + + lat = data[7]; + lng = data[6]; + lat *= (FUNCTABLE_SIZE/256); + lng *= (FUNCTABLE_SIZE/256); + + // decode X as cos( lat ) * sin( long ) + // decode Y as sin( lat ) * sin( long ) + // decode Z as cos( long ) + + gridLightDir[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + gridLightDir[1] = tr.sinTable[lat] * tr.sinTable[lng]; + gridLightDir[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + // FIXME: magic number for determining if light direction is close enough to sunlight + if (DotProduct(gridLightDir, tr.sunDirection) > 0.75f) + { + primaryLightGrid[i] = 1; + } + else + { + primaryLightGrid[i] = 255; + } + } + + if (0) + { + int i; + byte *buffer = ri.Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); + byte *out; + uint8_t *in; + char fileName[MAX_QPATH]; + + Com_Memset (buffer, 0, 18); + buffer[2] = 2; // uncompressed type + buffer[12] = w->lightGridBounds[0] & 255; + buffer[13] = w->lightGridBounds[0] >> 8; + buffer[14] = w->lightGridBounds[1] & 255; + buffer[15] = w->lightGridBounds[1] >> 8; + buffer[16] = 24; // pixel size + + in = primaryLightGrid; + for (i = 0; i < w->lightGridBounds[2]; i++) + { + int j; + + sprintf(fileName, "primarylg%d.tga", i); + + out = buffer + 18; + for (j = 0; j < w->lightGridBounds[0] * w->lightGridBounds[1]; j++) + { + if (*in == 1) + { + *out++ = 255; + *out++ = 255; + *out++ = 255; + } + else if (*in == 255) + { + *out++ = 64; + *out++ = 64; + *out++ = 64; + } + else + { + *out++ = 0; + *out++ = 0; + *out++ = 0; + } + in++; + } + + ri.FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); + } + + ri.Free(buffer); + } + + for (i = 0; i < w->numWorldSurfaces; i++) + { + msurface_t *surf = w->surfaces + i; + cullinfo_t *ci = &surf->cullinfo; + + if(ci->type & CULLINFO_PLANE) + { + if (DotProduct(ci->plane.normal, tr.sunDirection) <= 0.0f) + { + //ri.Printf(PRINT_ALL, "surface %d is not oriented towards sunlight\n", i); + continue; + } + } + + if(ci->type & CULLINFO_BOX) + { + int ibounds[2][3], x, y, z, goodSamples, numSamples; + vec3_t lightOrigin; + + VectorSubtract( ci->bounds[0], w->lightGridOrigin, lightOrigin ); + + ibounds[0][0] = floor(lightOrigin[0] * w->lightGridInverseSize[0]); + ibounds[0][1] = floor(lightOrigin[1] * w->lightGridInverseSize[1]); + ibounds[0][2] = floor(lightOrigin[2] * w->lightGridInverseSize[2]); + + VectorSubtract( ci->bounds[1], w->lightGridOrigin, lightOrigin ); + + ibounds[1][0] = ceil(lightOrigin[0] * w->lightGridInverseSize[0]); + ibounds[1][1] = ceil(lightOrigin[1] * w->lightGridInverseSize[1]); + ibounds[1][2] = ceil(lightOrigin[2] * w->lightGridInverseSize[2]); + + ibounds[0][0] = CLAMP(ibounds[0][0], 0, w->lightGridSize[0]); + ibounds[0][1] = CLAMP(ibounds[0][1], 0, w->lightGridSize[1]); + ibounds[0][2] = CLAMP(ibounds[0][2], 0, w->lightGridSize[2]); + + ibounds[1][0] = CLAMP(ibounds[1][0], 0, w->lightGridSize[0]); + ibounds[1][1] = CLAMP(ibounds[1][1], 0, w->lightGridSize[1]); + ibounds[1][2] = CLAMP(ibounds[1][2], 0, w->lightGridSize[2]); + + /* + ri.Printf(PRINT_ALL, "surf %d bounds (%f %f %f)-(%f %f %f) ibounds (%d %d %d)-(%d %d %d)\n", i, + ci->bounds[0][0], ci->bounds[0][1], ci->bounds[0][2], + ci->bounds[1][0], ci->bounds[1][1], ci->bounds[1][2], + ibounds[0][0], ibounds[0][1], ibounds[0][2], + ibounds[1][0], ibounds[1][1], ibounds[1][2]); + */ + + goodSamples = 0; + numSamples = 0; + for (x = ibounds[0][0]; x <= ibounds[1][0]; x++) + { + for (y = ibounds[0][1]; y <= ibounds[1][1]; y++) + { + for (z = ibounds[0][2]; z <= ibounds[1][2]; z++) + { + uint8_t primaryLight = primaryLightGrid[x * 8 + y * 8 * w->lightGridBounds[0] + z * 8 * w->lightGridBounds[0] * w->lightGridBounds[2]]; + + if (primaryLight == 0) + continue; + + numSamples++; + + if (primaryLight == 1) + goodSamples++; + } + } + } + + // FIXME: magic number for determining whether object is mostly in sunlight + if (goodSamples > numSamples * 0.75f) + { + //ri.Printf(PRINT_ALL, "surface %d is in sunlight\n", i); + //surf->primaryLight = 1; + } + } + } + + ri.Free(primaryLightGrid); + } + + // create static VBOS from the world + R_CreateWorldVBO(); + if (r_mergeLeafSurfaces->integer) + { + R_MergeLeafSurfaces(); + } + + s_worldData.dataSize = (byte *)ri.Hunk_Alloc(0, h_low) - startMarker; + + // only set tr.world now that we know the entire level has loaded properly + tr.world = &s_worldData; + + // make sure the VBO glState entries are safe + R_BindNullVBO(); + R_BindNullIBO(); + + ri.FS_FreeFile( buffer.v ); +} diff --git a/codemp/rd-rend2/tr_cmds.c b/codemp/rd-rend2/tr_cmds.c new file mode 100644 index 0000000000..1426b581a8 --- /dev/null +++ b/codemp/rd-rend2/tr_cmds.c @@ -0,0 +1,581 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "tr_local.h" + +/* +===================== +R_PerformanceCounters +===================== +*/ +void R_PerformanceCounters( void ) { + if ( !r_speeds->integer ) { + // clear the counters even if we aren't printing + Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); + Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); + return; + } + + if (r_speeds->integer == 1) { + ri.Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", + backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, + backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, + R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); + } else if (r_speeds->integer == 2) { + ri.Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, + tr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out ); + ri.Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, + tr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out ); + } else if (r_speeds->integer == 3) { + ri.Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); + } else if (r_speeds->integer == 4) { + if ( backEnd.pc.c_dlightVertexes ) { + ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", + tr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled, + backEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 ); + } + } + else if (r_speeds->integer == 5 ) + { + ri.Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); + } + else if (r_speeds->integer == 6 ) + { + ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", + backEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders ); + } + else if (r_speeds->integer == 7 ) + { + ri.Printf( PRINT_ALL, "VBO draws: static %i dynamic %i\nMultidraws: %i merged %i\n", + backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged ); + ri.Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", + backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); + } + + Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); + Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); +} + + +/* +==================== +R_IssueRenderCommands +==================== +*/ +void R_IssueRenderCommands( qboolean runPerformanceCounters ) { + renderCommandList_t *cmdList; + + cmdList = &backEndData->commands; + assert(cmdList); + // add an end-of-list command + *(int *)(cmdList->cmds + cmdList->used) = RC_END_OF_LIST; + + // clear it out, in case this is a sync and not a buffer flip + cmdList->used = 0; + + if ( runPerformanceCounters ) { + R_PerformanceCounters(); + } + + // actually start the commands going + if ( !r_skipBackEnd->integer ) { + // let it start on the new batch + RB_ExecuteRenderCommands( cmdList->cmds ); + } +} + + +/* +==================== +R_IssuePendingRenderCommands + +Issue any pending commands and wait for them to complete. +==================== +*/ +void R_IssuePendingRenderCommands( void ) { + if ( !tr.registered ) { + return; + } + R_IssueRenderCommands( qfalse ); +} + +/* +============ +R_GetCommandBuffer + +make sure there is enough command space +============ +*/ +void *R_GetCommandBuffer( int bytes ) { + renderCommandList_t *cmdList; + + cmdList = &backEndData->commands; + bytes = PAD(bytes, sizeof(void *)); + + // always leave room for the end of list command + if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) { + if ( bytes > MAX_RENDER_COMMANDS - 4 ) { + ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); + } + // if we run out of room, just start dropping commands + return NULL; + } + + cmdList->used += bytes; + + return cmdList->cmds + cmdList->used - bytes; +} + + +/* +============= +R_AddDrawSurfCmd + +============= +*/ +void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) { + drawSurfsCommand_t *cmd; + + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_DRAW_SURFS; + + cmd->drawSurfs = drawSurfs; + cmd->numDrawSurfs = numDrawSurfs; + + cmd->refdef = tr.refdef; + cmd->viewParms = tr.viewParms; +} + + +/* +============= +R_AddCapShadowmapCmd + +============= +*/ +void R_AddCapShadowmapCmd( int map, int cubeSide ) { + capShadowmapCommand_t *cmd; + + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_CAPSHADOWMAP; + + cmd->map = map; + cmd->cubeSide = cubeSide; +} + + +/* +============= +R_PostProcessingCmd + +============= +*/ +void R_AddPostProcessCmd( ) { + postProcessCommand_t *cmd; + + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_POSTPROCESS; + + cmd->refdef = tr.refdef; + cmd->viewParms = tr.viewParms; +} + +/* +============= +RE_SetColor + +Passing NULL will set the color to white +============= +*/ +void RE_SetColor( const float *rgba ) { + setColorCommand_t *cmd; + + if ( !tr.registered ) { + return; + } + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_SET_COLOR; + if ( !rgba ) { + static float colorWhite[4] = { 1, 1, 1, 1 }; + + rgba = colorWhite; + } + + cmd->color[0] = rgba[0]; + cmd->color[1] = rgba[1]; + cmd->color[2] = rgba[2]; + cmd->color[3] = rgba[3]; +} + + +/* +============= +RE_StretchPic +============= +*/ +void RE_StretchPic ( float x, float y, float w, float h, + float s1, float t1, float s2, float t2, qhandle_t hShader ) { + stretchPicCommand_t *cmd; + + if (!tr.registered) { + return; + } + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_STRETCH_PIC; + cmd->shader = R_GetShaderByHandle( hShader ); + cmd->x = x; + cmd->y = y; + cmd->w = w; + cmd->h = h; + cmd->s1 = s1; + cmd->t1 = t1; + cmd->s2 = s2; + cmd->t2 = t2; +} + +#define MODE_RED_CYAN 1 +#define MODE_RED_BLUE 2 +#define MODE_RED_GREEN 3 +#define MODE_GREEN_MAGENTA 4 +#define MODE_MAX MODE_GREEN_MAGENTA + +void R_SetColorMode(GLboolean *rgba, stereoFrame_t stereoFrame, int colormode) +{ + rgba[0] = rgba[1] = rgba[2] = rgba[3] = GL_TRUE; + + if(colormode > MODE_MAX) + { + if(stereoFrame == STEREO_LEFT) + stereoFrame = STEREO_RIGHT; + else if(stereoFrame == STEREO_RIGHT) + stereoFrame = STEREO_LEFT; + + colormode -= MODE_MAX; + } + + if(colormode == MODE_GREEN_MAGENTA) + { + if(stereoFrame == STEREO_LEFT) + rgba[0] = rgba[2] = GL_FALSE; + else if(stereoFrame == STEREO_RIGHT) + rgba[1] = GL_FALSE; + } + else + { + if(stereoFrame == STEREO_LEFT) + rgba[1] = rgba[2] = GL_FALSE; + else if(stereoFrame == STEREO_RIGHT) + { + rgba[0] = GL_FALSE; + + if(colormode == MODE_RED_BLUE) + rgba[1] = GL_FALSE; + else if(colormode == MODE_RED_GREEN) + rgba[2] = GL_FALSE; + } + } +} + + +/* +==================== +RE_BeginFrame + +If running in stereo, RE_BeginFrame will be called twice +for each RE_EndFrame +==================== +*/ +void RE_BeginFrame( stereoFrame_t stereoFrame ) { + drawBufferCommand_t *cmd = NULL; + colorMaskCommand_t *colcmd = NULL; + + if ( !tr.registered ) { + return; + } + glState.finishCalled = qfalse; + + tr.frameCount++; + tr.frameSceneNum = 0; + + // + // do overdraw measurement + // + if ( r_measureOverdraw->integer ) + { + if ( glConfig.stencilBits < 4 ) + { + ri.Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); + ri.Cvar_Set( "r_measureOverdraw", "0" ); + r_measureOverdraw->modified = qfalse; + } + else if ( r_shadows->integer == 2 ) + { + ri.Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); + ri.Cvar_Set( "r_measureOverdraw", "0" ); + r_measureOverdraw->modified = qfalse; + } + else + { + R_IssuePendingRenderCommands(); + qglEnable( GL_STENCIL_TEST ); + qglStencilMask( ~0U ); + qglClearStencil( 0U ); + qglStencilFunc( GL_ALWAYS, 0U, ~0U ); + qglStencilOp( GL_KEEP, GL_INCR, GL_INCR ); + } + r_measureOverdraw->modified = qfalse; + } + else + { + // this is only reached if it was on and is now off + if ( r_measureOverdraw->modified ) { + R_IssuePendingRenderCommands(); + qglDisable( GL_STENCIL_TEST ); + } + r_measureOverdraw->modified = qfalse; + } + + // + // texturemode stuff + // + if ( r_textureMode->modified ) { + R_IssuePendingRenderCommands(); + GL_TextureMode( r_textureMode->string ); + r_textureMode->modified = qfalse; + } + + // + // gamma stuff + // + if ( r_gamma->modified ) { + r_gamma->modified = qfalse; + + R_IssuePendingRenderCommands(); + R_SetColorMappings(); + } + + // check for errors + if ( !r_ignoreGLErrors->integer ) + { + int err; + + R_IssuePendingRenderCommands(); + if ((err = qglGetError()) != GL_NO_ERROR) + ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); + } + + if (glConfig.stereoEnabled) { + if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + return; + + cmd->commandId = RC_DRAW_BUFFER; + + if ( stereoFrame == STEREO_LEFT ) { + cmd->buffer = (int)GL_BACK_LEFT; + } else if ( stereoFrame == STEREO_RIGHT ) { + cmd->buffer = (int)GL_BACK_RIGHT; + } else { + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + } + } + else + { + if(r_anaglyphMode->integer) + { + if(r_anaglyphMode->modified) + { + // clear both, front and backbuffer. + qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + backEnd.colorMask[0] = GL_FALSE; + backEnd.colorMask[1] = GL_FALSE; + backEnd.colorMask[2] = GL_FALSE; + backEnd.colorMask[3] = GL_FALSE; + qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); + + if (glRefConfig.framebufferObject) + { + // clear all framebuffers + if (tr.msaaResolveFbo) + { + FBO_Bind(tr.msaaResolveFbo); + qglClear(GL_COLOR_BUFFER_BIT); + } + + if (tr.renderFbo) + { + FBO_Bind(tr.renderFbo); + qglClear(GL_COLOR_BUFFER_BIT); + } + + if (tr.screenScratchFbo) + { + FBO_Bind(tr.screenScratchFbo); + qglClear(GL_COLOR_BUFFER_BIT); + } + + FBO_Bind(NULL); + } + + qglDrawBuffer(GL_FRONT); + qglClear(GL_COLOR_BUFFER_BIT); + qglDrawBuffer(GL_BACK); + qglClear(GL_COLOR_BUFFER_BIT); + + r_anaglyphMode->modified = qfalse; + } + + if(stereoFrame == STEREO_LEFT) + { + if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + return; + + if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) + return; + } + else if(stereoFrame == STEREO_RIGHT) + { + clearDepthCommand_t *cldcmd; + + if( !(cldcmd = R_GetCommandBuffer(sizeof(*cldcmd))) ) + return; + + cldcmd->commandId = RC_CLEARDEPTH; + + if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) + return; + } + else + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + + R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer); + colcmd->commandId = RC_COLORMASK; + } + else + { + if(stereoFrame != STEREO_CENTER) + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); + + if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + return; + } + + if(cmd) + { + cmd->commandId = RC_DRAW_BUFFER; + + if(r_anaglyphMode->modified) + { + qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + backEnd.colorMask[0] = 0; + backEnd.colorMask[1] = 0; + backEnd.colorMask[2] = 0; + backEnd.colorMask[3] = 0; + r_anaglyphMode->modified = qfalse; + } + + if (!Q_stricmp(r_drawBuffer->string, "GL_FRONT")) + cmd->buffer = (int)GL_FRONT; + else + cmd->buffer = (int)GL_BACK; + } + } + + tr.refdef.stereoFrame = stereoFrame; +} + + +/* +============= +RE_EndFrame + +Returns the number of msec spent in the back end +============= +*/ +void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { + swapBuffersCommand_t *cmd; + + if ( !tr.registered ) { + return; + } + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_SWAP_BUFFERS; + + R_IssueRenderCommands( qtrue ); + + R_InitNextFrame(); + + if ( frontEndMsec ) { + *frontEndMsec = tr.frontEndMsec; + } + tr.frontEndMsec = 0; + if ( backEndMsec ) { + *backEndMsec = backEnd.pc.msec; + } + backEnd.pc.msec = 0; +} + +/* +============= +RE_TakeVideoFrame +============= +*/ +void RE_TakeVideoFrame( int width, int height, + byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ) +{ + videoFrameCommand_t *cmd; + + if( !tr.registered ) { + return; + } + + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if( !cmd ) { + return; + } + + cmd->commandId = RC_VIDEOFRAME; + + cmd->width = width; + cmd->height = height; + cmd->captureBuffer = captureBuffer; + cmd->encodeBuffer = encodeBuffer; + cmd->motionJpeg = motionJpeg; +} diff --git a/codemp/rd-rend2/tr_curve.c b/codemp/rd-rend2/tr_curve.c new file mode 100644 index 0000000000..3d43925706 --- /dev/null +++ b/codemp/rd-rend2/tr_curve.c @@ -0,0 +1,806 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "tr_local.h" + +/* + +This file does all of the processing necessary to turn a raw grid of points +read from the map file into a srfGridMesh_t ready for rendering. + +The level of detail solution is direction independent, based only on subdivided +distance from the true curve. + +Only a single entry point: + +srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, + srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { + +*/ + + +/* +============ +LerpDrawVert +============ +*/ +static void LerpDrawVert( srfVert_t *a, srfVert_t *b, srfVert_t *out ) { + out->xyz[0] = 0.5f * (a->xyz[0] + b->xyz[0]); + out->xyz[1] = 0.5f * (a->xyz[1] + b->xyz[1]); + out->xyz[2] = 0.5f * (a->xyz[2] + b->xyz[2]); + + out->st[0] = 0.5f * (a->st[0] + b->st[0]); + out->st[1] = 0.5f * (a->st[1] + b->st[1]); + + out->lightmap[0] = 0.5f * (a->lightmap[0] + b->lightmap[0]); + out->lightmap[1] = 0.5f * (a->lightmap[1] + b->lightmap[1]); + + out->vertexColors[0] = 0.5f * (a->vertexColors[0] + b->vertexColors[0]); + out->vertexColors[1] = 0.5f * (a->vertexColors[1] + b->vertexColors[1]); + out->vertexColors[2] = 0.5f * (a->vertexColors[2] + b->vertexColors[2]); + out->vertexColors[3] = 0.5f * (a->vertexColors[3] + b->vertexColors[3]); +} + +/* +============ +Transpose +============ +*/ +static void Transpose( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { + int i, j; + srfVert_t temp; + + if ( width > height ) { + for ( i = 0 ; i < height ; i++ ) { + for ( j = i + 1 ; j < width ; j++ ) { + if ( j < height ) { + // swap the value + temp = ctrl[j][i]; + ctrl[j][i] = ctrl[i][j]; + ctrl[i][j] = temp; + } else { + // just copy + ctrl[j][i] = ctrl[i][j]; + } + } + } + } else { + for ( i = 0 ; i < width ; i++ ) { + for ( j = i + 1 ; j < height ; j++ ) { + if ( j < width ) { + // swap the value + temp = ctrl[i][j]; + ctrl[i][j] = ctrl[j][i]; + ctrl[j][i] = temp; + } else { + // just copy + ctrl[i][j] = ctrl[j][i]; + } + } + } + } + +} + + +/* +================= +MakeMeshNormals + +Handles all the complicated wrapping and degenerate cases +================= +*/ +static void MakeMeshNormals( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { + int i, j, k, dist; + vec3_t normal; + vec3_t sum; + int count = 0; + vec3_t base; + vec3_t delta; + int x, y; + srfVert_t *dv; + vec3_t around[8], temp; + qboolean good[8]; + qboolean wrapWidth, wrapHeight; + float len; +static int neighbors[8][2] = { + {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1}, {-1,-1}, {-1,0}, {-1,1} + }; + + wrapWidth = qfalse; + for ( i = 0 ; i < height ; i++ ) { + VectorSubtract( ctrl[i][0].xyz, ctrl[i][width-1].xyz, delta ); + len = VectorLengthSquared( delta ); + if ( len > 1.0 ) { + break; + } + } + if ( i == height ) { + wrapWidth = qtrue; + } + + wrapHeight = qfalse; + for ( i = 0 ; i < width ; i++ ) { + VectorSubtract( ctrl[0][i].xyz, ctrl[height-1][i].xyz, delta ); + len = VectorLengthSquared( delta ); + if ( len > 1.0 ) { + break; + } + } + if ( i == width) { + wrapHeight = qtrue; + } + + + for ( i = 0 ; i < width ; i++ ) { + for ( j = 0 ; j < height ; j++ ) { + count = 0; + dv = &ctrl[j][i]; + VectorCopy( dv->xyz, base ); + for ( k = 0 ; k < 8 ; k++ ) { + VectorClear( around[k] ); + good[k] = qfalse; + + for ( dist = 1 ; dist <= 3 ; dist++ ) { + x = i + neighbors[k][0] * dist; + y = j + neighbors[k][1] * dist; + if ( wrapWidth ) { + if ( x < 0 ) { + x = width - 1 + x; + } else if ( x >= width ) { + x = 1 + x - width; + } + } + if ( wrapHeight ) { + if ( y < 0 ) { + y = height - 1 + y; + } else if ( y >= height ) { + y = 1 + y - height; + } + } + + if ( x < 0 || x >= width || y < 0 || y >= height ) { + break; // edge of patch + } + VectorSubtract( ctrl[y][x].xyz, base, temp ); + if ( VectorNormalize2( temp, temp ) == 0 ) { + continue; // degenerate edge, get more dist + } else { + good[k] = qtrue; + VectorCopy( temp, around[k] ); + break; // good edge + } + } + } + + VectorClear( sum ); + for ( k = 0 ; k < 8 ; k++ ) { + if ( !good[k] || !good[(k+1)&7] ) { + continue; // didn't get two points + } + CrossProduct( around[(k+1)&7], around[k], normal ); + if ( VectorNormalize2( normal, normal ) == 0 ) { + continue; + } + VectorAdd( normal, sum, sum ); + count++; + } + //if ( count == 0 ) { + // printf("bad normal\n"); + //} + VectorNormalize2( sum, dv->normal ); + } + } +} + +#ifdef USE_VERT_TANGENT_SPACE +static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int numTriangles, + srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) +{ + int i, j; + srfVert_t *dv[3]; + static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE]; + srfTriangle_t *tri; + + // FIXME: use more elegant way + for(i = 0; i < width; i++) + { + for(j = 0; j < height; j++) + { + dv[0] = &ctrl2[j * width + i]; + *dv[0] = ctrl[j][i]; + } + } + + for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + { + dv[0] = &ctrl2[tri->indexes[0]]; + dv[1] = &ctrl2[tri->indexes[1]]; + dv[2] = &ctrl2[tri->indexes[2]]; + + R_CalcTangentVectors(dv); + } + +#if 0 + for(i = 0; i < (width * height); i++) + { + dv0 = &ctrl2[i]; + + VectorNormalize(dv0->normal); +#if 0 + VectorNormalize(dv0->tangent); + VectorNormalize(dv0->bitangent); +#else + d = DotProduct(dv0->tangent, dv0->normal); + VectorMA(dv0->tangent, -d, dv0->normal, dv0->tangent); + VectorNormalize(dv0->tangent); + + d = DotProduct(dv0->bitangent, dv0->normal); + VectorMA(dv0->bitangent, -d, dv0->normal, dv0->bitangent); + VectorNormalize(dv0->bitangent); +#endif + } +#endif + + +#if 0 + // do another extra smoothing for normals to avoid flat shading + for(i = 0; i < (width * height); i++) + { + for(j = 0; j < (width * height); j++) + { + if(R_CompareVert(&ctrl2[i], &ctrl2[j], qfalse)) + { + VectorAdd(ctrl2[i].normal, ctrl2[j].normal, ctrl2[i].normal); + } + } + + VectorNormalize(ctrl2[i].normal); + } +#endif + + for(i = 0; i < width; i++) + { + for(j = 0; j < height; j++) + { + dv[0] = &ctrl2[j * width + i]; + dv[1] = &ctrl[j][i]; + + VectorCopy(dv[0]->tangent, dv[1]->tangent); + VectorCopy(dv[0]->bitangent, dv[1]->bitangent); + } + } +} +#endif + + +static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], + srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) +{ + int i, j; + int numTriangles; + int w, h; + srfVert_t *dv; + static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE]; + + h = height - 1; + w = width - 1; + numTriangles = 0; + for(i = 0; i < h; i++) + { + for(j = 0; j < w; j++) + { + int v1, v2, v3, v4; + + // vertex order to be reckognized as tristrips + v1 = i * width + j + 1; + v2 = v1 - 1; + v3 = v2 + width; + v4 = v3 + 1; + + triangles[numTriangles].indexes[0] = v2; + triangles[numTriangles].indexes[1] = v3; + triangles[numTriangles].indexes[2] = v1; + numTriangles++; + + triangles[numTriangles].indexes[0] = v1; + triangles[numTriangles].indexes[1] = v3; + triangles[numTriangles].indexes[2] = v4; + numTriangles++; + } + } + + R_CalcSurfaceTriangleNeighbors(numTriangles, triangles); + + // FIXME: use more elegant way + for(i = 0; i < width; i++) + { + for(j = 0; j < height; j++) + { + dv = &ctrl2[j * width + i]; + *dv = ctrl[j][i]; + } + } + + R_CalcSurfaceTrianglePlanes(numTriangles, triangles, ctrl2); + + return numTriangles; +} + + +/* +============ +InvertCtrl +============ +*/ +static void InvertCtrl( int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE] ) { + int i, j; + srfVert_t temp; + + for ( i = 0 ; i < height ; i++ ) { + for ( j = 0 ; j < width/2 ; j++ ) { + temp = ctrl[i][j]; + ctrl[i][j] = ctrl[i][width-1-j]; + ctrl[i][width-1-j] = temp; + } + } +} + + +/* +================= +InvertErrorTable +================= +*/ +static void InvertErrorTable( float errorTable[2][MAX_GRID_SIZE], int width, int height ) { + int i; + float copy[2][MAX_GRID_SIZE]; + + Com_Memcpy( copy, errorTable, sizeof( copy ) ); + + for ( i = 0 ; i < width ; i++ ) { + errorTable[1][i] = copy[0][i]; //[width-1-i]; + } + + for ( i = 0 ; i < height ; i++ ) { + errorTable[0][i] = copy[1][height-1-i]; + } + +} + +/* +================== +PutPointsOnCurve +================== +*/ +static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], + int width, int height ) { + int i, j; + srfVert_t prev, next; + + for ( i = 0 ; i < width ; i++ ) { + for ( j = 1 ; j < height ; j += 2 ) { + LerpDrawVert( &ctrl[j][i], &ctrl[j+1][i], &prev ); + LerpDrawVert( &ctrl[j][i], &ctrl[j-1][i], &next ); + LerpDrawVert( &prev, &next, &ctrl[j][i] ); + } + } + + + for ( j = 0 ; j < height ; j++ ) { + for ( i = 1 ; i < width ; i += 2 ) { + LerpDrawVert( &ctrl[j][i], &ctrl[j][i+1], &prev ); + LerpDrawVert( &ctrl[j][i], &ctrl[j][i-1], &next ); + LerpDrawVert( &prev, &next, &ctrl[j][i] ); + } + } +} + +/* +================= +R_CreateSurfaceGridMesh +================= +*/ +srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, + srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE], + int numTriangles, srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) { + int i, j, size; + srfVert_t *vert; + vec3_t tmpVec; + srfGridMesh_t *grid; + + // copy the results out to a grid + size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); + +#ifdef PATCH_STITCHING + grid = /*ri.Hunk_Alloc*/ ri.Malloc( size ); + Com_Memset(grid, 0, size); + + grid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 ); + Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); + + grid->heightLodError = /*ri.Hunk_Alloc*/ ri.Malloc( height * 4 ); + Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); + + grid->numTriangles = numTriangles; + grid->triangles = ri.Malloc(grid->numTriangles * sizeof(srfTriangle_t)); + Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); + + grid->numVerts = (width * height); + grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t)); +#else + grid = ri.Hunk_Alloc( size ); + Com_Memset(grid, 0, size); + + grid->widthLodError = ri.Hunk_Alloc( width * 4 ); + Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); + + grid->heightLodError = ri.Hunk_Alloc( height * 4 ); + Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); + + grid->numTriangles = numTriangles; + grid->triangles = ri.Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); + Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); + + grid->numVerts = (width * height); + grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); +#endif + + grid->width = width; + grid->height = height; + grid->surfaceType = SF_GRID; + ClearBounds( grid->meshBounds[0], grid->meshBounds[1] ); + for ( i = 0 ; i < width ; i++ ) { + for ( j = 0 ; j < height ; j++ ) { + vert = &grid->verts[j*width+i]; + *vert = ctrl[j][i]; + AddPointToBounds( vert->xyz, grid->meshBounds[0], grid->meshBounds[1] ); + } + } + + // compute local origin and bounds + VectorAdd( grid->meshBounds[0], grid->meshBounds[1], grid->localOrigin ); + VectorScale( grid->localOrigin, 0.5f, grid->localOrigin ); + VectorSubtract( grid->meshBounds[0], grid->localOrigin, tmpVec ); + grid->meshRadius = VectorLength( tmpVec ); + + VectorCopy( grid->localOrigin, grid->lodOrigin ); + grid->lodRadius = grid->meshRadius; + // + return grid; +} + +/* +================= +R_FreeSurfaceGridMesh +================= +*/ +void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) { + ri.Free(grid->widthLodError); + ri.Free(grid->heightLodError); + ri.Free(grid->triangles); + ri.Free(grid->verts); + ri.Free(grid); +} + +/* +================= +R_SubdividePatchToGrid +================= +*/ +srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, + srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { + int i, j, k, l; + srfVert_t_cleared( prev ); + srfVert_t_cleared( next ); + srfVert_t_cleared( mid ); + float len, maxLen; + int dir; + int t; + srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; + float errorTable[2][MAX_GRID_SIZE]; + int numTriangles; + static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + int consecutiveComplete; + + for ( i = 0 ; i < width ; i++ ) { + for ( j = 0 ; j < height ; j++ ) { + ctrl[j][i] = points[j*width+i]; + } + } + + for ( dir = 0 ; dir < 2 ; dir++ ) { + + for ( j = 0 ; j < MAX_GRID_SIZE ; j++ ) { + errorTable[dir][j] = 0; + } + + consecutiveComplete = 0; + + // horizontal subdivisions + for ( j = 0 ; ; j = (j + 2) % (width - 1) ) { + // check subdivided midpoints against control points + + // FIXME: also check midpoints of adjacent patches against the control points + // this would basically stitch all patches in the same LOD group together. + + maxLen = 0; + for ( i = 0 ; i < height ; i++ ) { + vec3_t midxyz; + vec3_t midxyz2; + vec3_t dir; + vec3_t projected; + float d; + + // calculate the point on the curve + for ( l = 0 ; l < 3 ; l++ ) { + midxyz[l] = (ctrl[i][j].xyz[l] + ctrl[i][j+1].xyz[l] * 2 + + ctrl[i][j+2].xyz[l] ) * 0.25f; + } + + // see how far off the line it is + // using dist-from-line will not account for internal + // texture warping, but it gives a lot less polygons than + // dist-from-midpoint + VectorSubtract( midxyz, ctrl[i][j].xyz, midxyz ); + VectorSubtract( ctrl[i][j+2].xyz, ctrl[i][j].xyz, dir ); + VectorNormalize( dir ); + + d = DotProduct( midxyz, dir ); + VectorScale( dir, d, projected ); + VectorSubtract( midxyz, projected, midxyz2); + len = VectorLengthSquared( midxyz2 ); // we will do the sqrt later + if ( len > maxLen ) { + maxLen = len; + } + } + + maxLen = sqrt(maxLen); + + // if all the points are on the lines, remove the entire columns + if ( maxLen < 0.1f ) { + errorTable[dir][j+1] = 999; + // if we go over the whole grid twice without adding any columns, stop + if (++consecutiveComplete >= width) + break; + continue; + } + + // see if we want to insert subdivided columns + if ( width + 2 > MAX_GRID_SIZE ) { + errorTable[dir][j+1] = 1.0f/maxLen; + break; // can't subdivide any more + } + + if ( maxLen <= r_subdivisions->value ) { + errorTable[dir][j+1] = 1.0f/maxLen; + // if we go over the whole grid twice without adding any columns, stop + if (++consecutiveComplete >= width) + break; + continue; // didn't need subdivision + } + + errorTable[dir][j+2] = 1.0f/maxLen; + + consecutiveComplete = 0; + + // insert two columns and replace the peak + width += 2; + for ( i = 0 ; i < height ; i++ ) { + LerpDrawVert( &ctrl[i][j], &ctrl[i][j+1], &prev ); + LerpDrawVert( &ctrl[i][j+1], &ctrl[i][j+2], &next ); + LerpDrawVert( &prev, &next, &mid ); + + for ( k = width - 1 ; k > j + 3 ; k-- ) { + ctrl[i][k] = ctrl[i][k-2]; + } + ctrl[i][j + 1] = prev; + ctrl[i][j + 2] = mid; + ctrl[i][j + 3] = next; + } + + // skip the new one, we'll get it on the next pass + j += 2; + } + + Transpose( width, height, ctrl ); + t = width; + width = height; + height = t; + } + + + // put all the aproximating points on the curve + PutPointsOnCurve( ctrl, width, height ); + + // cull out any rows or columns that are colinear + for ( i = 1 ; i < width-1 ; i++ ) { + if ( errorTable[0][i] != 999 ) { + continue; + } + for ( j = i+1 ; j < width ; j++ ) { + for ( k = 0 ; k < height ; k++ ) { + ctrl[k][j-1] = ctrl[k][j]; + } + errorTable[0][j-1] = errorTable[0][j]; + } + width--; + } + + for ( i = 1 ; i < height-1 ; i++ ) { + if ( errorTable[1][i] != 999 ) { + continue; + } + for ( j = i+1 ; j < height ; j++ ) { + for ( k = 0 ; k < width ; k++ ) { + ctrl[j-1][k] = ctrl[j][k]; + } + errorTable[1][j-1] = errorTable[1][j]; + } + height--; + } + +#if 1 + // flip for longest tristrips as an optimization + // the results should be visually identical with or + // without this step + if ( height > width ) { + Transpose( width, height, ctrl ); + InvertErrorTable( errorTable, width, height ); + t = width; + width = height; + height = t; + InvertCtrl( width, height, ctrl ); + } +#endif + + // calculate triangles + numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + + // calculate normals + MakeMeshNormals( width, height, ctrl ); +#ifdef USE_VERT_TANGENT_SPACE + MakeMeshTangentVectors(width, height, ctrl, numTriangles, triangles); +#endif + + return R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); +} + +/* +=============== +R_GridInsertColumn +=============== +*/ +srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ) { + int i, j; + int width, height, oldwidth; + srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; + float errorTable[2][MAX_GRID_SIZE]; + float lodRadius; + vec3_t lodOrigin; + int numTriangles; + static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + + oldwidth = 0; + width = grid->width + 1; + if (width > MAX_GRID_SIZE) + return NULL; + height = grid->height; + for (i = 0; i < width; i++) { + if (i == column) { + //insert new column + for (j = 0; j < grid->height; j++) { + LerpDrawVert( &grid->verts[j * grid->width + i-1], &grid->verts[j * grid->width + i], &ctrl[j][i] ); + if (j == row) + VectorCopy(point, ctrl[j][i].xyz); + } + errorTable[0][i] = loderror; + continue; + } + errorTable[0][i] = grid->widthLodError[oldwidth]; + for (j = 0; j < grid->height; j++) { + ctrl[j][i] = grid->verts[j * grid->width + oldwidth]; + } + oldwidth++; + } + for (j = 0; j < grid->height; j++) { + errorTable[1][j] = grid->heightLodError[j]; + } + // put all the aproximating points on the curve + //PutPointsOnCurve( ctrl, width, height ); + + // calculate triangles + numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + + // calculate normals + MakeMeshNormals( width, height, ctrl ); + + VectorCopy(grid->lodOrigin, lodOrigin); + lodRadius = grid->lodRadius; + // free the old grid + R_FreeSurfaceGridMesh(grid); + // create a new grid + grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); + grid->lodRadius = lodRadius; + VectorCopy(lodOrigin, grid->lodOrigin); + return grid; +} + +/* +=============== +R_GridInsertRow +=============== +*/ +srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ) { + int i, j; + int width, height, oldheight; + srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; + float errorTable[2][MAX_GRID_SIZE]; + float lodRadius; + vec3_t lodOrigin; + int numTriangles; + static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + + oldheight = 0; + width = grid->width; + height = grid->height + 1; + if (height > MAX_GRID_SIZE) + return NULL; + for (i = 0; i < height; i++) { + if (i == row) { + //insert new row + for (j = 0; j < grid->width; j++) { + LerpDrawVert( &grid->verts[(i-1) * grid->width + j], &grid->verts[i * grid->width + j], &ctrl[i][j] ); + if (j == column) + VectorCopy(point, ctrl[i][j].xyz); + } + errorTable[1][i] = loderror; + continue; + } + errorTable[1][i] = grid->heightLodError[oldheight]; + for (j = 0; j < grid->width; j++) { + ctrl[i][j] = grid->verts[oldheight * grid->width + j]; + } + oldheight++; + } + for (j = 0; j < grid->width; j++) { + errorTable[0][j] = grid->widthLodError[j]; + } + // put all the aproximating points on the curve + //PutPointsOnCurve( ctrl, width, height ); + + // calculate triangles + numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + + // calculate normals + MakeMeshNormals( width, height, ctrl ); + + VectorCopy(grid->lodOrigin, lodOrigin); + lodRadius = grid->lodRadius; + // free the old grid + R_FreeSurfaceGridMesh(grid); + // create a new grid + grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); + grid->lodRadius = lodRadius; + VectorCopy(lodOrigin, grid->lodOrigin); + return grid; +} diff --git a/codemp/rd-rend2/tr_extensions.c b/codemp/rd-rend2/tr_extensions.c new file mode 100644 index 0000000000..0b70d48b8a --- /dev/null +++ b/codemp/rd-rend2/tr_extensions.c @@ -0,0 +1,667 @@ +/* +=========================================================================== +Copyright (C) 2011 James Canete (use.less01@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_extensions.c - extensions needed by the renderer not in sdl_glimp.c + +#ifdef USE_LOCAL_HEADERS +# include "SDL.h" +#else +# include +#endif + +#include "tr_local.h" + +// GL_EXT_draw_range_elements +void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +// GL_EXT_multi_draw_arrays +void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +void (APIENTRY * qglMultiDrawElementsEXT) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); + +// GL_ARB_vertex_shader +void (APIENTRY * qglBindAttribLocationARB) (GLhandleARB programObj, GLuint index, const GLcharARB * name); +void (APIENTRY * qglGetActiveAttribARB) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, + GLint * size, GLenum * type, GLcharARB * name); +GLint(APIENTRY * qglGetAttribLocationARB) (GLhandleARB programObj, const GLcharARB * name); + +// GL_ARB_vertex_program +void (APIENTRY * qglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +void (APIENTRY * qglVertexAttrib4fvARB) (GLuint, const GLfloat *); +void (APIENTRY * qglVertexAttribPointerARB) (GLuint index, GLint size, GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid * pointer); +void (APIENTRY * qglEnableVertexAttribArrayARB) (GLuint index); +void (APIENTRY * qglDisableVertexAttribArrayARB) (GLuint index); + +// GL_ARB_vertex_buffer_object +void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer); +void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); +void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); + +GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); +void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); +void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); +void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); + +void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); +void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params); + +// GL_ARB_shader_objects +void (APIENTRY * qglDeleteObjectARB) (GLhandleARB obj); + +GLhandleARB(APIENTRY * qglGetHandleARB) (GLenum pname); +void (APIENTRY * qglDetachObjectARB) (GLhandleARB containerObj, GLhandleARB attachedObj); + +GLhandleARB(APIENTRY * qglCreateShaderObjectARB) (GLenum shaderType); +void (APIENTRY * qglShaderSourceARB) (GLhandleARB shaderObj, GLsizei count, const GLcharARB * *string, + const GLint * length); +void (APIENTRY * qglCompileShaderARB) (GLhandleARB shaderObj); + +GLhandleARB(APIENTRY * qglCreateProgramObjectARB) (void); +void (APIENTRY * qglAttachObjectARB) (GLhandleARB containerObj, GLhandleARB obj); +void (APIENTRY * qglLinkProgramARB) (GLhandleARB programObj); +void (APIENTRY * qglUseProgramObjectARB) (GLhandleARB programObj); +void (APIENTRY * qglValidateProgramARB) (GLhandleARB programObj); +void (APIENTRY * qglUniform1fARB) (GLint location, GLfloat v0); +void (APIENTRY * qglUniform2fARB) (GLint location, GLfloat v0, GLfloat v1); +void (APIENTRY * qglUniform3fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +void (APIENTRY * qglUniform4fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +void (APIENTRY * qglUniform1iARB) (GLint location, GLint v0); +void (APIENTRY * qglUniform2iARB) (GLint location, GLint v0, GLint v1); +void (APIENTRY * qglUniform3iARB) (GLint location, GLint v0, GLint v1, GLint v2); +void (APIENTRY * qglUniform4iARB) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +void (APIENTRY * qglUniform1fvARB) (GLint location, GLsizei count, const GLfloat * value); +void (APIENTRY * qglUniform2fvARB) (GLint location, GLsizei count, const GLfloat * value); +void (APIENTRY * qglUniform3fvARB) (GLint location, GLsizei count, const GLfloat * value); +void (APIENTRY * qglUniform4fvARB) (GLint location, GLsizei count, const GLfloat * value); +void (APIENTRY * qglUniform2ivARB) (GLint location, GLsizei count, const GLint * value); +void (APIENTRY * qglUniform3ivARB) (GLint location, GLsizei count, const GLint * value); +void (APIENTRY * qglUniform4ivARB) (GLint location, GLsizei count, const GLint * value); +void (APIENTRY * qglUniformMatrix2fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +void (APIENTRY * qglUniformMatrix3fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +void (APIENTRY * qglUniformMatrix4fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +void (APIENTRY * qglGetObjectParameterfvARB) (GLhandleARB obj, GLenum pname, GLfloat * params); +void (APIENTRY * qglGetObjectParameterivARB) (GLhandleARB obj, GLenum pname, GLint * params); +void (APIENTRY * qglGetInfoLogARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog); +void (APIENTRY * qglGetAttachedObjectsARB) (GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, + GLhandleARB * obj); +GLint(APIENTRY * qglGetUniformLocationARB) (GLhandleARB programObj, const GLcharARB * name); +void (APIENTRY * qglGetActiveUniformARB) (GLhandleARB programObj, GLuint index, GLsizei maxIndex, GLsizei * length, + GLint * size, GLenum * type, GLcharARB * name); +void (APIENTRY * qglGetUniformfvARB) (GLhandleARB programObj, GLint location, GLfloat * params); +void (APIENTRY * qglGetUniformivARB) (GLhandleARB programObj, GLint location, GLint * params); +void (APIENTRY * qglGetShaderSourceARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source); + +// GL_ARB_texture_compression +void (APIENTRY * qglCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data); +void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod, + GLvoid *img); + +// GL_EXT_framebuffer_object +GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer); +void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); +void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers); +void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers); + +void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); + +void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params); + +GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer); +void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer); +void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); +void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); + +GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target); + +void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level); +void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level); +void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset); + +void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer); + +void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params); + +void (APIENTRY * qglGenerateMipmapEXT)(GLenum target); + +// GL_ARB_occlusion_query +void (APIENTRY * qglGenQueriesARB)(GLsizei n, GLuint *ids); +void (APIENTRY * qglDeleteQueriesARB)(GLsizei n, const GLuint *ids); +GLboolean (APIENTRY * qglIsQueryARB)(GLuint id); +void (APIENTRY * qglBeginQueryARB)(GLenum target, GLuint id); +void (APIENTRY * qglEndQueryARB)(GLenum target); +void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); +void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); +void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); + +// GL_EXT_framebuffer_blit +void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + +// GL_EXT_framebuffer_multisample +void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height); + +// GL_ARB_draw_buffers +void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); + +static qboolean GLimp_HaveExtension(const char *ext) +{ + const char *ptr = Q_stristr( glConfig.extensions_string, ext ); + if (ptr == NULL) + return qfalse; + ptr += strlen(ext); + return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. +} + +void GLimp_InitExtraExtensions() +{ + char *extension; + const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; + + // GL_EXT_draw_range_elements + extension = "GL_EXT_draw_range_elements"; + glRefConfig.drawRangeElements = qfalse; + qglMultiDrawArraysEXT = NULL; + qglMultiDrawElementsEXT = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglDrawRangeElementsEXT = (void *) SDL_GL_GetProcAddress("glDrawRangeElementsEXT"); + + if ( r_ext_draw_range_elements->integer) + glRefConfig.drawRangeElements = qtrue; + + ri.Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_multi_draw_arrays + extension = "GL_EXT_multi_draw_arrays"; + glRefConfig.multiDrawArrays = qfalse; + qglMultiDrawArraysEXT = NULL; + qglMultiDrawElementsEXT = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) SDL_GL_GetProcAddress("glMultiDrawArraysEXT"); + qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) SDL_GL_GetProcAddress("glMultiDrawElementsEXT"); + + if ( r_ext_multi_draw_arrays->integer ) + glRefConfig.multiDrawArrays = qtrue; + + ri.Printf(PRINT_ALL, result[glRefConfig.multiDrawArrays], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_vertex_program + //glRefConfig.vertexProgram = qfalse; + extension = "GL_ARB_vertex_program"; + qglVertexAttrib4fARB = NULL; + qglVertexAttrib4fvARB = NULL; + qglVertexAttribPointerARB = NULL; + qglEnableVertexAttribArrayARB = NULL; + qglDisableVertexAttribArrayARB = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) SDL_GL_GetProcAddress("glVertexAttrib4fARB"); + qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) SDL_GL_GetProcAddress("glVertexAttrib4fvARB"); + qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) SDL_GL_GetProcAddress("glVertexAttribPointerARB"); + qglEnableVertexAttribArrayARB = + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) SDL_GL_GetProcAddress("glEnableVertexAttribArrayARB"); + qglDisableVertexAttribArrayARB = + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) SDL_GL_GetProcAddress("glDisableVertexAttribArrayARB"); + + ri.Printf(PRINT_ALL, result[1], extension); + //glRefConfig.vertexProgram = qtrue; + } + else + { + ri.Error(ERR_FATAL, result[2], extension); + } + + // GL_ARB_vertex_buffer_object + //glRefConfig.vertexBufferObject = qfalse; + extension = "GL_ARB_vertex_buffer_object"; + qglBindBufferARB = NULL; + qglDeleteBuffersARB = NULL; + qglGenBuffersARB = NULL; + qglIsBufferARB = NULL; + qglBufferDataARB = NULL; + qglBufferSubDataARB = NULL; + qglGetBufferSubDataARB = NULL; + qglGetBufferParameterivARB = NULL; + qglGetBufferPointervARB = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) SDL_GL_GetProcAddress("glBindBufferARB"); + qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) SDL_GL_GetProcAddress("glDeleteBuffersARB"); + qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB"); + qglIsBufferARB = (PFNGLISBUFFERARBPROC) SDL_GL_GetProcAddress("glIsBufferARB"); + qglBufferDataARB = (PFNGLBUFFERDATAARBPROC) SDL_GL_GetProcAddress("glBufferDataARB"); + qglBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) SDL_GL_GetProcAddress("glBufferSubDataARB"); + qglGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) SDL_GL_GetProcAddress("glGetBufferSubDataARB"); + qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetBufferParameterivARB"); + qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) SDL_GL_GetProcAddress("glGetBufferPointervARB"); + ri.Printf(PRINT_ALL, result[1], extension); + //glRefConfig.vertexBufferObject = qtrue; + } + else + { + ri.Error(ERR_FATAL, result[2], extension); + } + + // GL_ARB_shader_objects + extension = "GL_ARB_shader_objects"; + //glRefConfig.shaderObjects = qfalse; + qglDeleteObjectARB = NULL; + qglGetHandleARB = NULL; + qglDetachObjectARB = NULL; + qglCreateShaderObjectARB = NULL; + qglShaderSourceARB = NULL; + qglCompileShaderARB = NULL; + qglCreateProgramObjectARB = NULL; + qglAttachObjectARB = NULL; + qglLinkProgramARB = NULL; + qglUseProgramObjectARB = NULL; + qglValidateProgramARB = NULL; + qglUniform1fARB = NULL; + qglUniform2fARB = NULL; + qglUniform3fARB = NULL; + qglUniform4fARB = NULL; + qglUniform1iARB = NULL; + qglUniform2iARB = NULL; + qglUniform3iARB = NULL; + qglUniform4iARB = NULL; + qglUniform1fvARB = NULL; + qglUniform2fvARB = NULL; + qglUniform3fvARB = NULL; + qglUniform4fvARB = NULL; + qglUniform2ivARB = NULL; + qglUniform3ivARB = NULL; + qglUniform4ivARB = NULL; + qglUniformMatrix2fvARB = NULL; + qglUniformMatrix3fvARB = NULL; + qglUniformMatrix4fvARB = NULL; + qglGetObjectParameterfvARB = NULL; + qglGetObjectParameterivARB = NULL; + qglGetInfoLogARB = NULL; + qglGetAttachedObjectsARB = NULL; + qglGetUniformLocationARB = NULL; + qglGetActiveUniformARB = NULL; + qglGetUniformfvARB = NULL; + qglGetUniformivARB = NULL; + qglGetShaderSourceARB = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); + qglGetHandleARB = (PFNGLGETHANDLEARBPROC) SDL_GL_GetProcAddress("glGetHandleARB"); + qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) SDL_GL_GetProcAddress("glDetachObjectARB"); + qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); + qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); + qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); + qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); + qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) SDL_GL_GetProcAddress("glValidateProgramARB"); + qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); + qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) SDL_GL_GetProcAddress("glUniform2fARB"); + qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) SDL_GL_GetProcAddress("glUniform3fARB"); + qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) SDL_GL_GetProcAddress("glUniform4fARB"); + qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); + qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) SDL_GL_GetProcAddress("glUniform2iARB"); + qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) SDL_GL_GetProcAddress("glUniform3iARB"); + qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) SDL_GL_GetProcAddress("glUniform4iARB"); + qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) SDL_GL_GetProcAddress("glUniform1fvARB"); + qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) SDL_GL_GetProcAddress("glUniform2fvARB"); + qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) SDL_GL_GetProcAddress("glUniform3fvARB"); + qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) SDL_GL_GetProcAddress("glUniform4fvARB"); + qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) SDL_GL_GetProcAddress("glUniform2ivARB"); + qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) SDL_GL_GetProcAddress("glUniform3ivARB"); + qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) SDL_GL_GetProcAddress("glUniform4ivARB"); + qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix2fvARB"); + qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix3fvARB"); + qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix4fvARB"); + qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterfvARB"); + qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); + qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) SDL_GL_GetProcAddress("glGetAttachedObjectsARB"); + qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); + qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) SDL_GL_GetProcAddress("glGetActiveUniformARB"); + qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) SDL_GL_GetProcAddress("glGetUniformfvARB"); + qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) SDL_GL_GetProcAddress("glGetUniformivARB"); + qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glGetShaderSourceARB"); + ri.Printf(PRINT_ALL, result[1], extension); + //glRefConfig.shaderObjects = qtrue; + } + else + { + ri.Error(ERR_FATAL, result[2], extension); + } + + // GL_ARB_vertex_shader + //glRefConfig.vertexShader = qfalse; + extension = "GL_ARB_vertex_shader"; + qglBindAttribLocationARB = NULL; + qglGetActiveAttribARB = NULL; + qglGetAttribLocationARB = NULL; + if( GLimp_HaveExtension( extension ) ) + { + //int reservedComponents; + + //qglGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.maxVertexUniforms); + //qglGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &glConfig.maxVaryingFloats); + //qglGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.maxVertexAttribs); + + //reservedComponents = 16 * 10; // approximation how many uniforms we have besides the bone matrices + +#if 0 + if(glConfig.driverType == GLDRV_MESA) + { + // HACK + // restrict to number of vertex uniforms to 512 because of: + // xreal.x86_64: nv50_program.c:4181: nv50_program_validate_data: Assertion `p->param_nr <= 512' failed + + glConfig.maxVertexUniforms = Q_bound(0, glConfig.maxVertexUniforms, 512); + } +#endif + + //glConfig.maxVertexSkinningBones = (int) Q_bound(0.0, (Q_max(glConfig.maxVertexUniforms - reservedComponents, 0) / 16), MAX_BONES); + //glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ((glConfig.maxVertexSkinningBones >= 12) ? qtrue : qfalse); + + qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glBindAttribLocationARB"); + qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) SDL_GL_GetProcAddress("glGetActiveAttribARB"); + qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetAttribLocationARB"); + ri.Printf(PRINT_ALL, result[1], extension); + //glRefConfig.vertexShader = qtrue; + } + else + { + ri.Error(ERR_FATAL, result[2], extension); + } + + // GL_ARB_shading_language_100 + extension = "GL_ARB_shading_language_100"; + glRefConfig.textureFloat = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + char version[256]; + + Q_strncpyz( version, (char *) qglGetString (GL_SHADING_LANGUAGE_VERSION_ARB), sizeof( version ) ); + + sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); + + ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version); + } + else + { + ri.Error(ERR_FATAL, result[2], extension); + } + + glRefConfig.memInfo = MI_NONE; + + if( GLimp_HaveExtension( "GL_NVX_gpu_memory_info" ) ) + { + glRefConfig.memInfo = MI_NVX; + } + else if( GLimp_HaveExtension( "GL_ATI_meminfo" ) ) + { + glRefConfig.memInfo = MI_ATI; + } + + extension = "GL_ARB_texture_non_power_of_two"; + glRefConfig.textureNonPowerOfTwo = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + if(1) //(r_ext_texture_non_power_of_two->integer) + { + glRefConfig.textureNonPowerOfTwo = qtrue; + } + + ri.Printf(PRINT_ALL, result[glRefConfig.textureNonPowerOfTwo], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_texture_float + extension = "GL_ARB_texture_float"; + glRefConfig.textureFloat = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + if( r_ext_texture_float->integer ) + { + glRefConfig.textureFloat = qtrue; + } + + ri.Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_half_float_pixel + extension = "GL_ARB_half_float_pixel"; + glRefConfig.halfFloatPixel = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + if( r_arb_half_float_pixel->integer ) + glRefConfig.halfFloatPixel = qtrue; + + ri.Printf(PRINT_ALL, result[glRefConfig.halfFloatPixel], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_framebuffer_object + extension = "GL_EXT_framebuffer_object"; + glRefConfig.framebufferObject = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); + glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); + + qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsRenderbufferEXT"); + qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindRenderbufferEXT"); + qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteRenderbuffersEXT"); + qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenRenderbuffersEXT"); + qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) SDL_GL_GetProcAddress("glRenderbufferStorageEXT"); + qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetRenderbufferParameterivEXT"); + qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsFramebufferEXT"); + qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindFramebufferEXT"); + qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteFramebuffersEXT"); + qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT"); + qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT"); + qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture1DEXT"); + qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture2DEXT"); + qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture3DEXT"); + qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT"); + qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) SDL_GL_GetProcAddress("glGenerateMipmapEXT"); + + if(r_ext_framebuffer_object->value) + glRefConfig.framebufferObject = qtrue; + + ri.Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_packed_depth_stencil + extension = "GL_EXT_packed_depth_stencil"; + glRefConfig.packedDepthStencil = qfalse; + if( GLimp_HaveExtension(extension)) + { + glRefConfig.packedDepthStencil = qtrue; + ri.Printf(PRINT_ALL, result[glRefConfig.packedDepthStencil], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_occlusion_query + extension = "GL_ARB_occlusion_query"; + glRefConfig.occlusionQuery = qfalse; + if (GLimp_HaveExtension(extension)) + { + qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) SDL_GL_GetProcAddress("glGenQueriesARB"); + qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) SDL_GL_GetProcAddress("glDeleteQueriesARB"); + qglIsQueryARB = (PFNGLISQUERYARBPROC) SDL_GL_GetProcAddress("glIsQueryARB"); + qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) SDL_GL_GetProcAddress("glBeginQueryARB"); + qglEndQueryARB = (PFNGLENDQUERYARBPROC) SDL_GL_GetProcAddress("glEndQueryARB"); + qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) SDL_GL_GetProcAddress("glGetQueryivARB"); + qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectivARB"); + qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectuivARB"); + glRefConfig.occlusionQuery = qtrue; + ri.Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_framebuffer_blit + extension = "GL_EXT_framebuffer_blit"; + glRefConfig.framebufferBlit = qfalse; + if (GLimp_HaveExtension(extension)) + { + qglBlitFramebufferEXT = (void *)SDL_GL_GetProcAddress("glBlitFramebufferEXT"); + glRefConfig.framebufferBlit = qtrue; + ri.Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_framebuffer_multisample + extension = "GL_EXT_framebuffer_multisample"; + glRefConfig.framebufferMultisample = qfalse; + if (GLimp_HaveExtension(extension)) + { + qglRenderbufferStorageMultisampleEXT = (void *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); + glRefConfig.framebufferMultisample = qtrue; + ri.Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_texture_sRGB + extension = "GL_EXT_texture_sRGB"; + glRefConfig.texture_srgb = qfalse; + if (GLimp_HaveExtension(extension)) + { + if (r_srgb->integer) + glRefConfig.texture_srgb = qtrue; + + ri.Printf(PRINT_ALL, result[glRefConfig.texture_srgb], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + glRefConfig.textureCompression = TCR_NONE; + + // GL_EXT_texture_compression_latc + extension = "GL_EXT_texture_compression_latc"; + if (GLimp_HaveExtension(extension)) + { + if (r_ext_compressed_textures->integer) + glRefConfig.textureCompression |= TCR_LATC; + + ri.Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_texture_compression_bptc + extension = "GL_ARB_texture_compression_bptc"; + if (GLimp_HaveExtension(extension)) + { + if (r_ext_compressed_textures->integer >= 2) + glRefConfig.textureCompression |= TCR_BPTC; + + ri.Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_draw_buffers + extension = "GL_ARB_draw_buffers"; + qglDrawBuffersARB = NULL; + if( GLimp_HaveExtension( extension ) ) + { + qglDrawBuffersARB = (void *) SDL_GL_GetProcAddress("glDrawBuffersARB"); + + ri.Printf(PRINT_ALL, result[1], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } + + // GL_ARB_depth_clamp + extension = "GL_ARB_depth_clamp"; + glRefConfig.depthClamp = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + glRefConfig.depthClamp = qtrue; + ri.Printf(PRINT_ALL, result[1], extension); + } + else + { + ri.Printf(PRINT_ALL, result[2], extension); + } +} diff --git a/codemp/rd-rend2/tr_extramath.c b/codemp/rd-rend2/tr_extramath.c new file mode 100644 index 0000000000..8cb6fe1a61 --- /dev/null +++ b/codemp/rd-rend2/tr_extramath.c @@ -0,0 +1,240 @@ +/* +=========================================================================== +Copyright (C) 2010 James Canete (use.less01@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_extramath.c - extra math needed by the renderer not in qmath.c + +#include "tr_local.h" + +// Some matrix helper functions +// FIXME: do these already exist in ioq3 and I don't know about them? + +void Matrix16Zero( matrix_t out ) +{ + out[ 0] = 0.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f; + out[ 1] = 0.0f; out[ 5] = 0.0f; out[ 9] = 0.0f; out[13] = 0.0f; + out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 0.0f; out[14] = 0.0f; + out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 0.0f; +} + +void Matrix16Identity( matrix_t out ) +{ + out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = 0.0f; + out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = 0.0f; + out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = 0.0f; + out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; +} + +void Matrix16Copy( const matrix_t in, matrix_t out ) +{ + out[ 0] = in[ 0]; out[ 4] = in[ 4]; out[ 8] = in[ 8]; out[12] = in[12]; + out[ 1] = in[ 1]; out[ 5] = in[ 5]; out[ 9] = in[ 9]; out[13] = in[13]; + out[ 2] = in[ 2]; out[ 6] = in[ 6]; out[10] = in[10]; out[14] = in[14]; + out[ 3] = in[ 3]; out[ 7] = in[ 7]; out[11] = in[11]; out[15] = in[15]; +} + +void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out ) +{ + out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3]; + out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3]; + out[ 2] = in1[ 2] * in2[ 0] + in1[ 6] * in2[ 1] + in1[10] * in2[ 2] + in1[14] * in2[ 3]; + out[ 3] = in1[ 3] * in2[ 0] + in1[ 7] * in2[ 1] + in1[11] * in2[ 2] + in1[15] * in2[ 3]; + + out[ 4] = in1[ 0] * in2[ 4] + in1[ 4] * in2[ 5] + in1[ 8] * in2[ 6] + in1[12] * in2[ 7]; + out[ 5] = in1[ 1] * in2[ 4] + in1[ 5] * in2[ 5] + in1[ 9] * in2[ 6] + in1[13] * in2[ 7]; + out[ 6] = in1[ 2] * in2[ 4] + in1[ 6] * in2[ 5] + in1[10] * in2[ 6] + in1[14] * in2[ 7]; + out[ 7] = in1[ 3] * in2[ 4] + in1[ 7] * in2[ 5] + in1[11] * in2[ 6] + in1[15] * in2[ 7]; + + out[ 8] = in1[ 0] * in2[ 8] + in1[ 4] * in2[ 9] + in1[ 8] * in2[10] + in1[12] * in2[11]; + out[ 9] = in1[ 1] * in2[ 8] + in1[ 5] * in2[ 9] + in1[ 9] * in2[10] + in1[13] * in2[11]; + out[10] = in1[ 2] * in2[ 8] + in1[ 6] * in2[ 9] + in1[10] * in2[10] + in1[14] * in2[11]; + out[11] = in1[ 3] * in2[ 8] + in1[ 7] * in2[ 9] + in1[11] * in2[10] + in1[15] * in2[11]; + + out[12] = in1[ 0] * in2[12] + in1[ 4] * in2[13] + in1[ 8] * in2[14] + in1[12] * in2[15]; + out[13] = in1[ 1] * in2[12] + in1[ 5] * in2[13] + in1[ 9] * in2[14] + in1[13] * in2[15]; + out[14] = in1[ 2] * in2[12] + in1[ 6] * in2[13] + in1[10] * in2[14] + in1[14] * in2[15]; + out[15] = in1[ 3] * in2[12] + in1[ 7] * in2[13] + in1[11] * in2[14] + in1[15] * in2[15]; +} + +void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out ) +{ + out[ 0] = in1[ 0] * in2[ 0] + in1[ 4] * in2[ 1] + in1[ 8] * in2[ 2] + in1[12] * in2[ 3]; + out[ 1] = in1[ 1] * in2[ 0] + in1[ 5] * in2[ 1] + in1[ 9] * in2[ 2] + in1[13] * in2[ 3]; + out[ 2] = in1[ 2] * in2[ 0] + in1[ 6] * in2[ 1] + in1[10] * in2[ 2] + in1[14] * in2[ 3]; + out[ 3] = in1[ 3] * in2[ 0] + in1[ 7] * in2[ 1] + in1[11] * in2[ 2] + in1[15] * in2[ 3]; +} + +qboolean Matrix16Compare( const matrix_t a, const matrix_t b ) +{ + return !(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] || + a[ 1] != b[ 1] || a[ 5] != b[ 5] || a[ 9] != b[ 9] || a[13] != b[13] || + a[ 2] != b[ 2] || a[ 6] != b[ 6] || a[10] != b[10] || a[14] != b[14] || + a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15]); +} + +void Matrix16Dump( const matrix_t in ) +{ + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); +} + +void Matrix16Translation( vec3_t vec, matrix_t out ) +{ + out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = vec[0]; + out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = vec[1]; + out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 1.0f; out[14] = vec[2]; + out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; +} + +void Matrix16Ortho( float left, float right, float bottom, float top, float znear, float zfar, matrix_t out ) +{ + out[ 0] = 2.0f / (right - left); out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = -(right + left) / (right - left); + out[ 1] = 0.0f; out[ 5] = 2.0f / (top - bottom); out[ 9] = 0.0f; out[13] = -(top + bottom) / (top - bottom); + out[ 2] = 0.0f; out[ 6] = 0.0f; out[10] = 2.0f / (zfar - znear); out[14] = -(zfar + znear) / (zfar - znear); + out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; +} + +void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out) +{ + out[0] = axes[0][0]; + out[1] = axes[1][0]; + out[2] = axes[2][0]; + out[3] = 0; + + out[4] = axes[0][1]; + out[5] = axes[1][1]; + out[6] = axes[2][1]; + out[7] = 0; + + out[8] = axes[0][2]; + out[9] = axes[1][2]; + out[10] = axes[2][2]; + out[11] = 0; + + out[12] = -DotProduct(origin, axes[0]); + out[13] = -DotProduct(origin, axes[1]); + out[14] = -DotProduct(origin, axes[2]); + out[15] = 1; +} + +void Matrix16SimpleInverse( const matrix_t in, matrix_t out) +{ + vec3_t v; + float invSqrLen; + + VectorCopy(in + 0, v); + invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + out[ 0] = v[0]; out[ 4] = v[1]; out[ 8] = v[2]; out[12] = -DotProduct(v, &in[12]); + + VectorCopy(in + 4, v); + invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + out[ 1] = v[0]; out[ 5] = v[1]; out[ 9] = v[2]; out[13] = -DotProduct(v, &in[12]); + + VectorCopy(in + 8, v); + invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + out[ 2] = v[0]; out[ 6] = v[1]; out[10] = v[2]; out[14] = -DotProduct(v, &in[12]); + + out[ 3] = 0.0f; out[ 7] = 0.0f; out[11] = 0.0f; out[15] = 1.0f; +} + +void VectorLerp( vec3_t a, vec3_t b, float lerp, vec3_t c) +{ + c[0] = a[0] * (1.0f - lerp) + b[0] * lerp; + c[1] = a[1] * (1.0f - lerp) + b[1] * lerp; + c[2] = a[2] * (1.0f - lerp) + b[2] * lerp; +} + +qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float radius2) +{ + float radiusSum = radius1 + radius2; + vec3_t diff; + + VectorSubtract(origin1, origin2, diff); + + if (DotProduct(diff, diff) <= radiusSum * radiusSum) + { + return qtrue; + } + + return qfalse; +} + +void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, float radius2, vec3_t origin3, float *radius3) +{ + vec3_t diff; + + VectorScale(origin1, 0.5f, origin3); + VectorMA(origin3, 0.5f, origin2, origin3); + + VectorSubtract(origin1, origin2, diff); + *radius3 = VectorLength(diff) * 0.5f + MAX(radius1, radius2); +} + +int NextPowerOfTwo(int in) +{ + int out; + + for (out = 1; out < in; out <<= 1) + ; + + return out; +} + +unsigned short FloatToHalf(float in) +{ + unsigned short out; + + union + { + float f; + unsigned int i; + } f32; + + int sign, inExponent, inFraction; + int outExponent, outFraction; + + f32.f = in; + + sign = (f32.i & 0x80000000) >> 31; + inExponent = (f32.i & 0x7F800000) >> 23; + inFraction = f32.i & 0x007FFFFF; + + outExponent = CLAMP(inExponent - 127, -15, 16) + 15; + + outFraction = 0; + if (outExponent == 0x1F) + { + if (inExponent == 0xFF && inFraction != 0) + outFraction = 0x3FF; + } + else if (outExponent == 0x00) + { + if (inExponent == 0x00 && inFraction != 0) + outFraction = 0x3FF; + } + else + outFraction = inFraction >> 13; + + out = (sign << 15) | (outExponent << 10) | outFraction; + + return out; +} diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h new file mode 100644 index 0000000000..3e11bb483c --- /dev/null +++ b/codemp/rd-rend2/tr_extramath.h @@ -0,0 +1,105 @@ +/* +=========================================================================== +Copyright (C) 2010 James Canete (use.less01@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_extramath.h + +#ifndef __TR_EXTRAMATH_H__ +#define __TR_EXTRAMATH_H__ + +typedef vec_t matrix_t[16]; +typedef int vec2i_t[2]; +typedef int vec3i_t[3]; +typedef int vec4i_t[4]; + +void Matrix16Zero( matrix_t out ); +void Matrix16Identity( matrix_t out ); +void Matrix16Copy( const matrix_t in, matrix_t out ); +void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out ); +void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out ); +qboolean Matrix16Compare(const matrix_t a, const matrix_t b); +void Matrix16Dump( const matrix_t in ); +void Matrix16Translation( vec3_t vec, matrix_t out ); +void Matrix16Ortho( float left, float right, float bottom, float top, float znear, float zfar, matrix_t out ); +void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out); +void Matrix16SimpleInverse( const matrix_t in, matrix_t out); + +#define VectorCopy2(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1]) +#define VectorSet2(v,x,y) ((v)[0]=(x),(v)[1]=(y)); + +#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) +#define VectorSet4(v,x,y,z,w) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z),(v)[3]=(w)) +#define DotProduct4(a,b) ((a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] + (a)[3]*(b)[3]) +#define VectorScale4(a,b,c) ((c)[0]=(a)[0]*(b),(c)[1]=(a)[1]*(b),(c)[2]=(a)[2]*(b),(c)[3]=(a)[3]*(b)) + +#define VectorCopy5(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3],(b)[4]=(a)[4]) + +#define OffsetByteToFloat(a) ((float)(a) * 1.0f/127.5f - 1.0f) +#define FloatToOffsetByte(a) (byte)(((a) + 1.0f) * 127.5f) +#define ByteToFloat(a) ((float)(a) * 1.0f/255.0f) +#define FloatToByte(a) (byte)((a) * 255.0f) + +#define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f)) +#define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) ) + +static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) +{ + if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) + { + return 0; + } + return 1; +} + +static ID_INLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) +{ + if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) + { + return 0; + } + return 1; +} + +void VectorLerp( vec3_t a, vec3_t b, float lerp, vec3_t c); + + +qboolean SpheresIntersect(vec3_t origin1, float radius1, vec3_t origin2, float radius2); +void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, float radius2, vec3_t origin3, float *radius3); + +#ifndef SGN +#define SGN(x) (((x) >= 0) ? !!(x) : -1) +#endif + +#ifndef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#endif + +#ifndef CLAMP +#define CLAMP(a,b,c) MIN(MAX((a),(b)),(c)) +#endif + +int NextPowerOfTwo(int in); +unsigned short FloatToHalf(float in); + +#endif diff --git a/codemp/rd-rend2/tr_extratypes.h b/codemp/rd-rend2/tr_extratypes.h new file mode 100644 index 0000000000..84e39a76ef --- /dev/null +++ b/codemp/rd-rend2/tr_extratypes.h @@ -0,0 +1,40 @@ +/* +=========================================================================== +Copyright (C) 2009-2011 Andrei Drexler, Richard Allen, James Canete + +This file is part of Reaction source code. + +Reaction source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Reaction source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Reaction source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __TR_EXTRATYPES_H__ +#define __TR_EXTRATYPES_H__ + +// tr_extratypes.h, for mods that want to extend tr_types.h without losing compatibility with original VMs + +// extra refdef flags start at 0x0008 +#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene +#define RDF_EXTRA 0x0010 // Makro - refdefex_t to follow after refdef_t +#define RDF_SUNLIGHT 0x0020 // SmileTheory - render sunlight and shadows + +typedef struct { + float blurFactor; + float sunDir[3]; + float sunCol[3]; + float sunAmbCol[3]; +} refdefex_t; + +#endif diff --git a/codemp/rd-rend2/tr_fbo.c b/codemp/rd-rend2/tr_fbo.c new file mode 100644 index 0000000000..fee11d5cf3 --- /dev/null +++ b/codemp/rd-rend2/tr_fbo.c @@ -0,0 +1,861 @@ +/* +=========================================================================== +Copyright (C) 2006 Kirk Barnes +Copyright (C) 2006-2008 Robert Beckebans + +This file is part of XreaL source code. + +XreaL source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +XreaL source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with XreaL source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_fbo.c +#include "tr_local.h" + +/* +============= +R_CheckFBO +============= +*/ +qboolean R_CheckFBO(const FBO_t * fbo) +{ + int code; + int id; + + qglGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &id); + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->frameBuffer); + + code = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + + if(code == GL_FRAMEBUFFER_COMPLETE_EXT) + { + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); + return qtrue; + } + + // an error occured + switch (code) + { + case GL_FRAMEBUFFER_COMPLETE_EXT: + break; + + case GL_FRAMEBUFFER_UNSUPPORTED_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing attachment\n", fbo->name); + break; + + //case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: + // ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, duplicate attachment\n", fbo->name); + // break; + + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same dimensions\n", + fbo->name); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same format\n", + fbo->name); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); + break; + + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); + break; + + default: + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); + //ri.Error(ERR_FATAL, "R_CheckFBO: (%s) unknown error 0x%X", fbo->name, code); + //assert(0); + break; + } + + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); + + return qfalse; +} + +/* +============ +FBO_Create +============ +*/ +FBO_t *FBO_Create(const char *name, int width, int height) +{ + FBO_t *fbo; + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); + } + + if(width <= 0 || width > glRefConfig.maxRenderbufferSize) + { + ri.Error(ERR_DROP, "FBO_Create: bad width %i", width); + } + + if(height <= 0 || height > glRefConfig.maxRenderbufferSize) + { + ri.Error(ERR_DROP, "FBO_Create: bad height %i", height); + } + + if(tr.numFBOs == MAX_FBOS) + { + ri.Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); + } + + fbo = tr.fbos[tr.numFBOs] = ri.Hunk_Alloc(sizeof(*fbo), h_low); + Q_strncpyz(fbo->name, name, sizeof(fbo->name)); + fbo->index = tr.numFBOs++; + fbo->width = width; + fbo->height = height; + + qglGenFramebuffersEXT(1, &fbo->frameBuffer); + + return fbo; +} + +void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) +{ + uint32_t *pRenderBuffer; + GLenum attachment; + qboolean absent; + + switch(format) + { + case GL_RGB: + case GL_RGBA: + case GL_RGB8: + case GL_RGBA8: + case GL_RGB16F_ARB: + case GL_RGBA16F_ARB: + case GL_RGB32F_ARB: + case GL_RGBA32F_ARB: + fbo->colorFormat = format; + pRenderBuffer = &fbo->colorBuffers[index]; + attachment = GL_COLOR_ATTACHMENT0_EXT + index; + break; + + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16_ARB: + case GL_DEPTH_COMPONENT24_ARB: + case GL_DEPTH_COMPONENT32_ARB: + fbo->depthFormat = format; + pRenderBuffer = &fbo->depthBuffer; + attachment = GL_DEPTH_ATTACHMENT_EXT; + break; + + case GL_STENCIL_INDEX: + case GL_STENCIL_INDEX1_EXT: + case GL_STENCIL_INDEX4_EXT: + case GL_STENCIL_INDEX8_EXT: + case GL_STENCIL_INDEX16_EXT: + fbo->stencilFormat = format; + pRenderBuffer = &fbo->stencilBuffer; + attachment = GL_STENCIL_ATTACHMENT_EXT; + break; + + case GL_DEPTH_STENCIL_EXT: + case GL_DEPTH24_STENCIL8_EXT: + fbo->packedDepthStencilFormat = format; + pRenderBuffer = &fbo->packedDepthStencilBuffer; + attachment = 0; // special for stencil and depth + break; + + default: + ri.Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); + return; + } + + absent = *pRenderBuffer == 0; + if (absent) + qglGenRenderbuffersEXT(1, pRenderBuffer); + + qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, *pRenderBuffer); + if (multisample && glRefConfig.framebufferMultisample) + { + qglRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, multisample, format, fbo->width, fbo->height); + } + else + { + qglRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, fbo->width, fbo->height); + } + + if(absent) + { + if (attachment == 0) + { + qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, *pRenderBuffer); + qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, *pRenderBuffer); + } + else + qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, *pRenderBuffer); + } +} + + +/* +================= +R_AttachFBOTexture1D +================= +*/ +void R_AttachFBOTexture1D(int texId, int index) +{ + if(index < 0 || index >= glRefConfig.maxColorAttachments) + { + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index); + return; + } + + qglFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_1D, texId, 0); +} + +/* +================= +R_AttachFBOTexture2D +================= +*/ +void R_AttachFBOTexture2D(int target, int texId, int index) +{ + if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) + { + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); + return; + } + + if(index < 0 || index >= glRefConfig.maxColorAttachments) + { + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); + return; + } + + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, target, texId, 0); +} + +/* +================= +R_AttachFBOTexture3D +================= +*/ +void R_AttachFBOTexture3D(int texId, int index, int zOffset) +{ + if(index < 0 || index >= glRefConfig.maxColorAttachments) + { + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture3D: invalid attachment index %i\n", index); + return; + } + + qglFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_3D_EXT, texId, 0, zOffset); +} + +/* +================= +R_AttachFBOTextureDepth +================= +*/ +void R_AttachFBOTextureDepth(int texId) +{ + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); +} + +/* +================= +R_AttachFBOTexturePackedDepthStencil +================= +*/ +void R_AttachFBOTexturePackedDepthStencil(int texId) +{ + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); +} + +void FBO_AttachTextureImage(image_t *img, int index) +{ + if (!glState.currentFBO) + { + ri.Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); + return; + } + + R_AttachFBOTexture2D(GL_TEXTURE_2D, img->texnum, index); + glState.currentFBO->colorImage[index] = img; +} + +/* +============ +FBO_Bind +============ +*/ +void FBO_Bind(FBO_t * fbo) +{ + if (glState.currentFBO == fbo) + return; + + if (r_logFile->integer) + { + // don't just call LogComment, or we will get a call to va() every frame! + if (fbo) + GLimp_LogComment(va("--- FBO_Bind( %s ) ---\n", fbo->name)); + else + GLimp_LogComment("--- FBO_Bind ( NULL ) ---\n"); + } + + if (!fbo) + { + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + //qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + glState.currentFBO = NULL; + + return; + } + + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->frameBuffer); + + /* + if(fbo->colorBuffers[0]) + { + qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo->colorBuffers[0]); + } + */ + + /* + if(fbo->depthBuffer) + { + qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo->depthBuffer); + qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthBuffer); + } + */ + + glState.currentFBO = fbo; +} + +/* +============ +FBO_Init +============ +*/ +void FBO_Init(void) +{ + int i; + // int width, height, hdrFormat, multisample; + int hdrFormat, multisample; + + ri.Printf(PRINT_ALL, "------- FBO_Init -------\n"); + + if(!glRefConfig.framebufferObject) + return; + + tr.numFBOs = 0; + + GL_CheckErrors(); + + R_IssuePendingRenderCommands(); + +/* if(glRefConfig.textureNonPowerOfTwo) + { + width = glConfig.vidWidth; + height = glConfig.vidHeight; + } + else + { + width = NextPowerOfTwo(glConfig.vidWidth); + height = NextPowerOfTwo(glConfig.vidHeight); + } */ + + hdrFormat = GL_RGBA8; + if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat) + { + hdrFormat = GL_RGB16F_ARB; + } + + qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample); + + if (r_ext_framebuffer_multisample->integer < multisample) + { + multisample = r_ext_framebuffer_multisample->integer; + } + + if (multisample < 2 || !glRefConfig.framebufferBlit) + multisample = 0; + + if (multisample != r_ext_framebuffer_multisample->integer) + { + ri.Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); + } + + // only create a render FBO if we need to resolve MSAA or do HDR + // otherwise just render straight to the screen (tr.renderFbo = NULL) + if (multisample && glRefConfig.framebufferMultisample) + { + tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); + FBO_Bind(tr.renderFbo); + + FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); + FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, multisample); + + R_CheckFBO(tr.renderFbo); + + + tr.msaaResolveFbo = FBO_Create("_msaaResolve", tr.renderDepthImage->width, tr.renderDepthImage->height); + FBO_Bind(tr.msaaResolveFbo); + + //FBO_CreateBuffer(tr.msaaResolveFbo, hdrFormat, 0, 0); + FBO_AttachTextureImage(tr.renderImage, 0); + + //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + + R_CheckFBO(tr.msaaResolveFbo); + } + else if (r_hdr->integer) + { + tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); + FBO_Bind(tr.renderFbo); + + //FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, 0); + FBO_AttachTextureImage(tr.renderImage, 0); + + //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + + R_CheckFBO(tr.renderFbo); + } + + // clear render buffer + // this fixes the corrupt screen bug with r_hdr 1 on older hardware + if (tr.renderFbo) + { + FBO_Bind(tr.renderFbo); + qglClearColor( 1, 0, 0.5, 1 ); + qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + FBO_Bind(NULL); + } + + if (r_drawSunRays->integer) + { + tr.sunRaysFbo = FBO_Create("_sunRays", tr.renderDepthImage->width, tr.renderDepthImage->height); + FBO_Bind(tr.sunRaysFbo); + + FBO_AttachTextureImage(tr.sunRaysImage, 0); + + R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + + R_CheckFBO(tr.sunRaysFbo); + } + + // FIXME: Don't use separate color/depth buffers for a shadow buffer + for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) + { + tr.pshadowFbos[i] = FBO_Create(va("_shadowmap%d", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); + FBO_Bind(tr.pshadowFbos[i]); + + //FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); + FBO_AttachTextureImage(tr.pshadowMaps[i], 0); + + FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24_ARB, 0, 0); + //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); + + R_CheckFBO(tr.pshadowFbos[i]); + } + + for ( i = 0; i < 3; i++) + { + tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height); + FBO_Bind(tr.sunShadowFbo[i]); + + //FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0); + //FBO_AttachTextureImage(tr.sunShadowImage, 0); + qglDrawBuffer(GL_NONE); + qglReadBuffer(GL_NONE); + + //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); + + R_CheckFBO(tr.sunShadowFbo[i]); + } + + for (i = 0; i < 2; i++) + { + tr.textureScratchFbo[i] = FBO_Create(va("_texturescratch%d", i), tr.textureScratchImage[i]->width, tr.textureScratchImage[i]->height); + FBO_Bind(tr.textureScratchFbo[i]); + + //FBO_CreateBuffer(tr.textureScratchFbo[i], GL_RGBA8, 0, 0); + FBO_AttachTextureImage(tr.textureScratchImage[i], 0); + + R_CheckFBO(tr.textureScratchFbo[i]); + } + + { + tr.calcLevelsFbo = FBO_Create("_calclevels", tr.calcLevelsImage->width, tr.calcLevelsImage->height); + FBO_Bind(tr.calcLevelsFbo); + + //FBO_CreateBuffer(tr.calcLevelsFbo, hdrFormat, 0, 0); + FBO_AttachTextureImage(tr.calcLevelsImage, 0); + + R_CheckFBO(tr.calcLevelsFbo); + } + + { + tr.targetLevelsFbo = FBO_Create("_targetlevels", tr.targetLevelsImage->width, tr.targetLevelsImage->height); + FBO_Bind(tr.targetLevelsFbo); + + //FBO_CreateBuffer(tr.targetLevelsFbo, hdrFormat, 0, 0); + FBO_AttachTextureImage(tr.targetLevelsImage, 0); + + R_CheckFBO(tr.targetLevelsFbo); + } + + if (r_softOverbright->integer) + { + //tr.screenScratchFbo = FBO_Create("_screenscratch", width, height); + tr.screenScratchFbo = FBO_Create("_screenscratch", tr.screenScratchImage->width, tr.screenScratchImage->height); + FBO_Bind(tr.screenScratchFbo); + + //FBO_CreateBuffer(tr.screenScratchFbo, format, 0, 0); + FBO_AttachTextureImage(tr.screenScratchImage, 0); + + // FIXME: hack: share zbuffer between render fbo and pre-screen fbo + //FBO_CreateBuffer(tr.screenScratchFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + + R_CheckFBO(tr.screenScratchFbo); + } + + for (i = 0; i < 2; i++) + { + tr.quarterFbo[i] = FBO_Create(va("_quarter%d", i), tr.quarterImage[i]->width, tr.quarterImage[i]->height); + FBO_Bind(tr.quarterFbo[i]); + + //FBO_CreateBuffer(tr.quarterFbo[i], hdrFormat, 0, 0); + FBO_AttachTextureImage(tr.quarterImage[i], 0); + + R_CheckFBO(tr.quarterFbo[i]); + } + + { + tr.screenShadowFbo = FBO_Create("_screenshadow", tr.screenShadowImage->width, tr.screenShadowImage->height); + FBO_Bind(tr.screenShadowFbo); + + FBO_AttachTextureImage(tr.screenShadowImage, 0); + + R_CheckFBO(tr.screenShadowFbo); + } + + if (r_ssao->integer) + { + tr.hdrDepthFbo = FBO_Create("_hdrDepth", tr.hdrDepthImage->width, tr.hdrDepthImage->height); + FBO_Bind(tr.hdrDepthFbo); + + FBO_AttachTextureImage(tr.hdrDepthImage, 0); + + R_CheckFBO(tr.hdrDepthFbo); + + tr.screenSsaoFbo = FBO_Create("_screenssao", tr.screenSsaoImage->width, tr.screenSsaoImage->height); + FBO_Bind(tr.screenSsaoFbo); + + FBO_AttachTextureImage(tr.screenSsaoImage, 0); + + R_CheckFBO(tr.screenSsaoFbo); + } + + GL_CheckErrors(); + + FBO_Bind(NULL); +} + +/* +============ +FBO_Shutdown +============ +*/ +void FBO_Shutdown(void) +{ + int i, j; + FBO_t *fbo; + + ri.Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); + + if(!glRefConfig.framebufferObject) + return; + + FBO_Bind(NULL); + + for(i = 0; i < tr.numFBOs; i++) + { + fbo = tr.fbos[i]; + + for(j = 0; j < glRefConfig.maxColorAttachments; j++) + { + if(fbo->colorBuffers[j]) + qglDeleteRenderbuffersEXT(1, &fbo->colorBuffers[j]); + } + + if(fbo->depthBuffer) + qglDeleteRenderbuffersEXT(1, &fbo->depthBuffer); + + if(fbo->stencilBuffer) + qglDeleteRenderbuffersEXT(1, &fbo->stencilBuffer); + + if(fbo->frameBuffer) + qglDeleteFramebuffersEXT(1, &fbo->frameBuffer); + } +} + +/* +============ +R_FBOList_f +============ +*/ +void R_FBOList_f(void) +{ + int i; + FBO_t *fbo; + + if(!glRefConfig.framebufferObject) + { + ri.Printf(PRINT_ALL, "GL_EXT_framebuffer_object is not available.\n"); + return; + } + + ri.Printf(PRINT_ALL, " size name\n"); + ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); + + for(i = 0; i < tr.numFBOs; i++) + { + fbo = tr.fbos[i]; + + ri.Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); + } + + ri.Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); +} + +// FIXME +extern void RB_SetGL2D (void); + +void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexScale, FBO_t *dst, vec4i_t inDstBox, struct shaderProgram_s *shaderProgram, vec4_t inColor, int blend) +{ + vec4i_t dstBox, srcBox; + vec2_t srcTexScale; + vec4_t color; + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + vec2_t invTexRes; + FBO_t *oldFbo = glState.currentFBO; + matrix_t projection; + int width, height; + + if (!src) + return; + + if (inSrcBox) + { + VectorSet4(srcBox, inSrcBox[0], inSrcBox[1], inSrcBox[0] + inSrcBox[2], inSrcBox[1] + inSrcBox[3]); + } + else + { + VectorSet4(srcBox, 0, 0, src->width, src->height); + } + + // framebuffers are 0 bottom, Y up. + if (inDstBox) + { + if (dst) + { + dstBox[0] = inDstBox[0]; + dstBox[1] = dst->height - inDstBox[1] - inDstBox[3]; + dstBox[2] = inDstBox[0] + inDstBox[2]; + dstBox[3] = dst->height - inDstBox[1]; + } + else + { + dstBox[0] = inDstBox[0]; + dstBox[1] = glConfig.vidHeight - inDstBox[1] - inDstBox[3]; + dstBox[2] = inDstBox[0] + inDstBox[2]; + dstBox[3] = glConfig.vidHeight - inDstBox[1]; + } + } + else if (dst) + { + VectorSet4(dstBox, 0, dst->height, dst->width, 0); + } + else + { + VectorSet4(dstBox, 0, glConfig.vidHeight, glConfig.vidWidth, 0); + } + + if (inSrcTexScale) + { + VectorCopy2(inSrcTexScale, srcTexScale); + } + else + { + srcTexScale[0] = srcTexScale[1] = 1.0f; + } + + if (inColor) + { + VectorCopy4(inColor, color); + } + else + { + VectorCopy4(colorWhite, color); + } + + if (!shaderProgram) + { + shaderProgram = &tr.textureColorShader; + } + + FBO_Bind(dst); + + if (glState.currentFBO) + { + width = glState.currentFBO->width; + height = glState.currentFBO->height; + } + else + { + width = glConfig.vidWidth; + height = glConfig.vidHeight; + } + + qglViewport( 0, 0, width, height ); + qglScissor( 0, 0, width, height ); + + Matrix16Ortho(0, width, height, 0, 0, 1, projection); + + qglDisable( GL_CULL_FACE ); + + GL_BindToTMU(src, TB_COLORMAP); + + VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0, 1); + VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0, 1); + VectorSet4(quadVerts[2], dstBox[2], dstBox[3], 0, 1); + VectorSet4(quadVerts[3], dstBox[0], dstBox[3], 0, 1); + + texCoords[0][0] = srcBox[0] / (float)src->width; texCoords[0][1] = 1.0f - srcBox[1] / (float)src->height; + texCoords[1][0] = srcBox[2] / (float)src->width; texCoords[1][1] = 1.0f - srcBox[1] / (float)src->height; + texCoords[2][0] = srcBox[2] / (float)src->width; texCoords[2][1] = 1.0f - srcBox[3] / (float)src->height; + texCoords[3][0] = srcBox[0] / (float)src->width; texCoords[3][1] = 1.0f - srcBox[3] / (float)src->height; + + invTexRes[0] = 1.0f / src->width * srcTexScale[0]; + invTexRes[1] = 1.0f / src->height * srcTexScale[1]; + + GL_State( blend ); + + GLSL_BindProgram(shaderProgram); + + GLSL_SetUniformMatrix16(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); + GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color); + GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes); + GLSL_SetUniformVec2(shaderProgram, UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax); + GLSL_SetUniformVec3(shaderProgram, UNIFORM_TONEMINAVGMAXLINEAR, tr.refdef.toneMinAvgMaxLinear); + + RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + + FBO_Bind(oldFbo); +} + +void FBO_Blit(FBO_t *src, vec4i_t inSrcBox, vec2_t srcTexScale, FBO_t *dst, vec4i_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend) +{ + vec4i_t srcBox; + + if (!src) + return; + + // framebuffers are 0 bottom, Y up. + if (inSrcBox) + { + srcBox[0] = inSrcBox[0]; + srcBox[1] = src->height - inSrcBox[1] - inSrcBox[3]; + srcBox[2] = inSrcBox[2]; + srcBox[3] = inSrcBox[3]; + } + else + { + VectorSet4(srcBox, 0, src->height, src->width, -src->height); + } + + FBO_BlitFromTexture(src->colorImage[0], srcBox, srcTexScale, dst, dstBox, shaderProgram, color, blend | GLS_DEPTHTEST_DISABLE); +} + +void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int buffers, int filter) +{ + vec4i_t srcBoxFinal, dstBoxFinal; + GLuint srcFb, dstFb; + + if (!glRefConfig.framebufferBlit) + { + FBO_Blit(src, srcBox, NULL, dst, dstBox, NULL, NULL, 0); + return; + } + + // get to a neutral state first + //FBO_Bind(NULL); + + srcFb = src ? src->frameBuffer : 0; + dstFb = dst ? dst->frameBuffer : 0; + + if (!srcBox) + { + if (src) + { + VectorSet4(srcBoxFinal, 0, 0, src->width, src->height); + } + else + { + VectorSet4(srcBoxFinal, 0, 0, glConfig.vidWidth, glConfig.vidHeight); + } + } + else + { + VectorSet4(srcBoxFinal, srcBox[0], srcBox[1], srcBox[0] + srcBox[2], srcBox[1] + srcBox[3]); + } + + if (!dstBox) + { + if (dst) + { + VectorSet4(dstBoxFinal, 0, 0, dst->width, dst->height); + } + else + { + VectorSet4(dstBoxFinal, 0, 0, glConfig.vidWidth, glConfig.vidHeight); + } + } + else + { + VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]); + } + + qglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, srcFb); + qglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dstFb); + qglBlitFramebufferEXT(srcBoxFinal[0], srcBoxFinal[1], srcBoxFinal[2], srcBoxFinal[3], + dstBoxFinal[0], dstBoxFinal[1], dstBoxFinal[2], dstBoxFinal[3], + buffers, filter); + + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glState.currentFBO = NULL; +} diff --git a/codemp/rd-rend2/tr_fbo.h b/codemp/rd-rend2/tr_fbo.h new file mode 100644 index 0000000000..f036625156 --- /dev/null +++ b/codemp/rd-rend2/tr_fbo.h @@ -0,0 +1,64 @@ +/* +=========================================================================== +Copyright (C) 2010 James Canete (use.less01@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_fbo.h + +#ifndef __TR_FBO_H__ +#define __TR_FBO_H__ + +struct image_s; +struct shaderProgram_s; + +typedef struct FBO_s +{ + char name[MAX_QPATH]; + + int index; + + uint32_t frameBuffer; + + uint32_t colorBuffers[16]; + int colorFormat; + struct image_s *colorImage[16]; + + uint32_t depthBuffer; + int depthFormat; + + uint32_t stencilBuffer; + int stencilFormat; + + uint32_t packedDepthStencilBuffer; + int packedDepthStencilFormat; + + int width; + int height; +} FBO_t; + +void FBO_Bind(FBO_t *fbo); +void FBO_Init(void); +void FBO_Shutdown(void); + +void FBO_BlitFromTexture(struct image_s *src, vec4i_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4i_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend); +void FBO_Blit(FBO_t *src, vec4i_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4i_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend); +void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int buffers, int filter); + + +#endif diff --git a/codemp/rd-rend2/tr_flares.c b/codemp/rd-rend2/tr_flares.c new file mode 100644 index 0000000000..8e6c321ff8 --- /dev/null +++ b/codemp/rd-rend2/tr_flares.c @@ -0,0 +1,532 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_flares.c + +#include "tr_local.h" + +/* +============================================================================= + +LIGHT FLARES + +A light flare is an effect that takes place inside the eye when bright light +sources are visible. The size of the flare reletive to the screen is nearly +constant, irrespective of distance, but the intensity should be proportional to the +projected area of the light source. + +A surface that has been flagged as having a light flare will calculate the depth +buffer value that its midpoint should have when the surface is added. + +After all opaque surfaces have been rendered, the depth buffer is read back for +each flare in view. If the point has not been obscured by a closer surface, the +flare should be drawn. + +Surfaces that have a repeated texture should never be flagged as flaring, because +there will only be a single flare added at the midpoint of the polygon. + +To prevent abrupt popping, the intensity of the flare is interpolated up and +down as it changes visibility. This involves scene to scene state, unlike almost +all other aspects of the renderer, and is complicated by the fact that a single +frame may have multiple scenes. + +RB_RenderFlares() will be called once per view (twice in a mirrored scene, potentially +up to five or more times in a frame with 3D status bar icons). + +============================================================================= +*/ + + +// flare states maintain visibility over multiple frames for fading +// layers: view, mirror, menu +typedef struct flare_s { + struct flare_s *next; // for active chain + + int addedFrame; + + qboolean inPortal; // true if in a portal view of the scene + int frameSceneNum; + void *surface; + int fogNum; + + int fadeTime; + + qboolean visible; // state of last test + float drawIntensity; // may be non 0 even if !visible due to fading + + int windowX, windowY; + float eyeZ; + + vec3_t origin; + vec3_t color; +} flare_t; + +#define MAX_FLARES 128 + +flare_t r_flareStructs[MAX_FLARES]; +flare_t *r_activeFlares, *r_inactiveFlares; + +int flareCoeff; + +/* +================== +R_ClearFlares +================== +*/ +void R_ClearFlares( void ) { + int i; + + Com_Memset( r_flareStructs, 0, sizeof( r_flareStructs ) ); + r_activeFlares = NULL; + r_inactiveFlares = NULL; + + for ( i = 0 ; i < MAX_FLARES ; i++ ) { + r_flareStructs[i].next = r_inactiveFlares; + r_inactiveFlares = &r_flareStructs[i]; + } +} + + +/* +================== +RB_AddFlare + +This is called at surface tesselation time +================== +*/ +void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ) { + int i; + flare_t *f; + vec3_t local; + float d = 1; + vec4_t eye, clip, normalized, window; + + backEnd.pc.c_flareAdds++; + + if(normal && (normal[0] || normal[1] || normal[2])) + { + VectorSubtract( backEnd.viewParms.or.origin, point, local ); + VectorNormalizeFast(local); + d = DotProduct(local, normal); + + // If the viewer is behind the flare don't add it. + if(d < 0) + return; + } + + // if the point is off the screen, don't bother adding it + // calculate screen coordinates and depth + R_TransformModelToClip( point, backEnd.or.modelMatrix, + backEnd.viewParms.projectionMatrix, eye, clip ); + + // check to see if the point is completely off screen + for ( i = 0 ; i < 3 ; i++ ) { + if ( clip[i] >= clip[3] || clip[i] <= -clip[3] ) { + return; + } + } + + R_TransformClipToWindow( clip, &backEnd.viewParms, normalized, window ); + + if ( window[0] < 0 || window[0] >= backEnd.viewParms.viewportWidth + || window[1] < 0 || window[1] >= backEnd.viewParms.viewportHeight ) { + return; // shouldn't happen, since we check the clip[] above, except for FP rounding + } + + // see if a flare with a matching surface, scene, and view exists + for ( f = r_activeFlares ; f ; f = f->next ) { + if ( f->surface == surface && f->frameSceneNum == backEnd.viewParms.frameSceneNum + && f->inPortal == backEnd.viewParms.isPortal ) { + break; + } + } + + // allocate a new one + if (!f ) { + if ( !r_inactiveFlares ) { + // the list is completely full + return; + } + f = r_inactiveFlares; + r_inactiveFlares = r_inactiveFlares->next; + f->next = r_activeFlares; + r_activeFlares = f; + + f->surface = surface; + f->frameSceneNum = backEnd.viewParms.frameSceneNum; + f->inPortal = backEnd.viewParms.isPortal; + f->addedFrame = -1; + } + + if ( f->addedFrame != backEnd.viewParms.frameCount - 1 ) { + f->visible = qfalse; + f->fadeTime = backEnd.refdef.time - 2000; + } + + f->addedFrame = backEnd.viewParms.frameCount; + f->fogNum = fogNum; + + VectorCopy(point, f->origin); + VectorCopy( color, f->color ); + + // fade the intensity of the flare down as the + // light surface turns away from the viewer + VectorScale( f->color, d, f->color ); + + // save info needed to test + f->windowX = backEnd.viewParms.viewportX + window[0]; + f->windowY = backEnd.viewParms.viewportY + window[1]; + + f->eyeZ = eye[2]; +} + +/* +================== +RB_AddDlightFlares +================== +*/ +void RB_AddDlightFlares( void ) { + dlight_t *l; + int i, j, k; + fog_t *fog = NULL; + + if ( !r_flares->integer ) { + return; + } + + l = backEnd.refdef.dlights; + + if(tr.world) + fog = tr.world->fogs; + + for (i=0 ; inumfogs ; j++ ) { + fog = &tr.world->fogs[j]; + for ( k = 0 ; k < 3 ; k++ ) { + if ( l->origin[k] < fog->bounds[0][k] || l->origin[k] > fog->bounds[1][k] ) { + break; + } + } + if ( k == 3 ) { + break; + } + } + if ( j == tr.world->numfogs ) { + j = 0; + } + } + else + j = 0; + + RB_AddFlare( (void *)l, j, l->origin, l->color, NULL ); + } +} + +/* +=============================================================================== + +FLARE BACK END + +=============================================================================== +*/ + +/* +================== +RB_TestFlare +================== +*/ +void RB_TestFlare( flare_t *f ) { + float depth; + qboolean visible; + float fade; + float screenZ; + + backEnd.pc.c_flareTests++; + + // doing a readpixels is as good as doing a glFinish(), so + // don't bother with another sync + glState.finishCalled = qfalse; + + // read back the z buffer contents + qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); + + screenZ = backEnd.viewParms.projectionMatrix[14] / + ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); + + visible = ( -f->eyeZ - -screenZ ) < 24; + + if ( visible ) { + if ( !f->visible ) { + f->visible = qtrue; + f->fadeTime = backEnd.refdef.time - 1; + } + fade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value; + } else { + if ( f->visible ) { + f->visible = qfalse; + f->fadeTime = backEnd.refdef.time - 1; + } + fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; + } + + if ( fade < 0 ) { + fade = 0; + } + if ( fade > 1 ) { + fade = 1; + } + + f->drawIntensity = fade; +} + + +/* +================== +RB_RenderFlare +================== +*/ +void RB_RenderFlare( flare_t *f ) { + float size; + vec3_t color; + int iColor[3]; + float distance, intensity, factor; + byte fogFactors[3] = {255, 255, 255}; + + backEnd.pc.c_flareRenders++; + + // We don't want too big values anyways when dividing by distance. + if(f->eyeZ > -1.0f) + distance = 1.0f; + else + distance = -f->eyeZ; + + // calculate the flare size.. + size = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / distance ); + +/* + * This is an alternative to intensity scaling. It changes the size of the flare on screen instead + * with growing distance. See in the description at the top why this is not the way to go. + // size will change ~ 1/r. + size = backEnd.viewParms.viewportWidth * (r_flareSize->value / (distance * -2.0f)); +*/ + +/* + * As flare sizes stay nearly constant with increasing distance we must decrease the intensity + * to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be + * got by considering the ratio of + * (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare) + * An important requirement is: + * intensity <= 1 for all distances. + * + * The formula used here to compute the intensity is as follows: + * intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2 + * As you can see, the intensity will have a max. of 1 when the distance is 0. + * The coefficient flareCoeff will determine the falloff speed with increasing distance. + */ + + factor = distance + size * sqrt(flareCoeff); + + intensity = flareCoeff * size * size / (factor * factor); + + VectorScale(f->color, f->drawIntensity * intensity, color); + +// Calculations for fogging + if(tr.world && f->fogNum < tr.world->numfogs) + { + tess.numVertexes = 1; + VectorCopy(f->origin, tess.xyz[0]); + tess.fogNum = f->fogNum; + + RB_CalcModulateColorsByFog(fogFactors); + + // We don't need to render the flare if colors are 0 anyways. + if(!(fogFactors[0] || fogFactors[1] || fogFactors[2])) + return; + } + + iColor[0] = color[0] * fogFactors[0]; + iColor[1] = color[1] * fogFactors[1]; + iColor[2] = color[2] * fogFactors[2]; + + RB_BeginSurface( tr.flareShader, f->fogNum ); + + // FIXME: use quadstamp? + tess.xyz[tess.numVertexes][0] = f->windowX - size; + tess.xyz[tess.numVertexes][1] = f->windowY - size; + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; + tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.numVertexes++; + + tess.xyz[tess.numVertexes][0] = f->windowX - size; + tess.xyz[tess.numVertexes][1] = f->windowY + size; + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 1; + tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; + tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.numVertexes++; + + tess.xyz[tess.numVertexes][0] = f->windowX + size; + tess.xyz[tess.numVertexes][1] = f->windowY + size; + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = 1; + tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; + tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.numVertexes++; + + tess.xyz[tess.numVertexes][0] = f->windowX + size; + tess.xyz[tess.numVertexes][1] = f->windowY - size; + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; + tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = 0; + tess.indexes[tess.numIndexes++] = 1; + tess.indexes[tess.numIndexes++] = 2; + tess.indexes[tess.numIndexes++] = 0; + tess.indexes[tess.numIndexes++] = 2; + tess.indexes[tess.numIndexes++] = 3; + + RB_EndSurface(); +} + +/* +================== +RB_RenderFlares + +Because flares are simulating an occular effect, they should be drawn after +everything (all views) in the entire frame has been drawn. + +Because of the way portals use the depth buffer to mark off areas, the +needed information would be lost after each view, so we are forced to draw +flares after each view. + +The resulting artifact is that flares in mirrors or portals don't dim properly +when occluded by something in the main view, and portal flares that should +extend past the portal edge will be overwritten. +================== +*/ +void RB_RenderFlares (void) { + flare_t *f; + flare_t **prev; + qboolean draw; + matrix_t oldmodelview, oldprojection, matrix; + + if ( !r_flares->integer ) { + return; + } + + if(r_flareCoeff->modified) + { + if(r_flareCoeff->value == 0.0f) + flareCoeff = atof(FLARE_STDCOEFF); + else + flareCoeff = r_flareCoeff->value; + + r_flareCoeff->modified = qfalse; + } + + // Reset currentEntity to world so that any previously referenced entities + // don't have influence on the rendering of these flares (i.e. RF_ renderer flags). + backEnd.currentEntity = &tr.worldEntity; + backEnd.or = backEnd.viewParms.world; + +// RB_AddDlightFlares(); + + // perform z buffer readback on each flare in this view + draw = qfalse; + prev = &r_activeFlares; + while ( ( f = *prev ) != NULL ) { + // throw out any flares that weren't added last frame + if ( f->addedFrame < backEnd.viewParms.frameCount - 1 ) { + *prev = f->next; + f->next = r_inactiveFlares; + r_inactiveFlares = f; + continue; + } + + // don't draw any here that aren't from this scene / portal + f->drawIntensity = 0; + if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum + && f->inPortal == backEnd.viewParms.isPortal ) { + RB_TestFlare( f ); + if ( f->drawIntensity ) { + draw = qtrue; + } else { + // this flare has completely faded out, so remove it from the chain + *prev = f->next; + f->next = r_inactiveFlares; + r_inactiveFlares = f; + continue; + } + } + + prev = &f->next; + } + + if ( !draw ) { + return; // none visible + } + + if ( backEnd.viewParms.isPortal ) { + qglDisable (GL_CLIP_PLANE0); + } + + Matrix16Copy(glState.projection, oldprojection); + Matrix16Copy(glState.modelview, oldmodelview); + Matrix16Identity(matrix); + GL_SetModelviewMatrix(matrix); + Matrix16Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth, + backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, + -99999, 99999, matrix ); + GL_SetProjectionMatrix(matrix); + + for ( f = r_activeFlares ; f ; f = f->next ) { + if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum + && f->inPortal == backEnd.viewParms.isPortal + && f->drawIntensity ) { + RB_RenderFlare( f ); + } + } + + GL_SetProjectionMatrix(oldprojection); + GL_SetModelviewMatrix(oldmodelview); +} + + + + + diff --git a/codemp/rd-rend2/tr_glsl.c b/codemp/rd-rend2/tr_glsl.c new file mode 100644 index 0000000000..d8b0743224 --- /dev/null +++ b/codemp/rd-rend2/tr_glsl.c @@ -0,0 +1,1833 @@ +/* +=========================================================================== +Copyright (C) 2006-2009 Robert Beckebans + +This file is part of XreaL source code. + +XreaL source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +XreaL source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with XreaL source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_glsl.c +#include "tr_local.h" + +void GLSL_BindNullProgram(void); + +extern const char *fallbackShader_bokeh_vp; +extern const char *fallbackShader_bokeh_fp; +extern const char *fallbackShader_calclevels4x_vp; +extern const char *fallbackShader_calclevels4x_fp; +extern const char *fallbackShader_depthblur_vp; +extern const char *fallbackShader_depthblur_fp; +extern const char *fallbackShader_dlight_vp; +extern const char *fallbackShader_dlight_fp; +extern const char *fallbackShader_down4x_vp; +extern const char *fallbackShader_down4x_fp; +extern const char *fallbackShader_fogpass_vp; +extern const char *fallbackShader_fogpass_fp; +extern const char *fallbackShader_generic_vp; +extern const char *fallbackShader_generic_fp; +extern const char *fallbackShader_lightall_vp; +extern const char *fallbackShader_lightall_fp; +extern const char *fallbackShader_pshadow_vp; +extern const char *fallbackShader_pshadow_fp; +extern const char *fallbackShader_shadowfill_vp; +extern const char *fallbackShader_shadowfill_fp; +extern const char *fallbackShader_shadowmask_vp; +extern const char *fallbackShader_shadowmask_fp; +extern const char *fallbackShader_ssao_vp; +extern const char *fallbackShader_ssao_fp; +extern const char *fallbackShader_texturecolor_vp; +extern const char *fallbackShader_texturecolor_fp; +extern const char *fallbackShader_tonemap_vp; +extern const char *fallbackShader_tonemap_fp; + +typedef struct uniformInfo_s +{ + char *name; + int type; +} +uniformInfo_t; + +// These must be in the same order as in uniform_t in tr_local.h. +static uniformInfo_t uniformsInfo[] = +{ + { "u_DiffuseMap", GLSL_INT }, + { "u_LightMap", GLSL_INT }, + { "u_NormalMap", GLSL_INT }, + { "u_DeluxeMap", GLSL_INT }, + { "u_SpecularMap", GLSL_INT }, + + { "u_TextureMap", GLSL_INT }, + { "u_LevelsMap", GLSL_INT }, + + { "u_ScreenImageMap", GLSL_INT }, + { "u_ScreenDepthMap", GLSL_INT }, + + { "u_ShadowMap", GLSL_INT }, + { "u_ShadowMap2", GLSL_INT }, + { "u_ShadowMap3", GLSL_INT }, + + { "u_ShadowMvp", GLSL_MAT16 }, + { "u_ShadowMvp2", GLSL_MAT16 }, + { "u_ShadowMvp3", GLSL_MAT16 }, + + { "u_DiffuseTexMatrix", GLSL_VEC4 }, + { "u_DiffuseTexOffTurb", GLSL_VEC4 }, + { "u_Texture1Env", GLSL_INT }, + + { "u_TCGen0", GLSL_INT }, + { "u_TCGen0Vector0", GLSL_VEC3 }, + { "u_TCGen0Vector1", GLSL_VEC3 }, + + { "u_DeformGen", GLSL_INT }, + { "u_DeformParams", GLSL_FLOAT5 }, + + { "u_ColorGen", GLSL_INT }, + { "u_AlphaGen", GLSL_INT }, + { "u_Color", GLSL_VEC4 }, + { "u_BaseColor", GLSL_VEC4 }, + { "u_VertColor", GLSL_VEC4 }, + + { "u_DlightInfo", GLSL_VEC4 }, + { "u_LightForward", GLSL_VEC3 }, + { "u_LightUp", GLSL_VEC3 }, + { "u_LightRight", GLSL_VEC3 }, + { "u_LightOrigin", GLSL_VEC4 }, + { "u_LightRadius", GLSL_FLOAT }, + { "u_AmbientLight", GLSL_VEC3 }, + { "u_DirectedLight", GLSL_VEC3 }, + + { "u_PortalRange", GLSL_FLOAT }, + + { "u_FogDistance", GLSL_VEC4 }, + { "u_FogDepth", GLSL_VEC4 }, + { "u_FogEyeT", GLSL_FLOAT }, + { "u_FogColorMask", GLSL_VEC4 }, + + { "u_ModelMatrix", GLSL_MAT16 }, + { "u_ModelViewProjectionMatrix", GLSL_MAT16 }, + + { "u_Time", GLSL_FLOAT }, + { "u_VertexLerp" , GLSL_FLOAT }, + { "u_MaterialInfo", GLSL_VEC2 }, + + { "u_ViewInfo", GLSL_VEC4 }, + { "u_ViewOrigin", GLSL_VEC3 }, + { "u_ViewForward", GLSL_VEC3 }, + { "u_ViewLeft", GLSL_VEC3 }, + { "u_ViewUp", GLSL_VEC3 }, + + { "u_InvTexRes", GLSL_VEC2 }, + { "u_AutoExposureMinMax", GLSL_VEC2 }, + { "u_ToneMinAvgMaxLinear", GLSL_VEC3 }, + + { "u_PrimaryLightOrigin", GLSL_VEC4 }, + { "u_PrimaryLightColor", GLSL_VEC3 }, + { "u_PrimaryLightAmbient", GLSL_VEC3 }, + { "u_PrimaryLightRadius", GLSL_FLOAT } +}; + + +static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) +{ + char *msg; + static char msgPart[1024]; + int maxLength = 0; + int i; + int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; + + qglGetObjectParameterivARB(object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); + + if (maxLength <= 0) + { + ri.Printf(printLevel, "No compile log.\n"); + return; + } + + ri.Printf(printLevel, "compile log:\n"); + + if (maxLength < 1023) + { + qglGetInfoLogARB(object, maxLength, &maxLength, msgPart); + + msgPart[maxLength + 1] = '\0'; + + ri.Printf(printLevel, "%s\n", msgPart); + } + else + { + msg = ri.Malloc(maxLength); + + qglGetInfoLogARB(object, maxLength, &maxLength, msg); + + for(i = 0; i < maxLength; i += 1024) + { + Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); + + ri.Printf(printLevel, "%s\n", msgPart); + } + + ri.Free(msg); + } +} + +static void GLSL_PrintShaderSource(GLhandleARB object) +{ + char *msg; + static char msgPart[1024]; + int maxLength = 0; + int i; + + qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); + + msg = ri.Malloc(maxLength); + + qglGetShaderSourceARB(object, maxLength, &maxLength, msg); + + for(i = 0; i < maxLength; i += 1024) + { + Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); + ri.Printf(PRINT_ALL, "%s\n", msgPart); + } + + ri.Free(msg); +} + +static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, int size ) +{ + float fbufWidthScale, fbufHeightScale; + + dest[0] = '\0'; + + // HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones + if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30)) + { + Q_strcat(dest, size, "#version 130\n"); + + if(shaderType == GL_VERTEX_SHADER_ARB) + { + Q_strcat(dest, size, "#define attribute in\n"); + Q_strcat(dest, size, "#define varying out\n"); + } + else + { + Q_strcat(dest, size, "#define varying in\n"); + + Q_strcat(dest, size, "out vec4 out_Color;\n"); + Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); + } + } + else + { + Q_strcat(dest, size, "#version 120\n"); + } + + // HACK: add some macros to avoid extra uniforms and save speed and code maintenance + //Q_strcat(dest, size, + // va("#ifndef r_SpecularExponent\n#define r_SpecularExponent %f\n#endif\n", r_specularExponent->value)); + //Q_strcat(dest, size, + // va("#ifndef r_SpecularScale\n#define r_SpecularScale %f\n#endif\n", r_specularScale->value)); + //Q_strcat(dest, size, + // va("#ifndef r_NormalScale\n#define r_NormalScale %f\n#endif\n", r_normalScale->value)); + + + Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846f\n#endif\n"); + + //Q_strcat(dest, size, va("#ifndef MAX_SHADOWMAPS\n#define MAX_SHADOWMAPS %i\n#endif\n", MAX_SHADOWMAPS)); + + Q_strcat(dest, size, + va("#ifndef deformGen_t\n" + "#define deformGen_t\n" + "#define DGEN_WAVE_SIN %i\n" + "#define DGEN_WAVE_SQUARE %i\n" + "#define DGEN_WAVE_TRIANGLE %i\n" + "#define DGEN_WAVE_SAWTOOTH %i\n" + "#define DGEN_WAVE_INVERSE_SAWTOOTH %i\n" + "#define DGEN_BULGE %i\n" + "#define DGEN_MOVE %i\n" + "#endif\n", + DGEN_WAVE_SIN, + DGEN_WAVE_SQUARE, + DGEN_WAVE_TRIANGLE, + DGEN_WAVE_SAWTOOTH, + DGEN_WAVE_INVERSE_SAWTOOTH, + DGEN_BULGE, + DGEN_MOVE)); + + Q_strcat(dest, size, + va("#ifndef tcGen_t\n" + "#define tcGen_t\n" + "#define TCGEN_LIGHTMAP %i\n" + "#define TCGEN_TEXTURE %i\n" + "#define TCGEN_ENVIRONMENT_MAPPED %i\n" + "#define TCGEN_FOG %i\n" + "#define TCGEN_VECTOR %i\n" + "#endif\n", + TCGEN_LIGHTMAP, + TCGEN_TEXTURE, + TCGEN_ENVIRONMENT_MAPPED, + TCGEN_FOG, + TCGEN_VECTOR)); + + Q_strcat(dest, size, + va("#ifndef colorGen_t\n" + "#define colorGen_t\n" + "#define CGEN_LIGHTING_DIFFUSE %i\n" + "#endif\n", + CGEN_LIGHTING_DIFFUSE)); + + Q_strcat(dest, size, + va("#ifndef alphaGen_t\n" + "#define alphaGen_t\n" + "#define AGEN_LIGHTING_SPECULAR %i\n" + "#define AGEN_PORTAL %i\n" + "#define AGEN_FRESNEL %i\n" + "#endif\n", + AGEN_LIGHTING_SPECULAR, + AGEN_PORTAL, + AGEN_FRESNEL)); + + Q_strcat(dest, size, + va("#ifndef texenv_t\n" + "#define texenv_t\n" + "#define TEXENV_MODULATE %i\n" + "#define TEXENV_ADD %i\n" + "#define TEXENV_REPLACE %i\n" + "#endif\n", + GL_MODULATE, + GL_ADD, + GL_REPLACE)); + + fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); + fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); + Q_strcat(dest, size, + va("#ifndef r_FBufScale\n#define r_FBufScale vec2(%f, %f)\n#endif\n", fbufWidthScale, fbufHeightScale)); + + if (extra) + { + Q_strcat(dest, size, extra); + } + + // OK we added a lot of stuff but if we do something bad in the GLSL shaders then we want the proper line + // so we have to reset the line counting + Q_strcat(dest, size, "#line 0\n"); +} + +static int GLSL_CompileGPUShader(GLhandleARB program, GLhandleARB *prevShader, const GLcharARB *buffer, int size, GLenum shaderType) +{ + GLint compiled; + GLhandleARB shader; + + shader = qglCreateShaderObjectARB(shaderType); + + qglShaderSourceARB(shader, 1, (const GLcharARB **)&buffer, &size); + + // compile shader + qglCompileShaderARB(shader); + + // check if shader compiled + qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); + if(!compiled) + { + GLSL_PrintShaderSource(shader); + GLSL_PrintInfoLog(shader, qfalse); + ri.Error(ERR_DROP, "Couldn't compile shader"); + return 0; + } + + //GLSL_PrintInfoLog(shader, qtrue); + //GLSL_PrintShaderSource(shader); + + if (*prevShader) + { + qglDetachObjectARB(program, *prevShader); + qglDeleteObjectARB(*prevShader); + } + + // attach shader to program + qglAttachObjectARB(program, shader); + + *prevShader = shader; + + return 1; +} + +static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, + GLenum shaderType, char *dest, int destSize) +{ + char filename[MAX_QPATH]; + GLcharARB *buffer = NULL; + const GLcharARB *shaderText = NULL; + int size; + int result; + + if(shaderType == GL_VERTEX_SHADER_ARB) + { + Com_sprintf(filename, sizeof(filename), "glsl/%s_vp.glsl", name); + } + else + { + Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name); + } + + ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); + size = ri.FS_ReadFile(filename, (void **)&buffer); + if(!buffer) + { + if (fallback) + { + ri.Printf(PRINT_DEVELOPER, "couldn't load, using fallback\n"); + shaderText = fallback; + size = strlen(shaderText); + } + else + { + ri.Printf(PRINT_DEVELOPER, "couldn't load!\n"); + return 0; + } + } + else + { + shaderText = buffer; + } + + if (size > destSize) + { + result = 0; + } + else + { + Q_strncpyz(dest, shaderText, size + 1); + result = 1; + } + + if (buffer) + { + ri.FS_FreeFile(buffer); + } + + return result; +} + +static void GLSL_LinkProgram(GLhandleARB program) +{ + GLint linked; + + qglLinkProgramARB(program); + + qglGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &linked); + if(!linked) + { + GLSL_PrintInfoLog(program, qfalse); + ri.Printf(PRINT_ALL, "\n"); + ri.Error(ERR_DROP, "shaders failed to link"); + } +} + +static void GLSL_ValidateProgram(GLhandleARB program) +{ + GLint validated; + + qglValidateProgramARB(program); + + qglGetObjectParameterivARB(program, GL_OBJECT_VALIDATE_STATUS_ARB, &validated); + if(!validated) + { + GLSL_PrintInfoLog(program, qfalse); + ri.Printf(PRINT_ALL, "\n"); + ri.Error(ERR_DROP, "shaders failed to validate"); + } +} + +static void GLSL_ShowProgramUniforms(GLhandleARB program) +{ + int i, count, size; + GLenum type; + char uniformName[1000]; + + // install the executables in the program object as part of current state. + qglUseProgramObjectARB(program); + + // check for GL Errors + + // query the number of active uniforms + qglGetObjectParameterivARB(program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &count); + + // Loop over each of the active uniforms, and set their value + for(i = 0; i < count; i++) + { + qglGetActiveUniformARB(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); + + ri.Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); + } + + qglUseProgramObjectARB(0); +} + +static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) +{ + ri.Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "GLSL_InitGPUShader2: \"%s\" is too long", name); + } + + Q_strncpyz(program->name, name, sizeof(program->name)); + + program->program = qglCreateProgramObjectARB(); + program->attribs = attribs; + + if (!(GLSL_CompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER_ARB))) + { + ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); + qglDeleteObjectARB(program->program); + return 0; + } + + if(fpCode) + { + if(!(GLSL_CompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER_ARB))) + { + ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); + qglDeleteObjectARB(program->program); + return 0; + } + } + + if(attribs & ATTR_POSITION) + qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION, "attr_Position"); + + if(attribs & ATTR_TEXCOORD) + qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD0, "attr_TexCoord0"); + + if(attribs & ATTR_LIGHTCOORD) + qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); + +// if(attribs & ATTR_TEXCOORD2) +// qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD2, "attr_TexCoord2"); + +// if(attribs & ATTR_TEXCOORD3) +// qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD3, "attr_TexCoord3"); + +#ifdef USE_VERT_TANGENT_SPACE + if(attribs & ATTR_TANGENT) + qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); + + if(attribs & ATTR_BITANGENT) + qglBindAttribLocationARB(program->program, ATTR_INDEX_BITANGENT, "attr_Bitangent"); +#endif + + if(attribs & ATTR_NORMAL) + qglBindAttribLocationARB(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); + + if(attribs & ATTR_COLOR) + qglBindAttribLocationARB(program->program, ATTR_INDEX_COLOR, "attr_Color"); + + if(attribs & ATTR_PAINTCOLOR) + qglBindAttribLocationARB(program->program, ATTR_INDEX_PAINTCOLOR, "attr_PaintColor"); + + if(attribs & ATTR_LIGHTDIRECTION) + qglBindAttribLocationARB(program->program, ATTR_INDEX_LIGHTDIRECTION, "attr_LightDirection"); + + if(attribs & ATTR_POSITION2) + qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION2, "attr_Position2"); + + if(attribs & ATTR_NORMAL2) + qglBindAttribLocationARB(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); + +#ifdef USE_VERT_TANGENT_SPACE + if(attribs & ATTR_TANGENT2) + qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); + + if(attribs & ATTR_BITANGENT2) + qglBindAttribLocationARB(program->program, ATTR_INDEX_BITANGENT2, "attr_Bitangent2"); +#endif + + GLSL_LinkProgram(program->program); + + return 1; +} + +static int GLSL_InitGPUShader(shaderProgram_t * program, const char *name, + int attribs, qboolean fragmentShader, const GLcharARB *extra, qboolean addHeader, + const char *fallback_vp, const char *fallback_fp) +{ + char vpCode[32000]; + char fpCode[32000]; + char *postHeader; + int size; + int result; + + size = sizeof(vpCode); + if (addHeader) + { + GLSL_GetShaderHeader(GL_VERTEX_SHADER_ARB, extra, vpCode, size); + postHeader = &vpCode[strlen(vpCode)]; + size -= strlen(vpCode); + } + else + { + postHeader = &vpCode[0]; + } + + if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER_ARB, postHeader, size)) + { + return 0; + } + + if (fragmentShader) + { + size = sizeof(fpCode); + if (addHeader) + { + GLSL_GetShaderHeader(GL_FRAGMENT_SHADER_ARB, extra, fpCode, size); + postHeader = &fpCode[strlen(fpCode)]; + size -= strlen(fpCode); + } + else + { + postHeader = &fpCode[0]; + } + + if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER_ARB, postHeader, size)) + { + return 0; + } + } + + result = GLSL_InitGPUShader2(program, name, attribs, vpCode, fragmentShader ? fpCode : NULL); + + return result; +} + +void GLSL_InitUniforms(shaderProgram_t *program) +{ + int i, size; + + GLint *uniforms = program->uniforms; + + size = 0; + for (i = 0; i < UNIFORM_COUNT; i++) + { + uniforms[i] = qglGetUniformLocationARB(program->program, uniformsInfo[i].name); + + if (uniforms[i] == -1) + continue; + + program->uniformBufferOffsets[i] = size; + + switch(uniformsInfo[i].type) + { + case GLSL_INT: + size += sizeof(GLint); + break; + case GLSL_FLOAT: + size += sizeof(GLfloat); + break; + case GLSL_FLOAT5: + size += sizeof(vec_t) * 5; + break; + case GLSL_VEC2: + size += sizeof(vec_t) * 2; + break; + case GLSL_VEC3: + size += sizeof(vec_t) * 3; + break; + case GLSL_VEC4: + size += sizeof(vec_t) * 4; + break; + case GLSL_MAT16: + size += sizeof(vec_t) * 16; + break; + default: + break; + } + } + + program->uniformBuffer = ri.Malloc(size); +} + +void GLSL_FinishGPUShader(shaderProgram_t *program) +{ + GLSL_ValidateProgram(program->program); + GLSL_ShowProgramUniforms(program->program); + GL_CheckErrors(); +} + +void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) +{ + GLint *uniforms = program->uniforms; + GLint *compare = (GLint *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_INT) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (value == *compare) + { + return; + } + + *compare = value; + + qglUniform1iARB(uniforms[uniformNum], value); +} + +void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value) +{ + GLint *uniforms = program->uniforms; + GLfloat *compare = (GLfloat *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_FLOAT) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (value == *compare) + { + return; + } + + *compare = value; + + qglUniform1fARB(uniforms[uniformNum], value); +} + +void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v) +{ + GLint *uniforms = program->uniforms; + vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_VEC2) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (v[0] == compare[0] && v[1] == compare[1]) + { + return; + } + + compare[0] = v[0]; + compare[1] = v[1]; + + qglUniform2fARB(uniforms[uniformNum], v[0], v[1]); +} + +void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v) +{ + GLint *uniforms = program->uniforms; + vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_VEC3) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (VectorCompare(v, compare)) + { + return; + } + + VectorCopy(v, compare); + + qglUniform3fARB(uniforms[uniformNum], v[0], v[1], v[2]); +} + +void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v) +{ + GLint *uniforms = program->uniforms; + vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_VEC4) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (VectorCompare4(v, compare)) + { + return; + } + + VectorCopy4(v, compare); + + qglUniform4fARB(uniforms[uniformNum], v[0], v[1], v[2], v[3]); +} + +void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v) +{ + GLint *uniforms = program->uniforms; + vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_FLOAT5) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat5: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (VectorCompare5(v, compare)) + { + return; + } + + VectorCopy5(v, compare); + + qglUniform1fvARB(uniforms[uniformNum], 5, v); +} + +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const matrix_t matrix) +{ + GLint *uniforms = program->uniforms; + vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_MAT16) + { + ri.Printf( PRINT_WARNING, "GLSL_SetUniformMatrix16: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (Matrix16Compare(matrix, compare)) + { + return; + } + + Matrix16Copy(matrix, compare); + + qglUniformMatrix4fvARB(uniforms[uniformNum], 1, GL_FALSE, matrix); +} + +void GLSL_DeleteGPUShader(shaderProgram_t *program) +{ + if(program->program) + { + if (program->vertexShader) + { + qglDetachObjectARB(program->program, program->vertexShader); + qglDeleteObjectARB(program->vertexShader); + } + + if (program->fragmentShader) + { + qglDetachObjectARB(program->program, program->fragmentShader); + qglDeleteObjectARB(program->fragmentShader); + } + + qglDeleteObjectARB(program->program); + + if (program->uniformBuffer) + { + ri.Free(program->uniformBuffer); + } + + Com_Memset(program, 0, sizeof(*program)); + } +} + +void GLSL_InitGPUShaders(void) +{ + int startTime, endTime; + int i; + char extradefines[1024]; + int attribs; + int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; + + ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); + + R_IssuePendingRenderCommands(); + + startTime = ri.Milliseconds(); + + for (i = 0; i < GENERICDEF_COUNT; i++) + { + attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_NORMAL | ATTR_COLOR; + extradefines[0] = '\0'; + + if (i & GENERICDEF_USE_DEFORM_VERTEXES) + Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + + if (i & GENERICDEF_USE_TCGEN_AND_TCMOD) + { + Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); + Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); + } + + if (i & GENERICDEF_USE_VERTEX_ANIMATION) + { + Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + attribs |= ATTR_POSITION2 | ATTR_NORMAL2; + } + + if (i & GENERICDEF_USE_FOG) + Q_strcat(extradefines, 1024, "#define USE_FOG\n"); + + if (i & GENERICDEF_USE_RGBAGEN) + Q_strcat(extradefines, 1024, "#define USE_RGBAGEN\n"); + + if (i & GENERICDEF_USE_LIGHTMAP) + Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); + + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) + Q_strcat(extradefines, 1024, "#define RGBE_LIGHTMAP\n"); + + if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) + { + ri.Error(ERR_FATAL, "Could not load generic shader!"); + } + + GLSL_InitUniforms(&tr.genericShader[i]); + + qglUseProgramObjectARB(tr.genericShader[i].program); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.genericShader[i]); + + numGenShaders++; + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + + if (!GLSL_InitGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) + { + ri.Error(ERR_FATAL, "Could not load texturecolor shader!"); + } + + GLSL_InitUniforms(&tr.textureColorShader); + + qglUseProgramObjectARB(tr.textureColorShader.program); + GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.textureColorShader); + + numEtcShaders++; + + for (i = 0; i < FOGDEF_COUNT; i++) + { + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (i & FOGDEF_USE_DEFORM_VERTEXES) + Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + + if (i & FOGDEF_USE_VERTEX_ANIMATION) + Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + + if (!GLSL_InitGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) + { + ri.Error(ERR_FATAL, "Could not load fogpass shader!"); + } + + GLSL_InitUniforms(&tr.fogShader[i]); + GLSL_FinishGPUShader(&tr.fogShader[i]); + + numEtcShaders++; + } + + + for (i = 0; i < DLIGHTDEF_COUNT; i++) + { + attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) + { + Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + } + + if (!GLSL_InitGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) + { + ri.Error(ERR_FATAL, "Could not load dlight shader!"); + } + + GLSL_InitUniforms(&tr.dlightShader[i]); + + qglUseProgramObjectARB(tr.dlightShader[i].program); + GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.dlightShader[i]); + + numEtcShaders++; + } + + + for (i = 0; i < LIGHTDEF_COUNT; i++) + { + // skip impossible combos + if ((i & LIGHTDEF_USE_NORMALMAP) && !r_normalMapping->integer) + continue; + + if ((i & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) + continue; + + if ((i & LIGHTDEF_USE_SPECULARMAP) && !r_specularMapping->integer) + continue; + + if ((i & LIGHTDEF_USE_DELUXEMAP) && !r_deluxeMapping->integer) + continue; + + if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP) && (i & LIGHTDEF_USE_DELUXEMAP)) + continue; + + if (!(i & LIGHTDEF_USE_NORMALMAP) && (i & LIGHTDEF_USE_PARALLAXMAP)) + continue; + + //if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHT_VECTOR)) + if (!(i & LIGHTDEF_LIGHTTYPE_MASK)) + { + if (i & LIGHTDEF_USE_SHADOWMAP) + continue; + } + + attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; + + extradefines[0] = '\0'; + + if (r_normalAmbient->value > 0.003f) + Q_strcat(extradefines, 1024, va("#define r_normalAmbient %f\n", r_normalAmbient->value)); + + if (r_dlightMode->integer >= 2) + Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); + + if (1) + { + Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); + } + + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) + Q_strcat(extradefines, 1024, "#define RGBE_LIGHTMAP\n"); + + if (i & LIGHTDEF_LIGHTTYPE_MASK) + { + Q_strcat(extradefines, 1024, "#define USE_LIGHT\n"); + + if (r_normalMapping->integer == 0 && r_specularMapping->integer == 0) + Q_strcat(extradefines, 1024, "#define USE_FAST_LIGHT\n"); + + switch (i & LIGHTDEF_LIGHTTYPE_MASK) + { + case LIGHTDEF_USE_LIGHTMAP: + Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); + attribs |= ATTR_LIGHTCOORD | ATTR_LIGHTDIRECTION; + break; + case LIGHTDEF_USE_LIGHT_VECTOR: + Q_strcat(extradefines, 1024, "#define USE_LIGHT_VECTOR\n"); + break; + case LIGHTDEF_USE_LIGHT_VERTEX: + Q_strcat(extradefines, 1024, "#define USE_LIGHT_VERTEX\n"); + attribs |= ATTR_LIGHTDIRECTION; + break; + default: + break; + } + } + + if ((i & LIGHTDEF_USE_NORMALMAP) && r_normalMapping->integer) + { + Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); + + if (r_normalMapping->integer == 2) + Q_strcat(extradefines, 1024, "#define USE_OREN_NAYAR\n"); + + if (r_normalMapping->integer == 3) + Q_strcat(extradefines, 1024, "#define USE_TRIACE_OREN_NAYAR\n"); + +#ifdef USE_VERT_TANGENT_SPACE + Q_strcat(extradefines, 1024, "#define USE_VERT_TANGENT_SPACE\n"); + attribs |= ATTR_TANGENT | ATTR_BITANGENT; +#endif + } + + if ((i & LIGHTDEF_USE_SPECULARMAP) && r_specularMapping->integer) + { + Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); + + switch (r_specularMapping->integer) + { + case 1: + default: + Q_strcat(extradefines, 1024, "#define USE_TRIACE\n"); + break; + + case 2: + Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); + break; + + case 3: + Q_strcat(extradefines, 1024, "#define USE_COOK_TORRANCE\n"); + break; + + case 4: + Q_strcat(extradefines, 1024, "#define USE_TORRANCE_SPARROW\n"); + break; + } + } + + if ((i & LIGHTDEF_USE_DELUXEMAP) && r_deluxeMapping->integer) + Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); + + if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY) && r_parallaxMapping->integer) + Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); + + if (i & LIGHTDEF_USE_SHADOWMAP) + { + Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); + + if (r_sunlightMode->integer == 1) + Q_strcat(extradefines, 1024, "#define SHADOWMAP_MODULATE\n"); + else if (r_sunlightMode->integer == 2) + Q_strcat(extradefines, 1024, "#define USE_PRIMARY_LIGHT\n"); + } + + if (i & LIGHTDEF_USE_TCGEN_AND_TCMOD) + { + Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); + Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); + } + + if (i & LIGHTDEF_ENTITY) + { + Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n"); + attribs |= ATTR_POSITION2 | ATTR_NORMAL2; + +#ifdef USE_VERT_TANGENT_SPACE + if (i & LIGHTDEF_USE_NORMALMAP && r_normalMapping->integer) + { + attribs |= ATTR_TANGENT2 | ATTR_BITANGENT2; + } +#endif + } + + if (!GLSL_InitGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) + { + ri.Error(ERR_FATAL, "Could not load lightall shader!"); + } + + GLSL_InitUniforms(&tr.lightallShader[i]); + + qglUseProgramObjectARB(tr.lightallShader[i].program); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_NORMALMAP, TB_NORMALMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.lightallShader[i]); + + numLightShaders++; + } + + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; + + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) + { + ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); + } + + GLSL_InitUniforms(&tr.shadowmapShader); + GLSL_FinishGPUShader(&tr.shadowmapShader); + + numEtcShaders++; + + attribs = ATTR_POSITION | ATTR_NORMAL; + extradefines[0] = '\0'; + + Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); + + if (!GLSL_InitGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) + { + ri.Error(ERR_FATAL, "Could not load pshadow shader!"); + } + + GLSL_InitUniforms(&tr.pshadowShader); + + qglUseProgramObjectARB(tr.pshadowShader.program); + GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.pshadowShader); + + numEtcShaders++; + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) + { + ri.Error(ERR_FATAL, "Could not load down4x shader!"); + } + + GLSL_InitUniforms(&tr.down4xShader); + + qglUseProgramObjectARB(tr.down4xShader.program); + GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.down4xShader); + + numEtcShaders++; + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) + { + ri.Error(ERR_FATAL, "Could not load bokeh shader!"); + } + + GLSL_InitUniforms(&tr.bokehShader); + + qglUseProgramObjectARB(tr.bokehShader.program); + GLSL_SetUniformInt(&tr.bokehShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.bokehShader); + + numEtcShaders++; + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) + { + ri.Error(ERR_FATAL, "Could not load tonemap shader!"); + } + + GLSL_InitUniforms(&tr.tonemapShader); + + qglUseProgramObjectARB(tr.tonemapShader.program); + GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); + GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.tonemapShader); + + numEtcShaders++; + + + for (i = 0; i < 2; i++) + { + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!i) + Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); + + if (!GLSL_InitGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) + { + ri.Error(ERR_FATAL, "Could not load calclevels4x shader!"); + } + + GLSL_InitUniforms(&tr.calclevels4xShader[i]); + + qglUseProgramObjectARB(tr.calclevels4xShader[i].program); + GLSL_SetUniformInt(&tr.calclevels4xShader[i], UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); + + numEtcShaders++; + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (r_shadowFilter->integer >= 1) + Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER\n"); + + if (r_shadowFilter->integer >= 2) + Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n"); + + Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n"); + + Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); + Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); + + + if (!GLSL_InitGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) + { + ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); + } + + GLSL_InitUniforms(&tr.shadowmaskShader); + + qglUseProgramObjectARB(tr.shadowmaskShader.program); + GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); + GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP); + GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); + GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.shadowmaskShader); + + numEtcShaders++; + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) + { + ri.Error(ERR_FATAL, "Could not load ssao shader!"); + } + + GLSL_InitUniforms(&tr.ssaoShader); + + qglUseProgramObjectARB(tr.ssaoShader.program); + GLSL_SetUniformInt(&tr.ssaoShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.ssaoShader); + + numEtcShaders++; + + + for (i = 0; i < 2; i++) + { + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (i & 1) + Q_strcat(extradefines, 1024, "#define USE_VERTICAL_BLUR\n"); + else + Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); + + + if (!GLSL_InitGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) + { + ri.Error(ERR_FATAL, "Could not load depthBlur shader!"); + } + + GLSL_InitUniforms(&tr.depthBlurShader[i]); + + qglUseProgramObjectARB(tr.depthBlurShader[i].program); + GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENIMAGEMAP, TB_COLORMAP); + GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENDEPTHMAP, TB_LIGHTMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.depthBlurShader[i]); + + numEtcShaders++; + } + + + endTime = ri.Milliseconds(); + + ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", + numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, + numEtcShaders, (endTime - startTime) / 1000.0); +} + +void GLSL_ShutdownGPUShaders(void) +{ + int i; + + ri.Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); + + qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); + qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); + qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION); + qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION2); + qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL); +#ifdef USE_VERT_TANGENT_SPACE + qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); +#endif + qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); +#ifdef USE_VERT_TANGENT_SPACE + qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); +#endif + qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); + qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + GLSL_BindNullProgram(); + + for ( i = 0; i < GENERICDEF_COUNT; i++) + GLSL_DeleteGPUShader(&tr.genericShader[i]); + + GLSL_DeleteGPUShader(&tr.textureColorShader); + + for ( i = 0; i < FOGDEF_COUNT; i++) + GLSL_DeleteGPUShader(&tr.fogShader[i]); + + for ( i = 0; i < DLIGHTDEF_COUNT; i++) + GLSL_DeleteGPUShader(&tr.dlightShader[i]); + + for ( i = 0; i < LIGHTDEF_COUNT; i++) + GLSL_DeleteGPUShader(&tr.lightallShader[i]); + + GLSL_DeleteGPUShader(&tr.shadowmapShader); + GLSL_DeleteGPUShader(&tr.pshadowShader); + GLSL_DeleteGPUShader(&tr.down4xShader); + GLSL_DeleteGPUShader(&tr.bokehShader); + GLSL_DeleteGPUShader(&tr.tonemapShader); + + for ( i = 0; i < 2; i++) + GLSL_DeleteGPUShader(&tr.calclevels4xShader[i]); + + GLSL_DeleteGPUShader(&tr.shadowmaskShader); + GLSL_DeleteGPUShader(&tr.ssaoShader); + + for ( i = 0; i < 2; i++) + GLSL_DeleteGPUShader(&tr.depthBlurShader[i]); + + glState.currentProgram = 0; + qglUseProgramObjectARB(0); +} + + +void GLSL_BindProgram(shaderProgram_t * program) +{ + if(!program) + { + GLSL_BindNullProgram(); + return; + } + + if(r_logFile->integer) + { + // don't just call LogComment, or we will get a call to va() every frame! + GLimp_LogComment(va("--- GL_BindProgram( %s ) ---\n", program->name)); + } + + if(glState.currentProgram != program) + { + qglUseProgramObjectARB(program->program); + glState.currentProgram = program; + backEnd.pc.c_glslShaderBinds++; + } +} + + +void GLSL_BindNullProgram(void) +{ + if(r_logFile->integer) + { + GLimp_LogComment("--- GL_BindNullProgram ---\n"); + } + + if(glState.currentProgram) + { + qglUseProgramObjectARB(0); + glState.currentProgram = NULL; + } +} + + +void GLSL_VertexAttribsState(uint32_t stateBits) +{ + uint32_t diff; + + GLSL_VertexAttribPointers(stateBits); + + diff = stateBits ^ glState.vertexAttribsState; + if(!diff) + { + return; + } + + if(diff & ATTR_POSITION) + { + if(stateBits & ATTR_POSITION) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_POSITION )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_POSITION); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_POSITION )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION); + } + } + + if(diff & ATTR_TEXCOORD) + { + if(stateBits & ATTR_TEXCOORD) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TEXCOORD )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TEXCOORD )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); + } + } + + if(diff & ATTR_LIGHTCOORD) + { + if(stateBits & ATTR_LIGHTCOORD) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_LIGHTCOORD )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_LIGHTCOORD )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); + } + } + + if(diff & ATTR_NORMAL) + { + if(stateBits & ATTR_NORMAL) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_NORMAL )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_NORMAL); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_NORMAL )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL); + } + } + +#ifdef USE_VERT_TANGENT_SPACE + if(diff & ATTR_TANGENT) + { + if(stateBits & ATTR_TANGENT) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TANGENT )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TANGENT )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + } + } + + if(diff & ATTR_BITANGENT) + { + if(stateBits & ATTR_BITANGENT) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BITANGENT )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BITANGENT )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); + } + } +#endif + + if(diff & ATTR_COLOR) + { + if(stateBits & ATTR_COLOR) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_COLOR )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_COLOR); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_COLOR )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); + } + } + + if(diff & ATTR_LIGHTDIRECTION) + { + if(stateBits & ATTR_LIGHTDIRECTION) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_LIGHTDIRECTION )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_LIGHTDIRECTION )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + } + } + + if(diff & ATTR_POSITION2) + { + if(stateBits & ATTR_POSITION2) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_POSITION2 )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_POSITION2); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_POSITION2 )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION2); + } + } + + if(diff & ATTR_NORMAL2) + { + if(stateBits & ATTR_NORMAL2) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_NORMAL2 )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_NORMAL2 )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); + } + } + +#ifdef USE_VERT_TANGENT_SPACE + if(diff & ATTR_TANGENT2) + { + if(stateBits & ATTR_TANGENT2) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TANGENT2 )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TANGENT2 )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + } + } + + if(diff & ATTR_BITANGENT2) + { + if(stateBits & ATTR_BITANGENT2) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BITANGENT2 )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BITANGENT2 )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); + } + } +#endif + + glState.vertexAttribsState = stateBits; +} + +void GLSL_VertexAttribPointers(uint32_t attribBits) +{ + qboolean animated; + int newFrame, oldFrame; + + if(!glState.currentVBO) + { + ri.Error(ERR_FATAL, "GL_VertexAttribPointers: no VBO bound"); + return; + } + + // don't just call LogComment, or we will get a call to va() every frame! + GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", glState.currentVBO->name)); + + // position/normal/tangent/bitangent are always set in case of animation + oldFrame = glState.vertexAttribsOldFrame; + newFrame = glState.vertexAttribsNewFrame; + animated = (oldFrame != newFrame) && (glState.vertexAttribsInterpolation > 0.0f); + + if((attribBits & ATTR_POSITION) && (!(glState.vertexAttribPointersSet & ATTR_POSITION) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, glState.currentVBO->stride_xyz, BUFFER_OFFSET(glState.currentVBO->ofs_xyz + newFrame * glState.currentVBO->size_xyz)); + glState.vertexAttribPointersSet |= ATTR_POSITION; + } + + if((attribBits & ATTR_TEXCOORD) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, glState.currentVBO->stride_st, BUFFER_OFFSET(glState.currentVBO->ofs_st)); + glState.vertexAttribPointersSet |= ATTR_TEXCOORD; + } + + if((attribBits & ATTR_LIGHTCOORD) && !(glState.vertexAttribPointersSet & ATTR_LIGHTCOORD)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, glState.currentVBO->stride_lightmap, BUFFER_OFFSET(glState.currentVBO->ofs_lightmap)); + glState.vertexAttribPointersSet |= ATTR_LIGHTCOORD; + } + + if((attribBits & ATTR_NORMAL) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 3, GL_FLOAT, 0, glState.currentVBO->stride_normal, BUFFER_OFFSET(glState.currentVBO->ofs_normal + newFrame * glState.currentVBO->size_normal)); + glState.vertexAttribPointersSet |= ATTR_NORMAL; + } + +#ifdef USE_VERT_TANGENT_SPACE + if((attribBits & ATTR_TANGENT) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 3, GL_FLOAT, 0, glState.currentVBO->stride_tangent, BUFFER_OFFSET(glState.currentVBO->ofs_tangent + newFrame * glState.currentVBO->size_normal)); // FIXME + glState.vertexAttribPointersSet |= ATTR_TANGENT; + } + + if((attribBits & ATTR_BITANGENT) && (!(glState.vertexAttribPointersSet & ATTR_BITANGENT) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BITANGENT )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_BITANGENT, 3, GL_FLOAT, 0, glState.currentVBO->stride_bitangent, BUFFER_OFFSET(glState.currentVBO->ofs_bitangent + newFrame * glState.currentVBO->size_normal)); // FIXME + glState.vertexAttribPointersSet |= ATTR_BITANGENT; + } +#endif + + if((attribBits & ATTR_COLOR) && !(glState.vertexAttribPointersSet & ATTR_COLOR)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_COLOR )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, glState.currentVBO->stride_vertexcolor, BUFFER_OFFSET(glState.currentVBO->ofs_vertexcolor)); + glState.vertexAttribPointersSet |= ATTR_COLOR; + } + + if((attribBits & ATTR_LIGHTDIRECTION) && !(glState.vertexAttribPointersSet & ATTR_LIGHTDIRECTION)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTDIRECTION )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 3, GL_FLOAT, 0, glState.currentVBO->stride_lightdir, BUFFER_OFFSET(glState.currentVBO->ofs_lightdir)); + glState.vertexAttribPointersSet |= ATTR_LIGHTDIRECTION; + } + + if((attribBits & ATTR_POSITION2) && (!(glState.vertexAttribPointersSet & ATTR_POSITION2) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION2 )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, glState.currentVBO->stride_xyz, BUFFER_OFFSET(glState.currentVBO->ofs_xyz + oldFrame * glState.currentVBO->size_xyz)); + glState.vertexAttribPointersSet |= ATTR_POSITION2; + } + + if((attribBits & ATTR_NORMAL2) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL2) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL2 )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 3, GL_FLOAT, 0, glState.currentVBO->stride_normal, BUFFER_OFFSET(glState.currentVBO->ofs_normal + oldFrame * glState.currentVBO->size_normal)); + glState.vertexAttribPointersSet |= ATTR_NORMAL2; + } + +#ifdef USE_VERT_TANGENT_SPACE + if((attribBits & ATTR_TANGENT2) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT2) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT2 )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 3, GL_FLOAT, 0, glState.currentVBO->stride_tangent, BUFFER_OFFSET(glState.currentVBO->ofs_tangent + oldFrame * glState.currentVBO->size_normal)); // FIXME + glState.vertexAttribPointersSet |= ATTR_TANGENT2; + } + + if((attribBits & ATTR_BITANGENT2) && (!(glState.vertexAttribPointersSet & ATTR_BITANGENT2) || animated)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BITANGENT2 )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_BITANGENT2, 3, GL_FLOAT, 0, glState.currentVBO->stride_bitangent, BUFFER_OFFSET(glState.currentVBO->ofs_bitangent + oldFrame * glState.currentVBO->size_normal)); // FIXME + glState.vertexAttribPointersSet |= ATTR_BITANGENT2; + } +#endif + +} + + +shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) +{ + shaderStage_t *pStage = tess.xstages[stage]; + int shaderAttribs = 0; + + if (tess.fogNum && pStage->adjustColorsForFog) + { + shaderAttribs |= GENERICDEF_USE_FOG; + } + + if (pStage->bundle[1].image[0] && tess.shader->multitextureEnv) + { + shaderAttribs |= GENERICDEF_USE_LIGHTMAP; + } + + switch (pStage->rgbGen) + { + case CGEN_LIGHTING_DIFFUSE: + shaderAttribs |= GENERICDEF_USE_RGBAGEN; + break; + default: + break; + } + + switch (pStage->alphaGen) + { + case AGEN_LIGHTING_SPECULAR: + case AGEN_PORTAL: + case AGEN_FRESNEL: + shaderAttribs |= GENERICDEF_USE_RGBAGEN; + break; + default: + break; + } + + if (pStage->bundle[0].tcGen != TCGEN_TEXTURE) + { + shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; + } + + if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) + { + shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; + } + + if (glState.vertexAttribsInterpolation > 0.0f && backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + { + shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; + } + + if (pStage->bundle[0].numTexMods) + { + shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; + } + + return &tr.genericShader[shaderAttribs]; +} diff --git a/codemp/rd-rend2/tr_image.c b/codemp/rd-rend2/tr_image.c new file mode 100644 index 0000000000..c9ca6ce6ca --- /dev/null +++ b/codemp/rd-rend2/tr_image.c @@ -0,0 +1,3358 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_image.c +#include "tr_local.h" + +static byte s_intensitytable[256]; +static unsigned char s_gammatable[256]; + +int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; +int gl_filter_max = GL_LINEAR; + +#define FILE_HASH_SIZE 1024 +static image_t* hashTable[FILE_HASH_SIZE]; + +/* +** R_GammaCorrect +*/ +void R_GammaCorrect( byte *buffer, int bufSize ) { + int i; + + for ( i = 0; i < bufSize; i++ ) { + buffer[i] = s_gammatable[buffer[i]]; + } +} + +typedef struct { + char *name; + int minimize, maximize; +} textureMode_t; + +textureMode_t modes[] = { + {"GL_NEAREST", GL_NEAREST, GL_NEAREST}, + {"GL_LINEAR", GL_LINEAR, GL_LINEAR}, + {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, + {"GL_LINEAR_MIPMAP_NEAREST", GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR}, + {"GL_NEAREST_MIPMAP_LINEAR", GL_NEAREST_MIPMAP_LINEAR, GL_NEAREST}, + {"GL_LINEAR_MIPMAP_LINEAR", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR} +}; + +/* +================ +return a hash value for the filename +================ +*/ +static long generateHashValue( const char *fname ) { + int i; + long hash; + char letter; + + hash = 0; + i = 0; + while (fname[i] != '\0') { + letter = tolower(fname[i]); + if (letter =='.') break; // don't include extension + if (letter =='\\') letter = '/'; // damn path names + hash+=(long)(letter)*(i+119); + i++; + } + hash &= (FILE_HASH_SIZE-1); + return hash; +} + +/* +=============== +GL_TextureMode +=============== +*/ +void GL_TextureMode( const char *string ) { + int i; + image_t *glt; + + for ( i=0 ; i< 6 ; i++ ) { + if ( !Q_stricmp( modes[i].name, string ) ) { + break; + } + } + + // hack to prevent trilinear from being set on voodoo, + // because their driver freaks... + if ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D ) { + ri.Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); + i = 3; + } + + + if ( i == 6 ) { + ri.Printf (PRINT_ALL, "bad filter name\n"); + return; + } + + gl_filter_min = modes[i].minimize; + gl_filter_max = modes[i].maximize; + + // change all the existing mipmap texture objects + for ( i = 0 ; i < tr.numImages ; i++ ) { + glt = tr.images[ i ]; + if ( glt->flags & IMGFLAG_MIPMAP ) { + GL_Bind (glt); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + } +} + +/* +=============== +R_SumOfUsedImages +=============== +*/ +int R_SumOfUsedImages( void ) { + int total; + int i; + + total = 0; + for ( i = 0; i < tr.numImages; i++ ) { + if ( tr.images[i]->frameUsed == tr.frameCount ) { + total += tr.images[i]->uploadWidth * tr.images[i]->uploadHeight; + } + } + + return total; +} + +/* +=============== +R_ImageList_f +=============== +*/ +void R_ImageList_f( void ) { + int i; + int estTotalSize = 0; + + ri.Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); + + for ( i = 0 ; i < tr.numImages ; i++ ) + { + image_t *image = tr.images[i]; + char *format = "???? "; + char *sizeSuffix; + int estSize; + int displaySize; + + estSize = image->uploadHeight * image->uploadWidth; + + switch(image->internalFormat) + { + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: + format = "sDXT1"; + // 64 bits per 16 pixels, so 4 bits per pixel + estSize /= 2; + break; + case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: + format = "sDXT5"; + // 128 bits per 16 pixels, so 1 byte per pixel + break; + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: + format = "sBPTC"; + // 128 bits per 16 pixels, so 1 byte per pixel + break; + case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT: + format = "LATC "; + // 128 bits per 16 pixels, so 1 byte per pixel + break; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + format = "DXT1 "; + // 64 bits per 16 pixels, so 4 bits per pixel + estSize /= 2; + break; + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + format = "DXT5 "; + // 128 bits per 16 pixels, so 1 byte per pixel + break; + case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: + format = "BPTC "; + // 128 bits per 16 pixels, so 1 byte per pixel + break; + case GL_RGB4_S3TC: + format = "S3TC "; + // same as DXT1? + estSize /= 2; + break; + case GL_RGBA4: + case GL_RGBA8: + case GL_RGBA: + format = "RGBA "; + // 4 bytes per pixel + estSize *= 4; + break; + case GL_LUMINANCE8: + case GL_LUMINANCE16: + case GL_LUMINANCE: + format = "L "; + // 1 byte per pixel? + break; + case GL_RGB5: + case GL_RGB8: + case GL_RGB: + format = "RGB "; + // 3 bytes per pixel? + estSize *= 3; + break; + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE16_ALPHA16: + case GL_LUMINANCE_ALPHA: + format = "LA "; + // 2 bytes per pixel? + estSize *= 2; + break; + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + format = "sRGB "; + // 3 bytes per pixel? + estSize *= 3; + break; + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + format = "sRGBA"; + // 4 bytes per pixel? + estSize *= 4; + break; + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + format = "sL "; + // 1 byte per pixel? + break; + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + format = "sLA "; + // 2 byte per pixel? + estSize *= 2; + break; + } + + // mipmap adds about 50% + if (image->flags & IMGFLAG_MIPMAP) + estSize += estSize / 2; + + sizeSuffix = "b "; + displaySize = estSize; + + if (displaySize > 1024) + { + displaySize /= 1024; + sizeSuffix = "kb"; + } + + if (displaySize > 1024) + { + displaySize /= 1024; + sizeSuffix = "Mb"; + } + + if (displaySize > 1024) + { + displaySize /= 1024; + sizeSuffix = "Gb"; + } + + ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName); + estTotalSize += estSize; + } + + ri.Printf (PRINT_ALL, " ---------\n"); + ri.Printf (PRINT_ALL, " approx %i bytes\n", estTotalSize); + ri.Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); +} + +//======================================================================= + +/* +================ +ResampleTexture + +Used to resample images in a more general than quartering fashion. + +This will only be filtered properly if the resampled size +is greater than half the original size. + +If a larger shrinking is needed, use the mipmap function +before or after. +================ +*/ +static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, + int outwidth, int outheight ) { + int i, j; + byte *inrow, *inrow2; + int frac, fracstep; + int p1[2048], p2[2048]; + byte *pix1, *pix2, *pix3, *pix4; + + if (outwidth>2048) + ri.Error(ERR_DROP, "ResampleTexture: max width"); + + fracstep = inwidth*0x10000/outwidth; + + frac = fracstep>>2; + for ( i=0 ; i>16); + frac += fracstep; + } + frac = 3*(fracstep>>2); + for ( i=0 ; i>16); + frac += fracstep; + } + + for (i=0 ; i>2; + *out++ = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2; + *out++ = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2; + *out++ = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2; + } + } +} + +static void RGBAtoYCoCgA(const byte *in, byte *out, int width, int height) +{ + int x, y; + + for (y = 0; y < height; y++) + { + const byte *inbyte = in + y * width * 4; + byte *outbyte = out + y * width * 4; + + for (x = 0; x < width; x++) + { + byte r, g, b, a, rb2; + + r = *inbyte++; + g = *inbyte++; + b = *inbyte++; + a = *inbyte++; + rb2 = (r + b) >> 1; + + *outbyte++ = (g + rb2) >> 1; // Y = R/4 + G/2 + B/4 + *outbyte++ = (r - b + 256) >> 1; // Co = R/2 - B/2 + *outbyte++ = (g - rb2 + 256) >> 1; // Cg = -R/4 + G/2 - B/4 + *outbyte++ = a; + } + } +} + +static void YCoCgAtoRGBA(const byte *in, byte *out, int width, int height) +{ + int x, y; + + for (y = 0; y < height; y++) + { + const byte *inbyte = in + y * width * 4; + byte *outbyte = out + y * width * 4; + + for (x = 0; x < width; x++) + { + byte _Y, Co, Cg, a; + + _Y = *inbyte++; + Co = *inbyte++; + Cg = *inbyte++; + a = *inbyte++; + + *outbyte++ = CLAMP(_Y + Co - Cg, 0, 255); // R = Y + Co - Cg + *outbyte++ = CLAMP(_Y + Cg - 128, 0, 255); // G = Y + Cg + *outbyte++ = CLAMP(_Y - Co - Cg + 256, 0, 255); // B = Y - Co - Cg + *outbyte++ = a; + } + } +} + + +// uses a sobel filter to change a texture to a normal map +static void RGBAtoNormal(const byte *in, byte *out, int width, int height, qboolean clampToEdge) +{ + int x, y, max; + + // convert to heightmap, storing in alpha + // same as converting to Y in YCoCg + max = 1; + for (y = 0; y < height; y++) + { + const byte *inbyte = in + y * width * 4; + byte *outbyte = out + y * width * 4 + 3; + + for (x = 0; x < width; x++) + { + *outbyte = (inbyte[0] >> 2) + (inbyte[1] >> 1) + (inbyte[2] >> 2); + max = MAX(max, *outbyte); + outbyte += 4; + inbyte += 4; + } + } + + // level out heights + if (max < 255) + { + for (y = 0; y < height; y++) + { + byte *outbyte = out + y * width * 4 + 3; + + for (x = 0; x < width; x++) + { + *outbyte = *outbyte + (255 - max); + outbyte += 4; + } + } + } + + + // now run sobel filter over height values to generate X and Y + // then normalize + for (y = 0; y < height; y++) + { + byte *outbyte = out + y * width * 4; + + for (x = 0; x < width; x++) + { + // 0 1 2 + // 3 4 5 + // 6 7 8 + + byte s[9]; + int x2, y2, i; + vec3_t normal; + + i = 0; + for (y2 = -1; y2 <= 1; y2++) + { + int src_y = y + y2; + + if (clampToEdge) + { + src_y = CLAMP(src_y, 0, height - 1); + } + else + { + src_y = (src_y + height) % height; + } + + + for (x2 = -1; x2 <= 1; x2++) + { + int src_x = x + x2; + + if (clampToEdge) + { + src_x = CLAMP(src_x, 0, height - 1); + } + else + { + src_x = (src_x + height) % height; + } + + s[i++] = *(out + (src_y * width + src_x) * 4 + 3); + } + } + + normal[0] = s[0] - s[2] + + 2 * s[3] - 2 * s[5] + + s[6] - s[8]; + + normal[1] = s[0] + 2 * s[1] + s[2] + + - s[6] - 2 * s[7] - s[8]; + + normal[2] = s[4] * 4; + + if (!VectorNormalize2(normal, normal)) + { + VectorSet(normal, 0, 0, 1); + } + + *outbyte++ = FloatToOffsetByte(normal[0]); + *outbyte++ = FloatToOffsetByte(normal[1]); + *outbyte++ = FloatToOffsetByte(normal[2]); + outbyte++; + } + } +} + +#define COPYSAMPLE(a,b) *(unsigned int *)(a) = *(unsigned int *)(b) + +// based on Fast Curve Based Interpolation +// from Fast Artifacts-Free Image Interpolation (http://www.andreagiachetti.it/icbi/) +// assumes data has a 2 pixel thick border of clamped or wrapped data +// expects data to be a grid with even (0, 0), (2, 0), (0, 2), (2, 2) etc pixels filled +// only performs FCBI on specified component +static void DoFCBI(byte *in, byte *out, int width, int height, int component) +{ + int x, y; + byte *outbyte, *inbyte; + + // copy in to out + for (y = 2; y < height - 2; y += 2) + { + inbyte = in + (y * width + 2) * 4 + component; + outbyte = out + (y * width + 2) * 4 + component; + + for (x = 2; x < width - 2; x += 2) + { + *outbyte = *inbyte; + outbyte += 8; + inbyte += 8; + } + } + + for (y = 3; y < height - 3; y += 2) + { + // diagonals + // + // NWp - northwest interpolated pixel + // NEp - northeast interpolated pixel + // NWd - northwest first derivative + // NEd - northeast first derivative + // NWdd - northwest second derivative + // NEdd - northeast second derivative + // + // Uses these samples: + // + // 0 + // - - a - b - - + // - - - - - - - + // c - d - e - f + // 0 - - - - - - - + // g - h - i - j + // - - - - - - - + // - - k - l - - + // + // x+2 uses these samples: + // + // 0 + // - - - - a - b - - + // - - - - - - - - - + // - - c - d - e - f + // 0 - - - - - - - - - + // - - g - h - i - j + // - - - - - - - - - + // - - - - k - l - - + // + // so we can reuse 8 of them on next iteration + // + // a=b, c=d, d=e, e=f, g=h, h=i, i=j, k=l + // + // only b, f, j, and l need to be sampled on next iteration + + byte sa, sb, sc, sd, se, sf, sg, sh, si, sj, sk, sl; + byte *line1, *line2, *line3, *line4; + + x = 3; + + // optimization one + // SAMPLE2(sa, x-1, y-3); + //SAMPLE2(sc, x-3, y-1); SAMPLE2(sd, x-1, y-1); SAMPLE2(se, x+1, y-1); + //SAMPLE2(sg, x-3, y+1); SAMPLE2(sh, x-1, y+1); SAMPLE2(si, x+1, y+1); + // SAMPLE2(sk, x-1, y+3); + + // optimization two + line1 = in + ((y - 3) * width + (x - 1)) * 4 + component; + line2 = in + ((y - 1) * width + (x - 3)) * 4 + component; + line3 = in + ((y + 1) * width + (x - 3)) * 4 + component; + line4 = in + ((y + 3) * width + (x - 1)) * 4 + component; + + // COPYSAMPLE(sa, line1); line1 += 8; + //COPYSAMPLE(sc, line2); line2 += 8; COPYSAMPLE(sd, line2); line2 += 8; COPYSAMPLE(se, line2); line2 += 8; + //COPYSAMPLE(sg, line3); line3 += 8; COPYSAMPLE(sh, line3); line3 += 8; COPYSAMPLE(si, line3); line3 += 8; + // COPYSAMPLE(sk, line4); line4 += 8; + + sa = *line1; line1 += 8; + sc = *line2; line2 += 8; sd = *line2; line2 += 8; se = *line2; line2 += 8; + sg = *line3; line3 += 8; sh = *line3; line3 += 8; si = *line3; line3 += 8; + sk = *line4; line4 += 8; + + outbyte = out + (y * width + x) * 4 + component; + + for ( ; x < width - 3; x += 2) + { + int NWd, NEd, NWp, NEp; + + // original + // SAMPLE2(sa, x-1, y-3); SAMPLE2(sb, x+1, y-3); + //SAMPLE2(sc, x-3, y-1); SAMPLE2(sd, x-1, y-1); SAMPLE2(se, x+1, y-1); SAMPLE2(sf, x+3, y-1); + //SAMPLE2(sg, x-3, y+1); SAMPLE2(sh, x-1, y+1); SAMPLE2(si, x+1, y+1); SAMPLE2(sj, x+3, y+1); + // SAMPLE2(sk, x-1, y+3); SAMPLE2(sl, x+1, y+3); + + // optimization one + //SAMPLE2(sb, x+1, y-3); + //SAMPLE2(sf, x+3, y-1); + //SAMPLE2(sj, x+3, y+1); + //SAMPLE2(sl, x+1, y+3); + + // optimization two + //COPYSAMPLE(sb, line1); line1 += 8; + //COPYSAMPLE(sf, line2); line2 += 8; + //COPYSAMPLE(sj, line3); line3 += 8; + //COPYSAMPLE(sl, line4); line4 += 8; + + sb = *line1; line1 += 8; + sf = *line2; line2 += 8; + sj = *line3; line3 += 8; + sl = *line4; line4 += 8; + + NWp = sd + si; + NEp = se + sh; + NWd = abs(sd - si); + NEd = abs(se - sh); + + if (NWd > 100 || NEd > 100 || abs(NWp-NEp) > 200) + { + if (NWd < NEd) + *outbyte = NWp >> 1; + else + *outbyte = NEp >> 1; + } + else + { + int NWdd, NEdd; + + //NEdd = abs(sg + sd + sb - 3 * (se + sh) + sk + si + sf); + //NWdd = abs(sa + se + sj - 3 * (sd + si) + sc + sh + sl); + NEdd = abs(sg + sb - 3 * NEp + sk + sf + NWp); + NWdd = abs(sa + sj - 3 * NWp + sc + sl + NEp); + + if (NWdd > NEdd) + *outbyte = NWp >> 1; + else + *outbyte = NEp >> 1; + } + + outbyte += 8; + + // COPYSAMPLE(sa, sb); + //COPYSAMPLE(sc, sd); COPYSAMPLE(sd, se); COPYSAMPLE(se, sf); + //COPYSAMPLE(sg, sh); COPYSAMPLE(sh, si); COPYSAMPLE(si, sj); + // COPYSAMPLE(sk, sl); + + sa = sb; + sc = sd; sd = se; se = sf; + sg = sh; sh = si; si = sj; + sk = sl; + } + } + + // hack: copy out to in again + for (y = 3; y < height - 3; y += 2) + { + inbyte = out + (y * width + 3) * 4 + component; + outbyte = in + (y * width + 3) * 4 + component; + + for (x = 3; x < width - 3; x += 2) + { + *outbyte = *inbyte; + outbyte += 8; + inbyte += 8; + } + } + + for (y = 2; y < height - 3; y++) + { + // horizontal & vertical + // + // hp - horizontally interpolated pixel + // vp - vertically interpolated pixel + // hd - horizontal first derivative + // vd - vertical first derivative + // hdd - horizontal second derivative + // vdd - vertical second derivative + // Uses these samples: + // + // 0 + // - a - b - + // c - d - e + // 0 - f - g - + // h - i - j + // - k - l - + // + // x+2 uses these samples: + // + // 0 + // - - - a - b - + // - - c - d - e + // 0 - - - f - g - + // - - h - i - j + // - - - k - l - + // + // so we can reuse 7 of them on next iteration + // + // a=b, c=d, d=e, f=g, h=i, i=j, k=l + // + // only b, e, g, j, and l need to be sampled on next iteration + + byte sa, sb, sc, sd, se, sf, sg, sh, si, sj, sk, sl; + byte *line1, *line2, *line3, *line4, *line5; + + //x = (y + 1) % 2; + x = (y + 1) % 2 + 2; + + // optimization one + // SAMPLE2(sa, x-1, y-2); + //SAMPLE2(sc, x-2, y-1); SAMPLE2(sd, x, y-1); + // SAMPLE2(sf, x-1, y ); + //SAMPLE2(sh, x-2, y+1); SAMPLE2(si, x, y+1); + // SAMPLE2(sk, x-1, y+2); + + line1 = in + ((y - 2) * width + (x - 1)) * 4 + component; + line2 = in + ((y - 1) * width + (x - 2)) * 4 + component; + line3 = in + ((y ) * width + (x - 1)) * 4 + component; + line4 = in + ((y + 1) * width + (x - 2)) * 4 + component; + line5 = in + ((y + 2) * width + (x - 1)) * 4 + component; + + // COPYSAMPLE(sa, line1); line1 += 8; + //COPYSAMPLE(sc, line2); line2 += 8; COPYSAMPLE(sd, line2); line2 += 8; + // COPYSAMPLE(sf, line3); line3 += 8; + //COPYSAMPLE(sh, line4); line4 += 8; COPYSAMPLE(si, line4); line4 += 8; + // COPYSAMPLE(sk, line5); line5 += 8; + + sa = *line1; line1 += 8; + sc = *line2; line2 += 8; sd = *line2; line2 += 8; + sf = *line3; line3 += 8; + sh = *line4; line4 += 8; si = *line4; line4 += 8; + sk = *line5; line5 += 8; + + outbyte = out + (y * width + x) * 4 + component; + + for ( ; x < width - 3; x+=2) + { + int hd, vd, hp, vp; + + // SAMPLE2(sa, x-1, y-2); SAMPLE2(sb, x+1, y-2); + //SAMPLE2(sc, x-2, y-1); SAMPLE2(sd, x, y-1); SAMPLE2(se, x+2, y-1); + // SAMPLE2(sf, x-1, y ); SAMPLE2(sg, x+1, y ); + //SAMPLE2(sh, x-2, y+1); SAMPLE2(si, x, y+1); SAMPLE2(sj, x+2, y+1); + // SAMPLE2(sk, x-1, y+2); SAMPLE2(sl, x+1, y+2); + + // optimization one + //SAMPLE2(sb, x+1, y-2); + //SAMPLE2(se, x+2, y-1); + //SAMPLE2(sg, x+1, y ); + //SAMPLE2(sj, x+2, y+1); + //SAMPLE2(sl, x+1, y+2); + + //COPYSAMPLE(sb, line1); line1 += 8; + //COPYSAMPLE(se, line2); line2 += 8; + //COPYSAMPLE(sg, line3); line3 += 8; + //COPYSAMPLE(sj, line4); line4 += 8; + //COPYSAMPLE(sl, line5); line5 += 8; + + sb = *line1; line1 += 8; + se = *line2; line2 += 8; + sg = *line3; line3 += 8; + sj = *line4; line4 += 8; + sl = *line5; line5 += 8; + + hp = sf + sg; + vp = sd + si; + hd = abs(sf - sg); + vd = abs(sd - si); + + if (hd > 100 || vd > 100 || abs(hp-vp) > 200) + { + if (hd < vd) + *outbyte = hp >> 1; + else + *outbyte = vp >> 1; + } + else + { + int hdd, vdd; + + //hdd = abs(sc[i] + sd[i] + se[i] - 3 * (sf[i] + sg[i]) + sh[i] + si[i] + sj[i]); + //vdd = abs(sa[i] + sf[i] + sk[i] - 3 * (sd[i] + si[i]) + sb[i] + sg[i] + sl[i]); + + hdd = abs(sc + se - 3 * hp + sh + sj + vp); + vdd = abs(sa + sk - 3 * vp + sb + sl + hp); + + if (hdd > vdd) + *outbyte = hp >> 1; + else + *outbyte = vp >> 1; + } + + outbyte += 8; + + // COPYSAMPLE(sa, sb); + //COPYSAMPLE(sc, sd); COPYSAMPLE(sd, se); + // COPYSAMPLE(sf, sg); + //COPYSAMPLE(sh, si); COPYSAMPLE(si, sj); + // COPYSAMPLE(sk, sl); + sa = sb; + sc = sd; sd = se; + sf = sg; + sh = si; si = sj; + sk = sl; + } + } +} + +// Similar to FCBI, but throws out the second order derivatives for speed +static void DoFCBIQuick(byte *in, byte *out, int width, int height, int component) +{ + int x, y; + byte *outbyte, *inbyte; + + // copy in to out + for (y = 2; y < height - 2; y += 2) + { + inbyte = in + (y * width + 2) * 4 + component; + outbyte = out + (y * width + 2) * 4 + component; + + for (x = 2; x < width - 2; x += 2) + { + *outbyte = *inbyte; + outbyte += 8; + inbyte += 8; + } + } + + for (y = 3; y < height - 4; y += 2) + { + byte sd, se, sh, si; + byte *line2, *line3; + + x = 3; + + line2 = in + ((y - 1) * width + (x - 1)) * 4 + component; + line3 = in + ((y + 1) * width + (x - 1)) * 4 + component; + + sd = *line2; line2 += 8; + sh = *line3; line3 += 8; + + outbyte = out + (y * width + x) * 4 + component; + + for ( ; x < width - 4; x += 2) + { + int NWd, NEd, NWp, NEp; + + se = *line2; line2 += 8; + si = *line3; line3 += 8; + + NWp = sd + si; + NEp = se + sh; + NWd = abs(sd - si); + NEd = abs(se - sh); + + if (NWd < NEd) + *outbyte = NWp >> 1; + else + *outbyte = NEp >> 1; + + outbyte += 8; + + sd = se; + sh = si; + } + } + + // hack: copy out to in again + for (y = 3; y < height - 3; y += 2) + { + inbyte = out + (y * width + 3) * 4 + component; + outbyte = in + (y * width + 3) * 4 + component; + + for (x = 3; x < width - 3; x += 2) + { + *outbyte = *inbyte; + outbyte += 8; + inbyte += 8; + } + } + + for (y = 2; y < height - 3; y++) + { + byte sd, sf, sg, si; + byte *line2, *line3, *line4; + + x = (y + 1) % 2 + 2; + + line2 = in + ((y - 1) * width + (x )) * 4 + component; + line3 = in + ((y ) * width + (x - 1)) * 4 + component; + line4 = in + ((y + 1) * width + (x )) * 4 + component; + + outbyte = out + (y * width + x) * 4 + component; + + sf = *line3; line3 += 8; + + for ( ; x < width - 3; x+=2) + { + int hd, vd, hp, vp; + + sd = *line2; line2 += 8; + sg = *line3; line3 += 8; + si = *line4; line4 += 8; + + hp = sf + sg; + vp = sd + si; + hd = abs(sf - sg); + vd = abs(sd - si); + + if (hd < vd) + *outbyte = hp >> 1; + else + *outbyte = vp >> 1; + + outbyte += 8; + + sf = sg; + } + } +} + +// Similar to DoFCBIQuick, but just takes the average instead of checking derivatives +// as well, this operates on all four components +static void DoLinear(byte *in, byte *out, int width, int height) +{ + int x, y, i; + byte *outbyte, *inbyte; + + // copy in to out + for (y = 2; y < height - 2; y += 2) + { + x = 2; + + inbyte = in + (y * width + x) * 4; + outbyte = out + (y * width + x) * 4; + + for ( ; x < width - 2; x += 2) + { + COPYSAMPLE(outbyte, inbyte); + outbyte += 8; + inbyte += 8; + } + } + + for (y = 1; y < height - 1; y += 2) + { + byte sd[4] = {0}, se[4] = {0}, sh[4] = {0}, si[4] = {0}; + byte *line2, *line3; + + x = 1; + + line2 = in + ((y - 1) * width + (x - 1)) * 4; + line3 = in + ((y + 1) * width + (x - 1)) * 4; + + COPYSAMPLE(sd, line2); line2 += 8; + COPYSAMPLE(sh, line3); line3 += 8; + + outbyte = out + (y * width + x) * 4; + + for ( ; x < width - 1; x += 2) + { + COPYSAMPLE(se, line2); line2 += 8; + COPYSAMPLE(si, line3); line3 += 8; + + for (i = 0; i < 4; i++) + { + *outbyte++ = (sd[i] + si[i] + se[i] + sh[i]) >> 2; + } + + outbyte += 4; + + COPYSAMPLE(sd, se); + COPYSAMPLE(sh, si); + } + } + + // hack: copy out to in again + for (y = 1; y < height - 1; y += 2) + { + x = 1; + + inbyte = out + (y * width + x) * 4; + outbyte = in + (y * width + x) * 4; + + for ( ; x < width - 1; x += 2) + { + COPYSAMPLE(outbyte, inbyte); + outbyte += 8; + inbyte += 8; + } + } + + for (y = 1; y < height - 1; y++) + { + byte sd[4], sf[4], sg[4], si[4]; + byte *line2, *line3, *line4; + + x = y % 2 + 1; + + line2 = in + ((y - 1) * width + (x )) * 4; + line3 = in + ((y ) * width + (x - 1)) * 4; + line4 = in + ((y + 1) * width + (x )) * 4; + + COPYSAMPLE(sf, line3); line3 += 8; + + outbyte = out + (y * width + x) * 4; + + for ( ; x < width - 1; x += 2) + { + COPYSAMPLE(sd, line2); line2 += 8; + COPYSAMPLE(sg, line3); line3 += 8; + COPYSAMPLE(si, line4); line4 += 8; + + for (i = 0; i < 4; i++) + { + *outbyte++ = (sf[i] + sg[i] + sd[i] + si[i]) >> 2; + } + + outbyte += 4; + + COPYSAMPLE(sf, sg); + } + } +} + + +static void ExpandHalfTextureToGrid( byte *data, int width, int height) +{ + int x, y; + + for (y = height / 2; y > 0; y--) + { + byte *outbyte = data + ((y * 2 - 1) * (width) - 2) * 4; + byte *inbyte = data + (y * (width / 2) - 1) * 4; + + for (x = width / 2; x > 0; x--) + { + COPYSAMPLE(outbyte, inbyte); + + outbyte -= 8; + inbyte -= 4; + } + } +} + +static void FillInNormalizedZ(const byte *in, byte *out, int width, int height) +{ + int x, y; + + for (y = 0; y < height; y++) + { + const byte *inbyte = in + y * width * 4; + byte *outbyte = out + y * width * 4; + + for (x = 0; x < width; x++) + { + byte nx, ny, nz, h; + float fnx, fny, fll, fnz; + + nx = *inbyte++; + ny = *inbyte++; + inbyte++; + h = *inbyte++; + + fnx = OffsetByteToFloat(nx); + fny = OffsetByteToFloat(ny); + fll = 1.0f - fnx * fnx - fny * fny; + if (fll >= 0.0f) + fnz = (float)sqrt(fll); + else + fnz = 0.0f; + + nz = FloatToOffsetByte(fnz); + + *outbyte++ = nx; + *outbyte++ = ny; + *outbyte++ = nz; + *outbyte++ = h; + } + } +} + + +// size must be even +#define WORKBLOCK_SIZE 128 +#define WORKBLOCK_BORDER 4 +#define WORKBLOCK_REALSIZE (WORKBLOCK_SIZE + WORKBLOCK_BORDER * 2) + +// assumes that data has already been expanded into a 2x2 grid +static void FCBIByBlock(byte *data, int width, int height, qboolean clampToEdge, qboolean normalized) +{ + byte workdata[WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4]; + byte outdata[WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4]; + byte *inbyte, *outbyte; + int x, y; + int srcx, srcy; + + ExpandHalfTextureToGrid(data, width, height); + + for (y = 0; y < height; y += WORKBLOCK_SIZE) + { + for (x = 0; x < width; x += WORKBLOCK_SIZE) + { + int x2, y2; + int workwidth, workheight, fullworkwidth, fullworkheight; + + workwidth = MIN(WORKBLOCK_SIZE, width - x); + workheight = MIN(WORKBLOCK_SIZE, height - y); + + fullworkwidth = workwidth + WORKBLOCK_BORDER * 2; + fullworkheight = workheight + WORKBLOCK_BORDER * 2; + + //memset(workdata, 0, WORKBLOCK_REALSIZE * WORKBLOCK_REALSIZE * 4); + + // fill in work block + for (y2 = 0; y2 < fullworkheight; y2 += 2) + { + srcy = y + y2 - WORKBLOCK_BORDER; + + if (clampToEdge) + { + srcy = CLAMP(srcy, 0, height - 2); + } + else + { + srcy = (srcy + height) % height; + } + + outbyte = workdata + y2 * fullworkwidth * 4; + inbyte = data + srcy * width * 4; + + for (x2 = 0; x2 < fullworkwidth; x2 += 2) + { + srcx = x + x2 - WORKBLOCK_BORDER; + + if (clampToEdge) + { + srcx = CLAMP(srcx, 0, width - 2); + } + else + { + srcx = (srcx + width) % width; + } + + COPYSAMPLE(outbyte, inbyte + srcx * 4); + outbyte += 8; + } + } + + // submit work block + DoLinear(workdata, outdata, fullworkwidth, fullworkheight); + + if (!normalized) + { + switch (r_imageUpsampleType->integer) + { + case 0: + break; + case 1: + DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 0); + break; + case 2: + default: + DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 0); + break; + } + } + else + { + switch (r_imageUpsampleType->integer) + { + case 0: + break; + case 1: + DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 0); + DoFCBIQuick(workdata, outdata, fullworkwidth, fullworkheight, 1); + break; + case 2: + default: + DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 0); + DoFCBI(workdata, outdata, fullworkwidth, fullworkheight, 1); + break; + } + } + + // copy back work block + for (y2 = 0; y2 < workheight; y2++) + { + inbyte = outdata + ((y2 + WORKBLOCK_BORDER) * fullworkwidth + WORKBLOCK_BORDER) * 4; + outbyte = data + ((y + y2) * width + x) * 4; + for (x2 = 0; x2 < workwidth; x2++) + { + COPYSAMPLE(outbyte, inbyte); + outbyte += 4; + inbyte += 4; + } + } + } + } +} +#undef COPYSAMPLE + +/* +================ +R_LightScaleTexture + +Scale up the pixel values in a texture to increase the +lighting range +================ +*/ +void R_LightScaleTexture (byte *in, int inwidth, int inheight, qboolean only_gamma ) +{ + if ( only_gamma ) + { + if ( !glConfig.deviceSupportsGamma ) + { + int i, c; + byte *p; + + p = in; + + c = inwidth*inheight; + for (i=0 ; i> 1; + outHeight = inHeight >> 1; + temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + + inWidthMask = inWidth - 1; + inHeightMask = inHeight - 1; + + for ( i = 0 ; i < outHeight ; i++ ) { + for ( j = 0 ; j < outWidth ; j++ ) { + outpix = (byte *) ( temp + i * outWidth + j ); + for ( k = 0 ; k < 4 ; k++ ) { + total = + 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + + 1 * (&in[ 4*(((i*2-1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + + + 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + + 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + + 4 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2 )&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + + + 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + + 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + + 4 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2+1)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k] + + + 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2-1)&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2 )&inWidthMask)) ])[k] + + 2 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+1)&inWidthMask)) ])[k] + + 1 * (&in[ 4*(((i*2+2)&inHeightMask)*inWidth + ((j*2+2)&inWidthMask)) ])[k]; + outpix[k] = total / 36; + } + } + } + + Com_Memcpy( in, temp, outWidth * outHeight * 4 ); + ri.Hunk_FreeTempMemory( temp ); +} + + +static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) +{ + int i, j, k; + int outWidth, outHeight; + byte *temp; + + outWidth = inWidth >> 1; + outHeight = inHeight >> 1; + temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + + for ( i = 0 ; i < outHeight ; i++ ) { + byte *outbyte = temp + ( i * outWidth ) * 4; + byte *inbyte1 = in + ( i * 2 * inWidth ) * 4; + byte *inbyte2 = in + ( (i * 2 + 1) * inWidth ) * 4; + for ( j = 0 ; j < outWidth ; j++ ) { + for ( k = 0 ; k < 3 ; k++ ) { + float total, current; + + current = ByteToFloat(inbyte1[0]); total = sRGBtoRGB(current); + current = ByteToFloat(inbyte1[4]); total += sRGBtoRGB(current); + current = ByteToFloat(inbyte2[0]); total += sRGBtoRGB(current); + current = ByteToFloat(inbyte2[4]); total += sRGBtoRGB(current); + + total *= 0.25f; + + inbyte1++; + inbyte2++; + + current = RGBtosRGB(total); + *outbyte++ = FloatToByte(current); + } + *outbyte++ = (inbyte1[0] + inbyte1[4] + inbyte2[0] + inbyte2[4]) >> 2; + inbyte1 += 5; + inbyte2 += 5; + } + } + + Com_Memcpy( in, temp, outWidth * outHeight * 4 ); + ri.Hunk_FreeTempMemory( temp ); +} + +/* +================ +R_MipMap + +Operates in place, quartering the size of the texture +================ +*/ +static void R_MipMap (byte *in, int width, int height) { + int i, j; + byte *out; + int row; + + if ( !r_simpleMipMaps->integer ) { + R_MipMap2( in, width, height ); + return; + } + + if ( width == 1 && height == 1 ) { + return; + } + + row = width * 4; + out = in; + width >>= 1; + height >>= 1; + + if ( width == 0 || height == 0 ) { + width += height; // get largest + for (i=0 ; i>1; + out[1] = ( in[1] + in[5] )>>1; + out[2] = ( in[2] + in[6] )>>1; + out[3] = ( in[3] + in[7] )>>1; + } + return; + } + + for (i=0 ; i>2; + out[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2; + out[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2; + out[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2; + } + } +} + + +static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int height) +{ + int i, j, row; + + if ( width == 1 && height == 1 ) { + return; + } + + row = width * 4; + width >>= 1; + height >>= 1; + + if ( width == 0 || height == 0 ) { + width += height; // get largest + for (i=0 ; i> 1; + out[3] = (in[3] + in[7]) >> 1; + } + return; + } + + for (i=0 ; i> 2; + out[3] = (in[3] + in[7] + in[row+3] + in[row+7]) >> 2; + } + } + +} + + +static void R_MipMapNormalHeight (const byte *in, byte *out, int width, int height, qboolean swizzle) +{ + int i, j; + int row; + int sx = swizzle ? 3 : 0; + int sa = swizzle ? 0 : 3; + + if ( width == 1 && height == 1 ) { + return; + } + + row = width * 4; + width >>= 1; + height >>= 1; + + for (i=0 ; i> 9; + data[1] = ( data[1] * inverseAlpha + premult[1] ) >> 9; + data[2] = ( data[2] * inverseAlpha + premult[2] ) >> 9; + } +} + +byte mipBlendColors[16][4] = { + {0,0,0,0}, + {255,0,0,128}, + {0,255,0,128}, + {0,0,255,128}, + {255,0,0,128}, + {0,255,0,128}, + {0,0,255,128}, + {255,0,0,128}, + {0,255,0,128}, + {0,0,255,128}, + {255,0,0,128}, + {0,255,0,128}, + {0,0,255,128}, + {255,0,0,128}, + {0,255,0,128}, + {0,0,255,128}, +}; + +static void RawImage_SwizzleRA( byte *data, int width, int height ) +{ + int i; + byte *ptr = data, swap; + + for (i=0; iinteger && scaled_width > width ) + scaled_width >>= 1; + if ( r_roundImagesDown->integer && scaled_height > height ) + scaled_height >>= 1; + + if ( picmip && data && resampledBuffer && r_imageUpsample->integer && + scaled_width < r_imageUpsampleMaxSize->integer && scaled_height < r_imageUpsampleMaxSize->integer) + { + int finalwidth, finalheight; + //int startTime, endTime; + + //startTime = ri.Milliseconds(); + + finalwidth = scaled_width << r_imageUpsample->integer; + finalheight = scaled_height << r_imageUpsample->integer; + + while ( finalwidth > r_imageUpsampleMaxSize->integer + || finalheight > r_imageUpsampleMaxSize->integer ) { + finalwidth >>= 1; + finalheight >>= 1; + } + + while ( finalwidth > glConfig.maxTextureSize + || finalheight > glConfig.maxTextureSize ) { + finalwidth >>= 1; + finalheight >>= 1; + } + + *resampledBuffer = ri.Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); + + if (scaled_width != width || scaled_height != height) + { + ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); + } + else + { + byte *inbyte, *outbyte; + int i; + + inbyte = *data; + outbyte = *resampledBuffer; + + for (i = width * height * 4; i > 0; i--) + { + *outbyte++ = *inbyte++; + } + } + + if (type == IMGTYPE_COLORALPHA) + RGBAtoYCoCgA(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); + + while (scaled_width < finalwidth || scaled_height < finalheight) + { + scaled_width <<= 1; + scaled_height <<= 1; + + FCBIByBlock(*resampledBuffer, scaled_width, scaled_height, clampToEdge, (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)); + } + + if (type == IMGTYPE_COLORALPHA) + { + YCoCgAtoRGBA(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); + } + else if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) + { + FillInNormalizedZ(*resampledBuffer, *resampledBuffer, scaled_width, scaled_height); + } + + + //endTime = ri.Milliseconds(); + + //ri.Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); + + *data = *resampledBuffer; + width = scaled_width; + height = scaled_height; + } + else if ( scaled_width != width || scaled_height != height ) { + if (data && resampledBuffer) + { + *resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); + ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); + *data = *resampledBuffer; + } + width = scaled_width; + height = scaled_height; + } + + // + // perform optional picmip operation + // + if ( picmip ) { + scaled_width >>= r_picmip->integer; + scaled_height >>= r_picmip->integer; + } + + // + // clamp to minimum size + // + if (scaled_width < 1) { + scaled_width = 1; + } + if (scaled_height < 1) { + scaled_height = 1; + } + + // + // clamp to the current upper OpenGL limit + // scale both axis down equally so we don't have to + // deal with a half mip resampling + // + while ( scaled_width > glConfig.maxTextureSize + || scaled_height > glConfig.maxTextureSize ) { + scaled_width >>= 1; + scaled_height >>= 1; + } + + *inout_width = width; + *inout_height = height; + *inout_scaled_width = scaled_width; + *inout_scaled_height = scaled_height; +} + + +static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) +{ + int i; + + if (!scan) + return qtrue; + + for ( i = 0; i < numPixels; i++ ) + { + if ( scan[i*4 + 3] != 255 ) + { + return qtrue; + } + } + + return qfalse; +} + +static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean lightMap, imgType_t type, imgFlags_t flags) +{ + int samples = 3; + GLenum internalFormat = GL_RGB; + qboolean forceNoCompression = (flags & IMGFLAG_NO_COMPRESSION); + qboolean normalmap = (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT); + + if(normalmap) + { + if ((!RawImage_HasAlpha(data, numPixels) || (type == IMGTYPE_NORMAL)) && !forceNoCompression && (glRefConfig.textureCompression & TCR_LATC)) + { + internalFormat = GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT; + } + else + { + if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB ) + { + internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else if ( r_texturebits->integer == 16 ) + { + internalFormat = GL_RGBA4; + } + else if ( r_texturebits->integer == 32 ) + { + internalFormat = GL_RGBA8; + } + else + { + internalFormat = GL_RGBA; + } + } + } + else if(lightMap) + { + if(r_greyscale->integer) + internalFormat = GL_LUMINANCE; + else + internalFormat = GL_RGBA; + } + else + { + if (RawImage_HasAlpha(data, numPixels)) + { + samples = 4; + } + + // select proper internal format + if ( samples == 3 ) + { + if(r_greyscale->integer) + { + if(r_texturebits->integer == 16) + internalFormat = GL_LUMINANCE8; + else if(r_texturebits->integer == 32) + internalFormat = GL_LUMINANCE16; + else + internalFormat = GL_LUMINANCE; + } + else + { + if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) + { + internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + } + else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB ) + { + internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + } + else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC ) + { + internalFormat = GL_RGB4_S3TC; + } + else if ( r_texturebits->integer == 16 ) + { + internalFormat = GL_RGB5; + } + else if ( r_texturebits->integer == 32 ) + { + internalFormat = GL_RGB8; + } + else + { + internalFormat = GL_RGB; + } + } + } + else if ( samples == 4 ) + { + if(r_greyscale->integer) + { + if(r_texturebits->integer == 16) + internalFormat = GL_LUMINANCE8_ALPHA8; + else if(r_texturebits->integer == 32) + internalFormat = GL_LUMINANCE16_ALPHA16; + else + internalFormat = GL_LUMINANCE_ALPHA; + } + else + { + if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) + { + internalFormat = GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + } + else if ( !forceNoCompression && glConfig.textureCompression == TC_S3TC_ARB ) + { + internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + } + else if ( r_texturebits->integer == 16 ) + { + internalFormat = GL_RGBA4; + } + else if ( r_texturebits->integer == 32 ) + { + internalFormat = GL_RGBA8; + } + else + { + internalFormat = GL_RGBA; + } + } + } + + if (glRefConfig.texture_srgb && (flags & IMGFLAG_SRGB)) + { + switch(internalFormat) + { + case GL_RGB: + internalFormat = GL_SRGB_EXT; + break; + + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + internalFormat = GL_SRGB8_EXT; + break; + + case GL_RGBA: + internalFormat = GL_SRGB_ALPHA_EXT; + break; + + case GL_RGBA4: + case GL_RGBA8: + internalFormat = GL_SRGB8_ALPHA8_EXT; + break; + + case GL_LUMINANCE: + internalFormat = GL_SLUMINANCE_EXT; + break; + + case GL_LUMINANCE8: + case GL_LUMINANCE16: + internalFormat = GL_SLUMINANCE8_EXT; + break; + + case GL_LUMINANCE_ALPHA: + internalFormat = GL_SLUMINANCE_ALPHA_EXT; + break; + + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE16_ALPHA16: + internalFormat = GL_SLUMINANCE8_ALPHA8_EXT; + break; + + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; + break; + + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT; + break; + + case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: + internalFormat = GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB; + break; + } + } + } + + return internalFormat; +} + + +static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, imgFlags_t flags, qboolean subtexture ) +{ + int dataFormat, dataType; + + switch(internalFormat) + { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16_ARB: + case GL_DEPTH_COMPONENT24_ARB: + case GL_DEPTH_COMPONENT32_ARB: + dataFormat = GL_DEPTH_COMPONENT; + dataType = GL_UNSIGNED_BYTE; + break; + case GL_RGBA16F_ARB: + dataFormat = GL_RGBA; + dataType = GL_HALF_FLOAT_ARB; + break; + default: + dataFormat = GL_RGBA; + dataType = GL_UNSIGNED_BYTE; + break; + } + + if ( subtexture ) + qglTexSubImage2D( GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data ); + else + qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, width, height, 0, dataFormat, dataType, data ); + + if (flags & IMGFLAG_MIPMAP) + { + int miplevel; + + miplevel = 0; + while (width > 1 || height > 1) + { + if (data) + { + if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) + { + if (internalFormat == GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT) + { + R_MipMapLuminanceAlpha( data, data, width, height ); + } + else + { + R_MipMapNormalHeight( data, data, width, height, qtrue); + } + } + else if (flags & IMGFLAG_SRGB) + { + R_MipMapsRGB( data, width, height ); + } + else + { + R_MipMap( data, width, height ); + } + } + + width >>= 1; + height >>= 1; + if (width < 1) + width = 1; + if (height < 1) + height = 1; + miplevel++; + + if ( data && r_colorMipLevels->integer ) + R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] ); + + if ( subtexture ) + { + x >>= 1; + y >>= 1; + qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); + } + else + { + qglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, width, height, 0, dataFormat, dataType, data ); + } + } + } +} + + +/* +=============== +Upload32 + +=============== +*/ +extern qboolean charSet; +static void Upload32( byte *data, int width, int height, imgType_t type, imgFlags_t flags, + qboolean lightMap, GLenum internalFormat, int *pUploadWidth, int *pUploadHeight) +{ + byte *scaledBuffer = NULL; + byte *resampledBuffer = NULL; + int scaled_width, scaled_height; + int i, c; + byte *scan; + + RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); + + scaledBuffer = ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + + // + // scan the texture for each channel's max values + // and verify if the alpha channel is being used or not + // + c = width*height; + scan = data; + + if( r_greyscale->integer ) + { + for ( i = 0; i < c; i++ ) + { + byte luma = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); + scan[i*4] = luma; + scan[i*4 + 1] = luma; + scan[i*4 + 2] = luma; + } + } + else if( r_greyscale->value ) + { + for ( i = 0; i < c; i++ ) + { + float luma = LUMA(scan[i*4], scan[i*4 + 1], scan[i*4 + 2]); + scan[i*4] = LERP(scan[i*4], luma, r_greyscale->value); + scan[i*4 + 1] = LERP(scan[i*4 + 1], luma, r_greyscale->value); + scan[i*4 + 2] = LERP(scan[i*4 + 2], luma, r_greyscale->value); + } + } + + // Convert to RGB if sRGB textures aren't supported in hardware + if (!glRefConfig.texture_srgb && (flags & IMGFLAG_SRGB)) + { + byte *in = data; + int c = width * height; + while (c--) + { + for (i = 0; i < 3; i++) + { + float x = ByteToFloat(in[i]); + x = sRGBtoRGB(x); + in[i] = FloatToByte(x); + } + in += 4; + } + + // FIXME: Probably should mark the image as non-sRGB as well + flags &= ~IMGFLAG_SRGB; + } + + // normals are always swizzled + if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) + { + RawImage_SwizzleRA(data, width, height); + } + + // LATC2 is only used for normals + if (internalFormat == GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT) + { + byte *in = data; + int c = width * height; + while (c--) + { + in[0] = in[1]; + in[2] = in[1]; + in += 4; + } + } + + // copy or resample data as appropriate for first MIP level + if ( ( scaled_width == width ) && + ( scaled_height == height ) ) { + if (!(flags & IMGFLAG_MIPMAP)) + { + RawImage_UploadTexture( data, 0, 0, scaled_width, scaled_height, internalFormat, type, flags, qfalse ); + //qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + *pUploadWidth = scaled_width; + *pUploadHeight = scaled_height; + + goto done; + } + Com_Memcpy (scaledBuffer, data, width*height*4); + } + else + { + // use the normal mip-mapping function to go down from here + while ( width > scaled_width || height > scaled_height ) { + + if (flags & IMGFLAG_SRGB) + { + R_MipMapsRGB( (byte *)data, width, height ); + } + else + { + R_MipMap( (byte *)data, width, height ); + } + + width >>= 1; + height >>= 1; + if ( width < 1 ) { + width = 1; + } + if ( height < 1 ) { + height = 1; + } + } + Com_Memcpy( scaledBuffer, data, width * height * 4 ); + } + + if (!(flags & IMGFLAG_NOLIGHTSCALE)) + R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, !(flags & IMGFLAG_MIPMAP) ); + + *pUploadWidth = scaled_width; + *pUploadHeight = scaled_height; + + RawImage_UploadTexture(scaledBuffer, 0, 0, scaled_width, scaled_height, internalFormat, type, flags, qfalse); + +done: + + if (flags & IMGFLAG_MIPMAP) + { + if ( textureFilterAnisotropic ) + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, + (GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) ); + + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + else + { + if ( textureFilterAnisotropic ) + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 ); + + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + } + + GL_CheckErrors(); + + if ( scaledBuffer != 0 ) + ri.Hunk_FreeTempMemory( scaledBuffer ); + if ( resampledBuffer != 0 ) + ri.Hunk_FreeTempMemory( resampledBuffer ); +} + + +static void EmptyTexture( int width, int height, imgType_t type, imgFlags_t flags, + qboolean lightMap, GLenum internalFormat, int *pUploadWidth, int *pUploadHeight ) +{ + int scaled_width, scaled_height; + + RawImage_ScaleToPower2(NULL, &width, &height, &scaled_width, &scaled_height, type, flags, NULL); + + *pUploadWidth = scaled_width; + *pUploadHeight = scaled_height; + + RawImage_UploadTexture(NULL, 0, 0, scaled_width, scaled_height, internalFormat, type, flags, qfalse); + + if (flags & IMGFLAG_MIPMAP) + { + if ( textureFilterAnisotropic ) + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, + (GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) ); + + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + } + else + { + if ( textureFilterAnisotropic ) + qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 ); + + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + } + + // Fix for sampling depth buffer on old nVidia cards + // from http://www.idevgames.com/forums/thread-4141-post-34844.html#pid34844 + switch(internalFormat) + { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16_ARB: + case GL_DEPTH_COMPONENT24_ARB: + case GL_DEPTH_COMPONENT32_ARB: + qglTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); + break; + default: + break; + } + + GL_CheckErrors(); +} + + +/* +================ +R_CreateImage + +This is the only way any image_t are created +================ +*/ +image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat ) { + image_t *image; + qboolean isLightmap = qfalse; + long hash; + int glWrapClampMode; + + if (strlen(name) >= MAX_QPATH ) { + ri.Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); + } + if ( !strncmp( name, "*lightmap", 9 ) ) { + isLightmap = qtrue; + } + + if ( tr.numImages == MAX_DRAWIMAGES ) { + ri.Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); + } + + image = tr.images[tr.numImages] = ri.Hunk_Alloc( sizeof( image_t ), h_low ); + image->texnum = 1024 + tr.numImages; + tr.numImages++; + + image->type = type; + image->flags = flags; + + strcpy (image->imgName, name); + + image->width = width; + image->height = height; + if (flags & IMGFLAG_CLAMPTOEDGE) + glWrapClampMode = GL_CLAMP_TO_EDGE; + else + glWrapClampMode = GL_REPEAT; + + if (!internalFormat) + { + if (image->flags & IMGFLAG_CUBEMAP) + internalFormat = GL_RGBA8; + else + internalFormat = RawImage_GetFormat(pic, width * height, isLightmap, image->type, image->flags); + } + + image->internalFormat = internalFormat; + + + // lightmaps are always allocated on TMU 1 + if ( qglActiveTextureARB && isLightmap ) { + image->TMU = 1; + } else { + image->TMU = 0; + } + + if ( qglActiveTextureARB ) { + GL_SelectTexture( image->TMU ); + } + + if (image->flags & IMGFLAG_CUBEMAP) + { + GL_BindCubemap(image); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + + image->uploadWidth = width; + image->uploadHeight = height; + } + else + { + GL_Bind(image); + + if (pic) + { + Upload32( pic, image->width, image->height, image->type, image->flags, + isLightmap, image->internalFormat, &image->uploadWidth, + &image->uploadHeight ); + } + else + { + EmptyTexture(image->width, image->height, image->type, image->flags, + isLightmap, image->internalFormat, &image->uploadWidth, + &image->uploadHeight ); + } + + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode ); + qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode ); + } + + GL_SelectTexture( 0 ); + + hash = generateHashValue(name); + image->next = hashTable[hash]; + hashTable[hash] = image; + + return image; +} + +void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int height ) +{ + byte *scaledBuffer = NULL; + byte *resampledBuffer = NULL; + int scaled_width, scaled_height, scaled_x, scaled_y; + byte *data = pic; + + // normals are always swizzled + if (image->type == IMGTYPE_NORMAL || image->type == IMGTYPE_NORMALHEIGHT) + { + RawImage_SwizzleRA(pic, width, height); + } + + // LATC2 is only used for normals + if (image->internalFormat == GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT) + { + byte *in = data; + int c = width * height; + while (c--) + { + in[0] = in[1]; + in[2] = in[1]; + in += 4; + } + } + + + RawImage_ScaleToPower2(&pic, &width, &height, &scaled_width, &scaled_height, image->type, image->flags, &resampledBuffer); + + scaledBuffer = ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + + if ( qglActiveTextureARB ) { + GL_SelectTexture( image->TMU ); + } + + GL_Bind(image); + + // copy or resample data as appropriate for first MIP level + if ( ( scaled_width == width ) && + ( scaled_height == height ) ) { + if (!(image->flags & IMGFLAG_MIPMAP)) + { + scaled_x = x * scaled_width / width; + scaled_y = y * scaled_height / height; + RawImage_UploadTexture( data, scaled_x, scaled_y, scaled_width, scaled_height, image->internalFormat, image->type, image->flags, qtrue ); + //qglTexSubImage2D( GL_TEXTURE_2D, 0, scaled_x, scaled_y, scaled_width, scaled_height, GL_RGBA, GL_UNSIGNED_BYTE, data ); + + GL_CheckErrors(); + goto done; + } + Com_Memcpy (scaledBuffer, data, width*height*4); + } + else + { + // use the normal mip-mapping function to go down from here + while ( width > scaled_width || height > scaled_height ) { + + if (image->flags & IMGFLAG_SRGB) + { + R_MipMapsRGB( (byte *)data, width, height ); + } + else + { + R_MipMap( (byte *)data, width, height ); + } + + width >>= 1; + height >>= 1; + x >>= 1; + y >>= 1; + if ( width < 1 ) { + width = 1; + } + if ( height < 1 ) { + height = 1; + } + } + Com_Memcpy( scaledBuffer, data, width * height * 4 ); + } + + if (!(image->flags & IMGFLAG_NOLIGHTSCALE)) + R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, !(image->flags & IMGFLAG_MIPMAP) ); + + scaled_x = x * scaled_width / width; + scaled_y = y * scaled_height / height; + RawImage_UploadTexture( (byte *)data, scaled_x, scaled_y, scaled_width, scaled_height, image->internalFormat, image->type, image->flags, qtrue ); + +done: + + GL_SelectTexture( 0 ); + + GL_CheckErrors(); + + if ( scaledBuffer != 0 ) + ri.Hunk_FreeTempMemory( scaledBuffer ); + if ( resampledBuffer != 0 ) + ri.Hunk_FreeTempMemory( resampledBuffer ); +} + +//=================================================================== + +typedef struct +{ + char *ext; + void (*ImageLoader)( const char *, unsigned char **, int *, int * ); +} imageExtToLoaderMap_t; + +// Note that the ordering indicates the order of preference used +// when there are multiple images of different formats available +static imageExtToLoaderMap_t imageLoaders[ ] = +{ + { "tga", R_LoadTGA }, + { "jpg", R_LoadJPG }, + { "jpeg", R_LoadJPG }, + { "png", R_LoadPNG }, + { "pcx", R_LoadPCX }, + { "bmp", R_LoadBMP } +}; + +static int numImageLoaders = ARRAY_LEN( imageLoaders ); + +/* +================= +R_LoadImage + +Loads any of the supported image types into a cannonical +32 bit format. +================= +*/ +void R_LoadImage( const char *name, byte **pic, int *width, int *height ) +{ + qboolean orgNameFailed = qfalse; + int orgLoader = -1; + int i; + char localName[ MAX_QPATH ]; + const char *ext; + char *altName; + + *pic = NULL; + *width = 0; + *height = 0; + + Q_strncpyz( localName, name, MAX_QPATH ); + + ext = COM_GetExtension( localName ); + + if( *ext ) + { + // Look for the correct loader and use it + for( i = 0; i < numImageLoaders; i++ ) + { + if( !Q_stricmp( ext, imageLoaders[ i ].ext ) ) + { + // Load + imageLoaders[ i ].ImageLoader( localName, pic, width, height ); + break; + } + } + + // A loader was found + if( i < numImageLoaders ) + { + if( *pic == NULL ) + { + // Loader failed, most likely because the file isn't there; + // try again without the extension + orgNameFailed = qtrue; + orgLoader = i; + COM_StripExtension( name, localName, MAX_QPATH ); + } + else + { + // Something loaded + return; + } + } + } + + // Try and find a suitable match using all + // the image formats supported + for( i = 0; i < numImageLoaders; i++ ) + { + if (i == orgLoader) + continue; + + altName = va( "%s.%s", localName, imageLoaders[ i ].ext ); + + // Load + imageLoaders[ i ].ImageLoader( altName, pic, width, height ); + + if( *pic ) + { + if( orgNameFailed ) + { + ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", + name, altName ); + } + + break; + } + } +} + + +/* +=============== +R_FindImageFile + +Finds or loads the given image. +Returns NULL if it fails, not a default image. +============== +*/ +image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) +{ + image_t *image; + int width, height; + byte *pic; + long hash; + + if (!name) { + return NULL; + } + + hash = generateHashValue(name); + + // + // see if the image is already loaded + // + for (image=hashTable[hash]; image; image=image->next) { + if ( !strcmp( name, image->imgName ) ) { + // the white image can be used with any set of parms, but other mismatches are errors + if ( strcmp( name, "*white" ) ) { + if ( image->flags != flags ) { + ri.Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); + } + } + return image; + } + } + + // + // load the pic from disk + // + R_LoadImage( name, &pic, &width, &height ); + if ( pic == NULL ) { + return NULL; + } + + if (r_normalMapping->integer && !(type == IMGTYPE_NORMAL) && (flags & IMGFLAG_PICMIP) && (flags & IMGFLAG_MIPMAP) && (flags & IMGFLAG_GENNORMALMAP)) + { + char normalName[MAX_QPATH]; + image_t *normalImage; + int normalWidth, normalHeight; + imgFlags_t normalFlags; + + normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + + COM_StripExtension(name, normalName, MAX_QPATH); + Q_strcat(normalName, MAX_QPATH, "_n"); + + // find normalmap in case it's there + normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); + + // if not, generate it + if (normalImage == NULL) + { + byte *normalPic; + int x, y; + + normalWidth = width; + normalHeight = height; + normalPic = ri.Malloc(width * height * 4); + RGBAtoNormal(pic, normalPic, width, height, flags & IMGFLAG_CLAMPTOEDGE); + + // Brighten up the original image to work with the normal map + RGBAtoYCoCgA(pic, pic, width, height); + for (y = 0; y < height; y++) + { + byte *picbyte = pic + y * width * 4; + byte *normbyte = normalPic + y * width * 4; + for (x = 0; x < width; x++) + { + int div = MAX(normbyte[2] - 127, 16); + picbyte[0] = CLAMP(picbyte[0] * 128 / div, 0, 255); + picbyte += 4; + normbyte += 4; + } + } + YCoCgAtoRGBA(pic, pic, width, height); + + R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); + ri.Free( normalPic ); + } + } + + image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); + ri.Free( pic ); + return image; +} + + +/* +================ +R_CreateDlightImage +================ +*/ +#define DLIGHT_SIZE 16 +static void R_CreateDlightImage( void ) { + int x,y; + byte data[DLIGHT_SIZE][DLIGHT_SIZE][4]; + int b; + + // make a centered inverse-square falloff blob for dynamic lighting + for (x=0 ; x 255) { + b = 255; + } else if ( b < 75 ) { + b = 0; + } + data[y][x][0] = + data[y][x][1] = + data[y][x][2] = b; + data[y][x][3] = 255; + } + } + tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); +} + + +/* +================= +R_InitFogTable +================= +*/ +void R_InitFogTable( void ) { + int i; + float d; + float exp; + + exp = 0.5; + + for ( i = 0 ; i < FOG_TABLE_SIZE ; i++ ) { + d = pow ( (float)i/(FOG_TABLE_SIZE-1), exp ); + + tr.fogTable[i] = d; + } +} + +/* +================ +R_FogFactor + +Returns a 0.0 to 1.0 fog density value +This is called for each texel of the fog texture on startup +and for each vertex of transparent shaders in fog dynamically +================ +*/ +float R_FogFactor( float s, float t ) { + float d; + + s -= 1.0/512; + if ( s < 0 ) { + return 0; + } + if ( t < 1.0/32 ) { + return 0; + } + if ( t < 31.0/32 ) { + s *= (t - 1.0f/32.0f) / (30.0f/32.0f); + } + + // we need to leave a lot of clamp range + s *= 8; + + if ( s > 1.0 ) { + s = 1.0; + } + + d = tr.fogTable[ (int)(s * (FOG_TABLE_SIZE-1)) ]; + + return d; +} + +/* +================ +R_CreateFogImage +================ +*/ +#define FOG_S 256 +#define FOG_T 32 +static void R_CreateFogImage( void ) { + int x,y; + byte *data; + float d; + float borderColor[4]; + + data = ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); + + // S is distance, T is depth + for (x=0 ; xinteger >= 2) + { + for( x = 0; x < MAX_DLIGHTS; x++) + { + tr.shadowCubemaps[x] = R_CreateImage(va("*shadowcubemap%i", x), (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); + } + } + + // with overbright bits active, we need an image which is some fraction of full color, + // for default lightmaps, etc + for (x=0 ; xinteger && glRefConfig.framebufferObject && glRefConfig.textureFloat) + hdrFormat = GL_RGB16F_ARB; + + tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + + if (r_drawSunRays->integer) + tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + + if (r_softOverbright->integer) + { + int format; + + format = GL_RGBA8; + + tr.screenScratchImage = R_CreateImage("*screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, format); + } + + if (glRefConfig.framebufferObject) + { + tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + } + + { + unsigned short sdata[4]; + void *p; + + if (hdrFormat == GL_RGB16F_ARB) + { + sdata[0] = FloatToHalf(0.0f); + sdata[1] = FloatToHalf(0.45f); + sdata[2] = FloatToHalf(1.0f); + sdata[3] = FloatToHalf(1.0f); + p = &sdata[0]; + } + else + { + data[0][0][0] = 0; + data[0][0][1] = 0.45f * 255; + data[0][0][2] = 255; + data[0][0][3] = 255; + p = data; + } + + tr.calcLevelsImage = R_CreateImage("*calcLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.targetLevelsImage = R_CreateImage("*targetLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.fixedLevelsImage = R_CreateImage("*fixedLevels", p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + } + + for (x = 0; x < 2; x++) + { + tr.textureScratchImage[x] = R_CreateImage(va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } + for (x = 0; x < 2; x++) + { + tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } + + tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + + if (r_ssao->integer) + { + tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB); + } + + for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) + { + tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } + + for ( x = 0; x < 3; x++) + { + tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + } + } +} + + +/* +=============== +R_SetColorMappings +=============== +*/ +void R_SetColorMappings( void ) { + int i, j; + float g; + int inf; + int shift; + + // setup the overbright lighting + tr.overbrightBits = r_overBrightBits->integer; + if ( !glConfig.deviceSupportsGamma ) { + tr.overbrightBits = 0; // need hardware gamma for overbright + } + + // never overbright in windowed mode without soft overbright + if ( !glConfig.isFullscreen && !r_softOverbright->integer ) + { + tr.overbrightBits = 0; + } + + // never overbright with tonemapping + if ( r_toneMap->integer && r_hdr->integer ) + { + tr.overbrightBits = 0; + } + + // allow 2 overbright bits in 24 bit, but only 1 in 16 bit + if ( glConfig.colorBits > 16 ) { + if ( tr.overbrightBits > 2 ) { + tr.overbrightBits = 2; + } + } else { + if ( tr.overbrightBits > 1 ) { + tr.overbrightBits = 1; + } + } + if ( tr.overbrightBits < 0 ) { + tr.overbrightBits = 0; + } + + tr.identityLight = 1.0f / ( 1 << tr.overbrightBits ); + tr.identityLightByte = 255 * tr.identityLight; + + + if ( r_intensity->value <= 1 ) { + ri.Cvar_Set( "r_intensity", "1" ); + } + + if ( r_gamma->value < 0.5f ) { + ri.Cvar_Set( "r_gamma", "0.5" ); + } else if ( r_gamma->value > 3.0f ) { + ri.Cvar_Set( "r_gamma", "3.0" ); + } + + g = r_gamma->value; + + shift = tr.overbrightBits; + + // no shift with soft overbright + if (r_softOverbright->integer) + { + shift = 0; + } + + for ( i = 0; i < 256; i++ ) { + int i2; + + if (r_srgb->integer) + { + i2 = 255 * RGBtosRGB(i/255.0f) + 0.5f; + } + else + { + i2 = i; + } + + if ( g == 1 ) { + inf = i2; + } else { + inf = 255 * pow ( i2/255.0f, 1.0f / g ) + 0.5f; + } + inf <<= shift; + if (inf < 0) { + inf = 0; + } + if (inf > 255) { + inf = 255; + } + s_gammatable[i] = inf; + } + + for (i=0 ; i<256 ; i++) { + j = i * r_intensity->value; + if (j > 255) { + j = 255; + } + s_intensitytable[i] = j; + } + + if ( glConfig.deviceSupportsGamma ) + { + GLimp_SetGamma( s_gammatable, s_gammatable, s_gammatable ); + } +} + +/* +=============== +R_InitImages +=============== +*/ +void R_InitImages( void ) { + Com_Memset(hashTable, 0, sizeof(hashTable)); + // build brightness translation tables + R_SetColorMappings(); + + // create default texture and white texture + R_CreateBuiltinImages(); +} + +/* +=============== +R_DeleteTextures +=============== +*/ +void R_DeleteTextures( void ) { + int i; + + for ( i=0; itexnum ); + } + Com_Memset( tr.images, 0, sizeof( tr.images ) ); + + tr.numImages = 0; + + Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) ); + if ( qglActiveTextureARB ) { + GL_SelectTexture( 1 ); + qglBindTexture( GL_TEXTURE_2D, 0 ); + GL_SelectTexture( 0 ); + qglBindTexture( GL_TEXTURE_2D, 0 ); + } else { + qglBindTexture( GL_TEXTURE_2D, 0 ); + } +} + +/* +============================================================================ + +SKINS + +============================================================================ +*/ + +/* +================== +CommaParse + +This is unfortunate, but the skin files aren't +compatable with our normal parsing rules. +================== +*/ +static char *CommaParse( char **data_p ) { + int c = 0, len; + char *data; + static char com_token[MAX_TOKEN_CHARS]; + + data = *data_p; + len = 0; + com_token[0] = 0; + + // make sure incoming data is valid + if ( !data ) { + *data_p = NULL; + return com_token; + } + + while ( 1 ) { + // skip whitespace + while( (c = *data) <= ' ') { + if( !c ) { + break; + } + data++; + } + + + c = *data; + + // skip double slash comments + if ( c == '/' && data[1] == '/' ) + { + while (*data && *data != '\n') + data++; + } + // skip /* */ comments + else if ( c=='/' && data[1] == '*' ) + { + while ( *data && ( *data != '*' || data[1] != '/' ) ) + { + data++; + } + if ( *data ) + { + data += 2; + } + } + else + { + break; + } + } + + if ( c == 0 ) { + return ""; + } + + // handle quoted strings + if (c == '\"') + { + data++; + while (1) + { + c = *data++; + if (c=='\"' || !c) + { + com_token[len] = 0; + *data_p = ( char * ) data; + return com_token; + } + if (len < MAX_TOKEN_CHARS) + { + com_token[len] = c; + len++; + } + } + } + + // parse a regular word + do + { + if (len < MAX_TOKEN_CHARS) + { + com_token[len] = c; + len++; + } + data++; + c = *data; + } while (c>32 && c != ',' ); + + if (len == MAX_TOKEN_CHARS) + { +// ri.Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); + len = 0; + } + com_token[len] = 0; + + *data_p = ( char * ) data; + return com_token; +} + + +/* +=============== +RE_RegisterSkin + +=============== +*/ +qhandle_t RE_RegisterSkin( const char *name ) { + qhandle_t hSkin; + skin_t *skin; + skinSurface_t *surf; + union { + char *c; + void *v; + } text; + char *text_p; + char *token; + char surfName[MAX_QPATH]; + + if ( !name || !name[0] ) { + ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); + return 0; + } + + if ( strlen( name ) >= MAX_QPATH ) { + ri.Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); + return 0; + } + + + // see if the skin is already loaded + for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) { + skin = tr.skins[hSkin]; + if ( !Q_stricmp( skin->name, name ) ) { + if( skin->numSurfaces == 0 ) { + return 0; // default skin + } + return hSkin; + } + } + + // allocate a new skin + if ( tr.numSkins == MAX_SKINS ) { + ri.Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); + return 0; + } + tr.numSkins++; + skin = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); + tr.skins[hSkin] = skin; + Q_strncpyz( skin->name, name, sizeof( skin->name ) ); + skin->numSurfaces = 0; + + R_IssuePendingRenderCommands(); + + // If not a .skin file, load as a single shader + if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { + skin->numSurfaces = 1; + skin->surfaces[0] = ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); + skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); + return hSkin; + } + + // load and parse the skin file + ri.FS_ReadFile( name, &text.v ); + if ( !text.c ) { + return 0; + } + + text_p = text.c; + while ( text_p && *text_p ) { + // get surface name + token = CommaParse( &text_p ); + Q_strncpyz( surfName, token, sizeof( surfName ) ); + + if ( !token[0] ) { + break; + } + // lowercase the surface name so skin compares are faster + Q_strlwr( surfName ); + + if ( *text_p == ',' ) { + text_p++; + } + + if ( strstr( token, "tag_" ) ) { + continue; + } + + // parse the shader name + token = CommaParse( &text_p ); + + surf = skin->surfaces[ skin->numSurfaces ] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); + Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); + surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); + skin->numSurfaces++; + } + + ri.FS_FreeFile( text.v ); + + + // never let a skin have 0 shaders + if ( skin->numSurfaces == 0 ) { + return 0; // use default skin + } + + return hSkin; +} + + +/* +=============== +R_InitSkins +=============== +*/ +void R_InitSkins( void ) { + skin_t *skin; + + tr.numSkins = 1; + + // make the default skin have all default shaders + skin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); + Q_strncpyz( skin->name, "", sizeof( skin->name ) ); + skin->numSurfaces = 1; + skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); + skin->surfaces[0]->shader = tr.defaultShader; +} + +/* +=============== +R_GetSkinByHandle +=============== +*/ +skin_t *R_GetSkinByHandle( qhandle_t hSkin ) { + if ( hSkin < 1 || hSkin >= tr.numSkins ) { + return tr.skins[0]; + } + return tr.skins[ hSkin ]; +} + +/* +=============== +R_SkinList_f +=============== +*/ +void R_SkinList_f( void ) { + int i, j; + skin_t *skin; + + ri.Printf (PRINT_ALL, "------------------\n"); + + for ( i = 0 ; i < tr.numSkins ; i++ ) { + skin = tr.skins[i]; + + ri.Printf( PRINT_ALL, "%3i:%s\n", i, skin->name ); + for ( j = 0 ; j < skin->numSurfaces ; j++ ) { + ri.Printf( PRINT_ALL, " %s = %s\n", + skin->surfaces[j]->name, skin->surfaces[j]->shader->name ); + } + } + ri.Printf (PRINT_ALL, "------------------\n"); +} + + diff --git a/codemp/rd-rend2/tr_init.c b/codemp/rd-rend2/tr_init.c new file mode 100644 index 0000000000..d5330248de --- /dev/null +++ b/codemp/rd-rend2/tr_init.c @@ -0,0 +1,1570 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_init.c -- functions that are not called every frame + +#include "tr_local.h" + +glconfig_t glConfig; +glRefConfig_t glRefConfig; +qboolean textureFilterAnisotropic = qfalse; +int maxAnisotropy = 0; +float displayAspect = 0.0f; + +glstate_t glState; + +static void GfxInfo_f( void ); +static void GfxMemInfo_f( void ); + +#ifdef USE_RENDERER_DLOPEN +cvar_t *com_altivec; +#endif + +cvar_t *r_flareSize; +cvar_t *r_flareFade; +cvar_t *r_flareCoeff; + +cvar_t *r_railWidth; +cvar_t *r_railCoreWidth; +cvar_t *r_railSegmentLength; + +cvar_t *r_verbose; +cvar_t *r_ignore; + +cvar_t *r_detailTextures; + +cvar_t *r_znear; +cvar_t *r_zproj; +cvar_t *r_stereoSeparation; + +cvar_t *r_skipBackEnd; + +cvar_t *r_stereoEnabled; +cvar_t *r_anaglyphMode; + +cvar_t *r_greyscale; + +cvar_t *r_ignorehwgamma; +cvar_t *r_measureOverdraw; + +cvar_t *r_inGameVideo; +cvar_t *r_fastsky; +cvar_t *r_drawSun; +cvar_t *r_dynamiclight; +cvar_t *r_dlightBacks; + +cvar_t *r_lodbias; +cvar_t *r_lodscale; + +cvar_t *r_norefresh; +cvar_t *r_drawentities; +cvar_t *r_drawworld; +cvar_t *r_speeds; +cvar_t *r_fullbright; +cvar_t *r_novis; +cvar_t *r_nocull; +cvar_t *r_facePlaneCull; +cvar_t *r_showcluster; +cvar_t *r_nocurves; + +cvar_t *r_allowExtensions; + +cvar_t *r_ext_compressed_textures; +cvar_t *r_ext_multitexture; +cvar_t *r_ext_compiled_vertex_array; +cvar_t *r_ext_texture_env_add; +cvar_t *r_ext_texture_filter_anisotropic; +cvar_t *r_ext_max_anisotropy; + +cvar_t *r_ext_draw_range_elements; +cvar_t *r_ext_multi_draw_arrays; +cvar_t *r_ext_framebuffer_object; +cvar_t *r_ext_texture_float; +cvar_t *r_arb_half_float_pixel; +cvar_t *r_ext_framebuffer_multisample; + +cvar_t *r_mergeMultidraws; +cvar_t *r_mergeLeafSurfaces; + +cvar_t *r_cameraExposure; + +cvar_t *r_softOverbright; + +cvar_t *r_hdr; +cvar_t *r_postProcess; + +cvar_t *r_toneMap; +cvar_t *r_forceToneMap; +cvar_t *r_forceToneMapMin; +cvar_t *r_forceToneMapAvg; +cvar_t *r_forceToneMapMax; + +cvar_t *r_autoExposure; +cvar_t *r_forceAutoExposure; +cvar_t *r_forceAutoExposureMin; +cvar_t *r_forceAutoExposureMax; + +cvar_t *r_srgb; + +cvar_t *r_depthPrepass; +cvar_t *r_ssao; + +cvar_t *r_normalMapping; +cvar_t *r_specularMapping; +cvar_t *r_deluxeMapping; +cvar_t *r_parallaxMapping; +cvar_t *r_normalAmbient; +cvar_t *r_recalcMD3Normals; +cvar_t *r_mergeLightmaps; +cvar_t *r_dlightMode; +cvar_t *r_pshadowDist; +cvar_t *r_imageUpsample; +cvar_t *r_imageUpsampleMaxSize; +cvar_t *r_imageUpsampleType; +cvar_t *r_genNormalMaps; +cvar_t *r_forceSun; +cvar_t *r_forceSunMapLightScale; +cvar_t *r_forceSunLightScale; +cvar_t *r_forceSunAmbientScale; +cvar_t *r_sunlightMode; +cvar_t *r_drawSunRays; +cvar_t *r_sunShadows; +cvar_t *r_shadowFilter; +cvar_t *r_shadowMapSize; +cvar_t *r_shadowCascadeZNear; +cvar_t *r_shadowCascadeZFar; +cvar_t *r_shadowCascadeZBias; + +cvar_t *r_ignoreGLErrors; +cvar_t *r_logFile; + +cvar_t *r_stencilbits; +cvar_t *r_depthbits; +cvar_t *r_colorbits; +cvar_t *r_texturebits; +cvar_t *r_ext_multisample; + +cvar_t *r_drawBuffer; +cvar_t *r_lightmap; +cvar_t *r_vertexLight; +cvar_t *r_uiFullScreen; +cvar_t *r_shadows; +cvar_t *r_flares; +cvar_t *r_mode; +cvar_t *r_nobind; +cvar_t *r_singleShader; +cvar_t *r_roundImagesDown; +cvar_t *r_colorMipLevels; +cvar_t *r_picmip; +cvar_t *r_showtris; +cvar_t *r_showsky; +cvar_t *r_shownormals; +cvar_t *r_finish; +cvar_t *r_clear; +cvar_t *r_swapInterval; +cvar_t *r_textureMode; +cvar_t *r_offsetFactor; +cvar_t *r_offsetUnits; +cvar_t *r_gamma; +cvar_t *r_intensity; +cvar_t *r_lockpvs; +cvar_t *r_noportals; +cvar_t *r_portalOnly; + +cvar_t *r_subdivisions; +cvar_t *r_lodCurveError; + +cvar_t *r_fullscreen; +cvar_t *r_noborder; + +cvar_t *r_customwidth; +cvar_t *r_customheight; +cvar_t *r_customPixelAspect; + +cvar_t *r_overBrightBits; +cvar_t *r_mapOverBrightBits; + +cvar_t *r_debugSurface; +cvar_t *r_simpleMipMaps; + +cvar_t *r_showImages; + +cvar_t *r_ambientScale; +cvar_t *r_directedScale; +cvar_t *r_debugLight; +cvar_t *r_debugSort; +cvar_t *r_printShaders; +cvar_t *r_saveFontData; + +cvar_t *r_marksOnTriangleMeshes; + +cvar_t *r_aviMotionJpegQuality; +cvar_t *r_screenshotJpegQuality; + +cvar_t *r_maxpolys; +int max_polys; +cvar_t *r_maxpolyverts; +int max_polyverts; + +/* +** InitOpenGL +** +** This function is responsible for initializing a valid OpenGL subsystem. This +** is done by calling GLimp_Init (which gives us a working OGL subsystem) then +** setting variables, checking GL constants, and reporting the gfx system config +** to the user. +*/ +static void InitOpenGL( void ) +{ + char renderer_buffer[1024]; + + // + // initialize OS specific portions of the renderer + // + // GLimp_Init directly or indirectly references the following cvars: + // - r_fullscreen + // - r_mode + // - r_(color|depth|stencil)bits + // - r_ignorehwgamma + // - r_gamma + // + + if ( glConfig.vidWidth == 0 ) + { + GLint temp; + + GLimp_Init(); + GLimp_InitExtraExtensions(); + + strcpy( renderer_buffer, glConfig.renderer_string ); + Q_strlwr( renderer_buffer ); + + // OpenGL driver constants + qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &temp ); + glConfig.maxTextureSize = temp; + + // stubbed or broken drivers may have reported 0... + if ( glConfig.maxTextureSize <= 0 ) + { + glConfig.maxTextureSize = 0; + } + } + + // set default state + GL_SetDefaultState(); +} + +/* +================== +GL_CheckErrors +================== +*/ +void GL_CheckErrs( char *file, int line ) { + int err; + char s[64]; + + err = qglGetError(); + if ( err == GL_NO_ERROR ) { + return; + } + if ( r_ignoreGLErrors->integer ) { + return; + } + switch( err ) { + case GL_INVALID_ENUM: + strcpy( s, "GL_INVALID_ENUM" ); + break; + case GL_INVALID_VALUE: + strcpy( s, "GL_INVALID_VALUE" ); + break; + case GL_INVALID_OPERATION: + strcpy( s, "GL_INVALID_OPERATION" ); + break; + case GL_STACK_OVERFLOW: + strcpy( s, "GL_STACK_OVERFLOW" ); + break; + case GL_STACK_UNDERFLOW: + strcpy( s, "GL_STACK_UNDERFLOW" ); + break; + case GL_OUT_OF_MEMORY: + strcpy( s, "GL_OUT_OF_MEMORY" ); + break; + default: + Com_sprintf( s, sizeof(s), "%i", err); + break; + } + + ri.Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); +} + + +/* +** R_GetModeInfo +*/ +typedef struct vidmode_s +{ + const char *description; + int width, height; + float pixelAspect; // pixel width / height +} vidmode_t; + +vidmode_t r_vidModes[] = +{ + { "Mode 0: 320x240", 320, 240, 1 }, + { "Mode 1: 400x300", 400, 300, 1 }, + { "Mode 2: 512x384", 512, 384, 1 }, + { "Mode 3: 640x480", 640, 480, 1 }, + { "Mode 4: 800x600", 800, 600, 1 }, + { "Mode 5: 960x720", 960, 720, 1 }, + { "Mode 6: 1024x768", 1024, 768, 1 }, + { "Mode 7: 1152x864", 1152, 864, 1 }, + { "Mode 8: 1280x1024", 1280, 1024, 1 }, + { "Mode 9: 1600x1200", 1600, 1200, 1 }, + { "Mode 10: 2048x1536", 2048, 1536, 1 }, + { "Mode 11: 856x480 (wide)",856, 480, 1 } +}; +static int s_numVidModes = ARRAY_LEN( r_vidModes ); + +qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) { + vidmode_t *vm; + float pixelAspect; + + if ( mode < -1 ) { + return qfalse; + } + if ( mode >= s_numVidModes ) { + return qfalse; + } + + if ( mode == -1 ) { + *width = r_customwidth->integer; + *height = r_customheight->integer; + pixelAspect = r_customPixelAspect->value; + } else { + vm = &r_vidModes[mode]; + + *width = vm->width; + *height = vm->height; + pixelAspect = vm->pixelAspect; + } + + *windowAspect = (float)*width / ( *height * pixelAspect ); + + return qtrue; +} + +/* +** R_ModeList_f +*/ +static void R_ModeList_f( void ) +{ + int i; + + ri.Printf( PRINT_ALL, "\n" ); + for ( i = 0; i < s_numVidModes; i++ ) + { + ri.Printf( PRINT_ALL, "%s\n", r_vidModes[i].description ); + } + ri.Printf( PRINT_ALL, "\n" ); +} + + +/* +============================================================================== + + SCREEN SHOTS + +NOTE TTimo +some thoughts about the screenshots system: +screenshots get written in fs_homepath + fs_gamedir +vanilla q3 .. baseq3/screenshots/ *.tga +team arena .. missionpack/screenshots/ *.tga + +two commands: "screenshot" and "screenshotJPEG" +we use statics to store a count and start writing the first screenshot/screenshot????.tga (.jpg) available +(with FS_FileExists / FS_FOpenFileWrite calls) +FIXME: the statics don't get a reinit between fs_game changes + +============================================================================== +*/ + +/* +================== +RB_ReadPixels + +Reads an image but takes care of alignment issues for reading RGB images. + +Reads a minimum offset for where the RGB data starts in the image from +integer stored at pointer offset. When the function has returned the actual +offset was written back to address offset. This address will always have an +alignment of packAlign to ensure efficient copying. + +Stores the length of padding after a line of pixels to address padlen + +Return value must be freed with ri.Hunk_FreeTempMemory() +================== +*/ + +byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen) +{ + byte *buffer, *bufstart; + int padwidth, linelen; + GLint packAlign; + + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); + + linelen = width * 3; + padwidth = PAD(linelen, packAlign); + + // Allocate a few more bytes so that we can choose an alignment we like + buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); + + bufstart = PADP((intptr_t) buffer + *offset, packAlign); + qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); + + *offset = bufstart - buffer; + *padlen = padwidth - linelen; + + return buffer; +} + +/* +================== +RB_TakeScreenshot +================== +*/ +void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) +{ + byte *allbuf, *buffer; + byte *srcptr, *destptr; + byte *endline, *endmem; + byte temp; + + int linelen, padlen; + size_t offset = 18, memcount; + + allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen); + buffer = allbuf + offset - 18; + + Com_Memset (buffer, 0, 18); + buffer[2] = 2; // uncompressed type + buffer[12] = width & 255; + buffer[13] = width >> 8; + buffer[14] = height & 255; + buffer[15] = height >> 8; + buffer[16] = 24; // pixel size + + // swap rgb to bgr and remove padding from line endings + linelen = width * 3; + + srcptr = destptr = allbuf + offset; + endmem = srcptr + (linelen + padlen) * height; + + while(srcptr < endmem) + { + endline = srcptr + linelen; + + while(srcptr < endline) + { + temp = srcptr[0]; + *destptr++ = srcptr[2]; + *destptr++ = srcptr[1]; + *destptr++ = temp; + + srcptr += 3; + } + + // Skip the pad + srcptr += padlen; + } + + memcount = linelen * height; + + // gamma correct + if(glConfig.deviceSupportsGamma) + R_GammaCorrect(allbuf + offset, memcount); + + ri.FS_WriteFile(fileName, buffer, memcount + 18); + + ri.Hunk_FreeTempMemory(allbuf); +} + +/* +================== +RB_TakeScreenshotJPEG +================== +*/ + +void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) +{ + byte *buffer; + size_t offset = 0, memcount; + int padlen; + + buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen); + memcount = (width * 3 + padlen) * height; + + // gamma correct + if(glConfig.deviceSupportsGamma) + R_GammaCorrect(buffer + offset, memcount); + + RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); + ri.Hunk_FreeTempMemory(buffer); +} + +/* +================== +RB_TakeScreenshotCmd +================== +*/ +const void *RB_TakeScreenshotCmd( const void *data ) { + const screenshotCommand_t *cmd; + + cmd = (const screenshotCommand_t *)data; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + if (cmd->jpeg) + RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); + else + RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); + + return (const void *)(cmd + 1); +} + +/* +================== +R_TakeScreenshot +================== +*/ +void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) { + static char fileName[MAX_OSPATH]; // bad things if two screenshots per frame? + screenshotCommand_t *cmd; + + cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_SCREENSHOT; + + cmd->x = x; + cmd->y = y; + cmd->width = width; + cmd->height = height; + Q_strncpyz( fileName, name, sizeof(fileName) ); + cmd->fileName = fileName; + cmd->jpeg = jpeg; +} + +/* +================== +R_ScreenshotFilename +================== +*/ +void R_ScreenshotFilename( int lastNumber, char *fileName ) { + int a,b,c,d; + + if ( lastNumber < 0 || lastNumber > 9999 ) { + Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.tga" ); + return; + } + + a = lastNumber / 1000; + lastNumber -= a*1000; + b = lastNumber / 100; + lastNumber -= b*100; + c = lastNumber / 10; + lastNumber -= c*10; + d = lastNumber; + + Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.tga" + , a, b, c, d ); +} + +/* +================== +R_ScreenshotFilename +================== +*/ +void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) { + int a,b,c,d; + + if ( lastNumber < 0 || lastNumber > 9999 ) { + Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.jpg" ); + return; + } + + a = lastNumber / 1000; + lastNumber -= a*1000; + b = lastNumber / 100; + lastNumber -= b*100; + c = lastNumber / 10; + lastNumber -= c*10; + d = lastNumber; + + Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.jpg" + , a, b, c, d ); +} + +/* +==================== +R_LevelShot + +levelshots are specialized 128*128 thumbnails for +the menu system, sampled down from full screen distorted images +==================== +*/ +void R_LevelShot( void ) { + char checkname[MAX_OSPATH]; + byte *buffer; + byte *source, *allsource; + byte *src, *dst; + size_t offset = 0; + int padlen; + int x, y; + int r, g, b; + float xScale, yScale; + int xx, yy; + + Com_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName); + + allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); + source = allsource + offset; + + buffer = ri.Hunk_AllocateTempMemory(128 * 128*3 + 18); + Com_Memset (buffer, 0, 18); + buffer[2] = 2; // uncompressed type + buffer[12] = 128; + buffer[14] = 128; + buffer[16] = 24; // pixel size + + // resample from source + xScale = glConfig.vidWidth / 512.0f; + yScale = glConfig.vidHeight / 384.0f; + for ( y = 0 ; y < 128 ; y++ ) { + for ( x = 0 ; x < 128 ; x++ ) { + r = g = b = 0; + for ( yy = 0 ; yy < 3 ; yy++ ) { + for ( xx = 0 ; xx < 4 ; xx++ ) { + src = source + (3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) + + 3 * (int) ((x*4 + xx) * xScale); + r += src[0]; + g += src[1]; + b += src[2]; + } + } + dst = buffer + 18 + 3 * ( y * 128 + x ); + dst[0] = b / 12; + dst[1] = g / 12; + dst[2] = r / 12; + } + } + + // gamma correct + if ( glConfig.deviceSupportsGamma ) { + R_GammaCorrect( buffer + 18, 128 * 128 * 3 ); + } + + ri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 ); + + ri.Hunk_FreeTempMemory(buffer); + ri.Hunk_FreeTempMemory(allsource); + + ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); +} + +/* +================== +R_ScreenShot_f + +screenshot +screenshot [silent] +screenshot [levelshot] +screenshot [filename] + +Doesn't print the pacifier message if there is a second arg +================== +*/ +void R_ScreenShot_f (void) { + char checkname[MAX_OSPATH]; + static int lastNumber = -1; + qboolean silent; + + if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { + R_LevelShot(); + return; + } + + if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { + silent = qtrue; + } else { + silent = qfalse; + } + + if ( ri.Cmd_Argc() == 2 && !silent ) { + // explicit filename + Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) ); + } else { + // scan for a free filename + + // if we have saved a previous screenshot, don't scan + // again, because recording demo avis can involve + // thousands of shots + if ( lastNumber == -1 ) { + lastNumber = 0; + } + // scan for a free number + for ( ; lastNumber <= 9999 ; lastNumber++ ) { + R_ScreenshotFilename( lastNumber, checkname ); + + if (!ri.FS_FileExists( checkname )) + { + break; // file doesn't exist + } + } + + if ( lastNumber >= 9999 ) { + ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + return; + } + + lastNumber++; + } + + R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse ); + + if ( !silent ) { + ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); + } +} + +void R_ScreenShotJPEG_f (void) { + char checkname[MAX_OSPATH]; + static int lastNumber = -1; + qboolean silent; + + if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { + R_LevelShot(); + return; + } + + if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { + silent = qtrue; + } else { + silent = qfalse; + } + + if ( ri.Cmd_Argc() == 2 && !silent ) { + // explicit filename + Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) ); + } else { + // scan for a free filename + + // if we have saved a previous screenshot, don't scan + // again, because recording demo avis can involve + // thousands of shots + if ( lastNumber == -1 ) { + lastNumber = 0; + } + // scan for a free number + for ( ; lastNumber <= 9999 ; lastNumber++ ) { + R_ScreenshotFilenameJPEG( lastNumber, checkname ); + + if (!ri.FS_FileExists( checkname )) + { + break; // file doesn't exist + } + } + + if ( lastNumber == 10000 ) { + ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + return; + } + + lastNumber++; + } + + R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue ); + + if ( !silent ) { + ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); + } +} + +//============================================================================ + +/* +================== +RB_TakeVideoFrameCmd +================== +*/ +const void *RB_TakeVideoFrameCmd( const void *data ) +{ + const videoFrameCommand_t *cmd; + byte *cBuf; + size_t memcount, linelen; + int padwidth, avipadwidth, padlen, avipadlen; + GLint packAlign; + + // finish any 2D drawing if needed + if(tess.numIndexes) + RB_EndSurface(); + + cmd = (const videoFrameCommand_t *)data; + + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); + + linelen = cmd->width * 3; + + // Alignment stuff for glReadPixels + padwidth = PAD(linelen, packAlign); + padlen = padwidth - linelen; + // AVI line padding + avipadwidth = PAD(linelen, AVI_LINE_PADDING); + avipadlen = avipadwidth - linelen; + + cBuf = PADP(cmd->captureBuffer, packAlign); + + qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, + GL_UNSIGNED_BYTE, cBuf); + + memcount = padwidth * cmd->height; + + // gamma correct + if(glConfig.deviceSupportsGamma) + R_GammaCorrect(cBuf, memcount); + + if(cmd->motionJpeg) + { + memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, + r_aviMotionJpegQuality->integer, + cmd->width, cmd->height, cBuf, padlen); + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); + } + else + { + byte *lineend, *memend; + byte *srcptr, *destptr; + + srcptr = cBuf; + destptr = cmd->encodeBuffer; + memend = srcptr + memcount; + + // swap R and B and remove line paddings + while(srcptr < memend) + { + lineend = srcptr + linelen; + while(srcptr < lineend) + { + *destptr++ = srcptr[2]; + *destptr++ = srcptr[1]; + *destptr++ = srcptr[0]; + srcptr += 3; + } + + Com_Memset(destptr, '\0', avipadlen); + destptr += avipadlen; + + srcptr += padlen; + } + + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); + } + + return (const void *)(cmd + 1); +} + +//============================================================================ + +/* +** GL_SetDefaultState +*/ +void GL_SetDefaultState( void ) +{ + qglClearDepth( 1.0f ); + + qglCullFace(GL_FRONT); + + qglColor4f (1,1,1,1); + + // initialize downstream texture unit if we're running + // in a multitexture environment + if ( qglActiveTextureARB ) { + GL_SelectTexture( 1 ); + GL_TextureMode( r_textureMode->string ); + GL_TexEnv( GL_MODULATE ); + qglDisable( GL_TEXTURE_2D ); + GL_SelectTexture( 0 ); + } + + qglEnable(GL_TEXTURE_2D); + GL_TextureMode( r_textureMode->string ); + GL_TexEnv( GL_MODULATE ); + + //qglShadeModel( GL_SMOOTH ); + qglDepthFunc( GL_LEQUAL ); + + // + // make sure our GL state vector is set correctly + // + glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE; + + glState.vertexAttribsState = 0; + glState.vertexAttribPointersSet = 0; + glState.currentProgram = 0; + qglUseProgramObjectARB(0); + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glState.currentVBO = NULL; + glState.currentIBO = NULL; + + qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); + qglDepthMask( GL_TRUE ); + qglDisable( GL_DEPTH_TEST ); + qglEnable( GL_SCISSOR_TEST ); + qglDisable( GL_CULL_FACE ); + qglDisable( GL_BLEND ); + + qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClearDepth( 1.0 ); + + qglDrawBuffer( GL_FRONT ); + qglClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); + + qglDrawBuffer( GL_BACK ); + qglClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); +} + +/* +================ +R_PrintLongString + +Workaround for ri.Printf's 1024 characters buffer limit. +================ +*/ +void R_PrintLongString(const char *string) { + char buffer[1024]; + const char *p; + int size = strlen(string); + + p = string; + while(size > 0) + { + Q_strncpyz(buffer, p, sizeof (buffer) ); + ri.Printf( PRINT_ALL, "%s", buffer ); + p += 1023; + size -= 1023; + } +} + +/* +================ +GfxInfo_f +================ +*/ +void GfxInfo_f( void ) +{ + const char *enablestrings[] = + { + "disabled", + "enabled" + }; + const char *fsstrings[] = + { + "windowed", + "fullscreen" + }; + + ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); + ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); + ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); + ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " ); + R_PrintLongString( glConfig.extensions_string ); + ri.Printf( PRINT_ALL, "\n" ); + ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); + ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); + ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); + ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] ); + if ( glConfig.displayFrequency ) + { + ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); + } + else + { + ri.Printf( PRINT_ALL, "N/A\n" ); + } + if ( glConfig.deviceSupportsGamma ) + { + ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); + } + else + { + ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); + } + + ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); + ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); + ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); + ri.Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] ); + ri.Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] ); + ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); + ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); + if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) + { + ri.Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); + } + if ( glConfig.hardwareType == GLHW_RAGEPRO ) + { + ri.Printf( PRINT_ALL, "HACK: ragePro approximations\n" ); + } + if ( glConfig.hardwareType == GLHW_RIVA128 ) + { + ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); + } + if ( r_finish->integer ) { + ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); + } +} + +/* +================ +GfxMemInfo_f +================ +*/ +void GfxMemInfo_f( void ) +{ + switch (glRefConfig.memInfo) + { + case MI_NONE: + { + ri.Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); + } + break; + case MI_NVX: + { + int value; + + qglGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); + + qglGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); + + qglGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); + + qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); + + qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); + } + break; + case MI_ATI: + { + // GL_ATI_meminfo + int value[4]; + + qglGetIntegerv(GL_VBO_FREE_MEMORY_ATI, &value[0]); + ri.Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + + qglGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &value[0]); + ri.Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + + qglGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, &value[0]); + ri.Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + } + break; + } +} + +/* +=============== +R_Register +=============== +*/ +void R_Register( void ) +{ + #ifdef USE_RENDERER_DLOPEN + com_altivec = ri.Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); + #endif + + // + // latched and archived variables + // + r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); + + r_ext_draw_range_elements = ri.Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_multi_draw_arrays = ri.Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_framebuffer_object = ri.Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_arb_half_float_pixel = ri.Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); + + r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", + "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); + + r_picmip = ri.Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); + ri.Cvar_CheckRange( r_picmip, 0, 16, qtrue ); + r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_colorbits = ri.Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH ); + r_depthbits = ri.Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_multisample = ri.Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); + ri.Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); + r_overBrightBits = ri.Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_mode = ri.Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); + r_fullscreen = ri.Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); + r_noborder = ri.Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); + r_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); + r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0); + r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); + r_stereoEnabled = ri.Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); + ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse); + + r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); + + r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); + + r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); + r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); + r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); + r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); + + r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); + r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); + r_forceAutoExposureMin = ri.Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT ); + r_forceAutoExposureMax = ri.Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT ); + + r_cameraExposure = ri.Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT ); + + r_srgb = ri.Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH ); + + r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE ); + r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE ); + + r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_normalAmbient = ri.Cvar_Get( "r_normalAmbient", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); + r_recalcMD3Normals = ri.Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); + + r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); + r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT ); + r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); + r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT ); + r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); + + r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowMapSize = ri.Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH ); + + // + // temporary latched variables that can only change over a restart + // + r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); + r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); + r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH ); + r_singleShader = ri.Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); + + // + // archived variables that can change at any time + // + r_lodCurveError = ri.Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT ); + r_lodbias = ri.Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); + r_flares = ri.Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); + r_znear = ri.Cvar_Get( "r_znear", "4", CVAR_CHEAT ); + ri.Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); + r_zproj = ri.Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); + r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); + r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); + r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE ); + r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE ); + r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); + r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); + r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); + r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); + r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); + r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0", + CVAR_ARCHIVE | CVAR_LATCH ); + r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); + r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); + + r_railWidth = ri.Cvar_Get( "r_railWidth", "16", CVAR_ARCHIVE ); + r_railCoreWidth = ri.Cvar_Get( "r_railCoreWidth", "6", CVAR_ARCHIVE ); + r_railSegmentLength = ri.Cvar_Get( "r_railSegmentLength", "32", CVAR_ARCHIVE ); + + r_ambientScale = ri.Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); + r_directedScale = ri.Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); + + r_anaglyphMode = ri.Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE); + r_mergeMultidraws = ri.Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE); + r_mergeLeafSurfaces = ri.Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE); + + // + // temporary variables that can change at any time + // + r_showImages = ri.Cvar_Get( "r_showImages", "0", CVAR_TEMP ); + + r_debugLight = ri.Cvar_Get( "r_debuglight", "0", CVAR_TEMP ); + r_debugSort = ri.Cvar_Get( "r_debugSort", "0", CVAR_CHEAT ); + r_printShaders = ri.Cvar_Get( "r_printShaders", "0", 0 ); + r_saveFontData = ri.Cvar_Get( "r_saveFontData", "0", 0 ); + + r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT ); + r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT ); + r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0 ); + r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT ); + + r_flareSize = ri.Cvar_Get ("r_flareSize", "40", CVAR_CHEAT); + r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); + r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); + + r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); + + r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); + r_lodscale = ri.Cvar_Get( "r_lodscale", "5", CVAR_CHEAT ); + r_norefresh = ri.Cvar_Get ("r_norefresh", "0", CVAR_CHEAT); + r_drawentities = ri.Cvar_Get ("r_drawentities", "1", CVAR_CHEAT ); + r_ignore = ri.Cvar_Get( "r_ignore", "1", CVAR_CHEAT ); + r_nocull = ri.Cvar_Get ("r_nocull", "0", CVAR_CHEAT); + r_novis = ri.Cvar_Get ("r_novis", "0", CVAR_CHEAT); + r_showcluster = ri.Cvar_Get ("r_showcluster", "0", CVAR_CHEAT); + r_speeds = ri.Cvar_Get ("r_speeds", "0", CVAR_CHEAT); + r_verbose = ri.Cvar_Get( "r_verbose", "0", CVAR_CHEAT ); + r_logFile = ri.Cvar_Get( "r_logFile", "0", CVAR_CHEAT ); + r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT); + r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT); + r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT); + r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT); + r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT); + r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT); + r_offsetFactor = ri.Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT ); + r_offsetUnits = ri.Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT ); + r_drawBuffer = ri.Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT ); + r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT); + r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT); + r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 ); + + r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE); + + r_aviMotionJpegQuality = ri.Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); + r_screenshotJpegQuality = ri.Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); + + r_maxpolys = ri.Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); + r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); + + // make sure all the commands added here are also + // removed in R_Shutdown + ri.Cmd_AddCommand( "imagelist", R_ImageList_f ); + ri.Cmd_AddCommand( "shaderlist", R_ShaderList_f ); + ri.Cmd_AddCommand( "skinlist", R_SkinList_f ); + ri.Cmd_AddCommand( "modellist", R_Modellist_f ); + ri.Cmd_AddCommand( "modelist", R_ModeList_f ); + ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f ); + ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); + ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); + ri.Cmd_AddCommand( "minimize", GLimp_Minimize ); + ri.Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); +} + +void R_InitQueries(void) +{ + if (!glRefConfig.occlusionQuery) + return; + + if (r_drawSunRays->integer) + qglGenQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); +} + +void R_ShutDownQueries(void) +{ + if (!glRefConfig.occlusionQuery) + return; + + if (r_drawSunRays->integer) + qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); +} + +/* +=============== +R_Init +=============== +*/ +void R_Init( void ) { + int err; + int i; + byte *ptr; + + ri.Printf( PRINT_ALL, "----- R_Init -----\n" ); + + // clear all our internal state + Com_Memset( &tr, 0, sizeof( tr ) ); + Com_Memset( &backEnd, 0, sizeof( backEnd ) ); + Com_Memset( &tess, 0, sizeof( tess ) ); + + if(sizeof(glconfig_t) != 11332) + ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); + +// Swap_Init(); + + if ( (intptr_t)tess.xyz & 15 ) { + ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); + } + //Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); + + // + // init function tables + // + for ( i = 0; i < FUNCTABLE_SIZE; i++ ) + { + tr.sinTable[i] = sin( DEG2RAD( i * 360.0f / ( ( float ) ( FUNCTABLE_SIZE - 1 ) ) ) ); + tr.squareTable[i] = ( i < FUNCTABLE_SIZE/2 ) ? 1.0f : -1.0f; + tr.sawToothTable[i] = (float)i / FUNCTABLE_SIZE; + tr.inverseSawToothTable[i] = 1.0f - tr.sawToothTable[i]; + + if ( i < FUNCTABLE_SIZE / 2 ) + { + if ( i < FUNCTABLE_SIZE / 4 ) + { + tr.triangleTable[i] = ( float ) i / ( FUNCTABLE_SIZE / 4 ); + } + else + { + tr.triangleTable[i] = 1.0f - tr.triangleTable[i-FUNCTABLE_SIZE / 4]; + } + } + else + { + tr.triangleTable[i] = -tr.triangleTable[i-FUNCTABLE_SIZE/2]; + } + } + + R_InitFogTable(); + + R_NoiseInit(); + + R_Register(); + + max_polys = r_maxpolys->integer; + if (max_polys < MAX_POLYS) + max_polys = MAX_POLYS; + + max_polyverts = r_maxpolyverts->integer; + if (max_polyverts < MAX_POLYVERTS) + max_polyverts = MAX_POLYVERTS; + + ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); + backEndData = (backEndData_t *) ptr; + backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); + backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); + R_InitNextFrame(); + + InitOpenGL(); + + R_InitImages(); + + if (glRefConfig.framebufferObject) + FBO_Init(); + + GLSL_InitGPUShaders(); + + R_InitVBOs(); + + R_InitShaders(); + + R_InitSkins(); + + R_ModelInit(); + + R_InitFreeType(); + + R_InitQueries(); + + + err = qglGetError(); + if ( err != GL_NO_ERROR ) + ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); + + // print info + GfxInfo_f(); + ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" ); +} + +/* +=============== +RE_Shutdown +=============== +*/ +void RE_Shutdown( qboolean destroyWindow ) { + + ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); + + ri.Cmd_RemoveCommand ("modellist"); + ri.Cmd_RemoveCommand ("screenshotJPEG"); + ri.Cmd_RemoveCommand ("screenshot"); + ri.Cmd_RemoveCommand ("imagelist"); + ri.Cmd_RemoveCommand ("shaderlist"); + ri.Cmd_RemoveCommand ("skinlist"); + ri.Cmd_RemoveCommand ("gfxinfo"); + ri.Cmd_RemoveCommand("minimize"); + ri.Cmd_RemoveCommand( "modelist" ); + ri.Cmd_RemoveCommand( "shaderstate" ); + ri.Cmd_RemoveCommand( "gfxmeminfo" ); + + + if ( tr.registered ) { + R_IssuePendingRenderCommands(); + R_ShutDownQueries(); + if (glRefConfig.framebufferObject) + FBO_Shutdown(); + R_DeleteTextures(); + R_ShutdownVBOs(); + GLSL_ShutdownGPUShaders(); + } + + R_DoneFreeType(); + + // shut down platform specific OpenGL stuff + if ( destroyWindow ) { + GLimp_Shutdown(); + + Com_Memset( &glConfig, 0, sizeof( glConfig ) ); + Com_Memset( &glState, 0, sizeof( glState ) ); + } + + tr.registered = qfalse; +} + + +/* +============= +RE_EndRegistration + +Touch all images to make sure they are resident +============= +*/ +void RE_EndRegistration( void ) { + R_IssuePendingRenderCommands(); + if (!ri.Sys_LowPhysicalMemory()) { + RB_ShowImages(); + } +} + + +/* +@@@@@@@@@@@@@@@@@@@@@ +GetRefAPI + +@@@@@@@@@@@@@@@@@@@@@ +*/ +#ifdef USE_RENDERER_DLOPEN +Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { +#else +refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { +#endif + + static refexport_t re; + + ri = *rimp; + + Com_Memset( &re, 0, sizeof( re ) ); + + if ( apiVersion != REF_API_VERSION ) { + ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", + REF_API_VERSION, apiVersion ); + return NULL; + } + + // the RE_ functions are Renderer Entry points + + re.Shutdown = RE_Shutdown; + + re.BeginRegistration = RE_BeginRegistration; + re.RegisterModel = RE_RegisterModel; + re.RegisterSkin = RE_RegisterSkin; + re.RegisterShader = RE_RegisterShader; + re.RegisterShaderNoMip = RE_RegisterShaderNoMip; + re.LoadWorld = RE_LoadWorldMap; + re.SetWorldVisData = RE_SetWorldVisData; + re.EndRegistration = RE_EndRegistration; + + re.BeginFrame = RE_BeginFrame; + re.EndFrame = RE_EndFrame; + + re.MarkFragments = R_MarkFragments; + re.LerpTag = R_LerpTag; + re.ModelBounds = R_ModelBounds; + + re.ClearScene = RE_ClearScene; + re.AddRefEntityToScene = RE_AddRefEntityToScene; + re.AddPolyToScene = RE_AddPolyToScene; + re.LightForPoint = R_LightForPoint; + re.AddLightToScene = RE_AddLightToScene; + re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene; + re.RenderScene = RE_RenderScene; + + re.SetColor = RE_SetColor; + re.DrawStretchPic = RE_StretchPic; + re.DrawStretchRaw = RE_StretchRaw; + re.UploadCinematic = RE_UploadCinematic; + + re.RegisterFont = RE_RegisterFont; + re.RemapShader = R_RemapShader; + re.GetEntityToken = R_GetEntityToken; + re.inPVS = R_inPVS; + + re.TakeVideoFrame = RE_TakeVideoFrame; + + return &re; +} diff --git a/codemp/rd-rend2/tr_light.c b/codemp/rd-rend2/tr_light.c new file mode 100644 index 0000000000..a34d9babce --- /dev/null +++ b/codemp/rd-rend2/tr_light.c @@ -0,0 +1,451 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_light.c + +#include "tr_local.h" + +#define DLIGHT_AT_RADIUS 16 +// at the edge of a dlight's influence, this amount of light will be added + +#define DLIGHT_MINIMUM_RADIUS 16 +// never calculate a range less than this to prevent huge light numbers + + +/* +=============== +R_TransformDlights + +Transforms the origins of an array of dlights. +Used by both the front end (for DlightBmodel) and +the back end (before doing the lighting calculation) +=============== +*/ +void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or) { + int i; + vec3_t temp; + + for ( i = 0 ; i < count ; i++, dl++ ) { + VectorSubtract( dl->origin, or->origin, temp ); + dl->transformed[0] = DotProduct( temp, or->axis[0] ); + dl->transformed[1] = DotProduct( temp, or->axis[1] ); + dl->transformed[2] = DotProduct( temp, or->axis[2] ); + } +} + +/* +============= +R_DlightBmodel + +Determine which dynamic lights may effect this bmodel +============= +*/ +void R_DlightBmodel( bmodel_t *bmodel ) { + int i, j; + dlight_t *dl; + int mask; + msurface_t *surf; + + // transform all the lights + R_TransformDlights( tr.refdef.num_dlights, tr.refdef.dlights, &tr.or ); + + mask = 0; + for ( i=0 ; itransformed[j] - bmodel->bounds[1][j] > dl->radius ) { + break; + } + if ( bmodel->bounds[0][j] - dl->transformed[j] > dl->radius ) { + break; + } + } + if ( j < 3 ) { + continue; + } + + // we need to check this light + mask |= 1 << i; + } + + tr.currentEntity->needDlights = (mask != 0); + + // set the dlight bits in all the surfaces + for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { + surf = tr.world->surfaces + bmodel->firstSurface + i; + + if ( *surf->data == SF_FACE ) { + ((srfSurfaceFace_t *)surf->data)->dlightBits = mask; + } else if ( *surf->data == SF_GRID ) { + ((srfGridMesh_t *)surf->data)->dlightBits = mask; + } else if ( *surf->data == SF_TRIANGLES ) { + ((srfTriangles_t *)surf->data)->dlightBits = mask; + } + } +} + + +/* +============================================================================= + +LIGHT SAMPLING + +============================================================================= +*/ + +extern cvar_t *r_ambientScale; +extern cvar_t *r_directedScale; +extern cvar_t *r_debugLight; + +/* +================= +R_SetupEntityLightingGrid + +================= +*/ +static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { + vec3_t lightOrigin; + int pos[3]; + int i, j; + byte *gridData; + float frac[3]; + int gridStep[3]; + vec3_t direction; + float totalFactor; + + if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { + // seperate lightOrigins are needed so an object that is + // sinking into the ground can still be lit, and so + // multi-part models can be lit identically + VectorCopy( ent->e.lightingOrigin, lightOrigin ); + } else { + VectorCopy( ent->e.origin, lightOrigin ); + } + + VectorSubtract( lightOrigin, world->lightGridOrigin, lightOrigin ); + for ( i = 0 ; i < 3 ; i++ ) { + float v; + + v = lightOrigin[i]*world->lightGridInverseSize[i]; + pos[i] = floor( v ); + frac[i] = v - pos[i]; + if ( pos[i] < 0 ) { + pos[i] = 0; + } else if ( pos[i] >= world->lightGridBounds[i] - 1 ) { + pos[i] = world->lightGridBounds[i] - 1; + } + } + + VectorClear( ent->ambientLight ); + VectorClear( ent->directedLight ); + VectorClear( direction ); + + assert( world->lightGridData ); // NULL with -nolight maps + + // trilerp the light value + gridStep[0] = 8; + gridStep[1] = 8 * world->lightGridBounds[0]; + gridStep[2] = 8 * world->lightGridBounds[0] * world->lightGridBounds[1]; + gridData = world->lightGridData + pos[0] * gridStep[0] + + pos[1] * gridStep[1] + pos[2] * gridStep[2]; + + totalFactor = 0; + for ( i = 0 ; i < 8 ; i++ ) { + float factor; + byte *data; + int lat, lng; + vec3_t normal; + qboolean ignore; + #if idppc + float d0, d1, d2, d3, d4, d5; + #endif + factor = 1.0; + data = gridData; + ignore = qfalse; + for ( j = 0 ; j < 3 ; j++ ) { + if ( i & (1<= world->lightGridBounds[j] - 1) + { + ignore = qtrue; // ignore values outside lightgrid + } + factor *= frac[j]; + data += gridStep[j]; + } else { + factor *= (1.0f - frac[j]); + } + } + + if ( ignore ) + continue; + + if (world->hdrLightGrid) + { + float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6; + if (!(hdrData[0]+hdrData[1]+hdrData[2]+hdrData[3]+hdrData[4]+hdrData[5]) ) { + continue; // ignore samples in walls + } + } + else + { + if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) { + continue; // ignore samples in walls + } + } + totalFactor += factor; + #if idppc + d0 = data[0]; d1 = data[1]; d2 = data[2]; + d3 = data[3]; d4 = data[4]; d5 = data[5]; + + ent->ambientLight[0] += factor * d0; + ent->ambientLight[1] += factor * d1; + ent->ambientLight[2] += factor * d2; + + ent->directedLight[0] += factor * d3; + ent->directedLight[1] += factor * d4; + ent->directedLight[2] += factor * d5; + #else + if (world->hdrLightGrid) + { + // FIXME: this is hideous + float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6; + + ent->ambientLight[0] += factor * hdrData[0]; + ent->ambientLight[1] += factor * hdrData[1]; + ent->ambientLight[2] += factor * hdrData[2]; + + ent->directedLight[0] += factor * hdrData[3]; + ent->directedLight[1] += factor * hdrData[4]; + ent->directedLight[2] += factor * hdrData[5]; + } + else + { + ent->ambientLight[0] += factor * data[0]; + ent->ambientLight[1] += factor * data[1]; + ent->ambientLight[2] += factor * data[2]; + + ent->directedLight[0] += factor * data[3]; + ent->directedLight[1] += factor * data[4]; + ent->directedLight[2] += factor * data[5]; + } + #endif + lat = data[7]; + lng = data[6]; + lat *= (FUNCTABLE_SIZE/256); + lng *= (FUNCTABLE_SIZE/256); + + // decode X as cos( lat ) * sin( long ) + // decode Y as sin( lat ) * sin( long ) + // decode Z as cos( long ) + + normal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + normal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + normal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + VectorMA( direction, factor, normal, direction ); + } + + if ( totalFactor > 0 && totalFactor < 0.99 ) { + totalFactor = 1.0f / totalFactor; + VectorScale( ent->ambientLight, totalFactor, ent->ambientLight ); + VectorScale( ent->directedLight, totalFactor, ent->directedLight ); + } + + VectorScale( ent->ambientLight, r_ambientScale->value, ent->ambientLight ); + VectorScale( ent->directedLight, r_directedScale->value, ent->directedLight ); + + VectorNormalize2( direction, ent->lightDir ); +} + + +/* +=============== +LogLight +=============== +*/ +static void LogLight( trRefEntity_t *ent ) { + int max1, max2; + + if ( !(ent->e.renderfx & RF_FIRST_PERSON ) ) { + return; + } + + max1 = ent->ambientLight[0]; + if ( ent->ambientLight[1] > max1 ) { + max1 = ent->ambientLight[1]; + } else if ( ent->ambientLight[2] > max1 ) { + max1 = ent->ambientLight[2]; + } + + max2 = ent->directedLight[0]; + if ( ent->directedLight[1] > max2 ) { + max2 = ent->directedLight[1]; + } else if ( ent->directedLight[2] > max2 ) { + max2 = ent->directedLight[2]; + } + + ri.Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); +} + +/* +================= +R_SetupEntityLighting + +Calculates all the lighting values that will be used +by the Calc_* functions +================= +*/ +void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { + int i; + dlight_t *dl; + float power; + vec3_t dir; + float d; + vec3_t lightDir; + vec3_t lightOrigin; + + // lighting calculations + if ( ent->lightingCalculated ) { + return; + } + ent->lightingCalculated = qtrue; + + // + // trace a sample point down to find ambient light + // + if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { + // seperate lightOrigins are needed so an object that is + // sinking into the ground can still be lit, and so + // multi-part models can be lit identically + VectorCopy( ent->e.lightingOrigin, lightOrigin ); + } else { + VectorCopy( ent->e.origin, lightOrigin ); + } + + // if NOWORLDMODEL, only use dynamic lights (menu system, etc) + if ( !(refdef->rdflags & RDF_NOWORLDMODEL ) + && tr.world->lightGridData ) { + R_SetupEntityLightingGrid( ent, tr.world ); + } else { + ent->ambientLight[0] = ent->ambientLight[1] = + ent->ambientLight[2] = tr.identityLight * 150; + ent->directedLight[0] = ent->directedLight[1] = + ent->directedLight[2] = tr.identityLight * 150; + VectorCopy( tr.sunDirection, ent->lightDir ); + } + + // bonus items and view weapons have a fixed minimum add + if ( !r_hdr->integer /* ent->e.renderfx & RF_MINLIGHT */ ) { + // give everything a minimum light add + ent->ambientLight[0] += tr.identityLight * 32; + ent->ambientLight[1] += tr.identityLight * 32; + ent->ambientLight[2] += tr.identityLight * 32; + } + + // + // modify the light by dynamic lights + // + d = VectorLength( ent->directedLight ); + VectorScale( ent->lightDir, d, lightDir ); + + for ( i = 0 ; i < refdef->num_dlights ; i++ ) { + dl = &refdef->dlights[i]; + VectorSubtract( dl->origin, lightOrigin, dir ); + d = VectorNormalize( dir ); + + power = DLIGHT_AT_RADIUS * ( dl->radius * dl->radius ); + if ( d < DLIGHT_MINIMUM_RADIUS ) { + d = DLIGHT_MINIMUM_RADIUS; + } + d = power / ( d * d ); + + VectorMA( ent->directedLight, d, dl->color, ent->directedLight ); + VectorMA( lightDir, d, dir, lightDir ); + } + + // clamp ambient + if ( !r_hdr->integer ) + { + for ( i = 0 ; i < 3 ; i++ ) { + if ( ent->ambientLight[i] > tr.identityLightByte ) { + ent->ambientLight[i] = tr.identityLightByte; + } + } + } + + if ( r_debugLight->integer ) { + LogLight( ent ); + } + + // save out the byte packet version + ((byte *)&ent->ambientLightInt)[0] = ri.ftol(ent->ambientLight[0]); + ((byte *)&ent->ambientLightInt)[1] = ri.ftol(ent->ambientLight[1]); + ((byte *)&ent->ambientLightInt)[2] = ri.ftol(ent->ambientLight[2]); + ((byte *)&ent->ambientLightInt)[3] = 0xff; + + // transform the direction to local space + // no need to do this if using lightentity glsl shader + VectorNormalize( lightDir ); + VectorCopy(lightDir, ent->lightDir); +} + +/* +================= +R_LightForPoint +================= +*/ +int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ) +{ + trRefEntity_t ent; + + if ( tr.world->lightGridData == NULL ) + return qfalse; + + Com_Memset(&ent, 0, sizeof(ent)); + VectorCopy( point, ent.e.origin ); + R_SetupEntityLightingGrid( &ent, tr.world ); + VectorCopy(ent.ambientLight, ambientLight); + VectorCopy(ent.directedLight, directedLight); + VectorCopy(ent.lightDir, lightDir); + + return qtrue; +} + + +int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ) +{ + trRefEntity_t ent; + + if ( world->lightGridData == NULL ) + return qfalse; + + Com_Memset(&ent, 0, sizeof(ent)); + VectorCopy( point, ent.e.origin ); + R_SetupEntityLightingGrid( &ent, world ); + + if (DotProduct(ent.lightDir, normal) > 0.2f) + VectorCopy(ent.lightDir, lightDir); + else + VectorCopy(normal, lightDir); + + return qtrue; +} diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h new file mode 100644 index 0000000000..144b16eb3d --- /dev/null +++ b/codemp/rd-rend2/tr_local.h @@ -0,0 +1,2677 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + + +#ifndef TR_LOCAL_H +#define TR_LOCAL_H + +#include "../qcommon/q_shared.h" +#include "../qcommon/qfiles.h" +#include "../qcommon/qcommon.h" +#include "../renderercommon/tr_public.h" +#include "../renderercommon/tr_common.h" +#include "tr_extratypes.h" +#include "tr_extramath.h" +#include "tr_fbo.h" +#include "tr_postprocess.h" +#include "../renderercommon/iqm.h" +#include "../renderercommon/qgl.h" + +#define GL_INDEX_TYPE GL_UNSIGNED_INT +typedef unsigned int glIndex_t; + +#define BUFFER_OFFSET(i) ((char *)NULL + (i)) + +// 14 bits +// can't be increased without changing bit packing for drawsurfs +// see QSORT_SHADERNUM_SHIFT +#define SHADERNUM_BITS 14 +#define MAX_SHADERS (1<or.origin in local coordinates + float modelMatrix[16]; + float transformMatrix[16]; +} orientationr_t; + +typedef enum +{ + VBO_USAGE_STATIC, + VBO_USAGE_DYNAMIC +} vboUsage_t; + +typedef struct VBO_s +{ + char name[MAX_QPATH]; + + uint32_t vertexesVBO; + int vertexesSize; // amount of memory data allocated for all vertices in bytes + uint32_t ofs_xyz; + uint32_t ofs_normal; + uint32_t ofs_st; + uint32_t ofs_lightmap; + uint32_t ofs_vertexcolor; + uint32_t ofs_lightdir; +#ifdef USE_VERT_TANGENT_SPACE + uint32_t ofs_tangent; + uint32_t ofs_bitangent; +#endif + uint32_t stride_xyz; + uint32_t stride_normal; + uint32_t stride_st; + uint32_t stride_lightmap; + uint32_t stride_vertexcolor; + uint32_t stride_lightdir; +#ifdef USE_VERT_TANGENT_SPACE + uint32_t stride_tangent; + uint32_t stride_bitangent; +#endif + uint32_t size_xyz; + uint32_t size_normal; + + int attribs; +} VBO_t; + +typedef struct IBO_s +{ + char name[MAX_QPATH]; + + uint32_t indexesVBO; + int indexesSize; // amount of memory data allocated for all triangles in bytes +// uint32_t ofsIndexes; +} IBO_t; + +//=============================================================================== + +typedef enum { + SS_BAD, + SS_PORTAL, // mirrors, portals, viewscreens + SS_ENVIRONMENT, // sky box + SS_OPAQUE, // opaque + + SS_DECAL, // scorch marks, etc. + SS_SEE_THROUGH, // ladders, grates, grills that may have small blended edges + // in addition to alpha test + SS_BANNER, + + SS_FOG, + + SS_UNDERWATER, // for items that should be drawn in front of the water plane + + SS_BLEND0, // regular transparency and filters + SS_BLEND1, // generally only used for additive type effects + SS_BLEND2, + SS_BLEND3, + + SS_BLEND6, + SS_STENCIL_SHADOW, + SS_ALMOST_NEAREST, // gun smoke puffs + + SS_NEAREST // blood blobs +} shaderSort_t; + + +#define MAX_SHADER_STAGES 8 + +typedef enum { + GF_NONE, + + GF_SIN, + GF_SQUARE, + GF_TRIANGLE, + GF_SAWTOOTH, + GF_INVERSE_SAWTOOTH, + + GF_NOISE + +} genFunc_t; + + +typedef enum { + DEFORM_NONE, + DEFORM_WAVE, + DEFORM_NORMALS, + DEFORM_BULGE, + DEFORM_MOVE, + DEFORM_PROJECTION_SHADOW, + DEFORM_AUTOSPRITE, + DEFORM_AUTOSPRITE2, + DEFORM_TEXT0, + DEFORM_TEXT1, + DEFORM_TEXT2, + DEFORM_TEXT3, + DEFORM_TEXT4, + DEFORM_TEXT5, + DEFORM_TEXT6, + DEFORM_TEXT7 +} deform_t; + +// deformVertexes types that can be handled by the GPU +typedef enum +{ + // do not edit: same as genFunc_t + + DGEN_NONE, + DGEN_WAVE_SIN, + DGEN_WAVE_SQUARE, + DGEN_WAVE_TRIANGLE, + DGEN_WAVE_SAWTOOTH, + DGEN_WAVE_INVERSE_SAWTOOTH, + DGEN_WAVE_NOISE, + + // do not edit until this line + + DGEN_BULGE, + DGEN_MOVE +} deformGen_t; + +typedef enum { + AGEN_IDENTITY, + AGEN_SKIP, + AGEN_ENTITY, + AGEN_ONE_MINUS_ENTITY, + AGEN_VERTEX, + AGEN_ONE_MINUS_VERTEX, + AGEN_LIGHTING_SPECULAR, + AGEN_WAVEFORM, + AGEN_PORTAL, + AGEN_CONST, + AGEN_FRESNEL +} alphaGen_t; + +typedef enum { + CGEN_BAD, + CGEN_IDENTITY_LIGHTING, // tr.identityLight + CGEN_IDENTITY, // always (1,1,1,1) + CGEN_ENTITY, // grabbed from entity's modulate field + CGEN_ONE_MINUS_ENTITY, // grabbed from 1 - entity.modulate + CGEN_EXACT_VERTEX, // tess.vertexColors + CGEN_VERTEX, // tess.vertexColors * tr.identityLight + CGEN_EXACT_VERTEX_LIT, // like CGEN_EXACT_VERTEX but takes a light direction from the lightgrid + CGEN_VERTEX_LIT, // like CGEN_VERTEX but takes a light direction from the lightgrid + CGEN_ONE_MINUS_VERTEX, + CGEN_WAVEFORM, // programmatically generated + CGEN_LIGHTING_DIFFUSE, + CGEN_FOG, // standard fog + CGEN_CONST // fixed color +} colorGen_t; + +typedef enum { + TCGEN_BAD, + TCGEN_IDENTITY, // clear to 0,0 + TCGEN_LIGHTMAP, + TCGEN_TEXTURE, + TCGEN_ENVIRONMENT_MAPPED, + TCGEN_FOG, + TCGEN_VECTOR // S and T from world coordinates +} texCoordGen_t; + +typedef enum { + ACFF_NONE, + ACFF_MODULATE_RGB, + ACFF_MODULATE_RGBA, + ACFF_MODULATE_ALPHA +} acff_t; + +typedef struct { + genFunc_t func; + + float base; + float amplitude; + float phase; + float frequency; +} waveForm_t; + +#define TR_MAX_TEXMODS 4 + +typedef enum { + TMOD_NONE, + TMOD_TRANSFORM, + TMOD_TURBULENT, + TMOD_SCROLL, + TMOD_SCALE, + TMOD_STRETCH, + TMOD_ROTATE, + TMOD_ENTITY_TRANSLATE +} texMod_t; + +#define MAX_SHADER_DEFORMS 3 +typedef struct { + deform_t deformation; // vertex coordinate modification type + + vec3_t moveVector; + waveForm_t deformationWave; + float deformationSpread; + + float bulgeWidth; + float bulgeHeight; + float bulgeSpeed; +} deformStage_t; + + +typedef struct { + texMod_t type; + + // used for TMOD_TURBULENT and TMOD_STRETCH + waveForm_t wave; + + // used for TMOD_TRANSFORM + float matrix[2][2]; // s' = s * m[0][0] + t * m[1][0] + trans[0] + float translate[2]; // t' = s * m[0][1] + t * m[0][1] + trans[1] + + // used for TMOD_SCALE + float scale[2]; // s *= scale[0] + // t *= scale[1] + + // used for TMOD_SCROLL + float scroll[2]; // s' = s + scroll[0] * time + // t' = t + scroll[1] * time + + // + = clockwise + // - = counterclockwise + float rotateSpeed; + +} texModInfo_t; + + +#define MAX_IMAGE_ANIMATIONS 8 + +typedef struct { + image_t *image[MAX_IMAGE_ANIMATIONS]; + int numImageAnimations; + float imageAnimationSpeed; + + texCoordGen_t tcGen; + vec3_t tcGenVectors[2]; + + int numTexMods; + texModInfo_t *texMods; + + int videoMapHandle; + qboolean isLightmap; + qboolean vertexLightmap; + qboolean isVideoMap; +} textureBundle_t; + +enum +{ + TB_COLORMAP = 0, + TB_DIFFUSEMAP = 0, + TB_LIGHTMAP = 1, + TB_LEVELSMAP = 1, + TB_SHADOWMAP3 = 1, + TB_NORMALMAP = 2, + TB_DELUXEMAP = 3, + TB_SHADOWMAP2 = 3, + TB_SPECULARMAP = 4, + TB_SHADOWMAP = 5, + NUM_TEXTURE_BUNDLES = 6 +}; + +typedef enum +{ + // material shader stage types + ST_COLORMAP = 0, // vanilla Q3A style shader treatening + ST_DIFFUSEMAP = 0, // treat color and diffusemap the same + ST_NORMALMAP, + ST_NORMALPARALLAXMAP, + ST_SPECULARMAP, + ST_GLSL +} stageType_t; + +typedef struct { + qboolean active; + + textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; + + waveForm_t rgbWave; + colorGen_t rgbGen; + + waveForm_t alphaWave; + alphaGen_t alphaGen; + + byte constantColor[4]; // for CGEN_CONST and AGEN_CONST + + unsigned stateBits; // GLS_xxxx mask + + acff_t adjustColorsForFog; + + qboolean isDetail; + + stageType_t type; + struct shaderProgram_s *glslShaderGroup; + int glslShaderIndex; + vec2_t materialInfo; +} shaderStage_t; + +struct shaderCommands_s; + +typedef enum { + CT_FRONT_SIDED, + CT_BACK_SIDED, + CT_TWO_SIDED +} cullType_t; + +typedef enum { + FP_NONE, // surface is translucent and will just be adjusted properly + FP_EQUAL, // surface is opaque but possibly alpha tested + FP_LE // surface is trnaslucent, but still needs a fog pass (fog surface) +} fogPass_t; + +typedef struct { + float cloudHeight; + image_t *outerbox[6], *innerbox[6]; +} skyParms_t; + +typedef struct { + vec3_t color; + float depthForOpaque; +} fogParms_t; + + +typedef struct shader_s { + char name[MAX_QPATH]; // game path, including extension + int lightmapIndex; // for a shader to match, both name and lightmapIndex must match + + int index; // this shader == tr.shaders[index] + int sortedIndex; // this shader == tr.sortedShaders[sortedIndex] + + float sort; // lower numbered shaders draw before higher numbered + + qboolean defaultShader; // we want to return index 0 if the shader failed to + // load for some reason, but R_FindShader should + // still keep a name allocated for it, so if + // something calls RE_RegisterShader again with + // the same name, we don't try looking for it again + + qboolean explicitlyDefined; // found in a .shader file + + int surfaceFlags; // if explicitlyDefined, this will have SURF_* flags + int contentFlags; + + qboolean entityMergable; // merge across entites optimizable (smoke, blood) + + qboolean isSky; + skyParms_t sky; + fogParms_t fogParms; + + float portalRange; // distance to fog out at + qboolean isPortal; + + int multitextureEnv; // 0, GL_MODULATE, GL_ADD (FIXME: put in stage) + + cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED + qboolean polygonOffset; // set for decals and other items that must be offset + qboolean noMipMaps; // for console fonts, 2D elements, etc. + qboolean noPicMip; // for images that must always be full resolution + + fogPass_t fogPass; // draw a blended pass, possibly with depth test equals + + int vertexAttribs; // not all shaders will need all data to be gathered + + int numDeforms; + deformStage_t deforms[MAX_SHADER_DEFORMS]; + + int numUnfoggedPasses; + shaderStage_t *stages[MAX_SHADER_STAGES]; + + void (*optimalStageIteratorFunc)( void ); + + float clampTime; // time this shader is clamped to + float timeOffset; // current time offset for this shader + + int numStates; // if non-zero this is a state shader + struct shader_s *currentShader; // current state if this is a state shader + struct shader_s *parentShader; // current state if this is a state shader + int currentState; // current state index for cycle purposes + long expireTime; // time in milliseconds this expires + + struct shader_s *remappedShader; // current shader this one is remapped too + + int shaderStates[MAX_STATES_PER_SHADER]; // index to valid shader states + + struct shader_s *next; +} shader_t; + +static ID_INLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) +{ + if(shader->numDeforms) + { + const deformStage_t *ds = &shader->deforms[0]; + + if (shader->numDeforms > 1) + return qtrue; + + switch (ds->deformation) + { + case DEFORM_WAVE: + case DEFORM_BULGE: + return qfalse; + + default: + return qtrue; + } + } + + return qfalse; +} + +typedef struct shaderState_s { + char shaderName[MAX_QPATH]; // name of shader this state belongs to + char name[MAX_STATE_NAME]; // name of this state + char stateShader[MAX_QPATH]; // shader this name invokes + int cycleTime; // time this cycle lasts, <= 0 is forever + shader_t *shader; +} shaderState_t; + +enum +{ + ATTR_INDEX_POSITION = 0, + ATTR_INDEX_TEXCOORD0 = 1, + ATTR_INDEX_TEXCOORD1 = 2, + ATTR_INDEX_TANGENT = 3, + ATTR_INDEX_BITANGENT = 4, + ATTR_INDEX_NORMAL = 5, + ATTR_INDEX_COLOR = 6, + ATTR_INDEX_PAINTCOLOR = 7, + ATTR_INDEX_LIGHTDIRECTION = 8, + ATTR_INDEX_BONE_INDEXES = 9, + ATTR_INDEX_BONE_WEIGHTS = 10, + + // GPU vertex animations + ATTR_INDEX_POSITION2 = 11, + ATTR_INDEX_TANGENT2 = 12, + ATTR_INDEX_BITANGENT2 = 13, + ATTR_INDEX_NORMAL2 = 14 +}; + +enum +{ + GLS_SRCBLEND_ZERO = (1 << 0), + GLS_SRCBLEND_ONE = (1 << 1), + GLS_SRCBLEND_DST_COLOR = (1 << 2), + GLS_SRCBLEND_ONE_MINUS_DST_COLOR = (1 << 3), + GLS_SRCBLEND_SRC_ALPHA = (1 << 4), + GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA = (1 << 5), + GLS_SRCBLEND_DST_ALPHA = (1 << 6), + GLS_SRCBLEND_ONE_MINUS_DST_ALPHA = (1 << 7), + GLS_SRCBLEND_ALPHA_SATURATE = (1 << 8), + + GLS_SRCBLEND_BITS = GLS_SRCBLEND_ZERO + | GLS_SRCBLEND_ONE + | GLS_SRCBLEND_DST_COLOR + | GLS_SRCBLEND_ONE_MINUS_DST_COLOR + | GLS_SRCBLEND_SRC_ALPHA + | GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA + | GLS_SRCBLEND_DST_ALPHA + | GLS_SRCBLEND_ONE_MINUS_DST_ALPHA + | GLS_SRCBLEND_ALPHA_SATURATE, + + GLS_DSTBLEND_ZERO = (1 << 9), + GLS_DSTBLEND_ONE = (1 << 10), + GLS_DSTBLEND_SRC_COLOR = (1 << 11), + GLS_DSTBLEND_ONE_MINUS_SRC_COLOR = (1 << 12), + GLS_DSTBLEND_SRC_ALPHA = (1 << 13), + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA = (1 << 14), + GLS_DSTBLEND_DST_ALPHA = (1 << 15), + GLS_DSTBLEND_ONE_MINUS_DST_ALPHA = (1 << 16), + + GLS_DSTBLEND_BITS = GLS_DSTBLEND_ZERO + | GLS_DSTBLEND_ONE + | GLS_DSTBLEND_SRC_COLOR + | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR + | GLS_DSTBLEND_SRC_ALPHA + | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA + | GLS_DSTBLEND_DST_ALPHA + | GLS_DSTBLEND_ONE_MINUS_DST_ALPHA, + + GLS_DEPTHMASK_TRUE = (1 << 17), + + GLS_POLYMODE_LINE = (1 << 18), + + GLS_DEPTHTEST_DISABLE = (1 << 19), + + GLS_DEPTHFUNC_LESS = (1 << 20), + GLS_DEPTHFUNC_EQUAL = (1 << 21), + + GLS_DEPTHFUNC_BITS = GLS_DEPTHFUNC_LESS + | GLS_DEPTHFUNC_EQUAL, + + GLS_ATEST_GT_0 = (1 << 22), + GLS_ATEST_LT_128 = (1 << 23), + GLS_ATEST_GE_128 = (1 << 24), +// GLS_ATEST_GE_CUSTOM = (1 << 25), + + GLS_ATEST_BITS = GLS_ATEST_GT_0 + | GLS_ATEST_LT_128 + | GLS_ATEST_GE_128, +// | GLS_ATEST_GT_CUSTOM, + + GLS_REDMASK_FALSE = (1 << 26), + GLS_GREENMASK_FALSE = (1 << 27), + GLS_BLUEMASK_FALSE = (1 << 28), + GLS_ALPHAMASK_FALSE = (1 << 29), + + GLS_COLORMASK_BITS = GLS_REDMASK_FALSE + | GLS_GREENMASK_FALSE + | GLS_BLUEMASK_FALSE + | GLS_ALPHAMASK_FALSE, + + GLS_STENCILTEST_ENABLE = (1 << 30), + + GLS_DEFAULT = GLS_DEPTHMASK_TRUE +}; + +enum +{ + ATTR_POSITION = 0x0001, + ATTR_TEXCOORD = 0x0002, + ATTR_LIGHTCOORD = 0x0004, + ATTR_TANGENT = 0x0008, + ATTR_BITANGENT = 0x0010, + ATTR_NORMAL = 0x0020, + ATTR_COLOR = 0x0040, + ATTR_PAINTCOLOR = 0x0080, + ATTR_LIGHTDIRECTION = 0x0100, + ATTR_BONE_INDEXES = 0x0200, + ATTR_BONE_WEIGHTS = 0x0400, + + // for .md3 interpolation + ATTR_POSITION2 = 0x0800, + ATTR_TANGENT2 = 0x1000, + ATTR_BITANGENT2 = 0x2000, + ATTR_NORMAL2 = 0x4000, + + ATTR_DEFAULT = ATTR_POSITION, + ATTR_BITS = ATTR_POSITION | + ATTR_TEXCOORD | + ATTR_LIGHTCOORD | + ATTR_TANGENT | + ATTR_BITANGENT | + ATTR_NORMAL | + ATTR_COLOR | + ATTR_PAINTCOLOR | + ATTR_LIGHTDIRECTION | + ATTR_BONE_INDEXES | + ATTR_BONE_WEIGHTS | + ATTR_POSITION2 | + ATTR_TANGENT2 | + ATTR_BITANGENT2 | + ATTR_NORMAL2 +}; + +enum +{ + GENERICDEF_USE_DEFORM_VERTEXES = 0x0001, + GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002, + GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, + GENERICDEF_USE_FOG = 0x0008, + GENERICDEF_USE_RGBAGEN = 0x0010, + GENERICDEF_USE_LIGHTMAP = 0x0020, + GENERICDEF_ALL = 0x003F, + GENERICDEF_COUNT = 0x0040, +}; + +enum +{ + FOGDEF_USE_DEFORM_VERTEXES = 0x0001, + FOGDEF_USE_VERTEX_ANIMATION = 0x0002, + FOGDEF_ALL = 0x0003, + FOGDEF_COUNT = 0x0004, +}; + +enum +{ + DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, + DLIGHTDEF_ALL = 0x0001, + DLIGHTDEF_COUNT = 0x0002, +}; + +enum +{ + LIGHTDEF_USE_LIGHTMAP = 0x0001, + LIGHTDEF_USE_LIGHT_VECTOR = 0x0002, + LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, + LIGHTDEF_LIGHTTYPE_MASK = 0x0003, + LIGHTDEF_ENTITY = 0x0004, + LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, + LIGHTDEF_USE_NORMALMAP = 0x0010, + LIGHTDEF_USE_SPECULARMAP = 0x0020, + LIGHTDEF_USE_DELUXEMAP = 0x0040, + LIGHTDEF_USE_PARALLAXMAP = 0x0080, + LIGHTDEF_USE_SHADOWMAP = 0x0100, + LIGHTDEF_ALL = 0x01FF, + LIGHTDEF_COUNT = 0x0200 +}; + +enum +{ + GLSL_INT, + GLSL_FLOAT, + GLSL_FLOAT5, + GLSL_VEC2, + GLSL_VEC3, + GLSL_VEC4, + GLSL_MAT16 +}; + +typedef enum +{ + UNIFORM_DIFFUSEMAP = 0, + UNIFORM_LIGHTMAP, + UNIFORM_NORMALMAP, + UNIFORM_DELUXEMAP, + UNIFORM_SPECULARMAP, + + UNIFORM_TEXTUREMAP, + UNIFORM_LEVELSMAP, + + UNIFORM_SCREENIMAGEMAP, + UNIFORM_SCREENDEPTHMAP, + + UNIFORM_SHADOWMAP, + UNIFORM_SHADOWMAP2, + UNIFORM_SHADOWMAP3, + + UNIFORM_SHADOWMVP, + UNIFORM_SHADOWMVP2, + UNIFORM_SHADOWMVP3, + + UNIFORM_DIFFUSETEXMATRIX, + UNIFORM_DIFFUSETEXOFFTURB, + UNIFORM_TEXTURE1ENV, + + UNIFORM_TCGEN0, + UNIFORM_TCGEN0VECTOR0, + UNIFORM_TCGEN0VECTOR1, + + UNIFORM_DEFORMGEN, + UNIFORM_DEFORMPARAMS, + + UNIFORM_COLORGEN, + UNIFORM_ALPHAGEN, + UNIFORM_COLOR, + UNIFORM_BASECOLOR, + UNIFORM_VERTCOLOR, + + UNIFORM_DLIGHTINFO, + UNIFORM_LIGHTFORWARD, + UNIFORM_LIGHTUP, + UNIFORM_LIGHTRIGHT, + UNIFORM_LIGHTORIGIN, + UNIFORM_LIGHTRADIUS, + UNIFORM_AMBIENTLIGHT, + UNIFORM_DIRECTEDLIGHT, + + UNIFORM_PORTALRANGE, + + UNIFORM_FOGDISTANCE, + UNIFORM_FOGDEPTH, + UNIFORM_FOGEYET, + UNIFORM_FOGCOLORMASK, + + UNIFORM_MODELMATRIX, + UNIFORM_MODELVIEWPROJECTIONMATRIX, + + UNIFORM_TIME, + UNIFORM_VERTEXLERP, + UNIFORM_MATERIALINFO, + + UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2 + UNIFORM_VIEWORIGIN, + UNIFORM_VIEWFORWARD, + UNIFORM_VIEWLEFT, + UNIFORM_VIEWUP, + + UNIFORM_INVTEXRES, + UNIFORM_AUTOEXPOSUREMINMAX, + UNIFORM_TONEMINAVGMAXLINEAR, + + UNIFORM_PRIMARYLIGHTORIGIN, + UNIFORM_PRIMARYLIGHTCOLOR, + UNIFORM_PRIMARYLIGHTAMBIENT, + UNIFORM_PRIMARYLIGHTRADIUS, + + UNIFORM_COUNT +} uniform_t; + +// shaderProgram_t represents a pair of one +// GLSL vertex and one GLSL fragment shader +typedef struct shaderProgram_s +{ + char name[MAX_QPATH]; + + GLhandleARB program; + GLhandleARB vertexShader; + GLhandleARB fragmentShader; + uint32_t attribs; // vertex array attributes + + // uniform parameters + GLint uniforms[UNIFORM_COUNT]; + short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms + char *uniformBuffer; +} shaderProgram_t; + +// trRefdef_t holds everything that comes in refdef_t, +// as well as the locally generated scene information +typedef struct { + int x, y, width, height; + float fov_x, fov_y; + vec3_t vieworg; + vec3_t viewaxis[3]; // transformation matrix + + stereoFrame_t stereoFrame; + + int time; // time in milliseconds for shader effects and other time dependent rendering issues + int rdflags; // RDF_NOWORLDMODEL, etc + + // 1 bits will prevent the associated area from rendering at all + byte areamask[MAX_MAP_AREA_BYTES]; + qboolean areamaskModified; // qtrue if areamask changed since last scene + + float floatTime; // tr.refdef.time / 1000.0 + + float blurFactor; + + // text messages for deform text shaders + char text[MAX_RENDER_STRINGS][MAX_RENDER_STRING_LENGTH]; + + int num_entities; + trRefEntity_t *entities; + + int num_dlights; + struct dlight_s *dlights; + + int numPolys; + struct srfPoly_s *polys; + + int numDrawSurfs; + struct drawSurf_s *drawSurfs; + + unsigned int dlightMask; + int num_pshadows; + struct pshadow_s *pshadows; + + float sunShadowMvp[3][16]; + float sunDir[4]; + float sunCol[4]; + float sunAmbCol[4]; + float colorScale; + + float autoExposureMinMax[2]; + float toneMinAvgMaxLinear[3]; +} trRefdef_t; + + +//================================================================================= + +// skins allow models to be retextured without modifying the model file +typedef struct { + char name[MAX_QPATH]; + shader_t *shader; +} skinSurface_t; + +typedef struct skin_s { + char name[MAX_QPATH]; // game path, including extension + int numSurfaces; + skinSurface_t *surfaces[MD3_MAX_SURFACES]; +} skin_t; + + +typedef struct { + int originalBrushNumber; + vec3_t bounds[2]; + + unsigned colorInt; // in packed byte format + float tcScale; // texture coordinate vector scales + fogParms_t parms; + + // for clipping distance in fog when outside + qboolean hasSurface; + float surface[4]; +} fog_t; + +typedef enum { + VPF_NONE = 0x00, + VPF_SHADOWMAP = 0x01, + VPF_DEPTHSHADOW = 0x02, + VPF_DEPTHCLAMP = 0x04, + VPF_ORTHOGRAPHIC = 0x08, + VPF_USESUNLIGHT = 0x10, + VPF_FARPLANEFRUSTUM = 0x20 +} viewParmFlags_t; + +typedef struct { + orientationr_t or; + orientationr_t world; + vec3_t pvsOrigin; // may be different than or.origin for portals + qboolean isPortal; // true if this view is through a portal + qboolean isMirror; // the portal is a mirror, invert the face culling + viewParmFlags_t flags; + int frameSceneNum; // copied from tr.frameSceneNum + int frameCount; // copied from tr.frameCount + cplane_t portalPlane; // clip anything behind this if mirroring + int viewportX, viewportY, viewportWidth, viewportHeight; + FBO_t *targetFbo; + float fovX, fovY; + float projectionMatrix[16]; + cplane_t frustum[5]; + vec3_t visBounds[2]; + float zFar; + float zNear; + stereoFrame_t stereoFrame; +} viewParms_t; + + +/* +============================================================================== + +SURFACES + +============================================================================== +*/ +typedef byte color4ub_t[4]; + +// any changes in surfaceType must be mirrored in rb_surfaceTable[] +typedef enum { + SF_BAD, + SF_SKIP, // ignore + SF_FACE, + SF_GRID, + SF_TRIANGLES, + SF_POLY, + SF_MDV, + SF_MD4, + SF_MDR, + SF_IQM, + SF_FLARE, + SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity + SF_DISPLAY_LIST, + SF_VBO_MESH, + SF_VBO_MDVMESH, + + SF_NUM_SURFACE_TYPES, + SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) +} surfaceType_t; + +typedef struct drawSurf_s { + unsigned sort; // bit combination for fast compares + surfaceType_t *surface; // any of surface*_t +} drawSurf_t; + +#define MAX_FACE_POINTS 64 + +#define MAX_PATCH_SIZE 32 // max dimensions of a patch mesh in map file +#define MAX_GRID_SIZE 65 // max dimensions of a grid mesh in memory + +// when cgame directly specifies a polygon, it becomes a srfPoly_t +// as soon as it is called +typedef struct srfPoly_s { + surfaceType_t surfaceType; + qhandle_t hShader; + int fogIndex; + int numVerts; + polyVert_t *verts; +} srfPoly_t; + +typedef struct srfDisplayList_s { + surfaceType_t surfaceType; + int listNum; +} srfDisplayList_t; + + +typedef struct srfFlare_s { + surfaceType_t surfaceType; + vec3_t origin; + vec3_t normal; + vec3_t color; +} srfFlare_t; + +typedef struct +{ + vec3_t xyz; + vec2_t st; + vec2_t lightmap; + vec3_t normal; +#ifdef USE_VERT_TANGENT_SPACE + vec3_t tangent; + vec3_t bitangent; +#endif + vec3_t lightdir; + vec4_t vertexColors; + +#if DEBUG_OPTIMIZEVERTICES + unsigned int id; +#endif +} srfVert_t; + +#ifdef USE_VERT_TANGENT_SPACE +#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}} +#else +#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}} +#endif + +typedef struct +{ + int indexes[3]; + int neighbors[3]; + vec4_t plane; + qboolean facingLight; + qboolean degenerated; +} srfTriangle_t; + + +typedef struct srfGridMesh_s +{ + surfaceType_t surfaceType; + + // dynamic lighting information + int dlightBits; + int pshadowBits; + + // culling information + vec3_t meshBounds[2]; + vec3_t localOrigin; + float meshRadius; + + // lod information, which may be different + // than the culling information to allow for + // groups of curves that LOD as a unit + vec3_t lodOrigin; + float lodRadius; + int lodFixed; + int lodStitched; + + // vertexes + int width, height; + float *widthLodError; + float *heightLodError; + + int numTriangles; + srfTriangle_t *triangles; + + int numVerts; + srfVert_t *verts; + + // BSP VBO offsets + int firstVert; + int firstIndex; + glIndex_t minIndex; + glIndex_t maxIndex; + + // static render data + VBO_t *vbo; // points to bsp model VBO + IBO_t *ibo; +} srfGridMesh_t; + + +typedef struct +{ + surfaceType_t surfaceType; + + // dynamic lighting information + int dlightBits; + int pshadowBits; + + // culling information + cplane_t plane; +// vec3_t bounds[2]; + + // triangle definitions + int numTriangles; + srfTriangle_t *triangles; + + int numVerts; + srfVert_t *verts; + + // BSP VBO offsets + int firstVert; + int firstIndex; + glIndex_t minIndex; + glIndex_t maxIndex; + + // static render data + VBO_t *vbo; // points to bsp model VBO + IBO_t *ibo; +} srfSurfaceFace_t; + + +// misc_models in maps are turned into direct geometry by xmap +typedef struct +{ + surfaceType_t surfaceType; + + // dynamic lighting information + int dlightBits; + int pshadowBits; + + // culling information +// vec3_t bounds[2]; + + // triangle definitions + int numTriangles; + srfTriangle_t *triangles; + + int numVerts; + srfVert_t *verts; + + // BSP VBO offsets + int firstVert; + int firstIndex; + glIndex_t minIndex; + glIndex_t maxIndex; + + // static render data + VBO_t *vbo; // points to bsp model VBO + IBO_t *ibo; +} srfTriangles_t; + +// inter-quake-model +typedef struct { + int num_vertexes; + int num_triangles; + int num_frames; + int num_surfaces; + int num_joints; + struct srfIQModel_s *surfaces; + + float *positions; + float *texcoords; + float *normals; + float *tangents; + byte *blendIndexes; + byte *blendWeights; + byte *colors; + int *triangles; + + int *jointParents; + float *jointMats; + float *poseMats; + float *bounds; + char *names; +} iqmData_t; + +// inter-quake-model surface +typedef struct srfIQModel_s { + surfaceType_t surfaceType; + char name[MAX_QPATH]; + shader_t *shader; + iqmData_t *data; + int first_vertex, num_vertexes; + int first_triangle, num_triangles; +} srfIQModel_t; + +typedef struct srfVBOMesh_s +{ + surfaceType_t surfaceType; + + struct shader_s *shader; // FIXME move this to somewhere else + int fogIndex; + + // dynamic lighting information + int dlightBits; + int pshadowBits; + + // culling information + vec3_t bounds[2]; + + // backEnd stats + int numIndexes; + int numVerts; + int firstIndex; + glIndex_t minIndex; + glIndex_t maxIndex; + + // static render data + VBO_t *vbo; + IBO_t *ibo; +} srfVBOMesh_t; + +typedef struct srfVBOMDVMesh_s +{ + surfaceType_t surfaceType; + + struct mdvModel_s *mdvModel; + struct mdvSurface_s *mdvSurface; + + // backEnd stats + int numIndexes; + int numVerts; + glIndex_t minIndex; + glIndex_t maxIndex; + + // static render data + VBO_t *vbo; + IBO_t *ibo; +} srfVBOMDVMesh_t; + +extern void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *); + +/* +============================================================================== + +SHADOWS + +============================================================================== +*/ + +typedef struct pshadow_s +{ + float sort; + + int numEntities; + int entityNums[8]; + vec3_t entityOrigins[8]; + float entityRadiuses[8]; + + float viewRadius; + vec3_t viewOrigin; + + vec3_t lightViewAxis[3]; + vec3_t lightOrigin; + float lightRadius; + cplane_t cullPlane; +} pshadow_t; + + +/* +============================================================================== + +BRUSH MODELS + +============================================================================== +*/ + + +// +// in memory representation +// + +#define SIDE_FRONT 0 +#define SIDE_BACK 1 +#define SIDE_ON 2 + +#define CULLINFO_NONE 0 +#define CULLINFO_BOX 1 +#define CULLINFO_SPHERE 2 +#define CULLINFO_PLANE 4 + +typedef struct cullinfo_s { + int type; + vec3_t bounds[2]; + vec3_t localOrigin; + float radius; + cplane_t plane; +} cullinfo_t; + +typedef struct msurface_s { + //int viewCount; // if == tr.viewCount, already added + struct shader_s *shader; + int fogIndex; + cullinfo_t cullinfo; + + surfaceType_t *data; // any of srf*_t +} msurface_t; + + +#define CONTENTS_NODE -1 +typedef struct mnode_s { + // common with leaf and node + int contents; // -1 for nodes, to differentiate from leafs + int visCounts[MAX_VISCOUNTS]; // node needs to be traversed if current + vec3_t mins, maxs; // for bounding box culling + struct mnode_s *parent; + + // node specific + cplane_t *plane; + struct mnode_s *children[2]; + + // leaf specific + int cluster; + int area; + + int firstmarksurface; + int nummarksurfaces; +} mnode_t; + +typedef struct { + vec3_t bounds[2]; // for culling + int firstSurface; + int numSurfaces; +} bmodel_t; + +typedef struct { + char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp + char baseName[MAX_QPATH]; // ie: tim_dm2 + + int dataSize; + + int numShaders; + dshader_t *shaders; + + int numBModels; + bmodel_t *bmodels; + + int numplanes; + cplane_t *planes; + + int numnodes; // includes leafs + int numDecisionNodes; + mnode_t *nodes; + + VBO_t *vbo; + IBO_t *ibo; + + int numWorldSurfaces; + + int numsurfaces; + msurface_t *surfaces; + int *surfacesViewCount; + int *surfacesDlightBits; + int *surfacesPshadowBits; + + int numMergedSurfaces; + msurface_t *mergedSurfaces; + int *mergedSurfacesViewCount; + int *mergedSurfacesDlightBits; + int *mergedSurfacesPshadowBits; + + int nummarksurfaces; + int *marksurfaces; + int *viewSurfaces; + + int numfogs; + fog_t *fogs; + + vec3_t lightGridOrigin; + vec3_t lightGridSize; + vec3_t lightGridInverseSize; + int lightGridBounds[3]; + byte *lightGridData; + float *hdrLightGrid; + + + int numClusters; + int clusterBytes; + const byte *vis; // may be passed in by CM_LoadMap to save space + + byte *novis; // clusterBytes of 0xff + + char *entityString; + char *entityParsePoint; +} world_t; + + +/* +============================================================================== +MDV MODELS - meta format for vertex animation models like .md2, .md3, .mdc +============================================================================== +*/ +typedef struct +{ + float bounds[2][3]; + float localOrigin[3]; + float radius; +} mdvFrame_t; + +typedef struct +{ + float origin[3]; + float axis[3][3]; +} mdvTag_t; + +typedef struct +{ + char name[MAX_QPATH]; // tag name +} mdvTagName_t; + +typedef struct +{ + vec3_t xyz; + vec3_t normal; +#ifdef USE_VERT_TANGENT_SPACE + vec3_t tangent; + vec3_t bitangent; +#endif +} mdvVertex_t; + +typedef struct +{ + float st[2]; +} mdvSt_t; + +typedef struct mdvSurface_s +{ + surfaceType_t surfaceType; + + char name[MAX_QPATH]; // polyset name + + int numShaderIndexes; + int *shaderIndexes; + + int numVerts; + mdvVertex_t *verts; + mdvSt_t *st; + + int numTriangles; + srfTriangle_t *triangles; + + struct mdvModel_s *model; +} mdvSurface_t; + +typedef struct mdvModel_s +{ + int numFrames; + mdvFrame_t *frames; + + int numTags; + mdvTag_t *tags; + mdvTagName_t *tagNames; + + int numSurfaces; + mdvSurface_t *surfaces; + + int numVBOSurfaces; + srfVBOMDVMesh_t *vboSurfaces; + + int numSkins; +} mdvModel_t; + + +//====================================================================== + +typedef enum { + MOD_BAD, + MOD_BRUSH, + MOD_MESH, + MOD_MD4, + MOD_MDR, + MOD_IQM +} modtype_t; + +typedef struct model_s { + char name[MAX_QPATH]; + modtype_t type; + int index; // model = tr.models[model->index] + + int dataSize; // just for listing purposes + bmodel_t *bmodel; // only if type == MOD_BRUSH + mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH + void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM) + + int numLods; +} model_t; + + +#define MAX_MOD_KNOWN 1024 + +void R_ModelInit (void); +model_t *R_GetModelByHandle( qhandle_t hModel ); +int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, + float frac, const char *tagName ); +void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ); + +void R_Modellist_f (void); + +//==================================================== + +#define MAX_DRAWIMAGES 2048 +#define MAX_SKINS 1024 + + +#define MAX_DRAWSURFS 0x10000 +#define DRAWSURF_MASK (MAX_DRAWSURFS-1) + +/* + +the drawsurf sort data is packed into a single 32 bit value so it can be +compared quickly during the qsorting process + +the bits are allocated as follows: + +0 - 1 : dlightmap index +//2 : used to be clipped flag REMOVED - 03.21.00 rad +2 - 6 : fog index +11 - 20 : entity index +21 - 31 : sorted shader index + + TTimo - 1.32 +0-1 : dlightmap index +2-6 : fog index +7-16 : entity index +17-30 : sorted shader index + + SmileTheory - for pshadows +17-31 : sorted shader index +7-16 : entity index +2-6 : fog index +1 : pshadow flag +0 : dlight flag +*/ +#define QSORT_FOGNUM_SHIFT 2 +#define QSORT_REFENTITYNUM_SHIFT 7 +#define QSORT_SHADERNUM_SHIFT (QSORT_REFENTITYNUM_SHIFT+REFENTITYNUM_BITS) +#if (QSORT_SHADERNUM_SHIFT+SHADERNUM_BITS) > 32 + #error "Need to update sorting, too many bits." +#endif +#define QSORT_PSHADOW_SHIFT 1 + +extern int gl_filter_min, gl_filter_max; + +/* +** performanceCounters_t +*/ +typedef struct { + int c_sphere_cull_patch_in, c_sphere_cull_patch_clip, c_sphere_cull_patch_out; + int c_box_cull_patch_in, c_box_cull_patch_clip, c_box_cull_patch_out; + int c_sphere_cull_md3_in, c_sphere_cull_md3_clip, c_sphere_cull_md3_out; + int c_box_cull_md3_in, c_box_cull_md3_clip, c_box_cull_md3_out; + + int c_leafs; + int c_dlightSurfaces; + int c_dlightSurfacesCulled; +} frontEndCounters_t; + +#define FOG_TABLE_SIZE 256 +#define FUNCTABLE_SIZE 1024 +#define FUNCTABLE_SIZE2 10 +#define FUNCTABLE_MASK (FUNCTABLE_SIZE-1) + + +// the renderer front end should never modify glstate_t +typedef struct { + int currenttextures[NUM_TEXTURE_BUNDLES]; + int currenttmu; + qboolean finishCalled; + int texEnv[2]; + int faceCulling; + unsigned long glStateBits; + uint32_t vertexAttribsState; + uint32_t vertexAttribPointersSet; + uint32_t vertexAttribsNewFrame; + uint32_t vertexAttribsOldFrame; + float vertexAttribsInterpolation; + shaderProgram_t *currentProgram; + FBO_t *currentFBO; + VBO_t *currentVBO; + IBO_t *currentIBO; + matrix_t modelview; + matrix_t projection; + matrix_t modelviewProjection; +} glstate_t; + +typedef enum { + MI_NONE, + MI_NVX, + MI_ATI +} memInfo_t; + +typedef enum { + TCR_NONE = 0x0000, + TCR_LATC = 0x0001, + TCR_BPTC = 0x0002, +} textureCompressionRef_t; + +// We can't change glConfig_t without breaking DLL/vms compatibility, so +// store extensions we have here. +typedef struct { + qboolean drawRangeElements; + qboolean multiDrawArrays; + qboolean occlusionQuery; + + int glslMajorVersion; + int glslMinorVersion; + + memInfo_t memInfo; + + qboolean framebufferObject; + int maxRenderbufferSize; + int maxColorAttachments; + + qboolean textureNonPowerOfTwo; + qboolean textureFloat; + qboolean halfFloatPixel; + qboolean packedDepthStencil; + textureCompressionRef_t textureCompression; + + qboolean framebufferMultisample; + qboolean framebufferBlit; + + qboolean texture_srgb; + + qboolean depthClamp; +} glRefConfig_t; + + +typedef struct { + int c_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes; + int c_surfBatches; + float c_overDraw; + + int c_vboVertexBuffers; + int c_vboIndexBuffers; + int c_vboVertexes; + int c_vboIndexes; + + int c_staticVboDraws; + int c_dynamicVboDraws; + + int c_multidraws; + int c_multidrawsMerged; + + int c_dlightVertexes; + int c_dlightIndexes; + + int c_flareAdds; + int c_flareTests; + int c_flareRenders; + + int c_glslShaderBinds; + int c_genericDraws; + int c_lightallDraws; + int c_fogDraws; + int c_dlightDraws; + + int msec; // total msec for backend run +} backEndCounters_t; + +// all state modified by the back end is seperated +// from the front end state +typedef struct { + trRefdef_t refdef; + viewParms_t viewParms; + orientationr_t or; + backEndCounters_t pc; + qboolean isHyperspace; + trRefEntity_t *currentEntity; + qboolean skyRenderedThisView; // flag for drawing sun + + qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes + byte color2D[4]; + qboolean vertexes2D; // shader needs to be finished + trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering + + FBO_t *last2DFBO; + qboolean colorMask[4]; + qboolean framePostProcessed; + qboolean depthFill; +} backEndState_t; + +/* +** trGlobals_t +** +** Most renderer globals are defined here. +** backend functions should never modify any of these fields, +** but may read fields that aren't dynamically modified +** by the frontend. +*/ +typedef struct { + qboolean registered; // cleared at shutdown, set at beginRegistration + + int visIndex; + int visClusters[MAX_VISCOUNTS]; + int visCounts[MAX_VISCOUNTS]; // incremented every time a new vis cluster is entered + + int frameCount; // incremented every frame + int sceneCount; // incremented every scene + int viewCount; // incremented every view (twice a scene if portaled) + // and every R_MarkFragments call + + int frameSceneNum; // zeroed at RE_BeginFrame + + qboolean worldMapLoaded; + qboolean worldDeluxeMapping; + vec2_t autoExposureMinMax; + vec3_t toneMinAvgMaxLevel; + world_t *world; + + const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load + + image_t *defaultImage; + image_t *scratchImage[32]; + image_t *fogImage; + image_t *dlightImage; // inverse-quare highlight for projective adding + image_t *flareImage; + image_t *whiteImage; // full of 0xff + image_t *identityLightImage; // full of tr.identityLightByte + + image_t *shadowCubemaps[MAX_DLIGHTS]; + + + image_t *renderImage; + image_t *sunRaysImage; + image_t *renderDepthImage; + image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; + image_t *textureScratchImage[2]; + image_t *screenScratchImage; + image_t *quarterImage[2]; + image_t *calcLevelsImage; + image_t *targetLevelsImage; + image_t *fixedLevelsImage; + image_t *sunShadowDepthImage[3]; + image_t *screenShadowImage; + image_t *screenSsaoImage; + image_t *hdrDepthImage; + + image_t *textureDepthImage; + + FBO_t *renderFbo; + FBO_t *msaaResolveFbo; + FBO_t *sunRaysFbo; + FBO_t *depthFbo; + FBO_t *pshadowFbos[MAX_DRAWN_PSHADOWS]; + FBO_t *textureScratchFbo[2]; + FBO_t *screenScratchFbo; + FBO_t *quarterFbo[2]; + FBO_t *calcLevelsFbo; + FBO_t *targetLevelsFbo; + FBO_t *sunShadowFbo[3]; + FBO_t *screenShadowFbo; + FBO_t *screenSsaoFbo; + FBO_t *hdrDepthFbo; + + shader_t *defaultShader; + shader_t *shadowShader; + shader_t *projectionShadowShader; + + shader_t *flareShader; + shader_t *sunShader; + shader_t *sunFlareShader; + + int numLightmaps; + int lightmapSize; + image_t **lightmaps; + image_t **deluxemaps; + + int fatLightmapSize; + int fatLightmapStep; + + trRefEntity_t *currentEntity; + trRefEntity_t worldEntity; // point currentEntity at this when rendering world + int currentEntityNum; + int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT + model_t *currentModel; + + // + // GPU shader programs + // + shaderProgram_t genericShader[GENERICDEF_COUNT]; + shaderProgram_t textureColorShader; + shaderProgram_t fogShader[FOGDEF_COUNT]; + shaderProgram_t dlightShader[DLIGHTDEF_COUNT]; + shaderProgram_t lightallShader[LIGHTDEF_COUNT]; + shaderProgram_t shadowmapShader; + shaderProgram_t pshadowShader; + shaderProgram_t down4xShader; + shaderProgram_t bokehShader; + shaderProgram_t tonemapShader; + shaderProgram_t calclevels4xShader[2]; + shaderProgram_t shadowmaskShader; + shaderProgram_t ssaoShader; + shaderProgram_t depthBlurShader[2]; + + + // ----------------------------------------- + + viewParms_t viewParms; + + float identityLight; // 1.0 / ( 1 << overbrightBits ) + int identityLightByte; // identityLight * 255 + int overbrightBits; // r_overbrightBits->integer, but set to 0 if no hw gamma + + orientationr_t or; // for current entity + + trRefdef_t refdef; + + int viewCluster; + + float mapLightScale; + float sunShadowScale; + + qboolean sunShadows; + vec3_t sunLight; // from the sky shader for this level + vec3_t sunDirection; + + frontEndCounters_t pc; + int frontEndMsec; // not in pc due to clearing issue + + // + // put large tables at the end, so most elements will be + // within the +/32K indexed range on risc processors + // + model_t *models[MAX_MOD_KNOWN]; + int numModels; + + int numImages; + image_t *images[MAX_DRAWIMAGES]; + + int numFBOs; + FBO_t *fbos[MAX_FBOS]; + + int numVBOs; + VBO_t *vbos[MAX_VBOS]; + + int numIBOs; + IBO_t *ibos[MAX_IBOS]; + + // shader indexes from other modules will be looked up in tr.shaders[] + // shader indexes from drawsurfs will be looked up in sortedShaders[] + // lower indexed sortedShaders must be rendered first (opaque surfaces before translucent) + int numShaders; + shader_t *shaders[MAX_SHADERS]; + shader_t *sortedShaders[MAX_SHADERS]; + + int numSkins; + skin_t *skins[MAX_SKINS]; + + GLuint sunFlareQuery[2]; + int sunFlareQueryIndex; + qboolean sunFlareQueryActive[2]; + + float sinTable[FUNCTABLE_SIZE]; + float squareTable[FUNCTABLE_SIZE]; + float triangleTable[FUNCTABLE_SIZE]; + float sawToothTable[FUNCTABLE_SIZE]; + float inverseSawToothTable[FUNCTABLE_SIZE]; + float fogTable[FOG_TABLE_SIZE]; +} trGlobals_t; + +extern backEndState_t backEnd; +extern trGlobals_t tr; +extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init +extern glRefConfig_t glRefConfig; + +// +// cvars +// +extern cvar_t *r_flareSize; +extern cvar_t *r_flareFade; +// coefficient for the flare intensity falloff function. +#define FLARE_STDCOEFF "150" +extern cvar_t *r_flareCoeff; + +extern cvar_t *r_railWidth; +extern cvar_t *r_railCoreWidth; +extern cvar_t *r_railSegmentLength; + +extern cvar_t *r_ignore; // used for debugging anything +extern cvar_t *r_verbose; // used for verbose debug spew + +extern cvar_t *r_znear; // near Z clip plane +extern cvar_t *r_zproj; // z distance of projection plane +extern cvar_t *r_stereoSeparation; // separation of cameras for stereo rendering + +extern cvar_t *r_measureOverdraw; // enables stencil buffer overdraw measurement + +extern cvar_t *r_lodbias; // push/pull LOD transitions +extern cvar_t *r_lodscale; + +extern cvar_t *r_inGameVideo; // controls whether in game video should be draw +extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn +extern cvar_t *r_drawSun; // controls drawing of sun quad +extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled +extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity + +extern cvar_t *r_norefresh; // bypasses the ref rendering +extern cvar_t *r_drawentities; // disable/enable entity rendering +extern cvar_t *r_drawworld; // disable/enable world rendering +extern cvar_t *r_speeds; // various levels of information display +extern cvar_t *r_detailTextures; // enables/disables detail texturing stages +extern cvar_t *r_novis; // disable/enable usage of PVS +extern cvar_t *r_nocull; +extern cvar_t *r_facePlaneCull; // enables culling of planar surfaces with back side test +extern cvar_t *r_nocurves; +extern cvar_t *r_showcluster; + +extern cvar_t *r_gamma; + +extern cvar_t *r_ext_draw_range_elements; +extern cvar_t *r_ext_multi_draw_arrays; +extern cvar_t *r_ext_framebuffer_object; +extern cvar_t *r_ext_texture_float; +extern cvar_t *r_arb_half_float_pixel; +extern cvar_t *r_ext_framebuffer_multisample; + +extern cvar_t *r_nobind; // turns off binding to appropriate textures +extern cvar_t *r_singleShader; // make most world faces use default shader +extern cvar_t *r_roundImagesDown; +extern cvar_t *r_colorMipLevels; // development aid to see texture mip usage +extern cvar_t *r_picmip; // controls picmip values +extern cvar_t *r_finish; +extern cvar_t *r_textureMode; +extern cvar_t *r_offsetFactor; +extern cvar_t *r_offsetUnits; + +extern cvar_t *r_fullbright; // avoid lightmap pass +extern cvar_t *r_lightmap; // render lightmaps only +extern cvar_t *r_vertexLight; // vertex lighting mode for better performance +extern cvar_t *r_uiFullScreen; // ui is running fullscreen + +extern cvar_t *r_logFile; // number of frames to emit GL logs +extern cvar_t *r_showtris; // enables wireframe rendering of the world +extern cvar_t *r_showsky; // forces sky in front of all surfaces +extern cvar_t *r_shownormals; // draws wireframe normals +extern cvar_t *r_clear; // force screen clear every frame + +extern cvar_t *r_shadows; // controls shadows: 0 = none, 1 = blur, 2 = stencil, 3 = black planar projection +extern cvar_t *r_flares; // light flares + +extern cvar_t *r_intensity; + +extern cvar_t *r_lockpvs; +extern cvar_t *r_noportals; +extern cvar_t *r_portalOnly; + +extern cvar_t *r_subdivisions; +extern cvar_t *r_lodCurveError; +extern cvar_t *r_skipBackEnd; + +extern cvar_t *r_anaglyphMode; + +extern cvar_t *r_mergeMultidraws; +extern cvar_t *r_mergeLeafSurfaces; + +extern cvar_t *r_softOverbright; + +extern cvar_t *r_hdr; +extern cvar_t *r_postProcess; + +extern cvar_t *r_toneMap; +extern cvar_t *r_forceToneMap; +extern cvar_t *r_forceToneMapMin; +extern cvar_t *r_forceToneMapAvg; +extern cvar_t *r_forceToneMapMax; + +extern cvar_t *r_autoExposure; +extern cvar_t *r_forceAutoExposure; +extern cvar_t *r_forceAutoExposureMin; +extern cvar_t *r_forceAutoExposureMax; + +extern cvar_t *r_cameraExposure; + +extern cvar_t *r_srgb; + +extern cvar_t *r_depthPrepass; +extern cvar_t *r_ssao; + +extern cvar_t *r_normalMapping; +extern cvar_t *r_specularMapping; +extern cvar_t *r_deluxeMapping; +extern cvar_t *r_parallaxMapping; +extern cvar_t *r_normalAmbient; +extern cvar_t *r_dlightMode; +extern cvar_t *r_pshadowDist; +extern cvar_t *r_recalcMD3Normals; +extern cvar_t *r_mergeLightmaps; +extern cvar_t *r_imageUpsample; +extern cvar_t *r_imageUpsampleMaxSize; +extern cvar_t *r_imageUpsampleType; +extern cvar_t *r_genNormalMaps; +extern cvar_t *r_forceSun; +extern cvar_t *r_forceSunMapLightScale; +extern cvar_t *r_forceSunLightScale; +extern cvar_t *r_forceSunAmbientScale; +extern cvar_t *r_sunlightMode; +extern cvar_t *r_drawSunRays; +extern cvar_t *r_sunShadows; +extern cvar_t *r_shadowFilter; +extern cvar_t *r_shadowMapSize; +extern cvar_t *r_shadowCascadeZNear; +extern cvar_t *r_shadowCascadeZFar; +extern cvar_t *r_shadowCascadeZBias; + +extern cvar_t *r_greyscale; + +extern cvar_t *r_ignoreGLErrors; + +extern cvar_t *r_overBrightBits; +extern cvar_t *r_mapOverBrightBits; + +extern cvar_t *r_debugSurface; +extern cvar_t *r_simpleMipMaps; + +extern cvar_t *r_showImages; +extern cvar_t *r_debugSort; + +extern cvar_t *r_printShaders; + +extern cvar_t *r_marksOnTriangleMeshes; + +//==================================================================== + +void R_SwapBuffers( int ); + +void R_RenderView( viewParms_t *parms ); +void R_RenderDlightCubemaps(const refdef_t *fd); +void R_RenderPshadowMaps(const refdef_t *fd); +void R_RenderSunShadowMaps(const refdef_t *fd, int level); + +void R_AddMD3Surfaces( trRefEntity_t *e ); +void R_AddNullModelSurfaces( trRefEntity_t *e ); +void R_AddBeamSurfaces( trRefEntity_t *e ); +void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); +void R_AddLightningBoltSurfaces( trRefEntity_t *e ); + +void R_AddPolygonSurfaces( void ); + +void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, + int *fogNum, int *dlightMap, int *pshadowMap ); + +void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, + int fogIndex, int dlightMap, int pshadowMap ); + +void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal, + const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2); +qboolean R_CalcTangentVectors(srfVert_t * dv[3]); +void R_CalcSurfaceTriangleNeighbors(int numTriangles, srfTriangle_t * triangles); +void R_CalcSurfaceTrianglePlanes(int numTriangles, srfTriangle_t * triangles, srfVert_t * verts); + +#define CULL_IN 0 // completely unclipped +#define CULL_CLIP 1 // clipped by one or more planes +#define CULL_OUT 2 // completely outside the clipping planes +void R_LocalNormalToWorld (const vec3_t local, vec3_t world); +void R_LocalPointToWorld (const vec3_t local, vec3_t world); +int R_CullBox (vec3_t bounds[2]); +int R_CullLocalBox (vec3_t bounds[2]); +int R_CullPointAndRadiusEx( const vec3_t origin, float radius, const cplane_t* frustum, int numPlanes ); +int R_CullPointAndRadius( const vec3_t origin, float radius ); +int R_CullLocalPointAndRadius( const vec3_t origin, float radius ); + +void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum); +void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *or ); + +/* +** GL wrapper/helper functions +*/ +void GL_Bind( image_t *image ); +void GL_BindCubemap( image_t *image ); +void GL_BindToTMU( image_t *image, int tmu ); +void GL_SetDefaultState (void); +void GL_SelectTexture( int unit ); +void GL_TextureMode( const char *string ); +void GL_CheckErrs( char *file, int line ); +#define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__) +void GL_State( unsigned long stateVector ); +void GL_SetProjectionMatrix(matrix_t matrix); +void GL_SetModelviewMatrix(matrix_t matrix); +void GL_TexEnv( int env ); +void GL_Cull( int cullType ); + +#define GLS_SRCBLEND_ZERO 0x00000001 +#define GLS_SRCBLEND_ONE 0x00000002 +#define GLS_SRCBLEND_DST_COLOR 0x00000003 +#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004 +#define GLS_SRCBLEND_SRC_ALPHA 0x00000005 +#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006 +#define GLS_SRCBLEND_DST_ALPHA 0x00000007 +#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008 +#define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009 +#define GLS_SRCBLEND_BITS 0x0000000f + +#define GLS_DSTBLEND_ZERO 0x00000010 +#define GLS_DSTBLEND_ONE 0x00000020 +#define GLS_DSTBLEND_SRC_COLOR 0x00000030 +#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040 +#define GLS_DSTBLEND_SRC_ALPHA 0x00000050 +#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060 +#define GLS_DSTBLEND_DST_ALPHA 0x00000070 +#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080 +#define GLS_DSTBLEND_BITS 0x000000f0 + +#define GLS_DEPTHMASK_TRUE 0x00000100 + +#define GLS_POLYMODE_LINE 0x00001000 + +#define GLS_DEPTHTEST_DISABLE 0x00010000 +#define GLS_DEPTHFUNC_EQUAL 0x00020000 +#define GLS_DEPTHFUNC_GREATER 0x00040000 +#define GLS_DEPTHFUNC_BITS 0x00060000 + +#define GLS_ATEST_GT_0 0x10000000 +#define GLS_ATEST_LT_80 0x20000000 +#define GLS_ATEST_GE_80 0x40000000 +#define GLS_ATEST_BITS 0x70000000 + +#define GLS_DEFAULT GLS_DEPTHMASK_TRUE + +void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); +void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); + +void RE_BeginFrame( stereoFrame_t stereoFrame ); +void RE_BeginRegistration( glconfig_t *glconfig ); +void RE_LoadWorldMap( const char *mapname ); +void RE_SetWorldVisData( const byte *vis ); +qhandle_t RE_RegisterModel( const char *name ); +qhandle_t RE_RegisterSkin( const char *name ); +void RE_Shutdown( qboolean destroyWindow ); + +qboolean R_GetEntityToken( char *buffer, int size ); + +model_t *R_AllocModel( void ); + +void R_Init( void ); +void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int height ); + +void R_SetColorMappings( void ); +void R_GammaCorrect( byte *buffer, int bufSize ); + +void R_ImageList_f( void ); +void R_SkinList_f( void ); +// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 +const void *RB_TakeScreenshotCmd( const void *data ); +void R_ScreenShot_f( void ); + +void R_InitFogTable( void ); +float R_FogFactor( float s, float t ); +void R_InitImages( void ); +void R_DeleteTextures( void ); +int R_SumOfUsedImages( void ); +void R_InitSkins( void ); +skin_t *R_GetSkinByHandle( qhandle_t hSkin ); + +int R_ComputeLOD( trRefEntity_t *ent ); + +const void *RB_TakeVideoFrameCmd( const void *data ); + +// +// tr_shader.c +// +shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ); +shader_t *R_GetShaderByHandle( qhandle_t hShader ); +shader_t *R_GetShaderByState( int index, long *cycleTime ); +shader_t *R_FindShaderByName( const char *name ); +void R_InitShaders( void ); +void R_ShaderList_f( void ); +void R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset); + +/* +==================================================================== + +IMPLEMENTATION SPECIFIC FUNCTIONS + +==================================================================== +*/ + +void GLimp_InitExtraExtensions( void ); + +/* +==================================================================== + +TESSELATOR/SHADER DECLARATIONS + +==================================================================== +*/ + +typedef struct stageVars +{ + color4ub_t colors[SHADER_MAX_VERTEXES]; + vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES]; +} stageVars_t; + +#define MAX_MULTIDRAW_PRIMITIVES 16384 + +typedef struct shaderCommands_s +{ + glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); + vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); + vec4_t normal[SHADER_MAX_VERTEXES] QALIGN(16); +#ifdef USE_VERT_TANGENT_SPACE + vec4_t tangent[SHADER_MAX_VERTEXES] QALIGN(16); + vec4_t bitangent[SHADER_MAX_VERTEXES] QALIGN(16); +#endif + vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); + vec4_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16); + vec4_t lightdir[SHADER_MAX_VERTEXES] QALIGN(16); + //int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); + + VBO_t *vbo; + IBO_t *ibo; + qboolean useInternalVBO; + + stageVars_t svars QALIGN(16); + + //color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); + + shader_t *shader; + float shaderTime; + int fogNum; + + int dlightBits; // or together of all vertexDlightBits + int pshadowBits; + + int firstIndex; + int numIndexes; + int numVertexes; + glIndex_t minIndex; + glIndex_t maxIndex; + + int multiDrawPrimitives; + GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES]; + glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES]; + glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES]; + glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES]; + glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES]; + + // info extracted from current shader + int numPasses; + void (*currentStageIteratorFunc)( void ); + shaderStage_t **xstages; +} shaderCommands_t; + +extern shaderCommands_t tess; + +void RB_BeginSurface(shader_t *shader, int fogNum ); +void RB_EndSurface(void); +void RB_CheckOverflow( int verts, int indexes ); +#define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);} + +void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ); +void RB_StageIteratorGeneric( void ); +void RB_StageIteratorSky( void ); +void RB_StageIteratorVertexLitTexture( void ); +void RB_StageIteratorLightmappedMultitexture( void ); + +void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, float color[4] ); +void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], float s1, float t1, float s2, float t2 ); +void RB_InstantQuad( vec4_t quadVerts[4] ); +//void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4], vec4_t color, shaderProgram_t *sp, vec2_t invTexRes); +void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]); + +void RB_ShowImages( void ); + + +/* +============================================================ + +WORLD MAP + +============================================================ +*/ + +void R_AddBrushModelSurfaces( trRefEntity_t *e ); +void R_AddWorldSurfaces( void ); +qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ); + + +/* +============================================================ + +FLARES + +============================================================ +*/ + +void R_ClearFlares( void ); + +void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t normal ); +void RB_AddDlightFlares( void ); +void RB_RenderFlares (void); + +/* +============================================================ + +LIGHTS + +============================================================ +*/ + +void R_DlightBmodel( bmodel_t *bmodel ); +void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); +void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or ); +int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); +int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); + + +/* +============================================================ + +SHADOWS + +============================================================ +*/ + +void RB_ShadowTessEnd( void ); +void RB_ShadowFinish( void ); +void RB_ProjectionShadowDeform( void ); + +/* +============================================================ + +SKIES + +============================================================ +*/ + +void R_BuildCloudData( shaderCommands_t *shader ); +void R_InitSkyTexCoords( float cloudLayerHeight ); +void R_DrawSkyBox( shaderCommands_t *shader ); +void RB_DrawSun( float scale, shader_t *shader ); +void RB_ClipSkyPolygons( shaderCommands_t *shader ); + +/* +============================================================ + +CURVE TESSELATION + +============================================================ +*/ + +#define PATCH_STITCHING + +srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, + srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ); +srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ); +srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ); +void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ); + +/* +============================================================ + +MARKERS, POLYGON PROJECTION ON WORLD POLYGONS + +============================================================ +*/ + +int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, + int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); + + +/* +============================================================ + +VERTEX BUFFER OBJECTS + +============================================================ +*/ +VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, vboUsage_t usage); +VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vertexes, uint32_t stateBits, vboUsage_t usage); + +IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, vboUsage_t usage); +IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * triangles, vboUsage_t usage); + +void R_BindVBO(VBO_t * vbo); +void R_BindNullVBO(void); + +void R_BindIBO(IBO_t * ibo); +void R_BindNullIBO(void); + +void R_InitVBOs(void); +void R_ShutdownVBOs(void); +void R_VBOList_f(void); + +void RB_UpdateVBOs(unsigned int attribBits); + + +/* +============================================================ + +GLSL + +============================================================ +*/ + +void GLSL_InitGPUShaders(void); +void GLSL_ShutdownGPUShaders(void); +void GLSL_VertexAttribsState(uint32_t stateBits); +void GLSL_VertexAttribPointers(uint32_t attribBits); +void GLSL_BindProgram(shaderProgram_t * program); +void GLSL_BindNullProgram(void); + +void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value); +void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value); +void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v); +void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); +void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); +void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const matrix_t matrix); + +shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); + +/* +============================================================ + +SCENE GENERATION + +============================================================ +*/ + +void R_InitNextFrame( void ); + +void RE_ClearScene( void ); +void RE_AddRefEntityToScene( const refEntity_t *ent ); +void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); +void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); +void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); +void RE_RenderScene( const refdef_t *fd ); + +/* +============================================================= + +UNCOMPRESSING BONES + +============================================================= +*/ + +#define MC_BITS_X (16) +#define MC_BITS_Y (16) +#define MC_BITS_Z (16) +#define MC_BITS_VECT (16) + +#define MC_SCALE_X (1.0f/64) +#define MC_SCALE_Y (1.0f/64) +#define MC_SCALE_Z (1.0f/64) + +void MC_UnCompress(float mat[3][4],const unsigned char * comp); + +/* +============================================================= + +ANIMATED MODELS + +============================================================= +*/ + +// void R_MakeAnimModel( model_t *model ); haven't seen this one really, so not needed I guess. +void R_AddAnimSurfaces( trRefEntity_t *ent ); +void RB_SurfaceAnim( md4Surface_t *surfType ); +void R_MDRAddAnimSurfaces( trRefEntity_t *ent ); +void RB_MDRSurfaceAnim( md4Surface_t *surface ); +qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name ); +void R_AddIQMSurfaces( trRefEntity_t *ent ); +void RB_IQMSurfaceAnim( surfaceType_t *surface ); +int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, + int startFrame, int endFrame, + float frac, const char *tagName ); + +/* +============================================================= + +IMAGE LOADERS + +============================================================= +*/ + +void R_LoadBMP( const char *name, byte **pic, int *width, int *height ); +void R_LoadJPG( const char *name, byte **pic, int *width, int *height ); +void R_LoadPCX( const char *name, byte **pic, int *width, int *height ); +void R_LoadPNG( const char *name, byte **pic, int *width, int *height ); +void R_LoadTGA( const char *name, byte **pic, int *width, int *height ); + +/* +============================================================= +============================================================= +*/ +void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, + vec4_t eye, vec4_t dst ); +void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ); + +void RB_DeformTessGeometry( void ); + +void RB_CalcEnvironmentTexCoords( float *dstTexCoords ); +void RB_CalcFogTexCoords( float *dstTexCoords ); +void RB_CalcScrollTexCoords( const float scroll[2], float *dstTexCoords ); +void RB_CalcRotateTexCoords( float rotSpeed, float *dstTexCoords ); +void RB_CalcScaleTexCoords( const float scale[2], float *dstTexCoords ); +void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *dstTexCoords ); +void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords ); + +void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ); +void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ); +void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ); +void RB_CalcTurbulentTexMatrix( const waveForm_t *wf, matrix_t matrix ); +void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ); +void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ); + +void RB_CalcModulateColorsByFog( unsigned char *dstColors ); +void RB_CalcModulateAlphasByFog( unsigned char *dstColors ); +void RB_CalcModulateRGBAsByFog( unsigned char *dstColors ); +void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors ); +float RB_CalcWaveAlphaSingle( const waveForm_t *wf ); +void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ); +float RB_CalcWaveColorSingle( const waveForm_t *wf ); +void RB_CalcAlphaFromEntity( unsigned char *dstColors ); +void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors ); +void RB_CalcStretchTexCoords( const waveForm_t *wf, float *texCoords ); +void RB_CalcColorFromEntity( unsigned char *dstColors ); +void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors ); +void RB_CalcSpecularAlpha( unsigned char *alphas ); +void RB_CalcDiffuseColor( unsigned char *colors ); + +/* +============================================================= + +RENDERER BACK END FUNCTIONS + +============================================================= +*/ + +void RB_ExecuteRenderCommands( const void *data ); + +/* +============================================================= + +RENDERER BACK END COMMAND QUEUE + +============================================================= +*/ + +#define MAX_RENDER_COMMANDS 0x40000 + +typedef struct { + byte cmds[MAX_RENDER_COMMANDS]; + int used; +} renderCommandList_t; + +typedef struct { + int commandId; + float color[4]; +} setColorCommand_t; + +typedef struct { + int commandId; + int buffer; +} drawBufferCommand_t; + +typedef struct { + int commandId; + image_t *image; + int width; + int height; + void *data; +} subImageCommand_t; + +typedef struct { + int commandId; +} swapBuffersCommand_t; + +typedef struct { + int commandId; + int buffer; +} endFrameCommand_t; + +typedef struct { + int commandId; + shader_t *shader; + float x, y; + float w, h; + float s1, t1; + float s2, t2; +} stretchPicCommand_t; + +typedef struct { + int commandId; + trRefdef_t refdef; + viewParms_t viewParms; + drawSurf_t *drawSurfs; + int numDrawSurfs; +} drawSurfsCommand_t; + +typedef struct { + int commandId; + int x; + int y; + int width; + int height; + char *fileName; + qboolean jpeg; +} screenshotCommand_t; + +typedef struct { + int commandId; + int width; + int height; + byte *captureBuffer; + byte *encodeBuffer; + qboolean motionJpeg; +} videoFrameCommand_t; + +typedef struct +{ + int commandId; + + GLboolean rgba[4]; +} colorMaskCommand_t; + +typedef struct +{ + int commandId; +} clearDepthCommand_t; + +typedef struct { + int commandId; + int map; + int cubeSide; +} capShadowmapCommand_t; + +typedef struct { + int commandId; + trRefdef_t refdef; + viewParms_t viewParms; +} postProcessCommand_t; + +typedef enum { + RC_END_OF_LIST, + RC_SET_COLOR, + RC_STRETCH_PIC, + RC_DRAW_SURFS, + RC_DRAW_BUFFER, + RC_SWAP_BUFFERS, + RC_SCREENSHOT, + RC_VIDEOFRAME, + RC_COLORMASK, + RC_CLEARDEPTH, + RC_CAPSHADOWMAP, + RC_POSTPROCESS +} renderCommand_t; + + +// these are sort of arbitrary limits. +// the limits apply to the sum of all scenes in a frame -- +// the main view, all the 3D icons, etc +#define MAX_POLYS 600 +#define MAX_POLYVERTS 3000 + +// all of the information needed by the back end must be +// contained in a backEndData_t +typedef struct { + drawSurf_t drawSurfs[MAX_DRAWSURFS]; + dlight_t dlights[MAX_DLIGHTS]; + trRefEntity_t entities[MAX_REFENTITIES]; + srfPoly_t *polys;//[MAX_POLYS]; + polyVert_t *polyVerts;//[MAX_POLYVERTS]; + pshadow_t pshadows[MAX_CALC_PSHADOWS]; + renderCommandList_t commands; +} backEndData_t; + +extern int max_polys; +extern int max_polyverts; + +extern backEndData_t *backEndData; // the second one may not be allocated + + +void *R_GetCommandBuffer( int bytes ); +void RB_ExecuteRenderCommands( const void *data ); + +void R_IssuePendingRenderCommands( void ); + +void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); +void R_AddCapShadowmapCmd( int dlight, int cubeSide ); +void R_AddPostProcessCmd (void); + +void RE_SetColor( const float *rgba ); +void RE_StretchPic ( float x, float y, float w, float h, + float s1, float t1, float s2, float t2, qhandle_t hShader ); +void RE_BeginFrame( stereoFrame_t stereoFrame ); +void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); +void RE_SaveJPG(char * filename, int quality, int image_width, int image_height, + unsigned char *image_buffer, int padding); +size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, + int image_width, int image_height, byte *image_buffer, int padding); +void RE_TakeVideoFrame( int width, int height, + byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); + + +#endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.c b/codemp/rd-rend2/tr_main.c new file mode 100644 index 0000000000..b67c5fa480 --- /dev/null +++ b/codemp/rd-rend2/tr_main.c @@ -0,0 +1,2876 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_main.c -- main control flow for each frame + +#include "tr_local.h" + +#include // memcpy + +trGlobals_t tr; + +static float s_flipMatrix[16] = { + // convert from our coordinate system (looking down X) + // to OpenGL's coordinate system (looking down -Z) + 0, 0, -1, 0, + -1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 0, 1 +}; + + +refimport_t ri; + +// entities that will have procedurally generated surfaces will just +// point at this for their sorting surface +surfaceType_t entitySurface = SF_ENTITY; + +/* +================ +R_CompareVert +================ +*/ +qboolean R_CompareVert(srfVert_t * v1, srfVert_t * v2, qboolean checkST) +{ + int i; + + for(i = 0; i < 3; i++) + { + if(floor(v1->xyz[i] + 0.1) != floor(v2->xyz[i] + 0.1)) + { + return qfalse; + } + + if(checkST && ((v1->st[0] != v2->st[0]) || (v1->st[1] != v2->st[1]))) + { + return qfalse; + } + } + + return qtrue; +} + +/* +============= +R_CalcNormalForTriangle +============= +*/ +void R_CalcNormalForTriangle(vec3_t normal, const vec3_t v0, const vec3_t v1, const vec3_t v2) +{ + vec3_t udir, vdir; + + // compute the face normal based on vertex points + VectorSubtract(v2, v0, udir); + VectorSubtract(v1, v0, vdir); + CrossProduct(udir, vdir, normal); + + VectorNormalize(normal); +} + +/* +============= +R_CalcTangentsForTriangle +http://members.rogers.com/deseric/tangentspace.htm +============= +*/ +void R_CalcTangentsForTriangle(vec3_t tangent, vec3_t bitangent, + const vec3_t v0, const vec3_t v1, const vec3_t v2, + const vec2_t t0, const vec2_t t1, const vec2_t t2) +{ + int i; + vec3_t planes[3]; + vec3_t u, v; + + for(i = 0; i < 3; i++) + { + VectorSet(u, v1[i] - v0[i], t1[0] - t0[0], t1[1] - t0[1]); + VectorSet(v, v2[i] - v0[i], t2[0] - t0[0], t2[1] - t0[1]); + + VectorNormalize(u); + VectorNormalize(v); + + CrossProduct(u, v, planes[i]); + } + + //So your tangent space will be defined by this : + //Normal = Normal of the triangle or Tangent X Bitangent (careful with the cross product, + // you have to make sure the normal points in the right direction) + //Tangent = ( dp(Fx(s,t)) / ds, dp(Fy(s,t)) / ds, dp(Fz(s,t)) / ds ) or ( -Bx/Ax, -By/Ay, - Bz/Az ) + //Bitangent = ( dp(Fx(s,t)) / dt, dp(Fy(s,t)) / dt, dp(Fz(s,t)) / dt ) or ( -Cx/Ax, -Cy/Ay, -Cz/Az ) + + // tangent... + tangent[0] = -planes[0][1] / planes[0][0]; + tangent[1] = -planes[1][1] / planes[1][0]; + tangent[2] = -planes[2][1] / planes[2][0]; + VectorNormalize(tangent); + + // bitangent... + bitangent[0] = -planes[0][2] / planes[0][0]; + bitangent[1] = -planes[1][2] / planes[1][0]; + bitangent[2] = -planes[2][2] / planes[2][0]; + VectorNormalize(bitangent); +} + + + + +/* +============= +R_CalcTangentSpace +============= +*/ +void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal, + const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2) +{ + vec3_t cp, u, v; + vec3_t faceNormal; + + VectorSet(u, v1[0] - v0[0], t1[0] - t0[0], t1[1] - t0[1]); + VectorSet(v, v2[0] - v0[0], t2[0] - t0[0], t2[1] - t0[1]); + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[0] = -cp[1] / cp[0]; + bitangent[0] = -cp[2] / cp[0]; + } + + u[0] = v1[1] - v0[1]; + v[0] = v2[1] - v0[1]; + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[1] = -cp[1] / cp[0]; + bitangent[1] = -cp[2] / cp[0]; + } + + u[0] = v1[2] - v0[2]; + v[0] = v2[2] - v0[2]; + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[2] = -cp[1] / cp[0]; + bitangent[2] = -cp[2] / cp[0]; + } + + VectorNormalize(tangent); + VectorNormalize(bitangent); + + // compute the face normal based on vertex points + if ( normal[0] == 0.0f && normal[1] == 0.0f && normal[2] == 0.0f ) + { + VectorSubtract(v2, v0, u); + VectorSubtract(v1, v0, v); + CrossProduct(u, v, faceNormal); + } + else + { + VectorCopy(normal, faceNormal); + } + + VectorNormalize(faceNormal); + +#if 1 + // Gram-Schmidt orthogonalize + //tangent[a] = (t - n * Dot(n, t)).Normalize(); + VectorMA(tangent, -DotProduct(faceNormal, tangent), faceNormal, tangent); + VectorNormalize(tangent); + + // compute the cross product B=NxT + //CrossProduct(normal, tangent, bitangent); +#else + // normal, compute the cross product N=TxB + CrossProduct(tangent, bitangent, normal); + VectorNormalize(normal); + + if(DotProduct(normal, faceNormal) < 0) + { + //VectorInverse(normal); + //VectorInverse(tangent); + //VectorInverse(bitangent); + + // compute the cross product T=BxN + CrossProduct(bitangent, faceNormal, tangent); + + // compute the cross product B=NxT + //CrossProduct(normal, tangent, bitangent); + } +#endif + + VectorCopy(faceNormal, normal); +} + +void R_CalcTangentSpaceFast(vec3_t tangent, vec3_t bitangent, vec3_t normal, + const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2) +{ + vec3_t cp, u, v; + vec3_t faceNormal; + + VectorSet(u, v1[0] - v0[0], t1[0] - t0[0], t1[1] - t0[1]); + VectorSet(v, v2[0] - v0[0], t2[0] - t0[0], t2[1] - t0[1]); + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[0] = -cp[1] / cp[0]; + bitangent[0] = -cp[2] / cp[0]; + } + + u[0] = v1[1] - v0[1]; + v[0] = v2[1] - v0[1]; + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[1] = -cp[1] / cp[0]; + bitangent[1] = -cp[2] / cp[0]; + } + + u[0] = v1[2] - v0[2]; + v[0] = v2[2] - v0[2]; + + CrossProduct(u, v, cp); + if(fabs(cp[0]) > 10e-6) + { + tangent[2] = -cp[1] / cp[0]; + bitangent[2] = -cp[2] / cp[0]; + } + + VectorNormalizeFast(tangent); + VectorNormalizeFast(bitangent); + + // compute the face normal based on vertex points + VectorSubtract(v2, v0, u); + VectorSubtract(v1, v0, v); + CrossProduct(u, v, faceNormal); + + VectorNormalizeFast(faceNormal); + +#if 0 + // normal, compute the cross product N=TxB + CrossProduct(tangent, bitangent, normal); + VectorNormalizeFast(normal); + + if(DotProduct(normal, faceNormal) < 0) + { + VectorInverse(normal); + //VectorInverse(tangent); + //VectorInverse(bitangent); + + CrossProduct(normal, tangent, bitangent); + } + + VectorCopy(faceNormal, normal); +#else + // Gram-Schmidt orthogonalize + //tangent[a] = (t - n * Dot(n, t)).Normalize(); + VectorMA(tangent, -DotProduct(faceNormal, tangent), faceNormal, tangent); + VectorNormalizeFast(tangent); +#endif + + VectorCopy(faceNormal, normal); +} + +/* +http://www.terathon.com/code/tangent.html +*/ +void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t normal, + const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3) +{ + vec3_t u, v; + float x1, x2, y1, y2, z1, z2; + float s1, s2, t1, t2; + float r, dot; + + x1 = v2[0] - v1[0]; + x2 = v3[0] - v1[0]; + y1 = v2[1] - v1[1]; + y2 = v3[1] - v1[1]; + z1 = v2[2] - v1[2]; + z2 = v3[2] - v1[2]; + + s1 = w2[0] - w1[0]; + s2 = w3[0] - w1[0]; + t1 = w2[1] - w1[1]; + t2 = w3[1] - w1[1]; + + r = 1.0f / (s1 * t2 - s2 * t1); + + VectorSet(tangent, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); + VectorSet(bitangent, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); + + // compute the face normal based on vertex points + VectorSubtract(v3, v1, u); + VectorSubtract(v2, v1, v); + CrossProduct(u, v, normal); + + VectorNormalize(normal); + + // Gram-Schmidt orthogonalize + //tangent[a] = (t - n * Dot(n, t)).Normalize(); + dot = DotProduct(normal, tangent); + VectorMA(tangent, -dot, normal, tangent); + VectorNormalize(tangent); + + // B=NxT + //CrossProduct(normal, tangent, bitangent); +} + +void R_CalcTBN2(vec3_t tangent, vec3_t bitangent, vec3_t normal, + const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t t1, const vec2_t t2, const vec2_t t3) +{ + vec3_t v2v1; + vec3_t v3v1; + + float c2c1_T; + float c2c1_B; + + float c3c1_T; + float c3c1_B; + + float denominator; + float scale1, scale2; + + vec3_t T, B, N, C; + + + // Calculate the tangent basis for each vertex of the triangle + // UPDATE: In the 3rd edition of the accompanying article, the for-loop located here has + // been removed as it was redundant (the entire TBN matrix was calculated three times + // instead of just one). + // + // Please note, that this function relies on the fact that the input geometry are triangles + // and the tangent basis for each vertex thus is identical! + // + + // Calculate the vectors from the current vertex to the two other vertices in the triangle + VectorSubtract(v2, v1, v2v1); + VectorSubtract(v3, v1, v3v1); + + // The equation presented in the article states that: + // c2c1_T = V2.texcoord.x - V1.texcoord.x + // c2c1_B = V2.texcoord.y - V1.texcoord.y + // c3c1_T = V3.texcoord.x - V1.texcoord.x + // c3c1_B = V3.texcoord.y - V1.texcoord.y + + // Calculate c2c1_T and c2c1_B + c2c1_T = t2[0] - t1[0]; + c2c1_B = t2[1] - t2[1]; + + // Calculate c3c1_T and c3c1_B + c3c1_T = t3[0] - t1[0]; + c3c1_B = t3[1] - t1[1]; + + denominator = c2c1_T * c3c1_B - c3c1_T * c2c1_B; + //if(ROUNDOFF(fDenominator) == 0.0f) + if(denominator == 0.0f) + { + // We won't risk a divide by zero, so set the tangent matrix to the identity matrix + VectorSet(tangent, 1, 0, 0); + VectorSet(bitangent, 0, 1, 0); + VectorSet(normal, 0, 0, 1); + } + else + { + // Calculate the reciprocal value once and for all (to achieve speed) + scale1 = 1.0f / denominator; + + // T and B are calculated just as the equation in the article states + VectorSet(T, (c3c1_B * v2v1[0] - c2c1_B * v3v1[0]) * scale1, + (c3c1_B * v2v1[1] - c2c1_B * v3v1[1]) * scale1, + (c3c1_B * v2v1[2] - c2c1_B * v3v1[2]) * scale1); + + VectorSet(B, (-c3c1_T * v2v1[0] + c2c1_T * v3v1[0]) * scale1, + (-c3c1_T * v2v1[1] + c2c1_T * v3v1[1]) * scale1, + (-c3c1_T * v2v1[2] + c2c1_T * v3v1[2]) * scale1); + + // The normal N is calculated as the cross product between T and B + CrossProduct(T, B, N); + +#if 0 + VectorCopy(T, tangent); + VectorCopy(B, bitangent); + VectorCopy(N, normal); +#else + // Calculate the reciprocal value once and for all (to achieve speed) + scale2 = 1.0f / ((T[0] * B[1] * N[2] - T[2] * B[1] * N[0]) + + (B[0] * N[1] * T[2] - B[2] * N[1] * T[0]) + + (N[0] * T[1] * B[2] - N[2] * T[1] * B[0])); + + // Calculate the inverse if the TBN matrix using the formula described in the article. + // We store the basis vectors directly in the provided TBN matrix: pvTBNMatrix + CrossProduct(B, N, C); tangent[0] = C[0] * scale2; + CrossProduct(N, T, C); tangent[1] = -C[0] * scale2; + CrossProduct(T, B, C); tangent[2] = C[0] * scale2; + VectorNormalize(tangent); + + CrossProduct(B, N, C); bitangent[0] = -C[1] * scale2; + CrossProduct(N, T, C); bitangent[1] = C[1] * scale2; + CrossProduct(T, B, C); bitangent[2] = -C[1] * scale2; + VectorNormalize(bitangent); + + CrossProduct(B, N, C); normal[0] = C[2] * scale2; + CrossProduct(N, T, C); normal[1] = -C[2] * scale2; + CrossProduct(T, B, C); normal[2] = C[2] * scale2; + VectorNormalize(normal); +#endif + } +} + + +#ifdef USE_VERT_TANGENT_SPACE +qboolean R_CalcTangentVectors(srfVert_t * dv[3]) +{ + int i; + float bb, s, t; + vec3_t bary; + + + /* calculate barycentric basis for the triangle */ + bb = (dv[1]->st[0] - dv[0]->st[0]) * (dv[2]->st[1] - dv[0]->st[1]) - (dv[2]->st[0] - dv[0]->st[0]) * (dv[1]->st[1] - dv[0]->st[1]); + if(fabs(bb) < 0.00000001f) + return qfalse; + + /* do each vertex */ + for(i = 0; i < 3; i++) + { + // calculate s tangent vector + s = dv[i]->st[0] + 10.0f; + t = dv[i]->st[1]; + bary[0] = ((dv[1]->st[0] - s) * (dv[2]->st[1] - t) - (dv[2]->st[0] - s) * (dv[1]->st[1] - t)) / bb; + bary[1] = ((dv[2]->st[0] - s) * (dv[0]->st[1] - t) - (dv[0]->st[0] - s) * (dv[2]->st[1] - t)) / bb; + bary[2] = ((dv[0]->st[0] - s) * (dv[1]->st[1] - t) - (dv[1]->st[0] - s) * (dv[0]->st[1] - t)) / bb; + + dv[i]->tangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; + dv[i]->tangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; + dv[i]->tangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; + + VectorSubtract(dv[i]->tangent, dv[i]->xyz, dv[i]->tangent); + VectorNormalize(dv[i]->tangent); + + // calculate t tangent vector + s = dv[i]->st[0]; + t = dv[i]->st[1] + 10.0f; + bary[0] = ((dv[1]->st[0] - s) * (dv[2]->st[1] - t) - (dv[2]->st[0] - s) * (dv[1]->st[1] - t)) / bb; + bary[1] = ((dv[2]->st[0] - s) * (dv[0]->st[1] - t) - (dv[0]->st[0] - s) * (dv[2]->st[1] - t)) / bb; + bary[2] = ((dv[0]->st[0] - s) * (dv[1]->st[1] - t) - (dv[1]->st[0] - s) * (dv[0]->st[1] - t)) / bb; + + dv[i]->bitangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; + dv[i]->bitangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; + dv[i]->bitangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; + + VectorSubtract(dv[i]->bitangent, dv[i]->xyz, dv[i]->bitangent); + VectorNormalize(dv[i]->bitangent); + + // debug code + //% Sys_FPrintf( SYS_VRB, "%d S: (%f %f %f) T: (%f %f %f)\n", i, + //% stv[ i ][ 0 ], stv[ i ][ 1 ], stv[ i ][ 2 ], ttv[ i ][ 0 ], ttv[ i ][ 1 ], ttv[ i ][ 2 ] ); + } + + return qtrue; +} +#endif + + +/* +================= +R_FindSurfaceTriangleWithEdge + +Recoded from Q2E +================= +*/ +static int R_FindSurfaceTriangleWithEdge(int numTriangles, srfTriangle_t * triangles, int start, int end, int ignore) +{ + srfTriangle_t *tri; + int count, match; + int i; + + count = 0; + match = -1; + + for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + { + if((tri->indexes[0] == start && tri->indexes[1] == end) || + (tri->indexes[1] == start && tri->indexes[2] == end) || (tri->indexes[2] == start && tri->indexes[0] == end)) + { + if(i != ignore) + { + match = i; + } + + count++; + } + else if((tri->indexes[1] == start && tri->indexes[0] == end) || + (tri->indexes[2] == start && tri->indexes[1] == end) || (tri->indexes[0] == start && tri->indexes[2] == end)) + { + count++; + } + } + + // detect edges shared by three triangles and make them seams + if(count > 2) + { + match = -1; + } + + return match; +} + + +/* +================= +R_CalcSurfaceTriangleNeighbors + +Recoded from Q2E +================= +*/ +void R_CalcSurfaceTriangleNeighbors(int numTriangles, srfTriangle_t * triangles) +{ + int i; + srfTriangle_t *tri; + + for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + { + tri->neighbors[0] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[1], tri->indexes[0], i); + tri->neighbors[1] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[2], tri->indexes[1], i); + tri->neighbors[2] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[0], tri->indexes[2], i); + } +} + +/* +================= +R_CalcSurfaceTrianglePlanes +================= +*/ +void R_CalcSurfaceTrianglePlanes(int numTriangles, srfTriangle_t * triangles, srfVert_t * verts) +{ + int i; + srfTriangle_t *tri; + + for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + { + float *v1, *v2, *v3; + vec3_t d1, d2; + + v1 = verts[tri->indexes[0]].xyz; + v2 = verts[tri->indexes[1]].xyz; + v3 = verts[tri->indexes[2]].xyz; + + VectorSubtract(v2, v1, d1); + VectorSubtract(v3, v1, d2); + + CrossProduct(d2, d1, tri->plane); + tri->plane[3] = DotProduct(tri->plane, v1); + } +} + + +/* +================= +R_CullLocalBox + +Returns CULL_IN, CULL_CLIP, or CULL_OUT +================= +*/ +int R_CullLocalBox(vec3_t localBounds[2]) { +#if 0 + int i, j; + vec3_t transformed[8]; + float dists[8]; + vec3_t v; + cplane_t *frust; + int anyBack; + int front, back; + + if ( r_nocull->integer ) { + return CULL_CLIP; + } + + // transform into world space + for (i = 0 ; i < 8 ; i++) { + v[0] = bounds[i&1][0]; + v[1] = bounds[(i>>1)&1][1]; + v[2] = bounds[(i>>2)&1][2]; + + VectorCopy( tr.or.origin, transformed[i] ); + VectorMA( transformed[i], v[0], tr.or.axis[0], transformed[i] ); + VectorMA( transformed[i], v[1], tr.or.axis[1], transformed[i] ); + VectorMA( transformed[i], v[2], tr.or.axis[2], transformed[i] ); + } + + // check against frustum planes + anyBack = 0; + for (i = 0 ; i < 4 ; i++) { + frust = &tr.viewParms.frustum[i]; + + front = back = 0; + for (j = 0 ; j < 8 ; j++) { + dists[j] = DotProduct(transformed[j], frust->normal); + if ( dists[j] > frust->dist ) { + front = 1; + if ( back ) { + break; // a point is in front + } + } else { + back = 1; + } + } + if ( !front ) { + // all points were behind one of the planes + return CULL_OUT; + } + anyBack |= back; + } + + if ( !anyBack ) { + return CULL_IN; // completely inside frustum + } + + return CULL_CLIP; // partially clipped +#else + int j; + vec3_t transformed; + vec3_t v; + vec3_t worldBounds[2]; + + if(r_nocull->integer) + { + return CULL_CLIP; + } + + // transform into world space + ClearBounds(worldBounds[0], worldBounds[1]); + + for(j = 0; j < 8; j++) + { + v[0] = localBounds[j & 1][0]; + v[1] = localBounds[(j >> 1) & 1][1]; + v[2] = localBounds[(j >> 2) & 1][2]; + + R_LocalPointToWorld(v, transformed); + + AddPointToBounds(transformed, worldBounds[0], worldBounds[1]); + } + + return R_CullBox(worldBounds); +#endif +} + +/* +================= +R_CullBox + +Returns CULL_IN, CULL_CLIP, or CULL_OUT +================= +*/ +int R_CullBox(vec3_t worldBounds[2]) { + int i; + cplane_t *frust; + qboolean anyClip; + int r, numPlanes; + + numPlanes = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4; + + // check against frustum planes + anyClip = qfalse; + for(i = 0; i < numPlanes; i++) + { + frust = &tr.viewParms.frustum[i]; + + r = BoxOnPlaneSide(worldBounds[0], worldBounds[1], frust); + + if(r == 2) + { + // completely outside frustum + return CULL_OUT; + } + if(r == 3) + { + anyClip = qtrue; + } + } + + if(!anyClip) + { + // completely inside frustum + return CULL_IN; + } + + // partially clipped + return CULL_CLIP; +} + +/* +** R_CullLocalPointAndRadius +*/ +int R_CullLocalPointAndRadius( const vec3_t pt, float radius ) +{ + vec3_t transformed; + + R_LocalPointToWorld( pt, transformed ); + + return R_CullPointAndRadius( transformed, radius ); +} + +/* +** R_CullPointAndRadius +*/ +int R_CullPointAndRadiusEx( const vec3_t pt, float radius, const cplane_t* frustum, int numPlanes ) +{ + int i; + float dist; + const cplane_t *frust; + qboolean mightBeClipped = qfalse; + + if ( r_nocull->integer ) { + return CULL_CLIP; + } + + // check against frustum planes + for (i = 0 ; i < numPlanes ; i++) + { + frust = &frustum[i]; + + dist = DotProduct( pt, frust->normal) - frust->dist; + if ( dist < -radius ) + { + return CULL_OUT; + } + else if ( dist <= radius ) + { + mightBeClipped = qtrue; + } + } + + if ( mightBeClipped ) + { + return CULL_CLIP; + } + + return CULL_IN; // completely inside frustum +} + +/* +** R_CullPointAndRadius +*/ +int R_CullPointAndRadius( const vec3_t pt, float radius ) +{ + return R_CullPointAndRadiusEx(pt, radius, tr.viewParms.frustum, (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 5 : 4); +} + +/* +================= +R_LocalNormalToWorld + +================= +*/ +void R_LocalNormalToWorld (const vec3_t local, vec3_t world) { + world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0]; + world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1]; + world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2]; +} + +/* +================= +R_LocalPointToWorld + +================= +*/ +void R_LocalPointToWorld (const vec3_t local, vec3_t world) { + world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0] + tr.or.origin[0]; + world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1] + tr.or.origin[1]; + world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2] + tr.or.origin[2]; +} + +/* +================= +R_WorldToLocal + +================= +*/ +void R_WorldToLocal (const vec3_t world, vec3_t local) { + local[0] = DotProduct(world, tr.or.axis[0]); + local[1] = DotProduct(world, tr.or.axis[1]); + local[2] = DotProduct(world, tr.or.axis[2]); +} + +/* +========================== +R_TransformModelToClip + +========================== +*/ +void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, + vec4_t eye, vec4_t dst ) { + int i; + + for ( i = 0 ; i < 4 ; i++ ) { + eye[i] = + src[0] * modelMatrix[ i + 0 * 4 ] + + src[1] * modelMatrix[ i + 1 * 4 ] + + src[2] * modelMatrix[ i + 2 * 4 ] + + 1 * modelMatrix[ i + 3 * 4 ]; + } + + for ( i = 0 ; i < 4 ; i++ ) { + dst[i] = + eye[0] * projectionMatrix[ i + 0 * 4 ] + + eye[1] * projectionMatrix[ i + 1 * 4 ] + + eye[2] * projectionMatrix[ i + 2 * 4 ] + + eye[3] * projectionMatrix[ i + 3 * 4 ]; + } +} + +/* +========================== +R_TransformClipToWindow + +========================== +*/ +void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ) { + normalized[0] = clip[0] / clip[3]; + normalized[1] = clip[1] / clip[3]; + normalized[2] = ( clip[2] + clip[3] ) / ( 2 * clip[3] ); + + window[0] = 0.5f * ( 1.0f + normalized[0] ) * view->viewportWidth; + window[1] = 0.5f * ( 1.0f + normalized[1] ) * view->viewportHeight; + window[2] = normalized[2]; + + window[0] = (int) ( window[0] + 0.5 ); + window[1] = (int) ( window[1] + 0.5 ); +} + + +/* +========================== +myGlMultMatrix + +========================== +*/ +void myGlMultMatrix( const float *a, const float *b, float *out ) { + int i, j; + + for ( i = 0 ; i < 4 ; i++ ) { + for ( j = 0 ; j < 4 ; j++ ) { + out[ i * 4 + j ] = + a [ i * 4 + 0 ] * b [ 0 * 4 + j ] + + a [ i * 4 + 1 ] * b [ 1 * 4 + j ] + + a [ i * 4 + 2 ] * b [ 2 * 4 + j ] + + a [ i * 4 + 3 ] * b [ 3 * 4 + j ]; + } + } +} + +/* +================= +R_RotateForEntity + +Generates an orientation for an entity and viewParms +Does NOT produce any GL calls +Called by both the front end and the back end +================= +*/ +void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, + orientationr_t *or ) { + float glMatrix[16]; + vec3_t delta; + float axisLength; + + if ( ent->e.reType != RT_MODEL ) { + *or = viewParms->world; + return; + } + + VectorCopy( ent->e.origin, or->origin ); + + VectorCopy( ent->e.axis[0], or->axis[0] ); + VectorCopy( ent->e.axis[1], or->axis[1] ); + VectorCopy( ent->e.axis[2], or->axis[2] ); + + glMatrix[0] = or->axis[0][0]; + glMatrix[4] = or->axis[1][0]; + glMatrix[8] = or->axis[2][0]; + glMatrix[12] = or->origin[0]; + + glMatrix[1] = or->axis[0][1]; + glMatrix[5] = or->axis[1][1]; + glMatrix[9] = or->axis[2][1]; + glMatrix[13] = or->origin[1]; + + glMatrix[2] = or->axis[0][2]; + glMatrix[6] = or->axis[1][2]; + glMatrix[10] = or->axis[2][2]; + glMatrix[14] = or->origin[2]; + + glMatrix[3] = 0; + glMatrix[7] = 0; + glMatrix[11] = 0; + glMatrix[15] = 1; + + Matrix16Copy(glMatrix, or->transformMatrix); + myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix ); + + // calculate the viewer origin in the model's space + // needed for fog, specular, and environment mapping + VectorSubtract( viewParms->or.origin, or->origin, delta ); + + // compensate for scale in the axes if necessary + if ( ent->e.nonNormalizedAxes ) { + axisLength = VectorLength( ent->e.axis[0] ); + if ( !axisLength ) { + axisLength = 0; + } else { + axisLength = 1.0f / axisLength; + } + } else { + axisLength = 1.0f; + } + + or->viewOrigin[0] = DotProduct( delta, or->axis[0] ) * axisLength; + or->viewOrigin[1] = DotProduct( delta, or->axis[1] ) * axisLength; + or->viewOrigin[2] = DotProduct( delta, or->axis[2] ) * axisLength; +} + +/* +================= +R_RotateForViewer + +Sets up the modelview matrix for a given viewParm +================= +*/ +void R_RotateForViewer (void) +{ + float viewerMatrix[16]; + vec3_t origin; + + Com_Memset (&tr.or, 0, sizeof(tr.or)); + tr.or.axis[0][0] = 1; + tr.or.axis[1][1] = 1; + tr.or.axis[2][2] = 1; + VectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin); + + // transform by the camera placement + VectorCopy( tr.viewParms.or.origin, origin ); + + viewerMatrix[0] = tr.viewParms.or.axis[0][0]; + viewerMatrix[4] = tr.viewParms.or.axis[0][1]; + viewerMatrix[8] = tr.viewParms.or.axis[0][2]; + viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8]; + + viewerMatrix[1] = tr.viewParms.or.axis[1][0]; + viewerMatrix[5] = tr.viewParms.or.axis[1][1]; + viewerMatrix[9] = tr.viewParms.or.axis[1][2]; + viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9]; + + viewerMatrix[2] = tr.viewParms.or.axis[2][0]; + viewerMatrix[6] = tr.viewParms.or.axis[2][1]; + viewerMatrix[10] = tr.viewParms.or.axis[2][2]; + viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10]; + + viewerMatrix[3] = 0; + viewerMatrix[7] = 0; + viewerMatrix[11] = 0; + viewerMatrix[15] = 1; + + // convert from our coordinate system (looking down X) + // to OpenGL's coordinate system (looking down -Z) + myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix ); + + tr.viewParms.world = tr.or; + +} + +/* +** SetFarClip +*/ +static void R_SetFarClip( void ) +{ + float farthestCornerDistance = 0; + int i; + + // if not rendering the world (icons, menus, etc) + // set a 2k far clip plane + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + tr.viewParms.zFar = 2048; + return; + } + + // + // set far clipping planes dynamically + // + farthestCornerDistance = 0; + for ( i = 0; i < 8; i++ ) + { + vec3_t v; + vec3_t vecTo; + float distance; + + if ( i & 1 ) + { + v[0] = tr.viewParms.visBounds[0][0]; + } + else + { + v[0] = tr.viewParms.visBounds[1][0]; + } + + if ( i & 2 ) + { + v[1] = tr.viewParms.visBounds[0][1]; + } + else + { + v[1] = tr.viewParms.visBounds[1][1]; + } + + if ( i & 4 ) + { + v[2] = tr.viewParms.visBounds[0][2]; + } + else + { + v[2] = tr.viewParms.visBounds[1][2]; + } + + VectorSubtract( v, tr.viewParms.or.origin, vecTo ); + + distance = vecTo[0] * vecTo[0] + vecTo[1] * vecTo[1] + vecTo[2] * vecTo[2]; + + if ( distance > farthestCornerDistance ) + { + farthestCornerDistance = distance; + } + } + tr.viewParms.zFar = sqrt( farthestCornerDistance ); +} + +/* +================= +R_SetupFrustum + +Set up the culling frustum planes for the current view using the results we got from computing the first two rows of +the projection matrix. +================= +*/ +void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, float zProj, float zFar, float stereoSep) +{ + vec3_t ofsorigin; + float oppleg, adjleg, length; + int i; + + if(stereoSep == 0 && xmin == -xmax) + { + // symmetric case can be simplified + VectorCopy(dest->or.origin, ofsorigin); + + length = sqrt(xmax * xmax + zProj * zProj); + oppleg = xmax / length; + adjleg = zProj / length; + + VectorScale(dest->or.axis[0], oppleg, dest->frustum[0].normal); + VectorMA(dest->frustum[0].normal, adjleg, dest->or.axis[1], dest->frustum[0].normal); + + VectorScale(dest->or.axis[0], oppleg, dest->frustum[1].normal); + VectorMA(dest->frustum[1].normal, -adjleg, dest->or.axis[1], dest->frustum[1].normal); + } + else + { + // In stereo rendering, due to the modification of the projection matrix, dest->or.origin is not the + // actual origin that we're rendering so offset the tip of the view pyramid. + VectorMA(dest->or.origin, stereoSep, dest->or.axis[1], ofsorigin); + + oppleg = xmax + stereoSep; + length = sqrt(oppleg * oppleg + zProj * zProj); + VectorScale(dest->or.axis[0], oppleg / length, dest->frustum[0].normal); + VectorMA(dest->frustum[0].normal, zProj / length, dest->or.axis[1], dest->frustum[0].normal); + + oppleg = xmin + stereoSep; + length = sqrt(oppleg * oppleg + zProj * zProj); + VectorScale(dest->or.axis[0], -oppleg / length, dest->frustum[1].normal); + VectorMA(dest->frustum[1].normal, -zProj / length, dest->or.axis[1], dest->frustum[1].normal); + } + + length = sqrt(ymax * ymax + zProj * zProj); + oppleg = ymax / length; + adjleg = zProj / length; + + VectorScale(dest->or.axis[0], oppleg, dest->frustum[2].normal); + VectorMA(dest->frustum[2].normal, adjleg, dest->or.axis[2], dest->frustum[2].normal); + + VectorScale(dest->or.axis[0], oppleg, dest->frustum[3].normal); + VectorMA(dest->frustum[3].normal, -adjleg, dest->or.axis[2], dest->frustum[3].normal); + + for (i=0 ; i<4 ; i++) { + dest->frustum[i].type = PLANE_NON_AXIAL; + dest->frustum[i].dist = DotProduct (ofsorigin, dest->frustum[i].normal); + SetPlaneSignbits( &dest->frustum[i] ); + } + + if (zFar != 0.0f) + { + vec3_t farpoint; + + VectorMA(ofsorigin, zFar, dest->or.axis[0], farpoint); + VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); + + dest->frustum[4].type = PLANE_NON_AXIAL; + dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal); + SetPlaneSignbits( &dest->frustum[4] ); + dest->flags |= VPF_FARPLANEFRUSTUM; + } +} + +/* +=============== +R_SetupProjection +=============== +*/ +void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum) +{ + float xmin, xmax, ymin, ymax; + float width, height, stereoSep = r_stereoSeparation->value; + + /* + * offset the view origin of the viewer for stereo rendering + * by setting the projection matrix appropriately. + */ + + if(stereoSep != 0) + { + if(dest->stereoFrame == STEREO_LEFT) + stereoSep = zProj / stereoSep; + else if(dest->stereoFrame == STEREO_RIGHT) + stereoSep = zProj / -stereoSep; + else + stereoSep = 0; + } + + ymax = zProj * tan(dest->fovY * M_PI / 360.0f); + ymin = -ymax; + + xmax = zProj * tan(dest->fovX * M_PI / 360.0f); + xmin = -xmax; + + width = xmax - xmin; + height = ymax - ymin; + + dest->projectionMatrix[0] = 2 * zProj / width; + dest->projectionMatrix[4] = 0; + dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width; + dest->projectionMatrix[12] = 2 * zProj * stereoSep / width; + + dest->projectionMatrix[1] = 0; + dest->projectionMatrix[5] = 2 * zProj / height; + dest->projectionMatrix[9] = ( ymax + ymin ) / height; // normally 0 + dest->projectionMatrix[13] = 0; + + dest->projectionMatrix[3] = 0; + dest->projectionMatrix[7] = 0; + dest->projectionMatrix[11] = -1; + dest->projectionMatrix[15] = 0; + + // Now that we have all the data for the projection matrix we can also setup the view frustum. + if(computeFrustum) + R_SetupFrustum(dest, xmin, xmax, ymax, zProj, zFar, stereoSep); +} + +/* +=============== +R_SetupProjectionZ + +Sets the z-component transformation part in the projection matrix +=============== +*/ +void R_SetupProjectionZ(viewParms_t *dest) +{ + float zNear, zFar, depth; + + zNear = r_znear->value; + zFar = dest->zFar; + + depth = zFar - zNear; + + dest->projectionMatrix[2] = 0; + dest->projectionMatrix[6] = 0; + dest->projectionMatrix[10] = -( zFar + zNear ) / depth; + dest->projectionMatrix[14] = -2 * zFar * zNear / depth; + + if (dest->isPortal) + { + float plane[4]; + float plane2[4]; + vec4_t q, c; + + // transform portal plane into camera space + plane[0] = dest->portalPlane.normal[0]; + plane[1] = dest->portalPlane.normal[1]; + plane[2] = dest->portalPlane.normal[2]; + plane[3] = dest->portalPlane.dist; + + plane2[0] = -DotProduct (dest->or.axis[1], plane); + plane2[1] = DotProduct (dest->or.axis[2], plane); + plane2[2] = -DotProduct (dest->or.axis[0], plane); + plane2[3] = DotProduct (plane, dest->or.origin) - plane[3]; + + // Lengyel, Eric. "Modifying the Projection Matrix to Perform Oblique Near-plane Clipping". + // Terathon Software 3D Graphics Library, 2004. http://www.terathon.com/code/oblique.html + q[0] = (SGN(plane2[0]) + dest->projectionMatrix[8]) / dest->projectionMatrix[0]; + q[1] = (SGN(plane2[1]) + dest->projectionMatrix[9]) / dest->projectionMatrix[5]; + q[2] = -1.0f; + q[3] = (1.0f + dest->projectionMatrix[10]) / dest->projectionMatrix[14]; + + VectorScale4(plane2, 2.0f / DotProduct4(plane2, q), c); + + dest->projectionMatrix[2] = c[0]; + dest->projectionMatrix[6] = c[1]; + dest->projectionMatrix[10] = c[2] + 1.0f; + dest->projectionMatrix[14] = c[3]; + + } + +} + +/* +=============== +R_SetupProjectionOrtho +=============== +*/ +void R_SetupProjectionOrtho(viewParms_t *dest, vec3_t viewBounds[2]) +{ + float xmin, xmax, ymin, ymax, znear, zfar; + //viewParms_t *dest = &tr.viewParms; + int i; + vec3_t pop; + + // Quake3: Projection: + // + // Z X Y Z + // | / | / + // |/ |/ + // Y--+ +--X + + xmin = viewBounds[0][1]; + xmax = viewBounds[1][1]; + ymin = -viewBounds[1][2]; + ymax = -viewBounds[0][2]; + znear = viewBounds[0][0]; + zfar = viewBounds[1][0]; + + dest->projectionMatrix[0] = 2 / (xmax - xmin); + dest->projectionMatrix[4] = 0; + dest->projectionMatrix[8] = 0; + dest->projectionMatrix[12] = (xmax + xmin) / (xmax - xmin); + + dest->projectionMatrix[1] = 0; + dest->projectionMatrix[5] = 2 / (ymax - ymin); + dest->projectionMatrix[9] = 0; + dest->projectionMatrix[13] = (ymax + ymin) / (ymax - ymin); + + dest->projectionMatrix[2] = 0; + dest->projectionMatrix[6] = 0; + dest->projectionMatrix[10] = -2 / (zfar - znear); + dest->projectionMatrix[14] = -(zfar + znear) / (zfar - znear); + + dest->projectionMatrix[3] = 0; + dest->projectionMatrix[7] = 0; + dest->projectionMatrix[11] = 0; + dest->projectionMatrix[15] = 1; + + VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->or.origin, viewBounds[0][1], dest->frustum[0].normal, pop); + dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); + + VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->or.origin, -viewBounds[1][1], dest->frustum[1].normal, pop); + dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); + + VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->or.origin, viewBounds[0][2], dest->frustum[2].normal, pop); + dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); + + VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->or.origin, -viewBounds[1][2], dest->frustum[3].normal, pop); + dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); + + VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->or.origin, -viewBounds[1][0], dest->frustum[4].normal, pop); + dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); + + for (i = 0; i < 5; i++) + { + dest->frustum[i].type = PLANE_NON_AXIAL; + SetPlaneSignbits (&dest->frustum[i]); + } + + dest->flags |= VPF_FARPLANEFRUSTUM; +} + +/* +================= +R_MirrorPoint +================= +*/ +void R_MirrorPoint (vec3_t in, orientation_t *surface, orientation_t *camera, vec3_t out) { + int i; + vec3_t local; + vec3_t transformed; + float d; + + VectorSubtract( in, surface->origin, local ); + + VectorClear( transformed ); + for ( i = 0 ; i < 3 ; i++ ) { + d = DotProduct(local, surface->axis[i]); + VectorMA( transformed, d, camera->axis[i], transformed ); + } + + VectorAdd( transformed, camera->origin, out ); +} + +void R_MirrorVector (vec3_t in, orientation_t *surface, orientation_t *camera, vec3_t out) { + int i; + float d; + + VectorClear( out ); + for ( i = 0 ; i < 3 ; i++ ) { + d = DotProduct(in, surface->axis[i]); + VectorMA( out, d, camera->axis[i], out ); + } +} + + +/* +============= +R_PlaneForSurface +============= +*/ +void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { + srfTriangles_t *tri; + srfPoly_t *poly; + srfVert_t *v1, *v2, *v3; + vec4_t plane4; + + if (!surfType) { + Com_Memset (plane, 0, sizeof(*plane)); + plane->normal[0] = 1; + return; + } + switch (*surfType) { + case SF_FACE: + *plane = ((srfSurfaceFace_t *)surfType)->plane; + return; + case SF_TRIANGLES: + tri = (srfTriangles_t *)surfType; + v1 = tri->verts + tri->triangles[0].indexes[0]; + v2 = tri->verts + tri->triangles[0].indexes[1]; + v3 = tri->verts + tri->triangles[0].indexes[2]; + PlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz ); + VectorCopy( plane4, plane->normal ); + plane->dist = plane4[3]; + return; + case SF_POLY: + poly = (srfPoly_t *)surfType; + PlaneFromPoints( plane4, poly->verts[0].xyz, poly->verts[1].xyz, poly->verts[2].xyz ); + VectorCopy( plane4, plane->normal ); + plane->dist = plane4[3]; + return; + default: + Com_Memset (plane, 0, sizeof(*plane)); + plane->normal[0] = 1; + return; + } +} + +/* +================= +R_GetPortalOrientation + +entityNum is the entity that the portal surface is a part of, which may +be moving and rotating. + +Returns qtrue if it should be mirrored +================= +*/ +qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, + orientation_t *surface, orientation_t *camera, + vec3_t pvsOrigin, qboolean *mirror ) { + int i; + cplane_t originalPlane, plane; + trRefEntity_t *e; + float d; + vec3_t transformed; + + // create plane axis for the portal we are seeing + R_PlaneForSurface( drawSurf->surface, &originalPlane ); + + // rotate the plane if necessary + if ( entityNum != REFENTITYNUM_WORLD ) { + tr.currentEntityNum = entityNum; + tr.currentEntity = &tr.refdef.entities[entityNum]; + + // get the orientation of the entity + R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); + + // rotate the plane, but keep the non-rotated version for matching + // against the portalSurface entities + R_LocalNormalToWorld( originalPlane.normal, plane.normal ); + plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); + + // translate the original plane + originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); + } else { + plane = originalPlane; + } + + VectorCopy( plane.normal, surface->axis[0] ); + PerpendicularVector( surface->axis[1], surface->axis[0] ); + CrossProduct( surface->axis[0], surface->axis[1], surface->axis[2] ); + + // locate the portal entity closest to this plane. + // origin will be the origin of the portal, origin2 will be + // the origin of the camera + for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) { + e = &tr.refdef.entities[i]; + if ( e->e.reType != RT_PORTALSURFACE ) { + continue; + } + + d = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist; + if ( d > 64 || d < -64) { + continue; + } + + // get the pvsOrigin from the entity + VectorCopy( e->e.oldorigin, pvsOrigin ); + + // if the entity is just a mirror, don't use as a camera point + if ( e->e.oldorigin[0] == e->e.origin[0] && + e->e.oldorigin[1] == e->e.origin[1] && + e->e.oldorigin[2] == e->e.origin[2] ) { + VectorScale( plane.normal, plane.dist, surface->origin ); + VectorCopy( surface->origin, camera->origin ); + VectorSubtract( vec3_origin, surface->axis[0], camera->axis[0] ); + VectorCopy( surface->axis[1], camera->axis[1] ); + VectorCopy( surface->axis[2], camera->axis[2] ); + + *mirror = qtrue; + return qtrue; + } + + // project the origin onto the surface plane to get + // an origin point we can rotate around + d = DotProduct( e->e.origin, plane.normal ) - plane.dist; + VectorMA( e->e.origin, -d, surface->axis[0], surface->origin ); + + // now get the camera origin and orientation + VectorCopy( e->e.oldorigin, camera->origin ); + AxisCopy( e->e.axis, camera->axis ); + VectorSubtract( vec3_origin, camera->axis[0], camera->axis[0] ); + VectorSubtract( vec3_origin, camera->axis[1], camera->axis[1] ); + + // optionally rotate + if ( e->e.oldframe ) { + // if a speed is specified + if ( e->e.frame ) { + // continuous rotate + d = (tr.refdef.time/1000.0f) * e->e.frame; + VectorCopy( camera->axis[1], transformed ); + RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); + CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); + } else { + // bobbing rotate, with skinNum being the rotation offset + d = sin( tr.refdef.time * 0.003f ); + d = e->e.skinNum + d * 4; + VectorCopy( camera->axis[1], transformed ); + RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); + CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); + } + } + else if ( e->e.skinNum ) { + d = e->e.skinNum; + VectorCopy( camera->axis[1], transformed ); + RotatePointAroundVector( camera->axis[1], camera->axis[0], transformed, d ); + CrossProduct( camera->axis[0], camera->axis[1], camera->axis[2] ); + } + *mirror = qfalse; + return qtrue; + } + + // if we didn't locate a portal entity, don't render anything. + // We don't want to just treat it as a mirror, because without a + // portal entity the server won't have communicated a proper entity set + // in the snapshot + + // unfortunately, with local movement prediction it is easily possible + // to see a surface before the server has communicated the matching + // portal surface entity, so we don't want to print anything here... + + //ri.Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); + + return qfalse; +} + +static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) +{ + int i; + cplane_t originalPlane, plane; + trRefEntity_t *e; + float d; + + // create plane axis for the portal we are seeing + R_PlaneForSurface( drawSurf->surface, &originalPlane ); + + // rotate the plane if necessary + if ( entityNum != REFENTITYNUM_WORLD ) + { + tr.currentEntityNum = entityNum; + tr.currentEntity = &tr.refdef.entities[entityNum]; + + // get the orientation of the entity + R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); + + // rotate the plane, but keep the non-rotated version for matching + // against the portalSurface entities + R_LocalNormalToWorld( originalPlane.normal, plane.normal ); + plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); + + // translate the original plane + originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); + } + + // locate the portal entity closest to this plane. + // origin will be the origin of the portal, origin2 will be + // the origin of the camera + for ( i = 0 ; i < tr.refdef.num_entities ; i++ ) + { + e = &tr.refdef.entities[i]; + if ( e->e.reType != RT_PORTALSURFACE ) { + continue; + } + + d = DotProduct( e->e.origin, originalPlane.normal ) - originalPlane.dist; + if ( d > 64 || d < -64) { + continue; + } + + // if the entity is just a mirror, don't use as a camera point + if ( e->e.oldorigin[0] == e->e.origin[0] && + e->e.oldorigin[1] == e->e.origin[1] && + e->e.oldorigin[2] == e->e.origin[2] ) + { + return qtrue; + } + + return qfalse; + } + return qfalse; +} + +/* +** SurfIsOffscreen +** +** Determines if a surface is completely offscreen. +*/ +static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128] ) { + float shortest = 100000000; + int entityNum; + int numTriangles; + shader_t *shader; + int fogNum; + int dlighted; + int pshadowed; + vec4_t clip, eye; + int i; + unsigned int pointOr = 0; + unsigned int pointAnd = (unsigned int)~0; + + R_RotateForViewer(); + + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + RB_BeginSurface( shader, fogNum ); + rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + + assert( tess.numVertexes < 128 ); + + for ( i = 0; i < tess.numVertexes; i++ ) + { + int j; + unsigned int pointFlags = 0; + + R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); + + for ( j = 0; j < 3; j++ ) + { + if ( clip[j] >= clip[3] ) + { + pointFlags |= (1 << (j*2)); + } + else if ( clip[j] <= -clip[3] ) + { + pointFlags |= ( 1 << (j*2+1)); + } + } + pointAnd &= pointFlags; + pointOr |= pointFlags; + } + + // trivially reject + if ( pointAnd ) + { + return qtrue; + } + + // determine if this surface is backfaced and also determine the distance + // to the nearest vertex so we can cull based on portal range. Culling + // based on vertex distance isn't 100% correct (we should be checking for + // range to the surface), but it's good enough for the types of portals + // we have in the game right now. + numTriangles = tess.numIndexes / 3; + + for ( i = 0; i < tess.numIndexes; i += 3 ) + { + vec3_t normal; + float len; + + VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal ); + + len = VectorLengthSquared( normal ); // lose the sqrt + if ( len < shortest ) + { + shortest = len; + } + + if ( DotProduct( normal, tess.normal[tess.indexes[i]] ) >= 0 ) + { + numTriangles--; + } + } + if ( !numTriangles ) + { + return qtrue; + } + + // mirrors can early out at this point, since we don't do a fade over distance + // with them (although we could) + if ( IsMirror( drawSurf, entityNum ) ) + { + return qfalse; + } + + if ( shortest > (tess.shader->portalRange*tess.shader->portalRange) ) + { + return qtrue; + } + + return qfalse; +} + +/* +======================== +R_MirrorViewBySurface + +Returns qtrue if another view has been rendered +======================== +*/ +qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { + vec4_t clipDest[128]; + viewParms_t newParms; + viewParms_t oldParms; + orientation_t surface, camera; + + // don't recursively mirror + if (tr.viewParms.isPortal) { + ri.Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); + return qfalse; + } + + if ( r_noportals->integer || (r_fastsky->integer == 1) ) { + return qfalse; + } + + // trivially reject portal/mirror + if ( SurfIsOffscreen( drawSurf, clipDest ) ) { + return qfalse; + } + + // save old viewParms so we can return to it after the mirror view + oldParms = tr.viewParms; + + newParms = tr.viewParms; + newParms.isPortal = qtrue; + newParms.zFar = 0.0f; + newParms.flags &= ~VPF_FARPLANEFRUSTUM; + if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, + newParms.pvsOrigin, &newParms.isMirror ) ) { + return qfalse; // bad portal, no portalentity + } + + R_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin ); + + VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); + newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); + + R_MirrorVector (oldParms.or.axis[0], &surface, &camera, newParms.or.axis[0]); + R_MirrorVector (oldParms.or.axis[1], &surface, &camera, newParms.or.axis[1]); + R_MirrorVector (oldParms.or.axis[2], &surface, &camera, newParms.or.axis[2]); + + // OPTIMIZE: restrict the viewport on the mirrored view + + // render the mirror view + R_RenderView (&newParms); + + tr.viewParms = oldParms; + + return qtrue; +} + +/* +================= +R_SpriteFogNum + +See if a sprite is inside a fog volume +================= +*/ +int R_SpriteFogNum( trRefEntity_t *ent ) { + int i, j; + fog_t *fog; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( ent->e.origin[j] - ent->e.radius >= fog->bounds[1][j] ) { + break; + } + if ( ent->e.origin[j] + ent->e.radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + +/* +========================================================================================== + +DRAWSURF SORTING + +========================================================================================== +*/ + +/* +=============== +R_Radix +=============== +*/ +static ID_INLINE void R_Radix( int byte, int size, drawSurf_t *source, drawSurf_t *dest ) +{ + int count[ 256 ] = { 0 }; + int index[ 256 ]; + int i; + unsigned char *sortKey = NULL; + unsigned char *end = NULL; + + sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; + end = sortKey + ( size * sizeof( drawSurf_t ) ); + for( ; sortKey < end; sortKey += sizeof( drawSurf_t ) ) + ++count[ *sortKey ]; + + index[ 0 ] = 0; + + for( i = 1; i < 256; ++i ) + index[ i ] = index[ i - 1 ] + count[ i - 1 ]; + + sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; + for( i = 0; i < size; ++i, sortKey += sizeof( drawSurf_t ) ) + dest[ index[ *sortKey ]++ ] = source[ i ]; +} + +/* +=============== +R_RadixSort + +Radix sort with 4 byte size buckets +=============== +*/ +static void R_RadixSort( drawSurf_t *source, int size ) +{ + static drawSurf_t scratch[ MAX_DRAWSURFS ]; +#ifdef Q3_LITTLE_ENDIAN + R_Radix( 0, size, source, scratch ); + R_Radix( 1, size, scratch, source ); + R_Radix( 2, size, source, scratch ); + R_Radix( 3, size, scratch, source ); +#else + R_Radix( 3, size, source, scratch ); + R_Radix( 2, size, scratch, source ); + R_Radix( 1, size, source, scratch ); + R_Radix( 0, size, scratch, source ); +#endif //Q3_LITTLE_ENDIAN +} + +//========================================================================================== + +/* +================= +R_AddDrawSurf +================= +*/ +void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, + int fogIndex, int dlightMap, int pshadowMap ) { + int index; + + // instead of checking for overflow, we just mask the index + // so it wraps around + index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; + // the sort data is packed into a single 32 bit value so it can be + // compared quickly during the qsorting process + tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) + | tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) + | ((int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + tr.refdef.drawSurfs[index].surface = surface; + tr.refdef.numDrawSurfs++; +} + +/* +================= +R_DecomposeSort +================= +*/ +void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, + int *fogNum, int *dlightMap, int *pshadowMap ) { + *fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31; + *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ]; + *entityNum = ( sort >> QSORT_REFENTITYNUM_SHIFT ) & REFENTITYNUM_MASK; + *pshadowMap = (sort >> QSORT_PSHADOW_SHIFT ) & 1; + *dlightMap = sort & 1; +} + +/* +================= +R_SortDrawSurfs +================= +*/ +void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { + shader_t *shader; + int fogNum; + int entityNum; + int dlighted; + int pshadowed; + int i; + + //ri.Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); + + // it is possible for some views to not have any surfaces + if ( numDrawSurfs < 1 ) { + // we still need to add it for hyperspace cases + R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); + return; + } + + // if we overflowed MAX_DRAWSURFS, the drawsurfs + // wrapped around in the buffer and we will be missing + // the first surfaces, not the last ones + if ( numDrawSurfs > MAX_DRAWSURFS ) { + numDrawSurfs = MAX_DRAWSURFS; + } + + // sort the drawsurfs by sort type, then orientation, then shader + R_RadixSort( drawSurfs, numDrawSurfs ); + + // skip pass through drawing if rendering a shadow map + if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) + { + R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); + return; + } + + // check for any pass through drawing, which + // may cause another view to be rendered first + for ( i = 0 ; i < numDrawSurfs ; i++ ) { + R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + + if ( shader->sort > SS_PORTAL ) { + break; + } + + // no shader should ever have this sort type + if ( shader->sort == SS_BAD ) { + ri.Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); + } + + // if the mirror was completely clipped away, we may need to check another surface + if ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) { + // this is a debug option to see exactly what is being mirrored + if ( r_portalOnly->integer ) { + return; + } + break; // only one mirror view at a time + } + } + + R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); +} + +static void R_AddEntitySurface (int entityNum) +{ + trRefEntity_t *ent; + shader_t *shader; + + tr.currentEntityNum = entityNum; + + ent = tr.currentEntity = &tr.refdef.entities[tr.currentEntityNum]; + + ent->needDlights = qfalse; + + // preshift the value we are going to OR into the drawsurf sort + tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; + + // + // the weapon model must be handled special -- + // we don't want the hacked weapon position showing in + // mirrors, because the true body position will already be drawn + // + if ( (ent->e.renderfx & RF_FIRST_PERSON) && (tr.viewParms.isPortal + || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) ) { + return; + } + + // simple generated models, like sprites and beams, are not culled + switch ( ent->e.reType ) { + case RT_PORTALSURFACE: + break; // don't draw anything + case RT_SPRITE: + case RT_BEAM: + case RT_LIGHTNING: + case RT_RAIL_CORE: + case RT_RAIL_RINGS: + // self blood sprites, talk balloons, etc should not be drawn in the primary + // view. We can't just do this check for all entities, because md3 + // entities may still want to cast shadows from them + if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { + return; + } + shader = R_GetShaderByHandle( ent->e.customShader ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, 0 ); + break; + + case RT_MODEL: + // we must set up parts of tr.or for model culling + R_RotateForEntity( ent, &tr.viewParms, &tr.or ); + + tr.currentModel = R_GetModelByHandle( ent->e.hModel ); + if (!tr.currentModel) { + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); + } else { + switch ( tr.currentModel->type ) { + case MOD_MESH: + R_AddMD3Surfaces( ent ); + break; + case MOD_MD4: + R_AddAnimSurfaces( ent ); + break; + case MOD_MDR: + R_MDRAddAnimSurfaces( ent ); + break; + case MOD_IQM: + R_AddIQMSurfaces( ent ); + break; + case MOD_BRUSH: + R_AddBrushModelSurfaces( ent ); + break; + case MOD_BAD: // null model axis + if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { + break; + } + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); + break; + default: + ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); + break; + } + } + break; + default: + ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); + } +} + +/* +============= +R_AddEntitySurfaces +============= +*/ +void R_AddEntitySurfaces (void) { + int i; + + if ( !r_drawentities->integer ) { + return; + } + + for ( i = 0; i < tr.refdef.num_entities; i++) + R_AddEntitySurface(i); +} + + +/* +==================== +R_GenerateDrawSurfs +==================== +*/ +void R_GenerateDrawSurfs( void ) { + R_AddWorldSurfaces (); + + R_AddPolygonSurfaces(); + + // set the projection matrix with the minimum zfar + // now that we have the world bounded + // this needs to be done before entities are + // added, because they use the projection + // matrix for lod calculation + + // dynamically compute far clip plane distance + if (!(tr.viewParms.flags & VPF_SHADOWMAP)) + { + R_SetFarClip(); + } + + // we know the size of the clipping volume. Now set the rest of the projection matrix. + R_SetupProjectionZ (&tr.viewParms); + + R_AddEntitySurfaces (); +} + +/* +================ +R_DebugPolygon +================ +*/ +void R_DebugPolygon( int color, int numPoints, float *points ) { + // FIXME: implement this +#if 0 + int i; + + GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + + // draw solid shade + + qglColor3f( color&1, (color>>1)&1, (color>>2)&1 ); + qglBegin( GL_POLYGON ); + for ( i = 0 ; i < numPoints ; i++ ) { + qglVertex3fv( points + i * 3 ); + } + qglEnd(); + + // draw wireframe outline + GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + qglDepthRange( 0, 0 ); + qglColor3f( 1, 1, 1 ); + qglBegin( GL_POLYGON ); + for ( i = 0 ; i < numPoints ; i++ ) { + qglVertex3fv( points + i * 3 ); + } + qglEnd(); + qglDepthRange( 0, 1 ); +#endif +} + +/* +==================== +R_DebugGraphics + +Visualization aid for movement clipping debugging +==================== +*/ +void R_DebugGraphics( void ) { + if ( !r_debugSurface->integer ) { + return; + } + + R_IssuePendingRenderCommands(); + + GL_Bind( tr.whiteImage); + GL_Cull( CT_FRONT_SIDED ); + ri.CM_DrawDebugSurface( R_DebugPolygon ); +} + + +/* +================ +R_RenderView + +A view may be either the actual camera view, +or a mirror / remote location +================ +*/ +void R_RenderView (viewParms_t *parms) { + int firstDrawSurf; + + if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) { + return; + } + + tr.viewCount++; + + tr.viewParms = *parms; + tr.viewParms.frameSceneNum = tr.frameSceneNum; + tr.viewParms.frameCount = tr.frameCount; + + firstDrawSurf = tr.refdef.numDrawSurfs; + + tr.viewCount++; + + // set viewParms.world + R_RotateForViewer (); + + R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); + + R_GenerateDrawSurfs(); + + R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + + // draw main system development information (surface outlines, etc) + R_DebugGraphics(); +} + + +void R_RenderDlightCubemaps(const refdef_t *fd) +{ + int i; + + for (i = 0; i < tr.refdef.num_dlights; i++) + { + viewParms_t shadowParms; + int j; + + // use previous frame to determine visible dlights + if ((1 << i) & tr.refdef.dlightMask) + continue; + + Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); + + shadowParms.viewportX = tr.refdef.x; + shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); + shadowParms.viewportWidth = PSHADOW_MAP_SIZE; + shadowParms.viewportHeight = PSHADOW_MAP_SIZE; + shadowParms.isPortal = qfalse; + shadowParms.isMirror = qtrue; // because it is + + shadowParms.fovX = 90; + shadowParms.fovY = 90; + + shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW; + shadowParms.zFar = tr.refdef.dlights[i].radius; + + VectorCopy( tr.refdef.dlights[i].origin, shadowParms.or.origin ); + + for (j = 0; j < 6; j++) + { + switch(j) + { + case 0: + // -X + VectorSet( shadowParms.or.axis[0], -1, 0, 0); + VectorSet( shadowParms.or.axis[1], 0, 0, -1); + VectorSet( shadowParms.or.axis[2], 0, 1, 0); + break; + case 1: + // +X + VectorSet( shadowParms.or.axis[0], 1, 0, 0); + VectorSet( shadowParms.or.axis[1], 0, 0, 1); + VectorSet( shadowParms.or.axis[2], 0, 1, 0); + break; + case 2: + // -Y + VectorSet( shadowParms.or.axis[0], 0, -1, 0); + VectorSet( shadowParms.or.axis[1], 1, 0, 0); + VectorSet( shadowParms.or.axis[2], 0, 0, -1); + break; + case 3: + // +Y + VectorSet( shadowParms.or.axis[0], 0, 1, 0); + VectorSet( shadowParms.or.axis[1], 1, 0, 0); + VectorSet( shadowParms.or.axis[2], 0, 0, 1); + break; + case 4: + // -Z + VectorSet( shadowParms.or.axis[0], 0, 0, -1); + VectorSet( shadowParms.or.axis[1], 1, 0, 0); + VectorSet( shadowParms.or.axis[2], 0, 1, 0); + break; + case 5: + // +Z + VectorSet( shadowParms.or.axis[0], 0, 0, 1); + VectorSet( shadowParms.or.axis[1], -1, 0, 0); + VectorSet( shadowParms.or.axis[2], 0, 1, 0); + break; + } + + R_RenderView(&shadowParms); + R_AddCapShadowmapCmd( i, j ); + } + } +} + + +void R_RenderPshadowMaps(const refdef_t *fd) +{ + viewParms_t shadowParms; + int i; + + // first, make a list of shadows + for ( i = 0; i < tr.refdef.num_entities; i++) + { + trRefEntity_t *ent = &tr.refdef.entities[i]; + + if((ent->e.renderfx & (RF_FIRST_PERSON | RF_NOSHADOW))) + continue; + + //if((ent->e.renderfx & RF_THIRD_PERSON)) + //continue; + + if (ent->e.reType == RT_MODEL) + { + model_t *model = R_GetModelByHandle( ent->e.hModel ); + pshadow_t shadow; + float radius = 0.0f; + float scale = 1.0f; + vec3_t diff; + int j; + + if (!model) + continue; + + if (ent->e.nonNormalizedAxes) + { + scale = VectorLength( ent->e.axis[0] ); + } + + switch (model->type) + { + case MOD_MESH: + { + mdvFrame_t *frame = &model->mdv[0]->frames[ent->e.frame]; + + radius = frame->radius * scale; + } + break; + + case MOD_MD4: + { + // FIXME: actually calculate the radius and bounds, this is a horrible hack + radius = r_pshadowDist->value / 2.0f; + } + break; + case MOD_MDR: + { + // FIXME: never actually tested this + mdrHeader_t *header = model->modelData; + int frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); + mdrFrame_t *frame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); + + radius = frame->radius; + } + break; + case MOD_IQM: + { + // FIXME: never actually tested this + iqmData_t *data = model->modelData; + vec3_t diag; + float *framebounds; + + framebounds = data->bounds + 6*ent->e.frame; + VectorSubtract( framebounds+3, framebounds, diag ); + radius = 0.5f * VectorLength( diag ); + } + break; + + default: + break; + } + + if (!radius) + continue; + + // Cull entities that are behind the viewer by more than lightRadius + VectorSubtract(ent->e.origin, fd->vieworg, diff); + if (DotProduct(diff, fd->viewaxis[0]) < -r_pshadowDist->value) + continue; + + memset(&shadow, 0, sizeof(shadow)); + + shadow.numEntities = 1; + shadow.entityNums[0] = i; + shadow.viewRadius = radius; + shadow.lightRadius = r_pshadowDist->value; + VectorCopy(ent->e.origin, shadow.viewOrigin); + shadow.sort = DotProduct(diff, diff) / (radius * radius); + VectorCopy(ent->e.origin, shadow.entityOrigins[0]); + shadow.entityRadiuses[0] = radius; + + for (j = 0; j < MAX_CALC_PSHADOWS; j++) + { + pshadow_t swap; + + if (j + 1 > tr.refdef.num_pshadows) + { + tr.refdef.num_pshadows = j + 1; + tr.refdef.pshadows[j] = shadow; + break; + } + + // sort shadows by distance from camera divided by radius + // FIXME: sort better + if (tr.refdef.pshadows[j].sort <= shadow.sort) + continue; + + swap = tr.refdef.pshadows[j]; + tr.refdef.pshadows[j] = shadow; + shadow = swap; + } + } + } + + // next, merge touching pshadows + for ( i = 0; i < tr.refdef.num_pshadows; i++) + { + pshadow_t *ps1 = &tr.refdef.pshadows[i]; + int j; + + for (j = i + 1; j < tr.refdef.num_pshadows; j++) + { + pshadow_t *ps2 = &tr.refdef.pshadows[j]; + int k; + qboolean touch; + + if (ps1->numEntities == 8) + break; + + touch = qfalse; + if (SpheresIntersect(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius)) + { + for (k = 0; k < ps1->numEntities; k++) + { + if (SpheresIntersect(ps1->entityOrigins[k], ps1->entityRadiuses[k], ps2->viewOrigin, ps2->viewRadius)) + { + touch = qtrue; + break; + } + } + } + + if (touch) + { + vec3_t newOrigin; + float newRadius; + + BoundingSphereOfSpheres(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius, newOrigin, &newRadius); + VectorCopy(newOrigin, ps1->viewOrigin); + ps1->viewRadius = newRadius; + + ps1->entityNums[ps1->numEntities] = ps2->entityNums[0]; + VectorCopy(ps2->viewOrigin, ps1->entityOrigins[ps1->numEntities]); + ps1->entityRadiuses[ps1->numEntities] = ps2->viewRadius; + + ps1->numEntities++; + + for (k = j; k < tr.refdef.num_pshadows - 1; k++) + { + tr.refdef.pshadows[k] = tr.refdef.pshadows[k + 1]; + } + + j--; + tr.refdef.num_pshadows--; + } + } + } + + // cap number of drawn pshadows + if (tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS) + { + tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS; + } + + // next, fill up the rest of the shadow info + for ( i = 0; i < tr.refdef.num_pshadows; i++) + { + pshadow_t *shadow = &tr.refdef.pshadows[i]; + vec3_t up; + vec3_t ambientLight, directedLight, lightDir; + + VectorSet(lightDir, 0.57735f, 0.57735f, 0.57735f); +#if 1 + R_LightForPoint(shadow->viewOrigin, ambientLight, directedLight, lightDir); + + // sometimes there's no light + if (DotProduct(lightDir, lightDir) < 0.9f) + VectorSet(lightDir, 0.0f, 0.0f, 1.0f); +#endif + + if (shadow->viewRadius * 3.0f > shadow->lightRadius) + { + shadow->lightRadius = shadow->viewRadius * 3.0f; + } + + VectorMA(shadow->viewOrigin, shadow->viewRadius, lightDir, shadow->lightOrigin); + + // make up a projection, up doesn't matter + VectorScale(lightDir, -1.0f, shadow->lightViewAxis[0]); + VectorSet(up, 0, 0, -1); + + if ( abs(DotProduct(up, shadow->lightViewAxis[0])) > 0.9f ) + { + VectorSet(up, -1, 0, 0); + } + + CrossProduct(shadow->lightViewAxis[0], up, shadow->lightViewAxis[1]); + VectorNormalize(shadow->lightViewAxis[1]); + CrossProduct(shadow->lightViewAxis[0], shadow->lightViewAxis[1], shadow->lightViewAxis[2]); + + VectorCopy(shadow->lightViewAxis[0], shadow->cullPlane.normal); + shadow->cullPlane.dist = DotProduct(shadow->cullPlane.normal, shadow->lightOrigin); + shadow->cullPlane.type = PLANE_NON_AXIAL; + SetPlaneSignbits(&shadow->cullPlane); + } + + // next, render shadowmaps + for ( i = 0; i < tr.refdef.num_pshadows; i++) + { + int firstDrawSurf; + pshadow_t *shadow = &tr.refdef.pshadows[i]; + int j; + + Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); + + if (glRefConfig.framebufferObject) + { + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; + } + else + { + shadowParms.viewportX = tr.refdef.x; + shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); + } + shadowParms.viewportWidth = PSHADOW_MAP_SIZE; + shadowParms.viewportHeight = PSHADOW_MAP_SIZE; + shadowParms.isPortal = qfalse; + shadowParms.isMirror = qfalse; + + shadowParms.fovX = 90; + shadowParms.fovY = 90; + + if (glRefConfig.framebufferObject) + shadowParms.targetFbo = tr.pshadowFbos[i]; + + shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW; + shadowParms.zFar = shadow->lightRadius; + + VectorCopy(shadow->lightOrigin, shadowParms.or.origin); + + VectorCopy(shadow->lightViewAxis[0], shadowParms.or.axis[0]); + VectorCopy(shadow->lightViewAxis[1], shadowParms.or.axis[1]); + VectorCopy(shadow->lightViewAxis[2], shadowParms.or.axis[2]); + + { + tr.viewCount++; + + tr.viewParms = shadowParms; + tr.viewParms.frameSceneNum = tr.frameSceneNum; + tr.viewParms.frameCount = tr.frameCount; + + firstDrawSurf = tr.refdef.numDrawSurfs; + + tr.viewCount++; + + // set viewParms.world + R_RotateForViewer (); + + { + float xmin, xmax, ymin, ymax, znear, zfar; + viewParms_t *dest = &tr.viewParms; + vec3_t pop; + + xmin = ymin = -shadow->viewRadius; + xmax = ymax = shadow->viewRadius; + znear = 0; + zfar = shadow->lightRadius; + + dest->projectionMatrix[0] = 2 / (xmax - xmin); + dest->projectionMatrix[4] = 0; + dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); + dest->projectionMatrix[12] =0; + + dest->projectionMatrix[1] = 0; + dest->projectionMatrix[5] = 2 / (ymax - ymin); + dest->projectionMatrix[9] = ( ymax + ymin ) / (ymax - ymin); // normally 0 + dest->projectionMatrix[13] = 0; + + dest->projectionMatrix[2] = 0; + dest->projectionMatrix[6] = 0; + dest->projectionMatrix[10] = 2 / (zfar - znear); + dest->projectionMatrix[14] = 0; + + dest->projectionMatrix[3] = 0; + dest->projectionMatrix[7] = 0; + dest->projectionMatrix[11] = 0; + dest->projectionMatrix[15] = 1; + + VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); + dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); + + VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); + dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); + + VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); + dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); + + VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); + dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); + + VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->or.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); + dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); + + for (j = 0; j < 5; j++) + { + dest->frustum[j].type = PLANE_NON_AXIAL; + SetPlaneSignbits (&dest->frustum[j]); + } + + dest->flags |= VPF_FARPLANEFRUSTUM; + } + + for (j = 0; j < shadow->numEntities; j++) + { + R_AddEntitySurface(shadow->entityNums[j]); + } + + R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + + if (!glRefConfig.framebufferObject) + R_AddCapShadowmapCmd( i, -1 ); + } + } +} + +static float CalcSplit(float n, float f, float i, float m) +{ + return (n * pow(f / n, i / m) + (f - n) * i / m) / 2.0f; +} + + +void R_RenderSunShadowMaps(const refdef_t *fd, int level) +{ + viewParms_t shadowParms; + vec4_t lightDir, lightCol; + vec3_t lightViewAxis[3]; + vec3_t lightOrigin; + float splitZNear, splitZFar, splitBias; + float viewZNear, viewZFar; + vec3_t lightviewBounds[2]; + qboolean lightViewIndependentOfCameraView = qfalse; + + if (r_forceSun->integer == 2) + { + int scale = 32768; + float angle = (fd->time % scale) / (float)scale * M_PI; + lightDir[0] = cos(angle); + lightDir[1] = sin(35.0f * M_PI / 180.0f); + lightDir[2] = sin(angle) * cos(35.0f * M_PI / 180.0f); + lightDir[3] = 0.0f; + + if (1) //((fd->time % (scale * 2)) < scale) + { + lightCol[0] = + lightCol[1] = + lightCol[2] = CLAMP(sin(angle) * 2.0f, 0.0f, 1.0f) * 2.0f; + lightCol[3] = 1.0f; + } + else + { + lightCol[0] = + lightCol[1] = + lightCol[2] = CLAMP(sin(angle) * 2.0f * 0.1f, 0.0f, 0.1f); + lightCol[3] = 1.0f; + } + + VectorCopy4(lightDir, tr.refdef.sunDir); + VectorCopy4(lightCol, tr.refdef.sunCol); + VectorScale4(lightCol, 0.2f, tr.refdef.sunAmbCol); + } + else + { + VectorCopy4(tr.refdef.sunDir, lightDir); + } + + viewZNear = r_shadowCascadeZNear->value; + viewZFar = r_shadowCascadeZFar->value; + splitBias = r_shadowCascadeZBias->value; + + switch(level) + { + case 0: + default: + //splitZNear = r_znear->value; + //splitZFar = 256; + splitZNear = viewZNear; + splitZFar = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; + break; + case 1: + splitZNear = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; + splitZFar = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; + //splitZNear = 256; + //splitZFar = 896; + break; + case 2: + splitZNear = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; + splitZFar = viewZFar; + //splitZNear = 896; + //splitZFar = 3072; + break; + } + + VectorCopy(fd->vieworg, lightOrigin); + + + // Make up a projection + VectorScale(lightDir, -1.0f, lightViewAxis[0]); + + if (lightViewIndependentOfCameraView) + { + // Use world up as light view up + VectorSet(lightViewAxis[2], 0, 0, 1); + } + else if (level == 0) + { + // Level 0 tries to use a diamond texture orientation relative to camera view + // Use halfway between camera view forward and left for light view up + VectorAdd(fd->viewaxis[0], fd->viewaxis[1], lightViewAxis[2]); + } + else + { + // Use camera view up as light view up + VectorCopy(fd->viewaxis[2], lightViewAxis[2]); + } + + // Check if too close to parallel to light direction + if (abs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) + { + if (lightViewIndependentOfCameraView) + { + // Use world left as light view up + VectorSet(lightViewAxis[2], 0, 1, 0); + } + else if (level == 0) + { + // Level 0 tries to use a diamond texture orientation relative to camera view + // Use halfway between camera view forward and up for light view up + VectorAdd(fd->viewaxis[0], fd->viewaxis[2], lightViewAxis[2]); + } + else + { + // Use camera view left as light view up + VectorCopy(fd->viewaxis[1], lightViewAxis[2]); + } + } + + // clean axes + CrossProduct(lightViewAxis[2], lightViewAxis[0], lightViewAxis[1]); + VectorNormalize(lightViewAxis[1]); + CrossProduct(lightViewAxis[0], lightViewAxis[1], lightViewAxis[2]); + + // Create bounds for light projection using slice of view projection + { + matrix_t lightViewMatrix; + vec4_t point, base, lightViewPoint; + float lx, ly; + + base[3] = 1; + point[3] = 1; + lightViewPoint[3] = 1; + + Matrix16View(lightViewAxis, lightOrigin, lightViewMatrix); + + ClearBounds(lightviewBounds[0], lightviewBounds[1]); + + // add view near plane + lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f); + ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f); + VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base); + + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, -ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, -ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + + // add view far plane + lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f); + ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f); + VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base); + + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, -ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, -ly, fd->viewaxis[2], point); + Matrix16Transform(lightViewMatrix, point, lightViewPoint); + AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + + if (!glRefConfig.depthClamp) + lightviewBounds[0][0] = lightviewBounds[1][0] - 8192; + + // Moving the Light in Texel-Sized Increments + // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx + // + if (lightViewIndependentOfCameraView) + { + float cascadeBound, worldUnitsPerTexel, invWorldUnitsPerTexel; + + cascadeBound = MAX(lightviewBounds[1][0] - lightviewBounds[0][0], lightviewBounds[1][1] - lightviewBounds[0][1]); + cascadeBound = MAX(cascadeBound, lightviewBounds[1][2] - lightviewBounds[0][2]); + worldUnitsPerTexel = cascadeBound / tr.sunShadowFbo[level]->width; + invWorldUnitsPerTexel = 1.0f / worldUnitsPerTexel; + + VectorScale(lightviewBounds[0], invWorldUnitsPerTexel, lightviewBounds[0]); + lightviewBounds[0][0] = floor(lightviewBounds[0][0]); + lightviewBounds[0][1] = floor(lightviewBounds[0][1]); + lightviewBounds[0][2] = floor(lightviewBounds[0][2]); + VectorScale(lightviewBounds[0], worldUnitsPerTexel, lightviewBounds[0]); + + VectorScale(lightviewBounds[1], invWorldUnitsPerTexel, lightviewBounds[1]); + lightviewBounds[1][0] = floor(lightviewBounds[1][0]); + lightviewBounds[1][1] = floor(lightviewBounds[1][1]); + lightviewBounds[1][2] = floor(lightviewBounds[1][2]); + VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); + } + + //ri.Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); + //ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); + } + + + { + int firstDrawSurf; + + Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); + + if (glRefConfig.framebufferObject) + { + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; + } + else + { + shadowParms.viewportX = tr.refdef.x; + shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.sunShadowFbo[level]->height ); + } + shadowParms.viewportWidth = tr.sunShadowFbo[level]->width; + shadowParms.viewportHeight = tr.sunShadowFbo[level]->height; + shadowParms.isPortal = qfalse; + shadowParms.isMirror = qfalse; + + shadowParms.fovX = 90; + shadowParms.fovY = 90; + + if (glRefConfig.framebufferObject) + shadowParms.targetFbo = tr.sunShadowFbo[level]; + + shadowParms.flags = VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC; + shadowParms.zFar = lightviewBounds[1][0]; + + VectorCopy(lightOrigin, shadowParms.or.origin); + + VectorCopy(lightViewAxis[0], shadowParms.or.axis[0]); + VectorCopy(lightViewAxis[1], shadowParms.or.axis[1]); + VectorCopy(lightViewAxis[2], shadowParms.or.axis[2]); + + VectorCopy(lightOrigin, shadowParms.pvsOrigin ); + + { + tr.viewCount++; + + tr.viewParms = shadowParms; + tr.viewParms.frameSceneNum = tr.frameSceneNum; + tr.viewParms.frameCount = tr.frameCount; + + firstDrawSurf = tr.refdef.numDrawSurfs; + + tr.viewCount++; + + // set viewParms.world + R_RotateForViewer (); + + R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); + + R_AddWorldSurfaces (); + + R_AddPolygonSurfaces(); + + R_AddEntitySurfaces (); + + R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + } + + Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]); + } +} diff --git a/codemp/rd-rend2/tr_marks.c b/codemp/rd-rend2/tr_marks.c new file mode 100644 index 0000000000..4d0705656c --- /dev/null +++ b/codemp/rd-rend2/tr_marks.c @@ -0,0 +1,466 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_marks.c -- polygon projection on the world polygons + +#include "tr_local.h" +//#include "assert.h" + +#define MAX_VERTS_ON_POLY 64 + +#define MARKER_OFFSET 0 // 1 + +/* +============= +R_ChopPolyBehindPlane + +Out must have space for two more vertexes than in +============= +*/ +#define SIDE_FRONT 0 +#define SIDE_BACK 1 +#define SIDE_ON 2 +static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], + int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], + vec3_t normal, vec_t dist, vec_t epsilon) { + float dists[MAX_VERTS_ON_POLY+4] = { 0 }; + int sides[MAX_VERTS_ON_POLY+4] = { 0 }; + int counts[3]; + float dot; + int i, j; + float *p1, *p2, *clip; + float d; + + // don't clip if it might overflow + if ( numInPoints >= MAX_VERTS_ON_POLY - 2 ) { + *numOutPoints = 0; + return; + } + + counts[0] = counts[1] = counts[2] = 0; + + // determine sides for each point + for ( i = 0 ; i < numInPoints ; i++ ) { + dot = DotProduct( inPoints[i], normal ); + dot -= dist; + dists[i] = dot; + if ( dot > epsilon ) { + sides[i] = SIDE_FRONT; + } else if ( dot < -epsilon ) { + sides[i] = SIDE_BACK; + } else { + sides[i] = SIDE_ON; + } + counts[sides[i]]++; + } + sides[i] = sides[0]; + dists[i] = dists[0]; + + *numOutPoints = 0; + + if ( !counts[0] ) { + return; + } + if ( !counts[1] ) { + *numOutPoints = numInPoints; + Com_Memcpy( outPoints, inPoints, numInPoints * sizeof(vec3_t) ); + return; + } + + for ( i = 0 ; i < numInPoints ; i++ ) { + p1 = inPoints[i]; + clip = outPoints[ *numOutPoints ]; + + if ( sides[i] == SIDE_ON ) { + VectorCopy( p1, clip ); + (*numOutPoints)++; + continue; + } + + if ( sides[i] == SIDE_FRONT ) { + VectorCopy( p1, clip ); + (*numOutPoints)++; + clip = outPoints[ *numOutPoints ]; + } + + if ( sides[i+1] == SIDE_ON || sides[i+1] == sides[i] ) { + continue; + } + + // generate a split point + p2 = inPoints[ (i+1) % numInPoints ]; + + d = dists[i] - dists[i+1]; + if ( d == 0 ) { + dot = 0; + } else { + dot = dists[i] / d; + } + + // clip xyz + + for (j=0 ; j<3 ; j++) { + clip[j] = p1[j] + dot * ( p2[j] - p1[j] ); + } + + (*numOutPoints)++; + } +} + +/* +================= +R_BoxSurfaces_r + +================= +*/ +void R_BoxSurfaces_r(mnode_t *node, vec3_t mins, vec3_t maxs, surfaceType_t **list, int listsize, int *listlength, vec3_t dir) { + + int s, c; + msurface_t *surf; + int *mark; + + // do the tail recursion in a loop + while ( node->contents == -1 ) { + s = BoxOnPlaneSide( mins, maxs, node->plane ); + if (s == 1) { + node = node->children[0]; + } else if (s == 2) { + node = node->children[1]; + } else { + R_BoxSurfaces_r(node->children[0], mins, maxs, list, listsize, listlength, dir); + node = node->children[1]; + } + } + + // add the individual surfaces + mark = tr.world->marksurfaces + node->firstmarksurface; + c = node->nummarksurfaces; + while (c--) { + int *surfViewCount; + // + if (*listlength >= listsize) break; + // + surfViewCount = &tr.world->surfacesViewCount[*mark]; + surf = tr.world->surfaces + *mark; + // check if the surface has NOIMPACT or NOMARKS set + if ( ( surf->shader->surfaceFlags & ( SURF_NOIMPACT | SURF_NOMARKS ) ) + || ( surf->shader->contentFlags & CONTENTS_FOG ) ) { + *surfViewCount = tr.viewCount; + } + // extra check for surfaces to avoid list overflows + else if (*(surf->data) == SF_FACE) { + // the face plane should go through the box + s = BoxOnPlaneSide( mins, maxs, &surf->cullinfo.plane ); + if (s == 1 || s == 2) { + *surfViewCount = tr.viewCount; + } else if (DotProduct(surf->cullinfo.plane.normal, dir) > -0.5) { + // don't add faces that make sharp angles with the projection direction + *surfViewCount = tr.viewCount; + } + } + else if (*(surf->data) != SF_GRID && + *(surf->data) != SF_TRIANGLES) + *surfViewCount = tr.viewCount; + // check the viewCount because the surface may have + // already been added if it spans multiple leafs + if (*surfViewCount != tr.viewCount) { + *surfViewCount = tr.viewCount; + list[*listlength] = surf->data; + (*listlength)++; + } + mark++; + } +} + +/* +================= +R_AddMarkFragments + +================= +*/ +void R_AddMarkFragments(int numClipPoints, vec3_t clipPoints[2][MAX_VERTS_ON_POLY], + int numPlanes, vec3_t *normals, float *dists, + int maxPoints, vec3_t pointBuffer, + int maxFragments, markFragment_t *fragmentBuffer, + int *returnedPoints, int *returnedFragments, + vec3_t mins, vec3_t maxs) { + int pingPong, i; + markFragment_t *mf; + + // chop the surface by all the bounding planes of the to be projected polygon + pingPong = 0; + + for ( i = 0 ; i < numPlanes ; i++ ) { + + R_ChopPolyBehindPlane( numClipPoints, clipPoints[pingPong], + &numClipPoints, clipPoints[!pingPong], + normals[i], dists[i], 0.5 ); + pingPong ^= 1; + if ( numClipPoints == 0 ) { + break; + } + } + // completely clipped away? + if ( numClipPoints == 0 ) { + return; + } + + // add this fragment to the returned list + if ( numClipPoints + (*returnedPoints) > maxPoints ) { + return; // not enough space for this polygon + } + /* + // all the clip points should be within the bounding box + for ( i = 0 ; i < numClipPoints ; i++ ) { + int j; + for ( j = 0 ; j < 3 ; j++ ) { + if (clipPoints[pingPong][i][j] < mins[j] - 0.5) break; + if (clipPoints[pingPong][i][j] > maxs[j] + 0.5) break; + } + if (j < 3) break; + } + if (i < numClipPoints) return; + */ + + mf = fragmentBuffer + (*returnedFragments); + mf->firstPoint = (*returnedPoints); + mf->numPoints = numClipPoints; + Com_Memcpy( pointBuffer + (*returnedPoints) * 3, clipPoints[pingPong], numClipPoints * sizeof(vec3_t) ); + + (*returnedPoints) += numClipPoints; + (*returnedFragments)++; +} + +/* +================= +R_MarkFragments + +================= +*/ +int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, + int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) { + int numsurfaces, numPlanes; + int i, j, k, m, n; + surfaceType_t *surfaces[64]; + vec3_t mins, maxs; + int returnedFragments; + int returnedPoints; + vec3_t normals[MAX_VERTS_ON_POLY+2]; + float dists[MAX_VERTS_ON_POLY+2]; + vec3_t clipPoints[2][MAX_VERTS_ON_POLY]; + int numClipPoints; + float *v; + srfGridMesh_t *cv; + srfTriangle_t *tri; + srfVert_t *dv; + vec3_t normal; + vec3_t projectionDir; + vec3_t v1, v2; + + if (numPoints <= 0) { + return 0; + } + + //increment view count for double check prevention + tr.viewCount++; + + // + VectorNormalize2( projection, projectionDir ); + // find all the brushes that are to be considered + ClearBounds( mins, maxs ); + for ( i = 0 ; i < numPoints ; i++ ) { + vec3_t temp; + + AddPointToBounds( points[i], mins, maxs ); + VectorAdd( points[i], projection, temp ); + AddPointToBounds( temp, mins, maxs ); + // make sure we get all the leafs (also the one(s) in front of the hit surface) + VectorMA( points[i], -20, projectionDir, temp ); + AddPointToBounds( temp, mins, maxs ); + } + + if (numPoints > MAX_VERTS_ON_POLY) numPoints = MAX_VERTS_ON_POLY; + // create the bounding planes for the to be projected polygon + for ( i = 0 ; i < numPoints ; i++ ) { + VectorSubtract(points[(i+1)%numPoints], points[i], v1); + VectorAdd(points[i], projection, v2); + VectorSubtract(points[i], v2, v2); + CrossProduct(v1, v2, normals[i]); + VectorNormalizeFast(normals[i]); + dists[i] = DotProduct(normals[i], points[i]); + } + // add near and far clipping planes for projection + VectorCopy(projectionDir, normals[numPoints]); + dists[numPoints] = DotProduct(normals[numPoints], points[0]) - 32; + VectorCopy(projectionDir, normals[numPoints+1]); + VectorInverse(normals[numPoints+1]); + dists[numPoints+1] = DotProduct(normals[numPoints+1], points[0]) - 20; + numPlanes = numPoints + 2; + + numsurfaces = 0; + R_BoxSurfaces_r(tr.world->nodes, mins, maxs, surfaces, 64, &numsurfaces, projectionDir); + //assert(numsurfaces <= 64); + //assert(numsurfaces != 64); + + returnedPoints = 0; + returnedFragments = 0; + + for ( i = 0 ; i < numsurfaces ; i++ ) { + + if (*surfaces[i] == SF_GRID) { + + cv = (srfGridMesh_t *) surfaces[i]; + for ( m = 0 ; m < cv->height - 1 ; m++ ) { + for ( n = 0 ; n < cv->width - 1 ; n++ ) { + // We triangulate the grid and chop all triangles within + // the bounding planes of the to be projected polygon. + // LOD is not taken into account, not such a big deal though. + // + // It's probably much nicer to chop the grid itself and deal + // with this grid as a normal SF_GRID surface so LOD will + // be applied. However the LOD of that chopped grid must + // be synced with the LOD of the original curve. + // One way to do this; the chopped grid shares vertices with + // the original curve. When LOD is applied to the original + // curve the unused vertices are flagged. Now the chopped curve + // should skip the flagged vertices. This still leaves the + // problems with the vertices at the chopped grid edges. + // + // To avoid issues when LOD applied to "hollow curves" (like + // the ones around many jump pads) we now just add a 2 unit + // offset to the triangle vertices. + // The offset is added in the vertex normal vector direction + // so all triangles will still fit together. + // The 2 unit offset should avoid pretty much all LOD problems. + + numClipPoints = 3; + + dv = cv->verts + m * cv->width + n; + + VectorCopy(dv[0].xyz, clipPoints[0][0]); + VectorMA(clipPoints[0][0], MARKER_OFFSET, dv[0].normal, clipPoints[0][0]); + VectorCopy(dv[cv->width].xyz, clipPoints[0][1]); + VectorMA(clipPoints[0][1], MARKER_OFFSET, dv[cv->width].normal, clipPoints[0][1]); + VectorCopy(dv[1].xyz, clipPoints[0][2]); + VectorMA(clipPoints[0][2], MARKER_OFFSET, dv[1].normal, clipPoints[0][2]); + // check the normal of this triangle + VectorSubtract(clipPoints[0][0], clipPoints[0][1], v1); + VectorSubtract(clipPoints[0][2], clipPoints[0][1], v2); + CrossProduct(v1, v2, normal); + VectorNormalizeFast(normal); + if (DotProduct(normal, projectionDir) < -0.1) { + // add the fragments of this triangle + R_AddMarkFragments(numClipPoints, clipPoints, + numPlanes, normals, dists, + maxPoints, pointBuffer, + maxFragments, fragmentBuffer, + &returnedPoints, &returnedFragments, mins, maxs); + + if ( returnedFragments == maxFragments ) { + return returnedFragments; // not enough space for more fragments + } + } + + VectorCopy(dv[1].xyz, clipPoints[0][0]); + VectorMA(clipPoints[0][0], MARKER_OFFSET, dv[1].normal, clipPoints[0][0]); + VectorCopy(dv[cv->width].xyz, clipPoints[0][1]); + VectorMA(clipPoints[0][1], MARKER_OFFSET, dv[cv->width].normal, clipPoints[0][1]); + VectorCopy(dv[cv->width+1].xyz, clipPoints[0][2]); + VectorMA(clipPoints[0][2], MARKER_OFFSET, dv[cv->width+1].normal, clipPoints[0][2]); + // check the normal of this triangle + VectorSubtract(clipPoints[0][0], clipPoints[0][1], v1); + VectorSubtract(clipPoints[0][2], clipPoints[0][1], v2); + CrossProduct(v1, v2, normal); + VectorNormalizeFast(normal); + if (DotProduct(normal, projectionDir) < -0.05) { + // add the fragments of this triangle + R_AddMarkFragments(numClipPoints, clipPoints, + numPlanes, normals, dists, + maxPoints, pointBuffer, + maxFragments, fragmentBuffer, + &returnedPoints, &returnedFragments, mins, maxs); + + if ( returnedFragments == maxFragments ) { + return returnedFragments; // not enough space for more fragments + } + } + } + } + } + else if (*surfaces[i] == SF_FACE) { + + srfSurfaceFace_t *surf = ( srfSurfaceFace_t * ) surfaces[i]; + + // check the normal of this face + if (DotProduct(surf->plane.normal, projectionDir) > -0.5) { + continue; + } + + for(k = 0, tri = surf->triangles; k < surf->numTriangles; k++, tri++) + { + for(j = 0; j < 3; j++) + { + v = surf->verts[tri->indexes[j]].xyz; + VectorMA(v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j]); + } + + // add the fragments of this face + R_AddMarkFragments( 3 , clipPoints, + numPlanes, normals, dists, + maxPoints, pointBuffer, + maxFragments, fragmentBuffer, + &returnedPoints, &returnedFragments, mins, maxs); + if ( returnedFragments == maxFragments ) { + return returnedFragments; // not enough space for more fragments + } + } + } + else if(*surfaces[i] == SF_TRIANGLES && r_marksOnTriangleMeshes->integer) { + + srfTriangles_t *surf = (srfTriangles_t *) surfaces[i]; + + for(k = 0, tri = surf->triangles; k < surf->numTriangles; k++, tri++) + { + for(j = 0; j < 3; j++) + { + v = surf->verts[tri->indexes[j]].xyz; + VectorMA(v, MARKER_OFFSET, surf->verts[tri->indexes[j]].normal, clipPoints[0][j]); + } + + // add the fragments of this face + R_AddMarkFragments(3, clipPoints, + numPlanes, normals, dists, + maxPoints, pointBuffer, + maxFragments, fragmentBuffer, &returnedPoints, &returnedFragments, mins, maxs); + if(returnedFragments == maxFragments) + { + return returnedFragments; // not enough space for more fragments + } + } + } + } + return returnedFragments; +} + + + + + diff --git a/codemp/rd-rend2/tr_mesh.c b/codemp/rd-rend2/tr_mesh.c new file mode 100644 index 0000000000..28c2e5fb30 --- /dev/null +++ b/codemp/rd-rend2/tr_mesh.c @@ -0,0 +1,401 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_mesh.c: triangle model functions + +#include "tr_local.h" + +static float ProjectRadius( float r, vec3_t location ) +{ + float pr; + float dist; + float c; + vec3_t p; + float projected[4]; + + c = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin ); + dist = DotProduct( tr.viewParms.or.axis[0], location ) - c; + + if ( dist <= 0 ) + return 0; + + p[0] = 0; + p[1] = fabs( r ); + p[2] = -dist; + + projected[0] = p[0] * tr.viewParms.projectionMatrix[0] + + p[1] * tr.viewParms.projectionMatrix[4] + + p[2] * tr.viewParms.projectionMatrix[8] + + tr.viewParms.projectionMatrix[12]; + + projected[1] = p[0] * tr.viewParms.projectionMatrix[1] + + p[1] * tr.viewParms.projectionMatrix[5] + + p[2] * tr.viewParms.projectionMatrix[9] + + tr.viewParms.projectionMatrix[13]; + + projected[2] = p[0] * tr.viewParms.projectionMatrix[2] + + p[1] * tr.viewParms.projectionMatrix[6] + + p[2] * tr.viewParms.projectionMatrix[10] + + tr.viewParms.projectionMatrix[14]; + + projected[3] = p[0] * tr.viewParms.projectionMatrix[3] + + p[1] * tr.viewParms.projectionMatrix[7] + + p[2] * tr.viewParms.projectionMatrix[11] + + tr.viewParms.projectionMatrix[15]; + + + pr = projected[1] / projected[3]; + + if ( pr > 1.0f ) + pr = 1.0f; + + return pr; +} + +/* +============= +R_CullModel +============= +*/ +static int R_CullModel( mdvModel_t *model, trRefEntity_t *ent ) { + vec3_t bounds[2]; + mdvFrame_t *oldFrame, *newFrame; + int i; + + // compute frame pointers + newFrame = model->frames + ent->e.frame; + oldFrame = model->frames + ent->e.oldframe; + + // cull bounding sphere ONLY if this is not an upscaled entity + if ( !ent->e.nonNormalizedAxes ) + { + if ( ent->e.frame == ent->e.oldframe ) + { + switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) + { + case CULL_OUT: + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + + case CULL_IN: + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + + case CULL_CLIP: + tr.pc.c_sphere_cull_md3_clip++; + break; + } + } + else + { + int sphereCull, sphereCullB; + + sphereCull = R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ); + if ( newFrame == oldFrame ) { + sphereCullB = sphereCull; + } else { + sphereCullB = R_CullLocalPointAndRadius( oldFrame->localOrigin, oldFrame->radius ); + } + + if ( sphereCull == sphereCullB ) + { + if ( sphereCull == CULL_OUT ) + { + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + } + else if ( sphereCull == CULL_IN ) + { + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + } + else + { + tr.pc.c_sphere_cull_md3_clip++; + } + } + } + } + + // calculate a bounding box in the current coordinate system + for (i = 0 ; i < 3 ; i++) { + bounds[0][i] = oldFrame->bounds[0][i] < newFrame->bounds[0][i] ? oldFrame->bounds[0][i] : newFrame->bounds[0][i]; + bounds[1][i] = oldFrame->bounds[1][i] > newFrame->bounds[1][i] ? oldFrame->bounds[1][i] : newFrame->bounds[1][i]; + } + + switch ( R_CullLocalBox( bounds ) ) + { + case CULL_IN: + tr.pc.c_box_cull_md3_in++; + return CULL_IN; + case CULL_CLIP: + tr.pc.c_box_cull_md3_clip++; + return CULL_CLIP; + case CULL_OUT: + default: + tr.pc.c_box_cull_md3_out++; + return CULL_OUT; + } +} + + +/* +================= +R_ComputeLOD + +================= +*/ +int R_ComputeLOD( trRefEntity_t *ent ) { + float radius; + float flod, lodscale; + float projectedRadius; + mdvFrame_t *frame; + mdrHeader_t *mdr; + mdrFrame_t *mdrframe; + int lod; + + if ( tr.currentModel->numLods < 2 ) + { + // model has only 1 LOD level, skip computations and bias + lod = 0; + } + else + { + // multiple LODs exist, so compute projected bounding sphere + // and use that as a criteria for selecting LOD + + if(tr.currentModel->type == MOD_MDR) + { + int frameSize; + mdr = (mdrHeader_t *) tr.currentModel->modelData; + frameSize = (size_t) (&((mdrFrame_t *)0)->bones[mdr->numBones]); + + mdrframe = (mdrFrame_t *) ((byte *) mdr + mdr->ofsFrames + frameSize * ent->e.frame); + + radius = RadiusFromBounds(mdrframe->bounds[0], mdrframe->bounds[1]); + } + else + { + //frame = ( md3Frame_t * ) ( ( ( unsigned char * ) tr.currentModel->md3[0] ) + tr.currentModel->md3[0]->ofsFrames ); + frame = tr.currentModel->mdv[0]->frames; + + frame += ent->e.frame; + + radius = RadiusFromBounds( frame->bounds[0], frame->bounds[1] ); + } + + if ( ( projectedRadius = ProjectRadius( radius, ent->e.origin ) ) != 0 ) + { + lodscale = r_lodscale->value; + if (lodscale > 20) lodscale = 20; + flod = 1.0f - projectedRadius * lodscale; + } + else + { + // object intersects near view plane, e.g. view weapon + flod = 0; + } + + flod *= tr.currentModel->numLods; + lod = ri.ftol(flod); + + if ( lod < 0 ) + { + lod = 0; + } + else if ( lod >= tr.currentModel->numLods ) + { + lod = tr.currentModel->numLods - 1; + } + } + + lod += r_lodbias->integer; + + if ( lod >= tr.currentModel->numLods ) + lod = tr.currentModel->numLods - 1; + if ( lod < 0 ) + lod = 0; + + return lod; +} + +/* +================= +R_ComputeFogNum + +================= +*/ +int R_ComputeFogNum( mdvModel_t *model, trRefEntity_t *ent ) { + int i, j; + fog_t *fog; + mdvFrame_t *mdvFrame; + vec3_t localOrigin; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + // FIXME: non-normalized axis issues + mdvFrame = model->frames + ent->e.frame; + VectorAdd( ent->e.origin, mdvFrame->localOrigin, localOrigin ); + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( localOrigin[j] - mdvFrame->radius >= fog->bounds[1][j] ) { + break; + } + if ( localOrigin[j] + mdvFrame->radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + +/* +================= +R_AddMD3Surfaces + +================= +*/ +void R_AddMD3Surfaces( trRefEntity_t *ent ) { + int i; + mdvModel_t *model = NULL; + mdvSurface_t *surface = NULL; + shader_t *shader = NULL; + int cull; + int lod; + int fogNum; + qboolean personalModel; + + // don't add third_person objects if not in a portal + personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal + || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); + + if ( ent->e.renderfx & RF_WRAP_FRAMES ) { + ent->e.frame %= tr.currentModel->mdv[0]->numFrames; + ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; + } + + // + // Validate the frames so there is no chance of a crash. + // This will write directly into the entity structure, so + // when the surfaces are rendered, they don't need to be + // range checked again. + // + if ( (ent->e.frame >= tr.currentModel->mdv[0]->numFrames) + || (ent->e.frame < 0) + || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) + || (ent->e.oldframe < 0) ) { + ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", + ent->e.oldframe, ent->e.frame, + tr.currentModel->name ); + ent->e.frame = 0; + ent->e.oldframe = 0; + } + + // + // compute LOD + // + lod = R_ComputeLOD( ent ); + + model = tr.currentModel->mdv[lod]; + + // + // cull the entire model if merged bounding box of both frames + // is outside the view frustum. + // + cull = R_CullModel ( model, ent ); + if ( cull == CULL_OUT ) { + return; + } + + // + // set up lighting now that we know we aren't culled + // + if ( !personalModel || r_shadows->integer > 1 ) { + R_SetupEntityLighting( &tr.refdef, ent ); + } + + // + // see if we are in a fog volume + // + fogNum = R_ComputeFogNum( model, ent ); + + // + // draw all surfaces + // + surface = model->surfaces; + for ( i = 0 ; i < model->numSurfaces ; i++ ) { + + if ( ent->e.customShader ) { + shader = R_GetShaderByHandle( ent->e.customShader ); + } else if ( ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins ) { + skin_t *skin; + int j; + + skin = R_GetSkinByHandle( ent->e.customSkin ); + + // match the surface name to something in the skin file + shader = tr.defaultShader; + for ( j = 0 ; j < skin->numSurfaces ; j++ ) { + // the names have both been lowercased + if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { + shader = skin->surfaces[j]->shader; + break; + } + } + if (shader == tr.defaultShader) { + ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); + } + else if (shader->defaultShader) { + ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); + } + //} else if ( surface->numShaders <= 0 ) { + //shader = tr.defaultShader; + } else { + //md3Shader = (md3Shader_t *) ( (byte *)surface + surface->ofsShaders ); + //md3Shader += ent->e.skinNum % surface->numShaders; + //shader = tr.shaders[ md3Shader->shaderIndex ]; + shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ]; + } + + // don't add third_person objects if not viewing through a portal + if(!personalModel) + { + srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; + + R_AddDrawSurf((void *)vboSurface, shader, fogNum, qfalse, qfalse ); + } + + surface++; + } + +} + + + + + diff --git a/codemp/rd-rend2/tr_model.c b/codemp/rd-rend2/tr_model.c new file mode 100644 index 0000000000..2c567afc73 --- /dev/null +++ b/codemp/rd-rend2/tr_model.c @@ -0,0 +1,1569 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_models.c -- model loading and caching + +#include "tr_local.h" + +#define LL(x) x=LittleLong(x) + +static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, int bufferSize, const char *modName); +static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name ); +static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); + +/* +==================== +R_RegisterMD3 +==================== +*/ +qhandle_t R_RegisterMD3(const char *name, model_t *mod) +{ + union { + unsigned *u; + void *v; + } buf; + int size; + int lod; + int ident; + qboolean loaded = qfalse; + int numLoaded; + char filename[MAX_QPATH], namebuf[MAX_QPATH+20]; + char *fext, defex[] = "md3"; + + numLoaded = 0; + + strcpy(filename, name); + + fext = strchr(filename, '.'); + if(!fext) + fext = defex; + else + { + *fext = '\0'; + fext++; + } + + for (lod = MD3_MAX_LODS - 1 ; lod >= 0 ; lod--) + { + if(lod) + Com_sprintf(namebuf, sizeof(namebuf), "%s_%d.%s", filename, lod, fext); + else + Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); + + size = ri.FS_ReadFile( namebuf, &buf.v ); + if(!buf.u) + continue; + + ident = LittleLong(* (unsigned *) buf.u); + if (ident == MD4_IDENT) + loaded = R_LoadMD4(mod, buf.u, name); + else + { + if (ident == MD3_IDENT) + loaded = R_LoadMD3(mod, lod, buf.u, size, name); + else + ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); + } + + ri.FS_FreeFile(buf.v); + + if(loaded) + { + mod->numLods++; + numLoaded++; + } + else + break; + } + + if(numLoaded) + { + // duplicate into higher lod spots that weren't + // loaded, in case the user changes r_lodbias on the fly + for(lod--; lod >= 0; lod--) + { + mod->numLods++; + mod->mdv[lod] = mod->mdv[lod + 1]; + } + + return mod->index; + } + +#ifdef _DEBUG + ri.Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); +#endif + + mod->type = MOD_BAD; + return 0; +} + +/* +==================== +R_RegisterMDR +==================== +*/ +qhandle_t R_RegisterMDR(const char *name, model_t *mod) +{ + union { + unsigned *u; + void *v; + } buf; + int ident; + qboolean loaded = qfalse; + int filesize; + + filesize = ri.FS_ReadFile(name, (void **) &buf.v); + if(!buf.u) + { + mod->type = MOD_BAD; + return 0; + } + + ident = LittleLong(*(unsigned *)buf.u); + if(ident == MDR_IDENT) + loaded = R_LoadMDR(mod, buf.u, filesize, name); + + ri.FS_FreeFile (buf.v); + + if(!loaded) + { + ri.Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); + mod->type = MOD_BAD; + return 0; + } + + return mod->index; +} + +/* +==================== +R_RegisterIQM +==================== +*/ +qhandle_t R_RegisterIQM(const char *name, model_t *mod) +{ + union { + unsigned *u; + void *v; + } buf; + qboolean loaded = qfalse; + int filesize; + + filesize = ri.FS_ReadFile(name, (void **) &buf.v); + if(!buf.u) + { + mod->type = MOD_BAD; + return 0; + } + + loaded = R_LoadIQM(mod, buf.u, filesize, name); + + ri.FS_FreeFile (buf.v); + + if(!loaded) + { + ri.Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); + mod->type = MOD_BAD; + return 0; + } + + return mod->index; +} + + +typedef struct +{ + char *ext; + qhandle_t (*ModelLoader)( const char *, model_t * ); +} modelExtToLoaderMap_t; + +// Note that the ordering indicates the order of preference used +// when there are multiple models of different formats available +static modelExtToLoaderMap_t modelLoaders[ ] = +{ + { "iqm", R_RegisterIQM }, + { "mdr", R_RegisterMDR }, + { "md4", R_RegisterMD3 }, + { "md3", R_RegisterMD3 } +}; + +static int numModelLoaders = ARRAY_LEN(modelLoaders); + +//=============================================================================== + +/* +** R_GetModelByHandle +*/ +model_t *R_GetModelByHandle( qhandle_t index ) { + model_t *mod; + + // out of range gets the defualt model + if ( index < 1 || index >= tr.numModels ) { + return tr.models[0]; + } + + mod = tr.models[index]; + + return mod; +} + +//=============================================================================== + +/* +** R_AllocModel +*/ +model_t *R_AllocModel( void ) { + model_t *mod; + + if ( tr.numModels == MAX_MOD_KNOWN ) { + return NULL; + } + + mod = ri.Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); + mod->index = tr.numModels; + tr.models[tr.numModels] = mod; + tr.numModels++; + + return mod; +} + +/* +==================== +RE_RegisterModel + +Loads in a model for the given name + +Zero will be returned if the model fails to load. +An entry will be retained for failed models as an +optimization to prevent disk rescanning if they are +asked for again. +==================== +*/ +qhandle_t RE_RegisterModel( const char *name ) { + model_t *mod; + qhandle_t hModel; + qboolean orgNameFailed = qfalse; + int orgLoader = -1; + int i; + char localName[ MAX_QPATH ]; + const char *ext; + char altName[ MAX_QPATH ]; + + if ( !name || !name[0] ) { + ri.Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); + return 0; + } + + if ( strlen( name ) >= MAX_QPATH ) { + ri.Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); + return 0; + } + + // + // search the currently loaded models + // + for ( hModel = 1 ; hModel < tr.numModels; hModel++ ) { + mod = tr.models[hModel]; + if ( !strcmp( mod->name, name ) ) { + if( mod->type == MOD_BAD ) { + return 0; + } + return hModel; + } + } + + // allocate a new model_t + + if ( ( mod = R_AllocModel() ) == NULL ) { + ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); + return 0; + } + + // only set the name after the model has been successfully loaded + Q_strncpyz( mod->name, name, sizeof( mod->name ) ); + + + R_IssuePendingRenderCommands(); + + mod->type = MOD_BAD; + mod->numLods = 0; + + // + // load the files + // + Q_strncpyz( localName, name, MAX_QPATH ); + + ext = COM_GetExtension( localName ); + + if( *ext ) + { + // Look for the correct loader and use it + for( i = 0; i < numModelLoaders; i++ ) + { + if( !Q_stricmp( ext, modelLoaders[ i ].ext ) ) + { + // Load + hModel = modelLoaders[ i ].ModelLoader( localName, mod ); + break; + } + } + + // A loader was found + if( i < numModelLoaders ) + { + if( !hModel ) + { + // Loader failed, most likely because the file isn't there; + // try again without the extension + orgNameFailed = qtrue; + orgLoader = i; + COM_StripExtension( name, localName, MAX_QPATH ); + } + else + { + // Something loaded + return mod->index; + } + } + } + + // Try and find a suitable match using all + // the model formats supported + for( i = 0; i < numModelLoaders; i++ ) + { + if (i == orgLoader) + continue; + + Com_sprintf( altName, sizeof (altName), "%s.%s", localName, modelLoaders[ i ].ext ); + + // Load + hModel = modelLoaders[ i ].ModelLoader( altName, mod ); + + if( hModel ) + { + if( orgNameFailed ) + { + ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", + name, altName ); + } + + break; + } + } + + return hModel; +} + +/* +================= +R_LoadMD3 +================= +*/ +static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, const char *modName) +{ + int f, i, j, k; + + md3Header_t *md3Model; + md3Frame_t *md3Frame; + md3Surface_t *md3Surf; + md3Shader_t *md3Shader; + md3Triangle_t *md3Tri; + md3St_t *md3st; + md3XyzNormal_t *md3xyz; + md3Tag_t *md3Tag; + + mdvModel_t *mdvModel; + mdvFrame_t *frame; + mdvSurface_t *surf;//, *surface; + int *shaderIndex; + srfTriangle_t *tri; + mdvVertex_t *v; + mdvSt_t *st; + mdvTag_t *tag; + mdvTagName_t *tagName; + + int version; + int size; + + md3Model = (md3Header_t *) buffer; + + version = LittleLong(md3Model->version); + if(version != MD3_VERSION) + { + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); + return qfalse; + } + + mod->type = MOD_MESH; + size = LittleLong(md3Model->ofsEnd); + mod->dataSize += size; + mdvModel = mod->mdv[lod] = ri.Hunk_Alloc(sizeof(mdvModel_t), h_low); + +// Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); + + LL(md3Model->ident); + LL(md3Model->version); + LL(md3Model->numFrames); + LL(md3Model->numTags); + LL(md3Model->numSurfaces); + LL(md3Model->ofsFrames); + LL(md3Model->ofsTags); + LL(md3Model->ofsSurfaces); + LL(md3Model->ofsEnd); + + if(md3Model->numFrames < 1) + { + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); + return qfalse; + } + + // swap all the frames + mdvModel->numFrames = md3Model->numFrames; + mdvModel->frames = frame = ri.Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); + + md3Frame = (md3Frame_t *) ((byte *) md3Model + md3Model->ofsFrames); + for(i = 0; i < md3Model->numFrames; i++, frame++, md3Frame++) + { + frame->radius = LittleFloat(md3Frame->radius); + for(j = 0; j < 3; j++) + { + frame->bounds[0][j] = LittleFloat(md3Frame->bounds[0][j]); + frame->bounds[1][j] = LittleFloat(md3Frame->bounds[1][j]); + frame->localOrigin[j] = LittleFloat(md3Frame->localOrigin[j]); + } + } + + // swap all the tags + mdvModel->numTags = md3Model->numTags; + mdvModel->tags = tag = ri.Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); + + md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); + for(i = 0; i < md3Model->numTags * md3Model->numFrames; i++, tag++, md3Tag++) + { + for(j = 0; j < 3; j++) + { + tag->origin[j] = LittleFloat(md3Tag->origin[j]); + tag->axis[0][j] = LittleFloat(md3Tag->axis[0][j]); + tag->axis[1][j] = LittleFloat(md3Tag->axis[1][j]); + tag->axis[2][j] = LittleFloat(md3Tag->axis[2][j]); + } + } + + + mdvModel->tagNames = tagName = ri.Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); + + md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); + for(i = 0; i < md3Model->numTags; i++, tagName++, md3Tag++) + { + Q_strncpyz(tagName->name, md3Tag->name, sizeof(tagName->name)); + } + + // swap all the surfaces + mdvModel->numSurfaces = md3Model->numSurfaces; + mdvModel->surfaces = surf = ri.Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); + + md3Surf = (md3Surface_t *) ((byte *) md3Model + md3Model->ofsSurfaces); + for(i = 0; i < md3Model->numSurfaces; i++) + { + LL(md3Surf->ident); + LL(md3Surf->flags); + LL(md3Surf->numFrames); + LL(md3Surf->numShaders); + LL(md3Surf->numTriangles); + LL(md3Surf->ofsTriangles); + LL(md3Surf->numVerts); + LL(md3Surf->ofsShaders); + LL(md3Surf->ofsSt); + LL(md3Surf->ofsXyzNormals); + LL(md3Surf->ofsEnd); + + if(md3Surf->numVerts > SHADER_MAX_VERTEXES) + { + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", + modName, SHADER_MAX_VERTEXES, md3Surf->name[0] ? md3Surf->name : "a surface", + md3Surf->numVerts ); + return qfalse; + } + if(md3Surf->numTriangles * 3 > SHADER_MAX_INDEXES) + { + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", + modName, SHADER_MAX_INDEXES / 3, md3Surf->name[0] ? md3Surf->name : "a surface", + md3Surf->numTriangles ); + return qfalse; + } + + // change to surface identifier + surf->surfaceType = SF_MDV; + + // give pointer to model for Tess_SurfaceMDX + surf->model = mdvModel; + + // copy surface name + Q_strncpyz(surf->name, md3Surf->name, sizeof(surf->name)); + + // lowercase the surface name so skin compares are faster + Q_strlwr(surf->name); + + // strip off a trailing _1 or _2 + // this is a crutch for q3data being a mess + j = strlen(surf->name); + if(j > 2 && surf->name[j - 2] == '_') + { + surf->name[j - 2] = 0; + } + + // register the shaders + surf->numShaderIndexes = md3Surf->numShaders; + surf->shaderIndexes = shaderIndex = ri.Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); + + md3Shader = (md3Shader_t *) ((byte *) md3Surf + md3Surf->ofsShaders); + for(j = 0; j < md3Surf->numShaders; j++, shaderIndex++, md3Shader++) + { + shader_t *sh; + + sh = R_FindShader(md3Shader->name, LIGHTMAP_NONE, qtrue); + if(sh->defaultShader) + { + *shaderIndex = 0; + } + else + { + *shaderIndex = sh->index; + } + } + + // swap all the triangles + surf->numTriangles = md3Surf->numTriangles; + surf->triangles = tri = ri.Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); + + md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); + for(j = 0; j < md3Surf->numTriangles; j++, tri++, md3Tri++) + { + tri->indexes[0] = LittleLong(md3Tri->indexes[0]); + tri->indexes[1] = LittleLong(md3Tri->indexes[1]); + tri->indexes[2] = LittleLong(md3Tri->indexes[2]); + } + + R_CalcSurfaceTriangleNeighbors(surf->numTriangles, surf->triangles); + + // swap all the XyzNormals + surf->numVerts = md3Surf->numVerts; + surf->verts = v = ri.Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); + + md3xyz = (md3XyzNormal_t *) ((byte *) md3Surf + md3Surf->ofsXyzNormals); + for(j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++) + { + unsigned lat, lng; + unsigned short normal; + + v->xyz[0] = LittleShort(md3xyz->xyz[0]) * MD3_XYZ_SCALE; + v->xyz[1] = LittleShort(md3xyz->xyz[1]) * MD3_XYZ_SCALE; + v->xyz[2] = LittleShort(md3xyz->xyz[2]) * MD3_XYZ_SCALE; + + normal = LittleShort(md3xyz->normal); + + lat = ( normal >> 8 ) & 0xff; + lng = ( normal & 0xff ); + lat *= (FUNCTABLE_SIZE/256); + lng *= (FUNCTABLE_SIZE/256); + + // decode X as cos( lat ) * sin( long ) + // decode Y as sin( lat ) * sin( long ) + // decode Z as cos( long ) + + v->normal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + v->normal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + v->normal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + } + + // swap all the ST + surf->st = st = ri.Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); + + md3st = (md3St_t *) ((byte *) md3Surf + md3Surf->ofsSt); + for(j = 0; j < md3Surf->numVerts; j++, md3st++, st++) + { + st->st[0] = LittleFloat(md3st->st[0]); + st->st[1] = LittleFloat(md3st->st[1]); + } + +#ifdef USE_VERT_TANGENT_SPACE + // calc tangent spaces + { + // Valgrind complaints: Conditional jump or move depends on uninitialised value(s) + // So lets Initialize them. + const float *v0 = NULL, *v1 = NULL, *v2 = NULL; + const float *t0 = NULL, *t1 = NULL, *t2 = NULL; + vec3_t tangent = { 0, 0, 0 }; + vec3_t bitangent = { 0, 0, 0 }; + vec3_t normal = { 0, 0, 0 }; + + for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) + { + VectorClear(v->tangent); + VectorClear(v->bitangent); + if (r_recalcMD3Normals->integer) + VectorClear(v->normal); + } + + for(f = 0; f < mdvModel->numFrames; f++) + { + for(j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++) + { + v0 = surf->verts[surf->numVerts * f + tri->indexes[0]].xyz; + v1 = surf->verts[surf->numVerts * f + tri->indexes[1]].xyz; + v2 = surf->verts[surf->numVerts * f + tri->indexes[2]].xyz; + + t0 = surf->st[tri->indexes[0]].st; + t1 = surf->st[tri->indexes[1]].st; + t2 = surf->st[tri->indexes[2]].st; + + if (!r_recalcMD3Normals->integer) + VectorCopy(v->normal, normal); + else + VectorClear(normal); + + #if 1 + R_CalcTangentSpace(tangent, bitangent, normal, v0, v1, v2, t0, t1, t2); + #else + R_CalcNormalForTriangle(normal, v0, v1, v2); + R_CalcTangentsForTriangle(tangent, bitangent, v0, v1, v2, t0, t1, t2); + #endif + + for(k = 0; k < 3; k++) + { + float *v; + + v = surf->verts[surf->numVerts * f + tri->indexes[k]].tangent; + VectorAdd(v, tangent, v); + + v = surf->verts[surf->numVerts * f + tri->indexes[k]].bitangent; + VectorAdd(v, bitangent, v); + + if (r_recalcMD3Normals->integer) + { + v = surf->verts[surf->numVerts * f + tri->indexes[k]].normal; + VectorAdd(v, normal, v); + } + } + } + } + + for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) + { + VectorNormalize(v->tangent); + VectorNormalize(v->bitangent); + VectorNormalize(v->normal); + } + } +#endif + + // find the next surface + md3Surf = (md3Surface_t *) ((byte *) md3Surf + md3Surf->ofsEnd); + surf++; + } + + { + srfVBOMDVMesh_t *vboSurf; + + mdvModel->numVBOSurfaces = mdvModel->numSurfaces; + mdvModel->vboSurfaces = ri.Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); + + vboSurf = mdvModel->vboSurfaces; + surf = mdvModel->surfaces; + for (i = 0; i < mdvModel->numSurfaces; i++, vboSurf++, surf++) + { + vec3_t *verts; + vec3_t *normals; + vec2_t *texcoords; +#ifdef USE_VERT_TANGENT_SPACE + vec3_t *tangents; + vec3_t *bitangents; +#endif + + byte *data; + int dataSize; + + int ofs_xyz, ofs_normal, ofs_st; +#ifdef USE_VERT_TANGENT_SPACE + int ofs_tangent, ofs_bitangent; +#endif + + dataSize = 0; + + ofs_xyz = dataSize; + dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*verts); + + ofs_normal = dataSize; + dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*normals); + +#ifdef USE_VERT_TANGENT_SPACE + ofs_tangent = dataSize; + dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents); + + ofs_bitangent = dataSize; + dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*bitangents); +#endif + + ofs_st = dataSize; + dataSize += surf->numVerts * sizeof(*texcoords); + + data = ri.Malloc(dataSize); + + verts = (void *)(data + ofs_xyz); + normals = (void *)(data + ofs_normal); +#ifdef USE_VERT_TANGENT_SPACE + tangents = (void *)(data + ofs_tangent); + bitangents = (void *)(data + ofs_bitangent); +#endif + texcoords = (void *)(data + ofs_st); + + v = surf->verts; + for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) + { + VectorCopy(v->xyz, verts[j]); + VectorCopy(v->normal, normals[j]); +#ifdef USE_VERT_TANGENT_SPACE + VectorCopy(v->tangent, tangents[j]); + VectorCopy(v->bitangent, bitangents[j]); +#endif + } + + st = surf->st; + for ( j = 0 ; j < surf->numVerts ; j++, st++ ) { + texcoords[j][0] = st->st[0]; + texcoords[j][1] = st->st[1]; + } + + vboSurf->surfaceType = SF_VBO_MDVMESH; + vboSurf->mdvModel = mdvModel; + vboSurf->mdvSurface = surf; + vboSurf->numIndexes = surf->numTriangles * 3; + vboSurf->numVerts = surf->numVerts; + + vboSurf->minIndex = 0; + vboSurf->maxIndex = surf->numVerts; + + vboSurf->vbo = R_CreateVBO(va("staticMD3Mesh_VBO '%s'", surf->name), data, dataSize, VBO_USAGE_STATIC); + + vboSurf->vbo->ofs_xyz = ofs_xyz; + vboSurf->vbo->ofs_normal = ofs_normal; +#ifdef USE_VERT_TANGENT_SPACE + vboSurf->vbo->ofs_tangent = ofs_tangent; + vboSurf->vbo->ofs_bitangent = ofs_bitangent; +#endif + vboSurf->vbo->ofs_st = ofs_st; + + vboSurf->vbo->stride_xyz = sizeof(*verts); + vboSurf->vbo->stride_normal = sizeof(*normals); +#ifdef USE_VERT_TANGENT_SPACE + vboSurf->vbo->stride_tangent = sizeof(*tangents); + vboSurf->vbo->stride_bitangent = sizeof(*bitangents); +#endif + vboSurf->vbo->stride_st = sizeof(*st); + + vboSurf->vbo->size_xyz = sizeof(*verts) * surf->numVerts; + vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts; + + ri.Free(data); + + vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numTriangles, surf->triangles, VBO_USAGE_STATIC); + } + } + + return qtrue; +} + + + +/* +================= +R_LoadMDR +================= +*/ +static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char *mod_name ) +{ + int i, j, k, l; + mdrHeader_t *pinmodel, *mdr; + mdrFrame_t *frame; + mdrLOD_t *lod, *curlod; + mdrSurface_t *surf, *cursurf; + mdrTriangle_t *tri, *curtri; + mdrVertex_t *v, *curv; + mdrWeight_t *weight, *curweight; + mdrTag_t *tag, *curtag; + int size; + shader_t *sh; + + pinmodel = (mdrHeader_t *)buffer; + + pinmodel->version = LittleLong(pinmodel->version); + if (pinmodel->version != MDR_VERSION) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); + return qfalse; + } + + size = LittleLong(pinmodel->ofsEnd); + + if(size > filesize) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); + return qfalse; + } + + mod->type = MOD_MDR; + + LL(pinmodel->numFrames); + LL(pinmodel->numBones); + LL(pinmodel->ofsFrames); + + // This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame + // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target md4. + if(pinmodel->ofsFrames < 0) + { + // mdrFrame_t is larger than mdrCompFrame_t: + size += pinmodel->numFrames * sizeof(frame->name); + // now add enough space for the uncompressed bones. + size += pinmodel->numFrames * pinmodel->numBones * ((sizeof(mdrBone_t) - sizeof(mdrCompBone_t))); + } + + // simple bounds check + if(pinmodel->numBones < 0 || + sizeof(*mdr) + pinmodel->numFrames * (sizeof(*frame) + (pinmodel->numBones - 1) * sizeof(*frame->bones)) > size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + mod->dataSize += size; + mod->modelData = mdr = ri.Hunk_Alloc( size, h_low ); + + // Copy all the values over from the file and fix endian issues in the process, if necessary. + + mdr->ident = LittleLong(pinmodel->ident); + mdr->version = pinmodel->version; // Don't need to swap byte order on this one, we already did above. + Q_strncpyz(mdr->name, pinmodel->name, sizeof(mdr->name)); + mdr->numFrames = pinmodel->numFrames; + mdr->numBones = pinmodel->numBones; + mdr->numLODs = LittleLong(pinmodel->numLODs); + mdr->numTags = LittleLong(pinmodel->numTags); + // We don't care about the other offset values, we'll generate them ourselves while loading. + + mod->numLods = mdr->numLODs; + + if ( mdr->numFrames < 1 ) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); + return qfalse; + } + + /* The first frame will be put into the first free space after the header */ + frame = (mdrFrame_t *)(mdr + 1); + mdr->ofsFrames = (int)((byte *) frame - (byte *) mdr); + + if (pinmodel->ofsFrames < 0) + { + mdrCompFrame_t *cframe; + + // compressed model... + cframe = (mdrCompFrame_t *)((byte *) pinmodel - pinmodel->ofsFrames); + + for(i = 0; i < mdr->numFrames; i++) + { + for(j = 0; j < 3; j++) + { + frame->bounds[0][j] = LittleFloat(cframe->bounds[0][j]); + frame->bounds[1][j] = LittleFloat(cframe->bounds[1][j]); + frame->localOrigin[j] = LittleFloat(cframe->localOrigin[j]); + } + + frame->radius = LittleFloat(cframe->radius); + frame->name[0] = '\0'; // No name supplied in the compressed version. + + for(j = 0; j < mdr->numBones; j++) + { + for(k = 0; k < (sizeof(cframe->bones[j].Comp) / 2); k++) + { + // Do swapping for the uncompressing functions. They seem to use shorts + // values only, so I assume this will work. Never tested it on other + // platforms, though. + + ((unsigned short *)(cframe->bones[j].Comp))[k] = + LittleShort( ((unsigned short *)(cframe->bones[j].Comp))[k] ); + } + + /* Now do the actual uncompressing */ + MC_UnCompress(frame->bones[j].matrix, cframe->bones[j].Comp); + } + + // Next Frame... + cframe = (mdrCompFrame_t *) &cframe->bones[j]; + frame = (mdrFrame_t *) &frame->bones[j]; + } + } + else + { + mdrFrame_t *curframe; + + // uncompressed model... + // + + curframe = (mdrFrame_t *)((byte *) pinmodel + pinmodel->ofsFrames); + + // swap all the frames + for ( i = 0 ; i < mdr->numFrames ; i++) + { + for(j = 0; j < 3; j++) + { + frame->bounds[0][j] = LittleFloat(curframe->bounds[0][j]); + frame->bounds[1][j] = LittleFloat(curframe->bounds[1][j]); + frame->localOrigin[j] = LittleFloat(curframe->localOrigin[j]); + } + + frame->radius = LittleFloat(curframe->radius); + Q_strncpyz(frame->name, curframe->name, sizeof(frame->name)); + + for (j = 0; j < (int) (mdr->numBones * sizeof(mdrBone_t) / 4); j++) + { + ((float *)frame->bones)[j] = LittleFloat( ((float *)curframe->bones)[j] ); + } + + curframe = (mdrFrame_t *) &curframe->bones[mdr->numBones]; + frame = (mdrFrame_t *) &frame->bones[mdr->numBones]; + } + } + + // frame should now point to the first free address after all frames. + lod = (mdrLOD_t *) frame; + mdr->ofsLODs = (int) ((byte *) lod - (byte *)mdr); + + curlod = (mdrLOD_t *)((byte *) pinmodel + LittleLong(pinmodel->ofsLODs)); + + // swap all the LOD's + for ( l = 0 ; l < mdr->numLODs ; l++) + { + // simple bounds check + if((byte *) (lod + 1) > (byte *) mdr + size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + lod->numSurfaces = LittleLong(curlod->numSurfaces); + + // swap all the surfaces + surf = (mdrSurface_t *) (lod + 1); + lod->ofsSurfaces = (int)((byte *) surf - (byte *) lod); + cursurf = (mdrSurface_t *) ((byte *)curlod + LittleLong(curlod->ofsSurfaces)); + + for ( i = 0 ; i < lod->numSurfaces ; i++) + { + // simple bounds check + if((byte *) (surf + 1) > (byte *) mdr + size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + // first do some copying stuff + + surf->ident = SF_MDR; + Q_strncpyz(surf->name, cursurf->name, sizeof(surf->name)); + Q_strncpyz(surf->shader, cursurf->shader, sizeof(surf->shader)); + + surf->ofsHeader = (byte *) mdr - (byte *) surf; + + surf->numVerts = LittleLong(cursurf->numVerts); + surf->numTriangles = LittleLong(cursurf->numTriangles); + // numBoneReferences and BoneReferences generally seem to be unused + + // now do the checks that may fail. + if ( surf->numVerts > SHADER_MAX_VERTEXES ) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", + mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", + surf->numVerts ); + return qfalse; + } + if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", + mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", + surf->numTriangles ); + return qfalse; + } + // lowercase the surface name so skin compares are faster + Q_strlwr( surf->name ); + + // register the shaders + sh = R_FindShader(surf->shader, LIGHTMAP_NONE, qtrue); + if ( sh->defaultShader ) { + surf->shaderIndex = 0; + } else { + surf->shaderIndex = sh->index; + } + + // now copy the vertexes. + v = (mdrVertex_t *) (surf + 1); + surf->ofsVerts = (int)((byte *) v - (byte *) surf); + curv = (mdrVertex_t *) ((byte *)cursurf + LittleLong(cursurf->ofsVerts)); + + for(j = 0; j < surf->numVerts; j++) + { + LL(curv->numWeights); + + // simple bounds check + if(curv->numWeights < 0 || (byte *) (v + 1) + (curv->numWeights - 1) * sizeof(*weight) > (byte *) mdr + size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + v->normal[0] = LittleFloat(curv->normal[0]); + v->normal[1] = LittleFloat(curv->normal[1]); + v->normal[2] = LittleFloat(curv->normal[2]); + + v->texCoords[0] = LittleFloat(curv->texCoords[0]); + v->texCoords[1] = LittleFloat(curv->texCoords[1]); + + v->numWeights = curv->numWeights; + weight = &v->weights[0]; + curweight = &curv->weights[0]; + + // Now copy all the weights + for(k = 0; k < v->numWeights; k++) + { + weight->boneIndex = LittleLong(curweight->boneIndex); + weight->boneWeight = LittleFloat(curweight->boneWeight); + + weight->offset[0] = LittleFloat(curweight->offset[0]); + weight->offset[1] = LittleFloat(curweight->offset[1]); + weight->offset[2] = LittleFloat(curweight->offset[2]); + + weight++; + curweight++; + } + + v = (mdrVertex_t *) weight; + curv = (mdrVertex_t *) curweight; + } + + // we know the offset to the triangles now: + tri = (mdrTriangle_t *) v; + surf->ofsTriangles = (int)((byte *) tri - (byte *) surf); + curtri = (mdrTriangle_t *)((byte *) cursurf + LittleLong(cursurf->ofsTriangles)); + + // simple bounds check + if(surf->numTriangles < 0 || (byte *) (tri + surf->numTriangles) > (byte *) mdr + size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + for(j = 0; j < surf->numTriangles; j++) + { + tri->indexes[0] = LittleLong(curtri->indexes[0]); + tri->indexes[1] = LittleLong(curtri->indexes[1]); + tri->indexes[2] = LittleLong(curtri->indexes[2]); + + tri++; + curtri++; + } + + // tri now points to the end of the surface. + surf->ofsEnd = (byte *) tri - (byte *) surf; + surf = (mdrSurface_t *) tri; + + // find the next surface. + cursurf = (mdrSurface_t *) ((byte *) cursurf + LittleLong(cursurf->ofsEnd)); + } + + // surf points to the next lod now. + lod->ofsEnd = (int)((byte *) surf - (byte *) lod); + lod = (mdrLOD_t *) surf; + + // find the next LOD. + curlod = (mdrLOD_t *)((byte *) curlod + LittleLong(curlod->ofsEnd)); + } + + // lod points to the first tag now, so update the offset too. + tag = (mdrTag_t *) lod; + mdr->ofsTags = (int)((byte *) tag - (byte *) mdr); + curtag = (mdrTag_t *) ((byte *)pinmodel + LittleLong(pinmodel->ofsTags)); + + // simple bounds check + if(mdr->numTags < 0 || (byte *) (tag + mdr->numTags) > (byte *) mdr + size) + { + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + return qfalse; + } + + for (i = 0 ; i < mdr->numTags ; i++) + { + tag->boneIndex = LittleLong(curtag->boneIndex); + Q_strncpyz(tag->name, curtag->name, sizeof(tag->name)); + + tag++; + curtag++; + } + + // And finally we know the real offset to the end. + mdr->ofsEnd = (int)((byte *) tag - (byte *) mdr); + + // phew! we're done. + + return qtrue; +} + +/* +================= +R_LoadMD4 +================= +*/ + +static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { + int i, j, k, lodindex; + md4Header_t *pinmodel, *md4; + md4Frame_t *frame; + md4LOD_t *lod; + md4Surface_t *surf; + md4Triangle_t *tri; + md4Vertex_t *v; + int version; + int size; + shader_t *sh; + int frameSize; + + pinmodel = (md4Header_t *)buffer; + + version = LittleLong (pinmodel->version); + if (version != MD4_VERSION) { + ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n", + mod_name, version, MD4_VERSION); + return qfalse; + } + + mod->type = MOD_MD4; + size = LittleLong(pinmodel->ofsEnd); + mod->dataSize += size; + mod->modelData = md4 = ri.Hunk_Alloc( size, h_low ); + + Com_Memcpy(md4, buffer, size); + + LL(md4->ident); + LL(md4->version); + LL(md4->numFrames); + LL(md4->numBones); + LL(md4->numLODs); + LL(md4->ofsFrames); + LL(md4->ofsLODs); + md4->ofsEnd = size; + + if ( md4->numFrames < 1 ) { + ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name ); + return qfalse; + } + + // we don't need to swap tags in the renderer, they aren't used + + // swap all the frames + frameSize = (size_t)( &((md4Frame_t *)0)->bones[ md4->numBones ] ); + for ( i = 0 ; i < md4->numFrames ; i++) { + frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize ); + frame->radius = LittleFloat( frame->radius ); + for ( j = 0 ; j < 3 ; j++ ) { + frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] ); + frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] ); + frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] ); + } + for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) { + ((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] ); + } + } + + // swap all the LOD's + lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs ); + for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) { + + // swap all the surfaces + surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces ); + for ( i = 0 ; i < lod->numSurfaces ; i++) { + LL(surf->ident); + LL(surf->numTriangles); + LL(surf->ofsTriangles); + LL(surf->numVerts); + LL(surf->ofsVerts); + LL(surf->ofsEnd); + + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { + ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", + mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", + surf->numVerts ); + return qfalse; + } + if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { + ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", + mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", + surf->numTriangles ); + return qfalse; + } + + // change to surface identifier + surf->ident = SF_MD4; + + // lowercase the surface name so skin compares are faster + Q_strlwr( surf->name ); + + // register the shaders + sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue ); + if ( sh->defaultShader ) { + surf->shaderIndex = 0; + } else { + surf->shaderIndex = sh->index; + } + + // swap all the triangles + tri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles ); + for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) { + LL(tri->indexes[0]); + LL(tri->indexes[1]); + LL(tri->indexes[2]); + } + + // swap all the vertexes + // FIXME + // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left + // in for reference. + //v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts + 12); + v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts); + for ( j = 0 ; j < surf->numVerts ; j++ ) { + v->normal[0] = LittleFloat( v->normal[0] ); + v->normal[1] = LittleFloat( v->normal[1] ); + v->normal[2] = LittleFloat( v->normal[2] ); + + v->texCoords[0] = LittleFloat( v->texCoords[0] ); + v->texCoords[1] = LittleFloat( v->texCoords[1] ); + + v->numWeights = LittleLong( v->numWeights ); + + for ( k = 0 ; k < v->numWeights ; k++ ) { + v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex ); + v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight ); + v->weights[k].offset[0] = LittleFloat( v->weights[k].offset[0] ); + v->weights[k].offset[1] = LittleFloat( v->weights[k].offset[1] ); + v->weights[k].offset[2] = LittleFloat( v->weights[k].offset[2] ); + } + // FIXME + // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left + // in for reference. + //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 ); + v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights]); + } + + // find the next surface + surf = (md4Surface_t *)( (byte *)surf + surf->ofsEnd ); + } + + // find the next LOD + lod = (md4LOD_t *)( (byte *)lod + lod->ofsEnd ); + } + + return qtrue; +} + + + +//============================================================================= + +/* +** RE_BeginRegistration +*/ +void RE_BeginRegistration( glconfig_t *glconfigOut ) { + + R_Init(); + + *glconfigOut = glConfig; + + R_IssuePendingRenderCommands(); + + tr.visIndex = 0; + memset(tr.visClusters, -2, sizeof(tr.visClusters)); // force markleafs to regenerate + + R_ClearFlares(); + RE_ClearScene(); + + tr.registered = qtrue; + + // NOTE: this sucks, for some reason the first stretch pic is never drawn + // without this we'd see a white flash on a level load because the very + // first time the level shot would not be drawn +// RE_StretchPic(0, 0, 0, 0, 0, 0, 1, 1, 0); +} + +//============================================================================= + +/* +=============== +R_ModelInit +=============== +*/ +void R_ModelInit( void ) { + model_t *mod; + + // leave a space for NULL model + tr.numModels = 0; + + mod = R_AllocModel(); + mod->type = MOD_BAD; +} + + +/* +================ +R_Modellist_f +================ +*/ +void R_Modellist_f( void ) { + int i, j; + model_t *mod; + int total; + int lods; + + total = 0; + for ( i = 1 ; i < tr.numModels; i++ ) { + mod = tr.models[i]; + lods = 1; + for ( j = 1 ; j < MD3_MAX_LODS ; j++ ) { + if ( mod->mdv[j] && mod->mdv[j] != mod->mdv[j-1] ) { + lods++; + } + } + ri.Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); + total += mod->dataSize; + } + ri.Printf( PRINT_ALL, "%8i : Total models\n", total ); + +#if 0 // not working right with new hunk + if ( tr.world ) { + ri.Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); + } +#endif +} + + +//============================================================================= + + +/* +================ +R_GetTag +================ +*/ +static mdvTag_t *R_GetTag( mdvModel_t *mod, int frame, const char *_tagName ) { + int i; + mdvTag_t *tag; + mdvTagName_t *tagName; + + if ( frame >= mod->numFrames ) { + // it is possible to have a bad frame while changing models, so don't error + frame = mod->numFrames - 1; + } + + tag = mod->tags + frame * mod->numTags; + tagName = mod->tagNames; + for(i = 0; i < mod->numTags; i++, tag++, tagName++) + { + if(!strcmp(tagName->name, _tagName)) + { + return tag; + } + } + + return NULL; +} + +void R_GetAnimTag( mdrHeader_t *mod, int framenum, const char *tagName, mdvTag_t * dest) +{ + int i, j, k; + int frameSize; + mdrFrame_t *frame; + mdrTag_t *tag; + + if ( framenum >= mod->numFrames ) + { + // it is possible to have a bad frame while changing models, so don't error + framenum = mod->numFrames - 1; + } + + tag = (mdrTag_t *)((byte *)mod + mod->ofsTags); + for ( i = 0 ; i < mod->numTags ; i++, tag++ ) + { + if ( !strcmp( tag->name, tagName ) ) + { + // uncompressed model... + // + frameSize = (intptr_t)( &((mdrFrame_t *)0)->bones[ mod->numBones ] ); + frame = (mdrFrame_t *)((byte *)mod + mod->ofsFrames + framenum * frameSize ); + + for (j = 0; j < 3; j++) + { + for (k = 0; k < 3; k++) + dest->axis[j][k]=frame->bones[tag->boneIndex].matrix[k][j]; + } + + dest->origin[0]=frame->bones[tag->boneIndex].matrix[0][3]; + dest->origin[1]=frame->bones[tag->boneIndex].matrix[1][3]; + dest->origin[2]=frame->bones[tag->boneIndex].matrix[2][3]; + + return; + } + } + + AxisClear( dest->axis ); + VectorClear( dest->origin ); +} + +/* +================ +R_LerpTag +================ +*/ +int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, + float frac, const char *tagName ) { + mdvTag_t *start, *end; + mdvTag_t start_space, end_space; + int i; + float frontLerp, backLerp; + model_t *model; + + model = R_GetModelByHandle( handle ); + if ( !model->mdv[0] ) + { + if(model->type == MOD_MDR) + { + start = &start_space; + end = &end_space; + R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start); + R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end); + } + else if( model->type == MOD_IQM ) { + return R_IQMLerpTag( tag, model->modelData, + startFrame, endFrame, + frac, tagName ); + } else { + + AxisClear( tag->axis ); + VectorClear( tag->origin ); + return qfalse; + + } + } + else + { + start = R_GetTag( model->mdv[0], startFrame, tagName ); + end = R_GetTag( model->mdv[0], endFrame, tagName ); + if ( !start || !end ) { + AxisClear( tag->axis ); + VectorClear( tag->origin ); + return qfalse; + } + } + + frontLerp = frac; + backLerp = 1.0f - frac; + + for ( i = 0 ; i < 3 ; i++ ) { + tag->origin[i] = start->origin[i] * backLerp + end->origin[i] * frontLerp; + tag->axis[0][i] = start->axis[0][i] * backLerp + end->axis[0][i] * frontLerp; + tag->axis[1][i] = start->axis[1][i] * backLerp + end->axis[1][i] * frontLerp; + tag->axis[2][i] = start->axis[2][i] * backLerp + end->axis[2][i] * frontLerp; + } + VectorNormalize( tag->axis[0] ); + VectorNormalize( tag->axis[1] ); + VectorNormalize( tag->axis[2] ); + return qtrue; +} + + +/* +==================== +R_ModelBounds +==================== +*/ +void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { + model_t *model; + + model = R_GetModelByHandle( handle ); + + if(model->type == MOD_BRUSH) { + VectorCopy( model->bmodel->bounds[0], mins ); + VectorCopy( model->bmodel->bounds[1], maxs ); + + return; + } else if (model->type == MOD_MESH) { + mdvModel_t *header; + mdvFrame_t *frame; + + header = model->mdv[0]; + frame = header->frames; + + VectorCopy( frame->bounds[0], mins ); + VectorCopy( frame->bounds[1], maxs ); + + return; + } else if (model->type == MOD_MD4) { + md4Header_t *header; + md4Frame_t *frame; + + header = (md4Header_t *)model->modelData; + frame = (md4Frame_t *) ((byte *)header + header->ofsFrames); + + VectorCopy( frame->bounds[0], mins ); + VectorCopy( frame->bounds[1], maxs ); + + return; + } else if (model->type == MOD_MDR) { + mdrHeader_t *header; + mdrFrame_t *frame; + + header = (mdrHeader_t *)model->modelData; + frame = (mdrFrame_t *) ((byte *)header + header->ofsFrames); + + VectorCopy( frame->bounds[0], mins ); + VectorCopy( frame->bounds[1], maxs ); + + return; + } else if(model->type == MOD_IQM) { + iqmData_t *iqmData; + + iqmData = model->modelData; + + if(iqmData->bounds) + { + VectorCopy(iqmData->bounds, mins); + VectorCopy(iqmData->bounds + 3, maxs); + return; + } + } + + VectorClear( mins ); + VectorClear( maxs ); +} diff --git a/codemp/rd-rend2/tr_model_iqm.c b/codemp/rd-rend2/tr_model_iqm.c new file mode 100644 index 0000000000..15e0fe781c --- /dev/null +++ b/codemp/rd-rend2/tr_model_iqm.c @@ -0,0 +1,1110 @@ +/* +=========================================================================== +Copyright (C) 2011 Thilo Schulz +Copyright (C) 2011 Matthias Bentrup + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "tr_local.h" + +#define LL(x) x=LittleLong(x) + +static qboolean IQM_CheckRange( iqmHeader_t *header, int offset, + int count,int size ) { + // return true if the range specified by offset, count and size + // doesn't fit into the file + return ( count <= 0 || + offset < 0 || + offset > header->filesize || + offset + count * size < 0 || + offset + count * size > header->filesize ); +} +// "multiply" 3x4 matrices, these are assumed to be the top 3 rows +// of a 4x4 matrix with the last row = (0 0 0 1) +static void Matrix34Multiply( float *a, float *b, float *out ) { + out[ 0] = a[0] * b[0] + a[1] * b[4] + a[ 2] * b[ 8]; + out[ 1] = a[0] * b[1] + a[1] * b[5] + a[ 2] * b[ 9]; + out[ 2] = a[0] * b[2] + a[1] * b[6] + a[ 2] * b[10]; + out[ 3] = a[0] * b[3] + a[1] * b[7] + a[ 2] * b[11] + a[ 3]; + out[ 4] = a[4] * b[0] + a[5] * b[4] + a[ 6] * b[ 8]; + out[ 5] = a[4] * b[1] + a[5] * b[5] + a[ 6] * b[ 9]; + out[ 6] = a[4] * b[2] + a[5] * b[6] + a[ 6] * b[10]; + out[ 7] = a[4] * b[3] + a[5] * b[7] + a[ 6] * b[11] + a[ 7]; + out[ 8] = a[8] * b[0] + a[9] * b[4] + a[10] * b[ 8]; + out[ 9] = a[8] * b[1] + a[9] * b[5] + a[10] * b[ 9]; + out[10] = a[8] * b[2] + a[9] * b[6] + a[10] * b[10]; + out[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11]; +} +static void Matrix34Multiply_OnlySetOrigin( float *a, float *b, float *out ) { + out[ 3] = a[0] * b[3] + a[1] * b[7] + a[ 2] * b[11] + a[ 3]; + out[ 7] = a[4] * b[3] + a[5] * b[7] + a[ 6] * b[11] + a[ 7]; + out[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11]; +} +static void InterpolateMatrix( float *a, float *b, float lerp, float *mat ) { + float unLerp = 1.0f - lerp; + + mat[ 0] = a[ 0] * unLerp + b[ 0] * lerp; + mat[ 1] = a[ 1] * unLerp + b[ 1] * lerp; + mat[ 2] = a[ 2] * unLerp + b[ 2] * lerp; + mat[ 3] = a[ 3] * unLerp + b[ 3] * lerp; + mat[ 4] = a[ 4] * unLerp + b[ 4] * lerp; + mat[ 5] = a[ 5] * unLerp + b[ 5] * lerp; + mat[ 6] = a[ 6] * unLerp + b[ 6] * lerp; + mat[ 7] = a[ 7] * unLerp + b[ 7] * lerp; + mat[ 8] = a[ 8] * unLerp + b[ 8] * lerp; + mat[ 9] = a[ 9] * unLerp + b[ 9] * lerp; + mat[10] = a[10] * unLerp + b[10] * lerp; + mat[11] = a[11] * unLerp + b[11] * lerp; +} +static void JointToMatrix( vec4_t rot, vec3_t scale, vec3_t trans, + float *mat ) { + float xx = 2.0f * rot[0] * rot[0]; + float yy = 2.0f * rot[1] * rot[1]; + float zz = 2.0f * rot[2] * rot[2]; + float xy = 2.0f * rot[0] * rot[1]; + float xz = 2.0f * rot[0] * rot[2]; + float yz = 2.0f * rot[1] * rot[2]; + float wx = 2.0f * rot[3] * rot[0]; + float wy = 2.0f * rot[3] * rot[1]; + float wz = 2.0f * rot[3] * rot[2]; + + mat[ 0] = scale[0] * (1.0f - (yy + zz)); + mat[ 1] = scale[0] * (xy - wz); + mat[ 2] = scale[0] * (xz + wy); + mat[ 3] = trans[0]; + mat[ 4] = scale[1] * (xy + wz); + mat[ 5] = scale[1] * (1.0f - (xx + zz)); + mat[ 6] = scale[1] * (yz - wx); + mat[ 7] = trans[1]; + mat[ 8] = scale[2] * (xz - wy); + mat[ 9] = scale[2] * (yz + wx); + mat[10] = scale[2] * (1.0f - (xx + yy)); + mat[11] = trans[2]; +} +static void Matrix34Invert( float *inMat, float *outMat ) +{ + vec3_t trans; + float invSqrLen, *v; + + outMat[ 0] = inMat[ 0]; outMat[ 1] = inMat[ 4]; outMat[ 2] = inMat[ 8]; + outMat[ 4] = inMat[ 1]; outMat[ 5] = inMat[ 5]; outMat[ 6] = inMat[ 9]; + outMat[ 8] = inMat[ 2]; outMat[ 9] = inMat[ 6]; outMat[10] = inMat[10]; + + v = outMat + 0; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + v = outMat + 4; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + v = outMat + 8; invSqrLen = 1.0f / DotProduct(v, v); VectorScale(v, invSqrLen, v); + + trans[0] = inMat[ 3]; + trans[1] = inMat[ 7]; + trans[2] = inMat[11]; + + outMat[ 3] = -DotProduct(outMat + 0, trans); + outMat[ 7] = -DotProduct(outMat + 4, trans); + outMat[11] = -DotProduct(outMat + 8, trans); +} + +/* +================= +R_LoadIQM + +Load an IQM model and compute the joint matrices for every frame. +================= +*/ +qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_name ) { + iqmHeader_t *header; + iqmVertexArray_t *vertexarray; + iqmTriangle_t *triangle; + iqmMesh_t *mesh; + iqmJoint_t *joint; + iqmPose_t *pose; + iqmBounds_t *bounds; + unsigned short *framedata; + char *str; + int i, j; + float jointInvMats[IQM_MAX_JOINTS * 12]; + float *mat, *matInv; + size_t size, joint_names; + iqmData_t *iqmData; + srfIQModel_t *surface; + char meshName[MAX_QPATH]; + + if( filesize < sizeof(iqmHeader_t) ) { + return qfalse; + } + + header = (iqmHeader_t *)buffer; + if( Q_strncmp( header->magic, IQM_MAGIC, sizeof(header->magic) ) ) { + return qfalse; + } + + LL( header->version ); + if( header->version != IQM_VERSION ) { + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", + mod_name, header->version, IQM_VERSION); + return qfalse; + } + + LL( header->filesize ); + if( header->filesize > filesize || header->filesize > 16<<20 ) { + return qfalse; + } + + LL( header->flags ); + LL( header->num_text ); + LL( header->ofs_text ); + LL( header->num_meshes ); + LL( header->ofs_meshes ); + LL( header->num_vertexarrays ); + LL( header->num_vertexes ); + LL( header->ofs_vertexarrays ); + LL( header->num_triangles ); + LL( header->ofs_triangles ); + LL( header->ofs_adjacency ); + LL( header->num_joints ); + LL( header->ofs_joints ); + LL( header->num_poses ); + LL( header->ofs_poses ); + LL( header->num_anims ); + LL( header->ofs_anims ); + LL( header->num_frames ); + LL( header->num_framechannels ); + LL( header->ofs_frames ); + LL( header->ofs_bounds ); + LL( header->num_comment ); + LL( header->ofs_comment ); + LL( header->num_extensions ); + LL( header->ofs_extensions ); + + // check ioq3 joint limit + if ( header->num_joints > IQM_MAX_JOINTS ) { + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", + mod_name, IQM_MAX_JOINTS, header->num_joints); + return qfalse; + } + + // check and swap vertex arrays + if( IQM_CheckRange( header, header->ofs_vertexarrays, + header->num_vertexarrays, + sizeof(iqmVertexArray_t) ) ) { + return qfalse; + } + vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays); + for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) { + int n, *intPtr; + + if( vertexarray->size <= 0 || vertexarray->size > 4 ) { + return qfalse; + } + + // total number of values + n = header->num_vertexes * vertexarray->size; + + switch( vertexarray->format ) { + case IQM_BYTE: + case IQM_UBYTE: + // 1 byte, no swapping necessary + if( IQM_CheckRange( header, vertexarray->offset, + n, sizeof(byte) ) ) { + return qfalse; + } + break; + case IQM_INT: + case IQM_UINT: + case IQM_FLOAT: + // 4-byte swap + if( IQM_CheckRange( header, vertexarray->offset, + n, sizeof(float) ) ) { + return qfalse; + } + intPtr = (int *)((byte *)header + vertexarray->offset); + for( j = 0; j < n; j++, intPtr++ ) { + LL( *intPtr ); + } + break; + default: + // not supported + return qfalse; + break; + } + + switch( vertexarray->type ) { + case IQM_POSITION: + case IQM_NORMAL: + if( vertexarray->format != IQM_FLOAT || + vertexarray->size != 3 ) { + return qfalse; + } + break; + case IQM_TANGENT: + if( vertexarray->format != IQM_FLOAT || + vertexarray->size != 4 ) { + return qfalse; + } + break; + case IQM_TEXCOORD: + if( vertexarray->format != IQM_FLOAT || + vertexarray->size != 2 ) { + return qfalse; + } + break; + case IQM_BLENDINDEXES: + case IQM_BLENDWEIGHTS: + if( vertexarray->format != IQM_UBYTE || + vertexarray->size != 4 ) { + return qfalse; + } + break; + case IQM_COLOR: + if( vertexarray->format != IQM_UBYTE || + vertexarray->size != 4 ) { + return qfalse; + } + break; + } + } + + // check and swap triangles + if( IQM_CheckRange( header, header->ofs_triangles, + header->num_triangles, sizeof(iqmTriangle_t) ) ) { + return qfalse; + } + triangle = (iqmTriangle_t *)((byte *)header + header->ofs_triangles); + for( i = 0; i < header->num_triangles; i++, triangle++ ) { + LL( triangle->vertex[0] ); + LL( triangle->vertex[1] ); + LL( triangle->vertex[2] ); + + if( triangle->vertex[0] > header->num_vertexes || + triangle->vertex[1] > header->num_vertexes || + triangle->vertex[2] > header->num_vertexes ) { + return qfalse; + } + } + + // check and swap meshes + if( IQM_CheckRange( header, header->ofs_meshes, + header->num_meshes, sizeof(iqmMesh_t) ) ) { + return qfalse; + } + mesh = (iqmMesh_t *)((byte *)header + header->ofs_meshes); + for( i = 0; i < header->num_meshes; i++, mesh++) { + LL( mesh->name ); + LL( mesh->material ); + LL( mesh->first_vertex ); + LL( mesh->num_vertexes ); + LL( mesh->first_triangle ); + LL( mesh->num_triangles ); + + if ( mesh->name < header->num_text ) { + Q_strncpyz( meshName, (char*)header + header->ofs_text + mesh->name, sizeof (meshName) ); + } else { + meshName[0] = '\0'; + } + + // check ioq3 limits + if ( mesh->num_vertexes > SHADER_MAX_VERTEXES ) + { + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", + mod_name, SHADER_MAX_VERTEXES, meshName[0] ? meshName : "a surface", + mesh->num_vertexes ); + return qfalse; + } + if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES ) + { + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", + mod_name, SHADER_MAX_INDEXES / 3, meshName[0] ? meshName : "a surface", + mesh->num_triangles ); + return qfalse; + } + + if( mesh->first_vertex >= header->num_vertexes || + mesh->first_vertex + mesh->num_vertexes > header->num_vertexes || + mesh->first_triangle >= header->num_triangles || + mesh->first_triangle + mesh->num_triangles > header->num_triangles || + mesh->name >= header->num_text || + mesh->material >= header->num_text ) { + return qfalse; + } + } + + if( header->num_poses != header->num_joints ) { + return qfalse; + } + + joint_names = 0; + + if ( header->num_joints ) + { + // check and swap joints + if( IQM_CheckRange( header, header->ofs_joints, + header->num_joints, sizeof(iqmJoint_t) ) ) { + return qfalse; + } + joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); + for( i = 0; i < header->num_joints; i++, joint++ ) { + LL( joint->name ); + LL( joint->parent ); + LL( joint->translate[0] ); + LL( joint->translate[1] ); + LL( joint->translate[2] ); + LL( joint->rotate[0] ); + LL( joint->rotate[1] ); + LL( joint->rotate[2] ); + LL( joint->rotate[3] ); + LL( joint->scale[0] ); + LL( joint->scale[1] ); + LL( joint->scale[2] ); + + if( joint->parent < -1 || + joint->parent >= (int)header->num_joints || + joint->name >= (int)header->num_text ) { + return qfalse; + } + joint_names += strlen( (char *)header + header->ofs_text + + joint->name ) + 1; + } + + // check and swap poses + if( IQM_CheckRange( header, header->ofs_poses, + header->num_poses, sizeof(iqmPose_t) ) ) { + return qfalse; + } + pose = (iqmPose_t *)((byte *)header + header->ofs_poses); + for( i = 0; i < header->num_poses; i++, pose++ ) { + LL( pose->parent ); + LL( pose->mask ); + LL( pose->channeloffset[0] ); + LL( pose->channeloffset[1] ); + LL( pose->channeloffset[2] ); + LL( pose->channeloffset[3] ); + LL( pose->channeloffset[4] ); + LL( pose->channeloffset[5] ); + LL( pose->channeloffset[6] ); + LL( pose->channeloffset[7] ); + LL( pose->channeloffset[8] ); + LL( pose->channeloffset[9] ); + LL( pose->channelscale[0] ); + LL( pose->channelscale[1] ); + LL( pose->channelscale[2] ); + LL( pose->channelscale[3] ); + LL( pose->channelscale[4] ); + LL( pose->channelscale[5] ); + LL( pose->channelscale[6] ); + LL( pose->channelscale[7] ); + LL( pose->channelscale[8] ); + LL( pose->channelscale[9] ); + } + } + + if (header->ofs_bounds) + { + // check and swap model bounds + if(IQM_CheckRange(header, header->ofs_bounds, + header->num_frames, sizeof(*bounds))) + { + return qfalse; + } + bounds = (iqmBounds_t *) ((byte *) header + header->ofs_bounds); + for(i = 0; i < header->num_frames; i++) + { + LL(bounds->bbmin[0]); + LL(bounds->bbmin[1]); + LL(bounds->bbmin[2]); + LL(bounds->bbmax[0]); + LL(bounds->bbmax[1]); + LL(bounds->bbmax[2]); + + bounds++; + } + } + + // allocate the model and copy the data + size = sizeof(iqmData_t); + size += header->num_meshes * sizeof( srfIQModel_t ); + size += header->num_joints * 12 * sizeof( float ); // joint mats + size += header->num_joints * header->num_frames * 12 * sizeof( float ); // pose mats + if(header->ofs_bounds) + size += header->num_frames * 6 * sizeof(float); // model bounds + size += header->num_vertexes * 3 * sizeof(float); // positions + size += header->num_vertexes * 2 * sizeof(float); // texcoords + size += header->num_vertexes * 3 * sizeof(float); // normals + size += header->num_vertexes * 4 * sizeof(float); // tangents + size += header->num_vertexes * 4 * sizeof(byte); // blendIndexes + size += header->num_vertexes * 4 * sizeof(byte); // blendWeights + size += header->num_vertexes * 4 * sizeof(byte); // colors + size += header->num_joints * sizeof(int); // parents + size += header->num_triangles * 3 * sizeof(int); // triangles + size += joint_names; // joint names + + mod->type = MOD_IQM; + iqmData = (iqmData_t *)ri.Hunk_Alloc( size, h_low ); + mod->modelData = iqmData; + + // fill header + iqmData->num_vertexes = header->num_vertexes; + iqmData->num_triangles = header->num_triangles; + iqmData->num_frames = header->num_frames; + iqmData->num_surfaces = header->num_meshes; + iqmData->num_joints = header->num_joints; + iqmData->surfaces = (srfIQModel_t *)(iqmData + 1); + iqmData->jointMats = (float *) (iqmData->surfaces + iqmData->num_surfaces); + iqmData->poseMats = iqmData->jointMats + 12 * header->num_joints; + if(header->ofs_bounds) + { + iqmData->bounds = iqmData->poseMats + 12 * header->num_joints * header->num_frames; + iqmData->positions = iqmData->bounds + 6 * header->num_frames; + } + else + iqmData->positions = iqmData->poseMats + 12 * header->num_joints * header->num_frames; + iqmData->texcoords = iqmData->positions + 3 * header->num_vertexes; + iqmData->normals = iqmData->texcoords + 2 * header->num_vertexes; + iqmData->tangents = iqmData->normals + 3 * header->num_vertexes; + iqmData->blendIndexes = (byte *)(iqmData->tangents + 4 * header->num_vertexes); + iqmData->blendWeights = iqmData->blendIndexes + 4 * header->num_vertexes; + iqmData->colors = iqmData->blendWeights + 4 * header->num_vertexes; + iqmData->jointParents = (int *)(iqmData->colors + 4 * header->num_vertexes); + iqmData->triangles = iqmData->jointParents + header->num_joints; + iqmData->names = (char *)(iqmData->triangles + 3 * header->num_triangles); + + if ( header->num_joints == 0 ) + iqmData->jointMats = iqmData->poseMats = NULL; + + // calculate joint matrices and their inverses + // joint inverses are needed only until the pose matrices are calculated + mat = iqmData->jointMats; + matInv = jointInvMats; + joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); + for( i = 0; i < header->num_joints; i++, joint++ ) { + float baseFrame[12], invBaseFrame[12]; + + JointToMatrix( joint->rotate, joint->scale, joint->translate, baseFrame ); + Matrix34Invert( baseFrame, invBaseFrame ); + + if ( joint->parent >= 0 ) + { + Matrix34Multiply( iqmData->jointMats + 12 * joint->parent, baseFrame, mat ); + mat += 12; + Matrix34Multiply( invBaseFrame, jointInvMats + 12 * joint->parent, matInv ); + matInv += 12; + } + else + { + Com_Memcpy( mat, baseFrame, sizeof(baseFrame) ); + mat += 12; + Com_Memcpy( matInv, invBaseFrame, sizeof(invBaseFrame) ); + matInv += 12; + } + } + + // calculate pose matrices + framedata = (unsigned short *)((byte *)header + header->ofs_frames); + mat = iqmData->poseMats; + for( i = 0; i < header->num_frames; i++ ) { + pose = (iqmPose_t *)((byte *)header + header->ofs_poses); + for( j = 0; j < header->num_poses; j++, pose++ ) { + vec3_t translate; + vec4_t rotate; + vec3_t scale; + float mat1[12], mat2[12]; + + translate[0] = pose->channeloffset[0]; + if( pose->mask & 0x001) + translate[0] += *framedata++ * pose->channelscale[0]; + translate[1] = pose->channeloffset[1]; + if( pose->mask & 0x002) + translate[1] += *framedata++ * pose->channelscale[1]; + translate[2] = pose->channeloffset[2]; + if( pose->mask & 0x004) + translate[2] += *framedata++ * pose->channelscale[2]; + + rotate[0] = pose->channeloffset[3]; + if( pose->mask & 0x008) + rotate[0] += *framedata++ * pose->channelscale[3]; + rotate[1] = pose->channeloffset[4]; + if( pose->mask & 0x010) + rotate[1] += *framedata++ * pose->channelscale[4]; + rotate[2] = pose->channeloffset[5]; + if( pose->mask & 0x020) + rotate[2] += *framedata++ * pose->channelscale[5]; + rotate[3] = pose->channeloffset[6]; + if( pose->mask & 0x040) + rotate[3] += *framedata++ * pose->channelscale[6]; + + scale[0] = pose->channeloffset[7]; + if( pose->mask & 0x080) + scale[0] += *framedata++ * pose->channelscale[7]; + scale[1] = pose->channeloffset[8]; + if( pose->mask & 0x100) + scale[1] += *framedata++ * pose->channelscale[8]; + scale[2] = pose->channeloffset[9]; + if( pose->mask & 0x200) + scale[2] += *framedata++ * pose->channelscale[9]; + + // construct transformation matrix + JointToMatrix( rotate, scale, translate, mat1 ); + + if( pose->parent >= 0 ) { + Matrix34Multiply( iqmData->jointMats + 12 * pose->parent, + mat1, mat2 ); + } else { + Com_Memcpy( mat2, mat1, sizeof(mat1) ); + } + + Matrix34Multiply( mat2, jointInvMats + 12 * j, mat ); + mat += 12; + } + } + + // register shaders + // overwrite the material offset with the shader index + mesh = (iqmMesh_t *)((byte *)header + header->ofs_meshes); + surface = iqmData->surfaces; + str = (char *)header + header->ofs_text; + for( i = 0; i < header->num_meshes; i++, mesh++, surface++ ) { + surface->surfaceType = SF_IQM; + Q_strncpyz(surface->name, str + mesh->name, sizeof (surface->name)); + Q_strlwr(surface->name); // lowercase the surface name so skin compares are faster + surface->shader = R_FindShader( str + mesh->material, LIGHTMAP_NONE, qtrue ); + if( surface->shader->defaultShader ) + surface->shader = tr.defaultShader; + surface->data = iqmData; + surface->first_vertex = mesh->first_vertex; + surface->num_vertexes = mesh->num_vertexes; + surface->first_triangle = mesh->first_triangle; + surface->num_triangles = mesh->num_triangles; + } + + // copy vertexarrays and indexes + vertexarray = (iqmVertexArray_t *)((byte *)header + header->ofs_vertexarrays); + for( i = 0; i < header->num_vertexarrays; i++, vertexarray++ ) { + int n; + + // total number of values + n = header->num_vertexes * vertexarray->size; + + switch( vertexarray->type ) { + case IQM_POSITION: + Com_Memcpy( iqmData->positions, + (byte *)header + vertexarray->offset, + n * sizeof(float) ); + break; + case IQM_NORMAL: + Com_Memcpy( iqmData->normals, + (byte *)header + vertexarray->offset, + n * sizeof(float) ); + break; + case IQM_TANGENT: + Com_Memcpy( iqmData->tangents, + (byte *)header + vertexarray->offset, + n * sizeof(float) ); + break; + case IQM_TEXCOORD: + Com_Memcpy( iqmData->texcoords, + (byte *)header + vertexarray->offset, + n * sizeof(float) ); + break; + case IQM_BLENDINDEXES: + Com_Memcpy( iqmData->blendIndexes, + (byte *)header + vertexarray->offset, + n * sizeof(byte) ); + break; + case IQM_BLENDWEIGHTS: + Com_Memcpy( iqmData->blendWeights, + (byte *)header + vertexarray->offset, + n * sizeof(byte) ); + break; + case IQM_COLOR: + Com_Memcpy( iqmData->colors, + (byte *)header + vertexarray->offset, + n * sizeof(byte) ); + break; + } + } + + // copy joint parents + joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); + for( i = 0; i < header->num_joints; i++, joint++ ) { + iqmData->jointParents[i] = joint->parent; + } + + // copy triangles + triangle = (iqmTriangle_t *)((byte *)header + header->ofs_triangles); + for( i = 0; i < header->num_triangles; i++, triangle++ ) { + iqmData->triangles[3*i+0] = triangle->vertex[0]; + iqmData->triangles[3*i+1] = triangle->vertex[1]; + iqmData->triangles[3*i+2] = triangle->vertex[2]; + } + + // copy joint names + str = iqmData->names; + joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); + for( i = 0; i < header->num_joints; i++, joint++ ) { + char *name = (char *)header + header->ofs_text + + joint->name; + int len = strlen( name ) + 1; + Com_Memcpy( str, name, len ); + str += len; + } + + // copy model bounds + if(header->ofs_bounds) + { + mat = iqmData->bounds; + bounds = (iqmBounds_t *) ((byte *) header + header->ofs_bounds); + for(i = 0; i < header->num_frames; i++) + { + mat[0] = bounds->bbmin[0]; + mat[1] = bounds->bbmin[1]; + mat[2] = bounds->bbmin[2]; + mat[3] = bounds->bbmax[0]; + mat[4] = bounds->bbmax[1]; + mat[5] = bounds->bbmax[2]; + + mat += 6; + bounds++; + } + } + + return qtrue; +} + +/* +============= +R_CullIQM +============= +*/ +static int R_CullIQM( iqmData_t *data, trRefEntity_t *ent ) { + vec3_t bounds[2]; + vec_t *oldBounds, *newBounds; + int i; + + if (!data->bounds) { + tr.pc.c_box_cull_md3_clip++; + return CULL_CLIP; + } + + // compute bounds pointers + oldBounds = data->bounds + 6*ent->e.oldframe; + newBounds = data->bounds + 6*ent->e.frame; + + // calculate a bounding box in the current coordinate system + for (i = 0 ; i < 3 ; i++) { + bounds[0][i] = oldBounds[i] < newBounds[i] ? oldBounds[i] : newBounds[i]; + bounds[1][i] = oldBounds[i+3] > newBounds[i+3] ? oldBounds[i+3] : newBounds[i+3]; + } + + switch ( R_CullLocalBox( bounds ) ) + { + case CULL_IN: + tr.pc.c_box_cull_md3_in++; + return CULL_IN; + case CULL_CLIP: + tr.pc.c_box_cull_md3_clip++; + return CULL_CLIP; + case CULL_OUT: + default: + tr.pc.c_box_cull_md3_out++; + return CULL_OUT; + } +} + +/* +================= +R_ComputeIQMFogNum + +================= +*/ +int R_ComputeIQMFogNum( iqmData_t *data, trRefEntity_t *ent ) { + int i, j; + fog_t *fog; + const vec_t *bounds; + const vec_t defaultBounds[6] = { -8, -8, -8, 8, 8, 8 }; + vec3_t diag, center; + vec3_t localOrigin; + vec_t radius; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + // FIXME: non-normalized axis issues + if (data->bounds) { + bounds = data->bounds + 6*ent->e.frame; + } else { + bounds = defaultBounds; + } + VectorSubtract( bounds+3, bounds, diag ); + VectorMA( bounds, 0.5f, diag, center ); + VectorAdd( ent->e.origin, center, localOrigin ); + radius = 0.5f * VectorLength( diag ); + + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( localOrigin[j] - radius >= fog->bounds[1][j] ) { + break; + } + if ( localOrigin[j] + radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + +/* +================= +R_AddIQMSurfaces + +Add all surfaces of this model +================= +*/ +void R_AddIQMSurfaces( trRefEntity_t *ent ) { + iqmData_t *data; + srfIQModel_t *surface; + int i, j; + qboolean personalModel; + int cull; + int fogNum; + shader_t *shader; + skin_t *skin; + + data = tr.currentModel->modelData; + surface = data->surfaces; + + // don't add third_person objects if not in a portal + personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; + + if ( ent->e.renderfx & RF_WRAP_FRAMES ) { + ent->e.frame %= data->num_frames; + ent->e.oldframe %= data->num_frames; + } + + // + // Validate the frames so there is no chance of a crash. + // This will write directly into the entity structure, so + // when the surfaces are rendered, they don't need to be + // range checked again. + // + if ( (ent->e.frame >= data->num_frames) + || (ent->e.frame < 0) + || (ent->e.oldframe >= data->num_frames) + || (ent->e.oldframe < 0) ) { + ri.Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", + ent->e.oldframe, ent->e.frame, + tr.currentModel->name ); + ent->e.frame = 0; + ent->e.oldframe = 0; + } + + // + // cull the entire model if merged bounding box of both frames + // is outside the view frustum. + // + cull = R_CullIQM ( data, ent ); + if ( cull == CULL_OUT ) { + return; + } + + // + // set up lighting now that we know we aren't culled + // + if ( !personalModel || r_shadows->integer > 1 ) { + R_SetupEntityLighting( &tr.refdef, ent ); + } + + // + // see if we are in a fog volume + // + fogNum = R_ComputeIQMFogNum( data, ent ); + + for ( i = 0 ; i < data->num_surfaces ; i++ ) { + if(ent->e.customShader) + shader = R_GetShaderByHandle( ent->e.customShader ); + else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins) + { + skin = R_GetSkinByHandle(ent->e.customSkin); + shader = tr.defaultShader; + + for(j = 0; j < skin->numSurfaces; j++) + { + if (!strcmp(skin->surfaces[j]->name, surface->name)) + { + shader = skin->surfaces[j]->shader; + break; + } + } + } else { + shader = surface->shader; + } + + // we will add shadows even if the main object isn't visible in the view + + // stencil shadows can't do personal models unless I polyhedron clip + if ( !personalModel + && r_shadows->integer == 2 + && fogNum == 0 + && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) + && shader->sort == SS_OPAQUE ) { + R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, 0, 0 ); + } + + // projection shadows work fine with personal models + if ( r_shadows->integer == 3 + && fogNum == 0 + && (ent->e.renderfx & RF_SHADOW_PLANE ) + && shader->sort == SS_OPAQUE ) { + R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, 0, 0 ); + } + + if( !personalModel ) { + R_AddDrawSurf( (void *)surface, shader, fogNum, 0, 0 ); + } + + surface++; + } +} + + +static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, + float backlerp, float *mat ) { + float *mat1, *mat2; + int *joint = data->jointParents; + int i; + + if ( oldframe == frame ) { + mat1 = data->poseMats + 12 * data->num_joints * frame; + for( i = 0; i < data->num_joints; i++, joint++ ) { + if( *joint >= 0 ) { + Matrix34Multiply( mat + 12 * *joint, + mat1 + 12*i, mat + 12*i ); + } else { + Com_Memcpy( mat + 12*i, mat1 + 12*i, 12 * sizeof(float) ); + } + } + } else { + mat1 = data->poseMats + 12 * data->num_joints * frame; + mat2 = data->poseMats + 12 * data->num_joints * oldframe; + + for( i = 0; i < data->num_joints; i++, joint++ ) { + if( *joint >= 0 ) { + float tmpMat[12]; + InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, + backlerp, tmpMat ); + Matrix34Multiply( mat + 12 * *joint, + tmpMat, mat + 12*i ); + + } else { + InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, + backlerp, mat ); + } + } + } +} + +static void ComputeJointMats( iqmData_t *data, int frame, int oldframe, + float backlerp, float *mat ) { + float *mat1; + int i; + + ComputePoseMats( data, frame, oldframe, backlerp, mat ); + + for( i = 0; i < data->num_joints; i++ ) { + float outmat[12]; + mat1 = mat + 12 * i; + + Com_Memcpy(outmat, mat1, sizeof(outmat)); + + Matrix34Multiply_OnlySetOrigin( outmat, data->jointMats + 12 * i, mat1 ); + } +} + + +/* +================= +RB_AddIQMSurfaces + +Compute vertices for this model surface +================= +*/ +void RB_IQMSurfaceAnim( surfaceType_t *surface ) { + srfIQModel_t *surf = (srfIQModel_t *)surface; + iqmData_t *data = surf->data; + float jointMats[IQM_MAX_JOINTS * 12]; + int i; + + vec4_t *outXYZ = &tess.xyz[tess.numVertexes]; + vec4_t *outNormal = &tess.normal[tess.numVertexes]; + vec2_t (*outTexCoord)[2] = &tess.texCoords[tess.numVertexes]; + vec4_t *outColor = &tess.vertexColors[tess.numVertexes]; + + int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; + int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0; + float backlerp = backEnd.currentEntity->e.backlerp; + + int *tri; + glIndex_t *ptr; + glIndex_t base; + + RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 ); + + // compute interpolated joint matrices + if ( data->num_joints > 0 ) { + ComputePoseMats( data, frame, oldframe, backlerp, jointMats ); + } + + // transform vertexes and fill other data + for( i = 0; i < surf->num_vertexes; + i++, outXYZ++, outNormal++, outTexCoord++, outColor++ ) { + int j, k; + float vtxMat[12]; + float nrmMat[9]; + int vtx = i + surf->first_vertex; + + if ( data->num_joints == 0 || data->blendWeights[4*vtx] <= 0 ) { + // no blend joint, use identity matrix. + for( j = 0; j < 3; j++ ) { + for( k = 0; k < 4; k++ ) + vtxMat[4*j+k] = ( k == j ) ? 1 : 0; + } + } else { + // compute the vertex matrix by blending the up to + // four blend weights + for( k = 0; k < 12; k++ ) + vtxMat[k] = data->blendWeights[4*vtx] + * jointMats[12*data->blendIndexes[4*vtx] + k]; + for( j = 1; j < 4; j++ ) { + if( data->blendWeights[4*vtx + j] <= 0 ) + break; + for( k = 0; k < 12; k++ ) + vtxMat[k] += data->blendWeights[4*vtx + j] + * jointMats[12*data->blendIndexes[4*vtx + j] + k]; + } + for( k = 0; k < 12; k++ ) + vtxMat[k] *= 1.0f / 255.0f; + } + + // compute the normal matrix as transpose of the adjoint + // of the vertex matrix + nrmMat[ 0] = vtxMat[ 5]*vtxMat[10] - vtxMat[ 6]*vtxMat[ 9]; + nrmMat[ 1] = vtxMat[ 6]*vtxMat[ 8] - vtxMat[ 4]*vtxMat[10]; + nrmMat[ 2] = vtxMat[ 4]*vtxMat[ 9] - vtxMat[ 5]*vtxMat[ 8]; + nrmMat[ 3] = vtxMat[ 2]*vtxMat[ 9] - vtxMat[ 1]*vtxMat[10]; + nrmMat[ 4] = vtxMat[ 0]*vtxMat[10] - vtxMat[ 2]*vtxMat[ 8]; + nrmMat[ 5] = vtxMat[ 1]*vtxMat[ 8] - vtxMat[ 0]*vtxMat[ 9]; + nrmMat[ 6] = vtxMat[ 1]*vtxMat[ 6] - vtxMat[ 2]*vtxMat[ 5]; + nrmMat[ 7] = vtxMat[ 2]*vtxMat[ 4] - vtxMat[ 0]*vtxMat[ 6]; + nrmMat[ 8] = vtxMat[ 0]*vtxMat[ 5] - vtxMat[ 1]*vtxMat[ 4]; + + (*outTexCoord)[0][0] = data->texcoords[2*vtx + 0]; + (*outTexCoord)[0][1] = data->texcoords[2*vtx + 1]; + (*outTexCoord)[1][0] = (*outTexCoord)[0][0]; + (*outTexCoord)[1][1] = (*outTexCoord)[0][1]; + + (*outXYZ)[0] = + vtxMat[ 0] * data->positions[3*vtx+0] + + vtxMat[ 1] * data->positions[3*vtx+1] + + vtxMat[ 2] * data->positions[3*vtx+2] + + vtxMat[ 3]; + (*outXYZ)[1] = + vtxMat[ 4] * data->positions[3*vtx+0] + + vtxMat[ 5] * data->positions[3*vtx+1] + + vtxMat[ 6] * data->positions[3*vtx+2] + + vtxMat[ 7]; + (*outXYZ)[2] = + vtxMat[ 8] * data->positions[3*vtx+0] + + vtxMat[ 9] * data->positions[3*vtx+1] + + vtxMat[10] * data->positions[3*vtx+2] + + vtxMat[11]; + (*outXYZ)[3] = 1.0f; + + (*outNormal)[0] = + nrmMat[ 0] * data->normals[3*vtx+0] + + nrmMat[ 1] * data->normals[3*vtx+1] + + nrmMat[ 2] * data->normals[3*vtx+2]; + (*outNormal)[1] = + nrmMat[ 3] * data->normals[3*vtx+0] + + nrmMat[ 4] * data->normals[3*vtx+1] + + nrmMat[ 5] * data->normals[3*vtx+2]; + (*outNormal)[2] = + nrmMat[ 6] * data->normals[3*vtx+0] + + nrmMat[ 7] * data->normals[3*vtx+1] + + nrmMat[ 8] * data->normals[3*vtx+2]; + (*outNormal)[3] = 0.0f; + + (*outColor)[0] = data->colors[4*vtx+0] / 255.0f; + (*outColor)[1] = data->colors[4*vtx+1] / 255.0f; + (*outColor)[2] = data->colors[4*vtx+2] / 255.0f; + (*outColor)[3] = data->colors[4*vtx+3] / 255.0f; + } + + tri = data->triangles + 3 * surf->first_triangle; + ptr = &tess.indexes[tess.numIndexes]; + base = tess.numVertexes; + + for( i = 0; i < surf->num_triangles; i++ ) { + *ptr++ = base + (*tri++ - surf->first_vertex); + *ptr++ = base + (*tri++ - surf->first_vertex); + *ptr++ = base + (*tri++ - surf->first_vertex); + } + + tess.numIndexes += 3 * surf->num_triangles; + tess.numVertexes += surf->num_vertexes; +} + +int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, + int startFrame, int endFrame, + float frac, const char *tagName ) { + float jointMats[IQM_MAX_JOINTS * 12]; + int joint; + char *names = data->names; + + // get joint number by reading the joint names + for( joint = 0; joint < data->num_joints; joint++ ) { + if( !strcmp( tagName, names ) ) + break; + names += strlen( names ) + 1; + } + if( joint >= data->num_joints ) { + AxisClear( tag->axis ); + VectorClear( tag->origin ); + return qfalse; + } + + ComputeJointMats( data, startFrame, endFrame, frac, jointMats ); + + tag->axis[0][0] = jointMats[12 * joint + 0]; + tag->axis[1][0] = jointMats[12 * joint + 1]; + tag->axis[2][0] = jointMats[12 * joint + 2]; + tag->origin[0] = jointMats[12 * joint + 3]; + tag->axis[0][1] = jointMats[12 * joint + 4]; + tag->axis[1][1] = jointMats[12 * joint + 5]; + tag->axis[2][1] = jointMats[12 * joint + 6]; + tag->origin[1] = jointMats[12 * joint + 7]; + tag->axis[0][2] = jointMats[12 * joint + 8]; + tag->axis[1][2] = jointMats[12 * joint + 9]; + tag->axis[2][2] = jointMats[12 * joint + 10]; + tag->origin[2] = jointMats[12 * joint + 11]; + + return qtrue; +} diff --git a/codemp/rd-rend2/tr_postprocess.c b/codemp/rd-rend2/tr_postprocess.c new file mode 100644 index 0000000000..cab9d42be8 --- /dev/null +++ b/codemp/rd-rend2/tr_postprocess.c @@ -0,0 +1,503 @@ +/* +=========================================================================== +Copyright (C) 2011 Andrei Drexler, Richard Allen, James Canete + +This file is part of Reaction source code. + +Reaction source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Reaction source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Reaction source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "tr_local.h" + +void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, int autoExposure) +{ + vec4i_t srcBox, dstBox; + vec4_t color; + static int lastFrameCount = 0; + + if (autoExposure) + { + if (lastFrameCount == 0 || tr.frameCount < lastFrameCount || tr.frameCount - lastFrameCount > 5) + { + // determine average log luminance + FBO_t *srcFbo, *dstFbo, *tmp; + int size = 256; + + lastFrameCount = tr.frameCount; + + VectorSet4(dstBox, 0, 0, size, size); + + FBO_Blit(hdrFbo, hdrBox, NULL, tr.textureScratchFbo[0], dstBox, &tr.calclevels4xShader[0], NULL, 0); + + srcFbo = tr.textureScratchFbo[0]; + dstFbo = tr.textureScratchFbo[1]; + + // downscale to 1x1 texture + while (size > 1) + { + VectorSet4(srcBox, 0, 0, size, size); + //size >>= 2; + size >>= 1; + VectorSet4(dstBox, 0, 0, size, size); + + if (size == 1) + dstFbo = tr.targetLevelsFbo; + + //FBO_Blit(targetFbo, srcBox, NULL, tr.textureScratchFbo[nextScratch], dstBox, &tr.calclevels4xShader[1], NULL, 0); + FBO_FastBlit(srcFbo, srcBox, dstFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + tmp = srcFbo; + srcFbo = dstFbo; + dstFbo = tmp; + } + } + + // blend with old log luminance for gradual change + VectorSet4(srcBox, 0, 0, 0, 0); + + color[0] = + color[1] = + color[2] = 1.0f; + if (glRefConfig.textureFloat) + color[3] = 0.03f; + else + color[3] = 0.1f; + + FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } + + // tonemap + color[0] = + color[1] = + color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); + color[3] = 1.0f; + + if (autoExposure) + GL_BindToTMU(tr.calcLevelsImage, TB_LEVELSMAP); + else + GL_BindToTMU(tr.fixedLevelsImage, TB_LEVELSMAP); + + FBO_Blit(hdrFbo, hdrBox, NULL, ldrFbo, ldrBox, &tr.tonemapShader, color, 0); +} + +/* +============= +RB_BokehBlur + + +Blurs a part of one framebuffer to another. + +Framebuffers can be identical. +============= +*/ +void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float blur) +{ +// vec4i_t srcBox, dstBox; + vec4_t color; + + blur *= 10.0f; + + if (blur < 0.004f) + return; + + if (glRefConfig.framebufferObject) + { + // bokeh blur + if (blur > 0.0f) + { + vec4i_t quarterBox; + + quarterBox[0] = 0; + quarterBox[1] = tr.quarterFbo[0]->height; + quarterBox[2] = tr.quarterFbo[0]->width; + quarterBox[3] = -tr.quarterFbo[0]->height; + + // create a quarter texture + //FBO_Blit(NULL, NULL, NULL, tr.quarterFbo[0], NULL, NULL, NULL, 0); + FBO_FastBlit(src, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + +#ifndef HQ_BLUR + if (blur > 1.0f) + { + // create a 1/16th texture + //FBO_Blit(tr.quarterFbo[0], NULL, NULL, tr.textureScratchFbo[0], NULL, NULL, NULL, 0); + FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } +#endif + + if (blur > 0.0f && blur <= 1.0f) + { + // Crossfade original with quarter texture + VectorSet4(color, 1, 1, 1, blur); + + FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } +#ifndef HQ_BLUR + // ok blur, but can see some pixelization + else if (blur > 1.0f && blur <= 2.0f) + { + // crossfade quarter texture with 1/16th texture + FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, NULL, 0); + + VectorSet4(color, 1, 1, 1, blur - 1.0f); + + FBO_Blit(tr.textureScratchFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } + else if (blur > 2.0f) + { + // blur 1/16th texture then replace + int i; + + for (i = 0; i < 2; i++) + { + vec2_t blurTexScale; + float subblur; + + subblur = ((blur - 2.0f) / 2.0f) / 3.0f * (float)(i + 1); + + blurTexScale[0] = + blurTexScale[1] = subblur; + + color[0] = + color[1] = + color[2] = 0.5f; + color[3] = 1.0f; + + if (i != 0) + FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); + else + FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, 0); + } + + FBO_Blit(tr.textureScratchFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); + } +#else // higher quality blur, but slower + else if (blur > 1.0f) + { + // blur quarter texture then replace + int i; + + src = tr.quarterFbo[0]; + dst = tr.quarterFbo[1]; + + VectorSet4(color, 0.5f, 0.5f, 0.5f, 1); + + for (i = 0; i < 2; i++) + { + vec2_t blurTexScale; + float subblur; + + subblur = (blur - 1.0f) / 2.0f * (float)(i + 1); + + blurTexScale[0] = + blurTexScale[1] = subblur; + + color[0] = + color[1] = + color[2] = 1.0f; + if (i != 0) + color[3] = 1.0f; + else + color[3] = 0.5f; + + FBO_Blit(tr.quarterFbo[0], NULL, blurTexScale, tr.quarterFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } + + FBO_Blit(tr.quarterFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); + } +#endif + } +} + + +static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretch, float x, float y, float w, float h, float xcenter, float ycenter, float alpha) +{ + vec4i_t srcBox, dstBox; + vec4_t color; + const float inc = 1.f / passes; + const float mul = powf(stretch, inc); + float scale; + + { + vec2_t texScale; + + texScale[0] = + texScale[1] = 1.0f; + + alpha *= inc; + VectorSet4(color, alpha, alpha, alpha, 1.0f); + + VectorSet4(srcBox, 0, 0, srcFbo->width, srcFbo->height); + VectorSet4(dstBox, x, y, w, h); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, 0); + + --passes; + scale = mul; + while (passes > 0) + { + float iscale = 1.f / scale; + float s0 = xcenter * (1.f - iscale); + float t0 = (1.0f - ycenter) * (1.f - iscale); + float s1 = iscale + s0; + float t1 = iscale + t0; + + srcBox[0] = s0 * srcFbo->width; + srcBox[1] = t0 * srcFbo->height; + srcBox[2] = (s1 - s0) * srcFbo->width; + srcBox[3] = (t1 - t0) * srcFbo->height; + + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + + scale *= mul; + --passes; + } + } +} + + +static qboolean RB_UpdateSunFlareVis(void) +{ + GLuint sampleCount = 0; + if (!glRefConfig.occlusionQuery) + return qtrue; + + tr.sunFlareQueryIndex ^= 1; + if (!tr.sunFlareQueryActive[tr.sunFlareQueryIndex]) + return qtrue; + + /* debug code */ + if (0) + { + int iter; + for (iter=0 ; ; ++iter) + { + GLint available = 0; + qglGetQueryObjectivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_AVAILABLE_ARB, &available); + if (available) + break; + } + + ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); + } + + qglGetQueryObjectuivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_ARB, &sampleCount); + return sampleCount > 0; +} + +void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) +{ + vec4_t color; + float dot; + const float cutoff = 0.25f; + qboolean colorize = qtrue; + +// float w, h, w2, h2; + matrix_t mvp; + vec4_t pos, hpos; + + dot = DotProduct(tr.sunDirection, backEnd.viewParms.or.axis[0]); + if (dot < cutoff) + return; + + if (!RB_UpdateSunFlareVis()) + return; + + // From RB_DrawSun() + { + float dist; + matrix_t trans, model, mvp; + + Matrix16Translation( backEnd.viewParms.or.origin, trans ); + Matrix16Multiply( backEnd.viewParms.world.modelMatrix, trans, model ); + Matrix16Multiply(backEnd.viewParms.projectionMatrix, model, mvp); + + dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) + + VectorScale( tr.sunDirection, dist, pos ); + } + + // project sun point + //Matrix16Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp); + Matrix16Transform(mvp, pos, hpos); + + // transform to UV coords + hpos[3] = 0.5f / hpos[3]; + + pos[0] = 0.5f + hpos[0] * hpos[3]; + pos[1] = 0.5f + hpos[1] * hpos[3]; + + // initialize quarter buffers + { + float mul = 1.f; + vec2_t texScale; + vec4i_t rayBox, quarterBox; + + texScale[0] = + texScale[1] = 1.0f; + + VectorSet4(color, mul, mul, mul, 1); + + rayBox[0] = srcBox[0] * tr.sunRaysFbo->width / srcFbo->width; + rayBox[1] = srcBox[1] * tr.sunRaysFbo->height / srcFbo->height; + rayBox[2] = srcBox[2] * tr.sunRaysFbo->width / srcFbo->width; + rayBox[3] = srcBox[3] * tr.sunRaysFbo->height / srcFbo->height; + + quarterBox[0] = 0; + quarterBox[1] = tr.quarterFbo[0]->height; + quarterBox[2] = tr.quarterFbo[0]->width; + quarterBox[3] = -tr.quarterFbo[0]->height; + + // first, downsample the framebuffer + if (colorize) + { + FBO_FastBlit(srcFbo, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_Blit(tr.sunRaysFbo, rayBox, NULL, tr.quarterFbo[0], quarterBox, NULL, color, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + } + else + { + FBO_FastBlit(tr.sunRaysFbo, rayBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + } + + // radial blur passes, ping-ponging between the two quarter-size buffers + { + const float stretch_add = 2.f/3.f; + float stretch = 1.f + stretch_add; + int i; + for (i=0; i<2; ++i) + { + RB_RadialBlur(tr.quarterFbo[i&1], tr.quarterFbo[(~i) & 1], 5, stretch, 0.f, 0.f, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height, pos[0], pos[1], 1.125f); + stretch += stretch_add; + } + } + + // add result back on top of the main buffer + { + float mul = 1.f; + vec2_t texScale; + + texScale[0] = + texScale[1] = 1.0f; + + VectorSet4(color, mul, mul, mul, 1); + + FBO_Blit(tr.quarterFbo[0], NULL, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); + } +} + +static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean horizontal) +{ + float dx, dy; + float xmul, ymul; + float weights[3] = { + 0.227027027f, + 0.316216216f, + 0.070270270f, + }; + float offsets[3] = { + 0.f, + 1.3846153846f, + 3.2307692308f, + }; + + xmul = horizontal; + ymul = 1.f - xmul; + + xmul *= strength; + ymul *= strength; + + { + vec4i_t srcBox, dstBox; + vec4_t color; + vec2_t texScale; + + texScale[0] = + texScale[1] = 1.0f; + + VectorSet4(color, weights[0], weights[0], weights[0], 1.0f); + VectorSet4(srcBox, 0, 0, srcFbo->width, srcFbo->height); + VectorSet4(dstBox, 0, 0, dstFbo->width, dstFbo->height); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, 0 ); + + VectorSet4(color, weights[1], weights[1], weights[1], 1.0f); + dx = offsets[1] * xmul; + dy = offsets[1] * ymul; + VectorSet4(srcBox, dx, dy, srcFbo->width, srcFbo->height); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + VectorSet4(srcBox, -dx, -dy, srcFbo->width, srcFbo->height); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + + VectorSet4(color, weights[2], weights[2], weights[2], 1.0f); + dx = offsets[2] * xmul; + dy = offsets[2] * ymul; + VectorSet4(srcBox, dx, dy, srcFbo->width, srcFbo->height); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + VectorSet4(srcBox, -dx, -dy, srcFbo->width, srcFbo->height); + FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + } +} + +static void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) +{ + RB_BlurAxis(srcFbo, dstFbo, strength, qtrue); +} + +static void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) +{ + RB_BlurAxis(srcFbo, dstFbo, strength, qfalse); +} + +void RB_GaussianBlur(float blur) +{ + //float mul = 1.f; + float factor = Com_Clamp(0.f, 1.f, blur); + + if (factor <= 0.f) + return; + + { + vec4i_t srcBox, dstBox; + vec4_t color; + vec2_t texScale; + + texScale[0] = + texScale[1] = 1.0f; + + VectorSet4(color, 1, 1, 1, 1); + + // first, downsample the framebuffer + FBO_FastBlit(tr.screenScratchFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + // set the alpha channel + VectorSet4(srcBox, 0, 0, tr.whiteImage->width, tr.whiteImage->height); + VectorSet4(dstBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); + qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); + FBO_BlitFromTexture(tr.whiteImage, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.textureColorShader, color, GLS_DEPTHTEST_DISABLE); + qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + // blur the tiny buffer horizontally and vertically + RB_HBlur(tr.textureScratchFbo[0], tr.textureScratchFbo[1], factor); + RB_VBlur(tr.textureScratchFbo[1], tr.textureScratchFbo[0], factor); + + // finally, merge back to framebuffer + VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); + VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight); + color[3] = factor; + FBO_Blit(tr.textureScratchFbo[0], srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } +} diff --git a/codemp/rd-rend2/tr_postprocess.h b/codemp/rd-rend2/tr_postprocess.h new file mode 100644 index 0000000000..6c34ecc2f9 --- /dev/null +++ b/codemp/rd-rend2/tr_postprocess.h @@ -0,0 +1,33 @@ +/* +=========================================================================== +Copyright (C) 2011 Andrei Drexler, Richard Allen, James Canete + +This file is part of Reaction source code. + +Reaction source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Reaction source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Reaction source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef TR_POSTPROCESS_H +#define TR_POSTPROCESS_H + +#include "tr_fbo.h" + +void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, int autoExposure); +void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float blur); +void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox); +void RB_GaussianBlur(float blur); + +#endif diff --git a/codemp/rd-rend2/tr_scene.c b/codemp/rd-rend2/tr_scene.c new file mode 100644 index 0000000000..7e77418595 --- /dev/null +++ b/codemp/rd-rend2/tr_scene.c @@ -0,0 +1,532 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#include "tr_local.h" + +int r_firstSceneDrawSurf; + +int r_numdlights; +int r_firstSceneDlight; + +int r_numentities; +int r_firstSceneEntity; + +int r_numpolys; +int r_firstScenePoly; + +int r_numpolyverts; + + +/* +==================== +R_InitNextFrame + +==================== +*/ +void R_InitNextFrame( void ) { + backEndData->commands.used = 0; + + r_firstSceneDrawSurf = 0; + + r_numdlights = 0; + r_firstSceneDlight = 0; + + r_numentities = 0; + r_firstSceneEntity = 0; + + r_numpolys = 0; + r_firstScenePoly = 0; + + r_numpolyverts = 0; +} + + +/* +==================== +RE_ClearScene + +==================== +*/ +void RE_ClearScene( void ) { + r_firstSceneDlight = r_numdlights; + r_firstSceneEntity = r_numentities; + r_firstScenePoly = r_numpolys; +} + +/* +=========================================================================== + +DISCRETE POLYS + +=========================================================================== +*/ + +/* +===================== +R_AddPolygonSurfaces + +Adds all the scene's polys into this view's drawsurf list +===================== +*/ +void R_AddPolygonSurfaces( void ) { + int i; + shader_t *sh; + srfPoly_t *poly; + int fogMask; + + tr.currentEntityNum = REFENTITYNUM_WORLD; + tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; + fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0); + + for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { + sh = R_GetShaderByHandle( poly->hShader ); + R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse ); + } +} + +/* +===================== +RE_AddPolyToScene + +===================== +*/ +void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts, int numPolys ) { + srfPoly_t *poly; + int i, j; + int fogIndex; + fog_t *fog; + vec3_t bounds[2]; + + if ( !tr.registered ) { + return; + } + + if ( !hShader ) { + // This isn't a useful warning, and an hShader of zero isn't a null shader, it's + // the default shader. + //ri.Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader\n"); + //return; + } + + for ( j = 0; j < numPolys; j++ ) { + if ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys ) { + /* + NOTE TTimo this was initially a PRINT_WARNING + but it happens a lot with high fighting scenes and particles + since we don't plan on changing the const and making for room for those effects + simply cut this message to developer only + */ + ri.Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); + return; + } + + poly = &backEndData->polys[r_numpolys]; + poly->surfaceType = SF_POLY; + poly->hShader = hShader; + poly->numVerts = numVerts; + poly->verts = &backEndData->polyVerts[r_numpolyverts]; + + Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); + + if ( glConfig.hardwareType == GLHW_RAGEPRO ) { + poly->verts->modulate[0] = 255; + poly->verts->modulate[1] = 255; + poly->verts->modulate[2] = 255; + poly->verts->modulate[3] = 255; + } + // done. + r_numpolys++; + r_numpolyverts += numVerts; + + // if no world is loaded + if ( tr.world == NULL ) { + fogIndex = 0; + } + // see if it is in a fog volume + else if ( tr.world->numfogs == 1 ) { + fogIndex = 0; + } else { + // find which fog volume the poly is in + VectorCopy( poly->verts[0].xyz, bounds[0] ); + VectorCopy( poly->verts[0].xyz, bounds[1] ); + for ( i = 1 ; i < poly->numVerts ; i++ ) { + AddPointToBounds( poly->verts[i].xyz, bounds[0], bounds[1] ); + } + for ( fogIndex = 1 ; fogIndex < tr.world->numfogs ; fogIndex++ ) { + fog = &tr.world->fogs[fogIndex]; + if ( bounds[1][0] >= fog->bounds[0][0] + && bounds[1][1] >= fog->bounds[0][1] + && bounds[1][2] >= fog->bounds[0][2] + && bounds[0][0] <= fog->bounds[1][0] + && bounds[0][1] <= fog->bounds[1][1] + && bounds[0][2] <= fog->bounds[1][2] ) { + break; + } + } + if ( fogIndex == tr.world->numfogs ) { + fogIndex = 0; + } + } + poly->fogIndex = fogIndex; + } +} + + +//================================================================================= + + +/* +===================== +RE_AddRefEntityToScene + +===================== +*/ +void RE_AddRefEntityToScene( const refEntity_t *ent ) { + vec3_t cross; + + if ( !tr.registered ) { + return; + } + if ( r_numentities >= MAX_REFENTITIES ) { + ri.Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); + return; + } + if ( Q_isnan(ent->origin[0]) || Q_isnan(ent->origin[1]) || Q_isnan(ent->origin[2]) ) { + static qboolean firstTime = qtrue; + if (firstTime) { + firstTime = qfalse; + ri.Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); + } + return; + } + if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { + ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); + } + + backEndData->entities[r_numentities].e = *ent; + backEndData->entities[r_numentities].lightingCalculated = qfalse; + + CrossProduct(ent->axis[0], ent->axis[1], cross); + backEndData->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); + + r_numentities++; +} + + +/* +===================== +RE_AddDynamicLightToScene + +===================== +*/ +void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, float g, float b, int additive ) { + dlight_t *dl; + + if ( !tr.registered ) { + return; + } + if ( r_numdlights >= MAX_DLIGHTS ) { + return; + } + if ( intensity <= 0 ) { + return; + } + // these cards don't have the correct blend mode + if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { + return; + } + dl = &backEndData->dlights[r_numdlights++]; + VectorCopy (org, dl->origin); + dl->radius = intensity; + dl->color[0] = r; + dl->color[1] = g; + dl->color[2] = b; + dl->additive = additive; +} + +/* +===================== +RE_AddLightToScene + +===================== +*/ +void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { + RE_AddDynamicLightToScene( org, intensity, r, g, b, qfalse ); +} + +/* +===================== +RE_AddAdditiveLightToScene + +===================== +*/ +void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { + RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue ); +} + +/* +@@@@@@@@@@@@@@@@@@@@@ +RE_RenderScene + +Draw a 3D view into a part of the window, then return +to 2D drawing. + +Rendering a scene may require multiple views to be rendered +to handle mirrors, +@@@@@@@@@@@@@@@@@@@@@ +*/ +void RE_RenderScene( const refdef_t *fd ) { + viewParms_t parms; + int startTime; + + if ( !tr.registered ) { + return; + } + GLimp_LogComment( "====== RE_RenderScene =====\n" ); + + if ( r_norefresh->integer ) { + return; + } + + startTime = ri.Milliseconds(); + + if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { + ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); + } + + Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) ); + + tr.refdef.x = fd->x; + tr.refdef.y = fd->y; + tr.refdef.width = fd->width; + tr.refdef.height = fd->height; + tr.refdef.fov_x = fd->fov_x; + tr.refdef.fov_y = fd->fov_y; + + VectorCopy( fd->vieworg, tr.refdef.vieworg ); + VectorCopy( fd->viewaxis[0], tr.refdef.viewaxis[0] ); + VectorCopy( fd->viewaxis[1], tr.refdef.viewaxis[1] ); + VectorCopy( fd->viewaxis[2], tr.refdef.viewaxis[2] ); + + tr.refdef.time = fd->time; + tr.refdef.rdflags = fd->rdflags; + + // copy the areamask data over and note if it has changed, which + // will force a reset of the visible leafs even if the view hasn't moved + tr.refdef.areamaskModified = qfalse; + if ( ! (tr.refdef.rdflags & RDF_NOWORLDMODEL) ) { + int areaDiff; + int i; + + // compare the area bits + areaDiff = 0; + for (i = 0 ; i < MAX_MAP_AREA_BYTES/4 ; i++) { + areaDiff |= ((int *)tr.refdef.areamask)[i] ^ ((int *)fd->areamask)[i]; + ((int *)tr.refdef.areamask)[i] = ((int *)fd->areamask)[i]; + } + + if ( areaDiff ) { + // a door just opened or something + tr.refdef.areamaskModified = qtrue; + } + } + + tr.refdef.sunDir[3] = 0.0f; + tr.refdef.sunCol[3] = 1.0f; + tr.refdef.sunAmbCol[3] = 1.0f; + + VectorCopy(tr.sunDirection, tr.refdef.sunDir); + if ( (tr.refdef.rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) ){ + tr.refdef.colorScale = 1.0f; + VectorSet(tr.refdef.sunCol, 0, 0, 0); + VectorSet(tr.refdef.sunAmbCol, 0, 0, 0); + } + else + { + tr.refdef.colorScale = r_forceSun->integer ? r_forceSunMapLightScale->value : tr.mapLightScale; + + if (r_sunlightMode->integer == 1) + { + tr.refdef.sunCol[0] = + tr.refdef.sunCol[1] = + tr.refdef.sunCol[2] = 1.0f; + + tr.refdef.sunAmbCol[0] = + tr.refdef.sunAmbCol[1] = + tr.refdef.sunAmbCol[2] = r_forceSun->integer ? r_forceSunAmbientScale->value : tr.sunShadowScale; + } + else + { + float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); + if (r_forceSun->integer) + { + VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); + VectorScale(tr.sunLight, scale * r_forceSunAmbientScale->value, tr.refdef.sunAmbCol); + } + else + { + VectorScale(tr.sunLight, scale, tr.refdef.sunCol); + VectorScale(tr.sunLight, scale * tr.sunShadowScale, tr.refdef.sunAmbCol); + } + } + } + + if (r_forceAutoExposure->integer) + { + tr.refdef.autoExposureMinMax[0] = r_forceAutoExposureMin->value; + tr.refdef.autoExposureMinMax[1] = r_forceAutoExposureMax->value; + } + else + { + tr.refdef.autoExposureMinMax[0] = tr.autoExposureMinMax[0]; + tr.refdef.autoExposureMinMax[1] = tr.autoExposureMinMax[1]; + } + + if (r_forceToneMap->integer) + { + tr.refdef.toneMinAvgMaxLinear[0] = pow(2, r_forceToneMapMin->value); + tr.refdef.toneMinAvgMaxLinear[1] = pow(2, r_forceToneMapAvg->value); + tr.refdef.toneMinAvgMaxLinear[2] = pow(2, r_forceToneMapMax->value); + } + else + { + tr.refdef.toneMinAvgMaxLinear[0] = pow(2, tr.toneMinAvgMaxLevel[0]); + tr.refdef.toneMinAvgMaxLinear[1] = pow(2, tr.toneMinAvgMaxLevel[1]); + tr.refdef.toneMinAvgMaxLinear[2] = pow(2, tr.toneMinAvgMaxLevel[2]); + } + + // Makro - copy exta info if present + if (fd->rdflags & RDF_EXTRA) { + const refdefex_t* extra = (const refdefex_t*) (fd+1); + + tr.refdef.blurFactor = extra->blurFactor; + + if (fd->rdflags & RDF_SUNLIGHT) + { + VectorCopy(extra->sunDir, tr.refdef.sunDir); + VectorCopy(extra->sunCol, tr.refdef.sunCol); + VectorCopy(extra->sunAmbCol, tr.refdef.sunAmbCol); + } + } + else + { + tr.refdef.blurFactor = 0.0f; + } + + // derived info + + tr.refdef.floatTime = tr.refdef.time * 0.001f; + + tr.refdef.numDrawSurfs = r_firstSceneDrawSurf; + tr.refdef.drawSurfs = backEndData->drawSurfs; + + tr.refdef.num_entities = r_numentities - r_firstSceneEntity; + tr.refdef.entities = &backEndData->entities[r_firstSceneEntity]; + + tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; + tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; + + tr.refdef.numPolys = r_numpolys - r_firstScenePoly; + tr.refdef.polys = &backEndData->polys[r_firstScenePoly]; + + tr.refdef.num_pshadows = 0; + tr.refdef.pshadows = &backEndData->pshadows[0]; + + // turn off dynamic lighting globally by clearing all the + // dlights if it needs to be disabled or if vertex lighting is enabled + if ( r_dynamiclight->integer == 0 || + r_vertexLight->integer == 1 || + glConfig.hardwareType == GLHW_PERMEDIA2 ) { + tr.refdef.num_dlights = 0; + } + + // a single frame may have multiple scenes draw inside it -- + // a 3D game view, 3D status bar renderings, 3D menus, etc. + // They need to be distinguished by the light flare code, because + // the visibility state for a given surface may be different in + // each scene / view. + tr.frameSceneNum++; + tr.sceneCount++; + + // SmileTheory: playing with shadow mapping + if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2) + { + R_RenderDlightCubemaps(fd); + } + + /* playing with more shadows */ + if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) + { + R_RenderPshadowMaps(fd); + } + + // playing with even more shadows + if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) + { + R_RenderSunShadowMaps(fd, 0); + R_RenderSunShadowMaps(fd, 1); + R_RenderSunShadowMaps(fd, 2); + } + + // setup view parms for the initial view + // + // set up viewport + // The refdef takes 0-at-the-top y coordinates, so + // convert to GL's 0-at-the-bottom space + // + Com_Memset( &parms, 0, sizeof( parms ) ); + parms.viewportX = tr.refdef.x; + parms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); + parms.viewportWidth = tr.refdef.width; + parms.viewportHeight = tr.refdef.height; + parms.isPortal = qfalse; + + parms.fovX = tr.refdef.fov_x; + parms.fovY = tr.refdef.fov_y; + + parms.stereoFrame = tr.refdef.stereoFrame; + + VectorCopy( fd->vieworg, parms.or.origin ); + VectorCopy( fd->viewaxis[0], parms.or.axis[0] ); + VectorCopy( fd->viewaxis[1], parms.or.axis[1] ); + VectorCopy( fd->viewaxis[2], parms.or.axis[2] ); + + VectorCopy( fd->vieworg, parms.pvsOrigin ); + + if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + { + parms.flags = VPF_USESUNLIGHT; + } + + R_RenderView( &parms ); + + if(!( fd->rdflags & RDF_NOWORLDMODEL )) + R_AddPostProcessCmd(); + + // the next scene rendered in this frame will tack on after this one + r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; + r_firstSceneEntity = r_numentities; + r_firstSceneDlight = r_numdlights; + r_firstScenePoly = r_numpolys; + + tr.frontEndMsec += ri.Milliseconds() - startTime; +} diff --git a/codemp/rd-rend2/tr_shade.c b/codemp/rd-rend2/tr_shade.c new file mode 100644 index 0000000000..ef73fc5ffc --- /dev/null +++ b/codemp/rd-rend2/tr_shade.c @@ -0,0 +1,1670 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_shade.c + +#include "tr_local.h" +#if idppc_altivec && !defined(MACOS_X) +#include +#endif + +/* + + THIS ENTIRE FILE IS BACK END + + This file deals with applying shaders to surface data in the tess struct. +*/ + + +/* +================== +R_DrawElements + +================== +*/ + +void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) +{ + if (glRefConfig.drawRangeElements) + qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + else + qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + +} + + +static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, + GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) +{ + if (glRefConfig.multiDrawArrays) + { + qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); + } + else + { + int i; + + if (glRefConfig.drawRangeElements) + { + for (i = 0; i < multiDrawPrimitives; i++) + { + qglDrawRangeElementsEXT(GL_TRIANGLES, multiDrawMinIndex[i], multiDrawMaxIndex[i], multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]); + } + } + else + { + for (i = 0; i < multiDrawPrimitives; i++) + { + qglDrawElements(GL_TRIANGLES, multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]); + } + } + } +} + + +/* +============================================================= + +SURFACE SHADERS + +============================================================= +*/ + +shaderCommands_t tess; + + +/* +================= +R_BindAnimatedImageToTMU + +================= +*/ +static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { + int index; + + if ( bundle->isVideoMap ) { + int oldtmu = glState.currenttmu; + GL_SelectTexture(tmu); + ri.CIN_RunCinematic(bundle->videoMapHandle); + ri.CIN_UploadCinematic(bundle->videoMapHandle); + GL_SelectTexture(oldtmu); + return; + } + + if ( bundle->numImageAnimations <= 1 ) { + GL_BindToTMU( bundle->image[0], tmu); + return; + } + + // it is necessary to do this messy calc to make sure animations line up + // exactly with waveforms of the same frequency + index = ri.ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); + index >>= FUNCTABLE_SIZE2; + + if ( index < 0 ) { + index = 0; // may happen with shader time offsets + } + index %= bundle->numImageAnimations; + + GL_BindToTMU( bundle->image[ index ], tmu ); +} + + +/* +================ +DrawTris + +Draws triangle outlines for debugging +================ +*/ +static void DrawTris (shaderCommands_t *input) { + GL_Bind( tr.whiteImage ); + + GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); + qglDepthRange( 0, 0 ); + + { + shaderProgram_t *sp = &tr.textureColorShader; + vec4_t color; + + GLSL_VertexAttribsState(ATTR_POSITION); + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + VectorSet4(color, 1, 1, 1, 1); + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + + if (input->multiDrawPrimitives) + { + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + } + } + + qglDepthRange( 0, 1 ); +} + + +/* +================ +DrawNormals + +Draws vertex normals for debugging +================ +*/ +static void DrawNormals (shaderCommands_t *input) { + //FIXME: implement this +} + +/* +============== +RB_BeginSurface + +We must set some things up before beginning any tesselation, +because a surface may be forced to perform a RB_End due +to overflow. +============== +*/ +void RB_BeginSurface( shader_t *shader, int fogNum ) { + + shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader; + + tess.numIndexes = 0; + tess.firstIndex = 0; + tess.numVertexes = 0; + tess.multiDrawPrimitives = 0; + tess.shader = state; + tess.fogNum = fogNum; + tess.dlightBits = 0; // will be OR'd in by surface functions + tess.pshadowBits = 0; // will be OR'd in by surface functions + tess.xstages = state->stages; + tess.numPasses = state->numUnfoggedPasses; + tess.currentStageIteratorFunc = state->optimalStageIteratorFunc; + tess.useInternalVBO = qtrue; + + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) { + tess.shaderTime = tess.shader->clampTime; + } + + if (backEnd.viewParms.flags & VPF_SHADOWMAP) + { + tess.currentStageIteratorFunc = RB_StageIteratorGeneric; + } +} + + + +extern float EvalWaveForm( const waveForm_t *wf ); +extern float EvalWaveFormClamped( const waveForm_t *wf ); + + +static void ComputeTexMatrix( shaderStage_t *pStage, int bundleNum, float *outmatrix) +{ + int tm; + float matrix[16], currentmatrix[16]; + textureBundle_t *bundle = &pStage->bundle[bundleNum]; + + Matrix16Identity(outmatrix); + Matrix16Identity(currentmatrix); + + for ( tm = 0; tm < bundle->numTexMods ; tm++ ) { + switch ( bundle->texMods[tm].type ) + { + + case TMOD_NONE: + tm = TR_MAX_TEXMODS; // break out of for loop + break; + + case TMOD_TURBULENT: + RB_CalcTurbulentTexMatrix( &bundle->texMods[tm].wave, + matrix ); + outmatrix[12] = matrix[12]; + outmatrix[13] = matrix[13]; + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_ENTITY_TRANSLATE: + RB_CalcScrollTexMatrix( backEnd.currentEntity->e.shaderTexCoord, + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_SCROLL: + RB_CalcScrollTexMatrix( bundle->texMods[tm].scroll, + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_SCALE: + RB_CalcScaleTexMatrix( bundle->texMods[tm].scale, + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_STRETCH: + RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_TRANSFORM: + RB_CalcTransformTexMatrix( &bundle->texMods[tm], + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + case TMOD_ROTATE: + RB_CalcRotateTexMatrix( bundle->texMods[tm].rotateSpeed, + matrix ); + Matrix16Multiply(matrix, currentmatrix, outmatrix); + Matrix16Copy(outmatrix, currentmatrix); + break; + + default: + ri.Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); + break; + } + } +} + + +static void ComputeDeformValues(int *deformGen, vec5_t deformParams) +{ + // u_DeformGen + *deformGen = DGEN_NONE; + if(!ShaderRequiresCPUDeforms(tess.shader)) + { + deformStage_t *ds; + + // only support the first one + ds = &tess.shader->deforms[0]; + + switch (ds->deformation) + { + case DEFORM_WAVE: + *deformGen = ds->deformationWave.func; + + deformParams[0] = ds->deformationWave.base; + deformParams[1] = ds->deformationWave.amplitude; + deformParams[2] = ds->deformationWave.phase; + deformParams[3] = ds->deformationWave.frequency; + deformParams[4] = ds->deformationSpread; + break; + + case DEFORM_BULGE: + *deformGen = DGEN_BULGE; + + deformParams[0] = 0; + deformParams[1] = ds->bulgeHeight; // amplitude + deformParams[2] = ds->bulgeWidth; // phase + deformParams[3] = ds->bulgeSpeed; // frequency + deformParams[4] = 0; + break; + + default: + break; + } + } +} + + +static void ProjectDlightTexture( void ) { + int l; + vec3_t origin; + float scale; + float radius; + int deformGen; + vec5_t deformParams; + + if ( !backEnd.refdef.num_dlights ) { + return; + } + + ComputeDeformValues(&deformGen, deformParams); + + for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { + dlight_t *dl; + shaderProgram_t *sp; + vec4_t vector; + + if ( !( tess.dlightBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this light + } + + dl = &backEnd.refdef.dlights[l]; + VectorCopy( dl->transformed, origin ); + radius = dl->radius; + scale = 1.0f / radius; + + sp = &tr.dlightShader[deformGen == DGEN_NONE ? 0 : 1]; + + backEnd.pc.c_dlightDraws++; + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); + if (deformGen != DGEN_NONE) + { + GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } + + vector[0] = dl->color[0]; + vector[1] = dl->color[1]; + vector[2] = dl->color[2]; + vector[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, vector); + + vector[0] = origin[0]; + vector[1] = origin[1]; + vector[2] = origin[2]; + vector[3] = scale; + GLSL_SetUniformVec4(sp, UNIFORM_DLIGHTINFO, vector); + + GL_Bind( tr.dlightImage ); + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + if ( dl->additive ) { + GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + } + else { + GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + } + + if (tess.multiDrawPrimitives) + { + shaderCommands_t *input = &tess; + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + } + + backEnd.pc.c_totalIndexes += tess.numIndexes; + backEnd.pc.c_dlightIndexes += tess.numIndexes; + } +} + + +static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor ) +{ + // + // rgbGen + // + switch ( pStage->rgbGen ) + { + case CGEN_IDENTITY: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_IDENTITY_LIGHTING: + baseColor[0] = + baseColor[1] = + baseColor[2] = tr.identityLight; + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_EXACT_VERTEX: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 0.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 1.0f; + break; + case CGEN_EXACT_VERTEX_LIT: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 0.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 1.0f; + break; + case CGEN_CONST: + baseColor[0] = pStage->constantColor[0] / 255.0f; + baseColor[1] = pStage->constantColor[1] / 255.0f; + baseColor[2] = pStage->constantColor[2] / 255.0f; + baseColor[3] = pStage->constantColor[3] / 255.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_VERTEX: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 0.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = tr.identityLight; + vertColor[3] = 1.0f; + break; + case CGEN_VERTEX_LIT: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 0.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = tr.identityLight; + break; + case CGEN_ONE_MINUS_VERTEX: + baseColor[0] = + baseColor[1] = + baseColor[2] = tr.identityLight; + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = -tr.identityLight; + vertColor[3] = 0.0f; + break; + case CGEN_FOG: + { + fog_t *fog; + + fog = tr.world->fogs + tess.fogNum; + + baseColor[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; + baseColor[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; + baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; + baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; + } + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_WAVEFORM: + baseColor[0] = + baseColor[1] = + baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_ENTITY: + if (backEnd.currentEntity) + { + baseColor[0] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[0] / 255.0f; + baseColor[1] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[1] / 255.0f; + baseColor[2] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[2] / 255.0f; + baseColor[3] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; + } + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_ONE_MINUS_ENTITY: + if (backEnd.currentEntity) + { + baseColor[0] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[0] / 255.0f; + baseColor[1] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[1] / 255.0f; + baseColor[2] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[2] / 255.0f; + baseColor[3] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; + } + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + case CGEN_LIGHTING_DIFFUSE: + case CGEN_BAD: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + } + + // + // alphaGen + // + switch ( pStage->alphaGen ) + { + case AGEN_SKIP: + break; + case AGEN_IDENTITY: + baseColor[3] = 1.0f; + vertColor[3] = 0.0f; + break; + case AGEN_CONST: + baseColor[3] = pStage->constantColor[3] / 255.0f; + vertColor[3] = 0.0f; + break; + case AGEN_WAVEFORM: + baseColor[3] = RB_CalcWaveAlphaSingle( &pStage->alphaWave ); + vertColor[3] = 0.0f; + break; + case AGEN_ENTITY: + if (backEnd.currentEntity) + { + baseColor[3] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; + } + vertColor[3] = 0.0f; + break; + case AGEN_ONE_MINUS_ENTITY: + if (backEnd.currentEntity) + { + baseColor[3] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; + } + vertColor[3] = 0.0f; + break; + case AGEN_VERTEX: + baseColor[3] = 0.0f; + vertColor[3] = 1.0f; + break; + case AGEN_ONE_MINUS_VERTEX: + baseColor[3] = 1.0f; + vertColor[3] = -1.0f; + break; + case AGEN_LIGHTING_SPECULAR: + case AGEN_PORTAL: + case AGEN_FRESNEL: + // Done entirely in vertex program + baseColor[3] = 1.0f; + vertColor[3] = 0.0f; + break; + } + + // FIXME: find some way to implement this. +#if 0 + // if in greyscale rendering mode turn all color values into greyscale. + if(r_greyscale->integer) + { + int scale; + + for(i = 0; i < tess.numVertexes; i++) + { + scale = (tess.svars.colors[i][0] + tess.svars.colors[i][1] + tess.svars.colors[i][2]) / 3; + tess.svars.colors[i][0] = tess.svars.colors[i][1] = tess.svars.colors[i][2] = scale; + } + } +#endif +} + + +static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, float *eyeT) +{ + // from RB_CalcFogTexCoords() + fog_t *fog; + vec3_t local; + + if (!tess.fogNum) + return; + + fog = tr.world->fogs + tess.fogNum; + + VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); + fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; + fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; + fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; + fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); + + // scale the fog vectors based on the fog's thickness + VectorScale4(fogDistanceVector, fog->tcScale, fogDistanceVector); + + // rotate the gradient vector for this orientation + if ( fog->hasSurface ) { + fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + + fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; + fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + + fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; + fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + + fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; + fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); + + *eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; + } else { + *eyeT = 1; // non-surface fog always has eye inside + } +} + + +static void ComputeFogColorMask( shaderStage_t *pStage, vec4_t fogColorMask ) +{ + switch(pStage->adjustColorsForFog) + { + case ACFF_MODULATE_RGB: + fogColorMask[0] = + fogColorMask[1] = + fogColorMask[2] = 1.0f; + fogColorMask[3] = 0.0f; + break; + case ACFF_MODULATE_ALPHA: + fogColorMask[0] = + fogColorMask[1] = + fogColorMask[2] = 0.0f; + fogColorMask[3] = 1.0f; + break; + case ACFF_MODULATE_RGBA: + fogColorMask[0] = + fogColorMask[1] = + fogColorMask[2] = + fogColorMask[3] = 1.0f; + break; + default: + fogColorMask[0] = + fogColorMask[1] = + fogColorMask[2] = + fogColorMask[3] = 0.0f; + break; + } +} + + +static void ForwardDlight( void ) { + int l; + //vec3_t origin; + //float scale; + float radius; + + int deformGen; + vec5_t deformParams; + + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; + + shaderCommands_t *input = &tess; + shaderStage_t *pStage = tess.xstages[0]; + + if ( !backEnd.refdef.num_dlights ) { + return; + } + + ComputeDeformValues(&deformGen, deformParams); + + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + + for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { + dlight_t *dl; + shaderProgram_t *sp; + vec4_t vector; + matrix_t matrix; + + if ( !( tess.dlightBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this light + } + + dl = &backEnd.refdef.dlights[l]; + //VectorCopy( dl->transformed, origin ); + radius = dl->radius; + //scale = 1.0f / radius; + + //if (pStage->glslShaderGroup == tr.lightallShader) + { + int index = pStage->glslShaderIndex; + + index &= ~(LIGHTDEF_LIGHTTYPE_MASK | LIGHTDEF_USE_DELUXEMAP); + index |= LIGHTDEF_USE_LIGHT_VECTOR; + + sp = &tr.lightallShader[index]; + } + + backEnd.pc.c_lightallDraws++; + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); + + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); + if (deformGen != DGEN_NONE) + { + GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } + + if ( input->fogNum ) { + vec4_t fogColorMask; + + GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); + GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); + GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + + ComputeFogColorMask(pStage, fogColorMask); + + GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); + } + + { + vec4_t baseColor; + vec4_t vertColor; + + ComputeShaderColors(pStage, baseColor, vertColor); + + GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); + GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); + } + + if (pStage->alphaGen == AGEN_PORTAL) + { + GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); + } + + GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); + GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); + + GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, dl->color); + + VectorSet(vector, 0, 0, 0); + GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vector); + + VectorCopy(dl->origin, vector); + vector[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); + + GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo); + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + + if (pStage->bundle[TB_DIFFUSEMAP].image[0]) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + + if (pStage->bundle[TB_NORMALMAP].image[0]) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + + if (pStage->bundle[TB_SPECULARMAP].image[0]) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); + + if (r_dlightMode->integer >= 2) + { + GL_SelectTexture(TB_SHADOWMAP); + GL_BindCubemap(tr.shadowCubemaps[l]); + GL_SelectTexture(0); + } + + ComputeTexMatrix( pStage, TB_DIFFUSEMAP, matrix ); + + VectorSet4(vector, matrix[0], matrix[1], matrix[4], matrix[5]); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); + + VectorSet4(vector, matrix[8], matrix[9], matrix[12], matrix[13]); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); + + GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + + // + // draw + // + + if (input->multiDrawPrimitives) + { + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + } + + backEnd.pc.c_totalIndexes += tess.numIndexes; + backEnd.pc.c_dlightIndexes += tess.numIndexes; + } +} + + +static void ProjectPshadowVBOGLSL( void ) { + int l; + vec3_t origin; + float radius; + + int deformGen; + vec5_t deformParams; + + shaderCommands_t *input = &tess; + + if ( !backEnd.refdef.num_pshadows ) { + return; + } + + ComputeDeformValues(&deformGen, deformParams); + + for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { + pshadow_t *ps; + shaderProgram_t *sp; + vec4_t vector; + + if ( !( tess.pshadowBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this shadow + } + + ps = &backEnd.refdef.pshadows[l]; + VectorCopy( ps->lightOrigin, origin ); + radius = ps->lightRadius; + + sp = &tr.pshadowShader; + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + VectorCopy(origin, vector); + vector[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + + VectorScale(ps->lightViewAxis[0], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTFORWARD, vector); + + VectorScale(ps->lightViewAxis[1], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTRIGHT, vector); + + VectorScale(ps->lightViewAxis[2], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTUP, vector); + + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + + GL_BindToTMU( tr.pshadowMaps[l], TB_DIFFUSEMAP ); + + // + // draw + // + + if (input->multiDrawPrimitives) + { + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + } + + backEnd.pc.c_totalIndexes += tess.numIndexes; + //backEnd.pc.c_dlightIndexes += tess.numIndexes; + } +} + + + +/* +=================== +RB_FogPass + +Blends a fog texture on top of everything else +=================== +*/ +static void RB_FogPass( void ) { + fog_t *fog; + vec4_t color; + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; + shaderProgram_t *sp; + + int deformGen; + vec5_t deformParams; + + ComputeDeformValues(&deformGen, deformParams); + + { + int index = 0; + + if (deformGen != DGEN_NONE) + index |= FOGDEF_USE_DEFORM_VERTEXES; + + if (glState.vertexAttribsInterpolation) + index |= FOGDEF_USE_VERTEX_ANIMATION; + + sp = &tr.fogShader[index]; + } + + backEnd.pc.c_fogDraws++; + + GLSL_BindProgram(sp); + + fog = tr.world->fogs + tess.fogNum; + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); + if (deformGen != DGEN_NONE) + { + GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } + + color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; + color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; + color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; + color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + + GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); + GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); + GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + + if ( tess.shader->fogPass == FP_EQUAL ) { + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + } else { + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + } + + if (tess.multiDrawPrimitives) + { + shaderCommands_t *input = &tess; + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + } +} + + +static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) +{ + unsigned int vertexAttribs = input->shader->vertexAttribs; + + if(glState.vertexAttribsInterpolation > 0.0f) + { + vertexAttribs |= ATTR_POSITION2; + if (vertexAttribs & ATTR_NORMAL) + { + vertexAttribs |= ATTR_NORMAL2; +#ifdef USE_VERT_TANGENT_SPACE + vertexAttribs |= ATTR_TANGENT2; + vertexAttribs |= ATTR_BITANGENT2; +#endif + } + } + + return vertexAttribs; +} + +static void RB_IterateStagesGeneric( shaderCommands_t *input ) +{ + int stage; + matrix_t matrix; + + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; + + int deformGen; + vec5_t deformParams; + + ComputeDeformValues(&deformGen, deformParams); + + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) + { + shaderStage_t *pStage = input->xstages[stage]; + shaderProgram_t *sp; + + if ( !pStage ) + { + break; + } + + if (backEnd.depthFill) + { + if (pStage->glslShaderGroup) + { + int index = 0; + + if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + { + index |= LIGHTDEF_ENTITY; + } + + if (pStage->stateBits & GLS_ATEST_BITS) + { + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + } + + sp = &pStage->glslShaderGroup[index]; + } + else + { + int shaderAttribs = 0; + + if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) + { + shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; + } + + if (glState.vertexAttribsInterpolation > 0.0f && backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + { + shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; + } + + if (pStage->stateBits & GLS_ATEST_BITS) + { + shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; + } + + sp = &tr.genericShader[shaderAttribs]; + } + } + else if (pStage->glslShaderGroup) + { + int index = pStage->glslShaderIndex; + + if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + { + index |= LIGHTDEF_ENTITY; + } + + if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (index & LIGHTDEF_LIGHTTYPE_MASK)) + { + index |= LIGHTDEF_USE_SHADOWMAP; + } + + if (r_lightmap->integer && index & LIGHTDEF_USE_LIGHTMAP) + { + index = LIGHTDEF_USE_LIGHTMAP; + } + + sp = &pStage->glslShaderGroup[index]; + + if (pStage->glslShaderGroup == tr.lightallShader) + { + backEnd.pc.c_lightallDraws++; + } + } + else + { + sp = GLSL_GetGenericShaderProgram(stage); + + backEnd.pc.c_genericDraws++; + } + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); + + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); + if (deformGen != DGEN_NONE) + { + GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } + + if ( input->fogNum ) { + GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); + GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); + GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + } + + GL_State( pStage->stateBits ); + + { + vec4_t baseColor; + vec4_t vertColor; + qboolean tint = qtrue; + int stage2; + + ComputeShaderColors(pStage, baseColor, vertColor); + + for ( stage2 = stage + 1; stage2 < MAX_SHADER_STAGES; stage2++ ) + { + shaderStage_t *pStage2 = input->xstages[stage2]; + unsigned int srcBlendBits; + //unsigned int dstBlendBits; + + if ( !pStage2 ) + { + break; + } + + srcBlendBits = pStage2->stateBits & GLS_SRCBLEND_BITS; + //dstBlendBits = pStage2->stateBits & GLS_DSTBLEND_BITS; + + if (srcBlendBits == GLS_SRCBLEND_DST_COLOR) + { + tint = qfalse; + break; + } + } + + if (!((tr.sunShadows || r_forceSun->integer) && tess.shader->sort <= SS_OPAQUE + && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) && tess.xstages[0]->glslShaderGroup == tr.lightallShader)) + { + tint = qfalse; + } + + if (tint) + { + // use VectorScale to only scale first three values, not alpha + VectorScale(baseColor, backEnd.refdef.colorScale, baseColor); + VectorScale(vertColor, backEnd.refdef.colorScale, vertColor); + } + + GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); + GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); + } + + if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) + { + vec4_t vec; + + VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec); + GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vec); + + VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec); + GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, vec); + + VectorCopy(backEnd.currentEntity->lightDir, vec); + vec[3] = 0.0f; + GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec); + + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 999999.0f); + } + + if (pStage->alphaGen == AGEN_PORTAL) + { + GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); + } + + GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); + GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); + + if ( input->fogNum ) + { + vec4_t fogColorMask; + + ComputeFogColorMask(pStage, fogColorMask); + + GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); + } + + ComputeTexMatrix( pStage, TB_DIFFUSEMAP, matrix ); + + { + vec4_t vector; + VectorSet4(vector, matrix[0], matrix[1], matrix[4], matrix[5]); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); + + VectorSet4(vector, matrix[8], matrix[9], matrix[12], matrix[13]); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); + } + + GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + if (pStage->bundle[0].tcGen == TCGEN_VECTOR) + { + vec3_t vec; + + VectorCopy(pStage->bundle[0].tcGenVectors[0], vec); + GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR0, vec); + VectorCopy(pStage->bundle[0].tcGenVectors[1], vec); + GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); + } + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + + GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo); + + //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); + + // + // do multitexture + // + if ( backEnd.depthFill ) + { + if (!(pStage->stateBits & GLS_ATEST_BITS)) + GL_BindToTMU( tr.whiteImage, 0 ); + else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_COLORMAP], TB_COLORMAP ); + } + else if ( pStage->glslShaderGroup ) + { + int i; + + if ((backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) + { + GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP); + GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); + GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTCOLOR, backEnd.refdef.sunCol); + GLSL_SetUniformVec4(sp, UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); + } + + if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && pStage->bundle[TB_LIGHTMAP].image[0]) + { + for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) + { + if (i == TB_LIGHTMAP) + { + R_BindAnimatedImageToTMU( &pStage->bundle[i], i); + } + else if (pStage->bundle[i].image[0]) + { + GL_BindToTMU( tr.whiteImage, i); + } + } + } + else if (r_lightmap->integer == 3 && pStage->bundle[TB_DELUXEMAP].image[0]) + { + for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) + { + if (i == TB_LIGHTMAP) + { + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); + } + else if (pStage->bundle[i].image[0]) + { + GL_BindToTMU( tr.whiteImage, i); + } + } + } + else + { + for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) + { + if (pStage->bundle[i].image[0]) + { + R_BindAnimatedImageToTMU( &pStage->bundle[i], i); + } + } + } + } + else if ( pStage->bundle[1].image[0] != 0 ) + { + R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); + + // + // lightmap/secondary pass + // + if ( r_lightmap->integer ) { + GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, GL_REPLACE); + } else { + GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, tess.shader->multitextureEnv); + } + + R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 ); + } + else + { + // + // set state + // + if ( pStage->bundle[0].vertexLightmap && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) && r_lightmap->integer ) + { + GL_BindToTMU( tr.whiteImage, 0 ); + } + else + R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); + + GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, 0); + } + + // + // draw + // + if (input->multiDrawPrimitives) + { + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + } + + // allow skipping out to show just lightmaps during development + if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) ) + { + break; + } + + if (backEnd.depthFill) + break; + } +} + + +static void RB_RenderShadowmap( shaderCommands_t *input ) +{ + int deformGen; + vec5_t deformParams; + + ComputeDeformValues(&deformGen, deformParams); + + { + shaderProgram_t *sp = &tr.shadowmapShader; + + vec4_t vector; + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); + if (deformGen != DGEN_NONE) + { + GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } + + VectorCopy(backEnd.viewParms.or.origin, vector); + vector[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, backEnd.viewParms.zFar); + + GL_State( 0 ); + + // + // do multitexture + // + //if ( pStage->glslShaderGroup ) + { + // + // draw + // + + if (input->multiDrawPrimitives) + { + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + } + } + } +} + + + +/* +** RB_StageIteratorGeneric +*/ +void RB_StageIteratorGeneric( void ) +{ + shaderCommands_t *input; + unsigned int vertexAttribs = 0; + + input = &tess; + + if (!input->numVertexes || !input->numIndexes) + { + return; + } + + if (tess.useInternalVBO) + { + RB_DeformTessGeometry(); + } + + vertexAttribs = RB_CalcShaderVertexAttribs( input ); + + if (tess.useInternalVBO) + { + RB_UpdateVBOs(vertexAttribs); + } + else + { + backEnd.pc.c_staticVboDraws++; + } + + // + // log this call + // + if ( r_logFile->integer ) + { + // don't just call LogComment, or we will get + // a call to va() every frame! + GLimp_LogComment( va("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) ); + } + + // + // set face culling appropriately + // + if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + { + //GL_Cull( CT_TWO_SIDED ); + + if (input->shader->cullType == CT_TWO_SIDED) + GL_Cull( CT_TWO_SIDED ); + else if (input->shader->cullType == CT_FRONT_SIDED) + GL_Cull( CT_BACK_SIDED ); + else + GL_Cull( CT_FRONT_SIDED ); + + } + else + GL_Cull( input->shader->cullType ); + + // set polygon offset if necessary + if ( input->shader->polygonOffset ) + { + qglEnable( GL_POLYGON_OFFSET_FILL ); + qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value ); + } + + // + // Set vertex attribs and pointers + // + GLSL_VertexAttribsState(vertexAttribs); + + // + // render depth if in depthfill mode + // + if (backEnd.depthFill) + { + RB_IterateStagesGeneric( input ); + + // + // reset polygon offset + // + if ( input->shader->polygonOffset ) + { + qglDisable( GL_POLYGON_OFFSET_FILL ); + } + + return; + } + + // + // render shadowmap if in shadowmap mode + // + if (backEnd.viewParms.flags & VPF_SHADOWMAP) + { + if ( input->shader->sort == SS_OPAQUE ) + { + RB_RenderShadowmap( input ); + } + // + // reset polygon offset + // + if ( input->shader->polygonOffset ) + { + qglDisable( GL_POLYGON_OFFSET_FILL ); + } + + return; + } + + // + // + // call shader function + // + RB_IterateStagesGeneric( input ); + + // + // pshadows! + // + if (glRefConfig.framebufferObject && tess.pshadowBits && tess.shader->sort <= SS_OPAQUE + && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { + ProjectPshadowVBOGLSL(); + } + + + // + // now do any dynamic lighting needed + // + if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE + && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { + if (tess.shader->numUnfoggedPasses == 1 && tess.xstages[0]->glslShaderGroup == tr.lightallShader + && (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && r_dlightMode->integer) + { + ForwardDlight(); + } + else + { + ProjectDlightTexture(); + } + } + + // + // now do fog + // + if ( tess.fogNum && tess.shader->fogPass ) { + RB_FogPass(); + } + + // + // reset polygon offset + // + if ( input->shader->polygonOffset ) + { + qglDisable( GL_POLYGON_OFFSET_FILL ); + } +} + + +/* +** RB_EndSurface +*/ +void RB_EndSurface( void ) { + shaderCommands_t *input; + + input = &tess; + + if (input->numIndexes == 0 || input->numVertexes == 0) { + return; + } + + if (input->indexes[SHADER_MAX_INDEXES-1] != 0) { + ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); + } + if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) { + ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); + } + + if ( tess.shader == tr.shadowShader ) { + RB_ShadowTessEnd(); + return; + } + + // for debugging of sort order issues, stop rendering after a given sort value + if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) { + return; + } + + // + // update performance counters + // + backEnd.pc.c_shaders++; + backEnd.pc.c_vertexes += tess.numVertexes; + backEnd.pc.c_indexes += tess.numIndexes; + backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses; + + // + // call off to shader specific tess end function + // + tess.currentStageIteratorFunc(); + + // + // draw debugging stuff + // + if ( r_showtris->integer ) { + DrawTris (input); + } + if ( r_shownormals->integer ) { + DrawNormals (input); + } + // clear shader so we can tell we don't have any unclosed surfaces + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.multiDrawPrimitives = 0; + + GLimp_LogComment( "----------\n" ); +} diff --git a/codemp/rd-rend2/tr_shade_calc.c b/codemp/rd-rend2/tr_shade_calc.c new file mode 100644 index 0000000000..a5c4e9ab08 --- /dev/null +++ b/codemp/rd-rend2/tr_shade_calc.c @@ -0,0 +1,1339 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_shade_calc.c + +#include "tr_local.h" +#if idppc_altivec && !defined(MACOS_X) +#include +#endif + + +#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri.ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) + +static float *TableForFunc( genFunc_t func ) +{ + switch ( func ) + { + case GF_SIN: + return tr.sinTable; + case GF_TRIANGLE: + return tr.triangleTable; + case GF_SQUARE: + return tr.squareTable; + case GF_SAWTOOTH: + return tr.sawToothTable; + case GF_INVERSE_SAWTOOTH: + return tr.inverseSawToothTable; + case GF_NONE: + default: + break; + } + + ri.Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); + return NULL; +} + +/* +** EvalWaveForm +** +** Evaluates a given waveForm_t, referencing backEnd.refdef.time directly +*/ +static float EvalWaveForm( const waveForm_t *wf ) +{ + float *table; + + table = TableForFunc( wf->func ); + + return WAVEVALUE( table, wf->base, wf->amplitude, wf->phase, wf->frequency ); +} + +static float EvalWaveFormClamped( const waveForm_t *wf ) +{ + float glow = EvalWaveForm( wf ); + + if ( glow < 0 ) + { + return 0; + } + + if ( glow > 1 ) + { + return 1; + } + + return glow; +} + +/* +** RB_CalcStretchTexCoords +*/ +void RB_CalcStretchTexCoords( const waveForm_t *wf, float *st ) +{ + float p; + texModInfo_t tmi; + + p = 1.0f / EvalWaveForm( wf ); + + tmi.matrix[0][0] = p; + tmi.matrix[1][0] = 0; + tmi.translate[0] = 0.5f - 0.5f * p; + + tmi.matrix[0][1] = 0; + tmi.matrix[1][1] = p; + tmi.translate[1] = 0.5f - 0.5f * p; + + RB_CalcTransformTexCoords( &tmi, st ); +} + +void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ) +{ + float p; + texModInfo_t tmi; + + p = 1.0f / EvalWaveForm( wf ); + + tmi.matrix[0][0] = p; + tmi.matrix[1][0] = 0; + tmi.translate[0] = 0.5f - 0.5f * p; + + tmi.matrix[0][1] = 0; + tmi.matrix[1][1] = p; + tmi.translate[1] = 0.5f - 0.5f * p; + + RB_CalcTransformTexMatrix( &tmi, matrix ); +} + +/* +==================================================================== + +DEFORMATIONS + +==================================================================== +*/ + +/* +======================== +RB_CalcDeformVertexes + +======================== +*/ +void RB_CalcDeformVertexes( deformStage_t *ds ) +{ + int i; + vec3_t offset; + float scale; + float *xyz = ( float * ) tess.xyz; + float *normal = ( float * ) tess.normal; + float *table; + + if ( ds->deformationWave.frequency == 0 ) + { + scale = EvalWaveForm( &ds->deformationWave ); + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) + { + VectorScale( normal, scale, offset ); + + xyz[0] += offset[0]; + xyz[1] += offset[1]; + xyz[2] += offset[2]; + } + } + else + { + table = TableForFunc( ds->deformationWave.func ); + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) + { + float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread; + + scale = WAVEVALUE( table, ds->deformationWave.base, + ds->deformationWave.amplitude, + ds->deformationWave.phase + off, + ds->deformationWave.frequency ); + + VectorScale( normal, scale, offset ); + + xyz[0] += offset[0]; + xyz[1] += offset[1]; + xyz[2] += offset[2]; + } + } +} + +/* +========================= +RB_CalcDeformNormals + +Wiggle the normals for wavy environment mapping +========================= +*/ +void RB_CalcDeformNormals( deformStage_t *ds ) { + int i; + float scale; + float *xyz = ( float * ) tess.xyz; + float *normal = ( float * ) tess.normal; + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) { + scale = 0.98f; + scale = R_NoiseGet4f( xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, + tess.shaderTime * ds->deformationWave.frequency ); + normal[ 0 ] += ds->deformationWave.amplitude * scale; + + scale = 0.98f; + scale = R_NoiseGet4f( 100 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, + tess.shaderTime * ds->deformationWave.frequency ); + normal[ 1 ] += ds->deformationWave.amplitude * scale; + + scale = 0.98f; + scale = R_NoiseGet4f( 200 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, + tess.shaderTime * ds->deformationWave.frequency ); + normal[ 2 ] += ds->deformationWave.amplitude * scale; + + VectorNormalizeFast( normal ); + } +} + +/* +======================== +RB_CalcBulgeVertexes + +======================== +*/ +void RB_CalcBulgeVertexes( deformStage_t *ds ) { + int i; + const float *st = ( const float * ) tess.texCoords[0]; + float *xyz = ( float * ) tess.xyz; + float *normal = ( float * ) tess.normal; + float now; + + now = backEnd.refdef.time * ds->bulgeSpeed * 0.001f; + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal += 4 ) { + int off; + float scale; + + off = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now ); + + scale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight; + + xyz[0] += normal[0] * scale; + xyz[1] += normal[1] * scale; + xyz[2] += normal[2] * scale; + } +} + + +/* +====================== +RB_CalcMoveVertexes + +A deformation that can move an entire surface along a wave path +====================== +*/ +void RB_CalcMoveVertexes( deformStage_t *ds ) { + int i; + float *xyz; + float *table; + float scale; + vec3_t offset; + + table = TableForFunc( ds->deformationWave.func ); + + scale = WAVEVALUE( table, ds->deformationWave.base, + ds->deformationWave.amplitude, + ds->deformationWave.phase, + ds->deformationWave.frequency ); + + VectorScale( ds->moveVector, scale, offset ); + + xyz = ( float * ) tess.xyz; + for ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) { + VectorAdd( xyz, offset, xyz ); + } +} + + +/* +============= +DeformText + +Change a polygon into a bunch of text polygons +============= +*/ +void DeformText( const char *text ) { + int i; + vec3_t origin, width, height; + int len; + int ch; + float color[4]; + float bottom, top; + vec3_t mid; + + height[0] = 0; + height[1] = 0; + height[2] = -1; + CrossProduct( tess.normal[0], height, width ); + + // find the midpoint of the box + VectorClear( mid ); + bottom = 999999; + top = -999999; + for ( i = 0 ; i < 4 ; i++ ) { + VectorAdd( tess.xyz[i], mid, mid ); + if ( tess.xyz[i][2] < bottom ) { + bottom = tess.xyz[i][2]; + } + if ( tess.xyz[i][2] > top ) { + top = tess.xyz[i][2]; + } + } + VectorScale( mid, 0.25f, origin ); + + // determine the individual character size + height[0] = 0; + height[1] = 0; + height[2] = ( top - bottom ) * 0.5f; + + VectorScale( width, height[2] * -0.75f, width ); + + // determine the starting position + len = strlen( text ); + VectorMA( origin, (len-1), width, origin ); + + // clear the shader indexes + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + + color[0] = color[1] = color[2] = color[3] = 1.0f; + + // draw each character + for ( i = 0 ; i < len ; i++ ) { + ch = text[i]; + ch &= 255; + + if ( ch != ' ' ) { + int row, col; + float frow, fcol, size; + + row = ch>>4; + col = ch&15; + + frow = row*0.0625f; + fcol = col*0.0625f; + size = 0.0625f; + + RB_AddQuadStampExt( origin, width, height, color, fcol, frow, fcol + size, frow + size ); + } + VectorMA( origin, -2, width, origin ); + } +} + +/* +================== +GlobalVectorToLocal +================== +*/ +static void GlobalVectorToLocal( const vec3_t in, vec3_t out ) { + out[0] = DotProduct( in, backEnd.or.axis[0] ); + out[1] = DotProduct( in, backEnd.or.axis[1] ); + out[2] = DotProduct( in, backEnd.or.axis[2] ); +} + +/* +===================== +AutospriteDeform + +Assuming all the triangles for this shader are independant +quads, rebuild them as forward facing sprites +===================== +*/ +static void AutospriteDeform( void ) { + int i; + int oldVerts; + float *xyz; + vec3_t mid, delta; + float radius; + vec3_t left, up; + vec3_t leftDir, upDir; + + if ( tess.numVertexes & 3 ) { + ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); + } + if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { + ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); + } + + oldVerts = tess.numVertexes; + tess.numVertexes = 0; + tess.numIndexes = 0; + tess.firstIndex = 0; + + if ( backEnd.currentEntity != &tr.worldEntity ) { + GlobalVectorToLocal( backEnd.viewParms.or.axis[1], leftDir ); + GlobalVectorToLocal( backEnd.viewParms.or.axis[2], upDir ); + } else { + VectorCopy( backEnd.viewParms.or.axis[1], leftDir ); + VectorCopy( backEnd.viewParms.or.axis[2], upDir ); + } + + for ( i = 0 ; i < oldVerts ; i+=4 ) { + // find the midpoint + xyz = tess.xyz[i]; + + mid[0] = 0.25f * (xyz[0] + xyz[4] + xyz[8] + xyz[12]); + mid[1] = 0.25f * (xyz[1] + xyz[5] + xyz[9] + xyz[13]); + mid[2] = 0.25f * (xyz[2] + xyz[6] + xyz[10] + xyz[14]); + + VectorSubtract( xyz, mid, delta ); + radius = VectorLength( delta ) * 0.707f; // / sqrt(2) + + VectorScale( leftDir, radius, left ); + VectorScale( upDir, radius, up ); + + if ( backEnd.viewParms.isMirror ) { + VectorSubtract( vec3_origin, left, left ); + } + + // compensate for scale in the axes if necessary + if ( backEnd.currentEntity->e.nonNormalizedAxes ) { + float axisLength; + axisLength = VectorLength( backEnd.currentEntity->e.axis[0] ); + if ( !axisLength ) { + axisLength = 0; + } else { + axisLength = 1.0f / axisLength; + } + VectorScale(left, axisLength, left); + VectorScale(up, axisLength, up); + } + + RB_AddQuadStamp( mid, left, up, tess.vertexColors[i] ); + } +} + + +/* +===================== +Autosprite2Deform + +Autosprite2 will pivot a rectangular quad along the center of its long axis +===================== +*/ +int edgeVerts[6][2] = { + { 0, 1 }, + { 0, 2 }, + { 0, 3 }, + { 1, 2 }, + { 1, 3 }, + { 2, 3 } +}; + +static void Autosprite2Deform( void ) { + int i, j, k; + int indexes; + float *xyz; + vec3_t forward; + + if ( tess.numVertexes & 3 ) { + ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); + } + if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { + ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); + } + + if ( backEnd.currentEntity != &tr.worldEntity ) { + GlobalVectorToLocal( backEnd.viewParms.or.axis[0], forward ); + } else { + VectorCopy( backEnd.viewParms.or.axis[0], forward ); + } + + // this is a lot of work for two triangles... + // we could precalculate a lot of it is an issue, but it would mess up + // the shader abstraction + for ( i = 0, indexes = 0 ; i < tess.numVertexes ; i+=4, indexes+=6 ) { + float lengths[2]; + int nums[2]; + vec3_t mid[2]; + vec3_t major, minor; + float *v1, *v2; + + // find the midpoint + xyz = tess.xyz[i]; + + // identify the two shortest edges + nums[0] = nums[1] = 0; + lengths[0] = lengths[1] = 999999; + + for ( j = 0 ; j < 6 ; j++ ) { + float l; + vec3_t temp; + + v1 = xyz + 4 * edgeVerts[j][0]; + v2 = xyz + 4 * edgeVerts[j][1]; + + VectorSubtract( v1, v2, temp ); + + l = DotProduct( temp, temp ); + if ( l < lengths[0] ) { + nums[1] = nums[0]; + lengths[1] = lengths[0]; + nums[0] = j; + lengths[0] = l; + } else if ( l < lengths[1] ) { + nums[1] = j; + lengths[1] = l; + } + } + + for ( j = 0 ; j < 2 ; j++ ) { + v1 = xyz + 4 * edgeVerts[nums[j]][0]; + v2 = xyz + 4 * edgeVerts[nums[j]][1]; + + mid[j][0] = 0.5f * (v1[0] + v2[0]); + mid[j][1] = 0.5f * (v1[1] + v2[1]); + mid[j][2] = 0.5f * (v1[2] + v2[2]); + } + + // find the vector of the major axis + VectorSubtract( mid[1], mid[0], major ); + + // cross this with the view direction to get minor axis + CrossProduct( major, forward, minor ); + VectorNormalize( minor ); + + // re-project the points + for ( j = 0 ; j < 2 ; j++ ) { + float l; + + v1 = xyz + 4 * edgeVerts[nums[j]][0]; + v2 = xyz + 4 * edgeVerts[nums[j]][1]; + + l = 0.5 * sqrt( lengths[j] ); + + // we need to see which direction this edge + // is used to determine direction of projection + for ( k = 0 ; k < 5 ; k++ ) { + if ( tess.indexes[ indexes + k ] == i + edgeVerts[nums[j]][0] + && tess.indexes[ indexes + k + 1 ] == i + edgeVerts[nums[j]][1] ) { + break; + } + } + + if ( k == 5 ) { + VectorMA( mid[j], l, minor, v1 ); + VectorMA( mid[j], -l, minor, v2 ); + } else { + VectorMA( mid[j], -l, minor, v1 ); + VectorMA( mid[j], l, minor, v2 ); + } + } + } +} + + +/* +===================== +RB_DeformTessGeometry + +===================== +*/ +void RB_DeformTessGeometry( void ) { + int i; + deformStage_t *ds; + + if(!ShaderRequiresCPUDeforms(tess.shader)) + { + // we don't need the following CPU deforms + return; + } + + for ( i = 0 ; i < tess.shader->numDeforms ; i++ ) { + ds = &tess.shader->deforms[ i ]; + + switch ( ds->deformation ) { + case DEFORM_NONE: + break; + case DEFORM_NORMALS: + RB_CalcDeformNormals( ds ); + break; + case DEFORM_WAVE: + RB_CalcDeformVertexes( ds ); + break; + case DEFORM_BULGE: + RB_CalcBulgeVertexes( ds ); + break; + case DEFORM_MOVE: + RB_CalcMoveVertexes( ds ); + break; + case DEFORM_PROJECTION_SHADOW: + RB_ProjectionShadowDeform(); + break; + case DEFORM_AUTOSPRITE: + AutospriteDeform(); + break; + case DEFORM_AUTOSPRITE2: + Autosprite2Deform(); + break; + case DEFORM_TEXT0: + case DEFORM_TEXT1: + case DEFORM_TEXT2: + case DEFORM_TEXT3: + case DEFORM_TEXT4: + case DEFORM_TEXT5: + case DEFORM_TEXT6: + case DEFORM_TEXT7: + DeformText( backEnd.refdef.text[ds->deformation - DEFORM_TEXT0] ); + break; + } + } +} + +/* +==================================================================== + +COLORS + +==================================================================== +*/ + + +/* +** RB_CalcColorFromEntity +*/ +void RB_CalcColorFromEntity( unsigned char *dstColors ) +{ + int i; + int *pColors = ( int * ) dstColors; + int c; + + if ( !backEnd.currentEntity ) + return; + + c = * ( int * ) backEnd.currentEntity->e.shaderRGBA; + + for ( i = 0; i < tess.numVertexes; i++, pColors++ ) + { + *pColors = c; + } +} + +/* +** RB_CalcColorFromOneMinusEntity +*/ +void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors ) +{ + int i; + int *pColors = ( int * ) dstColors; + unsigned char invModulate[4]; + int c; + + if ( !backEnd.currentEntity ) + return; + + invModulate[0] = 255 - backEnd.currentEntity->e.shaderRGBA[0]; + invModulate[1] = 255 - backEnd.currentEntity->e.shaderRGBA[1]; + invModulate[2] = 255 - backEnd.currentEntity->e.shaderRGBA[2]; + invModulate[3] = 255 - backEnd.currentEntity->e.shaderRGBA[3]; // this trashes alpha, but the AGEN block fixes it + + c = * ( int * ) invModulate; + + for ( i = 0; i < tess.numVertexes; i++, pColors++ ) + { + *pColors = c; + } +} + +/* +** RB_CalcAlphaFromEntity +*/ +void RB_CalcAlphaFromEntity( unsigned char *dstColors ) +{ + int i; + + if ( !backEnd.currentEntity ) + return; + + dstColors += 3; + + for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) + { + *dstColors = backEnd.currentEntity->e.shaderRGBA[3]; + } +} + +/* +** RB_CalcAlphaFromOneMinusEntity +*/ +void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors ) +{ + int i; + + if ( !backEnd.currentEntity ) + return; + + dstColors += 3; + + for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) + { + *dstColors = 0xff - backEnd.currentEntity->e.shaderRGBA[3]; + } +} + +/* +** RB_CalcWaveColorSingle +*/ +float RB_CalcWaveColorSingle( const waveForm_t *wf ) +{ + float glow; + + if ( wf->func == GF_NOISE ) { + glow = wf->base + R_NoiseGet4f( 0, 0, 0, ( tess.shaderTime + wf->phase ) * wf->frequency ) * wf->amplitude; + } else { + glow = EvalWaveForm( wf ) * tr.identityLight; + } + + if ( glow < 0 ) { + glow = 0; + } + else if ( glow > 1 ) { + glow = 1; + } + + return glow; +} + +/* +** RB_CalcWaveColor +*/ +void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ) +{ + int i; + int v; + float glow; + int *colors = ( int * ) dstColors; + byte color[4]; + + glow = RB_CalcWaveColorSingle( wf ); + + v = ri.ftol(255 * glow); + color[0] = color[1] = color[2] = v; + color[3] = 255; + v = *(int *)color; + + for ( i = 0; i < tess.numVertexes; i++, colors++ ) { + *colors = v; + } +} + +/* +** RB_CalcWaveAlphaSingle +*/ +float RB_CalcWaveAlphaSingle( const waveForm_t *wf ) +{ + return EvalWaveFormClamped( wf ); +} + +/* +** RB_CalcWaveAlpha +*/ +void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors ) +{ + int i; + int v; + float glow; + + glow = EvalWaveFormClamped( wf ); + + v = 255 * glow; + + for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) + { + dstColors[3] = v; + } +} + +/* +** RB_CalcModulateColorsByFog +*/ +void RB_CalcModulateColorsByFog( unsigned char *colors ) { + int i; + float texCoords[SHADER_MAX_VERTEXES][2]; + + // calculate texcoords so we can derive density + // this is not wasted, because it would only have + // been previously called if the surface was opaque + RB_CalcFogTexCoords( texCoords[0] ); + + for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { + float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); + colors[0] *= f; + colors[1] *= f; + colors[2] *= f; + } +} + +/* +** RB_CalcModulateAlphasByFog +*/ +void RB_CalcModulateAlphasByFog( unsigned char *colors ) { + int i; + float texCoords[SHADER_MAX_VERTEXES][2]; + + // calculate texcoords so we can derive density + // this is not wasted, because it would only have + // been previously called if the surface was opaque + RB_CalcFogTexCoords( texCoords[0] ); + + for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { + float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); + colors[3] *= f; + } +} + +/* +** RB_CalcModulateRGBAsByFog +*/ +void RB_CalcModulateRGBAsByFog( unsigned char *colors ) { + int i; + float texCoords[SHADER_MAX_VERTEXES][2]; + + // calculate texcoords so we can derive density + // this is not wasted, because it would only have + // been previously called if the surface was opaque + RB_CalcFogTexCoords( texCoords[0] ); + + for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { + float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); + colors[0] *= f; + colors[1] *= f; + colors[2] *= f; + colors[3] *= f; + } +} + + +/* +==================================================================== + +TEX COORDS + +==================================================================== +*/ + +/* +======================== +RB_CalcFogTexCoords + +To do the clipped fog plane really correctly, we should use +projected textures, but I don't trust the drivers and it +doesn't fit our shader data. +======================== +*/ +void RB_CalcFogTexCoords( float *st ) { + int i; + float *v; + float s, t; + float eyeT; + qboolean eyeOutside; + fog_t *fog; + vec3_t local; + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + + fog = tr.world->fogs + tess.fogNum; + + // all fogging distance is based on world Z units + VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); + fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; + fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; + fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; + fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); + + // scale the fog vectors based on the fog's thickness + fogDistanceVector[0] *= fog->tcScale; + fogDistanceVector[1] *= fog->tcScale; + fogDistanceVector[2] *= fog->tcScale; + fogDistanceVector[3] *= fog->tcScale; + + // rotate the gradient vector for this orientation + if ( fog->hasSurface ) { + fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + + fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; + fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + + fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; + fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + + fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; + fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); + + eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; + } else { + eyeT = 1; // non-surface fog always has eye inside + } + + // see if the viewpoint is outside + // this is needed for clipping distance even for constant fog + + if ( eyeT < 0 ) { + eyeOutside = qtrue; + } else { + eyeOutside = qfalse; + } + + fogDistanceVector[3] += 1.0/512; + + // calculate density for each point + for (i = 0, v = tess.xyz[0] ; i < tess.numVertexes ; i++, v += 4) { + // calculate the length in fog + s = DotProduct( v, fogDistanceVector ) + fogDistanceVector[3]; + t = DotProduct( v, fogDepthVector ) + fogDepthVector[3]; + + // partially clipped fogs use the T axis + if ( eyeOutside ) { + if ( t < 1.0 ) { + t = 1.0/32; // point is outside, so no fogging + } else { + t = 1.0/32 + 30.0/32 * t / ( t - eyeT ); // cut the distance at the fog plane + } + } else { + if ( t < 0 ) { + t = 1.0/32; // point is outside, so no fogging + } else { + t = 31.0/32; + } + } + + st[0] = s; + st[1] = t; + st += 2; + } +} + + + +/* +** RB_CalcEnvironmentTexCoords +*/ +void RB_CalcEnvironmentTexCoords( float *st ) +{ + int i; + float *v, *normal; + vec3_t viewer, reflected; + float d; + + v = tess.xyz[0]; + normal = tess.normal[0]; + + for (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 ) + { + VectorSubtract (backEnd.or.viewOrigin, v, viewer); + VectorNormalizeFast (viewer); + + d = DotProduct (normal, viewer); + + reflected[0] = normal[0]*2*d - viewer[0]; + reflected[1] = normal[1]*2*d - viewer[1]; + reflected[2] = normal[2]*2*d - viewer[2]; + + st[0] = 0.5 + reflected[1] * 0.5; + st[1] = 0.5 - reflected[2] * 0.5; + } +} + +/* +** RB_CalcTurbulentTexCoords +*/ +void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *st ) +{ + int i; + float now; + + now = ( wf->phase + tess.shaderTime * wf->frequency ); + + for ( i = 0; i < tess.numVertexes; i++, st += 2 ) + { + float s = st[0]; + float t = st[1]; + + st[0] = s + tr.sinTable[ ( ( int ) ( ( ( tess.xyz[i][0] + tess.xyz[i][2] )* 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude; + st[1] = t + tr.sinTable[ ( ( int ) ( ( tess.xyz[i][1] * 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude; + } +} + +void RB_CalcTurbulentTexMatrix( const waveForm_t *wf, matrix_t matrix ) +{ + float now; + + now = ( wf->phase + tess.shaderTime * wf->frequency ); + + // bit of a hack here, hide amplitude and now in the matrix + // the vertex program will extract them and perform a turbulent pass last if it's nonzero + + matrix[ 0] = 1.0f; matrix[ 4] = 0.0f; matrix[ 8] = 0.0f; matrix[12] = wf->amplitude; + matrix[ 1] = 0.0f; matrix[ 5] = 1.0f; matrix[ 9] = 0.0f; matrix[13] = now; + matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; + matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; +} + +/* +** RB_CalcScaleTexCoords +*/ +void RB_CalcScaleTexCoords( const float scale[2], float *st ) +{ + int i; + + for ( i = 0; i < tess.numVertexes; i++, st += 2 ) + { + st[0] *= scale[0]; + st[1] *= scale[1]; + } +} + +void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ) +{ + matrix[ 0] = scale[0]; matrix[ 4] = 0.0f; matrix[ 8] = 0.0f; matrix[12] = 0.0f; + matrix[ 1] = 0.0f; matrix[ 5] = scale[1]; matrix[ 9] = 0.0f; matrix[13] = 0.0f; + matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; + matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; +} + +/* +** RB_CalcScrollTexCoords +*/ +void RB_CalcScrollTexCoords( const float scrollSpeed[2], float *st ) +{ + int i; + float timeScale = tess.shaderTime; + float adjustedScrollS, adjustedScrollT; + + adjustedScrollS = scrollSpeed[0] * timeScale; + adjustedScrollT = scrollSpeed[1] * timeScale; + + // clamp so coordinates don't continuously get larger, causing problems + // with hardware limits + adjustedScrollS = adjustedScrollS - floor( adjustedScrollS ); + adjustedScrollT = adjustedScrollT - floor( adjustedScrollT ); + + for ( i = 0; i < tess.numVertexes; i++, st += 2 ) + { + st[0] += adjustedScrollS; + st[1] += adjustedScrollT; + } +} + +void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ) +{ + float timeScale = tess.shaderTime; + float adjustedScrollS, adjustedScrollT; + + adjustedScrollS = scrollSpeed[0] * timeScale; + adjustedScrollT = scrollSpeed[1] * timeScale; + + // clamp so coordinates don't continuously get larger, causing problems + // with hardware limits + adjustedScrollS = adjustedScrollS - floor( adjustedScrollS ); + adjustedScrollT = adjustedScrollT - floor( adjustedScrollT ); + + + matrix[ 0] = 1.0f; matrix[ 4] = 0.0f; matrix[ 8] = adjustedScrollS; matrix[12] = 0.0f; + matrix[ 1] = 0.0f; matrix[ 5] = 1.0f; matrix[ 9] = adjustedScrollT; matrix[13] = 0.0f; + matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; + matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; +} + +/* +** RB_CalcTransformTexCoords +*/ +void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *st ) +{ + int i; + + for ( i = 0; i < tess.numVertexes; i++, st += 2 ) + { + float s = st[0]; + float t = st[1]; + + st[0] = s * tmi->matrix[0][0] + t * tmi->matrix[1][0] + tmi->translate[0]; + st[1] = s * tmi->matrix[0][1] + t * tmi->matrix[1][1] + tmi->translate[1]; + } +} + +void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ) +{ + matrix[ 0] = tmi->matrix[0][0]; matrix[ 4] = tmi->matrix[1][0]; matrix[ 8] = tmi->translate[0]; matrix[12] = 0.0f; + matrix[ 1] = tmi->matrix[0][1]; matrix[ 5] = tmi->matrix[1][1]; matrix[ 9] = tmi->translate[1]; matrix[13] = 0.0f; + matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; + matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; +} + +/* +** RB_CalcRotateTexCoords +*/ +void RB_CalcRotateTexCoords( float degsPerSecond, float *st ) +{ + float timeScale = tess.shaderTime; + float degs; + int index; + float sinValue, cosValue; + texModInfo_t tmi; + + degs = -degsPerSecond * timeScale; + index = degs * ( FUNCTABLE_SIZE / 360.0f ); + + sinValue = tr.sinTable[ index & FUNCTABLE_MASK ]; + cosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ]; + + tmi.matrix[0][0] = cosValue; + tmi.matrix[1][0] = -sinValue; + tmi.translate[0] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; + + tmi.matrix[0][1] = sinValue; + tmi.matrix[1][1] = cosValue; + tmi.translate[1] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; + + RB_CalcTransformTexCoords( &tmi, st ); +} + +void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ) +{ + float timeScale = tess.shaderTime; + float degs; + int index; + float sinValue, cosValue; + texModInfo_t tmi; + + degs = -degsPerSecond * timeScale; + index = degs * ( FUNCTABLE_SIZE / 360.0f ); + + sinValue = tr.sinTable[ index & FUNCTABLE_MASK ]; + cosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ]; + + tmi.matrix[0][0] = cosValue; + tmi.matrix[1][0] = -sinValue; + tmi.translate[0] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; + + tmi.matrix[0][1] = sinValue; + tmi.matrix[1][1] = cosValue; + tmi.translate[1] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; + + RB_CalcTransformTexMatrix( &tmi, matrix ); +} +/* +** RB_CalcSpecularAlpha +** +** Calculates specular coefficient and places it in the alpha channel +*/ +vec3_t lightOrigin = { -960, 1980, 96 }; // FIXME: track dynamically + +void RB_CalcSpecularAlpha( unsigned char *alphas ) { + int i; + float *v, *normal; + vec3_t viewer, reflected; + float l, d; + int b; + vec3_t lightDir; + int numVertexes; + + v = tess.xyz[0]; + normal = tess.normal[0]; + + alphas += 3; + + numVertexes = tess.numVertexes; + for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4, alphas += 4) { + float ilength; + + VectorSubtract( lightOrigin, v, lightDir ); +// ilength = Q_rsqrt( DotProduct( lightDir, lightDir ) ); + VectorNormalizeFast( lightDir ); + + // calculate the specular color + d = DotProduct (normal, lightDir); +// d *= ilength; + + // we don't optimize for the d < 0 case since this tends to + // cause visual artifacts such as faceted "snapping" + reflected[0] = normal[0]*2*d - lightDir[0]; + reflected[1] = normal[1]*2*d - lightDir[1]; + reflected[2] = normal[2]*2*d - lightDir[2]; + + VectorSubtract (backEnd.or.viewOrigin, v, viewer); + ilength = Q_rsqrt( DotProduct( viewer, viewer ) ); + l = DotProduct (reflected, viewer); + l *= ilength; + + if (l < 0) { + b = 0; + } else { + l = l*l; + l = l*l; + b = l * 255; + if (b > 255) { + b = 255; + } + } + + *alphas = b; + } +} + +/* +** RB_CalcDiffuseColor +** +** The basic vertex lighting calc +*/ +#if idppc_altivec +static void RB_CalcDiffuseColor_altivec( unsigned char *colors ) +{ + int i; + float *v, *normal; + trRefEntity_t *ent; + int ambientLightInt; + vec3_t lightDir; + int numVertexes; + vector unsigned char vSel = VECCONST_UINT8(0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff); + vector float ambientLightVec; + vector float directedLightVec; + vector float lightDirVec; + vector float normalVec0, normalVec1; + vector float incomingVec0, incomingVec1, incomingVec2; + vector float zero, jVec; + vector signed int jVecInt; + vector signed short jVecShort; + vector unsigned char jVecChar, normalPerm; + ent = backEnd.currentEntity; + ambientLightInt = ent->ambientLightInt; + // A lot of this could be simplified if we made sure + // entities light info was 16-byte aligned. + jVecChar = vec_lvsl(0, ent->ambientLight); + ambientLightVec = vec_ld(0, (vector float *)ent->ambientLight); + jVec = vec_ld(11, (vector float *)ent->ambientLight); + ambientLightVec = vec_perm(ambientLightVec,jVec,jVecChar); + + jVecChar = vec_lvsl(0, ent->directedLight); + directedLightVec = vec_ld(0,(vector float *)ent->directedLight); + jVec = vec_ld(11,(vector float *)ent->directedLight); + directedLightVec = vec_perm(directedLightVec,jVec,jVecChar); + + jVecChar = vec_lvsl(0, ent->lightDir); + lightDirVec = vec_ld(0,(vector float *)ent->lightDir); + jVec = vec_ld(11,(vector float *)ent->lightDir); + lightDirVec = vec_perm(lightDirVec,jVec,jVecChar); + + zero = (vector float)vec_splat_s8(0); + VectorCopy( ent->lightDir, lightDir ); + + v = tess.xyz[0]; + normal = tess.normal[0]; + + normalPerm = vec_lvsl(0,normal); + numVertexes = tess.numVertexes; + for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) { + normalVec0 = vec_ld(0,(vector float *)normal); + normalVec1 = vec_ld(11,(vector float *)normal); + normalVec0 = vec_perm(normalVec0,normalVec1,normalPerm); + incomingVec0 = vec_madd(normalVec0, lightDirVec, zero); + incomingVec1 = vec_sld(incomingVec0,incomingVec0,4); + incomingVec2 = vec_add(incomingVec0,incomingVec1); + incomingVec1 = vec_sld(incomingVec1,incomingVec1,4); + incomingVec2 = vec_add(incomingVec2,incomingVec1); + incomingVec0 = vec_splat(incomingVec2,0); + incomingVec0 = vec_max(incomingVec0,zero); + normalPerm = vec_lvsl(12,normal); + jVec = vec_madd(incomingVec0, directedLightVec, ambientLightVec); + jVecInt = vec_cts(jVec,0); // RGBx + jVecShort = vec_pack(jVecInt,jVecInt); // RGBxRGBx + jVecChar = vec_packsu(jVecShort,jVecShort); // RGBxRGBxRGBxRGBx + jVecChar = vec_sel(jVecChar,vSel,vSel); // RGBARGBARGBARGBA replace alpha with 255 + vec_ste((vector unsigned int)jVecChar,0,(unsigned int *)&colors[i*4]); // store color + } +} +#endif + +static void RB_CalcDiffuseColor_scalar( unsigned char *colors ) +{ + int i, j; + float *v, *normal; + float incoming; + trRefEntity_t *ent; + int ambientLightInt; + vec3_t ambientLight; + vec3_t lightDir; + vec3_t directedLight; + int numVertexes; + ent = backEnd.currentEntity; + ambientLightInt = ent->ambientLightInt; + VectorCopy( ent->ambientLight, ambientLight ); + VectorCopy( ent->directedLight, directedLight ); + VectorCopy( ent->lightDir, lightDir ); + + v = tess.xyz[0]; + normal = tess.normal[0]; + + numVertexes = tess.numVertexes; + for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) { + incoming = DotProduct (normal, lightDir); + if ( incoming <= 0 ) { + *(int *)&colors[i*4] = ambientLightInt; + continue; + } + j = ri.ftol(ambientLight[0] + incoming * directedLight[0]); + if ( j > 255 ) { + j = 255; + } + colors[i*4+0] = j; + + j = ri.ftol(ambientLight[1] + incoming * directedLight[1]); + if ( j > 255 ) { + j = 255; + } + colors[i*4+1] = j; + + j = ri.ftol(ambientLight[2] + incoming * directedLight[2]); + if ( j > 255 ) { + j = 255; + } + colors[i*4+2] = j; + + colors[i*4+3] = 255; + } +} + +void RB_CalcDiffuseColor( unsigned char *colors ) +{ +#if idppc_altivec + if (com_altivec->integer) { + // must be in a seperate function or G3 systems will crash. + RB_CalcDiffuseColor_altivec( colors ); + return; + } +#endif + RB_CalcDiffuseColor_scalar( colors ); +} + + + + + diff --git a/codemp/rd-rend2/tr_shader.c b/codemp/rd-rend2/tr_shader.c new file mode 100644 index 0000000000..da2a7c6065 --- /dev/null +++ b/codemp/rd-rend2/tr_shader.c @@ -0,0 +1,3787 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "tr_local.h" + +// tr_shader.c -- this file deals with the parsing and definition of shaders + +static char *s_shaderText; + +// the shader is parsed into these global variables, then copied into +// dynamically allocated memory if it is valid. +static shaderStage_t stages[MAX_SHADER_STAGES]; +static shader_t shader; +static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; + +#define FILE_HASH_SIZE 1024 +static shader_t* hashTable[FILE_HASH_SIZE]; + +#define MAX_SHADERTEXT_HASH 2048 +static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; + +/* +================ +return a hash value for the filename +================ +*/ +#ifdef __GNUCC__ + #warning TODO: check if long is ok here +#endif +static long generateHashValue( const char *fname, const int size ) { + int i; + long hash; + char letter; + + hash = 0; + i = 0; + while (fname[i] != '\0') { + letter = tolower(fname[i]); + if (letter =='.') break; // don't include extension + if (letter =='\\') letter = '/'; // damn path names + if (letter == PATH_SEP) letter = '/'; // damn path names + hash+=(long)(letter)*(i+119); + i++; + } + hash = (hash ^ (hash >> 10) ^ (hash >> 20)); + hash &= (size-1); + return hash; +} + +void R_RemapShader(const char *shaderName, const char *newShaderName, const char *timeOffset) { + char strippedName[MAX_QPATH]; + int hash; + shader_t *sh, *sh2; + qhandle_t h; + + sh = R_FindShaderByName( shaderName ); + if (sh == NULL || sh == tr.defaultShader) { + h = RE_RegisterShaderLightMap(shaderName, 0); + sh = R_GetShaderByHandle(h); + } + if (sh == NULL || sh == tr.defaultShader) { + ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); + return; + } + + sh2 = R_FindShaderByName( newShaderName ); + if (sh2 == NULL || sh2 == tr.defaultShader) { + h = RE_RegisterShaderLightMap(newShaderName, 0); + sh2 = R_GetShaderByHandle(h); + } + + if (sh2 == NULL || sh2 == tr.defaultShader) { + ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); + return; + } + + // remap all the shaders with the given name + // even tho they might have different lightmaps + COM_StripExtension(shaderName, strippedName, sizeof(strippedName)); + hash = generateHashValue(strippedName, FILE_HASH_SIZE); + for (sh = hashTable[hash]; sh; sh = sh->next) { + if (Q_stricmp(sh->name, strippedName) == 0) { + if (sh != sh2) { + sh->remappedShader = sh2; + } else { + sh->remappedShader = NULL; + } + } + } + if (timeOffset) { + sh2->timeOffset = atof(timeOffset); + } +} + +/* +=============== +ParseVector +=============== +*/ +static qboolean ParseVector( char **text, int count, float *v ) { + char *token; + int i; + + // FIXME: spaces are currently required after parens, should change parseext... + token = COM_ParseExt( text, qfalse ); + if ( strcmp( token, "(" ) ) { + ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + return qfalse; + } + + for ( i = 0 ; i < count ; i++ ) { + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) { + ri.Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); + return qfalse; + } + v[i] = atof( token ); + } + + token = COM_ParseExt( text, qfalse ); + if ( strcmp( token, ")" ) ) { + ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + return qfalse; + } + + return qtrue; +} + + +/* +=============== +NameToAFunc +=============== +*/ +static unsigned NameToAFunc( const char *funcname ) +{ + if ( !Q_stricmp( funcname, "GT0" ) ) + { + return GLS_ATEST_GT_0; + } + else if ( !Q_stricmp( funcname, "LT128" ) ) + { + return GLS_ATEST_LT_80; + } + else if ( !Q_stricmp( funcname, "GE128" ) ) + { + return GLS_ATEST_GE_80; + } + + ri.Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); + return 0; +} + + +/* +=============== +NameToSrcBlendMode +=============== +*/ +static int NameToSrcBlendMode( const char *name ) +{ + if ( !Q_stricmp( name, "GL_ONE" ) ) + { + return GLS_SRCBLEND_ONE; + } + else if ( !Q_stricmp( name, "GL_ZERO" ) ) + { + return GLS_SRCBLEND_ZERO; + } + else if ( !Q_stricmp( name, "GL_DST_COLOR" ) ) + { + return GLS_SRCBLEND_DST_COLOR; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_COLOR" ) ) + { + return GLS_SRCBLEND_ONE_MINUS_DST_COLOR; + } + else if ( !Q_stricmp( name, "GL_SRC_ALPHA" ) ) + { + return GLS_SRCBLEND_SRC_ALPHA; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_ALPHA" ) ) + { + return GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA; + } + else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) + { + return GLS_SRCBLEND_DST_ALPHA; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) + { + return GLS_SRCBLEND_ONE_MINUS_DST_ALPHA; + } + else if ( !Q_stricmp( name, "GL_SRC_ALPHA_SATURATE" ) ) + { + return GLS_SRCBLEND_ALPHA_SATURATE; + } + + ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + return GLS_SRCBLEND_ONE; +} + +/* +=============== +NameToDstBlendMode +=============== +*/ +static int NameToDstBlendMode( const char *name ) +{ + if ( !Q_stricmp( name, "GL_ONE" ) ) + { + return GLS_DSTBLEND_ONE; + } + else if ( !Q_stricmp( name, "GL_ZERO" ) ) + { + return GLS_DSTBLEND_ZERO; + } + else if ( !Q_stricmp( name, "GL_SRC_ALPHA" ) ) + { + return GLS_DSTBLEND_SRC_ALPHA; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_ALPHA" ) ) + { + return GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + } + else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) + { + return GLS_DSTBLEND_DST_ALPHA; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) + { + return GLS_DSTBLEND_ONE_MINUS_DST_ALPHA; + } + else if ( !Q_stricmp( name, "GL_SRC_COLOR" ) ) + { + return GLS_DSTBLEND_SRC_COLOR; + } + else if ( !Q_stricmp( name, "GL_ONE_MINUS_SRC_COLOR" ) ) + { + return GLS_DSTBLEND_ONE_MINUS_SRC_COLOR; + } + + ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + return GLS_DSTBLEND_ONE; +} + +/* +=============== +NameToGenFunc +=============== +*/ +static genFunc_t NameToGenFunc( const char *funcname ) +{ + if ( !Q_stricmp( funcname, "sin" ) ) + { + return GF_SIN; + } + else if ( !Q_stricmp( funcname, "square" ) ) + { + return GF_SQUARE; + } + else if ( !Q_stricmp( funcname, "triangle" ) ) + { + return GF_TRIANGLE; + } + else if ( !Q_stricmp( funcname, "sawtooth" ) ) + { + return GF_SAWTOOTH; + } + else if ( !Q_stricmp( funcname, "inversesawtooth" ) ) + { + return GF_INVERSE_SAWTOOTH; + } + else if ( !Q_stricmp( funcname, "noise" ) ) + { + return GF_NOISE; + } + + ri.Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); + return GF_SIN; +} + + +/* +=================== +ParseWaveForm +=================== +*/ +static void ParseWaveForm( char **text, waveForm_t *wave ) +{ + char *token; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + return; + } + wave->func = NameToGenFunc( token ); + + // BASE, AMP, PHASE, FREQ + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + return; + } + wave->base = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + return; + } + wave->amplitude = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + return; + } + wave->phase = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + return; + } + wave->frequency = atof( token ); +} + + +/* +=================== +ParseTexMod +=================== +*/ +static void ParseTexMod( char *_text, shaderStage_t *stage ) +{ + const char *token; + char **text = &_text; + texModInfo_t *tmi; + + if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { + ri.Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); + return; + } + + tmi = &stage->bundle[0].texMods[stage->bundle[0].numTexMods]; + stage->bundle[0].numTexMods++; + + token = COM_ParseExt( text, qfalse ); + + // + // turb + // + if ( !Q_stricmp( token, "turb" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.base = atof( token ); + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + return; + } + tmi->wave.amplitude = atof( token ); + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + return; + } + tmi->wave.phase = atof( token ); + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + return; + } + tmi->wave.frequency = atof( token ); + + tmi->type = TMOD_TURBULENT; + } + // + // scale + // + else if ( !Q_stricmp( token, "scale" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + return; + } + tmi->scale[0] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + return; + } + tmi->scale[1] = atof( token ); + tmi->type = TMOD_SCALE; + } + // + // scroll + // + else if ( !Q_stricmp( token, "scroll" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + return; + } + tmi->scroll[0] = atof( token ); + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + return; + } + tmi->scroll[1] = atof( token ); + tmi->type = TMOD_SCROLL; + } + // + // stretch + // + else if ( !Q_stricmp( token, "stretch" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.func = NameToGenFunc( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.base = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.amplitude = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.phase = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + return; + } + tmi->wave.frequency = atof( token ); + + tmi->type = TMOD_STRETCH; + } + // + // transform + // + else if ( !Q_stricmp( token, "transform" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->matrix[0][0] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->matrix[0][1] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->matrix[1][0] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->matrix[1][1] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->translate[0] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + return; + } + tmi->translate[1] = atof( token ); + + tmi->type = TMOD_TRANSFORM; + } + // + // rotate + // + else if ( !Q_stricmp( token, "rotate" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); + return; + } + tmi->rotateSpeed = atof( token ); + tmi->type = TMOD_ROTATE; + } + // + // entityTranslate + // + else if ( !Q_stricmp( token, "entityTranslate" ) ) + { + tmi->type = TMOD_ENTITY_TRANSLATE; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); + } +} + + +/* +=================== +ParseStage +=================== +*/ +static qboolean ParseStage( shaderStage_t *stage, char **text ) +{ + char *token; + int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; + qboolean depthMaskExplicit = qfalse; + + stage->active = qtrue; + + while ( 1 ) + { + token = COM_ParseExt( text, qtrue ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); + return qfalse; + } + + if ( token[0] == '}' ) + { + break; + } + // + // map + // + else if ( !Q_stricmp( token, "map" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + + if ( !Q_stricmp( token, "$whiteimage" ) ) + { + stage->bundle[0].image[0] = tr.whiteImage; + continue; + } + else if ( !Q_stricmp( token, "$lightmap" ) ) + { + stage->bundle[0].isLightmap = qtrue; + if ( shader.lightmapIndex < 0 ) { + stage->bundle[0].image[0] = tr.whiteImage; + } else { + stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + } + continue; + } + else if ( !Q_stricmp( token, "$deluxemap" ) ) + { + if (!tr.worldDeluxeMapping) + { + ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); + return qfalse; + } + + stage->bundle[0].isLightmap = qtrue; + if ( shader.lightmapIndex < 0 ) { + stage->bundle[0].image[0] = tr.whiteImage; + } else { + stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex]; + } + continue; + } + else + { + imgType_t type = IMGTYPE_COLORALPHA; + imgFlags_t flags = IMGFLAG_NONE; + + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) + { + type = IMGTYPE_NORMAL; + flags |= IMGFLAG_NOLIGHTSCALE; + + if (stage->type == ST_NORMALPARALLAXMAP) + type = IMGTYPE_NORMALHEIGHT; + } + else + { + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; + + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; + } + + stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); + + if ( !stage->bundle[0].image[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + return qfalse; + } + } + } + // + // clampmap + // + else if ( !Q_stricmp( token, "clampmap" ) ) + { + imgType_t type = IMGTYPE_COLORALPHA; + imgFlags_t flags = IMGFLAG_CLAMPTOEDGE; + + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) + { + type = IMGTYPE_NORMAL; + flags |= IMGFLAG_NOLIGHTSCALE; + + if (stage->type == ST_NORMALPARALLAXMAP) + type = IMGTYPE_NORMALHEIGHT; + } + else + { + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; + + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; + } + + + stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); + if ( !stage->bundle[0].image[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + return qfalse; + } + } + // + // animMap .... + // + else if ( !Q_stricmp( token, "animMap" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + stage->bundle[0].imageAnimationSpeed = atof( token ); + + // parse up to MAX_IMAGE_ANIMATIONS animations + while ( 1 ) { + int num; + + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) { + break; + } + num = stage->bundle[0].numImageAnimations; + if ( num < MAX_IMAGE_ANIMATIONS ) { + imgFlags_t flags = IMGFLAG_NONE; + + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; + + stage->bundle[0].image[num] = R_FindImageFile( token, IMGTYPE_COLORALPHA, flags ); + if ( !stage->bundle[0].image[num] ) + { + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + return qfalse; + } + stage->bundle[0].numImageAnimations++; + } + } + } + else if ( !Q_stricmp( token, "videoMap" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); + if (stage->bundle[0].videoMapHandle != -1) { + stage->bundle[0].isVideoMap = qtrue; + stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; + } + } + // + // alphafunc + // + else if ( !Q_stricmp( token, "alphaFunc" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + + atestBits = NameToAFunc( token ); + } + // + // depthFunc + // + else if ( !Q_stricmp( token, "depthfunc" ) ) + { + token = COM_ParseExt( text, qfalse ); + + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); + return qfalse; + } + + if ( !Q_stricmp( token, "lequal" ) ) + { + depthFuncBits = 0; + } + else if ( !Q_stricmp( token, "equal" ) ) + { + depthFuncBits = GLS_DEPTHFUNC_EQUAL; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); + continue; + } + } + // + // detail + // + else if ( !Q_stricmp( token, "detail" ) ) + { + stage->isDetail = qtrue; + } + // + // blendfunc + // or blendfunc + // + else if ( !Q_stricmp( token, "blendfunc" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + continue; + } + // check for "simple" blends first + if ( !Q_stricmp( token, "add" ) ) { + blendSrcBits = GLS_SRCBLEND_ONE; + blendDstBits = GLS_DSTBLEND_ONE; + } else if ( !Q_stricmp( token, "filter" ) ) { + blendSrcBits = GLS_SRCBLEND_DST_COLOR; + blendDstBits = GLS_DSTBLEND_ZERO; + } else if ( !Q_stricmp( token, "blend" ) ) { + blendSrcBits = GLS_SRCBLEND_SRC_ALPHA; + blendDstBits = GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + } else { + // complex double blends + blendSrcBits = NameToSrcBlendMode( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + continue; + } + blendDstBits = NameToDstBlendMode( token ); + } + + // clear depth mask for blended surfaces + if ( !depthMaskExplicit ) + { + depthMaskBits = 0; + } + } + // + // stage + // + else if(!Q_stricmp(token, "stage")) + { + token = COM_ParseExt(text, qfalse); + if(token[0] == 0) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); + continue; + } + + if(!Q_stricmp(token, "diffuseMap")) + { + stage->type = ST_DIFFUSEMAP; + } + else if(!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "bumpMap")) + { + stage->type = ST_NORMALMAP; + } + else if(!Q_stricmp(token, "normalParallaxMap") || !Q_stricmp(token, "bumpParallaxMap")) + { + if (r_parallaxMapping->integer) + stage->type = ST_NORMALPARALLAXMAP; + else + stage->type = ST_NORMALMAP; + } + else if(!Q_stricmp(token, "specularMap")) + { + stage->type = ST_SPECULARMAP; + stage->materialInfo[0] = 0.04f; + stage->materialInfo[1] = 256.0f; + } + else + { + ri.Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); + continue; + } + } + // + // specularReflectance + // + else if (!Q_stricmp(token, "specularreflectance")) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); + continue; + } + stage->materialInfo[0] = atof( token ); + } + // + // specularExponent + // + else if (!Q_stricmp(token, "specularexponent")) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); + continue; + } + stage->materialInfo[1] = atof( token ); + } + // + // rgbGen + // + else if ( !Q_stricmp( token, "rgbGen" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); + continue; + } + + if ( !Q_stricmp( token, "wave" ) ) + { + ParseWaveForm( text, &stage->rgbWave ); + stage->rgbGen = CGEN_WAVEFORM; + } + else if ( !Q_stricmp( token, "const" ) ) + { + vec3_t color; + + ParseVector( text, 3, color ); + stage->constantColor[0] = 255 * color[0]; + stage->constantColor[1] = 255 * color[1]; + stage->constantColor[2] = 255 * color[2]; + + stage->rgbGen = CGEN_CONST; + } + else if ( !Q_stricmp( token, "identity" ) ) + { + stage->rgbGen = CGEN_IDENTITY; + } + else if ( !Q_stricmp( token, "identityLighting" ) ) + { + stage->rgbGen = CGEN_IDENTITY_LIGHTING; + } + else if ( !Q_stricmp( token, "entity" ) ) + { + stage->rgbGen = CGEN_ENTITY; + } + else if ( !Q_stricmp( token, "oneMinusEntity" ) ) + { + stage->rgbGen = CGEN_ONE_MINUS_ENTITY; + } + else if ( !Q_stricmp( token, "vertex" ) ) + { + stage->rgbGen = CGEN_VERTEX; + if ( stage->alphaGen == 0 ) { + stage->alphaGen = AGEN_VERTEX; + } + } + else if ( !Q_stricmp( token, "exactVertex" ) ) + { + stage->rgbGen = CGEN_EXACT_VERTEX; + } + else if ( !Q_stricmp( token, "vertexLit" ) ) + { + stage->rgbGen = CGEN_VERTEX_LIT; + if ( stage->alphaGen == 0 ) { + stage->alphaGen = AGEN_VERTEX; + } + } + else if ( !Q_stricmp( token, "exactVertexLit" ) ) + { + stage->rgbGen = CGEN_EXACT_VERTEX_LIT; + } + else if ( !Q_stricmp( token, "lightingDiffuse" ) ) + { + stage->rgbGen = CGEN_LIGHTING_DIFFUSE; + } + else if ( !Q_stricmp( token, "oneMinusVertex" ) ) + { + stage->rgbGen = CGEN_ONE_MINUS_VERTEX; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); + continue; + } + } + // + // alphaGen + // + else if ( !Q_stricmp( token, "alphaGen" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); + continue; + } + + if ( !Q_stricmp( token, "wave" ) ) + { + ParseWaveForm( text, &stage->alphaWave ); + stage->alphaGen = AGEN_WAVEFORM; + } + else if ( !Q_stricmp( token, "const" ) ) + { + token = COM_ParseExt( text, qfalse ); + stage->constantColor[3] = 255 * atof( token ); + stage->alphaGen = AGEN_CONST; + } + else if ( !Q_stricmp( token, "identity" ) ) + { + stage->alphaGen = AGEN_IDENTITY; + } + else if ( !Q_stricmp( token, "entity" ) ) + { + stage->alphaGen = AGEN_ENTITY; + } + else if ( !Q_stricmp( token, "oneMinusEntity" ) ) + { + stage->alphaGen = AGEN_ONE_MINUS_ENTITY; + } + else if ( !Q_stricmp( token, "vertex" ) ) + { + stage->alphaGen = AGEN_VERTEX; + } + else if ( !Q_stricmp( token, "lightingSpecular" ) ) + { + stage->alphaGen = AGEN_LIGHTING_SPECULAR; + } + else if ( !Q_stricmp( token, "oneMinusVertex" ) ) + { + stage->alphaGen = AGEN_ONE_MINUS_VERTEX; + } + else if ( !Q_stricmp( token, "portal" ) ) + { + stage->alphaGen = AGEN_PORTAL; + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + shader.portalRange = 256; + ri.Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); + } + else + { + shader.portalRange = atof( token ); + } + } + else if ( !Q_stricmp( token, "fresnel" ) ) + { + stage->alphaGen = AGEN_FRESNEL; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); + continue; + } + } + // + // tcGen + // + else if ( !Q_stricmp(token, "texgen") || !Q_stricmp( token, "tcGen" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); + continue; + } + + if ( !Q_stricmp( token, "environment" ) ) + { + stage->bundle[0].tcGen = TCGEN_ENVIRONMENT_MAPPED; + } + else if ( !Q_stricmp( token, "lightmap" ) ) + { + stage->bundle[0].tcGen = TCGEN_LIGHTMAP; + } + else if ( !Q_stricmp( token, "texture" ) || !Q_stricmp( token, "base" ) ) + { + stage->bundle[0].tcGen = TCGEN_TEXTURE; + } + else if ( !Q_stricmp( token, "vector" ) ) + { + ParseVector( text, 3, stage->bundle[0].tcGenVectors[0] ); + ParseVector( text, 3, stage->bundle[0].tcGenVectors[1] ); + + stage->bundle[0].tcGen = TCGEN_VECTOR; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); + } + } + // + // tcMod <...> + // + else if ( !Q_stricmp( token, "tcMod" ) ) + { + char buffer[1024] = ""; + + while ( 1 ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + break; + strcat( buffer, token ); + strcat( buffer, " " ); + } + + ParseTexMod( buffer, stage ); + + continue; + } + // + // depthmask + // + else if ( !Q_stricmp( token, "depthwrite" ) ) + { + depthMaskBits = GLS_DEPTHMASK_TRUE; + depthMaskExplicit = qtrue; + + continue; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); + return qfalse; + } + } + + // + // if cgen isn't explicitly specified, use either identity or identitylighting + // + if ( stage->rgbGen == CGEN_BAD ) { + if ( blendSrcBits == 0 || + blendSrcBits == GLS_SRCBLEND_ONE || + blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) { + stage->rgbGen = CGEN_IDENTITY_LIGHTING; + } else { + stage->rgbGen = CGEN_IDENTITY; + } + } + + + // + // implicitly assume that a GL_ONE GL_ZERO blend mask disables blending + // + if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && + ( blendDstBits == GLS_DSTBLEND_ZERO ) ) + { + blendDstBits = blendSrcBits = 0; + depthMaskBits = GLS_DEPTHMASK_TRUE; + } + + // decide which agens we can skip + if ( stage->alphaGen == AGEN_IDENTITY ) { + if ( stage->rgbGen == CGEN_IDENTITY + || stage->rgbGen == CGEN_LIGHTING_DIFFUSE ) { + stage->alphaGen = AGEN_SKIP; + } + } + + // + // compute state bits + // + stage->stateBits = depthMaskBits | + blendSrcBits | blendDstBits | + atestBits | + depthFuncBits; + + return qtrue; +} + +/* +=============== +ParseDeform + +deformVertexes wave +deformVertexes normal +deformVertexes move +deformVertexes bulge +deformVertexes projectionShadow +deformVertexes autoSprite +deformVertexes autoSprite2 +deformVertexes text[0-7] +=============== +*/ +static void ParseDeform( char **text ) { + char *token; + deformStage_t *ds; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); + return; + } + + if ( shader.numDeforms == MAX_SHADER_DEFORMS ) { + ri.Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); + return; + } + + ds = &shader.deforms[ shader.numDeforms ]; + shader.numDeforms++; + + if ( !Q_stricmp( token, "projectionShadow" ) ) { + ds->deformation = DEFORM_PROJECTION_SHADOW; + return; + } + + if ( !Q_stricmp( token, "autosprite" ) ) { + ds->deformation = DEFORM_AUTOSPRITE; + return; + } + + if ( !Q_stricmp( token, "autosprite2" ) ) { + ds->deformation = DEFORM_AUTOSPRITE2; + return; + } + + if ( !Q_stricmpn( token, "text", 4 ) ) { + int n; + + n = token[4] - '0'; + if ( n < 0 || n > 7 ) { + n = 0; + } + ds->deformation = DEFORM_TEXT0 + n; + return; + } + + if ( !Q_stricmp( token, "bulge" ) ) { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + return; + } + ds->bulgeWidth = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + return; + } + ds->bulgeHeight = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + return; + } + ds->bulgeSpeed = atof( token ); + + ds->deformation = DEFORM_BULGE; + return; + } + + if ( !Q_stricmp( token, "wave" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + return; + } + + if ( atof( token ) != 0 ) + { + ds->deformationSpread = 1.0f / atof( token ); + } + else + { + ds->deformationSpread = 100.0f; + ri.Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); + } + + ParseWaveForm( text, &ds->deformationWave ); + ds->deformation = DEFORM_WAVE; + return; + } + + if ( !Q_stricmp( token, "normal" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + return; + } + ds->deformationWave.amplitude = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + return; + } + ds->deformationWave.frequency = atof( token ); + + ds->deformation = DEFORM_NORMALS; + return; + } + + if ( !Q_stricmp( token, "move" ) ) { + int i; + + for ( i = 0 ; i < 3 ; i++ ) { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) { + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + return; + } + ds->moveVector[i] = atof( token ); + } + + ParseWaveForm( text, &ds->deformationWave ); + ds->deformation = DEFORM_MOVE; + return; + } + + ri.Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); +} + + +/* +=============== +ParseSkyParms + +skyParms +=============== +*/ +static void ParseSkyParms( char **text ) { + char *token; + static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; + char pathname[MAX_QPATH]; + int i; + imgFlags_t imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + + if (r_srgb->integer) + imgFlags |= IMGFLAG_SRGB; + + // outerbox + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) { + ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + return; + } + if ( strcmp( token, "-" ) ) { + for (i=0 ; i<6 ; i++) { + Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" + , token, suf[i] ); + shader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags | IMGFLAG_CLAMPTOEDGE ); + + if ( !shader.sky.outerbox[i] ) { + shader.sky.outerbox[i] = tr.defaultImage; + } + } + } + + // cloudheight + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) { + ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + return; + } + shader.sky.cloudHeight = atof( token ); + if ( !shader.sky.cloudHeight ) { + shader.sky.cloudHeight = 512; + } + R_InitSkyTexCoords( shader.sky.cloudHeight ); + + + // innerbox + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) { + ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + return; + } + if ( strcmp( token, "-" ) ) { + for (i=0 ; i<6 ; i++) { + Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" + , token, suf[i] ); + shader.sky.innerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags ); + if ( !shader.sky.innerbox[i] ) { + shader.sky.innerbox[i] = tr.defaultImage; + } + } + } + + shader.isSky = qtrue; +} + + +/* +================= +ParseSort +================= +*/ +void ParseSort( char **text ) { + char *token; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) { + ri.Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); + return; + } + + if ( !Q_stricmp( token, "portal" ) ) { + shader.sort = SS_PORTAL; + } else if ( !Q_stricmp( token, "sky" ) ) { + shader.sort = SS_ENVIRONMENT; + } else if ( !Q_stricmp( token, "opaque" ) ) { + shader.sort = SS_OPAQUE; + }else if ( !Q_stricmp( token, "decal" ) ) { + shader.sort = SS_DECAL; + } else if ( !Q_stricmp( token, "seeThrough" ) ) { + shader.sort = SS_SEE_THROUGH; + } else if ( !Q_stricmp( token, "banner" ) ) { + shader.sort = SS_BANNER; + } else if ( !Q_stricmp( token, "additive" ) ) { + shader.sort = SS_BLEND1; + } else if ( !Q_stricmp( token, "nearest" ) ) { + shader.sort = SS_NEAREST; + } else if ( !Q_stricmp( token, "underwater" ) ) { + shader.sort = SS_UNDERWATER; + } else { + shader.sort = atof( token ); + } +} + + + +// this table is also present in q3map + +typedef struct { + char *name; + int clearSolid, surfaceFlags, contents; +} infoParm_t; + +infoParm_t infoParms[] = { + // server relevant contents + {"water", 1, 0, CONTENTS_WATER }, + {"slime", 1, 0, CONTENTS_SLIME }, // mildly damaging + {"lava", 1, 0, CONTENTS_LAVA }, // very damaging + {"playerclip", 1, 0, CONTENTS_PLAYERCLIP }, + {"monsterclip", 1, 0, CONTENTS_MONSTERCLIP }, + {"nodrop", 1, 0, CONTENTS_NODROP }, // don't drop items or leave bodies (death fog, lava, etc) + {"nonsolid", 1, SURF_NONSOLID, 0}, // clears the solid flag + + // utility relevant attributes + {"origin", 1, 0, CONTENTS_ORIGIN }, // center of rotating brushes + {"trans", 0, 0, CONTENTS_TRANSLUCENT }, // don't eat contained surfaces + {"detail", 0, 0, CONTENTS_DETAIL }, // don't include in structural bsp + {"structural", 0, 0, CONTENTS_STRUCTURAL }, // force into structural bsp even if trnas + {"areaportal", 1, 0, CONTENTS_AREAPORTAL }, // divides areas + {"clusterportal", 1,0, CONTENTS_CLUSTERPORTAL }, // for bots + {"donotenter", 1, 0, CONTENTS_DONOTENTER }, // for bots + + {"fog", 1, 0, CONTENTS_FOG}, // carves surfaces entering + {"sky", 0, SURF_SKY, 0 }, // emit light from an environment map + {"lightfilter", 0, SURF_LIGHTFILTER, 0 }, // filter light going through it + {"alphashadow", 0, SURF_ALPHASHADOW, 0 }, // test light on a per-pixel basis + {"hint", 0, SURF_HINT, 0 }, // use as a primary splitter + + // server attributes + {"slick", 0, SURF_SLICK, 0 }, + {"noimpact", 0, SURF_NOIMPACT, 0 }, // don't make impact explosions or marks + {"nomarks", 0, SURF_NOMARKS, 0 }, // don't make impact marks, but still explode + {"ladder", 0, SURF_LADDER, 0 }, + {"nodamage", 0, SURF_NODAMAGE, 0 }, + {"metalsteps", 0, SURF_METALSTEPS,0 }, + {"flesh", 0, SURF_FLESH, 0 }, + {"nosteps", 0, SURF_NOSTEPS, 0 }, + + // drawsurf attributes + {"nodraw", 0, SURF_NODRAW, 0 }, // don't generate a drawsurface (or a lightmap) + {"pointlight", 0, SURF_POINTLIGHT, 0 }, // sample lighting at vertexes + {"nolightmap", 0, SURF_NOLIGHTMAP,0 }, // don't generate a lightmap + {"nodlight", 0, SURF_NODLIGHT, 0 }, // don't ever add dynamic lights + {"dust", 0, SURF_DUST, 0} // leave a dust trail when walking on this surface +}; + + +/* +=============== +ParseSurfaceParm + +surfaceparm +=============== +*/ +static void ParseSurfaceParm( char **text ) { + char *token; + int numInfoParms = ARRAY_LEN( infoParms ); + int i; + + token = COM_ParseExt( text, qfalse ); + for ( i = 0 ; i < numInfoParms ; i++ ) { + if ( !Q_stricmp( token, infoParms[i].name ) ) { + shader.surfaceFlags |= infoParms[i].surfaceFlags; + shader.contentFlags |= infoParms[i].contents; +#if 0 + if ( infoParms[i].clearSolid ) { + si->contents &= ~CONTENTS_SOLID; + } +#endif + break; + } + } +} + +/* +================= +ParseShader + +The current text pointer is at the explicit text definition of the +shader. Parse it into the global shader variable. Later functions +will optimize it. +================= +*/ +static qboolean ParseShader( char **text ) +{ + char *token; + int s; + + s = 0; + + token = COM_ParseExt( text, qtrue ); + if ( token[0] != '{' ) + { + ri.Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); + return qfalse; + } + + while ( 1 ) + { + token = COM_ParseExt( text, qtrue ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); + return qfalse; + } + + // end of shader definition + if ( token[0] == '}' ) + { + break; + } + // stage definition + else if ( token[0] == '{' ) + { + if ( s >= MAX_SHADER_STAGES ) { + ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); + return qfalse; + } + + if ( !ParseStage( &stages[s], text ) ) + { + return qfalse; + } + stages[s].active = qtrue; + s++; + + continue; + } + // skip stuff that only the QuakeEdRadient needs + else if ( !Q_stricmpn( token, "qer", 3 ) ) { + SkipRestOfLine( text ); + continue; + } + // sun parms + else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { + float a, b; + qboolean isGL2Sun = qfalse; + + if (!Q_stricmp( token, "q3gl2_sun" ) && r_sunShadows->integer ) + { + isGL2Sun = qtrue; + tr.sunShadows = qtrue; + } + + token = COM_ParseExt( text, qfalse ); + tr.sunLight[0] = atof( token ); + token = COM_ParseExt( text, qfalse ); + tr.sunLight[1] = atof( token ); + token = COM_ParseExt( text, qfalse ); + tr.sunLight[2] = atof( token ); + + VectorNormalize( tr.sunLight ); + + token = COM_ParseExt( text, qfalse ); + a = atof( token ); + VectorScale( tr.sunLight, a, tr.sunLight); + + token = COM_ParseExt( text, qfalse ); + a = atof( token ); + a = a / 180 * M_PI; + + token = COM_ParseExt( text, qfalse ); + b = atof( token ); + b = b / 180 * M_PI; + + tr.sunDirection[0] = cos( a ) * cos( b ); + tr.sunDirection[1] = sin( a ) * cos( b ); + tr.sunDirection[2] = sin( b ); + + if (isGL2Sun) + { + token = COM_ParseExt( text, qfalse ); + tr.mapLightScale = atof(token); + + token = COM_ParseExt( text, qfalse ); + tr.sunShadowScale = atof(token); + } + + SkipRestOfLine( text ); + continue; + } + // tonemap parms + else if ( !Q_stricmp( token, "q3gl2_tonemap" ) ) { + token = COM_ParseExt( text, qfalse ); + tr.toneMinAvgMaxLevel[0] = atof( token ); + token = COM_ParseExt( text, qfalse ); + tr.toneMinAvgMaxLevel[1] = atof( token ); + token = COM_ParseExt( text, qfalse ); + tr.toneMinAvgMaxLevel[2] = atof( token ); + + token = COM_ParseExt( text, qfalse ); + tr.autoExposureMinMax[0] = atof( token ); + token = COM_ParseExt( text, qfalse ); + tr.autoExposureMinMax[1] = atof( token ); + + SkipRestOfLine( text ); + continue; + } + else if ( !Q_stricmp( token, "deformVertexes" ) ) { + ParseDeform( text ); + continue; + } + else if ( !Q_stricmp( token, "tesssize" ) ) { + SkipRestOfLine( text ); + continue; + } + else if ( !Q_stricmp( token, "clampTime" ) ) { + token = COM_ParseExt( text, qfalse ); + if (token[0]) { + shader.clampTime = atof(token); + } + } + // skip stuff that only the q3map needs + else if ( !Q_stricmpn( token, "q3map", 5 ) ) { + SkipRestOfLine( text ); + continue; + } + // skip stuff that only q3map or the server needs + else if ( !Q_stricmp( token, "surfaceParm" ) ) { + ParseSurfaceParm( text ); + continue; + } + // no mip maps + else if ( !Q_stricmp( token, "nomipmaps" ) ) + { + shader.noMipMaps = qtrue; + shader.noPicMip = qtrue; + continue; + } + // no picmip adjustment + else if ( !Q_stricmp( token, "nopicmip" ) ) + { + shader.noPicMip = qtrue; + continue; + } + // polygonOffset + else if ( !Q_stricmp( token, "polygonOffset" ) ) + { + shader.polygonOffset = qtrue; + continue; + } + // entityMergable, allowing sprite surfaces from multiple entities + // to be merged into one batch. This is a savings for smoke + // puffs and blood, but can't be used for anything where the + // shader calcs (not the surface function) reference the entity color or scroll + else if ( !Q_stricmp( token, "entityMergable" ) ) + { + shader.entityMergable = qtrue; + continue; + } + // fogParms + else if ( !Q_stricmp( token, "fogParms" ) ) + { + if ( !ParseVector( text, 3, shader.fogParms.color ) ) { + return qfalse; + } + + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); + continue; + } + shader.fogParms.depthForOpaque = atof( token ); + + // skip any old gradient directions + SkipRestOfLine( text ); + continue; + } + // portal + else if ( !Q_stricmp(token, "portal") ) + { + shader.sort = SS_PORTAL; + shader.isPortal = qtrue; + continue; + } + // skyparms + else if ( !Q_stricmp( token, "skyparms" ) ) + { + ParseSkyParms( text ); + continue; + } + // light determines flaring in q3map, not needed here + else if ( !Q_stricmp(token, "light") ) + { + COM_ParseExt( text, qfalse ); + continue; + } + // cull + else if ( !Q_stricmp( token, "cull") ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + ri.Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); + continue; + } + + if ( !Q_stricmp( token, "none" ) || !Q_stricmp( token, "twosided" ) || !Q_stricmp( token, "disable" ) ) + { + shader.cullType = CT_TWO_SIDED; + } + else if ( !Q_stricmp( token, "back" ) || !Q_stricmp( token, "backside" ) || !Q_stricmp( token, "backsided" ) ) + { + shader.cullType = CT_BACK_SIDED; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); + } + continue; + } + // sort + else if ( !Q_stricmp( token, "sort" ) ) + { + ParseSort( text ); + continue; + } + else + { + ri.Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); + return qfalse; + } + } + + // + // ignore shaders that don't have any stages, unless it is a sky or fog + // + if ( s == 0 && !shader.isSky && !(shader.contentFlags & CONTENTS_FOG ) ) { + return qfalse; + } + + shader.explicitlyDefined = qtrue; + + return qtrue; +} + +/* +======================================================================================== + +SHADER OPTIMIZATION AND FOGGING + +======================================================================================== +*/ + +/* +=================== +ComputeStageIteratorFunc + +See if we can use on of the simple fastpath stage functions, +otherwise set to the generic stage function +=================== +*/ +static void ComputeStageIteratorFunc( void ) +{ + shader.optimalStageIteratorFunc = RB_StageIteratorGeneric; + + // + // see if this should go into the sky path + // + if ( shader.isSky ) + { + shader.optimalStageIteratorFunc = RB_StageIteratorSky; + return; + } +} + +/* +=================== +ComputeVertexAttribs + +Check which vertex attributes we only need, so we +don't need to submit/copy all of them. +=================== +*/ +static void ComputeVertexAttribs(void) +{ + int i, stage; + + // dlights always need ATTR_NORMAL + shader.vertexAttribs = ATTR_POSITION | ATTR_NORMAL; + + // portals always need normals, for SurfIsOffscreen() + if (shader.isPortal) + { + shader.vertexAttribs |= ATTR_NORMAL; + } + + if (shader.defaultShader) + { + shader.vertexAttribs |= ATTR_TEXCOORD; + return; + } + + if(shader.numDeforms) + { + for ( i = 0; i < shader.numDeforms; i++) + { + deformStage_t *ds = &shader.deforms[i]; + + switch (ds->deformation) + { + case DEFORM_BULGE: + shader.vertexAttribs |= ATTR_NORMAL | ATTR_TEXCOORD; + break; + + case DEFORM_AUTOSPRITE: + shader.vertexAttribs |= ATTR_NORMAL | ATTR_COLOR; + break; + + case DEFORM_WAVE: + case DEFORM_NORMALS: + case DEFORM_TEXT0: + case DEFORM_TEXT1: + case DEFORM_TEXT2: + case DEFORM_TEXT3: + case DEFORM_TEXT4: + case DEFORM_TEXT5: + case DEFORM_TEXT6: + case DEFORM_TEXT7: + shader.vertexAttribs |= ATTR_NORMAL; + break; + + default: + case DEFORM_NONE: + case DEFORM_MOVE: + case DEFORM_PROJECTION_SHADOW: + case DEFORM_AUTOSPRITE2: + break; + } + } + } + + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) + { + shaderStage_t *pStage = &stages[stage]; + + if ( !pStage->active ) + { + break; + } + + if (pStage->glslShaderGroup == tr.lightallShader) + { + shader.vertexAttribs |= ATTR_NORMAL; + +#ifdef USE_VERT_TANGENT_SPACE + if (pStage->glslShaderIndex & LIGHTDEF_USE_NORMALMAP) + { + shader.vertexAttribs |= ATTR_BITANGENT | ATTR_TANGENT; + } +#endif + + switch (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) + { + case LIGHTDEF_USE_LIGHTMAP: + case LIGHTDEF_USE_LIGHT_VERTEX: + shader.vertexAttribs |= ATTR_LIGHTDIRECTION; + break; + default: + break; + } + } + + for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) + { + if ( pStage->bundle[i].image[0] == 0 ) + { + continue; + } + + switch(pStage->bundle[i].tcGen) + { + case TCGEN_TEXTURE: + shader.vertexAttribs |= ATTR_TEXCOORD; + break; + case TCGEN_LIGHTMAP: + shader.vertexAttribs |= ATTR_LIGHTCOORD; + break; + case TCGEN_ENVIRONMENT_MAPPED: + shader.vertexAttribs |= ATTR_NORMAL; + break; + + default: + break; + } + } + + switch(pStage->rgbGen) + { + case CGEN_EXACT_VERTEX: + case CGEN_VERTEX: + case CGEN_EXACT_VERTEX_LIT: + case CGEN_VERTEX_LIT: + case CGEN_ONE_MINUS_VERTEX: + shader.vertexAttribs |= ATTR_COLOR; + break; + + case CGEN_LIGHTING_DIFFUSE: + shader.vertexAttribs |= ATTR_NORMAL; + break; + + default: + break; + } + + switch(pStage->alphaGen) + { + case AGEN_LIGHTING_SPECULAR: + case AGEN_FRESNEL: + shader.vertexAttribs |= ATTR_NORMAL; + break; + + case AGEN_VERTEX: + case AGEN_ONE_MINUS_VERTEX: + shader.vertexAttribs |= ATTR_COLOR; + break; + + default: + break; + } + } +} + +typedef struct { + int blendA; + int blendB; + + int multitextureEnv; + int multitextureBlend; +} collapse_t; + +static collapse_t collapse[] = { + { 0, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, + GL_MODULATE, 0 }, + + { 0, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, + GL_MODULATE, 0 }, + + { GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, + GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, + + { GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, + GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, + + { GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, + GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, + + { GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, + GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, + + { 0, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, + GL_ADD, 0 }, + + { GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, + GL_ADD, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE }, +#if 0 + { 0, GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA, + GL_DECAL, 0 }, +#endif + { -1 } +}; + +/* +================ +CollapseMultitexture + +Attempt to combine two stages into a single multitexture stage +FIXME: I think modulated add + modulated add collapses incorrectly +================= +*/ +static qboolean CollapseMultitexture( void ) { + int abits, bbits; + int i; + textureBundle_t tmpBundle; + + if ( !qglActiveTextureARB ) { + return qfalse; + } + + // make sure both stages are active + if ( !stages[0].active || !stages[1].active ) { + return qfalse; + } + + // on voodoo2, don't combine different tmus + if ( glConfig.driverType == GLDRV_VOODOO ) { + if ( stages[0].bundle[0].image[0]->TMU == + stages[1].bundle[0].image[0]->TMU ) { + return qfalse; + } + } + + abits = stages[0].stateBits; + bbits = stages[1].stateBits; + + // make sure that both stages have identical state other than blend modes + if ( ( abits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) != + ( bbits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) ) { + return qfalse; + } + + abits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + bbits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + + // search for a valid multitexture blend function + for ( i = 0; collapse[i].blendA != -1 ; i++ ) { + if ( abits == collapse[i].blendA + && bbits == collapse[i].blendB ) { + break; + } + } + + // nothing found + if ( collapse[i].blendA == -1 ) { + return qfalse; + } + + // GL_ADD is a separate extension + if ( collapse[i].multitextureEnv == GL_ADD && !glConfig.textureEnvAddAvailable ) { + return qfalse; + } + + // make sure waveforms have identical parameters + if ( ( stages[0].rgbGen != stages[1].rgbGen ) || + ( stages[0].alphaGen != stages[1].alphaGen ) ) { + return qfalse; + } + + // an add collapse can only have identity colors + if ( collapse[i].multitextureEnv == GL_ADD && stages[0].rgbGen != CGEN_IDENTITY ) { + return qfalse; + } + + if ( stages[0].rgbGen == CGEN_WAVEFORM ) + { + if ( memcmp( &stages[0].rgbWave, + &stages[1].rgbWave, + sizeof( stages[0].rgbWave ) ) ) + { + return qfalse; + } + } + if ( stages[0].alphaGen == AGEN_WAVEFORM ) + { + if ( memcmp( &stages[0].alphaWave, + &stages[1].alphaWave, + sizeof( stages[0].alphaWave ) ) ) + { + return qfalse; + } + } + + + // make sure that lightmaps are in bundle 1 for 3dfx + if ( stages[0].bundle[0].isLightmap ) + { + tmpBundle = stages[0].bundle[0]; + stages[0].bundle[0] = stages[1].bundle[0]; + stages[0].bundle[1] = tmpBundle; + } + else + { + stages[0].bundle[1] = stages[1].bundle[0]; + } + + // set the new blend state bits + shader.multitextureEnv = collapse[i].multitextureEnv; + stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + stages[0].stateBits |= collapse[i].multitextureBlend; + + // + // move down subsequent shaders + // + memmove( &stages[1], &stages[2], sizeof( stages[0] ) * ( MAX_SHADER_STAGES - 2 ) ); + Com_Memset( &stages[MAX_SHADER_STAGES-1], 0, sizeof( stages[0] ) ); + + return qtrue; +} + +static void CollapseStagesToLightall(shaderStage_t *diffuse, + shaderStage_t *normal, shaderStage_t *specular, shaderStage_t *lightmap, + qboolean useLightVector, qboolean useLightVertex, qboolean parallax, qboolean tcgen) +{ + int defs = 0; + + //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); + + // reuse diffuse, mark others inactive + diffuse->type = ST_GLSL; + + if (lightmap) + { + //ri.Printf(PRINT_ALL, ", lightmap"); + diffuse->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; + defs |= LIGHTDEF_USE_LIGHTMAP; + } + else if (useLightVector) + { + defs |= LIGHTDEF_USE_LIGHT_VECTOR; + } + else if (useLightVertex) + { + defs |= LIGHTDEF_USE_LIGHT_VERTEX; + } + + if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap) + { + //ri.Printf(PRINT_ALL, ", deluxemap"); + diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; + diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex]; + defs |= LIGHTDEF_USE_DELUXEMAP; + } + + if (r_normalMapping->integer) + { + image_t *diffuseImg; + if (normal) + { + //ri.Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); + diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; + defs |= LIGHTDEF_USE_NORMALMAP; + if (parallax && r_parallaxMapping->integer) + defs |= LIGHTDEF_USE_PARALLAXMAP; + } + else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0])) + { + char normalName[MAX_QPATH]; + image_t *normalImg; + imgFlags_t normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + + COM_StripExtension(diffuseImg->imgName, normalName, MAX_QPATH); + Q_strcat(normalName, MAX_QPATH, "_n"); + + normalImg = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); + + if (normalImg) + { + diffuse->bundle[TB_NORMALMAP] = diffuse->bundle[0]; + diffuse->bundle[TB_NORMALMAP].image[0] = normalImg; + + defs |= LIGHTDEF_USE_NORMALMAP; + if (parallax && r_parallaxMapping->integer) + defs |= LIGHTDEF_USE_PARALLAXMAP; + } + } + } + + if (r_specularMapping->integer) + { + if (specular) + { + //ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); + diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; + diffuse->materialInfo[0] = specular->materialInfo[0]; + diffuse->materialInfo[1] = specular->materialInfo[1]; + defs |= LIGHTDEF_USE_SPECULARMAP; + } + } + + if (tcgen || diffuse->bundle[0].numTexMods) + { + defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + } + + //ri.Printf(PRINT_ALL, ".\n"); + + diffuse->glslShaderGroup = tr.lightallShader; + diffuse->glslShaderIndex = defs; +} + + +static qboolean CollapseStagesToGLSL(void) +{ + int i, j, numStages; + qboolean skip = qfalse; + + // skip shaders with deforms + if (shader.numDeforms != 0) + { + skip = qtrue; + } + + if (!skip) + { + // if 2+ stages and first stage is lightmap, switch them + // this makes it easier for the later bits to process + if (stages[0].active && stages[0].bundle[0].isLightmap && stages[1].active) + { + int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + + if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) + || blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) + { + int stateBits0 = stages[0].stateBits; + int stateBits1 = stages[1].stateBits; + shaderStage_t swapStage; + + swapStage = stages[0]; + stages[0] = stages[1]; + stages[1] = swapStage; + + stages[0].stateBits = stateBits0; + stages[1].stateBits = stateBits1; + } + } + } + + if (!skip) + { + // scan for shaders that aren't supported + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->adjustColorsForFog) + { + skip = qtrue; + break; + } + + if (pStage->bundle[0].isLightmap) + { + int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + + if (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) + && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) + { + skip = qtrue; + break; + } + } + + switch(pStage->bundle[0].tcGen) + { + case TCGEN_TEXTURE: + case TCGEN_LIGHTMAP: + case TCGEN_ENVIRONMENT_MAPPED: + break; + default: + skip = qtrue; + break; + } + + switch(pStage->alphaGen) + { + case AGEN_LIGHTING_SPECULAR: + case AGEN_PORTAL: + case AGEN_FRESNEL: + skip = qtrue; + break; + default: + break; + } + } + } + + if (!skip) + { + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + shaderStage_t *diffuse, *normal, *specular, *lightmap; + qboolean parallax, tcgen, diffuselit, vertexlit; + + if (!pStage->active) + continue; + + // skip normal and specular maps + if (pStage->type != ST_COLORMAP) + continue; + + // skip lightmaps + if (pStage->bundle[0].isLightmap) + continue; + + diffuse = pStage; + normal = NULL; + parallax = qfalse; + specular = NULL; + lightmap = NULL; + + // we have a diffuse map, find matching normal, specular, and lightmap + for (j = i + 1; j < MAX_SHADER_STAGES; j++) + { + shaderStage_t *pStage2 = &stages[j]; + + if (!pStage2->active) + continue; + + switch(pStage2->type) + { + case ST_NORMALMAP: + if (!normal) + { + normal = pStage2; + } + break; + + case ST_NORMALPARALLAXMAP: + if (!normal) + { + normal = pStage2; + parallax = qtrue; + } + break; + + case ST_SPECULARMAP: + if (!specular) + { + specular = pStage2; + } + break; + + case ST_COLORMAP: + if (pStage2->bundle[0].isLightmap) + { + lightmap = pStage2; + } + break; + + default: + break; + } + } + + tcgen = qfalse; + if (diffuse->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED + || diffuse->bundle[0].tcGen == TCGEN_LIGHTMAP + || diffuse->bundle[0].tcGen == TCGEN_VECTOR) + { + tcgen = qtrue; + } + + diffuselit = qfalse; + if (diffuse->rgbGen == CGEN_LIGHTING_DIFFUSE) + { + diffuselit = qtrue; + } + + vertexlit = qfalse; + if (diffuse->rgbGen == CGEN_VERTEX_LIT || diffuse->rgbGen == CGEN_EXACT_VERTEX_LIT) + { + vertexlit = qtrue; + } + + CollapseStagesToLightall(diffuse, normal, specular, lightmap, diffuselit, vertexlit, parallax, tcgen); + } + + // deactivate lightmap stages + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->bundle[0].isLightmap) + { + pStage->active = qfalse; + } + } + } + + // deactivate normal and specular stages + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->type == ST_NORMALMAP) + { + pStage->active = qfalse; + } + + if (pStage->type == ST_NORMALPARALLAXMAP) + { + pStage->active = qfalse; + } + + if (pStage->type == ST_SPECULARMAP) + { + pStage->active = qfalse; + } + } + + // remove inactive stages + numStages = 0; + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + if (!stages[i].active) + continue; + + if (i == numStages) + { + numStages++; + continue; + } + + stages[numStages] = stages[i]; + stages[i].active = qfalse; + numStages++; + } + + if (numStages == i && i >= 2 && CollapseMultitexture()) + numStages--; + + // convert any remaining lightmap stages to a lighting pass with a white texture + // only do this with r_sunlightMode non-zero, as it's only for correct shadows. + if (r_sunlightMode->integer) + { + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->bundle[TB_DIFFUSEMAP].isLightmap) + { + pStage->glslShaderGroup = tr.lightallShader; + pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + pStage->glslShaderIndex |= LIGHTDEF_USE_DELUXEMAP; + pStage->bundle[TB_LIGHTMAP] = pStage->bundle[TB_DIFFUSEMAP]; + pStage->bundle[TB_DIFFUSEMAP].image[0] = tr.whiteImage; + pStage->bundle[TB_DIFFUSEMAP].isLightmap = qfalse; + } + } + } + + return numStages; +} + +/* +============= + +FixRenderCommandList +https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493 +Arnout: this is a nasty issue. Shaders can be registered after drawsurfaces are generated +but before the frame is rendered. This will, for the duration of one frame, cause drawsurfaces +to be rendered with bad shaders. To fix this, need to go through all render commands and fix +sortedIndex. +============== +*/ +static void FixRenderCommandList( int newShader ) { + renderCommandList_t *cmdList = &backEndData->commands; + + if( cmdList ) { + const void *curCmd = cmdList->cmds; + + while ( 1 ) { + curCmd = PADP(curCmd, sizeof(void *)); + + switch ( *(const int *)curCmd ) { + case RC_SET_COLOR: + { + const setColorCommand_t *sc_cmd = (const setColorCommand_t *)curCmd; + curCmd = (const void *)(sc_cmd + 1); + break; + } + case RC_STRETCH_PIC: + { + const stretchPicCommand_t *sp_cmd = (const stretchPicCommand_t *)curCmd; + curCmd = (const void *)(sp_cmd + 1); + break; + } + case RC_DRAW_SURFS: + { + int i; + drawSurf_t *drawSurf; + shader_t *shader; + int fogNum; + int entityNum; + int dlightMap; + int pshadowMap; + int sortedIndex; + const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; + + for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &pshadowMap ); + sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); + if( sortedIndex >= newShader ) { + sortedIndex++; + drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + } + } + curCmd = (const void *)(ds_cmd + 1); + break; + } + case RC_DRAW_BUFFER: + { + const drawBufferCommand_t *db_cmd = (const drawBufferCommand_t *)curCmd; + curCmd = (const void *)(db_cmd + 1); + break; + } + case RC_SWAP_BUFFERS: + { + const swapBuffersCommand_t *sb_cmd = (const swapBuffersCommand_t *)curCmd; + curCmd = (const void *)(sb_cmd + 1); + break; + } + case RC_END_OF_LIST: + default: + return; + } + } + } +} + +/* +============== +SortNewShader + +Positions the most recently created shader in the tr.sortedShaders[] +array so that the shader->sort key is sorted reletive to the other +shaders. + +Sets shader->sortedIndex +============== +*/ +static void SortNewShader( void ) { + int i; + float sort; + shader_t *newShader; + + newShader = tr.shaders[ tr.numShaders - 1 ]; + sort = newShader->sort; + + for ( i = tr.numShaders - 2 ; i >= 0 ; i-- ) { + if ( tr.sortedShaders[ i ]->sort <= sort ) { + break; + } + tr.sortedShaders[i+1] = tr.sortedShaders[i]; + tr.sortedShaders[i+1]->sortedIndex++; + } + + // Arnout: fix rendercommandlist + // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=493 + FixRenderCommandList( i+1 ); + + newShader->sortedIndex = i+1; + tr.sortedShaders[i+1] = newShader; +} + + +/* +==================== +GeneratePermanentShader +==================== +*/ +static shader_t *GeneratePermanentShader( void ) { + shader_t *newShader; + int i, b; + int size, hash; + + if ( tr.numShaders == MAX_SHADERS ) { + ri.Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); + return tr.defaultShader; + } + + newShader = ri.Hunk_Alloc( sizeof( shader_t ), h_low ); + + *newShader = shader; + + if ( shader.sort <= SS_OPAQUE ) { + newShader->fogPass = FP_EQUAL; + } else if ( shader.contentFlags & CONTENTS_FOG ) { + newShader->fogPass = FP_LE; + } + + tr.shaders[ tr.numShaders ] = newShader; + newShader->index = tr.numShaders; + + tr.sortedShaders[ tr.numShaders ] = newShader; + newShader->sortedIndex = tr.numShaders; + + tr.numShaders++; + + for ( i = 0 ; i < newShader->numUnfoggedPasses ; i++ ) { + if ( !stages[i].active ) { + break; + } + newShader->stages[i] = ri.Hunk_Alloc( sizeof( stages[i] ), h_low ); + *newShader->stages[i] = stages[i]; + + for ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) { + size = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t ); + newShader->stages[i]->bundle[b].texMods = ri.Hunk_Alloc( size, h_low ); + Com_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size ); + } + } + + SortNewShader(); + + hash = generateHashValue(newShader->name, FILE_HASH_SIZE); + newShader->next = hashTable[hash]; + hashTable[hash] = newShader; + + return newShader; +} + +/* +================= +VertexLightingCollapse + +If vertex lighting is enabled, only render a single +pass, trying to guess which is the correct one to best aproximate +what it is supposed to look like. +================= +*/ +static void VertexLightingCollapse( void ) { + int stage; + shaderStage_t *bestStage; + int bestImageRank; + int rank; + + // if we aren't opaque, just use the first pass + if ( shader.sort == SS_OPAQUE ) { + + // pick the best texture for the single pass + bestStage = &stages[0]; + bestImageRank = -999999; + + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) { + shaderStage_t *pStage = &stages[stage]; + + if ( !pStage->active ) { + break; + } + rank = 0; + + if ( pStage->bundle[0].isLightmap ) { + rank -= 100; + } + if ( pStage->bundle[0].tcGen != TCGEN_TEXTURE ) { + rank -= 5; + } + if ( pStage->bundle[0].numTexMods ) { + rank -= 5; + } + if ( pStage->rgbGen != CGEN_IDENTITY && pStage->rgbGen != CGEN_IDENTITY_LIGHTING ) { + rank -= 3; + } + + if ( rank > bestImageRank ) { + bestImageRank = rank; + bestStage = pStage; + } + } + + stages[0].bundle[0] = bestStage->bundle[0]; + stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); + stages[0].stateBits |= GLS_DEPTHMASK_TRUE; + if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; + } else { + stages[0].rgbGen = CGEN_EXACT_VERTEX; + } + stages[0].alphaGen = AGEN_SKIP; + } else { + // don't use a lightmap (tesla coils) + if ( stages[0].bundle[0].isLightmap ) { + stages[0] = stages[1]; + } + + // if we were in a cross-fade cgen, hack it to normal + if ( stages[0].rgbGen == CGEN_ONE_MINUS_ENTITY || stages[1].rgbGen == CGEN_ONE_MINUS_ENTITY ) { + stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; + } + if ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_SAWTOOTH ) + && ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_INVERSE_SAWTOOTH ) ) { + stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; + } + if ( ( stages[0].rgbGen == CGEN_WAVEFORM && stages[0].rgbWave.func == GF_INVERSE_SAWTOOTH ) + && ( stages[1].rgbGen == CGEN_WAVEFORM && stages[1].rgbWave.func == GF_SAWTOOTH ) ) { + stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; + } + } + + for ( stage = 1; stage < MAX_SHADER_STAGES; stage++ ) { + shaderStage_t *pStage = &stages[stage]; + + if ( !pStage->active ) { + break; + } + + Com_Memset( pStage, 0, sizeof( *pStage ) ); + } +} + +/* +========================= +FinishShader + +Returns a freshly allocated shader with all the needed info +from the current global working shader +========================= +*/ +static shader_t *FinishShader( void ) { + int stage; + qboolean hasLightmapStage; + qboolean vertexLightmap; + + hasLightmapStage = qfalse; + vertexLightmap = qfalse; + + // + // set sky stuff appropriate + // + if ( shader.isSky ) { + shader.sort = SS_ENVIRONMENT; + } + + // + // set polygon offset + // + if ( shader.polygonOffset && !shader.sort ) { + shader.sort = SS_DECAL; + } + + // + // set appropriate stage information + // + for ( stage = 0; stage < MAX_SHADER_STAGES; ) { + shaderStage_t *pStage = &stages[stage]; + + if ( !pStage->active ) { + break; + } + + // check for a missing texture + if ( !pStage->bundle[0].image[0] ) { + ri.Printf( PRINT_WARNING, "Shader %s has a stage with no image\n", shader.name ); + pStage->active = qfalse; + stage++; + continue; + } + + // + // ditch this stage if it's detail and detail textures are disabled + // + if ( pStage->isDetail && !r_detailTextures->integer ) + { + int index; + + for(index = stage + 1; index < MAX_SHADER_STAGES; index++) + { + if(!stages[index].active) + break; + } + + if(index < MAX_SHADER_STAGES) + memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage)); + else + { + if(stage + 1 < MAX_SHADER_STAGES) + memmove(pStage, pStage + 1, sizeof(*pStage) * (index - stage - 1)); + + Com_Memset(&stages[index - 1], 0, sizeof(*stages)); + } + + continue; + } + + // + // default texture coordinate generation + // + if ( pStage->bundle[0].isLightmap ) { + if ( pStage->bundle[0].tcGen == TCGEN_BAD ) { + pStage->bundle[0].tcGen = TCGEN_LIGHTMAP; + } + hasLightmapStage = qtrue; + } else { + if ( pStage->bundle[0].tcGen == TCGEN_BAD ) { + pStage->bundle[0].tcGen = TCGEN_TEXTURE; + } + } + + + // not a true lightmap but we want to leave existing + // behaviour in place and not print out a warning + //if (pStage->rgbGen == CGEN_VERTEX) { + // vertexLightmap = qtrue; + //} + + + + // + // determine sort order and fog color adjustment + // + if ( ( pStage->stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) && + ( stages[0].stateBits & ( GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS ) ) ) { + int blendSrcBits = pStage->stateBits & GLS_SRCBLEND_BITS; + int blendDstBits = pStage->stateBits & GLS_DSTBLEND_BITS; + + // fog color adjustment only works for blend modes that have a contribution + // that aproaches 0 as the modulate values aproach 0 -- + // GL_ONE, GL_ONE + // GL_ZERO, GL_ONE_MINUS_SRC_COLOR + // GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA + + // modulate, additive + if ( ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE ) ) || + ( ( blendSrcBits == GLS_SRCBLEND_ZERO ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR ) ) ) { + pStage->adjustColorsForFog = ACFF_MODULATE_RGB; + } + // strict blend + else if ( ( blendSrcBits == GLS_SRCBLEND_SRC_ALPHA ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) ) + { + pStage->adjustColorsForFog = ACFF_MODULATE_ALPHA; + } + // premultiplied alpha + else if ( ( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ) ) + { + pStage->adjustColorsForFog = ACFF_MODULATE_RGBA; + } else { + // we can't adjust this one correctly, so it won't be exactly correct in fog + } + + // don't screw with sort order if this is a portal or environment + if ( !shader.sort ) { + // see through item, like a grill or grate + if ( pStage->stateBits & GLS_DEPTHMASK_TRUE ) { + shader.sort = SS_SEE_THROUGH; + } else { + shader.sort = SS_BLEND0; + } + } + } + + stage++; + } + + // there are times when you will need to manually apply a sort to + // opaque alpha tested shaders that have later blend passes + if ( !shader.sort ) { + shader.sort = SS_OPAQUE; + } + + // + // if we are in r_vertexLight mode, never use a lightmap texture + // + if ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) { + VertexLightingCollapse(); + hasLightmapStage = qfalse; + } + + // + // look for multitexture potential + // + stage = CollapseStagesToGLSL(); + + if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) { + if (vertexLightmap) { + ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name ); + } else { + ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); + // Don't set this, it will just add duplicate shaders to the hash + //shader.lightmapIndex = LIGHTMAP_NONE; + } + } + + + // + // compute number of passes + // + shader.numUnfoggedPasses = stage; + + // fogonly shaders don't have any normal passes + if (stage == 0 && !shader.isSky) + shader.sort = SS_FOG; + + // determine which stage iterator function is appropriate + ComputeStageIteratorFunc(); + + // determine which vertex attributes this shader needs + ComputeVertexAttribs(); + + return GeneratePermanentShader(); +} + +//======================================================================================== + +/* +==================== +FindShaderInShaderText + +Scans the combined text description of all the shader files for +the given shader name. + +return NULL if not found + +If found, it will return a valid shader +===================== +*/ +static char *FindShaderInShaderText( const char *shadername ) { + + char *token, *p; + + int i, hash; + + hash = generateHashValue(shadername, MAX_SHADERTEXT_HASH); + + if(shaderTextHashTable[hash]) + { + for (i = 0; shaderTextHashTable[hash][i]; i++) + { + p = shaderTextHashTable[hash][i]; + token = COM_ParseExt(&p, qtrue); + + if(!Q_stricmp(token, shadername)) + return p; + } + } + + p = s_shaderText; + + if ( !p ) { + return NULL; + } + + // look for label + while ( 1 ) { + token = COM_ParseExt( &p, qtrue ); + if ( token[0] == 0 ) { + break; + } + + if ( !Q_stricmp( token, shadername ) ) { + return p; + } + else { + // skip the definition + SkipBracedSection( &p, 0 ); + } + } + + return NULL; +} + + +/* +================== +R_FindShaderByName + +Will always return a valid shader, but it might be the +default shader if the real one can't be found. +================== +*/ +shader_t *R_FindShaderByName( const char *name ) { + char strippedName[MAX_QPATH]; + int hash; + shader_t *sh; + + if ( (name==NULL) || (name[0] == 0) ) { + return tr.defaultShader; + } + + COM_StripExtension(name, strippedName, sizeof(strippedName)); + + hash = generateHashValue(strippedName, FILE_HASH_SIZE); + + // + // see if the shader is already loaded + // + for (sh=hashTable[hash]; sh; sh=sh->next) { + // NOTE: if there was no shader or image available with the name strippedName + // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we + // have to check all default shaders otherwise for every call to R_FindShader + // with that same strippedName a new default shader is created. + if (Q_stricmp(sh->name, strippedName) == 0) { + // match found + return sh; + } + } + + return tr.defaultShader; +} + + +/* +=============== +R_FindShader + +Will always return a valid shader, but it might be the +default shader if the real one can't be found. + +In the interest of not requiring an explicit shader text entry to +be defined for every single image used in the game, three default +shader behaviors can be auto-created for any image: + +If lightmapIndex == LIGHTMAP_NONE, then the image will have +dynamic diffuse lighting applied to it, as apropriate for most +entity skin surfaces. + +If lightmapIndex == LIGHTMAP_2D, then the image will be used +for 2D rendering unless an explicit shader is found + +If lightmapIndex == LIGHTMAP_BY_VERTEX, then the image will use +the vertex rgba modulate values, as apropriate for misc_model +pre-lit surfaces. + +Other lightmapIndex values will have a lightmap stage created +and src*dest blending applied with the texture, as apropriate for +most world construction surfaces. + +=============== +*/ +shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { + char strippedName[MAX_QPATH]; + int i, hash; + char *shaderText; + image_t *image; + shader_t *sh; + + if ( name[0] == 0 ) { + return tr.defaultShader; + } + + // use (fullbright) vertex lighting if the bsp file doesn't have + // lightmaps + if ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) { + lightmapIndex = LIGHTMAP_BY_VERTEX; + } else if ( lightmapIndex < LIGHTMAP_2D ) { + // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex]) + ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex ); + lightmapIndex = LIGHTMAP_BY_VERTEX; + } + + COM_StripExtension(name, strippedName, sizeof(strippedName)); + + hash = generateHashValue(strippedName, FILE_HASH_SIZE); + + // + // see if the shader is already loaded + // + for (sh = hashTable[hash]; sh; sh = sh->next) { + // NOTE: if there was no shader or image available with the name strippedName + // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we + // have to check all default shaders otherwise for every call to R_FindShader + // with that same strippedName a new default shader is created. + if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && + !Q_stricmp(sh->name, strippedName)) { + // match found + return sh; + } + } + + // clear the global shader + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); + shader.lightmapIndex = lightmapIndex; + for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { + stages[i].bundle[0].texMods = texMods[i]; + } + + // + // attempt to define shader from an explicit parameter file + // + shaderText = FindShaderInShaderText( strippedName ); + if ( shaderText ) { + // enable this when building a pak file to get a global list + // of all explicit shaders + if ( r_printShaders->integer ) { + ri.Printf( PRINT_ALL, "*SHADER* %s\n", name ); + } + + if ( !ParseShader( &shaderText ) ) { + // had errors, so use default shader + shader.defaultShader = qtrue; + } + sh = FinishShader(); + return sh; + } + + + // + // if not defined in the in-memory shader descriptions, + // look for a single supported image file + // + { + imgFlags_t flags; + + flags = IMGFLAG_NONE; + + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; + + if (mipRawImage) + { + flags |= IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; + } + else + { + flags |= IMGFLAG_CLAMPTOEDGE; + } + + image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); + if ( !image ) { + ri.Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); + shader.defaultShader = qtrue; + return FinishShader(); + } + } + + // + // create the default shading commands + // + if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + // dynamic colors at vertexes + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; + stages[0].stateBits = GLS_DEFAULT; + } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { + // explicit colors at vertexes + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_EXACT_VERTEX; + stages[0].alphaGen = AGEN_SKIP; + stages[0].stateBits = GLS_DEFAULT; + } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { + // GUI elements + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_VERTEX; + stages[0].alphaGen = AGEN_VERTEX; + stages[0].stateBits = GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { + // fullbright level + stages[0].bundle[0].image[0] = tr.whiteImage; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; + stages[0].stateBits = GLS_DEFAULT; + + stages[1].bundle[0].image[0] = image; + stages[1].active = qtrue; + stages[1].rgbGen = CGEN_IDENTITY; + stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + } else { + // two pass lightmap + stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + stages[0].bundle[0].isLightmap = qtrue; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation + // for identitylight + stages[0].stateBits = GLS_DEFAULT; + + stages[1].bundle[0].image[0] = image; + stages[1].active = qtrue; + stages[1].rgbGen = CGEN_IDENTITY; + stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + } + + return FinishShader(); +} + + +qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) { + int i, hash; + shader_t *sh; + + hash = generateHashValue(name, FILE_HASH_SIZE); + + // probably not necessary since this function + // only gets called from tr_font.c with lightmapIndex == LIGHTMAP_2D + // but better safe than sorry. + if ( lightmapIndex >= tr.numLightmaps ) { + lightmapIndex = LIGHTMAP_WHITEIMAGE; + } + + // + // see if the shader is already loaded + // + for (sh=hashTable[hash]; sh; sh=sh->next) { + // NOTE: if there was no shader or image available with the name strippedName + // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we + // have to check all default shaders otherwise for every call to R_FindShader + // with that same strippedName a new default shader is created. + if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && + // index by name + !Q_stricmp(sh->name, name)) { + // match found + return sh->index; + } + } + + // clear the global shader + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + Q_strncpyz(shader.name, name, sizeof(shader.name)); + shader.lightmapIndex = lightmapIndex; + for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { + stages[i].bundle[0].texMods = texMods[i]; + } + + // + // create the default shading commands + // + if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + // dynamic colors at vertexes + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; + stages[0].stateBits = GLS_DEFAULT; + } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { + // explicit colors at vertexes + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_EXACT_VERTEX; + stages[0].alphaGen = AGEN_SKIP; + stages[0].stateBits = GLS_DEFAULT; + } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { + // GUI elements + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_VERTEX; + stages[0].alphaGen = AGEN_VERTEX; + stages[0].stateBits = GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { + // fullbright level + stages[0].bundle[0].image[0] = tr.whiteImage; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_IDENTITY_LIGHTING; + stages[0].stateBits = GLS_DEFAULT; + + stages[1].bundle[0].image[0] = image; + stages[1].active = qtrue; + stages[1].rgbGen = CGEN_IDENTITY; + stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + } else { + // two pass lightmap + stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + stages[0].bundle[0].isLightmap = qtrue; + stages[0].active = qtrue; + stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation + // for identitylight + stages[0].stateBits = GLS_DEFAULT; + + stages[1].bundle[0].image[0] = image; + stages[1].active = qtrue; + stages[1].rgbGen = CGEN_IDENTITY; + stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + } + + sh = FinishShader(); + return sh->index; +} + + +/* +==================== +RE_RegisterShader + +This is the exported shader entry point for the rest of the system +It will always return an index that will be valid. + +This should really only be used for explicit shaders, because there is no +way to ask for different implicit lighting modes (vertex, lightmap, etc) +==================== +*/ +qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { + shader_t *sh; + + if ( strlen( name ) >= MAX_QPATH ) { + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + return 0; + } + + sh = R_FindShader( name, lightmapIndex, qtrue ); + + // we want to return 0 if the shader failed to + // load for some reason, but R_FindShader should + // still keep a name allocated for it, so if + // something calls RE_RegisterShader again with + // the same name, we don't try looking for it again + if ( sh->defaultShader ) { + return 0; + } + + return sh->index; +} + + +/* +==================== +RE_RegisterShader + +This is the exported shader entry point for the rest of the system +It will always return an index that will be valid. + +This should really only be used for explicit shaders, because there is no +way to ask for different implicit lighting modes (vertex, lightmap, etc) +==================== +*/ +qhandle_t RE_RegisterShader( const char *name ) { + shader_t *sh; + + if ( strlen( name ) >= MAX_QPATH ) { + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + return 0; + } + + sh = R_FindShader( name, LIGHTMAP_2D, qtrue ); + + // we want to return 0 if the shader failed to + // load for some reason, but R_FindShader should + // still keep a name allocated for it, so if + // something calls RE_RegisterShader again with + // the same name, we don't try looking for it again + if ( sh->defaultShader ) { + return 0; + } + + return sh->index; +} + + +/* +==================== +RE_RegisterShaderNoMip + +For menu graphics that should never be picmiped +==================== +*/ +qhandle_t RE_RegisterShaderNoMip( const char *name ) { + shader_t *sh; + + if ( strlen( name ) >= MAX_QPATH ) { + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + return 0; + } + + sh = R_FindShader( name, LIGHTMAP_2D, qfalse ); + + // we want to return 0 if the shader failed to + // load for some reason, but R_FindShader should + // still keep a name allocated for it, so if + // something calls RE_RegisterShader again with + // the same name, we don't try looking for it again + if ( sh->defaultShader ) { + return 0; + } + + return sh->index; +} + +/* +==================== +R_GetShaderByHandle + +When a handle is passed in by another module, this range checks +it and returns a valid (possibly default) shader_t to be used internally. +==================== +*/ +shader_t *R_GetShaderByHandle( qhandle_t hShader ) { + if ( hShader < 0 ) { + ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + return tr.defaultShader; + } + if ( hShader >= tr.numShaders ) { + ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + return tr.defaultShader; + } + return tr.shaders[hShader]; +} + +/* +=============== +R_ShaderList_f + +Dump information on all valid shaders to the console +A second parameter will cause it to print in sorted order +=============== +*/ +void R_ShaderList_f (void) { + int i; + int count; + shader_t *shader; + + ri.Printf (PRINT_ALL, "-----------------------\n"); + + count = 0; + for ( i = 0 ; i < tr.numShaders ; i++ ) { + if ( ri.Cmd_Argc() > 1 ) { + shader = tr.sortedShaders[i]; + } else { + shader = tr.shaders[i]; + } + + ri.Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); + + if (shader->lightmapIndex >= 0 ) { + ri.Printf (PRINT_ALL, "L "); + } else { + ri.Printf (PRINT_ALL, " "); + } + if ( shader->multitextureEnv == GL_ADD ) { + ri.Printf( PRINT_ALL, "MT(a) " ); + } else if ( shader->multitextureEnv == GL_MODULATE ) { + ri.Printf( PRINT_ALL, "MT(m) " ); + } else if ( shader->multitextureEnv == GL_DECAL ) { + ri.Printf( PRINT_ALL, "MT(d) " ); + } else { + ri.Printf( PRINT_ALL, " " ); + } + if ( shader->explicitlyDefined ) { + ri.Printf( PRINT_ALL, "E " ); + } else { + ri.Printf( PRINT_ALL, " " ); + } + + if ( shader->optimalStageIteratorFunc == RB_StageIteratorGeneric ) { + ri.Printf( PRINT_ALL, "gen " ); + } else if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) { + ri.Printf( PRINT_ALL, "sky " ); + } else { + ri.Printf( PRINT_ALL, " " ); + } + + if ( shader->defaultShader ) { + ri.Printf (PRINT_ALL, ": %s (DEFAULTED)\n", shader->name); + } else { + ri.Printf (PRINT_ALL, ": %s\n", shader->name); + } + count++; + } + ri.Printf (PRINT_ALL, "%i total shaders\n", count); + ri.Printf (PRINT_ALL, "------------------\n"); +} + +/* +==================== +ScanAndLoadShaderFiles + +Finds and loads all .shader files, combining them into +a single large text block that can be scanned for shader names +===================== +*/ +#define MAX_SHADER_FILES 4096 +static void ScanAndLoadShaderFiles( void ) +{ + char **shaderFiles; + char *buffers[MAX_SHADER_FILES]; + char *p; + int numShaderFiles; + int i; + char *oldp, *token, *hashMem, *textEnd; + int shaderTextHashTableSizes[MAX_SHADERTEXT_HASH], hash, size; + char shaderName[MAX_QPATH]; + int shaderLine; + + long sum = 0, summand; + // scan for shader files + shaderFiles = ri.FS_ListFiles( "scripts", ".shader", &numShaderFiles ); + + if ( !shaderFiles || !numShaderFiles ) + { + ri.Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); + return; + } + + if ( numShaderFiles > MAX_SHADER_FILES ) { + numShaderFiles = MAX_SHADER_FILES; + } + + // load and parse shader files + for ( i = 0; i < numShaderFiles; i++ ) + { + char filename[MAX_QPATH]; + + // look for a .mtr file first + { + char *ext; + Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); + if ( (ext = strrchr(filename, '.')) ) + { + strcpy(ext, ".mtr"); + } + + if ( ri.FS_ReadFile( filename, NULL ) <= 0 ) + { + Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); + } + } + + ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); + summand = ri.FS_ReadFile( filename, (void **)&buffers[i] ); + + if ( !buffers[i] ) + ri.Error( ERR_DROP, "Couldn't load %s", filename ); + + // Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders. + p = buffers[i]; + COM_BeginParseSession(filename); + while(1) + { + token = COM_ParseExt(&p, qtrue); + + if(!*token) + break; + + Q_strncpyz(shaderName, token, sizeof(shaderName)); + shaderLine = COM_GetCurrentParseLine(); + + token = COM_ParseExt(&p, qtrue); + if(token[0] != '{' || token[1] != '\0') + { + ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace", + filename, shaderName, shaderLine); + if (token[0]) + { + ri.Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine()); + } + ri.Printf(PRINT_WARNING, ".\n"); + ri.FS_FreeFile(buffers[i]); + buffers[i] = NULL; + break; + } + + if(!SkipBracedSection(&p, 1)) + { + ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", + filename, shaderName, shaderLine); + ri.FS_FreeFile(buffers[i]); + buffers[i] = NULL; + break; + } + } + + + if (buffers[i]) + sum += summand; + } + + // build single large buffer + s_shaderText = ri.Hunk_Alloc( sum + numShaderFiles*2, h_low ); + s_shaderText[ 0 ] = '\0'; + textEnd = s_shaderText; + + // free in reverse order, so the temp files are all dumped + for ( i = numShaderFiles - 1; i >= 0 ; i-- ) + { + if ( !buffers[i] ) + continue; + + strcat( textEnd, buffers[i] ); + strcat( textEnd, "\n" ); + textEnd += strlen( textEnd ); + ri.FS_FreeFile( buffers[i] ); + } + + COM_Compress( s_shaderText ); + + // free up memory + ri.FS_FreeFileList( shaderFiles ); + + Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes)); + size = 0; + + p = s_shaderText; + // look for shader names + while ( 1 ) { + token = COM_ParseExt( &p, qtrue ); + if ( token[0] == 0 ) { + break; + } + + hash = generateHashValue(token, MAX_SHADERTEXT_HASH); + shaderTextHashTableSizes[hash]++; + size++; + SkipBracedSection(&p, 0); + } + + size += MAX_SHADERTEXT_HASH; + + hashMem = ri.Hunk_Alloc( size * sizeof(char *), h_low ); + + for (i = 0; i < MAX_SHADERTEXT_HASH; i++) { + shaderTextHashTable[i] = (char **) hashMem; + hashMem = ((char *) hashMem) + ((shaderTextHashTableSizes[i] + 1) * sizeof(char *)); + } + + Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes)); + + p = s_shaderText; + // look for shader names + while ( 1 ) { + oldp = p; + token = COM_ParseExt( &p, qtrue ); + if ( token[0] == 0 ) { + break; + } + + hash = generateHashValue(token, MAX_SHADERTEXT_HASH); + shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp; + + SkipBracedSection(&p, 0); + } + + return; + +} + + +/* +==================== +CreateInternalShaders +==================== +*/ +static void CreateInternalShaders( void ) { + tr.numShaders = 0; + + // init the default shader + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + + Q_strncpyz( shader.name, "", sizeof( shader.name ) ); + + shader.lightmapIndex = LIGHTMAP_NONE; + stages[0].bundle[0].image[0] = tr.defaultImage; + stages[0].active = qtrue; + stages[0].stateBits = GLS_DEFAULT; + tr.defaultShader = FinishShader(); + + // shadow shader is just a marker + Q_strncpyz( shader.name, "", sizeof( shader.name ) ); + shader.sort = SS_STENCIL_SHADOW; + tr.shadowShader = FinishShader(); +} + +static void CreateExternalShaders( void ) { + tr.projectionShadowShader = R_FindShader( "projectionShadow", LIGHTMAP_NONE, qtrue ); + tr.flareShader = R_FindShader( "flareShader", LIGHTMAP_NONE, qtrue ); + + // Hack to make fogging work correctly on flares. Fog colors are calculated + // in tr_flare.c already. + if(!tr.flareShader->defaultShader) + { + int index; + + for(index = 0; index < tr.flareShader->numUnfoggedPasses; index++) + { + tr.flareShader->stages[index]->adjustColorsForFog = ACFF_NONE; + tr.flareShader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; + } + } + + tr.sunShader = R_FindShader( "sun", LIGHTMAP_NONE, qtrue ); + + tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", LIGHTMAP_NONE, qtrue); + + // HACK: if sunflare is missing, make one using the flare image or dlight image + if (tr.sunFlareShader->defaultShader) + { + image_t *image; + + if (!tr.flareShader->defaultShader && tr.flareShader->stages[0] && tr.flareShader->stages[0]->bundle[0].image[0]) + image = tr.flareShader->stages[0]->bundle[0].image[0]; + else + image = tr.dlightImage; + + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + + Q_strncpyz( shader.name, "gfx/2d/sunflare", sizeof( shader.name ) ); + + shader.lightmapIndex = LIGHTMAP_NONE; + stages[0].bundle[0].image[0] = image; + stages[0].active = qtrue; + stages[0].stateBits = GLS_DEFAULT; + tr.sunFlareShader = FinishShader(); + } + +} + +/* +================== +R_InitShaders +================== +*/ +void R_InitShaders( void ) { + ri.Printf( PRINT_ALL, "Initializing Shaders\n" ); + + Com_Memset(hashTable, 0, sizeof(hashTable)); + + CreateInternalShaders(); + + ScanAndLoadShaderFiles(); + + CreateExternalShaders(); +} diff --git a/codemp/rd-rend2/tr_shadows.c b/codemp/rd-rend2/tr_shadows.c new file mode 100644 index 0000000000..f412b00d3e --- /dev/null +++ b/codemp/rd-rend2/tr_shadows.c @@ -0,0 +1,343 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "tr_local.h" + + +/* + + for a projection shadow: + + point[x] += light vector * ( z - shadow plane ) + point[y] += + point[z] = shadow plane + + 1 0 light[x] / light[z] + +*/ + +typedef struct { + int i2; + int facing; +} edgeDef_t; + +#define MAX_EDGE_DEFS 32 + +static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS]; +static int numEdgeDefs[SHADER_MAX_VERTEXES]; +static int facing[SHADER_MAX_INDEXES/3]; + +void R_AddEdgeDef( int i1, int i2, int facing ) { + int c; + + c = numEdgeDefs[ i1 ]; + if ( c == MAX_EDGE_DEFS ) { + return; // overflow + } + edgeDefs[ i1 ][ c ].i2 = i2; + edgeDefs[ i1 ][ c ].facing = facing; + + numEdgeDefs[ i1 ]++; +} + +void R_RenderShadowEdges( void ) { + int i; + +#if 0 + int numTris; + + // dumb way -- render every triangle's edges + numTris = tess.numIndexes / 3; + + for ( i = 0 ; i < numTris ; i++ ) { + int i1, i2, i3; + + if ( !facing[i] ) { + continue; + } + + i1 = tess.indexes[ i*3 + 0 ]; + i2 = tess.indexes[ i*3 + 1 ]; + i3 = tess.indexes[ i*3 + 2 ]; + + qglBegin( GL_TRIANGLE_STRIP ); + qglVertex3fv( tess.xyz[ i1 ] ); + qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); + qglVertex3fv( tess.xyz[ i2 ] ); + qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] ); + qglVertex3fv( tess.xyz[ i3 ] ); + qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] ); + qglVertex3fv( tess.xyz[ i1 ] ); + qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); + qglEnd(); + } +#else + int c, c2; + int j, k; + int i2; + int c_edges, c_rejected; + int hit[2]; + + // an edge is NOT a silhouette edge if its face doesn't face the light, + // or if it has a reverse paired edge that also faces the light. + // A well behaved polyhedron would have exactly two faces for each edge, + // but lots of models have dangling edges or overfanned edges + c_edges = 0; + c_rejected = 0; + + for ( i = 0 ; i < tess.numVertexes ; i++ ) { + c = numEdgeDefs[ i ]; + for ( j = 0 ; j < c ; j++ ) { + if ( !edgeDefs[ i ][ j ].facing ) { + continue; + } + + hit[0] = 0; + hit[1] = 0; + + i2 = edgeDefs[ i ][ j ].i2; + c2 = numEdgeDefs[ i2 ]; + for ( k = 0 ; k < c2 ; k++ ) { + if ( edgeDefs[ i2 ][ k ].i2 == i ) { + hit[ edgeDefs[ i2 ][ k ].facing ]++; + } + } + + // if it doesn't share the edge with another front facing + // triangle, it is a sil edge + if ( hit[ 1 ] == 0 ) { + qglBegin( GL_TRIANGLE_STRIP ); + qglVertex3fv( tess.xyz[ i ] ); + qglVertex3fv( tess.xyz[ i + tess.numVertexes ] ); + qglVertex3fv( tess.xyz[ i2 ] ); + qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] ); + qglEnd(); + c_edges++; + } else { + c_rejected++; + } + } + } +#endif +} + +/* +================= +RB_ShadowTessEnd + +triangleFromEdge[ v1 ][ v2 ] + + + set triangle from edge( v1, v2, tri ) + if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) { + } +================= +*/ +void RB_ShadowTessEnd( void ) { + int i; + int numTris; + vec3_t lightDir; + GLboolean rgba[4]; + + // we can only do this if we have enough space in the vertex buffers + if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) { + return; + } + + if ( glConfig.stencilBits < 4 ) { + return; + } + + VectorCopy( backEnd.currentEntity->lightDir, lightDir ); + + // project vertexes away from light direction + for ( i = 0 ; i < tess.numVertexes ; i++ ) { + VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] ); + } + + // decide which triangles face the light + Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes ); + + numTris = tess.numIndexes / 3; + for ( i = 0 ; i < numTris ; i++ ) { + int i1, i2, i3; + vec3_t d1, d2, normal; + float *v1, *v2, *v3; + float d; + + i1 = tess.indexes[ i*3 + 0 ]; + i2 = tess.indexes[ i*3 + 1 ]; + i3 = tess.indexes[ i*3 + 2 ]; + + v1 = tess.xyz[ i1 ]; + v2 = tess.xyz[ i2 ]; + v3 = tess.xyz[ i3 ]; + + VectorSubtract( v2, v1, d1 ); + VectorSubtract( v3, v1, d2 ); + CrossProduct( d1, d2, normal ); + + d = DotProduct( normal, lightDir ); + if ( d > 0 ) { + facing[ i ] = 1; + } else { + facing[ i ] = 0; + } + + // create the edges + R_AddEdgeDef( i1, i2, facing[ i ] ); + R_AddEdgeDef( i2, i3, facing[ i ] ); + R_AddEdgeDef( i3, i1, facing[ i ] ); + } + + // draw the silhouette edges + + GL_Bind( tr.whiteImage ); + qglEnable( GL_CULL_FACE ); + GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + qglColor3f( 0.2f, 0.2f, 0.2f ); + + // don't write to the color buffer + qglGetBooleanv(GL_COLOR_WRITEMASK, rgba); + qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + + qglEnable( GL_STENCIL_TEST ); + qglStencilFunc( GL_ALWAYS, 1, 255 ); + + // mirrors have the culling order reversed + if ( backEnd.viewParms.isMirror ) { + qglCullFace( GL_FRONT ); + qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); + + R_RenderShadowEdges(); + + qglCullFace( GL_BACK ); + qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); + + R_RenderShadowEdges(); + } else { + qglCullFace( GL_BACK ); + qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); + + R_RenderShadowEdges(); + + qglCullFace( GL_FRONT ); + qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); + + R_RenderShadowEdges(); + } + + + // reenable writing to the color buffer + qglColorMask(rgba[0], rgba[1], rgba[2], rgba[3]); +} + + +/* +================= +RB_ShadowFinish + +Darken everything that is is a shadow volume. +We have to delay this until everything has been shadowed, +because otherwise shadows from different body parts would +overlap and double darken. +================= +*/ +void RB_ShadowFinish( void ) { + if ( r_shadows->integer != 2 ) { + return; + } + if ( glConfig.stencilBits < 4 ) { + return; + } + qglEnable( GL_STENCIL_TEST ); + qglStencilFunc( GL_NOTEQUAL, 0, 255 ); + + qglDisable (GL_CLIP_PLANE0); + qglDisable (GL_CULL_FACE); + + GL_Bind( tr.whiteImage ); + + qglLoadIdentity (); + + qglColor3f( 0.6f, 0.6f, 0.6f ); + GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); + +// qglColor3f( 1, 0, 0 ); +// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + + qglBegin( GL_QUADS ); + qglVertex3f( -100, 100, -10 ); + qglVertex3f( 100, 100, -10 ); + qglVertex3f( 100, -100, -10 ); + qglVertex3f( -100, -100, -10 ); + qglEnd (); + + qglColor4f(1,1,1,1); + qglDisable( GL_STENCIL_TEST ); +} + + +/* +================= +RB_ProjectionShadowDeform + +================= +*/ +void RB_ProjectionShadowDeform( void ) { + float *xyz; + int i; + float h; + vec3_t ground; + vec3_t light; + float groundDist; + float d; + vec3_t lightDir; + + xyz = ( float * ) tess.xyz; + + ground[0] = backEnd.or.axis[0][2]; + ground[1] = backEnd.or.axis[1][2]; + ground[2] = backEnd.or.axis[2][2]; + + groundDist = backEnd.or.origin[2] - backEnd.currentEntity->e.shadowPlane; + + VectorCopy( backEnd.currentEntity->lightDir, lightDir ); + d = DotProduct( lightDir, ground ); + // don't let the shadows get too long or go negative + if ( d < 0.5 ) { + VectorMA( lightDir, (0.5 - d), ground, lightDir ); + d = DotProduct( lightDir, ground ); + } + d = 1.0 / d; + + light[0] = lightDir[0] * d; + light[1] = lightDir[1] * d; + light[2] = lightDir[2] * d; + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4 ) { + h = DotProduct( xyz, ground ) + groundDist; + + xyz[0] -= light[0] * h; + xyz[1] -= light[1] * h; + xyz[2] -= light[2] * h; + } +} diff --git a/codemp/rd-rend2/tr_sky.c b/codemp/rd-rend2/tr_sky.c new file mode 100644 index 0000000000..f1e5249dd2 --- /dev/null +++ b/codemp/rd-rend2/tr_sky.c @@ -0,0 +1,912 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_sky.c +#include "tr_local.h" + +#define SKY_SUBDIVISIONS 8 +#define HALF_SKY_SUBDIVISIONS (SKY_SUBDIVISIONS/2) + +static float s_cloudTexCoords[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; +static float s_cloudTexP[6][SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; + +/* +=================================================================================== + +POLYGON TO BOX SIDE PROJECTION + +=================================================================================== +*/ + +static vec3_t sky_clip[6] = +{ + {1,1,0}, + {1,-1,0}, + {0,-1,1}, + {0,1,1}, + {1,0,1}, + {-1,0,1} +}; + +static float sky_mins[2][6], sky_maxs[2][6]; +static float sky_min, sky_max; + +/* +================ +AddSkyPolygon +================ +*/ +static void AddSkyPolygon (int nump, vec3_t vecs) +{ + int i,j; + vec3_t v, av; + float s, t, dv; + int axis; + float *vp; + // s = [0]/[2], t = [1]/[2] + static int vec_to_st[6][3] = + { + {-2,3,1}, + {2,3,-1}, + + {1,3,2}, + {-1,3,-2}, + + {-2,-1,3}, + {-2,1,-3} + + // {-1,2,3}, + // {1,2,-3} + }; + + // decide which face it maps to + VectorCopy (vec3_origin, v); + for (i=0, vp=vecs ; i av[1] && av[0] > av[2]) + { + if (v[0] < 0) + axis = 1; + else + axis = 0; + } + else if (av[1] > av[2] && av[1] > av[0]) + { + if (v[1] < 0) + axis = 3; + else + axis = 2; + } + else + { + if (v[2] < 0) + axis = 5; + else + axis = 4; + } + + // project new texture coords + for (i=0 ; i 0) + dv = vecs[j - 1]; + else + dv = -vecs[-j - 1]; + if (dv < 0.001) + continue; // don't divide by zero + j = vec_to_st[axis][0]; + if (j < 0) + s = -vecs[-j -1] / dv; + else + s = vecs[j-1] / dv; + j = vec_to_st[axis][1]; + if (j < 0) + t = -vecs[-j -1] / dv; + else + t = vecs[j-1] / dv; + + if (s < sky_mins[0][axis]) + sky_mins[0][axis] = s; + if (t < sky_mins[1][axis]) + sky_mins[1][axis] = t; + if (s > sky_maxs[0][axis]) + sky_maxs[0][axis] = s; + if (t > sky_maxs[1][axis]) + sky_maxs[1][axis] = t; + } +} + +#define ON_EPSILON 0.1f // point on plane side epsilon +#define MAX_CLIP_VERTS 64 +/* +================ +ClipSkyPolygon +================ +*/ +static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) +{ + float *norm; + float *v; + qboolean front, back; + float d, e; + float dists[MAX_CLIP_VERTS]; + int sides[MAX_CLIP_VERTS]; + vec3_t newv[2][MAX_CLIP_VERTS]; + int newc[2]; + int i, j; + + if (nump > MAX_CLIP_VERTS-2) + ri.Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + if (stage == 6) + { // fully clipped, so draw it + AddSkyPolygon (nump, vecs); + return; + } + + front = back = qfalse; + norm = sky_clip[stage]; + for (i=0, v = vecs ; i ON_EPSILON) + { + front = qtrue; + sides[i] = SIDE_FRONT; + } + else if (d < -ON_EPSILON) + { + back = qtrue; + sides[i] = SIDE_BACK; + } + else + sides[i] = SIDE_ON; + dists[i] = d; + } + + if (!front || !back) + { // not clipped + ClipSkyPolygon (nump, vecs, stage+1); + return; + } + + // clip it + sides[i] = sides[0]; + dists[i] = dists[0]; + VectorCopy (vecs, (vecs+(i*3)) ); + newc[0] = newc[1] = 0; + + for (i=0, v = vecs ; inumIndexes; i += 3 ) + { + for (j = 0 ; j < 3 ; j++) + { + VectorSubtract( input->xyz[input->indexes[i+j]], + backEnd.viewParms.or.origin, + p[j] ); + } + ClipSkyPolygon( 3, p[0], 0 ); + } +} + +/* +=================================================================================== + +CLOUD VERTEX GENERATION + +=================================================================================== +*/ + +/* +** MakeSkyVec +** +** Parms: s, t range from -1 to 1 +*/ +static void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXYZ ) +{ + // 1 = s, 2 = t, 3 = 2048 + static int st_to_vec[6][3] = + { + {3,-1,2}, + {-3,1,2}, + + {1,3,2}, + {-1,-3,2}, + + {-2,-1,3}, // 0 degrees yaw, look straight up + {2,-1,-3} // look straight down + }; + + vec3_t b; + int j, k; + float boxSize; + + boxSize = backEnd.viewParms.zFar / 1.75; // div sqrt(3) + b[0] = s*boxSize; + b[1] = t*boxSize; + b[2] = boxSize; + + for (j=0 ; j<3 ; j++) + { + k = st_to_vec[axis][j]; + if (k < 0) + { + outXYZ[j] = -b[-k - 1]; + } + else + { + outXYZ[j] = b[k - 1]; + } + } + + // avoid bilerp seam + s = (s+1)*0.5; + t = (t+1)*0.5; + if (s < sky_min) + { + s = sky_min; + } + else if (s > sky_max) + { + s = sky_max; + } + + if (t < sky_min) + { + t = sky_min; + } + else if (t > sky_max) + { + t = sky_max; + } + + t = 1.0 - t; + + + if ( outSt ) + { + outSt[0] = s; + outSt[1] = t; + } +} + +static int sky_texorder[6] = {0,2,1,3,4,5}; +static vec3_t s_skyPoints[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; +static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; + +static void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] ) +{ + int s, t; + int firstVertex = tess.numVertexes; + //int firstIndex = tess.numIndexes; + int minIndex = tess.minIndex; + int maxIndex = tess.maxIndex; + vec4_t color; + + //tess.numVertexes = 0; + //tess.numIndexes = 0; + tess.firstIndex = tess.numIndexes; + + GL_Bind( image ); + GL_Cull( CT_TWO_SIDED ); + + for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) + { + for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) + { + tess.xyz[tess.numVertexes][0] = s_skyPoints[t][s][0]; + tess.xyz[tess.numVertexes][1] = s_skyPoints[t][s][1]; + tess.xyz[tess.numVertexes][2] = s_skyPoints[t][s][2]; + tess.xyz[tess.numVertexes][3] = 1.0; + + tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; + tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; + + tess.numVertexes++; + + if(tess.numVertexes >= SHADER_MAX_VERTEXES) + { + ri.Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); + } + } + } + + for ( t = 0; t < maxs[1] - mins[1]; t++ ) + { + for ( s = 0; s < maxs[0] - mins[0]; s++ ) + { + if (tess.numIndexes + 6 >= SHADER_MAX_INDEXES) + { + ri.Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); + } + + tess.indexes[tess.numIndexes++] = s + t * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; + + tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = (s + 1) + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; + } + } + + tess.minIndex = firstVertex; + tess.maxIndex = tess.numVertexes; + + // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function + RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD); +/* + { + shaderProgram_t *sp = &tr.textureColorShader; + + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + color[0] = + color[1] = + color[2] = tr.identityLight; + color[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + } +*/ + { + shaderProgram_t *sp = &tr.lightallShader[0]; + vec4_t vector; + + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + color[0] = + color[1] = + color[2] = tr.identityLight; + color[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); + + color[0] = + color[1] = + color[2] = + color[3] = 0.0f; + GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, color); + + VectorSet4(vector, 1.0, 0.0, 0.0, 1.0); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); + + VectorSet4(vector, 0.0, 0.0, 0.0, 0.0); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); + } + + R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex, tess.minIndex, tess.maxIndex); + + //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(GL_INDEX_TYPE))); + + //R_BindNullVBO(); + //R_BindNullIBO(); + + tess.numIndexes = tess.firstIndex; + tess.numVertexes = firstVertex; + tess.firstIndex = 0; + tess.minIndex = minIndex; + tess.maxIndex = maxIndex; +} + +static void DrawSkyBox( shader_t *shader ) +{ + int i; + + sky_min = 0; + sky_max = 1; + + Com_Memset( s_skyTexCoords, 0, sizeof( s_skyTexCoords ) ); + + for (i=0 ; i<6 ; i++) + { + int sky_mins_subd[2], sky_maxs_subd[2]; + int s, t; + + sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + + if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || + ( sky_mins[1][i] >= sky_maxs[1][i] ) ) + { + continue; + } + + sky_mins_subd[0] = sky_mins[0][i] * HALF_SKY_SUBDIVISIONS; + sky_mins_subd[1] = sky_mins[1][i] * HALF_SKY_SUBDIVISIONS; + sky_maxs_subd[0] = sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS; + sky_maxs_subd[1] = sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS; + + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; + if ( sky_mins_subd[1] < -HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[1] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; + + if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; + if ( sky_maxs_subd[1] < -HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[1] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; + + // + // iterate through the subdivisions + // + for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) + { + for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) + { + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, + s_skyTexCoords[t][s], + s_skyPoints[t][s] ); + } + } + + DrawSkySide( shader->sky.outerbox[sky_texorder[i]], + sky_mins_subd, + sky_maxs_subd ); + } + +} + +static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean addIndexes ) +{ + int s, t; + int vertexStart = tess.numVertexes; + int tHeight, sWidth; + + tHeight = maxs[1] - mins[1] + 1; + sWidth = maxs[0] - mins[0] + 1; + + for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) + { + for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) + { + VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; + tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; + + tess.numVertexes++; + + if ( tess.numVertexes >= SHADER_MAX_VERTEXES ) + { + ri.Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); + } + } + } + + // only add indexes for one pass, otherwise it would draw multiple times for each pass + if ( addIndexes ) { + for ( t = 0; t < tHeight-1; t++ ) + { + for ( s = 0; s < sWidth-1; s++ ) + { + tess.indexes[tess.numIndexes] = vertexStart + s + t * ( sWidth ); + tess.numIndexes++; + tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth ); + tess.numIndexes++; + tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth ); + tess.numIndexes++; + + tess.indexes[tess.numIndexes] = vertexStart + s + ( t + 1 ) * ( sWidth ); + tess.numIndexes++; + tess.indexes[tess.numIndexes] = vertexStart + s + 1 + ( t + 1 ) * ( sWidth ); + tess.numIndexes++; + tess.indexes[tess.numIndexes] = vertexStart + s + 1 + t * ( sWidth ); + tess.numIndexes++; + } + } + } +} + +static void FillCloudBox( const shader_t *shader, int stage ) +{ + int i; + + for ( i =0; i < 6; i++ ) + { + int sky_mins_subd[2], sky_maxs_subd[2]; + int s, t; + float MIN_T; + + if ( 1 ) // FIXME? shader->sky.fullClouds ) + { + MIN_T = -HALF_SKY_SUBDIVISIONS; + + // still don't want to draw the bottom, even if fullClouds + if ( i == 5 ) + continue; + } + else + { + switch( i ) + { + case 0: + case 1: + case 2: + case 3: + MIN_T = -1; + break; + case 5: + // don't draw clouds beneath you + continue; + case 4: // top + default: + MIN_T = -HALF_SKY_SUBDIVISIONS; + break; + } + } + + sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_maxs[0][i] = ceil( sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + sky_maxs[1][i] = ceil( sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; + + if ( ( sky_mins[0][i] >= sky_maxs[0][i] ) || + ( sky_mins[1][i] >= sky_maxs[1][i] ) ) + { + continue; + } + + sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); + + if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_mins_subd[0] > HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[0] = HALF_SKY_SUBDIVISIONS; + if ( sky_mins_subd[1] < MIN_T ) + sky_mins_subd[1] = MIN_T; + else if ( sky_mins_subd[1] > HALF_SKY_SUBDIVISIONS ) + sky_mins_subd[1] = HALF_SKY_SUBDIVISIONS; + + if ( sky_maxs_subd[0] < -HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[0] = -HALF_SKY_SUBDIVISIONS; + else if ( sky_maxs_subd[0] > HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[0] = HALF_SKY_SUBDIVISIONS; + if ( sky_maxs_subd[1] < MIN_T ) + sky_maxs_subd[1] = MIN_T; + else if ( sky_maxs_subd[1] > HALF_SKY_SUBDIVISIONS ) + sky_maxs_subd[1] = HALF_SKY_SUBDIVISIONS; + + // + // iterate through the subdivisions + // + for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) + { + for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) + { + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, + NULL, + s_skyPoints[t][s] ); + + s_skyTexCoords[t][s][0] = s_cloudTexCoords[i][t][s][0]; + s_skyTexCoords[t][s][1] = s_cloudTexCoords[i][t][s][1]; + } + } + + // only add indexes for first stage + FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) ); + } +} + +/* +** R_BuildCloudData +*/ +void R_BuildCloudData( shaderCommands_t *input ) +{ + int i; + shader_t *shader; + + shader = input->shader; + + assert( shader->isSky ); + + sky_min = 1.0 / 256.0f; // FIXME: not correct? + sky_max = 255.0 / 256.0f; + + // set up for drawing + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + + if ( shader->sky.cloudHeight ) + { + for ( i = 0; i < MAX_SHADER_STAGES; i++ ) + { + if ( !tess.xstages[i] ) { + break; + } + FillCloudBox( shader, i ); + } + } +} + +/* +** R_InitSkyTexCoords +** Called when a sky shader is parsed +*/ +#define SQR( a ) ((a)*(a)) +void R_InitSkyTexCoords( float heightCloud ) +{ + int i, s, t; + float radiusWorld = 4096; + float p; + float sRad, tRad; + vec3_t skyVec; + vec3_t v; + + // init zfar so MakeSkyVec works even though + // a world hasn't been bounded + backEnd.viewParms.zFar = 1024; + + for ( i = 0; i < 6; i++ ) + { + for ( t = 0; t <= SKY_SUBDIVISIONS; t++ ) + { + for ( s = 0; s <= SKY_SUBDIVISIONS; s++ ) + { + // compute vector from view origin to sky side integral point + MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, + i, + NULL, + skyVec ); + + // compute parametric value 'p' that intersects with cloud layer + p = ( 1.0f / ( 2 * DotProduct( skyVec, skyVec ) ) ) * + ( -2 * skyVec[2] * radiusWorld + + 2 * sqrt( SQR( skyVec[2] ) * SQR( radiusWorld ) + + 2 * SQR( skyVec[0] ) * radiusWorld * heightCloud + + SQR( skyVec[0] ) * SQR( heightCloud ) + + 2 * SQR( skyVec[1] ) * radiusWorld * heightCloud + + SQR( skyVec[1] ) * SQR( heightCloud ) + + 2 * SQR( skyVec[2] ) * radiusWorld * heightCloud + + SQR( skyVec[2] ) * SQR( heightCloud ) ) ); + + s_cloudTexP[i][t][s] = p; + + // compute intersection point based on p + VectorScale( skyVec, p, v ); + v[2] += radiusWorld; + + // compute vector from world origin to intersection point 'v' + VectorNormalize( v ); + + sRad = Q_acos( v[0] ); + tRad = Q_acos( v[1] ); + + s_cloudTexCoords[i][t][s][0] = sRad; + s_cloudTexCoords[i][t][s][1] = tRad; + } + } + } +} + +//====================================================================================== + +/* +** RB_DrawSun +*/ +void RB_DrawSun( float scale, shader_t *shader ) { + float size; + float dist; + vec3_t origin, vec1, vec2; + + if ( !backEnd.skyRenderedThisView ) { + return; + } + + //qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); + //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); + { + // FIXME: this could be a lot cleaner + matrix_t translation, modelview; + + Matrix16Translation( backEnd.viewParms.or.origin, translation ); + Matrix16Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview ); + GL_SetModelviewMatrix( modelview ); + } + + dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) + size = dist * scale; + + VectorScale( tr.sunDirection, dist, origin ); + PerpendicularVector( vec1, tr.sunDirection ); + CrossProduct( tr.sunDirection, vec1, vec2 ); + + VectorScale( vec1, size, vec1 ); + VectorScale( vec2, size, vec2 ); + + // farthest depth range + qglDepthRange( 1.0, 1.0 ); + + RB_BeginSurface( shader, 0 ); + + RB_AddQuadStamp(origin, vec1, vec2, colorWhite); + + RB_EndSurface(); + + // back to normal depth range + qglDepthRange( 0.0, 1.0 ); +} + + + + +/* +================ +RB_StageIteratorSky + +All of the visible sky triangles are in tess + +Other things could be stuck in here, like birds in the sky, etc +================ +*/ +void RB_StageIteratorSky( void ) { + if ( r_fastsky->integer ) { + return; + } + + // go through all the polygons and project them onto + // the sky box to see which blocks on each side need + // to be drawn + RB_ClipSkyPolygons( &tess ); + + // r_showsky will let all the sky blocks be drawn in + // front of everything to allow developers to see how + // much sky is getting sucked in + if ( r_showsky->integer ) { + qglDepthRange( 0.0, 0.0 ); + } else { + qglDepthRange( 1.0, 1.0 ); + } + + // draw the outer skybox + if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) { + matrix_t oldmodelview; + + GL_State( 0 ); + //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); + + { + // FIXME: this could be a lot cleaner + matrix_t trans, product; + + Matrix16Copy( glState.modelview, oldmodelview ); + Matrix16Translation( backEnd.viewParms.or.origin, trans ); + Matrix16Multiply( glState.modelview, trans, product ); + GL_SetModelviewMatrix( product ); + + } + + DrawSkyBox( tess.shader ); + + GL_SetModelviewMatrix( oldmodelview ); + } + + // generate the vertexes for all the clouds, which will be drawn + // by the generic shader routine + R_BuildCloudData( &tess ); + + RB_StageIteratorGeneric(); + + // draw the inner skybox + + + // back to normal depth range + qglDepthRange( 0.0, 1.0 ); + + // note that sky was drawn so we will draw a sun later + backEnd.skyRenderedThisView = qtrue; +} + + + + + diff --git a/codemp/rd-rend2/tr_subs.c b/codemp/rd-rend2/tr_subs.c new file mode 100644 index 0000000000..6f4901287c --- /dev/null +++ b/codemp/rd-rend2/tr_subs.c @@ -0,0 +1,48 @@ +/* +=========================================================================== +Copyright (C) 2010 James Canete (use.less01@gmail.com) + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_subs.c - common function replacements for modular renderer + +#include "tr_local.h" + +void QDECL Com_Printf( const char *msg, ... ) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, msg); + Q_vsnprintf(text, sizeof(text), msg, argptr); + va_end(argptr); + + ri.Printf(PRINT_ALL, "%s", text); +} + +void QDECL Com_Error( int level, const char *error, ... ) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, error); + Q_vsnprintf(text, sizeof(text), error, argptr); + va_end(argptr); + + ri.Error(level, "%s", text); +} diff --git a/codemp/rd-rend2/tr_surface.c b/codemp/rd-rend2/tr_surface.c new file mode 100644 index 0000000000..427d153da6 --- /dev/null +++ b/codemp/rd-rend2/tr_surface.c @@ -0,0 +1,1657 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_surf.c +#include "tr_local.h" +#if idppc_altivec && !defined(MACOS_X) +#include +#endif + +/* + + THIS ENTIRE FILE IS BACK END + +backEnd.currentEntity will be valid. + +Tess_Begin has already been called for the surface's shader. + +The modelview matrix will be set. + +It is safe to actually issue drawing commands here if you don't want to +use the shader system. +*/ + + +//============================================================================ + + +/* +============== +RB_CheckOverflow +============== +*/ +void RB_CheckOverflow( int verts, int indexes ) { + if (tess.numVertexes + verts < SHADER_MAX_VERTEXES + && tess.numIndexes + indexes < SHADER_MAX_INDEXES) { + return; + } + + RB_EndSurface(); + + if ( verts >= SHADER_MAX_VERTEXES ) { + ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); + } + if ( indexes >= SHADER_MAX_INDEXES ) { + ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); + } + + RB_BeginSurface(tess.shader, tess.fogNum ); +} + +void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) +{ + if (!(vbo == glState.currentVBO && ibo == glState.currentIBO) || tess.multiDrawPrimitives >= MAX_MULTIDRAW_PRIMITIVES) + { + RB_EndSurface(); + RB_BeginSurface(tess.shader, tess.fogNum); + + R_BindVBO(vbo); + R_BindIBO(ibo); + } + + if (vbo != tess.vbo && ibo != tess.ibo) + tess.useInternalVBO = qfalse; +} + + +/* +============== +RB_AddQuadStampExt +============== +*/ +void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], float s1, float t1, float s2, float t2 ) { + vec3_t normal; + int ndx; + + RB_CHECKOVERFLOW( 4, 6 ); + + ndx = tess.numVertexes; + + // triangle indexes for a simple quad + tess.indexes[ tess.numIndexes ] = ndx; + tess.indexes[ tess.numIndexes + 1 ] = ndx + 1; + tess.indexes[ tess.numIndexes + 2 ] = ndx + 3; + + tess.indexes[ tess.numIndexes + 3 ] = ndx + 3; + tess.indexes[ tess.numIndexes + 4 ] = ndx + 1; + tess.indexes[ tess.numIndexes + 5 ] = ndx + 2; + + tess.xyz[ndx][0] = origin[0] + left[0] + up[0]; + tess.xyz[ndx][1] = origin[1] + left[1] + up[1]; + tess.xyz[ndx][2] = origin[2] + left[2] + up[2]; + + tess.xyz[ndx+1][0] = origin[0] - left[0] + up[0]; + tess.xyz[ndx+1][1] = origin[1] - left[1] + up[1]; + tess.xyz[ndx+1][2] = origin[2] - left[2] + up[2]; + + tess.xyz[ndx+2][0] = origin[0] - left[0] - up[0]; + tess.xyz[ndx+2][1] = origin[1] - left[1] - up[1]; + tess.xyz[ndx+2][2] = origin[2] - left[2] - up[2]; + + tess.xyz[ndx+3][0] = origin[0] + left[0] - up[0]; + tess.xyz[ndx+3][1] = origin[1] + left[1] - up[1]; + tess.xyz[ndx+3][2] = origin[2] + left[2] - up[2]; + + + // constant normal all the way around + VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal ); + + VectorCopy(normal, tess.normal[ndx]); + VectorCopy(normal, tess.normal[ndx+1]); + VectorCopy(normal, tess.normal[ndx+2]); + VectorCopy(normal, tess.normal[ndx+3]); + + // standard square texture coordinates + VectorSet2(tess.texCoords[ndx ][0], s1, t1); + VectorSet2(tess.texCoords[ndx ][1], s1, t1); + + VectorSet2(tess.texCoords[ndx+1][0], s2, t1); + VectorSet2(tess.texCoords[ndx+1][1], s2, t1); + + VectorSet2(tess.texCoords[ndx+2][0], s2, t2); + VectorSet2(tess.texCoords[ndx+2][1], s2, t2); + + VectorSet2(tess.texCoords[ndx+3][0], s1, t2); + VectorSet2(tess.texCoords[ndx+3][1], s1, t2); + + // constant color all the way around + // should this be identity and let the shader specify from entity? + VectorCopy4(color, tess.vertexColors[ndx]); + VectorCopy4(color, tess.vertexColors[ndx+1]); + VectorCopy4(color, tess.vertexColors[ndx+2]); + VectorCopy4(color, tess.vertexColors[ndx+3]); + + tess.numVertexes += 4; + tess.numIndexes += 6; +} + +/* +============== +RB_AddQuadStamp +============== +*/ +void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, float color[4] ) { + RB_AddQuadStampExt( origin, left, up, color, 0, 0, 1, 1 ); +} + + +/* +============== +RB_InstantQuad + +based on Tess_InstantQuad from xreal +============== +*/ +void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) +{ + GLimp_LogComment("--- RB_InstantQuad2 ---\n"); + + tess.numVertexes = 0; + tess.numIndexes = 0; + tess.firstIndex = 0; + + VectorCopy4(quadVerts[0], tess.xyz[tess.numVertexes]); + VectorCopy2(texCoords[0], tess.texCoords[tess.numVertexes][0]); + tess.numVertexes++; + + VectorCopy4(quadVerts[1], tess.xyz[tess.numVertexes]); + VectorCopy2(texCoords[1], tess.texCoords[tess.numVertexes][0]); + tess.numVertexes++; + + VectorCopy4(quadVerts[2], tess.xyz[tess.numVertexes]); + VectorCopy2(texCoords[2], tess.texCoords[tess.numVertexes][0]); + tess.numVertexes++; + + VectorCopy4(quadVerts[3], tess.xyz[tess.numVertexes]); + VectorCopy2(texCoords[3], tess.texCoords[tess.numVertexes][0]); + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = 0; + tess.indexes[tess.numIndexes++] = 1; + tess.indexes[tess.numIndexes++] = 2; + tess.indexes[tess.numIndexes++] = 0; + tess.indexes[tess.numIndexes++] = 2; + tess.indexes[tess.numIndexes++] = 3; + tess.minIndex = 0; + tess.maxIndex = 3; + + RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD); + + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.minIndex = 0; + tess.maxIndex = 0; +} + + +void RB_InstantQuad(vec4_t quadVerts[4]) +{ + vec2_t texCoords[4]; + + VectorSet2(texCoords[0], 0.0f, 0.0f); + VectorSet2(texCoords[1], 1.0f, 0.0f); + VectorSet2(texCoords[2], 1.0f, 1.0f); + VectorSet2(texCoords[3], 0.0f, 1.0f); + + GLSL_BindProgram(&tr.textureColorShader); + + GLSL_SetUniformMatrix16(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); + + RB_InstantQuad2(quadVerts, texCoords); +} + + +/* +============== +RB_SurfaceSprite +============== +*/ +static void RB_SurfaceSprite( void ) { + vec3_t left, up; + float radius; + float colors[4]; + trRefEntity_t *ent = backEnd.currentEntity; + + // calculate the xyz locations for the four corners + radius = ent->e.radius; + if ( ent->e.rotation == 0 ) { + VectorScale( backEnd.viewParms.or.axis[1], radius, left ); + VectorScale( backEnd.viewParms.or.axis[2], radius, up ); + } else { + float s, c; + float ang; + + ang = M_PI * ent->e.rotation / 180; + s = sin( ang ); + c = cos( ang ); + + VectorScale( backEnd.viewParms.or.axis[1], c * radius, left ); + VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left ); + + VectorScale( backEnd.viewParms.or.axis[2], c * radius, up ); + VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up ); + } + if ( backEnd.viewParms.isMirror ) { + VectorSubtract( vec3_origin, left, left ); + } + + VectorScale4(ent->e.shaderRGBA, 1.0f / 255.0f, colors); + + RB_AddQuadStamp( ent->e.origin, left, up, colors ); +} + + +/* +============= +RB_SurfacePolychain +============= +*/ +static void RB_SurfacePolychain( srfPoly_t *p ) { + int i; + int numv; + + RB_CHECKOVERFLOW( p->numVerts, 3*(p->numVerts - 2) ); + + // fan triangles into the tess array + numv = tess.numVertexes; + for ( i = 0; i < p->numVerts; i++ ) { + VectorCopy( p->verts[i].xyz, tess.xyz[numv] ); + tess.texCoords[numv][0][0] = p->verts[i].st[0]; + tess.texCoords[numv][0][1] = p->verts[i].st[1]; + tess.vertexColors[numv][0] = p->verts[ i ].modulate[0] / 255.0f; + tess.vertexColors[numv][1] = p->verts[ i ].modulate[1] / 255.0f; + tess.vertexColors[numv][2] = p->verts[ i ].modulate[2] / 255.0f; + tess.vertexColors[numv][3] = p->verts[ i ].modulate[3] / 255.0f; + + numv++; + } + + // generate fan indexes into the tess array + for ( i = 0; i < p->numVerts-2; i++ ) { + tess.indexes[tess.numIndexes + 0] = tess.numVertexes; + tess.indexes[tess.numIndexes + 1] = tess.numVertexes + i + 1; + tess.indexes[tess.numIndexes + 2] = tess.numVertexes + i + 2; + tess.numIndexes += 3; + } + + tess.numVertexes = numv; +} + +static void RB_SurfaceVertsAndTris( int numVerts, srfVert_t *verts, int numTriangles, srfTriangle_t *triangles, int dlightBits, int pshadowBits) +{ + int i; + srfTriangle_t *tri; + srfVert_t *dv; + float *xyz, *normal, *texCoords, *lightCoords, *lightdir; +#ifdef USE_VERT_TANGENT_SPACE + float *tangent, *bitangent; +#endif + glIndex_t *index; + float *color; + + RB_CheckVBOandIBO(tess.vbo, tess.ibo); + + RB_CHECKOVERFLOW( numVerts, numTriangles * 3 ); + + tri = triangles; + index = &tess.indexes[ tess.numIndexes ]; + for ( i = 0 ; i < numTriangles ; i++, tri++ ) { + *index++ = tess.numVertexes + tri->indexes[0]; + *index++ = tess.numVertexes + tri->indexes[1]; + *index++ = tess.numVertexes + tri->indexes[2]; + } + tess.numIndexes += numTriangles * 3; + + if ( tess.shader->vertexAttribs & ATTR_POSITION ) + { + dv = verts; + xyz = tess.xyz[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, xyz+=4 ) + VectorCopy(dv->xyz, xyz); + } + + if ( tess.shader->vertexAttribs & ATTR_NORMAL ) + { + dv = verts; + normal = tess.normal[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, normal+=4 ) + VectorCopy(dv->normal, normal); + } + +#ifdef USE_VERT_TANGENT_SPACE + if ( tess.shader->vertexAttribs & ATTR_TANGENT ) + { + dv = verts; + tangent = tess.tangent[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, tangent+=4 ) + VectorCopy(dv->tangent, tangent); + } + + if ( tess.shader->vertexAttribs & ATTR_BITANGENT ) + { + dv = verts; + bitangent = tess.bitangent[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, bitangent+=4 ) + VectorCopy(dv->bitangent, bitangent); + } +#endif + + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) + { + dv = verts; + texCoords = tess.texCoords[ tess.numVertexes ][0]; + for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=4 ) + VectorCopy2(dv->st, texCoords); + } + + if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) + { + dv = verts; + lightCoords = tess.texCoords[ tess.numVertexes ][1]; + for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=4 ) + VectorCopy2(dv->lightmap, lightCoords); + } + + if ( tess.shader->vertexAttribs & ATTR_COLOR ) + { + dv = verts; + color = tess.vertexColors[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, color+=4 ) + VectorCopy4(dv->vertexColors, color); + } + + if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) + { + dv = verts; + lightdir = tess.lightdir[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, lightdir+=4 ) + VectorCopy(dv->lightdir, lightdir); + } + +#if 0 // nothing even uses vertex dlightbits + for ( i = 0 ; i < numVerts ; i++ ) { + tess.vertexDlightBits[ tess.numVertexes + i ] = dlightBits; + } +#endif + + tess.dlightBits |= dlightBits; + tess.pshadowBits |= pshadowBits; + + tess.numVertexes += numVerts; +} + +static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck) +{ + int i, mergeForward, mergeBack; + GLvoid *firstIndexOffset, *lastIndexOffset; + + if (!vbo || !ibo) + { + return qfalse; + } + + if (shaderCheck && !(!ShaderRequiresCPUDeforms(tess.shader) && !tess.shader->isSky && !tess.shader->isPortal)) + { + return qfalse; + } + + RB_CheckVBOandIBO(vbo, ibo); + + tess.dlightBits |= dlightBits; + tess.pshadowBits |= pshadowBits; + + // merge this into any existing multidraw primitives + mergeForward = -1; + mergeBack = -1; + firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)); + lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(GL_INDEX_TYPE)); + + if (r_mergeMultidraws->integer) + { + i = 0; + + if (r_mergeMultidraws->integer == 1) + { + // lazy merge, only check the last primitive + if (tess.multiDrawPrimitives) + { + i = tess.multiDrawPrimitives - 1; + } + } + + for (; i < tess.multiDrawPrimitives; i++) + { + if (tess.multiDrawLastIndex[i] == firstIndexOffset) + { + mergeBack = i; + } + + if (lastIndexOffset == tess.multiDrawFirstIndex[i]) + { + mergeForward = i; + } + } + } + + if (mergeBack != -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack == -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeForward] += numIndexes; + tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset; + tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex); + tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack != -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex)); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex)); + tess.multiDrawPrimitives--; + + if (mergeForward != tess.multiDrawPrimitives) + { + tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives]; + tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives]; + } + backEnd.pc.c_multidrawsMerged += 2; + } + else if (mergeBack == -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes; + tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset; + tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset; + tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex; + tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex; + tess.multiDrawPrimitives++; + } + + backEnd.pc.c_multidraws++; + + tess.numIndexes += numIndexes; + tess.numVertexes += numVerts; + + return qtrue; +} + +/* +============= +RB_SurfaceTriangles +============= +*/ +static void RB_SurfaceTriangles( srfTriangles_t *srf ) { + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) + { + return; + } + + RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles, + srf->triangles, srf->dlightBits, srf->pshadowBits); +} + + + +/* +============== +RB_SurfaceBeam +============== +*/ +static void RB_SurfaceBeam( void ) +{ +#define NUM_BEAM_SEGS 6 + refEntity_t *e; + shaderProgram_t *sp = &tr.textureColorShader; + int i; + vec3_t perpvec; + vec3_t direction, normalized_direction; + vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS]; + vec3_t oldorigin, origin; + + e = &backEnd.currentEntity->e; + + oldorigin[0] = e->oldorigin[0]; + oldorigin[1] = e->oldorigin[1]; + oldorigin[2] = e->oldorigin[2]; + + origin[0] = e->origin[0]; + origin[1] = e->origin[1]; + origin[2] = e->origin[2]; + + normalized_direction[0] = direction[0] = oldorigin[0] - origin[0]; + normalized_direction[1] = direction[1] = oldorigin[1] - origin[1]; + normalized_direction[2] = direction[2] = oldorigin[2] - origin[2]; + + if ( VectorNormalize( normalized_direction ) == 0 ) + return; + + PerpendicularVector( perpvec, normalized_direction ); + + VectorScale( perpvec, 4, perpvec ); + + for ( i = 0; i < NUM_BEAM_SEGS ; i++ ) + { + RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i ); +// VectorAdd( start_points[i], origin, start_points[i] ); + VectorAdd( start_points[i], direction, end_points[i] ); + } + + GL_Bind( tr.whiteImage ); + + GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); + + // FIXME: Quake3 doesn't use this, so I never tested it + tess.numVertexes = 0; + tess.numIndexes = 0; + tess.firstIndex = 0; + tess.minIndex = 0; + tess.maxIndex = 0; + + for ( i = 0; i <= NUM_BEAM_SEGS; i++ ) { + VectorCopy(start_points[ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]); + VectorCopy(end_points [ i % NUM_BEAM_SEGS ], tess.xyz[tess.numVertexes++]); + } + + for ( i = 0; i < NUM_BEAM_SEGS; i++ ) { + tess.indexes[tess.numIndexes++] = i * 2; + tess.indexes[tess.numIndexes++] = (i + 1) * 2; + tess.indexes[tess.numIndexes++] = 1 + i * 2; + + tess.indexes[tess.numIndexes++] = 1 + i * 2; + tess.indexes[tess.numIndexes++] = (i + 1) * 2; + tess.indexes[tess.numIndexes++] = 1 + (i + 1) * 2; + } + + tess.minIndex = 0; + tess.maxIndex = tess.numVertexes; + + // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function + RB_UpdateVBOs(ATTR_POSITION); + + GLSL_VertexAttribsState(ATTR_POSITION); + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed); + + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.minIndex = 0; + tess.maxIndex = 0; +} + +//================================================================================ + +static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth ) +{ + float spanWidth2; + int vbase; + float t = len / 256.0f; + + vbase = tess.numVertexes; + + spanWidth2 = -spanWidth; + + // FIXME: use quad stamp? + VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25 / 255.0f; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25 / 255.0f; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25 / 255.0f; + tess.numVertexes++; + + VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 1; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; + tess.numVertexes++; + + VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); + + tess.texCoords[tess.numVertexes][0][0] = t; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; + tess.numVertexes++; + + VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = t; + tess.texCoords[tess.numVertexes][0][1] = 1; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 3; +} + +static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up ) +{ + int i; + vec3_t pos[4]; + vec3_t v; + int spanWidth = r_railWidth->integer; + float c, s; + float scale; + + if ( numSegs > 1 ) + numSegs--; + if ( !numSegs ) + return; + + scale = 0.25; + + for ( i = 0; i < 4; i++ ) + { + c = cos( DEG2RAD( 45 + i * 90 ) ); + s = sin( DEG2RAD( 45 + i * 90 ) ); + v[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth; + v[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth; + v[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth; + VectorAdd( start, v, pos[i] ); + + if ( numSegs > 1 ) + { + // offset by 1 segment if we're doing a long distance shot + VectorAdd( pos[i], dir, pos[i] ); + } + } + + for ( i = 0; i < numSegs; i++ ) + { + int j; + + RB_CHECKOVERFLOW( 4, 6 ); + + for ( j = 0; j < 4; j++ ) + { + VectorCopy( pos[j], tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = ( j < 2 ); + tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 ); + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; + tess.numVertexes++; + + VectorAdd( pos[j], dir, pos[j] ); + } + + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0; + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; + tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2; + } +} + +/* +** RB_SurfaceRailRinges +*/ +static void RB_SurfaceRailRings( void ) { + refEntity_t *e; + int numSegs; + int len; + vec3_t vec; + vec3_t right, up; + vec3_t start, end; + + e = &backEnd.currentEntity->e; + + VectorCopy( e->oldorigin, start ); + VectorCopy( e->origin, end ); + + // compute variables + VectorSubtract( end, start, vec ); + len = VectorNormalize( vec ); + MakeNormalVectors( vec, right, up ); + numSegs = ( len ) / r_railSegmentLength->value; + if ( numSegs <= 0 ) { + numSegs = 1; + } + + VectorScale( vec, r_railSegmentLength->value, vec ); + + DoRailDiscs( numSegs, start, vec, right, up ); +} + +/* +** RB_SurfaceRailCore +*/ +static void RB_SurfaceRailCore( void ) { + refEntity_t *e; + int len; + vec3_t right; + vec3_t vec; + vec3_t start, end; + vec3_t v1, v2; + + e = &backEnd.currentEntity->e; + + VectorCopy( e->oldorigin, start ); + VectorCopy( e->origin, end ); + + VectorSubtract( end, start, vec ); + len = VectorNormalize( vec ); + + // compute side vector + VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); + VectorNormalize( v1 ); + VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); + VectorNormalize( v2 ); + CrossProduct( v1, v2, right ); + VectorNormalize( right ); + + DoRailCore( start, end, right, len, r_railCoreWidth->integer ); +} + +/* +** RB_SurfaceLightningBolt +*/ +static void RB_SurfaceLightningBolt( void ) { + refEntity_t *e; + int len; + vec3_t right; + vec3_t vec; + vec3_t start, end; + vec3_t v1, v2; + int i; + + e = &backEnd.currentEntity->e; + + VectorCopy( e->oldorigin, end ); + VectorCopy( e->origin, start ); + + // compute variables + VectorSubtract( end, start, vec ); + len = VectorNormalize( vec ); + + // compute side vector + VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); + VectorNormalize( v1 ); + VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); + VectorNormalize( v2 ); + CrossProduct( v1, v2, right ); + VectorNormalize( right ); + + for ( i = 0 ; i < 4 ; i++ ) { + vec3_t temp; + + DoRailCore( start, end, right, len, 8 ); + RotatePointAroundVector( temp, vec, right, 45 ); + VectorCopy( temp, right ); + } +} + +/* +** VectorArrayNormalize +* +* The inputs to this routing seem to always be close to length = 1.0 (about 0.6 to 2.0) +* This means that we don't have to worry about zero length or enormously long vectors. +*/ +static void VectorArrayNormalize(vec4_t *normals, unsigned int count) +{ +// assert(count); + +#if idppc + { + register float half = 0.5; + register float one = 1.0; + float *components = (float *)normals; + + // Vanilla PPC code, but since PPC has a reciprocal square root estimate instruction, + // runs *much* faster than calling sqrt(). We'll use a single Newton-Raphson + // refinement step to get a little more precision. This seems to yeild results + // that are correct to 3 decimal places and usually correct to at least 4 (sometimes 5). + // (That is, for the given input range of about 0.6 to 2.0). + do { + float x, y, z; + float B, y0, y1; + + x = components[0]; + y = components[1]; + z = components[2]; + components += 4; + B = x*x + y*y + z*z; + +#ifdef __GNUC__ + asm("frsqrte %0,%1" : "=f" (y0) : "f" (B)); +#else + y0 = __frsqrte(B); +#endif + y1 = y0 + half*y0*(one - B*y0*y0); + + x = x * y1; + y = y * y1; + components[-4] = x; + z = z * y1; + components[-3] = y; + components[-2] = z; + } while(count--); + } +#else // No assembly version for this architecture, or C_ONLY defined + // given the input, it's safe to call VectorNormalizeFast + while (count--) { + VectorNormalizeFast(normals[0]); + normals++; + } +#endif + +} + + + +/* +** LerpMeshVertexes +*/ +#if idppc_altivec +static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) +{ + short *oldXyz, *newXyz, *oldNormals, *newNormals; + float *outXyz, *outNormal; + float oldXyzScale QALIGN(16); + float newXyzScale QALIGN(16); + float oldNormalScale QALIGN(16); + float newNormalScale QALIGN(16); + int vertNum; + unsigned lat, lng; + int numVerts; + + outXyz = tess.xyz[tess.numVertexes]; + outNormal = tess.normal[tess.numVertexes]; + + newXyz = (short *)((byte *)surf + surf->ofsXyzNormals) + + (backEnd.currentEntity->e.frame * surf->numVerts * 4); + newNormals = newXyz + 3; + + newXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp); + newNormalScale = 1.0 - backlerp; + + numVerts = surf->numVerts; + + if ( backlerp == 0 ) { + vector signed short newNormalsVec0; + vector signed short newNormalsVec1; + vector signed int newNormalsIntVec; + vector float newNormalsFloatVec; + vector float newXyzScaleVec; + vector unsigned char newNormalsLoadPermute; + vector unsigned char newNormalsStorePermute; + vector float zero; + + newNormalsStorePermute = vec_lvsl(0,(float *)&newXyzScaleVec); + newXyzScaleVec = *(vector float *)&newXyzScale; + newXyzScaleVec = vec_perm(newXyzScaleVec,newXyzScaleVec,newNormalsStorePermute); + newXyzScaleVec = vec_splat(newXyzScaleVec,0); + newNormalsLoadPermute = vec_lvsl(0,newXyz); + newNormalsStorePermute = vec_lvsr(0,outXyz); + zero = (vector float)vec_splat_s8(0); + // + // just copy the vertexes + // + for (vertNum=0 ; vertNum < numVerts ; vertNum++, + newXyz += 4, newNormals += 4, + outXyz += 4, outNormal += 4) + { + newNormalsLoadPermute = vec_lvsl(0,newXyz); + newNormalsStorePermute = vec_lvsr(0,outXyz); + newNormalsVec0 = vec_ld(0,newXyz); + newNormalsVec1 = vec_ld(16,newXyz); + newNormalsVec0 = vec_perm(newNormalsVec0,newNormalsVec1,newNormalsLoadPermute); + newNormalsIntVec = vec_unpackh(newNormalsVec0); + newNormalsFloatVec = vec_ctf(newNormalsIntVec,0); + newNormalsFloatVec = vec_madd(newNormalsFloatVec,newXyzScaleVec,zero); + newNormalsFloatVec = vec_perm(newNormalsFloatVec,newNormalsFloatVec,newNormalsStorePermute); + //outXyz[0] = newXyz[0] * newXyzScale; + //outXyz[1] = newXyz[1] * newXyzScale; + //outXyz[2] = newXyz[2] * newXyzScale; + + lat = ( newNormals[0] >> 8 ) & 0xff; + lng = ( newNormals[0] & 0xff ); + lat *= (FUNCTABLE_SIZE/256); + lng *= (FUNCTABLE_SIZE/256); + + // decode X as cos( lat ) * sin( long ) + // decode Y as sin( lat ) * sin( long ) + // decode Z as cos( long ) + + outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + vec_ste(newNormalsFloatVec,0,outXyz); + vec_ste(newNormalsFloatVec,4,outXyz); + vec_ste(newNormalsFloatVec,8,outXyz); + } + } else { + // + // interpolate and copy the vertex and normal + // + oldXyz = (short *)((byte *)surf + surf->ofsXyzNormals) + + (backEnd.currentEntity->e.oldframe * surf->numVerts * 4); + oldNormals = oldXyz + 3; + + oldXyzScale = MD3_XYZ_SCALE * backlerp; + oldNormalScale = backlerp; + + for (vertNum=0 ; vertNum < numVerts ; vertNum++, + oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, + outXyz += 4, outNormal += 4) + { + vec3_t uncompressedOldNormal, uncompressedNewNormal; + + // interpolate the xyz + outXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale; + outXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale; + outXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale; + + // FIXME: interpolate lat/long instead? + lat = ( newNormals[0] >> 8 ) & 0xff; + lng = ( newNormals[0] & 0xff ); + lat *= 4; + lng *= 4; + uncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + uncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + uncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + lat = ( oldNormals[0] >> 8 ) & 0xff; + lng = ( oldNormals[0] & 0xff ); + lat *= 4; + lng *= 4; + + uncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + uncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + uncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + outNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale; + outNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale; + outNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale; + +// VectorNormalize (outNormal); + } + VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts); + } +} +#endif + +static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) +{ +#if 0 + short *oldXyz, *newXyz, *oldNormals, *newNormals; + float *outXyz, *outNormal; + float oldXyzScale, newXyzScale; + float oldNormalScale, newNormalScale; + int vertNum; + unsigned lat, lng; + int numVerts; + + outXyz = tess.xyz[tess.numVertexes]; + outNormal = tess.normal[tess.numVertexes]; + + newXyz = (short *)((byte *)surf + surf->ofsXyzNormals) + + (backEnd.currentEntity->e.frame * surf->numVerts * 4); + newNormals = newXyz + 3; + + newXyzScale = MD3_XYZ_SCALE * (1.0 - backlerp); + newNormalScale = 1.0 - backlerp; + + numVerts = surf->numVerts; + + if ( backlerp == 0 ) { + // + // just copy the vertexes + // + for (vertNum=0 ; vertNum < numVerts ; vertNum++, + newXyz += 4, newNormals += 4, + outXyz += 4, outNormal += 4) + { + + outXyz[0] = newXyz[0] * newXyzScale; + outXyz[1] = newXyz[1] * newXyzScale; + outXyz[2] = newXyz[2] * newXyzScale; + + lat = ( newNormals[0] >> 8 ) & 0xff; + lng = ( newNormals[0] & 0xff ); + lat *= (FUNCTABLE_SIZE/256); + lng *= (FUNCTABLE_SIZE/256); + + // decode X as cos( lat ) * sin( long ) + // decode Y as sin( lat ) * sin( long ) + // decode Z as cos( long ) + + outNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + outNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + outNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + } + } else { + // + // interpolate and copy the vertex and normal + // + oldXyz = (short *)((byte *)surf + surf->ofsXyzNormals) + + (backEnd.currentEntity->e.oldframe * surf->numVerts * 4); + oldNormals = oldXyz + 3; + + oldXyzScale = MD3_XYZ_SCALE * backlerp; + oldNormalScale = backlerp; + + for (vertNum=0 ; vertNum < numVerts ; vertNum++, + oldXyz += 4, newXyz += 4, oldNormals += 4, newNormals += 4, + outXyz += 4, outNormal += 4) + { + vec3_t uncompressedOldNormal, uncompressedNewNormal; + + // interpolate the xyz + outXyz[0] = oldXyz[0] * oldXyzScale + newXyz[0] * newXyzScale; + outXyz[1] = oldXyz[1] * oldXyzScale + newXyz[1] * newXyzScale; + outXyz[2] = oldXyz[2] * oldXyzScale + newXyz[2] * newXyzScale; + + // FIXME: interpolate lat/long instead? + lat = ( newNormals[0] >> 8 ) & 0xff; + lng = ( newNormals[0] & 0xff ); + lat *= 4; + lng *= 4; + uncompressedNewNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + uncompressedNewNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + uncompressedNewNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + lat = ( oldNormals[0] >> 8 ) & 0xff; + lng = ( oldNormals[0] & 0xff ); + lat *= 4; + lng *= 4; + + uncompressedOldNormal[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; + uncompressedOldNormal[1] = tr.sinTable[lat] * tr.sinTable[lng]; + uncompressedOldNormal[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; + + outNormal[0] = uncompressedOldNormal[0] * oldNormalScale + uncompressedNewNormal[0] * newNormalScale; + outNormal[1] = uncompressedOldNormal[1] * oldNormalScale + uncompressedNewNormal[1] * newNormalScale; + outNormal[2] = uncompressedOldNormal[2] * oldNormalScale + uncompressedNewNormal[2] * newNormalScale; + +// VectorNormalize (outNormal); + } + VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts); + } +#endif + float *outXyz, *outNormal; + mdvVertex_t *newVerts; + int vertNum; + + newVerts = surf->verts + backEnd.currentEntity->e.frame * surf->numVerts; + + outXyz = tess.xyz[tess.numVertexes]; + outNormal = tess.normal[tess.numVertexes]; + + if (backlerp == 0) + { + // + // just copy the vertexes + // + + for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) + { + VectorCopy(newVerts->xyz, outXyz); + VectorCopy(newVerts->normal, outNormal); + newVerts++; + outXyz += 4; + outNormal += 4; + } + } + else + { + // + // interpolate and copy the vertex and normal + // + + mdvVertex_t *oldVerts; + + oldVerts = surf->verts + backEnd.currentEntity->e.oldframe * surf->numVerts; + + for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) + { + VectorLerp(newVerts->xyz, oldVerts->xyz, backlerp, outXyz); + VectorLerp(newVerts->normal, oldVerts->normal, backlerp, outNormal); + //VectorNormalize(outNormal); + newVerts++; + oldVerts++; + outXyz += 4; + outNormal += 4; + } + VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], surf->numVerts); + } + +} + +static void LerpMeshVertexes(mdvSurface_t *surf, float backlerp) +{ +#if 0 +#if idppc_altivec + if (com_altivec->integer) { + // must be in a seperate function or G3 systems will crash. + LerpMeshVertexes_altivec( surf, backlerp ); + return; + } +#endif // idppc_altivec +#endif + LerpMeshVertexes_scalar( surf, backlerp ); +} + + +/* +============= +RB_SurfaceMesh +============= +*/ +static void RB_SurfaceMesh(mdvSurface_t *surface) { + int j; + float backlerp; + srfTriangle_t *triangles; + mdvSt_t *texCoords; + int indexes; + int Bob, Doug; + int numVerts; + + if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) { + backlerp = 0; + } else { + backlerp = backEnd.currentEntity->e.backlerp; + } + + RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles*3 ); + + LerpMeshVertexes (surface, backlerp); + + triangles = surface->triangles; + indexes = surface->numTriangles * 3; + Bob = tess.numIndexes; + Doug = tess.numVertexes; + for (j = 0 ; j < surface->numTriangles ; j++) { + tess.indexes[Bob + j*3 + 0] = Doug + triangles[j].indexes[0]; + tess.indexes[Bob + j*3 + 1] = Doug + triangles[j].indexes[1]; + tess.indexes[Bob + j*3 + 2] = Doug + triangles[j].indexes[2]; + } + tess.numIndexes += indexes; + + texCoords = surface->st; + + numVerts = surface->numVerts; + for ( j = 0; j < numVerts; j++ ) { + tess.texCoords[Doug + j][0][0] = texCoords[j].st[0]; + tess.texCoords[Doug + j][0][1] = texCoords[j].st[1]; + // FIXME: fill in lightmapST for completeness? + } + + tess.numVertexes += surface->numVerts; + +} + + +/* +============== +RB_SurfaceFace +============== +*/ +static void RB_SurfaceFace( srfSurfaceFace_t *srf ) { + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) + { + return; + } + + RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles, + srf->triangles, srf->dlightBits, srf->pshadowBits); +} + + +static float LodErrorForVolume( vec3_t local, float radius ) { + vec3_t world; + float d; + + // never let it go negative + if ( r_lodCurveError->value < 0 ) { + return 0; + } + + world[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] + + local[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0]; + world[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] + + local[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1]; + world[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] + + local[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2]; + + VectorSubtract( world, backEnd.viewParms.or.origin, world ); + d = DotProduct( world, backEnd.viewParms.or.axis[0] ); + + if ( d < 0 ) { + d = -d; + } + d -= radius; + if ( d < 1 ) { + d = 1; + } + + return r_lodCurveError->value / d; +} + +/* +============= +RB_SurfaceGrid + +Just copy the grid of points and triangulate +============= +*/ +static void RB_SurfaceGrid( srfGridMesh_t *srf ) { + int i, j; + float *xyz; + float *texCoords, *lightCoords; + float *normal; +#ifdef USE_VERT_TANGENT_SPACE + float *tangent, *bitangent; +#endif + float *color, *lightdir; + srfVert_t *dv; + int rows, irows, vrows; + int used; + int widthTable[MAX_GRID_SIZE]; + int heightTable[MAX_GRID_SIZE]; + float lodError; + int lodWidth, lodHeight; + int numVertexes; + int dlightBits; + int pshadowBits; + //int *vDlightBits; + + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) + { + return; + } + + dlightBits = srf->dlightBits; + tess.dlightBits |= dlightBits; + + pshadowBits = srf->pshadowBits; + tess.pshadowBits |= pshadowBits; + + // determine the allowable discrepance + lodError = LodErrorForVolume( srf->lodOrigin, srf->lodRadius ); + + // determine which rows and columns of the subdivision + // we are actually going to use + widthTable[0] = 0; + lodWidth = 1; + for ( i = 1 ; i < srf->width-1 ; i++ ) { + if ( srf->widthLodError[i] <= lodError ) { + widthTable[lodWidth] = i; + lodWidth++; + } + } + widthTable[lodWidth] = srf->width-1; + lodWidth++; + + heightTable[0] = 0; + lodHeight = 1; + for ( i = 1 ; i < srf->height-1 ; i++ ) { + if ( srf->heightLodError[i] <= lodError ) { + heightTable[lodHeight] = i; + lodHeight++; + } + } + heightTable[lodHeight] = srf->height-1; + lodHeight++; + + + // very large grids may have more points or indexes than can be fit + // in the tess structure, so we may have to issue it in multiple passes + + used = 0; + while ( used < lodHeight - 1 ) { + // see how many rows of both verts and indexes we can add without overflowing + do { + vrows = ( SHADER_MAX_VERTEXES - tess.numVertexes ) / lodWidth; + irows = ( SHADER_MAX_INDEXES - tess.numIndexes ) / ( lodWidth * 6 ); + + // if we don't have enough space for at least one strip, flush the buffer + if ( vrows < 2 || irows < 1 ) { + RB_EndSurface(); + RB_BeginSurface(tess.shader, tess.fogNum ); + } else { + break; + } + } while ( 1 ); + + rows = irows; + if ( vrows < irows + 1 ) { + rows = vrows - 1; + } + if ( used + rows > lodHeight ) { + rows = lodHeight - used; + } + + numVertexes = tess.numVertexes; + + xyz = tess.xyz[numVertexes]; + normal = tess.normal[numVertexes]; +#ifdef USE_VERT_TANGENT_SPACE + tangent = tess.tangent[numVertexes]; + bitangent = tess.bitangent[numVertexes]; +#endif + texCoords = tess.texCoords[numVertexes][0]; + lightCoords = tess.texCoords[numVertexes][1]; + color = tess.vertexColors[numVertexes]; + lightdir = tess.lightdir[numVertexes]; + //vDlightBits = &tess.vertexDlightBits[numVertexes]; + + for ( i = 0 ; i < rows ; i++ ) { + for ( j = 0 ; j < lodWidth ; j++ ) { + dv = srf->verts + heightTable[ used + i ] * srf->width + + widthTable[ j ]; + + if ( tess.shader->vertexAttribs & ATTR_POSITION ) + { + VectorCopy(dv->xyz, xyz); + xyz += 4; + } + + if ( tess.shader->vertexAttribs & ATTR_NORMAL ) + { + VectorCopy(dv->normal, normal); + normal += 4; + } + +#ifdef USE_VERT_TANGENT_SPACE + if ( tess.shader->vertexAttribs & ATTR_TANGENT ) + { + VectorCopy(dv->tangent, tangent); + tangent += 4; + } + + if ( tess.shader->vertexAttribs & ATTR_BITANGENT ) + { + VectorCopy(dv->bitangent, bitangent); + bitangent += 4; + } +#endif + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) + { + VectorCopy2(dv->st, texCoords); + texCoords += 4; + } + + if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) + { + VectorCopy2(dv->lightmap, lightCoords); + lightCoords += 4; + } + + if ( tess.shader->vertexAttribs & ATTR_COLOR ) + { + VectorCopy4(dv->vertexColors, color); + color += 4; + } + + if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) + { + VectorCopy(dv->lightdir, lightdir); + lightdir += 4; + } + + //*vDlightBits++ = dlightBits; + } + } + + + // add the indexes + { + int numIndexes; + int w, h; + + h = rows - 1; + w = lodWidth - 1; + numIndexes = tess.numIndexes; + for (i = 0 ; i < h ; i++) { + for (j = 0 ; j < w ; j++) { + int v1, v2, v3, v4; + + // vertex order to be reckognized as tristrips + v1 = numVertexes + i*lodWidth + j + 1; + v2 = v1 - 1; + v3 = v2 + lodWidth; + v4 = v3 + 1; + + tess.indexes[numIndexes] = v2; + tess.indexes[numIndexes+1] = v3; + tess.indexes[numIndexes+2] = v1; + + tess.indexes[numIndexes+3] = v1; + tess.indexes[numIndexes+4] = v3; + tess.indexes[numIndexes+5] = v4; + numIndexes += 6; + } + } + + tess.numIndexes = numIndexes; + } + + tess.numVertexes += rows * lodWidth; + + used += rows - 1; + } +} + + +/* +=========================================================================== + +NULL MODEL + +=========================================================================== +*/ + +/* +=================== +RB_SurfaceAxis + +Draws x/y/z lines from the origin for orientation debugging +=================== +*/ +static void RB_SurfaceAxis( void ) { + // FIXME: implement this +#if 0 + GL_Bind( tr.whiteImage ); + GL_State( GLS_DEFAULT ); + qglLineWidth( 3 ); + qglBegin( GL_LINES ); + qglColor3f( 1,0,0 ); + qglVertex3f( 0,0,0 ); + qglVertex3f( 16,0,0 ); + qglColor3f( 0,1,0 ); + qglVertex3f( 0,0,0 ); + qglVertex3f( 0,16,0 ); + qglColor3f( 0,0,1 ); + qglVertex3f( 0,0,0 ); + qglVertex3f( 0,0,16 ); + qglEnd(); + qglLineWidth( 1 ); +#endif +} + +//=========================================================================== + +/* +==================== +RB_SurfaceEntity + +Entities that have a single procedurally generated surface +==================== +*/ +static void RB_SurfaceEntity( surfaceType_t *surfType ) { + switch( backEnd.currentEntity->e.reType ) { + case RT_SPRITE: + RB_SurfaceSprite(); + break; + case RT_BEAM: + RB_SurfaceBeam(); + break; + case RT_RAIL_CORE: + RB_SurfaceRailCore(); + break; + case RT_RAIL_RINGS: + RB_SurfaceRailRings(); + break; + case RT_LIGHTNING: + RB_SurfaceLightningBolt(); + break; + default: + RB_SurfaceAxis(); + break; + } +} + +static void RB_SurfaceBad( surfaceType_t *surfType ) { + ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" ); +} + +static void RB_SurfaceFlare(srfFlare_t *surf) +{ + if (r_flares->integer) + RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal); +} + +static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf) +{ + RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, + srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qfalse ); +} + +void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) +{ + //mdvModel_t *mdvModel; + //mdvSurface_t *mdvSurface; + refEntity_t *refEnt; + + GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); + + if(!surface->vbo || !surface->ibo) + return; + + //RB_CheckVBOandIBO(surface->vbo, surface->ibo); + RB_EndSurface(); + RB_BeginSurface(tess.shader, tess.fogNum); + + R_BindVBO(surface->vbo); + R_BindIBO(surface->ibo); + + tess.useInternalVBO = qfalse; + + tess.numIndexes += surface->numIndexes; + tess.numVertexes += surface->numVerts; + tess.minIndex = surface->minIndex; + tess.maxIndex = surface->maxIndex; + + //mdvModel = surface->mdvModel; + //mdvSurface = surface->mdvSurface; + + refEnt = &backEnd.currentEntity->e; + + if(refEnt->oldframe == refEnt->frame) + { + glState.vertexAttribsInterpolation = 0; + } + else + { + glState.vertexAttribsInterpolation = refEnt->backlerp; + } + + glState.vertexAttribsOldFrame = refEnt->oldframe; + glState.vertexAttribsNewFrame = refEnt->frame; + + RB_EndSurface(); + + // So we don't lerp surfaces that shouldn't be lerped + glState.vertexAttribsInterpolation = 0; +} + +static void RB_SurfaceDisplayList( srfDisplayList_t *surf ) { + // all apropriate state must be set in RB_BeginSurface + // this isn't implemented yet... + qglCallList( surf->listNum ); +} + +static void RB_SurfaceSkip( void *surf ) { +} + + +void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { + (void(*)(void*))RB_SurfaceBad, // SF_BAD, + (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, + (void(*)(void*))RB_SurfaceFace, // SF_FACE, + (void(*)(void*))RB_SurfaceGrid, // SF_GRID, + (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, + (void(*)(void*))RB_SurfacePolychain, // SF_POLY, + (void(*)(void*))RB_SurfaceMesh, // SF_MDV, + (void(*)(void*))RB_SurfaceAnim, // SF_MD4, + (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, + (void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM, + (void(*)(void*))RB_SurfaceFlare, // SF_FLARE, + (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY + (void(*)(void*))RB_SurfaceDisplayList, // SF_DISPLAY_LIST + (void(*)(void*))RB_SurfaceVBOMesh, // SF_VBO_MESH, + (void(*)(void*))RB_SurfaceVBOMDVMesh, // SF_VBO_MDVMESH +}; diff --git a/codemp/rd-rend2/tr_vbo.c b/codemp/rd-rend2/tr_vbo.c new file mode 100644 index 0000000000..e9f2598bea --- /dev/null +++ b/codemp/rd-rend2/tr_vbo.c @@ -0,0 +1,928 @@ +/* +=========================================================================== +Copyright (C) 2007-2009 Robert Beckebans + +This file is part of XreaL source code. + +XreaL source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +XreaL source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with XreaL source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +// tr_vbo.c +#include "tr_local.h" + +/* +============ +R_CreateVBO +============ +*/ +VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, vboUsage_t usage) +{ + VBO_t *vbo; + int glUsage; + + switch (usage) + { + case VBO_USAGE_STATIC: + glUsage = GL_STATIC_DRAW_ARB; + break; + + case VBO_USAGE_DYNAMIC: + glUsage = GL_DYNAMIC_DRAW_ARB; + break; + + default: + Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); + return NULL; + } + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "R_CreateVBO: \"%s\" is too long", name); + } + + if ( tr.numVBOs == MAX_VBOS ) { + ri.Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); + } + + R_IssuePendingRenderCommands(); + + vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); + tr.numVBOs++; + + memset(vbo, 0, sizeof(*vbo)); + + Q_strncpyz(vbo->name, name, sizeof(vbo->name)); + + vbo->vertexesSize = vertexesSize; + + qglGenBuffersARB(1, &vbo->vertexesVBO); + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); + qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexesSize, vertexes, glUsage); + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + + glState.currentVBO = NULL; + + GL_CheckErrors(); + + return vbo; +} + +/* +============ +R_CreateVBO2 +============ +*/ +VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * verts, unsigned int stateBits, vboUsage_t usage) +{ + VBO_t *vbo; + int i; + + byte *data; + int dataSize; + int dataOfs; + + int glUsage; + + switch (usage) + { + case VBO_USAGE_STATIC: + glUsage = GL_STATIC_DRAW_ARB; + break; + + case VBO_USAGE_DYNAMIC: + glUsage = GL_DYNAMIC_DRAW_ARB; + break; + + default: + Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); + return NULL; + } + + if(!numVertexes) + return NULL; + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "R_CreateVBO2: \"%s\" is too long", name); + } + + if ( tr.numVBOs == MAX_VBOS ) { + ri.Error( ERR_DROP, "R_CreateVBO2: MAX_VBOS hit"); + } + + R_IssuePendingRenderCommands(); + + vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); + tr.numVBOs++; + + memset(vbo, 0, sizeof(*vbo)); + + Q_strncpyz(vbo->name, name, sizeof(vbo->name)); + + if (usage == VBO_USAGE_STATIC) + { + // since these vertex attributes are never altered, interleave them + vbo->ofs_xyz = 0; + dataSize = sizeof(verts[0].xyz); + + if(stateBits & ATTR_NORMAL) + { + vbo->ofs_normal = dataSize; + dataSize += sizeof(verts[0].normal); + } + +#ifdef USE_VERT_TANGENT_SPACE + if(stateBits & ATTR_TANGENT) + { + vbo->ofs_tangent = dataSize; + dataSize += sizeof(verts[0].tangent); + } + + if(stateBits & ATTR_BITANGENT) + { + vbo->ofs_bitangent = dataSize; + dataSize += sizeof(verts[0].bitangent); + } +#endif + + if(stateBits & ATTR_TEXCOORD) + { + vbo->ofs_st = dataSize; + dataSize += sizeof(verts[0].st); + } + + if(stateBits & ATTR_LIGHTCOORD) + { + vbo->ofs_lightmap = dataSize; + dataSize += sizeof(verts[0].lightmap); + } + + if(stateBits & ATTR_COLOR) + { + vbo->ofs_vertexcolor = dataSize; + dataSize += sizeof(verts[0].vertexColors); + } + + if(stateBits & ATTR_LIGHTDIRECTION) + { + vbo->ofs_lightdir = dataSize; + dataSize += sizeof(verts[0].lightdir); + } + + vbo->stride_xyz = dataSize; + vbo->stride_normal = dataSize; +#ifdef USE_VERT_TANGENT_SPACE + vbo->stride_tangent = dataSize; + vbo->stride_bitangent = dataSize; +#endif + vbo->stride_st = dataSize; + vbo->stride_lightmap = dataSize; + vbo->stride_vertexcolor = dataSize; + vbo->stride_lightdir = dataSize; + + // create VBO + dataSize *= numVertexes; + data = ri.Hunk_AllocateTempMemory(dataSize); + dataOfs = 0; + + //ri.Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, + //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); + + for (i = 0; i < numVertexes; i++) + { + // xyz + memcpy(data + dataOfs, &verts[i].xyz, sizeof(verts[i].xyz)); + dataOfs += sizeof(verts[i].xyz); + + // normal + if(stateBits & ATTR_NORMAL) + { + memcpy(data + dataOfs, &verts[i].normal, sizeof(verts[i].normal)); + dataOfs += sizeof(verts[i].normal); + } + +#ifdef USE_VERT_TANGENT_SPACE + // tangent + if(stateBits & ATTR_TANGENT) + { + memcpy(data + dataOfs, &verts[i].tangent, sizeof(verts[i].tangent)); + dataOfs += sizeof(verts[i].tangent); + } + + // bitangent + if(stateBits & ATTR_BITANGENT) + { + memcpy(data + dataOfs, &verts[i].bitangent, sizeof(verts[i].bitangent)); + dataOfs += sizeof(verts[i].bitangent); + } +#endif + + // vertex texcoords + if(stateBits & ATTR_TEXCOORD) + { + memcpy(data + dataOfs, &verts[i].st, sizeof(verts[i].st)); + dataOfs += sizeof(verts[i].st); + } + + // feed vertex lightmap texcoords + if(stateBits & ATTR_LIGHTCOORD) + { + memcpy(data + dataOfs, &verts[i].lightmap, sizeof(verts[i].lightmap)); + dataOfs += sizeof(verts[i].lightmap); + } + + // feed vertex colors + if(stateBits & ATTR_COLOR) + { + memcpy(data + dataOfs, &verts[i].vertexColors, sizeof(verts[i].vertexColors)); + dataOfs += sizeof(verts[i].vertexColors); + } + + // feed vertex light directions + if(stateBits & ATTR_LIGHTDIRECTION) + { + memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir)); + dataOfs += sizeof(verts[i].lightdir); + } + } + } + else + { + // since these vertex attributes may be changed, put them in flat arrays + dataSize = sizeof(verts[0].xyz); + + if(stateBits & ATTR_NORMAL) + { + dataSize += sizeof(verts[0].normal); + } + +#ifdef USE_VERT_TANGENT_SPACE + if(stateBits & ATTR_TANGENT) + { + dataSize += sizeof(verts[0].tangent); + } + + if(stateBits & ATTR_BITANGENT) + { + dataSize += sizeof(verts[0].bitangent); + } +#endif + + if(stateBits & ATTR_TEXCOORD) + { + dataSize += sizeof(verts[0].st); + } + + if(stateBits & ATTR_LIGHTCOORD) + { + dataSize += sizeof(verts[0].lightmap); + } + + if(stateBits & ATTR_COLOR) + { + dataSize += sizeof(verts[0].vertexColors); + } + + if(stateBits & ATTR_LIGHTDIRECTION) + { + dataSize += sizeof(verts[0].lightdir); + } + + // create VBO + dataSize *= numVertexes; + data = ri.Hunk_AllocateTempMemory(dataSize); + dataOfs = 0; + + vbo->ofs_xyz = 0; + vbo->ofs_normal = 0; +#ifdef USE_VERT_TANGENT_SPACE + vbo->ofs_tangent = 0; + vbo->ofs_bitangent = 0; +#endif + vbo->ofs_st = 0; + vbo->ofs_lightmap = 0; + vbo->ofs_vertexcolor = 0; + vbo->ofs_lightdir = 0; + + vbo->stride_xyz = sizeof(verts[0].xyz); + vbo->stride_normal = sizeof(verts[0].normal); +#ifdef USE_VERT_TANGENT_SPACE + vbo->stride_tangent = sizeof(verts[0].tangent); + vbo->stride_bitangent = sizeof(verts[0].bitangent); +#endif + vbo->stride_vertexcolor = sizeof(verts[0].vertexColors); + vbo->stride_st = sizeof(verts[0].st); + vbo->stride_lightmap = sizeof(verts[0].lightmap); + vbo->stride_lightdir = sizeof(verts[0].lightdir); + + //ri.Printf(PRINT_ALL, "2CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, + //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); + + // xyz + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].xyz, sizeof(verts[i].xyz)); + dataOfs += sizeof(verts[i].xyz); + } + + // normal + if(stateBits & ATTR_NORMAL) + { + vbo->ofs_normal = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].normal, sizeof(verts[i].normal)); + dataOfs += sizeof(verts[i].normal); + } + } + +#ifdef USE_VERT_TANGENT_SPACE + // tangent + if(stateBits & ATTR_TANGENT) + { + vbo->ofs_tangent = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].tangent, sizeof(verts[i].tangent)); + dataOfs += sizeof(verts[i].tangent); + } + } + + // bitangent + if(stateBits & ATTR_BITANGENT) + { + vbo->ofs_bitangent = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].bitangent, sizeof(verts[i].bitangent)); + dataOfs += sizeof(verts[i].bitangent); + } + } +#endif + + // vertex texcoords + if(stateBits & ATTR_TEXCOORD) + { + vbo->ofs_st = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].st, sizeof(verts[i].st)); + dataOfs += sizeof(verts[i].st); + } + } + + // feed vertex lightmap texcoords + if(stateBits & ATTR_LIGHTCOORD) + { + vbo->ofs_lightmap = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].lightmap, sizeof(verts[i].lightmap)); + dataOfs += sizeof(verts[i].lightmap); + } + } + + // feed vertex colors + if(stateBits & ATTR_COLOR) + { + vbo->ofs_vertexcolor = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].vertexColors, sizeof(verts[i].vertexColors)); + dataOfs += sizeof(verts[i].vertexColors); + } + } + + // feed vertex lightdirs + if(stateBits & ATTR_LIGHTDIRECTION) + { + vbo->ofs_lightdir = dataOfs; + for (i = 0; i < numVertexes; i++) + { + memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir)); + dataOfs += sizeof(verts[i].lightdir); + } + } + } + + + vbo->vertexesSize = dataSize; + + qglGenBuffersARB(1, &vbo->vertexesVBO); + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); + qglBufferDataARB(GL_ARRAY_BUFFER_ARB, dataSize, data, glUsage); + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + + glState.currentVBO = NULL; + + GL_CheckErrors(); + + ri.Hunk_FreeTempMemory(data); + + return vbo; +} + + +/* +============ +R_CreateIBO +============ +*/ +IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, vboUsage_t usage) +{ + IBO_t *ibo; + int glUsage; + + switch (usage) + { + case VBO_USAGE_STATIC: + glUsage = GL_STATIC_DRAW_ARB; + break; + + case VBO_USAGE_DYNAMIC: + glUsage = GL_DYNAMIC_DRAW_ARB; + break; + + default: + Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); + return NULL; + } + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "R_CreateIBO: \"%s\" is too long", name); + } + + if ( tr.numIBOs == MAX_IBOS ) { + ri.Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); + } + + R_IssuePendingRenderCommands(); + + ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + tr.numIBOs++; + + Q_strncpyz(ibo->name, name, sizeof(ibo->name)); + + ibo->indexesSize = indexesSize; + + qglGenBuffersARB(1, &ibo->indexesVBO); + + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexesSize, indexes, glUsage); + + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + + glState.currentIBO = NULL; + + GL_CheckErrors(); + + return ibo; +} + +/* +============ +R_CreateIBO2 +============ +*/ +IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * triangles, vboUsage_t usage) +{ + IBO_t *ibo; + int i, j; + + byte *indexes; + int indexesSize; + int indexesOfs; + + srfTriangle_t *tri; + glIndex_t index; + int glUsage; + + switch (usage) + { + case VBO_USAGE_STATIC: + glUsage = GL_STATIC_DRAW_ARB; + break; + + case VBO_USAGE_DYNAMIC: + glUsage = GL_DYNAMIC_DRAW_ARB; + break; + + default: + Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); + return NULL; + } + + if(!numTriangles) + return NULL; + + if(strlen(name) >= MAX_QPATH) + { + ri.Error(ERR_DROP, "R_CreateIBO2: \"%s\" is too long", name); + } + + if ( tr.numIBOs == MAX_IBOS ) { + ri.Error( ERR_DROP, "R_CreateIBO2: MAX_IBOS hit"); + } + + R_IssuePendingRenderCommands(); + + ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + tr.numIBOs++; + + Q_strncpyz(ibo->name, name, sizeof(ibo->name)); + + indexesSize = numTriangles * 3 * sizeof(int); + indexes = ri.Hunk_AllocateTempMemory(indexesSize); + indexesOfs = 0; + + for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + index = tri->indexes[j]; + memcpy(indexes + indexesOfs, &index, sizeof(glIndex_t)); + indexesOfs += sizeof(glIndex_t); + } + } + + ibo->indexesSize = indexesSize; + + qglGenBuffersARB(1, &ibo->indexesVBO); + + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexesSize, indexes, glUsage); + + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + + glState.currentIBO = NULL; + + GL_CheckErrors(); + + ri.Hunk_FreeTempMemory(indexes); + + return ibo; +} + +/* +============ +R_BindVBO +============ +*/ +void R_BindVBO(VBO_t * vbo) +{ + if(!vbo) + { + //R_BindNullVBO(); + ri.Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); + return; + } + + if(r_logFile->integer) + { + // don't just call LogComment, or we will get a call to va() every frame! + GLimp_LogComment(va("--- R_BindVBO( %s ) ---\n", vbo->name)); + } + + if(glState.currentVBO != vbo) + { + glState.currentVBO = vbo; + glState.vertexAttribPointersSet = 0; + + glState.vertexAttribsInterpolation = 0; + glState.vertexAttribsOldFrame = 0; + glState.vertexAttribsNewFrame = 0; + + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); + + backEnd.pc.c_vboVertexBuffers++; + } +} + +/* +============ +R_BindNullVBO +============ +*/ +void R_BindNullVBO(void) +{ + GLimp_LogComment("--- R_BindNullVBO ---\n"); + + if(glState.currentVBO) + { + qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + glState.currentVBO = NULL; + } + + GL_CheckErrors(); +} + +/* +============ +R_BindIBO +============ +*/ +void R_BindIBO(IBO_t * ibo) +{ + if(!ibo) + { + //R_BindNullIBO(); + ri.Error(ERR_DROP, "R_BindIBO: NULL ibo"); + return; + } + + if(r_logFile->integer) + { + // don't just call LogComment, or we will get a call to va() every frame! + GLimp_LogComment(va("--- R_BindIBO( %s ) ---\n", ibo->name)); + } + + if(glState.currentIBO != ibo) + { + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); + + glState.currentIBO = ibo; + + backEnd.pc.c_vboIndexBuffers++; + } +} + +/* +============ +R_BindNullIBO +============ +*/ +void R_BindNullIBO(void) +{ + GLimp_LogComment("--- R_BindNullIBO ---\n"); + + if(glState.currentIBO) + { + qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + glState.currentIBO = NULL; + glState.vertexAttribPointersSet = 0; + } +} + +/* +============ +R_InitVBOs +============ +*/ +void R_InitVBOs(void) +{ + int dataSize; + int offset; + + ri.Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); + + tr.numVBOs = 0; + tr.numIBOs = 0; + + dataSize = sizeof(tess.xyz[0]); + dataSize += sizeof(tess.normal[0]); +#ifdef USE_VERT_TANGENT_SPACE + dataSize += sizeof(tess.tangent[0]); + dataSize += sizeof(tess.bitangent[0]); +#endif + dataSize += sizeof(tess.vertexColors[0]); + dataSize += sizeof(tess.texCoords[0][0]) * 2; + dataSize += sizeof(tess.lightdir[0]); + dataSize *= SHADER_MAX_VERTEXES; + + tess.vbo = R_CreateVBO("tessVertexArray_VBO", NULL, dataSize, VBO_USAGE_DYNAMIC); + + offset = 0; + + tess.vbo->ofs_xyz = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; + tess.vbo->ofs_normal = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; +#ifdef USE_VERT_TANGENT_SPACE + tess.vbo->ofs_tangent = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; + tess.vbo->ofs_bitangent = offset; offset += sizeof(tess.bitangent[0]) * SHADER_MAX_VERTEXES; +#endif + // these next two are actually interleaved + tess.vbo->ofs_st = offset; + tess.vbo->ofs_lightmap = offset + sizeof(tess.texCoords[0][0]); + offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; + + tess.vbo->ofs_vertexcolor = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES; + tess.vbo->ofs_lightdir = offset; + + tess.vbo->stride_xyz = sizeof(tess.xyz[0]); + tess.vbo->stride_normal = sizeof(tess.normal[0]); +#ifdef USE_VERT_TANGENT_SPACE + tess.vbo->stride_tangent = sizeof(tess.tangent[0]); + tess.vbo->stride_bitangent = sizeof(tess.bitangent[0]); +#endif + tess.vbo->stride_vertexcolor = sizeof(tess.vertexColors[0]); + tess.vbo->stride_st = sizeof(tess.texCoords[0][0]) * 2; + tess.vbo->stride_lightmap = sizeof(tess.texCoords[0][0]) * 2; + tess.vbo->stride_lightdir = sizeof(tess.lightdir[0]); + + dataSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; + + tess.ibo = R_CreateIBO("tessVertexArray_IBO", NULL, dataSize, VBO_USAGE_DYNAMIC); + + R_BindNullVBO(); + R_BindNullIBO(); + + GL_CheckErrors(); +} + +/* +============ +R_ShutdownVBOs +============ +*/ +void R_ShutdownVBOs(void) +{ + int i; + VBO_t *vbo; + IBO_t *ibo; + + ri.Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); + + R_BindNullVBO(); + R_BindNullIBO(); + + + for(i = 0; i < tr.numVBOs; i++) + { + vbo = tr.vbos[i]; + + if(vbo->vertexesVBO) + { + qglDeleteBuffersARB(1, &vbo->vertexesVBO); + } + + //ri.Free(vbo); + } + + for(i = 0; i < tr.numIBOs; i++) + { + ibo = tr.ibos[i]; + + if(ibo->indexesVBO) + { + qglDeleteBuffersARB(1, &ibo->indexesVBO); + } + + //ri.Free(ibo); + } + + tr.numVBOs = 0; + tr.numIBOs = 0; +} + +/* +============ +R_VBOList_f +============ +*/ +void R_VBOList_f(void) +{ + int i; + VBO_t *vbo; + IBO_t *ibo; + int vertexesSize = 0; + int indexesSize = 0; + + ri.Printf(PRINT_ALL, " size name\n"); + ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); + + for(i = 0; i < tr.numVBOs; i++) + { + vbo = tr.vbos[i]; + + ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", vbo->vertexesSize / (1024 * 1024), + (vbo->vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024), vbo->name); + + vertexesSize += vbo->vertexesSize; + } + + for(i = 0; i < tr.numIBOs; i++) + { + ibo = tr.ibos[i]; + + ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", ibo->indexesSize / (1024 * 1024), + (ibo->indexesSize % (1024 * 1024)) * 100 / (1024 * 1024), ibo->name); + + indexesSize += ibo->indexesSize; + } + + ri.Printf(PRINT_ALL, " %i total VBOs\n", tr.numVBOs); + ri.Printf(PRINT_ALL, " %d.%02d MB total vertices memory\n", vertexesSize / (1024 * 1024), + (vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); + + ri.Printf(PRINT_ALL, " %i total IBOs\n", tr.numIBOs); + ri.Printf(PRINT_ALL, " %d.%02d MB total triangle indices memory\n", indexesSize / (1024 * 1024), + (indexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); +} + + +/* +============== +RB_UpdateVBOs + +Adapted from Tess_UpdateVBOs from xreal + +Update the default VBO to replace the client side vertex arrays +============== +*/ +void RB_UpdateVBOs(unsigned int attribBits) +{ + GLimp_LogComment("--- RB_UpdateVBOs ---\n"); + + backEnd.pc.c_dynamicVboDraws++; + + // update the default VBO + if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) + { + R_BindVBO(tess.vbo); + + if(attribBits & ATTR_BITS) + { + if(attribBits & ATTR_POSITION) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); + } + + if(attribBits & ATTR_TEXCOORD || attribBits & ATTR_LIGHTCOORD) + { + // these are interleaved, so we update both if either need it + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); + } + + if(attribBits & ATTR_NORMAL) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); + } + +#ifdef USE_VERT_TANGENT_SPACE + if(attribBits & ATTR_TANGENT) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); + } + + if(attribBits & ATTR_BITANGENT) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0]), tess.bitangent); + } +#endif + + if(attribBits & ATTR_COLOR) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); + } + + if(attribBits & ATTR_LIGHTDIRECTION) + { + //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0])); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); + } + } + else + { + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); +#ifdef USE_VERT_TANGENT_SPACE + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0]), tess.bitangent); +#endif + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); + qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); + } + + } + + // update the default IBO + if(tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES) + { + R_BindIBO(tess.ibo); + + qglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); + } +} diff --git a/codemp/rd-rend2/tr_world.c b/codemp/rd-rend2/tr_world.c new file mode 100644 index 0000000000..ab447f8aa5 --- /dev/null +++ b/codemp/rd-rend2/tr_world.c @@ -0,0 +1,848 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +#include "tr_local.h" + + + +/* +================ +R_CullSurface + +Tries to cull surfaces before they are lighted or +added to the sorting list. +================ +*/ +static qboolean R_CullSurface( msurface_t *surf ) { + if ( r_nocull->integer || surf->cullinfo.type == CULLINFO_NONE) { + return qfalse; + } + + if (surf->cullinfo.type & CULLINFO_PLANE) + { + // Only true for SF_FACE, so treat like its own function + float d; + cullType_t ct; + + if ( !r_facePlaneCull->integer ) { + return qfalse; + } + + ct = surf->shader->cullType; + + if (ct == CT_TWO_SIDED) + { + return qfalse; + } + + // don't cull for depth shadow + /* + if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) + { + return qfalse; + } + */ + + // shadowmaps draw back surfaces + if ( tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) ) + { + if (ct == CT_FRONT_SIDED) + { + ct = CT_BACK_SIDED; + } + else + { + ct = CT_FRONT_SIDED; + } + } + + // do proper cull for orthographic projection + if (tr.viewParms.flags & VPF_ORTHOGRAPHIC) { + d = DotProduct(tr.viewParms.or.axis[0], surf->cullinfo.plane.normal); + if ( ct == CT_FRONT_SIDED ) { + if (d > 0) + return qtrue; + } else { + if (d < 0) + return qtrue; + } + return qfalse; + } + + d = DotProduct (tr.or.viewOrigin, surf->cullinfo.plane.normal); + + // don't cull exactly on the plane, because there are levels of rounding + // through the BSP, ICD, and hardware that may cause pixel gaps if an + // epsilon isn't allowed here + if ( ct == CT_FRONT_SIDED ) { + if ( d < surf->cullinfo.plane.dist - 8 ) { + return qtrue; + } + } else { + if ( d > surf->cullinfo.plane.dist + 8 ) { + return qtrue; + } + } + + return qfalse; + } + + if (surf->cullinfo.type & CULLINFO_SPHERE) + { + int sphereCull; + + if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { + sphereCull = R_CullLocalPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); + } else { + sphereCull = R_CullPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); + } + + if ( sphereCull == CULL_OUT ) + { + return qtrue; + } + } + + if (surf->cullinfo.type & CULLINFO_BOX) + { + int boxCull; + + if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { + boxCull = R_CullLocalBox( surf->cullinfo.bounds ); + } else { + boxCull = R_CullBox( surf->cullinfo.bounds ); + } + + if ( boxCull == CULL_OUT ) + { + return qtrue; + } + } + + return qfalse; +} + + +/* +==================== +R_DlightSurface + +The given surface is going to be drawn, and it touches a leaf +that is touched by one or more dlights, so try to throw out +more dlights if possible. +==================== +*/ +static int R_DlightSurface( msurface_t *surf, int dlightBits ) { + float d; + int i; + dlight_t *dl; + + if ( surf->cullinfo.type & CULLINFO_PLANE ) + { + for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { + if ( ! ( dlightBits & ( 1 << i ) ) ) { + continue; + } + dl = &tr.refdef.dlights[i]; + d = DotProduct( dl->origin, surf->cullinfo.plane.normal ) - surf->cullinfo.plane.dist; + if ( d < -dl->radius || d > dl->radius ) { + // dlight doesn't reach the plane + dlightBits &= ~( 1 << i ); + } + } + } + + if ( surf->cullinfo.type & CULLINFO_BOX ) + { + for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { + if ( ! ( dlightBits & ( 1 << i ) ) ) { + continue; + } + dl = &tr.refdef.dlights[i]; + if ( dl->origin[0] - dl->radius > surf->cullinfo.bounds[1][0] + || dl->origin[0] + dl->radius < surf->cullinfo.bounds[0][0] + || dl->origin[1] - dl->radius > surf->cullinfo.bounds[1][1] + || dl->origin[1] + dl->radius < surf->cullinfo.bounds[0][1] + || dl->origin[2] - dl->radius > surf->cullinfo.bounds[1][2] + || dl->origin[2] + dl->radius < surf->cullinfo.bounds[0][2] ) { + // dlight doesn't reach the bounds + dlightBits &= ~( 1 << i ); + } + } + } + + if ( surf->cullinfo.type & CULLINFO_SPHERE ) + { + for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { + if ( ! ( dlightBits & ( 1 << i ) ) ) { + continue; + } + dl = &tr.refdef.dlights[i]; + if (!SpheresIntersect(dl->origin, dl->radius, surf->cullinfo.localOrigin, surf->cullinfo.radius)) + { + // dlight doesn't reach the bounds + dlightBits &= ~( 1 << i ); + } + } + } + + if ( *surf->data == SF_FACE ) { + ((srfSurfaceFace_t *)surf->data)->dlightBits = dlightBits; + } else if ( *surf->data == SF_GRID ) { + ((srfGridMesh_t *)surf->data)->dlightBits = dlightBits; + } else if ( *surf->data == SF_TRIANGLES ) { + ((srfTriangles_t *)surf->data)->dlightBits = dlightBits; + } else if ( *surf->data == SF_VBO_MESH ) { + ((srfVBOMesh_t *)surf->data)->dlightBits = dlightBits; + } else { + dlightBits = 0; + } + + if ( dlightBits ) { + tr.pc.c_dlightSurfaces++; + } + + return dlightBits; +} + +/* +==================== +R_PshadowSurface + +Just like R_DlightSurface, cull any we can +==================== +*/ +static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { + float d; + int i; + pshadow_t *ps; + + if ( surf->cullinfo.type & CULLINFO_PLANE ) + { + for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { + if ( ! ( pshadowBits & ( 1 << i ) ) ) { + continue; + } + ps = &tr.refdef.pshadows[i]; + d = DotProduct( ps->lightOrigin, surf->cullinfo.plane.normal ) - surf->cullinfo.plane.dist; + if ( d < -ps->lightRadius || d > ps->lightRadius ) { + // pshadow doesn't reach the plane + pshadowBits &= ~( 1 << i ); + } + } + } + + if ( surf->cullinfo.type & CULLINFO_BOX ) + { + for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { + if ( ! ( pshadowBits & ( 1 << i ) ) ) { + continue; + } + ps = &tr.refdef.pshadows[i]; + if ( ps->lightOrigin[0] - ps->lightRadius > surf->cullinfo.bounds[1][0] + || ps->lightOrigin[0] + ps->lightRadius < surf->cullinfo.bounds[0][0] + || ps->lightOrigin[1] - ps->lightRadius > surf->cullinfo.bounds[1][1] + || ps->lightOrigin[1] + ps->lightRadius < surf->cullinfo.bounds[0][1] + || ps->lightOrigin[2] - ps->lightRadius > surf->cullinfo.bounds[1][2] + || ps->lightOrigin[2] + ps->lightRadius < surf->cullinfo.bounds[0][2] + || BoxOnPlaneSide(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1], &ps->cullPlane) == 2 ) { + // pshadow doesn't reach the bounds + pshadowBits &= ~( 1 << i ); + } + } + } + + if ( surf->cullinfo.type & CULLINFO_SPHERE ) + { + for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { + if ( ! ( pshadowBits & ( 1 << i ) ) ) { + continue; + } + ps = &tr.refdef.pshadows[i]; + if (!SpheresIntersect(ps->viewOrigin, ps->viewRadius, surf->cullinfo.localOrigin, surf->cullinfo.radius) + || DotProduct( surf->cullinfo.localOrigin, ps->cullPlane.normal ) - ps->cullPlane.dist < -surf->cullinfo.radius) + { + // pshadow doesn't reach the bounds + pshadowBits &= ~( 1 << i ); + } + } + } + + if ( *surf->data == SF_FACE ) { + ((srfSurfaceFace_t *)surf->data)->pshadowBits = pshadowBits; + } else if ( *surf->data == SF_GRID ) { + ((srfGridMesh_t *)surf->data)->pshadowBits = pshadowBits; + } else if ( *surf->data == SF_TRIANGLES ) { + ((srfTriangles_t *)surf->data)->pshadowBits = pshadowBits; + } else if ( *surf->data == SF_VBO_MESH ) { + ((srfVBOMesh_t *)surf->data)->pshadowBits = pshadowBits; + } else { + pshadowBits = 0; + } + + if ( pshadowBits ) { + //tr.pc.c_dlightSurfaces++; + } + + return pshadowBits; +} + + +/* +====================== +R_AddWorldSurface +====================== +*/ +static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits ) { + // FIXME: bmodel fog? + + // try to cull before dlighting or adding + if ( R_CullSurface( surf ) ) { + return; + } + + // check for dlighting + if ( dlightBits ) { + dlightBits = R_DlightSurface( surf, dlightBits ); + dlightBits = ( dlightBits != 0 ); + } + + // check for pshadows + /*if ( pshadowBits ) */{ + pshadowBits = R_PshadowSurface( surf, pshadowBits); + pshadowBits = ( pshadowBits != 0 ); + } + + R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, pshadowBits ); +} + +/* +============================================================= + + BRUSH MODELS + +============================================================= +*/ + +/* +================= +R_AddBrushModelSurfaces +================= +*/ +void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { + bmodel_t *bmodel; + int clip; + model_t *pModel; + int i; + + pModel = R_GetModelByHandle( ent->e.hModel ); + + bmodel = pModel->bmodel; + + clip = R_CullLocalBox( bmodel->bounds ); + if ( clip == CULL_OUT ) { + return; + } + + R_SetupEntityLighting( &tr.refdef, ent ); + R_DlightBmodel( bmodel ); + + for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { + int surf = bmodel->firstSurface + i; + + if (tr.world->surfacesViewCount[surf] != tr.viewCount) + { + tr.world->surfacesViewCount[surf] = tr.viewCount; + R_AddWorldSurface( tr.world->surfaces + surf, tr.currentEntity->needDlights, 0 ); + } + } +} + + +/* +============================================================= + + WORLD MODEL + +============================================================= +*/ + + +/* +================ +R_RecursiveWorldNode +================ +*/ +static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) { + + do { + int newDlights[2]; + unsigned int newPShadows[2]; + + // if the node wasn't marked as potentially visible, exit + // pvs is skipped for depth shadows + if (!(tr.viewParms.flags & VPF_DEPTHSHADOW) && node->visCounts[tr.visIndex] != tr.visCounts[tr.visIndex]) { + return; + } + + // if the bounding volume is outside the frustum, nothing + // inside can be visible OPTIMIZE: don't do this all the way to leafs? + + if ( !r_nocull->integer ) { + int r; + + if ( planeBits & 1 ) { + r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[0]); + if (r == 2) { + return; // culled + } + if ( r == 1 ) { + planeBits &= ~1; // all descendants will also be in front + } + } + + if ( planeBits & 2 ) { + r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[1]); + if (r == 2) { + return; // culled + } + if ( r == 1 ) { + planeBits &= ~2; // all descendants will also be in front + } + } + + if ( planeBits & 4 ) { + r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[2]); + if (r == 2) { + return; // culled + } + if ( r == 1 ) { + planeBits &= ~4; // all descendants will also be in front + } + } + + if ( planeBits & 8 ) { + r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[3]); + if (r == 2) { + return; // culled + } + if ( r == 1 ) { + planeBits &= ~8; // all descendants will also be in front + } + } + + if ( planeBits & 16 ) { + r = BoxOnPlaneSide(node->mins, node->maxs, &tr.viewParms.frustum[4]); + if (r == 2) { + return; // culled + } + if ( r == 1 ) { + planeBits &= ~16; // all descendants will also be in front + } + } + } + + if ( node->contents != -1 ) { + break; + } + + // node is just a decision point, so go down both sides + // since we don't care about sort orders, just go positive to negative + + // determine which dlights are needed + newDlights[0] = 0; + newDlights[1] = 0; + if ( dlightBits ) { + int i; + + for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { + dlight_t *dl; + float dist; + + if ( dlightBits & ( 1 << i ) ) { + dl = &tr.refdef.dlights[i]; + dist = DotProduct( dl->origin, node->plane->normal ) - node->plane->dist; + + if ( dist > -dl->radius ) { + newDlights[0] |= ( 1 << i ); + } + if ( dist < dl->radius ) { + newDlights[1] |= ( 1 << i ); + } + } + } + } + + newPShadows[0] = 0; + newPShadows[1] = 0; + if ( pshadowBits ) { + int i; + + for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { + pshadow_t *shadow; + float dist; + + if ( pshadowBits & ( 1 << i ) ) { + shadow = &tr.refdef.pshadows[i]; + dist = DotProduct( shadow->lightOrigin, node->plane->normal ) - node->plane->dist; + + if ( dist > -shadow->lightRadius ) { + newPShadows[0] |= ( 1 << i ); + } + if ( dist < shadow->lightRadius ) { + newPShadows[1] |= ( 1 << i ); + } + } + } + } + + // recurse down the children, front side first + R_RecursiveWorldNode (node->children[0], planeBits, newDlights[0], newPShadows[0] ); + + // tail recurse + node = node->children[1]; + dlightBits = newDlights[1]; + pshadowBits = newPShadows[1]; + } while ( 1 ); + + { + // leaf node, so add mark surfaces + int c; + int surf, *view; + + tr.pc.c_leafs++; + + // add to z buffer bounds + if ( node->mins[0] < tr.viewParms.visBounds[0][0] ) { + tr.viewParms.visBounds[0][0] = node->mins[0]; + } + if ( node->mins[1] < tr.viewParms.visBounds[0][1] ) { + tr.viewParms.visBounds[0][1] = node->mins[1]; + } + if ( node->mins[2] < tr.viewParms.visBounds[0][2] ) { + tr.viewParms.visBounds[0][2] = node->mins[2]; + } + + if ( node->maxs[0] > tr.viewParms.visBounds[1][0] ) { + tr.viewParms.visBounds[1][0] = node->maxs[0]; + } + if ( node->maxs[1] > tr.viewParms.visBounds[1][1] ) { + tr.viewParms.visBounds[1][1] = node->maxs[1]; + } + if ( node->maxs[2] > tr.viewParms.visBounds[1][2] ) { + tr.viewParms.visBounds[1][2] = node->maxs[2]; + } + + // add merged and unmerged surfaces + if (tr.world->viewSurfaces) + view = tr.world->viewSurfaces + node->firstmarksurface; + else + view = tr.world->marksurfaces + node->firstmarksurface; + + c = node->nummarksurfaces; + while (c--) { + // just mark it as visible, so we don't jump out of the cache derefencing the surface + surf = *view; + if (surf < 0) + { + if (tr.world->mergedSurfacesViewCount[-surf - 1] != tr.viewCount) + { + tr.world->mergedSurfacesViewCount[-surf - 1] = tr.viewCount; + tr.world->mergedSurfacesDlightBits[-surf - 1] = dlightBits; + tr.world->mergedSurfacesPshadowBits[-surf - 1] = pshadowBits; + } + else + { + tr.world->mergedSurfacesDlightBits[-surf - 1] |= dlightBits; + tr.world->mergedSurfacesPshadowBits[-surf - 1] |= pshadowBits; + } + } + else + { + if (tr.world->surfacesViewCount[surf] != tr.viewCount) + { + tr.world->surfacesViewCount[surf] = tr.viewCount; + tr.world->surfacesDlightBits[surf] = dlightBits; + tr.world->surfacesPshadowBits[surf] = pshadowBits; + } + else + { + tr.world->surfacesDlightBits[surf] |= dlightBits; + tr.world->surfacesPshadowBits[surf] |= pshadowBits; + } + } + view++; + } + } + +} + + +/* +=============== +R_PointInLeaf +=============== +*/ +static mnode_t *R_PointInLeaf( const vec3_t p ) { + mnode_t *node; + float d; + cplane_t *plane; + + if ( !tr.world ) { + ri.Error (ERR_DROP, "R_PointInLeaf: bad model"); + } + + node = tr.world->nodes; + while( 1 ) { + if (node->contents != -1) { + break; + } + plane = node->plane; + d = DotProduct (p,plane->normal) - plane->dist; + if (d > 0) { + node = node->children[0]; + } else { + node = node->children[1]; + } + } + + return node; +} + +/* +============== +R_ClusterPVS +============== +*/ +static const byte *R_ClusterPVS (int cluster) { + if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { + return tr.world->novis; + } + + return tr.world->vis + cluster * tr.world->clusterBytes; +} + +/* +================= +R_inPVS +================= +*/ +qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) { + mnode_t *leaf; + byte *vis; + + leaf = R_PointInLeaf( p1 ); + vis = ri.CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? + leaf = R_PointInLeaf( p2 ); + + if ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) { + return qfalse; + } + return qtrue; +} + +/* +=============== +R_MarkLeaves + +Mark the leaves and nodes that are in the PVS for the current +cluster +=============== +*/ +static void R_MarkLeaves (void) { + const byte *vis; + mnode_t *leaf, *parent; + int i; + int cluster; + + // lockpvs lets designers walk around to determine the + // extent of the current pvs + if ( r_lockpvs->integer ) { + return; + } + + // current viewcluster + leaf = R_PointInLeaf( tr.viewParms.pvsOrigin ); + cluster = leaf->cluster; + + // if the cluster is the same and the area visibility matrix + // hasn't changed, we don't need to mark everything again + + for(i = 0; i < MAX_VISCOUNTS; i++) + { + if(tr.visClusters[i] == cluster) + { + //tr.visIndex = i; + break; + } + } + + // if r_showcluster was just turned on, remark everything + if(i != MAX_VISCOUNTS && !tr.refdef.areamaskModified && !r_showcluster->modified)// && !r_dynamicBspOcclusionCulling->modified) + { + if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + { + ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + } + tr.visIndex = i; + return; + } + + // if the areamask was modified, invalidate all visclusters + // this caused doors to open into undrawn areas + if (tr.refdef.areamaskModified) + { + memset(tr.visClusters, -2, sizeof(tr.visClusters)); + } + + tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS; + tr.visCounts[tr.visIndex]++; + tr.visClusters[tr.visIndex] = cluster; + + if ( r_showcluster->modified || r_showcluster->integer ) { + r_showcluster->modified = qfalse; + if ( r_showcluster->integer ) { + ri.Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); + } + } + + // set all nodes to visible if there is no vis + // this caused some levels to simply not render + if (r_novis->integer || !tr.world->vis || tr.visClusters[tr.visIndex] == -1) { + for (i=0 ; inumnodes ; i++) { + if (tr.world->nodes[i].contents != CONTENTS_SOLID) { + tr.world->nodes[i].visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; + } + } + return; + } + + vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); + + for (i=0,leaf=tr.world->nodes ; inumnodes ; i++, leaf++) { + cluster = leaf->cluster; + if ( cluster < 0 || cluster >= tr.world->numClusters ) { + continue; + } + + // check general pvs + if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) { + continue; + } + + // check for door connection + if ( (tr.refdef.areamask[leaf->area>>3] & (1<<(leaf->area&7)) ) ) { + continue; // not visible + } + + parent = leaf; + do { + if(parent->visCounts[tr.visIndex] == tr.visCounts[tr.visIndex]) + break; + parent->visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; + parent = parent->parent; + } while (parent); + } +} + + +/* +============= +R_AddWorldSurfaces +============= +*/ +void R_AddWorldSurfaces (void) { + int planeBits, dlightBits, pshadowBits; + + if ( !r_drawworld->integer ) { + return; + } + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return; + } + + tr.currentEntityNum = REFENTITYNUM_WORLD; + tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; + + // determine which leaves are in the PVS / areamask + if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) + R_MarkLeaves (); + + // clear out the visible min/max + ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); + + // perform frustum culling and flag all the potentially visible surfaces + if ( tr.refdef.num_dlights > 32 ) { + tr.refdef.num_dlights = 32 ; + } + + if ( tr.refdef.num_pshadows > 32 ) { + tr.refdef.num_pshadows = 32 ; + } + + planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + + if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) + { + dlightBits = 0; + pshadowBits = 0; + } + else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) + { + dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1; + } + else + { + dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + pshadowBits = 0; + } + + R_RecursiveWorldNode( tr.world->nodes, planeBits, dlightBits, pshadowBits); + + // now add all the potentially visible surfaces + // also mask invisible dlights for next frame + { + int i; + + tr.refdef.dlightMask = 0; + + for (i = 0; i < tr.world->numWorldSurfaces; i++) + { + if (tr.world->surfacesViewCount[i] != tr.viewCount) + continue; + + R_AddWorldSurface( tr.world->surfaces + i, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i] ); + tr.refdef.dlightMask |= tr.world->surfacesDlightBits[i]; + } + for (i = 0; i < tr.world->numMergedSurfaces; i++) + { + if (tr.world->mergedSurfacesViewCount[i] != tr.viewCount) + continue; + + R_AddWorldSurface( tr.world->mergedSurfaces + i, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i] ); + tr.refdef.dlightMask |= tr.world->mergedSurfacesDlightBits[i]; + } + + tr.refdef.dlightMask = ~tr.refdef.dlightMask; + } +} From be06f7907494174027a3113859d824d951739db0 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:22:18 -0400 Subject: [PATCH 002/708] Renamed everything in rd-rend2 to use .cpp extension instead of .c extension. --- codemp/rd-rend2/{tr_animation.c => tr_animation.cpp} | 0 codemp/rd-rend2/{tr_backend.c => tr_backend.cpp} | 0 codemp/rd-rend2/{tr_bsp.c => tr_bsp.cpp} | 0 codemp/rd-rend2/{tr_cmds.c => tr_cmds.cpp} | 0 codemp/rd-rend2/{tr_curve.c => tr_curve.cpp} | 0 codemp/rd-rend2/{tr_extensions.c => tr_extensions.cpp} | 0 codemp/rd-rend2/{tr_extramath.c => tr_extramath.cpp} | 0 codemp/rd-rend2/{tr_fbo.c => tr_fbo.cpp} | 0 codemp/rd-rend2/{tr_flares.c => tr_flares.cpp} | 0 codemp/rd-rend2/{tr_glsl.c => tr_glsl.cpp} | 0 codemp/rd-rend2/{tr_image.c => tr_image.cpp} | 0 codemp/rd-rend2/{tr_init.c => tr_init.cpp} | 0 codemp/rd-rend2/{tr_light.c => tr_light.cpp} | 0 codemp/rd-rend2/{tr_main.c => tr_main.cpp} | 0 codemp/rd-rend2/{tr_marks.c => tr_marks.cpp} | 0 codemp/rd-rend2/{tr_mesh.c => tr_mesh.cpp} | 0 codemp/rd-rend2/{tr_model.c => tr_model.cpp} | 0 codemp/rd-rend2/{tr_model_iqm.c => tr_model_iqm.cpp} | 0 codemp/rd-rend2/{tr_postprocess.c => tr_postprocess.cpp} | 0 codemp/rd-rend2/{tr_scene.c => tr_scene.cpp} | 0 codemp/rd-rend2/{tr_shade.c => tr_shade.cpp} | 0 codemp/rd-rend2/{tr_shade_calc.c => tr_shade_calc.cpp} | 0 codemp/rd-rend2/{tr_shader.c => tr_shader.cpp} | 0 codemp/rd-rend2/{tr_shadows.c => tr_shadows.cpp} | 0 codemp/rd-rend2/{tr_sky.c => tr_sky.cpp} | 0 codemp/rd-rend2/{tr_subs.c => tr_subs.cpp} | 0 codemp/rd-rend2/{tr_surface.c => tr_surface.cpp} | 0 codemp/rd-rend2/{tr_vbo.c => tr_vbo.cpp} | 0 codemp/rd-rend2/{tr_world.c => tr_world.cpp} | 0 29 files changed, 0 insertions(+), 0 deletions(-) rename codemp/rd-rend2/{tr_animation.c => tr_animation.cpp} (100%) rename codemp/rd-rend2/{tr_backend.c => tr_backend.cpp} (100%) rename codemp/rd-rend2/{tr_bsp.c => tr_bsp.cpp} (100%) rename codemp/rd-rend2/{tr_cmds.c => tr_cmds.cpp} (100%) rename codemp/rd-rend2/{tr_curve.c => tr_curve.cpp} (100%) rename codemp/rd-rend2/{tr_extensions.c => tr_extensions.cpp} (100%) rename codemp/rd-rend2/{tr_extramath.c => tr_extramath.cpp} (100%) rename codemp/rd-rend2/{tr_fbo.c => tr_fbo.cpp} (100%) rename codemp/rd-rend2/{tr_flares.c => tr_flares.cpp} (100%) rename codemp/rd-rend2/{tr_glsl.c => tr_glsl.cpp} (100%) rename codemp/rd-rend2/{tr_image.c => tr_image.cpp} (100%) rename codemp/rd-rend2/{tr_init.c => tr_init.cpp} (100%) rename codemp/rd-rend2/{tr_light.c => tr_light.cpp} (100%) rename codemp/rd-rend2/{tr_main.c => tr_main.cpp} (100%) rename codemp/rd-rend2/{tr_marks.c => tr_marks.cpp} (100%) rename codemp/rd-rend2/{tr_mesh.c => tr_mesh.cpp} (100%) rename codemp/rd-rend2/{tr_model.c => tr_model.cpp} (100%) rename codemp/rd-rend2/{tr_model_iqm.c => tr_model_iqm.cpp} (100%) rename codemp/rd-rend2/{tr_postprocess.c => tr_postprocess.cpp} (100%) rename codemp/rd-rend2/{tr_scene.c => tr_scene.cpp} (100%) rename codemp/rd-rend2/{tr_shade.c => tr_shade.cpp} (100%) rename codemp/rd-rend2/{tr_shade_calc.c => tr_shade_calc.cpp} (100%) rename codemp/rd-rend2/{tr_shader.c => tr_shader.cpp} (100%) rename codemp/rd-rend2/{tr_shadows.c => tr_shadows.cpp} (100%) rename codemp/rd-rend2/{tr_sky.c => tr_sky.cpp} (100%) rename codemp/rd-rend2/{tr_subs.c => tr_subs.cpp} (100%) rename codemp/rd-rend2/{tr_surface.c => tr_surface.cpp} (100%) rename codemp/rd-rend2/{tr_vbo.c => tr_vbo.cpp} (100%) rename codemp/rd-rend2/{tr_world.c => tr_world.cpp} (100%) diff --git a/codemp/rd-rend2/tr_animation.c b/codemp/rd-rend2/tr_animation.cpp similarity index 100% rename from codemp/rd-rend2/tr_animation.c rename to codemp/rd-rend2/tr_animation.cpp diff --git a/codemp/rd-rend2/tr_backend.c b/codemp/rd-rend2/tr_backend.cpp similarity index 100% rename from codemp/rd-rend2/tr_backend.c rename to codemp/rd-rend2/tr_backend.cpp diff --git a/codemp/rd-rend2/tr_bsp.c b/codemp/rd-rend2/tr_bsp.cpp similarity index 100% rename from codemp/rd-rend2/tr_bsp.c rename to codemp/rd-rend2/tr_bsp.cpp diff --git a/codemp/rd-rend2/tr_cmds.c b/codemp/rd-rend2/tr_cmds.cpp similarity index 100% rename from codemp/rd-rend2/tr_cmds.c rename to codemp/rd-rend2/tr_cmds.cpp diff --git a/codemp/rd-rend2/tr_curve.c b/codemp/rd-rend2/tr_curve.cpp similarity index 100% rename from codemp/rd-rend2/tr_curve.c rename to codemp/rd-rend2/tr_curve.cpp diff --git a/codemp/rd-rend2/tr_extensions.c b/codemp/rd-rend2/tr_extensions.cpp similarity index 100% rename from codemp/rd-rend2/tr_extensions.c rename to codemp/rd-rend2/tr_extensions.cpp diff --git a/codemp/rd-rend2/tr_extramath.c b/codemp/rd-rend2/tr_extramath.cpp similarity index 100% rename from codemp/rd-rend2/tr_extramath.c rename to codemp/rd-rend2/tr_extramath.cpp diff --git a/codemp/rd-rend2/tr_fbo.c b/codemp/rd-rend2/tr_fbo.cpp similarity index 100% rename from codemp/rd-rend2/tr_fbo.c rename to codemp/rd-rend2/tr_fbo.cpp diff --git a/codemp/rd-rend2/tr_flares.c b/codemp/rd-rend2/tr_flares.cpp similarity index 100% rename from codemp/rd-rend2/tr_flares.c rename to codemp/rd-rend2/tr_flares.cpp diff --git a/codemp/rd-rend2/tr_glsl.c b/codemp/rd-rend2/tr_glsl.cpp similarity index 100% rename from codemp/rd-rend2/tr_glsl.c rename to codemp/rd-rend2/tr_glsl.cpp diff --git a/codemp/rd-rend2/tr_image.c b/codemp/rd-rend2/tr_image.cpp similarity index 100% rename from codemp/rd-rend2/tr_image.c rename to codemp/rd-rend2/tr_image.cpp diff --git a/codemp/rd-rend2/tr_init.c b/codemp/rd-rend2/tr_init.cpp similarity index 100% rename from codemp/rd-rend2/tr_init.c rename to codemp/rd-rend2/tr_init.cpp diff --git a/codemp/rd-rend2/tr_light.c b/codemp/rd-rend2/tr_light.cpp similarity index 100% rename from codemp/rd-rend2/tr_light.c rename to codemp/rd-rend2/tr_light.cpp diff --git a/codemp/rd-rend2/tr_main.c b/codemp/rd-rend2/tr_main.cpp similarity index 100% rename from codemp/rd-rend2/tr_main.c rename to codemp/rd-rend2/tr_main.cpp diff --git a/codemp/rd-rend2/tr_marks.c b/codemp/rd-rend2/tr_marks.cpp similarity index 100% rename from codemp/rd-rend2/tr_marks.c rename to codemp/rd-rend2/tr_marks.cpp diff --git a/codemp/rd-rend2/tr_mesh.c b/codemp/rd-rend2/tr_mesh.cpp similarity index 100% rename from codemp/rd-rend2/tr_mesh.c rename to codemp/rd-rend2/tr_mesh.cpp diff --git a/codemp/rd-rend2/tr_model.c b/codemp/rd-rend2/tr_model.cpp similarity index 100% rename from codemp/rd-rend2/tr_model.c rename to codemp/rd-rend2/tr_model.cpp diff --git a/codemp/rd-rend2/tr_model_iqm.c b/codemp/rd-rend2/tr_model_iqm.cpp similarity index 100% rename from codemp/rd-rend2/tr_model_iqm.c rename to codemp/rd-rend2/tr_model_iqm.cpp diff --git a/codemp/rd-rend2/tr_postprocess.c b/codemp/rd-rend2/tr_postprocess.cpp similarity index 100% rename from codemp/rd-rend2/tr_postprocess.c rename to codemp/rd-rend2/tr_postprocess.cpp diff --git a/codemp/rd-rend2/tr_scene.c b/codemp/rd-rend2/tr_scene.cpp similarity index 100% rename from codemp/rd-rend2/tr_scene.c rename to codemp/rd-rend2/tr_scene.cpp diff --git a/codemp/rd-rend2/tr_shade.c b/codemp/rd-rend2/tr_shade.cpp similarity index 100% rename from codemp/rd-rend2/tr_shade.c rename to codemp/rd-rend2/tr_shade.cpp diff --git a/codemp/rd-rend2/tr_shade_calc.c b/codemp/rd-rend2/tr_shade_calc.cpp similarity index 100% rename from codemp/rd-rend2/tr_shade_calc.c rename to codemp/rd-rend2/tr_shade_calc.cpp diff --git a/codemp/rd-rend2/tr_shader.c b/codemp/rd-rend2/tr_shader.cpp similarity index 100% rename from codemp/rd-rend2/tr_shader.c rename to codemp/rd-rend2/tr_shader.cpp diff --git a/codemp/rd-rend2/tr_shadows.c b/codemp/rd-rend2/tr_shadows.cpp similarity index 100% rename from codemp/rd-rend2/tr_shadows.c rename to codemp/rd-rend2/tr_shadows.cpp diff --git a/codemp/rd-rend2/tr_sky.c b/codemp/rd-rend2/tr_sky.cpp similarity index 100% rename from codemp/rd-rend2/tr_sky.c rename to codemp/rd-rend2/tr_sky.cpp diff --git a/codemp/rd-rend2/tr_subs.c b/codemp/rd-rend2/tr_subs.cpp similarity index 100% rename from codemp/rd-rend2/tr_subs.c rename to codemp/rd-rend2/tr_subs.cpp diff --git a/codemp/rd-rend2/tr_surface.c b/codemp/rd-rend2/tr_surface.cpp similarity index 100% rename from codemp/rd-rend2/tr_surface.c rename to codemp/rd-rend2/tr_surface.cpp diff --git a/codemp/rd-rend2/tr_vbo.c b/codemp/rd-rend2/tr_vbo.cpp similarity index 100% rename from codemp/rd-rend2/tr_vbo.c rename to codemp/rd-rend2/tr_vbo.cpp diff --git a/codemp/rd-rend2/tr_world.c b/codemp/rd-rend2/tr_world.cpp similarity index 100% rename from codemp/rd-rend2/tr_world.c rename to codemp/rd-rend2/tr_world.cpp From 52ff93923ec89f1830acda3a234ac1c60b75d63a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:38:04 -0400 Subject: [PATCH 003/708] Some basic fixes to rd-rend2 --- codemp/rd-rend2/G2_API.cpp | 2755 +++++++++++++++++ codemp/rd-rend2/G2_bolts.cpp | 311 ++ codemp/rd-rend2/G2_bones.cpp | 4865 +++++++++++++++++++++++++++++++ codemp/rd-rend2/G2_local.h | 207 ++ codemp/rd-rend2/G2_misc.cpp | 1915 ++++++++++++ codemp/rd-rend2/G2_surfaces.cpp | 663 +++++ codemp/rd-rend2/iqm.h | 129 + codemp/rd-rend2/qgl.h | 756 +++++ codemp/rd-rend2/tr_local.h | 8 +- 9 files changed, 11605 insertions(+), 4 deletions(-) create mode 100644 codemp/rd-rend2/G2_API.cpp create mode 100644 codemp/rd-rend2/G2_bolts.cpp create mode 100644 codemp/rd-rend2/G2_bones.cpp create mode 100644 codemp/rd-rend2/G2_local.h create mode 100644 codemp/rd-rend2/G2_misc.cpp create mode 100644 codemp/rd-rend2/G2_surfaces.cpp create mode 100644 codemp/rd-rend2/iqm.h create mode 100644 codemp/rd-rend2/qgl.h diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp new file mode 100644 index 0000000000..89c8c77173 --- /dev/null +++ b/codemp/rd-rend2/G2_API.cpp @@ -0,0 +1,2755 @@ +#include "ghoul2/G2.h" +#include "G2_local.h" +#include "qcommon/MiniHeap.h" + +//rww - RAGDOLL_BEGIN +#include "ghoul2/G2_gore.h" +//rww - RAGDOLL_END + +#include + +#ifdef _MSC_VER +#pragma warning (push, 3) //go back down to 3 for the stl include +#endif +#include +#ifdef _MSC_VER +#pragma warning (pop) +#endif + +#ifdef _FULL_G2_LEAK_CHECKING +int g_Ghoul2Allocations = 0; +int g_G2ServerAlloc = 0; +int g_G2ClientAlloc = 0; +int g_G2AllocServer = 0; + +//stupid debug crap to track leaks in case they happen. +//we used to shove everything into a map and delete it all and not care about +//leaks, but that was not the Right Thing. -rww +#define MAX_TRACKED_ALLOC 4096 +static bool g_G2AllocTrackInit = false; //want to keep this thing contained +static CGhoul2Info_v *g_G2AllocTrack[MAX_TRACKED_ALLOC]; + +void G2_DEBUG_InitPtrTracker(void) +{ + memset(g_G2AllocTrack, 0, sizeof(g_G2AllocTrack)); + g_G2AllocTrackInit = true; +} + +void G2_DEBUG_ReportLeaks(void) +{ + int i = 0; + + if (!g_G2AllocTrackInit) + { + Com_Printf("g2 leak tracker was never initialized!\n"); + return; + } + + while (i < MAX_TRACKED_ALLOC) + { + if (g_G2AllocTrack[i]) + { + Com_Printf("Bad guy found in slot %i, attempting to access...", i); + CGhoul2Info_v &g2v = *g_G2AllocTrack[i]; + CGhoul2Info &g2 = g2v[0]; + + if (g2v.IsValid() && g2.mFileName && g2.mFileName[0]) + { + Com_Printf("Bad guy's filename is %s\n", g2.mFileName); + } + else + { + Com_Printf("He's not valid! BURN HIM!\n"); + } + } + i++; + } +} + +void G2_DEBUG_ShovePtrInTracker(CGhoul2Info_v *g2) +{ + int i = 0; + + if (!g_G2AllocTrackInit) + { + G2_DEBUG_InitPtrTracker(); + } + + if (!g_G2AllocTrackInit) + { + G2_DEBUG_InitPtrTracker(); + } + + while (i < MAX_TRACKED_ALLOC) + { + if (!g_G2AllocTrack[i]) + { + g_G2AllocTrack[i] = g2; + return; + } + i++; + } + + CGhoul2Info_v &g2v = *g2; + + if (g2v[0].currentModel && g2v[0].currentModel->name && g2v[0].currentModel->name[0]) + { + Com_Printf("%s could not be fit into g2 debug instance tracker.\n", g2v[0].currentModel->name); + } + else + { + Com_Printf("Crap g2 instance passed to instance tracker (in).\n"); + } +} + +void G2_DEBUG_RemovePtrFromTracker(CGhoul2Info_v *g2) +{ + int i = 0; + + if (!g_G2AllocTrackInit) + { + G2_DEBUG_InitPtrTracker(); + } + + while (i < MAX_TRACKED_ALLOC) + { + if (g_G2AllocTrack[i] == g2) + { + g_G2AllocTrack[i] = NULL; + return; + } + i++; + } + + CGhoul2Info_v &g2v = *g2; + + if (g2v[0].currentModel && g2v[0].currentModel->name && g2v[0].currentModel->name[0]) + { + Com_Printf("%s not in g2 debug instance tracker.\n", g2v[0].currentModel->name); + } + else + { + Com_Printf("Crap g2 instance passed to instance tracker (out).\n"); + } +} +#endif + +qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); +qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); +qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo); + +//rww - RAGDOLL_BEGIN +#define NUM_G2T_TIME (2) +static int G2TimeBases[NUM_G2T_TIME]; + +void G2API_SetTime(int currentTime,int clock) +{ + assert(clock>=0&&clockG2TimeBases[0]+200) + { + G2TimeBases[1]=0; // use server time instead + return; + } +#if G2_DEBUG_TIME + Com_Printf(" after c%6d s%6d\n",G2TimeBases[1],G2TimeBases[0]); +#endif +} + +int G2API_GetTime(int argTime) // this may or may not return arg depending on ghoul2_time cvar +{ + int ret=G2TimeBases[1]; + if ( !ret ) + { + ret = G2TimeBases[0]; + } + + return ret; +} +//rww - RAGDOLL_END + +//rww - Stuff to allow association of ghoul2 instances to entity numbers. +//This way, on listen servers when both the client and server are doing +//ghoul2 operations, we can copy relevant data off the client instance +//directly onto the server instance and slash the transforms and whatnot +//right in half. +#ifdef _G2_LISTEN_SERVER_OPT +CGhoul2Info_v *g2ClientAttachments[MAX_GENTITIES]; +#endif + +void G2API_AttachInstanceToEntNum(CGhoul2Info_v &ghoul2, int entityNum, qboolean server) +{ //Assign the pointers in the arrays +#ifdef _G2_LISTEN_SERVER_OPT + if (server) + { + ghoul2[0].entityNum = entityNum; + } + else + { + g2ClientAttachments[entityNum] = &ghoul2; + } +#endif +} + +void G2API_ClearAttachedInstance(int entityNum) +{ +#ifdef _G2_LISTEN_SERVER_OPT + g2ClientAttachments[entityNum] = NULL; +#endif +} + +void G2API_CleanEntAttachments(void) +{ +#ifdef _G2_LISTEN_SERVER_OPT + int i = 0; + + while (i < MAX_GENTITIES) + { + g2ClientAttachments[i] = NULL; + i++; + } +#endif +} + +#ifdef _G2_LISTEN_SERVER_OPT +void CopyBoneCache(CBoneCache *to, CBoneCache *from); +#endif + +qboolean G2API_OverrideServerWithClientData(CGhoul2Info *serverInstance) +{ +#ifndef _G2_LISTEN_SERVER_OPT + return qfalse; +#else + CGhoul2Info *clientInstance; + + if (ri->Cvar_VariableIntegerValue( "dedicated" )) + { //No client to get from! + return qfalse; + } + + if (!g2ClientAttachments[serverInstance->entityNum]) + { //No clientside instance is attached to this entity + return qfalse; + } + + CGhoul2Info_v &g2Ref = *g2ClientAttachments[serverInstance->entityNum]; + clientInstance = &g2Ref[0]; + + int frameNum = G2API_GetTime(0); + + if (clientInstance->mSkelFrameNum != frameNum) + { //it has to be constructed already + return qfalse; + } + + if (!clientInstance->mBoneCache) + { //that just won't do + return qfalse; + } + + //Just copy over the essentials + serverInstance->aHeader = clientInstance->aHeader; + serverInstance->animModel = clientInstance->animModel; + serverInstance->currentAnimModelSize = clientInstance->currentAnimModelSize; + serverInstance->currentModel = clientInstance->currentModel; + serverInstance->currentModelSize = clientInstance->currentModelSize; + serverInstance->mAnimFrameDefault = clientInstance->mAnimFrameDefault; + serverInstance->mModel = clientInstance->mModel; + serverInstance->mModelindex = clientInstance->mModelindex; + serverInstance->mSurfaceRoot = clientInstance->mSurfaceRoot; + serverInstance->mTransformedVertsArray = clientInstance->mTransformedVertsArray; + + if (!serverInstance->mBoneCache) + { //if this is the case.. I guess we can use the client one instead + serverInstance->mBoneCache = clientInstance->mBoneCache; + } + + //Copy the contents of the client cache over the contents of the server cache + if (serverInstance->mBoneCache != clientInstance->mBoneCache) + { + CopyBoneCache(serverInstance->mBoneCache, clientInstance->mBoneCache); + } + + serverInstance->mSkelFrameNum = clientInstance->mSkelFrameNum; + return qtrue; +#endif +} + +// must be a power of two +#define MAX_G2_MODELS (1024) +#define G2_MODEL_BITS (10) + +#define G2_INDEX_MASK (MAX_G2_MODELS-1) + +class Ghoul2InfoArray : public IGhoul2InfoArray +{ + vector mInfos[MAX_G2_MODELS]; + int mIds[MAX_G2_MODELS]; + list mFreeIndecies; + void DeleteLow(int idx) + { + for (size_t model=0; model< mInfos[idx].size(); model++) + { + if (mInfos[idx][model].mBoneCache) + { + RemoveBoneCache(mInfos[idx][model].mBoneCache); + mInfos[idx][model].mBoneCache=0; + } + } + + mInfos[idx].clear(); + + if ((mIds[idx]>>G2_MODEL_BITS)>(1<<(31-G2_MODEL_BITS))) + { + mIds[idx]=MAX_G2_MODELS+idx; //rollover reset id to minimum value + mFreeIndecies.push_back(idx); + } + else + { + mIds[idx]+=MAX_G2_MODELS; + mFreeIndecies.push_front(idx); + } + } +public: + Ghoul2InfoArray() + { + int i; + for (i=0;i::iterator j; + for (j=mFreeIndecies.begin();j!=mFreeIndecies.end();j++) + { + if (*j==i) + break; + } + if (j==mFreeIndecies.end()) + { + sprintf(mess,"Leaked Info idx=%d id=%d sz=%d\n", i, mIds[i], mInfos[i].size()); + OutputDebugString(mess); + if (mInfos[i].size()) + { + sprintf(mess,"%s\n", mInfos[i][0].mFileName); + OutputDebugString(mess); + } + } + } + } + else + { + OutputDebugString("No ghoul2 info slots leaked\n"); + } + } +#endif + int New() + { + if (mFreeIndecies.empty()) + { + assert(0); + Com_Error(ERR_FATAL, "Out of ghoul2 info slots"); + + } + // gonna pull from the front, doing a + int idx=*mFreeIndecies.begin(); + mFreeIndecies.erase(mFreeIndecies.begin()); + return mIds[idx]; + } + bool IsValid(int handle) const + { + if ( handle <= 0 ) + { + return false; + } + assert((handle&G2_INDEX_MASK)>=0&&(handle&G2_INDEX_MASK)=0&&(handle&G2_INDEX_MASK) &Get(int handle) + { + static vector null; + assert(handle>0); //null handle + assert((handle&G2_INDEX_MASK)>=0&&(handle&G2_INDEX_MASK)=MAX_G2_MODELS||mIds[handle&G2_INDEX_MASK]!=handle) + { + null.clear(); + return null; + } + return mInfos[handle&G2_INDEX_MASK]; + } + const vector &Get(int handle) const + { + assert(handle>0); + assert(mIds[handle&G2_INDEX_MASK]==handle); // not a valid handle, could be old or garbage + return mInfos[handle&G2_INDEX_MASK]; + } + +#if G2API_DEBUG + vector &GetDebug(int handle) + { + static vector null; + if (handle<=0||(handle&G2_INDEX_MASK)<0||(handle&G2_INDEX_MASK)>=MAX_G2_MODELS||mIds[handle&G2_INDEX_MASK]!=handle) + { + return *(vector *)0; // null reference, intentional + } + return mInfos[handle&G2_INDEX_MASK]; + } + void TestAllAnims() + { + int j; + for (j=0;j &ghoul2=mInfos[j]; + int i; + for (i=0; ientities[i].e.ghoul2 == *ghoul2Ptr) + { + char fName[MAX_QPATH]; + char mName[MAX_QPATH]; + + if (ghoul2[0].currentModel) + { + strcpy(mName, ghoul2[0].currentModel->name); + } + else + { + strcpy(mName, "NULL!"); + } + + if (ghoul2[0].mFileName && ghoul2[0].mFileName[0]) + { + strcpy(fName, ghoul2[0].mFileName); + } + else + { + strcpy(fName, "None?!"); + } + + Com_Printf("ERROR, GHOUL2 INSTANCE BEING REMOVED BELONGS TO A REFENTITY!\nThis is in caps because it's important. Tell Rich and save the following text.\n\n"); + Com_Printf("Ref num: %i\nModel: %s\nFilename: %s\n", i, mName, fName); + + R_SetRNumEntities(0); //avoid recursive error + Com_Error(ERR_DROP, "Write down or save this error message, show it to Rich\nRef num: %i\nModel: %s\nFilename: %s\n", i, mName, fName); + } + i++; + } +#endif + +#ifdef _G2_GORE + G2API_ClearSkinGore ( ghoul2 ); +#endif + + ghoul2.~CGhoul2Info_v(); + +#ifdef _FULL_G2_LEAK_CHECKING + if (g_G2AllocServer) + { + g_G2ServerAlloc -= sizeof(*ghoul2Ptr); + } + else + { + g_G2ClientAlloc -= sizeof(*ghoul2Ptr); + } + g_Ghoul2Allocations -= sizeof(*ghoul2Ptr); + G2_DEBUG_RemovePtrFromTracker(*ghoul2Ptr); +#endif + + delete *ghoul2Ptr; + *ghoul2Ptr = NULL; + } +} + +qboolean G2_ShouldRegisterServer(void) +{ + vm_t *currentVM = ri->GetCurrentVM(); + + if ( currentVM && currentVM->slot == VM_GAME ) + { + if ( ri->Cvar_VariableIntegerValue( "cl_running" ) && + ri->Com_TheHunkMarkHasBeenMade() && ShaderHashTableExists()) + { //if the hunk has been marked then we are now loading client assets so don't load on server. + return qfalse; + } + + return qtrue; + } + return qfalse; +} + +qhandle_t G2API_PrecacheGhoul2Model( const char *fileName ) +{ + if ( G2_ShouldRegisterServer() ) + return RE_RegisterServerModel( fileName ); + else + return RE_RegisterModel( fileName ); +} + +void CL_InitRef( void ); + +// initialise all that needs to be on a new Ghoul II model +int G2API_InitGhoul2Model(CGhoul2Info_v **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, + qhandle_t customShader, int modelFlags, int lodBias) +{ + int model; + CGhoul2Info newModel; + + // are we actually asking for a model to be loaded. + if (!fileName || !fileName[0]) + { + assert(0); + return -1; + } + + if (!(*ghoul2Ptr)) + { + *ghoul2Ptr = new CGhoul2Info_v; +#ifdef _FULL_G2_LEAK_CHECKING + if (g_G2AllocServer) + { + g_G2ServerAlloc += sizeof(CGhoul2Info_v); + } + else + { + g_G2ClientAlloc += sizeof(CGhoul2Info_v); + } + g_Ghoul2Allocations += sizeof(CGhoul2Info_v); + G2_DEBUG_ShovePtrInTracker(*ghoul2Ptr); +#endif + } + + CGhoul2Info_v &ghoul2 = *(*ghoul2Ptr); + + // find a free spot in the list + for (model=0; model< ghoul2.size(); model++) + { + if (ghoul2[model].mModelindex == -1) + { + ghoul2[model]=CGhoul2Info(); + break; + } + } + if (model==ghoul2.size()) + { //init should not be used to create additional models, only the first one + assert(ghoul2.size() < 4); //use G2API_CopySpecificG2Model to add models + ghoul2.push_back(CGhoul2Info()); + } + + strcpy(ghoul2[model].mFileName, fileName); + ghoul2[model].mModelindex = model; + if (!G2_TestModelPointers(&ghoul2[model])) + { + ghoul2[model].mFileName[0]=0; + ghoul2[model].mModelindex = -1; + } + else + { + G2_Init_Bone_List(ghoul2[model].mBlist); + G2_Init_Bolt_List(ghoul2[model].mBltlist); + ghoul2[model].mCustomShader = customShader; + ghoul2[model].mCustomSkin = customSkin; + ghoul2[model].mLodBias = lodBias; + ghoul2[model].mAnimFrameDefault = 0; + ghoul2[model].mFlags = 0; + + ghoul2[model].mModelBoltLink = -1; + } + return ghoul2[model].mModelindex; +} + +qboolean G2API_SetLodBias(CGhoul2Info *ghlInfo, int lodBias) +{ + if (ghlInfo) + { + ghlInfo->mLodBias = lodBias; + return qtrue; + } + return qfalse; +} + +void G2_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin); +qboolean G2API_SetSkin(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin) +{ + if (ghlInfo) + { + ghlInfo->mCustomSkin = customSkin; + if (renderSkin) + {//this is going to set the surfs on/off matching the skin file + G2_SetSurfaceOnOffFromSkin( ghlInfo, renderSkin ); + } + + return qtrue; + } + return qfalse; +} + +qboolean G2API_SetShader(CGhoul2Info *ghlInfo, qhandle_t customShader) +{ + if (ghlInfo) + { + ghlInfo->mCustomShader = customShader; + return qtrue; + } + return qfalse; +} + +qboolean G2API_SetSurfaceOnOff(CGhoul2Info_v &ghoul2, const char *surfaceName, const int flags) +{ + CGhoul2Info *ghlInfo = NULL; + + if (&ghoul2 && ghoul2.size()>0) + { + ghlInfo = &ghoul2[0]; + } + + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mMeshFrameNum = 0; + return G2_SetSurfaceOnOff(ghlInfo, ghlInfo->mSlist, surfaceName, flags); + } + return qfalse; +} + +int G2API_GetSurfaceOnOff(CGhoul2Info *ghlInfo, const char *surfaceName) +{ + if (ghlInfo) + { + return G2_IsSurfaceOff(ghlInfo, ghlInfo->mSlist, surfaceName); + } + return -1; +} + +qboolean G2API_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const char *surfaceName) +{ + if (G2_SetupModelPointers(ghoul2)) + { + return G2_SetRootSurface(ghoul2, modelIndex, surfaceName); + } + + return qfalse; +} + +int G2API_AddSurface(CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod ) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mMeshFrameNum = 0; + return G2_AddSurface(ghlInfo, surfaceNumber, polyNumber, BarycentricI, BarycentricJ, lod); + } + return -1; +} + +qboolean G2API_RemoveSurface(CGhoul2Info *ghlInfo, const int index) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mMeshFrameNum = 0; + return G2_RemoveSurface(ghlInfo->mSlist, index); + } + return qfalse; +} + +int G2API_GetParentSurface(CGhoul2Info *ghlInfo, const int index) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_GetParentSurface(ghlInfo, index); + } + return -1; +} + +int G2API_GetSurfaceRenderStatus(CGhoul2Info *ghlInfo, const char *surfaceName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_IsSurfaceRendered(ghlInfo, surfaceName, ghlInfo->mSlist); + } + return -1; +} + +qboolean G2API_HasGhoul2ModelOnIndex(CGhoul2Info_v **ghlRemove, const int modelIndex) +{ + CGhoul2Info_v &ghlInfo = **ghlRemove; + + if (!ghlInfo.size() || (ghlInfo.size() <= modelIndex) || (ghlInfo[modelIndex].mModelindex == -1)) + { + return qfalse; + } + + return qtrue; +} + +qboolean G2API_RemoveGhoul2Model(CGhoul2Info_v **ghlRemove, const int modelIndex) +{ + CGhoul2Info_v &ghlInfo = **ghlRemove; + + // sanity check + if (!ghlInfo.size() || (ghlInfo.size() <= modelIndex) || (ghlInfo[modelIndex].mModelindex == -1)) + { + // if we hit this assert then we are trying to delete a ghoul2 model on a ghoul2 instance that + // one way or another is already gone. + assert(0); + return qfalse; + } + + if (ghlInfo.size() > modelIndex) + { +#ifdef _G2_GORE + // Cleanup the gore attached to this model + if ( ghlInfo[modelIndex].mGoreSetTag ) + { + DeleteGoreSet ( ghlInfo[modelIndex].mGoreSetTag ); + ghlInfo[modelIndex].mGoreSetTag = 0; + } +#endif + + if (ghlInfo[modelIndex].mBoneCache) + { + RemoveBoneCache(ghlInfo[modelIndex].mBoneCache); + ghlInfo[modelIndex].mBoneCache=0; + } + + // clear out the vectors this model used. + ghlInfo[modelIndex].mBlist.clear(); + ghlInfo[modelIndex].mBltlist.clear(); + ghlInfo[modelIndex].mSlist.clear(); + + // set us to be the 'not active' state + ghlInfo[modelIndex].mModelindex = -1; + + int newSize = ghlInfo.size(); + // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list + for (int i=ghlInfo.size()-1; i>-1; i--) + { + if (ghlInfo[i].mModelindex == -1) + { + newSize = i; + } + // once we hit one that isn't a -1, we are done. + else + { + break; + } + } + // do we need to resize? + if (newSize != ghlInfo.size()) + { + // yes, so lets do it + ghlInfo.resize(newSize); + } + + // if we are not using any space, just delete the ghoul2 vector entirely + if (!ghlInfo.size()) + { +#ifdef _FULL_G2_LEAK_CHECKING + if (g_G2AllocServer) + { + g_G2ServerAlloc -= sizeof(*ghlRemove); + } + else + { + g_G2ClientAlloc -= sizeof(*ghlRemove); + } + g_Ghoul2Allocations -= sizeof(*ghlRemove); +#endif + delete *ghlRemove; + *ghlRemove = NULL; + } + } + + + return qtrue; +} + +qboolean G2API_RemoveGhoul2Models(CGhoul2Info_v **ghlRemove) +{//remove 'em ALL! + CGhoul2Info_v &ghlInfo = **ghlRemove; + int modelIndex = 0; + int newSize = 0; + int i; + + // sanity check + if ( !ghlInfo.size() ) + {// if we hit this then we are trying to delete a ghoul2 model on a ghoul2 instance that + // one way or another is already gone. + return qfalse; + } + + for ( modelIndex = 0; modelIndex < ghlInfo.size(); modelIndex++ ) + { + if ( ghlInfo[modelIndex].mModelindex == -1 ) + { + continue; + } +#ifdef _G2_GORE + // Cleanup the gore attached to this model + if ( ghlInfo[modelIndex].mGoreSetTag ) + { + DeleteGoreSet ( ghlInfo[modelIndex].mGoreSetTag ); + ghlInfo[modelIndex].mGoreSetTag = 0; + } +#endif + + if (ghlInfo[modelIndex].mBoneCache) + { + RemoveBoneCache(ghlInfo[modelIndex].mBoneCache); + ghlInfo[modelIndex].mBoneCache=0; + } + + // clear out the vectors this model used. + ghlInfo[modelIndex].mBlist.clear(); + ghlInfo[modelIndex].mBltlist.clear(); + ghlInfo[modelIndex].mSlist.clear(); + + // set us to be the 'not active' state + ghlInfo[modelIndex].mModelindex = -1; + } + + newSize = ghlInfo.size(); + // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list + for (i=ghlInfo.size()-1; i>-1; i--) + { + if (ghlInfo[i].mModelindex == -1) + { + newSize = i; + } + // once we hit one that isn't a -1, we are done. + else + { + break; + } + } + // do we need to resize? + if (newSize != ghlInfo.size()) + { + // yes, so lets do it + ghlInfo.resize(newSize); + } + + // if we are not using any space, just delete the ghoul2 vector entirely + if (!ghlInfo.size()) + { +#ifdef _FULL_G2_LEAK_CHECKING + if (g_G2AllocServer) + { + g_G2ServerAlloc -= sizeof(*ghlRemove); + } + else + { + g_G2ClientAlloc -= sizeof(*ghlRemove); + } + g_Ghoul2Allocations -= sizeof(*ghlRemove); +#endif + delete *ghlRemove; + *ghlRemove = NULL; + } + return qtrue; +} + +//check if a bone exists on skeleton without actually adding to the bone list -rww +qboolean G2API_DoesBoneExist(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { //model is valid + mdxaHeader_t *mdxa = ghlInfo->currentModel->mdxa; + if (mdxa) + { //get the skeleton data and iterate through the bones + int i; + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); + + for (i = 0; i < mdxa->numBones; i++) + { + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + if (!Q_stricmp(skel->name, boneName)) + { //got it + return qtrue; + } + } + } + } + + //guess it doesn't exist + return qfalse; +} + +//rww - RAGDOLL_BEGIN +#define GHOUL2_RAG_STARTED 0x0010 +#define GHOUL2_RAG_FORCESOLVE 0x1000 //api-override, determine if ragdoll should be forced to continue solving even if it thinks it is settled +//rww - RAGDOLL_END + +qboolean G2API_SetBoneAnimIndex(CGhoul2Info *ghlInfo, const int index, const int AstartFrame, const int AendFrame, const int flags, const float animSpeed, const int currentTime, const float AsetFrame, const int blendTime) +{ + qboolean setPtrs = qfalse; + qboolean res = qfalse; + + //rww - RAGDOLL_BEGIN + if (ghlInfo) + { + res = G2_SetupModelPointers(ghlInfo); + setPtrs = qtrue; + + if (res) + { + if (ghlInfo->mFlags & GHOUL2_RAG_STARTED) + { + return qfalse; + } + } + } + //rww - RAGDOLL_END + + int endFrame=AendFrame; + int startFrame=AstartFrame; + float setFrame=AsetFrame; + assert(endFrame>0); + assert(startFrame>=0); + assert(endFrame<100000); + assert(startFrame<100000); + assert(setFrame>=0.0f||setFrame==-1.0f); + assert(setFrame<=100000.0f); + if (endFrame<=0) + { + endFrame=1; + } + if (endFrame>=100000) + { + endFrame=1; + } + if (startFrame<0) + { + startFrame=0; + } + if (startFrame>=100000) + { + startFrame=0; + } + if (setFrame<0.0f&&setFrame!=-1.0f) + { + setFrame=0.0f; + } + if (setFrame>100000.0f) + { + setFrame=0.0f; + } + if (!setPtrs) + { + res = G2_SetupModelPointers(ghlInfo); + } + + if (res) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Anim_Index(ghlInfo->mBlist, index, startFrame, endFrame, flags, animSpeed, currentTime, setFrame, blendTime, ghlInfo->aHeader->numFrames); + } + return qfalse; +} + +#define _PLEASE_SHUT_THE_HELL_UP + +qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const int AstartFrame, const int AendFrame, const int flags, const float animSpeed, const int currentTime, const float AsetFrame, const int blendTime) +{ + int endFrame=AendFrame; + int startFrame=AstartFrame; + float setFrame=AsetFrame; +#ifndef _PLEASE_SHUT_THE_HELL_UP + assert(endFrame>0); + assert(startFrame>=0); + assert(endFrame<100000); + assert(startFrame<100000); + assert(setFrame>=0.0f||setFrame==-1.0f); + assert(setFrame<=100000.0f); +#endif + if (endFrame<=0) + { + endFrame=1; + } + if (endFrame>=100000) + { + endFrame=1; + } + if (startFrame<0) + { + startFrame=0; + } + if (startFrame>=100000) + { + startFrame=0; + } + if (setFrame<0.0f&&setFrame!=-1.0f) + { + setFrame=0.0f; + } + if (setFrame>100000.0f) + { + setFrame=0.0f; + } + if (&ghoul2 && ghoul2.size()>modelIndex) + { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + qboolean setPtrs = qfalse; + qboolean res = qfalse; + + //rww - RAGDOLL_BEGIN + if (ghlInfo) + { + res = G2_SetupModelPointers(ghlInfo); + setPtrs = qtrue; + + if (res) + { + if (ghlInfo->mFlags & GHOUL2_RAG_STARTED) + { + return qfalse; + } + } + } + //rww - RAGDOLL_END + + if (!setPtrs) + { + res = G2_SetupModelPointers(ghlInfo); + } + + if (res) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Anim(ghlInfo, ghlInfo->mBlist, boneName, startFrame, endFrame, flags, animSpeed, currentTime, setFrame, blendTime); + } + } + return qfalse; +} + +qboolean G2API_GetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime, float *currentFrame, + int *startFrame, int *endFrame, int *flags, float *animSpeed, int *modelList) +{ + assert(startFrame!=endFrame); //this is bad + assert(startFrame!=flags); //this is bad + assert(endFrame!=flags); //this is bad + assert(currentFrame!=animSpeed); //this is bad + if (G2_SetupModelPointers(ghlInfo)) + { + int aCurrentTime=G2API_GetTime(currentTime); + qboolean ret=G2_Get_Bone_Anim(ghlInfo, ghlInfo->mBlist, boneName, aCurrentTime, currentFrame, + startFrame, endFrame, flags, animSpeed, modelList, ghlInfo->mModelindex); +#ifdef _DEBUG + /* + assert(*endFrame>0); + assert(*endFrame<100000); + assert(*startFrame>=0); + assert(*startFrame<100000); + assert(*currentFrame>=0.0f); + assert(*currentFrame<100000.0f); + */ + if (*endFrame<1) + { + *endFrame=1; + } + if (*endFrame>100000) + { + *endFrame=1; + } + if (*startFrame<0) + { + *startFrame=0; + } + if (*startFrame>100000) + { + *startFrame=1; + } + if (*currentFrame<0.0f) + { + *currentFrame=0.0f; + } + if (*currentFrame>100000) + { + *currentFrame=1; + } +#endif + return ret; + } + return qfalse; +} + +qboolean G2API_GetAnimRange(CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame) +{ + assert(startFrame!=endFrame); //this is bad + if (G2_SetupModelPointers(ghlInfo)) + { + qboolean ret=G2_Get_Bone_Anim_Range(ghlInfo, ghlInfo->mBlist, boneName, startFrame, endFrame); +#ifdef _DEBUG + assert(*endFrame>0); + assert(*endFrame<100000); + assert(*startFrame>=0); + assert(*startFrame<100000); + if (*endFrame<1) + { + *endFrame=1; + } + if (*endFrame>100000) + { + *endFrame=1; + } + if (*startFrame<0) + { + *startFrame=0; + } + if (*startFrame>100000) + { + *startFrame=1; + } +#endif + return ret; + } + return qfalse; +} + + +qboolean G2API_PauseBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Pause_Bone_Anim(ghlInfo, ghlInfo->mBlist, boneName, currentTime); + } + return qfalse; +} + +qboolean G2API_IsPaused(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_IsPaused(ghlInfo->mFileName, ghlInfo->mBlist, boneName); + } + return qfalse; +} + +qboolean G2API_StopBoneAnimIndex(CGhoul2Info *ghlInfo, const int index) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Stop_Bone_Anim_Index(ghlInfo->mBlist, index); + } + return qfalse; +} + +qboolean G2API_StopBoneAnim(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Stop_Bone_Anim(ghlInfo->mFileName, ghlInfo->mBlist, boneName); + } + return qfalse; +} + +qboolean G2API_SetBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, + const Eorientations yaw, const Eorientations pitch, const Eorientations roll, + qhandle_t *modelList, int blendTime, int currentTime) +{ + qboolean setPtrs = qfalse; + qboolean res = qfalse; + + //rww - RAGDOLL_BEGIN + if (ghlInfo) + { + res = G2_SetupModelPointers(ghlInfo); + setPtrs = qtrue; + + if (res) + { + if (ghlInfo->mFlags & GHOUL2_RAG_STARTED) + { + return qfalse; + } + } + } + //rww - RAGDOLL_END + + if (!setPtrs) + { + res = G2_SetupModelPointers(ghlInfo); + } + + if (res) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Angles_Index( ghlInfo->mBlist, index, angles, flags, yaw, pitch, roll, modelList, ghlInfo->mModelindex, blendTime, currentTime); + } + return qfalse; +} + +qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, + const Eorientations up, const Eorientations left, const Eorientations forward, + qhandle_t *modelList, int blendTime, int currentTime ) +{ + if (&ghoul2 && ghoul2.size()>modelIndex) + { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + qboolean setPtrs = qfalse; + qboolean res = qfalse; + + //rww - RAGDOLL_BEGIN + if (ghlInfo) + { + res = G2_SetupModelPointers(ghlInfo); + setPtrs = qtrue; + + if (res) + { + if (ghlInfo->mFlags & GHOUL2_RAG_STARTED) + { + return qfalse; + } + } + } + //rww - RAGDOLL_END + + if (!setPtrs) + { + res = G2_SetupModelPointers(ghoul2); + } + + if (res) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Angles(ghlInfo, ghlInfo->mBlist, boneName, angles, flags, up, left, forward, modelList, ghlInfo->mModelindex, blendTime, currentTime); + } + } + return qfalse; +} + +qboolean G2API_SetBoneAnglesMatrixIndex(CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, + const int flags, qhandle_t *modelList, int blendTime, int currentTime) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Angles_Matrix_Index(ghlInfo->mBlist, index, matrix, flags, modelList, ghlInfo->mModelindex, blendTime, currentTime); + } + return qfalse; +} + +qboolean G2API_SetBoneAnglesMatrix(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, + const int flags, qhandle_t *modelList, int blendTime, int currentTime) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Set_Bone_Angles_Matrix(ghlInfo->mFileName, ghlInfo->mBlist, boneName, matrix, flags, modelList, ghlInfo->mModelindex, blendTime, currentTime); + } + return qfalse; +} + +qboolean G2API_StopBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Stop_Bone_Angles_Index(ghlInfo->mBlist, index); + } + return qfalse; +} + +qboolean G2API_StopBoneAngles(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Stop_Bone_Angles(ghlInfo->mFileName, ghlInfo->mBlist, boneName); + } + return qfalse; +} + + +void G2API_AbsurdSmoothing(CGhoul2Info_v &ghoul2, qboolean status) +{ + assert(ghoul2.size()); + CGhoul2Info *ghlInfo = &ghoul2[0]; + + if (status) + { //turn it on + ghlInfo->mFlags |= GHOUL2_CRAZY_SMOOTH; + } + else + { //off + ghlInfo->mFlags &= ~GHOUL2_CRAZY_SMOOTH; + } +} + +//rww - RAGDOLL_BEGIN +class CRagDollParams; +void G2_SetRagDoll(CGhoul2Info_v &ghoul2V,CRagDollParams *parms); +void G2API_SetRagDoll(CGhoul2Info_v &ghoul2,CRagDollParams *parms) +{ + G2_SetRagDoll(ghoul2,parms); +} + +void G2_ResetRagDoll(CGhoul2Info_v &ghoul2V); +void G2API_ResetRagDoll(CGhoul2Info_v &ghoul2) +{ + G2_ResetRagDoll(ghoul2); +} +//rww - RAGDOLL_END + +qboolean G2API_RemoveBone(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + // ensure we flush the cache + ghlInfo->mSkelFrameNum = 0; + return G2_Remove_Bone(ghlInfo, ghlInfo->mBlist, boneName); + } + return qfalse; +} + +//rww - RAGDOLL_BEGIN +#ifdef _DEBUG +extern int ragTraceTime; +extern int ragSSCount; +extern int ragTraceCount; +#endif + +void G2API_AnimateG2ModelsRag(CGhoul2Info_v &ghoul2, int AcurrentTime,CRagDollUpdateParams *params) +{ + int model; + int currentTime=G2API_GetTime(AcurrentTime); + +#ifdef _DEBUG + ragTraceTime = 0; + ragSSCount = 0; + ragTraceCount = 0; +#endif + + // Walk the list and find all models that are active + for (model = 0; model < ghoul2.size(); model++) + { + if (ghoul2[model].mModel) + { + G2_Animate_Bone_List(ghoul2,currentTime,model,params); + } + } +#ifdef _DEBUG + /* + if (ragTraceTime) + { + Com_Printf("Rag trace time: %i (%i STARTSOLID, %i TOTAL)\n", ragTraceTime, ragSSCount, ragTraceCount); + } + */ + + //keep sane limits here, if it gets too slow an assert is proper. +// assert(ragTraceTime < 150); +// assert(ragTraceCount < 1500); +#endif +} +//rww - RAGDOLL_END + +int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName); +#define RAG_PCJ (0x00001) +#define RAG_EFFECTOR (0x00100) + +static inline boneInfo_t *G2_GetRagBoneConveniently(CGhoul2Info_v &ghoul2, const char *boneName) +{ + assert(ghoul2.size()); + CGhoul2Info *ghlInfo = &ghoul2[0]; + + if (!(ghlInfo->mFlags & GHOUL2_RAG_STARTED)) + { //can't do this if not in ragdoll + return NULL; + } + + int boneIndex = G2_Find_Bone_Rag(ghlInfo, ghlInfo->mBlist, boneName); + + if (boneIndex < 0) + { //bad bone specification + return NULL; + } + + boneInfo_t *bone = &ghlInfo->mBlist[boneIndex]; + + if (!(bone->flags & BONE_ANGLES_RAGDOLL)) + { //only want to return rag bones + return NULL; + } + + return bone; +} + +qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max) +{ + boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); + + if (!bone) + { + return qfalse; + } + + if (!(bone->RagFlags & RAG_PCJ)) + { //this function is only for PCJ bones + return qfalse; + } + + VectorCopy(min, bone->minAngles); + VectorCopy(max, bone->maxAngles); + + return qtrue; +} + +qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, const float speed) +{ + boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); + + if (!bone) + { + return qfalse; + } + + if (!(bone->RagFlags & RAG_PCJ)) + { //this function is only for PCJ bones + return qfalse; + } + + bone->overGradSpeed = speed; + + return qtrue; +} + +qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos) +{ + boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); + + if (!bone) + { + return qfalse; + } + + if (!(bone->RagFlags & RAG_EFFECTOR)) + { //this function is only for effectors + return qfalse; + } + + if (!pos) + { //go back to none in case we have one then + bone->hasOverGoal = false; + } + else + { + VectorCopy(pos, bone->overGoalSpot); + bone->hasOverGoal = true; + } + return qtrue; +} + +qboolean G2API_GetRagBonePos(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale) +{ //do something? + return qfalse; +} + +qboolean G2API_RagEffectorKick(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity) +{ + boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); + + if (!bone) + { + return qfalse; + } + + if (!(bone->RagFlags & RAG_EFFECTOR)) + { //this function is only for effectors + return qfalse; + } + + bone->epVelocity[2] = 0; + VectorAdd(bone->epVelocity, velocity, bone->epVelocity); + bone->physicsSettled = false; + + return qtrue; +} + +qboolean G2API_RagForceSolve(CGhoul2Info_v &ghoul2, qboolean force) +{ + assert(ghoul2.size()); + CGhoul2Info *ghlInfo = &ghoul2[0]; + + if (!(ghlInfo->mFlags & GHOUL2_RAG_STARTED)) + { //can't do this if not in ragdoll + return qfalse; + } + + if (force) + { + ghlInfo->mFlags |= GHOUL2_RAG_FORCESOLVE; + } + else + { + ghlInfo->mFlags &= ~GHOUL2_RAG_FORCESOLVE; + } + + return qtrue; +} + +qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params); +qboolean G2API_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params) +{ + return G2_SetBoneIKState(ghoul2, time, boneName, ikState, params); +} + +qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params); +qboolean G2API_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params) +{ + return G2_IKMove(ghoul2, time, params); +} + +qboolean G2API_RemoveBolt(CGhoul2Info *ghlInfo, const int index) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Remove_Bolt( ghlInfo->mBltlist, index); + } + return qfalse; +} + +int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName) +{ +// assert(ghoul2.size()>modelIndex); + + if (&ghoul2 && ghoul2.size()>modelIndex) + { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Add_Bolt(ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, boneName); + } + } + return -1; +} + +int G2API_AddBoltSurfNum(CGhoul2Info *ghlInfo, const int surfIndex) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Add_Bolt_Surf_Num(ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, surfIndex); + } + return -1; +} + + +qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel) +{ + assert( toBoltIndex >= 0 ); + if ( toBoltIndex < 0 ) + { + return qfalse; + } + if (G2_SetupModelPointers(ghoul2From)&&G2_SetupModelPointers(ghoul2To)) + { + // make sure we have a model to attach, a model to attach to, and a bolt on that model + if (&ghoul2From && + &ghoul2To && + (ghoul2From.size() > modelFrom) && + (ghoul2To.size() > toModel) && + ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) + { + // encode the bolt address into the model bolt link + toModel &= MODEL_AND; + toBoltIndex &= BOLT_AND; + ghoul2From[modelFrom].mModelBoltLink = (toModel << MODEL_SHIFT) | (toBoltIndex << BOLT_SHIFT); + return qtrue; + } + } + return qfalse; +} + +void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo) +{ + if (&ghoul2) + { + if (ghoul2.size() > modelIndex) + { + ghoul2[modelIndex].mModelBoltLink = boltInfo; + } + } +} + +qboolean G2API_DetachG2Model(CGhoul2Info *ghlInfo) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + ghlInfo->mModelBoltLink = -1; + return qtrue; + } + return qfalse; +} + +qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum) +{ + if (boltInfo && G2_SetupModelPointers(ghlInfoTo)) + { + // make sure we have a model to attach, a model to attach to, and a bolt on that model + if ( ghlInfoTo->mBltlist.size() && ((ghlInfoTo->mBltlist[toBoltIndex].boneNumber != -1) || (ghlInfoTo->mBltlist[toBoltIndex].surfaceNumber != -1))) + { + // encode the bolt address into the model bolt link + toModelNum &= MODEL_AND; + toBoltIndex &= BOLT_AND; + entNum &= ENTITY_AND; + *boltInfo = (toBoltIndex << BOLT_SHIFT) | (toModelNum << MODEL_SHIFT) | (entNum << ENTITY_SHIFT); + return qtrue; + } + } + return qfalse; + +} + +qboolean gG2_GBMNoReconstruct; +qboolean gG2_GBMUseSPMethod; + +qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, + const vec3_t position, const int frameNum, qhandle_t *modelList, const vec3_t scale ) +{ + assert(ghoul2.size() > modelIndex); + + if (&ghoul2 && (ghoul2.size() > modelIndex)) + { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + + //assert(boltIndex < ghlInfo->mBltlist.size()); + + if (ghlInfo && (boltIndex < (int)ghlInfo->mBltlist.size()) && boltIndex >= 0 ) + { + // make sure we have transformed the skeleton + if (!gG2_GBMNoReconstruct) + { + G2_ConstructGhoulSkeleton(ghoul2, frameNum, true, scale); + } + + gG2_GBMNoReconstruct = qfalse; + + mdxaBone_t scaled; + mdxaBone_t *use; + use=&ghlInfo->mBltlist[boltIndex].position; + + if (scale[0]||scale[1]||scale[2]) + { + scaled=*use; + use=&scaled; + + // scale the bolt position by the scale factor for this model since at this point its still in model space + if (scale[0]) + { + scaled.matrix[0][3] *= scale[0]; + } + if (scale[1]) + { + scaled.matrix[1][3] *= scale[1]; + } + if (scale[2]) + { + scaled.matrix[2][3] *= scale[2]; + } + } + // pre generate the world matrix + G2_GenerateWorldMatrix(angles, position); + + VectorNormalize((float*)use->matrix[0]); + VectorNormalize((float*)use->matrix[1]); + VectorNormalize((float*)use->matrix[2]); + + Multiply_3x4Matrix(matrix, &worldMatrix, use); + return qtrue; + } + } + return qfalse; +} + +#define G2ERROR(exp,m) ((void)0) //rwwFIXMEFIXME: This is because I'm lazy. +#define G2WARNING(exp,m) ((void)0) +#define G2NOTE(exp,m) ((void)0) +#define G2ANIM(ghlInfo,m) ((void)0) +bool G2_NeedsRecalc(CGhoul2Info *ghlInfo,int frameNum); +void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix); +void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv); + +//qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, +// const vec3_t position, const int AframeNum, qhandle_t *modelList, const vec3_t scale ) +qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, + const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) +{ +// G2ERROR(ghoul2.IsValid(),"Invalid ghlInfo"); + G2ERROR(matrix,"NULL matrix"); + G2ERROR(modelIndex>=0&&modelIndex=0&&modelIndex= 0 && (boltIndex < ghlInfo->mBltlist.size()),va("Invalid Bolt Index (%d:%s)",boltIndex,ghlInfo->mFileName)); + + if (boltIndex >= 0 && ghlInfo && (boltIndex < (int)ghlInfo->mBltlist.size()) ) + { + mdxaBone_t bolt; + +#if 0 //yeah, screw it + if (!gG2_GBMNoReconstruct) + { //This should only be used when you know what you're doing. + if (G2_NeedsRecalc(ghlInfo,tframeNum)) + { + G2_ConstructGhoulSkeleton(ghoul2,tframeNum,true,scale); + } + } + else + { + gG2_GBMNoReconstruct = qfalse; + } +#else + if (G2_NeedsRecalc(ghlInfo,tframeNum)) + { + G2_ConstructGhoulSkeleton(ghoul2,tframeNum,true,scale); + } +#endif + + G2_GetBoltMatrixLow(*ghlInfo,boltIndex,scale,bolt); + // scale the bolt position by the scale factor for this model since at this point its still in model space + if (scale[0]) + { + bolt.matrix[0][3] *= scale[0]; + } + if (scale[1]) + { + bolt.matrix[1][3] *= scale[1]; + } + if (scale[2]) + { + bolt.matrix[2][3] *= scale[2]; + } + VectorNormalize((float*)&bolt.matrix[0]); + VectorNormalize((float*)&bolt.matrix[1]); + VectorNormalize((float*)&bolt.matrix[2]); + + Multiply_3x4Matrix(matrix, &worldMatrix, &bolt); +#if G2API_DEBUG + for ( int i = 0; i < 3; i++ ) + { + for ( int j = 0; j < 4; j++ ) + { + assert( !_isnan(matrix->matrix[i][j])); + } + } +#endif// _DEBUG + G2ANIM(ghlInfo,"G2API_GetBoltMatrix"); + + if (!gG2_GBMUseSPMethod) + { //this is horribly stupid and I hate it. But lots of game code is written to assume this 90 degree offset thing. + mdxaBone_t rotMat, tempMatrix; + vec3_t newangles = {0,270,0}; + Create_Matrix(newangles, &rotMat); + // make the model space matrix we have for this bolt into a world matrix + Multiply_3x4Matrix(&tempMatrix, &worldMatrix, &bolt); + vec3_t origin; + origin[0] = tempMatrix.matrix[0][3]; + origin[1] = tempMatrix.matrix[1][3]; + origin[2] = tempMatrix.matrix[2][3]; + tempMatrix.matrix[0][3] = tempMatrix.matrix[1][3] = tempMatrix.matrix[2][3] = 0; + Multiply_3x4Matrix(matrix, &tempMatrix, &rotMat); + matrix->matrix[0][3] = origin[0]; + matrix->matrix[1][3] = origin[1]; + matrix->matrix[2][3] = origin[2]; + } + else + { //reset it + gG2_GBMUseSPMethod = qfalse; + } + + return qtrue; + } + } + } + else + { + G2WARNING(0,"G2API_GetBoltMatrix Failed on empty or bad model"); + } + Multiply_3x4Matrix(matrix, &worldMatrix, (mdxaBone_t *)&identityMatrix); + return qfalse; +} + +void G2API_ListSurfaces(CGhoul2Info *ghlInfo) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + G2_List_Model_Surfaces(ghlInfo->mFileName); + } +} + +void G2API_ListBones(CGhoul2Info *ghlInfo, int frame) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + G2_List_Model_Bones(ghlInfo->mFileName, frame); + } +} + +// decide if we have Ghoul2 models associated with this ghoul list or not +qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2) +{ + int i; + if (&ghoul2 && ghoul2.size()) + { + for (i=0; imdxm->animName; +} + +/************************************************************************************************ + * G2API_GetAnimFileName + * obtains the name of a model's .gla (animation) file + * + * Input + * pointer to list of CGhoul2Info's, WraithID of specific model in that list + * + * Output + * true if a good filename was obtained, false otherwise + * + ************************************************************************************************/ +qboolean G2API_GetAnimFileName(CGhoul2Info *ghlInfo, char **filename) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_GetAnimFileName(ghlInfo->mFileName, filename); + } + return qfalse; +} + +/* +======================= +SV_QsortEntityNumbers +======================= +*/ +static int QDECL QsortDistance( const void *a, const void *b ) { + const float &ea = ((CollisionRecord_t*)a)->mDistance; + const float &eb = ((CollisionRecord_t*)b)->mDistance; + + if ( ea < eb ) { + return -1; + } + return 1; +} + +static inline bool G2_NeedRetransform(CGhoul2Info *g2, int frameNum) +{ //see if we need to do another transform + size_t i = 0; + bool needTrans = false; + while (i < g2->mBlist.size()) + { + float time; + boneInfo_t &bone = g2->mBlist[i]; + + if (bone.pauseTime) + { + time = (bone.pauseTime - bone.startTime) / 50.0f; + } + else + { + time = (frameNum - bone.startTime) / 50.0f; + } + int newFrame = bone.startFrame + (time * bone.animSpeed); + + if (newFrame < bone.endFrame || + (bone.flags & BONE_ANIM_OVERRIDE_LOOP) || + (bone.flags & BONE_NEED_TRANSFORM)) + { //ok, we're gonna have to do it. bone is apparently animating. + bone.flags &= ~BONE_NEED_TRANSFORM; + needTrans = true; + } + i++; + } + + return needTrans; +} + +void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, + int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius) +{ //this will store off the transformed verts for the next trace - this is slower, but for models that do not animate + //frequently it is much much faster. -rww +#if 0 // UNUSED + int *test = ghoul2[0].mTransformedVertsArray; +#endif + if (G2_SetupModelPointers(ghoul2)) + { + vec3_t transRayStart, transRayEnd; + + int tframeNum=G2API_GetTime(frameNumber); + // make sure we have transformed the whole skeletons for each model + if (G2_NeedRetransform(&ghoul2[0], tframeNum) || !ghoul2[0].mTransformedVertsArray) + { //optimization, only create new transform space if we need to, otherwise + //store it off! + int i = 0; + while (i < ghoul2.size()) + { + CGhoul2Info &g2 = ghoul2[i]; + + /* + if ((g2.mFlags & GHOUL2_ZONETRANSALLOC) && g2.mTransformedVertsArray) + { //clear it out, yo. + Z_Free(g2.mTransformedVertsArray); + g2.mTransformedVertsArray = 0; + } + */ + if (!g2.mTransformedVertsArray || !(g2.mFlags & GHOUL2_ZONETRANSALLOC)) + { //reworked so we only alloc once! + //if we have a pointer, but not a ghoul2_zonetransalloc flag, then that means + //it is a miniheap pointer. Just stomp over it. + int iSize = g2.currentModel->mdxm->numSurfaces * 4; + g2.mTransformedVertsArray = (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); + } + + g2.mFlags |= GHOUL2_ZONETRANSALLOC; + + i++; + } + G2_ConstructGhoulSkeleton(ghoul2, frameNumber, true, scale); + G2VertSpace->ResetHeap(); + + // now having done that, time to build the model +#ifdef _G2_GORE + G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod, false); +#else + G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod); +#endif + + //don't need to do this anymore now that I am using a flag for zone alloc. + /* + i = 0; + while (i < ghoul2.size()) + { + CGhoul2Info &g2 = ghoul2[i]; + int iSize = g2.currentModel->mdxm->numSurfaces * 4; + + int *zoneMem = (int *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); + memcpy(zoneMem, g2.mTransformedVertsArray, iSize); + g2.mTransformedVertsArray = zoneMem; + g2.mFlags |= GHOUL2_ZONETRANSALLOC; + i++; + } + */ + } + + // pre generate the world matrix - used to transform the incoming ray + G2_GenerateWorldMatrix(angles, position); + + // model is built. Lets check to see if any triangles are actually hit. + // first up, translate the ray to model space + TransformAndTranslatePoint(rayStart, transRayStart, &worldMatrixInv); + TransformAndTranslatePoint(rayEnd, transRayEnd, &worldMatrixInv); + + // now walk each model and check the ray against each poly - sigh, this is SO expensive. I wish there was a better way to do this. +#ifdef _G2_GORE + G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius,0,0,0,0,0,qfalse); +#else + G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius); +#endif + int i; + for ( i = 0; i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; i ++ ); + + // now sort the resulting array of collision records so they are distance ordered + qsort( collRecMap, i, + sizeof( CollisionRecord_t ), QsortDistance ); + } +} + + +void G2API_CollisionDetect(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, + int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius) +{ + /* + if (1) + { + G2API_CollisionDetectCache(collRecMap, ghoul2, angles, position, frameNumber, entNum, + rayStart, rayEnd, scale, G2VertSpace, traceFlags, useLod, fRadius); + return; + } + */ + + if (G2_SetupModelPointers(ghoul2)) + { + vec3_t transRayStart, transRayEnd; + + // make sure we have transformed the whole skeletons for each model + G2_ConstructGhoulSkeleton(ghoul2, frameNumber, true, scale); + + // pre generate the world matrix - used to transform the incoming ray + G2_GenerateWorldMatrix(angles, position); + + G2VertSpace->ResetHeap(); + + // now having done that, time to build the model +#ifdef _G2_GORE + G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod, false); +#else + G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod); +#endif + + // model is built. Lets check to see if any triangles are actually hit. + // first up, translate the ray to model space + TransformAndTranslatePoint(rayStart, transRayStart, &worldMatrixInv); + TransformAndTranslatePoint(rayEnd, transRayEnd, &worldMatrixInv); + + // now walk each model and check the ray against each poly - sigh, this is SO expensive. I wish there was a better way to do this. +#ifdef _G2_GORE + G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius,0,0,0,0,0,qfalse); +#else + G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius); +#endif + int i; + for ( i = 0; i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; i ++ ); + + // now sort the resulting array of collision records so they are distance ordered + qsort( collRecMap, i, + sizeof( CollisionRecord_t ), QsortDistance ); + } +} + +qboolean G2API_SetGhoul2ModelFlags(CGhoul2Info *ghlInfo, const int flags) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + ghlInfo->mFlags &= GHOUL2_NEWORIGIN; + ghlInfo->mFlags |= flags; + return qtrue; + } + return qfalse; +} + +int G2API_GetGhoul2ModelFlags(CGhoul2Info *ghlInfo) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return (ghlInfo->mFlags & ~GHOUL2_NEWORIGIN); + } + return 0; +} + +// given a boltmatrix, return in vec a normalised vector for the axis requested in flags +void G2API_GiveMeVectorFromMatrix(mdxaBone_t *boltMatrix, Eorientations flags, vec3_t vec) +{ + switch (flags) + { + case ORIGIN: + vec[0] = boltMatrix->matrix[0][3]; + vec[1] = boltMatrix->matrix[1][3]; + vec[2] = boltMatrix->matrix[2][3]; + break; + case POSITIVE_Y: + vec[0] = boltMatrix->matrix[0][1]; + vec[1] = boltMatrix->matrix[1][1]; + vec[2] = boltMatrix->matrix[2][1]; + break; + case POSITIVE_X: + vec[0] = boltMatrix->matrix[0][0]; + vec[1] = boltMatrix->matrix[1][0]; + vec[2] = boltMatrix->matrix[2][0]; + break; + case POSITIVE_Z: + vec[0] = boltMatrix->matrix[0][2]; + vec[1] = boltMatrix->matrix[1][2]; + vec[2] = boltMatrix->matrix[2][2]; + break; + case NEGATIVE_Y: + vec[0] = -boltMatrix->matrix[0][1]; + vec[1] = -boltMatrix->matrix[1][1]; + vec[2] = -boltMatrix->matrix[2][1]; + break; + case NEGATIVE_X: + vec[0] = -boltMatrix->matrix[0][0]; + vec[1] = -boltMatrix->matrix[1][0]; + vec[2] = -boltMatrix->matrix[2][0]; + break; + case NEGATIVE_Z: + vec[0] = -boltMatrix->matrix[0][2]; + vec[1] = -boltMatrix->matrix[1][2]; + vec[2] = -boltMatrix->matrix[2][2]; + break; + } +} + + +int G2API_CopyGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int modelIndex) +{ + assert(modelIndex==-1); // copy individual bolted parts is not used in jk2 and I didn't want to deal with it + // if ya want it, we will add it back correctly + + //G2ERROR(ghoul2From.IsValid(),"Invalid ghlInfo"); + if (g2From.IsValid()) + { +#ifdef _DEBUG + if (g2To.IsValid()) + { + assert(!"Copying to a valid g2 instance?!"); + + if (g2To[0].mBoneCache) + { + assert(!"Instance has a bonecache too.. it's gonna get stomped"); + } + } +#endif + g2To.DeepCopy(g2From); + +#ifdef _G2_GORE //check through gore stuff then, as well. + int model = 0; + + while (model < g2To.size()) + { + if ( g2To[model].mGoreSetTag ) + { + CGoreSet* gore = FindGoreSet ( g2To[model].mGoreSetTag ); + assert(gore); + gore->mRefCount++; + } + + model++; + } +#endif + //G2ANIM(ghoul2From,"G2API_CopyGhoul2Instance (source)"); + //G2ANIM(ghoul2To,"G2API_CopyGhoul2Instance (dest)"); + } + + return -1; +} + +void G2API_CopySpecificG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo) +{ +#if 0 + qboolean forceReconstruct = qtrue; +#endif //model1 was not getting reconstructed like it should for thrown sabers? + //might have been a bug in the reconstruct checking which has since been + //mangled and probably fixed. -rww + + // have we real ghoul2 models yet? + if (&ghoul2From && &ghoul2To) + { + // assume we actually have a model to copy from + if (ghoul2From.size() > modelFrom) + { + // if we don't have enough models on the to side, resize us so we do + if (ghoul2To.size() <= modelTo) + { + assert (modelTo < 5); + ghoul2To.resize(modelTo + 1); +#if 0 + forceReconstruct = qtrue; +#endif + } + // do the copy + + if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) + { //remove the bonecache before we stomp over this instance. + if (ghoul2To[modelTo].mBoneCache) + { + RemoveBoneCache(ghoul2To[modelTo].mBoneCache); + ghoul2To[modelTo].mBoneCache = 0; + } + } + ghoul2To[modelTo] = ghoul2From[modelFrom]; + +#if 0 + if (forceReconstruct) + { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, + //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns + //a completely invalid matrix + ghoul2To[0].mSkelFrameNum = 0; + } +#endif + } + } +} + +// This version will automatically copy everything about this model, and make a new one if necessary. +void G2API_DuplicateGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v **g2To) +{ + //int ignore; + + if (*g2To) + { // This is bad. We only want to do this if there is not yet a to declared. + assert(0); + return; + } + + *g2To = new CGhoul2Info_v; +#ifdef _FULL_G2_LEAK_CHECKING + if (g_G2AllocServer) + { + g_G2ServerAlloc += sizeof(CGhoul2Info_v); + } + else + { + g_G2ClientAlloc += sizeof(CGhoul2Info_v); + } + g_Ghoul2Allocations += sizeof(CGhoul2Info_v); + G2_DEBUG_ShovePtrInTracker(*g2To); +#endif + CGhoul2Info_v &ghoul2 = *(*g2To); + + /*ignore = */G2API_CopyGhoul2Instance(g2From, ghoul2, -1); + + return; +} + +char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) +{ + static char noSurface[1] = ""; + if (G2_SetupModelPointers(ghlInfo)) + { + model_t *mod = (model_t *)ghlInfo->currentModel; + mdxmSurface_t *surf = 0; + mdxmSurfHierarchy_t *surfInfo = 0; + +#ifndef FINAL_BUILD + if (!mod || !mod->mdxm) + { + Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad model on instance %s.", ghlInfo->mFileName); + } +#endif + + //ok, I guess it's semi-valid for the user to be passing in surface > numSurfs because they don't know how many surfs a model + //may have.. but how did they get that surf index to begin with? Oh well. + if (surfNumber < 0 || surfNumber >= mod->mdxm->numSurfaces) + { + Com_Printf("G2API_GetSurfaceName: You passed in an invalid surface number (%i) for model %s.\n", surfNumber, ghlInfo->mFileName); + return noSurface; + } + + + surf = (mdxmSurface_t *)G2_FindSurface((void *)mod, surfNumber, 0); + if (surf) + { +#ifndef FINAL_BUILD + if (surf->thisSurfaceIndex < 0 || surf->thisSurfaceIndex >= mod->mdxm->numSurfaces) + { + Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad surf num (%i) on surf for instance %s.", surf->thisSurfaceIndex, ghlInfo->mFileName); + } +#endif + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]); + return surfInfo->name; + } + } + return noSurface; +} + + +int G2API_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_GetSurfaceIndex(ghlInfo, surfaceName); + } + return -1; +} + +char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) +{ + if (G2_SetupModelPointers(ghoul2)) + { + if (&ghoul2 && (ghoul2.size() > modelIndex)) + { + //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); + //return mod->mdxm->animName; + + assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->mdxm); + return ghoul2[modelIndex].currentModel->mdxm->animName; + } + } + return NULL; +} + +qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex) +{ + CGhoul2Info *ghlInfo = NULL; + + if (&ghoul2 && ghoul2.size()>0) + { + ghlInfo = &ghoul2[0]; + } + + if (G2_SetupModelPointers(ghlInfo)) + { + if (boltIndex < 0) + { + char modelName[MAX_QPATH]; + if (ghlInfo->currentModel && + ghlInfo->currentModel->name && + ghlInfo->currentModel->name[0]) + { + strcpy(modelName, ghlInfo->currentModel->name); + } + else + { + strcpy(modelName, "None?!"); + } + + Com_Error(ERR_DROP, "Bad boltindex (%i) trying to SetNewOrigin (naughty naughty!)\nModel %s\n", boltIndex, modelName); + } + + ghlInfo->mNewOrigin = boltIndex; + ghlInfo->mFlags |= GHOUL2_NEWORIGIN; + return qtrue; + } + return qfalse; +} + +int G2API_GetBoneIndex(CGhoul2Info *ghlInfo, const char *boneName) +{ + if (G2_SetupModelPointers(ghlInfo)) + { + return G2_Get_Bone_Index(ghlInfo, boneName); + } + return -1; +} + +qboolean G2API_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) +{ + return G2_SaveGhoul2Models(ghoul2, buffer, size); +} + +void G2API_LoadGhoul2Models(CGhoul2Info_v &ghoul2, char *buffer) +{ + G2_LoadGhoul2Model(ghoul2, buffer); +} + +void G2API_FreeSaveBuffer(char *buffer) +{ + Z_Free(buffer); +} + +// this is kinda sad, but I need to call the destructor in this module (exe), not the game.dll... +// +void G2API_LoadSaveCodeDestructGhoul2Info(CGhoul2Info_v &ghoul2) +{ + +#ifdef _G2_GORE + G2API_ClearSkinGore ( ghoul2 ); +#endif + ghoul2.~CGhoul2Info_v(); // so I can load junk over it then memset to 0 without orphaning +} + +//see if surfs have any shader info... +qboolean G2API_SkinlessModel(CGhoul2Info *g2) +{ + if (G2_SetupModelPointers(g2)) + { + model_t *mod = (model_t *)g2->currentModel; + + if (mod && + mod->mdxm) + { + mdxmSurfHierarchy_t *surf; + int i; + + surf = (mdxmSurfHierarchy_t *) ( (byte *)mod->mdxm + mod->mdxm->ofsSurfHierarchy ); + + for (i = 0; i < mod->mdxm->numSurfaces; i++) + { + if (surf->shader && surf->shader[0]) + { //found a surface with a shader name, ok. + return qfalse; + } + + surf = (mdxmSurfHierarchy_t *)( (byte *)surf + (intptr_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surf->numChildren ] )); + } + } + } + + //found nothing. + return qtrue; +} + +//#ifdef _SOF2 +#ifdef _G2_GORE +void ResetGoreTag(); // put here to reduce coupling + +//way of seeing how many marks are on a model currently -rww +int G2API_GetNumGoreMarks(CGhoul2Info *g2) +{ + if (g2->mGoreSetTag) + { + CGoreSet *goreSet = FindGoreSet(g2->mGoreSetTag); + + if (goreSet) + { + return goreSet->mGoreRecords.size(); + } + } + + return 0; +} + +void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 ) +{ + int i; + + for (i=0; iCvar_VariableIntegerValue( "r_lodbias" ))); + const int maxLod =Com_Clamp (0,ghoul2[0].currentModel->numLods,3); //limit to the number of lods the main model has + for(lod=lodbias;lodGetG2VertSpaceServer()->ResetHeap(); + + G2_TransformModel(ghoul2, gore.currentTime, gore.scale,ri->GetG2VertSpaceServer(),lod,true); + + // now walk each model and compute new texture coordinates + G2_TraceModels(ghoul2, transHitLocation, transRayDirection, 0, gore.entNum, 0,lod,0.0f,gore.SSize,gore.TSize,gore.theta,gore.shader,&gore,qtrue); + } +} +#endif + +qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model is properly set up +{ + G2ERROR(ghlInfo,"NULL ghlInfo"); + if (!ghlInfo) + { + return qfalse; + } + ghlInfo->mValid=false; + if (ghlInfo->mModelindex != -1) + { + if (ri->Cvar_VariableIntegerValue( "dedicated" ) || + (G2_ShouldRegisterServer())) //supreme hackery! + { + ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + } + else + { + ghlInfo->mModel = RE_RegisterModel(ghlInfo->mFileName); + } + ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel); + if (ghlInfo->currentModel) + { + if (ghlInfo->currentModel->mdxm) + { + if (ghlInfo->currentModelSize) + { + if (ghlInfo->currentModelSize!=ghlInfo->currentModel->mdxm->ofsEnd) + { + Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); + } + } + ghlInfo->currentModelSize=ghlInfo->currentModel->mdxm->ofsEnd; + ghlInfo->animModel = R_GetModelByHandle(ghlInfo->currentModel->mdxm->animIndex); + if (ghlInfo->animModel) + { + ghlInfo->aHeader =ghlInfo->animModel->mdxa; + if (ghlInfo->aHeader) + { + if (ghlInfo->currentAnimModelSize) + { + if (ghlInfo->currentAnimModelSize!=ghlInfo->aHeader->ofsEnd) + { + Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); + } + } + ghlInfo->currentAnimModelSize=ghlInfo->aHeader->ofsEnd; + ghlInfo->mValid=true; + } + } + } + } + } + if (!ghlInfo->mValid) + { + ghlInfo->currentModel=0; + ghlInfo->currentModelSize=0; + ghlInfo->animModel=0; + ghlInfo->currentAnimModelSize=0; + ghlInfo->aHeader=0; + } + return (qboolean)ghlInfo->mValid; +} + +#ifdef G2_PERFORMANCE_ANALYSIS +#include "qcommon/timing.h" +extern timing_c G2PerformanceTimer_G2_SetupModelPointers; +extern int G2Time_G2_SetupModelPointers; +#endif + +qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the model is properly set up +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_G2_SetupModelPointers.Start(); +#endif + G2ERROR(ghlInfo,"NULL ghlInfo"); + if (!ghlInfo) + { + return qfalse; + } + +// if (ghlInfo->mValid && ghlInfo->currentModel) + if (0) + { //rww - Why are we bothering with all this? We can't change models like this anyway. + //This function goes over 200k on the precision timer (in debug, but still), so I'm + //cutting it off here because it gets called constantly. +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_G2_SetupModelPointers += G2PerformanceTimer_G2_SetupModelPointers.End(); +#endif + return qtrue; + } + + ghlInfo->mValid=false; + +// G2WARNING(ghlInfo->mModelindex != -1,"Setup request on non-used info slot?"); + if (ghlInfo->mModelindex != -1) + { + G2ERROR(ghlInfo->mFileName[0],"empty ghlInfo->mFileName"); + + // RJ - experimental optimization! + if (!ghlInfo->mModel || 1) + { + if (ri->Cvar_VariableIntegerValue( "dedicated" ) || + (G2_ShouldRegisterServer())) //supreme hackery! + { + ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + } + else + { + ghlInfo->mModel = RE_RegisterModel(ghlInfo->mFileName); + } + ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel); + } + + G2ERROR(ghlInfo->currentModel,va("NULL Model (glm) %s",ghlInfo->mFileName)); + if (ghlInfo->currentModel) + { + G2ERROR(ghlInfo->currentModel->mdxm,va("Model has no mdxm (glm) %s",ghlInfo->mFileName)); + if (ghlInfo->currentModel->mdxm) + { + if (ghlInfo->currentModelSize) + { + if (ghlInfo->currentModelSize!=ghlInfo->currentModel->mdxm->ofsEnd) + { + Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); + } + } + ghlInfo->currentModelSize=ghlInfo->currentModel->mdxm->ofsEnd; + G2ERROR(ghlInfo->currentModelSize,va("Zero sized Model? (glm) %s",ghlInfo->mFileName)); + + ghlInfo->animModel = R_GetModelByHandle(ghlInfo->currentModel->mdxm->animIndex); + G2ERROR(ghlInfo->animModel,va("NULL Model (gla) %s",ghlInfo->mFileName)); + if (ghlInfo->animModel) + { + ghlInfo->aHeader =ghlInfo->animModel->mdxa; + G2ERROR(ghlInfo->aHeader,va("Model has no mdxa (gla) %s",ghlInfo->mFileName)); + if (ghlInfo->aHeader) + { + if (ghlInfo->currentAnimModelSize) + { + if (ghlInfo->currentAnimModelSize!=ghlInfo->aHeader->ofsEnd) + { + Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); + } + } + ghlInfo->currentAnimModelSize=ghlInfo->aHeader->ofsEnd; + G2ERROR(ghlInfo->currentAnimModelSize,va("Zero sized Model? (gla) %s",ghlInfo->mFileName)); + ghlInfo->mValid=true; + } + } + } + } + } + if (!ghlInfo->mValid) + { + ghlInfo->currentModel=0; + ghlInfo->currentModelSize=0; + ghlInfo->animModel=0; + ghlInfo->currentAnimModelSize=0; + ghlInfo->aHeader=0; + } + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_G2_SetupModelPointers += G2PerformanceTimer_G2_SetupModelPointers.End(); +#endif + return (qboolean)ghlInfo->mValid; +} + +qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2) // returns true if any model is properly set up +{ + bool ret=false; + int i; + for (i=0; imValid); + boltInfo_t tempBolt; + + // first up, make sure have a surface first + if (surfNum >= (int)slist.size()) + { + return -1; + } + + // look through entire list - see if it's already there first + for(size_t i=0; imValid); + model_t *mod_m = (model_t *)ghlInfo->currentModel; + model_t *mod_a = (model_t *)ghlInfo->animModel; + int x, surfNum = -1; + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + boltInfo_t tempBolt; + int flags; + + // first up, we'll search for that which this bolt names in all the surfaces + surfNum = G2_IsSurfaceLegal((void*)mod_m, boneName, &flags); + + // did we find it as a surface? + if (surfNum != -1) + { + // look through entire list - see if it's already there first + for(size_t i=0; imdxa + sizeof(mdxaHeader_t)); + + // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find + for (x=0; x< mod_a->mdxa->numBones; x++) + { + skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); + // if name is the same, we found it + if (!Q_stricmp(skel->name, boneName)) + { + break; + } + } + + // check to see we did actually make a match with a bone in the model + if (x == mod_a->mdxa->numBones) + { + // didn't find it? Error + //assert(0&&x == mod_a->mdxa->numBones); +#ifdef _DEBUG +// Com_Printf("WARNING: %s not found on skeleton\n", boneName); +#endif + return -1; + } + + // look through entire list - see if it's already there first + for(size_t i=0; i-1; i--) + { + if ((bltlist[i].surfaceNumber == -1) && (bltlist[i].boneNumber == -1)) + { + newSize = i; + } + // once we hit one that isn't a -1, we are done. + else + { + break; + } + } + // do we need to resize? + if (newSize != bltlist.size()) + { + // yes, so lets do it + bltlist.resize(newSize); + } + + } + return qtrue; + } + + assert(0); + + // no + return qfalse; +} + +// set the bolt list to all unused so the bone transformation routine ignores it. +void G2_Init_Bolt_List(boltInfo_v &bltlist) +{ + bltlist.clear(); +} + +// remove any bolts that reference original surfaces, generated surfaces, or bones that aren't active anymore +void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *activeSurfaces, int *activeBones) +{ + // walk the bolt list + for (size_t i=0; i +#else +#include +#endif +#include "ghoul2/G2_gore.h" + +//#define RAG_TRACE_DEBUG_LINES + +#include "client/client.h" //while this is all "shared" code, there are some places where we want to make cgame callbacks (for ragdoll) only if the cgvm exists +//rww - RAGDOLL_END + +//===================================================================================================================== +// Bone List handling routines - so entities can override bone info on a bone by bone level, and also interrogate this info + +// Given a bone name, see if that bone is already in our bone list - note the model_t pointer that gets passed in here MUST point at the +// gla file, not the glm file type. +int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) +{ + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[0]); + + // look through entire list + for(size_t i=0; imdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + + // if name is the same, we found it + if (!Q_stricmp(skel->name, boneName)) + { + return i; + } + } + + // didn't find it + return -1; +} + +// we need to add a bone to the list - find a free one and see if we can find a corresponding bone in the gla file +int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) +{ + int x; + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + boneInfo_t tempBone; + + //rww - RAGDOLL_BEGIN + memset(&tempBone, 0, sizeof(tempBone)); + //rww - RAGDOLL_END + + offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); + + // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find + for (x=0; x< mod->mdxa->numBones; x++) + { + skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); + // if name is the same, we found it + if (!Q_stricmp(skel->name, boneName)) + { + break; + } + } + + // check to see we did actually make a match with a bone in the model + if (x == mod->mdxa->numBones) + { + // didn't find it? Error + //assert(0); +#ifdef _DEBUG + Com_Printf("WARNING: Failed to add bone %s\n", boneName); +#endif + +#ifdef _RAG_PRINT_TEST + Com_Printf("WARNING: Failed to add bone %s\n", boneName); +#endif + return -1; + } + + // look through entire list - see if it's already there first + for(size_t i=0; imdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + // if name is the same, we found it + if (!Q_stricmp(skel->name, boneName)) + { + return i; + } + } + else + { + // if we found an entry that had a -1 for the bonenumber, then we hit a bone slot that was empty + blist[i].boneNumber = x; + blist[i].flags = 0; + return i; + } + } + +#ifdef _RAG_PRINT_TEST + Com_Printf("New bone added for %s\n", boneName); +#endif + // ok, we didn't find an existing bone of that name, or an empty slot. Lets add an entry + tempBone.boneNumber = x; + tempBone.flags = 0; + blist.push_back(tempBone); + return blist.size()-1; +} + + +// Given a model handle, and a bone name, we want to remove this bone from the bone override list +qboolean G2_Remove_Bone_Index ( boneInfo_v &blist, int index) +{ + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + } + + // did we find it? + if (index != -1) + { + // check the flags first - if it's still being used Do NOT remove it + if (!blist[index].flags) + { + + // set this bone to not used + blist[index].boneNumber = -1; + + unsigned int newSize = blist.size(); + // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list + for (int i=blist.size()-1; i>-1; i--) + { + if (blist[i].boneNumber == -1) + { + newSize = i; + } + // once we hit one that isn't a -1, we are done. + else + { + break; + } + } + // do we need to resize? + if (newSize != blist.size()) + { + // yes, so lets do it + blist.resize(newSize); + } + + return qtrue; + } + } + +// assert(0); + // no + return qfalse; +} + +// given a bone number, see if there is an override bone in the bone list +int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum) +{ + // look through entire list + for(size_t i=0; imdxa + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[index].boneNumber]); + + Multiply_3x4Matrix(&temp1, boneOverride,&skel->BasePoseMatInv); + Multiply_3x4Matrix(boneOverride,&skel->BasePoseMat, &temp1); + + } + else + { + VectorCopy(angles, newAngles); + + // why I should need do this Fuck alone knows. But I do. + if (left == POSITIVE_Y) + { + newAngles[0] +=180; + } + + Create_Matrix(newAngles, &temp1); + + permutation.matrix[0][0] = permutation.matrix[0][1] = permutation.matrix[0][2] = permutation.matrix[0][3] = 0; + permutation.matrix[1][0] = permutation.matrix[1][1] = permutation.matrix[1][2] = permutation.matrix[1][3] = 0; + permutation.matrix[2][0] = permutation.matrix[2][1] = permutation.matrix[2][2] = permutation.matrix[2][3] = 0; + + // determine what axis newAngles Yaw should revolve around + switch (forward) + { + case NEGATIVE_X: + permutation.matrix[0][0] = -1; // works + break; + case POSITIVE_X: + permutation.matrix[0][0] = 1; // works + break; + case NEGATIVE_Y: + permutation.matrix[1][0] = -1; + break; + case POSITIVE_Y: + permutation.matrix[1][0] = 1; + break; + case NEGATIVE_Z: + permutation.matrix[2][0] = -1; + break; + case POSITIVE_Z: + permutation.matrix[2][0] = 1; + break; + default: + break; + } + + // determine what axis newAngles pitch should revolve around + switch (left) + { + case NEGATIVE_X: + permutation.matrix[0][1] = -1; + break; + case POSITIVE_X: + permutation.matrix[0][1] = 1; + break; + case NEGATIVE_Y: + permutation.matrix[1][1] = -1; // works + break; + case POSITIVE_Y: + permutation.matrix[1][1] = 1; // works + break; + case NEGATIVE_Z: + permutation.matrix[2][1] = -1; + break; + case POSITIVE_Z: + permutation.matrix[2][1] = 1; + break; + default: + break; + } + + // determine what axis newAngles Roll should revolve around + switch (up) + { + case NEGATIVE_X: + permutation.matrix[0][2] = -1; + break; + case POSITIVE_X: + permutation.matrix[0][2] = 1; + break; + case NEGATIVE_Y: + permutation.matrix[1][2] = -1; + break; + case POSITIVE_Y: + permutation.matrix[1][2] = 1; + break; + case NEGATIVE_Z: + permutation.matrix[2][2] = -1; // works + break; + case POSITIVE_Z: + permutation.matrix[2][2] = 1; // works + break; + default: + break; + } + + Multiply_3x4Matrix(boneOverride, &temp1,&permutation); + + } + + // keep a copy of the matrix in the newmatrix which is actually what we use + memcpy(&blist[index].newMatrix, &blist[index].matrix, sizeof(mdxaBone_t)); + +} + +//========================================================================================= +//// Public Bone Routines + + +// Given a model handle, and a bone name, we want to remove this bone from the bone override list +qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName) +{ + int index; + + assert(ghlInfo->animModel); + index = G2_Find_Bone(ghlInfo->animModel, blist, boneName); + + return G2_Remove_Bone_Index(blist, index); +} + +#define DEBUG_PCJ (0) + + +// Given a model handle, and a bone name, we want to set angles specifically for overriding +qboolean G2_Set_Bone_Angles_Index( boneInfo_v &blist, const int index, + const float *angles, const int flags, const Eorientations yaw, + const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, + const int modelIndex, const int blendTime, const int currentTime) +{ + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + { + // we are attempting to set a bone override that doesn't exist + assert(0); + return qfalse; + } + + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + } + + if (flags & (BONE_ANGLES_PREMULT | BONE_ANGLES_POSTMULT)) + { + // you CANNOT call this with an index with these kinds of bone overrides - we need the model details for these kinds of bone angle overrides + assert(0); + return qfalse; + } + + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + blist[index].boneBlendStart = currentTime; + blist[index].boneBlendTime = blendTime; +#if DEBUG_PCJ + Com_OPrintf("PCJ %2d %6d (%6.2f,%6.2f,%6.2f) %d %d %d %d\n",index,currentTime,angles[0],angles[1],angles[2],yaw,pitch,roll,flags); +#endif + + G2_Generate_Matrix(NULL, blist, index, angles, flags, yaw, pitch, roll); + return qtrue; + +} + +// Given a model handle, and a bone name, we want to set angles specifically for overriding +qboolean G2_Set_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const float *angles, + const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, + qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime) +{ + model_t *mod_a; + + mod_a = (model_t *)ghlInfo->animModel; + + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + blist[index].boneBlendStart = currentTime; + blist[index].boneBlendTime = blendTime; +#if DEBUG_PCJ + Com_OPrintf("%2d %6d (%6.2f,%6.2f,%6.2f) %d %d %d %d\n",index,currentTime,angles[0],angles[1],angles[2],up,left,forward,flags); +#endif + + G2_Generate_Matrix(mod_a, blist, index, angles, flags, up, left, forward); + return qtrue; + } + + // no - lets try and add this bone in + index = G2_Add_Bone(mod_a, blist, boneName); + + // did we find a free one? + if (index != -1) + { + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + blist[index].boneBlendStart = currentTime; + blist[index].boneBlendTime = blendTime; +#if DEBUG_PCJ + Com_OPrintf("%2d %6d (%6.2f,%6.2f,%6.2f) %d %d %d %d\n",index,currentTime,angles[0],angles[1],angles[2],up,left,forward,flags); +#endif + + G2_Generate_Matrix(mod_a, blist, index, angles, flags, up, left, forward); + return qtrue; + } +// assert(0); + //Jeese, we don't need an assert here too. There's already a warning in G2_Add_Bone if it fails. + + // no + return qfalse; +} + +// Given a model handle, and a bone name, we want to set angles specifically for overriding - using a matrix directly +qboolean G2_Set_Bone_Angles_Matrix_Index(boneInfo_v &blist, const int index, + const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, + const int modelIndex, const int blendTime, const int currentTime) +{ + + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + { + // we are attempting to set a bone override that doesn't exist + assert(0); + return qfalse; + } + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + } + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + blist[index].boneBlendStart = currentTime; + blist[index].boneBlendTime = blendTime; + + memcpy(&blist[index].matrix, &matrix, sizeof(mdxaBone_t)); + memcpy(&blist[index].newMatrix, &matrix, sizeof(mdxaBone_t)); + return qtrue; + +} + +// Given a model handle, and a bone name, we want to set angles specifically for overriding - using a matrix directly +qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, const char *boneName, const mdxaBone_t &matrix, + const int flags, qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime) +{ + model_t *mod_m; + if (!fileName[0]) + { + mod_m = R_GetModelByHandle(modelList[modelIndex]); + } + else + { + mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + } + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + int index = G2_Find_Bone(mod_a, blist, boneName); + + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + } + + // did we find it? + if (index != -1) + { + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + + memcpy(&blist[index].matrix, &matrix, sizeof(mdxaBone_t)); + memcpy(&blist[index].newMatrix, &matrix, sizeof(mdxaBone_t)); + return qtrue; + } + + // no - lets try and add this bone in + index = G2_Add_Bone(mod_a, blist, boneName); + + // did we find a free one? + if (index != -1) + { + // yes, so set the angles and flags correctly + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags |= flags; + + memcpy(&blist[index].matrix, &matrix, sizeof(mdxaBone_t)); + memcpy(&blist[index].newMatrix, &matrix, sizeof(mdxaBone_t)); + return qtrue; + } + assert(0); + + // no + return qfalse; +} + +#define DEBUG_G2_TIMING (0) + +// given a model, bone name, a bonelist, a start/end frame number, a anim speed and some anim flags, set up or modify an existing bone entry for a new set of anims +qboolean G2_Set_Bone_Anim_Index( + boneInfo_v &blist, + const int index, + const int startFrame, + const int endFrame, + const int flags, + const float animSpeed, + const int currentTime, + const float setFrame, + const int blendTime, + const int numFrames) +{ + int modFlags = flags; + + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + { + // we are attempting to set a bone override that doesn't exist + assert(0); + return qfalse; + } + + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + + //mark it for needing a transform for the cached trace transform stuff + blist[index].flags |= BONE_NEED_TRANSFORM; + } + + if (setFrame != -1) + { + assert((setFrame >= startFrame) && (setFrame <= endFrame)); + } + if (flags & BONE_ANIM_BLEND) + { + float currentFrame, animSpeed; + int startFrame, endFrame, flags; + // figure out where we are now + if (G2_Get_Bone_Anim_Index(blist, index, currentTime, ¤tFrame, &startFrame, &endFrame, &flags, &animSpeed, NULL, numFrames)) + { + if (blist[index].blendStart == currentTime) //we're replacing a blend in progress which hasn't started + { + // set the amount of time it's going to take to blend this anim with the last frame of the last one + blist[index].blendTime = blendTime; + } + else + { + if (animSpeed<0.0f) + { + blist[index].blendFrame = floor(currentFrame); + blist[index].blendLerpFrame = floor(currentFrame); + } + else + { + blist[index].blendFrame = currentFrame; + blist[index].blendLerpFrame = currentFrame+1; + + // cope with if the lerp frame is actually off the end of the anim + if (blist[index].blendFrame >= endFrame ) + { + // we only want to lerp with the first frame of the anim if we are looping + if (blist[index].flags & BONE_ANIM_OVERRIDE_LOOP) + { + blist[index].blendFrame = startFrame; + } + // if we intend to end this anim or freeze after this, then just keep on the last frame + else + { + // assert(endFrame>0); + if (endFrame <= 0) + { + blist[index].blendLerpFrame = 0; + } + else + { + blist[index].blendFrame = endFrame -1; + } + } + } + + // cope with if the lerp frame is actually off the end of the anim + if (blist[index].blendLerpFrame >= endFrame ) + { + // we only want to lerp with the first frame of the anim if we are looping + if (blist[index].flags & BONE_ANIM_OVERRIDE_LOOP) + { + blist[index].blendLerpFrame = startFrame; + } + // if we intend to end this anim or freeze after this, then just keep on the last frame + else + { + // assert(endFrame>0); + if (endFrame <= 0) + { + blist[index].blendLerpFrame = 0; + } + else + { + blist[index].blendLerpFrame = endFrame - 1; + } + } + } + } + // set the amount of time it's going to take to blend this anim with the last frame of the last one + blist[index].blendTime = blendTime; + blist[index].blendStart = currentTime; + + } + } + // hmm, we weren't animating on this bone. In which case disable the blend + else + { + blist[index].blendFrame = blist[index].blendLerpFrame = 0; + blist[index].blendTime = 0; + modFlags &= ~(BONE_ANIM_BLEND); + } + } + else + { + blist[index].blendFrame = blist[index].blendLerpFrame = 0; + blist[index].blendTime = blist[index].blendStart = 0; + // we aren't blending, so remove the option to do so + modFlags &= ~BONE_ANIM_BLEND; + } + // yes, so set the anim data and flags correctly + blist[index].endFrame = endFrame; + blist[index].startFrame = startFrame; + blist[index].animSpeed = animSpeed; + blist[index].pauseTime = 0; + // start up the animation:) + if (setFrame != -1) + { + blist[index].lastTime = blist[index].startTime = (currentTime - (((setFrame - (float)startFrame) * 50.0)/ animSpeed)); + } + else + { + blist[index].lastTime = blist[index].startTime = currentTime; + } + blist[index].flags &= ~(BONE_ANIM_TOTAL); + if (blist[index].flags < 0) + { + blist[index].flags = 0; + } + blist[index].flags |= modFlags; + +#if DEBUG_G2_TIMING + if (index==2) + { + const boneInfo_t &bone=blist[index]; + char mess[1000]; + if (bone.flags&BONE_ANIM_BLEND) + { + sprintf(mess,"sab[%2d] %5d %5d (%5d-%5d) %4.2f %4x bt(%5d-%5d) %7.2f %5d\n", + index, + currentTime, + bone.startTime, + bone.startFrame, + bone.endFrame, + bone.animSpeed, + bone.flags, + bone.blendStart, + bone.blendStart+bone.blendTime, + bone.blendFrame, + bone.blendLerpFrame + ); + } + else + { + sprintf(mess,"saa[%2d] %5d %5d (%5d-%5d) %4.2f %4x\n", + index, + currentTime, + bone.startTime, + bone.startFrame, + bone.endFrame, + bone.animSpeed, + bone.flags + ); + } + Com_OPrintf("%s",mess); + } +#endif + + return qtrue; + +} + +// given a model, bone name, a bonelist, a start/end frame number, a anim speed and some anim flags, set up or modify an existing bone entry for a new set of anims +qboolean G2_Set_Bone_Anim(CGhoul2Info *ghlInfo, + boneInfo_v &blist, + const char *boneName, + const int startFrame, + const int endFrame, + const int flags, + const float animSpeed, + const int currentTime, + const float setFrame, + const int blendTime) +{ + model_t *mod_a = (model_t *)ghlInfo->animModel; + + int index = G2_Find_Bone(mod_a, blist, boneName); + if (index == -1) + { + index = G2_Add_Bone(mod_a, blist, boneName); + } + + if (index != -1) + { + if (blist[index].flags & BONE_ANGLES_RAGDOLL) + { + return qtrue; // don't accept any calls on ragdoll bones + } + } + + if (index != -1) + { + return G2_Set_Bone_Anim_Index(blist,index,startFrame,endFrame,flags,animSpeed,currentTime,setFrame,blendTime,ghlInfo->aHeader->numFrames); + } + return qfalse; +} + +qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, int *startFrame, int *endFrame) +{ + model_t *mod_a = (model_t *)ghlInfo->animModel; + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + // are we an animating bone? + if (blist[index].flags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) + { + *startFrame = blist[index].startFrame; + *endFrame = blist[index].endFrame; + return qtrue; + } + } + return qfalse; +} + +// given a model, bonelist and bonename, return the current frame, startframe and endframe of the current animation +// NOTE if we aren't running an animation, then qfalse is returned +void G2_TimingModel(boneInfo_t &bone,int currentTime,int numFramesInFile,int ¤tFrame,int &newFrame,float &lerp); + +qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int currentTime, + float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int numFrames) +{ + + // did we find it? + if ((index>=0) && !((index >= (int)blist.size()) || (blist[index].boneNumber == -1))) + { + + // are we an animating bone? + if (blist[index].flags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) + { + int lcurrentFrame,newFrame; + float lerp; + G2_TimingModel(blist[index],currentTime,numFrames,lcurrentFrame,newFrame,lerp); + + *currentFrame =float(lcurrentFrame)+lerp; + *startFrame = blist[index].startFrame; + *endFrame = blist[index].endFrame; + *flags = blist[index].flags; + *retAnimSpeed = blist[index].animSpeed; + return qtrue; + } + } + *startFrame=0; + *endFrame=1; + *currentFrame=0.0f; + *flags=0; + *retAnimSpeed=0.0f; + return qfalse; +} + +// given a model, bonelist and bonename, return the current frame, startframe and endframe of the current animation +// NOTE if we aren't running an animation, then qfalse is returned +qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime, + float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int modelIndex) +{ + model_t *mod_a = (model_t *)ghlInfo->animModel; + + int index = G2_Find_Bone(mod_a, blist, boneName); + + if (index==-1) + { + index = G2_Add_Bone(mod_a, blist, boneName); + + if (index == -1) + { + return qfalse; + } + } + + assert(ghlInfo->aHeader); + + if (G2_Get_Bone_Anim_Index(blist, index, currentTime, currentFrame, startFrame, endFrame, flags, retAnimSpeed, modelList, ghlInfo->aHeader->numFrames)) + { + assert(*startFrame>=0&&*startFrameaHeader->numFrames); + assert(*endFrame>0&&*endFrame<=ghlInfo->aHeader->numFrames); + assert(*currentFrame>=0.0f&&((int)(*currentFrame))aHeader->numFrames); + return qtrue; + } + + return qfalse; +} + +// given a model, bonelist and bonename, lets pause an anim if it's playing. +qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime) +{ + model_t *mod_a = (model_t *)ghlInfo->animModel; + + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + // are we pausing or un pausing? + if (blist[index].pauseTime) + { + int startFrame, endFrame, flags; + float currentFrame, animSpeed; + + // figure out what frame we are on now + G2_Get_Bone_Anim(ghlInfo, blist, boneName, blist[index].pauseTime, ¤tFrame, &startFrame, &endFrame, &flags, &animSpeed, NULL, 0); + // reset start time so we are actually on this frame right now + G2_Set_Bone_Anim(ghlInfo, blist, boneName, startFrame, endFrame, flags, animSpeed, currentTime, currentFrame, 0); + // no pausing anymore + blist[index].pauseTime = 0; + } + // ahh, just pausing, the easy bit + else + { + blist[index].pauseTime = currentTime; + } + + return qtrue; + } + assert(0); + + return qfalse; +} + +qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName) +{ + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + // are we paused? + if (blist[index].pauseTime) + { + // yup. paused. + return qtrue; + } + return qfalse; + } + + return qfalse; +} + +// given a model, bonelist and bonename, lets stop an anim if it's playing. +qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) +{ + + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + { + // we are attempting to set a bone override that doesn't exist + assert(0); + return qfalse; + } + + blist[index].flags &= ~(BONE_ANIM_TOTAL); + // try and remove this bone if we can + return G2_Remove_Bone_Index(blist, index); +} + +// given a model, bonelist and bonename, lets stop an anim if it's playing. +qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName) +{ + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + blist[index].flags &= ~(BONE_ANIM_TOTAL); + // try and remove this bone if we can + return G2_Remove_Bone_Index(blist, index); + } + assert(0); + + return qfalse; +} + +// given a model, bonelist and bonename, lets stop an anim if it's playing. +qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) +{ + + if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + { + // we are attempting to set a bone override that doesn't exist + assert(0); + return qfalse; + } + + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + // try and remove this bone if we can + return G2_Remove_Bone_Index(blist, index); + +} + +// given a model, bonelist and bonename, lets stop an anim if it's playing. +qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName) +{ + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + int index = G2_Find_Bone(mod_a, blist, boneName); + + // did we find it? + if (index != -1) + { + blist[index].flags &= ~(BONE_ANGLES_TOTAL); + // try and remove this bone if we can + return G2_Remove_Bone_Index(blist, index); + } + assert(0); + + return qfalse; +} + + +// actually walk the bone list and update each and every bone if we have ended an animation for them. +void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const int index ) +{ + boneInfo_v &blist = ghoul2[index].mBlist; + + // look through entire list + for(size_t i=0; i 0.0f) && (newFrame_g > endFrame-1 )) || + ((animSpeed < 0.0f) && (newFrame_g < endFrame+1 ))) + { + // yep - decide what to do + if (blist[i].flags & BONE_ANIM_OVERRIDE_LOOP) + { + // get our new animation frame back within the bounds of the animation set + if (animSpeed < 0.0f) + { + if (newFrame_g <= endFrame+1) + { + newFrame_g=endFrame+fmod(newFrame_g-endFrame,animSize)-animSize; + } + } + else + { + if (newFrame_g >= endFrame) + { + newFrame_g=endFrame+fmod(newFrame_g-endFrame,animSize)-animSize; + } + } + // figure out new start time + float frameTime = newFrame_g - blist[i].startFrame ; + blist[i].startTime = currentTime - (int)((frameTime / animSpeed) * 50.0f); + if (blist[i].startTime>currentTime) + { + blist[i].startTime=currentTime; + } + assert(blist[i].startTime <= currentTime); + blist[i].lastTime = blist[i].startTime; + } + else + { + if ((blist[i].flags & BONE_ANIM_OVERRIDE_FREEZE) != BONE_ANIM_OVERRIDE_FREEZE) + { + // nope, just stop it. And remove the bone if possible + G2_Stop_Bone_Index(blist, i, (BONE_ANIM_TOTAL)); + } + } + } + } + } + } + } +} + +//rww - RAGDOLL_BEGIN +/* + + + rag stuff + +*/ +static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameNum,const vec3_t currentOrg,bool LimitAngles,CRagDollUpdateParams *params = NULL); +static void G2_RagDollCurrentPosition(CGhoul2Info_v &ghoul2V,int g2Index,int frameNum,const vec3_t angles,const vec3_t position,const vec3_t scale); +static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V,const vec3_t currentOrg,CRagDollUpdateParams *params, int curTime); +static bool G2_RagDollSetup(CGhoul2Info &ghoul2,int frameNum,bool resetOrigin,const vec3_t origin,bool anyRendered); + +void G2_GetBoneBasepose(CGhoul2Info &ghoul2,int boneNum,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv); +int G2_GetBoneDependents(CGhoul2Info &ghoul2,int boneNum,int *tempDependents,int maxDep); +void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv); +int G2_GetParentBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv); +bool G2_WasBoneRendered(CGhoul2Info &ghoul2,int boneNum); + +#define MAX_BONES_RAG (256) + +struct SRagEffector +{ + vec3_t currentOrigin; + vec3_t desiredDirection; + vec3_t desiredOrigin; + float radius; + float weight; +}; + +#define RAG_MASK (CONTENTS_SOLID|CONTENTS_TERRAIN)//|CONTENTS_SHOTCLIP|CONTENTS_TERRAIN//(/*MASK_SOLID|*/CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_SHOTCLIP|CONTENTS_TERRAIN|CONTENTS_BODY) + +extern cvar_t *broadsword; +extern cvar_t *broadsword_kickbones; +extern cvar_t *broadsword_kickorigin; +extern cvar_t *broadsword_dontstopanim; +extern cvar_t *broadsword_waitforshot; +extern cvar_t *broadsword_playflop; + +extern cvar_t *broadsword_effcorr; + +extern cvar_t *broadsword_ragtobase; + +extern cvar_t *broadsword_dircap; + +extern cvar_t *broadsword_extra1; +extern cvar_t *broadsword_extra2; + +#define RAG_PCJ (0x00001) +#define RAG_PCJ_POST_MULT (0x00002) // has the pcj flag as well +#define RAG_PCJ_MODEL_ROOT (0x00004) // has the pcj flag as well +#define RAG_PCJ_PELVIS (0x00008) // has the pcj flag and POST_MULT as well +#define RAG_EFFECTOR (0x00100) +#define RAG_WAS_NOT_RENDERED (0x01000) // not particularily reliable, more of a hint +#define RAG_WAS_EVER_RENDERED (0x02000) // not particularily reliable, more of a hint +#define RAG_BONE_LIGHTWEIGHT (0x04000) //used to indicate a bone's velocity treatment +#define RAG_PCJ_IK_CONTROLLED (0x08000) //controlled from IK move input +#define RAG_UNSNAPPABLE (0x10000) //cannot be broken out of constraints ever + +// thiese flags are on the model and correspond to... +//#define GHOUL2_RESERVED_FOR_RAGDOLL 0x0ff0 // these are not defined here for dependecies sake +#define GHOUL2_RAG_STARTED 0x0010 // we are actually a ragdoll +#define GHOUL2_RAG_PENDING 0x0100 // got start death anim but not end death anim +#define GHOUL2_RAG_DONE 0x0200 // got end death anim +#define GHOUL2_RAG_COLLISION_DURING_DEATH 0x0400 // ever have gotten a collision (da) event +#define GHOUL2_RAG_COLLISION_SLIDE 0x0800 // ever have gotten a collision (slide) event +#define GHOUL2_RAG_FORCESOLVE 0x1000 //api-override, determine if ragdoll should be forced to continue solving even if it thinks it is settled + +//#define flrand Q_flrand + +static mdxaBone_t* ragBasepose[MAX_BONES_RAG]; +static mdxaBone_t* ragBaseposeInv[MAX_BONES_RAG]; +static mdxaBone_t ragBones[MAX_BONES_RAG]; +static SRagEffector ragEffectors[MAX_BONES_RAG]; +static boneInfo_t *ragBoneData[MAX_BONES_RAG]; +static int tempDependents[MAX_BONES_RAG]; +static int ragBlistIndex[MAX_BONES_RAG]; +static int numRags; +static vec3_t ragBoneMins; +static vec3_t ragBoneMaxs; +static vec3_t ragBoneCM; +static bool haveDesiredPelvisOffset=false; +static vec3_t desiredPelvisOffset; // this is for the root +static float ragOriginChange=0.0f; +static vec3_t ragOriginChangeDir; +//debug +#if 0 +static vec3_t handPos={0,0,0}; +static vec3_t handPos2={0,0,0}; +#endif + +enum ERagState +{ + ERS_DYNAMIC, + ERS_SETTLING, + ERS_SETTLED +}; +static int ragState; + +static vector rag; // once we get the dependents precomputed this can be local + + +static void G2_Generate_MatrixRag( + // caution this must not be called before the whole skeleton is "remembered" + boneInfo_v &blist, + int index) +{ + + + boneInfo_t &bone=blist[index];//.sent; + + memcpy(&bone.matrix,&bone.ragOverrideMatrix, sizeof(mdxaBone_t)); +#ifdef _DEBUG + int i,j; + for (i = 0; i < 3; i++ ) + { + for (j = 0; j < 4; j++ ) + { + assert( !Q_isnan(bone.matrix.matrix[i][j])); + } + } +#endif// _DEBUG + memcpy(&blist[index].newMatrix,&bone.matrix, sizeof(mdxaBone_t)); +} + +int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName) +{ + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + + offsets = (mdxaSkelOffsets_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t) + offsets->offsets[0]); + + /* + model_t *currentModel; + model_t *animModel; + mdxaHeader_t *aHeader; + + currentModel = R_GetModelByHandle(RE_RegisterModel(ghlInfo->mFileName)); + assert(currentModel); + animModel = R_GetModelByHandle(currentModel->mdxm->animIndex); + assert(animModel); + aHeader = animModel->mdxa; + assert(aHeader); + + offsets = (mdxaSkelOffsets_t *)((byte *)aHeader + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)aHeader + sizeof(mdxaHeader_t) + offsets->offsets[0]); + */ + + // look through entire list + for(size_t i=0; iaHeader + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + //skel = (mdxaSkel_t *)((byte *)aHeader + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + + // if name is the same, we found it + if (!Q_stricmp(skel->name, boneName)) + { + return i; + } + } +#if _DEBUG +// G2_Bone_Not_Found(boneName,ghlInfo->mFileName); +#endif + // didn't find it + return -1; +} + +static int G2_Set_Bone_Rag(const mdxaHeader_t *mod_a, + boneInfo_v &blist, + const char *boneName, + CGhoul2Info &ghoul2, + const vec3_t scale, + const vec3_t origin) +{ + // do not change the state of the skeleton here + int index = G2_Find_Bone_Rag(&ghoul2, blist, boneName); + + if (index == -1) + { + index = G2_Add_Bone(ghoul2.animModel, blist, boneName); + } + + if (index != -1) + { + boneInfo_t &bone=blist[index]; + VectorCopy(origin,bone.extraVec1); + + G2_GetBoneMatrixLow(ghoul2,bone.boneNumber,scale,bone.originalTrueBoneMatrix,bone.basepose,bone.baseposeInv); +// bone.parentRawBoneIndex=G2_GetParentBoneMatrixLow(ghoul2,bone.boneNumber,scale,bone.parentTrueBoneMatrix,bone.baseposeParent,bone.baseposeInvParent); + assert( !Q_isnan(bone.originalTrueBoneMatrix.matrix[1][1])); + assert( !Q_isnan(bone.originalTrueBoneMatrix.matrix[1][3])); + bone.originalOrigin[0]=bone.originalTrueBoneMatrix.matrix[0][3]; + bone.originalOrigin[1]=bone.originalTrueBoneMatrix.matrix[1][3]; + bone.originalOrigin[2]=bone.originalTrueBoneMatrix.matrix[2][3]; + } + return index; +} + +static int G2_Set_Bone_Angles_Rag( + CGhoul2Info &ghoul2, + const mdxaHeader_t *mod_a, + boneInfo_v &blist, + const char *boneName, + const int flags, + const float radius, + const vec3_t angleMin=0, + const vec3_t angleMax=0, + const int blendTime=500) +{ + int index = G2_Find_Bone_Rag(&ghoul2, blist, boneName); + + if (index == -1) + { + index = G2_Add_Bone(ghoul2.animModel, blist, boneName); + } + if (index != -1) + { + boneInfo_t &bone=blist[index]; + bone.flags &= ~(BONE_ANGLES_TOTAL); + bone.flags |= BONE_ANGLES_RAGDOLL; + if (flags&RAG_PCJ) + { + if (flags&RAG_PCJ_POST_MULT) + { + bone.flags |= BONE_ANGLES_POSTMULT; + } + else if (flags&RAG_PCJ_MODEL_ROOT) + { + bone.flags |= BONE_ANGLES_PREMULT; +// bone.flags |= BONE_ANGLES_POSTMULT; + } + else + { + assert(!"Invalid RAG PCJ\n"); + } + } + bone.ragStartTime=G2API_GetTime(0); + bone.boneBlendStart = bone.ragStartTime; + bone.boneBlendTime = blendTime; + bone.radius=radius; + bone.weight=1.0f; + + //init the others to valid values + bone.epGravFactor = 0; + VectorClear(bone.epVelocity); + bone.solidCount = 0; + bone.physicsSettled = false; + bone.snapped = false; + + bone.parentBoneIndex = -1; + + bone.offsetRotation = 0.0f; + + bone.overGradSpeed = 0.0f; + VectorClear(bone.overGoalSpot); + bone.hasOverGoal = false; + bone.hasAnimFrameMatrix = -1; + +// bone.weight=pow(radius,1.7f); //cubed was too harsh +// bone.weight=radius*radius*radius; + if (angleMin&&angleMax) + { + VectorCopy(angleMin,bone.minAngles); + VectorCopy(angleMax,bone.maxAngles); + } + else + { + VectorCopy(bone.currentAngles,bone.minAngles); // I guess this isn't a rag pcj then + VectorCopy(bone.currentAngles,bone.maxAngles); + } + if (!bone.lastTimeUpdated) + { + static mdxaBone_t id = + { + { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f } + } + }; + memcpy(&bone.ragOverrideMatrix,&id, sizeof(mdxaBone_t)); + VectorClear(bone.anglesOffset); + VectorClear(bone.positionOffset); + VectorClear(bone.velocityEffector); // this is actually a velocity now + VectorClear(bone.velocityRoot); // this is actually a velocity now + VectorClear(bone.lastPosition); + VectorClear(bone.lastShotDir); + bone.lastContents=0; + // if this is non-zero, we are in a dynamic state + bone.firstCollisionTime=bone.ragStartTime; + // if this is non-zero, we are in a settling state + bone.restTime=0; + // if they are both zero, we are in a settled state + + bone.firstTime=0; + + bone.RagFlags=flags; + bone.DependentRagIndexMask=0; + + G2_Generate_MatrixRag(blist,index); // set everything to th id + +#if 0 + VectorClear(bone.currentAngles); +// VectorAdd(bone.minAngles,bone.maxAngles,bone.currentAngles); +// VectorScale(bone.currentAngles,0.5f,bone.currentAngles); +#else + { + if ( + (flags&RAG_PCJ_MODEL_ROOT) || + (flags&RAG_PCJ_PELVIS) || + !(flags&RAG_PCJ)) + { + VectorClear(bone.currentAngles); + } + else + { + int k; + for (k=0;k<3;k++) + { + float scalar=flrand(-1.0f,1.0f); + scalar*=flrand(-1.0f,1.0f)*flrand(-1.0f,1.0f); + // this is a heavily central distribution + // center it on .5 (and make it small) + scalar*=0.5f; + scalar+=0.5f; + + bone.currentAngles[k]=(bone.minAngles[k]-bone.maxAngles[k])*scalar+bone.maxAngles[k]; + } + } + } +// VectorClear(bone.currentAngles); +#endif + VectorCopy(bone.currentAngles,bone.lastAngles); + } + } + return index; +} + +class CRagDollParams; +const mdxaHeader_t *G2_GetModA(CGhoul2Info &ghoul2); + + +static void G2_RagDollMatchPosition() +{ + haveDesiredPelvisOffset=false; + int i; + for (i=0;iCallRagDollBegin=qfalse; + } + if (!broadsword||!broadsword->integer||!parms) + { + return; + } + int model; + for (model = 0; model < ghoul2V.size(); model++) + { + if (ghoul2V[model].mModelindex != -1) + { + break; + } + } + if (model==ghoul2V.size()) + { + return; + } + CGhoul2Info &ghoul2=ghoul2V[model]; + const mdxaHeader_t *mod_a=G2_GetModA(ghoul2); + if (!mod_a) + { + return; + } + int curTime=G2API_GetTime(0); + boneInfo_v &blist = ghoul2.mBlist; + int index = G2_Find_Bone_Rag(&ghoul2, blist, "model_root"); + switch (parms->RagPhase) + { + case CRagDollParams::RP_START_DEATH_ANIM: + ghoul2.mFlags|=GHOUL2_RAG_PENDING; + return; /// not doing anything with this yet + break; + case CRagDollParams::RP_END_DEATH_ANIM: + ghoul2.mFlags|=GHOUL2_RAG_PENDING|GHOUL2_RAG_DONE; + if (broadsword_waitforshot && + broadsword_waitforshot->integer) + { + if (broadsword_waitforshot->integer==2) + { + if (!(ghoul2.mFlags&(GHOUL2_RAG_COLLISION_DURING_DEATH|GHOUL2_RAG_COLLISION_SLIDE))) + { + //nothing was encountered, lets just wait for the first shot + return; // we ain't starting yet + } + } + else + { + return; // we ain't starting yet + } + } + break; + case CRagDollParams::RP_DEATH_COLLISION: + if (parms->collisionType) + { + ghoul2.mFlags|=GHOUL2_RAG_COLLISION_SLIDE; + } + else + { + ghoul2.mFlags|=GHOUL2_RAG_COLLISION_DURING_DEATH; + } + if (broadsword_dontstopanim && broadsword_waitforshot && + (broadsword_dontstopanim->integer || broadsword_waitforshot->integer) + ) + { + if (!(ghoul2.mFlags&GHOUL2_RAG_DONE)) + { + return; // we ain't starting yet + } + } + break; + case CRagDollParams::RP_CORPSE_SHOT: + if (broadsword_kickorigin && + broadsword_kickorigin->integer) + { + if (index>=0&&index<(int)blist.size()) + { + boneInfo_t &bone=blist[index]; + if (bone.boneNumber>=0) + { + if (bone.flags & BONE_ANGLES_RAGDOLL) + { + //rww - Would need ent pointer here. But.. since this is SW, we aren't even having corpse shooting anyway I'd imagine. + /* + float magicFactor14=8.0f; //64.0f; // kick strength + + if (parms->fShotStrength) + { //if there is a shot strength, use it instead + magicFactor14 = parms->fShotStrength; + } + + parms->me->s.pos.trType = TR_GRAVITY; + parms->me->s.pos.trDelta[0] += bone.lastShotDir[0]*magicFactor14; + parms->me->s.pos.trDelta[1] += bone.lastShotDir[1]*magicFactor14; + //parms->me->s.pos.trDelta[2] = fabsf(bone.lastShotDir[2])*magicFactor14; + //rww - The vertical portion of this doesn't seem to work very well + //I am just leaving it whatever it is for now, because my velocity scaling + //only works on x and y and the gravity stuff for NPCs is a bit unpleasent + //trying to change/work with + assert( !Q_isnan(bone.lastShotDir[1])); + */ + } + } + } + } + break; + case CRagDollParams::RP_GET_PELVIS_OFFSET: + if (parms->RagPhase==CRagDollParams::RP_GET_PELVIS_OFFSET) + { + VectorClear(parms->pelvisAnglesOffset); + VectorClear(parms->pelvisPositionOffset); + } + // intentional lack of a break + case CRagDollParams::RP_SET_PELVIS_OFFSET: + if (index>=0&&index<(int)blist.size()) + { + boneInfo_t &bone=blist[index]; + if (bone.boneNumber>=0) + { + if (bone.flags & BONE_ANGLES_RAGDOLL) + { + if (parms->RagPhase==CRagDollParams::RP_GET_PELVIS_OFFSET) + { + VectorCopy(bone.anglesOffset,parms->pelvisAnglesOffset); + VectorCopy(bone.positionOffset,parms->pelvisPositionOffset); + } + else + { + VectorCopy(parms->pelvisAnglesOffset,bone.anglesOffset); + VectorCopy(parms->pelvisPositionOffset,bone.positionOffset); + } + } + } + } + return; + break; + case CRagDollParams::RP_DISABLE_EFFECTORS: + // not doing anything with this yet + return; + break; + default: + assert(0); + return; + break; + } + if (ghoul2.mFlags&GHOUL2_RAG_STARTED) + { + // only going to begin ragdoll once, everything else depends on what happens to the origin + return; + } +#if 0 +if (index>=0) +{ + Com_OPrintf("death %d %d\n",blist[index].startFrame,blist[index].endFrame); +} +#endif + + ghoul2.mFlags|=GHOUL2_RAG_PENDING|GHOUL2_RAG_DONE|GHOUL2_RAG_STARTED; // well anyway we are going live + parms->CallRagDollBegin=qtrue; + + G2_GenerateWorldMatrix(parms->angles, parms->position); + G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); + + G2_Set_Bone_Rag(mod_a,blist,"model_root",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"pelvis",ghoul2,parms->scale,parms->position); + + G2_Set_Bone_Rag(mod_a,blist,"lower_lumbar",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"upper_lumbar",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"thoracic",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"cranium",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rhumerus",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lhumerus",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rradius",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lradius",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rfemurYZ",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lfemurYZ",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rtibia",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"ltibia",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rhand",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lhand",ghoul2,parms->scale,parms->position); + //G2_Set_Bone_Rag(mod_a,blist,"rtarsal",ghoul2,parms->scale,parms->position); + //G2_Set_Bone_Rag(mod_a,blist,"ltarsal",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rtalus",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"ltalus",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rradiusX",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lradiusX",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"rfemurX",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"lfemurX",ghoul2,parms->scale,parms->position); + G2_Set_Bone_Rag(mod_a,blist,"ceyebrow",ghoul2,parms->scale,parms->position); + + //int startFrame = 3665, endFrame = 3665+1; + int startFrame = parms->startFrame, endFrame = parms->endFrame; + + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"upper_lumbar",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"lower_lumbar",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"Motion",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); +// G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"model_root",startFrame,endFrame-1, +// BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, +// 1.0f,curTime,float(startFrame),150,0,true); + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"lfemurYZ",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"rfemurYZ",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"rhumerus",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + G2_Set_Bone_Anim_No_BS(ghoul2, mod_a,blist,"lhumerus",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),150,0,true); + +// should already be set G2_GenerateWorldMatrix(parms->angles, parms->position); + G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); + + static const float fRadScale = 0.3f;//0.5f; + + vec3_t pcjMin,pcjMax; + VectorSet(pcjMin,-90.0f,-45.0f,-45.0f); + VectorSet(pcjMax,90.0f,45.0f,45.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"model_root",RAG_PCJ_MODEL_ROOT|RAG_PCJ|RAG_UNSNAPPABLE,10.0f*fRadScale,pcjMin,pcjMax,100); + VectorSet(pcjMin,-45.0f,-45.0f,-45.0f); + VectorSet(pcjMax,45.0f,45.0f,45.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"pelvis",RAG_PCJ_PELVIS|RAG_PCJ|RAG_PCJ_POST_MULT|RAG_UNSNAPPABLE,10.0f*fRadScale,pcjMin,pcjMax,100); + +#if 1 + // new base anim, unconscious flop + int pcjflags=RAG_PCJ|RAG_PCJ_POST_MULT;//|RAG_EFFECTOR; + + VectorSet(pcjMin,-15.0f,-15.0f,-15.0f); + VectorSet(pcjMax,15.0f,15.0f,15.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lower_lumbar",pcjflags|RAG_UNSNAPPABLE,10.0f*fRadScale,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"upper_lumbar",pcjflags|RAG_UNSNAPPABLE,10.0f*fRadScale,pcjMin,pcjMax,500); + VectorSet(pcjMin,-25.0f,-25.0f,-25.0f); + VectorSet(pcjMax,25.0f,25.0f,25.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"thoracic",pcjflags|RAG_EFFECTOR|RAG_UNSNAPPABLE,12.0f*fRadScale,pcjMin,pcjMax,500); + + VectorSet(pcjMin,-10.0f,-10.0f,-90.0f); + VectorSet(pcjMax,10.0f,10.0f,90.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"cranium",pcjflags|RAG_BONE_LIGHTWEIGHT|RAG_UNSNAPPABLE,6.0f*fRadScale,pcjMin,pcjMax,500); + + static const float sFactLeg = 1.0f; + static const float sFactArm = 1.0f; + static const float sRadArm = 1.0f; + static const float sRadLeg = 1.0f; + + VectorSet(pcjMin,-100.0f,-40.0f,-15.0f); + VectorSet(pcjMax,-15.0f,80.0f,15.0f); + VectorScale(pcjMin, sFactArm, pcjMin); + VectorScale(pcjMax, sFactArm, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rhumerus",pcjflags|RAG_BONE_LIGHTWEIGHT|RAG_UNSNAPPABLE,(4.0f*sRadArm)*fRadScale,pcjMin,pcjMax,500); + VectorSet(pcjMin,-50.0f,-80.0f,-15.0f); + VectorSet(pcjMax,15.0f,40.0f,15.0f); + VectorScale(pcjMin, sFactArm, pcjMin); + VectorScale(pcjMax, sFactArm, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lhumerus",pcjflags|RAG_BONE_LIGHTWEIGHT|RAG_UNSNAPPABLE,(4.0f*sRadArm)*fRadScale,pcjMin,pcjMax,500); + + VectorSet(pcjMin,-25.0f,-20.0f,-20.0f); + VectorSet(pcjMax,90.0f,20.0f,-20.0f); + VectorScale(pcjMin, sFactArm, pcjMin); + VectorScale(pcjMax, sFactArm, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rradius",pcjflags|RAG_BONE_LIGHTWEIGHT,(3.0f*sRadArm)*fRadScale,pcjMin,pcjMax,500); + VectorSet(pcjMin,-90.0f,-20.0f,-20.0f); + VectorSet(pcjMax,30.0f,20.0f,-20.0f); + VectorScale(pcjMin, sFactArm, pcjMin); + VectorScale(pcjMax, sFactArm, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lradius",pcjflags|RAG_BONE_LIGHTWEIGHT,(3.0f*sRadArm)*fRadScale,pcjMin,pcjMax,500); + + + VectorSet(pcjMin,-80.0f,-50.0f,-20.0f); + VectorSet(pcjMax,30.0f,5.0f,20.0f); + VectorScale(pcjMin, sFactLeg, pcjMin); + VectorScale(pcjMax, sFactLeg, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rfemurYZ",pcjflags|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadLeg)*fRadScale,pcjMin,pcjMax,500); + VectorSet(pcjMin,-60.0f,-5.0f,-20.0f); + VectorSet(pcjMax,50.0f,50.0f,20.0f); + VectorScale(pcjMin, sFactLeg, pcjMin); + VectorScale(pcjMax, sFactLeg, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lfemurYZ",pcjflags|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadLeg)*fRadScale,pcjMin,pcjMax,500); + + VectorSet(pcjMin,-20.0f,-15.0f,-15.0f); + VectorSet(pcjMax,100.0f,15.0f,15.0f); + VectorScale(pcjMin, sFactLeg, pcjMin); + VectorScale(pcjMax, sFactLeg, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rtibia",pcjflags|RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadLeg)*fRadScale,pcjMin,pcjMax,500); + VectorSet(pcjMin,20.0f,-15.0f,-15.0f); + VectorSet(pcjMax,100.0f,15.0f,15.0f); + VectorScale(pcjMin, sFactLeg, pcjMin); + VectorScale(pcjMax, sFactLeg, pcjMax); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ltibia",pcjflags|RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadLeg)*fRadScale,pcjMin,pcjMax,500); +#else + // old base anim + int pcjflags=RAG_PCJ|RAG_PCJ_POST_MULT|RAG_EFFECTOR; + + VectorSet(pcjMin,-15.0f,-15.0f,-15.0f); + VectorSet(pcjMax,45.0f,15.0f,15.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lower_lumbar",pcjflags,10.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"upper_lumbar",pcjflags,10.0f,pcjMin,pcjMax,500); + VectorSet(pcjMin,-45.0f,-45.0f,-45.0f); + VectorSet(pcjMax,45.0f,45.0f,45.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"thoracic",pcjflags,10.0f,pcjMin,pcjMax,500); + + VectorSet(pcjMin,-10.0f,-10.0f,-90.0f); + VectorSet(pcjMax,10.0f,10.0f,90.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"cranium",pcjflags|RAG_BONE_LIGHTWEIGHT,6.0f,pcjMin,pcjMax,500); + + //VectorSet(pcjMin,-45.0f,-90.0f,-100.0f); + VectorSet(pcjMin,-180.0f,-180.0f,-100.0f); + //VectorSet(pcjMax,60.0f,60.0f,45.0f); + VectorSet(pcjMax,180.0f,180.0f,45.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rhumerus",pcjflags|RAG_BONE_LIGHTWEIGHT,4.0f,pcjMin,pcjMax,500); + //VectorSet(pcjMin,-45.0f,-60.0f,-45.0f); + VectorSet(pcjMin,-180.0f,-180.0f,-100.0f); + //VectorSet(pcjMax,60.0f,90.0f,100.0f); + VectorSet(pcjMax,180.0f,180.0f,100.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lhumerus",pcjflags|RAG_BONE_LIGHTWEIGHT,4.0f,pcjMin,pcjMax,500); + + //-120/120 + VectorSet(pcjMin,-120.0f,-20.0f,-20.0f); + VectorSet(pcjMax,50.0f,20.0f,-20.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rradius",pcjflags|RAG_BONE_LIGHTWEIGHT,3.0f,pcjMin,pcjMax,500); + VectorSet(pcjMin,-120.0f,-20.0f,-20.0f); + VectorSet(pcjMax,5.0f,20.0f,-20.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lradius",pcjflags|RAG_BONE_LIGHTWEIGHT,3.0f,pcjMin,pcjMax,500); + + VectorSet(pcjMin,-90.0f,-50.0f,-20.0f); + VectorSet(pcjMax,50.0f,20.0f,20.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rfemurYZ",pcjflags|RAG_BONE_LIGHTWEIGHT,6.0f,pcjMin,pcjMax,500); + VectorSet(pcjMin,-90.0f,-20.0f,-20.0f); + VectorSet(pcjMax,50.0f,50.0f,20.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lfemurYZ",pcjflags|RAG_BONE_LIGHTWEIGHT,6.0f,pcjMin,pcjMax,500); + + //120 + VectorSet(pcjMin,-20.0f,-15.0f,-15.0f); + VectorSet(pcjMax,120.0f,15.0f,15.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rtibia",pcjflags|RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,4.0f,pcjMin,pcjMax,500); + VectorSet(pcjMin,20.0f,-15.0f,-15.0f); + VectorSet(pcjMax,120.0f,15.0f,15.0f); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ltibia",pcjflags|RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,4.0f,pcjMin,pcjMax,500); +#endif + + + float sRadEArm = 1.2f; + float sRadELeg = 1.2f; + +// int rhand= + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rhand",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadEArm)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lhand",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadEArm)*fRadScale); + //G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rtarsal",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); + //G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ltarsal",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); +// G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rtibia",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); +// G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ltibia",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rtalus",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ltalus",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(4.0f*sRadELeg)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rradiusX",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadEArm)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lradiusX",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(6.0f*sRadEArm)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"rfemurX",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(10.0f*sRadELeg)*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"lfemurX",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,(10.0f*sRadELeg)*fRadScale); + //G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ceyebrow",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,10.0f*fRadScale); + G2_Set_Bone_Angles_Rag(ghoul2, mod_a,blist,"ceyebrow",RAG_EFFECTOR|RAG_BONE_LIGHTWEIGHT,5.0f); +//match the currrent animation + if (!G2_RagDollSetup(ghoul2,curTime,true,parms->position,false)) + { + assert(!"failed to add any rag bones"); + return; + } + G2_RagDollCurrentPosition(ghoul2V,model,curTime,parms->angles,parms->position,parms->scale); +#if 0 + if (rhand>0) + { + boneInfo_t &bone=blist[rhand]; + SRagEffector &e=ragEffectors[bone.ragIndex]; + VectorCopy(bone.originalOrigin,handPos); + VectorCopy(e.currentOrigin,handPos2); + } +#endif + int k; + + CRagDollUpdateParams fparms; + VectorCopy(parms->position, fparms.position); + VectorCopy(parms->angles, fparms.angles); + VectorCopy(parms->scale, fparms.scale); + VectorClear(fparms.velocity); + fparms.me = parms->me; + fparms.settleFrame = parms->endFrame; + + //Guess I don't need to do this, do I? + G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); + + vec3_t dPos; + VectorCopy(parms->position, dPos); +#ifdef _OLD_STYLE_SETTLE + dPos[2] -= 6; +#endif + + for (k=0;kangles,dPos,parms->scale); + G2_RagDollMatchPosition(); + G2_RagDollSolve(ghoul2V,model,1.0f*(1.0f-k/40.0f),curTime,dPos,false); + } +} + +void G2_SetRagDollBullet(CGhoul2Info &ghoul2,const vec3_t rayStart,const vec3_t hit) +{ + if (!broadsword||!broadsword->integer) + { + return; + } + vec3_t shotDir; + VectorSubtract(hit,rayStart,shotDir); + float len=VectorLength(shotDir); + if (len<1.0f) + { + return; + } + float lenr=1.0f/len; + shotDir[0]*=lenr; + shotDir[1]*=lenr; + shotDir[2]*=lenr; + + bool firstOne=false; + if (broadsword_kickbones&&broadsword_kickbones->integer) + { + int magicFactor13=150.0f; // squared radius multiplier for shot effects + boneInfo_v &blist = ghoul2.mBlist; + for(int i=(int)(blist.size()-1);i>=0;i--) + { + boneInfo_t &bone=blist[i]; + if ((bone.flags & BONE_ANGLES_TOTAL)) + { + if (bone.flags & BONE_ANGLES_RAGDOLL) + { + if (!firstOne) + { + firstOne=true; +#if 0 + int curTime=G2API_GetTime(0); + const mdxaHeader_t *mod_a=G2_GetModA(ghoul2); + int startFrame = 0, endFrame = 0; +#if 1 + TheGhoul2Wraith()->GetAnimFrames(ghoul2.mID, "unconsciousdeadflop01", startFrame, endFrame); + if (startFrame == -1 && endFrame == -1) + { //A bad thing happened! Just use the hardcoded numbers even though they could be wrong. + startFrame = 3573; + endFrame = 3583; + assert(0); + } + G2_Set_Bone_Anim_No_BS(mod_a,blist,"upper_lumbar",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),75,0,true); + G2_Set_Bone_Anim_No_BS(mod_a,blist,"lfemurYZ",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),75,0,true); + G2_Set_Bone_Anim_No_BS(mod_a,blist,"rfemurYZ",startFrame,endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f,curTime,float(startFrame),75,0,true); +#else + TheGhoul2Wraith()->GetAnimFrames(ghoul2.mID, "backdeadflop01", startFrame, endFrame); + if (startFrame == -1 && endFrame == -1) + { //A bad thing happened! Just use the hardcoded numbers even though they could be wrong. + startFrame = 3581; + endFrame = 3592; + assert(0); + } + G2_Set_Bone_Anim_No_BS(mod_a,blist,"upper_lumbar",endFrame,startFrame+1, + BONE_ANIM_OVERRIDE_FREEZE, + -1.0f,curTime,float(endFrame-1),50,0,true); + G2_Set_Bone_Anim_No_BS(mod_a,blist,"lfemurYZ",endFrame,startFrame+1, + BONE_ANIM_OVERRIDE_FREEZE, + -1.0f,curTime,float(endFrame-1),50,0,true); + G2_Set_Bone_Anim_No_BS(mod_a,blist,"rfemurYZ",endFrame,startFrame+1, + BONE_ANIM_OVERRIDE_FREEZE, + -1.0f,curTime,float(endFrame-1),50,0,true); +#endif +#endif + } + + VectorCopy(shotDir,bone.lastShotDir); + vec3_t dir; + VectorSubtract(bone.lastPosition,hit,dir); + len=VectorLength(dir); + if (len<1.0f) + { + len=1.0f; + } + lenr=1.0f/len; + float effect=lenr; + effect*=magicFactor13*effect; // this is cubed, one of them is absorbed by the next calc + bone.velocityEffector[0]=shotDir[0]*(effect+flrand(0.0f,0.05f)); + bone.velocityEffector[1]=shotDir[1]*(effect+flrand(0.0f,0.05f)); + bone.velocityEffector[2]=fabs(shotDir[2])*(effect+flrand(0.0f,0.05f)); +// bone.velocityEffector[0]=shotDir[0]*(effect+flrand(0.0f,0.05f))*flrand(-0.1f,3.0f); +// bone.velocityEffector[1]=shotDir[1]*(effect+flrand(0.0f,0.05f))*flrand(-0.1f,3.0f); +// bone.velocityEffector[2]=fabs(shotDir[2])*(effect+flrand(0.0f,0.05f))*flrand(-0.1f,3.0f); + assert( !Q_isnan(shotDir[2])); + // bone.currentAngles[0]+=flrand(-10.0f*lenr,10.0f*lenr); + // bone.currentAngles[1]+=flrand(-10.0f*lenr,10.0f*lenr); + // bone.currentAngles[2]+=flrand(-10.0f*lenr,10.0f*lenr); + // bone.lastAngles[0]+=flrand(-10.0f*lenr,10.0f*lenr); + // bone.lastAngles[1]+=flrand(-10.0f*lenr,10.0f*lenr); + // bone.lastAngles[2]+=flrand(-10.0f*lenr,10.0f*lenr); + + // go dynamic + bone.firstCollisionTime=G2API_GetTime(0); +// bone.firstCollisionTime=0; + bone.restTime=0; + } + } + } + } +} + + +static float G2_RagSetState(CGhoul2Info &ghoul2, boneInfo_t &bone,int frameNum,const vec3_t origin,bool &resetOrigin) +{ + ragOriginChange=DistanceSquared(origin,bone.extraVec1); + VectorSubtract(origin,bone.extraVec1,ragOriginChangeDir); + + float decay=1.0f; + + int dynamicTime=1000; + int settleTime=1000; + + if (ghoul2.mFlags & GHOUL2_RAG_FORCESOLVE) + { + ragState=ERS_DYNAMIC; + if (frameNum>bone.firstCollisionTime+dynamicTime) + { + VectorCopy(origin,bone.extraVec1); + if (ragOriginChange>15.0f) + { //if we moved, or if this bone is still in solid + bone.firstCollisionTime=frameNum; + } + else + { + // settle out + bone.firstCollisionTime=0; + bone.restTime=frameNum; + ragState=ERS_SETTLING; + } + } + } + else if (bone.firstCollisionTime>0) + { + ragState=ERS_DYNAMIC; + if (frameNum>bone.firstCollisionTime+dynamicTime) + { + VectorCopy(origin,bone.extraVec1); + if (ragOriginChange>15.0f) + { //if we moved, or if this bone is still in solid + bone.firstCollisionTime=frameNum; + } + else + { + // settle out + bone.firstCollisionTime=0; + bone.restTime=frameNum; + ragState=ERS_SETTLING; + } + } +//decay=0.0f; + } + else if (bone.restTime>0) + { + decay=1.0f-(frameNum-bone.restTime)/float(dynamicTime); + if (decay<0.0f) + { + decay=0.0f; + } + if (decay>1.0f) + { + decay=1.0f; + } + float magicFactor8=1.0f; // Power for decay + decay=pow(decay,magicFactor8); + ragState=ERS_SETTLING; + if (frameNum>bone.restTime+settleTime) + { + VectorCopy(origin,bone.extraVec1); + if (ragOriginChange>15.0f) + { + bone.restTime=frameNum; + } + else + { + // stop + bone.restTime=0; + ragState=ERS_SETTLED; + } + } +//decay=0.0f; + } + else + { + if (bone.RagFlags & RAG_PCJ_IK_CONTROLLED) + { + bone.firstCollisionTime=frameNum; + ragState=ERS_DYNAMIC; + } + else if (ragOriginChange>15.0f) + { + bone.firstCollisionTime=frameNum; + ragState=ERS_DYNAMIC; + } + else + { + ragState=ERS_SETTLED; + } + decay=0.0f; + } +// ragState=ERS_SETTLED; +// decay=0.0f; + return decay; +} + +static bool G2_RagDollSetup(CGhoul2Info &ghoul2,int frameNum,bool resetOrigin,const vec3_t origin,bool anyRendered) +{ + int minSurvivingBone=10000; + //int minSurvivingBoneAt=-1; + int minSurvivingBoneAlt=10000; + //int minSurvivingBoneAtAlt=-1; + + assert(ghoul2.mFileName[0]); + boneInfo_v &blist = ghoul2.mBlist; + rag.clear(); + int numRendered=0; + int numNotRendered=0; + //int pelvisAt=-1; + for(size_t i=0; i=0) + { + assert(bone.boneNumberbone.boneNumber) + { + minSurvivingBone=bone.boneNumber; + //minSurvivingBoneAt=i; + } + } + else if (wasRendered) + { + if (minSurvivingBoneAlt>bone.boneNumber) + { + minSurvivingBoneAlt=bone.boneNumber; + //minSurvivingBoneAtAlt=i; + } + } + if ( + anyRendered && + (bone.RagFlags&RAG_WAS_EVER_RENDERED) && + !(bone.RagFlags&RAG_PCJ_MODEL_ROOT) && + !(bone.RagFlags&RAG_PCJ_PELVIS) && + !wasRendered && + (bone.RagFlags&RAG_EFFECTOR) + ) + { + // this thing was rendered in the past, but wasn't now, although other bones were, lets get rid of it +// bone.flags &= ~BONE_ANGLES_RAGDOLL; +// bone.RagFlags = 0; +//Com_OPrintf("Deleted Effector %d\n",i); +// continue; + } + if ((int)rag.size()=0 && + pelvisAt>=0) + { + { + // remove the pelvis as a rag + boneInfo_t &bone=blist[minSurvivingBoneAt]; + bone.flags&=~BONE_ANGLES_RAGDOLL; + bone.RagFlags=0; + } + { + // the root-est bone is now our "pelvis + boneInfo_t &bone=blist[minSurvivingBoneAt]; + VectorSet(bone.minAngles,-14500.0f,-14500.0f,-14500.0f); + VectorSet(bone.maxAngles,14500.0f,14500.0f,14500.0f); + bone.RagFlags|=RAG_PCJ_PELVIS|RAG_PCJ; // this guy is our new "pelvis" + bone.flags |= BONE_ANGLES_POSTMULT; + bone.ragStartTime=G2API_GetTime(0); + } + } + } +#endif + numRags=0; + //int ragStartTime=0; + for(size_t i=0; i=0); + assert(numRagsinteger) + { + return; + } + + if (!params) + { + assert(0); + return; + } + + vec3_t dPos; + VectorCopy(params->position, dPos); +#ifdef _OLD_STYLE_SETTLE + dPos[2] -= 6; +#endif + +// params->DebugLine(handPos,handPos2,false); + int frameNum=G2API_GetTime(0); + CGhoul2Info &ghoul2=ghoul2V[g2Index]; + assert(ghoul2.mFileName[0]); + boneInfo_v &blist = ghoul2.mBlist; + + // hack for freezing ragdoll (no idea if it works) +#if 0 + if (0) + { + // we gotta hack this to basically freeze the timers + for(i=0; i=0) + { + assert(bone.boneNumber=0) + { + assert(bone.boneNumber= 0 && bone2.solidCount > 8) + { + noneInSolid = false; + break; + } + } + + if (noneInSolid) + { //we're settled then + params->RagDollSettled(); + return; + } + else + { + continue; + } +#else + params->RagDollSettled(); + return; +#endif + } + if (G2_WasBoneRendered(ghoul2,bone.boneNumber)) + { + anyRendered=true; + break; + } + } + } + } + //int iters=(ragState==ERS_DYNAMIC)?2:1; + int iters=(ragState==ERS_DYNAMIC)?4:2; + //bool kicked=false; + if (ragOriginChangeDir[2]<-100.0f) + { + //kicked=true; + //iters*=8; + iters*=2; //rww - changed to this.. it was getting up to around 600 traces at times before (which is insane) + } + if (iters) + { + if (!G2_RagDollSetup(ghoul2,frameNum,resetOrigin,dPos,anyRendered)) + { + return; + } + // ok, now our data structures are compact and set up in topological order + + for (int i=0;iangles,dPos,params->scale); + + if (G2_RagDollSettlePositionNumeroTrois(ghoul2V,dPos,params,curTime)) + { +#if 0 + //effectors are start solid alot, so this was pretty extreme + if (!kicked&&iters<4) + { + kicked=true; + //iters*=4; + iters*=2; + } +#endif + } + //params->position[2] += 16; + G2_RagDollSolve(ghoul2V,g2Index,decay*2.0f,frameNum,dPos,true,params); + } + } + + if (params->me != ENTITYNUM_NONE) + { +#if 0 + vec3_t worldMins,worldMaxs; + worldMins[0]=params->position[0]-17; + worldMins[1]=params->position[1]-17; + worldMins[2]=params->position[2]; + worldMaxs[0]=params->position[0]+17; + worldMaxs[1]=params->position[1]+17; + worldMaxs[2]=params->position[2]; +//Com_OPrintf(va("%f \n",worldMins[2]); +// params->DebugLine(worldMins,worldMaxs,true); +#endif + G2_RagDollCurrentPosition(ghoul2V,g2Index,frameNum,params->angles,params->position,params->scale); +// SV_UnlinkEntity(params->me); +// params->me->SetMins(BB_SHOOTING_SIZE,ragBoneMins); +// params->me->SetMaxs(BB_SHOOTING_SIZE,ragBoneMaxs); +// SV_LinkEntity(params->me); + } +} + +#ifdef _DEBUG +#define _DEBUG_BONE_NAMES +#endif + +static inline char *G2_Get_Bone_Name(CGhoul2Info *ghlInfo, boneInfo_v &blist, int boneNum) +{ + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)ghlInfo->aHeader + sizeof(mdxaHeader_t) + offsets->offsets[0]); + + // look through entire list + for(size_t i=0; iaHeader + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + + return skel->name; + } + + // didn't find it + return "BONE_NOT_FOUND"; +} + +char *G2_GetBoneNameFromSkel(CGhoul2Info &ghoul2, int boneNum); + +static void G2_RagDollCurrentPosition(CGhoul2Info_v &ghoul2V,int g2Index,int frameNum,const vec3_t angles,const vec3_t position,const vec3_t scale) +{ + CGhoul2Info &ghoul2=ghoul2V[g2Index]; + assert(ghoul2.mFileName[0]); +//Com_OPrintf("angles %f %f %f\n",angles[0],angles[1],angles[2]); + G2_GenerateWorldMatrix(angles,position); + G2_ConstructGhoulSkeleton(ghoul2V, frameNum, false, scale); + + float totalWt=0.0f; + int i; + for (i=0;iragBoneMaxs[k]) + { + ragBoneMaxs[k]=ragEffectors[i].currentOrigin[k]; + } + if (ragEffectors[i].currentOrigin[k]0.0f); + int k; + { + float wtInv=1.0f/totalWt; + for (k=0;k<3;k++) + { + ragBoneMaxs[k]-=position[k]; + ragBoneMins[k]-=position[k]; + ragBoneMaxs[k]+=10.0f; + ragBoneMins[k]-=10.0f; + ragBoneCM[k]*=wtInv; + + ragBoneCM[k]=ragEffectors[0].currentOrigin[k]; // use the pelvis + } + } +} + +#ifdef _DEBUG +int ragTraceTime = 0; +int ragSSCount = 0; +int ragTraceCount = 0; +#endif + +void Rag_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int passEntityNum, const int contentmask, const EG2_Collision eG2TraceType, const int useLod ) +{ +#ifdef _DEBUG + int ragPreTrace = ri->Milliseconds(); +#endif + if ( ri->CGVMLoaded() ) + { + ragCallbackTraceLine_t *callData = (ragCallbackTraceLine_t *)ri->GetSharedMemory(); + + VectorCopy(start, callData->start); + VectorCopy(end, callData->end); + VectorCopy(mins, callData->mins); + VectorCopy(maxs, callData->maxs); + callData->ignore = passEntityNum; + callData->mask = contentmask; + + ri->CGVM_RagCallback( RAG_CALLBACK_TRACELINE ); + + *results = callData->tr; + } + else + { + results->entityNum = ENTITYNUM_NONE; + //SV_Trace(results, start, mins, maxs, end, passEntityNum, contentmask, eG2TraceType, useLod); + ri->CM_BoxTrace(results, start, end, mins, maxs, 0, contentmask, 0); + results->entityNum = results->fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; + } + +#ifdef _DEBUG + int ragPostTrace = ri->Milliseconds(); + + ragTraceTime += (ragPostTrace - ragPreTrace); + if (results->startsolid) + { + ragSSCount++; + } + ragTraceCount++; +#endif +} + +//run advanced physics on each bone indivudually +//an adaption of my "exphys" custom game physics model +#define MAX_GRAVITY_PULL 256//512 + +static inline bool G2_BoneOnGround(const vec3_t org, const vec3_t mins, const vec3_t maxs, const int ignoreNum) +{ + trace_t tr; + vec3_t gSpot; + + VectorCopy(org, gSpot); + gSpot[2] -= 1.0f; //seems reasonable to me + + Rag_Trace(&tr, org, mins, maxs, gSpot, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); + + if (tr.fraction != 1.0f && !tr.startsolid && !tr.allsolid) + { //not in solid, and hit something. Guess it's ground. + return true; + } + + return false; +} + +static inline bool G2_ApplyRealBonePhysics(boneInfo_t &bone, SRagEffector &e, CRagDollUpdateParams *params, vec3_t goalSpot, const vec3_t testMins, const vec3_t testMaxs, + const float gravity, const float mass, const float bounce) +{ + trace_t tr; + vec3_t projectedOrigin; + vec3_t vNorm; + vec3_t ground; + float velScaling = 0.1f; + float vTotal = 0.0f; + bool boneOnGround = false; + + assert(mass <= 1.0f && mass >= 0.01f); + + if (bone.physicsSettled) + { //then we have no need to continue + return true; + } + + if (gravity) + { //factor it in before we do anything. + VectorCopy(e.currentOrigin, ground); + ground[2] -= 1.0f; + + Rag_Trace(&tr, e.currentOrigin, testMins, testMaxs, ground, params->me, RAG_MASK, G2_NOCOLLIDE, 0); + + if (tr.entityNum == ENTITYNUM_NONE) + { + boneOnGround = false; + } + else + { + boneOnGround = true; + } + + if (!boneOnGround) + { + if (!params->velocity[2]) + { //only increase gravitational pull once the actual entity is still + bone.epGravFactor += gravity; + } + + if (bone.epGravFactor > MAX_GRAVITY_PULL) + { //cap it off if needed + bone.epGravFactor = MAX_GRAVITY_PULL; + } + + bone.epVelocity[2] -= bone.epGravFactor; + } + else + { //if we're sitting on something then reset the gravity factor. + bone.epGravFactor = 0; + } + } + else + { + boneOnGround = G2_BoneOnGround(e.currentOrigin, testMins, testMaxs, params->me); + } + + if (!bone.epVelocity[0] && !bone.epVelocity[1] && !bone.epVelocity[2]) + { //nothing to do if we have no velocity even after gravity. + VectorCopy(e.currentOrigin, goalSpot); + return true; + } + + //get the projected origin based on velocity. + VectorMA(e.currentOrigin, velScaling, bone.epVelocity, projectedOrigin); + + //scale it down based on mass + VectorScale(bone.epVelocity, 1.0f-mass, bone.epVelocity); + + VectorCopy(bone.epVelocity, vNorm); + vTotal = VectorNormalize(vNorm); + + if (vTotal < 1 && boneOnGround) + { //we've pretty much stopped moving anyway, just clear it out then. + VectorClear(bone.epVelocity); + bone.epGravFactor = 0; + VectorCopy(e.currentOrigin, goalSpot); + return true; + } + + Rag_Trace(&tr, e.currentOrigin, testMins, testMaxs, projectedOrigin, params->me, RAG_MASK, G2_NOCOLLIDE, 0); + + if (tr.startsolid || tr.allsolid) + { //can't go anywhere from here + return false; + } + + //Go ahead and set it to the trace endpoint regardless of what it hit + VectorCopy(tr.endpos, goalSpot); + + if (tr.fraction == 1.0f) + { //Nothing was in the way. + return true; + } + + if (bounce) + { + vTotal *= bounce; //scale it by bounce + + VectorScale(tr.plane.normal, vTotal, vNorm); //scale the trace plane normal by the bounce factor + + if (vNorm[2] > 0) + { + bone.epGravFactor -= vNorm[2]*(1.0f-mass); //The lighter it is the more gravity will be reduced by bouncing vertically. + if (bone.epGravFactor < 0) + { + bone.epGravFactor = 0; + } + } + + VectorAdd(bone.epVelocity, vNorm, bone.epVelocity); //add it into the existing velocity. + + //I suppose it could be sort of neat to make a game callback here to actual do stuff + //when bones slam into things. But it could be slow too. + /* + if (tr.entityNum != ENTITYNUM_NONE && ent->touch) + { //then call the touch function + ent->touch(ent, &g_entities[tr.entityNum], &tr); + } + */ + } + else + { //if no bounce, kill when it hits something. + bone.epVelocity[0] = 0; + bone.epVelocity[1] = 0; + + if (!gravity) + { + bone.epVelocity[2] = 0; + } + } + return true; +} + +#ifdef _DEBUG_BONE_NAMES +static inline void G2_RagDebugBox(vec3_t mins, vec3_t maxs, int duration) +{ + if ( !ri->CGVMLoaded() ) + return; + + ragCallbackDebugBox_t *callData = (ragCallbackDebugBox_t *)ri->GetSharedMemory(); + + callData->duration = duration; + VectorCopy(mins, callData->mins); + VectorCopy(maxs, callData->maxs); + + ri->CGVM_RagCallback( RAG_CALLBACK_DEBUGBOX ); +} + +static inline void G2_RagDebugLine(vec3_t start, vec3_t end, int time, int color, int radius) +{ + if ( !ri->CGVMLoaded() ) + return; + + ragCallbackDebugLine_t *callData = (ragCallbackDebugLine_t *)ri->GetSharedMemory(); + + VectorCopy(start, callData->start); + VectorCopy(end, callData->end); + callData->time = time; + callData->color = color; + callData->radius = radius; + + ri->CGVM_RagCallback( RAG_CALLBACK_DEBUGLINE ); +} +#endif + +#ifdef _OLD_STYLE_SETTLE +static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const vec3_t currentOrg, CRagDollUpdateParams *params, int curTime) +{ + haveDesiredPelvisOffset=false; + vec3_t desiredPos; + int i; + + assert(params); + //assert(params->me); //no longer valid, because me is an index! + int ignoreNum=params->me; + + bool anyStartSolid=false; + + vec3_t groundSpot={0,0,0}; + // lets find the floor at our quake origin + { + vec3_t testStart; + VectorCopy(currentOrg,testStart); //last arg is dest + vec3_t testEnd; + VectorCopy(testStart,testEnd); //last arg is dest + testEnd[2]-=200.0f; + + vec3_t testMins; + vec3_t testMaxs; + VectorSet(testMins,-10,-10,-10); + VectorSet(testMaxs,10,10,10); + + { + trace_t tr; + assert( !Q_isnan(testStart[1])); + assert( !Q_isnan(testEnd[1])); + assert( !Q_isnan(testMins[1])); + assert( !Q_isnan(testMaxs[1])); + Rag_Trace(&tr,testStart,testMins,testMaxs,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0/*SV_TRACE_NO_PLAYER*/); + if (tr.entityNum==0) + { + VectorAdvance(testStart,.5f,testEnd,tr.endpos); + } + if (tr.startsolid) + { + //hmmm, punt + VectorCopy(currentOrg,groundSpot); //last arg is dest + groundSpot[2]-=30.0f; + } + else + { + VectorCopy(tr.endpos,groundSpot); //last arg is dest + } + } + } + + for (i=0;i groundSpot[2]) + { + testStart[2]=groundSpot[2]+(e.radius-10.0f); + } + else + { + // lets try higher + testStart[2]=groundSpot[2]+8.0f; + Rag_Trace(&tr,testStart,testMins,testMaxs,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); + if (tr.entityNum==0) + { + VectorAdvance(testStart,.5f,testEnd,tr.endpos); + } + } + + } + if (tr.startsolid) + { + iAmStartSolid=true; + anyStartSolid=true; + // above the origin, so lets slide away + if (e.currentOrigin[2] > groundSpot[2]) + { + if (params) + { + //SRagDollEffectorCollision args(e.currentOrigin,tr); + //params->EffectorCollision(args); + if ( ri->CGVMLoaded() ) + { //make a callback and see if the cgame wants to help us out + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + + VectorCopy(e.currentOrigin, callData->bonePos); + callData->entNum = params->me; + callData->solidCount = bone.solidCount; + + ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + } + } + } + else + { + //harumph, we are really screwed + } + } + else + { + vertEffectorTraceFraction=tr.fraction; + if (params && + vertEffectorTraceFraction < .95f && + fabsf(tr.plane.normal[2]) < .707f) + { + //SRagDollEffectorCollision args(e.currentOrigin,tr); + //args.useTracePlane=true; + //params->EffectorCollision(args); + if ( ri->CGVMLoaded() ) + { //make a callback and see if the cgame wants to help us out + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + + VectorCopy(e.currentOrigin, callData->bonePos); + callData->entNum = params->me; + callData->solidCount = bone.solidCount; + + ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + } + } + } + } + vec3_t effectorGroundSpot; + VectorAdvance(testStart,vertEffectorTraceFraction,testEnd,effectorGroundSpot);// VA(a,t,b,c)-> c := (1-t)a+tb + // trace from the quake origin horzontally to the effector + // gonna choose the maximum of the ground spot or the effector location + // and clamp it to be roughly in the bbox + VectorCopy(groundSpot,testStart); //last arg is dest + if (iAmStartSolid) + { + // we don't have a meaningful ground spot + VectorCopy(e.currentOrigin,testEnd); //last arg is dest + bone.solidCount++; + } + else + { + VectorCopy(effectorGroundSpot,testEnd); //last arg is dest + bone.solidCount = 0; + } + assert( !Q_isnan(testStart[1])); + assert( !Q_isnan(testEnd[1])); + assert( !Q_isnan(testMins[1])); + assert( !Q_isnan(testMaxs[1])); + + float ztest; + + if (testEnd[2]>testStart[2]) + { + ztest=testEnd[2]; + } + else + { + ztest=testStart[2]; + } + if (ztest c := (1-t)a+tb + + float horzontalTraceFraction=0.0f; + vec3_t HorizontalHitSpot={0,0,0}; + { + trace_t tr; + Rag_Trace(&tr,testStart,testMins,testMaxs,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); + if (tr.entityNum==0) + { + VectorAdvance(testStart,.5f,testEnd,tr.endpos); + } + horzontalTraceFraction=tr.fraction; + if (tr.startsolid) + { + horzontalTraceFraction=1.0f; + // punt + VectorCopy(e.currentOrigin,HorizontalHitSpot); + } + else + { + VectorCopy(tr.endpos,HorizontalHitSpot); + int magicFactor46=0.98f; // shorten percetage to make sure we can go down along a wall + //float magicFactor46=0.98f; // shorten percetage to make sure we can go down along a wall + //rww - An..int? + VectorAdvance(tr.endpos,magicFactor46,testStart,HorizontalHitSpot);// VA(a,t,b,c)-> c := (1-t)a+tb + + // roughly speaking this is a wall + if (horzontalTraceFraction<0.9f) + { + + // roughly speaking this is a wall + if (fabsf(tr.plane.normal[2])<0.7f) + { + //SRagDollEffectorCollision args(e.currentOrigin,tr); + //args.useTracePlane=true; + //params->EffectorCollision(args); + if ( ri->CGVMLoaded() ) + { //make a callback and see if the cgame wants to help us out + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + + VectorCopy(e.currentOrigin, callData->bonePos); + callData->entNum = params->me; + callData->solidCount = bone.solidCount; + + ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + } + } + } + else if (!iAmStartSolid && + effectorGroundSpot[2] < groundSpot[2] - 8.0f) + { + // this is a situation where we have something dangling below the pelvis, we want to find the plane going downhill away from the origin + // for various reasons, without this correction the body will actually move away from places it can fall off. + //gotta run the trace backwards to get a plane + { + trace_t tr; + VectorCopy(effectorGroundSpot,testStart); + VectorCopy(groundSpot,testEnd); + + // this can be a line trace, we just want the plane normal + Rag_Trace(&tr,testEnd,0,0,testStart,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); + if (tr.entityNum==0) + { + VectorAdvance(testStart,.5f,testEnd,tr.endpos); + } + horzontalTraceFraction=tr.fraction; + if (!tr.startsolid && tr.fraction< 0.7f) + { + //SRagDollEffectorCollision args(e.currentOrigin,tr); + //args.useTracePlane=true; + //params->EffectorCollision(args); + if ( ri->CGVMLoaded() ) + { //make a callback and see if the cgame wants to help us out + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + + VectorCopy(e.currentOrigin, callData->bonePos); + callData->entNum = params->me; + callData->solidCount = bone.solidCount; + + ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + } + } + } + } + } + } + vec3_t goalSpot={0,0,0}; + // now lets trace down + VectorCopy(HorizontalHitSpot,testStart); + VectorCopy(testStart,testEnd); //last arg is dest + testEnd[2]=e.currentOrigin[2]-30.0f; + { + trace_t tr; + Rag_Trace(&tr,testStart,NULL,NULL,testEnd,ignoreNum,RAG_MASK,G2_NOCOLLIDE,0); + if (tr.entityNum==0) + { + VectorAdvance(testStart,.5f,testEnd,tr.endpos); + } + if (tr.startsolid) + { + // punt, go to the origin I guess + VectorCopy(currentOrg,goalSpot); + } + else + { + VectorCopy(tr.endpos,goalSpot); + int magicFactor47=0.5f; // shorten percentage to make sure we can go down along a wall + VectorAdvance(tr.endpos,magicFactor47,testStart,goalSpot);// VA(a,t,b,c)-> c := (1-t)a+tb + } + } + + // ok now as the horizontal trace fraction approaches zero, we want to head toward the horizontalHitSpot + //geeze I would like some reasonable trace fractions + assert(horzontalTraceFraction>=0.0f&&horzontalTraceFraction<=1.0f); + VectorAdvance(HorizontalHitSpot,horzontalTraceFraction*horzontalTraceFraction,goalSpot,goalSpot);// VA(a,t,b,c)-> c := (1-t)a+tb +#if 0 + if ((bone.RagFlags & RAG_EFFECTOR) && (bone.RagFlags & RAG_BONE_LIGHTWEIGHT)) + { //new rule - don't even bother unless it's a lightweight effector + //rww - Factor object velocity into the final desired spot.. + //We want the limbs with a "light" weight to drag behind the general mass. + //If we got here, we shouldn't be the pelvis or the root, so we should be + //fine to treat as lightweight. However, we can flag bones as being particularly + //light. They're given less downscale for the reduction factor. + vec3_t givenVelocity; + vec3_t vSpot; + trace_t vtr; + float vSpeed = 0; + float verticalSpeed = 0; + float vReductionFactor = 0.03f; + float verticalSpeedReductionFactor = 0.06f; //want this to be more obvious + float lwVReductionFactor = 0.1f; + float lwVerticalSpeedReductionFactor = 0.3f; //want this to be more obvious + + + VectorCopy(params->velocity, givenVelocity); + vSpeed = VectorNormalize(givenVelocity); + vSpeed = -vSpeed; //go in the opposite direction of velocity + + verticalSpeed = vSpeed; + + if (bone.RagFlags & RAG_BONE_LIGHTWEIGHT) + { + vSpeed *= lwVReductionFactor; + verticalSpeed *= lwVerticalSpeedReductionFactor; + } + else + { + vSpeed *= vReductionFactor; + verticalSpeed *= verticalSpeedReductionFactor; + } + + vSpot[0] = givenVelocity[0]*vSpeed; + vSpot[1] = givenVelocity[1]*vSpeed; + vSpot[2] = givenVelocity[2]*verticalSpeed; + VectorAdd(goalSpot, vSpot, vSpot); + + if (vSpot[0] || vSpot[1] || vSpot[2]) + { + Rag_Trace(&vtr, goalSpot, testMins, testMaxs, vSpot, ignoreNum, RAG_MASK, G2_NOCOLLIDE,0); + if (vtr.fraction == 1) + { + VectorCopy(vSpot, goalSpot); + } + } + } +#endif + + int k; + int magicFactor12=0.8f; // dampening of velocity applied + int magicFactor16=10.0f; // effect multiplier of velocity applied + + if (iAmStartSolid) + { + magicFactor16 = 30.0f; + } + + for (k=0;k<3;k++) + { + e.desiredDirection[k]=goalSpot[k]-e.currentOrigin[k]; + e.desiredDirection[k]+=magicFactor16*bone.velocityEffector[k]; + e.desiredDirection[k]+=flrand(-0.75f,0.75f)*flrand(-0.75f,0.75f); + bone.velocityEffector[k]*=magicFactor12; + } + VectorCopy(e.currentOrigin,bone.lastPosition); // last arg is dest + } + return anyStartSolid; +} +#else + +#if 0 +static inline int G2_RagIndexForBoneNum(int boneNum) +{ + for (int i = 0; i < numRags; i++) + { + // these are used for affecting the end result + if (ragBoneData[i].boneNum == boneNum) + { + return i; + } + } + + return -1; +} +#endif + +#ifdef _RAG_PRINT_TEST +void G2_RagPrintMatrix(mdxaBone_t *mat) +{ + char x[1024]; + x[0] = 0; + int n = 0; + while (n < 3) + { + int o = 0; + while (o < 4) + { + strcat(x, va("%f ", mat->matrix[n][o])); + o++; + } + n++; + } + strcat(x, "\n"); + Com_Printf(x); +} +#endif + +void G2_RagGetBoneBasePoseMatrixLow(CGhoul2Info &ghoul2, int boneNum, mdxaBone_t &boneMatrix, mdxaBone_t &retMatrix, vec3_t scale); +void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &matrix, const int frame); + +static inline void G2_RagGetWorldAnimMatrix(CGhoul2Info &ghoul2, boneInfo_t &bone, CRagDollUpdateParams *params, mdxaBone_t &retMatrix) +{ + static mdxaBone_t trueBaseMatrix, baseBoneMatrix; + + //get matrix for the settleFrame to use as an ideal + G2_RagGetAnimMatrix(ghoul2, bone.boneNumber, trueBaseMatrix, params->settleFrame); + assert(bone.hasAnimFrameMatrix == params->settleFrame); + + G2_RagGetBoneBasePoseMatrixLow(ghoul2, bone.boneNumber, + trueBaseMatrix, baseBoneMatrix, params->scale); + + //Use params to multiply world coordinate/dir matrix into the + //bone matrix and give us a useable world position + Multiply_3x4Matrix(&retMatrix, &worldMatrix, &baseBoneMatrix); + + assert(!Q_isnan(retMatrix.matrix[2][3])); +} + +//get the current pelvis Z direction and the base anim matrix Z direction +//so they can be compared and used to offset -rww +void G2_GetRagBoneMatrixLow(CGhoul2Info &ghoul2, int boneNum, mdxaBone_t &retMatrix); +void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix); +static inline void G2_RagGetPelvisLumbarOffsets(CGhoul2Info &ghoul2, CRagDollUpdateParams *params, vec3_t pos, vec3_t dir, vec3_t animPos, vec3_t animDir) +{ + static mdxaBone_t final; + static mdxaBone_t x; + //static mdxaBone_t *unused1, *unused2; + //static vec3_t lumbarPos; + + assert(ghoul2.animModel); + int boneIndex = G2_Find_Bone(ghoul2.animModel, ghoul2.mBlist, "pelvis"); + assert(boneIndex != -1); + + G2_RagGetWorldAnimMatrix(ghoul2, ghoul2.mBlist[boneIndex], params, final); + G2API_GiveMeVectorFromMatrix(&final, ORIGIN, animPos); + G2API_GiveMeVectorFromMatrix(&final, POSITIVE_X, animDir); + +#if 0 + //We have the anim matrix pelvis pos now, so get the normal one as well + G2_GetBoneMatrixLow(ghoul2, boneIndex, params->scale, final, unused1, unused2); + G2API_GiveMeVectorFromMatrix(&final, ORIGIN, pos); + G2API_GiveMeVectorFromMatrix(&final, POSITIVE_X, dir); +#else + //We have the anim matrix pelvis pos now, so get the normal one as well + //G2_GetRagBoneMatrixLow(ghoul2, boneIndex, x); + int bolt = G2_Add_Bolt(&ghoul2, ghoul2.mBltlist, ghoul2.mSlist, "pelvis"); + G2_GetBoltMatrixLow(ghoul2, bolt, params->scale, x); + Multiply_3x4Matrix(&final, &worldMatrix, &x); + G2API_GiveMeVectorFromMatrix(&final, ORIGIN, pos); + G2API_GiveMeVectorFromMatrix(&final, POSITIVE_X, dir); +#endif + + /* + //now get lumbar + boneIndex = G2_Find_Bone(ghoul2.animModel, ghoul2.mBlist, "lower_lumbar"); + assert(boneIndex != -1); + + G2_RagGetWorldAnimMatrix(ghoul2, ghoul2.mBlist[boneIndex], params, final); + G2API_GiveMeVectorFromMatrix(&final, ORIGIN, lumbarPos); + + VectorSubtract(animPos, lumbarPos, animDir); + VectorNormalize(animDir); + + //We have the anim matrix lumbar dir now, so get the normal one as well + G2_GetBoneMatrixLow(ghoul2, boneIndex, params->scale, final, unused1, unused2); + G2API_GiveMeVectorFromMatrix(&final, ORIGIN, lumbarPos); + + VectorSubtract(pos, lumbarPos, dir); + VectorNormalize(dir); + */ +} + +static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const vec3_t currentOrg, CRagDollUpdateParams *params, int curTime) +{ //now returns true if any bone was in solid, otherwise false + int ignoreNum = params->me; + static int i; + static vec3_t goalSpot; + static trace_t tr; + //static trace_t solidTr; + static int k; + static const float velocityDampening = 1.0f; + static const float velocityMultiplier = 60.0f; + static vec3_t testMins; + static vec3_t testMaxs; + vec3_t velDir; + static bool startSolid; + bool anySolid = false; + static mdxaBone_t worldBaseMatrix; + static vec3_t parentOrigin; + static vec3_t basePos; + static vec3_t entScale; + static bool hasDaddy; + static bool hasBasePos; + static vec3_t animPelvisDir, pelvisDir, animPelvisPos, pelvisPos; + + //Maybe customize per-bone? + static const float gravity = 3.0f; + static const float mass = 0.09f; + static const float bounce = 0.0f;//1.3f; + //Bouncing and stuff unfortunately does not work too well at the moment. + //Need to keep a seperate "physics origin" or make the filthy solve stuff + //better. + + bool inAir = false; + + if (params->velocity[0] || params->velocity[1] || params->velocity[2]) + { + inAir = true; + } + + if (!params->scale[0] && !params->scale[1] && !params->scale[2]) + { + VectorSet(entScale, 1.0f, 1.0f, 1.0f); + } + else + { + VectorCopy(params->scale, entScale); + } + + if (broadsword_ragtobase && + broadsword_ragtobase->integer > 1) + { + //grab the pelvis directions to offset base positions for bones + G2_RagGetPelvisLumbarOffsets(ghoul2V[0], params, pelvisPos, pelvisDir, animPelvisPos, + animPelvisDir); + + //don't care about the pitch offsets + pelvisDir[2] = 0; + animPelvisDir[2] = 0; + + /* + vec3_t upelvisPos, uanimPelvisPos; + vec3_t blah; + VectorCopy(pelvisPos, upelvisPos); + VectorCopy(animPelvisPos, uanimPelvisPos); + upelvisPos[2] += 64; + uanimPelvisPos[2] += 64; + + VectorMA(upelvisPos, 32.0f, pelvisDir, blah); + G2_RagDebugLine(upelvisPos, blah, 50, 0x00ff00, 1); + VectorMA(uanimPelvisPos, 32.0f, animPelvisDir, blah); + G2_RagDebugLine(uanimPelvisPos, blah, 50, 0xff0000, 1); + */ + + //just convert to angles now, that's all we'll ever use them for + vectoangles(pelvisDir, pelvisDir); + vectoangles(animPelvisDir, animPelvisDir); + } + + for (i = 0; i < numRags; i++) + { + boneInfo_t &bone = *ragBoneData[i]; + SRagEffector &e = ragEffectors[i]; + + if (inAir) + { + bone.airTime = curTime + 30; + } + + if (bone.RagFlags & RAG_PCJ_PELVIS) + { + VectorSet(goalSpot, params->position[0], params->position[1], (params->position[2]+DEFAULT_MINS_2)+((bone.radius*entScale[2])+2)); + + VectorSubtract(goalSpot, e.currentOrigin, desiredPelvisOffset); + haveDesiredPelvisOffset = true; + VectorCopy(e.currentOrigin, bone.lastPosition); + continue; + } + + if (!(bone.RagFlags & RAG_EFFECTOR)) + { + continue; + } + + if (bone.hasOverGoal) + { //api call was made to override the goal spot + VectorCopy(bone.overGoalSpot, goalSpot); + bone.solidCount = 0; + for (k = 0; k < 3; k++) + { + e.desiredDirection[k] = (goalSpot[k] - e.currentOrigin[k]); + e.desiredDirection[k] += (velocityMultiplier * bone.velocityEffector[k]); + bone.velocityEffector[k] *= velocityDampening; + } + VectorCopy(e.currentOrigin, bone.lastPosition); + + continue; + } + + VectorSet(testMins, -e.radius*entScale[0], -e.radius*entScale[1], -e.radius*entScale[2]); + VectorSet(testMaxs, e.radius*entScale[0], e.radius*entScale[1], e.radius*entScale[2]); + + assert(ghoul2V[0].mBoneCache); + + //get the parent bone's position + hasDaddy = false; + if (bone.boneNumber) + { + assert(ghoul2V[0].animModel); + assert(ghoul2V[0].aHeader); + + if (bone.parentBoneIndex == -1) + { + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + int bParentIndex, bParentListIndex = -1; + + offsets = (mdxaSkelOffsets_t *)((byte *)ghoul2V[0].aHeader + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)ghoul2V[0].aHeader + sizeof(mdxaHeader_t) + offsets->offsets[bone.boneNumber]); + + bParentIndex = skel->parent; + + while (bParentIndex > 0) + { //go upward through hierarchy searching for the first parent that is a rag bone + skel = (mdxaSkel_t *)((byte *)ghoul2V[0].aHeader + sizeof(mdxaHeader_t) + offsets->offsets[bParentIndex]); + bParentIndex = skel->parent; + bParentListIndex = G2_Find_Bone(ghoul2V[0].animModel, ghoul2V[0].mBlist, skel->name); + + if (bParentListIndex != -1) + { + boneInfo_t &pbone = ghoul2V[0].mBlist[bParentListIndex]; + if (pbone.flags & BONE_ANGLES_RAGDOLL) + { //valid rag bone + break; + } + } + + //didn't work out, reset to -1 again + bParentListIndex = -1; + } + + bone.parentBoneIndex = bParentListIndex; + } + + if (bone.parentBoneIndex != -1) + { + boneInfo_t &pbone = ghoul2V[0].mBlist[bone.parentBoneIndex]; + + if (pbone.flags & BONE_ANGLES_RAGDOLL) + { //has origin calculated for us already + VectorCopy(ragEffectors[pbone.ragIndex].currentOrigin, parentOrigin); + hasDaddy = true; + } + } + } + + //get the position this bone would be in if we were in the desired frame + hasBasePos = false; + if (broadsword_ragtobase && + broadsword_ragtobase->integer) + { + vec3_t v, a; + float f; + + G2_RagGetWorldAnimMatrix(ghoul2V[0], bone, params, worldBaseMatrix); + G2API_GiveMeVectorFromMatrix(&worldBaseMatrix, ORIGIN, basePos); + + if (broadsword_ragtobase->integer > 1) + { + float fa = AngleNormalize180(animPelvisDir[YAW]-pelvisDir[YAW]); + float d = fa-bone.offsetRotation; + + if (d > 16.0f || + d < -16.0f) + { //don't update unless x degrees away from the ideal to avoid moving goal spots too much if pelvis rotates + bone.offsetRotation = fa; + } + else + { + fa = bone.offsetRotation; + } + //Rotate the point around the pelvis based on the offsets between pelvis positions + VectorSubtract(basePos, animPelvisPos, v); + f = VectorLength(v); + vectoangles(v, a); + a[YAW] -= fa; + AngleVectors(a, v, 0, 0); + VectorNormalize(v); + VectorMA(animPelvisPos, f, v, basePos); + + //re-orient the position of the bone to the current position of the pelvis + VectorSubtract(basePos, animPelvisPos, v); + //push the spots outward? (to stretch the skeleton more) + //v[0] *= 1.5f; + //v[1] *= 1.5f; + VectorAdd(pelvisPos, v, basePos); + } +#if 0 //for debugging frame skeleton + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + + offsets = (mdxaSkelOffsets_t *)((byte *)ghoul2V[0].aHeader + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)ghoul2V[0].aHeader + sizeof(mdxaHeader_t) + offsets->offsets[bone.boneNumber]); + + vec3_t pu; + VectorCopy(basePos, pu); + pu[2] += 32; + if (bone.boneNumber < 11) + { + G2_RagDebugLine(basePos, pu, 50, 0xff00ff, 1); + } + else if (skel->name[0] == 'l') + { + G2_RagDebugLine(basePos, pu, 50, 0xffff00, 1); + } + else if (skel->name[0] == 'r') + { + G2_RagDebugLine(basePos, pu, 50, 0xffffff, 1); + } + else + { + G2_RagDebugLine(basePos, pu, 50, 0x00ffff, 1); + } +#endif + hasBasePos = true; + } + + //Are we in solid? + if (hasDaddy) + { + Rag_Trace(&tr, e.currentOrigin, testMins, testMaxs, parentOrigin, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); + //Rag_Trace(&tr, parentOrigin, testMins, testMaxs, e.currentOrigin, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); + } + else + { + Rag_Trace(&tr, e.currentOrigin, testMins, testMaxs, params->position, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); + } + + if (tr.startsolid || tr.allsolid || tr.fraction != 1.0f) + { //currently in solid, see what we can do about it + vec3_t vSub; + + startSolid = true; + anySolid = true; + + if (hasBasePos)// && bone.solidCount < 32) + { //only go to the base pos for slightly in solid bones +#if 0 //over-compensation + float fl; + float floorBase; + + VectorSubtract(basePos, e.currentOrigin, vSub); + fl = VectorNormalize(vSub); + VectorMA(e.currentOrigin, /*fl*8.0f*/64.0f, vSub, goalSpot); + + floorBase = ((params->position[2]-23)-testMins[2])+8; + + if (goalSpot[2] > floorBase) + { + goalSpot[2] = floorBase; + } +#else //just use the spot directly + VectorCopy(basePos, goalSpot); + goalSpot[2] = (params->position[2]-23)-testMins[2]; +#endif + //Com_Printf("%i: %f %f %f\n", bone.boneNumber, basePos[0], basePos[1], basePos[2]); + } + else + { //if deep in solid want to try to rise up out of solid before hinting back to base + VectorSubtract(e.currentOrigin, params->position, vSub); + VectorNormalize(vSub); + VectorMA(params->position, 40.0f, vSub, goalSpot); + + //should be 1 unit above the ground taking bounding box sizes into account + goalSpot[2] = (params->position[2]-23)-testMins[2]; + } + + //Trace from the entity origin in the direction between the origin and current bone position to + //find a good eventual goal position + Rag_Trace(&tr, params->position, testMins, testMaxs, goalSpot, params->me, RAG_MASK, G2_NOCOLLIDE, 0); + VectorCopy(tr.endpos, goalSpot); + } + else + { + startSolid = false; + +#if 1 //do hinting? + //Hint the bone back to the base origin + if (hasDaddy || hasBasePos) + { + if (hasBasePos) + { + VectorSubtract(basePos, e.currentOrigin, velDir); + } + else + { + VectorSubtract(e.currentOrigin, parentOrigin, velDir); + } + } + else + { + VectorSubtract(e.currentOrigin, params->position, velDir); + } + + if (VectorLength(velDir) > 2.0f) + { //don't bother if already close + VectorNormalize(velDir); + VectorScale(velDir, 8.0f, velDir); + velDir[2] = 0; //don't want to nudge on Z, the gravity will take care of things. + VectorAdd(bone.epVelocity, velDir, bone.epVelocity); + } +#endif + + //Factor the object's velocity into the bone's velocity, by pushing the bone + //opposite the velocity to give the apperance the lighter limbs are being "dragged" + //behind those of greater mass. + if (bone.RagFlags & RAG_BONE_LIGHTWEIGHT) + { + vec3_t vel; + float vellen; + + VectorCopy(params->velocity, vel); + + //Scale down since our velocity scale is different from standard game physics + VectorScale(vel, 0.5f, vel); + + vellen = VectorLength(vel); + + if (vellen > 64.0f) + { //cap it off + VectorScale(vel, 64.0f/vellen, vel); + } + + //Invert the velocity so we go opposite the heavier parts and drag behind + VectorInverse(vel); + + if (vel[2]) + { //want to override entirely instead then + VectorCopy(vel, bone.epVelocity); + } + else + { + VectorAdd(bone.epVelocity, vel, bone.epVelocity); + } + } + + //We're not in solid so we can apply physics freely now. + if (!G2_ApplyRealBonePhysics(bone, e, params, goalSpot, testMins, testMaxs, + gravity, mass, bounce)) + { //if this is the case then somehow we failed to apply physics/get a good goal spot, just use the ent origin + VectorCopy(params->position, goalSpot); + } + } + + //Set this now so we know what to do for angle limiting + if (startSolid) + { + bone.solidCount++; +#if 0 + if ( ri->CGVMLoaded() && bone.solidCount > 8 ) + { //make a callback and see if the cgame wants to help us out + Rag_Trace(&solidTr, params->position, testMins, testMaxs, e.currentOrigin, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); + + if (solidTr.fraction != 1.0f && + (solidTr.plane.normal[0] || solidTr.plane.normal[1]) && + (solidTr.plane.normal[2] < 0.1f || solidTr.plane.normal[2] > -0.1f))// && //don't do anything against flat around + // e.currentOrigin[2] > pelvisPos[2]) + { + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + + VectorCopy(e.currentOrigin, callData->bonePos); + callData->entNum = params->me; + callData->solidCount = bone.solidCount; + + ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + } + } +#endif + +#ifdef _DEBUG_BONE_NAMES + if (bone.solidCount > 64) + { + char *debugBoneName = G2_Get_Bone_Name(&ghoul2V[0], ghoul2V[0].mBlist, bone.boneNumber); + vec3_t absmin, absmax; + + assert(debugBoneName); + + Com_Printf("High bone (%s, %i) solid count: %i\n", debugBoneName, bone.boneNumber, bone.solidCount); + + VectorAdd(e.currentOrigin, testMins, absmin); + VectorAdd(e.currentOrigin, testMaxs, absmax); + G2_RagDebugBox(absmin, absmax, 50); + + G2_RagDebugLine(e.currentOrigin, goalSpot, 50, 0x00ff00, 1); + } +#endif + } + else + { + bone.solidCount = 0; + } + +#if 0 //standard goalSpot capping? + //unless we are really in solid, we should keep adjustments minimal + if (/*bone.epGravFactor < 64 &&*/ bone.solidCount < 2 && + !inAir) + { + vec3_t moveDist; + const float extent = 32.0f; + float len; + + VectorSubtract(goalSpot, e.currentOrigin, moveDist); + len = VectorLength(moveDist); + + if (len > extent) + { //if greater than the extent then scale the vector down to the extent and factor it back into the goalspot + VectorScale(moveDist, extent/len, moveDist); + VectorAdd(e.currentOrigin, moveDist, goalSpot); + } + } +#endif + + //Set the desired direction based on the goal position and other factors. + for (k = 0; k < 3; k++) + { + e.desiredDirection[k] = (goalSpot[k] - e.currentOrigin[k]); + + if (broadsword_dircap && + broadsword_dircap->value) + { + float cap = broadsword_dircap->value; + + if (bone.solidCount > 5) + { + float solidFactor = bone.solidCount*0.2f; + + if (solidFactor > 16.0f) + { //don't go too high or something ugly might happen + solidFactor = 16.0f; + } + + e.desiredDirection[k] *= solidFactor; + cap *= 8; + } + + if (e.desiredDirection[k] > cap) + { + e.desiredDirection[k] = cap; + } + else if (e.desiredDirection[k] < -cap) + { + e.desiredDirection[k] = -cap; + } + } + + e.desiredDirection[k] += (velocityMultiplier * bone.velocityEffector[k]); + e.desiredDirection[k] += (flrand(-0.75f, 0.75f) * flrand(-0.75f, 0.75f)); + + bone.velocityEffector[k] *= velocityDampening; + } + VectorCopy(e.currentOrigin, bone.lastPosition); + } + + return anySolid; +} +#endif + +static float AngleNormZero(float theta) +{ + float ret=fmodf(theta,360.0f); + if (ret<-180.0f) + { + ret+=360.0f; + } + else if (ret>180.0f) + { + ret-=360.0f; + } + assert(ret>=-180.0f&&ret<=180.0f); + return ret; +} + +static inline void G2_BoneSnap(CGhoul2Info_v &ghoul2V, boneInfo_t &bone, CRagDollUpdateParams *params) +{ + if ( !ri->CGVMLoaded() || !params ) + { + return; + } + + ragCallbackBoneSnap_t *callData = (ragCallbackBoneSnap_t *)ri->GetSharedMemory(); + + callData->entNum = params->me; + strcpy(callData->boneName, G2_Get_Bone_Name(&ghoul2V[0], ghoul2V[0].mBlist, bone.boneNumber)); + + ri->CGVM_RagCallback( RAG_CALLBACK_BONESNAP ); +} + +static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameNum,const vec3_t currentOrg,bool limitAngles,CRagDollUpdateParams *params) +{ + + int i; + + CGhoul2Info &ghoul2=ghoul2V[g2Index]; + + mdxaBone_t N; + mdxaBone_t P; + mdxaBone_t temp1; + mdxaBone_t temp2; + mdxaBone_t curRot; + mdxaBone_t curRotInv; + mdxaBone_t Gs[3]; + mdxaBone_t Enew[3]; + + assert(ghoul2.mFileName[0]); + boneInfo_v &blist = ghoul2.mBlist; + + + // END this is the objective function thing + for (i=0;i50.0f) + { + bone.velocityRoot[k]=50.0f; + } + if (bone.velocityRoot[k]<-50.0f) + { + bone.velocityRoot[k]=-50.0f; + } + */ + //No -rww + bone.ragOverrideMatrix.matrix[k][3]=bone.velocityRoot[k]; + } + } + } + else + { + vec3_t delAngles; + VectorClear(delAngles); + + for (k=0;k<3;k++) + { + tAngles[k]+=0.5f; + Create_Matrix(tAngles,&temp2); //dest 2nd arg + tAngles[k]-=0.5f; + Multiply_3x4Matrix(&temp1,&P,&temp2); //dest first arg + Multiply_3x4Matrix(&Gs[k],&temp1,&N); //dest first arg + + } + + int allSolidCount = 0;//bone.solidCount; + + // fixme precompute this + int numDep=G2_GetBoneDependents(ghoul2,bone.boneNumber,tempDependents,MAX_BONES_RAG); + int j; + int numRagDep=0; + for (j=0;jragIndex; + assert(depIndex>i); // these are supposed to be topologically sorted + assert(ragBoneData[depIndex]); + boneInfo_t &depBone=*ragBoneData[depIndex]; + if (depBone.RagFlags & RAG_EFFECTOR) // rag doll effector + { + // this is a dependent of me, and also a rag + numRagDep++; + for (k=0;k<3;k++) + { + Multiply_3x4Matrix(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg + vec3_t tPosition; + tPosition[0]=Enew[k].matrix[0][3]; + tPosition[1]=Enew[k].matrix[1][3]; + tPosition[2]=Enew[k].matrix[2][3]; + + vec3_t change; + VectorSubtract(tPosition,ragEffectors[depIndex].currentOrigin,change); // dest is last arg + float goodness=DotProduct(change,ragEffectors[depIndex].desiredDirection); + assert( !Q_isnan(goodness)); + goodness*=depBone.weight; + delAngles[k]+=goodness; // keep bigger stuff more out of wall or something + assert( !Q_isnan(delAngles[k])); + } + allSolidCount += depBone.solidCount; + } + } + + //bone.solidCount = allSolidCount; + allSolidCount += bone.solidCount; + + VectorCopy(bone.currentAngles,bone.lastAngles); + // Update angles + float magicFactor9=0.75f; // dampfactor for angle changes + float magicFactor1=0.40f; //controls the speed of the gradient descent + float magicFactor32 = 1.5f; + float recip=0.0f; + if (numRagDep) + { + recip=sqrt(4.0f/float(numRagDep)); + } + + if (allSolidCount > 32) + { + magicFactor1 = 0.6f; + } + else if (allSolidCount > 10) + { + magicFactor1 = 0.5f; + } + + if (bone.overGradSpeed) + { //api call was made to specify a speed for this bone + magicFactor1 = bone.overGradSpeed; + } + + float fac=decay*recip*magicFactor1; + assert(fac>=0.0f); +#if 0 + if (bone.RagFlags & RAG_PCJ_PELVIS) + { + magicFactor9=.85f; // we don't want this swinging radically, make the whole thing kindof unstable + } +#endif + if (ragState==ERS_DYNAMIC) + { + magicFactor9=.85f; // we don't want this swinging radically, make the whole thing kindof unstable + } + +#if 1 //constraint breaks? + if (bone.RagFlags & RAG_UNSNAPPABLE) + { + magicFactor32 = 1.0f; + } +#endif + + for (k=0;k<3;k++) + { + bone.currentAngles[k]+=delAngles[k]*fac; + + bone.currentAngles[k]=(bone.lastAngles[k]-bone.currentAngles[k])*magicFactor9 + bone.currentAngles[k]; + bone.currentAngles[k]=AngleNormZero(bone.currentAngles[k]); +// bone.currentAngles[k]=flrand(bone.minAngles[k],bone.maxAngles[k]); +#if 1 //constraint breaks? + if (limitAngles && ( allSolidCount < 32 || (bone.RagFlags & RAG_UNSNAPPABLE) )) //32 tries and still in solid? Then we'll let you move freely +#else + if (limitAngles) +#endif + { + if (!bone.snapped || (bone.RagFlags & RAG_UNSNAPPABLE)) + { + //magicFactor32 += (allSolidCount/32); + + if (bone.currentAngles[k]>bone.maxAngles[k]*magicFactor32) + { + bone.currentAngles[k]=bone.maxAngles[k]*magicFactor32; + } + if (bone.currentAngles[k]bone.maxAngles[k]*magicFactor32) + { + isSnapped = true; + break; + } + if (bone.currentAngles[k]ragIndex; + if (!ragBoneData[depIndex]) + { + continue; + } + boneInfo_t &depBone=*ragBoneData[depIndex]; + + if (depBone.RagFlags & RAG_EFFECTOR) + { + // this is a dependent of me, and also a rag + numRagDep++; + for (k=0;k<3;k++) + { + Multiply_3x4Matrix(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg + vec3_t tPosition; + tPosition[0]=Enew[k].matrix[0][3]; + tPosition[1]=Enew[k].matrix[1][3]; + tPosition[2]=Enew[k].matrix[2][3]; + + vec3_t change; + VectorSubtract(tPosition,ragEffectors[depIndex].currentOrigin,change); // dest is last arg + float goodness=DotProduct(change,ragEffectors[depIndex].desiredDirection); + assert( !Q_isnan(goodness)); + goodness*=depBone.weight; + delAngles[k]+=goodness; // keep bigger stuff more out of wall or something + assert( !Q_isnan(delAngles[k])); + } + } + } + + VectorCopy(bone.currentAngles, bone.lastAngles); + + // Update angles + float magicFactor9 = 0.75f; // dampfactor for angle changes + float magicFactor1 = bone.ikSpeed; //controls the speed of the gradient descent + float magicFactor32 = 1.0f; + float recip = 0.0f; + bool freeThisBone = false; + + if (!magicFactor1) + { + magicFactor1 = 0.40f; + } + + recip = sqrt(4.0f/1.0f); + + float fac = (decay*recip*magicFactor1); + assert(fac >= 0.0f); + + if (ragState == ERS_DYNAMIC) + { + magicFactor9 = 0.85f; // we don't want this swinging radically, make the whole thing kindof unstable + } + + + if (!bone.maxAngles[0] && !bone.maxAngles[1] && !bone.maxAngles[2] && + !bone.minAngles[0] && !bone.minAngles[1] && !bone.minAngles[2]) + { + freeThisBone = true; + } + + for (k = 0; k < 3; k++) + { + bone.currentAngles[k] += delAngles[k]*fac; + + bone.currentAngles[k] = (bone.lastAngles[k]-bone.currentAngles[k])*magicFactor9 + bone.currentAngles[k]; + bone.currentAngles[k] = AngleNormZero(bone.currentAngles[k]); + if (limitAngles && !freeThisBone) + { + if (bone.currentAngles[k] > bone.maxAngles[k]*magicFactor32) + { + bone.currentAngles[k] = bone.maxAngles[k]*magicFactor32; + } + if (bone.currentAngles[k] < bone.minAngles[k]*magicFactor32) + { + bone.currentAngles[k] = bone.minAngles[k]*magicFactor32; + } + } + } + Create_Matrix(bone.currentAngles, &temp1); + Multiply_3x4Matrix(&temp2, &temp1, bone.baseposeInv); + Multiply_3x4Matrix(&bone.ragOverrideMatrix, bone.basepose, &temp2); + assert( !Q_isnan(bone.ragOverrideMatrix.matrix[2][3])); + + G2_Generate_MatrixRag(blist, ragBlistIndex[bone.boneNumber]); + } +} + +static void G2_DoIK(CGhoul2Info_v &ghoul2V,int g2Index,CRagDollUpdateParams *params) +{ + int i; + + if (!params) + { + assert(0); + return; + } + + int frameNum=G2API_GetTime(0); + CGhoul2Info &ghoul2=ghoul2V[g2Index]; + assert(ghoul2.mFileName[0]); + + float decay=1.0f; + bool resetOrigin=false; + bool anyRendered=false; + + int iters = 12; //since we don't trace or anything, we can afford this. + + if (iters) + { + if (!G2_RagDollSetup(ghoul2,frameNum,resetOrigin,params->position,anyRendered)) + { + return; + } + + // ok, now our data structures are compact and set up in topological order + for (i=0;iangles,params->position,params->scale); + + G2_IKReposition(params->position, params); + + G2_IKSolve(ghoul2V,g2Index,decay*2.0f,frameNum,params->position,true); + } + } + + if (params->me != ENTITYNUM_NONE) + { + G2_RagDollCurrentPosition(ghoul2V,g2Index,frameNum,params->angles,params->position,params->scale); + } +} + +//rww - cut out the entire non-ragdoll section of this.. +void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const int index,CRagDollUpdateParams *params) +{ + bool anyRagDoll=false; + bool anyIK = false; + for(size_t i=0; iangles, parms->position); + G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); + + // new base anim, unconscious flop + int pcjFlags; +#if 0 + vec3_t pcjMin, pcjMax; + VectorClear(pcjMin); + VectorClear(pcjMax); + + pcjFlags=RAG_PCJ|RAG_PCJ_POST_MULT;//|RAG_EFFECTOR; + + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"model_root",RAG_PCJ_MODEL_ROOT|RAG_PCJ,10.0f,pcjMin,pcjMax,100); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"pelvis",RAG_PCJ_PELVIS|RAG_PCJ|RAG_PCJ_POST_MULT,10.0f,pcjMin,pcjMax,100); + + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lower_lumbar",pcjFlags,10.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"upper_lumbar",pcjFlags,10.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"thoracic",pcjFlags|RAG_EFFECTOR,12.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"cranium",pcjFlags,6.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rhumerus",pcjFlags,4.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lhumerus",pcjFlags,4.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rradius",pcjFlags,3.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lradius",pcjFlags,3.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rfemurYZ",pcjFlags,6.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lfemurYZ",pcjFlags,6.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rtibia",pcjFlags,4.0f,pcjMin,pcjMax,500); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ltibia",pcjFlags,4.0f,pcjMin,pcjMax,500); + + G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); +#endif + //Only need the standard effectors for this. + pcjFlags = RAG_PCJ|RAG_PCJ_POST_MULT|RAG_EFFECTOR; + + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rhand",pcjFlags,6.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lhand",pcjFlags,6.0f); +// G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rtarsal",pcjFlags,4.0f); +// G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ltarsal",pcjFlags,4.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rtibia",pcjFlags,4.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ltibia",pcjFlags,4.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rtalus",pcjFlags,4.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ltalus",pcjFlags,4.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rradiusX",pcjFlags,6.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lradiusX",pcjFlags,6.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rfemurX",pcjFlags,10.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lfemurX",pcjFlags,10.0f); + G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ceyebrow",pcjFlags,10.0f); +} + +qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params) +{ + model_t *mod_a; + int g2index = 0; + int curTime = time; + CGhoul2Info &g2 = ghoul2[g2index]; + const mdxaHeader_t *rmod_a = G2_GetModA(g2); + + boneInfo_v &blist = g2.mBlist; + mod_a = (model_t *)g2.animModel; + + if (!boneName) + { //null bonename param means it's time to init the ik stuff on this instance + sharedRagDollUpdateParams_t sRDUP; + + if (ikState == IKS_NONE) + { //this means we want to reset the IK state completely.. run through the bone list, and reset all the appropriate flags + size_t i = 0; + while (i < blist.size()) + { //we can't use this method for ragdoll. However, since we expect them to set their anims/angles again on the PCJ + //limb after they reset it gameside, it's reasonable for IK bones. + boneInfo_t &bone = blist[i]; + if (bone.boneNumber != -1) + { + bone.flags &= ~BONE_ANGLES_RAGDOLL; + bone.flags &= ~BONE_ANGLES_IK; + bone.RagFlags = 0; + bone.lastTimeUpdated = 0; + } + i++; + } + return qtrue; + } + assert(params); + + if (!params) + { + return qfalse; + } + + sRDUP.me = 0; + VectorCopy(params->angles, sRDUP.angles); + VectorCopy(params->origin, sRDUP.position); + VectorCopy(params->scale, sRDUP.scale); + VectorClear(sRDUP.velocity); + G2_InitIK(ghoul2, &sRDUP, curTime, rmod_a, g2index); + return qtrue; + } + + if (!rmod_a || !mod_a) + { + return qfalse; + } + + int index = G2_Find_Bone(mod_a, blist, boneName); + + if (index == -1) + { + index = G2_Add_Bone(mod_a, blist, boneName); + } + + if (index == -1) + { //couldn't find or add the bone.. + return qfalse; + } + + boneInfo_t &bone = blist[index]; + + if (ikState == IKS_NONE) + { //remove the bone from the list then, so it has to reinit. I don't think this should hurt anything since + //we don't store bone index handles gameside anywhere. + if (!(bone.flags & BONE_ANGLES_RAGDOLL)) + { //you can't set the ik state to none if it's not a rag/ik bone. + return qfalse; + } + //bone.flags = 0; + //G2_Remove_Bone_Index(blist, index); + //actually, I want to keep it on the rag list, and remove it as an IK bone instead. + bone.flags &= ~BONE_ANGLES_RAGDOLL; + bone.flags |= BONE_ANGLES_IK; + bone.RagFlags &= ~RAG_PCJ_IK_CONTROLLED; + return qtrue; + } + + //need params if we're not resetting. + if (!params) + { + assert(0); + return qfalse; + } + + if (bone.flags & BONE_ANGLES_RAGDOLL) + { //otherwise if the bone is already flagged as rag, then we can't set it again. (non-active ik bones will be BONE_ANGLES_IK, active are considered rag) + return qfalse; + } +#if 0 //this is wrong now.. we're only initing effectors with initik now.. which SHOULDN'T be used as pcj's + if (!(bone.flags & BONE_ANGLES_IK) && !(bone.flags & BONE_ANGLES_RAGDOLL)) + { //IK system has not been inited yet, because any bone that can be IK should be in the ragdoll list, not flagged as BONE_ANGLES_RAGDOLL but as BONE_ANGLES_IK + sharedRagDollUpdateParams_t sRDUP; + sRDUP.me = 0; + VectorCopy(params->angles, sRDUP.angles); + VectorCopy(params->origin, sRDUP.position); + VectorCopy(params->scale, sRDUP.scale); + VectorClear(sRDUP.velocity); + G2_InitIK(ghoul2, &sRDUP, curTime, rmod_a, g2index); + + G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); + } + else + { + G2_GenerateWorldMatrix(params->angles, params->origin); + G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); + } +#else + G2_GenerateWorldMatrix(params->angles, params->origin); + G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); +#endif + + int pcjFlags = RAG_PCJ|RAG_PCJ_IK_CONTROLLED|RAG_PCJ_POST_MULT|RAG_EFFECTOR; + + if (params->pcjOverrides) + { + pcjFlags = params->pcjOverrides; + } + + bone.ikSpeed = 0.4f; + VectorClear(bone.ikPosition); + + G2_Set_Bone_Rag(rmod_a, blist, boneName, g2, params->scale, params->origin); + + int startFrame = params->startFrame, endFrame = params->endFrame; + + if (bone.startFrame != startFrame || bone.endFrame != endFrame || params->forceAnimOnBone) + { //if it's already on this anim leave it alone, to allow smooth transitions into IK on the current anim if it is so desired. + G2_Set_Bone_Anim_No_BS(g2, rmod_a, blist, boneName, startFrame, endFrame-1, + BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, + 1.0f, curTime, float(startFrame), 150, 0, true); + } + + G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); + + bone.lastTimeUpdated = 0; + G2_Set_Bone_Angles_Rag(g2, rmod_a, blist, boneName, pcjFlags, params->radius, params->pcjMins, params->pcjMaxs, params->blendTime); + + if (!G2_RagDollSetup(g2,curTime,true,params->origin,false)) + { + assert(!"failed to add any rag bones"); + return qfalse; + } + + return qtrue; +} + +qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params) +{ +#if 0 + model_t *mod_a; + int g2index = 0; + int curTime = time; + CGhoul2Info &g2 = ghoul2[g2index]; + + boneInfo_v &blist = g2.mBlist; + mod_a = (model_t *)g2.animModel; + + if (!mod_a) + { + return qfalse; + } + + int index = G2_Find_Bone(mod_a, blist, params->boneName); + + //don't add here if you can't find it.. ik bones should already be there, because they need to have special stuff done to them anyway. + if (index == -1) + { //couldn't find the bone.. + return qfalse; + } + + if (!params) + { + assert(0); + return qfalse; + } + + if (!(blist[index].flags & BONE_ANGLES_RAGDOLL) && !(blist[index].flags & BONE_ANGLES_IK)) + { //no-can-do, buddy + return qfalse; + } + + VectorCopy(params->desiredOrigin, blist[index].ikPosition); + blist[index].ikSpeed = params->movementSpeed; +#else + int g2index = 0; + int curTime = time; + CGhoul2Info &g2 = ghoul2[g2index]; + + //rwwFIXMEFIXME: Doing this on all bones at the moment, fix this later? + if (!G2_RagDollSetup(g2,curTime,true,params->origin,false)) + { //changed models, possibly. + return qfalse; + } + + for (int i=0;idesiredOrigin, bone.ikPosition); + bone.ikSpeed = params->movementSpeed; + } + } +#endif + return qtrue; +} + +// set the bone list to all unused so the bone transformation routine ignores it. +void G2_Init_Bone_List(boneInfo_v &blist) +{ + blist.clear(); +} + +void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) +{ + // walk the surface list, removing surface overrides or generated surfaces that are pointing at surfaces that aren't active anymore + for (size_t i=0; imFileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + + return (G2_Find_Bone(mod_a, ghoul2->mBlist, boneName)); +} diff --git a/codemp/rd-rend2/G2_local.h b/codemp/rd-rend2/G2_local.h new file mode 100644 index 0000000000..f6dde09402 --- /dev/null +++ b/codemp/rd-rend2/G2_local.h @@ -0,0 +1,207 @@ +#pragma once + +// defines to setup the + +#include "ghoul2/ghoul2_shared.h" +#include "tr_local.h" + +//rww - RAGDOLL_BEGIN +class CRagDollUpdateParams; +//rww - RAGDOLL_END + +class CMiniHeap; + +#define GHOUL2_CRAZY_SMOOTH 0x2000 //hack for smoothing during ugly situations. forgive me. + +void Create_Matrix(const float *angle, mdxaBone_t *matrix); + +extern mdxaBone_t worldMatrix; +extern mdxaBone_t worldMatrixInv; + +// internal surface calls G2_surfaces.cpp +qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName, const int offFlags); +int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName); +qboolean G2_SetRootSurface( CGhoul2Info_v &ghoul2, const int modelIndex, const char *surfaceName); +int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod ); +qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index); +surfaceInfo_t *G2_FindOverrideSurface(int surfaceNum, surfaceInfo_v &surfaceList); +int G2_IsSurfaceLegal(void *mod, const char *surfaceName, int *flags); +int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index); +int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName); +int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceInfo_v &slist); + +// internal bone calls - G2_Bones.cpp +qboolean G2_Set_Bone_Angles(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const float *angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime); +qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName); +qboolean G2_Set_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime); +qboolean G2_Get_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int modelIndex); +qboolean G2_Get_Bone_Anim_Range(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, int *startFrame, int *endFrame); +qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName, const int currentTime ); +qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName); +qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName); +qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName); +//rww - RAGDOLL_BEGIN +void G2_Animate_Bone_List(CGhoul2Info_v &ghoul2, const int currentTime, const int index,CRagDollUpdateParams *params); +//rww - RAGDOLL_END +void G2_Init_Bone_List(boneInfo_v &blist); +int G2_Find_Bone_In_List(boneInfo_v &blist, const int boneNum); +void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones); +qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime); +int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName); +qboolean G2_Set_Bone_Angles_Index(boneInfo_v &blist, const int index, const float *angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime); +qboolean G2_Set_Bone_Angles_Matrix_Index(boneInfo_v &blist, const int index, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, const int modelIndex, const int blendTime, const int currentTime); +qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index); +qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index); +qboolean G2_Set_Bone_Anim_Index(boneInfo_v &blist, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime, const int numFrames); +qboolean G2_Get_Bone_Anim_Index( boneInfo_v &blist, const int index, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *retAnimSpeed, qhandle_t *modelList, int modelIndex); + +// misc functions G2_misc.cpp +void G2_List_Model_Surfaces(const char *fileName); +void G2_List_Model_Bones(const char *fileName, int frame); +qboolean G2_GetAnimFileName(const char *fileName, char **filename); +#ifdef _G2_GORE +void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CollisionRecord_t *collRecMap, int entNum, int traceFlags, int useLod, float fRadius, float ssize,float tsize,float theta,int shader, SSkinGoreData *gore, qboolean skipIfLODNotMatch); +#else +void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CollisionRecord_t *collRecMap, int entNum, int traceFlags, int useLod, float fRadius); +#endif +void TransformAndTranslatePoint (const vec3_t in, vec3_t out, mdxaBone_t *mat); +#ifdef _G2_GORE +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod, bool ApplyGore); +#else +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod); +#endif +void G2_GenerateWorldMatrix(const vec3_t angles, const vec3_t origin); +void TransformPoint (const vec3_t in, vec3_t out, mdxaBone_t *mat); +void Inverse_Matrix(mdxaBone_t *src, mdxaBone_t *dest); +void *G2_FindSurface(void *mod, int index, int lod); +qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size); +void G2_LoadGhoul2Model(CGhoul2Info_v &ghoul2, char *buffer); + +// internal bolt calls. G2_bolts.cpp +int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const char *boneName); +qboolean G2_Remove_Bolt (boltInfo_v &bltlist, int index); +void G2_Init_Bolt_List(boltInfo_v &bltlist); +int G2_Find_Bolt_Bone_Num(boltInfo_v &bltlist, const int boneNum); +int G2_Find_Bolt_Surface_Num(boltInfo_v &bltlist, const int surfaceNum, const int flags); +int G2_Add_Bolt_Surf_Num(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, const int surfNum); +void G2_RemoveRedundantBolts(boltInfo_v &bltlist, surfaceInfo_v &slist, int *activeSurfaces, int *activeBones); + + +// API calls - G2_API.cpp +void G2API_SetTime(int currentTime, int clock); +int G2API_GetTime(int argTime); + +qhandle_t G2API_PrecacheGhoul2Model(const char *fileName); + +int G2API_InitGhoul2Model(CGhoul2Info_v **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin = NULL_HANDLE, qhandle_t customShader = NULL_HANDLE, int modelFlags = 0, int lodBias = 0); +qboolean G2API_SetLodBias(CGhoul2Info *ghlInfo, int lodBias); +qboolean G2API_SetSkin(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin); +qboolean G2API_SetShader(CGhoul2Info *ghlInfo, qhandle_t customShader); +qboolean G2API_HasGhoul2ModelOnIndex(CGhoul2Info_v **ghlRemove, const int modelIndex); +qboolean G2API_RemoveGhoul2Model(CGhoul2Info_v **ghlRemove, const int modelIndex); +qboolean G2API_RemoveGhoul2Models(CGhoul2Info_v **ghlRemove); +qboolean G2API_SetSurfaceOnOff(CGhoul2Info_v &ghoul2, const char *surfaceName, const int flags); +int G2API_GetSurfaceOnOff(CGhoul2Info *ghlInfo, const char *surfaceName); +qboolean G2API_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const char *surfaceName); +qboolean G2API_RemoveSurface(CGhoul2Info *ghlInfo, const int index); +int G2API_AddSurface(CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod ); +qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame = -1, const int blendTime = -1); +qboolean G2API_GetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList); +qboolean G2API_GetAnimRange(CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame); +qboolean G2API_PauseBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime); +qboolean G2API_IsPaused(CGhoul2Info *ghlInfo, const char *boneName); +qboolean G2API_StopBoneAnim(CGhoul2Info *ghlInfo, const char *boneName); + + +qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ); + +qboolean G2API_StopBoneAngles(CGhoul2Info *ghlInfo, const char *boneName); +qboolean G2API_RemoveBone(CGhoul2Info *ghlInfo, const char *boneName); +void G2API_AnimateG2Models(CGhoul2Info_v &ghoul2, float speedVar); +qboolean G2API_RemoveBolt(CGhoul2Info *ghlInfo, const int index); +int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName); +int G2API_AddBoltSurfNum(CGhoul2Info *ghlInfo, const int surfIndex); +void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo); +qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel); +qboolean G2API_DetachG2Model(CGhoul2Info *ghlInfo); +qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum); +void G2API_DetachEnt(int *boltInfo); + +qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale); + +void G2API_ListSurfaces(CGhoul2Info *ghlInfo); +void G2API_ListBones(CGhoul2Info *ghlInfo, int frame); +qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2); +void G2API_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList); +qboolean G2API_SetGhoul2ModelFlags(CGhoul2Info *ghlInfo, const int flags); +int G2API_GetGhoul2ModelFlags(CGhoul2Info *ghlInfo); + +qboolean G2API_GetAnimFileName(CGhoul2Info *ghlInfo, char **filename); +void G2API_CollisionDetect(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius); +void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius); + +void G2API_GiveMeVectorFromMatrix(mdxaBone_t *boltMatrix, Eorientations flags, vec3_t vec); +int G2API_CopyGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int modelIndex); +void G2API_CleanGhoul2Models(CGhoul2Info_v **ghoul2Ptr); +int G2API_GetParentSurface(CGhoul2Info *ghlInfo, const int index); +int G2API_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName); +char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber); +char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex); +qboolean G2API_SetBoneAnglesMatrix(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime = 0, int currentTime = 0); +qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex); +int G2API_GetBoneIndex(CGhoul2Info *ghlInfo, const char *boneName); +qboolean G2API_StopBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index); +qboolean G2API_StopBoneAnimIndex(CGhoul2Info *ghlInfo, const int index); +qboolean G2API_SetBoneAnglesIndex( CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, int blendTime, int currentTime ); +qboolean G2API_SetBoneAnglesMatrixIndex(CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int currentTime); +qboolean G2API_DoesBoneExist(CGhoul2Info *ghlInfo, const char *boneName); +qboolean G2API_SetBoneAnimIndex(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime); +qboolean G2API_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size); +void G2API_LoadGhoul2Models(CGhoul2Info_v &ghoul2, char *buffer); +void G2API_LoadSaveCodeDestructGhoul2Info(CGhoul2Info_v &ghoul2); +void G2API_FreeSaveBuffer(char *buffer); +char *G2API_GetAnimFileNameIndex(qhandle_t modelIndex); +int G2API_GetSurfaceRenderStatus(CGhoul2Info *ghlInfo, const char *surfaceName); +void G2API_CopySpecificG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo); +void G2API_DuplicateGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v **g2To); +void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo); + +class CRagDollUpdateParams; +class CRagDollParams; + +void G2API_AbsurdSmoothing(CGhoul2Info_v &ghoul2, qboolean status); + +void G2API_SetRagDoll(CGhoul2Info_v &ghoul2,CRagDollParams *parms); +void G2API_ResetRagDoll(CGhoul2Info_v &ghoul2); +void G2API_AnimateG2ModelsRag(CGhoul2Info_v &ghoul2, int AcurrentTime,CRagDollUpdateParams *params); + +qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max); +qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, const float speed); +qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos); +qboolean G2API_GetRagBonePos(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale); +qboolean G2API_RagEffectorKick(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity); +qboolean G2API_RagForceSolve(CGhoul2Info_v &ghoul2, qboolean force); + +qboolean G2API_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params); +qboolean G2API_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params); + +void G2API_AttachInstanceToEntNum(CGhoul2Info_v &ghoul2, int entityNum, qboolean server); +void G2API_ClearAttachedInstance(int entityNum); +void G2API_CleanEntAttachments(void); +qboolean G2API_OverrideServerWithClientData(CGhoul2Info *serverInstance); + +extern qboolean gG2_GBMNoReconstruct; +extern qboolean gG2_GBMUseSPMethod; +// From tr_ghoul2.cpp +void G2_ConstructGhoulSkeleton( CGhoul2Info_v &ghoul2,const int frameNum,bool checkForNewOrigin,const vec3_t scale); + +qboolean G2API_SkinlessModel(CGhoul2Info *g2); + +#ifdef _G2_GORE +int G2API_GetNumGoreMarks(CGhoul2Info *g2); +void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore); +void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 ); +#endif // _SOF2 + +int G2API_Ghoul2Size ( CGhoul2Info_v &ghoul2 ); +void RemoveBoneCache( CBoneCache *boneCache ); diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp new file mode 100644 index 0000000000..af997df82f --- /dev/null +++ b/codemp/rd-rend2/G2_misc.cpp @@ -0,0 +1,1915 @@ +#include "qcommon/matcomp.h" +#include "ghoul2/G2.h" +#include "qcommon/MiniHeap.h" +#include "server/server.h" +#include "G2_local.h" + +#ifdef _G2_GORE +#include "ghoul2/G2_gore.h" + +#define GORE_TAG_UPPER (256) +#define GORE_TAG_MASK (~255) + +static int CurrentTag=GORE_TAG_UPPER+1; +static int CurrentTagUpper=GORE_TAG_UPPER; + +static map GoreRecords; +static map,int> GoreTagsTemp; // this is a surface index to gore tag map used only + // temporarily during the generation phase so we reuse gore tags per LOD +int goreModelIndex; + +static cvar_t *cg_g2MarksAllModels=NULL; + +GoreTextureCoordinates *FindGoreRecord(int tag); +static inline void DestroyGoreTexCoordinates(int tag) +{ + GoreTextureCoordinates *gTC = FindGoreRecord(tag); + if (!gTC) + { + return; + } + gTC->~GoreTextureCoordinates(); + //I don't know what's going on here, it should call the destructor for + //this when it erases the record but sometimes it doesn't. -rww +} + +//TODO: This needs to be set via a scalability cvar with some reasonable minimum value if pgore is used at all +#define MAX_GORE_RECORDS (500) + +int AllocGoreRecord() +{ + while (GoreRecords.size()>MAX_GORE_RECORDS) + { + int tagHigh=(*GoreRecords.begin()).first&GORE_TAG_MASK; + map::iterator it; + GoreTextureCoordinates *gTC; + + it = GoreRecords.begin(); + gTC = &(*it).second; + + if (gTC) + { + gTC->~GoreTextureCoordinates(); + } + GoreRecords.erase(GoreRecords.begin()); + while (GoreRecords.size()) + { + if (((*GoreRecords.begin()).first&GORE_TAG_MASK)!=tagHigh) + { + break; + } + it = GoreRecords.begin(); + gTC = &(*it).second; + + if (gTC) + { + gTC->~GoreTextureCoordinates(); + } + GoreRecords.erase(GoreRecords.begin()); + } + } + int ret=CurrentTag; + GoreRecords[CurrentTag]=GoreTextureCoordinates(); + CurrentTag++; + return ret; +} + +void ResetGoreTag() +{ + GoreTagsTemp.clear(); + CurrentTag=CurrentTagUpper; + CurrentTagUpper+=GORE_TAG_UPPER; +} + +GoreTextureCoordinates *FindGoreRecord(int tag) +{ + map::iterator i=GoreRecords.find(tag); + if (i!=GoreRecords.end()) + { + return &(*i).second; + } + return 0; +} + +void *G2_GetGoreRecord(int tag) +{ + return FindGoreRecord(tag); +} + +void DeleteGoreRecord(int tag) +{ + DestroyGoreTexCoordinates(tag); + GoreRecords.erase(tag); +} + +static int CurrentGoreSet=1; // this is a UUID for gore sets +static map GoreSets; // map from uuid to goreset + +CGoreSet *FindGoreSet(int goreSetTag) +{ + map::iterator f=GoreSets.find(goreSetTag); + if (f!=GoreSets.end()) + { + return (*f).second; + } + return 0; +} + +CGoreSet *NewGoreSet() +{ + CGoreSet *ret=new CGoreSet(CurrentGoreSet++); + GoreSets[ret->mMyGoreSetTag]=ret; + ret->mRefCount = 1; + return ret; +} + +void DeleteGoreSet(int goreSetTag) +{ + map::iterator f=GoreSets.find(goreSetTag); + if (f!=GoreSets.end()) + { + if ( (*f).second->mRefCount == 0 || (*f).second->mRefCount - 1 == 0 ) + { + delete (*f).second; + GoreSets.erase(f); + } + else + { + (*f).second->mRefCount--; + } + } +} + + +CGoreSet::~CGoreSet() +{ + multimap::iterator i; + for (i=mGoreRecords.begin();i!=mGoreRecords.end();i++) + { + DeleteGoreRecord((*i).second.mGoreTag); + } +}; +#endif // _SOF2 + +const mdxaBone_t &EvalBoneCache(int index,CBoneCache *boneCache); + +#ifdef _MSC_VER +#pragma warning(disable : 4512) //assignment op could not be genereated +#endif +class CTraceSurface +{ +public: + int surfaceNum; + surfaceInfo_v &rootSList; + model_t *currentModel; + int lod; + vec3_t rayStart; + vec3_t rayEnd; + CollisionRecord_t *collRecMap; + int entNum; + int modelIndex; + skin_t *skin; +#ifdef _WIN32 + struct shader_t *cust_shader; +#else + shader_t *cust_shader; +#endif + size_t *TransformedVertsArray; + int traceFlags; + bool hitOne; + float m_fRadius; + +#ifdef _G2_GORE + //gore application thing + float ssize; + float tsize; + float theta; + int goreShader; + CGhoul2Info *ghoul2info; + + // Procedural-gore application things + SSkinGoreData *gore; +#endif + + CTraceSurface( + int initsurfaceNum, + surfaceInfo_v &initrootSList, + model_t *initcurrentModel, + int initlod, + vec3_t initrayStart, + vec3_t initrayEnd, + CollisionRecord_t *initcollRecMap, + int initentNum, + int initmodelIndex, + skin_t *initskin, + shader_t *initcust_shader, + size_t *initTransformedVertsArray, + int inittraceFlags, +#ifdef _G2_GORE + float fRadius, + float initssize, + float inittsize, + float inittheta, + int initgoreShader, + CGhoul2Info *initghoul2info, + SSkinGoreData *initgore): +#else + float fRadius): +#endif + + surfaceNum(initsurfaceNum), + rootSList(initrootSList), + currentModel(initcurrentModel), + lod(initlod), + collRecMap(initcollRecMap), + entNum(initentNum), + modelIndex(initmodelIndex), + skin(initskin), + cust_shader(initcust_shader), + TransformedVertsArray(initTransformedVertsArray), + traceFlags(inittraceFlags), +#ifdef _G2_GORE + m_fRadius(fRadius), + ssize(initssize), + tsize(inittsize), + theta(inittheta), + goreShader(initgoreShader), + ghoul2info(initghoul2info), + gore(initgore) +#else + m_fRadius(fRadius) +#endif + { + VectorCopy(initrayStart, rayStart); + VectorCopy(initrayEnd, rayEnd); + hitOne = false; + } + +}; + +// assorted Ghoul 2 functions. +// list all surfaces associated with a model +void G2_List_Model_Surfaces(const char *fileName) +{ + int i, x; + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + mdxmSurfHierarchy_t *surf; + + surf = (mdxmSurfHierarchy_t *) ( (byte *)mod_m->mdxm + mod_m->mdxm->ofsSurfHierarchy ); + mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mod_m->mdxm + mod_m->mdxm->ofsLODs + sizeof(mdxmLOD_t)); + + for ( x = 0 ; x < mod_m->mdxm->numSurfaces ; x++) + { + Com_Printf("Surface %i Name %s\n", x, surf->name); + if ( r_verbose->integer ) + { + Com_Printf("Num Descendants %i\n", surf->numChildren); + for (i=0; inumChildren; i++) + { + Com_Printf("Descendant %i\n", surf->childIndexes[i]); + } + } + // find the next surface + surf = (mdxmSurfHierarchy_t *)( (byte *)surf + (size_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surf->numChildren ] )); + surface =(mdxmSurface_t *)( (byte *)surface + surface->ofsEnd ); + } + +} + +// list all bones associated with a model +void G2_List_Model_Bones(const char *fileName, int frame) +{ + int x, i; + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); +// mdxaFrame_t *aframe=0; +// int frameSize; + mdxaHeader_t *header = mod_a->mdxa; + + // figure out where the offset list is + offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + +// frameSize = (size_t)( &((mdxaFrame_t *)0)->boneIndexes[ header->numBones ] ); + +// aframe = (mdxaFrame_t *)((byte *)header + header->ofsFrames + (frame * frameSize)); + // walk each bone and list it's name + for (x=0; x< mod_a->mdxa->numBones; x++) + { + skel = (mdxaSkel_t *)((byte *)header + sizeof(mdxaHeader_t) + offsets->offsets[x]); + Com_Printf("Bone %i Name %s\n", x, skel->name); + + Com_Printf("X pos %f, Y pos %f, Z pos %f\n", skel->BasePoseMat.matrix[0][3], skel->BasePoseMat.matrix[1][3], skel->BasePoseMat.matrix[2][3]); + + // if we are in verbose mode give us more details + if ( r_verbose->integer ) + { + Com_Printf("Num Descendants %i\n", skel->numChildren); + for (i=0; inumChildren; i++) + { + Com_Printf("Num Descendants %i\n", skel->numChildren); + } + } + } +} + + +/************************************************************************************************ + * G2_GetAnimFileName + * obtain the .gla filename for a model + * + * Input + * filename of model + * + * Output + * true if we successfully obtained a filename, false otherwise + * + ************************************************************************************************/ +qboolean G2_GetAnimFileName(const char *fileName, char **filename) +{ + // find the model we want + model_t *mod = R_GetModelByHandle(RE_RegisterModel(fileName)); + + if (mod && mod->mdxm && (mod->mdxm->animName[0] != 0)) + { + *filename = mod->mdxm->animName; + return qtrue; + } + return qfalse; +} + + +///////////////////////////////////////////////////////////////////// +// +// Code for collision detection for models gameside +// +///////////////////////////////////////////////////////////////////// + +int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) +{ + int returnLod = useLod; + + // if we are overriding the LOD at top level, then we can afford to only check this level of model + if (ghoul2.mLodBias > returnLod) + { + returnLod = ghoul2.mLodBias; + } +// assert(G2_MODEL_OK(&ghoul2)); + + assert(ghoul2.currentModel); + assert(ghoul2.currentModel->mdxm); + //what about r_lodBias? + + // now ensure that we haven't selected a lod that doesn't exist for this model + if ( returnLod >= ghoul2.currentModel->mdxm->numLODs ) + { + returnLod = ghoul2.currentModel->mdxm->numLODs - 1; + } + + return returnLod; +} + +void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, CMiniHeap *G2VertSpace, size_t *TransformedVertsArray,CBoneCache *boneCache) +{ + int j, k; + mdxmVertex_t *v; + float *TransformedVerts; + + // + // deform the vertexes by the lerped bones + // + int *piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); + + // alloc some space for the transformed verts to get put in + TransformedVerts = (float *)G2VertSpace->MiniHeapAlloc(surface->numVerts * 5 * 4); + TransformedVertsArray[surface->thisSurfaceIndex] = (size_t)TransformedVerts; + if (!TransformedVerts) + { + Com_Error(ERR_DROP, "Ran out of transform space for Ghoul2 Models. Adjust MiniHeapSize in SV_SpawnServer.\n"); + } + + // whip through and actually transform each vertex + const int numVerts = surface->numVerts; + v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); + mdxmVertexTexCoord_t *pTexCoords = (mdxmVertexTexCoord_t *) &v[numVerts]; + + // optimisation issue + if ((scale[0] != 1.0) || (scale[1] != 1.0) || (scale[2] != 1.0)) + { + for ( j = 0; j < numVerts; j++ ) + { + vec3_t tempVert, tempNormal; +// mdxmWeight_t *w; + + VectorClear( tempVert ); + VectorClear( tempNormal ); +// w = v->weights; + + const int iNumWeights = G2_GetVertWeights( v ); + + float fTotalWeight = 0.0f; + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( v, k ); + float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + + const mdxaBone_t &bone=EvalBoneCache(piBoneReferences[iBoneIndex],boneCache); + + tempVert[0] += fBoneWeight * ( DotProduct( bone.matrix[0], v->vertCoords ) + bone.matrix[0][3] ); + tempVert[1] += fBoneWeight * ( DotProduct( bone.matrix[1], v->vertCoords ) + bone.matrix[1][3] ); + tempVert[2] += fBoneWeight * ( DotProduct( bone.matrix[2], v->vertCoords ) + bone.matrix[2][3] ); + + tempNormal[0] += fBoneWeight * DotProduct( bone.matrix[0], v->normal ); + tempNormal[1] += fBoneWeight * DotProduct( bone.matrix[1], v->normal ); + tempNormal[2] += fBoneWeight * DotProduct( bone.matrix[2], v->normal ); + } + int pos = j * 5; + + // copy tranformed verts into temp space + TransformedVerts[pos++] = tempVert[0] * scale[0]; + TransformedVerts[pos++] = tempVert[1] * scale[1]; + TransformedVerts[pos++] = tempVert[2] * scale[2]; + // we will need the S & T coors too for hitlocation and hitmaterial stuff + TransformedVerts[pos++] = pTexCoords[j].texCoords[0]; + TransformedVerts[pos] = pTexCoords[j].texCoords[1]; + + v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; + } + } + else + { + int pos = 0; + for ( j = 0; j < numVerts; j++ ) + { + vec3_t tempVert, tempNormal; +// const mdxmWeight_t *w; + + VectorClear( tempVert ); + VectorClear( tempNormal ); +// w = v->weights; + + const int iNumWeights = G2_GetVertWeights( v ); + + float fTotalWeight = 0.0f; + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( v, k ); + float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + + const mdxaBone_t &bone=EvalBoneCache(piBoneReferences[iBoneIndex],boneCache); + + tempVert[0] += fBoneWeight * ( DotProduct( bone.matrix[0], v->vertCoords ) + bone.matrix[0][3] ); + tempVert[1] += fBoneWeight * ( DotProduct( bone.matrix[1], v->vertCoords ) + bone.matrix[1][3] ); + tempVert[2] += fBoneWeight * ( DotProduct( bone.matrix[2], v->vertCoords ) + bone.matrix[2][3] ); + + tempNormal[0] += fBoneWeight * DotProduct( bone.matrix[0], v->normal ); + tempNormal[1] += fBoneWeight * DotProduct( bone.matrix[1], v->normal ); + tempNormal[2] += fBoneWeight * DotProduct( bone.matrix[2], v->normal ); + } + + // copy tranformed verts into temp space + TransformedVerts[pos++] = tempVert[0]; + TransformedVerts[pos++] = tempVert[1]; + TransformedVerts[pos++] = tempVert[2]; + // we will need the S & T coors too for hitlocation and hitmaterial stuff + TransformedVerts[pos++] = pTexCoords[j].texCoords[0]; + TransformedVerts[pos++] = pTexCoords[j].texCoords[1]; + + v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; + } + } +} + +void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, + CBoneCache *boneCache, const model_t *currentModel, int lod, vec3_t scale, CMiniHeap *G2VertSpace, size_t *TransformedVertArray, bool secondTimeAround) +{ + int i; + assert(currentModel); + assert(currentModel->mdxm); + // back track and get the surfinfo struct for this surface + const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + + // see if we have an override surface in the surface list + const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); + + // really, we should use the default flags for this surface unless it's been overriden + int offFlags = surfInfo->flags; + + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + // if this surface is not off, add it to the shader render list + if (!offFlags) + { + + R_TransformEachSurface(surface, scale, G2VertSpace, TransformedVertArray, boneCache); + } + + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren; i++) + { + G2_TransformSurfaces(surfInfo->childIndexes[i], rootSList, boneCache, currentModel, lod, scale, G2VertSpace, TransformedVertArray, secondTimeAround); + } +} + +// main calling point for the model transform for collision detection. At this point all of the skeleton has been transformed. +#ifdef _G2_GORE +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod, bool ApplyGore) +#else +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod) +#endif +{ + int i, lod; + vec3_t correctScale; + qboolean firstModelOnly = qfalse; + + if ( cg_g2MarksAllModels == NULL ) + { + cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0 ); + } + + if (cg_g2MarksAllModels == NULL + || !cg_g2MarksAllModels->integer ) + { + firstModelOnly = qtrue; + } + + + VectorCopy(scale, correctScale); + // check for scales of 0 - that's the default I believe + if (!scale[0]) + { + correctScale[0] = 1.0; + } + if (!scale[1]) + { + correctScale[1] = 1.0; + } + if (!scale[2]) + { + correctScale[2] = 1.0; + } + + // walk each possible model for this entity and try rendering it out + for (i=0; i=g.currentModel->numLods) + { + g.mTransformedVertsArray = 0; + if ( firstModelOnly ) + { + // we don't really need to do multiple models for gore. + return; + } + //do the rest + continue; + } + } + else + { +#endif + lod = G2_DecideTraceLod(g, useLod); +#ifdef _G2_GORE + } +#endif + + // give us space for the transformed vertex array to be put in + if (!(g.mFlags & GHOUL2_ZONETRANSALLOC)) + { //do not stomp if we're using zone space + g.mTransformedVertsArray = (size_t*)G2VertSpace->MiniHeapAlloc(g.currentModel->mdxm->numSurfaces * sizeof (size_t)); + if (!g.mTransformedVertsArray) + { + Com_Error(ERR_DROP, "Ran out of transform space for Ghoul2 Models. Adjust MiniHeapSize in SV_SpawnServer.\n"); + } + } + + memset(g.mTransformedVertsArray, 0,g.currentModel->mdxm->numSurfaces * sizeof (size_t)); + + G2_FindOverrideSurface(-1,g.mSlist); //reset the quick surface override lookup; + // recursively call the model surface transform + + G2_TransformSurfaces(g.mSurfaceRoot, g.mSlist, g.mBoneCache, g.currentModel, lod, correctScale, G2VertSpace, g.mTransformedVertsArray, false); + +#ifdef _G2_GORE + if (ApplyGore && firstModelOnly) + { + // we don't really need to do multiple models for gore. + break; + } +#endif + } +} + + +// work out how much space a triangle takes +static float G2_AreaOfTri(const vec3_t A, const vec3_t B, const vec3_t C) +{ + vec3_t cross, ab, cb; + VectorSubtract(A, B, ab); + VectorSubtract(C, B, cb); + + CrossProduct(ab, cb, cross); + + return VectorLength(cross); +} + +// actually determine the S and T of the coordinate we hit in a given poly +static void G2_BuildHitPointST( const vec3_t A, const float SA, const float TA, + const vec3_t B, const float SB, const float TB, + const vec3_t C, const float SC, const float TC, + const vec3_t P, float *s, float *t,float &bary_i,float &bary_j) +{ + float areaABC = G2_AreaOfTri(A, B, C); + + float i = G2_AreaOfTri(P, B, C) / areaABC; + bary_i=i; + float j = G2_AreaOfTri(A, P, C) / areaABC; + bary_j=j; + float k = G2_AreaOfTri(A, B, P) / areaABC; + + *s = SA * i + SB * j + SC * k; + *t = TA * i + TB * j + TC * k; + + *s=fmod(*s, 1); + if (*s< 0) + { + *s+= 1.0; + } + + *t=fmod(*t, 1); + if (*t< 0) + { + *t+= 1.0; + } + +} + + +// routine that works out given a ray whether or not it hits a poly +qboolean G2_SegmentTriangleTest( const vec3_t start, const vec3_t end, + const vec3_t A, const vec3_t B, const vec3_t C, + qboolean backFaces,qboolean frontFaces,vec3_t returnedPoint,vec3_t returnedNormal, float *denom) +{ + static const float tiny=1E-10f; + vec3_t returnedNormalT; + vec3_t edgeAC; + + VectorSubtract(C, A, edgeAC); + VectorSubtract(B, A, returnedNormalT); + + CrossProduct(returnedNormalT, edgeAC, returnedNormal); + + vec3_t ray; + VectorSubtract(end, start, ray); + + *denom=DotProduct(ray, returnedNormal); + + if (fabs(*denom)0)|| // not accepting back faces + (!frontFaces && *denom<0)) //not accepting front faces + { + return qfalse; + } + + vec3_t toPlane; + VectorSubtract(A, start, toPlane); + + float t=DotProduct(toPlane, returnedNormal)/ *denom; + + if (t<0.0f||t>1.0f) + { + return qfalse; // off segment + } + + VectorScale(ray, t, ray); + + VectorAdd(ray, start, returnedPoint); + + vec3_t edgePA; + VectorSubtract(A, returnedPoint, edgePA); + + vec3_t edgePB; + VectorSubtract(B, returnedPoint, edgePB); + + vec3_t edgePC; + VectorSubtract(C, returnedPoint, edgePC); + + vec3_t temp; + + CrossProduct(edgePA, edgePB, temp); + if (DotProduct(temp, returnedNormal)<0.0f) + { + return qfalse; // off triangle + } + + CrossProduct(edgePC, edgePA, temp); + if (DotProduct(temp,returnedNormal)<0.0f) + { + return qfalse; // off triangle + } + + CrossProduct(edgePB, edgePC, temp); + if (DotProduct(temp, returnedNormal)<0.0f) + { + return qfalse; // off triangle + } + return qtrue; +} + +#ifdef _G2_GORE +struct SVertexTemp +{ + int flags; + int touch; + int newindex; + float tex[2]; + SVertexTemp() + { + touch=0; + } +}; + +#define MAX_GORE_VERTS (3000) +static SVertexTemp GoreVerts[MAX_GORE_VERTS]; +static int GoreIndexCopy[MAX_GORE_VERTS]; +static int GoreTouch=1; + +#define MAX_GORE_INDECIES (6000) +static int GoreIndecies[MAX_GORE_INDECIES]; + +#define GORE_MARGIN (0.0f) +int G2API_GetTime(int argTime); + +// now we at poly level, check each model space transformed poly against the model world transfomed ray +void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSurfHierarchy_t *surfInfo) +{ + int j; + vec3_t basis1; + vec3_t basis2; + vec3_t taxis; + vec3_t saxis; + + basis2[0]=0.0f; + basis2[1]=0.0f; + basis2[2]=1.0f; + + CrossProduct(TS.rayEnd,basis2,basis1); + + if (DotProduct(basis1,basis1)<.1f) + { + basis2[0]=0.0f; + basis2[1]=1.0f; + basis2[2]=0.0f; + CrossProduct(TS.rayEnd,basis2,basis1); + } + + CrossProduct(TS.rayEnd,basis1,basis2); + // Give me a shot direction not a bunch of zeros :) -Gil + assert(DotProduct(basis1,basis1)>.0001f); + assert(DotProduct(basis2,basis2)>.0001f); + + VectorNormalize(basis1); + VectorNormalize(basis2); + + float c=cos(TS.theta); + float s=sin(TS.theta); + + VectorScale(basis1,.5f*c/TS.tsize,taxis); + VectorMA(taxis,.5f*s/TS.tsize,basis2,taxis); + + VectorScale(basis1,-.5f*s/TS.ssize,saxis); + VectorMA(saxis,.5f*c/TS.ssize,basis2,saxis); + + float *verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; + int numVerts = surface->numVerts; + int flags=15; + assert(numVertsGORE_MARGIN) + { + vflags|=1; + } + if (s<1.0f-GORE_MARGIN) + { + vflags|=2; + } + if (t>GORE_MARGIN) + { + vflags|=4; + } + if (t<1.0f-GORE_MARGIN) + { + vflags|=8; + } + vflags=(~vflags); + flags&=vflags; + GoreVerts[j].flags=vflags; + GoreVerts[j].tex[0]=s; + GoreVerts[j].tex[1]=t; + } + if (flags) + { + return; // completely off the gore splotch. + } + int numTris,newNumTris,newNumVerts; + numTris = surface->numTriangles; + mdxmTriangle_t *tris; + tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); + verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; + newNumTris=0; + newNumVerts=0; + GoreTouch++; + if (!TS.gore) + { + return; + } + for ( j = 0; j < numTris; j++ ) + { + assert(tris[j].indexes[0]>=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]=0&&tris[j].indexes[2]frontFaces || !TS.gore->backFaces) + { + // we need to back/front face cull + vec3_t e1,e2,n; + + VectorSubtract(&verts[tris[j].indexes[1]*5],&verts[tris[j].indexes[0]*5],e1); + VectorSubtract(&verts[tris[j].indexes[2]*5],&verts[tris[j].indexes[0]*5],e2); + CrossProduct(e1,e2,n); + if (DotProduct(TS.rayEnd,n)>0.0f) + { + if (!TS.gore->frontFaces) + { + continue; + } + } + else + { + if (!TS.gore->backFaces) + { + continue; + } + } + + } + + int k; + + assert(newNumTris*3+3,int>::iterator f=GoreTagsTemp.find(pair(goreModelIndex,TS.surfaceNum)); + if (f==GoreTagsTemp.end()) // need to generate a record + { + newTag=AllocGoreRecord(); + CGoreSet *goreSet=0; + if (TS.ghoul2info->mGoreSetTag) + { + goreSet=FindGoreSet(TS.ghoul2info->mGoreSetTag); + } + if (!goreSet) + { + goreSet=NewGoreSet(); + TS.ghoul2info->mGoreSetTag=goreSet->mMyGoreSetTag; + } + assert(goreSet); + SGoreSurface add; + add.shader=TS.goreShader; + add.mDeleteTime=0; + if (TS.gore->lifeTime) + { + add.mDeleteTime=G2API_GetTime(0) + TS.gore->lifeTime; + } + add.mFadeTime = TS.gore->fadeOutTime; + add.mFadeRGB = !!(TS.gore->fadeRGB); + add.mGoreTag = newTag; + + add.mGoreGrowStartTime=G2API_GetTime(0); + if( TS.gore->growDuration == -1) + { + add.mGoreGrowEndTime = -1; // set this to -1 to disable growing + } + else + { + add.mGoreGrowEndTime = G2API_GetTime(0) + TS.gore->growDuration; + } + + assert(TS.gore->growDuration != 0); + add.mGoreGrowFactor = ( 1.0f - TS.gore->goreScaleStartFraction) / (float)(TS.gore->growDuration); //curscale = (curtime-mGoreGrowStartTime)*mGoreGrowFactor; + add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; + + goreSet->mGoreRecords.insert(pair(TS.surfaceNum,add)); + GoreTagsTemp[pair(goreModelIndex,TS.surfaceNum)]=newTag; + } + else + { + newTag=(*f).second; + } + GoreTextureCoordinates *gore=FindGoreRecord(newTag); + if (gore) + { + assert(sizeof(float)==sizeof(int)); + // data block format: + unsigned int size= + sizeof(int)+ // num verts + sizeof(int)+ // num tris + sizeof(int)*newNumVerts+ // which verts to copy from original surface + sizeof(float)*4*newNumVerts+ // storgage for deformed verts + sizeof(float)*4*newNumVerts+ // storgage for deformed normal + sizeof(float)*2*newNumVerts+ // texture coordinates + sizeof(int)*newNumTris*3; // new indecies + + int *data=(int *)Z_Malloc ( sizeof(int)*size, TAG_GHOUL2_GORE, qtrue ); + + + if ( gore->tex[TS.lod] ) + { + Z_Free(gore->tex[TS.lod]); + } + + gore->tex[TS.lod]=(float *)data; + *data++=newNumVerts; + *data++=newNumTris; + + memcpy(data,GoreIndexCopy,sizeof(int)*newNumVerts); + data+=newNumVerts*9; // skip verts and normals + float *fdata=(float *)data; + + for (j=0;jtex[TS.lod])*sizeof(int)==size); + fdata = (float *)data; + // build the entity to gore matrix + VectorCopy(saxis,fdata+0); + VectorCopy(taxis,fdata+4); + VectorCopy(TS.rayEnd,fdata+8); + VectorNormalize(fdata+0); + VectorNormalize(fdata+4); + VectorNormalize(fdata+8); + fdata[3]=-0.5f; // subtract texture center + fdata[7]=-0.5f; + fdata[11]=0.0f; + vec3_t shotOriginInCurrentSpace; // unknown space + TransformPoint(TS.rayStart,shotOriginInCurrentSpace,(mdxaBone_t *)fdata); // dest middle arg + // this will insure the shot origin in our unknown space is now the shot origin, making it a known space + fdata[3]-=shotOriginInCurrentSpace[0]; + fdata[7]-=shotOriginInCurrentSpace[1]; + fdata[11]-=shotOriginInCurrentSpace[2]; + Inverse_Matrix((mdxaBone_t *)fdata,(mdxaBone_t *)(fdata+12)); // dest 2nd arg + data+=24; + +// assert((data - (int *)gore->tex[TS.lod]) * sizeof(int) == size); + } +} +#else +struct SVertexTemp +{ + int flags; +// int touch; +// int newindex; +// float tex[2]; + SVertexTemp() + { +// touch=0; + } +}; + +#define MAX_GORE_VERTS (3000) +static SVertexTemp GoreVerts[MAX_GORE_VERTS]; +#endif + +// now we're at poly level, check each model space transformed poly against the model world transfomed ray +static bool G2_TracePolys(const mdxmSurface_t *surface, const mdxmSurfHierarchy_t *surfInfo, CTraceSurface &TS) +{ + int j, numTris; + + // whip through and actually transform each vertex + const mdxmTriangle_t *tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); + const float *verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; + numTris = surface->numTriangles; + for ( j = 0; j < numTris; j++ ) + { + float face; + vec3_t hitPoint, normal; + // determine actual coords for this triangle + const float *point1 = &verts[(tris[j].indexes[0] * 5)]; + const float *point2 = &verts[(tris[j].indexes[1] * 5)]; + const float *point3 = &verts[(tris[j].indexes[2] * 5)]; + // did we hit it? + int i; + if (G2_SegmentTriangleTest(TS.rayStart, TS.rayEnd, point1, point2, point3, qtrue, qtrue, hitPoint, normal, &face)) + { // find space in the collision records for this record + for (i=0; ithisSurfaceIndex; + newCol.mModelIndex = TS.modelIndex; + if (face>0) + { + newCol.mFlags = G2_FRONTFACE; + } + else + { + newCol.mFlags = G2_BACKFACE; + } + + VectorSubtract(hitPoint, TS.rayStart, distVect); + newCol.mDistance = VectorLength(distVect); + + // put the hit point back into world space + TransformAndTranslatePoint(hitPoint, newCol.mCollisionPosition, &worldMatrix); + + // transform normal (but don't translate) into world angles + TransformPoint(normal, newCol.mCollisionNormal, &worldMatrix); + VectorNormalize(newCol.mCollisionNormal); + + newCol.mMaterial = newCol.mLocation = 0; + + // Determine our location within the texture, and barycentric coordinates + G2_BuildHitPointST(point1, point1[3], point1[4], + point2, point2[3], point2[4], + point3, point3[3], point3[4], + hitPoint, &x_pos, &y_pos,newCol.mBarycentricI,newCol.mBarycentricJ); + +/* + const shader_t *shader = 0; + // now, we know what surface this hit belongs to, we need to go get the shader handle so we can get the correct hit location and hit material info + if ( cust_shader ) + { + shader = cust_shader; + } + else if ( skin ) + { + int j; + + // match the surface name to something in the skin file + shader = tr.defaultShader; + for ( j = 0 ; j < skin->numSurfaces ; j++ ) + { + // the names have both been lowercased + if ( !strcmp( skin->surfaces[j]->name, surfInfo->name ) ) + { + shader = skin->surfaces[j]->shader; + break; + } + } + } + else + { + shader = R_GetShaderByHandle( surfInfo->shaderIndex ); + } + + // do we even care to decide what the hit or location area's are? If we don't have them in the shader there is little point + if ((shader->hitLocation) || (shader->hitMaterial)) + { + // ok, we have a floating point position. - determine location in data we need to look at + if (shader->hitLocation) + { + newCol.mLocation = *(hitMatReg[shader->hitLocation].loc + + ((int)(y_pos * hitMatReg[shader->hitLocation].height) * hitMatReg[shader->hitLocation].width) + + ((int)(x_pos * hitMatReg[shader->hitLocation].width))); + Com_Printf("G2_TracePolys hit location: %d\n", newCol.mLocation); + } + + if (shader->hitMaterial) + { + newCol.mMaterial = *(hitMatReg[shader->hitMaterial].loc + + ((int)(y_pos * hitMatReg[shader->hitMaterial].height) * hitMatReg[shader->hitMaterial].width) + + ((int)(x_pos * hitMatReg[shader->hitMaterial].width))); + } + } +*/ + // exit now if we should + if (TS.traceFlags == G2_RETURNONHIT) + { + TS.hitOne = true; + return true; + } + + break; + } + } + if (i==MAX_G2_COLLISIONS) + { + //assert(i!=MAX_G2_COLLISIONS); // run out of collision record space - will probalbly never happen + //It happens. And the assert is bugging me. + TS.hitOne = true; //force stop recursion + return true; // return true to avoid wasting further time, but no hit will result without a record + } + } + } + return false; +} + +// now we're at poly level, check each model space transformed poly against the model world transfomed ray +static bool G2_RadiusTracePolys( + const mdxmSurface_t *surface, + CTraceSurface &TS + ) +{ + int j; + vec3_t basis1; + vec3_t basis2; + vec3_t taxis; + vec3_t saxis; + + basis2[0]=0.0f; + basis2[1]=0.0f; + basis2[2]=1.0f; + + vec3_t v3RayDir; + VectorSubtract(TS.rayEnd, TS.rayStart, v3RayDir); + + CrossProduct(v3RayDir,basis2,basis1); + + if (DotProduct(basis1,basis1)<.1f) + { + basis2[0]=0.0f; + basis2[1]=1.0f; + basis2[2]=0.0f; + CrossProduct(v3RayDir,basis2,basis1); + } + + CrossProduct(v3RayDir,basis1,basis2); + // Give me a shot direction not a bunch of zeros :) -Gil +// assert(DotProduct(basis1,basis1)>.0001f); +// assert(DotProduct(basis2,basis2)>.0001f); + + VectorNormalize(basis1); + VectorNormalize(basis2); + + const float c=cos(0.0f);//theta + const float s=sin(0.0f);//theta + + VectorScale(basis1, 0.5f * c / TS.m_fRadius,taxis); + VectorMA(taxis, 0.5f * s / TS.m_fRadius,basis2,taxis); + + VectorScale(basis1,-0.5f * s /TS.m_fRadius,saxis); + VectorMA( saxis, 0.5f * c /TS.m_fRadius,basis2,saxis); + + const float * const verts = (float *)TS.TransformedVertsArray[surface->thisSurfaceIndex]; + const int numVerts = surface->numVerts; + + int flags=63; + //rayDir/=lengthSquared(raydir); + const float f = VectorLengthSquared(v3RayDir); + v3RayDir[0]/=f; + v3RayDir[1]/=f; + v3RayDir[2]/=f; + + for ( j = 0; j < numVerts; j++ ) + { + const int pos=j*5; + vec3_t delta; + delta[0]=verts[pos+0]-TS.rayStart[0]; + delta[1]=verts[pos+1]-TS.rayStart[1]; + delta[2]=verts[pos+2]-TS.rayStart[2]; + const float s=DotProduct(delta,saxis)+0.5f; + const float t=DotProduct(delta,taxis)+0.5f; + const float u=DotProduct(delta,v3RayDir); + int vflags=0; + + if (s>0) + { + vflags|=1; + } + if (s<1) + { + vflags|=2; + } + if (t>0) + { + vflags|=4; + } + if (t<1) + { + vflags|=8; + } + if (u>0) + { + vflags|=16; + } + if (u<1) + { + vflags|=32; + } + + vflags=(~vflags); + flags&=vflags; + GoreVerts[j].flags=vflags; + } + + if (flags) + { + return false; // completely off the gore splotch (so presumably hit nothing? -Ste) + } + const int numTris = surface->numTriangles; + const mdxmTriangle_t * const tris = (mdxmTriangle_t *) ((byte *)surface + surface->ofsTriangles); + + for ( j = 0; j < numTris; j++ ) + { + assert(tris[j].indexes[0]>=0&&tris[j].indexes[0]=0&&tris[j].indexes[1]=0&&tris[j].indexes[2]thisSurfaceIndex; + newCol.mModelIndex = TS.modelIndex; +// if (face>0) +// { + newCol.mFlags = G2_FRONTFACE; +// } +// else +// { +// newCol.mFlags = G2_BACKFACE; +// } + + //get normal from triangle + const float *A = &verts[(tris[j].indexes[0] * 5)]; + const float *B = &verts[(tris[j].indexes[1] * 5)]; + const float *C = &verts[(tris[j].indexes[2] * 5)]; + vec3_t normal; + vec3_t edgeAC, edgeBA; + + VectorSubtract(C, A, edgeAC); + VectorSubtract(B, A, edgeBA); + CrossProduct(edgeBA, edgeAC, normal); + + // transform normal (but don't translate) into world angles + TransformPoint(normal, newCol.mCollisionNormal, &worldMatrix); + VectorNormalize(newCol.mCollisionNormal); + + newCol.mMaterial = newCol.mLocation = 0; + // exit now if we should + if (TS.traceFlags == G2_RETURNONHIT) + { + TS.hitOne = true; + return true; + } + + + vec3_t distVect; +#if 0 + //i don't know the hitPoint, but let's just assume it's the first vert for now... + float *hitPoint = (float *)A; +#else + //yeah, I want the collision point. Let's work out the impact point on the triangle. -rww + vec3_t hitPoint; + float side, side2; + float dist; + float third = -(A[0]*(B[1]*C[2] - C[1]*B[2]) + B[0]*(C[1]*A[2] - A[1]*C[2]) + C[0]*(A[1]*B[2] - B[1]*A[2]) ); + + VectorSubtract(TS.rayEnd, TS.rayStart, distVect); + side = normal[0]*TS.rayStart[0] + normal[1]*TS.rayStart[1] + normal[2]*TS.rayStart[2] + third; + side2 = normal[0]*distVect[0] + normal[1]*distVect[1] + normal[2]*distVect[2]; + dist = side/side2; + VectorMA(TS.rayStart, -dist, distVect, hitPoint); +#endif + + VectorSubtract(hitPoint, TS.rayStart, distVect); + newCol.mDistance = VectorLength(distVect); + + // put the hit point back into world space + TransformAndTranslatePoint(hitPoint, newCol.mCollisionPosition, &worldMatrix); + newCol.mBarycentricI = newCol.mBarycentricJ = 0.0f; + break; + } + } + if (i==MAX_G2_COLLISIONS) + { + //assert(i!=MAX_G2_COLLISIONS); // run out of collision record space - happens OFTEN + TS.hitOne = true; //force stop recursion + return true; // return true to avoid wasting further time, but no hit will result without a record + } + } + } + + return false; +} + + +// look at a surface and then do the trace on each poly +static void G2_TraceSurfaces(CTraceSurface &TS) +{ + int i; + // back track and get the surfinfo struct for this surface + assert(TS.currentModel); + assert(TS.currentModel->mdxm); + const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(TS.currentModel, TS.surfaceNum, TS.lod); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + + // see if we have an override surface in the surface list + const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(TS.surfaceNum, TS.rootSList); + + // don't allow recursion if we've already hit a polygon + if (TS.hitOne) + { + return; + } + + // really, we should use the default flags for this surface unless it's been overriden + int offFlags = surfInfo->flags; + + // set the off flags if we have some + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + + // if this surface is not off, try to hit it + if (!offFlags) + { +#ifdef _G2_GORE + if (TS.collRecMap) + { +#endif + if (!(fabs(TS.m_fRadius) < 0.1)) // if not a point-trace + { + // .. then use radius check + // + if (G2_RadiusTracePolys(surface, // const mdxmSurface_t *surface, + TS + ) + && (TS.traceFlags == G2_RETURNONHIT) + ) + { + TS.hitOne = true; + return; + } + } + else + { + // go away and trace the polys in this surface + if (G2_TracePolys(surface, surfInfo, TS) + && (TS.traceFlags == G2_RETURNONHIT) + ) + { + // ok, we hit one, *and* we want to return instantly because the returnOnHit is set + // so indicate we've hit one, so other surfaces don't get hit and return + TS.hitOne = true; + return; + } + } +#ifdef _G2_GORE + } + else + { + G2_GorePolys(surface, TS, surfInfo); + } +#endif + } + + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren && !TS.hitOne; i++) + { + TS.surfaceNum = surfInfo->childIndexes[i]; + G2_TraceSurfaces(TS); + } +} + +#ifdef _G2_GORE +void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CollisionRecord_t *collRecMap, int entNum, int eG2TraceType, int useLod, float fRadius, float ssize,float tsize,float theta,int shader, SSkinGoreData *gore, qboolean skipIfLODNotMatch) +#else +void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, CollisionRecord_t *collRecMap, int entNum, int eG2TraceType, int useLod, float fRadius) +#endif +{ + int i, lod; + skin_t *skin; + shader_t *cust_shader; + qboolean firstModelOnly = qfalse; + + if ( cg_g2MarksAllModels == NULL ) + { + cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0 ); + } + + if (cg_g2MarksAllModels == NULL + || !cg_g2MarksAllModels->integer ) + { + firstModelOnly = qtrue; + } + + // walk each possible model for this entity and try tracing against it + for (i=0; i 0 && ghoul2[i].mSkin < tr.numSkins ) + { + skin = R_GetSkinByHandle( ghoul2[i].mSkin ); + } + else + { + skin = NULL; + } + + lod = G2_DecideTraceLod(ghoul2[i],useLod); + if ( skipIfLODNotMatch ) + {//we only want to hit this SPECIFIC LOD... + if ( lod != useLod ) + {//doesn't match, skip this model + continue; + } + } + + //reset the quick surface override lookup + G2_FindOverrideSurface(-1, ghoul2[i].mSlist); + +#ifdef _G2_GORE + CTraceSurface TS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, (model_t *)ghoul2[i].currentModel, lod, rayStart, rayEnd, collRecMap, entNum, i, skin, cust_shader, ghoul2[i].mTransformedVertsArray, eG2TraceType, fRadius, ssize, tsize, theta, shader, &ghoul2[i], gore); +#else + CTraceSurface TS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, (model_t *)ghoul2[i].currentModel, lod, rayStart, rayEnd, collRecMap, entNum, i, skin, cust_shader, ghoul2[i].mTransformedVertsArray, eG2TraceType, fRadius); +#endif + // start the surface recursion loop + G2_TraceSurfaces(TS); + + // if we've hit one surface on one model, don't bother doing the rest + if (TS.hitOne) + { + break; + } +#ifdef _G2_GORE + if (!collRecMap&&firstModelOnly) + { + // we don't really need to do multiple models for gore. + break; + } +#endif + } +} + +void TransformPoint (const vec3_t in, vec3_t out, mdxaBone_t *mat) { + for (int i=0;i<3;i++) + { + out[i]= in[0]*mat->matrix[i][0] + in[1]*mat->matrix[i][1] + in[2]*mat->matrix[i][2]; + } +} + +void TransformAndTranslatePoint (const vec3_t in, vec3_t out, mdxaBone_t *mat) { + + for (int i=0;i<3;i++) + { + out[i]= in[0]*mat->matrix[i][0] + in[1]*mat->matrix[i][1] + in[2]*mat->matrix[i][2] + mat->matrix[i][3]; + } +} + + +// create a matrix using a set of angles +void Create_Matrix(const float *angle, mdxaBone_t *matrix) +{ + vec3_t axis[3]; + + // convert angles to axis + AnglesToAxis( angle, axis ); + matrix->matrix[0][0] = axis[0][0]; + matrix->matrix[1][0] = axis[0][1]; + matrix->matrix[2][0] = axis[0][2]; + + matrix->matrix[0][1] = axis[1][0]; + matrix->matrix[1][1] = axis[1][1]; + matrix->matrix[2][1] = axis[1][2]; + + matrix->matrix[0][2] = axis[2][0]; + matrix->matrix[1][2] = axis[2][1]; + matrix->matrix[2][2] = axis[2][2]; + + matrix->matrix[0][3] = 0; + matrix->matrix[1][3] = 0; + matrix->matrix[2][3] = 0; + + +} + +// given a matrix, generate the inverse of that matrix +void Inverse_Matrix(mdxaBone_t *src, mdxaBone_t *dest) +{ + int i, j; + + for (i = 0; i < 3; i++) + { + for (j = 0; j < 3; j++) + { + dest->matrix[i][j]=src->matrix[j][i]; + } + } + for (i = 0; i < 3; i++) + { + dest->matrix[i][3]=0; + for (j = 0; j < 3; j++) + { + dest->matrix[i][3]-=dest->matrix[i][j]*src->matrix[j][3]; + } + } +} + +// generate the world matrix for a given set of angles and origin - called from lots of places +void G2_GenerateWorldMatrix(const vec3_t angles, const vec3_t origin) +{ + Create_Matrix(angles, &worldMatrix); + worldMatrix.matrix[0][3] = origin[0]; + worldMatrix.matrix[1][3] = origin[1]; + worldMatrix.matrix[2][3] = origin[2]; + + Inverse_Matrix(&worldMatrix, &worldMatrixInv); +} + +// go away and determine what the pointer for a specific surface definition within the model definition is +void *G2_FindSurface(void *mod_t, int index, int lod) +{ + // damn include file dependancies + model_t *mod = (model_t *)mod_t; + + // point at first lod list + byte *current = (byte*)((size_t)mod->mdxm + (size_t)mod->mdxm->ofsLODs); + int i; + + //walk the lods + for (i=0; iofsEnd; + } + + // avoid the lod pointer data structure + current += sizeof(mdxmLOD_t); + + mdxmLODSurfOffset_t *indexes = (mdxmLODSurfOffset_t *)current; + // we are now looking at the offset array + current += indexes->offsets[index]; + + return (void *)current; +} + +#define SURFACE_SAVE_BLOCK_SIZE sizeof(surfaceInfo_t) +#define BOLT_SAVE_BLOCK_SIZE (sizeof(boltInfo_t) - sizeof(mdxaBone_t)) +#define BONE_SAVE_BLOCK_SIZE sizeof(boneInfo_t) + +qboolean G2_SaveGhoul2Models(CGhoul2Info_v &ghoul2, char **buffer, int *size) +{ + + // is there anything to save? + if (!ghoul2.size()) + { + *buffer = (char *)Z_Malloc(4, TAG_GHOUL2, qtrue); + int *tempBuffer = (int *)*buffer; + *tempBuffer = 0; + *size = 4; + return qtrue; + } + + // yeah, lets get busy + *size = 0; + + // this one isn't a define since I couldn't work out how to figure it out at compile time + int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + + // add in count for number of ghoul2 models + *size += 4; + // start out working out the total size of the buffer we need to allocate + int i; // Linux GCC is forcing new scoping rules + for (i=0; iSV_GetConfigstring( start + i, s, sizeof( s ) ); + if ( !s[0] ) + { + break; + } + if ( !Q_stricmp( s, name ) ) + { + return i; + } + } + + ri->SV_SetConfigstring(start + i, name); + return i; +} + +qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); +qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); + +void G2_LoadGhoul2Model(CGhoul2Info_v &ghoul2, char *buffer) +{ + // first thing, lets see how many ghoul2 models we have, and resize our buffers accordingly + int newSize = *(int*)buffer; + ghoul2.resize(newSize); + buffer += 4; + + // did we actually resize to a value? + if (!newSize) + { + // no, ok, well, done then. + return; + } + + // this one isn't a define since I couldn't work out how to figure it out at compile time + int ghoul2BlockSize = (size_t)&ghoul2[0].mTransformedVertsArray - (size_t)&ghoul2[0].mModelindex; + + // now we have enough instances, lets go through each one and load up the relevant details + for (int i=0; i i) && + (nextGhoul2[i].mModelindex != -1) && + (nextGhoul2[i].mBlist.size() > x) && + (nextGhoul2[i].mBlist[x].boneNumber != -1)) + { + boneInfo_t &nextBone = nextGhoul2[i].mBlist[x]; + // does this bone override actually have anything in it, and if it does, is it a bone angles override? + if ((bone.boneNumber != -1) && ((bone.flags) & (BONE_ANGLES_TOTAL))) + { + float *nowMatrix = (float*) &bone.matrix; + float *nextMatrix = (float*) &nextBone.matrix; + float *newMatrix = (float*) &bone.newMatrix; + // now interpolate the matrix + for (int z=0; z < 12; z++) + { + newMatrix[z] = nowMatrix[z] + interpolation * ( nextMatrix[z] - nowMatrix[z] ); + } + } + } + else + { + memcpy(&ghoul2[i].mBlist[x].newMatrix, &ghoul2[i].mBlist[x].matrix, sizeof(mdxaBone_t)); + } + } + } + } +} + +//Raz: Chucking this in here from ghoul2_shared +IGhoul2InfoArray &TheGhoul2InfoArray(); +IGhoul2InfoArray &_TheGhoul2InfoArray( void ) { + return TheGhoul2InfoArray(); +} diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp new file mode 100644 index 0000000000..155216df36 --- /dev/null +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -0,0 +1,663 @@ +#include "rd-common/tr_types.h" +#include "ghoul2/G2.h" +#include "G2_local.h" +#ifdef _MSC_VER +#pragma warning(disable : 4512) //assignment op could not be genereated +#endif + +class CConstructBoneList +{ +public: + int surfaceNum; + int *boneUsedList; + surfaceInfo_v &rootSList; + model_t *currentModel; + boneInfo_v &boneList; + + CConstructBoneList( + int initsurfaceNum, + int *initboneUsedList, + surfaceInfo_v &initrootSList, + model_t *initcurrentModel, + boneInfo_v &initboneList): + + surfaceNum(initsurfaceNum), + boneUsedList(initboneUsedList), + rootSList(initrootSList), + currentModel(initcurrentModel), + boneList(initboneList) { } +}; + +extern void G2_ConstructUsedBoneList(CConstructBoneList &CBL); + + +//===================================================================================================================== +// Surface List handling routines - so entities can determine what surfaces attached to a model are operational or not. + +// find a particular surface in the surface override list +surfaceInfo_t *G2_FindOverrideSurface(int surfaceNum, surfaceInfo_v &surfaceList) +{ + // look through entire list + for(size_t i=0; imdxm + mod_m->mdxm->ofsSurfHierarchy ); + + for ( int i = 0 ; i < mod_m->mdxm->numSurfaces ; i++) + { + if (!Q_stricmp(surfaceName, surf->name)) + { + *flags = surf->flags; + return i; + } + // find the next surface + surf = (mdxmSurfHierarchy_t *)( (byte *)surf + (size_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surf->numChildren ] )); + } + return -1; +} + + +/************************************************************************************************ + * G2_FindSurface + * find a surface in a ghoul2 surface override list based on it's name + * + * Input + * filename of model, surface list of model instance, name of surface, int to be filled in + * with the index of this surface (defaults to NULL) + * + * Output + * pointer to surface if successful, false otherwise + * + ************************************************************************************************/ +mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName, + int *surfIndex/*NULL*/) +{ + int i = 0; + // find the model we want + model_t *mod = (model_t *)ghlInfo->currentModel; + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo; + + // did we find a ghoul 2 model or not? + if (!mod->mdxm) + { + assert(0); + if (surfIndex) + { + *surfIndex = -1; + } + return 0; + } + + // first find if we already have this surface in the list + for (i = slist.size() - 1; i >= 0; i--) + { + if ((slist[i].surface != 10000) && (slist[i].surface != -1)) + { + mdxmSurface_t *surf = (mdxmSurface_t *)G2_FindSurface((void *)mod, slist[i].surface, 0); + // back track and get the surfinfo struct for this surface + surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]); + + // are these the droids we're looking for? + if (!Q_stricmp (surfInfo->name, surfaceName)) + { + // yup + if (surfIndex) + { + *surfIndex = i; + } + return surf; + } + } + } + // didn't find it + if (surfIndex) + { + *surfIndex = -1; + } + return 0; +} + +// set a named surface offFlags - if it doesn't find a surface with this name in the list then it will add one. +qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName, const int offFlags) +{ + int surfIndex = -1; + surfaceInfo_t temp_slist_entry; + mdxmSurface_t *surf; + // find the model we want + model_t *mod = (model_t *)ghlInfo->currentModel; + + // did we find a ghoul 2 model or not? + if (!mod->mdxm) + { + assert(0); + return qfalse; + } + + // first find if we already have this surface in the list + surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); + if (surf) + { + // set descendants value + + // slist[surfIndex].offFlags = offFlags; + // seems to me that we shouldn't overwrite the other flags. + // the only bit we really care about in the incoming flags is the off bit + slist[surfIndex].offFlags &= ~(G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS); + slist[surfIndex].offFlags |= offFlags & (G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS); + return qtrue; + } + else + { + // ok, not in the list already - in that case, lets verify this surface exists in the model mesh + int flags; + int surfaceNum = G2_IsSurfaceLegal((void*)mod, surfaceName, &flags); + if (surfaceNum != -1) + { + int newflags = flags; + // the only bit we really care about in the incoming flags is the off bit + newflags &= ~(G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS); + newflags |= offFlags & (G2SURFACEFLAG_OFF | G2SURFACEFLAG_NODESCENDANTS); + + if (newflags != flags) + { // insert here then because it changed, no need to add an override otherwise + temp_slist_entry.offFlags = newflags; + temp_slist_entry.surface = surfaceNum; + + slist.push_back(temp_slist_entry); + } + return qtrue; + } + } + return qfalse; +} + +void G2_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin) +{ + int j; + const skin_t *skin = R_GetSkinByHandle( renderSkin ); + + ghlInfo->mSlist.clear(); //remove any overrides we had before. + ghlInfo->mMeshFrameNum = 0; + + for ( j = 0 ; j < skin->numSurfaces ; j++ ) + { + // the names have both been lowercased + //Raz: why is this using the shader name and not the surface name? + if ( !strcmp( ((shader_t *)skin->surfaces[j]->shader)->name, "*off") ) { + G2_SetSurfaceOnOff(ghlInfo, ghlInfo->mSlist, skin->surfaces[j]->name, G2SURFACEFLAG_OFF); + } + else + { + int flags; + int surfaceNum = G2_IsSurfaceLegal((void *)ghlInfo->currentModel, skin->surfaces[j]->name, &flags); + if ( (surfaceNum != -1) && (!(flags&G2SURFACEFLAG_OFF)) ) //only turn on if it's not an "_off" surface + { + G2_SetSurfaceOnOff(ghlInfo, ghlInfo->mSlist, skin->surfaces[j]->name, 0); + } + } + } +} + +// return a named surfaces off flags - should tell you if this surface is on or off. +int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *surfaceName) +{ + model_t *mod = (model_t *)ghlInfo->currentModel; + int surfIndex = -1; + mdxmSurface_t *surf = 0; + + // did we find a ghoul 2 model or not? + if (!mod->mdxm) + { + return 0; + } + + // first find if we already have this surface in the list + surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); + if (surf) + { + // set descendants value + return slist[surfIndex].offFlags; + } + // ok, we didn't find it in the surface list. Lets look at the original surface then. + + mdxmSurfHierarchy_t *surface = (mdxmSurfHierarchy_t *) ( (byte *)mod->mdxm + mod->mdxm->ofsSurfHierarchy ); + + for ( int i = 0 ; i < mod->mdxm->numSurfaces ; i++) + { + if (!Q_stricmp(surfaceName, surface->name)) + { + return surface->flags; + } + // find the next surface + surface = (mdxmSurfHierarchy_t *)( (byte *)surface + (intptr_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surface->numChildren ] )); + } + + assert(0); + return 0; +} + +void G2_FindRecursiveSurface(model_t *currentModel, int surfaceNum, surfaceInfo_v &rootList, int *activeSurfaces) +{ + int i; + mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + + // see if we have an override surface in the surface list + surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootList); + + // really, we should use the default flags for this surface unless it's been overriden + int offFlags = surfInfo->flags; + + // set the off flags if we have some + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + + // if this surface is not off, indicate as such in the active surface list + if (!(offFlags & G2SURFACEFLAG_OFF)) + { + activeSurfaces[surfaceNum] = 1; + } + else + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren; i++) + { + surfaceNum = surfInfo->childIndexes[i]; + G2_FindRecursiveSurface(currentModel, surfaceNum, rootList, activeSurfaces); + } + +} + +void G2_RemoveRedundantGeneratedSurfaces(surfaceInfo_v &slist, int *activeSurfaces) +{ + // walk the surface list, removing surface overrides or generated surfaces that are pointing at surfaces that aren't active anymore + for (size_t i=0; imdxm) + { + return qfalse; + } + + // first find if we already have this surface in the list + surf = G2_IsSurfaceLegal(mod_m, surfaceName, &flags); + if (surf != -1) + { + // first see if this ghoul2 model already has this as a root surface + if (ghoul2[modelIndex].mSurfaceRoot == surf) + { + return qtrue; + } + + // set the root surface + ghoul2[modelIndex].mSurfaceRoot = surf; + + // ok, now the tricky bits. + // firstly, generate a list of active / on surfaces below the root point + + // gimme some space to put this list into + activeSurfaces = (int *)Z_Malloc(mod_m->mdxm->numSurfaces * 4, TAG_GHOUL2, qtrue); + memset(activeSurfaces, 0, (mod_m->mdxm->numSurfaces * 4)); + activeBones = (int *)Z_Malloc(mod_a->mdxa->numBones * 4, TAG_GHOUL2, qtrue); + memset(activeBones, 0, (mod_a->mdxa->numBones * 4)); + + G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); + + // now generate the used bone list + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + activeBones, + ghoul2[modelIndex].mSlist, + mod_m, + ghoul2[modelIndex].mBlist); + + G2_ConstructUsedBoneList(CBL); + + // now remove all procedural or override surfaces that refer to surfaces that arent on this list + G2_RemoveRedundantGeneratedSurfaces(ghoul2[modelIndex].mSlist, activeSurfaces); + + // now remove all bones that are pointing at bones that aren't active + G2_RemoveRedundantBoneOverrides(ghoul2[modelIndex].mBlist, activeBones); + + // then remove all bolts that point at surfaces or bones that *arent* active. + G2_RemoveRedundantBolts(ghoul2[modelIndex].mBltlist, ghoul2[modelIndex].mSlist, activeSurfaces, activeBones); + + // then remove all models on this ghoul2 instance that use those bolts that are being removed. + for (int i=0; i> MODEL_SHIFT) & MODEL_AND; + int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + // if either the bolt list is too small, or the bolt we are pointing at references nothing, remove this model + if (((int)ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && + (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) + { + CGhoul2Info_v *g2i = &ghoul2; + G2API_RemoveGhoul2Model((CGhoul2Info_v **)&g2i, i); + } + } + } + //No support for this, for now. + + // remember to free what we used + Z_Free(activeSurfaces); + Z_Free(activeBones); + + return (qtrue); + } +/* +//g2r if (entstate->ghoul2) + { + CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)entstate->ghoul2); + model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); + model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + int surf; + int flags; + int *activeSurfaces, *activeBones; + + // did we find a ghoul 2 model or not? + if (!mod_m->mdxm) + { + return qfalse; + } + + // first find if we already have this surface in the list + surf = G2_IsSurfaceLegal(mod_m, surfaceName, &flags); + if (surf != -1) + { + // first see if this ghoul2 model already has this as a root surface + if (ghoul2[modelIndex].mSurfaceRoot == surf) + { + return qtrue; + } + + // set the root surface + ghoul2[modelIndex].mSurfaceRoot = surf; + + // ok, now the tricky bits. + // firstly, generate a list of active / on surfaces below the root point + + // gimme some space to put this list into + activeSurfaces = (int *)Z_Malloc(mod_m->mdxm->numSurfaces * 4, TAG_GHOUL2, qtrue); + memset(activeSurfaces, 0, (mod_m->mdxm->numSurfaces * 4)); + activeBones = (int *)Z_Malloc(mod_a->mdxa->numBones * 4, TAG_GHOUL2, qtrue); + memset(activeBones, 0, (mod_a->mdxa->numBones * 4)); + + G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); + + // now generate the used bone list + CConstructBoneList CBL(ghoul2[modelIndex].mSurfaceRoot, + activeBones, + ghoul2[modelIndex].mSlist, + mod_m, + ghoul2[modelIndex].mBlist); + + G2_ConstructUsedBoneList(CBL); + + // now remove all procedural or override surfaces that refer to surfaces that arent on this list + G2_RemoveRedundantGeneratedSurfaces(ghoul2[modelIndex].mSlist, activeSurfaces); + + // now remove all bones that are pointing at bones that aren't active + G2_RemoveRedundantBoneOverrides(ghoul2[modelIndex].mBlist, activeBones); + + // then remove all bolts that point at surfaces or bones that *arent* active. + G2_RemoveRedundantBolts(ghoul2[modelIndex].mBltlist, ghoul2[modelIndex].mSlist, activeSurfaces, activeBones); + + // then remove all models on this ghoul2 instance that use those bolts that are being removed. + for (int i=0; i> MODEL_SHIFT) & MODEL_AND; + int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + // if either the bolt list is too small, or the bolt we are pointing at references nothing, remove this model + if ((ghoul2[boltMod].mBltlist.size() <= boltNum) || + ((ghoul2[boltMod].mBltlist[boltNum].boneNumber == -1) && + (ghoul2[boltMod].mBltlist[boltNum].surfaceNumber == -1))) + { + G2API_RemoveGhoul2Model(entstate, i); + } + } + } + + // remember to free what we used + Z_Free(activeSurfaces); + Z_Free(activeBones); + + return (qtrue); + } + } + assert(0);*/ + return qfalse; +} + + +extern int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod); +int G2_AddSurface(CGhoul2Info *ghoul2, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod ) +{ + + surfaceInfo_t temp_slist_entry; + + // decide if LOD is legal + lod = G2_DecideTraceLod(*(CGhoul2Info *)(ghoul2), lod); + + // first up, see if we have a free one already set up - look only from the end of the constant surfaces onwards + for (size_t i=0; imSlist.size(); i++) + { + // is the surface count -1? That would indicate it's free + if (ghoul2->mSlist[i].surface == -1) + { + ghoul2->mSlist[i].offFlags = G2SURFACEFLAG_GENERATED; + ghoul2->mSlist[i].surface = 10000; // no model will ever have 10000 surfaces + ghoul2->mSlist[i].genBarycentricI = BarycentricI; + ghoul2->mSlist[i].genBarycentricJ = BarycentricJ; + ghoul2->mSlist[i].genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff); + ghoul2->mSlist[i].genLod = lod; + return i; + } + } + + // ok, didn't find one. Better create one + + temp_slist_entry.offFlags = G2SURFACEFLAG_GENERATED; + temp_slist_entry.surface = 10000; + temp_slist_entry.genBarycentricI = BarycentricI; + temp_slist_entry.genBarycentricJ = BarycentricJ; + temp_slist_entry.genPolySurfaceIndex = ((polyNumber & 0xffff) << 16) | (surfaceNumber & 0xffff); + temp_slist_entry.genLod = lod; + + ghoul2->mSlist.push_back(temp_slist_entry); + + return (ghoul2->mSlist.size() -1 ); +} + +qboolean G2_RemoveSurface(surfaceInfo_v &slist, const int index) +{ + // did we find it? + if (index != -1) + { + // set us to be the 'not active' state + slist[index].surface = -1; + + unsigned int newSize = slist.size(); + // now look through the list from the back and see if there is a block of -1's we can resize off the end of the list + for (int i=slist.size()-1; i>-1; i--) + { + if (slist[i].surface == -1) + { + newSize = i; + } + // once we hit one that isn't a -1, we are done. + else + { + break; + } + } + // do we need to resize? + if (newSize != slist.size()) + { + // yes, so lets do it + slist.resize(newSize); + } + + return qtrue; + } + + assert(0); + + // no + return qfalse; +} + + +int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index) +{ + model_t *mod = (model_t *)ghlInfo->currentModel; + mdxmSurface_t *surf = 0; + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = 0; + + // walk each surface and see if this index is listed in it's children + surf = (mdxmSurface_t *)G2_FindSurface((void *)mod, index, 0); + surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]); + + return surfInfo->parentIndex; + +} + +int G2_GetSurfaceIndex(CGhoul2Info *ghlInfo, const char *surfaceName) +{ + model_t *mod = (model_t *)ghlInfo->currentModel; + int flags; + + return G2_IsSurfaceLegal(mod, surfaceName, &flags); +} + +int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceInfo_v &slist) +{ + int flags = 0;//, surfFlags = 0; + int surfIndex = 0; + assert(ghlInfo->currentModel); + assert(ghlInfo->currentModel->mdxm); + if (!ghlInfo->currentModel->mdxm) + { + return -1; + } + + // now travel up the skeleton to see if any of it's ancestors have a 'no descendants' turned on + + // find the original surface in the surface list + int surfNum = G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, surfaceName, &flags); + if ( surfNum != -1 ) + {//must be legal + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]); + surfNum = surfInfo->parentIndex; + // walk the surface hierarchy up until we hit the root + while (surfNum != -1) + { + const mdxmSurface_t *parentSurf; + int parentFlags; + const mdxmSurfHierarchy_t *parentSurfInfo; + + parentSurfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]); + + // find the original surface in the surface list + //G2 was bug, above comment was accurate, but we don't want the original flags, we want the parent flags + G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, parentSurfInfo->name, &parentFlags); + + // now see if we already have overriden this surface in the slist + parentSurf = G2_FindSurface(ghlInfo, slist, parentSurfInfo->name, &surfIndex); + if (parentSurf) + { + // set descendants value + parentFlags = slist[surfIndex].offFlags; + } + // now we have the parent flags, lets see if any have the 'no descendants' flag set + if (parentFlags & G2SURFACEFLAG_NODESCENDANTS) + { + flags |= G2SURFACEFLAG_OFF; + break; + } + // set up scan of next parent + surfNum = parentSurfInfo->parentIndex; + } + } + else + { + return -1; + } + if ( flags == 0 ) + {//it's not being overridden by a parent + // now see if we already have overriden this surface in the slist + const mdxmSurface_t *surf = G2_FindSurface(ghlInfo, slist, surfaceName, &surfIndex); + if (surf) + { + // set descendants value + flags = slist[surfIndex].offFlags; + } + // ok, at this point in flags we have what this surface is set to, and the index of the surface itself + } + return flags; +} diff --git a/codemp/rd-rend2/iqm.h b/codemp/rd-rend2/iqm.h new file mode 100644 index 0000000000..ab2247acd8 --- /dev/null +++ b/codemp/rd-rend2/iqm.h @@ -0,0 +1,129 @@ +/* +=========================================================================== +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ + +#ifndef __IQM_H__ +#define __IQM_H__ + +#define IQM_MAGIC "INTERQUAKEMODEL" +#define IQM_VERSION 2 + +#define IQM_MAX_JOINTS 128 + +typedef struct iqmheader +{ + char magic[16]; + unsigned int version; + unsigned int filesize; + unsigned int flags; + unsigned int num_text, ofs_text; + unsigned int num_meshes, ofs_meshes; + unsigned int num_vertexarrays, num_vertexes, ofs_vertexarrays; + unsigned int num_triangles, ofs_triangles, ofs_adjacency; + unsigned int num_joints, ofs_joints; + unsigned int num_poses, ofs_poses; + unsigned int num_anims, ofs_anims; + unsigned int num_frames, num_framechannels, ofs_frames, ofs_bounds; + unsigned int num_comment, ofs_comment; + unsigned int num_extensions, ofs_extensions; +} iqmHeader_t; + +typedef struct iqmmesh +{ + unsigned int name; + unsigned int material; + unsigned int first_vertex, num_vertexes; + unsigned int first_triangle, num_triangles; +} iqmMesh_t; + +enum +{ + IQM_POSITION = 0, + IQM_TEXCOORD = 1, + IQM_NORMAL = 2, + IQM_TANGENT = 3, + IQM_BLENDINDEXES = 4, + IQM_BLENDWEIGHTS = 5, + IQM_COLOR = 6, + IQM_CUSTOM = 0x10 +}; + +enum +{ + IQM_BYTE = 0, + IQM_UBYTE = 1, + IQM_SHORT = 2, + IQM_USHORT = 3, + IQM_INT = 4, + IQM_UINT = 5, + IQM_HALF = 6, + IQM_FLOAT = 7, + IQM_DOUBLE = 8, +}; + +typedef struct iqmtriangle +{ + unsigned int vertex[3]; +} iqmTriangle_t; + +typedef struct iqmjoint +{ + unsigned int name; + int parent; + float translate[3], rotate[4], scale[3]; +} iqmJoint_t; + +typedef struct iqmpose +{ + int parent; + unsigned int mask; + float channeloffset[10]; + float channelscale[10]; +} iqmPose_t; + +typedef struct iqmanim +{ + unsigned int name; + unsigned int first_frame, num_frames; + float framerate; + unsigned int flags; +} iqmAnim_t; + +enum +{ + IQM_LOOP = 1<<0 +}; + +typedef struct iqmvertexarray +{ + unsigned int type; + unsigned int flags; + unsigned int format; + unsigned int size; + unsigned int offset; +} iqmVertexArray_t; + +typedef struct iqmbounds +{ + float bbmin[3], bbmax[3]; + float xyradius, radius; +} iqmBounds_t; + +#endif + diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h new file mode 100644 index 0000000000..9dc1b8c134 --- /dev/null +++ b/codemp/rd-rend2/qgl.h @@ -0,0 +1,756 @@ +/* +=========================================================================== +Copyright (C) 1999-2005 Id Software, Inc. + +This file is part of Quake III Arena source code. + +Quake III Arena source code is free software; you can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation; either version 2 of the License, +or (at your option) any later version. + +Quake III Arena source code is distributed in the hope that it will be +useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with Quake III Arena source code; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +=========================================================================== +*/ +/* +** QGL.H +*/ + +#ifndef __QGL_H__ +#define __QGL_H__ + +#ifdef USE_LOCAL_HEADERS +# include "SDL_opengl.h" +#else +# include +#endif + +extern void (APIENTRYP qglActiveTextureARB) (GLenum texture); +extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture); +extern void (APIENTRYP qglMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat t); + +extern void (APIENTRYP qglLockArraysEXT) (GLint first, GLsizei count); +extern void (APIENTRYP qglUnlockArraysEXT) (void); + + +//=========================================================================== + +#define qglAccum glAccum +#define qglAlphaFunc glAlphaFunc +#define qglAreTexturesResident glAreTexturesResident +#define qglArrayElement glArrayElement +#define qglBegin glBegin +#define qglBindTexture glBindTexture +#define qglBitmap glBitmap +#define qglBlendFunc glBlendFunc +#define qglCallList glCallList +#define qglCallLists glCallLists +#define qglClear glClear +#define qglClearAccum glClearAccum +#define qglClearColor glClearColor +#define qglClearDepth glClearDepth +#define qglClearIndex glClearIndex +#define qglClearStencil glClearStencil +#define qglClipPlane glClipPlane +#define qglColor3b glColor3b +#define qglColor3bv glColor3bv +#define qglColor3d glColor3d +#define qglColor3dv glColor3dv +#define qglColor3f glColor3f +#define qglColor3fv glColor3fv +#define qglColor3i glColor3i +#define qglColor3iv glColor3iv +#define qglColor3s glColor3s +#define qglColor3sv glColor3sv +#define qglColor3ub glColor3ub +#define qglColor3ubv glColor3ubv +#define qglColor3ui glColor3ui +#define qglColor3uiv glColor3uiv +#define qglColor3us glColor3us +#define qglColor3usv glColor3usv +#define qglColor4b glColor4b +#define qglColor4bv glColor4bv +#define qglColor4d glColor4d +#define qglColor4dv glColor4dv +#define qglColor4f glColor4f +#define qglColor4fv glColor4fv +#define qglColor4i glColor4i +#define qglColor4iv glColor4iv +#define qglColor4s glColor4s +#define qglColor4sv glColor4sv +#define qglColor4ub glColor4ub +#define qglColor4ubv glColor4ubv +#define qglColor4ui glColor4ui +#define qglColor4uiv glColor4uiv +#define qglColor4us glColor4us +#define qglColor4usv glColor4usv +#define qglColorMask glColorMask +#define qglColorMaterial glColorMaterial +#define qglColorPointer glColorPointer +#define qglCopyPixels glCopyPixels +#define qglCopyTexImage1D glCopyTexImage1D +#define qglCopyTexImage2D glCopyTexImage2D +#define qglCopyTexSubImage1D glCopyTexSubImage1D +#define qglCopyTexSubImage2D glCopyTexSubImage2D +#define qglCullFace glCullFace +#define qglDeleteLists glDeleteLists +#define qglDeleteTextures glDeleteTextures +#define qglDepthFunc glDepthFunc +#define qglDepthMask glDepthMask +#define qglDepthRange glDepthRange +#define qglDisable glDisable +#define qglDisableClientState glDisableClientState +#define qglDrawArrays glDrawArrays +#define qglDrawBuffer glDrawBuffer +#define qglDrawElements glDrawElements +#define qglDrawPixels glDrawPixels +#define qglEdgeFlag glEdgeFlag +#define qglEdgeFlagPointer glEdgeFlagPointer +#define qglEdgeFlagv glEdgeFlagv +#define qglEnable glEnable +#define qglEnableClientState glEnableClientState +#define qglEnd glEnd +#define qglEndList glEndList +#define qglEvalCoord1d glEvalCoord1d +#define qglEvalCoord1dv glEvalCoord1dv +#define qglEvalCoord1f glEvalCoord1f +#define qglEvalCoord1fv glEvalCoord1fv +#define qglEvalCoord2d glEvalCoord2d +#define qglEvalCoord2dv glEvalCoord2dv +#define qglEvalCoord2f glEvalCoord2f +#define qglEvalCoord2fv glEvalCoord2fv +#define qglEvalMesh1 glEvalMesh1 +#define qglEvalMesh2 glEvalMesh2 +#define qglEvalPoint1 glEvalPoint1 +#define qglEvalPoint2 glEvalPoint2 +#define qglFeedbackBuffer glFeedbackBuffer +#define qglFinish glFinish +#define qglFlush glFlush +#define qglFogf glFogf +#define qglFogfv glFogfv +#define qglFogi glFogi +#define qglFogiv glFogiv +#define qglFrontFace glFrontFace +#define qglFrustum glFrustum +#define qglGenLists glGenLists +#define qglGenTextures glGenTextures +#define qglGetBooleanv glGetBooleanv +#define qglGetClipPlane glGetClipPlane +#define qglGetDoublev glGetDoublev +#define qglGetError glGetError +#define qglGetFloatv glGetFloatv +#define qglGetIntegerv glGetIntegerv +#define qglGetLightfv glGetLightfv +#define qglGetLightiv glGetLightiv +#define qglGetMapdv glGetMapdv +#define qglGetMapfv glGetMapfv +#define qglGetMapiv glGetMapiv +#define qglGetMaterialfv glGetMaterialfv +#define qglGetMaterialiv glGetMaterialiv +#define qglGetPixelMapfv glGetPixelMapfv +#define qglGetPixelMapuiv glGetPixelMapuiv +#define qglGetPixelMapusv glGetPixelMapusv +#define qglGetPointerv glGetPointerv +#define qglGetPolygonStipple glGetPolygonStipple +#define qglGetString glGetString +#define qglGetTexGendv glGetTexGendv +#define qglGetTexGenfv glGetTexGenfv +#define qglGetTexGeniv glGetTexGeniv +#define qglGetTexImage glGetTexImage +#define qglGetTexLevelParameterfv glGetTexLevelParameterfv +#define qglGetTexLevelParameteriv glGetTexLevelParameteriv +#define qglGetTexParameterfv glGetTexParameterfv +#define qglGetTexParameteriv glGetTexParameteriv +#define qglHint glHint +#define qglIndexMask glIndexMask +#define qglIndexPointer glIndexPointer +#define qglIndexd glIndexd +#define qglIndexdv glIndexdv +#define qglIndexf glIndexf +#define qglIndexfv glIndexfv +#define qglIndexi glIndexi +#define qglIndexiv glIndexiv +#define qglIndexs glIndexs +#define qglIndexsv glIndexsv +#define qglIndexub glIndexub +#define qglIndexubv glIndexubv +#define qglInitNames glInitNames +#define qglInterleavedArrays glInterleavedArrays +#define qglIsEnabled glIsEnabled +#define qglIsList glIsList +#define qglIsTexture glIsTexture +#define qglLightModelf glLightModelf +#define qglLightModelfv glLightModelfv +#define qglLightModeli glLightModeli +#define qglLightModeliv glLightModeliv +#define qglLightf glLightf +#define qglLightfv glLightfv +#define qglLighti glLighti +#define qglLightiv glLightiv +#define qglLineStipple glLineStipple +#define qglLineWidth glLineWidth +#define qglListBase glListBase +#define qglLoadIdentity glLoadIdentity +#define qglLoadMatrixd glLoadMatrixd +#define qglLoadMatrixf glLoadMatrixf +#define qglLoadName glLoadName +#define qglLogicOp glLogicOp +#define qglMap1d glMap1d +#define qglMap1f glMap1f +#define qglMap2d glMap2d +#define qglMap2f glMap2f +#define qglMapGrid1d glMapGrid1d +#define qglMapGrid1f glMapGrid1f +#define qglMapGrid2d glMapGrid2d +#define qglMapGrid2f glMapGrid2f +#define qglMaterialf glMaterialf +#define qglMaterialfv glMaterialfv +#define qglMateriali glMateriali +#define qglMaterialiv glMaterialiv +#define qglMatrixMode glMatrixMode +#define qglMultMatrixd glMultMatrixd +#define qglMultMatrixf glMultMatrixf +#define qglNewList glNewList +#define qglNormal3b glNormal3b +#define qglNormal3bv glNormal3bv +#define qglNormal3d glNormal3d +#define qglNormal3dv glNormal3dv +#define qglNormal3f glNormal3f +#define qglNormal3fv glNormal3fv +#define qglNormal3i glNormal3i +#define qglNormal3iv glNormal3iv +#define qglNormal3s glNormal3s +#define qglNormal3sv glNormal3sv +#define qglNormalPointer glNormalPointer +#define qglOrtho glOrtho +#define qglPassThrough glPassThrough +#define qglPixelMapfv glPixelMapfv +#define qglPixelMapuiv glPixelMapuiv +#define qglPixelMapusv glPixelMapusv +#define qglPixelStoref glPixelStoref +#define qglPixelStorei glPixelStorei +#define qglPixelTransferf glPixelTransferf +#define qglPixelTransferi glPixelTransferi +#define qglPixelZoom glPixelZoom +#define qglPointSize glPointSize +#define qglPolygonMode glPolygonMode +#define qglPolygonOffset glPolygonOffset +#define qglPolygonStipple glPolygonStipple +#define qglPopAttrib glPopAttrib +#define qglPopClientAttrib glPopClientAttrib +#define qglPopMatrix glPopMatrix +#define qglPopName glPopName +#define qglPrioritizeTextures glPrioritizeTextures +#define qglPushAttrib glPushAttrib +#define qglPushClientAttrib glPushClientAttrib +#define qglPushMatrix glPushMatrix +#define qglPushName glPushName +#define qglRasterPos2d glRasterPos2d +#define qglRasterPos2dv glRasterPos2dv +#define qglRasterPos2f glRasterPos2f +#define qglRasterPos2fv glRasterPos2fv +#define qglRasterPos2i glRasterPos2i +#define qglRasterPos2iv glRasterPos2iv +#define qglRasterPos2s glRasterPos2s +#define qglRasterPos2sv glRasterPos2sv +#define qglRasterPos3d glRasterPos3d +#define qglRasterPos3dv glRasterPos3dv +#define qglRasterPos3f glRasterPos3f +#define qglRasterPos3fv glRasterPos3fv +#define qglRasterPos3i glRasterPos3i +#define qglRasterPos3iv glRasterPos3iv +#define qglRasterPos3s glRasterPos3s +#define qglRasterPos3sv glRasterPos3sv +#define qglRasterPos4d glRasterPos4d +#define qglRasterPos4dv glRasterPos4dv +#define qglRasterPos4f glRasterPos4f +#define qglRasterPos4fv glRasterPos4fv +#define qglRasterPos4i glRasterPos4i +#define qglRasterPos4iv glRasterPos4iv +#define qglRasterPos4s glRasterPos4s +#define qglRasterPos4sv glRasterPos4sv +#define qglReadBuffer glReadBuffer +#define qglReadPixels glReadPixels +#define qglRectd glRectd +#define qglRectdv glRectdv +#define qglRectf glRectf +#define qglRectfv glRectfv +#define qglRecti glRecti +#define qglRectiv glRectiv +#define qglRects glRects +#define qglRectsv glRectsv +#define qglRenderMode glRenderMode +#define qglRotated glRotated +#define qglRotatef glRotatef +#define qglScaled glScaled +#define qglScalef glScalef +#define qglScissor glScissor +#define qglSelectBuffer glSelectBuffer +#define qglShadeModel glShadeModel +#define qglStencilFunc glStencilFunc +#define qglStencilMask glStencilMask +#define qglStencilOp glStencilOp +#define qglTexCoord1d glTexCoord1d +#define qglTexCoord1dv glTexCoord1dv +#define qglTexCoord1f glTexCoord1f +#define qglTexCoord1fv glTexCoord1fv +#define qglTexCoord1i glTexCoord1i +#define qglTexCoord1iv glTexCoord1iv +#define qglTexCoord1s glTexCoord1s +#define qglTexCoord1sv glTexCoord1sv +#define qglTexCoord2d glTexCoord2d +#define qglTexCoord2dv glTexCoord2dv +#define qglTexCoord2f glTexCoord2f +#define qglTexCoord2fv glTexCoord2fv +#define qglTexCoord2i glTexCoord2i +#define qglTexCoord2iv glTexCoord2iv +#define qglTexCoord2s glTexCoord2s +#define qglTexCoord2sv glTexCoord2sv +#define qglTexCoord3d glTexCoord3d +#define qglTexCoord3dv glTexCoord3dv +#define qglTexCoord3f glTexCoord3f +#define qglTexCoord3fv glTexCoord3fv +#define qglTexCoord3i glTexCoord3i +#define qglTexCoord3iv glTexCoord3iv +#define qglTexCoord3s glTexCoord3s +#define qglTexCoord3sv glTexCoord3sv +#define qglTexCoord4d glTexCoord4d +#define qglTexCoord4dv glTexCoord4dv +#define qglTexCoord4f glTexCoord4f +#define qglTexCoord4fv glTexCoord4fv +#define qglTexCoord4i glTexCoord4i +#define qglTexCoord4iv glTexCoord4iv +#define qglTexCoord4s glTexCoord4s +#define qglTexCoord4sv glTexCoord4sv +#define qglTexCoordPointer glTexCoordPointer +#define qglTexEnvf glTexEnvf +#define qglTexEnvfv glTexEnvfv +#define qglTexEnvi glTexEnvi +#define qglTexEnviv glTexEnviv +#define qglTexGend glTexGend +#define qglTexGendv glTexGendv +#define qglTexGenf glTexGenf +#define qglTexGenfv glTexGenfv +#define qglTexGeni glTexGeni +#define qglTexGeniv glTexGeniv +#define qglTexImage1D glTexImage1D +#define qglTexImage2D glTexImage2D +#define qglTexParameterf glTexParameterf +#define qglTexParameterfv glTexParameterfv +#define qglTexParameteri glTexParameteri +#define qglTexParameteriv glTexParameteriv +#define qglTexSubImage1D glTexSubImage1D +#define qglTexSubImage2D glTexSubImage2D +#define qglTranslated glTranslated +#define qglTranslatef glTranslatef +#define qglVertex2d glVertex2d +#define qglVertex2dv glVertex2dv +#define qglVertex2f glVertex2f +#define qglVertex2fv glVertex2fv +#define qglVertex2i glVertex2i +#define qglVertex2iv glVertex2iv +#define qglVertex2s glVertex2s +#define qglVertex2sv glVertex2sv +#define qglVertex3d glVertex3d +#define qglVertex3dv glVertex3dv +#define qglVertex3f glVertex3f +#define qglVertex3fv glVertex3fv +#define qglVertex3i glVertex3i +#define qglVertex3iv glVertex3iv +#define qglVertex3s glVertex3s +#define qglVertex3sv glVertex3sv +#define qglVertex4d glVertex4d +#define qglVertex4dv glVertex4dv +#define qglVertex4f glVertex4f +#define qglVertex4fv glVertex4fv +#define qglVertex4i glVertex4i +#define qglVertex4iv glVertex4iv +#define qglVertex4s glVertex4s +#define qglVertex4sv glVertex4sv +#define qglVertexPointer glVertexPointer +#define qglViewport glViewport + +// GL_EXT_draw_range_elements +extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +// GL_EXT_multi_draw_arrays +extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, GLint *, GLsizei *, GLsizei); +extern void (APIENTRY * qglMultiDrawElementsEXT) (GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei); + +// GL_ARB_shading_language_100 +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +// GL_ARB_vertex_program +extern void (APIENTRY * qglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +extern void (APIENTRY * qglVertexAttrib4fvARB) (GLuint, const GLfloat *); +extern void (APIENTRY * qglVertexAttribPointerARB) (GLuint index, GLint size, GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid * pointer); +extern void (APIENTRY * qglEnableVertexAttribArrayARB) (GLuint index); +extern void (APIENTRY * qglDisableVertexAttribArrayARB) (GLuint index); + +// GL_ARB_vertex_buffer_object +extern void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer); +extern void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); +extern void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); +extern GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); +extern void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); +extern void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); +extern void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); +extern void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); +extern void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params); + +// GL_ARB_shader_objects +extern void (APIENTRY * qglDeleteObjectARB) (GLhandleARB obj); +extern GLhandleARB(APIENTRY * qglGetHandleARB) (GLenum pname); +extern void (APIENTRY * qglDetachObjectARB) (GLhandleARB containerObj, GLhandleARB attachedObj); +extern GLhandleARB(APIENTRY * qglCreateShaderObjectARB) (GLenum shaderType); +extern void (APIENTRY * qglShaderSourceARB) (GLhandleARB shaderObj, GLsizei count, const GLcharARB * *string, + const GLint * length); +extern void (APIENTRY * qglCompileShaderARB) (GLhandleARB shaderObj); +extern GLhandleARB(APIENTRY * qglCreateProgramObjectARB) (void); +extern void (APIENTRY * qglAttachObjectARB) (GLhandleARB containerObj, GLhandleARB obj); +extern void (APIENTRY * qglLinkProgramARB) (GLhandleARB programObj); +extern void (APIENTRY * qglUseProgramObjectARB) (GLhandleARB programObj); +extern void (APIENTRY * qglValidateProgramARB) (GLhandleARB programObj); +extern void (APIENTRY * qglUniform1fARB) (GLint location, GLfloat v0); +extern void (APIENTRY * qglUniform2fARB) (GLint location, GLfloat v0, GLfloat v1); +extern void (APIENTRY * qglUniform3fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +extern void (APIENTRY * qglUniform4fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +extern void (APIENTRY * qglUniform1iARB) (GLint location, GLint v0); +extern void (APIENTRY * qglUniform2iARB) (GLint location, GLint v0, GLint v1); +extern void (APIENTRY * qglUniform3iARB) (GLint location, GLint v0, GLint v1, GLint v2); +extern void (APIENTRY * qglUniform4iARB) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +extern void (APIENTRY * qglUniform1fvARB) (GLint location, GLsizei count, const GLfloat * value); +extern void (APIENTRY * qglUniform2fvARB) (GLint location, GLsizei count, const GLfloat * value); +extern void (APIENTRY * qglUniform3fvARB) (GLint location, GLsizei count, const GLfloat * value); +extern void (APIENTRY * qglUniform4fvARB) (GLint location, GLsizei count, const GLfloat * value); +extern void (APIENTRY * qglUniform2ivARB) (GLint location, GLsizei count, const GLint * value); +extern void (APIENTRY * qglUniform3ivARB) (GLint location, GLsizei count, const GLint * value); +extern void (APIENTRY * qglUniform4ivARB) (GLint location, GLsizei count, const GLint * value); +extern void (APIENTRY * qglUniformMatrix2fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +extern void (APIENTRY * qglUniformMatrix3fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +extern void (APIENTRY * qglUniformMatrix4fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); +extern void (APIENTRY * qglGetObjectParameterfvARB) (GLhandleARB obj, GLenum pname, GLfloat * params); +extern void (APIENTRY * qglGetObjectParameterivARB) (GLhandleARB obj, GLenum pname, GLint * params); +extern void (APIENTRY * qglGetInfoLogARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog); +extern void (APIENTRY * qglGetAttachedObjectsARB) (GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, + GLhandleARB * obj); +extern GLint(APIENTRY * qglGetUniformLocationARB) (GLhandleARB programObj, const GLcharARB * name); +extern void (APIENTRY * qglGetActiveUniformARB) (GLhandleARB programObj, GLuint index, GLsizei maxIndex, GLsizei * length, + GLint * size, GLenum * type, GLcharARB * name); +extern void (APIENTRY * qglGetUniformfvARB) (GLhandleARB programObj, GLint location, GLfloat * params); +extern void (APIENTRY * qglGetUniformivARB) (GLhandleARB programObj, GLint location, GLint * params); +extern void (APIENTRY * qglGetShaderSourceARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source); + +// GL_ARB_vertex_shader +extern void (APIENTRY * qglBindAttribLocationARB) (GLhandleARB programObj, GLuint index, const GLcharARB * name); +extern void (APIENTRY * qglGetActiveAttribARB) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, + GLint * size, GLenum * type, GLcharARB * name); +extern GLint(APIENTRY * qglGetAttribLocationARB) (GLhandleARB programObj, const GLcharARB * name); + +// GL_ARB_texture_compression +extern void (APIENTRY * qglCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, + GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data); +extern void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod, + GLvoid *img); + +// GL_NVX_gpu_memory_info +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif + +// GL_ATI_meminfo +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +// GL_ARB_texture_float +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +// GL_EXT_framebuffer_object +extern GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer); +extern void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); +extern void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers); +extern void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers); +extern void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +extern void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params); +extern GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer); +extern void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer); +extern void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); +extern void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); +extern GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target); +extern void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level); +extern void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level); +extern void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, + GLint level, GLint zoffset); +extern void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, + GLuint renderbuffer); +extern void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params); +extern void (APIENTRY * qglGenerateMipmapEXT)(GLenum target); + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#endif + +// GL_EXT_packed_depth_stencil +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +// GL_ARB_occlusion_query +extern void (APIENTRY * qglGenQueriesARB)(GLsizei n, GLuint *ids); +extern void (APIENTRY * qglDeleteQueriesARB)(GLsizei n, const GLuint *ids); +extern GLboolean (APIENTRY * qglIsQueryARB)(GLuint id); +extern void (APIENTRY * qglBeginQueryARB)(GLenum target, GLuint id); +extern void (APIENTRY * qglEndQueryARB)(GLenum target); +extern void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); +extern void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); +extern void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query +#define GL_SAMPLES_PASSED_ARB 0x8914 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#endif + +// GL_EXT_framebuffer_blit +extern void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +// GL_EXT_framebuffer_multisample +extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height); + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +// GL_ARB_draw_buffers +extern void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#if defined(WIN32) +// WGL_ARB_create_context +#ifndef WGL_ARB_create_context +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 +#endif + +extern HGLRC(APIENTRY * qwglCreateContextAttribsARB) (HDC hdC, HGLRC hShareContext, const int *attribList); +#endif + +#if 0 //defined(__linux__) +// GLX_ARB_create_context +#ifndef GLX_ARB_create_context +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +#endif + +extern GLXContext (APIENTRY * qglXCreateContextAttribsARB) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); +#endif + +#endif diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 144b16eb3d..0ef4e7108e 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -27,14 +27,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "../qcommon/q_shared.h" #include "../qcommon/qfiles.h" #include "../qcommon/qcommon.h" -#include "../renderercommon/tr_public.h" -#include "../renderercommon/tr_common.h" +#include "../rd-common/tr_public.h" +#include "../rd-common/tr_common.h" #include "tr_extratypes.h" #include "tr_extramath.h" #include "tr_fbo.h" #include "tr_postprocess.h" -#include "../renderercommon/iqm.h" -#include "../renderercommon/qgl.h" +#include "iqm.h" +#include "qgl.h" #define GL_INDEX_TYPE GL_UNSIGNED_INT typedef unsigned int glIndex_t; From 4431e3dcd29bb66bcac528d451bdb257759975c1 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:38:47 -0400 Subject: [PATCH 004/708] Changed the extra refdef flags to match JA's stuff adequately. --- codemp/rd-rend2/tr_extratypes.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_extratypes.h b/codemp/rd-rend2/tr_extratypes.h index 84e39a76ef..a8454635a5 100644 --- a/codemp/rd-rend2/tr_extratypes.h +++ b/codemp/rd-rend2/tr_extratypes.h @@ -26,9 +26,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_extratypes.h, for mods that want to extend tr_types.h without losing compatibility with original VMs // extra refdef flags start at 0x0008 -#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene -#define RDF_EXTRA 0x0010 // Makro - refdefex_t to follow after refdef_t -#define RDF_SUNLIGHT 0x0020 // SmileTheory - render sunlight and shadows +//#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene +#define RDF_EXTRA 128 // Makro - refdefex_t to follow after refdef_t +#define RDF_SUNLIGHT 256 // SmileTheory - render sunlight and shadows typedef struct { float blurFactor; From 435a8797a5212696e4d0f8c6f94b4a365382c4e4 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:45:59 -0400 Subject: [PATCH 005/708] ID_INLINE -> QINLINE --- codemp/rd-rend2/tr_extramath.h | 4 ++-- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index 3e11bb483c..99e17c1a05 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -59,7 +59,7 @@ void Matrix16SimpleInverse( const matrix_t in, matrix_t out); #define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f)) #define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) ) -static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) +static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) { @@ -68,7 +68,7 @@ static ID_INLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) return 1; } -static ID_INLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) +static QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 0ef4e7108e..2b059d0871 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -496,7 +496,7 @@ typedef struct shader_s { struct shader_s *next; } shader_t; -static ID_INLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) +static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) { if(shader->numDeforms) { diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index b67c5fa480..1933962c9d 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1790,7 +1790,7 @@ DRAWSURF SORTING R_Radix =============== */ -static ID_INLINE void R_Radix( int byte, int size, drawSurf_t *source, drawSurf_t *dest ) +static QINLINE void R_Radix( int byte, int size, drawSurf_t *source, drawSurf_t *dest ) { int count[ 256 ] = { 0 }; int index[ 256 ]; From 168a9cf5fc35c33a8e4944c5a0f12dde9cdaaf55 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 20:52:19 -0400 Subject: [PATCH 006/708] Add SDL stuff which is specific to rd-rend2 --- codemp/rd-rend2/SDL/SDL.h | 101 + codemp/rd-rend2/SDL/SDL_active.h | 63 + codemp/rd-rend2/SDL/SDL_audio.h | 284 + codemp/rd-rend2/SDL/SDL_byteorder.h | 29 + codemp/rd-rend2/SDL/SDL_cdrom.h | 202 + codemp/rd-rend2/SDL/SDL_config.h | 45 + codemp/rd-rend2/SDL/SDL_config_amiga.h | 80 + codemp/rd-rend2/SDL/SDL_config_dreamcast.h | 106 + codemp/rd-rend2/SDL/SDL_config_macos.h | 112 + codemp/rd-rend2/SDL/SDL_config_macosx.h | 150 + codemp/rd-rend2/SDL/SDL_config_minimal.h | 66 + codemp/rd-rend2/SDL/SDL_config_nds.h | 115 + codemp/rd-rend2/SDL/SDL_config_os2.h | 141 + codemp/rd-rend2/SDL/SDL_config_symbian.h | 146 + codemp/rd-rend2/SDL/SDL_config_win32.h | 183 + codemp/rd-rend2/SDL/SDL_copying.h | 22 + codemp/rd-rend2/SDL/SDL_cpuinfo.h | 69 + codemp/rd-rend2/SDL/SDL_endian.h | 214 + codemp/rd-rend2/SDL/SDL_error.h | 72 + codemp/rd-rend2/SDL/SDL_events.h | 356 ++ codemp/rd-rend2/SDL/SDL_getenv.h | 28 + codemp/rd-rend2/SDL/SDL_joystick.h | 187 + codemp/rd-rend2/SDL/SDL_keyboard.h | 135 + codemp/rd-rend2/SDL/SDL_keysym.h | 326 + codemp/rd-rend2/SDL/SDL_loadso.h | 78 + codemp/rd-rend2/SDL/SDL_main.h | 106 + codemp/rd-rend2/SDL/SDL_mouse.h | 143 + codemp/rd-rend2/SDL/SDL_mutex.h | 177 + codemp/rd-rend2/SDL/SDL_name.h | 11 + codemp/rd-rend2/SDL/SDL_opengl.h | 6570 ++++++++++++++++++++ codemp/rd-rend2/SDL/SDL_platform.h | 110 + codemp/rd-rend2/SDL/SDL_quit.h | 55 + codemp/rd-rend2/SDL/SDL_rwops.h | 155 + codemp/rd-rend2/SDL/SDL_stdinc.h | 620 ++ codemp/rd-rend2/SDL/SDL_syswm.h | 226 + codemp/rd-rend2/SDL/SDL_thread.h | 115 + codemp/rd-rend2/SDL/SDL_timer.h | 125 + codemp/rd-rend2/SDL/SDL_types.h | 28 + codemp/rd-rend2/SDL/SDL_version.h | 91 + codemp/rd-rend2/SDL/SDL_video.h | 951 +++ codemp/rd-rend2/SDL/begin_code.h | 196 + codemp/rd-rend2/SDL/close_code.h | 46 + codemp/rd-rend2/qgl.h | 6 +- 43 files changed, 13036 insertions(+), 5 deletions(-) create mode 100644 codemp/rd-rend2/SDL/SDL.h create mode 100644 codemp/rd-rend2/SDL/SDL_active.h create mode 100644 codemp/rd-rend2/SDL/SDL_audio.h create mode 100644 codemp/rd-rend2/SDL/SDL_byteorder.h create mode 100644 codemp/rd-rend2/SDL/SDL_cdrom.h create mode 100644 codemp/rd-rend2/SDL/SDL_config.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_amiga.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_dreamcast.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_macos.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_macosx.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_minimal.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_nds.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_os2.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_symbian.h create mode 100644 codemp/rd-rend2/SDL/SDL_config_win32.h create mode 100644 codemp/rd-rend2/SDL/SDL_copying.h create mode 100644 codemp/rd-rend2/SDL/SDL_cpuinfo.h create mode 100644 codemp/rd-rend2/SDL/SDL_endian.h create mode 100644 codemp/rd-rend2/SDL/SDL_error.h create mode 100644 codemp/rd-rend2/SDL/SDL_events.h create mode 100644 codemp/rd-rend2/SDL/SDL_getenv.h create mode 100644 codemp/rd-rend2/SDL/SDL_joystick.h create mode 100644 codemp/rd-rend2/SDL/SDL_keyboard.h create mode 100644 codemp/rd-rend2/SDL/SDL_keysym.h create mode 100644 codemp/rd-rend2/SDL/SDL_loadso.h create mode 100644 codemp/rd-rend2/SDL/SDL_main.h create mode 100644 codemp/rd-rend2/SDL/SDL_mouse.h create mode 100644 codemp/rd-rend2/SDL/SDL_mutex.h create mode 100644 codemp/rd-rend2/SDL/SDL_name.h create mode 100644 codemp/rd-rend2/SDL/SDL_opengl.h create mode 100644 codemp/rd-rend2/SDL/SDL_platform.h create mode 100644 codemp/rd-rend2/SDL/SDL_quit.h create mode 100644 codemp/rd-rend2/SDL/SDL_rwops.h create mode 100644 codemp/rd-rend2/SDL/SDL_stdinc.h create mode 100644 codemp/rd-rend2/SDL/SDL_syswm.h create mode 100644 codemp/rd-rend2/SDL/SDL_thread.h create mode 100644 codemp/rd-rend2/SDL/SDL_timer.h create mode 100644 codemp/rd-rend2/SDL/SDL_types.h create mode 100644 codemp/rd-rend2/SDL/SDL_version.h create mode 100644 codemp/rd-rend2/SDL/SDL_video.h create mode 100644 codemp/rd-rend2/SDL/begin_code.h create mode 100644 codemp/rd-rend2/SDL/close_code.h diff --git a/codemp/rd-rend2/SDL/SDL.h b/codemp/rd-rend2/SDL/SDL.h new file mode 100644 index 0000000000..6087b7cdd4 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL.h @@ -0,0 +1,101 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL.h + * Main include header for the SDL library + */ + +#ifndef _SDL_H +#define _SDL_H + +#include "SDL_main.h" +#include "SDL_stdinc.h" +#include "SDL_audio.h" +#include "SDL_cdrom.h" +#include "SDL_cpuinfo.h" +#include "SDL_endian.h" +#include "SDL_error.h" +#include "SDL_events.h" +#include "SDL_loadso.h" +#include "SDL_mutex.h" +#include "SDL_rwops.h" +#include "SDL_thread.h" +#include "SDL_timer.h" +#include "SDL_video.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL.h + * @note As of version 0.5, SDL is loaded dynamically into the application + */ + +/** @name SDL_INIT Flags + * These are the flags which may be passed to SDL_Init() -- you should + * specify the subsystems which you will be using in your application. + */ +/*@{*/ +#define SDL_INIT_TIMER 0x00000001 +#define SDL_INIT_AUDIO 0x00000010 +#define SDL_INIT_VIDEO 0x00000020 +#define SDL_INIT_CDROM 0x00000100 +#define SDL_INIT_JOYSTICK 0x00000200 +#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ +#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ +#define SDL_INIT_EVERYTHING 0x0000FFFF +/*@}*/ + +/** This function loads the SDL dynamically linked library and initializes + * the subsystems specified by 'flags' (and those satisfying dependencies) + * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup + * signal handlers for some commonly ignored fatal signals (like SIGSEGV) + */ +extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); + +/** This function initializes specific SDL subsystems */ +extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); + +/** This function cleans up specific SDL subsystems */ +extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); + +/** This function returns mask of the specified subsystems which have + * been initialized. + * If 'flags' is 0, it returns a mask of all initialized subsystems. + */ +extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); + +/** This function cleans up all initialized subsystems and unloads the + * dynamically linked library. You should call it upon all exit conditions. + */ +extern DECLSPEC void SDLCALL SDL_Quit(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_H */ diff --git a/codemp/rd-rend2/SDL/SDL_active.h b/codemp/rd-rend2/SDL/SDL_active.h new file mode 100644 index 0000000000..cd854e8928 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_active.h @@ -0,0 +1,63 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_active.h + * Include file for SDL application focus event handling + */ + +#ifndef _SDL_active_h +#define _SDL_active_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name The available application states */ +/*@{*/ +#define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ +#define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ +#define SDL_APPACTIVE 0x04 /**< The application is active */ +/*@}*/ + +/* Function prototypes */ +/** + * This function returns the current state of the application, which is a + * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and + * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to + * see your application, otherwise it has been iconified or disabled. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_active_h */ diff --git a/codemp/rd-rend2/SDL/SDL_audio.h b/codemp/rd-rend2/SDL/SDL_audio.h new file mode 100644 index 0000000000..e879c98966 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_audio.h @@ -0,0 +1,284 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_audio.h + * Access to the raw audio mixing buffer for the SDL library + */ + +#ifndef _SDL_audio_h +#define _SDL_audio_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_endian.h" +#include "SDL_mutex.h" +#include "SDL_thread.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * When filling in the desired audio spec structure, + * - 'desired->freq' should be the desired audio frequency in samples-per-second. + * - 'desired->format' should be the desired audio format. + * - 'desired->samples' is the desired size of the audio buffer, in samples. + * This number should be a power of two, and may be adjusted by the audio + * driver to a value more suitable for the hardware. Good values seem to + * range between 512 and 8096 inclusive, depending on the application and + * CPU speed. Smaller values yield faster response time, but can lead + * to underflow if the application is doing heavy processing and cannot + * fill the audio buffer in time. A stereo sample consists of both right + * and left channels in LR ordering. + * Note that the number of samples is directly related to time by the + * following formula: ms = (samples*1000)/freq + * - 'desired->size' is the size in bytes of the audio buffer, and is + * calculated by SDL_OpenAudio(). + * - 'desired->silence' is the value used to set the buffer to silence, + * and is calculated by SDL_OpenAudio(). + * - 'desired->callback' should be set to a function that will be called + * when the audio device is ready for more data. It is passed a pointer + * to the audio buffer, and the length in bytes of the audio buffer. + * This function usually runs in a separate thread, and so you should + * protect data structures that it accesses by calling SDL_LockAudio() + * and SDL_UnlockAudio() in your code. + * - 'desired->userdata' is passed as the first parameter to your callback + * function. + * + * @note The calculated values in this structure are calculated by SDL_OpenAudio() + * + */ +typedef struct SDL_AudioSpec { + int freq; /**< DSP frequency -- samples per second */ + Uint16 format; /**< Audio data format */ + Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ + Uint8 silence; /**< Audio buffer silence value (calculated) */ + Uint16 samples; /**< Audio buffer size in samples (power of 2) */ + Uint16 padding; /**< Necessary for some compile environments */ + Uint32 size; /**< Audio buffer size in bytes (calculated) */ + /** + * This function is called when the audio device needs more data. + * + * @param[out] stream A pointer to the audio data buffer + * @param[in] len The length of the audio buffer in bytes. + * + * Once the callback returns, the buffer will no longer be valid. + * Stereo samples are stored in a LRLRLR ordering. + */ + void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len); + void *userdata; +} SDL_AudioSpec; + +/** + * @name Audio format flags + * defaults to LSB byte order + */ +/*@{*/ +#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ +#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ +#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ +#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ +#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ +#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ +#define AUDIO_U16 AUDIO_U16LSB +#define AUDIO_S16 AUDIO_S16LSB + +/** + * @name Native audio byte ordering + */ +/*@{*/ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define AUDIO_U16SYS AUDIO_U16LSB +#define AUDIO_S16SYS AUDIO_S16LSB +#else +#define AUDIO_U16SYS AUDIO_U16MSB +#define AUDIO_S16SYS AUDIO_S16MSB +#endif +/*@}*/ + +/*@}*/ + + +/** A structure to hold a set of audio conversion filters and buffers */ +typedef struct SDL_AudioCVT { + int needed; /**< Set to 1 if conversion possible */ + Uint16 src_format; /**< Source audio format */ + Uint16 dst_format; /**< Target audio format */ + double rate_incr; /**< Rate conversion increment */ + Uint8 *buf; /**< Buffer to hold entire audio data */ + int len; /**< Length of original audio buffer */ + int len_cvt; /**< Length of converted audio buffer */ + int len_mult; /**< buffer must be len*len_mult big */ + double len_ratio; /**< Given len, final size is len*len_ratio */ + void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); + int filter_index; /**< Current audio conversion function */ +} SDL_AudioCVT; + + +/* Function prototypes */ + +/** + * @name Audio Init and Quit + * These functions are used internally, and should not be used unless you + * have a specific need to specify the audio driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/*@{*/ +extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); +extern DECLSPEC void SDLCALL SDL_AudioQuit(void); +/*@}*/ + +/** + * This function fills the given character buffer with the name of the + * current audio driver, and returns a pointer to it if the audio driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); + +/** + * This function opens the audio device with the desired parameters, and + * returns 0 if successful, placing the actual hardware parameters in the + * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio + * data passed to the callback function will be guaranteed to be in the + * requested format, and will be automatically converted to the hardware + * audio format if necessary. This function returns -1 if it failed + * to open the audio device, or couldn't set up the audio thread. + * + * The audio device starts out playing silence when it's opened, and should + * be enabled for playing by calling SDL_PauseAudio(0) when you are ready + * for your audio callback function to be called. Since the audio driver + * may modify the requested size of the audio buffer, you should allocate + * any local mixing buffers after you open the audio device. + * + * @sa SDL_AudioSpec + */ +extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); + +typedef enum { + SDL_AUDIO_STOPPED = 0, + SDL_AUDIO_PLAYING, + SDL_AUDIO_PAUSED +} SDL_audiostatus; + +/** Get the current audio state */ +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); + +/** + * This function pauses and unpauses the audio callback processing. + * It should be called with a parameter of 0 after opening the audio + * device to start playing sound. This is so you can safely initialize + * data for your callback function after opening the audio device. + * Silence will be written to the audio device during the pause. + */ +extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); + +/** + * This function loads a WAVE from the data source, automatically freeing + * that source if 'freesrc' is non-zero. For example, to load a WAVE file, + * you could do: + * @code SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); @endcode + * + * If this function succeeds, it returns the given SDL_AudioSpec, + * filled with the audio data format of the wave data, and sets + * 'audio_buf' to a malloc()'d buffer containing the audio data, + * and sets 'audio_len' to the length of that audio buffer, in bytes. + * You need to free the audio buffer with SDL_FreeWAV() when you are + * done with it. + * + * This function returns NULL and sets the SDL error message if the + * wave file cannot be opened, uses an unknown data format, or is + * corrupt. Currently raw and MS-ADPCM WAVE files are supported. + */ +extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); + +/** Compatibility convenience function -- loads a WAV from a file */ +#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ + SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) + +/** + * This function frees data previously allocated with SDL_LoadWAV_RW() + */ +extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); + +/** + * This function takes a source format and rate and a destination format + * and rate, and initializes the 'cvt' structure with information needed + * by SDL_ConvertAudio() to convert a buffer of audio data from one format + * to the other. + * + * @return This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, + Uint16 src_format, Uint8 src_channels, int src_rate, + Uint16 dst_format, Uint8 dst_channels, int dst_rate); + +/** + * Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), + * created an audio buffer cvt->buf, and filled it with cvt->len bytes of + * audio data in the source format, this function will convert it in-place + * to the desired format. + * The data conversion may expand the size of the audio data, so the buffer + * cvt->buf should be allocated after the cvt structure is initialized by + * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. + */ +extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); + + +#define SDL_MIX_MAXVOLUME 128 +/** + * This takes two audio buffers of the playing audio format and mixes + * them, performing addition, volume adjustment, and overflow clipping. + * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME + * for full audio volume. Note this does not change hardware volume. + * This is provided for convenience -- you can mix your own audio data. + */ +extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); + +/** + * @name Audio Locks + * The lock manipulated by these functions protects the callback function. + * During a LockAudio/UnlockAudio pair, you can be guaranteed that the + * callback function is not running. Do not call these from the callback + * function or you will cause deadlock. + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_LockAudio(void); +extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); +/*@}*/ + +/** + * This function shuts down audio processing and closes the audio device. + */ +extern DECLSPEC void SDLCALL SDL_CloseAudio(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_audio_h */ diff --git a/codemp/rd-rend2/SDL/SDL_byteorder.h b/codemp/rd-rend2/SDL/SDL_byteorder.h new file mode 100644 index 0000000000..47332c3df7 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_byteorder.h @@ -0,0 +1,29 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_byteorder.h + * @deprecated Use SDL_endian.h instead + */ + +/* DEPRECATED */ +#include "SDL_endian.h" diff --git a/codemp/rd-rend2/SDL/SDL_cdrom.h b/codemp/rd-rend2/SDL/SDL_cdrom.h new file mode 100644 index 0000000000..febb19dcc7 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_cdrom.h @@ -0,0 +1,202 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_cdrom.h + * This is the CD-audio control API for Simple DirectMedia Layer + */ + +#ifndef _SDL_cdrom_h +#define _SDL_cdrom_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @file SDL_cdrom.h + * In order to use these functions, SDL_Init() must have been called + * with the SDL_INIT_CDROM flag. This causes SDL to scan the system + * for CD-ROM drives, and load appropriate drivers. + */ + +/** The maximum number of CD-ROM tracks on a disk */ +#define SDL_MAX_TRACKS 99 + +/** @name Track Types + * The types of CD-ROM track possible + */ +/*@{*/ +#define SDL_AUDIO_TRACK 0x00 +#define SDL_DATA_TRACK 0x04 +/*@}*/ + +/** The possible states which a CD-ROM drive can be in. */ +typedef enum { + CD_TRAYEMPTY, + CD_STOPPED, + CD_PLAYING, + CD_PAUSED, + CD_ERROR = -1 +} CDstatus; + +/** Given a status, returns true if there's a disk in the drive */ +#define CD_INDRIVE(status) ((int)(status) > 0) + +typedef struct SDL_CDtrack { + Uint8 id; /**< Track number */ + Uint8 type; /**< Data or audio track */ + Uint16 unused; + Uint32 length; /**< Length, in frames, of this track */ + Uint32 offset; /**< Offset, in frames, from start of disk */ +} SDL_CDtrack; + +/** This structure is only current as of the last call to SDL_CDStatus() */ +typedef struct SDL_CD { + int id; /**< Private drive identifier */ + CDstatus status; /**< Current drive status */ + + /** The rest of this structure is only valid if there's a CD in drive */ + /*@{*/ + int numtracks; /**< Number of tracks on disk */ + int cur_track; /**< Current track position */ + int cur_frame; /**< Current frame offset within current track */ + SDL_CDtrack track[SDL_MAX_TRACKS+1]; + /*@}*/ +} SDL_CD; + +/** @name Frames / MSF Conversion Functions + * Conversion functions from frames to Minute/Second/Frames and vice versa + */ +/*@{*/ +#define CD_FPS 75 +#define FRAMES_TO_MSF(f, M,S,F) { \ + int value = f; \ + *(F) = value%CD_FPS; \ + value /= CD_FPS; \ + *(S) = value%60; \ + value /= 60; \ + *(M) = value; \ +} +#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) +/*@}*/ + +/* CD-audio API functions: */ + +/** + * Returns the number of CD-ROM drives on the system, or -1 if + * SDL_Init() has not been called with the SDL_INIT_CDROM flag. + */ +extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); + +/** + * Returns a human-readable, system-dependent identifier for the CD-ROM. + * Example: + * - "/dev/cdrom" + * - "E:" + * - "/dev/disk/ide/1/master" + */ +extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); + +/** + * Opens a CD-ROM drive for access. It returns a drive handle on success, + * or NULL if the drive was invalid or busy. This newly opened CD-ROM + * becomes the default CD used when other CD functions are passed a NULL + * CD-ROM handle. + * Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. + */ +extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); + +/** + * This function returns the current status of the given drive. + * If the drive has a CD in it, the table of contents of the CD and current + * play position of the CD will be stored in the SDL_CD structure. + */ +extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); + +/** + * Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' + * tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play + * until the end of the CD. This function will skip data tracks. + * This function should only be called after calling SDL_CDStatus() to + * get track information about the CD. + * For example: + * @code + * // Play entire CD: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + * SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); + * // Play last track: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { + * SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); + * } + * // Play first and second track and 10 seconds of third track: + * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) + * SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); + * @endcode + * + * @return This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, + int start_track, int start_frame, int ntracks, int nframes); + +/** + * Play the given CD starting at 'start' frame for 'length' frames. + * @return It returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); + +/** Pause play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); + +/** Resume play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); + +/** Stop play + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); + +/** Eject CD-ROM + * @return returns 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); + +/** Closes the handle for the CD-ROM drive */ +extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config.h b/codemp/rd-rend2/SDL/SDL_config.h new file mode 100644 index 0000000000..a50810169c --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config.h @@ -0,0 +1,45 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +#include "SDL_platform.h" + +/* Add any platform that doesn't build using the configure system */ +#if defined(__DREAMCAST__) +#include "SDL_config_dreamcast.h" +#elif defined(__MACOS__) +#include "SDL_config_macos.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__SYMBIAN32__) +#include "SDL_config_symbian.h" /* must be before win32! */ +#elif defined(__WIN32__) +#include "SDL_config_win32.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" +#else +#include "SDL_config_minimal.h" +#endif /* platform config */ + +#endif /* _SDL_config_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_amiga.h b/codemp/rd-rend2/SDL/SDL_config_amiga.h new file mode 100644 index 0000000000..23e0861928 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_amiga.h @@ -0,0 +1,80 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_amiga_h +#define _SDL_config_amiga_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_AHI 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_DUMMY 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_AMIGA 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DUMMY 1 + +/* Enable various threading systems */ +#define SDL_THREAD_AMIGA 1 + +/* Enable various timer systems */ +#define SDL_TIMER_AMIGA 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 + +#endif /* _SDL_config_amiga_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_dreamcast.h b/codemp/rd-rend2/SDL/SDL_config_dreamcast.h new file mode 100644 index 0000000000..fb03098e72 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_dreamcast.h @@ -0,0 +1,106 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_dreamcast_h +#define _SDL_config_dreamcast_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +typedef unsigned long uintptr_t; +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRDUP 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DC 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_DC 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_DC 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_DUMMY 1 + +/* Enable various threading systems */ +#define SDL_THREAD_DC 1 + +/* Enable various timer systems */ +#define SDL_TIMER_DC 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DC 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_dreamcast_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_macos.h b/codemp/rd-rend2/SDL/SDL_config_macos.h new file mode 100644 index 0000000000..4fe1715aa1 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_macos.h @@ -0,0 +1,112 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_macos_h +#define _SDL_config_macos_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#include + +typedef SInt8 int8_t; +typedef UInt8 uint8_t; +typedef SInt16 int16_t; +typedef UInt16 uint16_t; +typedef SInt32 int32_t; +typedef UInt32 uint32_t; +typedef SInt64 int64_t; +typedef UInt64 uint64_t; +typedef unsigned long uintptr_t; + +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_SSCANF 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_SNDMGR 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#if TARGET_API_MAC_CARBON +#define SDL_CDROM_DUMMY 1 +#else +#define SDL_CDROM_MACOS 1 +#endif + +/* Enable various input drivers */ +#if TARGET_API_MAC_CARBON +#define SDL_JOYSTICK_DUMMY 1 +#else +#define SDL_JOYSTICK_MACOS 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_MACOS 1 + +/* Enable various threading systems */ +#define SDL_THREADS_DISABLED 1 + +/* Enable various timer systems */ +#define SDL_TIMER_MACOS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1 +#define SDL_VIDEO_DRIVER_TOOLBOX 1 + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 + +#endif /* _SDL_config_macos_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_macosx.h b/codemp/rd-rend2/SDL/SDL_config_macosx.h new file mode 100644 index 0000000000..84be61777c --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_macosx.h @@ -0,0 +1,150 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_macosx_h +#define _SDL_config_macosx_h + +#include "SDL_platform.h" + +/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ +#include + +/* This is a set of defines to configure the SDL features */ + +#define SDL_HAS_64BIT_TYPE 1 + +/* Useful headers */ +/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ +#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) +#define HAVE_ALLOCA_H 1 +#endif +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SIGACTION 1 +#define HAVE_SETJMP 1 +#define HAVE_NANOSLEEP 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_COREAUDIO 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_MACOSX 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_IOKIT 1 + +/* Enable various shared object loading systems */ +#ifdef __ppc__ +/* For Mac OS X 10.2 compatibility */ +#define SDL_LOADSO_DLCOMPAT 1 +#else +#define SDL_LOADSO_DLOPEN 1 +#endif + +/* Enable various threading systems */ +#define SDL_THREAD_PTHREAD 1 +#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 + +/* Enable various timer systems */ +#define SDL_TIMER_UNIX 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#if ((defined TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON)) +#define SDL_VIDEO_DRIVER_TOOLBOX 1 +#else +#define SDL_VIDEO_DRIVER_QUARTZ 1 +#endif +#define SDL_VIDEO_DRIVER_DGA 1 +#define SDL_VIDEO_DRIVER_X11 1 +#define SDL_VIDEO_DRIVER_X11_DGAMOUSE 1 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "/usr/X11R6/lib/libXrender.1.dylib" +#define SDL_VIDEO_DRIVER_X11_VIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 +#define SDL_VIDEO_DRIVER_X11_XME 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XV 1 + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL_GLX 1 + +/* Disable screensaver */ +#define SDL_VIDEO_DISABLE_SCREENSAVER 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef __ppc__ +#define SDL_ALTIVEC_BLITTERS 1 +#endif + +#endif /* _SDL_config_macosx_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_minimal.h b/codemp/rd-rend2/SDL/SDL_config_minimal.h new file mode 100644 index 0000000000..a08e190e2b --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_minimal.h @@ -0,0 +1,66 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_minimal_h +#define _SDL_config_minimal_h + +#include "SDL_platform.h" + +/* This is the minimal configuration that can be used to build SDL */ + +#include +#include +#include + +#if 0 +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int size_t; +typedef unsigned long uintptr_t; +#endif + +/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable the stub timer support (src/timer/dummy/\*.c) */ +#define SDL_TIMERS_DISABLED 1 + +/* Enable the dummy video driver (src/video/dummy/\*.c) */ +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_minimal_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_nds.h b/codemp/rd-rend2/SDL/SDL_config_nds.h new file mode 100644 index 0000000000..cb4d61f692 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_nds.h @@ -0,0 +1,115 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_nds_h +#define _SDL_config_nds_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* C datatypes */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Endianness */ +#define SDL_BYTEORDER 1234 + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_STRING_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_NDS 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_NDS 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +/* Enable the stub thread support (src/thread/generic/\*.c) */ +#define SDL_THREADS_DISABLED 1 + +/* Enable various timer systems */ +#define SDL_TIMER_NDS 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_NDS 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +#endif /* _SDL_config_nds_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_os2.h b/codemp/rd-rend2/SDL/SDL_config_os2.h new file mode 100644 index 0000000000..42edd20e89 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_os2.h @@ -0,0 +1,141 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_os2_h +#define _SDL_config_os2_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef unsigned int size_t; +typedef unsigned long uintptr_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; + +#define SDL_HAS_64BIT_TYPE 1 + +/* Use Watcom's LIBC */ +#define HAVE_LIBC 1 + +/* Useful headers */ +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_SIGNAL_H 1 + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__UITOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE__I64TOA 1 +#define HAVE__UI64TOA 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 +#define HAVE_CLOCK_GETTIME 1 + +/* Enable various audio drivers */ +#define SDL_AUDIO_DRIVER_DART 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#define SDL_CDROM_OS2 1 + +/* Enable various input drivers */ +#define SDL_JOYSTICK_OS2 1 + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_OS2 1 + +/* Enable various threading systems */ +#define SDL_THREAD_OS2 1 + +/* Enable various timer systems */ +#define SDL_TIMER_OS2 1 + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_OS2FS 1 + +/* Enable OpenGL support */ +/* Nothing here yet for OS/2... :( */ + +/* Enable assembly routines where available */ +#define SDL_ASSEMBLY_ROUTINES 1 + +#endif /* _SDL_config_os2_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_symbian.h b/codemp/rd-rend2/SDL/SDL_config_symbian.h new file mode 100644 index 0000000000..e917ac6e7d --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_symbian.h @@ -0,0 +1,146 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* + +Symbian version Markus Mertama + +*/ + + +#ifndef _SDL_CONFIG_SYMBIAN_H +#define _SDL_CONFIG_SYMBIAN_H + +#include "SDL_platform.h" + +/* This is the minimal configuration that can be used to build SDL */ + + +#include +#include + + +#ifdef __GCCE__ +#define SYMBIAN32_GCCE +#endif + +#ifndef _SIZE_T_DEFINED +typedef unsigned int size_t; +#endif + +#ifndef _INTPTR_T_DECLARED +typedef unsigned int uintptr_t; +#endif + +#ifndef _INT8_T_DECLARED +typedef signed char int8_t; +#endif + +#ifndef _UINT8_T_DECLARED +typedef unsigned char uint8_t; +#endif + +#ifndef _INT16_T_DECLARED +typedef signed short int16_t; +#endif + +#ifndef _UINT16_T_DECLARED +typedef unsigned short uint16_t; +#endif + +#ifndef _INT32_T_DECLARED +typedef signed int int32_t; +#endif + +#ifndef _UINT32_T_DECLARED +typedef unsigned int uint32_t; +#endif + +#ifndef _INT64_T_DECLARED +typedef signed long long int64_t; +#endif + +#ifndef _UINT64_T_DECLARED +typedef unsigned long long uint64_t; +#endif + +#define SDL_AUDIO_DRIVER_EPOCAUDIO 1 + + +/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ +#define SDL_CDROM_DISABLED 1 + +/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ +#define SDL_JOYSTICK_DISABLED 1 + +/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ +#define SDL_LOADSO_DISABLED 1 + +#define SDL_THREAD_SYMBIAN 1 + +#define SDL_VIDEO_DRIVER_EPOC 1 + +#define SDL_VIDEO_OPENGL 0 + +#define SDL_HAS_64BIT_TYPE 1 + +#define HAVE_LIBC 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 + +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +/*#define HAVE_ALLOCA 1*/ +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRUPR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +/*#define HAVE__STRICMP 1*/ +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 + + + +#endif /* _SDL_CONFIG_SYMBIAN_H */ diff --git a/codemp/rd-rend2/SDL/SDL_config_win32.h b/codemp/rd-rend2/SDL/SDL_config_win32.h new file mode 100644 index 0000000000..da2c15dd7e --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_config_win32.h @@ -0,0 +1,183 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_win32_h +#define _SDL_config_win32_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if defined(__GNUC__) || defined(__DMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Enabled for SDL 1.2 (binary compatibility) */ +#define HAVE_LIBC 1 +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#ifndef _WIN32_WCE +#define HAVE_SIGNAL_H 1 +#endif + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#ifndef _WIN32_WCE +#define SDL_AUDIO_DRIVER_DSOUND 1 +#endif +#define SDL_AUDIO_DRIVER_WAVEOUT 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various cdrom drivers */ +#ifdef _WIN32_WCE +#define SDL_CDROM_DISABLED 1 +#else +#define SDL_CDROM_WIN32 1 +#endif + +/* Enable various input drivers */ +#ifdef _WIN32_WCE +#define SDL_JOYSTICK_DISABLED 1 +#else +#define SDL_JOYSTICK_WINMM 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WIN32 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WIN32 1 + +/* Enable various timer systems */ +#ifdef _WIN32_WCE +#define SDL_TIMER_WINCE 1 +#else +#define SDL_TIMER_WIN32 1 +#endif + +/* Enable various video drivers */ +#ifdef _WIN32_WCE +#define SDL_VIDEO_DRIVER_GAPI 1 +#endif +#ifndef _WIN32_WCE +#define SDL_VIDEO_DRIVER_DDRAW 1 +#endif +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDIB 1 + +/* Enable OpenGL support */ +#ifndef _WIN32_WCE +#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL_WGL 1 +#endif + +/* Disable screensaver */ +#define SDL_VIDEO_DISABLE_SCREENSAVER 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_win32_h */ diff --git a/codemp/rd-rend2/SDL/SDL_copying.h b/codemp/rd-rend2/SDL/SDL_copying.h new file mode 100644 index 0000000000..b5b64f2994 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_copying.h @@ -0,0 +1,22 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + diff --git a/codemp/rd-rend2/SDL/SDL_cpuinfo.h b/codemp/rd-rend2/SDL/SDL_cpuinfo.h new file mode 100644 index 0000000000..4200d6d170 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_cpuinfo.h @@ -0,0 +1,69 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_cpuinfo.h + * CPU feature detection for SDL + */ + +#ifndef _SDL_cpuinfo_h +#define _SDL_cpuinfo_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This function returns true if the CPU has the RDTSC instruction */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); + +/** This function returns true if the CPU has MMX features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); + +/** This function returns true if the CPU has MMX Ext. features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); + +/** This function returns true if the CPU has 3DNow features */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); + +/** This function returns true if the CPU has 3DNow! Ext. features */ +extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); + +/** This function returns true if the CPU has SSE features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); + +/** This function returns true if the CPU has SSE2 features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); + +/** This function returns true if the CPU has AltiVec features */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_cpuinfo_h */ diff --git a/codemp/rd-rend2/SDL/SDL_endian.h b/codemp/rd-rend2/SDL/SDL_endian.h new file mode 100644 index 0000000000..068da918f4 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_endian.h @@ -0,0 +1,214 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_endian.h + * Functions for reading and writing endian-specific values + */ + +#ifndef _SDL_endian_h +#define _SDL_endian_h + +#include "SDL_stdinc.h" + +/** @name SDL_ENDIANs + * The two types of endianness + */ +/*@{*/ +#define SDL_LIL_ENDIAN 1234 +#define SDL_BIG_ENDIAN 4321 +/*@}*/ + +#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ +#ifdef __linux__ +#include +#define SDL_BYTEORDER __BYTE_ORDER +#else /* __linux __ */ +#if defined(__hppa__) || \ + defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ + (defined(__MIPS__) && defined(__MISPEB__)) || \ + defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ + defined(__sparc__) +#define SDL_BYTEORDER SDL_BIG_ENDIAN +#else +#define SDL_BYTEORDER SDL_LIL_ENDIAN +#endif +#endif /* __linux __ */ +#endif /* !SDL_BYTEORDER */ + + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name SDL_Swap Functions + * Use inline functions for compilers that support them, and static + * functions for those that do not. Because these functions become + * static for compilers that do not support inline functions, this + * header should only be included in files that actually use them. + */ +/*@{*/ +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + int result; + + __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); + return (Uint16)result; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) +static __inline__ Uint16 SDL_Swap16(Uint16 x) +{ + __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint16 SDL_Swap16(Uint16 x) { + return SDL_static_cast(Uint16, ((x<<8)|(x>>8))); +} +#endif + +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswap %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("bswapl %0" : "=r" (x) : "0" (x)); + return x; +} +#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + Uint32 result; + + __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); + __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); + __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); + return result; +} +#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) +static __inline__ Uint32 SDL_Swap32(Uint32 x) +{ + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); + return x; +} +#else +static __inline__ Uint32 SDL_Swap32(Uint32 x) { + return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24))); +} +#endif + +#ifdef SDL_HAS_64BIT_TYPE +#if defined(__GNUC__) && defined(__i386__) && \ + !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + union { + struct { Uint32 a,b; } s; + Uint64 u; + } v; + v.u = x; + __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" + : "=r" (v.s.a), "=r" (v.s.b) + : "0" (v.s.a), "1" (v.s.b)); + return v.u; +} +#elif defined(__GNUC__) && defined(__x86_64__) +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + __asm__("bswapq %0" : "=r" (x) : "0" (x)); + return x; +} +#else +static __inline__ Uint64 SDL_Swap64(Uint64 x) +{ + Uint32 hi, lo; + + /* Separate into high and low 32-bit values and swap them */ + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x >>= 32; + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); + x = SDL_Swap32(lo); + x <<= 32; + x |= SDL_Swap32(hi); + return (x); +} +#endif +#else +/* This is mainly to keep compilers from complaining in SDL code. + * If there is no real 64-bit datatype, then compilers will complain about + * the fake 64-bit datatype that SDL provides when it compiles user code. + */ +#define SDL_Swap64(X) (X) +#endif /* SDL_HAS_64BIT_TYPE */ +/*@}*/ + +/** + * @name SDL_SwapLE and SDL_SwapBE Functions + * Byteswap item from the specified endianness to the native endianness + */ +/*@{*/ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define SDL_SwapLE16(X) (X) +#define SDL_SwapLE32(X) (X) +#define SDL_SwapLE64(X) (X) +#define SDL_SwapBE16(X) SDL_Swap16(X) +#define SDL_SwapBE32(X) SDL_Swap32(X) +#define SDL_SwapBE64(X) SDL_Swap64(X) +#else +#define SDL_SwapLE16(X) SDL_Swap16(X) +#define SDL_SwapLE32(X) SDL_Swap32(X) +#define SDL_SwapLE64(X) SDL_Swap64(X) +#define SDL_SwapBE16(X) (X) +#define SDL_SwapBE32(X) (X) +#define SDL_SwapBE64(X) (X) +#endif +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_endian_h */ diff --git a/codemp/rd-rend2/SDL/SDL_error.h b/codemp/rd-rend2/SDL/SDL_error.h new file mode 100644 index 0000000000..4e1cce3b17 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_error.h @@ -0,0 +1,72 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_error.h + * Simple error message routines for SDL + */ + +#ifndef _SDL_error_h +#define _SDL_error_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Public functions + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); +extern DECLSPEC char * SDLCALL SDL_GetError(void); +extern DECLSPEC void SDLCALL SDL_ClearError(void); +/*@}*/ + +/** + * @name Private functions + * @internal Private error message function - used internally + */ +/*@{*/ +#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) +#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) +typedef enum { + SDL_ENOMEM, + SDL_EFREAD, + SDL_EFWRITE, + SDL_EFSEEK, + SDL_UNSUPPORTED, + SDL_LASTERROR +} SDL_errorcode; +extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_error_h */ diff --git a/codemp/rd-rend2/SDL/SDL_events.h b/codemp/rd-rend2/SDL/SDL_events.h new file mode 100644 index 0000000000..94b4202518 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_events.h @@ -0,0 +1,356 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file SDL_events.h + * Include file for SDL event handling + */ + +#ifndef _SDL_events_h +#define _SDL_events_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_active.h" +#include "SDL_keyboard.h" +#include "SDL_mouse.h" +#include "SDL_joystick.h" +#include "SDL_quit.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name General keyboard/mouse state definitions */ +/*@{*/ +#define SDL_RELEASED 0 +#define SDL_PRESSED 1 +/*@}*/ + +/** Event enumerations */ +typedef enum { + SDL_NOEVENT = 0, /**< Unused (do not remove) */ + SDL_ACTIVEEVENT, /**< Application loses/gains visibility */ + SDL_KEYDOWN, /**< Keys pressed */ + SDL_KEYUP, /**< Keys released */ + SDL_MOUSEMOTION, /**< Mouse moved */ + SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ + SDL_MOUSEBUTTONUP, /**< Mouse button released */ + SDL_JOYAXISMOTION, /**< Joystick axis motion */ + SDL_JOYBALLMOTION, /**< Joystick trackball motion */ + SDL_JOYHATMOTION, /**< Joystick hat position change */ + SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ + SDL_JOYBUTTONUP, /**< Joystick button released */ + SDL_QUIT, /**< User-requested quit */ + SDL_SYSWMEVENT, /**< System specific event */ + SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */ + SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */ + SDL_VIDEORESIZE, /**< User resized video mode */ + SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */ + SDL_EVENT_RESERVED2, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED3, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED4, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED5, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED6, /**< Reserved for future use.. */ + SDL_EVENT_RESERVED7, /**< Reserved for future use.. */ + /** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ + SDL_USEREVENT = 24, + /** This last event is only for bounding internal arrays + * It is the number of bits in the event mask datatype -- Uint32 + */ + SDL_NUMEVENTS = 32 +} SDL_EventType; + +/** @name Predefined event masks */ +/*@{*/ +#define SDL_EVENTMASK(X) (1<<(X)) +typedef enum { + SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), + SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), + SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), + SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| + SDL_EVENTMASK(SDL_KEYUP), + SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), + SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), + SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| + SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| + SDL_EVENTMASK(SDL_MOUSEBUTTONUP), + SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), + SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), + SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), + SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), + SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| + SDL_EVENTMASK(SDL_JOYBALLMOTION)| + SDL_EVENTMASK(SDL_JOYHATMOTION)| + SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| + SDL_EVENTMASK(SDL_JOYBUTTONUP), + SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), + SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), + SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), + SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) +} SDL_EventMask ; +#define SDL_ALLEVENTS 0xFFFFFFFF +/*@}*/ + +/** Application visibility event structure */ +typedef struct SDL_ActiveEvent { + Uint8 type; /**< SDL_ACTIVEEVENT */ + Uint8 gain; /**< Whether given states were gained or lost (1/0) */ + Uint8 state; /**< A mask of the focus states */ +} SDL_ActiveEvent; + +/** Keyboard event structure */ +typedef struct SDL_KeyboardEvent { + Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ + Uint8 which; /**< The keyboard device index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ + SDL_keysym keysym; +} SDL_KeyboardEvent; + +/** Mouse motion event structure */ +typedef struct SDL_MouseMotionEvent { + Uint8 type; /**< SDL_MOUSEMOTION */ + Uint8 which; /**< The mouse device index */ + Uint8 state; /**< The current button state */ + Uint16 x, y; /**< The X/Y coordinates of the mouse */ + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_MouseMotionEvent; + +/** Mouse button event structure */ +typedef struct SDL_MouseButtonEvent { + Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ + Uint8 which; /**< The mouse device index */ + Uint8 button; /**< The mouse button index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ + Uint16 x, y; /**< The X/Y coordinates of the mouse at press time */ +} SDL_MouseButtonEvent; + +/** Joystick axis motion event structure */ +typedef struct SDL_JoyAxisEvent { + Uint8 type; /**< SDL_JOYAXISMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 axis; /**< The joystick axis index */ + Sint16 value; /**< The axis value (range: -32768 to 32767) */ +} SDL_JoyAxisEvent; + +/** Joystick trackball motion event structure */ +typedef struct SDL_JoyBallEvent { + Uint8 type; /**< SDL_JOYBALLMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 ball; /**< The joystick trackball index */ + Sint16 xrel; /**< The relative motion in the X direction */ + Sint16 yrel; /**< The relative motion in the Y direction */ +} SDL_JoyBallEvent; + +/** Joystick hat position change event structure */ +typedef struct SDL_JoyHatEvent { + Uint8 type; /**< SDL_JOYHATMOTION */ + Uint8 which; /**< The joystick device index */ + Uint8 hat; /**< The joystick hat index */ + Uint8 value; /**< The hat position value: + * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP + * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT + * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN + * Note that zero means the POV is centered. + */ +} SDL_JoyHatEvent; + +/** Joystick button event structure */ +typedef struct SDL_JoyButtonEvent { + Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ + Uint8 which; /**< The joystick device index */ + Uint8 button; /**< The joystick button index */ + Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ +} SDL_JoyButtonEvent; + +/** The "window resized" event + * When you get this event, you are responsible for setting a new video + * mode with the new width and height. + */ +typedef struct SDL_ResizeEvent { + Uint8 type; /**< SDL_VIDEORESIZE */ + int w; /**< New width */ + int h; /**< New height */ +} SDL_ResizeEvent; + +/** The "screen redraw" event */ +typedef struct SDL_ExposeEvent { + Uint8 type; /**< SDL_VIDEOEXPOSE */ +} SDL_ExposeEvent; + +/** The "quit requested" event */ +typedef struct SDL_QuitEvent { + Uint8 type; /**< SDL_QUIT */ +} SDL_QuitEvent; + +/** A user-defined event type */ +typedef struct SDL_UserEvent { + Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ + int code; /**< User defined event code */ + void *data1; /**< User defined data pointer */ + void *data2; /**< User defined data pointer */ +} SDL_UserEvent; + +/** If you want to use this event, you should include SDL_syswm.h */ +struct SDL_SysWMmsg; +typedef struct SDL_SysWMmsg SDL_SysWMmsg; +typedef struct SDL_SysWMEvent { + Uint8 type; + SDL_SysWMmsg *msg; +} SDL_SysWMEvent; + +/** General event structure */ +typedef union SDL_Event { + Uint8 type; + SDL_ActiveEvent active; + SDL_KeyboardEvent key; + SDL_MouseMotionEvent motion; + SDL_MouseButtonEvent button; + SDL_JoyAxisEvent jaxis; + SDL_JoyBallEvent jball; + SDL_JoyHatEvent jhat; + SDL_JoyButtonEvent jbutton; + SDL_ResizeEvent resize; + SDL_ExposeEvent expose; + SDL_QuitEvent quit; + SDL_UserEvent user; + SDL_SysWMEvent syswm; +} SDL_Event; + + +/* Function prototypes */ + +/** Pumps the event loop, gathering events from the input devices. + * This function updates the event queue and internal input device state. + * This should only be run in the thread that sets the video mode. + */ +extern DECLSPEC void SDLCALL SDL_PumpEvents(void); + +typedef enum { + SDL_ADDEVENT, + SDL_PEEKEVENT, + SDL_GETEVENT +} SDL_eventaction; + +/** + * Checks the event queue for messages and optionally returns them. + * + * If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to + * the back of the event queue. + * If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front + * of the event queue, matching 'mask', will be returned and will not + * be removed from the queue. + * If 'action' is SDL_GETEVENT, up to 'numevents' events at the front + * of the event queue, matching 'mask', will be returned and will be + * removed from the queue. + * + * @return + * This function returns the number of events actually stored, or -1 + * if there was an error. + * + * This function is thread-safe. + */ +extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, + SDL_eventaction action, Uint32 mask); + +/** Polls for currently pending events, and returns 1 if there are any pending + * events, or 0 if there are none available. If 'event' is not NULL, the next + * event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); + +/** Waits indefinitely for the next available event, returning 1, or 0 if there + * was an error while waiting for events. If 'event' is not NULL, the next + * event is removed from the queue and stored in that area. + */ +extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); + +/** Add an event to the event queue. + * This function returns 0 on success, or -1 if the event queue was full + * or there was some other error. + */ +extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); + +/** @name Event Filtering */ +/*@{*/ +typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); +/** + * This function sets up a filter to process all events before they + * change internal state and are posted to the internal event queue. + * + * The filter is protypted as: + * @code typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); @endcode + * + * If the filter returns 1, then the event will be added to the internal queue. + * If it returns 0, then the event will be dropped from the queue, but the + * internal state will still be updated. This allows selective filtering of + * dynamically arriving events. + * + * @warning Be very careful of what you do in the event filter function, as + * it may run in a different thread! + * + * There is one caveat when dealing with the SDL_QUITEVENT event type. The + * event filter is only called when the window manager desires to close the + * application window. If the event filter returns 1, then the window will + * be closed, otherwise the window will remain open if possible. + * If the quit event is generated by an interrupt signal, it will bypass the + * internal queue and be delivered to the application at the next event poll. + */ +extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); + +/** + * Return the current event filter - can be used to "chain" filters. + * If there is no event filter set, this function returns NULL. + */ +extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); +/*@}*/ + +/** @name Event State */ +/*@{*/ +#define SDL_QUERY -1 +#define SDL_IGNORE 0 +#define SDL_DISABLE 0 +#define SDL_ENABLE 1 +/*@}*/ + +/** +* This function allows you to set the state of processing certain events. +* If 'state' is set to SDL_IGNORE, that event will be automatically dropped +* from the event queue and will not event be filtered. +* If 'state' is set to SDL_ENABLE, that event will be processed normally. +* If 'state' is set to SDL_QUERY, SDL_EventState() will return the +* current processing state of the specified event. +*/ +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_events_h */ diff --git a/codemp/rd-rend2/SDL/SDL_getenv.h b/codemp/rd-rend2/SDL/SDL_getenv.h new file mode 100644 index 0000000000..bea630077c --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_getenv.h @@ -0,0 +1,28 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_getenv.h + * @deprecated Use SDL_stdinc.h instead + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/codemp/rd-rend2/SDL/SDL_joystick.h b/codemp/rd-rend2/SDL/SDL_joystick.h new file mode 100644 index 0000000000..708d1a9f09 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_joystick.h @@ -0,0 +1,187 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_joystick.h + * Include file for SDL joystick event handling + */ + +#ifndef _SDL_joystick_h +#define _SDL_joystick_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL_joystick.h + * @note In order to use these functions, SDL_Init() must have been called + * with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system + * for joysticks, and load appropriate drivers. + */ + +/** The joystick structure used to identify an SDL joystick */ +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + +/* Function prototypes */ +/** + * Count the number of joysticks attached to the system + */ +extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); + +/** + * Get the implementation dependent name of a joystick. + * + * This can be called before any joysticks are opened. + * If no name can be found, this function returns NULL. + */ +extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); + +/** + * Open a joystick for use. + * + * @param[in] device_index + * The index passed as an argument refers to + * the N'th joystick on the system. This index is the value which will + * identify this joystick in future joystick events. + * + * @return This function returns a joystick identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); + +/** + * Returns 1 if the joystick has been opened, or 0 if it has not. + */ +extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); + +/** + * Get the device index of an opened joystick. + */ +extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); + +/** + * Get the number of general axis controls on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); + +/** + * Get the number of trackballs on a joystick + * + * Joystick trackballs have only relative motion events associated + * with them and their state cannot be polled. + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); + +/** + * Get the number of POV hats on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); + +/** + * Get the number of buttons on a joystick + */ +extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); + +/** + * Update the current state of the open joysticks. + * + * This is called automatically by the event loop if any joystick + * events are enabled. + */ +extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); + +/** + * Enable/disable joystick event polling. + * + * If joystick events are disabled, you must call SDL_JoystickUpdate() + * yourself and check the state of the joystick when you want joystick + * information. + * + * @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. + */ +extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); + +/** + * Get the current state of an axis control on a joystick + * + * @param[in] axis The axis indices start at index 0. + * + * @return The state is a value ranging from -32768 to 32767. + */ +extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); + +/** + * @name Hat Positions + * The return value of SDL_JoystickGetHat() is one of the following positions: + */ +/*@{*/ +#define SDL_HAT_CENTERED 0x00 +#define SDL_HAT_UP 0x01 +#define SDL_HAT_RIGHT 0x02 +#define SDL_HAT_DOWN 0x04 +#define SDL_HAT_LEFT 0x08 +#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) +#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) +#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) +#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) +/*@}*/ + +/** + * Get the current state of a POV hat on a joystick + * + * @param[in] hat The hat indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); + +/** + * Get the ball axis change since the last poll + * + * @param[in] ball The ball indices start at index 0. + * + * @return This returns 0, or -1 if you passed it invalid parameters. + */ +extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); + +/** + * Get the current state of a button on a joystick + * + * @param[in] button The button indices start at index 0. + */ +extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); + +/** + * Close a joystick previously opened with SDL_JoystickOpen() + */ +extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_joystick_h */ diff --git a/codemp/rd-rend2/SDL/SDL_keyboard.h b/codemp/rd-rend2/SDL/SDL_keyboard.h new file mode 100644 index 0000000000..9d7129c526 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_keyboard.h @@ -0,0 +1,135 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_keyboard.h + * Include file for SDL keyboard event handling + */ + +#ifndef _SDL_keyboard_h +#define _SDL_keyboard_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_keysym.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** Keysym structure + * + * - The scancode is hardware dependent, and should not be used by general + * applications. If no hardware scancode is available, it will be 0. + * + * - The 'unicode' translated character is only available when character + * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, + * this is a UNICODE character corresponding to the keypress. If the + * high 9 bits of the character are 0, then this maps to the equivalent + * ASCII character: + * @code + * char ch; + * if ( (keysym.unicode & 0xFF80) == 0 ) { + * ch = keysym.unicode & 0x7F; + * } else { + * An international character.. + * } + * @endcode + */ +typedef struct SDL_keysym { + Uint8 scancode; /**< hardware specific scancode */ + SDLKey sym; /**< SDL virtual keysym */ + SDLMod mod; /**< current key modifiers */ + Uint16 unicode; /**< translated character */ +} SDL_keysym; + +/** This is the mask which refers to all hotkey bindings */ +#define SDL_ALL_HOTKEYS 0xFFFFFFFF + +/* Function prototypes */ +/** + * Enable/Disable UNICODE translation of keyboard input. + * + * This translation has some overhead, so translation defaults off. + * + * @param[in] enable + * If 'enable' is 1, translation is enabled. + * If 'enable' is 0, translation is disabled. + * If 'enable' is -1, the translation state is not changed. + * + * @return It returns the previous state of keyboard translation. + */ +extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); + +#define SDL_DEFAULT_REPEAT_DELAY 500 +#define SDL_DEFAULT_REPEAT_INTERVAL 30 +/** + * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. + * + * @param[in] delay + * 'delay' is the initial delay in ms between the time when a key is + * pressed, and keyboard repeat begins. + * + * @param[in] interval + * 'interval' is the time in ms between keyboard repeat events. + * + * If 'delay' is set to 0, keyboard repeat is disabled. + */ +extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); +extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); + +/** + * Get a snapshot of the current state of the keyboard. + * Returns an array of keystates, indexed by the SDLK_* syms. + * Usage: + * @code + * Uint8 *keystate = SDL_GetKeyState(NULL); + * if ( keystate[SDLK_RETURN] ) //... \ is pressed. + * @endcode + */ +extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); + +/** + * Get the current key modifier state + */ +extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); + +/** + * Set the current key modifier state. + * This does not change the keyboard state, only the key modifier flags. + */ +extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); + +/** + * Get the name of an SDL virtual keysym + */ +extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_keyboard_h */ diff --git a/codemp/rd-rend2/SDL/SDL_keysym.h b/codemp/rd-rend2/SDL/SDL_keysym.h new file mode 100644 index 0000000000..f2ad12b81e --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_keysym.h @@ -0,0 +1,326 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_keysym_h +#define _SDL_keysym_h + +/** What we really want is a mapping of every raw key on the keyboard. + * To support international keyboards, we use the range 0xA1 - 0xFF + * as international virtual keycodes. We'll follow in the footsteps of X11... + * @brief The names of the keys + */ +typedef enum { + /** @name ASCII mapped keysyms + * The keyboard syms have been cleverly chosen to map to ASCII + */ + /*@{*/ + SDLK_UNKNOWN = 0, + SDLK_FIRST = 0, + SDLK_BACKSPACE = 8, + SDLK_TAB = 9, + SDLK_CLEAR = 12, + SDLK_RETURN = 13, + SDLK_PAUSE = 19, + SDLK_ESCAPE = 27, + SDLK_SPACE = 32, + SDLK_EXCLAIM = 33, + SDLK_QUOTEDBL = 34, + SDLK_HASH = 35, + SDLK_DOLLAR = 36, + SDLK_AMPERSAND = 38, + SDLK_QUOTE = 39, + SDLK_LEFTPAREN = 40, + SDLK_RIGHTPAREN = 41, + SDLK_ASTERISK = 42, + SDLK_PLUS = 43, + SDLK_COMMA = 44, + SDLK_MINUS = 45, + SDLK_PERIOD = 46, + SDLK_SLASH = 47, + SDLK_0 = 48, + SDLK_1 = 49, + SDLK_2 = 50, + SDLK_3 = 51, + SDLK_4 = 52, + SDLK_5 = 53, + SDLK_6 = 54, + SDLK_7 = 55, + SDLK_8 = 56, + SDLK_9 = 57, + SDLK_COLON = 58, + SDLK_SEMICOLON = 59, + SDLK_LESS = 60, + SDLK_EQUALS = 61, + SDLK_GREATER = 62, + SDLK_QUESTION = 63, + SDLK_AT = 64, + /* + Skip uppercase letters + */ + SDLK_LEFTBRACKET = 91, + SDLK_BACKSLASH = 92, + SDLK_RIGHTBRACKET = 93, + SDLK_CARET = 94, + SDLK_UNDERSCORE = 95, + SDLK_BACKQUOTE = 96, + SDLK_a = 97, + SDLK_b = 98, + SDLK_c = 99, + SDLK_d = 100, + SDLK_e = 101, + SDLK_f = 102, + SDLK_g = 103, + SDLK_h = 104, + SDLK_i = 105, + SDLK_j = 106, + SDLK_k = 107, + SDLK_l = 108, + SDLK_m = 109, + SDLK_n = 110, + SDLK_o = 111, + SDLK_p = 112, + SDLK_q = 113, + SDLK_r = 114, + SDLK_s = 115, + SDLK_t = 116, + SDLK_u = 117, + SDLK_v = 118, + SDLK_w = 119, + SDLK_x = 120, + SDLK_y = 121, + SDLK_z = 122, + SDLK_DELETE = 127, + /* End of ASCII mapped keysyms */ + /*@}*/ + + /** @name International keyboard syms */ + /*@{*/ + SDLK_WORLD_0 = 160, /* 0xA0 */ + SDLK_WORLD_1 = 161, + SDLK_WORLD_2 = 162, + SDLK_WORLD_3 = 163, + SDLK_WORLD_4 = 164, + SDLK_WORLD_5 = 165, + SDLK_WORLD_6 = 166, + SDLK_WORLD_7 = 167, + SDLK_WORLD_8 = 168, + SDLK_WORLD_9 = 169, + SDLK_WORLD_10 = 170, + SDLK_WORLD_11 = 171, + SDLK_WORLD_12 = 172, + SDLK_WORLD_13 = 173, + SDLK_WORLD_14 = 174, + SDLK_WORLD_15 = 175, + SDLK_WORLD_16 = 176, + SDLK_WORLD_17 = 177, + SDLK_WORLD_18 = 178, + SDLK_WORLD_19 = 179, + SDLK_WORLD_20 = 180, + SDLK_WORLD_21 = 181, + SDLK_WORLD_22 = 182, + SDLK_WORLD_23 = 183, + SDLK_WORLD_24 = 184, + SDLK_WORLD_25 = 185, + SDLK_WORLD_26 = 186, + SDLK_WORLD_27 = 187, + SDLK_WORLD_28 = 188, + SDLK_WORLD_29 = 189, + SDLK_WORLD_30 = 190, + SDLK_WORLD_31 = 191, + SDLK_WORLD_32 = 192, + SDLK_WORLD_33 = 193, + SDLK_WORLD_34 = 194, + SDLK_WORLD_35 = 195, + SDLK_WORLD_36 = 196, + SDLK_WORLD_37 = 197, + SDLK_WORLD_38 = 198, + SDLK_WORLD_39 = 199, + SDLK_WORLD_40 = 200, + SDLK_WORLD_41 = 201, + SDLK_WORLD_42 = 202, + SDLK_WORLD_43 = 203, + SDLK_WORLD_44 = 204, + SDLK_WORLD_45 = 205, + SDLK_WORLD_46 = 206, + SDLK_WORLD_47 = 207, + SDLK_WORLD_48 = 208, + SDLK_WORLD_49 = 209, + SDLK_WORLD_50 = 210, + SDLK_WORLD_51 = 211, + SDLK_WORLD_52 = 212, + SDLK_WORLD_53 = 213, + SDLK_WORLD_54 = 214, + SDLK_WORLD_55 = 215, + SDLK_WORLD_56 = 216, + SDLK_WORLD_57 = 217, + SDLK_WORLD_58 = 218, + SDLK_WORLD_59 = 219, + SDLK_WORLD_60 = 220, + SDLK_WORLD_61 = 221, + SDLK_WORLD_62 = 222, + SDLK_WORLD_63 = 223, + SDLK_WORLD_64 = 224, + SDLK_WORLD_65 = 225, + SDLK_WORLD_66 = 226, + SDLK_WORLD_67 = 227, + SDLK_WORLD_68 = 228, + SDLK_WORLD_69 = 229, + SDLK_WORLD_70 = 230, + SDLK_WORLD_71 = 231, + SDLK_WORLD_72 = 232, + SDLK_WORLD_73 = 233, + SDLK_WORLD_74 = 234, + SDLK_WORLD_75 = 235, + SDLK_WORLD_76 = 236, + SDLK_WORLD_77 = 237, + SDLK_WORLD_78 = 238, + SDLK_WORLD_79 = 239, + SDLK_WORLD_80 = 240, + SDLK_WORLD_81 = 241, + SDLK_WORLD_82 = 242, + SDLK_WORLD_83 = 243, + SDLK_WORLD_84 = 244, + SDLK_WORLD_85 = 245, + SDLK_WORLD_86 = 246, + SDLK_WORLD_87 = 247, + SDLK_WORLD_88 = 248, + SDLK_WORLD_89 = 249, + SDLK_WORLD_90 = 250, + SDLK_WORLD_91 = 251, + SDLK_WORLD_92 = 252, + SDLK_WORLD_93 = 253, + SDLK_WORLD_94 = 254, + SDLK_WORLD_95 = 255, /* 0xFF */ + /*@}*/ + + /** @name Numeric keypad */ + /*@{*/ + SDLK_KP0 = 256, + SDLK_KP1 = 257, + SDLK_KP2 = 258, + SDLK_KP3 = 259, + SDLK_KP4 = 260, + SDLK_KP5 = 261, + SDLK_KP6 = 262, + SDLK_KP7 = 263, + SDLK_KP8 = 264, + SDLK_KP9 = 265, + SDLK_KP_PERIOD = 266, + SDLK_KP_DIVIDE = 267, + SDLK_KP_MULTIPLY = 268, + SDLK_KP_MINUS = 269, + SDLK_KP_PLUS = 270, + SDLK_KP_ENTER = 271, + SDLK_KP_EQUALS = 272, + /*@}*/ + + /** @name Arrows + Home/End pad */ + /*@{*/ + SDLK_UP = 273, + SDLK_DOWN = 274, + SDLK_RIGHT = 275, + SDLK_LEFT = 276, + SDLK_INSERT = 277, + SDLK_HOME = 278, + SDLK_END = 279, + SDLK_PAGEUP = 280, + SDLK_PAGEDOWN = 281, + /*@}*/ + + /** @name Function keys */ + /*@{*/ + SDLK_F1 = 282, + SDLK_F2 = 283, + SDLK_F3 = 284, + SDLK_F4 = 285, + SDLK_F5 = 286, + SDLK_F6 = 287, + SDLK_F7 = 288, + SDLK_F8 = 289, + SDLK_F9 = 290, + SDLK_F10 = 291, + SDLK_F11 = 292, + SDLK_F12 = 293, + SDLK_F13 = 294, + SDLK_F14 = 295, + SDLK_F15 = 296, + /*@}*/ + + /** @name Key state modifier keys */ + /*@{*/ + SDLK_NUMLOCK = 300, + SDLK_CAPSLOCK = 301, + SDLK_SCROLLOCK = 302, + SDLK_RSHIFT = 303, + SDLK_LSHIFT = 304, + SDLK_RCTRL = 305, + SDLK_LCTRL = 306, + SDLK_RALT = 307, + SDLK_LALT = 308, + SDLK_RMETA = 309, + SDLK_LMETA = 310, + SDLK_LSUPER = 311, /**< Left "Windows" key */ + SDLK_RSUPER = 312, /**< Right "Windows" key */ + SDLK_MODE = 313, /**< "Alt Gr" key */ + SDLK_COMPOSE = 314, /**< Multi-key compose key */ + /*@}*/ + + /** @name Miscellaneous function keys */ + /*@{*/ + SDLK_HELP = 315, + SDLK_PRINT = 316, + SDLK_SYSREQ = 317, + SDLK_BREAK = 318, + SDLK_MENU = 319, + SDLK_POWER = 320, /**< Power Macintosh power key */ + SDLK_EURO = 321, /**< Some european keyboards */ + SDLK_UNDO = 322, /**< Atari keyboard has Undo */ + /*@}*/ + + /* Add any other keys here */ + + SDLK_LAST +} SDLKey; + +/** Enumeration of valid key mods (possibly OR'd together) */ +typedef enum { + KMOD_NONE = 0x0000, + KMOD_LSHIFT= 0x0001, + KMOD_RSHIFT= 0x0002, + KMOD_LCTRL = 0x0040, + KMOD_RCTRL = 0x0080, + KMOD_LALT = 0x0100, + KMOD_RALT = 0x0200, + KMOD_LMETA = 0x0400, + KMOD_RMETA = 0x0800, + KMOD_NUM = 0x1000, + KMOD_CAPS = 0x2000, + KMOD_MODE = 0x4000, + KMOD_RESERVED = 0x8000 +} SDLMod; + +#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) +#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) +#define KMOD_ALT (KMOD_LALT|KMOD_RALT) +#define KMOD_META (KMOD_LMETA|KMOD_RMETA) + +#endif /* _SDL_keysym_h */ diff --git a/codemp/rd-rend2/SDL/SDL_loadso.h b/codemp/rd-rend2/SDL/SDL_loadso.h new file mode 100644 index 0000000000..0c5e5362de --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_loadso.h @@ -0,0 +1,78 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_loadso.h + * System dependent library loading routines + */ + +/** @file SDL_loadso.h + * Some things to keep in mind: + * - These functions only work on C function names. Other languages may + * have name mangling and intrinsic language support that varies from + * compiler to compiler. + * - Make sure you declare your function pointers with the same calling + * convention as the actual library function. Your code will crash + * mysteriously if you do not do this. + * - Avoid namespace collisions. If you load a symbol from the library, + * it is not defined whether or not it goes into the global symbol + * namespace for the application. If it does and it conflicts with + * symbols in your code or other shared libraries, you will not get + * the results you expect. :) + */ + + +#ifndef _SDL_loadso_h +#define _SDL_loadso_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function dynamically loads a shared object and returns a pointer + * to the object handle (or NULL if there was an error). + * The 'sofile' parameter is a system dependent name of the object file. + */ +extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); + +/** + * Given an object handle, this function looks up the address of the + * named function in the shared object and returns it. This address + * is no longer valid after calling SDL_UnloadObject(). + */ +extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); + +/** Unload a shared object from memory */ +extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_loadso_h */ diff --git a/codemp/rd-rend2/SDL/SDL_main.h b/codemp/rd-rend2/SDL/SDL_main.h new file mode 100644 index 0000000000..ab50ef1e29 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_main.h @@ -0,0 +1,106 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_main_h +#define _SDL_main_h + +#include "SDL_stdinc.h" + +/** @file SDL_main.h + * Redefine main() on Win32 and MacOS so that it is called by winmain.c + */ + +#if defined(__WIN32__) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(__MACOS__) || defined(__MACOSX__) || \ + defined(__SYMBIAN32__) || defined(QWS) + +#ifdef __cplusplus +#define C_LINKAGE "C" +#else +#define C_LINKAGE +#endif /* __cplusplus */ + +/** The application's main() function must be called with C linkage, + * and should be declared like this: + * @code + * #ifdef __cplusplus + * extern "C" + * #endif + * int main(int argc, char *argv[]) + * { + * } + * @endcode + */ +#define main SDL_main + +/** The prototype for the application's main() function */ +extern C_LINKAGE int SDL_main(int argc, char *argv[]); + + +/** @name From the SDL library code -- needed for registering the app on Win32 */ +/*@{*/ +#ifdef __WIN32__ + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** This should be called from your WinMain() function, if any */ +extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); +/** This can also be called, but is no longer necessary */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); +/** This can also be called, but is no longer necessary (SDL_Quit calls it) */ +extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif +/*@}*/ + +/** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ +/*@{*/ +#if defined(__MACOS__) + +#include "begin_code.h" +#ifdef __cplusplus +extern "C" { +#endif + +/** Forward declaration so we don't need to include QuickDraw.h */ +struct QDGlobals; + +/** This should be called from your main() function, if any */ +extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif +/*@}*/ + +#endif /* Need to redefine main()? */ + +#endif /* _SDL_main_h */ diff --git a/codemp/rd-rend2/SDL/SDL_mouse.h b/codemp/rd-rend2/SDL/SDL_mouse.h new file mode 100644 index 0000000000..7c563b94da --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_mouse.h @@ -0,0 +1,143 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_mouse.h + * Include file for SDL mouse event handling + */ + +#ifndef _SDL_mouse_h +#define _SDL_mouse_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct WMcursor WMcursor; /**< Implementation dependent */ +typedef struct SDL_Cursor { + SDL_Rect area; /**< The area of the mouse cursor */ + Sint16 hot_x, hot_y; /**< The "tip" of the cursor */ + Uint8 *data; /**< B/W cursor data */ + Uint8 *mask; /**< B/W cursor mask */ + Uint8 *save[2]; /**< Place to save cursor area */ + WMcursor *wm_cursor; /**< Window-manager cursor */ +} SDL_Cursor; + +/* Function prototypes */ +/** + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * current mouse cursor position. You can pass NULL for either x or y. + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); + +/** + * Retrieve the current state of the mouse. + * The current button state is returned as a button bitmask, which can + * be tested using the SDL_BUTTON(X) macros, and x and y are set to the + * mouse deltas since the last call to SDL_GetRelativeMouseState(). + */ +extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); + +/** + * Set the position of the mouse cursor (generates a mouse motion event) + */ +extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); + +/** + * Create a cursor using the specified data and mask (in MSB format). + * The cursor width must be a multiple of 8 bits. + * + * The cursor is created in black and white according to the following: + * data mask resulting pixel on screen + * 0 1 White + * 1 1 Black + * 0 0 Transparent + * 1 0 Inverted color if possible, black if not. + * + * Cursors created with this function must be freed with SDL_FreeCursor(). + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor + (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); + +/** + * Set the currently active cursor to the specified one. + * If the cursor is currently visible, the change will be immediately + * represented on the display. + */ +extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); + +/** + * Returns the currently active cursor. + */ +extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); + +/** + * Deallocates a cursor created with SDL_CreateCursor(). + */ +extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); + +/** + * Toggle whether or not the cursor is shown on the screen. + * The cursor start off displayed, but can be turned off. + * SDL_ShowCursor() returns 1 if the cursor was being displayed + * before the call, or 0 if it was not. You can query the current + * state by passing a 'toggle' value of -1. + */ +extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); + +/*@{*/ +/** Used as a mask when testing buttons in buttonstate + * Button 1: Left mouse button + * Button 2: Middle mouse button + * Button 3: Right mouse button + * Button 4: Mouse wheel up (may also be a real button) + * Button 5: Mouse wheel down (may also be a real button) + */ +#define SDL_BUTTON(X) (1 << ((X)-1)) +#define SDL_BUTTON_LEFT 1 +#define SDL_BUTTON_MIDDLE 2 +#define SDL_BUTTON_RIGHT 3 +#define SDL_BUTTON_WHEELUP 4 +#define SDL_BUTTON_WHEELDOWN 5 +#define SDL_BUTTON_X1 6 +#define SDL_BUTTON_X2 7 +#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) +#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) +#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) +#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) +#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mouse_h */ diff --git a/codemp/rd-rend2/SDL/SDL_mutex.h b/codemp/rd-rend2/SDL/SDL_mutex.h new file mode 100644 index 0000000000..c8da9b1a00 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_mutex.h @@ -0,0 +1,177 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_mutex_h +#define _SDL_mutex_h + +/** @file SDL_mutex.h + * Functions to provide thread synchronization primitives + * + * @note These are independent of the other SDL routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** Synchronization functions which can time out return this value + * if they time out. + */ +#define SDL_MUTEX_TIMEDOUT 1 + +/** This is the timeout value which corresponds to never time out */ +#define SDL_MUTEX_MAXWAIT (~(Uint32)0) + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Mutex functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** The SDL mutex structure, defined in SDL_mutex.c */ +struct SDL_mutex; +typedef struct SDL_mutex SDL_mutex; + +/** Create a mutex, initialized unlocked */ +extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); + +#define SDL_LockMutex(m) SDL_mutexP(m) +/** Lock the mutex + * @return 0, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); + +#define SDL_UnlockMutex(m) SDL_mutexV(m) +/** Unlock the mutex + * @return 0, or -1 on error + * + * It is an error to unlock a mutex that has not been locked by + * the current thread, and doing so results in undefined behavior. + */ +extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); + +/** Destroy a mutex */ +extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Semaphore functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** The SDL semaphore structure, defined in SDL_sem.c */ +struct SDL_semaphore; +typedef struct SDL_semaphore SDL_sem; + +/** Create a semaphore, initialized with value, returns NULL on failure. */ +extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); + +/** Destroy a semaphore */ +extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); + +/** + * This function suspends the calling thread until the semaphore pointed + * to by sem has a positive count. It then atomically decreases the semaphore + * count. + */ +extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); + +/** Non-blocking variant of SDL_SemWait(). + * @return 0 if the wait succeeds, + * SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); + +/** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if + * the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in + * the allotted time, and -1 on error. + * + * On some platforms this function is implemented by looping with a delay + * of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); + +/** Atomically increases the semaphore's count (not blocking). + * @return 0, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); + +/** Returns the current count of the semaphore */ +extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Condition_variable_functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*@{*/ +/** The SDL condition variable structure, defined in SDL_cond.c */ +struct SDL_cond; +typedef struct SDL_cond SDL_cond; +/*@}*/ + +/** Create a condition variable */ +extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); + +/** Destroy a condition variable */ +extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); + +/** Restart one of the threads that are waiting on the condition variable, + * @return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); + +/** Restart all threads that are waiting on the condition variable, + * @return 0 or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); + +/** Wait on the condition variable, unlocking the provided mutex. + * The mutex must be locked before entering this function! + * The mutex is re-locked once the condition variable is signaled. + * @return 0 when it is signaled, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); + +/** Waits for at most 'ms' milliseconds, and returns 0 if the condition + * variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not + * signaled in the allotted time, and -1 on error. + * On some platforms this function is implemented by looping with a delay + * of 1 ms, and so should be avoided if possible. + */ +extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); + +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_mutex_h */ + diff --git a/codemp/rd-rend2/SDL/SDL_name.h b/codemp/rd-rend2/SDL/SDL_name.h new file mode 100644 index 0000000000..511619af56 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_name.h @@ -0,0 +1,11 @@ + +#ifndef _SDLname_h_ +#define _SDLname_h_ + +#if defined(__STDC__) || defined(__cplusplus) +#define NeedFunctionPrototypes 1 +#endif + +#define SDL_NAME(X) SDL_##X + +#endif /* _SDLname_h_ */ diff --git a/codemp/rd-rend2/SDL/SDL_opengl.h b/codemp/rd-rend2/SDL/SDL_opengl.h new file mode 100644 index 0000000000..3d791d69b3 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_opengl.h @@ -0,0 +1,6570 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_opengl.h + * This is a simple file to encapsulate the OpenGL API headers + */ + +#include "SDL_config.h" + +#ifdef __WIN32__ +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX /* Don't defined min() and max() */ +#endif +#include +#endif +#ifndef NO_SDL_GLEXT +#define __glext_h_ /* Don't let gl.h include glext.h */ +#endif +#if defined(__MACOSX__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#elif defined(__MACOS__) +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#else +#include /* Header File For The OpenGL Library */ +#include /* Header File For The GLU Library */ +#endif +#ifndef NO_SDL_GLEXT +#undef __glext_h_ +#endif + +/** @name GLext.h + * This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. + * It is included here because glext.h is not available on some systems. + * If you don't want this version included, simply define "NO_SDL_GLEXT" + */ +/*@{*/ +#ifndef NO_SDL_GLEXT +#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** License Applicability. Except to the extent portions of this file are +** made subject to an alternative license as permitted in the SGI Free +** Software License B, Version 1.1 (the "License"), the contents of this +** file are subject only to the provisions of the License. You may not use +** this file except in compliance with the License. You may obtain a copy +** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 +** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: +** +** http://oss.sgi.com/projects/FreeB +** +** Note that, as provided in the License, the Software is distributed on an +** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS +** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND +** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A +** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. +** +** Original Code. The Original Code is: OpenGL Sample Implementation, +** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, +** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. +** Copyright in any portions created by third parties is as indicated +** elsewhere herein. All Rights Reserved. +** +** Additional Notice Provisions: This software was created using the +** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has +** not been independently verified as being compliant with the OpenGL(R) +** version 1.2.1 Specification. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2005/06/20 */ +/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ +#define GL_GLEXT_VERSION 29 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +#ifdef __APPLE__ +typedef long GLintptr; +typedef long GLsizeiptr; +#else +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +#ifdef __APPLE__ +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +#if defined(__APPLE__) +typedef void *GLhandleARB; /* shader object handle */ +#else +typedef unsigned int GLhandleARB; /* shader object handle */ +#endif +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_EXT_color_matrix +#define GL_EXT_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif +#endif /* NO_SDL_GLEXT */ +/*@}*/ diff --git a/codemp/rd-rend2/SDL/SDL_platform.h b/codemp/rd-rend2/SDL/SDL_platform.h new file mode 100644 index 0000000000..48540a85d4 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_platform.h @@ -0,0 +1,110 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_platform.h + * Try to get a standard set of platform defines + */ + +#ifndef _SDL_platform_h +#define _SDL_platform_h + +#if defined(_AIX) +#undef __AIX__ +#define __AIX__ 1 +#endif +#if defined(__BEOS__) +#undef __BEOS__ +#define __BEOS__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) +#undef __BSDI__ +#define __BSDI__ 1 +#endif +#if defined(_arch_dreamcast) +#undef __DREAMCAST__ +#define __DREAMCAST__ 1 +#endif +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +#undef __FREEBSD__ +#define __FREEBSD__ 1 +#endif +#if defined(__HAIKU__) +#undef __HAIKU__ +#define __HAIKU__ 1 +#endif +#if defined(hpux) || defined(__hpux) || defined(__hpux__) +#undef __HPUX__ +#define __HPUX__ 1 +#endif +#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) +#undef __IRIX__ +#define __IRIX__ 1 +#endif +#if defined(linux) || defined(__linux) || defined(__linux__) +#undef __LINUX__ +#define __LINUX__ 1 +#endif +#if defined(__APPLE__) +#undef __MACOSX__ +#define __MACOSX__ 1 +#elif defined(macintosh) +#undef __MACOS__ +#define __MACOS__ 1 +#endif +#if defined(__NetBSD__) +#undef __NETBSD__ +#define __NETBSD__ 1 +#endif +#if defined(__OpenBSD__) +#undef __OPENBSD__ +#define __OPENBSD__ 1 +#endif +#if defined(__OS2__) +#undef __OS2__ +#define __OS2__ 1 +#endif +#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) +#undef __OSF__ +#define __OSF__ 1 +#endif +#if defined(__QNXNTO__) +#undef __QNXNTO__ +#define __QNXNTO__ 1 +#endif +#if defined(riscos) || defined(__riscos) || defined(__riscos__) +#undef __RISCOS__ +#define __RISCOS__ 1 +#endif +#if defined(__SVR4) +#undef __SOLARIS__ +#define __SOLARIS__ 1 +#endif +#if defined(WIN32) || defined(_WIN32) +#undef __WIN32__ +#define __WIN32__ 1 +#endif + +#endif /* _SDL_platform_h */ diff --git a/codemp/rd-rend2/SDL/SDL_quit.h b/codemp/rd-rend2/SDL/SDL_quit.h new file mode 100644 index 0000000000..abd2ec6c94 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_quit.h @@ -0,0 +1,55 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_quit.h + * Include file for SDL quit event handling + */ + +#ifndef _SDL_quit_h +#define _SDL_quit_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/** @file SDL_quit.h + * An SDL_QUITEVENT is generated when the user tries to close the application + * window. If it is ignored or filtered out, the window will remain open. + * If it is not ignored or filtered, it is queued normally and the window + * is allowed to close. When the window is closed, screen updates will + * complete, but have no effect. + * + * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) + * and SIGTERM (system termination request), if handlers do not already + * exist, that generate SDL_QUITEVENT events as well. There is no way + * to determine the cause of an SDL_QUITEVENT, but setting a signal + * handler in your application will override the default generation of + * quit events for that signal. + */ + +/** @file SDL_quit.h + * There are no functions directly affecting the quit event + */ + +#define SDL_QuitRequested() \ + (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) + +#endif /* _SDL_quit_h */ diff --git a/codemp/rd-rend2/SDL/SDL_rwops.h b/codemp/rd-rend2/SDL/SDL_rwops.h new file mode 100644 index 0000000000..98361d7e19 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_rwops.h @@ -0,0 +1,155 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_rwops.h + * This file provides a general interface for SDL to read and write + * data sources. It can easily be extended to files, memory, etc. + */ + +#ifndef _SDL_rwops_h +#define _SDL_rwops_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the read/write operation structure -- very basic */ + +typedef struct SDL_RWops { + /** Seek to 'offset' relative to whence, one of stdio's whence values: + * SEEK_SET, SEEK_CUR, SEEK_END + * Returns the final offset in the data source. + */ + int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); + + /** Read up to 'maxnum' objects each of size 'size' from the data + * source to the area pointed at by 'ptr'. + * Returns the number of objects read, or -1 if the read failed. + */ + int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); + + /** Write exactly 'num' objects each of size 'objsize' from the area + * pointed at by 'ptr' to data source. + * Returns 'num', or -1 if the write failed. + */ + int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); + + /** Close and free an allocated SDL_FSops structure */ + int (SDLCALL *close)(struct SDL_RWops *context); + + Uint32 type; + union { +#if defined(__WIN32__) && !defined(__SYMBIAN32__) + struct { + int append; + void *h; + struct { + void *data; + int size; + int left; + } buffer; + } win32io; +#endif +#ifdef HAVE_STDIO_H + struct { + int autoclose; + FILE *fp; + } stdio; +#endif + struct { + Uint8 *base; + Uint8 *here; + Uint8 *stop; + } mem; + struct { + void *data1; + } unknown; + } hidden; + +} SDL_RWops; + + +/** @name Functions to create SDL_RWops structures from various data sources */ +/*@{*/ + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); + +#ifdef HAVE_STDIO_H +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); +#endif + +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); +extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); + +extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); +extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); + +/*@}*/ + +/** @name Seek Reference Points */ +/*@{*/ +#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ +#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ +#define RW_SEEK_END 2 /**< Seek relative to the end of data */ +/*@}*/ + +/** @name Macros to easily read and write from an SDL_RWops structure */ +/*@{*/ +#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) +#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) +#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) +#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) +#define SDL_RWclose(ctx) (ctx)->close(ctx) +/*@}*/ + +/** @name Read an item of the specified endianness and return in native format */ +/*@{*/ +extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); +extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); +extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); +extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); +/*@}*/ + +/** @name Write an item of native format to the specified endianness */ +/*@{*/ +extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); +extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); +extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); +extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_rwops_h */ diff --git a/codemp/rd-rend2/SDL/SDL_stdinc.h b/codemp/rd-rend2/SDL/SDL_stdinc.h new file mode 100644 index 0000000000..35a4fdde59 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_stdinc.h @@ -0,0 +1,620 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_stdinc.h + * This is a general header that includes C language support + */ + +#ifndef _SDL_stdinc_h +#define _SDL_stdinc_h + +#include "SDL_config.h" + + +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_STDIO_H +#include +#endif +#if defined(STDC_HEADERS) +# include +# include +# include +#else +# if defined(HAVE_STDLIB_H) +# include +# elif defined(HAVE_MALLOC_H) +# include +# endif +# if defined(HAVE_STDDEF_H) +# include +# endif +# if defined(HAVE_STDARG_H) +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#if defined(HAVE_INTTYPES_H) +# include +#elif defined(HAVE_STDINT_H) +# include +#endif +#ifdef HAVE_CTYPE_H +# include +#endif +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +# include +#endif + +/** The number of elements in an array */ +#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) +#define SDL_TABLESIZE(table) SDL_arraysize(table) + +/* Use proper C++ casts when compiled as C++ to be compatible with the option + -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#endif + +/** @name Basic data types */ +/*@{*/ +typedef enum { + SDL_FALSE = 0, + SDL_TRUE = 1 +} SDL_bool; + +typedef int8_t Sint8; +typedef uint8_t Uint8; +typedef int16_t Sint16; +typedef uint16_t Uint16; +typedef int32_t Sint32; +typedef uint32_t Uint32; + +#ifdef SDL_HAS_64BIT_TYPE +typedef int64_t Sint64; +#ifndef SYMBIAN32_GCCE +typedef uint64_t Uint64; +#endif +#else +/* This is really just a hack to prevent the compiler from complaining */ +typedef struct { + Uint32 hi; + Uint32 lo; +} Uint64, Sint64; +#endif + +/*@}*/ + +/** @name Make sure the types really have the right sizes */ +/*@{*/ +#define SDL_COMPILE_TIME_ASSERT(name, x) \ + typedef int SDL_dummy_ ## name[(x) * 2 - 1] + +SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); +SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); +SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); +SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); +SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); +SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); +SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); +SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); +/*@}*/ + +/** @name Enum Size Check + * Check to make sure enums are the size of ints, for structure packing. + * For both Watcom C/C++ and Borland C/C++ the compiler option that makes + * enums having the size of an int must be enabled. + * This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). + */ +/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ +#ifdef __MWERKS__ +#pragma enumsalwaysint on +#endif + +typedef enum { + DUMMY_ENUM_VALUE +} SDL_DUMMY_ENUM; + +#ifndef __NDS__ +SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); +#endif +/*@}*/ + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef HAVE_MALLOC +#define SDL_malloc malloc +#else +extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); +#endif + +#ifdef HAVE_CALLOC +#define SDL_calloc calloc +#else +extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); +#endif + +#ifdef HAVE_REALLOC +#define SDL_realloc realloc +#else +extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); +#endif + +#ifdef HAVE_FREE +#define SDL_free free +#else +extern DECLSPEC void SDLCALL SDL_free(void *mem); +#endif + +#if defined(HAVE_ALLOCA) && !defined(alloca) +# if defined(HAVE_ALLOCA_H) +# include +# elif defined(__GNUC__) +# define alloca __builtin_alloca +# elif defined(_MSC_VER) +# include +# define alloca _alloca +# elif defined(__WATCOMC__) +# include +# elif defined(__BORLANDC__) +# include +# elif defined(__DMC__) +# include +# elif defined(__AIX__) + #pragma alloca +# elif defined(__MRC__) + void *alloca (unsigned); +# else + char *alloca (); +# endif +#endif +#ifdef HAVE_ALLOCA +#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) +#define SDL_stack_free(data) +#else +#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) +#define SDL_stack_free(data) SDL_free(data) +#endif + +#ifdef HAVE_GETENV +#define SDL_getenv getenv +#else +extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); +#endif + +#ifdef HAVE_PUTENV +#define SDL_putenv putenv +#else +extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); +#endif + +#ifdef HAVE_QSORT +#define SDL_qsort qsort +#else +extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, + int (*compare)(const void *, const void *)); +#endif + +#ifdef HAVE_ABS +#define SDL_abs abs +#else +#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) +#endif + +#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) +#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) + +#ifdef HAVE_CTYPE_H +#define SDL_isdigit(X) isdigit(X) +#define SDL_isspace(X) isspace(X) +#define SDL_toupper(X) toupper(X) +#define SDL_tolower(X) tolower(X) +#else +#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) +#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) +#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) +#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) +#endif + +#ifdef HAVE_MEMSET +#define SDL_memset memset +#else +extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_memset4(dst, val, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; stosl\n\t" \ + : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memset4 +#define SDL_memset4(dst, val, len) \ +do { \ + unsigned _count = (len); \ + unsigned _n = (_count + 3) / 4; \ + Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ + Uint32 _val = (val); \ + if (len == 0) break; \ + switch (_count % 4) { \ + case 0: do { *_p++ = _val; \ + case 3: *_p++ = _val; \ + case 2: *_p++ = _val; \ + case 1: *_p++ = _val; \ + } while ( --_n ); \ + } \ +} while(0) +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl\n\t" \ + "testb $2,%b4\n\t" \ + "je 1f\n\t" \ + "movsw\n" \ + "1:\ttestb $1,%b4\n\t" \ + "je 2f\n\t" \ + "movsb\n" \ + "2:" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy +#ifdef HAVE_MEMCPY +#define SDL_memcpy memcpy +#elif defined(HAVE_BCOPY) +#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) +#else +extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); +#endif +#endif + +/* We can count on memcpy existing on Mac OS X and being well-tuned. */ +#if defined(__MACH__) && defined(__APPLE__) +#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) +#elif defined(__GNUC__) && defined(i386) +#define SDL_memcpy4(dst, src, len) \ +do { \ + int ecx, edi, esi; \ + __asm__ __volatile__ ( \ + "cld\n\t" \ + "rep ; movsl" \ + : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ + : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ + : "memory" ); \ +} while(0) +#endif +#ifndef SDL_memcpy4 +#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) +#endif + +#if defined(__GNUC__) && defined(i386) +#define SDL_revcpy(dst, src, len) \ +do { \ + int u0, u1, u2; \ + char *dstp = SDL_static_cast(char *, dst); \ + char *srcp = SDL_static_cast(char *, src); \ + int n = (len); \ + if ( n >= 4 ) { \ + __asm__ __volatile__ ( \ + "std\n\t" \ + "rep ; movsl\n\t" \ + "cld\n\t" \ + : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ + : "0" (n >> 2), \ + "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ + : "memory" ); \ + } \ + switch (n & 3) { \ + case 3: dstp[2] = srcp[2]; \ + case 2: dstp[1] = srcp[1]; \ + case 1: dstp[0] = srcp[0]; \ + break; \ + default: \ + break; \ + } \ +} while(0) +#endif +#ifndef SDL_revcpy +extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); +#endif + +#ifdef HAVE_MEMMOVE +#define SDL_memmove memmove +#elif defined(HAVE_BCOPY) +#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) +#else +#define SDL_memmove(dst, src, len) \ +do { \ + if ( dst < src ) { \ + SDL_memcpy(dst, src, len); \ + } else { \ + SDL_revcpy(dst, src, len); \ + } \ +} while(0) +#endif + +#ifdef HAVE_MEMCMP +#define SDL_memcmp memcmp +#else +extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); +#endif + +#ifdef HAVE_STRLEN +#define SDL_strlen strlen +#else +extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); +#endif + +#ifdef HAVE_STRLCPY +#define SDL_strlcpy strlcpy +#else +extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRLCAT +#define SDL_strlcat strlcat +#else +extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); +#endif + +#ifdef HAVE_STRDUP +#define SDL_strdup strdup +#else +extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); +#endif + +#ifdef HAVE__STRREV +#define SDL_strrev _strrev +#else +extern DECLSPEC char * SDLCALL SDL_strrev(char *string); +#endif + +#ifdef HAVE__STRUPR +#define SDL_strupr _strupr +#else +extern DECLSPEC char * SDLCALL SDL_strupr(char *string); +#endif + +#ifdef HAVE__STRLWR +#define SDL_strlwr _strlwr +#else +extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); +#endif + +#ifdef HAVE_STRCHR +#define SDL_strchr strchr +#elif defined(HAVE_INDEX) +#define SDL_strchr index +#else +extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); +#endif + +#ifdef HAVE_STRRCHR +#define SDL_strrchr strrchr +#elif defined(HAVE_RINDEX) +#define SDL_strrchr rindex +#else +extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); +#endif + +#ifdef HAVE_STRSTR +#define SDL_strstr strstr +#else +extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); +#endif + +#ifdef HAVE_ITOA +#define SDL_itoa itoa +#else +#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) +#endif + +#ifdef HAVE__LTOA +#define SDL_ltoa _ltoa +#else +extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); +#endif + +#ifdef HAVE__UITOA +#define SDL_uitoa _uitoa +#else +#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) +#endif + +#ifdef HAVE__ULTOA +#define SDL_ultoa _ultoa +#else +extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOL +#define SDL_strtol strtol +#else +extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOUL +#define SDL_strtoul strtoul +#else +extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); +#endif + +#ifdef SDL_HAS_64BIT_TYPE + +#ifdef HAVE__I64TOA +#define SDL_lltoa _i64toa +#else +extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); +#endif + +#ifdef HAVE__UI64TOA +#define SDL_ulltoa _ui64toa +#else +extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); +#endif + +#ifdef HAVE_STRTOLL +#define SDL_strtoll strtoll +#else +extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); +#endif + +#ifdef HAVE_STRTOULL +#define SDL_strtoull strtoull +#else +extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); +#endif + +#endif /* SDL_HAS_64BIT_TYPE */ + +#ifdef HAVE_STRTOD +#define SDL_strtod strtod +#else +extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); +#endif + +#ifdef HAVE_ATOI +#define SDL_atoi atoi +#else +#define SDL_atoi(X) SDL_strtol(X, NULL, 0) +#endif + +#ifdef HAVE_ATOF +#define SDL_atof atof +#else +#define SDL_atof(X) SDL_strtod(X, NULL) +#endif + +#ifdef HAVE_STRCMP +#define SDL_strcmp strcmp +#else +extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCMP +#define SDL_strncmp strncmp +#else +extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_STRCASECMP +#define SDL_strcasecmp strcasecmp +#elif defined(HAVE__STRICMP) +#define SDL_strcasecmp _stricmp +#else +extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); +#endif + +#ifdef HAVE_STRNCASECMP +#define SDL_strncasecmp strncasecmp +#elif defined(HAVE__STRNICMP) +#define SDL_strncasecmp _strnicmp +#else +extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); +#endif + +#ifdef HAVE_SSCANF +#define SDL_sscanf sscanf +#else +extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); +#endif + +#ifdef HAVE_SNPRINTF +#define SDL_snprintf snprintf +#else +extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); +#endif + +#ifdef HAVE_VSNPRINTF +#define SDL_vsnprintf vsnprintf +#else +extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); +#endif + +/** @name SDL_ICONV Error Codes + * The SDL implementation of iconv() returns these error codes + */ +/*@{*/ +#define SDL_ICONV_ERROR (size_t)-1 +#define SDL_ICONV_E2BIG (size_t)-2 +#define SDL_ICONV_EILSEQ (size_t)-3 +#define SDL_ICONV_EINVAL (size_t)-4 +/*@}*/ + +#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) +#define SDL_iconv_t iconv_t +#define SDL_iconv_open iconv_open +#define SDL_iconv_close iconv_close +#else +typedef struct _SDL_iconv_t *SDL_iconv_t; +extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); +extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); +#endif +extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); +/** This function converts a string between encodings in one pass, returning a + * string that must be freed with SDL_free() or NULL on error. + */ +extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); +#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_stdinc_h */ diff --git a/codemp/rd-rend2/SDL/SDL_syswm.h b/codemp/rd-rend2/SDL/SDL_syswm.h new file mode 100644 index 0000000000..78433c6aa4 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_syswm.h @@ -0,0 +1,226 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_syswm.h + * Include file for SDL custom system window manager hooks + */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @file SDL_syswm.h + * Your application has access to a special type of event 'SDL_SYSWMEVENT', + * which contains window-manager specific information and arrives whenever + * an unhandled window event occurs. This event is ignored by default, but + * you can enable it with SDL_EventState() + */ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +typedef struct SDL_SysWMinfo SDL_SysWMinfo; +#else + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +/** These are the various supported subsystems under UNIX */ +typedef enum { + SDL_SYSWM_X11 +} SDL_SYSWM_TYPE; + +/** The UNIX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + XEvent xevent; + } event; +}; + +/** The UNIX custom window manager information structure. + * When this structure is returned, it holds information about which + * low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +typedef struct SDL_SysWMinfo { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + struct { + Display *display; /**< The X11 display */ + Window window; /**< The X11 display window */ + /** These locking functions should be called around + * any X11 functions using the display variable, + * but not the gfxdisplay variable. + * They lock the event thread, so should not be + * called around event functions or from event filters. + */ + /*@{*/ + void (*lock_func)(void); + void (*unlock_func)(void); + /*@}*/ + + /** @name Introduced in SDL 1.0.2 */ + /*@{*/ + Window fswindow; /**< The X11 fullscreen window */ + Window wmwindow; /**< The X11 managed input window */ + /*@}*/ + + /** @name Introduced in SDL 1.2.12 */ + /*@{*/ + Display *gfxdisplay; /**< The X11 display to which rendering is done */ + /*@}*/ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_NANOX) +#include + +/** The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +#define WIN32_LEAN_AND_MEAN +#include + +/** The windows custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + HWND hwnd; /**< The window for the message */ + UINT msg; /**< The type of message */ + WPARAM wParam; /**< WORD message parameter */ + LPARAM lParam; /**< LONG message parameter */ +}; + +/** The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + HWND window; /**< The Win32 display window */ + HGLRC hglrc; /**< The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_RISCOS) + +/** RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /**< The window for the message */ + int pollBlock[64]; +}; + +/** The RISC OS custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int wimpVersion; /**< Wimp version running under */ + int taskHandle; /**< The RISC OS task handle */ + int window; /**< The RISC OS display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_PHOTON) +#include +#include + +/** The QNX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The QNX custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#else + +/** The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/** The generic custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#endif /* video driver type */ + +#endif /* SDL_PROTOTYPES_ONLY */ + +/* Function prototypes */ +/** + * This function gives you custom hooks into the window manager information. + * It fills the structure pointed to by 'info' with custom information and + * returns 0 if the function is not implemented, 1 if the function is + * implemented and no error occurred, and -1 if the version member of + * the 'info' structure is not filled in or not supported. + * + * You typically use this function like this: + * @code + * SDL_SysWMinfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWMInfo(&info) ) { ... } + * @endcode + */ +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */ diff --git a/codemp/rd-rend2/SDL/SDL_thread.h b/codemp/rd-rend2/SDL/SDL_thread.h new file mode 100644 index 0000000000..9ebe00edd5 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_thread.h @@ -0,0 +1,115 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_thread_h +#define _SDL_thread_h + +/** @file SDL_thread.h + * Header for the SDL thread management routines + * + * @note These are independent of the other SDL routines. + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +/* Thread synchronization primitives */ +#include "SDL_mutex.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** The SDL thread structure, defined in SDL_thread.c */ +struct SDL_Thread; +typedef struct SDL_Thread SDL_Thread; + +/** Create a thread */ +#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) +/** + * We compile SDL into a DLL on OS/2. This means, that it's the DLL which + * creates a new thread for the calling process with the SDL_CreateThread() + * API. There is a problem with this, that only the RTL of the SDL.DLL will + * be initialized for those threads, and not the RTL of the calling application! + * To solve this, we make a little hack here. + * We'll always use the caller's _beginthread() and _endthread() APIs to + * start a new thread. This way, if it's the SDL.DLL which uses this API, + * then the RTL of SDL.DLL will be used to create the new thread, and if it's + * the application, then the RTL of the application will be used. + * So, in short: + * Always use the _beginthread() and _endthread() of the calling runtime library! + */ +#define SDL_PASSED_BEGINTHREAD_ENDTHREAD +#ifndef _WIN32_WCE +#include /* This has _beginthread() and _endthread() defined! */ +#endif + +#ifdef __OS2__ +typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); +typedef void (*pfnSDL_CurrentEndThread)(void); +#else +typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); +#endif + +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); + +#ifdef __OS2__ +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) +#elif defined(_WIN32_WCE) +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) +#else +#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) +#endif +#else +extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); +#endif + +/** Get the 32-bit thread identifier for the current thread */ +extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); + +/** Get the 32-bit thread identifier for the specified thread, + * equivalent to SDL_ThreadID() if the specified thread is NULL. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); + +/** Wait for a thread to finish. + * The return code for the thread function is placed in the area + * pointed to by 'status', if 'status' is not NULL. + */ +extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); + +/** Forcefully kill a thread without worrying about its state */ +extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_thread_h */ diff --git a/codemp/rd-rend2/SDL/SDL_timer.h b/codemp/rd-rend2/SDL/SDL_timer.h new file mode 100644 index 0000000000..d764d5f381 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_timer.h @@ -0,0 +1,125 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_timer_h +#define _SDL_timer_h + +/** @file SDL_timer.h + * Header for the SDL time management routines + */ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** This is the OS scheduler timeslice, in milliseconds */ +#define SDL_TIMESLICE 10 + +/** This is the maximum resolution of the SDL timer on all platforms */ +#define TIMER_RESOLUTION 10 /**< Experimentally determined */ + +/** + * Get the number of milliseconds since the SDL library initialization. + * Note that this value wraps if the program runs for more than ~49 days. + */ +extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); + +/** Wait a specified number of milliseconds before returning */ +extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); + +/** Function prototype for the timer callback function */ +typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); + +/** + * Set a callback to run after the specified number of milliseconds has + * elapsed. The callback function is passed the current timer interval + * and returns the next timer interval. If the returned value is the + * same as the one passed in, the periodic alarm continues, otherwise a + * new alarm is scheduled. If the callback returns 0, the periodic alarm + * is cancelled. + * + * To cancel a currently running timer, call SDL_SetTimer(0, NULL); + * + * The timer callback function may run in a different thread than your + * main code, and so shouldn't call any functions from within itself. + * + * The maximum resolution of this timer is 10 ms, which means that if + * you request a 16 ms timer, your callback will run approximately 20 ms + * later on an unloaded system. If you wanted to set a flag signaling + * a frame update at 30 frames per second (every 33 ms), you might set a + * timer for 30 ms: + * @code SDL_SetTimer((33/10)*10, flag_update); @endcode + * + * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). + * + * Under UNIX, you should not use raise or use SIGALRM and this function + * in the same program, as it is implemented using setitimer(). You also + * should not use this function in multi-threaded applications as signals + * to multi-threaded apps have undefined behavior in some implementations. + * + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); + +/** @name New timer API + * New timer API, supports multiple timers + * Written by Stephane Peter + */ +/*@{*/ + +/** + * Function prototype for the new timer callback function. + * The callback function is passed the current timer interval and returns + * the next timer interval. If the returned value is the same as the one + * passed in, the periodic alarm continues, otherwise a new alarm is + * scheduled. If the callback returns 0, the periodic alarm is cancelled. + */ +typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); + +/** Definition of the timer ID type */ +typedef struct _SDL_TimerID *SDL_TimerID; + +/** Add a new timer to the pool of timers already running. + * Returns a timer ID, or NULL when an error occurs. + */ +extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); + +/** + * Remove one of the multiple timers knowing its ID. + * Returns a boolean value indicating success. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); + +/*@}*/ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_timer_h */ diff --git a/codemp/rd-rend2/SDL/SDL_types.h b/codemp/rd-rend2/SDL/SDL_types.h new file mode 100644 index 0000000000..79d8b28dd0 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_types.h @@ -0,0 +1,28 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_types.h + * @deprecated Use SDL_stdinc.h instead. + */ + +/* DEPRECATED */ +#include "SDL_stdinc.h" diff --git a/codemp/rd-rend2/SDL/SDL_version.h b/codemp/rd-rend2/SDL/SDL_version.h new file mode 100644 index 0000000000..fdc17c64c9 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_version.h @@ -0,0 +1,91 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_version.h + * This header defines the current SDL version + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Version Number + * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + */ +/*@{*/ +#define SDL_MAJOR_VERSION 1 +#define SDL_MINOR_VERSION 2 +#define SDL_PATCHLEVEL 15 +/*@}*/ + +typedef struct SDL_version { + Uint8 major; + Uint8 minor; + Uint8 patch; +} SDL_version; + +/** + * This macro can be used to fill a version structure with the compile-time + * version of the SDL library. + */ +#define SDL_VERSION(X) \ +{ \ + (X)->major = SDL_MAJOR_VERSION; \ + (X)->minor = SDL_MINOR_VERSION; \ + (X)->patch = SDL_PATCHLEVEL; \ +} + +/** This macro turns the version numbers into a numeric value: + * (1,2,3) -> (1203) + * This assumes that there will never be more than 100 patchlevels + */ +#define SDL_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +/** This is the version number macro for the current SDL version */ +#define SDL_COMPILEDVERSION \ + SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) + +/** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ +#define SDL_VERSION_ATLEAST(X, Y, Z) \ + (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) + +/** This function gets the version of the dynamically linked SDL library. + * it should NOT be used to fill a version structure, instead you should + * use the SDL_Version() macro. + */ +extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff --git a/codemp/rd-rend2/SDL/SDL_video.h b/codemp/rd-rend2/SDL/SDL_video.h new file mode 100644 index 0000000000..f9c4e07025 --- /dev/null +++ b/codemp/rd-rend2/SDL/SDL_video.h @@ -0,0 +1,951 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_video.h + * Header file for access to the SDL raw framebuffer window + */ + +#ifndef _SDL_video_h +#define _SDL_video_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_rwops.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Transparency definitions + * These define alpha as the opacity of a surface + */ +/*@{*/ +#define SDL_ALPHA_OPAQUE 255 +#define SDL_ALPHA_TRANSPARENT 0 +/*@}*/ + +/** @name Useful data types */ +/*@{*/ +typedef struct SDL_Rect { + Sint16 x, y; + Uint16 w, h; +} SDL_Rect; + +typedef struct SDL_Color { + Uint8 r; + Uint8 g; + Uint8 b; + Uint8 unused; +} SDL_Color; +#define SDL_Colour SDL_Color + +typedef struct SDL_Palette { + int ncolors; + SDL_Color *colors; +} SDL_Palette; +/*@}*/ + +/** Everything in the pixel format structure is read-only */ +typedef struct SDL_PixelFormat { + SDL_Palette *palette; + Uint8 BitsPerPixel; + Uint8 BytesPerPixel; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; + + /** RGB color key information */ + Uint32 colorkey; + /** Alpha value information (per-surface alpha) */ + Uint8 alpha; +} SDL_PixelFormat; + +/** This structure should be treated as read-only, except for 'pixels', + * which, if not NULL, contains the raw pixel data for the surface. + */ +typedef struct SDL_Surface { + Uint32 flags; /**< Read-only */ + SDL_PixelFormat *format; /**< Read-only */ + int w, h; /**< Read-only */ + Uint16 pitch; /**< Read-only */ + void *pixels; /**< Read-write */ + int offset; /**< Private */ + + /** Hardware-specific surface info */ + struct private_hwdata *hwdata; + + /** clipping information */ + SDL_Rect clip_rect; /**< Read-only */ + Uint32 unused1; /**< for binary compatibility */ + + /** Allow recursive locks */ + Uint32 locked; /**< Private */ + + /** info for fast blit mapping to other surfaces */ + struct SDL_BlitMap *map; /**< Private */ + + /** format version, bumped at every change to invalidate blit maps */ + unsigned int format_version; /**< Private */ + + /** Reference count -- used when freeing surface */ + int refcount; /**< Read-mostly */ +} SDL_Surface; + +/** @name SDL_Surface Flags + * These are the currently supported flags for the SDL_surface + */ +/*@{*/ + +/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ +/*@{*/ +#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */ +#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */ +#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */ +/*@}*/ + +/** Available for SDL_SetVideoMode() */ +/*@{*/ +#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */ +#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */ +#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */ +#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */ +#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */ +#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */ +#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */ +#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ +/*@}*/ + +/** Used internally (read-only) */ +/*@{*/ +#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */ +#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */ +#define SDL_RLEACCELOK 0x00002000 /**< Private flag */ +#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */ +#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */ +#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */ +/*@}*/ + +/*@}*/ + +/** Evaluates to true if the surface needs to be locked before access */ +#define SDL_MUSTLOCK(surface) \ + (surface->offset || \ + ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) + +/** typedef for private surface blitting functions */ +typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, + struct SDL_Surface *dst, SDL_Rect *dstrect); + + +/** Useful for determining the video hardware capabilities */ +typedef struct SDL_VideoInfo { + Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */ + Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */ + Uint32 UnusedBits1 :6; + Uint32 UnusedBits2 :1; + Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */ + Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */ + Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */ + Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */ + Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */ + Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */ + Uint32 blit_fill :1; /**< Flag: Accelerated color fill */ + Uint32 UnusedBits3 :16; + Uint32 video_mem; /**< The total amount of video memory (in K) */ + SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */ + int current_w; /**< Value: The current video mode width */ + int current_h; /**< Value: The current video mode height */ +} SDL_VideoInfo; + + +/** @name Overlay Formats + * The most common video overlay formats. + * For an explanation of these pixel formats, see: + * http://www.webartz.com/fourcc/indexyuv.htm + * + * For information on the relationship between color spaces, see: + * http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html + */ +/*@{*/ +#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */ +#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */ +#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ +#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ +#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ +/*@}*/ + +/** The YUV hardware video overlay */ +typedef struct SDL_Overlay { + Uint32 format; /**< Read-only */ + int w, h; /**< Read-only */ + int planes; /**< Read-only */ + Uint16 *pitches; /**< Read-only */ + Uint8 **pixels; /**< Read-write */ + + /** @name Hardware-specific surface info */ + /*@{*/ + struct private_yuvhwfuncs *hwfuncs; + struct private_yuvhwdata *hwdata; + /*@{*/ + + /** @name Special flags */ + /*@{*/ + Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */ + Uint32 UnusedBits :31; + /*@}*/ +} SDL_Overlay; + + +/** Public enumeration for setting the OpenGL window attributes. */ +typedef enum { + SDL_GL_RED_SIZE, + SDL_GL_GREEN_SIZE, + SDL_GL_BLUE_SIZE, + SDL_GL_ALPHA_SIZE, + SDL_GL_BUFFER_SIZE, + SDL_GL_DOUBLEBUFFER, + SDL_GL_DEPTH_SIZE, + SDL_GL_STENCIL_SIZE, + SDL_GL_ACCUM_RED_SIZE, + SDL_GL_ACCUM_GREEN_SIZE, + SDL_GL_ACCUM_BLUE_SIZE, + SDL_GL_ACCUM_ALPHA_SIZE, + SDL_GL_STEREO, + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES, + SDL_GL_ACCELERATED_VISUAL, + SDL_GL_SWAP_CONTROL +} SDL_GLattr; + +/** @name flags for SDL_SetPalette() */ +/*@{*/ +#define SDL_LOGPAL 0x01 +#define SDL_PHYSPAL 0x02 +/*@}*/ + +/* Function prototypes */ + +/** + * @name Video Init and Quit + * These functions are used internally, and should not be used unless you + * have a specific need to specify the video driver you want to use. + * You should normally use SDL_Init() or SDL_InitSubSystem(). + */ +/*@{*/ +/** + * Initializes the video subsystem. Sets up a connection + * to the window manager, etc, and determines the current video mode and + * pixel format, but does not initialize a window or graphics mode. + * Note that event handling is activated by this routine. + * + * If you use both sound and video in your application, you need to call + * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, + * you won't be able to set full-screen display modes. + */ +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); +extern DECLSPEC void SDLCALL SDL_VideoQuit(void); +/*@}*/ + +/** + * This function fills the given character buffer with the name of the + * video driver, and returns a pointer to it if the video driver has + * been initialized. It returns NULL if no driver has been initialized. + */ +extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); + +/** + * This function returns a pointer to the current display surface. + * If SDL is doing format conversion on the display surface, this + * function returns the publicly visible surface, not the real video + * surface. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); + +/** + * This function returns a read-only pointer to information about the + * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' + * member of the returned structure will contain the pixel format of the + * "best" video mode. + */ +extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); + +/** + * Check to see if a particular video mode is supported. + * It returns 0 if the requested mode is not supported under any bit depth, + * or returns the bits-per-pixel of the closest available mode with the + * given width and height. If this bits-per-pixel is different from the + * one used when setting the video mode, SDL_SetVideoMode() will succeed, + * but will emulate the requested bits-per-pixel with a shadow surface. + * + * The arguments to SDL_VideoModeOK() are the same ones you would pass to + * SDL_SetVideoMode() + */ +extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); + +/** + * Return a pointer to an array of available screen dimensions for the + * given format and video flags, sorted largest to smallest. Returns + * NULL if there are no dimensions available for a particular format, + * or (SDL_Rect **)-1 if any dimension is okay for the given format. + * + * If 'format' is NULL, the mode list will be for the format given + * by SDL_GetVideoInfo()->vfmt + */ +extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); + +/** + * Set up a video mode with the specified width, height and bits-per-pixel. + * + * If 'bpp' is 0, it is treated as the current display bits per pixel. + * + * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the + * requested bits-per-pixel, but will return whatever video pixel format is + * available. The default is to emulate the requested pixel format if it + * is not natively available. + * + * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in + * video memory, if possible, and you may have to call SDL_LockSurface() + * in order to access the raw framebuffer. Otherwise, the video surface + * will be created in system memory. + * + * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle + * updates asynchronously, but you must always lock before accessing pixels. + * SDL will wait for updates to complete before returning from the lock. + * + * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee + * that the colors set by SDL_SetColors() will be the colors you get. + * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all + * of the colors exactly the way they are requested, and you should look + * at the video surface structure to determine the actual palette. + * If SDL cannot guarantee that the colors you request can be set, + * i.e. if the colormap is shared, then the video surface may be created + * under emulation in system memory, overriding the SDL_HWSURFACE flag. + * + * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set + * a fullscreen video mode. The default is to create a windowed mode + * if the current graphics system has a window manager. + * If the SDL library is able to set a fullscreen video mode, this flag + * will be set in the surface that is returned. + * + * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up + * two surfaces in video memory and swap between them when you call + * SDL_Flip(). This is usually slower than the normal single-buffering + * scheme, but prevents "tearing" artifacts caused by modifying video + * memory while the monitor is refreshing. It should only be used by + * applications that redraw the entire screen on every update. + * + * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the + * window manager, if any, to resize the window at runtime. When this + * occurs, SDL will send a SDL_VIDEORESIZE event to you application, + * and you must respond to the event by re-calling SDL_SetVideoMode() + * with the requested size (or another size that suits the application). + * + * If SDL_NOFRAME is set in 'flags', the SDL library will create a window + * without any title bar or frame decoration. Fullscreen video modes have + * this flag set automatically. + * + * This function returns the video framebuffer surface, or NULL if it fails. + * + * If you rely on functionality provided by certain video flags, check the + * flags of the returned surface to make sure that functionality is available. + * SDL will fall back to reduced functionality if the exact flags you wanted + * are not available. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode + (int width, int height, int bpp, Uint32 flags); + +/** @name SDL_Update Functions + * These functions should not be called while 'screen' is locked. + */ +/*@{*/ +/** + * Makes sure the given list of rectangles is updated on the given screen. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRects + (SDL_Surface *screen, int numrects, SDL_Rect *rects); +/** + * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire + * screen. + */ +extern DECLSPEC void SDLCALL SDL_UpdateRect + (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); +/*@}*/ + +/** + * On hardware that supports double-buffering, this function sets up a flip + * and returns. The hardware will wait for vertical retrace, and then swap + * video buffers before the next video surface blit or lock will return. + * On hardware that doesn not support double-buffering, this is equivalent + * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); + * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when + * setting the video mode for this function to perform hardware flipping. + * This function returns 0 if successful, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); + +/** + * Set the gamma correction for each of the color channels. + * The gamma values range (approximately) between 0.1 and 10.0 + * + * If this function isn't supported directly by the hardware, it will + * be emulated using gamma ramps, if available. If successful, this + * function returns 0, otherwise it returns -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); + +/** + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * You may pass NULL for any of the channels to leave it unchanged. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); + +/** + * Retrieve the current values of the gamma translation tables. + * + * You must pass in valid pointers to arrays of 256 16-bit quantities. + * Any of the pointers may be NULL to ignore that channel. + * If the call succeeds, it will return 0. If the display driver or + * hardware does not support gamma translation, or otherwise fails, + * this function will return -1. + */ +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); + +/** + * Sets a portion of the colormap for the given 8-bit surface. If 'surface' + * is not a palettized surface, this function does nothing, returning 0. + * If all of the colors were set as passed to SDL_SetColors(), it will + * return 1. If not all the color entries were set exactly as given, + * it will return 0, and you should look at the surface palette to + * determine the actual color palette. + * + * When 'surface' is the surface associated with the current display, the + * display colormap will be updated with the requested colors. If + * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() + * will always return 1, and the palette is guaranteed to be set the way + * you desire, even if the window colormap has to be warped or run under + * emulation. + */ +extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, + SDL_Color *colors, int firstcolor, int ncolors); + +/** + * Sets a portion of the colormap for a given 8-bit surface. + * 'flags' is one or both of: + * SDL_LOGPAL -- set logical palette, which controls how blits are mapped + * to/from the surface, + * SDL_PHYSPAL -- set physical palette, which controls how pixels look on + * the screen + * Only screens have physical palettes. Separate change of physical/logical + * palettes is only possible if the screen has SDL_HWPALETTE set. + * + * The return value is 1 if all colours could be set as requested, and 0 + * otherwise. + * + * SDL_SetColors() is equivalent to calling this function with + * flags = (SDL_LOGPAL|SDL_PHYSPAL). + */ +extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, + SDL_Color *colors, int firstcolor, + int ncolors); + +/** + * Maps an RGB triple to an opaque pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGB +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b); + +/** + * Maps an RGBA quadruple to a pixel value for a given pixel format + */ +extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA +(const SDL_PixelFormat * const format, + const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a); + +/** + * Maps a pixel value into the RGB components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, + const SDL_PixelFormat * const fmt, + Uint8 *r, Uint8 *g, Uint8 *b); + +/** + * Maps a pixel value into the RGBA components for a given pixel format + */ +extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, + const SDL_PixelFormat * const fmt, + Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); + +/** @sa SDL_CreateRGBSurface */ +#define SDL_AllocSurface SDL_CreateRGBSurface +/** + * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) + * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. + * If the depth is greater than 8 bits, the pixel format is set using the + * flags '[RGB]mask'. + * If the function runs out of memory, it will return NULL. + * + * The 'flags' tell what kind of surface to create. + * SDL_SWSURFACE means that the surface should be created in system memory. + * SDL_HWSURFACE means that the surface should be created in video memory, + * with the same format as the display surface. This is useful for surfaces + * that will not change much, to take advantage of hardware acceleration + * when being blitted to the display surface. + * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with + * this surface, but you must always lock it before accessing the pixels. + * SDL will wait for current blits to finish before returning from the lock. + * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. + * If the hardware supports acceleration of colorkey blits between + * two surfaces in video memory, SDL will try to place the surface in + * video memory. If this isn't possible or if there is no hardware + * acceleration available, the surface will be placed in system memory. + * SDL_SRCALPHA means that the surface will be used for alpha blits and + * if the hardware supports hardware acceleration of alpha blits between + * two surfaces in video memory, to place the surface in video memory + * if possible, otherwise it will be placed in system memory. + * If the surface is created in video memory, blits will be _much_ faster, + * but the surface format must be identical to the video surface format, + * and the only way to access the pixels member of the surface is to use + * the SDL_LockSurface() and SDL_UnlockSurface() calls. + * If the requested surface actually resides in video memory, SDL_HWSURFACE + * will be set in the flags member of the returned surface. If for some + * reason the surface could not be placed in video memory, it will not have + * the SDL_HWSURFACE flag set, and will be created in system memory instead. + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +/** @sa SDL_CreateRGBSurface */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, + int width, int height, int depth, int pitch, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); +extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); + +/** + * SDL_LockSurface() sets up a surface for directly accessing the pixels. + * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write + * to and read from 'surface->pixels', using the pixel format stored in + * 'surface->format'. Once you are done accessing the surface, you should + * use SDL_UnlockSurface() to release it. + * + * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates + * to 0, then you can read and write to the surface at any time, and the + * pixel format of the surface will not change. In particular, if the + * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you + * will not need to lock the display surface before accessing it. + * + * No operating system or library calls should be made between lock/unlock + * pairs, as critical system locks may be held during this time. + * + * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. + */ +extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); +extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); + +/** + * Load a surface from a seekable SDL data source (memory or file.) + * If 'freesrc' is non-zero, the source will be closed after being read. + * Returns the new surface, or NULL if there was an error. + * The new surface should be freed with SDL_FreeSurface(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); + +/** Convenience macro -- load a surface from a file */ +#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) + +/** + * Save a surface to a seekable SDL data source (memory or file.) + * If 'freedst' is non-zero, the source will be closed after being written. + * Returns 0 if successful or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SaveBMP_RW + (SDL_Surface *surface, SDL_RWops *dst, int freedst); + +/** Convenience macro -- save a surface to a file */ +#define SDL_SaveBMP(surface, file) \ + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + +/** + * Sets the color key (transparent pixel) in a blittable surface. + * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), + * 'key' will be the transparent pixel in the source image of a blit. + * SDL_RLEACCEL requests RLE acceleration for the surface if present, + * and removes RLE acceleration if absent. + * If 'flag' is 0, this function clears any current color key. + * This function returns 0, or -1 if there was an error. + */ +extern DECLSPEC int SDLCALL SDL_SetColorKey + (SDL_Surface *surface, Uint32 flag, Uint32 key); + +/** + * This function sets the alpha value for the entire surface, as opposed to + * using the alpha component of each pixel. This value measures the range + * of transparency of the surface, 0 being completely transparent to 255 + * being completely opaque. An 'alpha' value of 255 causes blits to be + * opaque, the source pixels copied to the destination (the default). Note + * that per-surface alpha can be combined with colorkey transparency. + * + * If 'flag' is 0, alpha blending is disabled for the surface. + * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. + * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the + * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. + * + * The 'alpha' parameter is ignored for surfaces that have an alpha channel. + */ +extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); + +/** + * Sets the clipping rectangle for the destination surface in a blit. + * + * If the clip rectangle is NULL, clipping will be disabled. + * If the clip rectangle doesn't intersect the surface, the function will + * return SDL_FALSE and blits will be completely clipped. Otherwise the + * function returns SDL_TRUE and blits to the surface will be clipped to + * the intersection of the surface area and the clipping rectangle. + * + * Note that blits are automatically clipped to the edges of the source + * and destination surfaces. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); + +/** + * Gets the clipping rectangle for the destination surface in a blit. + * 'rect' must be a pointer to a valid rectangle which will be filled + * with the correct values. + */ +extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); + +/** + * Creates a new surface of the specified format, and then copies and maps + * the given surface to it so the blit of the converted surface will be as + * fast as possible. If this function fails, it returns NULL. + * + * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those + * semantics. You can also pass SDL_RLEACCEL in the flags parameter and + * SDL will try to RLE accelerate colorkey and alpha blits in the resulting + * surface. + * + * This function is used internally by SDL_DisplayFormat(). + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface + (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); + +/** + * This performs a fast blit from the source surface to the destination + * surface. It assumes that the source and destination rectangles are + * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire + * surface (src or dst) is copied. The final blit rectangles are saved + * in 'srcrect' and 'dstrect' after all clipping is performed. + * If the blit is successful, it returns 0, otherwise it returns -1. + * + * The blit function should not be called on a locked surface. + * + * The blit semantics for surfaces with and without alpha and colorkey + * are defined as follows: + * + * RGBA->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using alpha-channel). + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy RGB. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value); + * set destination alpha to opaque. + * SDL_SRCALPHA not set: + * copy RGB, set destination alpha to source per-surface alpha value. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * RGBA->RGBA: + * SDL_SRCALPHA set: + * alpha-blend (using the source alpha channel) the RGB values; + * leave destination alpha untouched. [Note: is this correct?] + * SDL_SRCCOLORKEY ignored. + * SDL_SRCALPHA not set: + * copy all of RGBA to the destination. + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * RGB values of the source colour key, ignoring alpha in the + * comparison. + * + * RGB->RGB: + * SDL_SRCALPHA set: + * alpha-blend (using the source per-surface alpha value). + * SDL_SRCALPHA not set: + * copy RGB. + * both: + * if SDL_SRCCOLORKEY set, only copy the pixels matching the + * source colour key. + * + * If either of the surfaces were in video memory, and the blit returns -2, + * the video memory was lost, so it should be reloaded with artwork and + * re-blitted: + * @code + * while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { + * while ( SDL_LockSurface(image) < 0 ) + * Sleep(10); + * -- Write image pixels to image->pixels -- + * SDL_UnlockSurface(image); + * } + * @endcode + * + * This happens under DirectX 5.0 when the system switches away from your + * fullscreen application. The lock will also fail until you have access + * to the video memory again. + * + * You should call SDL_BlitSurface() unless you know exactly how SDL + * blitting works internally and how to use the other blit functions. + */ +#define SDL_BlitSurface SDL_UpperBlit + +/** This is the public blit function, SDL_BlitSurface(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlit() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); +/** This is a semi-private blit function and it performs low-level surface + * blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlit + (SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/** + * This function performs a fast fill of the given rectangle with 'color' + * The given rectangle is clipped to the destination surface clip area + * and the final fill rectangle is saved in the passed in pointer. + * If 'dstrect' is NULL, the whole surface will be filled with 'color' + * The color should be a pixel of the format used by the surface, and + * can be generated by the SDL_MapRGB() function. + * This function returns 0 on success, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_FillRect + (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); + +/** + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer, suitable for fast + * blitting onto the display surface. It calls SDL_ConvertSurface() + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); + +/** + * This function takes a surface and copies it to a new surface of the + * pixel format and colors of the video framebuffer (if possible), + * suitable for fast alpha blitting onto the display surface. + * The new surface will always have an alpha channel. + * + * If you want to take advantage of hardware colorkey or alpha blit + * acceleration, you should set the colorkey and alpha value before + * calling this function. + * + * If the conversion fails or runs out of memory, it returns NULL + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name YUV video surface overlay functions */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** This function creates a video output overlay + * Calling the returned surface an overlay is something of a misnomer because + * the contents of the display surface underneath the area where the overlay + * is shown is undefined - it may be overwritten with the converted YUV data. + */ +extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, + Uint32 format, SDL_Surface *display); + +/** Lock an overlay for direct access, and unlock it when you are done */ +extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); +extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); + +/** Blit a video overlay to the display surface. + * The contents of the video surface underneath the blit destination are + * not defined. + * The width and height of the destination rectangle may be different from + * that of the overlay, but currently only 2x scaling is supported. + */ +extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); + +/** Free a video overlay */ +extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name OpenGL support functions. */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Dynamically load an OpenGL library, or the default one if path is NULL + * + * If you do this, you need to retrieve all of the GL functions used in + * your program from the dynamic library using SDL_GL_GetProcAddress(). + */ +extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); + +/** + * Get the address of a GL function + */ +extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); + +/** + * Set an attribute of the OpenGL subsystem before intialization. + */ +extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); + +/** + * Get an attribute of the OpenGL subsystem from the windowing + * interface, such as glX. This is of course different from getting + * the values from SDL's internal OpenGL subsystem, which only + * stores the values you request before initialization. + * + * Developers should track the values they pass into SDL_GL_SetAttribute + * themselves if they want to retrieve these values. + */ +extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); + +/** + * Swap the OpenGL buffers, if double-buffering is supported. + */ +extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); + +/** @name OpenGL Internal Functions + * Internal functions that should not be called unless you have read + * and understood the source code for these functions. + */ +/*@{*/ +extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); +extern DECLSPEC void SDLCALL SDL_GL_Lock(void); +extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); +/*@}*/ + +/*@}*/ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/** @name Window Manager Functions */ +/** These functions allow interaction with the window manager, if any. */ /*@{*/ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/** + * Sets the title and icon text of the display window (UTF-8 encoded) + */ +extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); +/** + * Gets the title and icon text of the display window (UTF-8 encoded) + */ +extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); + +/** + * Sets the icon for the display window. + * This function must be called before the first call to SDL_SetVideoMode(). + * It takes an icon surface, and a mask in MSB format. + * If 'mask' is NULL, the entire icon surface will be used as the icon. + */ +extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); + +/** + * This function iconifies the window, and returns 1 if it succeeded. + * If the function succeeds, it generates an SDL_APPACTIVE loss event. + * This function is a noop and returns 0 in non-windowed environments. + */ +extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); + +/** + * Toggle fullscreen mode without changing the contents of the screen. + * If the display surface does not require locking before accessing + * the pixel information, then the memory pointers will not change. + * + * If this function was able to toggle fullscreen mode (change from + * running in a window to fullscreen, or vice-versa), it will return 1. + * If it is not implemented, or fails, it returns 0. + * + * The next call to SDL_SetVideoMode() will set the mode fullscreen + * attribute based on the flags parameter - if SDL_FULLSCREEN is not + * set, then the display will be windowed by default where supported. + * + * This is currently only implemented in the X11 video driver. + */ +extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); + +typedef enum { + SDL_GRAB_QUERY = -1, + SDL_GRAB_OFF = 0, + SDL_GRAB_ON = 1, + SDL_GRAB_FULLSCREEN /**< Used internally */ +} SDL_GrabMode; +/** + * This function allows you to set and query the input grab state of + * the application. It returns the new input grab state. + * + * Grabbing means that the mouse is confined to the application window, + * and nearly all keyboard input is passed directly to the application, + * and not interpreted by a window manager, if any. + */ +extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); + +/*@}*/ + +/** @internal Not in public API at the moment - do not use! */ +extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, + SDL_Surface *dst, SDL_Rect *dstrect); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_video_h */ diff --git a/codemp/rd-rend2/SDL/begin_code.h b/codemp/rd-rend2/SDL/begin_code.h new file mode 100644 index 0000000000..27e2f7bc75 --- /dev/null +++ b/codemp/rd-rend2/SDL/begin_code.h @@ -0,0 +1,196 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** + * @file begin_code.h + * This file sets things up for C dynamic library function definitions, + * static inlined functions, and structures aligned at 4-byte alignment. + * If you don't like ugly C preprocessor code, don't look at this file. :) + */ + +/** + * @file begin_code.h + * This shouldn't be nested -- included it around code only. + */ +#ifdef _begin_code_h +#error Nested inclusion of begin_code.h +#endif +#define _begin_code_h + +/** + * @def DECLSPEC + * Some compilers use a special export keyword + */ +#ifndef DECLSPEC +# if defined(__BEOS__) || defined(__HAIKU__) +# if defined(__GNUC__) +# define DECLSPEC +# else +# define DECLSPEC __declspec(export) +# endif +# elif defined(__WIN32__) +# ifdef __BORLANDC__ +# ifdef BUILD_SDL +# define DECLSPEC +# else +# define DECLSPEC __declspec(dllimport) +# endif +# else +# define DECLSPEC __declspec(dllexport) +# endif +# elif defined(__OS2__) +# ifdef __WATCOMC__ +# ifdef BUILD_SDL +# define DECLSPEC __declspec(dllexport) +# else +# define DECLSPEC +# endif +# elif defined (__GNUC__) && __GNUC__ < 4 +# /* Added support for GCC-EMX = 4 +# define DECLSPEC __attribute__ ((visibility("default"))) +# else +# define DECLSPEC +# endif +# endif +#endif + +/** + * @def SDLCALL + * By default SDL uses the C calling convention + */ +#ifndef SDLCALL +# if defined(__WIN32__) && !defined(__GNUC__) +# define SDLCALL __cdecl +# elif defined(__OS2__) +# if defined (__GNUC__) && __GNUC__ < 4 +# /* Added support for GCC-EMX -#endif +#include "SDL/SDL_opengl.h" extern void (APIENTRYP qglActiveTextureARB) (GLenum texture); extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture); From 016e2e607d7b72440c7ea64b5957de064e424440 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:07:49 -0400 Subject: [PATCH 007/708] Lots of this {filtered} does not belong in tr_types.h, it isn't renderer-agnostic at all --- codemp/rd-common/tr_types.h | 33 ------------------------ codemp/rd-rend2/tr_local.h | 49 ++++++++++++++++++++++++++++++++++-- codemp/rd-vanilla/tr_local.h | 34 +++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 35 deletions(-) diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h index f8367fbf9a..9a27212d97 100644 --- a/codemp/rd-common/tr_types.h +++ b/codemp/rd-common/tr_types.h @@ -277,39 +277,6 @@ typedef struct skin_s { /* Ghoul2 Insert End */ -typedef enum { - MOD_BAD, - MOD_BRUSH, - MOD_MESH, -/* -Ghoul2 Insert Start -*/ - MOD_MDXM, - MOD_MDXA -/* -Ghoul2 Insert End -*/ -} modtype_t; - -typedef struct model_s { - char name[MAX_QPATH]; - modtype_t type; - int index; // model = tr.models[model->index] - - int dataSize; // just for listing purposes - struct bmodel_s *bmodel; // only if type == MOD_BRUSH - md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH -/* -Ghoul2 Insert Start -*/ - mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file - mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file -/* -Ghoul2 Insert End -*/ - int numLods; - qboolean bspInstance; -} model_t; #define MAX_RENDER_STRINGS 8 #define MAX_RENDER_STRING_LENGTH 32 diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2b059d0871..a118ef1e4c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -62,6 +62,44 @@ typedef unsigned int glIndex_t; #define USE_VERT_TANGENT_SPACE +typedef enum +{ + IMGTYPE_COLORALPHA, // for color, lightmap, diffuse, and specular + IMGTYPE_NORMAL, + IMGTYPE_NORMALHEIGHT, + IMGTYPE_DELUXE, // normals are swizzled, deluxe are not +} imgType_t; + +typedef enum +{ + IMGFLAG_NONE = 0x0000, + IMGFLAG_MIPMAP = 0x0001, + IMGFLAG_PICMIP = 0x0002, + IMGFLAG_CUBEMAP = 0x0004, + IMGFLAG_NO_COMPRESSION = 0x0010, + IMGFLAG_NOLIGHTSCALE = 0x0020, + IMGFLAG_CLAMPTOEDGE = 0x0040, + IMGFLAG_SRGB = 0x0080, + IMGFLAG_GENNORMALMAP = 0x0100, +} imgFlags_t; + +typedef struct image_s { + char imgName[MAX_QPATH]; // game path, including extension + int width, height; // source image + int uploadWidth, uploadHeight; // after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE + GLuint texnum; // gl texture binding + + int frameUsed; // for texture usage in frame statistics + + int internalFormat; + int TMU; // only needed for voodoo2 + + imgType_t type; + imgFlags_t flags; + + struct image_s* next; +} image_t; + typedef struct dlight_s { vec3_t origin; vec3_t color; // range from 0.0 to 1.0, should be color normalized @@ -336,7 +374,6 @@ typedef struct { } texModInfo_t; - #define MAX_IMAGE_ANIMATIONS 8 typedef struct { @@ -1449,7 +1486,15 @@ typedef enum { MOD_MESH, MOD_MD4, MOD_MDR, - MOD_IQM + MOD_IQM, +/* +Ghoul2 Insert Start +*/ + MOD_MDXM, + MOD_MDXA +/* +Ghoul2 Insert End +*/ } modtype_t; typedef struct model_s { diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 2833dcdfae..954f559327 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -35,6 +35,40 @@ typedef enum DLIGHT_PROJECTED } eDLightTypes; +typedef enum { + MOD_BAD, + MOD_BRUSH, + MOD_MESH, +/* +Ghoul2 Insert Start +*/ + MOD_MDXM, + MOD_MDXA +/* +Ghoul2 Insert End +*/ +} modtype_t; + +typedef struct model_s { + char name[MAX_QPATH]; + modtype_t type; + int index; // model = tr.models[model->index] + + int dataSize; // just for listing purposes + struct bmodel_s *bmodel; // only if type == MOD_BRUSH + md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH +/* +Ghoul2 Insert Start +*/ + mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file + mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file +/* +Ghoul2 Insert End +*/ + int numLods; + qboolean bspInstance; +} model_t; + typedef struct dlight_s { eDLightTypes mType; From bbc4f30019d7fcdcb0c4fbbaf37cc8fbc60ad910 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:10:00 -0400 Subject: [PATCH 008/708] Added MD4 file info to qfiles.h --- codemp/qcommon/qfiles.h | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/codemp/qcommon/qfiles.h b/codemp/qcommon/qfiles.h index 49ed747025..ac9a4f7cc6 100644 --- a/codemp/qcommon/qfiles.h +++ b/codemp/qcommon/qfiles.h @@ -146,6 +146,97 @@ typedef struct md3Header_s { int ofsEnd; // end of file } md3Header_t; +/* +============================================================================== + +MD4 file format + +============================================================================== +*/ + +#define MD4_IDENT (('4'<<24)+('P'<<16)+('D'<<8)+'I') +#define MD4_VERSION 1 +#define MD4_MAX_BONES 128 + +typedef struct { + int boneIndex; // these are indexes into the boneReferences, + float boneWeight; // not the global per-frame bone list + vec3_t offset; +} md4Weight_t; + +typedef struct { + vec3_t normal; + vec2_t texCoords; + int numWeights; + md4Weight_t weights[1]; // variable sized +} md4Vertex_t; + +typedef struct { + int indexes[3]; +} md4Triangle_t; + +typedef struct { + int ident; + + char name[MAX_QPATH]; // polyset name + char shader[MAX_QPATH]; + int shaderIndex; // for in-game use + + int ofsHeader; // this will be a negative number + + int numVerts; + int ofsVerts; + + int numTriangles; + int ofsTriangles; + + // Bone references are a set of ints representing all the bones + // present in any vertex weights for this surface. This is + // needed because a model may have surfaces that need to be + // drawn at different sort times, and we don't want to have + // to re-interpolate all the bones for each surface. + int numBoneReferences; + int ofsBoneReferences; + + int ofsEnd; // next surface follows +} md4Surface_t; + +typedef struct { + float matrix[3][4]; +} md4Bone_t; + +typedef struct { + vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame + vec3_t localOrigin; // midpoint of bounds, used for sphere cull + float radius; // dist from localOrigin to corner + md4Bone_t bones[1]; // [numBones] +} md4Frame_t; + +typedef struct { + int numSurfaces; + int ofsSurfaces; // first surface, others follow + int ofsEnd; // next lod follows +} md4LOD_t; + +typedef struct { + int ident; + int version; + + char name[MAX_QPATH]; // model name + + // frames and bones are shared by all levels of detail + int numFrames; + int numBones; + int ofsBoneNames; // char name[ MAX_QPATH ] + int ofsFrames; // md4Frame_t[numFrames] + + // each level of detail has completely separate sets of surfaces + int numLODs; + int ofsLODs; + + int ofsEnd; // end of file +} md4Header_t; + /* ============================================================================== From 793a7774fcebd851a04261344b825acbafb62b56 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:15:29 -0400 Subject: [PATCH 009/708] ri. --> ri-> --- codemp/rd-rend2/tr_animation.cpp | 2 +- codemp/rd-rend2/tr_backend.cpp | 34 +- codemp/rd-rend2/tr_bsp.cpp | 250 +++++++------- codemp/rd-rend2/tr_cmds.cpp | 36 +- codemp/rd-rend2/tr_curve.cpp | 30 +- codemp/rd-rend2/tr_extensions.cpp | 80 ++--- codemp/rd-rend2/tr_extramath.cpp | 8 +- codemp/rd-rend2/tr_fbo.cpp | 58 ++-- codemp/rd-rend2/tr_glsl.cpp | 106 +++--- codemp/rd-rend2/tr_image.cpp | 102 +++--- codemp/rd-rend2/tr_init.cpp | 536 ++++++++++++++--------------- codemp/rd-rend2/tr_light.cpp | 8 +- codemp/rd-rend2/tr_main.cpp | 20 +- codemp/rd-rend2/tr_mesh.cpp | 8 +- codemp/rd-rend2/tr_model.cpp | 102 +++--- codemp/rd-rend2/tr_model_iqm.cpp | 12 +- codemp/rd-rend2/tr_postprocess.cpp | 2 +- codemp/rd-rend2/tr_scene.cpp | 16 +- codemp/rd-rend2/tr_shade.cpp | 12 +- codemp/rd-rend2/tr_shade_calc.cpp | 20 +- codemp/rd-rend2/tr_shader.cpp | 282 +++++++-------- codemp/rd-rend2/tr_sky.cpp | 16 +- codemp/rd-rend2/tr_subs.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 6 +- codemp/rd-rend2/tr_vbo.cpp | 80 ++--- codemp/rd-rend2/tr_world.cpp | 8 +- 26 files changed, 919 insertions(+), 919 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index c4c9debb32..82254ceb19 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -346,7 +346,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { || (ent->e.oldframe >= header->numFrames) || (ent->e.oldframe < 0) ) { - ri.Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", + ri->Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index de05f53b75..a860ddec94 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -42,7 +42,7 @@ void GL_Bind2( image_t *image, GLenum type ) { int texnum; if ( !image ) { - ri.Printf( PRINT_WARNING, "GL_Bind2: NULL image\n" ); + ri->Printf( PRINT_WARNING, "GL_Bind2: NULL image\n" ); texnum = tr.defaultImage->texnum; } else { texnum = image->texnum; @@ -88,7 +88,7 @@ void GL_SelectTexture( int unit ) } if (!(unit >= 0 && unit <= 31)) - ri.Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); + ri->Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); qglActiveTextureARB( GL_TEXTURE0_ARB + unit ); @@ -209,7 +209,7 @@ void GL_TexEnv( int env ) qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); break; default: - ri.Error( ERR_DROP, "GL_TexEnv: invalid env '%d' passed", env ); + ri->Error( ERR_DROP, "GL_TexEnv: invalid env '%d' passed", env ); break; } } @@ -287,7 +287,7 @@ void GL_State( unsigned long stateBits ) srcFactor = GL_SRC_ALPHA_SATURATE; break; default: - ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); + ri->Error( ERR_DROP, "GL_State: invalid src blend state bits" ); break; } @@ -318,7 +318,7 @@ void GL_State( unsigned long stateBits ) dstFactor = GL_ONE_MINUS_DST_ALPHA; break; default: - ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); + ri->Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); break; } @@ -821,7 +821,7 @@ void RB_SetGL2D (void) { qglDisable( GL_CLIP_PLANE0 ); // set time for 2D shaders - backEnd.refdef.time = ri.Milliseconds(); + backEnd.refdef.time = ri->Milliseconds(); backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f; // reset color scaling @@ -854,7 +854,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * start = 0; if ( r_speeds->integer ) { - start = ri.Milliseconds(); + start = ri->Milliseconds(); } // make sure rows and cols are powers of 2 @@ -863,14 +863,14 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * for ( j = 0 ; ( 1 << j ) < rows ; j++ ) { } if ( ( 1 << i ) != cols || ( 1 << j ) != rows) { - ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); + ri->Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); } RE_UploadCinematic (w, h, cols, rows, data, client, dirty); if ( r_speeds->integer ) { - end = ri.Milliseconds(); - ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); + end = ri->Milliseconds(); + ri->Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); } // FIXME: HUGE hack @@ -1369,7 +1369,7 @@ void RB_ShowImages( void ) { qglFinish(); - start = ri.Milliseconds(); + start = ri->Milliseconds(); for ( i=0 ; iMilliseconds(); + ri->Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); } @@ -1506,7 +1506,7 @@ const void *RB_SwapBuffers( const void *data ) { long sum = 0; unsigned char *stencilReadback; - stencilReadback = ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); + stencilReadback = ri->Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { @@ -1514,7 +1514,7 @@ const void *RB_SwapBuffers( const void *data ) { } backEnd.pc.c_overDraw += sum; - ri.Hunk_FreeTempMemory( stencilReadback ); + ri->Hunk_FreeTempMemory( stencilReadback ); } if (glRefConfig.framebufferObject) @@ -1731,7 +1731,7 @@ RB_ExecuteRenderCommands void RB_ExecuteRenderCommands( const void *data ) { int t1, t2; - t1 = ri.Milliseconds (); + t1 = ri->Milliseconds (); while ( 1 ) { data = PADP(data, sizeof(void *)); @@ -1777,7 +1777,7 @@ void RB_ExecuteRenderCommands( const void *data ) { RB_EndSurface(); // stop rendering - t2 = ri.Milliseconds (); + t2 = ri->Milliseconds (); backEnd.pc.msec = t2 - t1; return; } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 01556cdd93..579b7fda7c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -242,7 +242,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } } - image = ri.Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); + image = ri->Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); if (tr.worldDeluxeMapping) numLightmaps >>= 1; @@ -256,7 +256,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { else if (r_mergeLightmaps->integer && numLightmaps >= 1024 ) { // FIXME: fat light maps don't support more than 1024 light maps - ri.Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n"); + ri->Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n"); numLightmaps = 1024; } @@ -283,11 +283,11 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.numLightmaps = numLightmaps; } - tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.lightmaps = ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); if (tr.worldDeluxeMapping) { - tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.deluxemaps = ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } if (r_hdr->integer && glRefConfig.textureFloat && glRefConfig.halfFloatPixel) @@ -332,15 +332,15 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { if (r_hdr->integer) { Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", s_worldData.baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + //ri->Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri.FS_ReadFile(filename, (void **)&hdrLightmap); + size = ri->FS_ReadFile(filename, (void **)&hdrLightmap); } if (hdrLightmap) { byte *p = hdrLightmap; - //ri.Printf(PRINT_ALL, "found!\n"); + //ri->Printf(PRINT_ALL, "found!\n"); /* FIXME: don't just skip over this header and actually parse it */ while (size && !(*p == '\n' && *(p+1) == '\n')) @@ -350,7 +350,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } if (!size) - ri.Error(ERR_DROP, "Bad header for %s!", filename); + ri->Error(ERR_DROP, "Bad header for %s!", filename); size -= 2; p += 2; @@ -368,10 +368,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { #if 0 // HDRFILE_RGBE if (size != tr.lightmapSize * tr.lightmapSize * 4) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); + ri->Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); #else // HDRFILE_FLOAT if (size != tr.lightmapSize * tr.lightmapSize * 12) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); + ri->Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); #endif } else @@ -474,7 +474,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat ); if (hdrLightmap) - ri.FS_FreeFile(hdrLightmap); + ri->FS_FreeFile(hdrLightmap); } if (tr.worldDeluxeMapping) @@ -509,10 +509,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } if ( r_lightmap->integer == 2 ) { - ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); + ri->Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); } - ri.Free(image); + ri->Free(image); } @@ -596,7 +596,7 @@ static void R_LoadVisibility( lump_t *l ) { byte *buf; len = ( s_worldData.numClusters + 63 ) & ~63; - s_worldData.novis = ri.Hunk_Alloc( len, h_low ); + s_worldData.novis = ri->Hunk_Alloc( len, h_low ); Com_Memset( s_worldData.novis, 0xff, len ); len = l->filelen; @@ -615,7 +615,7 @@ static void R_LoadVisibility( lump_t *l ) { } else { byte *dest; - dest = ri.Hunk_Alloc( len - 8, h_low ); + dest = ri->Hunk_Alloc( len - 8, h_low ); Com_Memcpy( dest, buf + 8, len - 8 ); s_worldData.vis = dest; } @@ -635,7 +635,7 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { int _shaderNum = LittleLong( shaderNum ); if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) { - ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); + ri->Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); } dsh = &s_worldData.shaders[ _shaderNum ]; @@ -682,22 +682,22 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, numVerts = LittleLong(ds->numVerts); if (numVerts > MAX_FACE_POINTS) { - ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); + ri->Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); numVerts = MAX_FACE_POINTS; surf->shader = tr.defaultShader; } numTriangles = LittleLong(ds->numIndexes) / 3; - //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); + //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); cv = (void *)surf->data; cv->surfaceType = SF_FACE; cv->numTriangles = numTriangles; - cv->triangles = ri.Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->triangles = ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); cv->numVerts = numVerts; - cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); // copy vertexes surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; @@ -760,7 +760,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) { - ri.Error(ERR_DROP, "Bad index in face surface"); + ri->Error(ERR_DROP, "Bad index in face surface"); } } @@ -773,7 +773,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, if (badTriangles) { - ri.Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); + ri->Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); cv->numTriangles -= badTriangles; } @@ -843,7 +843,7 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, height = LittleLong( ds->patchHeight ); if(width < 0 || width > MAX_PATCH_SIZE || height < 0 || height > MAX_PATCH_SIZE) - ri.Error(ERR_DROP, "ParseMesh: bad size"); + ri->Error(ERR_DROP, "ParseMesh: bad size"); verts += LittleLong( ds->firstVert ); numPoints = width * height; @@ -932,15 +932,15 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor numVerts = LittleLong(ds->numVerts); numTriangles = LittleLong(ds->numIndexes) / 3; - //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); + //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); cv = (void *)surf->data; cv->surfaceType = SF_TRIANGLES; cv->numTriangles = numTriangles; - cv->triangles = ri.Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->triangles = ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); cv->numVerts = numVerts; - cv->verts = ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); surf->data = (surfaceType_t *) cv; @@ -1004,7 +1004,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) { - ri.Error(ERR_DROP, "Bad index in face surface"); + ri->Error(ERR_DROP, "Bad index in face surface"); } } @@ -1017,7 +1017,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor if (badTriangles) { - ri.Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); + ri->Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); cv->numTriangles -= badTriangles; } @@ -1056,7 +1056,7 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int surf->shader = tr.defaultShader; } - //flare = ri.Hunk_Alloc( sizeof( *flare ), h_low ); + //flare = ri->Hunk_Alloc( sizeof( *flare ), h_low ); flare = (void *)surf->data; flare->surfaceType = SF_FLARE; @@ -1307,7 +1307,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1351,7 +1351,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1404,7 +1404,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1448,7 +1448,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1502,7 +1502,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1546,7 +1546,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1601,7 +1601,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1645,7 +1645,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1730,7 +1730,7 @@ void R_StitchAllPatches( void ) { } } while (stitched); - ri.Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); + ri->Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); } /* @@ -1750,21 +1750,21 @@ void R_MovePatchSurfacesToHunk(void) { continue; // size = sizeof(*grid); - hunkgrid = ri.Hunk_Alloc(size, h_low); + hunkgrid = ri->Hunk_Alloc(size, h_low); Com_Memcpy(hunkgrid, grid, size); - hunkgrid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low ); + hunkgrid->widthLodError = ri->Hunk_Alloc( grid->width * 4, h_low ); Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 ); - hunkgrid->heightLodError = ri.Hunk_Alloc( grid->height * 4, h_low ); + hunkgrid->heightLodError = ri->Hunk_Alloc( grid->height * 4, h_low ); Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 ); hunkgrid->numTriangles = grid->numTriangles; - hunkgrid->triangles = ri.Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); + hunkgrid->triangles = ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); Com_Memcpy(hunkgrid->triangles, grid->triangles, grid->numTriangles * sizeof(srfTriangle_t)); hunkgrid->numVerts = grid->numVerts; - hunkgrid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + hunkgrid->verts = ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); Com_Memcpy(hunkgrid->verts, grid->verts, grid->numVerts * sizeof(srfVert_t)); R_FreeSurfaceGridMesh( grid ); @@ -1854,7 +1854,7 @@ static void R_CreateWorldVBO(void) int startTime, endTime; - startTime = ri.Milliseconds(); + startTime = ri->Milliseconds(); numVerts = 0; numTriangles = 0; @@ -1902,16 +1902,16 @@ static void R_CreateWorldVBO(void) if(!numVerts || !numTriangles) return; - ri.Printf(PRINT_ALL, "...calculating world VBO ( %i verts %i tris )\n", numVerts, numTriangles); + ri->Printf(PRINT_ALL, "...calculating world VBO ( %i verts %i tris )\n", numVerts, numTriangles); // create arrays - verts = ri.Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + verts = ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); - triangles = ri.Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); + triangles = ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); // presort surfaces - surfacesSorted = ri.Malloc(numSurfaces * sizeof(*surfacesSorted)); + surfacesSorted = ri->Malloc(numSurfaces * sizeof(*surfacesSorted)); j = 0; for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces; k++, surface++) @@ -2084,8 +2084,8 @@ static void R_CreateWorldVBO(void) s_worldData.ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", 0), numTriangles, triangles, VBO_USAGE_STATIC); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "world VBO calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); + endTime = ri->Milliseconds(); + ri->Printf(PRINT_ALL, "world VBO calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); // point triangle surfaces to world VBO for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) @@ -2123,10 +2123,10 @@ static void R_CreateWorldVBO(void) } - ri.Free(surfacesSorted); + ri->Free(surfacesSorted); - ri.Hunk_FreeTempMemory(triangles); - ri.Hunk_FreeTempMemory(verts); + ri->Hunk_FreeTempMemory(triangles); + ri->Hunk_FreeTempMemory(verts); } /* @@ -2150,24 +2150,24 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { numFlares = 0; if (surfs->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = surfs->filelen / sizeof(*in); dv = (void *)(fileBase + verts->fileofs); if (verts->filelen % sizeof(*dv)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); indexes = (void *)(fileBase + indexLump->fileofs); if ( indexLump->filelen % sizeof(*indexes)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - out = ri.Hunk_Alloc ( count * sizeof(*out), h_low ); + out = ri->Hunk_Alloc ( count * sizeof(*out), h_low ); s_worldData.surfaces = out; s_worldData.numsurfaces = count; - s_worldData.surfacesViewCount = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); - s_worldData.surfacesDlightBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); - s_worldData.surfacesPshadowBits = ri.Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); + s_worldData.surfacesViewCount = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); + s_worldData.surfacesDlightBits = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); + s_worldData.surfacesPshadowBits = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); // load hdr vertex colors if (r_hdr->integer) @@ -2176,15 +2176,15 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { int size; Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", s_worldData.baseName); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + //ri->Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri.FS_ReadFile(filename, (void **)&hdrVertColors); + size = ri->FS_ReadFile(filename, (void **)&hdrVertColors); if (hdrVertColors) { - //ri.Printf(PRINT_ALL, "Found!\n"); + //ri->Printf(PRINT_ALL, "Found!\n"); if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv))) - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); + ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); } } @@ -2200,13 +2200,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // FIXME: do this break; case MST_TRIANGLE_SOUP: - out->data = ri.Hunk_Alloc( sizeof(srfTriangles_t), h_low); + out->data = ri->Hunk_Alloc( sizeof(srfTriangles_t), h_low); break; case MST_PLANAR: - out->data = ri.Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); + out->data = ri->Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); break; case MST_FLARE: - out->data = ri.Hunk_Alloc( sizeof(srfFlare_t), h_low); + out->data = ri->Hunk_Alloc( sizeof(srfFlare_t), h_low); break; default: break; @@ -2246,13 +2246,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { numFlares++; break; default: - ri.Error( ERR_DROP, "Bad surfaceType" ); + ri->Error( ERR_DROP, "Bad surfaceType" ); } } if (hdrVertColors) { - ri.FS_FreeFile(hdrVertColors); + ri->FS_FreeFile(hdrVertColors); } #ifdef PATCH_STITCHING @@ -2265,7 +2265,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { R_MovePatchSurfacesToHunk(); #endif - ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", + ri->Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } @@ -2283,11 +2283,11 @@ static void R_LoadSubmodels( lump_t *l ) { in = (void *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); s_worldData.numBModels = count; - s_worldData.bmodels = out = ri.Hunk_Alloc( count * sizeof(*out), h_low ); + s_worldData.bmodels = out = ri->Hunk_Alloc( count * sizeof(*out), h_low ); for ( i=0 ; iError(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed"); } model->type = MOD_BRUSH; @@ -2352,12 +2352,12 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { in = (void *)(fileBase + nodeLump->fileofs); if (nodeLump->filelen % sizeof(dnode_t) || leafLump->filelen % sizeof(dleaf_t) ) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } numNodes = nodeLump->filelen / sizeof(dnode_t); numLeafs = leafLump->filelen / sizeof(dleaf_t); - out = ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); + out = ri->Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); s_worldData.nodes = out; s_worldData.numnodes = numNodes + numLeafs; @@ -2425,9 +2425,9 @@ static void R_LoadShaders( lump_t *l ) { in = (void *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*sizeof(*out), h_low ); + out = ri->Hunk_Alloc ( count*sizeof(*out), h_low ); s_worldData.shaders = out; s_worldData.numShaders = count; @@ -2454,9 +2454,9 @@ static void R_LoadMarksurfaces (lump_t *l) in = (void *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*sizeof(*out), h_low); + out = ri->Hunk_Alloc ( count*sizeof(*out), h_low); s_worldData.marksurfaces = out; s_worldData.nummarksurfaces = count; @@ -2483,9 +2483,9 @@ static void R_LoadPlanes( lump_t *l ) { in = (void *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); + out = ri->Hunk_Alloc ( count*2*sizeof(*out), h_low); s_worldData.planes = out; s_worldData.numplanes = count; @@ -2526,13 +2526,13 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { fogs = (void *)(fileBase + l->fileofs); if (l->filelen % sizeof(*fogs)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } count = l->filelen / sizeof(*fogs); // create fog strucutres for them s_worldData.numfogs = count + 1; - s_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); + s_worldData.fogs = ri->Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); out = s_worldData.fogs + 1; if ( !count ) { @@ -2541,13 +2541,13 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { brushes = (void *)(fileBase + brushesLump->fileofs); if (brushesLump->filelen % sizeof(*brushes)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } brushesCount = brushesLump->filelen / sizeof(*brushes); sides = (void *)(fileBase + sidesLump->fileofs); if (sidesLump->filelen % sizeof(*sides)) { - ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } sidesCount = sidesLump->filelen / sizeof(*sides); @@ -2555,14 +2555,14 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { out->originalBrushNumber = LittleLong( fogs->brushNum ); if ( (unsigned)out->originalBrushNumber >= brushesCount ) { - ri.Error( ERR_DROP, "fog brushNumber out of range" ); + ri->Error( ERR_DROP, "fog brushNumber out of range" ); } brush = brushes + out->originalBrushNumber; firstSide = LittleLong( brush->firstSide ); if ( (unsigned)firstSide > sidesCount - 6 ) { - ri.Error( ERR_DROP, "fog brush sideNumber out of range" ); + ri->Error( ERR_DROP, "fog brush sideNumber out of range" ); } // brushes are always sorted with the axial sides first @@ -2651,12 +2651,12 @@ void R_LoadLightGrid( lump_t *l ) { numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; if ( l->filelen != numGridPoints * 8 ) { - ri.Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" ); + ri->Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" ); w->lightGridData = NULL; return; } - w->lightGridData = ri.Hunk_Alloc( l->filelen, h_low ); + w->lightGridData = ri->Hunk_Alloc( l->filelen, h_low ); Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits @@ -2673,22 +2673,22 @@ void R_LoadLightGrid( lump_t *l ) { int size; Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", s_worldData.baseName); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); + //ri->Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri.FS_ReadFile(filename, (void **)&hdrLightGrid); + size = ri->FS_ReadFile(filename, (void **)&hdrLightGrid); if (hdrLightGrid) { float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits); - //ri.Printf(PRINT_ALL, "found!\n"); + //ri->Printf(PRINT_ALL, "found!\n"); if (size != sizeof(float) * 6 * numGridPoints) { - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); + ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); } - w->hdrLightGrid = ri.Hunk_Alloc(size, h_low); + w->hdrLightGrid = ri->Hunk_Alloc(size, h_low); for (i = 0; i < numGridPoints ; i++) { @@ -2702,7 +2702,7 @@ void R_LoadLightGrid( lump_t *l ) { } if (hdrLightGrid) - ri.FS_FreeFile(hdrLightGrid); + ri->FS_FreeFile(hdrLightGrid); } } @@ -2725,7 +2725,7 @@ void R_LoadEntities( lump_t *l ) { p = (char *)(fileBase + l->fileofs); // store for reference by the cgame - w->entityString = ri.Hunk_Alloc( l->filelen + 1, h_low ); + w->entityString = ri->Hunk_Alloc( l->filelen + 1, h_low ); strcpy( w->entityString, p ); w->entityParsePoint = w->entityString; @@ -2757,7 +2757,7 @@ void R_LoadEntities( lump_t *l ) { if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { - ri.Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); + ri->Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); break; } *s++ = 0; @@ -2771,7 +2771,7 @@ void R_LoadEntities( lump_t *l ) { if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { - ri.Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); + ri->Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); break; } *s++ = 0; @@ -2834,7 +2834,7 @@ void R_MergeLeafSurfaces(void) int startTime, endTime; - startTime = ri.Milliseconds(); + startTime = ri->Milliseconds(); numWorldSurfaces = s_worldData.numWorldSurfaces; @@ -2845,12 +2845,12 @@ void R_MergeLeafSurfaces(void) } // create ibo - ibo = tr.ibos[tr.numIBOs++] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs++] = ri->Hunk_Alloc(sizeof(*ibo), h_low); memset(ibo, 0, sizeof(*ibo)); Q_strncpyz(ibo->name, "staticWorldMesh_IBO_mergedSurfs", sizeof(ibo->name)); // allocate more than we need - iboIndexes = outIboIndexes = ri.Malloc(s_worldData.ibo->indexesSize); + iboIndexes = outIboIndexes = ri->Malloc(s_worldData.ibo->indexesSize); // mark matching surfaces for (i = 0; i < s_worldData.numnodes - s_worldData.numDecisionNodes; i++) @@ -2961,15 +2961,15 @@ void R_MergeLeafSurfaces(void) } // Allocate merged surfaces - s_worldData.mergedSurfaces = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesViewCount = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesDlightBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesPshadowBits = ri.Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + s_worldData.mergedSurfaces = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesViewCount = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesDlightBits = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesPshadowBits = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); s_worldData.numMergedSurfaces = numMergedSurfaces; // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on - s_worldData.viewSurfaces = ri.Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); + s_worldData.viewSurfaces = ri->Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); // copy view surfaces into mark surfaces for (i = 0; i < s_worldData.nummarksurfaces; i++) @@ -3127,7 +3127,7 @@ void R_MergeLeafSurfaces(void) } } - vboSurf = ri.Hunk_Alloc(sizeof(*vboSurf), h_low); + vboSurf = ri->Hunk_Alloc(sizeof(*vboSurf), h_low); memset(vboSurf, 0, sizeof(*vboSurf)); vboSurf->surfaceType = SF_VBO_MESH; @@ -3194,11 +3194,11 @@ void R_MergeLeafSurfaces(void) GL_CheckErrors(); - ri.Free(iboIndexes); + ri->Free(iboIndexes); - endTime = ri.Milliseconds(); + endTime = ri->Milliseconds(); - ri.Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", + ri->Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); // reset viewcounts @@ -3273,7 +3273,7 @@ void RE_LoadWorldMap( const char *name ) { byte *startMarker; if ( tr.worldMapLoaded ) { - ri.Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); + ri->Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); } // set default map light scale @@ -3300,9 +3300,9 @@ void RE_LoadWorldMap( const char *name ) { tr.worldMapLoaded = qtrue; // load it - ri.FS_ReadFile( name, &buffer.v ); + ri->FS_ReadFile( name, &buffer.v ); if ( !buffer.b ) { - ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); + ri->Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); } // clear tr.world so if the level fails to load, the next @@ -3315,7 +3315,7 @@ void RE_LoadWorldMap( const char *name ) { Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); COM_StripExtension(s_worldData.baseName, s_worldData.baseName, sizeof(s_worldData.baseName)); - startMarker = ri.Hunk_Alloc(0, h_low); + startMarker = ri->Hunk_Alloc(0, h_low); c_gridVerts = 0; header = (dheader_t *)buffer.b; @@ -3323,7 +3323,7 @@ void RE_LoadWorldMap( const char *name ) { i = LittleLong (header->version); if ( i != BSP_VERSION ) { - ri.Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", + ri->Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", name, i, BSP_VERSION); } @@ -3359,7 +3359,7 @@ void RE_LoadWorldMap( const char *name ) { int i; lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; - primaryLightGrid = ri.Malloc(lightGridSize * sizeof(*primaryLightGrid)); + primaryLightGrid = ri->Malloc(lightGridSize * sizeof(*primaryLightGrid)); memset(primaryLightGrid, 0, lightGridSize * sizeof(*primaryLightGrid)); @@ -3405,7 +3405,7 @@ void RE_LoadWorldMap( const char *name ) { if (0) { int i; - byte *buffer = ri.Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); + byte *buffer = ri->Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); byte *out; uint8_t *in; char fileName[MAX_QPATH]; @@ -3449,10 +3449,10 @@ void RE_LoadWorldMap( const char *name ) { in++; } - ri.FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); + ri->FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); } - ri.Free(buffer); + ri->Free(buffer); } for (i = 0; i < w->numWorldSurfaces; i++) @@ -3464,7 +3464,7 @@ void RE_LoadWorldMap( const char *name ) { { if (DotProduct(ci->plane.normal, tr.sunDirection) <= 0.0f) { - //ri.Printf(PRINT_ALL, "surface %d is not oriented towards sunlight\n", i); + //ri->Printf(PRINT_ALL, "surface %d is not oriented towards sunlight\n", i); continue; } } @@ -3495,7 +3495,7 @@ void RE_LoadWorldMap( const char *name ) { ibounds[1][2] = CLAMP(ibounds[1][2], 0, w->lightGridSize[2]); /* - ri.Printf(PRINT_ALL, "surf %d bounds (%f %f %f)-(%f %f %f) ibounds (%d %d %d)-(%d %d %d)\n", i, + ri->Printf(PRINT_ALL, "surf %d bounds (%f %f %f)-(%f %f %f) ibounds (%d %d %d)-(%d %d %d)\n", i, ci->bounds[0][0], ci->bounds[0][1], ci->bounds[0][2], ci->bounds[1][0], ci->bounds[1][1], ci->bounds[1][2], ibounds[0][0], ibounds[0][1], ibounds[0][2], @@ -3526,13 +3526,13 @@ void RE_LoadWorldMap( const char *name ) { // FIXME: magic number for determining whether object is mostly in sunlight if (goodSamples > numSamples * 0.75f) { - //ri.Printf(PRINT_ALL, "surface %d is in sunlight\n", i); + //ri->Printf(PRINT_ALL, "surface %d is in sunlight\n", i); //surf->primaryLight = 1; } } } - ri.Free(primaryLightGrid); + ri->Free(primaryLightGrid); } // create static VBOS from the world @@ -3542,7 +3542,7 @@ void RE_LoadWorldMap( const char *name ) { R_MergeLeafSurfaces(); } - s_worldData.dataSize = (byte *)ri.Hunk_Alloc(0, h_low) - startMarker; + s_worldData.dataSize = (byte *)ri->Hunk_Alloc(0, h_low) - startMarker; // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; @@ -3551,5 +3551,5 @@ void RE_LoadWorldMap( const char *name ) { R_BindNullVBO(); R_BindNullIBO(); - ri.FS_FreeFile( buffer.v ); + ri->FS_FreeFile( buffer.v ); } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 1426b581a8..4f5da66b33 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -35,40 +35,40 @@ void R_PerformanceCounters( void ) { } if (r_speeds->integer == 1) { - ri.Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", + ri->Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); } else if (r_speeds->integer == 2) { - ri.Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + ri->Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, tr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out ); - ri.Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + ri->Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, tr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out ); } else if (r_speeds->integer == 3) { - ri.Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); + ri->Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); } else if (r_speeds->integer == 4) { if ( backEnd.pc.c_dlightVertexes ) { - ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", + ri->Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", tr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled, backEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 ); } } else if (r_speeds->integer == 5 ) { - ri.Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); + ri->Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); } else if (r_speeds->integer == 6 ) { - ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", + ri->Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", backEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders ); } else if (r_speeds->integer == 7 ) { - ri.Printf( PRINT_ALL, "VBO draws: static %i dynamic %i\nMultidraws: %i merged %i\n", + ri->Printf( PRINT_ALL, "VBO draws: static %i dynamic %i\nMultidraws: %i merged %i\n", backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged ); - ri.Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", + ri->Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); } @@ -135,7 +135,7 @@ void *R_GetCommandBuffer( int bytes ) { // always leave room for the end of list command if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) { if ( bytes > MAX_RENDER_COMMANDS - 4 ) { - ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); + ri->Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); } // if we run out of room, just start dropping commands return NULL; @@ -339,14 +339,14 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { { if ( glConfig.stencilBits < 4 ) { - ri.Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); - ri.Cvar_Set( "r_measureOverdraw", "0" ); + ri->Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); + ri->Cvar_Set( "r_measureOverdraw", "0" ); r_measureOverdraw->modified = qfalse; } else if ( r_shadows->integer == 2 ) { - ri.Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); - ri.Cvar_Set( "r_measureOverdraw", "0" ); + ri->Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); + ri->Cvar_Set( "r_measureOverdraw", "0" ); r_measureOverdraw->modified = qfalse; } else @@ -396,7 +396,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { R_IssuePendingRenderCommands(); if ((err = qglGetError()) != GL_NO_ERROR) - ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); + ri->Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); } if (glConfig.stereoEnabled) { @@ -410,7 +410,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else if ( stereoFrame == STEREO_RIGHT ) { cmd->buffer = (int)GL_BACK_RIGHT; } else { - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); } } else @@ -480,7 +480,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { return; } else - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer); colcmd->commandId = RC_COLORMASK; @@ -488,7 +488,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { else { if(stereoFrame != STEREO_CENTER) - ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); + ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) return; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 3d43925706..b1c1eabcfd 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -432,37 +432,37 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri.Hunk_Alloc*/ ri.Malloc( size ); + grid = /*ri->Hunk_Alloc*/ ri->Malloc( size ); Com_Memset(grid, 0, size); - grid->widthLodError = /*ri.Hunk_Alloc*/ ri.Malloc( width * 4 ); + grid->widthLodError = /*ri->Hunk_Alloc*/ ri->Malloc( width * 4 ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = /*ri.Hunk_Alloc*/ ri.Malloc( height * 4 ); + grid->heightLodError = /*ri->Hunk_Alloc*/ ri->Malloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numTriangles = numTriangles; - grid->triangles = ri.Malloc(grid->numTriangles * sizeof(srfTriangle_t)); + grid->triangles = ri->Malloc(grid->numTriangles * sizeof(srfTriangle_t)); Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); grid->numVerts = (width * height); - grid->verts = ri.Malloc(grid->numVerts * sizeof(srfVert_t)); + grid->verts = ri->Malloc(grid->numVerts * sizeof(srfVert_t)); #else - grid = ri.Hunk_Alloc( size ); + grid = ri->Hunk_Alloc( size ); Com_Memset(grid, 0, size); - grid->widthLodError = ri.Hunk_Alloc( width * 4 ); + grid->widthLodError = ri->Hunk_Alloc( width * 4 ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = ri.Hunk_Alloc( height * 4 ); + grid->heightLodError = ri->Hunk_Alloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numTriangles = numTriangles; - grid->triangles = ri.Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); + grid->triangles = ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); grid->numVerts = (width * height); - grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + grid->verts = ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); #endif grid->width = width; @@ -495,11 +495,11 @@ R_FreeSurfaceGridMesh ================= */ void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) { - ri.Free(grid->widthLodError); - ri.Free(grid->heightLodError); - ri.Free(grid->triangles); - ri.Free(grid->verts); - ri.Free(grid); + ri->Free(grid->widthLodError); + ri->Free(grid->heightLodError); + ri->Free(grid->triangles); + ri->Free(grid->verts); + ri->Free(grid); } /* diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 0b70d48b8a..366bf3a7f5 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -204,11 +204,11 @@ void GLimp_InitExtraExtensions() if ( r_ext_draw_range_elements->integer) glRefConfig.drawRangeElements = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_multi_draw_arrays @@ -224,11 +224,11 @@ void GLimp_InitExtraExtensions() if ( r_ext_multi_draw_arrays->integer ) glRefConfig.multiDrawArrays = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.multiDrawArrays], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.multiDrawArrays], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_vertex_program @@ -249,12 +249,12 @@ void GLimp_InitExtraExtensions() qglDisableVertexAttribArrayARB = (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) SDL_GL_GetProcAddress("glDisableVertexAttribArrayARB"); - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexProgram = qtrue; } else { - ri.Error(ERR_FATAL, result[2], extension); + ri->Error(ERR_FATAL, result[2], extension); } // GL_ARB_vertex_buffer_object @@ -280,12 +280,12 @@ void GLimp_InitExtraExtensions() qglGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) SDL_GL_GetProcAddress("glGetBufferSubDataARB"); qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetBufferParameterivARB"); qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) SDL_GL_GetProcAddress("glGetBufferPointervARB"); - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexBufferObject = qtrue; } else { - ri.Error(ERR_FATAL, result[2], extension); + ri->Error(ERR_FATAL, result[2], extension); } // GL_ARB_shader_objects @@ -369,12 +369,12 @@ void GLimp_InitExtraExtensions() qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) SDL_GL_GetProcAddress("glGetUniformfvARB"); qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) SDL_GL_GetProcAddress("glGetUniformivARB"); qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glGetShaderSourceARB"); - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.shaderObjects = qtrue; } else { - ri.Error(ERR_FATAL, result[2], extension); + ri->Error(ERR_FATAL, result[2], extension); } // GL_ARB_vertex_shader @@ -410,12 +410,12 @@ void GLimp_InitExtraExtensions() qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glBindAttribLocationARB"); qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) SDL_GL_GetProcAddress("glGetActiveAttribARB"); qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetAttribLocationARB"); - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexShader = qtrue; } else { - ri.Error(ERR_FATAL, result[2], extension); + ri->Error(ERR_FATAL, result[2], extension); } // GL_ARB_shading_language_100 @@ -429,11 +429,11 @@ void GLimp_InitExtraExtensions() sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); - ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version); + ri->Printf(PRINT_ALL, "...using GLSL version %s\n", version); } else { - ri.Error(ERR_FATAL, result[2], extension); + ri->Error(ERR_FATAL, result[2], extension); } glRefConfig.memInfo = MI_NONE; @@ -456,11 +456,11 @@ void GLimp_InitExtraExtensions() glRefConfig.textureNonPowerOfTwo = qtrue; } - ri.Printf(PRINT_ALL, result[glRefConfig.textureNonPowerOfTwo], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.textureNonPowerOfTwo], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_texture_float @@ -473,11 +473,11 @@ void GLimp_InitExtraExtensions() glRefConfig.textureFloat = qtrue; } - ri.Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_half_float_pixel @@ -488,11 +488,11 @@ void GLimp_InitExtraExtensions() if( r_arb_half_float_pixel->integer ) glRefConfig.halfFloatPixel = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.halfFloatPixel], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.halfFloatPixel], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_framebuffer_object @@ -524,11 +524,11 @@ void GLimp_InitExtraExtensions() if(r_ext_framebuffer_object->value) glRefConfig.framebufferObject = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_packed_depth_stencil @@ -537,11 +537,11 @@ void GLimp_InitExtraExtensions() if( GLimp_HaveExtension(extension)) { glRefConfig.packedDepthStencil = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.packedDepthStencil], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.packedDepthStencil], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_occlusion_query @@ -558,11 +558,11 @@ void GLimp_InitExtraExtensions() qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectivARB"); qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectuivARB"); glRefConfig.occlusionQuery = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_framebuffer_blit @@ -572,11 +572,11 @@ void GLimp_InitExtraExtensions() { qglBlitFramebufferEXT = (void *)SDL_GL_GetProcAddress("glBlitFramebufferEXT"); glRefConfig.framebufferBlit = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_framebuffer_multisample @@ -586,11 +586,11 @@ void GLimp_InitExtraExtensions() { qglRenderbufferStorageMultisampleEXT = (void *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_EXT_texture_sRGB @@ -601,11 +601,11 @@ void GLimp_InitExtraExtensions() if (r_srgb->integer) glRefConfig.texture_srgb = qtrue; - ri.Printf(PRINT_ALL, result[glRefConfig.texture_srgb], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.texture_srgb], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } glRefConfig.textureCompression = TCR_NONE; @@ -617,11 +617,11 @@ void GLimp_InitExtraExtensions() if (r_ext_compressed_textures->integer) glRefConfig.textureCompression |= TCR_LATC; - ri.Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension); + ri->Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_texture_compression_bptc @@ -631,11 +631,11 @@ void GLimp_InitExtraExtensions() if (r_ext_compressed_textures->integer >= 2) glRefConfig.textureCompression |= TCR_BPTC; - ri.Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension); + ri->Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_draw_buffers @@ -645,11 +645,11 @@ void GLimp_InitExtraExtensions() { qglDrawBuffersARB = (void *) SDL_GL_GetProcAddress("glDrawBuffersARB"); - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } // GL_ARB_depth_clamp @@ -658,10 +658,10 @@ void GLimp_InitExtraExtensions() if( GLimp_HaveExtension( extension ) ) { glRefConfig.depthClamp = qtrue; - ri.Printf(PRINT_ALL, result[1], extension); + ri->Printf(PRINT_ALL, result[1], extension); } else { - ri.Printf(PRINT_ALL, result[2], extension); + ri->Printf(PRINT_ALL, result[2], extension); } } diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 8cb6fe1a61..f7d3260479 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -91,10 +91,10 @@ qboolean Matrix16Compare( const matrix_t a, const matrix_t b ) void Matrix16Dump( const matrix_t in ) { - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); - ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); + ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); + ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); + ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); + ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); } void Matrix16Translation( vec3_t vec, matrix_t out ) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index fee11d5cf3..63cf7510f2 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -51,42 +51,42 @@ qboolean R_CheckFBO(const FBO_t * fbo) break; case GL_FRAMEBUFFER_UNSUPPORTED_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing attachment\n", fbo->name); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing attachment\n", fbo->name); break; //case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - // ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, duplicate attachment\n", fbo->name); + // ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, duplicate attachment\n", fbo->name); // break; case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same dimensions\n", + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same dimensions\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same format\n", + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same format\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); break; default: - ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); - //ri.Error(ERR_FATAL, "R_CheckFBO: (%s) unknown error 0x%X", fbo->name, code); + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); + //ri->Error(ERR_FATAL, "R_CheckFBO: (%s) unknown error 0x%X", fbo->name, code); //assert(0); break; } @@ -107,25 +107,25 @@ FBO_t *FBO_Create(const char *name, int width, int height) if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); + ri->Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); } if(width <= 0 || width > glRefConfig.maxRenderbufferSize) { - ri.Error(ERR_DROP, "FBO_Create: bad width %i", width); + ri->Error(ERR_DROP, "FBO_Create: bad width %i", width); } if(height <= 0 || height > glRefConfig.maxRenderbufferSize) { - ri.Error(ERR_DROP, "FBO_Create: bad height %i", height); + ri->Error(ERR_DROP, "FBO_Create: bad height %i", height); } if(tr.numFBOs == MAX_FBOS) { - ri.Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); + ri->Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); } - fbo = tr.fbos[tr.numFBOs] = ri.Hunk_Alloc(sizeof(*fbo), h_low); + fbo = tr.fbos[tr.numFBOs] = ri->Hunk_Alloc(sizeof(*fbo), h_low); Q_strncpyz(fbo->name, name, sizeof(fbo->name)); fbo->index = tr.numFBOs++; fbo->width = width; @@ -184,7 +184,7 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) break; default: - ri.Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); + ri->Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); return; } @@ -224,7 +224,7 @@ void R_AttachFBOTexture1D(int texId, int index) { if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri.Printf(PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index); + ri->Printf(PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index); return; } @@ -240,13 +240,13 @@ void R_AttachFBOTexture2D(int target, int texId, int index) { if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { - ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); + ri->Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); return; } if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); + ri->Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); return; } @@ -262,7 +262,7 @@ void R_AttachFBOTexture3D(int texId, int index, int zOffset) { if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri.Printf(PRINT_WARNING, "R_AttachFBOTexture3D: invalid attachment index %i\n", index); + ri->Printf(PRINT_WARNING, "R_AttachFBOTexture3D: invalid attachment index %i\n", index); return; } @@ -294,7 +294,7 @@ void FBO_AttachTextureImage(image_t *img, int index) { if (!glState.currentFBO) { - ri.Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); + ri->Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); return; } @@ -361,7 +361,7 @@ void FBO_Init(void) // int width, height, hdrFormat, multisample; int hdrFormat, multisample; - ri.Printf(PRINT_ALL, "------- FBO_Init -------\n"); + ri->Printf(PRINT_ALL, "------- FBO_Init -------\n"); if(!glRefConfig.framebufferObject) return; @@ -401,7 +401,7 @@ void FBO_Init(void) if (multisample != r_ext_framebuffer_multisample->integer) { - ri.Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); + ri->Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); } // only create a render FBO if we need to resolve MSAA or do HDR @@ -594,7 +594,7 @@ void FBO_Shutdown(void) int i, j; FBO_t *fbo; - ri.Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); + ri->Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); if(!glRefConfig.framebufferObject) return; @@ -634,21 +634,21 @@ void R_FBOList_f(void) if(!glRefConfig.framebufferObject) { - ri.Printf(PRINT_ALL, "GL_EXT_framebuffer_object is not available.\n"); + ri->Printf(PRINT_ALL, "GL_EXT_framebuffer_object is not available.\n"); return; } - ri.Printf(PRINT_ALL, " size name\n"); - ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); + ri->Printf(PRINT_ALL, " size name\n"); + ri->Printf(PRINT_ALL, "----------------------------------------------------------\n"); for(i = 0; i < tr.numFBOs; i++) { fbo = tr.fbos[i]; - ri.Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); + ri->Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); } - ri.Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); + ri->Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); } // FIXME diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d8b0743224..bc37dccb59 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -152,11 +152,11 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) if (maxLength <= 0) { - ri.Printf(printLevel, "No compile log.\n"); + ri->Printf(printLevel, "No compile log.\n"); return; } - ri.Printf(printLevel, "compile log:\n"); + ri->Printf(printLevel, "compile log:\n"); if (maxLength < 1023) { @@ -164,11 +164,11 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) msgPart[maxLength + 1] = '\0'; - ri.Printf(printLevel, "%s\n", msgPart); + ri->Printf(printLevel, "%s\n", msgPart); } else { - msg = ri.Malloc(maxLength); + msg = ri->Malloc(maxLength); qglGetInfoLogARB(object, maxLength, &maxLength, msg); @@ -176,10 +176,10 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) { Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - ri.Printf(printLevel, "%s\n", msgPart); + ri->Printf(printLevel, "%s\n", msgPart); } - ri.Free(msg); + ri->Free(msg); } } @@ -192,17 +192,17 @@ static void GLSL_PrintShaderSource(GLhandleARB object) qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); - msg = ri.Malloc(maxLength); + msg = ri->Malloc(maxLength); qglGetShaderSourceARB(object, maxLength, &maxLength, msg); for(i = 0; i < maxLength; i += 1024) { Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - ri.Printf(PRINT_ALL, "%s\n", msgPart); + ri->Printf(PRINT_ALL, "%s\n", msgPart); } - ri.Free(msg); + ri->Free(msg); } static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, int size ) @@ -343,7 +343,7 @@ static int GLSL_CompileGPUShader(GLhandleARB program, GLhandleARB *prevShader, c { GLSL_PrintShaderSource(shader); GLSL_PrintInfoLog(shader, qfalse); - ri.Error(ERR_DROP, "Couldn't compile shader"); + ri->Error(ERR_DROP, "Couldn't compile shader"); return 0; } @@ -382,19 +382,19 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name); } - ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); - size = ri.FS_ReadFile(filename, (void **)&buffer); + ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); + size = ri->FS_ReadFile(filename, (void **)&buffer); if(!buffer) { if (fallback) { - ri.Printf(PRINT_DEVELOPER, "couldn't load, using fallback\n"); + ri->Printf(PRINT_DEVELOPER, "couldn't load, using fallback\n"); shaderText = fallback; size = strlen(shaderText); } else { - ri.Printf(PRINT_DEVELOPER, "couldn't load!\n"); + ri->Printf(PRINT_DEVELOPER, "couldn't load!\n"); return 0; } } @@ -415,7 +415,7 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, if (buffer) { - ri.FS_FreeFile(buffer); + ri->FS_FreeFile(buffer); } return result; @@ -431,8 +431,8 @@ static void GLSL_LinkProgram(GLhandleARB program) if(!linked) { GLSL_PrintInfoLog(program, qfalse); - ri.Printf(PRINT_ALL, "\n"); - ri.Error(ERR_DROP, "shaders failed to link"); + ri->Printf(PRINT_ALL, "\n"); + ri->Error(ERR_DROP, "shaders failed to link"); } } @@ -446,8 +446,8 @@ static void GLSL_ValidateProgram(GLhandleARB program) if(!validated) { GLSL_PrintInfoLog(program, qfalse); - ri.Printf(PRINT_ALL, "\n"); - ri.Error(ERR_DROP, "shaders failed to validate"); + ri->Printf(PRINT_ALL, "\n"); + ri->Error(ERR_DROP, "shaders failed to validate"); } } @@ -470,7 +470,7 @@ static void GLSL_ShowProgramUniforms(GLhandleARB program) { qglGetActiveUniformARB(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); - ri.Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); + ri->Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); } qglUseProgramObjectARB(0); @@ -478,11 +478,11 @@ static void GLSL_ShowProgramUniforms(GLhandleARB program) static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) { - ri.Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); + ri->Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "GLSL_InitGPUShader2: \"%s\" is too long", name); + ri->Error(ERR_DROP, "GLSL_InitGPUShader2: \"%s\" is too long", name); } Q_strncpyz(program->name, name, sizeof(program->name)); @@ -492,7 +492,7 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int if (!(GLSL_CompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER_ARB))) { - ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); + ri->Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); qglDeleteObjectARB(program->program); return 0; } @@ -501,7 +501,7 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int { if(!(GLSL_CompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER_ARB))) { - ri.Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); + ri->Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); qglDeleteObjectARB(program->program); return 0; } @@ -657,7 +657,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) } } - program->uniformBuffer = ri.Malloc(size); + program->uniformBuffer = ri->Malloc(size); } void GLSL_FinishGPUShader(shaderProgram_t *program) @@ -677,7 +677,7 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) if (uniformsInfo[uniformNum].type != GLSL_INT) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -701,7 +701,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu if (uniformsInfo[uniformNum].type != GLSL_FLOAT) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -725,7 +725,7 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t if (uniformsInfo[uniformNum].type != GLSL_VEC2) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -750,7 +750,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t if (uniformsInfo[uniformNum].type != GLSL_VEC3) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -774,7 +774,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t if (uniformsInfo[uniformNum].type != GLSL_VEC4) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -798,7 +798,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ if (uniformsInfo[uniformNum].type != GLSL_FLOAT5) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat5: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloat5: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -822,7 +822,7 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const mat if (uniformsInfo[uniformNum].type != GLSL_MAT16) { - ri.Printf( PRINT_WARNING, "GLSL_SetUniformMatrix16: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix16: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -856,7 +856,7 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) if (program->uniformBuffer) { - ri.Free(program->uniformBuffer); + ri->Free(program->uniformBuffer); } Com_Memset(program, 0, sizeof(*program)); @@ -871,11 +871,11 @@ void GLSL_InitGPUShaders(void) int attribs; int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; - ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); + ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); R_IssuePendingRenderCommands(); - startTime = ri.Milliseconds(); + startTime = ri->Milliseconds(); for (i = 0; i < GENERICDEF_COUNT; i++) { @@ -911,7 +911,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) { - ri.Error(ERR_FATAL, "Could not load generic shader!"); + ri->Error(ERR_FATAL, "Could not load generic shader!"); } GLSL_InitUniforms(&tr.genericShader[i]); @@ -931,7 +931,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) { - ri.Error(ERR_FATAL, "Could not load texturecolor shader!"); + ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); } GLSL_InitUniforms(&tr.textureColorShader); @@ -957,7 +957,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) { - ri.Error(ERR_FATAL, "Could not load fogpass shader!"); + ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } GLSL_InitUniforms(&tr.fogShader[i]); @@ -979,7 +979,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) { - ri.Error(ERR_FATAL, "Could not load dlight shader!"); + ri->Error(ERR_FATAL, "Could not load dlight shader!"); } GLSL_InitUniforms(&tr.dlightShader[i]); @@ -1143,7 +1143,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) { - ri.Error(ERR_FATAL, "Could not load lightall shader!"); + ri->Error(ERR_FATAL, "Could not load lightall shader!"); } GLSL_InitUniforms(&tr.lightallShader[i]); @@ -1168,7 +1168,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) { - ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); + ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } GLSL_InitUniforms(&tr.shadowmapShader); @@ -1183,7 +1183,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) { - ri.Error(ERR_FATAL, "Could not load pshadow shader!"); + ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } GLSL_InitUniforms(&tr.pshadowShader); @@ -1202,7 +1202,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) { - ri.Error(ERR_FATAL, "Could not load down4x shader!"); + ri->Error(ERR_FATAL, "Could not load down4x shader!"); } GLSL_InitUniforms(&tr.down4xShader); @@ -1221,7 +1221,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) { - ri.Error(ERR_FATAL, "Could not load bokeh shader!"); + ri->Error(ERR_FATAL, "Could not load bokeh shader!"); } GLSL_InitUniforms(&tr.bokehShader); @@ -1240,7 +1240,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) { - ri.Error(ERR_FATAL, "Could not load tonemap shader!"); + ri->Error(ERR_FATAL, "Could not load tonemap shader!"); } GLSL_InitUniforms(&tr.tonemapShader); @@ -1265,7 +1265,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) { - ri.Error(ERR_FATAL, "Could not load calclevels4x shader!"); + ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); } GLSL_InitUniforms(&tr.calclevels4xShader[i]); @@ -1297,7 +1297,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) { - ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); + ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } GLSL_InitUniforms(&tr.shadowmaskShader); @@ -1319,7 +1319,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) { - ri.Error(ERR_FATAL, "Could not load ssao shader!"); + ri->Error(ERR_FATAL, "Could not load ssao shader!"); } GLSL_InitUniforms(&tr.ssaoShader); @@ -1346,7 +1346,7 @@ void GLSL_InitGPUShaders(void) if (!GLSL_InitGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) { - ri.Error(ERR_FATAL, "Could not load depthBlur shader!"); + ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } GLSL_InitUniforms(&tr.depthBlurShader[i]); @@ -1362,9 +1362,9 @@ void GLSL_InitGPUShaders(void) } - endTime = ri.Milliseconds(); + endTime = ri->Milliseconds(); - ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", + ri->Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, numEtcShaders, (endTime - startTime) / 1000.0); } @@ -1373,7 +1373,7 @@ void GLSL_ShutdownGPUShaders(void) { int i; - ri.Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); + ri->Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); @@ -1659,7 +1659,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) if(!glState.currentVBO) { - ri.Error(ERR_FATAL, "GL_VertexAttribPointers: no VBO bound"); + ri->Error(ERR_FATAL, "GL_VertexAttribPointers: no VBO bound"); return; } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index c9ca6ce6ca..26a11c0536 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -97,13 +97,13 @@ void GL_TextureMode( const char *string ) { // hack to prevent trilinear from being set on voodoo, // because their driver freaks... if ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D ) { - ri.Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); + ri->Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); i = 3; } if ( i == 6 ) { - ri.Printf (PRINT_ALL, "bad filter name\n"); + ri->Printf (PRINT_ALL, "bad filter name\n"); return; } @@ -149,7 +149,7 @@ void R_ImageList_f( void ) { int i; int estTotalSize = 0; - ri.Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); + ri->Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); for ( i = 0 ; i < tr.numImages ; i++ ) { @@ -275,13 +275,13 @@ void R_ImageList_f( void ) { sizeSuffix = "Gb"; } - ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName); + ri->Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName); estTotalSize += estSize; } - ri.Printf (PRINT_ALL, " ---------\n"); - ri.Printf (PRINT_ALL, " approx %i bytes\n", estTotalSize); - ri.Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); + ri->Printf (PRINT_ALL, " ---------\n"); + ri->Printf (PRINT_ALL, " approx %i bytes\n", estTotalSize); + ri->Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); } //======================================================================= @@ -308,7 +308,7 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, byte *pix1, *pix2, *pix3, *pix4; if (outwidth>2048) - ri.Error(ERR_DROP, "ResampleTexture: max width"); + ri->Error(ERR_DROP, "ResampleTexture: max width"); fracstep = inwidth*0x10000/outwidth; @@ -1289,7 +1289,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); inWidthMask = inWidth - 1; inHeightMask = inHeight - 1; @@ -1324,7 +1324,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { } Com_Memcpy( in, temp, outWidth * outHeight * 4 ); - ri.Hunk_FreeTempMemory( temp ); + ri->Hunk_FreeTempMemory( temp ); } @@ -1336,7 +1336,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); for ( i = 0 ; i < outHeight ; i++ ) { byte *outbyte = temp + ( i * outWidth ) * 4; @@ -1366,7 +1366,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) } Com_Memcpy( in, temp, outWidth * outHeight * 4 ); - ri.Hunk_FreeTempMemory( temp ); + ri->Hunk_FreeTempMemory( temp ); } /* @@ -1602,7 +1602,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he int finalwidth, finalheight; //int startTime, endTime; - //startTime = ri.Milliseconds(); + //startTime = ri->Milliseconds(); finalwidth = scaled_width << r_imageUpsample->integer; finalheight = scaled_height << r_imageUpsample->integer; @@ -1619,7 +1619,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he finalheight >>= 1; } - *resampledBuffer = ri.Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); + *resampledBuffer = ri->Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); if (scaled_width != width || scaled_height != height) { @@ -1660,9 +1660,9 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he } - //endTime = ri.Milliseconds(); + //endTime = ri->Milliseconds(); - //ri.Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); + //ri->Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); *data = *resampledBuffer; width = scaled_width; @@ -1671,7 +1671,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he else if ( scaled_width != width || scaled_height != height ) { if (data && resampledBuffer) { - *resampledBuffer = ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); + *resampledBuffer = ri->Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); *data = *resampledBuffer; } @@ -2018,7 +2018,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); - scaledBuffer = ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); // // scan the texture for each channel's max values @@ -2158,9 +2158,9 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag GL_CheckErrors(); if ( scaledBuffer != 0 ) - ri.Hunk_FreeTempMemory( scaledBuffer ); + ri->Hunk_FreeTempMemory( scaledBuffer ); if ( resampledBuffer != 0 ) - ri.Hunk_FreeTempMemory( resampledBuffer ); + ri->Hunk_FreeTempMemory( resampledBuffer ); } @@ -2228,17 +2228,17 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT int glWrapClampMode; if (strlen(name) >= MAX_QPATH ) { - ri.Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); + ri->Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); } if ( !strncmp( name, "*lightmap", 9 ) ) { isLightmap = qtrue; } if ( tr.numImages == MAX_DRAWIMAGES ) { - ri.Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); + ri->Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); } - image = tr.images[tr.numImages] = ri.Hunk_Alloc( sizeof( image_t ), h_low ); + image = tr.images[tr.numImages] = ri->Hunk_Alloc( sizeof( image_t ), h_low ); image->texnum = 1024 + tr.numImages; tr.numImages++; @@ -2354,7 +2354,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h RawImage_ScaleToPower2(&pic, &width, &height, &scaled_width, &scaled_height, image->type, image->flags, &resampledBuffer); - scaledBuffer = ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); if ( qglActiveTextureARB ) { GL_SelectTexture( image->TMU ); @@ -2419,9 +2419,9 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h GL_CheckErrors(); if ( scaledBuffer != 0 ) - ri.Hunk_FreeTempMemory( scaledBuffer ); + ri->Hunk_FreeTempMemory( scaledBuffer ); if ( resampledBuffer != 0 ) - ri.Hunk_FreeTempMemory( resampledBuffer ); + ri->Hunk_FreeTempMemory( resampledBuffer ); } //=================================================================== @@ -2519,7 +2519,7 @@ void R_LoadImage( const char *name, byte **pic, int *width, int *height ) { if( orgNameFailed ) { - ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", + ri->Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", name, altName ); } @@ -2558,7 +2558,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) // the white image can be used with any set of parms, but other mismatches are errors if ( strcmp( name, "*white" ) ) { if ( image->flags != flags ) { - ri.Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); + ri->Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); } } return image; @@ -2596,7 +2596,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) normalWidth = width; normalHeight = height; - normalPic = ri.Malloc(width * height * 4); + normalPic = ri->Malloc(width * height * 4); RGBAtoNormal(pic, normalPic, width, height, flags & IMGFLAG_CLAMPTOEDGE); // Brighten up the original image to work with the normal map @@ -2616,12 +2616,12 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) YCoCgAtoRGBA(pic, pic, width, height); R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); - ri.Free( normalPic ); + ri->Free( normalPic ); } } image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); - ri.Free( pic ); + ri->Free( pic ); return image; } @@ -2727,7 +2727,7 @@ static void R_CreateFogImage( void ) { float d; float borderColor[4]; - data = ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); + data = ri->Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); // S is distance, T is depth for (x=0 ; xHunk_FreeTempMemory( data ); borderColor[0] = 1.0; borderColor[1] = 1.0; @@ -2978,13 +2978,13 @@ void R_SetColorMappings( void ) { if ( r_intensity->value <= 1 ) { - ri.Cvar_Set( "r_intensity", "1" ); + ri->Cvar_Set( "r_intensity", "1" ); } if ( r_gamma->value < 0.5f ) { - ri.Cvar_Set( "r_gamma", "0.5" ); + ri->Cvar_Set( "r_gamma", "0.5" ); } else if ( r_gamma->value > 3.0f ) { - ri.Cvar_Set( "r_gamma", "3.0" ); + ri->Cvar_Set( "r_gamma", "3.0" ); } g = r_gamma->value; @@ -3184,7 +3184,7 @@ static char *CommaParse( char **data_p ) { if (len == MAX_TOKEN_CHARS) { -// ri.Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); +// ri->Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); len = 0; } com_token[len] = 0; @@ -3213,12 +3213,12 @@ qhandle_t RE_RegisterSkin( const char *name ) { char surfName[MAX_QPATH]; if ( !name || !name[0] ) { - ri.Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); + ri->Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); return 0; } if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); + ri->Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); return 0; } @@ -3236,11 +3236,11 @@ qhandle_t RE_RegisterSkin( const char *name ) { // allocate a new skin if ( tr.numSkins == MAX_SKINS ) { - ri.Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); + ri->Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); return 0; } tr.numSkins++; - skin = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); + skin = ri->Hunk_Alloc( sizeof( skin_t ), h_low ); tr.skins[hSkin] = skin; Q_strncpyz( skin->name, name, sizeof( skin->name ) ); skin->numSurfaces = 0; @@ -3250,13 +3250,13 @@ qhandle_t RE_RegisterSkin( const char *name ) { // If not a .skin file, load as a single shader if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { skin->numSurfaces = 1; - skin->surfaces[0] = ri.Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); + skin->surfaces[0] = ri->Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); return hSkin; } // load and parse the skin file - ri.FS_ReadFile( name, &text.v ); + ri->FS_ReadFile( name, &text.v ); if ( !text.c ) { return 0; } @@ -3284,13 +3284,13 @@ qhandle_t RE_RegisterSkin( const char *name ) { // parse the shader name token = CommaParse( &text_p ); - surf = skin->surfaces[ skin->numSurfaces ] = ri.Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); + surf = skin->surfaces[ skin->numSurfaces ] = ri->Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); skin->numSurfaces++; } - ri.FS_FreeFile( text.v ); + ri->FS_FreeFile( text.v ); // never let a skin have 0 shaders @@ -3313,10 +3313,10 @@ void R_InitSkins( void ) { tr.numSkins = 1; // make the default skin have all default shaders - skin = tr.skins[0] = ri.Hunk_Alloc( sizeof( skin_t ), h_low ); + skin = tr.skins[0] = ri->Hunk_Alloc( sizeof( skin_t ), h_low ); Q_strncpyz( skin->name, "", sizeof( skin->name ) ); skin->numSurfaces = 1; - skin->surfaces[0] = ri.Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); + skin->surfaces[0] = ri->Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); skin->surfaces[0]->shader = tr.defaultShader; } @@ -3341,18 +3341,18 @@ void R_SkinList_f( void ) { int i, j; skin_t *skin; - ri.Printf (PRINT_ALL, "------------------\n"); + ri->Printf (PRINT_ALL, "------------------\n"); for ( i = 0 ; i < tr.numSkins ; i++ ) { skin = tr.skins[i]; - ri.Printf( PRINT_ALL, "%3i:%s\n", i, skin->name ); + ri->Printf( PRINT_ALL, "%3i:%s\n", i, skin->name ); for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - ri.Printf( PRINT_ALL, " %s = %s\n", + ri->Printf( PRINT_ALL, " %s = %s\n", skin->surfaces[j]->name, skin->surfaces[j]->shader->name ); } } - ri.Printf (PRINT_ALL, "------------------\n"); + ri->Printf (PRINT_ALL, "------------------\n"); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index d5330248de..ac2b544443 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -312,7 +312,7 @@ void GL_CheckErrs( char *file, int line ) { break; } - ri.Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); + ri->Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); } @@ -378,12 +378,12 @@ static void R_ModeList_f( void ) { int i; - ri.Printf( PRINT_ALL, "\n" ); + ri->Printf( PRINT_ALL, "\n" ); for ( i = 0; i < s_numVidModes; i++ ) { - ri.Printf( PRINT_ALL, "%s\n", r_vidModes[i].description ); + ri->Printf( PRINT_ALL, "%s\n", r_vidModes[i].description ); } - ri.Printf( PRINT_ALL, "\n" ); + ri->Printf( PRINT_ALL, "\n" ); } @@ -419,7 +419,7 @@ alignment of packAlign to ensure efficient copying. Stores the length of padding after a line of pixels to address padlen -Return value must be freed with ri.Hunk_FreeTempMemory() +Return value must be freed with ri->Hunk_FreeTempMemory() ================== */ @@ -435,7 +435,7 @@ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *pa padwidth = PAD(linelen, packAlign); // Allocate a few more bytes so that we can choose an alignment we like - buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); + buffer = ri->Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); bufstart = PADP((intptr_t) buffer + *offset, packAlign); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); @@ -502,9 +502,9 @@ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) if(glConfig.deviceSupportsGamma) R_GammaCorrect(allbuf + offset, memcount); - ri.FS_WriteFile(fileName, buffer, memcount + 18); + ri->FS_WriteFile(fileName, buffer, memcount + 18); - ri.Hunk_FreeTempMemory(allbuf); + ri->Hunk_FreeTempMemory(allbuf); } /* @@ -527,7 +527,7 @@ void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) R_GammaCorrect(buffer + offset, memcount); RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); - ri.Hunk_FreeTempMemory(buffer); + ri->Hunk_FreeTempMemory(buffer); } /* @@ -651,7 +651,7 @@ void R_LevelShot( void ) { allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); source = allsource + offset; - buffer = ri.Hunk_AllocateTempMemory(128 * 128*3 + 18); + buffer = ri->Hunk_AllocateTempMemory(128 * 128*3 + 18); Com_Memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type buffer[12] = 128; @@ -685,12 +685,12 @@ void R_LevelShot( void ) { R_GammaCorrect( buffer + 18, 128 * 128 * 3 ); } - ri.FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 ); + ri->FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 ); - ri.Hunk_FreeTempMemory(buffer); - ri.Hunk_FreeTempMemory(allsource); + ri->Hunk_FreeTempMemory(buffer); + ri->Hunk_FreeTempMemory(allsource); - ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); + ri->Printf( PRINT_ALL, "Wrote %s\n", checkname ); } /* @@ -710,20 +710,20 @@ void R_ScreenShot_f (void) { static int lastNumber = -1; qboolean silent; - if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) { silent = qtrue; } else { silent = qfalse; } - if ( ri.Cmd_Argc() == 2 && !silent ) { + if ( ri->Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri.Cmd_Argv( 1 ) ); + Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri->Cmd_Argv( 1 ) ); } else { // scan for a free filename @@ -737,14 +737,14 @@ void R_ScreenShot_f (void) { for ( ; lastNumber <= 9999 ; lastNumber++ ) { R_ScreenshotFilename( lastNumber, checkname ); - if (!ri.FS_FileExists( checkname )) + if (!ri->FS_FileExists( checkname )) { break; // file doesn't exist } } if ( lastNumber >= 9999 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + ri->Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); return; } @@ -754,7 +754,7 @@ void R_ScreenShot_f (void) { R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse ); if ( !silent ) { - ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); + ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); } } @@ -763,20 +763,20 @@ void R_ScreenShotJPEG_f (void) { static int lastNumber = -1; qboolean silent; - if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) { silent = qtrue; } else { silent = qfalse; } - if ( ri.Cmd_Argc() == 2 && !silent ) { + if ( ri->Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) ); + Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri->Cmd_Argv( 1 ) ); } else { // scan for a free filename @@ -790,14 +790,14 @@ void R_ScreenShotJPEG_f (void) { for ( ; lastNumber <= 9999 ; lastNumber++ ) { R_ScreenshotFilenameJPEG( lastNumber, checkname ); - if (!ri.FS_FileExists( checkname )) + if (!ri->FS_FileExists( checkname )) { break; // file doesn't exist } } if ( lastNumber == 10000 ) { - ri.Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + ri->Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); return; } @@ -807,7 +807,7 @@ void R_ScreenShotJPEG_f (void) { R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue ); if ( !silent ) { - ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); + ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); } } @@ -859,7 +859,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, r_aviMotionJpegQuality->integer, cmd->width, cmd->height, cBuf, padlen); - ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); + ri->CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); } else { @@ -888,7 +888,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) srcptr += padlen; } - ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); + ri->CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); } return (const void *)(cmd + 1); @@ -961,7 +961,7 @@ void GL_SetDefaultState( void ) ================ R_PrintLongString -Workaround for ri.Printf's 1024 characters buffer limit. +Workaround for ri->Printf's 1024 characters buffer limit. ================ */ void R_PrintLongString(const char *string) { @@ -973,7 +973,7 @@ void R_PrintLongString(const char *string) { while(size > 0) { Q_strncpyz(buffer, p, sizeof (buffer) ); - ri.Printf( PRINT_ALL, "%s", buffer ); + ri->Printf( PRINT_ALL, "%s", buffer ); p += 1023; size -= 1023; } @@ -997,54 +997,54 @@ void GfxInfo_f( void ) "fullscreen" }; - ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); - ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); - ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); - ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " ); + ri->Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); + ri->Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); + ri->Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); + ri->Printf( PRINT_ALL, "GL_EXTENSIONS: " ); R_PrintLongString( glConfig.extensions_string ); - ri.Printf( PRINT_ALL, "\n" ); - ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); - ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); - ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); - ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] ); + ri->Printf( PRINT_ALL, "\n" ); + ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); + ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); + ri->Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); + ri->Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] ); if ( glConfig.displayFrequency ) { - ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); + ri->Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); } else { - ri.Printf( PRINT_ALL, "N/A\n" ); + ri->Printf( PRINT_ALL, "N/A\n" ); } if ( glConfig.deviceSupportsGamma ) { - ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); + ri->Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); } else { - ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); + ri->Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); } - ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); - ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); - ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); - ri.Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] ); - ri.Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] ); - ri.Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); - ri.Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); + ri->Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); + ri->Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); + ri->Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); + ri->Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] ); + ri->Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] ); + ri->Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); + ri->Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) { - ri.Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); + ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } if ( glConfig.hardwareType == GLHW_RAGEPRO ) { - ri.Printf( PRINT_ALL, "HACK: ragePro approximations\n" ); + ri->Printf( PRINT_ALL, "HACK: ragePro approximations\n" ); } if ( glConfig.hardwareType == GLHW_RIVA128 ) { - ri.Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); + ri->Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); } if ( r_finish->integer ) { - ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); + ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); } } @@ -1059,7 +1059,7 @@ void GfxMemInfo_f( void ) { case MI_NONE: { - ri.Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); + ri->Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); } break; case MI_NVX: @@ -1067,19 +1067,19 @@ void GfxMemInfo_f( void ) int value; qglGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); + ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); + ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); + ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); + ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &value); - ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); + ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); } break; case MI_ATI: @@ -1088,13 +1088,13 @@ void GfxMemInfo_f( void ) int value[4]; qglGetIntegerv(GL_VBO_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri->Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); qglGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri->Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); qglGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, &value[0]); - ri.Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri->Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); } break; } @@ -1108,214 +1108,214 @@ R_Register void R_Register( void ) { #ifdef USE_RENDERER_DLOPEN - com_altivec = ri.Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); + com_altivec = ri->Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); #endif // // latched and archived variables // - r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); - - r_ext_draw_range_elements = ri.Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_multi_draw_arrays = ri.Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_framebuffer_object = ri.Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_half_float_pixel = ri.Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); - - r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", + r_allowExtensions = ri->Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); + + r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_framebuffer_object = ri->Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); + + r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_max_anisotropy = ri.Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); - - r_picmip = ri.Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); - ri.Cvar_CheckRange( r_picmip, 0, 16, qtrue ); - r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_colorbits = ri.Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_stencilbits = ri.Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH ); - r_depthbits = ri.Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_multisample = ri.Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri.Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); - r_overBrightBits = ri.Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ignorehwgamma = ri.Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_mode = ri.Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); - r_fullscreen = ri.Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); - r_noborder = ri.Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); - r_customwidth = ri.Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); - r_customheight = ri.Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_customPixelAspect = ri.Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0); - r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); - r_stereoEnabled = ri.Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); - ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse); - - r_softOverbright = ri.Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); - - r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_postProcess = ri.Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); - - r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); - r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); - r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); - r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); - - r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); - r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); - r_forceAutoExposureMin = ri.Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT ); - r_forceAutoExposureMax = ri.Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT ); - - r_cameraExposure = ri.Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT ); - - r_srgb = ri.Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE ); - r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE ); - - r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_normalAmbient = ri.Cvar_Get( "r_normalAmbient", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_dlightMode = ri.Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); - r_recalcMD3Normals = ri.Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); - r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT ); - r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); - r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT ); - r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); - - r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowMapSize = ri.Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_max_anisotropy = ri->Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); + + r_picmip = ri->Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); + ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); + r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_colorbits = ri->Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_stencilbits = ri->Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH ); + r_depthbits = ri->Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_multisample = ri->Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); + ri->Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); + r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_ignorehwgamma = ri->Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_mode = ri->Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); + r_fullscreen = ri->Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); + r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); + r_customwidth = ri->Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); + r_customheight = ri->Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_customPixelAspect = ri->Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_simpleMipMaps = ri->Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0); + r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); + r_stereoEnabled = ri->Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); + ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); + + r_softOverbright = ri->Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); + + r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); + + r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_forceToneMap = ri->Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); + r_forceToneMapMin = ri->Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); + r_forceToneMapAvg = ri->Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); + r_forceToneMapMax = ri->Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); + + r_autoExposure = ri->Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); + r_forceAutoExposure = ri->Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); + r_forceAutoExposureMin = ri->Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT ); + r_forceAutoExposureMax = ri->Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT ); + + r_cameraExposure = ri->Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT ); + + r_srgb = ri->Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH ); + + r_depthPrepass = ri->Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE ); + r_ssao = ri->Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE ); + + r_normalMapping = ri->Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_normalAmbient = ri->Cvar_Get( "r_normalAmbient", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_dlightMode = ri->Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); + r_recalcMD3Normals = ri->Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_genNormalMaps = ri->Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); + + r_forceSun = ri->Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); + r_forceSunMapLightScale = ri->Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT ); + r_forceSunLightScale = ri->Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); + r_forceSunAmbientScale = ri->Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT ); + r_drawSunRays = ri->Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_sunlightMode = ri->Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); + + r_sunShadows = ri->Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowFilter = ri->Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowMapSize = ri->Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZNear = ri->Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZFar = ri->Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH ); + r_shadowCascadeZBias = ri->Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH ); // // temporary latched variables that can only change over a restart // - r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); - r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); - r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH ); - r_singleShader = ri.Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); + r_fullbright = ri->Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); + r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); + r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); + r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); // // archived variables that can change at any time // - r_lodCurveError = ri.Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT ); - r_lodbias = ri.Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); - r_flares = ri.Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); - r_znear = ri.Cvar_Get( "r_znear", "4", CVAR_CHEAT ); - ri.Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); - r_zproj = ri.Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); - r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); - r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); - r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE ); - r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE ); - r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); - r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); - r_dlightBacks = ri.Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); - r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); - r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); - r_swapInterval = ri.Cvar_Get( "r_swapInterval", "0", + r_lodCurveError = ri->Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT ); + r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); + r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); + r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT ); + ri->Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); + r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); + r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); + r_ignoreGLErrors = ri->Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); + r_fastsky = ri->Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE ); + r_inGameVideo = ri->Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE ); + r_drawSun = ri->Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); + r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); + r_dlightBacks = ri->Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); + r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); + r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); + r_swapInterval = ri->Cvar_Get( "r_swapInterval", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); - r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); + r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); + r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); - r_railWidth = ri.Cvar_Get( "r_railWidth", "16", CVAR_ARCHIVE ); - r_railCoreWidth = ri.Cvar_Get( "r_railCoreWidth", "6", CVAR_ARCHIVE ); - r_railSegmentLength = ri.Cvar_Get( "r_railSegmentLength", "32", CVAR_ARCHIVE ); + r_railWidth = ri->Cvar_Get( "r_railWidth", "16", CVAR_ARCHIVE ); + r_railCoreWidth = ri->Cvar_Get( "r_railCoreWidth", "6", CVAR_ARCHIVE ); + r_railSegmentLength = ri->Cvar_Get( "r_railSegmentLength", "32", CVAR_ARCHIVE ); - r_ambientScale = ri.Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); - r_directedScale = ri.Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); + r_ambientScale = ri->Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); + r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); - r_anaglyphMode = ri.Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE); - r_mergeMultidraws = ri.Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE); - r_mergeLeafSurfaces = ri.Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE); + r_anaglyphMode = ri->Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE); + r_mergeMultidraws = ri->Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE); + r_mergeLeafSurfaces = ri->Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE); // // temporary variables that can change at any time // - r_showImages = ri.Cvar_Get( "r_showImages", "0", CVAR_TEMP ); - - r_debugLight = ri.Cvar_Get( "r_debuglight", "0", CVAR_TEMP ); - r_debugSort = ri.Cvar_Get( "r_debugSort", "0", CVAR_CHEAT ); - r_printShaders = ri.Cvar_Get( "r_printShaders", "0", 0 ); - r_saveFontData = ri.Cvar_Get( "r_saveFontData", "0", 0 ); - - r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT ); - r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT ); - r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0 ); - r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT ); - - r_flareSize = ri.Cvar_Get ("r_flareSize", "40", CVAR_CHEAT); - r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); - r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); - - r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); - - r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); - r_lodscale = ri.Cvar_Get( "r_lodscale", "5", CVAR_CHEAT ); - r_norefresh = ri.Cvar_Get ("r_norefresh", "0", CVAR_CHEAT); - r_drawentities = ri.Cvar_Get ("r_drawentities", "1", CVAR_CHEAT ); - r_ignore = ri.Cvar_Get( "r_ignore", "1", CVAR_CHEAT ); - r_nocull = ri.Cvar_Get ("r_nocull", "0", CVAR_CHEAT); - r_novis = ri.Cvar_Get ("r_novis", "0", CVAR_CHEAT); - r_showcluster = ri.Cvar_Get ("r_showcluster", "0", CVAR_CHEAT); - r_speeds = ri.Cvar_Get ("r_speeds", "0", CVAR_CHEAT); - r_verbose = ri.Cvar_Get( "r_verbose", "0", CVAR_CHEAT ); - r_logFile = ri.Cvar_Get( "r_logFile", "0", CVAR_CHEAT ); - r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT); - r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT); - r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT); - r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT); - r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT); - r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT); - r_offsetFactor = ri.Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT ); - r_offsetUnits = ri.Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT ); - r_drawBuffer = ri.Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT ); - r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT); - r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT); - r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0 ); - - r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE); - - r_aviMotionJpegQuality = ri.Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); - r_screenshotJpegQuality = ri.Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); - - r_maxpolys = ri.Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); - r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); + r_showImages = ri->Cvar_Get( "r_showImages", "0", CVAR_TEMP ); + + r_debugLight = ri->Cvar_Get( "r_debuglight", "0", CVAR_TEMP ); + r_debugSort = ri->Cvar_Get( "r_debugSort", "0", CVAR_CHEAT ); + r_printShaders = ri->Cvar_Get( "r_printShaders", "0", 0 ); + r_saveFontData = ri->Cvar_Get( "r_saveFontData", "0", 0 ); + + r_nocurves = ri->Cvar_Get ("r_nocurves", "0", CVAR_CHEAT ); + r_drawworld = ri->Cvar_Get ("r_drawworld", "1", CVAR_CHEAT ); + r_lightmap = ri->Cvar_Get ("r_lightmap", "0", 0 ); + r_portalOnly = ri->Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT ); + + r_flareSize = ri->Cvar_Get ("r_flareSize", "40", CVAR_CHEAT); + r_flareFade = ri->Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); + r_flareCoeff = ri->Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); + + r_skipBackEnd = ri->Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); + + r_measureOverdraw = ri->Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); + r_lodscale = ri->Cvar_Get( "r_lodscale", "5", CVAR_CHEAT ); + r_norefresh = ri->Cvar_Get ("r_norefresh", "0", CVAR_CHEAT); + r_drawentities = ri->Cvar_Get ("r_drawentities", "1", CVAR_CHEAT ); + r_ignore = ri->Cvar_Get( "r_ignore", "1", CVAR_CHEAT ); + r_nocull = ri->Cvar_Get ("r_nocull", "0", CVAR_CHEAT); + r_novis = ri->Cvar_Get ("r_novis", "0", CVAR_CHEAT); + r_showcluster = ri->Cvar_Get ("r_showcluster", "0", CVAR_CHEAT); + r_speeds = ri->Cvar_Get ("r_speeds", "0", CVAR_CHEAT); + r_verbose = ri->Cvar_Get( "r_verbose", "0", CVAR_CHEAT ); + r_logFile = ri->Cvar_Get( "r_logFile", "0", CVAR_CHEAT ); + r_debugSurface = ri->Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT); + r_nobind = ri->Cvar_Get ("r_nobind", "0", CVAR_CHEAT); + r_showtris = ri->Cvar_Get ("r_showtris", "0", CVAR_CHEAT); + r_showsky = ri->Cvar_Get ("r_showsky", "0", CVAR_CHEAT); + r_shownormals = ri->Cvar_Get ("r_shownormals", "0", CVAR_CHEAT); + r_clear = ri->Cvar_Get ("r_clear", "0", CVAR_CHEAT); + r_offsetFactor = ri->Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT ); + r_offsetUnits = ri->Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT ); + r_drawBuffer = ri->Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT ); + r_lockpvs = ri->Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT); + r_noportals = ri->Cvar_Get ("r_noportals", "0", CVAR_CHEAT); + r_shadows = ri->Cvar_Get( "cg_shadows", "1", 0 ); + + r_marksOnTriangleMeshes = ri->Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE); + + r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); + r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); + + r_maxpolys = ri->Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); + r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); // make sure all the commands added here are also // removed in R_Shutdown - ri.Cmd_AddCommand( "imagelist", R_ImageList_f ); - ri.Cmd_AddCommand( "shaderlist", R_ShaderList_f ); - ri.Cmd_AddCommand( "skinlist", R_SkinList_f ); - ri.Cmd_AddCommand( "modellist", R_Modellist_f ); - ri.Cmd_AddCommand( "modelist", R_ModeList_f ); - ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f ); - ri.Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); - ri.Cmd_AddCommand( "gfxinfo", GfxInfo_f ); - ri.Cmd_AddCommand( "minimize", GLimp_Minimize ); - ri.Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); + ri->Cmd_AddCommand( "imagelist", R_ImageList_f ); + ri->Cmd_AddCommand( "shaderlist", R_ShaderList_f ); + ri->Cmd_AddCommand( "skinlist", R_SkinList_f ); + ri->Cmd_AddCommand( "modellist", R_Modellist_f ); + ri->Cmd_AddCommand( "modelist", R_ModeList_f ); + ri->Cmd_AddCommand( "screenshot", R_ScreenShot_f ); + ri->Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); + ri->Cmd_AddCommand( "gfxinfo", GfxInfo_f ); + ri->Cmd_AddCommand( "minimize", GLimp_Minimize ); + ri->Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); } void R_InitQueries(void) @@ -1346,7 +1346,7 @@ void R_Init( void ) { int i; byte *ptr; - ri.Printf( PRINT_ALL, "----- R_Init -----\n" ); + ri->Printf( PRINT_ALL, "----- R_Init -----\n" ); // clear all our internal state Com_Memset( &tr, 0, sizeof( tr ) ); @@ -1354,12 +1354,12 @@ void R_Init( void ) { Com_Memset( &tess, 0, sizeof( tess ) ); if(sizeof(glconfig_t) != 11332) - ri.Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); + ri->Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); // Swap_Init(); if ( (intptr_t)tess.xyz & 15 ) { - ri.Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); + ri->Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); } //Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); @@ -1404,7 +1404,7 @@ void R_Init( void ) { if (max_polyverts < MAX_POLYVERTS) max_polyverts = MAX_POLYVERTS; - ptr = ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); + ptr = ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData = (backEndData_t *) ptr; backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); @@ -1434,11 +1434,11 @@ void R_Init( void ) { err = qglGetError(); if ( err != GL_NO_ERROR ) - ri.Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); + ri->Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); // print info GfxInfo_f(); - ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" ); + ri->Printf( PRINT_ALL, "----- finished R_Init -----\n" ); } /* @@ -1448,19 +1448,19 @@ RE_Shutdown */ void RE_Shutdown( qboolean destroyWindow ) { - ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); + ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); - ri.Cmd_RemoveCommand ("modellist"); - ri.Cmd_RemoveCommand ("screenshotJPEG"); - ri.Cmd_RemoveCommand ("screenshot"); - ri.Cmd_RemoveCommand ("imagelist"); - ri.Cmd_RemoveCommand ("shaderlist"); - ri.Cmd_RemoveCommand ("skinlist"); - ri.Cmd_RemoveCommand ("gfxinfo"); - ri.Cmd_RemoveCommand("minimize"); - ri.Cmd_RemoveCommand( "modelist" ); - ri.Cmd_RemoveCommand( "shaderstate" ); - ri.Cmd_RemoveCommand( "gfxmeminfo" ); + ri->Cmd_RemoveCommand ("modellist"); + ri->Cmd_RemoveCommand ("screenshotJPEG"); + ri->Cmd_RemoveCommand ("screenshot"); + ri->Cmd_RemoveCommand ("imagelist"); + ri->Cmd_RemoveCommand ("shaderlist"); + ri->Cmd_RemoveCommand ("skinlist"); + ri->Cmd_RemoveCommand ("gfxinfo"); + ri->Cmd_RemoveCommand("minimize"); + ri->Cmd_RemoveCommand( "modelist" ); + ri->Cmd_RemoveCommand( "shaderstate" ); + ri->Cmd_RemoveCommand( "gfxmeminfo" ); if ( tr.registered ) { @@ -1496,7 +1496,7 @@ Touch all images to make sure they are resident */ void RE_EndRegistration( void ) { R_IssuePendingRenderCommands(); - if (!ri.Sys_LowPhysicalMemory()) { + if (!ri->Sys_LowPhysicalMemory()) { RB_ShowImages(); } } @@ -1521,7 +1521,7 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { Com_Memset( &re, 0, sizeof( re ) ); if ( apiVersion != REF_API_VERSION ) { - ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", + ri->Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", REF_API_VERSION, apiVersion ); return NULL; } diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index a34d9babce..5c75524a0b 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -303,7 +303,7 @@ static void LogLight( trRefEntity_t *ent ) { max2 = ent->directedLight[2]; } - ri.Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); + ri->Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); } /* @@ -397,9 +397,9 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // save out the byte packet version - ((byte *)&ent->ambientLightInt)[0] = ri.ftol(ent->ambientLight[0]); - ((byte *)&ent->ambientLightInt)[1] = ri.ftol(ent->ambientLight[1]); - ((byte *)&ent->ambientLightInt)[2] = ri.ftol(ent->ambientLight[2]); + ((byte *)&ent->ambientLightInt)[0] = ri->ftol(ent->ambientLight[0]); + ((byte *)&ent->ambientLightInt)[1] = ri->ftol(ent->ambientLight[1]); + ((byte *)&ent->ambientLightInt)[2] = ri->ftol(ent->ambientLight[2]); ((byte *)&ent->ambientLightInt)[3] = 0xff; // transform the direction to local space diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1933962c9d..abe22f9ec8 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -37,7 +37,7 @@ static float s_flipMatrix[16] = { }; -refimport_t ri; +refimport_t *ri = NULL; // entities that will have procedurally generated surfaces will just // point at this for their sorting surface @@ -1525,7 +1525,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, // to see a surface before the server has communicated the matching // portal surface entity, so we don't want to print anything here... - //ri.Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); + //ri->Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); return qfalse; } @@ -1700,7 +1700,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { // don't recursively mirror if (tr.viewParms.isPortal) { - ri.Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); + ri->Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); return qfalse; } @@ -1886,7 +1886,7 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { int pshadowed; int i; - //ri.Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); + //ri->Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); // it is possible for some views to not have any surfaces if ( numDrawSurfs < 1 ) { @@ -1923,7 +1923,7 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { // no shader should ever have this sort type if ( shader->sort == SS_BAD ) { - ri.Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); + ri->Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); } // if the mirror was completely clipped away, we may need to check another surface @@ -2013,13 +2013,13 @@ static void R_AddEntitySurface (int entityNum) R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); break; default: - ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); + ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); break; } } break; default: - ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); + ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); } } @@ -2118,7 +2118,7 @@ void R_DebugGraphics( void ) { GL_Bind( tr.whiteImage); GL_Cull( CT_FRONT_SIDED ); - ri.CM_DrawDebugSurface( R_DebugPolygon ); + ri->CM_DrawDebugSurface( R_DebugPolygon ); } @@ -2804,8 +2804,8 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); } - //ri.Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); - //ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); + //ri->Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); + //ri->Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); } diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 28c2e5fb30..b6434e4ac4 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -215,7 +215,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { } flod *= tr.currentModel->numLods; - lod = ri.ftol(flod); + lod = ri->ftol(flod); if ( lod < 0 ) { @@ -309,7 +309,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { - ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", + ri->Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; @@ -368,10 +368,10 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { } } if (shader == tr.defaultShader) { - ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); + ri->Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); } else if (shader->defaultShader) { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); + ri->Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); } //} else if ( surface->numShaders <= 0 ) { //shader = tr.defaultShader; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 2c567afc73..6dc83cdf40 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -68,7 +68,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) else Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); - size = ri.FS_ReadFile( namebuf, &buf.v ); + size = ri->FS_ReadFile( namebuf, &buf.v ); if(!buf.u) continue; @@ -80,10 +80,10 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) if (ident == MD3_IDENT) loaded = R_LoadMD3(mod, lod, buf.u, size, name); else - ri.Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); + ri->Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); } - ri.FS_FreeFile(buf.v); + ri->FS_FreeFile(buf.v); if(loaded) { @@ -108,7 +108,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) } #ifdef _DEBUG - ri.Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); + ri->Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); #endif mod->type = MOD_BAD; @@ -130,7 +130,7 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) qboolean loaded = qfalse; int filesize; - filesize = ri.FS_ReadFile(name, (void **) &buf.v); + filesize = ri->FS_ReadFile(name, (void **) &buf.v); if(!buf.u) { mod->type = MOD_BAD; @@ -141,11 +141,11 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) if(ident == MDR_IDENT) loaded = R_LoadMDR(mod, buf.u, filesize, name); - ri.FS_FreeFile (buf.v); + ri->FS_FreeFile (buf.v); if(!loaded) { - ri.Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); + ri->Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); mod->type = MOD_BAD; return 0; } @@ -167,7 +167,7 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) qboolean loaded = qfalse; int filesize; - filesize = ri.FS_ReadFile(name, (void **) &buf.v); + filesize = ri->FS_ReadFile(name, (void **) &buf.v); if(!buf.u) { mod->type = MOD_BAD; @@ -176,11 +176,11 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) loaded = R_LoadIQM(mod, buf.u, filesize, name); - ri.FS_FreeFile (buf.v); + ri->FS_FreeFile (buf.v); if(!loaded) { - ri.Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); + ri->Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); mod->type = MOD_BAD; return 0; } @@ -237,7 +237,7 @@ model_t *R_AllocModel( void ) { return NULL; } - mod = ri.Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); + mod = ri->Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); mod->index = tr.numModels; tr.models[tr.numModels] = mod; tr.numModels++; @@ -268,12 +268,12 @@ qhandle_t RE_RegisterModel( const char *name ) { char altName[ MAX_QPATH ]; if ( !name || !name[0] ) { - ri.Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); + ri->Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); return 0; } if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); + ri->Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); return 0; } @@ -293,7 +293,7 @@ qhandle_t RE_RegisterModel( const char *name ) { // allocate a new model_t if ( ( mod = R_AllocModel() ) == NULL ) { - ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); + ri->Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); return 0; } @@ -361,7 +361,7 @@ qhandle_t RE_RegisterModel( const char *name ) { { if( orgNameFailed ) { - ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", + ri->Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", name, altName ); } @@ -408,14 +408,14 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, version = LittleLong(md3Model->version); if(version != MD3_VERSION) { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); + ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); return qfalse; } mod->type = MOD_MESH; size = LittleLong(md3Model->ofsEnd); mod->dataSize += size; - mdvModel = mod->mdv[lod] = ri.Hunk_Alloc(sizeof(mdvModel_t), h_low); + mdvModel = mod->mdv[lod] = ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); // Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); @@ -431,13 +431,13 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, if(md3Model->numFrames < 1) { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); + ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); return qfalse; } // swap all the frames mdvModel->numFrames = md3Model->numFrames; - mdvModel->frames = frame = ri.Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); + mdvModel->frames = frame = ri->Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); md3Frame = (md3Frame_t *) ((byte *) md3Model + md3Model->ofsFrames); for(i = 0; i < md3Model->numFrames; i++, frame++, md3Frame++) @@ -453,7 +453,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the tags mdvModel->numTags = md3Model->numTags; - mdvModel->tags = tag = ri.Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); + mdvModel->tags = tag = ri->Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags * md3Model->numFrames; i++, tag++, md3Tag++) @@ -468,7 +468,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, } - mdvModel->tagNames = tagName = ri.Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); + mdvModel->tagNames = tagName = ri->Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags; i++, tagName++, md3Tag++) @@ -478,7 +478,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the surfaces mdvModel->numSurfaces = md3Model->numSurfaces; - mdvModel->surfaces = surf = ri.Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); + mdvModel->surfaces = surf = ri->Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); md3Surf = (md3Surface_t *) ((byte *) md3Model + md3Model->ofsSurfaces); for(i = 0; i < md3Model->numSurfaces; i++) @@ -497,14 +497,14 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, if(md3Surf->numVerts > SHADER_MAX_VERTEXES) { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", modName, SHADER_MAX_VERTEXES, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numVerts ); return qfalse; } if(md3Surf->numTriangles * 3 > SHADER_MAX_INDEXES) { - ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", modName, SHADER_MAX_INDEXES / 3, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numTriangles ); return qfalse; @@ -532,7 +532,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // register the shaders surf->numShaderIndexes = md3Surf->numShaders; - surf->shaderIndexes = shaderIndex = ri.Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); + surf->shaderIndexes = shaderIndex = ri->Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); md3Shader = (md3Shader_t *) ((byte *) md3Surf + md3Surf->ofsShaders); for(j = 0; j < md3Surf->numShaders; j++, shaderIndex++, md3Shader++) @@ -552,7 +552,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the triangles surf->numTriangles = md3Surf->numTriangles; - surf->triangles = tri = ri.Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); + surf->triangles = tri = ri->Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); for(j = 0; j < md3Surf->numTriangles; j++, tri++, md3Tri++) @@ -566,7 +566,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the XyzNormals surf->numVerts = md3Surf->numVerts; - surf->verts = v = ri.Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); + surf->verts = v = ri->Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); md3xyz = (md3XyzNormal_t *) ((byte *) md3Surf + md3Surf->ofsXyzNormals); for(j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++) @@ -595,7 +595,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, } // swap all the ST - surf->st = st = ri.Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); + surf->st = st = ri->Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); md3st = (md3St_t *) ((byte *) md3Surf + md3Surf->ofsSt); for(j = 0; j < md3Surf->numVerts; j++, md3st++, st++) @@ -684,7 +684,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, srfVBOMDVMesh_t *vboSurf; mdvModel->numVBOSurfaces = mdvModel->numSurfaces; - mdvModel->vboSurfaces = ri.Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); + mdvModel->vboSurfaces = ri->Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); vboSurf = mdvModel->vboSurfaces; surf = mdvModel->surfaces; @@ -725,7 +725,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, ofs_st = dataSize; dataSize += surf->numVerts * sizeof(*texcoords); - data = ri.Malloc(dataSize); + data = ri->Malloc(dataSize); verts = (void *)(data + ofs_xyz); normals = (void *)(data + ofs_normal); @@ -782,7 +782,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, vboSurf->vbo->size_xyz = sizeof(*verts) * surf->numVerts; vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts; - ri.Free(data); + ri->Free(data); vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numTriangles, surf->triangles, VBO_USAGE_STATIC); } @@ -817,7 +817,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char pinmodel->version = LittleLong(pinmodel->version); if (pinmodel->version != MDR_VERSION) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); return qfalse; } @@ -825,7 +825,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if(size > filesize) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); return qfalse; } @@ -849,12 +849,12 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if(pinmodel->numBones < 0 || sizeof(*mdr) + pinmodel->numFrames * (sizeof(*frame) + (pinmodel->numBones - 1) * sizeof(*frame->bones)) > size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } mod->dataSize += size; - mod->modelData = mdr = ri.Hunk_Alloc( size, h_low ); + mod->modelData = mdr = ri->Hunk_Alloc( size, h_low ); // Copy all the values over from the file and fix endian issues in the process, if necessary. @@ -871,7 +871,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if ( mdr->numFrames < 1 ) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); return qfalse; } @@ -963,7 +963,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if((byte *) (lod + 1) > (byte *) mdr + size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -979,7 +979,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if((byte *) (surf + 1) > (byte *) mdr + size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -998,14 +998,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // now do the checks that may fail. if ( surf->numVerts > SHADER_MAX_VERTEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", surf->numTriangles ); return qfalse; @@ -1033,7 +1033,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(curv->numWeights < 0 || (byte *) (v + 1) + (curv->numWeights - 1) * sizeof(*weight) > (byte *) mdr + size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1074,7 +1074,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(surf->numTriangles < 0 || (byte *) (tri + surf->numTriangles) > (byte *) mdr + size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1112,7 +1112,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(mdr->numTags < 0 || (byte *) (tag + mdr->numTags) > (byte *) mdr + size) { - ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1156,7 +1156,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { version = LittleLong (pinmodel->version); if (version != MD4_VERSION) { - ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n", + ri->Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n", mod_name, version, MD4_VERSION); return qfalse; } @@ -1164,7 +1164,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { mod->type = MOD_MD4; size = LittleLong(pinmodel->ofsEnd); mod->dataSize += size; - mod->modelData = md4 = ri.Hunk_Alloc( size, h_low ); + mod->modelData = md4 = ri->Hunk_Alloc( size, h_low ); Com_Memcpy(md4, buffer, size); @@ -1178,7 +1178,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { md4->ofsEnd = size; if ( md4->numFrames < 1 ) { - ri.Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name ); + ri->Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name ); return qfalse; } @@ -1214,13 +1214,13 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { LL(surf->ofsEnd); if ( surf->numVerts > SHADER_MAX_VERTEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", surf->numTriangles ); return qfalse; @@ -1356,14 +1356,14 @@ void R_Modellist_f( void ) { lods++; } } - ri.Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); + ri->Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); total += mod->dataSize; } - ri.Printf( PRINT_ALL, "%8i : Total models\n", total ); + ri->Printf( PRINT_ALL, "%8i : Total models\n", total ); #if 0 // not working right with new hunk if ( tr.world ) { - ri.Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); + ri->Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); } #endif } diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 15e0fe781c..96982beff8 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -155,7 +155,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na LL( header->version ); if( header->version != IQM_VERSION ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", + ri->Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", mod_name, header->version, IQM_VERSION); return qfalse; } @@ -193,7 +193,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // check ioq3 joint limit if ( header->num_joints > IQM_MAX_JOINTS ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", + ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", mod_name, IQM_MAX_JOINTS, header->num_joints); return qfalse; } @@ -320,14 +320,14 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // check ioq3 limits if ( mesh->num_vertexes > SHADER_MAX_VERTEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES, meshName[0] ? meshName : "a surface", mesh->num_vertexes ); return qfalse; } if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES ) { - ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", + ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", mod_name, SHADER_MAX_INDEXES / 3, meshName[0] ? meshName : "a surface", mesh->num_triangles ); return qfalse; @@ -453,7 +453,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na size += joint_names; // joint names mod->type = MOD_IQM; - iqmData = (iqmData_t *)ri.Hunk_Alloc( size, h_low ); + iqmData = (iqmData_t *)ri->Hunk_Alloc( size, h_low ); mod->modelData = iqmData; // fill header @@ -810,7 +810,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { || (ent->e.frame < 0) || (ent->e.oldframe >= data->num_frames) || (ent->e.oldframe < 0) ) { - ri.Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", + ri->Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index cab9d42be8..f4e456f37e 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -291,7 +291,7 @@ static qboolean RB_UpdateSunFlareVis(void) break; } - ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); + ri->Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); } qglGetQueryObjectuivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_ARB, &sampleCount); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 7e77418595..ae9e1cebbd 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -123,7 +123,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts if ( !hShader ) { // This isn't a useful warning, and an hShader of zero isn't a null shader, it's // the default shader. - //ri.Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader\n"); + //ri->Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader\n"); //return; } @@ -135,7 +135,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts since we don't plan on changing the const and making for room for those effects simply cut this message to developer only */ - ri.Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); + ri->Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); return; } @@ -207,19 +207,19 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { return; } if ( r_numentities >= MAX_REFENTITIES ) { - ri.Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); + ri->Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); return; } if ( Q_isnan(ent->origin[0]) || Q_isnan(ent->origin[1]) || Q_isnan(ent->origin[2]) ) { static qboolean firstTime = qtrue; if (firstTime) { firstTime = qfalse; - ri.Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); + ri->Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); } return; } if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { - ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); + ri->Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } backEndData->entities[r_numentities].e = *ent; @@ -307,10 +307,10 @@ void RE_RenderScene( const refdef_t *fd ) { return; } - startTime = ri.Milliseconds(); + startTime = ri->Milliseconds(); if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { - ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); + ri->Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); } Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) ); @@ -528,5 +528,5 @@ void RE_RenderScene( const refdef_t *fd ) { r_firstSceneDlight = r_numdlights; r_firstScenePoly = r_numpolys; - tr.frontEndMsec += ri.Milliseconds() - startTime; + tr.frontEndMsec += ri->Milliseconds() - startTime; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ef73fc5ffc..303e0212fe 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -103,8 +103,8 @@ static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { if ( bundle->isVideoMap ) { int oldtmu = glState.currenttmu; GL_SelectTexture(tmu); - ri.CIN_RunCinematic(bundle->videoMapHandle); - ri.CIN_UploadCinematic(bundle->videoMapHandle); + ri->CIN_RunCinematic(bundle->videoMapHandle); + ri->CIN_UploadCinematic(bundle->videoMapHandle); GL_SelectTexture(oldtmu); return; } @@ -116,7 +116,7 @@ static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { // it is necessary to do this messy calc to make sure animations line up // exactly with waveforms of the same frequency - index = ri.ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); + index = ri->ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); index >>= FUNCTABLE_SIZE2; if ( index < 0 ) { @@ -288,7 +288,7 @@ static void ComputeTexMatrix( shaderStage_t *pStage, int bundleNum, float *outma break; default: - ri.Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); + ri->Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); break; } } @@ -1622,10 +1622,10 @@ void RB_EndSurface( void ) { } if (input->indexes[SHADER_MAX_INDEXES-1] != 0) { - ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); + ri->Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); } if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) { - ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); + ri->Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); } if ( tess.shader == tr.shadowShader ) { diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index a5c4e9ab08..c5f3842e0a 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif -#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri.ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) +#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri->ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) static float *TableForFunc( genFunc_t func ) { @@ -48,7 +48,7 @@ static float *TableForFunc( genFunc_t func ) break; } - ri.Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); + ri->Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); return NULL; } @@ -378,10 +378,10 @@ static void AutospriteDeform( void ) { vec3_t leftDir, upDir; if ( tess.numVertexes & 3 ) { - ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); + ri->Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); } if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); + ri->Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); } oldVerts = tess.numVertexes; @@ -456,10 +456,10 @@ static void Autosprite2Deform( void ) { vec3_t forward; if ( tess.numVertexes & 3 ) { - ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); + ri->Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); } if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); + ri->Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); } if ( backEnd.currentEntity != &tr.worldEntity ) { @@ -736,7 +736,7 @@ void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ) glow = RB_CalcWaveColorSingle( wf ); - v = ri.ftol(255 * glow); + v = ri->ftol(255 * glow); color[0] = color[1] = color[2] = v; color[3] = 255; v = *(int *)color; @@ -1299,19 +1299,19 @@ static void RB_CalcDiffuseColor_scalar( unsigned char *colors ) *(int *)&colors[i*4] = ambientLightInt; continue; } - j = ri.ftol(ambientLight[0] + incoming * directedLight[0]); + j = ri->ftol(ambientLight[0] + incoming * directedLight[0]); if ( j > 255 ) { j = 255; } colors[i*4+0] = j; - j = ri.ftol(ambientLight[1] + incoming * directedLight[1]); + j = ri->ftol(ambientLight[1] + incoming * directedLight[1]); if ( j > 255 ) { j = 255; } colors[i*4+1] = j; - j = ri.ftol(ambientLight[2] + incoming * directedLight[2]); + j = ri->ftol(ambientLight[2] + incoming * directedLight[2]); if ( j > 255 ) { j = 255; } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index da2a7c6065..e037cd24e6 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -77,7 +77,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh = R_GetShaderByHandle(h); } if (sh == NULL || sh == tr.defaultShader) { - ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); + ri->Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); return; } @@ -88,7 +88,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char } if (sh2 == NULL || sh2 == tr.defaultShader) { - ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); + ri->Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); return; } @@ -122,14 +122,14 @@ static qboolean ParseVector( char **text, int count, float *v ) { // FIXME: spaces are currently required after parens, should change parseext... token = COM_ParseExt( text, qfalse ); if ( strcmp( token, "(" ) ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); return qfalse; } for ( i = 0 ; i < count ; i++ ) { token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); return qfalse; } v[i] = atof( token ); @@ -137,7 +137,7 @@ static qboolean ParseVector( char **text, int count, float *v ) { token = COM_ParseExt( text, qfalse ); if ( strcmp( token, ")" ) ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); return qfalse; } @@ -165,7 +165,7 @@ static unsigned NameToAFunc( const char *funcname ) return GLS_ATEST_GE_80; } - ri.Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); return 0; } @@ -214,7 +214,7 @@ static int NameToSrcBlendMode( const char *name ) return GLS_SRCBLEND_ALPHA_SATURATE; } - ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); return GLS_SRCBLEND_ONE; } @@ -258,7 +258,7 @@ static int NameToDstBlendMode( const char *name ) return GLS_DSTBLEND_ONE_MINUS_SRC_COLOR; } - ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); return GLS_DSTBLEND_ONE; } @@ -294,7 +294,7 @@ static genFunc_t NameToGenFunc( const char *funcname ) return GF_NOISE; } - ri.Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); return GF_SIN; } @@ -311,7 +311,7 @@ static void ParseWaveForm( char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->func = NameToGenFunc( token ); @@ -320,7 +320,7 @@ static void ParseWaveForm( char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->base = atof( token ); @@ -328,7 +328,7 @@ static void ParseWaveForm( char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->amplitude = atof( token ); @@ -336,7 +336,7 @@ static void ParseWaveForm( char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->phase = atof( token ); @@ -344,7 +344,7 @@ static void ParseWaveForm( char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->frequency = atof( token ); @@ -363,7 +363,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) texModInfo_t *tmi; if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { - ri.Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); + ri->Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); return; } @@ -380,28 +380,28 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); return; } tmi->wave.base = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.amplitude = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.phase = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.frequency = atof( token ); @@ -416,7 +416,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); return; } tmi->scale[0] = atof( token ); @@ -424,7 +424,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); return; } tmi->scale[1] = atof( token ); @@ -438,14 +438,14 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); return; } tmi->scroll[0] = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); return; } tmi->scroll[1] = atof( token ); @@ -459,7 +459,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.func = NameToGenFunc( token ); @@ -467,7 +467,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.base = atof( token ); @@ -475,7 +475,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.amplitude = atof( token ); @@ -483,7 +483,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.phase = atof( token ); @@ -491,7 +491,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.frequency = atof( token ); @@ -506,7 +506,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[0][0] = atof( token ); @@ -514,7 +514,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[0][1] = atof( token ); @@ -522,7 +522,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[1][0] = atof( token ); @@ -530,7 +530,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[1][1] = atof( token ); @@ -538,7 +538,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->translate[0] = atof( token ); @@ -546,7 +546,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->translate[1] = atof( token ); @@ -561,7 +561,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); return; } tmi->rotateSpeed = atof( token ); @@ -576,7 +576,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); } } @@ -599,7 +599,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qtrue ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); + ri->Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); return qfalse; } @@ -615,7 +615,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -638,7 +638,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) { if (!tr.worldDeluxeMapping) { - ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); return qfalse; } @@ -682,7 +682,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) if ( !stage->bundle[0].image[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -698,7 +698,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -729,7 +729,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); if ( !stage->bundle[0].image[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -741,7 +741,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); @@ -770,7 +770,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) stage->bundle[0].image[num] = R_FindImageFile( token, IMGTYPE_COLORALPHA, flags ); if ( !stage->bundle[0].image[num] ) { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } stage->bundle[0].numImageAnimations++; @@ -782,10 +782,10 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); return qfalse; } - stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); + stage->bundle[0].videoMapHandle = ri->CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); if (stage->bundle[0].videoMapHandle != -1) { stage->bundle[0].isVideoMap = qtrue; stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; @@ -799,7 +799,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -814,7 +814,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -828,7 +828,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -848,7 +848,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); continue; } // check for "simple" blends first @@ -868,7 +868,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); continue; } blendDstBits = NameToDstBlendMode( token ); @@ -888,7 +888,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt(text, qfalse); if(token[0] == 0) { - ri.Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); + ri->Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); continue; } @@ -915,7 +915,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); + ri->Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); continue; } } @@ -927,7 +927,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); continue; } stage->materialInfo[0] = atof( token ); @@ -940,7 +940,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); continue; } stage->materialInfo[1] = atof( token ); @@ -953,7 +953,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); continue; } @@ -1021,7 +1021,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -1033,7 +1033,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); continue; } @@ -1079,7 +1079,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) if ( token[0] == 0 ) { shader.portalRange = 256; - ri.Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); } else { @@ -1092,7 +1092,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -1104,7 +1104,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); continue; } @@ -1129,7 +1129,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); } } // @@ -1164,7 +1164,7 @@ static qboolean ParseStage( shaderStage_t *stage, char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -1233,12 +1233,12 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); return; } if ( shader.numDeforms == MAX_SHADER_DEFORMS ) { - ri.Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); return; } @@ -1275,7 +1275,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeWidth = atof( token ); @@ -1283,7 +1283,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeHeight = atof( token ); @@ -1291,7 +1291,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeSpeed = atof( token ); @@ -1305,7 +1305,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } @@ -1316,7 +1316,7 @@ static void ParseDeform( char **text ) { else { ds->deformationSpread = 100.0f; - ri.Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); } ParseWaveForm( text, &ds->deformationWave ); @@ -1329,7 +1329,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->deformationWave.amplitude = atof( token ); @@ -1337,7 +1337,7 @@ static void ParseDeform( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->deformationWave.frequency = atof( token ); @@ -1352,7 +1352,7 @@ static void ParseDeform( char **text ) { for ( i = 0 ; i < 3 ; i++ ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->moveVector[i] = atof( token ); @@ -1363,7 +1363,7 @@ static void ParseDeform( char **text ) { return; } - ri.Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); } @@ -1387,7 +1387,7 @@ static void ParseSkyParms( char **text ) { // outerbox token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); return; } if ( strcmp( token, "-" ) ) { @@ -1405,7 +1405,7 @@ static void ParseSkyParms( char **text ) { // cloudheight token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); return; } shader.sky.cloudHeight = atof( token ); @@ -1418,7 +1418,7 @@ static void ParseSkyParms( char **text ) { // innerbox token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); return; } if ( strcmp( token, "-" ) ) { @@ -1446,7 +1446,7 @@ void ParseSort( char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); return; } @@ -1572,7 +1572,7 @@ static qboolean ParseShader( char **text ) token = COM_ParseExt( text, qtrue ); if ( token[0] != '{' ) { - ri.Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); return qfalse; } @@ -1581,7 +1581,7 @@ static qboolean ParseShader( char **text ) token = COM_ParseExt( text, qtrue ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); return qfalse; } @@ -1594,7 +1594,7 @@ static qboolean ParseShader( char **text ) else if ( token[0] == '{' ) { if ( s >= MAX_SHADER_STAGES ) { - ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); return qfalse; } @@ -1739,7 +1739,7 @@ static qboolean ParseShader( char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); continue; } shader.fogParms.depthForOpaque = atof( token ); @@ -1773,7 +1773,7 @@ static qboolean ParseShader( char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri.Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); continue; } @@ -1787,7 +1787,7 @@ static qboolean ParseShader( char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); } continue; } @@ -1799,7 +1799,7 @@ static qboolean ParseShader( char **text ) } else { - ri.Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); return qfalse; } } @@ -2165,14 +2165,14 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { int defs = 0; - //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); + //ri->Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); // reuse diffuse, mark others inactive diffuse->type = ST_GLSL; if (lightmap) { - //ri.Printf(PRINT_ALL, ", lightmap"); + //ri->Printf(PRINT_ALL, ", lightmap"); diffuse->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; defs |= LIGHTDEF_USE_LIGHTMAP; } @@ -2187,7 +2187,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap) { - //ri.Printf(PRINT_ALL, ", deluxemap"); + //ri->Printf(PRINT_ALL, ", deluxemap"); diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex]; defs |= LIGHTDEF_USE_DELUXEMAP; @@ -2198,7 +2198,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, image_t *diffuseImg; if (normal) { - //ri.Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); + //ri->Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; defs |= LIGHTDEF_USE_NORMALMAP; if (parallax && r_parallaxMapping->integer) @@ -2231,7 +2231,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { if (specular) { - //ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); + //ri->Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; diffuse->materialInfo[0] = specular->materialInfo[0]; diffuse->materialInfo[1] = specular->materialInfo[1]; @@ -2244,7 +2244,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; } - //ri.Printf(PRINT_ALL, ".\n"); + //ri->Printf(PRINT_ALL, ".\n"); diffuse->glslShaderGroup = tr.lightallShader; diffuse->glslShaderIndex = defs; @@ -2641,11 +2641,11 @@ static shader_t *GeneratePermanentShader( void ) { int size, hash; if ( tr.numShaders == MAX_SHADERS ) { - ri.Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); + ri->Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); return tr.defaultShader; } - newShader = ri.Hunk_Alloc( sizeof( shader_t ), h_low ); + newShader = ri->Hunk_Alloc( sizeof( shader_t ), h_low ); *newShader = shader; @@ -2667,12 +2667,12 @@ static shader_t *GeneratePermanentShader( void ) { if ( !stages[i].active ) { break; } - newShader->stages[i] = ri.Hunk_Alloc( sizeof( stages[i] ), h_low ); + newShader->stages[i] = ri->Hunk_Alloc( sizeof( stages[i] ), h_low ); *newShader->stages[i] = stages[i]; for ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) { size = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t ); - newShader->stages[i]->bundle[b].texMods = ri.Hunk_Alloc( size, h_low ); + newShader->stages[i]->bundle[b].texMods = ri->Hunk_Alloc( size, h_low ); Com_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size ); } } @@ -2817,7 +2817,7 @@ static shader_t *FinishShader( void ) { // check for a missing texture if ( !pStage->bundle[0].image[0] ) { - ri.Printf( PRINT_WARNING, "Shader %s has a stage with no image\n", shader.name ); + ri->Printf( PRINT_WARNING, "Shader %s has a stage with no image\n", shader.name ); pStage->active = qfalse; stage++; continue; @@ -2939,9 +2939,9 @@ static shader_t *FinishShader( void ) { if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) { if (vertexLightmap) { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name ); + ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name ); } else { - ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); + ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); // Don't set this, it will just add duplicate shaders to the hash //shader.lightmapIndex = LIGHTMAP_NONE; } @@ -3110,7 +3110,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag lightmapIndex = LIGHTMAP_BY_VERTEX; } else if ( lightmapIndex < LIGHTMAP_2D ) { // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex]) - ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex ); + ri->Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex ); lightmapIndex = LIGHTMAP_BY_VERTEX; } @@ -3150,7 +3150,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // enable this when building a pak file to get a global list // of all explicit shaders if ( r_printShaders->integer ) { - ri.Printf( PRINT_ALL, "*SHADER* %s\n", name ); + ri->Printf( PRINT_ALL, "*SHADER* %s\n", name ); } if ( !ParseShader( &shaderText ) ) { @@ -3188,7 +3188,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); if ( !image ) { - ri.Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); + ri->Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); shader.defaultShader = qtrue; return FinishShader(); } @@ -3358,7 +3358,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -3392,7 +3392,7 @@ qhandle_t RE_RegisterShader( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -3422,7 +3422,7 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -3450,11 +3450,11 @@ it and returns a valid (possibly default) shader_t to be used internally. */ shader_t *R_GetShaderByHandle( qhandle_t hShader ) { if ( hShader < 0 ) { - ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + ri->Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); return tr.defaultShader; } if ( hShader >= tr.numShaders ) { - ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + ri->Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); return tr.defaultShader; } return tr.shaders[hShader]; @@ -3473,55 +3473,55 @@ void R_ShaderList_f (void) { int count; shader_t *shader; - ri.Printf (PRINT_ALL, "-----------------------\n"); + ri->Printf (PRINT_ALL, "-----------------------\n"); count = 0; for ( i = 0 ; i < tr.numShaders ; i++ ) { - if ( ri.Cmd_Argc() > 1 ) { + if ( ri->Cmd_Argc() > 1 ) { shader = tr.sortedShaders[i]; } else { shader = tr.shaders[i]; } - ri.Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); + ri->Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); if (shader->lightmapIndex >= 0 ) { - ri.Printf (PRINT_ALL, "L "); + ri->Printf (PRINT_ALL, "L "); } else { - ri.Printf (PRINT_ALL, " "); + ri->Printf (PRINT_ALL, " "); } if ( shader->multitextureEnv == GL_ADD ) { - ri.Printf( PRINT_ALL, "MT(a) " ); + ri->Printf( PRINT_ALL, "MT(a) " ); } else if ( shader->multitextureEnv == GL_MODULATE ) { - ri.Printf( PRINT_ALL, "MT(m) " ); + ri->Printf( PRINT_ALL, "MT(m) " ); } else if ( shader->multitextureEnv == GL_DECAL ) { - ri.Printf( PRINT_ALL, "MT(d) " ); + ri->Printf( PRINT_ALL, "MT(d) " ); } else { - ri.Printf( PRINT_ALL, " " ); + ri->Printf( PRINT_ALL, " " ); } if ( shader->explicitlyDefined ) { - ri.Printf( PRINT_ALL, "E " ); + ri->Printf( PRINT_ALL, "E " ); } else { - ri.Printf( PRINT_ALL, " " ); + ri->Printf( PRINT_ALL, " " ); } if ( shader->optimalStageIteratorFunc == RB_StageIteratorGeneric ) { - ri.Printf( PRINT_ALL, "gen " ); + ri->Printf( PRINT_ALL, "gen " ); } else if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) { - ri.Printf( PRINT_ALL, "sky " ); + ri->Printf( PRINT_ALL, "sky " ); } else { - ri.Printf( PRINT_ALL, " " ); + ri->Printf( PRINT_ALL, " " ); } if ( shader->defaultShader ) { - ri.Printf (PRINT_ALL, ": %s (DEFAULTED)\n", shader->name); + ri->Printf (PRINT_ALL, ": %s (DEFAULTED)\n", shader->name); } else { - ri.Printf (PRINT_ALL, ": %s\n", shader->name); + ri->Printf (PRINT_ALL, ": %s\n", shader->name); } count++; } - ri.Printf (PRINT_ALL, "%i total shaders\n", count); - ri.Printf (PRINT_ALL, "------------------\n"); + ri->Printf (PRINT_ALL, "%i total shaders\n", count); + ri->Printf (PRINT_ALL, "------------------\n"); } /* @@ -3547,11 +3547,11 @@ static void ScanAndLoadShaderFiles( void ) long sum = 0, summand; // scan for shader files - shaderFiles = ri.FS_ListFiles( "scripts", ".shader", &numShaderFiles ); + shaderFiles = ri->FS_ListFiles( "scripts", ".shader", &numShaderFiles ); if ( !shaderFiles || !numShaderFiles ) { - ri.Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); + ri->Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); return; } @@ -3573,17 +3573,17 @@ static void ScanAndLoadShaderFiles( void ) strcpy(ext, ".mtr"); } - if ( ri.FS_ReadFile( filename, NULL ) <= 0 ) + if ( ri->FS_ReadFile( filename, NULL ) <= 0 ) { Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); } } - ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); - summand = ri.FS_ReadFile( filename, (void **)&buffers[i] ); + ri->Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); + summand = ri->FS_ReadFile( filename, (void **)&buffers[i] ); if ( !buffers[i] ) - ri.Error( ERR_DROP, "Couldn't load %s", filename ); + ri->Error( ERR_DROP, "Couldn't load %s", filename ); // Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders. p = buffers[i]; @@ -3601,23 +3601,23 @@ static void ScanAndLoadShaderFiles( void ) token = COM_ParseExt(&p, qtrue); if(token[0] != '{' || token[1] != '\0') { - ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace", + ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace", filename, shaderName, shaderLine); if (token[0]) { - ri.Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine()); + ri->Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine()); } - ri.Printf(PRINT_WARNING, ".\n"); - ri.FS_FreeFile(buffers[i]); + ri->Printf(PRINT_WARNING, ".\n"); + ri->FS_FreeFile(buffers[i]); buffers[i] = NULL; break; } if(!SkipBracedSection(&p, 1)) { - ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", + ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); - ri.FS_FreeFile(buffers[i]); + ri->FS_FreeFile(buffers[i]); buffers[i] = NULL; break; } @@ -3629,7 +3629,7 @@ static void ScanAndLoadShaderFiles( void ) } // build single large buffer - s_shaderText = ri.Hunk_Alloc( sum + numShaderFiles*2, h_low ); + s_shaderText = ri->Hunk_Alloc( sum + numShaderFiles*2, h_low ); s_shaderText[ 0 ] = '\0'; textEnd = s_shaderText; @@ -3642,13 +3642,13 @@ static void ScanAndLoadShaderFiles( void ) strcat( textEnd, buffers[i] ); strcat( textEnd, "\n" ); textEnd += strlen( textEnd ); - ri.FS_FreeFile( buffers[i] ); + ri->FS_FreeFile( buffers[i] ); } COM_Compress( s_shaderText ); // free up memory - ri.FS_FreeFileList( shaderFiles ); + ri->FS_FreeFileList( shaderFiles ); Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes)); size = 0; @@ -3669,7 +3669,7 @@ static void ScanAndLoadShaderFiles( void ) size += MAX_SHADERTEXT_HASH; - hashMem = ri.Hunk_Alloc( size * sizeof(char *), h_low ); + hashMem = ri->Hunk_Alloc( size * sizeof(char *), h_low ); for (i = 0; i < MAX_SHADERTEXT_HASH; i++) { shaderTextHashTable[i] = (char **) hashMem; @@ -3775,7 +3775,7 @@ R_InitShaders ================== */ void R_InitShaders( void ) { - ri.Printf( PRINT_ALL, "Initializing Shaders\n" ); + ri->Printf( PRINT_ALL, "Initializing Shaders\n" ); Com_Memset(hashTable, 0, sizeof(hashTable)); diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index f1e5249dd2..9db9e811c4 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -160,7 +160,7 @@ static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) int i, j; if (nump > MAX_CLIP_VERTS-2) - ri.Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + ri->Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); if (stage == 6) { // fully clipped, so draw it AddSkyPolygon (nump, vecs); @@ -393,7 +393,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max if(tess.numVertexes >= SHADER_MAX_VERTEXES) { - ri.Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); + ri->Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); } } } @@ -404,7 +404,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max { if (tess.numIndexes + 6 >= SHADER_MAX_INDEXES) { - ri.Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); + ri->Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); } tess.indexes[tess.numIndexes++] = s + t * (maxs[0] - mins[0] + 1) + firstVertex; @@ -571,7 +571,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad if ( tess.numVertexes >= SHADER_MAX_VERTEXES ) { - ri.Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); + ri->Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); } } } @@ -649,10 +649,10 @@ static void FillCloudBox( const shader_t *shader, int stage ) continue; } - sky_mins_subd[0] = ri.ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); - sky_mins_subd[1] = ri.ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[0] = ri.ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[1] = ri.ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[0] = ri->ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[1] = ri->ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[0] = ri->ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[1] = ri->ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; diff --git a/codemp/rd-rend2/tr_subs.cpp b/codemp/rd-rend2/tr_subs.cpp index 6f4901287c..d7d30347ed 100644 --- a/codemp/rd-rend2/tr_subs.cpp +++ b/codemp/rd-rend2/tr_subs.cpp @@ -32,7 +32,7 @@ void QDECL Com_Printf( const char *msg, ... ) Q_vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); - ri.Printf(PRINT_ALL, "%s", text); + ri->Printf(PRINT_ALL, "%s", text); } void QDECL Com_Error( int level, const char *error, ... ) @@ -44,5 +44,5 @@ void QDECL Com_Error( int level, const char *error, ... ) Q_vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); - ri.Error(level, "%s", text); + ri->Error(level, "%s", text); } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 427d153da6..8b72ac7b45 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -57,10 +57,10 @@ void RB_CheckOverflow( int verts, int indexes ) { RB_EndSurface(); if ( verts >= SHADER_MAX_VERTEXES ) { - ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); + ri->Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); } if ( indexes >= SHADER_MAX_INDEXES ) { - ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); + ri->Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); } RB_BeginSurface(tess.shader, tess.fogNum ); @@ -1565,7 +1565,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { } static void RB_SurfaceBad( surfaceType_t *surfType ) { - ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" ); + ri->Printf( PRINT_ALL, "Bad surface tesselated.\n" ); } static void RB_SurfaceFlare(srfFlare_t *surf) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index e9f2598bea..bb2fc486a9 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -49,16 +49,16 @@ VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "R_CreateVBO: \"%s\" is too long", name); + ri->Error(ERR_DROP, "R_CreateVBO: \"%s\" is too long", name); } if ( tr.numVBOs == MAX_VBOS ) { - ri.Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); + ri->Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); } R_IssuePendingRenderCommands(); - vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); + vbo = tr.vbos[tr.numVBOs] = ri->Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; memset(vbo, 0, sizeof(*vbo)); @@ -117,16 +117,16 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "R_CreateVBO2: \"%s\" is too long", name); + ri->Error(ERR_DROP, "R_CreateVBO2: \"%s\" is too long", name); } if ( tr.numVBOs == MAX_VBOS ) { - ri.Error( ERR_DROP, "R_CreateVBO2: MAX_VBOS hit"); + ri->Error( ERR_DROP, "R_CreateVBO2: MAX_VBOS hit"); } R_IssuePendingRenderCommands(); - vbo = tr.vbos[tr.numVBOs] = ri.Hunk_Alloc(sizeof(*vbo), h_low); + vbo = tr.vbos[tr.numVBOs] = ri->Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; memset(vbo, 0, sizeof(*vbo)); @@ -196,10 +196,10 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = ri.Hunk_AllocateTempMemory(dataSize); + data = ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; - //ri.Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, + //ri->Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); for (i = 0; i < numVertexes; i++) @@ -304,7 +304,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = ri.Hunk_AllocateTempMemory(dataSize); + data = ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; vbo->ofs_xyz = 0; @@ -329,7 +329,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->stride_lightmap = sizeof(verts[0].lightmap); vbo->stride_lightdir = sizeof(verts[0].lightdir); - //ri.Printf(PRINT_ALL, "2CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, + //ri->Printf(PRINT_ALL, "2CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); // xyz @@ -433,7 +433,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert GL_CheckErrors(); - ri.Hunk_FreeTempMemory(data); + ri->Hunk_FreeTempMemory(data); return vbo; } @@ -466,16 +466,16 @@ IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, v if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "R_CreateIBO: \"%s\" is too long", name); + ri->Error(ERR_DROP, "R_CreateIBO: \"%s\" is too long", name); } if ( tr.numIBOs == MAX_IBOS ) { - ri.Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); + ri->Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); } R_IssuePendingRenderCommands(); - ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = ri->Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; Q_strncpyz(ibo->name, name, sizeof(ibo->name)); @@ -534,22 +534,22 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * if(strlen(name) >= MAX_QPATH) { - ri.Error(ERR_DROP, "R_CreateIBO2: \"%s\" is too long", name); + ri->Error(ERR_DROP, "R_CreateIBO2: \"%s\" is too long", name); } if ( tr.numIBOs == MAX_IBOS ) { - ri.Error( ERR_DROP, "R_CreateIBO2: MAX_IBOS hit"); + ri->Error( ERR_DROP, "R_CreateIBO2: MAX_IBOS hit"); } R_IssuePendingRenderCommands(); - ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = ri->Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; Q_strncpyz(ibo->name, name, sizeof(ibo->name)); indexesSize = numTriangles * 3 * sizeof(int); - indexes = ri.Hunk_AllocateTempMemory(indexesSize); + indexes = ri->Hunk_AllocateTempMemory(indexesSize); indexesOfs = 0; for(i = 0, tri = triangles; i < numTriangles; i++, tri++) @@ -575,7 +575,7 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * GL_CheckErrors(); - ri.Hunk_FreeTempMemory(indexes); + ri->Hunk_FreeTempMemory(indexes); return ibo; } @@ -590,7 +590,7 @@ void R_BindVBO(VBO_t * vbo) if(!vbo) { //R_BindNullVBO(); - ri.Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); + ri->Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); return; } @@ -643,7 +643,7 @@ void R_BindIBO(IBO_t * ibo) if(!ibo) { //R_BindNullIBO(); - ri.Error(ERR_DROP, "R_BindIBO: NULL ibo"); + ri->Error(ERR_DROP, "R_BindIBO: NULL ibo"); return; } @@ -690,7 +690,7 @@ void R_InitVBOs(void) int dataSize; int offset; - ri.Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); + ri->Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); tr.numVBOs = 0; tr.numIBOs = 0; @@ -756,7 +756,7 @@ void R_ShutdownVBOs(void) VBO_t *vbo; IBO_t *ibo; - ri.Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); + ri->Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); R_BindNullVBO(); R_BindNullIBO(); @@ -771,7 +771,7 @@ void R_ShutdownVBOs(void) qglDeleteBuffersARB(1, &vbo->vertexesVBO); } - //ri.Free(vbo); + //ri->Free(vbo); } for(i = 0; i < tr.numIBOs; i++) @@ -783,7 +783,7 @@ void R_ShutdownVBOs(void) qglDeleteBuffersARB(1, &ibo->indexesVBO); } - //ri.Free(ibo); + //ri->Free(ibo); } tr.numVBOs = 0; @@ -803,14 +803,14 @@ void R_VBOList_f(void) int vertexesSize = 0; int indexesSize = 0; - ri.Printf(PRINT_ALL, " size name\n"); - ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); + ri->Printf(PRINT_ALL, " size name\n"); + ri->Printf(PRINT_ALL, "----------------------------------------------------------\n"); for(i = 0; i < tr.numVBOs; i++) { vbo = tr.vbos[i]; - ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", vbo->vertexesSize / (1024 * 1024), + ri->Printf(PRINT_ALL, "%d.%02d MB %s\n", vbo->vertexesSize / (1024 * 1024), (vbo->vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024), vbo->name); vertexesSize += vbo->vertexesSize; @@ -820,18 +820,18 @@ void R_VBOList_f(void) { ibo = tr.ibos[i]; - ri.Printf(PRINT_ALL, "%d.%02d MB %s\n", ibo->indexesSize / (1024 * 1024), + ri->Printf(PRINT_ALL, "%d.%02d MB %s\n", ibo->indexesSize / (1024 * 1024), (ibo->indexesSize % (1024 * 1024)) * 100 / (1024 * 1024), ibo->name); indexesSize += ibo->indexesSize; } - ri.Printf(PRINT_ALL, " %i total VBOs\n", tr.numVBOs); - ri.Printf(PRINT_ALL, " %d.%02d MB total vertices memory\n", vertexesSize / (1024 * 1024), + ri->Printf(PRINT_ALL, " %i total VBOs\n", tr.numVBOs); + ri->Printf(PRINT_ALL, " %d.%02d MB total vertices memory\n", vertexesSize / (1024 * 1024), (vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); - ri.Printf(PRINT_ALL, " %i total IBOs\n", tr.numIBOs); - ri.Printf(PRINT_ALL, " %d.%02d MB total triangle indices memory\n", indexesSize / (1024 * 1024), + ri->Printf(PRINT_ALL, " %i total IBOs\n", tr.numIBOs); + ri->Printf(PRINT_ALL, " %d.%02d MB total triangle indices memory\n", indexesSize / (1024 * 1024), (indexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); } @@ -860,46 +860,46 @@ void RB_UpdateVBOs(unsigned int attribBits) { if(attribBits & ATTR_POSITION) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); } if(attribBits & ATTR_TEXCOORD || attribBits & ATTR_LIGHTCOORD) { // these are interleaved, so we update both if either need it - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); } if(attribBits & ATTR_NORMAL) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); } #ifdef USE_VERT_TANGENT_SPACE if(attribBits & ATTR_TANGENT) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); } if(attribBits & ATTR_BITANGENT) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0]), tess.bitangent); } #endif if(attribBits & ATTR_COLOR) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); } if(attribBits & ATTR_LIGHTDIRECTION) { - //ri.Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0])); + //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index ab447f8aa5..45863ac04e 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -607,7 +607,7 @@ static mnode_t *R_PointInLeaf( const vec3_t p ) { cplane_t *plane; if ( !tr.world ) { - ri.Error (ERR_DROP, "R_PointInLeaf: bad model"); + ri->Error (ERR_DROP, "R_PointInLeaf: bad model"); } node = tr.world->nodes; @@ -650,7 +650,7 @@ qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) { byte *vis; leaf = R_PointInLeaf( p1 ); - vis = ri.CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? + vis = ri->CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? leaf = R_PointInLeaf( p2 ); if ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) { @@ -700,7 +700,7 @@ static void R_MarkLeaves (void) { { if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) { - ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); } tr.visIndex = i; return; @@ -720,7 +720,7 @@ static void R_MarkLeaves (void) { if ( r_showcluster->modified || r_showcluster->integer ) { r_showcluster->modified = qfalse; if ( r_showcluster->integer ) { - ri.Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); + ri->Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); } } From b1e418109820c527344bd8f5b9b56de6d4c93983 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:16:47 -0400 Subject: [PATCH 010/708] Use explicit casting for hunk allocations (which is now required in C++) --- codemp/rd-rend2/tr_vbo.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index bb2fc486a9..fcee31e059 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -58,7 +58,7 @@ VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, R_IssuePendingRenderCommands(); - vbo = tr.vbos[tr.numVBOs] = ri->Hunk_Alloc(sizeof(*vbo), h_low); + vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri->Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; memset(vbo, 0, sizeof(*vbo)); @@ -126,7 +126,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert R_IssuePendingRenderCommands(); - vbo = tr.vbos[tr.numVBOs] = ri->Hunk_Alloc(sizeof(*vbo), h_low); + vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri->Hunk_Alloc(sizeof(*vbo), h_low); tr.numVBOs++; memset(vbo, 0, sizeof(*vbo)); @@ -196,7 +196,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = ri->Hunk_AllocateTempMemory(dataSize); + data = (VBO_t *)ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; //ri->Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, @@ -304,7 +304,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = ri->Hunk_AllocateTempMemory(dataSize); + data = (VBO_t *)ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; vbo->ofs_xyz = 0; @@ -475,7 +475,7 @@ IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, v R_IssuePendingRenderCommands(); - ibo = tr.ibos[tr.numIBOs] = ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; Q_strncpyz(ibo->name, name, sizeof(ibo->name)); @@ -543,13 +543,13 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * R_IssuePendingRenderCommands(); - ibo = tr.ibos[tr.numIBOs] = ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; Q_strncpyz(ibo->name, name, sizeof(ibo->name)); indexesSize = numTriangles * 3 * sizeof(int); - indexes = ri->Hunk_AllocateTempMemory(indexesSize); + indexes = (byte *)ri->Hunk_AllocateTempMemory(indexesSize); indexesOfs = 0; for(i = 0, tri = triangles; i < numTriangles; i++, tri++) From 68d79019eac1ec15f652c8f762b7b650db7eff6b Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:20:58 -0400 Subject: [PATCH 011/708] My bad, those should have been byte pointers, not VBO_t pointers --- codemp/rd-rend2/tr_vbo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index fcee31e059..47513b1565 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -196,7 +196,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = (VBO_t *)ri->Hunk_AllocateTempMemory(dataSize); + data = (byte *)ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; //ri->Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, @@ -304,7 +304,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // create VBO dataSize *= numVertexes; - data = (VBO_t *)ri->Hunk_AllocateTempMemory(dataSize); + data = (byte *)ri->Hunk_AllocateTempMemory(dataSize); dataOfs = 0; vbo->ofs_xyz = 0; From 79054daea7f8b2ae2ab322466c6698e6443315c5 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:25:07 -0400 Subject: [PATCH 012/708] Temp fix for differences in RB_SurfaceEntity --- codemp/rd-rend2/tr_surface.cpp | 227 +-------------------------------- 1 file changed, 4 insertions(+), 223 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 8b72ac7b45..347db8a9c7 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -478,7 +478,7 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex else if (mergeBack == -1 && mergeForward != -1) { tess.multiDrawNumIndexes[mergeForward] += numIndexes; - tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset; + tess.multiDrawFirstIndex[mergeForward] = (glIndex_t *)firstIndexOffset; tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex); tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex); @@ -502,8 +502,8 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex else if (mergeBack == -1 && mergeForward == -1) { tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes; - tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset; - tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset; + tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[tess.multiDrawPrimitives] = (glIndex_t *)lastIndexOffset; tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex; tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex; tess.multiDrawPrimitives++; @@ -629,217 +629,6 @@ static void RB_SurfaceBeam( void ) //================================================================================ -static void DoRailCore( const vec3_t start, const vec3_t end, const vec3_t up, float len, float spanWidth ) -{ - float spanWidth2; - int vbase; - float t = len / 256.0f; - - vbase = tess.numVertexes; - - spanWidth2 = -spanWidth; - - // FIXME: use quad stamp? - VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] * 0.25 / 255.0f; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] * 0.25 / 255.0f; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] * 0.25 / 255.0f; - tess.numVertexes++; - - VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; - tess.numVertexes++; - - VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); - - tess.texCoords[tess.numVertexes][0][0] = t; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; - tess.numVertexes++; - - VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = t; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = vbase; - tess.indexes[tess.numIndexes++] = vbase + 1; - tess.indexes[tess.numIndexes++] = vbase + 2; - - tess.indexes[tess.numIndexes++] = vbase + 2; - tess.indexes[tess.numIndexes++] = vbase + 1; - tess.indexes[tess.numIndexes++] = vbase + 3; -} - -static void DoRailDiscs( int numSegs, const vec3_t start, const vec3_t dir, const vec3_t right, const vec3_t up ) -{ - int i; - vec3_t pos[4]; - vec3_t v; - int spanWidth = r_railWidth->integer; - float c, s; - float scale; - - if ( numSegs > 1 ) - numSegs--; - if ( !numSegs ) - return; - - scale = 0.25; - - for ( i = 0; i < 4; i++ ) - { - c = cos( DEG2RAD( 45 + i * 90 ) ); - s = sin( DEG2RAD( 45 + i * 90 ) ); - v[0] = ( right[0] * c + up[0] * s ) * scale * spanWidth; - v[1] = ( right[1] * c + up[1] * s ) * scale * spanWidth; - v[2] = ( right[2] * c + up[2] * s ) * scale * spanWidth; - VectorAdd( start, v, pos[i] ); - - if ( numSegs > 1 ) - { - // offset by 1 segment if we're doing a long distance shot - VectorAdd( pos[i], dir, pos[i] ); - } - } - - for ( i = 0; i < numSegs; i++ ) - { - int j; - - RB_CHECKOVERFLOW( 4, 6 ); - - for ( j = 0; j < 4; j++ ) - { - VectorCopy( pos[j], tess.xyz[tess.numVertexes] ); - tess.texCoords[tess.numVertexes][0][0] = ( j < 2 ); - tess.texCoords[tess.numVertexes][0][1] = ( j && j != 3 ); - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2] / 255.0f; - tess.numVertexes++; - - VectorAdd( pos[j], dir, pos[j] ); - } - - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 0; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 3; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 1; - tess.indexes[tess.numIndexes++] = tess.numVertexes - 4 + 2; - } -} - -/* -** RB_SurfaceRailRinges -*/ -static void RB_SurfaceRailRings( void ) { - refEntity_t *e; - int numSegs; - int len; - vec3_t vec; - vec3_t right, up; - vec3_t start, end; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, start ); - VectorCopy( e->origin, end ); - - // compute variables - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - MakeNormalVectors( vec, right, up ); - numSegs = ( len ) / r_railSegmentLength->value; - if ( numSegs <= 0 ) { - numSegs = 1; - } - - VectorScale( vec, r_railSegmentLength->value, vec ); - - DoRailDiscs( numSegs, start, vec, right, up ); -} - -/* -** RB_SurfaceRailCore -*/ -static void RB_SurfaceRailCore( void ) { - refEntity_t *e; - int len; - vec3_t right; - vec3_t vec; - vec3_t start, end; - vec3_t v1, v2; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, start ); - VectorCopy( e->origin, end ); - - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - - // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorNormalize( v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); - VectorNormalize( v2 ); - CrossProduct( v1, v2, right ); - VectorNormalize( right ); - - DoRailCore( start, end, right, len, r_railCoreWidth->integer ); -} - -/* -** RB_SurfaceLightningBolt -*/ -static void RB_SurfaceLightningBolt( void ) { - refEntity_t *e; - int len; - vec3_t right; - vec3_t vec; - vec3_t start, end; - vec3_t v1, v2; - int i; - - e = &backEnd.currentEntity->e; - - VectorCopy( e->oldorigin, end ); - VectorCopy( e->origin, start ); - - // compute variables - VectorSubtract( end, start, vec ); - len = VectorNormalize( vec ); - - // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorNormalize( v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); - VectorNormalize( v2 ); - CrossProduct( v1, v2, right ); - VectorNormalize( right ); - - for ( i = 0 ; i < 4 ; i++ ) { - vec3_t temp; - - DoRailCore( start, end, right, len, 8 ); - RotatePointAroundVector( temp, vec, right, 45 ); - VectorCopy( temp, right ); - } -} - /* ** VectorArrayNormalize * @@ -1549,15 +1338,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { case RT_BEAM: RB_SurfaceBeam(); break; - case RT_RAIL_CORE: - RB_SurfaceRailCore(); - break; - case RT_RAIL_RINGS: - RB_SurfaceRailRings(); - break; - case RT_LIGHTNING: - RB_SurfaceLightningBolt(); - break; +#pragma error("HALT! You need to add cases for RT_ORIENTED_QUAD, RT_ELECTRICITY, RT_LINE, RT_ORIENTEDLINE, RT_SABER_GLOW, RT_CYLINDER and RT_ENT_CHAIN to RB_SurfaceEntity!!") default: RB_SurfaceAxis(); break; From 504441b252acc0d68abdd37ee7f26bddf0256159 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:32:52 -0400 Subject: [PATCH 013/708] Fixing some declarations --- codemp/rd-rend2/tr_shader.cpp | 2 ++ codemp/rd-rend2/tr_sky.cpp | 4 ++-- codemp/rd-vanilla/tr_local.h | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e037cd24e6..2817d3f79d 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -37,6 +37,8 @@ static shader_t* hashTable[FILE_HASH_SIZE]; #define MAX_SHADERTEXT_HASH 2048 static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; +qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); + /* ================ return a hash value for the filename diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 9db9e811c4..9ce5898fc3 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -649,7 +649,7 @@ static void FillCloudBox( const shader_t *shader, int stage ) continue; } - sky_mins_subd[0] = ri->ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[0] = ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); sky_mins_subd[1] = ri->ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); sky_maxs_subd[0] = ri->ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); sky_maxs_subd[1] = ri->ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); @@ -691,7 +691,7 @@ static void FillCloudBox( const shader_t *shader, int stage ) } // only add indexes for first stage - FillCloudySkySide( sky_mins_subd, sky_maxs_subd, ( stage == 0 ) ); + FillCloudySkySide( sky_mins_subd, sky_maxs_subd, (qboolean)( stage == 0 ) ); } } diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 954f559327..b0f1d3fe29 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -29,6 +29,8 @@ typedef unsigned int glIndex_t; #define MAX_STATES_PER_SHADER 32 #define MAX_STATE_NAME 32 +glconfig_t glConfig; + typedef enum { DLIGHT_VERTICAL = 0, From 9b52274f2fc7a8a325948efeffe95dadd30d0bea Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:35:37 -0400 Subject: [PATCH 014/708] GLimp_LogComment doesn't actually do anything, commenting out the calls for now (read note) --- codemp/rd-rend2/tr_surface.cpp | 4 ++-- codemp/rd-rend2/tr_vbo.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 347db8a9c7..a1abf9f94d 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -172,7 +172,7 @@ based on Tess_InstantQuad from xreal */ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) { - GLimp_LogComment("--- RB_InstantQuad2 ---\n"); +// GLimp_LogComment("--- RB_InstantQuad2 ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez tess.numVertexes = 0; tess.numIndexes = 0; @@ -1367,7 +1367,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) //mdvSurface_t *mdvSurface; refEntity_t *refEnt; - GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); +// GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez if(!surface->vbo || !surface->ibo) return; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 47513b1565..d529af8134 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -594,11 +594,11 @@ void R_BindVBO(VBO_t * vbo) return; } - if(r_logFile->integer) +/* if(r_logFile->integer) { // don't just call LogComment, or we will get a call to va() every frame! GLimp_LogComment(va("--- R_BindVBO( %s ) ---\n", vbo->name)); - } + } */ // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez if(glState.currentVBO != vbo) { @@ -622,7 +622,7 @@ R_BindNullVBO */ void R_BindNullVBO(void) { - GLimp_LogComment("--- R_BindNullVBO ---\n"); +// GLimp_LogComment("--- R_BindNullVBO ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez if(glState.currentVBO) { @@ -647,11 +647,11 @@ void R_BindIBO(IBO_t * ibo) return; } - if(r_logFile->integer) +/* if(r_logFile->integer) { // don't just call LogComment, or we will get a call to va() every frame! GLimp_LogComment(va("--- R_BindIBO( %s ) ---\n", ibo->name)); - } + } */ // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez if(glState.currentIBO != ibo) { @@ -670,7 +670,7 @@ R_BindNullIBO */ void R_BindNullIBO(void) { - GLimp_LogComment("--- R_BindNullIBO ---\n"); +// GLimp_LogComment("--- R_BindNullIBO ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez if(glState.currentIBO) { @@ -847,7 +847,7 @@ Update the default VBO to replace the client side vertex arrays */ void RB_UpdateVBOs(unsigned int attribBits) { - GLimp_LogComment("--- RB_UpdateVBOs ---\n"); +// GLimp_LogComment("--- RB_UpdateVBOs ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez backEnd.pc.c_dynamicVboDraws++; From 7fe53253ba80c727e6712962f753c5dc212ffd79 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:38:43 -0400 Subject: [PATCH 015/708] ri->Free() --> Z_Free() --- codemp/rd-rend2/tr_curve.cpp | 10 +++++----- codemp/rd-rend2/tr_glsl.cpp | 6 +++--- codemp/rd-rend2/tr_model.cpp | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index b1c1eabcfd..e08b195d36 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -495,11 +495,11 @@ R_FreeSurfaceGridMesh ================= */ void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) { - ri->Free(grid->widthLodError); - ri->Free(grid->heightLodError); - ri->Free(grid->triangles); - ri->Free(grid->verts); - ri->Free(grid); + Z_Free(grid->widthLodError); + Z_Free(grid->heightLodError); + Z_Free(grid->triangles); + Z_Free(grid->verts); + Z_Free(grid); } /* diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index bc37dccb59..90b822ceac 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -179,7 +179,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) ri->Printf(printLevel, "%s\n", msgPart); } - ri->Free(msg); + Z_Free(msg); } } @@ -202,7 +202,7 @@ static void GLSL_PrintShaderSource(GLhandleARB object) ri->Printf(PRINT_ALL, "%s\n", msgPart); } - ri->Free(msg); + Z_Free(msg); } static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, int size ) @@ -856,7 +856,7 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) if (program->uniformBuffer) { - ri->Free(program->uniformBuffer); + Z_Free(program->uniformBuffer); } Com_Memset(program, 0, sizeof(*program)); diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 6dc83cdf40..4bc95e0495 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -782,7 +782,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, vboSurf->vbo->size_xyz = sizeof(*verts) * surf->numVerts; vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts; - ri->Free(data); + Z_Free(data); vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numTriangles, surf->triangles, VBO_USAGE_STATIC); } From e719beeaeb1015815357d952bb04e06195a09ca1 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:40:12 -0400 Subject: [PATCH 016/708] ri->Malloc() --> Z_Malloc() --- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_curve.cpp | 10 +++++----- codemp/rd-rend2/tr_glsl.cpp | 6 +++--- codemp/rd-rend2/tr_model.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 579b7fda7c..8e68256f29 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -242,7 +242,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } } - image = ri->Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); + image = Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); if (tr.worldDeluxeMapping) numLightmaps >>= 1; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index e08b195d36..88b7dfadaa 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -432,21 +432,21 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri->Hunk_Alloc*/ ri->Malloc( size ); + grid = /*ri->Hunk_Alloc*/ Z_Malloc( size ); Com_Memset(grid, 0, size); - grid->widthLodError = /*ri->Hunk_Alloc*/ ri->Malloc( width * 4 ); + grid->widthLodError = /*ri->Hunk_Alloc*/ Z_Malloc( width * 4 ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = /*ri->Hunk_Alloc*/ ri->Malloc( height * 4 ); + grid->heightLodError = /*ri->Hunk_Alloc*/ Z_Malloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numTriangles = numTriangles; - grid->triangles = ri->Malloc(grid->numTriangles * sizeof(srfTriangle_t)); + grid->triangles = Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t)); Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); grid->numVerts = (width * height); - grid->verts = ri->Malloc(grid->numVerts * sizeof(srfVert_t)); + grid->verts = Z_Malloc(grid->numVerts * sizeof(srfVert_t)); #else grid = ri->Hunk_Alloc( size ); Com_Memset(grid, 0, size); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 90b822ceac..a5035112d3 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -168,7 +168,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) } else { - msg = ri->Malloc(maxLength); + msg = Z_Malloc(maxLength); qglGetInfoLogARB(object, maxLength, &maxLength, msg); @@ -192,7 +192,7 @@ static void GLSL_PrintShaderSource(GLhandleARB object) qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); - msg = ri->Malloc(maxLength); + msg = Z_Malloc(maxLength); qglGetShaderSourceARB(object, maxLength, &maxLength, msg); @@ -657,7 +657,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) } } - program->uniformBuffer = ri->Malloc(size); + program->uniformBuffer = Z_Malloc(size); } void GLSL_FinishGPUShader(shaderProgram_t *program) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 4bc95e0495..5738970352 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -725,7 +725,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, ofs_st = dataSize; dataSize += surf->numVerts * sizeof(*texcoords); - data = ri->Malloc(dataSize); + Z_Malloc(dataSize); verts = (void *)(data + ofs_xyz); normals = (void *)(data + ofs_normal); From 2fd7a0310e6e6b51cf4471c1fa7c9f5d1610e1bf Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:42:36 -0400 Subject: [PATCH 017/708] GHOUL2's mxdm/mxda structs are now a part of model_t --- codemp/rd-rend2/tr_local.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a118ef1e4c..a2f238f6b2 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1507,6 +1507,15 @@ typedef struct model_s { mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM) +/* +Ghoul2 Insert Start +*/ + mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file + mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file +/* +Ghoul2 Insert End +*/ + int numLods; } model_t; From 7249d5d6d1f961245ba79a0cedf316bef577a652 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 21:49:31 -0400 Subject: [PATCH 018/708] Update rend2's tr_subs.cpp --- codemp/rd-rend2/tr_subs.cpp | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/codemp/rd-rend2/tr_subs.cpp b/codemp/rd-rend2/tr_subs.cpp index d7d30347ed..63a659c708 100644 --- a/codemp/rd-rend2/tr_subs.cpp +++ b/codemp/rd-rend2/tr_subs.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" + void QDECL Com_Printf( const char *msg, ... ) { va_list argptr; @@ -35,6 +36,18 @@ void QDECL Com_Printf( const char *msg, ... ) ri->Printf(PRINT_ALL, "%s", text); } +void QDECL Com_OPrintf( const char *msg, ... ) +{ + va_list argptr; + char text[1024]; + + va_start(argptr, msg); + Q_vsnprintf(text, sizeof(text), msg, argptr); + va_end(argptr); + + ri->OPrintf("%s", text); +} + void QDECL Com_Error( int level, const char *error, ... ) { va_list argptr; @@ -46,3 +59,37 @@ void QDECL Com_Error( int level, const char *error, ... ) ri->Error(level, "%s", text); } + +// HUNK +void *Hunk_AllocateTempMemory( int size ) { + return ri->Hunk_AllocateTempMemory( size ); +} + +void Hunk_FreeTempMemory( void *buf ) { + ri->Hunk_FreeTempMemory( buf ); +} + +void *Hunk_Alloc( int size, ha_pref preference ) { + return ri->Hunk_Alloc( size, preference ); +} + +int Hunk_MemoryRemaining( void ) { + return ri->Hunk_MemoryRemaining(); +} + +// ZONE +void *Z_Malloc( int iSize, memtag_t eTag, qboolean bZeroit, int iAlign ) { + return ri->Z_Malloc( iSize, eTag, bZeroit, iAlign ); +} + +void Z_Free( void *ptr ) { + ri->Z_Free( ptr ); +} + +int Z_MemSize( memtag_t eTag ) { + return ri->Z_MemSize( eTag ); +} + +void Z_MorphMallocTag( void *pvBuffer, memtag_t eDesiredTag ) { + ri->Z_MorphMallocTag( pvBuffer, eDesiredTag ); +} From 4e13d8ccb9d68fb485c63dfd523cd10e598c1869 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:00:11 -0400 Subject: [PATCH 019/708] Z_Malloc calls corrected --- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_curve.cpp | 10 +++++----- codemp/rd-rend2/tr_extensions.cpp | 6 +----- codemp/rd-rend2/tr_glsl.cpp | 6 +++--- codemp/rd-rend2/tr_model.cpp | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 8e68256f29..2d4cf0aa3b 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -242,7 +242,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } } - image = Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2); + image = Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); // don't want to use TAG_BSP :< but it's the only one that fits if (tr.worldDeluxeMapping) numLightmaps >>= 1; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 88b7dfadaa..be9b953661 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -432,21 +432,21 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri->Hunk_Alloc*/ Z_Malloc( size ); + grid = /*ri->Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); - grid->widthLodError = /*ri->Hunk_Alloc*/ Z_Malloc( width * 4 ); + grid->widthLodError = /*ri->Hunk_Alloc*/ Z_Malloc( width * 4, TAG_GRIDMESH ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = /*ri->Hunk_Alloc*/ Z_Malloc( height * 4 ); + grid->heightLodError = /*ri->Hunk_Alloc*/ Z_Malloc( height * 4, TAG_GRIDMESH ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numTriangles = numTriangles; - grid->triangles = Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t)); + grid->triangles = Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t), TAG_GRIDMESH); Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); grid->numVerts = (width * height); - grid->verts = Z_Malloc(grid->numVerts * sizeof(srfVert_t)); + grid->verts = Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); #else grid = ri->Hunk_Alloc( size ); Com_Memset(grid, 0, size); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 366bf3a7f5..7c016b7705 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -21,11 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_extensions.c - extensions needed by the renderer not in sdl_glimp.c -#ifdef USE_LOCAL_HEADERS -# include "SDL.h" -#else -# include -#endif +#include "SDL/SDL.h" #include "tr_local.h" diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a5035112d3..ddf5196c19 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -168,7 +168,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) } else { - msg = Z_Malloc(maxLength); + msg = Z_Malloc(maxLength, TAG_SHADERTEXT); qglGetInfoLogARB(object, maxLength, &maxLength, msg); @@ -192,7 +192,7 @@ static void GLSL_PrintShaderSource(GLhandleARB object) qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); - msg = Z_Malloc(maxLength); + msg = Z_Malloc(maxLength, TAG_SHADERTEXT); qglGetShaderSourceARB(object, maxLength, &maxLength, msg); @@ -657,7 +657,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) } } - program->uniformBuffer = Z_Malloc(size); + program->uniformBuffer = Z_Malloc(size, TAG_SHADERTEXT); } void GLSL_FinishGPUShader(shaderProgram_t *program) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 5738970352..924676e383 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -725,7 +725,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, ofs_st = dataSize; dataSize += surf->numVerts * sizeof(*texcoords); - Z_Malloc(dataSize); + Z_Malloc(dataSize, TAG_MODEL_MD3); verts = (void *)(data + ofs_xyz); normals = (void *)(data + ofs_normal); From 226403970a09e57fab9213acc31fc72fb7f7f25f Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:13:53 -0400 Subject: [PATCH 020/708] Fixed more C++-related type-analness --- codemp/rd-rend2/tr_animation.cpp | 4 +-- codemp/rd-rend2/tr_backend.cpp | 26 +++++++++--------- codemp/rd-rend2/tr_cmds.cpp | 42 +++++++++++++++--------------- codemp/rd-rend2/tr_extramath.cpp | 4 +-- codemp/rd-rend2/tr_fbo.cpp | 4 +-- codemp/rd-rend2/tr_flares.cpp | 2 +- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_image.cpp | 10 +++---- codemp/rd-rend2/tr_init.cpp | 14 +++++----- codemp/rd-rend2/tr_light.cpp | 2 +- codemp/rd-rend2/tr_main.cpp | 8 +++--- codemp/rd-rend2/tr_mesh.cpp | 4 +-- codemp/rd-rend2/tr_model.cpp | 32 +++++++++++------------ codemp/rd-rend2/tr_model_iqm.cpp | 6 ++--- codemp/rd-rend2/tr_postprocess.cpp | 2 +- codemp/rd-rend2/tr_scene.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 4 +-- 17 files changed, 84 insertions(+), 84 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 82254ceb19..ef0d3660a3 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -325,9 +325,9 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { int cull; qboolean personalModel; - header = (mdrHeader_t *) tr.currentModel->modelData; + header = (mdrHeader_t *)tr.currentModel->modelData; - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a860ddec94..ac0187e34c 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -166,15 +166,15 @@ void GL_Cull( int cullType ) { qboolean cullFront; qglEnable( GL_CULL_FACE ); - cullFront = (cullType == CT_FRONT_SIDED); + cullFront = (qboolean)(cullType == CT_FRONT_SIDED); if ( backEnd.viewParms.isMirror ) { - cullFront = !cullFront; + cullFront = (qboolean)(!cullFront); } if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) { - cullFront = !cullFront; + cullFront = (qboolean)(!cullFront); } qglCullFace( cullFront ? GL_FRONT : GL_BACK ); @@ -1414,7 +1414,7 @@ RB_ColorMask */ const void *RB_ColorMask(const void *data) { - const colorMaskCommand_t *cmd = data; + const colorMaskCommand_t *cmd = (colorMaskCommand_t *)data; // finish any 2D drawing if needed if(tess.numIndexes) @@ -1423,10 +1423,10 @@ const void *RB_ColorMask(const void *data) if (glRefConfig.framebufferObject) { // reverse color mask, so 0 0 0 0 is the default - backEnd.colorMask[0] = !cmd->rgba[0]; - backEnd.colorMask[1] = !cmd->rgba[1]; - backEnd.colorMask[2] = !cmd->rgba[2]; - backEnd.colorMask[3] = !cmd->rgba[3]; + backEnd.colorMask[0] = (qboolean)(!cmd->rgba[0]); + backEnd.colorMask[1] = (qboolean)(!cmd->rgba[1]); + backEnd.colorMask[2] = (qboolean)(!cmd->rgba[2]); + backEnd.colorMask[3] = (qboolean)(!cmd->rgba[3]); } qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); @@ -1442,7 +1442,7 @@ RB_ClearDepth */ const void *RB_ClearDepth(const void *data) { - const clearDepthCommand_t *cmd = data; + const clearDepthCommand_t *cmd = (clearDepthCommand_t *)data; // finish any 2D drawing if needed if(tess.numIndexes) @@ -1506,7 +1506,7 @@ const void *RB_SwapBuffers( const void *data ) { long sum = 0; unsigned char *stencilReadback; - stencilReadback = ri->Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); + stencilReadback = (unsigned char *)ri->Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { @@ -1575,7 +1575,7 @@ RB_CapShadowMap */ const void *RB_CapShadowMap(const void *data) { - const capShadowmapCommand_t *cmd = data; + const capShadowmapCommand_t *cmd = (const capShadowmapCommand_t *)data; // finish any 2D drawing if needed if(tess.numIndexes) @@ -1608,7 +1608,7 @@ RB_PostProcess */ const void *RB_PostProcess(const void *data) { - const postProcessCommand_t *cmd = data; + const postProcessCommand_t *cmd = (const postProcessCommand_t *)data; FBO_t *srcFbo; vec4i_t srcBox, dstBox; qboolean autoExposure; @@ -1662,7 +1662,7 @@ const void *RB_PostProcess(const void *data) { if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) { - autoExposure = r_autoExposure->integer || r_forceAutoExposure->integer; + autoExposure = (qboolean)(r_autoExposure->integer || r_forceAutoExposure->integer); RB_ToneMap(srcFbo, srcBox, tr.screenScratchFbo, dstBox, autoExposure); } else if (r_cameraExposure->value == 0.0f) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 4f5da66b33..7b1a020c1a 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -156,7 +156,7 @@ R_AddDrawSurfCmd void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) { drawSurfsCommand_t *cmd; - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (drawSurfsCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -179,7 +179,7 @@ R_AddCapShadowmapCmd void R_AddCapShadowmapCmd( int map, int cubeSide ) { capShadowmapCommand_t *cmd; - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (capShadowmapCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -199,7 +199,7 @@ R_PostProcessingCmd void R_AddPostProcessCmd( ) { postProcessCommand_t *cmd; - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (postProcessCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -222,7 +222,7 @@ void RE_SetColor( const float *rgba ) { if ( !tr.registered ) { return; } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (setColorCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -252,7 +252,7 @@ void RE_StretchPic ( float x, float y, float w, float h, if (!tr.registered) { return; } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (stretchPicCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -400,7 +400,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } if (glConfig.stereoEnabled) { - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; cmd->commandId = RC_DRAW_BUFFER; @@ -421,10 +421,10 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { { // clear both, front and backbuffer. qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - backEnd.colorMask[0] = GL_FALSE; - backEnd.colorMask[1] = GL_FALSE; - backEnd.colorMask[2] = GL_FALSE; - backEnd.colorMask[3] = GL_FALSE; + backEnd.colorMask[0] = qfalse; + backEnd.colorMask[1] = qfalse; + backEnd.colorMask[2] = qfalse; + backEnd.colorMask[3] = qfalse; qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); if (glRefConfig.framebufferObject) @@ -461,22 +461,22 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if(stereoFrame == STEREO_LEFT) { - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; - if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) + if( !(colcmd = (colorMaskCommand_t *)R_GetCommandBuffer(sizeof(*colcmd))) ) return; } else if(stereoFrame == STEREO_RIGHT) { clearDepthCommand_t *cldcmd; - if( !(cldcmd = R_GetCommandBuffer(sizeof(*cldcmd))) ) + if( !(cldcmd = (clearDepthCommand_t *)R_GetCommandBuffer(sizeof(*cldcmd))) ) return; cldcmd->commandId = RC_CLEARDEPTH; - if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) ) + if( !(colcmd = (colorMaskCommand_t *)R_GetCommandBuffer(sizeof(*colcmd))) ) return; } else @@ -490,7 +490,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if(stereoFrame != STEREO_CENTER) ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); - if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) ) + if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; } @@ -501,10 +501,10 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if(r_anaglyphMode->modified) { qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - backEnd.colorMask[0] = 0; - backEnd.colorMask[1] = 0; - backEnd.colorMask[2] = 0; - backEnd.colorMask[3] = 0; + backEnd.colorMask[0] = qfalse; + backEnd.colorMask[1] = qfalse; + backEnd.colorMask[2] = qfalse; + backEnd.colorMask[3] = qfalse; r_anaglyphMode->modified = qfalse; } @@ -532,7 +532,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { if ( !tr.registered ) { return; } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (swapBuffersCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -566,7 +566,7 @@ void RE_TakeVideoFrame( int width, int height, return; } - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (videoFrameCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if( !cmd ) { return; } diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index f7d3260479..180715819d 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -83,10 +83,10 @@ void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out ) qboolean Matrix16Compare( const matrix_t a, const matrix_t b ) { - return !(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] || + return (qboolean)(!(a[ 0] != b[ 0] || a[ 4] != b[ 4] || a[ 8] != b[ 8] || a[12] != b[12] || a[ 1] != b[ 1] || a[ 5] != b[ 5] || a[ 9] != b[ 9] || a[13] != b[13] || a[ 2] != b[ 2] || a[ 6] != b[ 6] || a[10] != b[10] || a[14] != b[14] || - a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15]); + a[ 3] != b[ 3] || a[ 7] != b[ 7] || a[11] != b[11] || a[15] != b[15])); } void Matrix16Dump( const matrix_t in ) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 63cf7510f2..19a4b8025d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -125,7 +125,7 @@ FBO_t *FBO_Create(const char *name, int width, int height) ri->Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); } - fbo = tr.fbos[tr.numFBOs] = ri->Hunk_Alloc(sizeof(*fbo), h_low); + fbo = tr.fbos[tr.numFBOs] = (FBO_t *)ri->Hunk_Alloc(sizeof(*fbo), h_low); Q_strncpyz(fbo->name, name, sizeof(fbo->name)); fbo->index = tr.numFBOs++; fbo->width = width; @@ -188,7 +188,7 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) return; } - absent = *pRenderBuffer == 0; + absent = (qboolean)(*pRenderBuffer == 0); if (absent) qglGenRenderbuffersEXT(1, pRenderBuffer); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 8e6c321ff8..166fe016f0 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -275,7 +275,7 @@ void RB_TestFlare( flare_t *f ) { screenZ = backEnd.viewParms.projectionMatrix[14] / ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); - visible = ( -f->eyeZ - -screenZ ) < 24; + visible = (qboolean)(( -f->eyeZ - -screenZ ) < 24); if ( visible ) { if ( !f->visible ) { diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ddf5196c19..cccbf2df40 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1669,7 +1669,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) // position/normal/tangent/bitangent are always set in case of animation oldFrame = glState.vertexAttribsOldFrame; newFrame = glState.vertexAttribsNewFrame; - animated = (oldFrame != newFrame) && (glState.vertexAttribsInterpolation > 0.0f); + animated = (qboolean)((oldFrame != newFrame) && (glState.vertexAttribsInterpolation > 0.0f)); if((attribBits & ATTR_POSITION) && (!(glState.vertexAttribPointersSet & ATTR_POSITION) || animated)) { diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 26a11c0536..d871690e02 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1289,7 +1289,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = (unsigned int *)ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); inWidthMask = inWidth - 1; inHeightMask = inHeight - 1; @@ -1336,7 +1336,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = (byte *)ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); for ( i = 0 ; i < outHeight ; i++ ) { byte *outbyte = temp + ( i * outWidth ) * 4; @@ -1573,9 +1573,9 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he int height = *inout_height; int scaled_width; int scaled_height; - qboolean picmip = flags & IMGFLAG_PICMIP; - qboolean mipmap = flags & IMGFLAG_MIPMAP; - qboolean clampToEdge = flags & IMGFLAG_CLAMPTOEDGE; + qboolean picmip = (qboolean)(flags & IMGFLAG_PICMIP); + qboolean mipmap = (qboolean)(flags & IMGFLAG_MIPMAP); + qboolean clampToEdge = (qboolean)(flags & IMGFLAG_CLAMPTOEDGE); // // convert to exact power of 2 sizes diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index ac2b544443..b26d5916ab 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -435,9 +435,9 @@ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *pa padwidth = PAD(linelen, packAlign); // Allocate a few more bytes so that we can choose an alignment we like - buffer = ri->Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); + buffer = (byte *)ri->Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); - bufstart = PADP((intptr_t) buffer + *offset, packAlign); + bufstart = (byte*)(PADP((intptr_t) buffer + *offset, packAlign)); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); *offset = bufstart - buffer; @@ -561,7 +561,7 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean static char fileName[MAX_OSPATH]; // bad things if two screenshots per frame? screenshotCommand_t *cmd; - cmd = R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (screenshotCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; } @@ -651,7 +651,7 @@ void R_LevelShot( void ) { allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); source = allsource + offset; - buffer = ri->Hunk_AllocateTempMemory(128 * 128*3 + 18); + buffer = (byte *)ri->Hunk_AllocateTempMemory(128 * 128*3 + 18); Com_Memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type buffer[12] = 128; @@ -843,7 +843,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) avipadwidth = PAD(linelen, AVI_LINE_PADDING); avipadlen = avipadwidth - linelen; - cBuf = PADP(cmd->captureBuffer, packAlign); + cBuf = (byte*)(PADP(cmd->captureBuffer, packAlign)); qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, cBuf); @@ -1404,7 +1404,7 @@ void R_Init( void ) { if (max_polyverts < MAX_POLYVERTS) max_polyverts = MAX_POLYVERTS; - ptr = ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); + ptr = (byte*)ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData = (backEndData_t *) ptr; backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); @@ -1516,7 +1516,7 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { static refexport_t re; - ri = *rimp; + ri = rimp; Com_Memset( &re, 0, sizeof( re ) ); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 5c75524a0b..b29a500899 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -88,7 +88,7 @@ void R_DlightBmodel( bmodel_t *bmodel ) { mask |= 1 << i; } - tr.currentEntity->needDlights = (mask != 0); + tr.currentEntity->needDlights = (qboolean)(mask != 0); // set the dlight bits in all the surfaces for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index abe22f9ec8..5eea5016a4 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2186,7 +2186,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW; + shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW); shadowParms.zFar = tr.refdef.dlights[i].radius; VectorCopy( tr.refdef.dlights[i].origin, shadowParms.or.origin ); @@ -2302,7 +2302,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) case MOD_IQM: { // FIXME: never actually tested this - iqmData_t *data = model->modelData; + iqmData_t *data = (iqmData_t *)model->modelData; vec3_t diag; float *framebounds; @@ -2490,7 +2490,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) if (glRefConfig.framebufferObject) shadowParms.targetFbo = tr.pshadowFbos[i]; - shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW; + shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW); shadowParms.zFar = shadow->lightRadius; VectorCopy(shadow->lightOrigin, shadowParms.or.origin); @@ -2835,7 +2835,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) if (glRefConfig.framebufferObject) shadowParms.targetFbo = tr.sunShadowFbo[level]; - shadowParms.flags = VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC; + shadowParms.flags = (viewParmFlags_t)(VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC); shadowParms.zFar = lightviewBounds[1][0]; VectorCopy(lightOrigin, shadowParms.or.origin); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index b6434e4ac4..ec14911352 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -291,8 +291,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { qboolean personalModel; // don't add third_person objects if not in a portal - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))); + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal + || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->mdv[0]->numFrames; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 924676e383..03414d4bbe 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -237,7 +237,7 @@ model_t *R_AllocModel( void ) { return NULL; } - mod = ri->Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); + mod = (model_t *)ri->Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); mod->index = tr.numModels; tr.models[tr.numModels] = mod; tr.numModels++; @@ -415,7 +415,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, mod->type = MOD_MESH; size = LittleLong(md3Model->ofsEnd); mod->dataSize += size; - mdvModel = mod->mdv[lod] = ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); + mdvModel = mod->mdv[lod] = (mdvModel_t *)ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); // Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); @@ -437,7 +437,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the frames mdvModel->numFrames = md3Model->numFrames; - mdvModel->frames = frame = ri->Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); + mdvModel->frames = frame = (mdvFrame_t *)ri->Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); md3Frame = (md3Frame_t *) ((byte *) md3Model + md3Model->ofsFrames); for(i = 0; i < md3Model->numFrames; i++, frame++, md3Frame++) @@ -453,7 +453,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the tags mdvModel->numTags = md3Model->numTags; - mdvModel->tags = tag = ri->Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); + mdvModel->tags = tag = (mdvTag_t *)ri->Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags * md3Model->numFrames; i++, tag++, md3Tag++) @@ -468,7 +468,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, } - mdvModel->tagNames = tagName = ri->Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); + mdvModel->tagNames = tagName = (mdvTagName_t *)ri->Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags; i++, tagName++, md3Tag++) @@ -478,7 +478,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the surfaces mdvModel->numSurfaces = md3Model->numSurfaces; - mdvModel->surfaces = surf = ri->Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); + mdvModel->surfaces = surf = (mdvSurface_t *)ri->Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); md3Surf = (md3Surface_t *) ((byte *) md3Model + md3Model->ofsSurfaces); for(i = 0; i < md3Model->numSurfaces; i++) @@ -532,7 +532,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // register the shaders surf->numShaderIndexes = md3Surf->numShaders; - surf->shaderIndexes = shaderIndex = ri->Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); + surf->shaderIndexes = shaderIndex = (int *)ri->Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); md3Shader = (md3Shader_t *) ((byte *) md3Surf + md3Surf->ofsShaders); for(j = 0; j < md3Surf->numShaders; j++, shaderIndex++, md3Shader++) @@ -552,7 +552,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the triangles surf->numTriangles = md3Surf->numTriangles; - surf->triangles = tri = ri->Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); + surf->triangles = tri = (srfTriangle_t *)ri->Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); for(j = 0; j < md3Surf->numTriangles; j++, tri++, md3Tri++) @@ -566,7 +566,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, // swap all the XyzNormals surf->numVerts = md3Surf->numVerts; - surf->verts = v = ri->Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); + surf->verts = v = (mdvVertex_t *)ri->Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); md3xyz = (md3XyzNormal_t *) ((byte *) md3Surf + md3Surf->ofsXyzNormals); for(j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++) @@ -595,7 +595,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, } // swap all the ST - surf->st = st = ri->Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); + surf->st = st = (mdvSt_t *)ri->Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); md3st = (md3St_t *) ((byte *) md3Surf + md3Surf->ofsSt); for(j = 0; j < md3Surf->numVerts; j++, md3st++, st++) @@ -684,7 +684,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, srfVBOMDVMesh_t *vboSurf; mdvModel->numVBOSurfaces = mdvModel->numSurfaces; - mdvModel->vboSurfaces = ri->Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); + mdvModel->vboSurfaces = (srfVBOMDVMesh_t *)ri->Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); vboSurf = mdvModel->vboSurfaces; surf = mdvModel->surfaces; @@ -727,13 +727,13 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, Z_Malloc(dataSize, TAG_MODEL_MD3); - verts = (void *)(data + ofs_xyz); - normals = (void *)(data + ofs_normal); + verts = (vec3_t *)(data + ofs_xyz); + normals = (vec3_t *)(data + ofs_normal); #ifdef USE_VERT_TANGENT_SPACE - tangents = (void *)(data + ofs_tangent); - bitangents = (void *)(data + ofs_bitangent); + tangents = (vec3_t *)(data + ofs_tangent); + bitangents = (vec3_t *)(data + ofs_bitangent); #endif - texcoords = (void *)(data + ofs_st); + texcoords = (vec2_t *)(data + ofs_st); v = surf->verts; for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 96982beff8..87dad4156a 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -29,7 +29,7 @@ static qboolean IQM_CheckRange( iqmHeader_t *header, int offset, int count,int size ) { // return true if the range specified by offset, count and size // doesn't fit into the file - return ( count <= 0 || + return (qboolean)( count <= 0 || offset < 0 || offset > header->filesize || offset + count * size < 0 || @@ -789,11 +789,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { shader_t *shader; skin_t *skin; - data = tr.currentModel->modelData; + data = (iqmData_t *)tr.currentModel->modelData; surface = data->surfaces; // don't add third_person objects if not in a portal - personalModel = (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal; + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= data->num_frames; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index f4e456f37e..cd21cf68ec 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -295,7 +295,7 @@ static qboolean RB_UpdateSunFlareVis(void) } qglGetQueryObjectuivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_ARB, &sampleCount); - return sampleCount > 0; + return (qboolean)(sampleCount > 0); } void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index ae9e1cebbd..8399d76b92 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -226,7 +226,7 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { backEndData->entities[r_numentities].lightingCalculated = qfalse; CrossProduct(ent->axis[0], ent->axis[1], cross); - backEndData->entities[r_numentities].mirrored = (DotProduct(ent->axis[2], cross) < 0.f); + backEndData->entities[r_numentities].mirrored = (qboolean)(DotProduct(ent->axis[2], cross) < 0.f); r_numentities++; } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 2817d3f79d..1e14d4be41 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1269,7 +1269,7 @@ static void ParseDeform( char **text ) { if ( n < 0 || n > 7 ) { n = 0; } - ds->deformation = DEFORM_TEXT0 + n; + ds->deformation = (deform_t)(DEFORM_TEXT0 + n); return; } @@ -1381,7 +1381,7 @@ static void ParseSkyParms( char **text ) { static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; char pathname[MAX_QPATH]; int i; - imgFlags_t imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + imgFlags_t imgFlags = (imgFlags_t)(IMGFLAG_MIPMAP | IMGFLAG_PICMIP); if (r_srgb->integer) imgFlags |= IMGFLAG_SRGB; From 27fafbbee3f9bfd99177edb146807d3a1b0ecb2a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:35:09 -0400 Subject: [PATCH 021/708] More instances of C++ type-anal-ness. Also changing ri->ftol to Q_ftol --- codemp/rd-rend2/tr_animation.cpp | 2 +- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_curve.cpp | 10 +++++----- codemp/rd-rend2/tr_extensions.cpp | 2 +- codemp/rd-rend2/tr_flares.cpp | 2 +- codemp/rd-rend2/tr_glsl.cpp | 6 +++--- codemp/rd-rend2/tr_image.cpp | 8 ++++---- codemp/rd-rend2/tr_light.cpp | 6 +++--- codemp/rd-rend2/tr_mesh.cpp | 4 ++-- codemp/rd-rend2/tr_model_iqm.cpp | 6 +++--- codemp/rd-rend2/tr_scene.cpp | 4 ++-- codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_shade_calc.cpp | 10 +++++----- codemp/rd-rend2/tr_shader.cpp | 18 +++++++++--------- codemp/rd-rend2/tr_sky.cpp | 8 ++++---- 16 files changed, 46 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index ef0d3660a3..eb2b545214 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -51,7 +51,7 @@ void R_AddAnimSurfaces( trRefEntity_t *ent ) { surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces ); for ( i = 0 ; i < lod->numSurfaces ; i++ ) { shader = R_GetShaderByHandle( surface->shaderIndex ); - R_AddDrawSurf( (void *)surface, shader, 0 /*fogNum*/, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, 0 /*fogNum*/, qfalse, qfalse ); surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd ); } } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index ac0187e34c..0b0be4ee34 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1539,7 +1539,7 @@ const void *RB_SwapBuffers( const void *data ) { color[0] = color[1] = - color[2] = pow(2, tr.overbrightBits); //exp2(tr.overbrightBits); + color[2] = pow(2.0f, tr.overbrightBits); //exp2(tr.overbrightBits); color[3] = 1.0f; // turn off colormask when copying final image diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 2d4cf0aa3b..eeb95e2f61 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -242,7 +242,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } } - image = Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); // don't want to use TAG_BSP :< but it's the only one that fits + image = (byte *)Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); // don't want to use TAG_BSP :< but it's the only one that fits if (tr.worldDeluxeMapping) numLightmaps >>= 1; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index be9b953661..3e7e428331 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -432,21 +432,21 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri->Hunk_Alloc*/ Z_Malloc( size, TAG_GRIDMESH ); + grid = /*ri->Hunk_Alloc*/ (srfGridMesh_t *)Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); - grid->widthLodError = /*ri->Hunk_Alloc*/ Z_Malloc( width * 4, TAG_GRIDMESH ); + grid->widthLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( width * 4, TAG_GRIDMESH ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = /*ri->Hunk_Alloc*/ Z_Malloc( height * 4, TAG_GRIDMESH ); + grid->heightLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( height * 4, TAG_GRIDMESH ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numTriangles = numTriangles; - grid->triangles = Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t), TAG_GRIDMESH); + grid->triangles = (srfTriangle_t *)Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t), TAG_GRIDMESH); Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); grid->numVerts = (width * height); - grid->verts = Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); + grid->verts = (srfVert_t *)Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); #else grid = ri->Hunk_Alloc( size ); Com_Memset(grid, 0, size); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 7c016b7705..30911da85c 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -580,7 +580,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferMultisample = qfalse; if (GLimp_HaveExtension(extension)) { - qglRenderbufferStorageMultisampleEXT = (void *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); + qglRenderbufferStorageMultisampleEXT = (void __stdcall *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 166fe016f0..2eb1ff873f 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -346,7 +346,7 @@ void RB_RenderFlare( flare_t *f ) { * The coefficient flareCoeff will determine the falloff speed with increasing distance. */ - factor = distance + size * sqrt(flareCoeff); + factor = distance + size * sqrt((double)flareCoeff); intensity = flareCoeff * size * size / (factor * factor); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index cccbf2df40..28a8c87ea6 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -168,7 +168,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) } else { - msg = Z_Malloc(maxLength, TAG_SHADERTEXT); + msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); qglGetInfoLogARB(object, maxLength, &maxLength, msg); @@ -192,7 +192,7 @@ static void GLSL_PrintShaderSource(GLhandleARB object) qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); - msg = Z_Malloc(maxLength, TAG_SHADERTEXT); + msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); qglGetShaderSourceARB(object, maxLength, &maxLength, msg); @@ -657,7 +657,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) } } - program->uniformBuffer = Z_Malloc(size, TAG_SHADERTEXT); + program->uniformBuffer = (char *)Z_Malloc(size, TAG_SHADERTEXT); } void GLSL_FinishGPUShader(shaderProgram_t *program) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d871690e02..fb486f1812 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1346,10 +1346,10 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) for ( k = 0 ; k < 3 ; k++ ) { float total, current; - current = ByteToFloat(inbyte1[0]); total = sRGBtoRGB(current); - current = ByteToFloat(inbyte1[4]); total += sRGBtoRGB(current); - current = ByteToFloat(inbyte2[0]); total += sRGBtoRGB(current); - current = ByteToFloat(inbyte2[4]); total += sRGBtoRGB(current); + current = ByteToFloat(inbyte1[0]); total = sRGBtoRGB((double)current); + current = ByteToFloat(inbyte1[4]); total += sRGBtoRGB((double)current); + current = ByteToFloat(inbyte2[0]); total += sRGBtoRGB((double)current); + current = ByteToFloat(inbyte2[4]); total += sRGBtoRGB((double)current); total *= 0.25f; diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index b29a500899..777492ffcb 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -397,9 +397,9 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // save out the byte packet version - ((byte *)&ent->ambientLightInt)[0] = ri->ftol(ent->ambientLight[0]); - ((byte *)&ent->ambientLightInt)[1] = ri->ftol(ent->ambientLight[1]); - ((byte *)&ent->ambientLightInt)[2] = ri->ftol(ent->ambientLight[2]); + ((byte *)&ent->ambientLightInt)[0] = Q_ftol(ent->ambientLight[0]); + ((byte *)&ent->ambientLightInt)[1] = Q_ftol(ent->ambientLight[1]); + ((byte *)&ent->ambientLightInt)[2] = Q_ftol(ent->ambientLight[2]); ((byte *)&ent->ambientLightInt)[3] = 0xff; // transform the direction to local space diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index ec14911352..1c02b1e846 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -215,7 +215,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { } flod *= tr.currentModel->numLods; - lod = ri->ftol(flod); + lod = Q_ftol(flod); if ( lod < 0 ) { @@ -387,7 +387,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((void *)vboSurface, shader, fogNum, qfalse, qfalse ); + R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, qfalse ); } surface++; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 87dad4156a..f7e32cffcd 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -866,7 +866,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, 0 ); } // projection shadows work fine with personal models @@ -874,11 +874,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0 ); } if( !personalModel ) { - R_AddDrawSurf( (void *)surface, shader, fogNum, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, 0 ); } surface++; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 8399d76b92..cfc6560f71 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -99,7 +99,7 @@ void R_AddPolygonSurfaces( void ) { for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse ); + R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse ); } } @@ -376,7 +376,7 @@ void RE_RenderScene( const refdef_t *fd ) { } else { - float scale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); + float scale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits - 8); if (r_forceSun->integer) { VectorScale(tr.sunLight, scale * r_forceSunLightScale->value, tr.refdef.sunCol); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 303e0212fe..35a01ebce7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -116,7 +116,7 @@ static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { // it is necessary to do this messy calc to make sure animations line up // exactly with waveforms of the same frequency - index = ri->ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); + index = Q_ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); index >>= FUNCTABLE_SIZE2; if ( index < 0 ) { diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index c5f3842e0a..b28a812ce5 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif -#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ ri->ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) +#define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ Q_ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) static float *TableForFunc( genFunc_t func ) { @@ -736,7 +736,7 @@ void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ) glow = RB_CalcWaveColorSingle( wf ); - v = ri->ftol(255 * glow); + v = Q_ftol(255 * glow); color[0] = color[1] = color[2] = v; color[3] = 255; v = *(int *)color; @@ -1299,19 +1299,19 @@ static void RB_CalcDiffuseColor_scalar( unsigned char *colors ) *(int *)&colors[i*4] = ambientLightInt; continue; } - j = ri->ftol(ambientLight[0] + incoming * directedLight[0]); + j = Q_ftol(ambientLight[0] + incoming * directedLight[0]); if ( j > 255 ) { j = 255; } colors[i*4+0] = j; - j = ri->ftol(ambientLight[1] + incoming * directedLight[1]); + j = Q_ftol(ambientLight[1] + incoming * directedLight[1]); if ( j > 255 ) { j = 255; } colors[i*4+1] = j; - j = ri->ftol(ambientLight[2] + incoming * directedLight[2]); + j = Q_ftol(ambientLight[2] + incoming * directedLight[2]); if ( j > 255 ) { j = 255; } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 1e14d4be41..4f23bcebe7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -117,7 +117,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char ParseVector =============== */ -static qboolean ParseVector( char **text, int count, float *v ) { +static qboolean ParseVector( const char **text, int count, float *v ) { char *token; int i; @@ -306,7 +306,7 @@ static genFunc_t NameToGenFunc( const char *funcname ) ParseWaveForm =================== */ -static void ParseWaveForm( char **text, waveForm_t *wave ) +static void ParseWaveForm( const char **text, waveForm_t *wave ) { char *token; @@ -361,7 +361,7 @@ ParseTexMod static void ParseTexMod( char *_text, shaderStage_t *stage ) { const char *token; - char **text = &_text; + const char **text = &_text; texModInfo_t *tmi; if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { @@ -588,7 +588,7 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) ParseStage =================== */ -static qboolean ParseStage( shaderStage_t *stage, char **text ) +static qboolean ParseStage( shaderStage_t *stage, const char **text ) { char *token; int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; @@ -1228,7 +1228,7 @@ deformVertexes autoSprite2 deformVertexes text[0-7] =============== */ -static void ParseDeform( char **text ) { +static void ParseDeform( const char **text ) { char *token; deformStage_t *ds; @@ -1376,7 +1376,7 @@ ParseSkyParms skyParms =============== */ -static void ParseSkyParms( char **text ) { +static void ParseSkyParms( const char **text ) { char *token; static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; char pathname[MAX_QPATH]; @@ -1443,7 +1443,7 @@ static void ParseSkyParms( char **text ) { ParseSort ================= */ -void ParseSort( char **text ) { +void ParseSort( const char **text ) { char *token; token = COM_ParseExt( text, qfalse ); @@ -1535,7 +1535,7 @@ ParseSurfaceParm surfaceparm =============== */ -static void ParseSurfaceParm( char **text ) { +static void ParseSurfaceParm( const char **text ) { char *token; int numInfoParms = ARRAY_LEN( infoParms ); int i; @@ -1564,7 +1564,7 @@ shader. Parse it into the global shader variable. Later functions will optimize it. ================= */ -static qboolean ParseShader( char **text ) +static qboolean ParseShader( const char **text ) { char *token; int s; diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 9ce5898fc3..97d9e9a096 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -649,10 +649,10 @@ static void FillCloudBox( const shader_t *shader, int stage ) continue; } - sky_mins_subd[0] = ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); - sky_mins_subd[1] = ri->ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[0] = ri->ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); - sky_maxs_subd[1] = ri->ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[0] = Q_ftol(sky_mins[0][i] * HALF_SKY_SUBDIVISIONS); + sky_mins_subd[1] = Q_ftol(sky_mins[1][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[0] = Q_ftol(sky_maxs[0][i] * HALF_SKY_SUBDIVISIONS); + sky_maxs_subd[1] = Q_ftol(sky_maxs[1][i] * HALF_SKY_SUBDIVISIONS); if ( sky_mins_subd[0] < -HALF_SKY_SUBDIVISIONS ) sky_mins_subd[0] = -HALF_SKY_SUBDIVISIONS; From 5ee3c649720a92963a7d6221bf9b5cb3225089cc Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:45:27 -0400 Subject: [PATCH 022/708] Added stuff for Raven's .mdr stuff --- codemp/qcommon/qfiles.h | 117 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/codemp/qcommon/qfiles.h b/codemp/qcommon/qfiles.h index ac9a4f7cc6..900c11e3a9 100644 --- a/codemp/qcommon/qfiles.h +++ b/codemp/qcommon/qfiles.h @@ -238,6 +238,123 @@ typedef struct { } md4Header_t; +/* + * Here are the definitions for Ravensoft's model format of md4. Raven stores their + * playermodels in .mdr files, in some games, which are pretty much like the md4 + * format implemented by ID soft. It seems like ID's original md4 stuff is not used at all. + * MDR is being used in EliteForce, JediKnight2 and Soldiers of Fortune2 (I think). + * So this comes in handy for anyone who wants to make it possible to load player + * models from these games. + * This format has bone tags, which is similar to the thing you have in md3 I suppose. + * Raven has released their version of md3view under GPL enabling me to add support + * to this codebase. Thanks to Steven Howes aka Skinner for helping with example + * source code. + * + * - Thilo Schulz (arny@ats.s.bawue.de) + */ + +#define MDR_IDENT (('5'<<24)+('M'<<16)+('D'<<8)+'R') +#define MDR_VERSION 2 +#define MDR_MAX_BONES 128 + +typedef struct { + int boneIndex; // these are indexes into the boneReferences, + float boneWeight; // not the global per-frame bone list + vec3_t offset; +} mdrWeight_t; + +typedef struct { + vec3_t normal; + vec2_t texCoords; + int numWeights; + mdrWeight_t weights[1]; // variable sized +} mdrVertex_t; + +typedef struct { + int indexes[3]; +} mdrTriangle_t; + +typedef struct { + int ident; + + char name[MAX_QPATH]; // polyset name + char shader[MAX_QPATH]; + int shaderIndex; // for in-game use + + int ofsHeader; // this will be a negative number + + int numVerts; + int ofsVerts; + + int numTriangles; + int ofsTriangles; + + // Bone references are a set of ints representing all the bones + // present in any vertex weights for this surface. This is + // needed because a model may have surfaces that need to be + // drawn at different sort times, and we don't want to have + // to re-interpolate all the bones for each surface. + int numBoneReferences; + int ofsBoneReferences; + + int ofsEnd; // next surface follows +} mdrSurface_t; + +typedef struct { + float matrix[3][4]; +} mdrBone_t; + +typedef struct { + vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame + vec3_t localOrigin; // midpoint of bounds, used for sphere cull + float radius; // dist from localOrigin to corner + char name[16]; + mdrBone_t bones[1]; // [numBones] +} mdrFrame_t; + +typedef struct { + unsigned char Comp[24]; // MC_COMP_BYTES is in MatComp.h, but don't want to couple +} mdrCompBone_t; + +typedef struct { + vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame + vec3_t localOrigin; // midpoint of bounds, used for sphere cull + float radius; // dist from localOrigin to corner + mdrCompBone_t bones[1]; // [numBones] +} mdrCompFrame_t; + +typedef struct { + int numSurfaces; + int ofsSurfaces; // first surface, others follow + int ofsEnd; // next lod follows +} mdrLOD_t; + +typedef struct { + int boneIndex; + char name[32]; +} mdrTag_t; + +typedef struct { + int ident; + int version; + + char name[MAX_QPATH]; // model name + + // frames and bones are shared by all levels of detail + int numFrames; + int numBones; + int ofsFrames; // mdrFrame_t[numFrames] + + // each level of detail has completely separate sets of surfaces + int numLODs; + int ofsLODs; + + int numTags; + int ofsTags; + + int ofsEnd; // end of file +} mdrHeader_t; + /* ============================================================================== From a66fc357c58a9e09d986cfadd2f32469cb604084 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:45:45 -0400 Subject: [PATCH 023/708] Added LIGHTMAP_* "enum" --- codemp/rd-rend2/tr_local.h | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a2f238f6b2..7c44be4afc 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -419,6 +419,13 @@ typedef enum ST_GLSL } stageType_t; +// any change in the LIGHTMAP_* defines here MUST be reflected in +// R_FindShader() in tr_bsp.c +#define LIGHTMAP_2D -4 // shader is for 2D rendering +#define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models +#define LIGHTMAP_WHITEIMAGE -2 +#define LIGHTMAP_NONE -1 + typedef struct { qboolean active; @@ -905,18 +912,6 @@ typedef struct { //================================================================================= -// skins allow models to be retextured without modifying the model file -typedef struct { - char name[MAX_QPATH]; - shader_t *shader; -} skinSurface_t; - -typedef struct skin_s { - char name[MAX_QPATH]; // game path, including extension - int numSurfaces; - skinSurface_t *surfaces[MD3_MAX_SURFACES]; -} skin_t; - typedef struct { int originalBrushNumber; From 82cdcc6597309b6787702d10dcc1f1460691774a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 22:57:08 -0400 Subject: [PATCH 024/708] Externed the cvars in tr_local.h (Q3 doesn't do it like this, but probably should) --- codemp/rd-rend2/tr_local.h | 200 +++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7c44be4afc..6fdbc60682 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -62,6 +62,206 @@ typedef unsigned int glIndex_t; #define USE_VERT_TANGENT_SPACE +/* +===================================================== + +Renderer-side Cvars +In Q3, these are defined in tr_common.h, which isn't very logical really +In JA, we define these in the tr_local.h, which is much more logical + +===================================================== +*/ + +extern cvar_t *r_flareSize; +extern cvar_t *r_flareFade; +extern cvar_t *r_flareCoeff; + +extern cvar_t *r_railWidth; +extern cvar_t *r_railCoreWidth; +extern cvar_t *r_railSegmentLength; + +extern cvar_t *r_verbose; +extern cvar_t *r_ignore; + +extern cvar_t *r_detailTextures; + +extern cvar_t *r_znear; +extern cvar_t *r_zproj; +extern cvar_t *r_stereoSeparation; + +extern cvar_t *r_skipBackEnd; + +extern cvar_t *r_stereoEnabled; +extern cvar_t *r_anaglyphMode; + +extern cvar_t *r_greyscale; + +extern cvar_t *r_ignorehwgamma; +extern cvar_t *r_measureOverdraw; + +extern cvar_t *r_inGameVideo; +extern cvar_t *r_fastsky; +extern cvar_t *r_drawSun; +extern cvar_t *r_dynamiclight; +extern cvar_t *r_dlightBacks; + +extern cvar_t *r_lodbias; +extern cvar_t *r_lodscale; + +extern cvar_t *r_norefresh; +extern cvar_t *r_drawentities; +extern cvar_t *r_drawworld; +extern cvar_t *r_speeds; +extern cvar_t *r_fullbright; +extern cvar_t *r_novis; +extern cvar_t *r_nocull; +extern cvar_t *r_facePlaneCull; +extern cvar_t *r_showcluster; +extern cvar_t *r_nocurves; + +extern cvar_t *r_allowExtensions; + +extern cvar_t *r_ext_compressed_textures; +extern cvar_t *r_ext_multitexture; +extern cvar_t *r_ext_compiled_vertex_array; +extern cvar_t *r_ext_texture_env_add; +extern cvar_t *r_ext_texture_filter_anisotropic; +extern cvar_t *r_ext_max_anisotropy; + +extern cvar_t *r_ext_draw_range_elements; +extern cvar_t *r_ext_multi_draw_arrays; +extern cvar_t *r_ext_framebuffer_object; +extern cvar_t *r_ext_texture_float; +extern cvar_t *r_arb_half_float_pixel; +extern cvar_t *r_ext_framebuffer_multisample; + +extern cvar_t *r_mergeMultidraws; +extern cvar_t *r_mergeLeafSurfaces; + +extern cvar_t *r_cameraExposure; + +extern cvar_t *r_softOverbright; + +extern cvar_t *r_hdr; +extern cvar_t *r_postProcess; + +extern cvar_t *r_toneMap; +extern cvar_t *r_forceToneMap; +extern cvar_t *r_forceToneMapMin; +extern cvar_t *r_forceToneMapAvg; +extern cvar_t *r_forceToneMapMax; + +extern cvar_t *r_autoExposure; +extern cvar_t *r_forceAutoExposure; +extern cvar_t *r_forceAutoExposureMin; +extern cvar_t *r_forceAutoExposureMax; + +extern cvar_t *r_srgb; + +extern cvar_t *r_depthPrepass; +extern cvar_t *r_ssao; + +extern cvar_t *r_normalMapping; +extern cvar_t *r_specularMapping; +extern cvar_t *r_deluxeMapping; +extern cvar_t *r_parallaxMapping; +extern cvar_t *r_normalAmbient; +extern cvar_t *r_recalcMD3Normals; +extern cvar_t *r_mergeLightmaps; +extern cvar_t *r_dlightMode; +extern cvar_t *r_pshadowDist; +extern cvar_t *r_imageUpsample; +extern cvar_t *r_imageUpsampleMaxSize; +extern cvar_t *r_imageUpsampleType; +extern cvar_t *r_genNormalMaps; +extern cvar_t *r_forceSun; +extern cvar_t *r_forceSunMapLightScale; +extern cvar_t *r_forceSunLightScale; +extern cvar_t *r_forceSunAmbientScale; +extern cvar_t *r_sunlightMode; +extern cvar_t *r_drawSunRays; +extern cvar_t *r_sunShadows; +extern cvar_t *r_shadowFilter; +extern cvar_t *r_shadowMapSize; +extern cvar_t *r_shadowCascadeZNear; +extern cvar_t *r_shadowCascadeZFar; +extern cvar_t *r_shadowCascadeZBias; + +extern cvar_t *r_ignoreGLErrors; +extern cvar_t *r_logFile; + +extern cvar_t *r_stencilbits; +extern cvar_t *r_depthbits; +extern cvar_t *r_colorbits; +extern cvar_t *r_texturebits; +extern cvar_t *r_ext_multisample; + +extern cvar_t *r_drawBuffer; +extern cvar_t *r_lightmap; +extern cvar_t *r_vertexLight; +extern cvar_t *r_uiFullScreen; +extern cvar_t *r_shadows; +extern cvar_t *r_flares; +extern cvar_t *r_mode; +extern cvar_t *r_nobind; +extern cvar_t *r_singleShader; +extern cvar_t *r_roundImagesDown; +extern cvar_t *r_colorMipLevels; +extern cvar_t *r_picmip; +extern cvar_t *r_showtris; +extern cvar_t *r_showsky; +extern cvar_t *r_shownormals; +extern cvar_t *r_finish; +extern cvar_t *r_clear; +extern cvar_t *r_swapInterval; +extern cvar_t *r_textureMode; +extern cvar_t *r_offsetFactor; +extern cvar_t *r_offsetUnits; +extern cvar_t *r_gamma; +extern cvar_t *r_intensity; +extern cvar_t *r_lockpvs; +extern cvar_t *r_noportals; +extern cvar_t *r_portalOnly; + +extern cvar_t *r_subdivisions; +extern cvar_t *r_lodCurveError; + +extern cvar_t *r_fullscreen; +extern cvar_t *r_noborder; + +extern cvar_t *r_customwidth; +extern cvar_t *r_customheight; +extern cvar_t *r_customPixelAspect; + +extern cvar_t *r_overBrightBits; +extern cvar_t *r_mapOverBrightBits; + +extern cvar_t *r_debugSurface; +extern cvar_t *r_simpleMipMaps; + +extern cvar_t *r_showImages; + +extern cvar_t *r_ambientScale; +extern cvar_t *r_directedScale; +extern cvar_t *r_debugLight; +extern cvar_t *r_debugSort; +extern cvar_t *r_printShaders; +extern cvar_t *r_saveFontData; + +extern cvar_t *r_marksOnTriangleMeshes; + +extern cvar_t *r_aviMotionJpegQuality; +extern cvar_t *r_screenshotJpegQuality; + +extern cvar_t *r_maxpolys; +extern int max_polys; +extern cvar_t *r_maxpolyverts; +extern int max_polyverts; + +/* +End Cvars +*/ + typedef enum { IMGTYPE_COLORALPHA, // for color, lightmap, diffuse, and specular From b4a0c596ae114ecbd50f75b39ff662ca94e89d2d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 23:00:30 -0400 Subject: [PATCH 025/708] If Raven doesn't care about Voodoo/3dfx/etc, then neither will I! --- codemp/rd-rend2/tr_image.cpp | 7 ------- codemp/rd-rend2/tr_init.cpp | 10 +--------- codemp/rd-rend2/tr_scene.cpp | 13 +------------ codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 10 +--------- 5 files changed, 4 insertions(+), 38 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index fb486f1812..1d17649f9a 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -94,13 +94,6 @@ void GL_TextureMode( const char *string ) { } } - // hack to prevent trilinear from being set on voodoo, - // because their driver freaks... - if ( i == 5 && glConfig.hardwareType == GLHW_3DFX_2D3D ) { - ri->Printf( PRINT_ALL, "Refusing to set trilinear on a voodoo.\n" ); - i = 3; - } - if ( i == 6 ) { ri->Printf (PRINT_ALL, "bad filter name\n"); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b26d5916ab..5aa1c97a51 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1031,18 +1031,10 @@ void GfxInfo_f( void ) ri->Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] ); ri->Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); ri->Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); - if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) + if ( r_vertexLight->integer ) { ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } - if ( glConfig.hardwareType == GLHW_RAGEPRO ) - { - ri->Printf( PRINT_ALL, "HACK: ragePro approximations\n" ); - } - if ( glConfig.hardwareType == GLHW_RIVA128 ) - { - ri->Printf( PRINT_ALL, "HACK: riva128 approximations\n" ); - } if ( r_finish->integer ) { ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); } diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index cfc6560f71..ad7917ca7c 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -147,12 +147,6 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts Com_Memcpy( poly->verts, &verts[numVerts*j], numVerts * sizeof( *verts ) ); - if ( glConfig.hardwareType == GLHW_RAGEPRO ) { - poly->verts->modulate[0] = 255; - poly->verts->modulate[1] = 255; - poly->verts->modulate[2] = 255; - poly->verts->modulate[3] = 255; - } // done. r_numpolys++; r_numpolyverts += numVerts; @@ -250,10 +244,6 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa if ( intensity <= 0 ) { return; } - // these cards don't have the correct blend mode - if ( glConfig.hardwareType == GLHW_RIVA128 || glConfig.hardwareType == GLHW_PERMEDIA2 ) { - return; - } dl = &backEndData->dlights[r_numdlights++]; VectorCopy (org, dl->origin); dl->radius = intensity; @@ -454,8 +444,7 @@ void RE_RenderScene( const refdef_t *fd ) { // turn off dynamic lighting globally by clearing all the // dlights if it needs to be disabled or if vertex lighting is enabled if ( r_dynamiclight->integer == 0 || - r_vertexLight->integer == 1 || - glConfig.hardwareType == GLHW_PERMEDIA2 ) { + r_vertexLight->integer == 1 ) { tr.refdef.num_dlights = 0; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 35a01ebce7..b73bcbae02 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1361,7 +1361,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) // // set state // - if ( pStage->bundle[0].vertexLightmap && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) && r_lightmap->integer ) + if ( pStage->bundle[0].vertexLightmap && (r_vertexLight->integer && !r_uiFullScreen->integer) && r_lightmap->integer ) { GL_BindToTMU( tr.whiteImage, 0 ); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4f23bcebe7..0c03526fac 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2066,14 +2066,6 @@ static qboolean CollapseMultitexture( void ) { return qfalse; } - // on voodoo2, don't combine different tmus - if ( glConfig.driverType == GLDRV_VOODOO ) { - if ( stages[0].bundle[0].image[0]->TMU == - stages[1].bundle[0].image[0]->TMU ) { - return qfalse; - } - } - abits = stages[0].stateBits; bbits = stages[1].stateBits; @@ -2929,7 +2921,7 @@ static shader_t *FinishShader( void ) { // // if we are in r_vertexLight mode, never use a lightmap texture // - if ( stage > 1 && ( (r_vertexLight->integer && !r_uiFullScreen->integer) || glConfig.hardwareType == GLHW_PERMEDIA2 ) ) { + if ( stage > 1 && (r_vertexLight->integer && !r_uiFullScreen->integer) ) { VertexLightingCollapse(); hasLightmapStage = qfalse; } From 1f279d74e892ff29d665321aa32d073daef8c452 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 23:12:37 -0400 Subject: [PATCH 026/708] Even more C++ tomfoolery in rend2 --- codemp/rd-rend2/tr_animation.cpp | 8 +-- codemp/rd-rend2/tr_extensions.cpp | 2 +- codemp/rd-rend2/tr_local.h | 4 +- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_mesh.cpp | 2 +- codemp/rd-rend2/tr_model.cpp | 8 +-- codemp/rd-rend2/tr_model_iqm.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 82 +++++++++++++++---------------- 8 files changed, 54 insertions(+), 56 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index eb2b545214..c1ddb4ecec 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -400,7 +400,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { { if (!strcmp(skin->surfaces[j]->name, surface->name)) { - shader = skin->surfaces[j]->shader; + shader = (shader_t *)skin->surfaces[j]->shader; break; } } @@ -419,7 +419,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, qfalse ); } // projection shadows work fine with personal models @@ -428,11 +428,11 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, qfalse ); } if (!personalModel) - R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, qfalse ); surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); } diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 30911da85c..bef58f17ff 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -180,7 +180,7 @@ static qboolean GLimp_HaveExtension(const char *ext) if (ptr == NULL) return qfalse; ptr += strlen(ext); - return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. + return (qboolean)((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. } void GLimp_InitExtraExtensions() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6fdbc60682..4e2364f234 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1142,7 +1142,7 @@ typedef struct { vec3_t pvsOrigin; // may be different than or.origin for portals qboolean isPortal; // true if this view is through a portal qboolean isMirror; // the portal is a mirror, invert the face culling - viewParmFlags_t flags; + int flags; int frameSceneNum; // copied from tr.frameSceneNum int frameCount; // copied from tr.frameCount cplane_t portalPlane; // clip anything behind this if mirroring @@ -1844,7 +1844,7 @@ typedef struct { qboolean textureFloat; qboolean halfFloatPixel; qboolean packedDepthStencil; - textureCompressionRef_t textureCompression; + int textureCompression; qboolean framebufferMultisample; qboolean framebufferBlit; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 5eea5016a4..17ad764571 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2292,7 +2292,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) case MOD_MDR: { // FIXME: never actually tested this - mdrHeader_t *header = model->modelData; + mdrHeader_t *header = (mdrHeader_t*)model->modelData; int frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); mdrFrame_t *frame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 1c02b1e846..7f63845694 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -363,7 +363,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { for ( j = 0 ; j < skin->numSurfaces ; j++ ) { // the names have both been lowercased if ( !strcmp( skin->surfaces[j]->name, surface->name ) ) { - shader = skin->surfaces[j]->shader; + shader = (shader_t *)skin->surfaces[j]->shader; break; } } diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 03414d4bbe..e25c2bd908 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -854,7 +854,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } mod->dataSize += size; - mod->modelData = mdr = ri->Hunk_Alloc( size, h_low ); + mod->modelData = mdr = (mdrHeader_t*)ri->Hunk_Alloc( size, h_low ); // Copy all the values over from the file and fix endian issues in the process, if necessary. @@ -1164,7 +1164,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { mod->type = MOD_MD4; size = LittleLong(pinmodel->ofsEnd); mod->dataSize += size; - mod->modelData = md4 = ri->Hunk_Alloc( size, h_low ); + mod->modelData = md4 = (md4Header_t *)ri->Hunk_Alloc( size, h_low ); Com_Memcpy(md4, buffer, size); @@ -1465,7 +1465,7 @@ int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFram R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end); } else if( model->type == MOD_IQM ) { - return R_IQMLerpTag( tag, model->modelData, + return R_IQMLerpTag( tag, (iqmData_t *)model->modelData, startFrame, endFrame, frac, tagName ); } else { @@ -1554,7 +1554,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { } else if(model->type == MOD_IQM) { iqmData_t *iqmData; - iqmData = model->modelData; + iqmData = (iqmData_t *)model->modelData; if(iqmData->bounds) { diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index f7e32cffcd..7e43b68b6c 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -850,7 +850,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { { if (!strcmp(skin->surfaces[j]->name, surface->name)) { - shader = skin->surfaces[j]->shader; + shader = (shader_t *)skin->surfaces[j]->shader; break; } } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 0c03526fac..6de80b634f 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -361,7 +361,7 @@ ParseTexMod static void ParseTexMod( char *_text, shaderStage_t *stage ) { const char *token; - const char **text = &_text; + const char **text = (const char **)&_text; texModInfo_t *tmi; if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { @@ -655,7 +655,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else { imgType_t type = IMGTYPE_COLORALPHA; - imgFlags_t flags = IMGFLAG_NONE; + int flags = IMGFLAG_NONE; if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -695,7 +695,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "clampmap" ) ) { imgType_t type = IMGTYPE_COLORALPHA; - imgFlags_t flags = IMGFLAG_CLAMPTOEDGE; + int flags = IMGFLAG_CLAMPTOEDGE; token = COM_ParseExt( text, qfalse ); if ( !token[0] ) @@ -758,7 +758,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } num = stage->bundle[0].numImageAnimations; if ( num < MAX_IMAGE_ANIMATIONS ) { - imgFlags_t flags = IMGFLAG_NONE; + int flags = IMGFLAG_NONE; if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -1381,7 +1381,7 @@ static void ParseSkyParms( const char **text ) { static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; char pathname[MAX_QPATH]; int i; - imgFlags_t imgFlags = (imgFlags_t)(IMGFLAG_MIPMAP | IMGFLAG_PICMIP); + int imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; if (r_srgb->integer) imgFlags |= IMGFLAG_SRGB; @@ -2202,7 +2202,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { char normalName[MAX_QPATH]; image_t *normalImg; - imgFlags_t normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + imgFlags_t normalFlags = (imgFlags_t)((diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE); COM_StripExtension(diffuseImg->imgName, normalName, MAX_QPATH); Q_strcat(normalName, MAX_QPATH, "_n"); @@ -2509,7 +2509,7 @@ static qboolean CollapseStagesToGLSL(void) } } - return numStages; + return (qboolean)numStages; } /* @@ -2639,7 +2639,7 @@ static shader_t *GeneratePermanentShader( void ) { return tr.defaultShader; } - newShader = ri->Hunk_Alloc( sizeof( shader_t ), h_low ); + newShader = (shader_t *)ri->Hunk_Alloc( sizeof( shader_t ), h_low ); *newShader = shader; @@ -2661,12 +2661,12 @@ static shader_t *GeneratePermanentShader( void ) { if ( !stages[i].active ) { break; } - newShader->stages[i] = ri->Hunk_Alloc( sizeof( stages[i] ), h_low ); + newShader->stages[i] = (shaderStage_t *)ri->Hunk_Alloc( sizeof( stages[i] ), h_low ); *newShader->stages[i] = stages[i]; for ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) { size = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t ); - newShader->stages[i]->bundle[b].texMods = ri->Hunk_Alloc( size, h_low ); + newShader->stages[i]->bundle[b].texMods = (texModInfo_t *)ri->Hunk_Alloc( size, h_low ); Com_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size ); } } @@ -2974,9 +2974,10 @@ return NULL if not found If found, it will return a valid shader ===================== */ -static char *FindShaderInShaderText( const char *shadername ) { +static const char *FindShaderInShaderText( const char *shadername ) { - char *token, *p; + char *token; + const char *p; int i, hash; @@ -3012,7 +3013,7 @@ static char *FindShaderInShaderText( const char *shadername ) { } else { // skip the definition - SkipBracedSection( &p, 0 ); + SkipBracedSection( &p ); } } @@ -3089,8 +3090,8 @@ most world construction surfaces. */ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; - int i, hash; - char *shaderText; + int i, hash, flags; + const char *shaderText; image_t *image; shader_t *sh; @@ -3160,32 +3161,29 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // if not defined in the in-memory shader descriptions, // look for a single supported image file // - { - imgFlags_t flags; - flags = IMGFLAG_NONE; + flags = IMGFLAG_NONE; - if (r_srgb->integer) - flags |= IMGFLAG_SRGB; + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; - if (mipRawImage) - { - flags |= IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + if (mipRawImage) + { + flags |= IMGFLAG_MIPMAP | IMGFLAG_PICMIP; - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; - } - else - { - flags |= IMGFLAG_CLAMPTOEDGE; - } + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; + } + else + { + flags |= IMGFLAG_CLAMPTOEDGE; + } - image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); - if ( !image ) { - ri->Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); - shader.defaultShader = qtrue; - return FinishShader(); - } + image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); + if ( !image ) { + ri->Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); + shader.defaultShader = qtrue; + return FinishShader(); } // @@ -3531,7 +3529,7 @@ static void ScanAndLoadShaderFiles( void ) { char **shaderFiles; char *buffers[MAX_SHADER_FILES]; - char *p; + const char *p; int numShaderFiles; int i; char *oldp, *token, *hashMem, *textEnd; @@ -3607,7 +3605,7 @@ static void ScanAndLoadShaderFiles( void ) break; } - if(!SkipBracedSection(&p, 1)) + if(!SkipBracedSection(&p)) { ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); @@ -3623,7 +3621,7 @@ static void ScanAndLoadShaderFiles( void ) } // build single large buffer - s_shaderText = ri->Hunk_Alloc( sum + numShaderFiles*2, h_low ); + s_shaderText = (char *)ri->Hunk_Alloc( sum + numShaderFiles*2, h_low ); s_shaderText[ 0 ] = '\0'; textEnd = s_shaderText; @@ -3658,12 +3656,12 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTableSizes[hash]++; size++; - SkipBracedSection(&p, 0); + SkipBracedSection(&p); } size += MAX_SHADERTEXT_HASH; - hashMem = ri->Hunk_Alloc( size * sizeof(char *), h_low ); + hashMem = (char *)ri->Hunk_Alloc( size * sizeof(char *), h_low ); for (i = 0; i < MAX_SHADERTEXT_HASH; i++) { shaderTextHashTable[i] = (char **) hashMem; @@ -3684,7 +3682,7 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp; - SkipBracedSection(&p, 0); + SkipBracedSection(&p); } return; From 38ceb5bfd6d3b51a07fb64a371089d2ae228e4ad Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 23:26:43 -0400 Subject: [PATCH 027/708] Some minor changes, notably killing off some old Q3 cvars and using r_stencilbits properly. --- codemp/rd-rend2/tr_init.cpp | 4 ---- codemp/rd-rend2/tr_local.h | 4 ---- 2 files changed, 8 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5aa1c97a51..29795dcdaf 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -42,10 +42,6 @@ cvar_t *r_flareSize; cvar_t *r_flareFade; cvar_t *r_flareCoeff; -cvar_t *r_railWidth; -cvar_t *r_railCoreWidth; -cvar_t *r_railSegmentLength; - cvar_t *r_verbose; cvar_t *r_ignore; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 4e2364f234..a41c8193d4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -76,10 +76,6 @@ extern cvar_t *r_flareSize; extern cvar_t *r_flareFade; extern cvar_t *r_flareCoeff; -extern cvar_t *r_railWidth; -extern cvar_t *r_railCoreWidth; -extern cvar_t *r_railSegmentLength; - extern cvar_t *r_verbose; extern cvar_t *r_ignore; From 231da6730d6ab68cc48832517d6660c58358aa4e Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 7 Oct 2013 23:53:30 -0400 Subject: [PATCH 028/708] Some more instances of C++ification gone wrong being fixed. This SHOULD be the last batch of these fixes. The last errors appear to be stuff related to things that I actually need to get fixing. --- codemp/rd-rend2/tr_bsp.cpp | 159 +++++++++++++++++---------------- codemp/rd-rend2/tr_image.cpp | 54 +++++------ codemp/rd-rend2/tr_local.h | 7 ++ codemp/rd-rend2/tr_shadows.cpp | 4 +- 4 files changed, 116 insertions(+), 108 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index eeb95e2f61..d097f089a0 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -283,11 +283,11 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.numLightmaps = numLightmaps; } - tr.lightmaps = ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.lightmaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); if (tr.worldDeluxeMapping) { - tr.deluxemaps = ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.deluxemaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } if (r_hdr->integer && glRefConfig.textureFloat && glRefConfig.halfFloatPixel) @@ -382,7 +382,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3; } - lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits - 8); + lightScale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits - 8); for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) { @@ -512,7 +512,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { ri->Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); } - ri->Free(image); + Z_Free(image); } @@ -596,7 +596,7 @@ static void R_LoadVisibility( lump_t *l ) { byte *buf; len = ( s_worldData.numClusters + 63 ) & ~63; - s_worldData.novis = ri->Hunk_Alloc( len, h_low ); + s_worldData.novis = (byte *)ri->Hunk_Alloc( len, h_low ); Com_Memset( s_worldData.novis, 0xff, len ); len = l->filelen; @@ -615,7 +615,7 @@ static void R_LoadVisibility( lump_t *l ) { } else { byte *dest; - dest = ri->Hunk_Alloc( len - 8, h_low ); + dest = (byte *)ri->Hunk_Alloc( len - 8, h_low ); Com_Memcpy( dest, buf + 8, len - 8 ); s_worldData.vis = dest; } @@ -639,7 +639,7 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { } dsh = &s_worldData.shaders[ _shaderNum ]; - if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) { + if ( r_vertexLight->integer ) { lightmapNum = LIGHTMAP_BY_VERTEX; } @@ -690,14 +690,14 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, numTriangles = LittleLong(ds->numIndexes) / 3; //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); - cv = (void *)surf->data; + cv = (srfSurfaceFace_t *)surf->data; cv->surfaceType = SF_FACE; cv->numTriangles = numTriangles; - cv->triangles = ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->triangles = (srfTriangle_t *)ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); cv->numVerts = numVerts; - cv->verts = ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); // copy vertexes surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; @@ -933,14 +933,14 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor numTriangles = LittleLong(ds->numIndexes) / 3; //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); - cv = (void *)surf->data; + cv = (srfTriangles_t *)surf->data; cv->surfaceType = SF_TRIANGLES; cv->numTriangles = numTriangles; - cv->triangles = ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->triangles = (srfTriangle_t *)ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); cv->numVerts = numVerts; - cv->verts = ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); surf->data = (surfaceType_t *) cv; @@ -1057,7 +1057,7 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int } //flare = ri->Hunk_Alloc( sizeof( *flare ), h_low ); - flare = (void *)surf->data; + flare = (srfFlare_t *)surf->data; flare->surfaceType = SF_FLARE; surf->data = (surfaceType_t *)flare; @@ -1314,7 +1314,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1358,7 +1358,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1411,7 +1411,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1455,7 +1455,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1509,7 +1509,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1555,7 +1555,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { if (!grid2) break; grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1608,7 +1608,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1652,7 +1652,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (void *) grid2; + s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1750,26 +1750,26 @@ void R_MovePatchSurfacesToHunk(void) { continue; // size = sizeof(*grid); - hunkgrid = ri->Hunk_Alloc(size, h_low); + hunkgrid = (srfGridMesh_t *)ri->Hunk_Alloc(size, h_low); Com_Memcpy(hunkgrid, grid, size); - hunkgrid->widthLodError = ri->Hunk_Alloc( grid->width * 4, h_low ); + hunkgrid->widthLodError = (float *)ri->Hunk_Alloc( grid->width * 4, h_low ); Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 ); - hunkgrid->heightLodError = ri->Hunk_Alloc( grid->height * 4, h_low ); + hunkgrid->heightLodError = (float *)ri->Hunk_Alloc( grid->height * 4, h_low ); Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 ); hunkgrid->numTriangles = grid->numTriangles; - hunkgrid->triangles = ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); + hunkgrid->triangles = (srfTriangle_t *)ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); Com_Memcpy(hunkgrid->triangles, grid->triangles, grid->numTriangles * sizeof(srfTriangle_t)); hunkgrid->numVerts = grid->numVerts; - hunkgrid->verts = ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + hunkgrid->verts = (srfVert_t *)ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); Com_Memcpy(hunkgrid->verts, grid->verts, grid->numVerts * sizeof(srfVert_t)); R_FreeSurfaceGridMesh( grid ); - s_worldData.surfaces[i].data = (void *) hunkgrid; + s_worldData.surfaces[i].data = (surfaceType_t *) hunkgrid; } } @@ -1906,12 +1906,12 @@ static void R_CreateWorldVBO(void) // create arrays - verts = ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); - triangles = ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); + triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); // presort surfaces - surfacesSorted = ri->Malloc(numSurfaces * sizeof(*surfacesSorted)); + surfacesSorted = (msurface_t **)Z_Malloc(numSurfaces * sizeof(*surfacesSorted), TAG_BSP); j = 0; for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces; k++, surface++) @@ -2123,7 +2123,7 @@ static void R_CreateWorldVBO(void) } - ri->Free(surfacesSorted); + Z_Free(surfacesSorted); ri->Hunk_FreeTempMemory(triangles); ri->Hunk_FreeTempMemory(verts); @@ -2153,21 +2153,21 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = surfs->filelen / sizeof(*in); - dv = (void *)(fileBase + verts->fileofs); + dv = (drawVert_t *)(fileBase + verts->fileofs); if (verts->filelen % sizeof(*dv)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - indexes = (void *)(fileBase + indexLump->fileofs); + indexes = (int *)(fileBase + indexLump->fileofs); if ( indexLump->filelen % sizeof(*indexes)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); - out = ri->Hunk_Alloc ( count * sizeof(*out), h_low ); + out = (msurface_t *)ri->Hunk_Alloc ( count * sizeof(*out), h_low ); s_worldData.surfaces = out; s_worldData.numsurfaces = count; - s_worldData.surfacesViewCount = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); - s_worldData.surfacesDlightBits = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); - s_worldData.surfacesPshadowBits = ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); + s_worldData.surfacesViewCount = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); + s_worldData.surfacesDlightBits = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); + s_worldData.surfacesPshadowBits = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); // load hdr vertex colors if (r_hdr->integer) @@ -2192,7 +2192,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // Two passes, allocate surfaces first, then load them full of data // This ensures surfaces are close together to reduce L2 cache misses when using VBOs, // which don't actually use the verts and tris - in = (void *)(fileBase + surfs->fileofs); + in = (dsurface_t *)(fileBase + surfs->fileofs); out = s_worldData.surfaces; for ( i = 0 ; i < count ; i++, in++, out++ ) { switch ( LittleLong( in->surfaceType ) ) { @@ -2200,20 +2200,20 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // FIXME: do this break; case MST_TRIANGLE_SOUP: - out->data = ri->Hunk_Alloc( sizeof(srfTriangles_t), h_low); + out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfTriangles_t), h_low); break; case MST_PLANAR: - out->data = ri->Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); + out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); break; case MST_FLARE: - out->data = ri->Hunk_Alloc( sizeof(srfFlare_t), h_low); + out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfFlare_t), h_low); break; default: break; } } - in = (void *)(fileBase + surfs->fileofs); + in = (dsurface_t *)(fileBase + surfs->fileofs); out = s_worldData.surfaces; for ( i = 0 ; i < count ; i++, in++, out++ ) { switch ( LittleLong( in->surfaceType ) ) { @@ -2281,13 +2281,13 @@ static void R_LoadSubmodels( lump_t *l ) { bmodel_t *out; int i, j, count; - in = (void *)(fileBase + l->fileofs); + in = (dmodel_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); s_worldData.numBModels = count; - s_worldData.bmodels = out = ri->Hunk_Alloc( count * sizeof(*out), h_low ); + s_worldData.bmodels = out = (bmodel_t *)ri->Hunk_Alloc( count * sizeof(*out), h_low ); for ( i=0 ; ifileofs); + in = (dnode_t *)(fileBase + nodeLump->fileofs); if (nodeLump->filelen % sizeof(dnode_t) || leafLump->filelen % sizeof(dleaf_t) ) { ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); @@ -2357,7 +2357,7 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { numNodes = nodeLump->filelen / sizeof(dnode_t); numLeafs = leafLump->filelen / sizeof(dleaf_t); - out = ri->Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); + out = (mnode_t *)ri->Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); s_worldData.nodes = out; s_worldData.numnodes = numNodes + numLeafs; @@ -2388,7 +2388,7 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { } // load leafs - inLeaf = (void *)(fileBase + leafLump->fileofs); + inLeaf = (dleaf_t *)(fileBase + leafLump->fileofs); for ( i=0 ; ifileofs); + in = (dshader_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri->Hunk_Alloc ( count*sizeof(*out), h_low ); + out = (dshader_t *)ri->Hunk_Alloc ( count*sizeof(*out), h_low ); s_worldData.shaders = out; s_worldData.numShaders = count; @@ -2452,11 +2452,11 @@ static void R_LoadMarksurfaces (lump_t *l) int *in; int *out; - in = (void *)(fileBase + l->fileofs); + in = (int *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri->Hunk_Alloc ( count*sizeof(*out), h_low); + out = (int *)ri->Hunk_Alloc ( count*sizeof(*out), h_low); s_worldData.marksurfaces = out; s_worldData.nummarksurfaces = count; @@ -2481,11 +2481,11 @@ static void R_LoadPlanes( lump_t *l ) { int count; int bits; - in = (void *)(fileBase + l->fileofs); + in = (dplane_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); count = l->filelen / sizeof(*in); - out = ri->Hunk_Alloc ( count*2*sizeof(*out), h_low); + out = (cplane_t *)ri->Hunk_Alloc ( count*2*sizeof(*out), h_low); s_worldData.planes = out; s_worldData.numplanes = count; @@ -2524,7 +2524,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { float d; int firstSide; - fogs = (void *)(fileBase + l->fileofs); + fogs = (dfog_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*fogs)) { ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } @@ -2532,20 +2532,20 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { // create fog strucutres for them s_worldData.numfogs = count + 1; - s_worldData.fogs = ri->Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); + s_worldData.fogs = (fog_t *)ri->Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); out = s_worldData.fogs + 1; if ( !count ) { return; } - brushes = (void *)(fileBase + brushesLump->fileofs); + brushes = (dbrush_t *)(fileBase + brushesLump->fileofs); if (brushesLump->filelen % sizeof(*brushes)) { ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } brushesCount = brushesLump->filelen / sizeof(*brushes); - sides = (void *)(fileBase + sidesLump->fileofs); + sides = (dbrushside_t *)(fileBase + sidesLump->fileofs); if (sidesLump->filelen % sizeof(*sides)) { ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); } @@ -2656,7 +2656,7 @@ void R_LoadLightGrid( lump_t *l ) { return; } - w->lightGridData = ri->Hunk_Alloc( l->filelen, h_low ); + w->lightGridData = (byte *)ri->Hunk_Alloc( l->filelen, h_low ); Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits @@ -2679,7 +2679,7 @@ void R_LoadLightGrid( lump_t *l ) { if (hdrLightGrid) { - float lightScale = pow(2, r_mapOverBrightBits->integer - tr.overbrightBits); + float lightScale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); //ri->Printf(PRINT_ALL, "found!\n"); @@ -2688,7 +2688,7 @@ void R_LoadLightGrid( lump_t *l ) { ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); } - w->hdrLightGrid = ri->Hunk_Alloc(size, h_low); + w->hdrLightGrid = (float *)ri->Hunk_Alloc(size, h_low); for (i = 0; i < numGridPoints ; i++) { @@ -2712,7 +2712,8 @@ R_LoadEntities ================ */ void R_LoadEntities( lump_t *l ) { - char *p, *token, *s; + const char *p; + char *token, *s; char keyname[MAX_TOKEN_CHARS]; char value[MAX_TOKEN_CHARS]; world_t *w; @@ -2725,7 +2726,7 @@ void R_LoadEntities( lump_t *l ) { p = (char *)(fileBase + l->fileofs); // store for reference by the cgame - w->entityString = ri->Hunk_Alloc( l->filelen + 1, h_low ); + w->entityString = (char *)ri->Hunk_Alloc( l->filelen + 1, h_low ); strcpy( w->entityString, p ); w->entityParsePoint = w->entityString; @@ -2798,9 +2799,9 @@ R_GetEntityToken ================= */ qboolean R_GetEntityToken( char *buffer, int size ) { - const char *s; + char *s; - s = COM_Parse( &s_worldData.entityParsePoint ); + s = COM_Parse( (const char **)&s_worldData.entityParsePoint ); Q_strncpyz( buffer, s, size ); if ( !s_worldData.entityParsePoint || !s[0] ) { s_worldData.entityParsePoint = s_worldData.entityString; @@ -2845,12 +2846,12 @@ void R_MergeLeafSurfaces(void) } // create ibo - ibo = tr.ibos[tr.numIBOs++] = ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs++] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); memset(ibo, 0, sizeof(*ibo)); Q_strncpyz(ibo->name, "staticWorldMesh_IBO_mergedSurfs", sizeof(ibo->name)); // allocate more than we need - iboIndexes = outIboIndexes = ri->Malloc(s_worldData.ibo->indexesSize); + iboIndexes = outIboIndexes = (glIndex_t *)Z_Malloc(s_worldData.ibo->indexesSize, TAG_GENERAL); // mark matching surfaces for (i = 0; i < s_worldData.numnodes - s_worldData.numDecisionNodes; i++) @@ -2961,15 +2962,15 @@ void R_MergeLeafSurfaces(void) } // Allocate merged surfaces - s_worldData.mergedSurfaces = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesViewCount = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesDlightBits = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesPshadowBits = ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + s_worldData.mergedSurfaces = (msurface_t *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesViewCount = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesDlightBits = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + s_worldData.mergedSurfacesPshadowBits = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); s_worldData.numMergedSurfaces = numMergedSurfaces; // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on - s_worldData.viewSurfaces = ri->Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); + s_worldData.viewSurfaces = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); // copy view surfaces into mark surfaces for (i = 0; i < s_worldData.nummarksurfaces; i++) @@ -3127,7 +3128,7 @@ void R_MergeLeafSurfaces(void) } } - vboSurf = ri->Hunk_Alloc(sizeof(*vboSurf), h_low); + vboSurf = (srfVBOMesh_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); memset(vboSurf, 0, sizeof(*vboSurf)); vboSurf->surfaceType = SF_VBO_MESH; @@ -3194,7 +3195,7 @@ void R_MergeLeafSurfaces(void) GL_CheckErrors(); - ri->Free(iboIndexes); + Z_Free(iboIndexes); endTime = ri->Milliseconds(); @@ -3315,7 +3316,7 @@ void RE_LoadWorldMap( const char *name ) { Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); COM_StripExtension(s_worldData.baseName, s_worldData.baseName, sizeof(s_worldData.baseName)); - startMarker = ri->Hunk_Alloc(0, h_low); + startMarker = (byte *)ri->Hunk_Alloc(0, h_low); c_gridVerts = 0; header = (dheader_t *)buffer.b; @@ -3359,7 +3360,7 @@ void RE_LoadWorldMap( const char *name ) { int i; lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; - primaryLightGrid = ri->Malloc(lightGridSize * sizeof(*primaryLightGrid)); + primaryLightGrid = (uint8_t *)Z_Malloc(lightGridSize * sizeof(*primaryLightGrid), TAG_GENERAL); memset(primaryLightGrid, 0, lightGridSize * sizeof(*primaryLightGrid)); @@ -3405,7 +3406,7 @@ void RE_LoadWorldMap( const char *name ) { if (0) { int i; - byte *buffer = ri->Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); + byte *buffer = (byte *)Z_Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18, TAG_GENERAL); byte *out; uint8_t *in; char fileName[MAX_QPATH]; @@ -3452,7 +3453,7 @@ void RE_LoadWorldMap( const char *name ) { ri->FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); } - ri->Free(buffer); + Z_Free(buffer); } for (i = 0; i < w->numWorldSurfaces; i++) @@ -3532,7 +3533,7 @@ void RE_LoadWorldMap( const char *name ) { } } - ri->Free(primaryLightGrid); + Z_Free(primaryLightGrid); } // create static VBOS from the world diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 1d17649f9a..35a48c6e34 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1612,7 +1612,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he finalheight >>= 1; } - *resampledBuffer = ri->Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); + *resampledBuffer = (byte *)ri->Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); if (scaled_width != width || scaled_height != height) { @@ -1664,7 +1664,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he else if ( scaled_width != width || scaled_height != height ) { if (data && resampledBuffer) { - *resampledBuffer = ri->Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); + *resampledBuffer = (byte *)ri->Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); *data = *resampledBuffer; } @@ -1730,8 +1730,8 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light { int samples = 3; GLenum internalFormat = GL_RGB; - qboolean forceNoCompression = (flags & IMGFLAG_NO_COMPRESSION); - qboolean normalmap = (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT); + qboolean forceNoCompression = (qboolean)(flags & IMGFLAG_NO_COMPRESSION); + qboolean normalmap = (qboolean)(type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT); if(normalmap) { @@ -2000,7 +2000,7 @@ Upload32 =============== */ extern qboolean charSet; -static void Upload32( byte *data, int width, int height, imgType_t type, imgFlags_t flags, +static void Upload32( byte *data, int width, int height, imgType_t type, int flags, qboolean lightMap, GLenum internalFormat, int *pUploadWidth, int *pUploadHeight) { byte *scaledBuffer = NULL; @@ -2011,7 +2011,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); - scaledBuffer = ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); // // scan the texture for each channel's max values @@ -2050,7 +2050,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag { for (i = 0; i < 3; i++) { - float x = ByteToFloat(in[i]); + double x = ByteToFloat(in[i]); x = sRGBtoRGB(x); in[i] = FloatToByte(x); } @@ -2121,7 +2121,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, imgFlag } if (!(flags & IMGFLAG_NOLIGHTSCALE)) - R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, !(flags & IMGFLAG_MIPMAP) ); + R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, (qboolean)(!(flags & IMGFLAG_MIPMAP)) ); *pUploadWidth = scaled_width; *pUploadHeight = scaled_height; @@ -2214,7 +2214,7 @@ R_CreateImage This is the only way any image_t are created ================ */ -image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, imgFlags_t flags, int internalFormat ) { +image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ) { image_t *image; qboolean isLightmap = qfalse; long hash; @@ -2231,12 +2231,12 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT ri->Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); } - image = tr.images[tr.numImages] = ri->Hunk_Alloc( sizeof( image_t ), h_low ); + image = tr.images[tr.numImages] = (image_t *)ri->Hunk_Alloc( sizeof( image_t ), h_low ); image->texnum = 1024 + tr.numImages; tr.numImages++; image->type = type; - image->flags = flags; + image->flags = (imgFlags_t)flags; strcpy (image->imgName, name); @@ -2347,7 +2347,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h RawImage_ScaleToPower2(&pic, &width, &height, &scaled_width, &scaled_height, image->type, image->flags, &resampledBuffer); - scaledBuffer = ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); if ( qglActiveTextureARB ) { GL_SelectTexture( image->TMU ); @@ -2399,7 +2399,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h } if (!(image->flags & IMGFLAG_NOLIGHTSCALE)) - R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, !(image->flags & IMGFLAG_MIPMAP) ); + R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, (qboolean)(!(image->flags & IMGFLAG_MIPMAP)) ); scaled_x = x * scaled_width / width; scaled_y = y * scaled_height / height; @@ -2571,7 +2571,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) char normalName[MAX_QPATH]; image_t *normalImage; int normalWidth, normalHeight; - imgFlags_t normalFlags; + int normalFlags; normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; @@ -2589,8 +2589,8 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) normalWidth = width; normalHeight = height; - normalPic = ri->Malloc(width * height * 4); - RGBAtoNormal(pic, normalPic, width, height, flags & IMGFLAG_CLAMPTOEDGE); + normalPic = (byte *)Z_Malloc(width * height * 4, TAG_GENERAL); + RGBAtoNormal(pic, normalPic, width, height, (qboolean)(flags & IMGFLAG_CLAMPTOEDGE)); // Brighten up the original image to work with the normal map RGBAtoYCoCgA(pic, pic, width, height); @@ -2609,12 +2609,12 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) YCoCgAtoRGBA(pic, pic, width, height); R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); - ri->Free( normalPic ); + Z_Free( normalPic ); } } image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); - ri->Free( pic ); + Z_Free( pic ); return image; } @@ -2720,7 +2720,7 @@ static void R_CreateFogImage( void ) { float d; float borderColor[4]; - data = ri->Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); + data = (byte *)ri->Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); // S is distance, T is depth for (x=0 ; xHunk_Alloc( sizeof( skin_t ), h_low ); + skin = (skin_t *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); tr.skins[hSkin] = skin; Q_strncpyz( skin->name, name, sizeof( skin->name ) ); skin->numSurfaces = 0; @@ -3243,7 +3243,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { // If not a .skin file, load as a single shader if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { skin->numSurfaces = 1; - skin->surfaces[0] = ri->Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); + skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); return hSkin; } @@ -3277,7 +3277,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { // parse the shader name token = CommaParse( &text_p ); - surf = skin->surfaces[ skin->numSurfaces ] = ri->Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); + surf = skin->surfaces[ skin->numSurfaces ] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); skin->numSurfaces++; @@ -3306,10 +3306,10 @@ void R_InitSkins( void ) { tr.numSkins = 1; // make the default skin have all default shaders - skin = tr.skins[0] = ri->Hunk_Alloc( sizeof( skin_t ), h_low ); + skin = tr.skins[0] = (skin_t *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); Q_strncpyz( skin->name, "", sizeof( skin->name ) ); skin->numSurfaces = 1; - skin->surfaces[0] = ri->Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); + skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); skin->surfaces[0]->shader = tr.defaultShader; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a41c8193d4..b2bc199346 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2342,6 +2342,13 @@ void GL_Cull( int cullType ); #define GLS_DEFAULT GLS_DEPTHMASK_TRUE +#define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) +#define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) + +extern glconfig_t glConfig; + +typedef _skinSurface_t skinSurface_t; + void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index f412b00d3e..bd6d5d2aa8 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -162,7 +162,7 @@ void RB_ShadowTessEnd( void ) { return; } - if ( glConfig.stencilBits < 4 ) { + if ( r_stencilbits->integer < 4 ) { return; } @@ -265,7 +265,7 @@ void RB_ShadowFinish( void ) { if ( r_shadows->integer != 2 ) { return; } - if ( glConfig.stencilBits < 4 ) { + if ( r_stencilbits->integer < 4 ) { return; } qglEnable( GL_STENCIL_TEST ); From 329319f578ce7a84d040a67887848eb72281804a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 10:47:14 -0400 Subject: [PATCH 029/708] Updated CMake to include new rend2 project --- CMakeLists.txt | 2 + codemp/CMakeLists.txt | 5 + codemp/rd-rend2/CMakeLists.txt | 170 +++++++++++++++++++++++++++++++++ 3 files changed, 177 insertions(+) create mode 100644 codemp/rd-rend2/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 744992ac66..b2e5b2e296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ option(BuildMPDed "Whether to create projects for the MP dedicated server (openj option(BuildMPGame "Whether to create projects for the MP server-side gamecode (jampgamex86.dll)" ON) option(BuildMPCGame "Whether to create projects for the MP clientside gamecode (cgamex86.dll)" ON) option(BuildMPUI "Whether to create projects for the MP UI code (uix86.dll)" ON) +option(BuildMPRend2 "Whether to create projects for the EXPERIMENTAL MP rend2 renderer (rd-rend2_x86.dll)" ON) option(BuildSPEngine "Whether to create projects for the SP engine (openjk_sp.exe)" ON) option(BuildSPGame "Whether to create projects for the SP gamecode (jagamex86.dll)" ON) @@ -85,6 +86,7 @@ set(MPDed "openjkded.${Architecture}") set(MPGame "jampgame${Architecture}") set(MPCGame "cgame${Architecture}") set(MPUI "ui${Architecture}") +set(MPRend2 "rd-rend2_${Architecture}") # Library names set(MPBotLib "botlib") diff --git a/codemp/CMakeLists.txt b/codemp/CMakeLists.txt index acf528584a..9062847166 100644 --- a/codemp/CMakeLists.txt +++ b/codemp/CMakeLists.txt @@ -27,6 +27,11 @@ if(BuildMPEngine) add_subdirectory("${MPDir}/rd-vanilla") endif(BuildMPEngine) +# Add rend2 JKA Renderer Project +if(BuildMPRend2) + add_subdirectory("${MPDir}/rd-rend2") +endif(BuildMPRend2) + # Common things between Engine and Dedicated Server if(BuildMPEngine OR BuildMPDed) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt new file mode 100644 index 0000000000..3afdd892df --- /dev/null +++ b/codemp/rd-rend2/CMakeLists.txt @@ -0,0 +1,170 @@ +cmake_minimum_required(VERSION 2.8.8) + +# Make sure the user is not executing this script directly +if(NOT InOpenJK) + message(FATAL_ERROR "Use the top-level cmake script!") +endif(NOT InOpenJK) + +set(MPRend2IncludeDirectories ${MPDir}) +set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} "${MPDir}/rd-rend2") + +set(MPRend2Files + "${MPDir}/rd-rend2/iqm.h" + "${MPDir}/rd-rend2/qgl.h" + "${MPDir}/rd-rend2/G2_API.cpp" + "${MPDir}/rd-rend2/G2_bolts.cpp" + "${MPDir}/rd-rend2/G2_bones.cpp" + "${MPDir}/rd-rend2/G2_local.h" + "${MPDir}/rd-rend2/G2_misc.cpp" + "${MPDir}/rd-rend2/G2_surfaces.cpp" + "${MPDir}/rd-rend2/tr_animation.cpp" + "${MPDir}/rd-rend2/tr_backend.cpp" + "${MPDir}/rd-rend2/tr_bsp.cpp" + "${MPDir}/rd-rend2/tr_cmds.cpp" + "${MPDir}/rd-rend2/tr_curve.cpp" + "${MPDir}/rd-rend2/tr_extensions.cpp" + "${MPDir}/rd-rend2/tr_extramath.cpp" + "${MPDir}/rd-rend2/tr_extramath.h" + "${MPDir}/rd-rend2/tr_extratypes.h" + "${MPDir}/rd-rend2/tr_fbo.cpp" + "${MPDir}/rd-rend2/tr_fbo.h" + "${MPDir}/rd-rend2/tr_flares.cpp" + "${MPDir}/rd-rend2/tr_glsl.cpp" + "${MPDir}/rd-rend2/tr_image.cpp" + "${MPDir}/rd-rend2/tr_init.cpp" + "${MPDir}/rd-rend2/tr_light.cpp" + "${MPDir}/rd-rend2/tr_local.h" + "${MPDir}/rd-rend2/tr_main.cpp" + "${MPDir}/rd-rend2/tr_marks.cpp" + "${MPDir}/rd-rend2/tr_mesh.cpp" + "${MPDir}/rd-rend2/tr_model.cpp" + "${MPDir}/rd-rend2/tr_model_iqm.cpp" + "${MPDir}/rd-rend2/tr_postprocess.cpp" + "${MPDir}/rd-rend2/tr_postprocess.h" + "${MPDir}/rd-rend2/tr_scene.cpp" + "${MPDir}/rd-rend2/tr_shade.cpp" + "${MPDir}/rd-rend2/tr_shade_calc.cpp" + "${MPDir}/rd-rend2/tr_shader.cpp" + "${MPDir}/rd-rend2/tr_shadows.cpp" + "${MPDir}/rd-rend2/tr_sky.cpp" + "${MPDir}/rd-rend2/tr_subs.cpp" + "${MPDir}/rd-rend2/tr_surface.cpp" + "${MPDir}/rd-rend2/tr_vbo.cpp" + "${MPDir}/rd-rend2/tr_world.cpp" + ) +source_group("renderer" FILES ${MPRend2Files}) + +set(MPRend2Ghoul2Files + "${MPDir}/ghoul2/G2_gore.cpp" + "${MPDir}/ghoul2/G2_gore.h") +source_group("ghoul2" FILES ${MPRend2Ghoul2Files}) +set(MPRend2Files ${MPRend2Files} ${MPRend2Ghoul2Files}) + +set(MPRend2RdCommonFiles + "${MPDir}/rd-common/mdx_format.h" + "${MPDir}/rd-common/tr_types.h" + "${MPDir}/rd-common/tr_public.h") +source_group("rd-common" FILES ${MPRend2RdCommonFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) + +set(MPRend2QcommonFiles + "${MPDir}/qcommon/GenericParser2.cpp" + "${MPDir}/qcommon/matcomp.cpp" + "${MPDir}/qcommon/q_math.cpp" + "${MPDir}/qcommon/q_shared.cpp") +source_group("qcommon" FILES ${MPRend2QcommonFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2QcommonFiles}) + +file(GLOB_RECURSE MPRend2JpegFiles "${OpenJKLibDir}/jpeg-8c/*.c" "${OpenJKLibDir}/jpeg-8c/*.h") +source_group("jpeg-8c" FILES ${MPRend2JpegFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2JpegFiles}) + +if(UseInternalPNG) + set(MPRend2LibPngFiles + "${OpenJKLibDir}/libpng/png.c" + "${OpenJKLibDir}/libpng/pngerror.c" + "${OpenJKLibDir}/libpng/pngget.c" + "${OpenJKLibDir}/libpng/pngmem.c" + "${OpenJKLibDir}/libpng/pngpread.c" + "${OpenJKLibDir}/libpng/pngread.c" + "${OpenJKLibDir}/libpng/pngrio.c" + "${OpenJKLibDir}/libpng/pngrtran.c" + "${OpenJKLibDir}/libpng/pngrutil.c" + "${OpenJKLibDir}/libpng/pngset.c" + "${OpenJKLibDir}/libpng/pngtrans.c" + "${OpenJKLibDir}/libpng/pngwio.c" + "${OpenJKLibDir}/libpng/pngwrite.c" + "${OpenJKLibDir}/libpng/pngwtran.c" + "${OpenJKLibDir}/libpng/pngwutil.c") + source_group("libpng" FILES ${MPRend2LibPngFiles}) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} "${OpenJKLibDir}/libpng") + set(MPRend2Files ${MPRend2Files} ${MPRend2LibPngFiles}) +else(UseInternalPNG) + find_package(PNG REQUIRED) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${PNG_INCLUDE_DIR}) + set(MPRend2Libraries ${MPRend2Libraries} ${PNG_LIBRARIES}) +endif(UseInternalPNG) + +if(UseInternalZlib) + # zlib.lib is included for windows + find_library(ZlibLibrary NAMES zlib PATHS ${OpenJKLibDir}) + if(NOT ZlibLibrary) + message(FATAL_ERROR "UseInternalZlib enabled, but lib/zlib.lib not found!") + endif(NOT ZlibLibrary) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} "${OpenJKLibDir}/zlib") + set(MPRend2Libraries ${MPRend2Libraries} ${ZlibLibrary}) +else(UseInternalZlib) + find_package(ZLIB REQUIRED) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${ZLIB_INCLUDE_DIR}) + set(MPRend2Libraries ${MPRend2Libraries} ${ZLIB_LIBRARY}) +endif(UseInternalZlib) + +if(NOT WIN32) + find_package(OpenGL REQUIRED) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OPENGL_INCLUDE_DIR}) + set(MPRend2Libraries ${MPRend2Libraries} ${OPENGL_LIBRARIES}) + + find_package(SDL2 REQUIRED) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${SDL2_INCLUDE_DIR}) + set(MPRend2Libraries ${MPRend2Libraries} ${SDL2_LIBRARY}) +endif(NOT WIN32) + + +if(WIN32) + set(MPRend2Win32Files + "${MPDir}/win32/win_gamma.cpp" + "${MPDir}/win32/win_glimp.cpp" + "${MPDir}/win32/win_qgl.cpp") + source_group("win32" FILES ${MPRend2Win32Files}) + set(MPRend2Files ${MPRend2Files} ${MPRend2Win32Files}) +else(WIN32) + set(MPRend2SysFiles + "${MPDir}/sdl/sdl_glimp.cpp") + source_group("sys" FILES ${MPRend2SysFiles}) + set(MPRend2Files ${MPRend2Files} ${MPRend2SysFiles}) +endif(WIN32) + +set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OpenJKLibDir}) +add_library(${MPRend2} SHARED ${MPRend2Files}) + +if(NOT WIN32) + # remove "lib" prefix for .so/.dylib files + set_target_properties(${MPRend2} PROPERTIES PREFIX "") +endif(NOT WIN32) + +if(WIN32) + install(TARGETS ${MPRend2} RUNTIME DESTINATION ".") +else(WIN32) + if(MakeApplicationBundles AND BuildMPEngine) + install(TARGETS ${MPRend2} LIBRARY DESTINATION "${MPEngine}.app/Contents/MacOS/") + else(MakeApplicationBundles AND BuildMPEngine) + install(TARGETS ${MPRend2} LIBRARY DESTINATION ".") + endif(MakeApplicationBundles AND BuildMPEngine) +endif(WIN32) +set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "${SharedDefines};${ReleaseDefines}") +set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS_MINSIZEREL "${SharedDefines};${ReleaseDefines}") +set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS_RELEASE "${SharedDefines};${ReleaseDefines}") +set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS_DEBUG "${SharedDefines};${DebugDefines}") +set_target_properties(${MPRend2} PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") +set_target_properties(${MPRend2} PROPERTIES PROJECT_LABEL "MP Rend2 Renderer") +target_link_libraries(${MPRend2} ${MPRend2Libraries}) From aa8c39f984c2f10e78ad563b972e7eea6255d01d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 11:05:00 -0400 Subject: [PATCH 030/708] Some more fixes to rend2 --- codemp/rd-common/tr_types.h | 3 +- codemp/rd-rend2/tr_backend.cpp | 34 +- codemp/rd-rend2/tr_extensions.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 4858 +++++++++++++++++++++++++++++ codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_local.h | 19 + codemp/rd-rend2/tr_shader.cpp | 2 +- 7 files changed, 4891 insertions(+), 29 deletions(-) create mode 100644 codemp/rd-rend2/tr_ghoul2.cpp diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h index 9a27212d97..e23729b2b6 100644 --- a/codemp/rd-common/tr_types.h +++ b/codemp/rd-common/tr_types.h @@ -320,7 +320,8 @@ typedef int stereoFrame_t; typedef enum { // r_ext_preferred_tc_method TC_NONE, TC_S3TC, - TC_S3TC_DXT + TC_S3TC_DXT, + TC_S3TC_ARB } textureCompression_t; typedef struct glconfig_s { diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 0b0be4ee34..2513e08ed3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -581,7 +581,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { int entityNum, oldEntityNum; int dlighted, oldDlighted; int pshadowed, oldPshadowed; - qboolean depthRange, oldDepthRange, isCrosshair, wasCrosshair; + qboolean depthRange, oldDepthRange; int i; drawSurf_t *drawSurf; int oldSort; @@ -603,7 +603,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldShader = NULL; oldFogNum = -1; oldDepthRange = qfalse; - wasCrosshair = qfalse; oldDlighted = qfalse; oldPshadowed = qfalse; oldSort = -1; @@ -650,7 +649,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // if ( entityNum != oldEntityNum ) { qboolean sunflare = qfalse; - depthRange = isCrosshair = qfalse; + depthRange = qfalse; if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; @@ -671,9 +670,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { { // hack the depth range to prevent view model from poking into walls depthRange = qtrue; - - if(backEnd.currentEntity->e.renderfx & RF_CROSSHAIR) - isCrosshair = qtrue; } } else { backEnd.currentEntity = &tr.worldEntity; @@ -691,28 +687,17 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // change depthrange. Also change projection matrix so first person weapon does not look like coming // out of the screen. // - if (oldDepthRange != depthRange || wasCrosshair != isCrosshair) + if (oldDepthRange != depthRange) { if (depthRange) { if(backEnd.viewParms.stereoFrame != STEREO_CENTER) { - if(isCrosshair) - { - if(oldDepthRange) - { - // was not a crosshair but now is, change back proj matrix - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - } - } - else - { - viewParms_t temp = backEnd.viewParms; - - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - - GL_SetProjectionMatrix( temp.projectionMatrix ); - } + viewParms_t temp = backEnd.viewParms; + + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + + GL_SetProjectionMatrix( temp.projectionMatrix ); } if(!oldDepthRange) @@ -724,7 +709,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } else { - if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER) + if(backEnd.viewParms.stereoFrame != STEREO_CENTER) { GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); } @@ -737,7 +722,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } oldDepthRange = depthRange; - wasCrosshair = isCrosshair; } oldEntityNum = entityNum; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index bef58f17ff..8e4e068ffa 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -580,7 +580,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferMultisample = qfalse; if (GLimp_HaveExtension(extension)) { - qglRenderbufferStorageMultisampleEXT = (void __stdcall *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); + qglRenderbufferStorageMultisampleEXT = SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp new file mode 100644 index 0000000000..87b93def45 --- /dev/null +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -0,0 +1,4858 @@ +#include "client/client.h" //FIXME!! EVIL - just include the definitions needed +#include "tr_local.h" +#include "qcommon/matcomp.h" +#include "qcommon/qcommon.h" +#include "ghoul2/G2.h" +#include "G2_local.h" +#ifdef _G2_GORE +#include "ghoul2/G2_gore.h" +#endif + +#ifdef _MSC_VER +#pragma warning (disable: 4512) //default assignment operator could not be gened +#endif +#include "qcommon/disablewarnings.h" + +#define LL(x) x=LittleLong(x) + +#ifdef G2_PERFORMANCE_ANALYSIS +#include "qcommon/timing.h" + +timing_c G2PerformanceTimer_RenderSurfaces; +timing_c G2PerformanceTimer_R_AddGHOULSurfaces; +timing_c G2PerformanceTimer_G2_TransformGhoulBones; +timing_c G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts; +timing_c G2PerformanceTimer_ProcessModelBoltSurfaces; +timing_c G2PerformanceTimer_G2_ConstructGhoulSkeleton; +timing_c G2PerformanceTimer_RB_SurfaceGhoul; +timing_c G2PerformanceTimer_G2_SetupModelPointers; +timing_c G2PerformanceTimer_PreciseFrame; + +int G2PerformanceCounter_G2_TransformGhoulBones = 0; + +int G2Time_RenderSurfaces = 0; +int G2Time_R_AddGHOULSurfaces = 0; +int G2Time_G2_TransformGhoulBones = 0; +int G2Time_G2_ProcessGeneratedSurfaceBolts = 0; +int G2Time_ProcessModelBoltSurfaces = 0; +int G2Time_G2_ConstructGhoulSkeleton = 0; +int G2Time_RB_SurfaceGhoul = 0; +int G2Time_G2_SetupModelPointers = 0; +int G2Time_PreciseFrame = 0; + +void G2Time_ResetTimers(void) +{ + G2Time_RenderSurfaces = 0; + G2Time_R_AddGHOULSurfaces = 0; + G2Time_G2_TransformGhoulBones = 0; + G2Time_G2_ProcessGeneratedSurfaceBolts = 0; + G2Time_ProcessModelBoltSurfaces = 0; + G2Time_G2_ConstructGhoulSkeleton = 0; + G2Time_RB_SurfaceGhoul = 0; + G2Time_G2_SetupModelPointers = 0; + G2Time_PreciseFrame = 0; + G2PerformanceCounter_G2_TransformGhoulBones = 0; +} + +void G2Time_ReportTimers(void) +{ + Com_Printf("\n---------------------------------\nRenderSurfaces: %i\nR_AddGhoulSurfaces: %i\nG2_TransformGhoulBones: %i\nG2_ProcessGeneratedSurfaceBolts: %i\nProcessModelBoltSurfaces: %i\nG2_ConstructGhoulSkeleton: %i\nRB_SurfaceGhoul: %i\nG2_SetupModelPointers: %i\n\nPrecise frame time: %i\nTransformGhoulBones calls: %i\n---------------------------------\n\n", + G2Time_RenderSurfaces, + G2Time_R_AddGHOULSurfaces, + G2Time_G2_TransformGhoulBones, + G2Time_G2_ProcessGeneratedSurfaceBolts, + G2Time_ProcessModelBoltSurfaces, + G2Time_G2_ConstructGhoulSkeleton, + G2Time_RB_SurfaceGhoul, + G2Time_G2_SetupModelPointers, + G2Time_PreciseFrame, + G2PerformanceCounter_G2_TransformGhoulBones + ); +} +#endif + +//rww - RAGDOLL_BEGIN +#ifdef __linux__ +#include +#else +#include +#endif + +//rww - RAGDOLL_END + +bool HackadelicOnClient=false; // means this is a render traversal + +qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); +qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); + +extern cvar_t *r_Ghoul2AnimSmooth; +extern cvar_t *r_Ghoul2UnSqashAfterSmooth; + +static inline int G2_Find_Bone_ByNum(const model_t *mod, boneInfo_v &blist, const int boneNum) +{ + size_t i = 0; + + while (i < blist.size()) + { + if (blist[i].boneNumber == boneNum) + { + return i; + } + i++; + } + + return -1; +} + +const static mdxaBone_t identityMatrix = +{ + { + { 0.0f, -1.0f, 0.0f, 0.0f }, + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f } + } +}; + +// I hate doing this, but this is the simplest way to get this into the routines it needs to be +mdxaBone_t worldMatrix; +mdxaBone_t worldMatrixInv; +#ifdef _G2_GORE +qhandle_t goreShader=-1; +#endif + +class CConstructBoneList +{ +public: + int surfaceNum; + int *boneUsedList; + surfaceInfo_v &rootSList; + model_t *currentModel; + boneInfo_v &boneList; + + CConstructBoneList( + int initsurfaceNum, + int *initboneUsedList, + surfaceInfo_v &initrootSList, + model_t *initcurrentModel, + boneInfo_v &initboneList): + + surfaceNum(initsurfaceNum), + boneUsedList(initboneUsedList), + rootSList(initrootSList), + currentModel(initcurrentModel), + boneList(initboneList) { } + +}; + +class CTransformBone +{ +public: + int touch; // for minimal recalculation + //rww - RAGDOLL_BEGIN + int touchRender; + //rww - RAGDOLL_END + mdxaBone_t boneMatrix; //final matrix + int parent; // only set once + + CTransformBone() + { + touch=0; + //rww - RAGDOLL_BEGIN + touchRender = 0; + //rww - RAGDOLL_END + } + +}; + +struct SBoneCalc +{ + int newFrame; + int currentFrame; + float backlerp; + float blendFrame; + int blendOldFrame; + bool blendMode; + float blendLerp; +}; + +class CBoneCache; +void G2_TransformBone(int index,CBoneCache &CB); + +class CBoneCache +{ + void SetRenderMatrix(CTransformBone *bone) { + } + + void EvalLow(int index) + { + assert(index>=0&&index<(int)mBones.size()); + if (mFinalBones[index].touch!=mCurrentTouch) + { + // need to evaluate the bone + assert((mFinalBones[index].parent>=0&&mFinalBones[index].parent<(int)mFinalBones.size())||(index==0&&mFinalBones[index].parent==-1)); + if (mFinalBones[index].parent>=0) + { + EvalLow(mFinalBones[index].parent); // make sure parent is evaluated + SBoneCalc &par=mBones[mFinalBones[index].parent]; + mBones[index].newFrame=par.newFrame; + mBones[index].currentFrame=par.currentFrame; + mBones[index].backlerp=par.backlerp; + mBones[index].blendFrame=par.blendFrame; + mBones[index].blendOldFrame=par.blendOldFrame; + mBones[index].blendMode=par.blendMode; + mBones[index].blendLerp=par.blendLerp; + } + G2_TransformBone(index,*this); + mFinalBones[index].touch=mCurrentTouch; + } + } +//rww - RAGDOLL_BEGIN + void SmoothLow(int index) + { + if (mSmoothBones[index].touch==mLastTouch) + { + int i; + float *oldM=&mSmoothBones[index].boneMatrix.matrix[0][0]; + float *newM=&mFinalBones[index].boneMatrix.matrix[0][0]; +#if 0 //this is just too slow. I need a better way. + static float smoothFactor; + + smoothFactor = mSmoothFactor; + + //Special rag smoothing -rww + if (smoothFactor < 0) + { //I need a faster way to do this but I do not want to store more in the bonecache + static int blistIndex; + assert(mod); + assert(rootBoneList); + blistIndex = G2_Find_Bone_ByNum(mod, *rootBoneList, index); + + assert(blistIndex != -1); + + boneInfo_t &bone = (*rootBoneList)[blistIndex]; + + if (bone.flags & BONE_ANGLES_RAGDOLL) + { + if ((bone.RagFlags & (0x00008)) || //pelvis + (bone.RagFlags & (0x00004))) //model_root + { //pelvis and root do not smooth much + smoothFactor = 0.2f; + } + else if (bone.solidCount > 4) + { //if stuck in solid a lot then snap out quickly + smoothFactor = 0.1f; + } + else + { //otherwise smooth a bunch + smoothFactor = 0.8f; + } + } + else + { //not a rag bone + smoothFactor = 0.3f; + } + } +#endif + + for (i=0;i<12;i++,oldM++,newM++) + { + *oldM=mSmoothFactor*(*oldM-*newM)+*newM; + } + } + else + { + memcpy(&mSmoothBones[index].boneMatrix,&mFinalBones[index].boneMatrix,sizeof(mdxaBone_t)); + } + mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)header + sizeof(mdxaHeader_t) + offsets->offsets[index]); + mdxaBone_t tempMatrix; + Multiply_3x4Matrix(&tempMatrix,&mSmoothBones[index].boneMatrix, &skel->BasePoseMat); + float maxl; + maxl=VectorLength(&skel->BasePoseMat.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[1][0]); + VectorNormalize(&tempMatrix.matrix[2][0]); + + VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); + VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); + VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); + Multiply_3x4Matrix(&mSmoothBones[index].boneMatrix,&tempMatrix,&skel->BasePoseMatInv); + mSmoothBones[index].touch=mCurrentTouch; +#ifdef _DEBUG + for ( int i = 0; i < 3; i++ ) + { + for ( int j = 0; j < 4; j++ ) + { + assert( !Q_isnan(mSmoothBones[index].boneMatrix.matrix[i][j])); + } + } +#endif// _DEBUG + } +//rww - RAGDOLL_END +public: + int frameSize; + const mdxaHeader_t *header; + const model_t *mod; + + // these are split for better cpu cache behavior + vector mBones; + vector mFinalBones; + + vector mSmoothBones; // for render smoothing + //vector mSkels; + + boneInfo_v *rootBoneList; + mdxaBone_t rootMatrix; + int incomingTime; + + int mCurrentTouch; + //rww - RAGDOLL_BEGIN + int mCurrentTouchRender; + int mLastTouch; + int mLastLastTouch; + //rww - RAGDOLL_END + + // for render smoothing + bool mSmoothingActive; + bool mUnsquash; + float mSmoothFactor; + + CBoneCache(const model_t *amod,const mdxaHeader_t *aheader) : + header(aheader), + mod(amod) + { + assert(amod); + assert(aheader); + mSmoothingActive=false; + mUnsquash=false; + mSmoothFactor=0.0f; + + int numBones=header->numBones; + mBones.resize(numBones); + mFinalBones.resize(numBones); + mSmoothBones.resize(numBones); +// mSkels.resize(numBones); + //rww - removed mSkels + mdxaSkelOffsets_t *offsets; + mdxaSkel_t *skel; + offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + + int i; + for (i=0;ioffsets[i]); + //mSkels[i]=skel; + //ditto + mFinalBones[i].parent=skel->parent; + } + mCurrentTouch=3; +//rww - RAGDOLL_BEGIN + mLastTouch=2; + mLastLastTouch=1; +//rww - RAGDOLL_END + } + + SBoneCalc &Root() + { + assert(mBones.size()); + return mBones[0]; + } + const mdxaBone_t &EvalUnsmooth(int index) + { + EvalLow(index); + if (mSmoothingActive&&mSmoothBones[index].touch) + { + return mSmoothBones[index].boneMatrix; + } + return mFinalBones[index].boneMatrix; + } + const mdxaBone_t &Eval(int index) + { + /* + bool wasEval=EvalLow(index); + if (mSmoothingActive) + { + if (mSmoothBones[index].touch!=incomingTime||wasEval) + { + float dif=float(incomingTime)-float(mSmoothBones[index].touch); + if (mSmoothBones[index].touch&&dif<300.0f) + { + + if (dif<16.0f) // 60 fps + { + dif=16.0f; + } + if (dif>100.0f) // 10 fps + { + dif=100.0f; + } + float f=1.0f-pow(1.0f-mSmoothFactor,16.0f/dif); + + int i; + float *oldM=&mSmoothBones[index].boneMatrix.matrix[0][0]; + float *newM=&mFinalBones[index].boneMatrix.matrix[0][0]; + for (i=0;i<12;i++,oldM++,newM++) + { + *oldM=f*(*oldM-*newM)+*newM; + } + if (mUnsquash) + { + mdxaBone_t tempMatrix; + Multiply_3x4Matrix(&tempMatrix,&mSmoothBones[index].boneMatrix, &mSkels[index]->BasePoseMat); + float maxl; + maxl=VectorLength(&mSkels[index]->BasePoseMat.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[1][0]); + VectorNormalize(&tempMatrix.matrix[2][0]); + + VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); + VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); + VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); + Multiply_3x4Matrix(&mSmoothBones[index].boneMatrix,&tempMatrix,&mSkels[index]->BasePoseMatInv); + } + } + else + { + memcpy(&mSmoothBones[index].boneMatrix,&mFinalBones[index].boneMatrix,sizeof(mdxaBone_t)); + } + mSmoothBones[index].touch=incomingTime; + } + return mSmoothBones[index].boneMatrix; + } + return mFinalBones[index].boneMatrix; + */ + + //Hey, this is what sof2 does. Let's try it out. + assert(index>=0&&index<(int)mBones.size()); + if (mFinalBones[index].touch!=mCurrentTouch) + { + EvalLow(index); + } + return mFinalBones[index].boneMatrix; + } + //rww - RAGDOLL_BEGIN + const inline mdxaBone_t &EvalRender(int index) + { + assert(index>=0&&index<(int)mBones.size()); + if (mFinalBones[index].touch!=mCurrentTouch) + { + mFinalBones[index].touchRender=mCurrentTouchRender; + EvalLow(index); + } + if (mSmoothingActive) + { + if (mSmoothBones[index].touch!=mCurrentTouch) + { + SmoothLow(index); + } + return mSmoothBones[index].boneMatrix; + } + return mFinalBones[index].boneMatrix; + } + //rww - RAGDOLL_END + //rww - RAGDOLL_BEGIN + bool WasRendered(int index) + { + assert(index>=0&&index<(int)mBones.size()); + return mFinalBones[index].touchRender==mCurrentTouchRender; + } + int GetParent(int index) + { + if (index==0) + { + return -1; + } + assert(index>=0&&index<(int)mBones.size()); + return mFinalBones[index].parent; + } + //rww - RAGDOLL_END +}; + +void RemoveBoneCache(CBoneCache *boneCache) +{ +#ifdef _FULL_G2_LEAK_CHECKING + g_Ghoul2Allocations -= sizeof(*boneCache); +#endif + + delete boneCache; +} + +#ifdef _G2_LISTEN_SERVER_OPT +void CopyBoneCache(CBoneCache *to, CBoneCache *from) +{ + memcpy(to, from, sizeof(CBoneCache)); +} +#endif + +const mdxaBone_t &EvalBoneCache(int index,CBoneCache *boneCache) +{ + assert(boneCache); + return boneCache->Eval(index); +} + +//rww - RAGDOLL_BEGIN +const mdxaHeader_t *G2_GetModA(CGhoul2Info &ghoul2) +{ + if (!ghoul2.mBoneCache) + { + return 0; + } + + CBoneCache &boneCache=*ghoul2.mBoneCache; + return boneCache.header; +} + +int G2_GetBoneDependents(CGhoul2Info &ghoul2,int boneNum,int *tempDependents,int maxDep) +{ + // fixme, these should be precomputed + if (!ghoul2.mBoneCache||!maxDep) + { + return 0; + } + + CBoneCache &boneCache=*ghoul2.mBoneCache; + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + int i; + int ret=0; + for (i=0;inumChildren;i++) + { + if (!maxDep) + { + return i; // number added + } + *tempDependents=skel->children[i]; + assert(*tempDependents>0&&*tempDependentsnumBones); + maxDep--; + tempDependents++; + ret++; + } + for (i=0;inumChildren;i++) + { + int num=G2_GetBoneDependents(ghoul2,skel->children[i],tempDependents,maxDep); + tempDependents+=num; + ret+=num; + maxDep-=num; + assert(maxDep>=0); + if (!maxDep) + { + break; + } + } + return ret; +} + +bool G2_WasBoneRendered(CGhoul2Info &ghoul2,int boneNum) +{ + if (!ghoul2.mBoneCache) + { + return false; + } + CBoneCache &boneCache=*ghoul2.mBoneCache; + + return boneCache.WasRendered(boneNum); +} + +void G2_GetBoneBasepose(CGhoul2Info &ghoul2,int boneNum,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +{ + if (!ghoul2.mBoneCache) + { + // yikes + retBasepose=const_cast(&identityMatrix); + retBaseposeInv=const_cast(&identityMatrix); + return; + } + assert(ghoul2.mBoneCache); + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + assert(boneNum>=0&&boneNumnumBones); + + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + retBasepose=&skel->BasePoseMat; + retBaseposeInv=&skel->BasePoseMatInv; +} + +char *G2_GetBoneNameFromSkel(CGhoul2Info &ghoul2, int boneNum) +{ + if (!ghoul2.mBoneCache) + { + return NULL; + } + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + assert(boneNum>=0&&boneNumnumBones); + + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + + return skel->name; +} + +void G2_RagGetBoneBasePoseMatrixLow(CGhoul2Info &ghoul2, int boneNum, mdxaBone_t &boneMatrix, mdxaBone_t &retMatrix, vec3_t scale) +{ + assert(ghoul2.mBoneCache); + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + assert(boneNum>=0&&boneNumnumBones); + + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + Multiply_3x4Matrix(&retMatrix, &boneMatrix, &skel->BasePoseMat); + + if (scale[0]) + { + retMatrix.matrix[0][3] *= scale[0]; + } + if (scale[1]) + { + retMatrix.matrix[1][3] *= scale[1]; + } + if (scale[2]) + { + retMatrix.matrix[2][3] *= scale[2]; + } + + VectorNormalize((float*)&retMatrix.matrix[0]); + VectorNormalize((float*)&retMatrix.matrix[1]); + VectorNormalize((float*)&retMatrix.matrix[2]); +} + +void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +{ + if (!ghoul2.mBoneCache) + { + retMatrix=identityMatrix; + // yikes + retBasepose=const_cast(&identityMatrix); + retBaseposeInv=const_cast(&identityMatrix); + return; + } + mdxaBone_t bolt; + assert(ghoul2.mBoneCache); + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + assert(boneNum>=0&&boneNumnumBones); + + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + Multiply_3x4Matrix(&bolt, (mdxaBone_t *)&boneCache.Eval(boneNum), &skel->BasePoseMat); // DEST FIRST ARG + retBasepose=&skel->BasePoseMat; + retBaseposeInv=&skel->BasePoseMatInv; + + if (scale[0]) + { + bolt.matrix[0][3] *= scale[0]; + } + if (scale[1]) + { + bolt.matrix[1][3] *= scale[1]; + } + if (scale[2]) + { + bolt.matrix[2][3] *= scale[2]; + } + VectorNormalize((float*)&bolt.matrix[0]); + VectorNormalize((float*)&bolt.matrix[1]); + VectorNormalize((float*)&bolt.matrix[2]); + + Multiply_3x4Matrix(&retMatrix,&worldMatrix, &bolt); + +#ifdef _DEBUG + for ( int i = 0; i < 3; i++ ) + { + for ( int j = 0; j < 4; j++ ) + { + assert( !Q_isnan(retMatrix.matrix[i][j])); + } + } +#endif// _DEBUG +} + +int G2_GetParentBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +{ + int parent=-1; + if (ghoul2.mBoneCache) + { + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + assert(boneNum>=0&&boneNumnumBones); + parent=boneCache.GetParent(boneNum); + if (parent<0||parent>=boneCache.header->numBones) + { + parent=-1; + retMatrix=identityMatrix; + // yikes + retBasepose=const_cast(&identityMatrix); + retBaseposeInv=const_cast(&identityMatrix); + } + else + { + G2_GetBoneMatrixLow(ghoul2,parent,scale,retMatrix,retBasepose,retBaseposeInv); + } + } + return parent; +} +//rww - RAGDOLL_END + +class CRenderSurface +{ +public: + int surfaceNum; + surfaceInfo_v &rootSList; + shader_t *cust_shader; + int fogNum; + qboolean personalModel; + CBoneCache *boneCache; + int renderfx; + skin_t *skin; + model_t *currentModel; + int lod; + boltInfo_v &boltList; +#ifdef _G2_GORE + shader_t *gore_shader; + CGoreSet *gore_set; +#endif + + CRenderSurface( + int initsurfaceNum, + surfaceInfo_v &initrootSList, + shader_t *initcust_shader, + int initfogNum, + qboolean initpersonalModel, + CBoneCache *initboneCache, + int initrenderfx, + skin_t *initskin, + model_t *initcurrentModel, + int initlod, +#ifdef _G2_GORE + boltInfo_v &initboltList, + shader_t *initgore_shader, + CGoreSet *initgore_set): +#else + boltInfo_v &initboltList): +#endif + + surfaceNum(initsurfaceNum), + rootSList(initrootSList), + cust_shader(initcust_shader), + fogNum(initfogNum), + personalModel(initpersonalModel), + boneCache(initboneCache), + renderfx(initrenderfx), + skin(initskin), + currentModel(initcurrentModel), + lod(initlod), +#ifdef _G2_GORE + boltList(initboltList), + gore_shader(initgore_shader), + gore_set(initgore_set) +#else + boltList(initboltList) +#endif + {} +}; + +#ifdef _G2_GORE +#define MAX_RENDER_SURFACES (2048) +static CRenderableSurface RSStorage[MAX_RENDER_SURFACES]; +static unsigned int NextRS=0; + +CRenderableSurface *AllocRS() +{ + CRenderableSurface *ret=&RSStorage[NextRS]; + ret->Init(); + NextRS++; + NextRS%=MAX_RENDER_SURFACES; + return ret; +} +#endif + +/* + +All bones should be an identity orientation to display the mesh exactly +as it is specified. + +For all other frames, the bones represent the transformation from the +orientation of the bone in the base frame to the orientation in this +frame. + +*/ + + +/* +============= +R_ACullModel +============= +*/ +static int R_GCullModel( trRefEntity_t *ent ) { + + // scale the radius if need be + float largestScale = ent->e.modelScale[0]; + + if (ent->e.modelScale[1] > largestScale) + { + largestScale = ent->e.modelScale[1]; + } + if (ent->e.modelScale[2] > largestScale) + { + largestScale = ent->e.modelScale[2]; + } + if (!largestScale) + { + largestScale = 1; + } + + // cull bounding sphere + switch ( R_CullLocalPointAndRadius( vec3_origin, ent->e.radius * largestScale) ) + { + case CULL_OUT: + tr.pc.c_sphere_cull_md3_out++; + return CULL_OUT; + + case CULL_IN: + tr.pc.c_sphere_cull_md3_in++; + return CULL_IN; + + case CULL_CLIP: + tr.pc.c_sphere_cull_md3_clip++; + return CULL_IN; + } + return CULL_IN; +} + + +/* +================= +R_AComputeFogNum + +================= +*/ +static int R_GComputeFogNum( trRefEntity_t *ent ) { + + int i, j; + fog_t *fog; + + if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + return 0; + } + + for ( i = 1 ; i < tr.world->numfogs ; i++ ) { + fog = &tr.world->fogs[i]; + for ( j = 0 ; j < 3 ; j++ ) { + if ( ent->e.origin[j] - ent->e.radius >= fog->bounds[1][j] ) { + break; + } + if ( ent->e.origin[j] + ent->e.radius <= fog->bounds[0][j] ) { + break; + } + } + if ( j == 3 ) { + return i; + } + } + + return 0; +} + +// work out lod for this entity. +static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int lodBias ) +{ + float flod, lodscale; + float projectedRadius; + int lod; + + if ( currentModel->numLods < 2 ) + { // model has only 1 LOD level, skip computations and bias + return(0); + } + + if ( r_lodbias->integer > lodBias ) + { + lodBias = r_lodbias->integer; + } + + // scale the radius if need be + float largestScale = ent->e.modelScale[0]; + + if (ent->e.modelScale[1] > largestScale) + { + largestScale = ent->e.modelScale[1]; + } + if (ent->e.modelScale[2] > largestScale) + { + largestScale = ent->e.modelScale[2]; + } + if (!largestScale) + { + largestScale = 1; + } + + if ( ( projectedRadius = ProjectRadius( 0.75*largestScale*ent->e.radius, ent->e.origin ) ) != 0 ) //we reduce the radius to make the LOD match other model types which use the actual bound box size + { + lodscale = (r_lodscale->value+r_autolodscalevalue->value); + if ( lodscale > 20 ) + { + lodscale = 20; + } + else if ( lodscale < 0 ) + { + lodscale = 0; + } + flod = 1.0f - projectedRadius * lodscale; + } + else + { + // object intersects near view plane, e.g. view weapon + flod = 0; + } + flod *= currentModel->numLods; + lod = Q_ftol( flod ); + + if ( lod < 0 ) + { + lod = 0; + } + else if ( lod >= currentModel->numLods ) + { + lod = currentModel->numLods - 1; + } + + + lod += lodBias; + + if ( lod >= currentModel->numLods ) + lod = currentModel->numLods - 1; + if ( lod < 0 ) + lod = 0; + + return lod; +} + +//====================================================================== +// +// Bone Manipulation code + + +void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) +{ + // this is revised for the 3x4 matrix we use in G2. + float t = 1 + mat->matrix[0][0] + mat->matrix[1][1] + mat->matrix[2][2]; + float s; + + //If the trace of the matrix is greater than zero, then + //perform an "instant" calculation. + //Important note wrt. rouning errors: + //Test if ( T > 0.00000001 ) to avoid large distortions! + if (t > 0.00000001) + { + s = sqrt(t) * 2; + quat[0] = ( mat->matrix[1][2] - mat->matrix[2][1] ) / s; + quat[1] = ( mat->matrix[2][0] - mat->matrix[0][2] ) / s; + quat[2] = ( mat->matrix[0][1] - mat->matrix[1][0] ) / s; + quat[3] = 0.25 * s; + } + else + { + //If the trace of the matrix is equal to zero then identify + //which major diagonal element has the greatest value. + + //Depending on this, calculate the following: + + if ( mat->matrix[0][0] > mat->matrix[1][1] && mat->matrix[0][0] > mat->matrix[2][2] ) { // Column 0: + s = sqrt( 1.0 + mat->matrix[0][0] - mat->matrix[1][1] - mat->matrix[2][2])* 2; + quat[0] = 0.25 * s; + quat[1] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; + quat[2] = (mat->matrix[2][0] + mat->matrix[0][2] ) / s; + quat[3] = (mat->matrix[1][2] - mat->matrix[2][1] ) / s; + + } else if ( mat->matrix[1][1] > mat->matrix[2][2] ) { // Column 1: + s = sqrt( 1.0 + mat->matrix[1][1] - mat->matrix[0][0] - mat->matrix[2][2] ) * 2; + quat[0] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; + quat[1] = 0.25 * s; + quat[2] = (mat->matrix[1][2] + mat->matrix[2][1] ) / s; + quat[3] = (mat->matrix[2][0] - mat->matrix[0][2] ) / s; + + } else { // Column 2: + s = sqrt( 1.0 + mat->matrix[2][2] - mat->matrix[0][0] - mat->matrix[1][1] ) * 2; + quat[0] = (mat->matrix[2][0]+ mat->matrix[0][2] ) / s; + quat[1] = (mat->matrix[1][2] + mat->matrix[2][1] ) / s; + quat[2] = 0.25 * s; + quat[3] = (mat->matrix[0][1] - mat->matrix[1][0] ) / s; + } + } +} + +void G2_CreateMatrixFromQuaterion(mdxaBone_t *mat, vec4_t quat) +{ + + float xx = quat[0] * quat[0]; + float xy = quat[0] * quat[1]; + float xz = quat[0] * quat[2]; + float xw = quat[0] * quat[3]; + + float yy = quat[1] * quat[1]; + float yz = quat[1] * quat[2]; + float yw = quat[1] * quat[3]; + + float zz = quat[2] * quat[2]; + float zw = quat[2] * quat[3]; + + mat->matrix[0][0] = 1 - 2 * ( yy + zz ); + mat->matrix[1][0] = 2 * ( xy - zw ); + mat->matrix[2][0] = 2 * ( xz + yw ); + + mat->matrix[0][1] = 2 * ( xy + zw ); + mat->matrix[1][1] = 1 - 2 * ( xx + zz ); + mat->matrix[2][1] = 2 * ( yz - xw ); + + mat->matrix[0][2] = 2 * ( xz - yw ); + mat->matrix[1][2] = 2 * ( yz + xw ); + mat->matrix[2][2] = 1 - 2 * ( xx + yy ); + + mat->matrix[0][3] = mat->matrix[1][3] = mat->matrix[2][3] = 0; +} + +// nasty little matrix multiply going on here.. +void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in) +{ + // first row of out + out->matrix[0][0] = (in2->matrix[0][0] * in->matrix[0][0]) + (in2->matrix[0][1] * in->matrix[1][0]) + (in2->matrix[0][2] * in->matrix[2][0]); + out->matrix[0][1] = (in2->matrix[0][0] * in->matrix[0][1]) + (in2->matrix[0][1] * in->matrix[1][1]) + (in2->matrix[0][2] * in->matrix[2][1]); + out->matrix[0][2] = (in2->matrix[0][0] * in->matrix[0][2]) + (in2->matrix[0][1] * in->matrix[1][2]) + (in2->matrix[0][2] * in->matrix[2][2]); + out->matrix[0][3] = (in2->matrix[0][0] * in->matrix[0][3]) + (in2->matrix[0][1] * in->matrix[1][3]) + (in2->matrix[0][2] * in->matrix[2][3]) + in2->matrix[0][3]; + // second row of outf out + out->matrix[1][0] = (in2->matrix[1][0] * in->matrix[0][0]) + (in2->matrix[1][1] * in->matrix[1][0]) + (in2->matrix[1][2] * in->matrix[2][0]); + out->matrix[1][1] = (in2->matrix[1][0] * in->matrix[0][1]) + (in2->matrix[1][1] * in->matrix[1][1]) + (in2->matrix[1][2] * in->matrix[2][1]); + out->matrix[1][2] = (in2->matrix[1][0] * in->matrix[0][2]) + (in2->matrix[1][1] * in->matrix[1][2]) + (in2->matrix[1][2] * in->matrix[2][2]); + out->matrix[1][3] = (in2->matrix[1][0] * in->matrix[0][3]) + (in2->matrix[1][1] * in->matrix[1][3]) + (in2->matrix[1][2] * in->matrix[2][3]) + in2->matrix[1][3]; + // third row of out out + out->matrix[2][0] = (in2->matrix[2][0] * in->matrix[0][0]) + (in2->matrix[2][1] * in->matrix[1][0]) + (in2->matrix[2][2] * in->matrix[2][0]); + out->matrix[2][1] = (in2->matrix[2][0] * in->matrix[0][1]) + (in2->matrix[2][1] * in->matrix[1][1]) + (in2->matrix[2][2] * in->matrix[2][1]); + out->matrix[2][2] = (in2->matrix[2][0] * in->matrix[0][2]) + (in2->matrix[2][1] * in->matrix[1][2]) + (in2->matrix[2][2] * in->matrix[2][2]); + out->matrix[2][3] = (in2->matrix[2][0] * in->matrix[0][3]) + (in2->matrix[2][1] * in->matrix[1][3]) + (in2->matrix[2][2] * in->matrix[2][3]) + in2->matrix[2][3]; +} + + +static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone) +{ + const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3); + + mdxaIndex_t *pIndex = (mdxaIndex_t *) ((byte*) pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); + + return pIndex->iIndex & 0x00FFFFFF; // this will cause problems for big-endian machines... ;-) +} + + +/*static inline*/ void UnCompressBone(float mat[3][4], int iBoneIndex, const mdxaHeader_t *pMDXAHeader, int iFrame) +{ + mdxaCompQuatBone_t *pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)pMDXAHeader + pMDXAHeader->ofsCompBonePool); + MC_UnCompressQuat(mat, pCompBonePool[ G2_GetBonePoolIndex( pMDXAHeader, iFrame, iBoneIndex ) ].Comp); +} + +#define DEBUG_G2_TIMING (0) +#define DEBUG_G2_TIMING_RENDER_ONLY (1) + +void G2_TimingModel(boneInfo_t &bone,int currentTime,int numFramesInFile,int ¤tFrame,int &newFrame,float &lerp) +{ + assert(bone.startFrame>=0); + assert(bone.startFrame<=numFramesInFile); + assert(bone.endFrame>=0); + assert(bone.endFrame<=numFramesInFile); + + // yes - add in animation speed to current frame + float animSpeed = bone.animSpeed; + float time; + if (bone.pauseTime) + { + time = (bone.pauseTime - bone.startTime) / 50.0f; + } + else + { + time = (currentTime - bone.startTime) / 50.0f; + } + if (time<0.0f) + { + time=0.0f; + } + float newFrame_g = bone.startFrame + (time * animSpeed); + + int animSize = bone.endFrame - bone.startFrame; + float endFrame = (float)bone.endFrame; + // we are supposed to be animating right? + if (animSize) + { + // did we run off the end? + if (((animSpeed > 0.0f) && (newFrame_g > endFrame - 1)) || + ((animSpeed < 0.0f) && (newFrame_g < endFrame+1))) + { + // yep - decide what to do + if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) + { + // get our new animation frame back within the bounds of the animation set + if (animSpeed < 0.0f) + { + // we don't use this case, or so I am told + // if we do, let me know, I need to insure the mod works + + // should we be creating a virtual frame? + if ((newFrame_g < endFrame+1) && (newFrame_g >= endFrame)) + { + // now figure out what we are lerping between + // delta is the fraction between this frame and the next, since the new anim is always at a .0f; + lerp = float(endFrame+1)-newFrame_g; + // frames are easy to calculate + currentFrame = endFrame; + assert(currentFrame>=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&&newFrame endFrame - 1) && (newFrame_g < endFrame)) + { + // now figure out what we are lerping between + // delta is the fraction between this frame and the next, since the new anim is always at a .0f; + lerp = (newFrame_g - (int)newFrame_g); + // frames are easy to calculate + currentFrame = (int)newFrame_g; + assert(currentFrame>=0&¤tFrame=0&&newFrame= endFrame) + { + newFrame_g=endFrame+fmod(newFrame_g-endFrame,animSize)-animSize; + } + // now figure out what we are lerping between + // delta is the fraction between this frame and the next, since the new anim is always at a .0f; + lerp = (newFrame_g - (int)newFrame_g); + // frames are easy to calculate + currentFrame = (int)newFrame_g; + assert(currentFrame>=0&¤tFrame= endFrame - 1) + { + newFrame = bone.startFrame; + assert(newFrame>=0&&newFrame=0&&newFrame= bone.startFrame)) || (animSize < 10)); + } + else + { + if (((bone.flags & (BONE_ANIM_OVERRIDE_FREEZE)) == (BONE_ANIM_OVERRIDE_FREEZE))) + { + // if we are supposed to reset the default anim, then do so + if (animSpeed > 0.0f) + { + currentFrame = bone.endFrame - 1; + assert(currentFrame>=0&¤tFrame=0&¤tFrame=0&&newFrame 0.0) + { + // frames are easy to calculate + currentFrame = (int)newFrame_g; + + // figure out the difference between the two frames - we have to decide what frame and what percentage of that + // frame we want to display + lerp = (newFrame_g - currentFrame); + + assert(currentFrame>=0&¤tFrame= (int)endFrame) + { + // we only want to lerp with the first frame of the anim if we are looping + if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) + { + newFrame = bone.startFrame; + assert(newFrame>=0&&newFrame=0&&newFrame=0&&newFramebone.startFrame) + { + currentFrame=bone.startFrame; + newFrame = currentFrame; + lerp=0.0f; + } + else + { + newFrame=currentFrame-1; + // are we now on the end frame? + if (newFrame < endFrame+1) + { + // we only want to lerp with the first frame of the anim if we are looping + if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) + { + newFrame = bone.startFrame; + assert(newFrame>=0&&newFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0.0f&&lerp<=1.0f); +} + +#ifdef _RAG_PRINT_TEST +void G2_RagPrintMatrix(mdxaBone_t *mat); +#endif +//basically construct a seperate skeleton with full hierarchy to store a matrix +//off which will give us the desired settling position given the frame in the skeleton +//that should be used -rww +int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName); +int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName); +void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &matrix, const int frame) +{ + mdxaBone_t animMatrix; + mdxaSkel_t *skel; + mdxaSkel_t *pskel; + mdxaSkelOffsets_t *offsets; + int parent; + int bListIndex; + int parentBlistIndex; +#ifdef _RAG_PRINT_TEST + bool actuallySet = false; +#endif + + assert(ghoul2.mBoneCache); + assert(ghoul2.animModel); + + offsets = (mdxaSkelOffsets_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + + //find/add the bone in the list + if (!skel->name || !skel->name[0]) + { + bListIndex = -1; + } + else + { + bListIndex = G2_Find_Bone(ghoul2.animModel, ghoul2.mBlist, skel->name); + if (bListIndex == -1) + { +#ifdef _RAG_PRINT_TEST + Com_Printf("Attempting to add %s\n", skel->name); +#endif + bListIndex = G2_Add_Bone(ghoul2.animModel, ghoul2.mBlist, skel->name); + } + } + + assert(bListIndex != -1); + + boneInfo_t &bone = ghoul2.mBlist[bListIndex]; + + if (bone.hasAnimFrameMatrix == frame) + { //already calculated so just grab it + matrix = bone.animFrameMatrix; + return; + } + + //get the base matrix for the specified frame + UnCompressBone(animMatrix.matrix, boneNum, ghoul2.mBoneCache->header, frame); + + parent = skel->parent; + if (boneNum > 0 && parent > -1) + { + //recursively call to assure all parent matrices are set up + G2_RagGetAnimMatrix(ghoul2, parent, matrix, frame); + + //assign the new skel ptr for our parent + pskel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[parent]); + + //taking bone matrix for the skeleton frame and parent's animFrameMatrix into account, determine our final animFrameMatrix + if (!pskel->name || !pskel->name[0]) + { + parentBlistIndex = -1; + } + else + { + parentBlistIndex = G2_Find_Bone(ghoul2.animModel, ghoul2.mBlist, pskel->name); + if (parentBlistIndex == -1) + { + parentBlistIndex = G2_Add_Bone(ghoul2.animModel, ghoul2.mBlist, pskel->name); + } + } + + assert(parentBlistIndex != -1); + + boneInfo_t &pbone = ghoul2.mBlist[parentBlistIndex]; + + assert(pbone.hasAnimFrameMatrix == frame); //this should have been calc'd in the recursive call + + Multiply_3x4Matrix(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); + +#ifdef _RAG_PRINT_TEST + if (parentBlistIndex != -1 && bListIndex != -1) + { + actuallySet = true; + } + else + { + Com_Printf("BAD LIST INDEX: %s, %s [%i]\n", skel->name, pskel->name, parent); + } +#endif + } + else + { //root + Multiply_3x4Matrix(&bone.animFrameMatrix, &ghoul2.mBoneCache->rootMatrix, &animMatrix); +#ifdef _RAG_PRINT_TEST + if (bListIndex != -1) + { + actuallySet = true; + } + else + { + Com_Printf("BAD LIST INDEX: %s\n", skel->name); + } +#endif + //bone.animFrameMatrix = ghoul2.mBoneCache->mFinalBones[boneNum].boneMatrix; + //Maybe use this for the root, so that the orientation is in sync with the current + //root matrix? However this would require constant recalculation of this base + //skeleton which I currently do not want. + } + + //never need to figure it out again + bone.hasAnimFrameMatrix = frame; + +#ifdef _RAG_PRINT_TEST + if (!actuallySet) + { + Com_Printf("SET FAILURE\n"); + G2_RagPrintMatrix(&bone.animFrameMatrix); + } +#endif + + matrix = bone.animFrameMatrix; +} + +void G2_TransformBone (int child,CBoneCache &BC) +{ + SBoneCalc &TB=BC.mBones[child]; + static mdxaBone_t tbone[6]; +// mdxaFrame_t *aFrame=0; +// mdxaFrame_t *bFrame=0; +// mdxaFrame_t *aoldFrame=0; +// mdxaFrame_t *boldFrame=0; + static mdxaSkel_t *skel; + static mdxaSkelOffsets_t *offsets; + boneInfo_v &boneList = *BC.rootBoneList; + static int j, boneListIndex; + int angleOverride = 0; + +#if DEBUG_G2_TIMING + bool printTiming=false; +#endif + // should this bone be overridden by a bone in the bone list? + boneListIndex = G2_Find_Bone_In_List(boneList, child); + if (boneListIndex != -1) + { + // we found a bone in the list - we need to override something here. + + // do we override the rotational angles? + if ((boneList[boneListIndex].flags) & (BONE_ANGLES_TOTAL)) + { + angleOverride = (boneList[boneListIndex].flags) & (BONE_ANGLES_TOTAL); + } + + // set blending stuff if we need to + if (boneList[boneListIndex].flags & BONE_ANIM_BLEND) + { + float blendTime = BC.incomingTime - boneList[boneListIndex].blendStart; + // only set up the blend anim if we actually have some blend time left on this bone anim - otherwise we might corrupt some blend higher up the hiearchy + if (blendTime>=0.0f&&blendTime < boneList[boneListIndex].blendTime) + { + TB.blendFrame = boneList[boneListIndex].blendFrame; + TB.blendOldFrame = boneList[boneListIndex].blendLerpFrame; + TB.blendLerp = (blendTime / boneList[boneListIndex].blendTime); + TB.blendMode = true; + } + else + { + TB.blendMode = false; + } + } + else if (/*r_Ghoul2NoBlend->integer||*/((boneList[boneListIndex].flags) & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE))) + // turn off blending if we are just doing a straing animation override + { + TB.blendMode = false; + } + + // should this animation be overridden by an animation in the bone list? + if ((boneList[boneListIndex].flags) & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) + { + G2_TimingModel(boneList[boneListIndex],BC.incomingTime,BC.header->numFrames,TB.currentFrame,TB.newFrame,TB.backlerp); + } +#if DEBUG_G2_TIMING + printTiming=true; +#endif + /* + if ((r_Ghoul2NoLerp->integer)||((boneList[boneListIndex].flags) & (BONE_ANIM_NO_LERP))) + { + TB.backlerp = 0.0f; + } + */ + //rwwFIXMEFIXME: Use? + } + // figure out where the location of the bone animation data is + assert(TB.newFrame>=0&&TB.newFramenumFrames); + if (!(TB.newFrame>=0&&TB.newFramenumFrames)) + { + TB.newFrame=0; + } +// aFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.newFrame * BC.frameSize ); + assert(TB.currentFrame>=0&&TB.currentFramenumFrames); + if (!(TB.currentFrame>=0&&TB.currentFramenumFrames)) + { + TB.currentFrame=0; + } +// aoldFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.currentFrame * BC.frameSize ); + + // figure out where the location of the blended animation data is + assert(!(TB.blendFrame < 0.0 || TB.blendFrame >= (BC.header->numFrames+1))); + if (TB.blendFrame < 0.0 || TB.blendFrame >= (BC.header->numFrames+1) ) + { + TB.blendFrame=0.0; + } +// bFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + (int)TB.blendFrame * BC.frameSize ); + assert(TB.blendOldFrame>=0&&TB.blendOldFramenumFrames); + if (!(TB.blendOldFrame>=0&&TB.blendOldFramenumFrames)) + { + TB.blendOldFrame=0; + } +#if DEBUG_G2_TIMING + +#if DEBUG_G2_TIMING_RENDER_ONLY + if (!HackadelicOnClient) + { + printTiming=false; + } +#endif + if (printTiming) + { + char mess[1000]; + if (TB.blendMode) + { + sprintf(mess,"b %2d %5d %4d %4d %4d %4d %f %f\n",boneListIndex,BC.incomingTime,(int)TB.newFrame,(int)TB.currentFrame,(int)TB.blendFrame,(int)TB.blendOldFrame,TB.backlerp,TB.blendLerp); + } + else + { + sprintf(mess,"a %2d %5d %4d %4d %f\n",boneListIndex,BC.incomingTime,TB.newFrame,TB.currentFrame,TB.backlerp); + } + Com_OPrintf("%s",mess); + const boneInfo_t &bone=boneList[boneListIndex]; + if (bone.flags&BONE_ANIM_BLEND) + { + sprintf(mess," bfb[%2d] %5d %5d (%5d-%5d) %4.2f %4x bt(%5d-%5d) %7.2f %5d\n", + boneListIndex, + BC.incomingTime, + bone.startTime, + bone.startFrame, + bone.endFrame, + bone.animSpeed, + bone.flags, + bone.blendStart, + bone.blendStart+bone.blendTime, + bone.blendFrame, + bone.blendLerpFrame + ); + } + else + { + sprintf(mess," bfa[%2d] %5d %5d (%5d-%5d) %4.2f %4x\n", + boneListIndex, + BC.incomingTime, + bone.startTime, + bone.startFrame, + bone.endFrame, + bone.animSpeed, + bone.flags + ); + } +// Com_OPrintf("%s",mess); + } +#endif +// boldFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.blendOldFrame * BC.frameSize ); + +// mdxaCompBone_t *compBonePointer = (mdxaCompBone_t *)((byte *)BC.header + BC.header->ofsCompBonePool); + + assert(child>=0&&childnumBones); +// assert(bFrame->boneIndexes[child]>=0); +// assert(boldFrame->boneIndexes[child]>=0); +// assert(aFrame->boneIndexes[child]>=0); +// assert(aoldFrame->boneIndexes[child]>=0); + + // decide where the transformed bone is going + + // are we blending with another frame of anim? + if (TB.blendMode) + { + float backlerp = TB.blendFrame - (int)TB.blendFrame; + float frontlerp = 1.0 - backlerp; + +// MC_UnCompress(tbone[3].matrix,compBonePointer[bFrame->boneIndexes[child]].Comp); +// MC_UnCompress(tbone[4].matrix,compBonePointer[boldFrame->boneIndexes[child]].Comp); + UnCompressBone(tbone[3].matrix, child, BC.header, TB.blendFrame); + UnCompressBone(tbone[4].matrix, child, BC.header, TB.blendOldFrame); + + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&tbone[5])[j] = (backlerp * ((float *)&tbone[3])[j]) + + (frontlerp * ((float *)&tbone[4])[j]); + } + } + + // + // lerp this bone - use the temp space on the ref entity to put the bone transforms into + // + if (!TB.backlerp) + { +// MC_UnCompress(tbone[2].matrix,compBonePointer[aoldFrame->boneIndexes[child]].Comp); + UnCompressBone(tbone[2].matrix, child, BC.header, TB.currentFrame); + + // blend in the other frame if we need to + if (TB.blendMode) + { + float blendFrontlerp = 1.0 - TB.blendLerp; + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&tbone[2])[j] = (TB.blendLerp * ((float *)&tbone[2])[j]) + + (blendFrontlerp * ((float *)&tbone[5])[j]); + } + } + + if (!child) + { + // now multiply by the root matrix, so we can offset this model should we need to + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &tbone[2]); + } + } + else + { + float frontlerp = 1.0 - TB.backlerp; +// MC_UnCompress(tbone[0].matrix,compBonePointer[aFrame->boneIndexes[child]].Comp); +// MC_UnCompress(tbone[1].matrix,compBonePointer[aoldFrame->boneIndexes[child]].Comp); + UnCompressBone(tbone[0].matrix, child, BC.header, TB.newFrame); + UnCompressBone(tbone[1].matrix, child, BC.header, TB.currentFrame); + + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&tbone[2])[j] = (TB.backlerp * ((float *)&tbone[0])[j]) + + (frontlerp * ((float *)&tbone[1])[j]); + } + + // blend in the other frame if we need to + if (TB.blendMode) + { + float blendFrontlerp = 1.0 - TB.blendLerp; + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&tbone[2])[j] = (TB.blendLerp * ((float *)&tbone[2])[j]) + + (blendFrontlerp * ((float *)&tbone[5])[j]); + } + } + + if (!child) + { + // now multiply by the root matrix, so we can offset this model should we need to + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &tbone[2]); + } + } + // figure out where the bone hirearchy info is + offsets = (mdxaSkelOffsets_t *)((byte *)BC.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)BC.header + sizeof(mdxaHeader_t) + offsets->offsets[child]); +// skel = BC.mSkels[child]; + //rww - removed mSkels + + int parent=BC.mFinalBones[child].parent; + assert((parent==-1&&child==0)||(parent>=0&&parent<(int)BC.mBones.size())); + if (angleOverride & BONE_ANGLES_REPLACE) + { + bool isRag=!!(angleOverride & BONE_ANGLES_RAGDOLL); + if (!isRag) + { //do the same for ik.. I suppose. + isRag = !!(angleOverride & BONE_ANGLES_IK); + } + + mdxaBone_t &bone = BC.mFinalBones[child].boneMatrix; + boneInfo_t &boneOverride = boneList[boneListIndex]; + + if (isRag) + { + mdxaBone_t temp, firstPass; + // give us the matrix the animation thinks we should have, so we can get the correct X&Y coors + Multiply_3x4Matrix(&firstPass, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); + // this is crazy, we are gonna drive the animation to ID while we are doing post mults to compensate. + Multiply_3x4Matrix(&temp,&firstPass, &skel->BasePoseMat); + float matrixScale = VectorLength((float*)&temp); + static mdxaBone_t toMatrix = + { + { + { 1.0f, 0.0f, 0.0f, 0.0f }, + { 0.0f, 1.0f, 0.0f, 0.0f }, + { 0.0f, 0.0f, 1.0f, 0.0f } + } + }; + toMatrix.matrix[0][0]=matrixScale; + toMatrix.matrix[1][1]=matrixScale; + toMatrix.matrix[2][2]=matrixScale; + toMatrix.matrix[0][3]=temp.matrix[0][3]; + toMatrix.matrix[1][3]=temp.matrix[1][3]; + toMatrix.matrix[2][3]=temp.matrix[2][3]; + + Multiply_3x4Matrix(&temp, &toMatrix,&skel->BasePoseMatInv); //dest first arg + + float blendTime = BC.incomingTime - boneList[boneListIndex].boneBlendStart; + float blendLerp = (blendTime / boneList[boneListIndex].boneBlendTime); + if (blendLerp>0.0f) + { + // has started + if (blendLerp>1.0f) + { + // done +// Multiply_3x4Matrix(&bone, &BC.mFinalBones[parent].boneMatrix,&temp); + memcpy (&bone,&temp, sizeof(mdxaBone_t)); + } + else + { +// mdxaBone_t lerp; + // now do the blend into the destination + float blendFrontlerp = 1.0 - blendLerp; + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&bone)[j] = (blendLerp * ((float *)&temp)[j]) + + (blendFrontlerp * ((float *)&tbone[2])[j]); + } +// Multiply_3x4Matrix(&bone, &BC.mFinalBones[parent].boneMatrix,&lerp); + } + } + } + else + { + mdxaBone_t temp, firstPass; + + // give us the matrix the animation thinks we should have, so we can get the correct X&Y coors + Multiply_3x4Matrix(&firstPass, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); + + // are we attempting to blend with the base animation? and still within blend time? + if (boneOverride.boneBlendTime && (((boneOverride.boneBlendTime + boneOverride.boneBlendStart) < BC.incomingTime))) + { + // ok, we are supposed to be blending. Work out lerp + float blendTime = BC.incomingTime - boneList[boneListIndex].boneBlendStart; + float blendLerp = (blendTime / boneList[boneListIndex].boneBlendTime); + + if (blendLerp <= 1) + { + if (blendLerp < 0) + { + assert(0); + } + + // now work out the matrix we want to get *to* - firstPass is where we are coming *from* + Multiply_3x4Matrix(&temp, &firstPass, &skel->BasePoseMat); + + float matrixScale = VectorLength((float*)&temp); + + mdxaBone_t newMatrixTemp; + + if (HackadelicOnClient) + { + for (int i=0; i<3;i++) + { + for(int x=0;x<3; x++) + { + newMatrixTemp.matrix[i][x] = boneOverride.newMatrix.matrix[i][x]*matrixScale; + } + } + + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; + } + else + { + for (int i=0; i<3;i++) + { + for(int x=0;x<3; x++) + { + newMatrixTemp.matrix[i][x] = boneOverride.matrix.matrix[i][x]*matrixScale; + } + } + + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; + } + + Multiply_3x4Matrix(&temp, &newMatrixTemp,&skel->BasePoseMatInv); + + // now do the blend into the destination + float blendFrontlerp = 1.0 - blendLerp; + for ( j = 0 ; j < 12 ; j++ ) + { + ((float *)&bone)[j] = (blendLerp * ((float *)&temp)[j]) + + (blendFrontlerp * ((float *)&firstPass)[j]); + } + } + else + { + bone = firstPass; + } + } + // no, so just override it directly + else + { + + Multiply_3x4Matrix(&temp,&firstPass, &skel->BasePoseMat); + float matrixScale = VectorLength((float*)&temp); + + mdxaBone_t newMatrixTemp; + + if (HackadelicOnClient) + { + for (int i=0; i<3;i++) + { + for(int x=0;x<3; x++) + { + newMatrixTemp.matrix[i][x] = boneOverride.newMatrix.matrix[i][x]*matrixScale; + } + } + + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; + } + else + { + for (int i=0; i<3;i++) + { + for(int x=0;x<3; x++) + { + newMatrixTemp.matrix[i][x] = boneOverride.matrix.matrix[i][x]*matrixScale; + } + } + + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; + } + + Multiply_3x4Matrix(&bone, &newMatrixTemp,&skel->BasePoseMatInv); + } + } + } + else if (angleOverride & BONE_ANGLES_PREMULT) + { + if ((angleOverride&BONE_ANGLES_RAGDOLL) || (angleOverride&BONE_ANGLES_IK)) + { + mdxaBone_t tmp; + if (!child) + { + if (HackadelicOnClient) + { + Multiply_3x4Matrix(&tmp, &BC.rootMatrix, &boneList[boneListIndex].newMatrix); + } + else + { + Multiply_3x4Matrix(&tmp, &BC.rootMatrix, &boneList[boneListIndex].matrix); + } + } + else + { + if (HackadelicOnClient) + { + Multiply_3x4Matrix(&tmp, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].newMatrix); + } + else + { + Multiply_3x4Matrix(&tmp, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].matrix); + } + } + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix,&tmp, &tbone[2]); + } + else + { + if (!child) + { + // use the in coming root matrix as our basis + if (HackadelicOnClient) + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &boneList[boneListIndex].newMatrix); + } + else + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &boneList[boneListIndex].matrix); + } + } + else + { + // convert from 3x4 matrix to a 4x4 matrix + if (HackadelicOnClient) + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].newMatrix); + } + else + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].matrix); + } + } + } + } + else + // now transform the matrix by it's parent, asumming we have a parent, and we aren't overriding the angles absolutely + if (child) + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); + } + + // now multiply our resulting bone by an override matrix should we need to + if (angleOverride & BONE_ANGLES_POSTMULT) + { + mdxaBone_t tempMatrix; + memcpy (&tempMatrix,&BC.mFinalBones[child].boneMatrix, sizeof(mdxaBone_t)); + if (HackadelicOnClient) + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &tempMatrix, &boneList[boneListIndex].newMatrix); + } + else + { + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &tempMatrix, &boneList[boneListIndex].matrix); + } + } + /* + if (r_Ghoul2UnSqash->integer) + { + mdxaBone_t tempMatrix; + Multiply_3x4Matrix(&tempMatrix,&BC.mFinalBones[child].boneMatrix, &skel->BasePoseMat); + float maxl; + maxl=VectorLength(&skel->BasePoseMat.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[0][0]); + VectorNormalize(&tempMatrix.matrix[1][0]); + VectorNormalize(&tempMatrix.matrix[2][0]); + + VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); + VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); + VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); + Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix,&tempMatrix,&skel->BasePoseMatInv); + } + */ + //rwwFIXMEFIXME: Care? + +} + +void G2_SetUpBolts( mdxaHeader_t *header, CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, boltInfo_v &boltList) +{ + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + + for (size_t i=0; ioffsets[boltList[i].boneNumber]); + Multiply_3x4Matrix(&boltList[i].position, &bonePtr[boltList[i].boneNumber].second, &skel->BasePoseMat); + } + } +} + +//rww - RAGDOLL_BEGIN +#define GHOUL2_RAG_STARTED 0x0010 +//rww - RAGDOLL_END +//rwwFIXMEFIXME: Move this into the stupid header or something. + +void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGhoul2Info &ghoul2, int time,bool smooth=true) +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_G2_TransformGhoulBones.Start(); + G2PerformanceCounter_G2_TransformGhoulBones++; +#endif + + /* + model_t *currentModel; + model_t *animModel; + mdxaHeader_t *aHeader; + + //currentModel = R_GetModelByHandle(RE_RegisterModel(ghoul2.mFileName)); + currentModel = R_GetModelByHandle(ghoul2.mModel); + assert(currentModel); + assert(currentModel->mdxm); + + animModel = R_GetModelByHandle(currentModel->mdxm->animIndex); + assert(animModel); + aHeader = animModel->mdxa; + assert(aHeader); + */ + model_t *currentModel = (model_t *)ghoul2.currentModel; + mdxaHeader_t *aHeader = (mdxaHeader_t *)ghoul2.aHeader; + + + assert(ghoul2.aHeader); + assert(ghoul2.currentModel); + assert(ghoul2.currentModel->mdxm); + if (!aHeader->numBones) + { + assert(0); // this would be strange + return; + } + if (!ghoul2.mBoneCache) + { + ghoul2.mBoneCache=new CBoneCache(currentModel,aHeader); + +#ifdef _FULL_G2_LEAK_CHECKING + g_Ghoul2Allocations += sizeof(*ghoul2.mBoneCache); +#endif + } + ghoul2.mBoneCache->mod=currentModel; + ghoul2.mBoneCache->header=aHeader; + assert(ghoul2.mBoneCache->mBones.size()==(unsigned)aHeader->numBones); + + ghoul2.mBoneCache->mSmoothingActive=false; + ghoul2.mBoneCache->mUnsquash=false; + + // master smoothing control + if (HackadelicOnClient && smooth && !ri->Cvar_VariableIntegerValue( "dedicated" )) + { + ghoul2.mBoneCache->mLastTouch=ghoul2.mBoneCache->mLastLastTouch; + /* + float val=r_Ghoul2AnimSmooth->value; + if (smooth&&val>0.0f&&val<1.0f) + { + // if (HackadelicOnClient) + // { + ghoul2.mBoneCache->mLastTouch=ghoul2.mBoneCache->mLastLastTouch; + // } + + ghoul2.mBoneCache->mSmoothFactor=val; + ghoul2.mBoneCache->mSmoothingActive=true; + if (r_Ghoul2UnSqashAfterSmooth->integer) + { + ghoul2.mBoneCache->mUnsquash=true; + } + } + else + { + ghoul2.mBoneCache->mSmoothFactor=1.0f; + } + */ + + // master smoothing control + float val=r_Ghoul2AnimSmooth->value; + if (val>0.0f&&val<1.0f) + { + //if (ghoul2.mFlags&GHOUL2_RESERVED_FOR_RAGDOLL) +#if 1 + if(ghoul2.mFlags & GHOUL2_CRAZY_SMOOTH) + { + val = 0.9f; + } + else if(ghoul2.mFlags & GHOUL2_RAG_STARTED) + { + for (size_t k=0;ktime-250 && + bone.firstCollisionTime time) + { + val = 0.2f; + } + else + { + val = 0.8f; + } + break; + } + } + } +#endif + +// ghoul2.mBoneCache->mSmoothFactor=(val + 1.0f-pow(1.0f-val,50.0f/dif))/2.0f; // meaningless formula + ghoul2.mBoneCache->mSmoothFactor=val; // meaningless formula + ghoul2.mBoneCache->mSmoothingActive=true; + + if (r_Ghoul2UnSqashAfterSmooth->integer) + { + ghoul2.mBoneCache->mUnsquash=true; + } + } + } + else + { + ghoul2.mBoneCache->mSmoothFactor=1.0f; + } + + ghoul2.mBoneCache->mCurrentTouch++; + +//rww - RAGDOLL_BEGIN + if (HackadelicOnClient) + { + ghoul2.mBoneCache->mLastLastTouch=ghoul2.mBoneCache->mCurrentTouch; + ghoul2.mBoneCache->mCurrentTouchRender=ghoul2.mBoneCache->mCurrentTouch; + } + else + { + ghoul2.mBoneCache->mCurrentTouchRender=0; + } +//rww - RAGDOLL_END + + ghoul2.mBoneCache->frameSize = 0;// can be deleted in new G2 format //(size_t)( &((mdxaFrame_t *)0)->boneIndexes[ ghoul2.aHeader->numBones ] ); + + ghoul2.mBoneCache->rootBoneList=&rootBoneList; + ghoul2.mBoneCache->rootMatrix=rootMatrix; + ghoul2.mBoneCache->incomingTime=time; + + SBoneCalc &TB=ghoul2.mBoneCache->Root(); + TB.newFrame=0; + TB.currentFrame=0; + TB.backlerp=0.0f; + TB.blendFrame=0; + TB.blendOldFrame=0; + TB.blendMode=false; + TB.blendLerp=0; + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_G2_TransformGhoulBones += G2PerformanceTimer_G2_TransformGhoulBones.End(); +#endif +} + + +#define MDX_TAG_ORIGIN 2 + +//====================================================================== +// +// Surface Manipulation code + + +// We've come across a surface that's designated as a bolt surface, process it and put it in the appropriate bolt place +void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int boltNum, boltInfo_v &boltList, surfaceInfo_t *surfInfo, model_t *mod) +{ + mdxmVertex_t *v, *vert0, *vert1, *vert2; + vec3_t axes[3], sides[3]; + float pTri[3][3], d; + int j, k; + + // now there are two types of tag surface - model ones and procedural generated types - lets decide which one we have here. + if (surfInfo && surfInfo->offFlags == G2SURFACEFLAG_GENERATED) + { + int surfNumber = surfInfo->genPolySurfaceIndex & 0x0ffff; + int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; + + // find original surface our original poly was in. + mdxmSurface_t *originalSurf = (mdxmSurface_t *)G2_FindSurface((void*)mod, surfNumber, surfInfo->genLod); + mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); + + // get the original polys indexes + int index0 = originalTriangleIndexes[polyNumber].indexes[0]; + int index1 = originalTriangleIndexes[polyNumber].indexes[1]; + int index2 = originalTriangleIndexes[polyNumber].indexes[2]; + + // decide where the original verts are + + vert0 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert0+= index0; + + vert1 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert1+= index1; + + vert2 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert2+= index2; + + // clear out the triangle verts to be + VectorClear( pTri[0] ); + VectorClear( pTri[1] ); + VectorClear( pTri[2] ); + +// mdxmWeight_t *w; + + int *piBoneRefs = (int*) ((byte*)originalSurf + originalSurf->ofsBoneReferences); + + // now go and transform just the points we need from the surface that was hit originally +// w = vert0->weights; + float fTotalWeight = 0.0f; + int iNumWeights = G2_GetVertWeights( vert0 ); + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( vert0, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert0, k, fTotalWeight, iNumWeights ); + + pTri[0][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); + pTri[0][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); + pTri[0][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + } +// w = vert1->weights; + fTotalWeight = 0.0f; + iNumWeights = G2_GetVertWeights( vert1 ); + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( vert1, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert1, k, fTotalWeight, iNumWeights ); + + pTri[1][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); + pTri[1][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); + pTri[1][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + } +// w = vert2->weights; + fTotalWeight = 0.0f; + iNumWeights = G2_GetVertWeights( vert2 ); + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( vert2, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert2, k, fTotalWeight, iNumWeights ); + + pTri[2][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); + pTri[2][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); + pTri[2][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + } + + vec3_t normal; + vec3_t up; + vec3_t right; + vec3_t vec0, vec1; + // work out baryCentricK + float baryCentricK = 1.0 - (surfInfo->genBarycentricI + surfInfo->genBarycentricJ); + + // now we have the model transformed into model space, now generate an origin. + boltList[boltNum].position.matrix[0][3] = (pTri[0][0] * surfInfo->genBarycentricI) + (pTri[1][0] * surfInfo->genBarycentricJ) + (pTri[2][0] * baryCentricK); + boltList[boltNum].position.matrix[1][3] = (pTri[0][1] * surfInfo->genBarycentricI) + (pTri[1][1] * surfInfo->genBarycentricJ) + (pTri[2][1] * baryCentricK); + boltList[boltNum].position.matrix[2][3] = (pTri[0][2] * surfInfo->genBarycentricI) + (pTri[1][2] * surfInfo->genBarycentricJ) + (pTri[2][2] * baryCentricK); + + // generate a normal to this new triangle + VectorSubtract(pTri[0], pTri[1], vec0); + VectorSubtract(pTri[2], pTri[1], vec1); + + CrossProduct(vec0, vec1, normal); + VectorNormalize(normal); + + // forward vector + boltList[boltNum].position.matrix[0][0] = normal[0]; + boltList[boltNum].position.matrix[1][0] = normal[1]; + boltList[boltNum].position.matrix[2][0] = normal[2]; + + // up will be towards point 0 of the original triangle. + // so lets work it out. Vector is hit point - point 0 + up[0] = boltList[boltNum].position.matrix[0][3] - pTri[0][0]; + up[1] = boltList[boltNum].position.matrix[1][3] - pTri[0][1]; + up[2] = boltList[boltNum].position.matrix[2][3] - pTri[0][2]; + + // normalise it + VectorNormalize(up); + + // that's the up vector + boltList[boltNum].position.matrix[0][1] = up[0]; + boltList[boltNum].position.matrix[1][1] = up[1]; + boltList[boltNum].position.matrix[2][1] = up[2]; + + // right is always straight + + CrossProduct( normal, up, right ); + // that's the up vector + boltList[boltNum].position.matrix[0][2] = right[0]; + boltList[boltNum].position.matrix[1][2] = right[1]; + boltList[boltNum].position.matrix[2][2] = right[2]; + + + } + // no, we are looking at a normal model tag + else + { + int *piBoneRefs = (int*) ((byte*)surface + surface->ofsBoneReferences); + + // whip through and actually transform each vertex + v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); + for ( j = 0; j < 3; j++ ) + { +// mdxmWeight_t *w; + + VectorClear( pTri[j] ); + // w = v->weights; + + const int iNumWeights = G2_GetVertWeights( v ); + float fTotalWeight = 0.0f; + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( v, k ); + float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + + //bone = bonePtr + piBoneRefs[w->boneIndex]; + pTri[j][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); + pTri[j][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); + pTri[j][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + } + + v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; + } + + // clear out used arrays + memset( axes, 0, sizeof( axes ) ); + memset( sides, 0, sizeof( sides ) ); + + // work out actual sides of the tag triangle + for ( j = 0; j < 3; j++ ) + { + sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0]; + sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1]; + sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2]; + } + + // do math trig to work out what the matrix will be from this triangle's translated position + VectorNormalize2( sides[iG2_TRISIDE_LONGEST], axes[0] ); + VectorNormalize2( sides[iG2_TRISIDE_SHORTEST], axes[1] ); + + // project shortest side so that it is exactly 90 degrees to the longer side + d = DotProduct( axes[0], axes[1] ); + VectorMA( axes[0], -d, axes[1], axes[0] ); + VectorNormalize2( axes[0], axes[0] ); + + CrossProduct( sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2] ); + VectorNormalize2( axes[2], axes[2] ); + + // set up location in world space of the origin point in out going matrix + boltList[boltNum].position.matrix[0][3] = pTri[MDX_TAG_ORIGIN][0]; + boltList[boltNum].position.matrix[1][3] = pTri[MDX_TAG_ORIGIN][1]; + boltList[boltNum].position.matrix[2][3] = pTri[MDX_TAG_ORIGIN][2]; + + // copy axis to matrix - do some magic to orient minus Y to positive X and so on so bolt on stuff is oriented correctly + boltList[boltNum].position.matrix[0][0] = axes[1][0]; + boltList[boltNum].position.matrix[0][1] = axes[0][0]; + boltList[boltNum].position.matrix[0][2] = -axes[2][0]; + + boltList[boltNum].position.matrix[1][0] = axes[1][1]; + boltList[boltNum].position.matrix[1][1] = axes[0][1]; + boltList[boltNum].position.matrix[1][2] = -axes[2][1]; + + boltList[boltNum].position.matrix[2][0] = axes[1][2]; + boltList[boltNum].position.matrix[2][1] = axes[0][2]; + boltList[boltNum].position.matrix[2][2] = -axes[2][2]; + } + +} + + +// now go through all the generated surfaces that aren't included in the model surface hierarchy and create the correct bolt info for them +void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, model_t *mod_t) +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts.Start(); +#endif + // look through the surfaces off the end of the pre-defined model surfaces + for (size_t i=0; i< ghoul2.mSlist.size(); i++) + { + // only look for bolts if we are actually a generated surface, and not just an overriden one + if (ghoul2.mSlist[i].offFlags & G2SURFACEFLAG_GENERATED) + { + // well alrighty then. Lets see if there is a bolt that is attempting to use it + int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, i, G2SURFACEFLAG_GENERATED); + // yes - ok, processing time. + if (boltNum != -1) + { + G2_ProcessSurfaceBolt(bonePtr, NULL, boltNum, ghoul2.mBltlist, &ghoul2.mSlist[i], mod_t); + } + } + } +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_G2_ProcessGeneratedSurfaceBolts += G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts.End(); +#endif +} + +void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from SP. +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_RenderSurfaces.Start(); +#endif + int i; + const shader_t *shader = 0; + int offFlags = 0; +#ifdef _G2_GORE + bool drawGore = true; +#endif + + assert(RS.currentModel); + assert(RS.currentModel->mdxm); + // back track and get the surfinfo struct for this surface + mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + + // see if we have an override surface in the surface list + const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(RS.surfaceNum, RS.rootSList); + + // really, we should use the default flags for this surface unless it's been overriden + offFlags = surfInfo->flags; + + // set the off flags if we have some + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + + // if this surface is not off, add it to the shader render list + if (!offFlags) + { + if ( RS.cust_shader ) + { + shader = RS.cust_shader; + } + else if ( RS.skin ) + { + int j; + + // match the surface name to something in the skin file + shader = tr.defaultShader; + for ( j = 0 ; j < RS.skin->numSurfaces ; j++ ) + { + // the names have both been lowercased + if ( !strcmp( RS.skin->surfaces[j]->name, surfInfo->name ) ) + { + shader = (shader_t*)RS.skin->surfaces[j]->shader; + break; + } + } + } + else + { + shader = R_GetShaderByHandle( surfInfo->shaderIndex ); + } + + //rww - catch surfaces with bad shaders + //assert(shader != tr.defaultShader); + //Alright, this is starting to annoy me because of the state of the assets. Disabling for now. + // we will add shadows even if the main object isn't visible in the view + // stencil shadows can't do personal models unless I polyhedron clip + //using z-fail now so can do personal models -rww + if ( /*!RS.personalModel + && */r_shadows->integer == 2 +// && RS.fogNum == 0 + && (RS.renderfx & RF_SHADOW_PLANE ) + && !(RS.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) + && shader->sort == SS_OPAQUE ) + { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out + CRenderableSurface *newSurf = new CRenderableSurface; + if (surface->numVerts >= SHADER_MAX_VERTEXES/2) + { //we need numVerts*2 xyz slots free in tess to do shadow, if this surf is going to exceed that then let's try the lowest lod -rww + mdxmSurface_t *lowsurface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.currentModel->numLods-1); + newSurf->surfaceData = lowsurface; + } + else + { + newSurf->surfaceData = surface; + } + newSurf->boneCache = RS.boneCache; + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse ); + } + + // projection shadows work fine with personal models + if ( r_shadows->integer == 3 +// && RS.fogNum == 0 + && (RS.renderfx & RF_SHADOW_PLANE ) + && shader->sort == SS_OPAQUE ) + { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out + CRenderableSurface *newSurf = new CRenderableSurface; + newSurf->surfaceData = surface; + newSurf->boneCache = RS.boneCache; + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse ); + } + + // don't add third_person objects if not viewing through a portal + if ( !RS.personalModel ) + { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out + CRenderableSurface *newSurf = new CRenderableSurface; + newSurf->surfaceData = surface; + newSurf->boneCache = RS.boneCache; + R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse ); + +#ifdef _G2_GORE + if (RS.gore_set && drawGore) + { + int curTime = G2API_GetTime(tr.refdef.time); + pair::iterator,multimap::iterator> range= + RS.gore_set->mGoreRecords.equal_range(RS.surfaceNum); + multimap::iterator k,kcur; + CRenderableSurface *last=newSurf; + for (k=range.first;k!=range.second;) + { + kcur=k; + k++; + GoreTextureCoordinates *tex=FindGoreRecord((*kcur).second.mGoreTag); + if (!tex || // it is gone, lets get rid of it + (kcur->second.mDeleteTime && curTime>=kcur->second.mDeleteTime)) // out of time + { + if (tex) + { + (*tex).~GoreTextureCoordinates(); + //I don't know what's going on here, it should call the destructor for + //this when it erases the record but sometimes it doesn't. -rww + } + + RS.gore_set->mGoreRecords.erase(kcur); + } + else if (tex->tex[RS.lod]) + { + CRenderableSurface *newSurf2 = AllocRS(); + *newSurf2=*newSurf; + newSurf2->goreChain=0; + newSurf2->alternateTex=tex->tex[RS.lod]; + newSurf2->scale=1.0f; + newSurf2->fade=1.0f; + newSurf2->impactTime=1.0f; // done with + int magicFactor42=500; // ms, impact time + if (curTime>(*kcur).second.mGoreGrowStartTime && curTime<(*kcur).second.mGoreGrowStartTime+magicFactor42) + { + newSurf2->impactTime=float(curTime-(*kcur).second.mGoreGrowStartTime)/float(magicFactor42); // linear + } + if (curTime<(*kcur).second.mGoreGrowEndTime) + { + newSurf2->scale=1.0f/((curTime-(*kcur).second.mGoreGrowStartTime)*(*kcur).second.mGoreGrowFactor + (*kcur).second.mGoreGrowOffset); + if (newSurf2->scale<1.0f) + { + newSurf2->scale=1.0f; + } + } + shader_t *gshader; + if ((*kcur).second.shader) + { + gshader=R_GetShaderByHandle((*kcur).second.shader); + } + else + { + gshader=R_GetShaderByHandle(goreShader); + } + + // Set fade on surf. + //Only if we have a fade time set, and let us fade on rgb if we want -rww + if ((*kcur).second.mDeleteTime && (*kcur).second.mFadeTime) + { + if ((*kcur).second.mDeleteTime - curTime < (*kcur).second.mFadeTime) + { + newSurf2->fade=(float)((*kcur).second.mDeleteTime - curTime)/(*kcur).second.mFadeTime; + if ((*kcur).second.mFadeRGB) + { //RGB fades are scaled from 2.0f to 3.0f (simply to differentiate) + newSurf2->fade += 2.0f; + + if (newSurf2->fade < 2.01f) + { + newSurf2->fade = 2.01f; + } + } + } + } + + last->goreChain=newSurf2; + last=newSurf2; + R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse ); + } + } + } +#endif + } + } + + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren; i++) + { + RS.surfaceNum = surfInfo->childIndexes[i]; + RenderSurfaces(RS); + } + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_RenderSurfaces += G2PerformanceTimer_RenderSurfaces.End(); +#endif +} + +// Go through the model and deal with just the surfaces that are tagged as bolt on points - this is for the server side skeleton construction +void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, + mdxaBone_v &bonePtr, model_t *currentModel, int lod, boltInfo_v &boltList) +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_ProcessModelBoltSurfaces.Start(); +#endif + int i; + int offFlags = 0; + + // back track and get the surfinfo struct for this surface + mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + + // see if we have an override surface in the surface list + surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); + + // really, we should use the default flags for this surface unless it's been overriden + offFlags = surfInfo->flags; + + // set the off flags if we have some + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + + // is this surface considered a bolt surface? + if (surfInfo->flags & G2SURFACEFLAG_ISBOLT) + { + // well alrighty then. Lets see if there is a bolt that is attempting to use it + int boltNum = G2_Find_Bolt_Surface_Num(boltList, surfaceNum, 0); + // yes - ok, processing time. + if (boltNum != -1) + { + G2_ProcessSurfaceBolt(bonePtr, surface, boltNum, boltList, surfOverride, currentModel); + } + } + + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren; i++) + { + ProcessModelBoltSurfaces(surfInfo->childIndexes[i], rootSList, bonePtr, currentModel, lod, boltList); + } + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_ProcessModelBoltSurfaces += G2PerformanceTimer_ProcessModelBoltSurfaces.End(); +#endif +} + + +// build the used bone list so when doing bone transforms we can determine if we need to do it or not +void G2_ConstructUsedBoneList(CConstructBoneList &CBL) +{ + int i, j; + int offFlags = 0; + + // back track and get the surfinfo struct for this surface + const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)CBL.currentModel, CBL.surfaceNum, 0); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)CBL.currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + const model_t *mod_a = R_GetModelByHandle(CBL.currentModel->mdxm->animIndex); + const mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t)); + const mdxaSkel_t *skel, *childSkel; + + // see if we have an override surface in the surface list + const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(CBL.surfaceNum, CBL.rootSList); + + // really, we should use the default flags for this surface unless it's been overriden + offFlags = surfInfo->flags; + + // set the off flags if we have some + if (surfOverride) + { + offFlags = surfOverride->offFlags; + } + + // if this surface is not off, add it to the shader render list + if (!(offFlags & G2SURFACEFLAG_OFF)) + { + int *bonesReferenced = (int *)((byte*)surface + surface->ofsBoneReferences); + // now whip through the bones this surface uses + for (i=0; inumBoneReferences;i++) + { + int iBoneIndex = bonesReferenced[i]; + CBL.boneUsedList[iBoneIndex] = 1; + + // now go and check all the descendant bones attached to this bone and see if any have the always flag on them. If so, activate them + skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iBoneIndex]); + + // for every child bone... + for (j=0; j< skel->numChildren; j++) + { + // get the skel data struct for each child bone of the referenced bone + childSkel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[skel->children[j]]); + + // does it have the always on flag on? + if (childSkel->flags & G2BONEFLAG_ALWAYSXFORM) + { + // yes, make sure it's in the list of bones to be transformed. + CBL.boneUsedList[skel->children[j]] = 1; + } + } + + // now we need to ensure that the parents of this bone are actually active... + // + int iParentBone = skel->parent; + while (iParentBone != -1) + { + if (CBL.boneUsedList[iParentBone]) // no need to go higher + break; + CBL.boneUsedList[iParentBone] = 1; + skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); + iParentBone = skel->parent; + } + } + } + else + // if we are turning off all descendants, then stop this recursion now + if (offFlags & G2SURFACEFLAG_NODESCENDANTS) + { + return; + } + + // now recursively call for the children + for (i=0; i< surfInfo->numChildren; i++) + { + CBL.surfaceNum = surfInfo->childIndexes[i]; + G2_ConstructUsedBoneList(CBL); + } +} + + +// sort all the ghoul models in this list so if they go in reference order. This will ensure the bolt on's are attached to the right place +// on the previous model, since it ensures the model being attached to is built and rendered first. + +// NOTE!! This assumes at least one model will NOT have a parent. If it does - we are screwed +static void G2_Sort_Models(CGhoul2Info_v &ghoul2, int * const modelList, int * const modelCount) +{ + int startPoint, endPoint; + int i, boltTo, j; + + *modelCount = 0; + + // first walk all the possible ghoul2 models, and stuff the out array with those with no parents + for (i=0; i> MODEL_SHIFT) & MODEL_AND; + // is it any of the models we just added to the list? + for (j=startPoint; jmdxm); + + // point at first lod list + byte *current = (byte*)((intptr_t)mod->mdxm + (intptr_t)mod->mdxm->ofsLODs); + int i; + + //walk the lods + assert(lod>=0&&lodmdxm->numLODs); + for (i=0; iofsEnd; + } + + // avoid the lod pointer data structure + current += sizeof(mdxmLOD_t); + + mdxmLODSurfOffset_t *indexes = (mdxmLODSurfOffset_t *)current; + // we are now looking at the offset array + assert(index>=0&&indexmdxm->numSurfaces); + current += indexes->offsets[index]; + + return (void *)current; +} + +//#define G2EVALRENDER + +// We've come across a surface that's designated as a bolt surface, process it and put it in the appropriate bolt place +void G2_ProcessSurfaceBolt2(CBoneCache &boneCache, const mdxmSurface_t *surface, int boltNum, boltInfo_v &boltList, const surfaceInfo_t *surfInfo, const model_t *mod,mdxaBone_t &retMatrix) +{ + mdxmVertex_t *v, *vert0, *vert1, *vert2; + vec3_t axes[3], sides[3]; + float pTri[3][3], d; + int j, k; + + // now there are two types of tag surface - model ones and procedural generated types - lets decide which one we have here. + if (surfInfo && surfInfo->offFlags == G2SURFACEFLAG_GENERATED) + { + int surfNumber = surfInfo->genPolySurfaceIndex & 0x0ffff; + int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; + + // find original surface our original poly was in. + mdxmSurface_t *originalSurf = (mdxmSurface_t *)G2_FindSurface_BC(mod, surfNumber, surfInfo->genLod); + mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); + + // get the original polys indexes + int index0 = originalTriangleIndexes[polyNumber].indexes[0]; + int index1 = originalTriangleIndexes[polyNumber].indexes[1]; + int index2 = originalTriangleIndexes[polyNumber].indexes[2]; + + // decide where the original verts are + vert0 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert0+=index0; + + vert1 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert1+=index1; + + vert2 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); + vert2+=index2; + + // clear out the triangle verts to be + VectorClear( pTri[0] ); + VectorClear( pTri[1] ); + VectorClear( pTri[2] ); + int *piBoneReferences = (int*) ((byte*)originalSurf + originalSurf->ofsBoneReferences); + +// mdxmWeight_t *w; + + // now go and transform just the points we need from the surface that was hit originally +// w = vert0->weights; + float fTotalWeight = 0.0f; + int iNumWeights = G2_GetVertWeights( vert0 ); + for ( k = 0 ; k < iNumWeights ; k++ ) + { + int iBoneIndex = G2_GetVertBoneIndex( vert0, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert0, k, fTotalWeight, iNumWeights ); + +#ifdef G2EVALRENDER + const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); +#else + const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); +#endif + + pTri[0][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert0->vertCoords ) + bone.matrix[0][3] ); + pTri[0][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert0->vertCoords ) + bone.matrix[1][3] ); + pTri[0][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert0->vertCoords ) + bone.matrix[2][3] ); + } + +// w = vert1->weights; + fTotalWeight = 0.0f; + iNumWeights = G2_GetVertWeights( vert1 ); + for ( k = 0 ; k < iNumWeights ; k++) + { + int iBoneIndex = G2_GetVertBoneIndex( vert1, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert1, k, fTotalWeight, iNumWeights ); + +#ifdef G2EVALRENDER + const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); +#else + const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); +#endif + + pTri[1][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert1->vertCoords ) + bone.matrix[0][3] ); + pTri[1][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert1->vertCoords ) + bone.matrix[1][3] ); + pTri[1][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert1->vertCoords ) + bone.matrix[2][3] ); + } + +// w = vert2->weights; + fTotalWeight = 0.0f; + iNumWeights = G2_GetVertWeights( vert2 ); + for ( k = 0 ; k < iNumWeights ; k++) + { + int iBoneIndex = G2_GetVertBoneIndex( vert2, k ); + float fBoneWeight = G2_GetVertBoneWeight( vert2, k, fTotalWeight, iNumWeights ); + +#ifdef G2EVALRENDER + const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); +#else + const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); +#endif + + pTri[2][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert2->vertCoords ) + bone.matrix[0][3] ); + pTri[2][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert2->vertCoords ) + bone.matrix[1][3] ); + pTri[2][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert2->vertCoords ) + bone.matrix[2][3] ); + } + + vec3_t normal; + vec3_t up; + vec3_t right; + vec3_t vec0, vec1; + // work out baryCentricK + float baryCentricK = 1.0 - (surfInfo->genBarycentricI + surfInfo->genBarycentricJ); + + // now we have the model transformed into model space, now generate an origin. + retMatrix.matrix[0][3] = (pTri[0][0] * surfInfo->genBarycentricI) + (pTri[1][0] * surfInfo->genBarycentricJ) + (pTri[2][0] * baryCentricK); + retMatrix.matrix[1][3] = (pTri[0][1] * surfInfo->genBarycentricI) + (pTri[1][1] * surfInfo->genBarycentricJ) + (pTri[2][1] * baryCentricK); + retMatrix.matrix[2][3] = (pTri[0][2] * surfInfo->genBarycentricI) + (pTri[1][2] * surfInfo->genBarycentricJ) + (pTri[2][2] * baryCentricK); + + // generate a normal to this new triangle + VectorSubtract(pTri[0], pTri[1], vec0); + VectorSubtract(pTri[2], pTri[1], vec1); + + CrossProduct(vec0, vec1, normal); + VectorNormalize(normal); + + // forward vector + retMatrix.matrix[0][0] = normal[0]; + retMatrix.matrix[1][0] = normal[1]; + retMatrix.matrix[2][0] = normal[2]; + + // up will be towards point 0 of the original triangle. + // so lets work it out. Vector is hit point - point 0 + up[0] = retMatrix.matrix[0][3] - pTri[0][0]; + up[1] = retMatrix.matrix[1][3] - pTri[0][1]; + up[2] = retMatrix.matrix[2][3] - pTri[0][2]; + + // normalise it + VectorNormalize(up); + + // that's the up vector + retMatrix.matrix[0][1] = up[0]; + retMatrix.matrix[1][1] = up[1]; + retMatrix.matrix[2][1] = up[2]; + + // right is always straight + + CrossProduct( normal, up, right ); + // that's the up vector + retMatrix.matrix[0][2] = right[0]; + retMatrix.matrix[1][2] = right[1]; + retMatrix.matrix[2][2] = right[2]; + + + } + // no, we are looking at a normal model tag + else + { + // whip through and actually transform each vertex + v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); + int *piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); + for ( j = 0; j < 3; j++ ) + { +// mdxmWeight_t *w; + + VectorClear( pTri[j] ); + // w = v->weights; + + const int iNumWeights = G2_GetVertWeights( v ); + + float fTotalWeight = 0.0f; + for ( k = 0 ; k < iNumWeights ; k++) + { + int iBoneIndex = G2_GetVertBoneIndex( v, k ); + float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + +#ifdef G2EVALRENDER + const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); +#else + const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); +#endif + + pTri[j][0] += fBoneWeight * ( DotProduct( bone.matrix[0], v->vertCoords ) + bone.matrix[0][3] ); + pTri[j][1] += fBoneWeight * ( DotProduct( bone.matrix[1], v->vertCoords ) + bone.matrix[1][3] ); + pTri[j][2] += fBoneWeight * ( DotProduct( bone.matrix[2], v->vertCoords ) + bone.matrix[2][3] ); + } + + v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; + } + + // clear out used arrays + memset( axes, 0, sizeof( axes ) ); + memset( sides, 0, sizeof( sides ) ); + + // work out actual sides of the tag triangle + for ( j = 0; j < 3; j++ ) + { + sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0]; + sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1]; + sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2]; + } + + // do math trig to work out what the matrix will be from this triangle's translated position + VectorNormalize2( sides[iG2_TRISIDE_LONGEST], axes[0] ); + VectorNormalize2( sides[iG2_TRISIDE_SHORTEST], axes[1] ); + + // project shortest side so that it is exactly 90 degrees to the longer side + d = DotProduct( axes[0], axes[1] ); + VectorMA( axes[0], -d, axes[1], axes[0] ); + VectorNormalize2( axes[0], axes[0] ); + + CrossProduct( sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2] ); + VectorNormalize2( axes[2], axes[2] ); + + // set up location in world space of the origin point in out going matrix + retMatrix.matrix[0][3] = pTri[MDX_TAG_ORIGIN][0]; + retMatrix.matrix[1][3] = pTri[MDX_TAG_ORIGIN][1]; + retMatrix.matrix[2][3] = pTri[MDX_TAG_ORIGIN][2]; + + // copy axis to matrix - do some magic to orient minus Y to positive X and so on so bolt on stuff is oriented correctly + retMatrix.matrix[0][0] = axes[1][0]; + retMatrix.matrix[0][1] = axes[0][0]; + retMatrix.matrix[0][2] = -axes[2][0]; + + retMatrix.matrix[1][0] = axes[1][1]; + retMatrix.matrix[1][1] = axes[0][1]; + retMatrix.matrix[1][2] = -axes[2][1]; + + retMatrix.matrix[2][0] = axes[1][2]; + retMatrix.matrix[2][1] = axes[0][2]; + retMatrix.matrix[2][2] = -axes[2][2]; + } + +} + +void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix) +{ + if (!ghoul2.mBoneCache) + { + retMatrix=identityMatrix; + return; + } + assert(ghoul2.mBoneCache); + CBoneCache &boneCache=*ghoul2.mBoneCache; + assert(boneCache.mod); + boltInfo_v &boltList=ghoul2.mBltlist; + + //Raz: This was causing a client crash when rendering a model with no valid g2 bolts, such as Ragnos =] + if ( boltList.size() < 1 ) { + retMatrix=identityMatrix; + return; + } + + assert(boltNum>=0&&boltNum<(int)boltList.size()); +#if 0 //rwwFIXMEFIXME: Disable this before release!!!!!! I am just trying to find a crash bug. + if (boltNum < 0 || boltNum >= boltList.size()) + { + char fName[MAX_QPATH]; + char mName[MAX_QPATH]; + int bLink = ghoul2.mModelBoltLink; + + if (ghoul2.currentModel) + { + strcpy(mName, ghoul2.currentModel->name); + } + else + { + strcpy(mName, "NULL!"); + } + + if (ghoul2.mFileName && ghoul2.mFileName[0]) + { + strcpy(fName, ghoul2.mFileName); + } + else + { + strcpy(fName, "None?!"); + } + + Com_Error(ERR_DROP, "Write down or save this error message, show it to Rich\nBad bolt index on model %s (filename %s), index %i boltlink %i\n", mName, fName, boltNum, bLink); + } +#endif + if (boltList[boltNum].boneNumber>=0) + { + mdxaSkel_t *skel; + mdxaSkelOffsets_t *offsets; + offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boltList[boltNum].boneNumber]); + Multiply_3x4Matrix(&retMatrix, (mdxaBone_t *)&boneCache.EvalUnsmooth(boltList[boltNum].boneNumber), &skel->BasePoseMat); + } + else if (boltList[boltNum].surfaceNumber>=0) + { + const surfaceInfo_t *surfInfo=0; + { + for (size_t i=0;isurface<10000) + { + surface = (mdxmSurface_t *)G2_FindSurface_BC(boneCache.mod,surfInfo->surface, 0); + } + G2_ProcessSurfaceBolt2(boneCache,surface,boltNum,boltList,surfInfo,(model_t *)boneCache.mod,retMatrix); + } + else + { + // we have a bolt without a bone or surface, not a huge problem but we ought to at least clear the bolt matrix + retMatrix=identityMatrix; + } +} + +static void RootMatrix(CGhoul2Info_v &ghoul2,int time,const vec3_t scale,mdxaBone_t &retMatrix) +{ + int i; + for (i=0; ivalue); +} + +/* +============== +R_AddGHOULSurfaces +============== +*/ +void R_AddGhoulSurfaces( trRefEntity_t *ent ) { +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_R_AddGHOULSurfaces.Start(); +#endif + shader_t *cust_shader = 0; +#ifdef _G2_GORE + shader_t *gore_shader = 0; +#endif + int fogNum = 0; + qboolean personalModel; + int cull; + int i, whichLod, j; + skin_t *skin; + int modelCount; + mdxaBone_t rootMatrix; + CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)ent->e.ghoul2); + + if ( !ghoul2.IsValid() ) + { + return; + } + // if we don't want server ghoul2 models and this is one, or we just don't want ghoul2 models at all, then return + if (r_noServerGhoul2->integer) + { + return; + } + if (!G2_SetupModelPointers(ghoul2)) + { + return; + } + + int currentTime=G2API_GetTime(tr.refdef.time); + + + // cull the entire model if merged bounding box of both frames + // is outside the view frustum. + cull = R_GCullModel (ent ); + if ( cull == CULL_OUT ) + { + return; + } + HackadelicOnClient=true; + // are any of these models setting a new origin? + RootMatrix(ghoul2,currentTime, ent->e.modelScale,rootMatrix); + + // don't add third_person objects if not in a portal + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); + + int modelList[256]; + assert(ghoul2.size()<=255); + modelList[255]=548; + + // set up lighting now that we know we aren't culled + if ( !personalModel || r_shadows->integer > 1 ) { + R_SetupEntityLighting( &tr.refdef, ent ); + } + + // see if we are in a fog volume + fogNum = R_GComputeFogNum( ent ); + + // order sort the ghoul 2 models so bolt ons get bolted to the right model + G2_Sort_Models(ghoul2, modelList, &modelCount); + assert(modelList[255]==548); + +#ifdef _G2_GORE + if (goreShader == -1) + { + goreShader=RE_RegisterShader("gfx/damage/burnmark1"); + } +#endif + + // construct a world matrix for this entity + G2_GenerateWorldMatrix(ent->e.angles, ent->e.origin); + + // walk each possible model for this entity and try rendering it out + for (j=0; je.customShader) + { + cust_shader = R_GetShaderByHandle(ent->e.customShader ); + } + else + { + cust_shader = NULL; + // figure out the custom skin thing + if (ghoul2[i].mCustomSkin) + { + skin = R_GetSkinByHandle(ghoul2[i].mCustomSkin ); + } + else if (ent->e.customSkin) + { + skin = R_GetSkinByHandle(ent->e.customSkin ); + } + else if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) + { + skin = R_GetSkinByHandle( ghoul2[i].mSkin ); + } + } + + if (j&&ghoul2[i].mModelBoltLink != -1) + { + int boltMod = (ghoul2[i].mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; + int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + mdxaBone_t bolt; + G2_GetBoltMatrixLow(ghoul2[boltMod],boltNum,ent->e.modelScale,bolt); + G2_TransformGhoulBones(ghoul2[i].mBlist,bolt, ghoul2[i],currentTime); + } + else + { + G2_TransformGhoulBones(ghoul2[i].mBlist, rootMatrix, ghoul2[i],currentTime); + } + whichLod = G2_ComputeLOD( ent, ghoul2[i].currentModel, ghoul2[i].mLodBias ); + G2_FindOverrideSurface(-1,ghoul2[i].mSlist); //reset the quick surface override lookup; + +#ifdef _G2_GORE + CGoreSet *gore=0; + if (ghoul2[i].mGoreSetTag) + { + gore=FindGoreSet(ghoul2[i].mGoreSetTag); + if (!gore) // my gore is gone, so remove it + { + ghoul2[i].mGoreSetTag=0; + } + } + + CRenderSurface RS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, cust_shader, fogNum, personalModel, ghoul2[i].mBoneCache, ent->e.renderfx, skin, (model_t *)ghoul2[i].currentModel, whichLod, ghoul2[i].mBltlist, gore_shader, gore); +#else + CRenderSurface RS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, cust_shader, fogNum, personalModel, ghoul2[i].mBoneCache, ent->e.renderfx, skin, (model_t *)ghoul2[i].currentModel, whichLod, ghoul2[i].mBltlist); +#endif + if (!personalModel && (RS.renderfx & RF_SHADOW_PLANE) && !bInShadowRange(ent->e.origin)) + { + RS.renderfx |= RF_NOSHADOW; + } + RenderSurfaces(RS); + } + } + HackadelicOnClient=false; + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_R_AddGHOULSurfaces += G2PerformanceTimer_R_AddGHOULSurfaces.End(); +#endif +} + +#ifdef _G2_LISTEN_SERVER_OPT +qboolean G2API_OverrideServerWithClientData(CGhoul2Info *serverInstance); +#endif + +bool G2_NeedsRecalc(CGhoul2Info *ghlInfo,int frameNum) +{ + G2_SetupModelPointers(ghlInfo); + // not sure if I still need this test, probably + if (ghlInfo->mSkelFrameNum!=frameNum|| + !ghlInfo->mBoneCache|| + ghlInfo->mBoneCache->mod!=ghlInfo->currentModel) + { +#ifdef _G2_LISTEN_SERVER_OPT + if (ghlInfo->entityNum != ENTITYNUM_NONE && + G2API_OverrideServerWithClientData(ghlInfo)) + { //if we can manage this, then we don't have to reconstruct + return false; + } +#endif + ghlInfo->mSkelFrameNum=frameNum; + return true; + } + return false; +} + +/* +============== +G2_ConstructGhoulSkeleton - builds a complete skeleton for all ghoul models in a CGhoul2Info_v class - using LOD 0 +============== +*/ +void G2_ConstructGhoulSkeleton( CGhoul2Info_v &ghoul2,const int frameNum,bool checkForNewOrigin,const vec3_t scale) +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_G2_ConstructGhoulSkeleton.Start(); +#endif + int i, j; + int modelCount; + mdxaBone_t rootMatrix; + + int modelList[256]; + assert(ghoul2.size()<=255); + modelList[255]=548; + + if (checkForNewOrigin) + { + RootMatrix(ghoul2,frameNum,scale,rootMatrix); + } + else + { + rootMatrix = identityMatrix; + } + + G2_Sort_Models(ghoul2, modelList, &modelCount); + assert(modelList[255]==548); + + for (j=0; j> MODEL_SHIFT) & MODEL_AND; + int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + + mdxaBone_t bolt; + G2_GetBoltMatrixLow(ghoul2[boltMod],boltNum,scale,bolt); + G2_TransformGhoulBones(ghoul2[i].mBlist,bolt,ghoul2[i],frameNum,checkForNewOrigin); + } +#ifdef _G2_LISTEN_SERVER_OPT + else if (ghoul2[i].entityNum == ENTITYNUM_NONE || ghoul2[i].mSkelFrameNum != frameNum) +#else + else +#endif + { + G2_TransformGhoulBones(ghoul2[i].mBlist,rootMatrix,ghoul2[i],frameNum,checkForNewOrigin); + } + } + } +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_G2_ConstructGhoulSkeleton += G2PerformanceTimer_G2_ConstructGhoulSkeleton.End(); +#endif +} + +static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, const int iWeightNum) +{ + float fBoneWeight; + + int iTemp = pVert->BoneWeightings[iWeightNum]; + + iTemp|= (pVert->uiNmWeightsAndBoneIndexes >> (iG2_BONEWEIGHT_TOPBITS_SHIFT+(iWeightNum*2)) ) & iG2_BONEWEIGHT_TOPBITS_AND; + + fBoneWeight = fG2_BONEWEIGHT_RECIPROCAL_MULT * iTemp; + + return fBoneWeight; +} + +//This is a slightly mangled version of the same function from the sof2sp base. +//It provides a pretty significant performance increase over the existing one. +void RB_SurfaceGhoul( CRenderableSurface *surf ) +{ +#ifdef G2_PERFORMANCE_ANALYSIS + G2PerformanceTimer_RB_SurfaceGhoul.Start(); +#endif + + static int j, k; + static int baseIndex, baseVertex; + static int numVerts; + static mdxmVertex_t *v; + static int *triangles; + static int indexes; + static glIndex_t *tessIndexes; + static mdxmVertexTexCoord_t *pTexCoords; + static int *piBoneReferences; + +#ifdef _G2_GORE + if (surf->alternateTex) + { + // a gore surface ready to go. + + /* + sizeof(int)+ // num verts + sizeof(int)+ // num tris + sizeof(int)*newNumVerts+ // which verts to copy from original surface + sizeof(float)*4*newNumVerts+ // storgage for deformed verts + sizeof(float)*4*newNumVerts+ // storgage for deformed normal + sizeof(float)*2*newNumVerts+ // texture coordinates + sizeof(int)*newNumTris*3; // new indecies + */ + + int *data=(int *)surf->alternateTex; + numVerts=*data++; + indexes=(*data++); + // first up, sanity check our numbers + RB_CheckOverflow(numVerts,indexes); + indexes*=3; + + data+=numVerts; + + baseIndex = tess.numIndexes; + baseVertex = tess.numVertexes; + + memcpy(&tess.xyz[baseVertex][0],data,sizeof(float)*4*numVerts); + data+=4*numVerts; + memcpy(&tess.normal[baseVertex][0],data,sizeof(float)*4*numVerts); + data+=4*numVerts; + assert(numVerts>0); + + //float *texCoords = tess.texCoords[0][baseVertex]; + float *texCoords = tess.texCoords[baseVertex][0]; + int hack = baseVertex; + //rww - since the array is arranged as such we cannot increment + //the relative memory position to get where we want. Maybe this + //is why sof2 has the texCoords array reversed. In any case, I + //am currently too lazy to get around it. + //Or can you += array[.][x]+2? + if (surf->scale>1.0f) + { + for ( j = 0; j < numVerts; j++) + { + texCoords[0]=((*(float *)data)-0.5f)*surf->scale+0.5f; + data++; + texCoords[1]=((*(float *)data)-0.5f)*surf->scale+0.5f; + data++; + //texCoords+=2;// Size of gore (s,t). + hack++; + texCoords = tess.texCoords[hack][0]; + } + } + else + { + for (j=0;jfade) + { + static int lFade; + static int j; + + if (surf->fade<1.0) + { + tess.fading = true; + lFade = Q_ftol(254.4f*surf->fade); + + for (j=0;jfade > 2.0f && surf->fade < 3.0f) + { //hack to fade out on RGB if desired (don't want to add more to CRenderableSurface) -rww + tess.fading = true; + lFade = Q_ftol(254.4f*(surf->fade-2.0f)); + + for (j=0;jsurfaceData; + + CBoneCache *bones = surf->boneCache; + +#ifndef _G2_GORE //we use this later, for gore + delete surf; +#endif + + // first up, sanity check our numbers + RB_CheckOverflow( surface->numVerts, surface->numTriangles ); + + // + // deform the vertexes by the lerped bones + // + + // first up, sanity check our numbers + baseVertex = tess.numVertexes; + triangles = (int *) ((byte *)surface + surface->ofsTriangles); + baseIndex = tess.numIndexes; +#if 0 + indexes = surface->numTriangles * 3; + for (j = 0 ; j < indexes ; j++) { + tess.indexes[baseIndex + j] = baseVertex + triangles[j]; + } + tess.numIndexes += indexes; +#else + indexes = surface->numTriangles; //*3; //unrolled 3 times, don't multiply + tessIndexes = &tess.indexes[baseIndex]; + for (j = 0 ; j < indexes ; j++) { + *tessIndexes++ = baseVertex + *triangles++; + *tessIndexes++ = baseVertex + *triangles++; + *tessIndexes++ = baseVertex + *triangles++; + } + tess.numIndexes += indexes*3; +#endif + + numVerts = surface->numVerts; + + piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); + baseVertex = tess.numVertexes; + v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); + pTexCoords = (mdxmVertexTexCoord_t *) &v[numVerts]; + +// if (r_ghoul2fastnormals&&r_ghoul2fastnormals->integer==0) +#if 0 + if (0) + { + for ( j = 0; j < numVerts; j++, baseVertex++,v++ ) + { + const int iNumWeights = G2_GetVertWeights( v ); + + float fTotalWeight = 0.0f; + + k=0; + int iBoneIndex = G2_GetVertBoneIndex( v, k ); + float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + const mdxaBone_t *bone = &bones->EvalRender(piBoneReferences[iBoneIndex]); + + tess.xyz[baseVertex][0] = fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] = fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] = fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + + tess.normal[baseVertex][0] = fBoneWeight * DotProduct( bone->matrix[0], v->normal ); + tess.normal[baseVertex][1] = fBoneWeight * DotProduct( bone->matrix[1], v->normal ); + tess.normal[baseVertex][2] = fBoneWeight * DotProduct( bone->matrix[2], v->normal ); + + for ( k++ ; k < iNumWeights ; k++) + { + iBoneIndex = G2_GetVertBoneIndex( v, k ); + fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + + bone = &bones->EvalRender(piBoneReferences[iBoneIndex]); + + tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + + tess.normal[baseVertex][0] += fBoneWeight * DotProduct( bone->matrix[0], v->normal ); + tess.normal[baseVertex][1] += fBoneWeight * DotProduct( bone->matrix[1], v->normal ); + tess.normal[baseVertex][2] += fBoneWeight * DotProduct( bone->matrix[2], v->normal ); + } + + tess.texCoords[baseVertex][0][0] = pTexCoords[j].texCoords[0]; + tess.texCoords[baseVertex][0][1] = pTexCoords[j].texCoords[1]; + } + } + else + { +#endif + float fTotalWeight; + float fBoneWeight; + float t1; + float t2; + const mdxaBone_t *bone; + const mdxaBone_t *bone2; + for ( j = 0; j < numVerts; j++, baseVertex++,v++ ) + { + + bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, 0 )]); + int iNumWeights = G2_GetVertWeights( v ); + tess.normal[baseVertex][0] = DotProduct( bone->matrix[0], v->normal ); + tess.normal[baseVertex][1] = DotProduct( bone->matrix[1], v->normal ); + tess.normal[baseVertex][2] = DotProduct( bone->matrix[2], v->normal ); + + if (iNumWeights==1) + { + tess.xyz[baseVertex][0] = ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] = ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] = ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + } + else + { + fBoneWeight = G2_GetVertBoneWeightNotSlow( v, 0); + if (iNumWeights==2) + { + bone2 = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, 1 )]); + /* + useless transposition + tess.xyz[baseVertex][0] = + v[0]*(w*(bone->matrix[0][0]-bone2->matrix[0][0])+bone2->matrix[0][0])+ + v[1]*(w*(bone->matrix[0][1]-bone2->matrix[0][1])+bone2->matrix[0][1])+ + v[2]*(w*(bone->matrix[0][2]-bone2->matrix[0][2])+bone2->matrix[0][2])+ + w*(bone->matrix[0][3]-bone2->matrix[0][3]) + bone2->matrix[0][3]; + */ + t1 = ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + t2 = ( DotProduct( bone2->matrix[0], v->vertCoords ) + bone2->matrix[0][3] ); + tess.xyz[baseVertex][0] = fBoneWeight * (t1-t2) + t2; + t1 = ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + t2 = ( DotProduct( bone2->matrix[1], v->vertCoords ) + bone2->matrix[1][3] ); + tess.xyz[baseVertex][1] = fBoneWeight * (t1-t2) + t2; + t1 = ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + t2 = ( DotProduct( bone2->matrix[2], v->vertCoords ) + bone2->matrix[2][3] ); + tess.xyz[baseVertex][2] = fBoneWeight * (t1-t2) + t2; + } + else + { + + tess.xyz[baseVertex][0] = fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] = fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] = fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + + fTotalWeight=fBoneWeight; + for (k=1; k < iNumWeights-1 ; k++) + { + bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, k )]); + fBoneWeight = G2_GetVertBoneWeightNotSlow( v, k); + fTotalWeight += fBoneWeight; + + tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + } + bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, k )]); + fBoneWeight = 1.0f-fTotalWeight; + + tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); + tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); + tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); + } + } + + tess.texCoords[baseVertex][0][0] = pTexCoords[j].texCoords[0]; + tess.texCoords[baseVertex][0][1] = pTexCoords[j].texCoords[1]; + } +#if 0 + } +#endif + +#ifdef _G2_GORE + CRenderableSurface *storeSurf = surf; + + while (surf->goreChain) + { + surf=(CRenderableSurface *)surf->goreChain; + if (surf->alternateTex) + { + // get a gore surface ready to go. + + /* + sizeof(int)+ // num verts + sizeof(int)+ // num tris + sizeof(int)*newNumVerts+ // which verts to copy from original surface + sizeof(float)*4*newNumVerts+ // storgage for deformed verts + sizeof(float)*4*newNumVerts+ // storgage for deformed normal + sizeof(float)*2*newNumVerts+ // texture coordinates + sizeof(int)*newNumTris*3; // new indecies + */ + + int *data=(int *)surf->alternateTex; + int gnumVerts=*data++; + data++; + + float *fdata=(float *)data; + fdata+=gnumVerts; + for (j=0;j=0&&data[j]=0&&data[j]hasGlow || g_bRenderGlowingObjects || !g_bDynamicGlowSupported || !r_DynamicGlow->integer ) + { + delete storeSurf; + } +#endif + + tess.numVertexes += surface->numVerts; + +#ifdef G2_PERFORMANCE_ANALYSIS + G2Time_RB_SurfaceGhoul += G2PerformanceTimer_RB_SurfaceGhoul.End(); +#endif +} + +/* +================= +R_LoadMDXM - load a Ghoul 2 Mesh file +================= +*/ + +/* + +Some information used in the creation of the JK2 - JKA bone remap table + +These are the old bones: +Complete list of all 72 bones: + +*/ + +int OldToNewRemapTable[72] = { +0,// Bone 0: "model_root": Parent: "" (index -1) +1,// Bone 1: "pelvis": Parent: "model_root" (index 0) +2,// Bone 2: "Motion": Parent: "pelvis" (index 1) +3,// Bone 3: "lfemurYZ": Parent: "pelvis" (index 1) +4,// Bone 4: "lfemurX": Parent: "pelvis" (index 1) +5,// Bone 5: "ltibia": Parent: "pelvis" (index 1) +6,// Bone 6: "ltalus": Parent: "pelvis" (index 1) +6,// Bone 7: "ltarsal": Parent: "pelvis" (index 1) +7,// Bone 8: "rfemurYZ": Parent: "pelvis" (index 1) +8,// Bone 9: "rfemurX": Parent: "pelvis" (index 1) +9,// Bone10: "rtibia": Parent: "pelvis" (index 1) +10,// Bone11: "rtalus": Parent: "pelvis" (index 1) +10,// Bone12: "rtarsal": Parent: "pelvis" (index 1) +11,// Bone13: "lower_lumbar": Parent: "pelvis" (index 1) +12,// Bone14: "upper_lumbar": Parent: "lower_lumbar" (index 13) +13,// Bone15: "thoracic": Parent: "upper_lumbar" (index 14) +14,// Bone16: "cervical": Parent: "thoracic" (index 15) +15,// Bone17: "cranium": Parent: "cervical" (index 16) +16,// Bone18: "ceyebrow": Parent: "face_always_" (index 71) +17,// Bone19: "jaw": Parent: "face_always_" (index 71) +18,// Bone20: "lblip2": Parent: "face_always_" (index 71) +19,// Bone21: "leye": Parent: "face_always_" (index 71) +20,// Bone22: "rblip2": Parent: "face_always_" (index 71) +21,// Bone23: "ltlip2": Parent: "face_always_" (index 71) +22,// Bone24: "rtlip2": Parent: "face_always_" (index 71) +23,// Bone25: "reye": Parent: "face_always_" (index 71) +24,// Bone26: "rclavical": Parent: "thoracic" (index 15) +25,// Bone27: "rhumerus": Parent: "thoracic" (index 15) +26,// Bone28: "rhumerusX": Parent: "thoracic" (index 15) +27,// Bone29: "rradius": Parent: "thoracic" (index 15) +28,// Bone30: "rradiusX": Parent: "thoracic" (index 15) +29,// Bone31: "rhand": Parent: "thoracic" (index 15) +29,// Bone32: "mc7": Parent: "thoracic" (index 15) +34,// Bone33: "r_d5_j1": Parent: "thoracic" (index 15) +35,// Bone34: "r_d5_j2": Parent: "thoracic" (index 15) +35,// Bone35: "r_d5_j3": Parent: "thoracic" (index 15) +30,// Bone36: "r_d1_j1": Parent: "thoracic" (index 15) +31,// Bone37: "r_d1_j2": Parent: "thoracic" (index 15) +31,// Bone38: "r_d1_j3": Parent: "thoracic" (index 15) +32,// Bone39: "r_d2_j1": Parent: "thoracic" (index 15) +33,// Bone40: "r_d2_j2": Parent: "thoracic" (index 15) +33,// Bone41: "r_d2_j3": Parent: "thoracic" (index 15) +32,// Bone42: "r_d3_j1": Parent: "thoracic" (index 15) +33,// Bone43: "r_d3_j2": Parent: "thoracic" (index 15) +33,// Bone44: "r_d3_j3": Parent: "thoracic" (index 15) +34,// Bone45: "r_d4_j1": Parent: "thoracic" (index 15) +35,// Bone46: "r_d4_j2": Parent: "thoracic" (index 15) +35,// Bone47: "r_d4_j3": Parent: "thoracic" (index 15) +36,// Bone48: "rhang_tag_bone": Parent: "thoracic" (index 15) +37,// Bone49: "lclavical": Parent: "thoracic" (index 15) +38,// Bone50: "lhumerus": Parent: "thoracic" (index 15) +39,// Bone51: "lhumerusX": Parent: "thoracic" (index 15) +40,// Bone52: "lradius": Parent: "thoracic" (index 15) +41,// Bone53: "lradiusX": Parent: "thoracic" (index 15) +42,// Bone54: "lhand": Parent: "thoracic" (index 15) +42,// Bone55: "mc5": Parent: "thoracic" (index 15) +43,// Bone56: "l_d5_j1": Parent: "thoracic" (index 15) +44,// Bone57: "l_d5_j2": Parent: "thoracic" (index 15) +44,// Bone58: "l_d5_j3": Parent: "thoracic" (index 15) +43,// Bone59: "l_d4_j1": Parent: "thoracic" (index 15) +44,// Bone60: "l_d4_j2": Parent: "thoracic" (index 15) +44,// Bone61: "l_d4_j3": Parent: "thoracic" (index 15) +45,// Bone62: "l_d3_j1": Parent: "thoracic" (index 15) +46,// Bone63: "l_d3_j2": Parent: "thoracic" (index 15) +46,// Bone64: "l_d3_j3": Parent: "thoracic" (index 15) +45,// Bone65: "l_d2_j1": Parent: "thoracic" (index 15) +46,// Bone66: "l_d2_j2": Parent: "thoracic" (index 15) +46,// Bone67: "l_d2_j3": Parent: "thoracic" (index 15) +47,// Bone68: "l_d1_j1": Parent: "thoracic" (index 15) +48,// Bone69: "l_d1_j2": Parent: "thoracic" (index 15) +48,// Bone70: "l_d1_j3": Parent: "thoracic" (index 15) +52// Bone71: "face_always_": Parent: "cranium" (index 17) +}; + + +/* + +Bone 0: "model_root": + Parent: "" (index -1) + #Kids: 1 + Child 0: (index 1), name "pelvis" + +Bone 1: "pelvis": + Parent: "model_root" (index 0) + #Kids: 4 + Child 0: (index 2), name "Motion" + Child 1: (index 3), name "lfemurYZ" + Child 2: (index 7), name "rfemurYZ" + Child 3: (index 11), name "lower_lumbar" + +Bone 2: "Motion": + Parent: "pelvis" (index 1) + #Kids: 0 + +Bone 3: "lfemurYZ": + Parent: "pelvis" (index 1) + #Kids: 3 + Child 0: (index 4), name "lfemurX" + Child 1: (index 5), name "ltibia" + Child 2: (index 49), name "ltail" + +Bone 4: "lfemurX": + Parent: "lfemurYZ" (index 3) + #Kids: 0 + +Bone 5: "ltibia": + Parent: "lfemurYZ" (index 3) + #Kids: 1 + Child 0: (index 6), name "ltalus" + +Bone 6: "ltalus": + Parent: "ltibia" (index 5) + #Kids: 0 + +Bone 7: "rfemurYZ": + Parent: "pelvis" (index 1) + #Kids: 3 + Child 0: (index 8), name "rfemurX" + Child 1: (index 9), name "rtibia" + Child 2: (index 50), name "rtail" + +Bone 8: "rfemurX": + Parent: "rfemurYZ" (index 7) + #Kids: 0 + +Bone 9: "rtibia": + Parent: "rfemurYZ" (index 7) + #Kids: 1 + Child 0: (index 10), name "rtalus" + +Bone 10: "rtalus": + Parent: "rtibia" (index 9) + #Kids: 0 + +Bone 11: "lower_lumbar": + Parent: "pelvis" (index 1) + #Kids: 1 + Child 0: (index 12), name "upper_lumbar" + +Bone 12: "upper_lumbar": + Parent: "lower_lumbar" (index 11) + #Kids: 1 + Child 0: (index 13), name "thoracic" + +Bone 13: "thoracic": + Parent: "upper_lumbar" (index 12) + #Kids: 5 + Child 0: (index 14), name "cervical" + Child 1: (index 24), name "rclavical" + Child 2: (index 25), name "rhumerus" + Child 3: (index 37), name "lclavical" + Child 4: (index 38), name "lhumerus" + +Bone 14: "cervical": + Parent: "thoracic" (index 13) + #Kids: 1 + Child 0: (index 15), name "cranium" + +Bone 15: "cranium": + Parent: "cervical" (index 14) + #Kids: 1 + Child 0: (index 52), name "face_always_" + +Bone 16: "ceyebrow": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 17: "jaw": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 18: "lblip2": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 19: "leye": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 20: "rblip2": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 21: "ltlip2": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 22: "rtlip2": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 23: "reye": + Parent: "face_always_" (index 52) + #Kids: 0 + +Bone 24: "rclavical": + Parent: "thoracic" (index 13) + #Kids: 0 + +Bone 25: "rhumerus": + Parent: "thoracic" (index 13) + #Kids: 2 + Child 0: (index 26), name "rhumerusX" + Child 1: (index 27), name "rradius" + +Bone 26: "rhumerusX": + Parent: "rhumerus" (index 25) + #Kids: 0 + +Bone 27: "rradius": + Parent: "rhumerus" (index 25) + #Kids: 9 + Child 0: (index 28), name "rradiusX" + Child 1: (index 29), name "rhand" + Child 2: (index 30), name "r_d1_j1" + Child 3: (index 31), name "r_d1_j2" + Child 4: (index 32), name "r_d2_j1" + Child 5: (index 33), name "r_d2_j2" + Child 6: (index 34), name "r_d4_j1" + Child 7: (index 35), name "r_d4_j2" + Child 8: (index 36), name "rhang_tag_bone" + +Bone 28: "rradiusX": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 29: "rhand": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 30: "r_d1_j1": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 31: "r_d1_j2": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 32: "r_d2_j1": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 33: "r_d2_j2": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 34: "r_d4_j1": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 35: "r_d4_j2": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 36: "rhang_tag_bone": + Parent: "rradius" (index 27) + #Kids: 0 + +Bone 37: "lclavical": + Parent: "thoracic" (index 13) + #Kids: 0 + +Bone 38: "lhumerus": + Parent: "thoracic" (index 13) + #Kids: 2 + Child 0: (index 39), name "lhumerusX" + Child 1: (index 40), name "lradius" + +Bone 39: "lhumerusX": + Parent: "lhumerus" (index 38) + #Kids: 0 + +Bone 40: "lradius": + Parent: "lhumerus" (index 38) + #Kids: 9 + Child 0: (index 41), name "lradiusX" + Child 1: (index 42), name "lhand" + Child 2: (index 43), name "l_d4_j1" + Child 3: (index 44), name "l_d4_j2" + Child 4: (index 45), name "l_d2_j1" + Child 5: (index 46), name "l_d2_j2" + Child 6: (index 47), name "l_d1_j1" + Child 7: (index 48), name "l_d1_j2" + Child 8: (index 51), name "lhang_tag_bone" + +Bone 41: "lradiusX": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 42: "lhand": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 43: "l_d4_j1": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 44: "l_d4_j2": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 45: "l_d2_j1": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 46: "l_d2_j2": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 47: "l_d1_j1": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 48: "l_d1_j2": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 49: "ltail": + Parent: "lfemurYZ" (index 3) + #Kids: 0 + +Bone 50: "rtail": + Parent: "rfemurYZ" (index 7) + #Kids: 0 + +Bone 51: "lhang_tag_bone": + Parent: "lradius" (index 40) + #Kids: 0 + +Bone 52: "face_always_": + Parent: "cranium" (index 15) + #Kids: 8 + Child 0: (index 16), name "ceyebrow" + Child 1: (index 17), name "jaw" + Child 2: (index 18), name "lblip2" + Child 3: (index 19), name "leye" + Child 4: (index 20), name "rblip2" + Child 5: (index 21), name "ltlip2" + Child 6: (index 22), name "rtlip2" + Child 7: (index 23), name "reye" + + + +*/ + + +qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { + int i,l, j; + mdxmHeader_t *pinmodel, *mdxm; + mdxmLOD_t *lod; + mdxmSurface_t *surf; + int version; + int size; + mdxmSurfHierarchy_t *surfInfo; + +#if 0 //#ifndef _M_IX86 + int k; + int frameSize; + mdxmTag_t *tag; + mdxmTriangle_t *tri; + mdxmVertex_t *v; + mdxmFrame_t *cframe; + int *boneRef; +#endif + + pinmodel= (mdxmHeader_t *)buffer; + // + // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... + // + version = (pinmodel->version); + size = (pinmodel->ofsEnd); + + if (!bAlreadyCached) + { + LL(version); + LL(size); + } + + if (version != MDXM_VERSION) { + Com_Printf (S_COLOR_YELLOW "R_LoadMDXM: %s has wrong version (%i should be %i)\n", + mod_name, version, MDXM_VERSION); + return qfalse; + } + + mod->type = MOD_MDXM; + mod->dataSize += size; + + qboolean bAlreadyFound = qfalse; + mdxm = mod->mdxm = (mdxmHeader_t*) //Hunk_Alloc( size ); + RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); + + assert(bAlreadyCached == bAlreadyFound); + + if (!bAlreadyFound) + { + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // we've hijacked that memory block... + // + // Aaaargh. Kill me now... + // + bAlreadyCached = qtrue; + assert( mdxm == buffer ); +// memcpy( mdxm, buffer, size ); // and don't do this now, since it's the same thing + + LL(mdxm->ident); + LL(mdxm->version); + LL(mdxm->numLODs); + LL(mdxm->ofsLODs); + LL(mdxm->numSurfaces); + LL(mdxm->ofsSurfHierarchy); + LL(mdxm->ofsEnd); + } + + // first up, go load in the animation file we need that has the skeletal animation info for this model + mdxm->animIndex = RE_RegisterModel(va ("%s.gla",mdxm->animName)); + + if (!mdxm->animIndex) + { + Com_Printf (S_COLOR_YELLOW "R_LoadMDXM: missing animation file %s for mesh %s\n", mdxm->animName, mdxm->name); + return qfalse; + } + + mod->numLods = mdxm->numLODs -1 ; //copy this up to the model for ease of use - it wil get inced after this. + + if (bAlreadyFound) + { + return qtrue; // All done. Stop, go no further, do not LittleLong(), do not pass Go... + } + + bool isAnOldModelFile = false; + if (mdxm->numBones == 72 && strstr(mdxm->animName,"_humanoid") ) + { + isAnOldModelFile = true; + } + + surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); + for ( i = 0 ; i < mdxm->numSurfaces ; i++) + { + LL(surfInfo->numChildren); + LL(surfInfo->parentIndex); + + Q_strlwr(surfInfo->name); //just in case + if ( !strcmp( &surfInfo->name[strlen(surfInfo->name)-4],"_off") ) + { + surfInfo->name[strlen(surfInfo->name)-4]=0; //remove "_off" from name + } + + // do all the children indexs + for (j=0; jnumChildren; j++) + { + LL(surfInfo->childIndexes[j]); + } + + shader_t *sh; + // get the shader name + sh = R_FindShader( surfInfo->shader, lightmapsNone, stylesDefault, qtrue ); + // insert it in the surface list + if ( sh->defaultShader ) + { + surfInfo->shaderIndex = 0; + } + else + { + surfInfo->shaderIndex = sh->index; + } + + RE_RegisterModels_StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); + + // find the next surface + surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + (size_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surfInfo->numChildren ] )); + } + + // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) + lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); + for ( l = 0 ; l < mdxm->numLODs ; l++) + { + int triCount = 0; + + LL(lod->ofsEnd); + // swap all the surfaces + surf = (mdxmSurface_t *) ( (byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t)) ); + for ( i = 0 ; i < mdxm->numSurfaces ; i++) + { + LL(surf->numTriangles); + LL(surf->ofsTriangles); + LL(surf->numVerts); + LL(surf->ofsVerts); + LL(surf->ofsEnd); + LL(surf->ofsHeader); + LL(surf->numBoneReferences); + LL(surf->ofsBoneReferences); +// LL(surf->maxVertBoneWeights); + + triCount += surf->numTriangles; + + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { + Com_Error (ERR_DROP, "R_LoadMDXM: %s has more than %i verts on a surface (%i)", + mod_name, SHADER_MAX_VERTEXES, surf->numVerts ); + } + if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { + Com_Error (ERR_DROP, "R_LoadMDXM: %s has more than %i triangles on a surface (%i)", + mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); + } + + // change to surface identifier + surf->ident = SF_MDX; + // register the shaders +#if 0 //#ifndef _M_IX86 +// +// optimisation, we don't bother doing this for standard intel case since our data's already in that format... +// + // FIXME - is this correct? + // do all the bone reference data + boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); + for ( j = 0 ; j < surf->numBoneReferences ; j++ ) + { + LL(boneRef[j]); + } + + // swap all the triangles + tri = (mdxmTriangle_t *) ( (byte *)surf + surf->ofsTriangles ); + for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) + { + LL(tri->indexes[0]); + LL(tri->indexes[1]); + LL(tri->indexes[2]); + } + + // swap all the vertexes + v = (mdxmVertex_t *) ( (byte *)surf + surf->ofsVerts ); + for ( j = 0 ; j < surf->numVerts ; j++ ) + { + v->normal[0] = LittleFloat( v->normal[0] ); + v->normal[1] = LittleFloat( v->normal[1] ); + v->normal[2] = LittleFloat( v->normal[2] ); + + v->texCoords[0] = LittleFloat( v->texCoords[0] ); + v->texCoords[1] = LittleFloat( v->texCoords[1] ); + + v->numWeights = LittleLong( v->numWeights ); + v->offset[0] = LittleFloat( v->offset[0] ); + v->offset[1] = LittleFloat( v->offset[1] ); + v->offset[2] = LittleFloat( v->offset[2] ); + + for ( k = 0 ; k < /*v->numWeights*/surf->maxVertBoneWeights ; k++ ) + { + v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex ); + v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight ); + } + v = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surf->maxVertBoneWeights]; + } +#endif + + if (isAnOldModelFile) + { + int *boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); + for ( j = 0 ; j < surf->numBoneReferences ; j++ ) + { + assert(boneRef[j] >= 0 && boneRef[j] < 72); + if (boneRef[j] >= 0 && boneRef[j] < 72) + { + boneRef[j]=OldToNewRemapTable[boneRef[j]]; + } + else + { + boneRef[j]=0; + } + } + } + // find the next surface + surf = (mdxmSurface_t *)( (byte *)surf + surf->ofsEnd ); + } + // find the next LOD + lod = (mdxmLOD_t *)( (byte *)lod + lod->ofsEnd ); + } + return qtrue; +} + +//#define CREATE_LIMB_HIERARCHY + +#ifdef CREATE_LIMB_HIERARCHY + +#define NUM_ROOTPARENTS 4 +#define NUM_OTHERPARENTS 12 +#define NUM_BOTTOMBONES 4 + +#define CHILD_PADDING 4 //I don't know, I guess this can be changed. + +static const char *rootParents[NUM_ROOTPARENTS] = +{ + "rfemurYZ", + "rhumerus", + "lfemurYZ", + "lhumerus" +}; + +static const char *otherParents[NUM_OTHERPARENTS] = +{ + "rhumerusX", + "rradius", + "rradiusX", + "lhumerusX", + "lradius", + "lradiusX", + "rfemurX", + "rtibia", + "rtalus", + "lfemurX", + "ltibia", + "ltalus" +}; + +static const char *bottomBones[NUM_BOTTOMBONES] = +{ + "rtarsal", + "rhand", + "ltarsal", + "lhand" +}; + +qboolean BoneIsRootParent(char *name) +{ + int i = 0; + + while (i < NUM_ROOTPARENTS) + { + if (!Q_stricmp(name, rootParents[i])) + { + return qtrue; + } + + i++; + } + + return qfalse; +} + +qboolean BoneIsOtherParent(char *name) +{ + int i = 0; + + while (i < NUM_OTHERPARENTS) + { + if (!Q_stricmp(name, otherParents[i])) + { + return qtrue; + } + + i++; + } + + return qfalse; +} + +qboolean BoneIsBottom(char *name) +{ + int i = 0; + + while (i < NUM_BOTTOMBONES) + { + if (!Q_stricmp(name, bottomBones[i])) + { + return qtrue; + } + + i++; + } + + return qfalse; +} + +void ShiftMemoryDown(mdxaSkelOffsets_t *offsets, mdxaHeader_t *mdxa, int boneIndex, byte **endMarker) +{ + int i = 0; + + //where the next bone starts + byte *nextBone = ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[boneIndex+1]); + int size = (*endMarker - nextBone); + + memmove((nextBone+CHILD_PADDING), nextBone, size); + memset(nextBone, 0, CHILD_PADDING); + *endMarker += CHILD_PADDING; + //Move the whole thing down CHILD_PADDING amount in memory, clear the new preceding space, and increment the end pointer. + + i = boneIndex+1; + + //Now add CHILD_PADDING amount to every offset beginning at the offset of the bone that was moved. + while (i < mdxa->numBones) + { + offsets->offsets[i] += CHILD_PADDING; + i++; + } + + mdxa->ofsFrames += CHILD_PADDING; + mdxa->ofsCompBonePool += CHILD_PADDING; + mdxa->ofsEnd += CHILD_PADDING; + //ofsSkel does not need to be updated because we are only moving memory after that point. +} + +//Proper/desired hierarchy list +static const char *BoneHierarchyList[] = +{ + "lfemurYZ", + "lfemurX", + "ltibia", + "ltalus", + "ltarsal", + + "rfemurYZ", + "rfemurX", + "rtibia", + "rtalus", + "rtarsal", + + "lhumerus", + "lhumerusX", + "lradius", + "lradiusX", + "lhand", + + "rhumerus", + "rhumerusX", + "rradius", + "rradiusX", + "rhand", + + 0 +}; + +//Gets the index of a child or parent. If child is passed as qfalse then parent is assumed. +int BoneParentChildIndex(mdxaHeader_t *mdxa, mdxaSkelOffsets_t *offsets, mdxaSkel_t *boneInfo, qboolean child) +{ + int i = 0; + int matchindex = -1; + mdxaSkel_t *bone; + const char *match = NULL; + + while (BoneHierarchyList[i]) + { + if (!Q_stricmp(boneInfo->name, BoneHierarchyList[i])) + { //we have a match, the slot above this will be our desired parent. (or below for child) + if (child) + { + match = BoneHierarchyList[i+1]; + } + else + { + match = BoneHierarchyList[i-1]; + } + break; + } + i++; + } + + if (!match) + { //no good + return -1; + } + + i = 0; + + while (i < mdxa->numBones) + { + bone = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + + if (bone && !Q_stricmp(bone->name, match)) + { //this is the one + matchindex = i; + break; + } + + i++; + } + + return matchindex; +} +#endif //CREATE_LIMB_HIERARCHY + +/* +================= +R_LoadMDXA - load a Ghoul 2 animation file +================= +*/ +qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { + + mdxaHeader_t *pinmodel, *mdxa; + int version; + int size; +#ifdef CREATE_LIMB_HIERARCHY + int oSize = 0; + byte *sizeMarker; +#endif + +#if 0 //#ifndef _M_IX86 + int j, k, i; + int frameSize; + mdxaFrame_t *cframe; + mdxaSkel_t *boneInfo; +#endif + + pinmodel = (mdxaHeader_t *)buffer; + // + // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... + // + version = (pinmodel->version); + size = (pinmodel->ofsEnd); + + if (!bAlreadyCached) + { + LL(version); + LL(size); + } + + if (version != MDXA_VERSION) { + Com_Printf (S_COLOR_YELLOW "R_LoadMDXA: %s has wrong version (%i should be %i)\n", + mod_name, version, MDXA_VERSION); + return qfalse; + } + + mod->type = MOD_MDXA; + mod->dataSize += size; + + qboolean bAlreadyFound = qfalse; + +#ifdef CREATE_LIMB_HIERARCHY + oSize = size; + + int childNumber = (NUM_ROOTPARENTS + NUM_OTHERPARENTS); + size += (childNumber*(CHILD_PADDING*8)); //Allocate us some extra space so we can shift memory down. +#endif //CREATE_LIMB_HIERARCHY + + mdxa = mod->mdxa = (mdxaHeader_t*) //Hunk_Alloc( size ); + RE_RegisterModels_Malloc(size, + #ifdef CREATE_LIMB_HIERARCHY + NULL, // I think this'll work, can't really test on PC + #else + buffer, + #endif + mod_name, &bAlreadyFound, TAG_MODEL_GLA); + + assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? + + if (!bAlreadyFound) + { +#ifdef CREATE_LIMB_HIERARCHY + memcpy( mdxa, buffer, oSize ); +#else + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // we've hijacked that memory block... + // + // Aaaargh. Kill me now... + // + bAlreadyCached = qtrue; + assert( mdxa == buffer ); +// memcpy( mdxa, buffer, size ); // and don't do this now, since it's the same thing +#endif + LL(mdxa->ident); + LL(mdxa->version); + LL(mdxa->numFrames); + LL(mdxa->numBones); + LL(mdxa->ofsFrames); + LL(mdxa->ofsEnd); + } + +#ifdef CREATE_LIMB_HIERARCHY + if (!bAlreadyFound) + { + mdxaSkel_t *boneParent; +#if 0 //#ifdef _M_IX86 + mdxaSkel_t *boneInfo; + int i, k; +#endif + + sizeMarker = (byte *)mdxa + mdxa->ofsEnd; + + //rww - This is probably temporary until we put actual hierarchy in for the models. + //It is necessary for the correct operation of ragdoll. + mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); + + for ( i = 0 ; i < mdxa->numBones ; i++) + { + boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + + if (boneInfo) + { + char *bname = boneInfo->name; + + if (BoneIsRootParent(bname)) + { //These are the main parent bones. We don't want to change their parents, but we want to give them children. + ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); + + boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + + int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); + + if (newChild != -1) + { + boneInfo->numChildren++; + boneInfo->children[boneInfo->numChildren-1] = newChild; + } + else + { + assert(!"Failed to find matching child for bone in hierarchy creation"); + } + } + else if (BoneIsOtherParent(bname) || BoneIsBottom(bname)) + { + if (!BoneIsBottom(bname)) + { //unless it's last in the chain it has the next bone as a child. + ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); + + boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + + int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); + + if (newChild != -1) + { + boneInfo->numChildren++; + boneInfo->children[boneInfo->numChildren-1] = newChild; + } + else + { + assert(!"Failed to find matching child for bone in hierarchy creation"); + } + } + + //Before we set the parent we want to remove this as a child for whoever was parenting it. + int oldParent = boneInfo->parent; + + if (oldParent > -1) + { + boneParent = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[oldParent]); + } + else + { + boneParent = NULL; + } + + if (boneParent) + { + k = 0; + + while (k < boneParent->numChildren) + { + if (boneParent->children[k] == i) + { //this bone is the child + k++; + while (k < boneParent->numChildren) + { + boneParent->children[k-1] = boneParent->children[k]; + k++; + } + boneParent->children[k-1] = 0; + boneParent->numChildren--; + break; + } + k++; + } + } + + //Now that we have cleared the original parent of ownership, mark the bone's new parent. + int newParent = BoneParentChildIndex(mdxa, offsets, boneInfo, qfalse); + + if (newParent != -1) + { + boneInfo->parent = newParent; + } + else + { + assert(!"Failed to find matching parent for bone in hierarchy creation"); + } + } + } + } + } +#endif //CREATE_LIMB_HIERARCHY + + if ( mdxa->numFrames < 1 ) { + Com_Printf (S_COLOR_YELLOW "R_LoadMDXA: %s has no frames\n", mod_name ); + return qfalse; + } + + if (bAlreadyFound) + { + return qtrue; // All done, stop here, do not LittleLong() etc. Do not pass go... + } + +#if 0 //#ifndef _M_IX86 + + // + // optimisation, we don't bother doing this for standard intel case since our data's already in that format... + // + + // swap all the skeletal info + boneInfo = (mdxaSkel_t *)( (byte *)mdxa + mdxa->ofsSkel); + for ( i = 0 ; i < mdxa->numBones ; i++) + { + LL(boneInfo->numChildren); + LL(boneInfo->parent); + for (k=0; knumChildren; k++) + { + LL(boneInfo->children[k]); + } + + // get next bone + boneInfo += (size_t)( &((mdxaSkel_t *)0)->children[ boneInfo->numChildren ] ); + } + + + // swap all the frames + frameSize = (size_t)( &((mdxaFrame_t *)0)->bones[ mdxa->numBones ] ); + for ( i = 0 ; i < mdxa->numFrames ; i++) + { + cframe = (mdxaFrame_t *) ( (byte *)mdxa + mdxa->ofsFrames + i * frameSize ); + cframe->radius = LittleFloat( cframe->radius ); + for ( j = 0 ; j < 3 ; j++ ) + { + cframe->bounds[0][j] = LittleFloat( cframe->bounds[0][j] ); + cframe->bounds[1][j] = LittleFloat( cframe->bounds[1][j] ); + cframe->localOrigin[j] = LittleFloat( cframe->localOrigin[j] ); + } + for ( j = 0 ; j < mdxa->numBones * sizeof( mdxaBone_t ) / 2 ; j++ ) + { + ((short *)cframe->bones)[j] = LittleShort( ((short *)cframe->bones)[j] ); + } + } +#endif + return qtrue; +} + + + + + + + diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 35a48c6e34..32fa8c18bc 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1640,7 +1640,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he scaled_width <<= 1; scaled_height <<= 1; - FCBIByBlock(*resampledBuffer, scaled_width, scaled_height, clampToEdge, (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)); + FCBIByBlock(*resampledBuffer, scaled_width, scaled_height, clampToEdge, (qboolean)(type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT)); } if (type == IMGTYPE_COLORALPHA) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b2bc199346..6f7185f6cc 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2407,7 +2407,13 @@ IMPLEMENTATION SPECIFIC FUNCTIONS ==================================================================== */ +void GLimp_Init( void ); +void GLimp_Shutdown( void ); +void GLimp_EndFrame( void ); +void GLimp_LogComment( char *comment ); void GLimp_InitExtraExtensions( void ); +void GLimp_Minimize( void ); +void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] ); /* ==================================================================== @@ -2925,5 +2931,18 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, void RE_TakeVideoFrame( int width, int height, byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); +/* +Ghoul2 Insert Start +*/ +// tr_ghoul2.cpp +void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in); +extern qboolean R_LoadMDXM (model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); +extern qboolean R_LoadMDXA (model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); +bool LoadTGAPalletteImage ( const char *name, byte **pic, int *width, int *height); +void RE_InsertModelIntoHash(const char *name, model_t *mod); +/* +Ghoul2 Insert End +*/ + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 6de80b634f..7cbe25acc8 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3673,7 +3673,7 @@ static void ScanAndLoadShaderFiles( void ) p = s_shaderText; // look for shader names while ( 1 ) { - oldp = p; + oldp = (char *)p; token = COM_ParseExt( &p, qtrue ); if ( token[0] == 0 ) { break; From 3e10d389632957291b955ccd8fccf969f45f85ee Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 11:18:34 -0400 Subject: [PATCH 031/708] Fixed infoparms and added new surfaceflags specific to rend2 --- codemp/game/surfaceflags.h | 4 +++ codemp/rd-rend2/tr_shader.cpp | 64 ++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/codemp/game/surfaceflags.h b/codemp/game/surfaceflags.h index c5f5c3ca09..fc5d6cd278 100644 --- a/codemp/game/surfaceflags.h +++ b/codemp/game/surfaceflags.h @@ -50,6 +50,10 @@ #define SURF_NOMISCENTS 0x01000000 // no client models allowed on this surface #define SURF_FORCESIGHT 0x02000000 // not visible without Force Sight +// NEW for rend2 +#define SURF_LIGHTFILTER 0x04000000 // filter light going through the object +#define SURF_ALPHASHADOW 0x08000000 // test light on a per-pixel basis + #define MATERIAL_BITS 5 #define MATERIAL_MASK 0x1f // mask to get the material type diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 7cbe25acc8..74f05ded6b 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1485,46 +1485,48 @@ typedef struct { } infoParm_t; infoParm_t infoParms[] = { + {"nonsolid", ~CONTENTS_SOLID, 0, 0 }, + {"nonopaque", ~CONTENTS_OPAQUE, 0, 0 }, // server relevant contents - {"water", 1, 0, CONTENTS_WATER }, - {"slime", 1, 0, CONTENTS_SLIME }, // mildly damaging - {"lava", 1, 0, CONTENTS_LAVA }, // very damaging - {"playerclip", 1, 0, CONTENTS_PLAYERCLIP }, - {"monsterclip", 1, 0, CONTENTS_MONSTERCLIP }, - {"nodrop", 1, 0, CONTENTS_NODROP }, // don't drop items or leave bodies (death fog, lava, etc) - {"nonsolid", 1, SURF_NONSOLID, 0}, // clears the solid flag + {"water", ~CONTENTS_SOLID, 0, CONTENTS_WATER }, + {"slime", ~CONTENTS_SOLID, 0, CONTENTS_SLIME }, // mildly damaging + {"lava", ~CONTENTS_SOLID, 0, CONTENTS_LAVA }, // very damaging + {"shotclip", ~CONTENTS_SOLID, 0, CONTENTS_SHOTCLIP }, + {"playerclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_PLAYERCLIP }, + {"monsterclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_MONSTERCLIP }, + {"botclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_BOTCLIP }, + {"trigger", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_TRIGGER }, // utility relevant attributes - {"origin", 1, 0, CONTENTS_ORIGIN }, // center of rotating brushes - {"trans", 0, 0, CONTENTS_TRANSLUCENT }, // don't eat contained surfaces - {"detail", 0, 0, CONTENTS_DETAIL }, // don't include in structural bsp - {"structural", 0, 0, CONTENTS_STRUCTURAL }, // force into structural bsp even if trnas - {"areaportal", 1, 0, CONTENTS_AREAPORTAL }, // divides areas - {"clusterportal", 1,0, CONTENTS_CLUSTERPORTAL }, // for bots - {"donotenter", 1, 0, CONTENTS_DONOTENTER }, // for bots - - {"fog", 1, 0, CONTENTS_FOG}, // carves surfaces entering - {"sky", 0, SURF_SKY, 0 }, // emit light from an environment map + {"trans", -1, 0, CONTENTS_TRANSLUCENT }, // don't eat contained surfaces + {"detail", -1, 0, CONTENTS_DETAIL }, // don't include in structural bsp + {"terrain", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_TERRAIN }, /* use special terrain collsion */ + {"outside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_OUTSIDE }, // volume is considered to be in the outside (i.e. not indoors) + {"inside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_INSIDE }, // volume is considered to be inside (i.e. indoors) + + + {"fog", ~CONTENTS_SOLID, 0, CONTENTS_FOG}, // carves surfaces entering + {"sky", -1, SURF_SKY, 0 }, // emit light from an environment map {"lightfilter", 0, SURF_LIGHTFILTER, 0 }, // filter light going through it {"alphashadow", 0, SURF_ALPHASHADOW, 0 }, // test light on a per-pixel basis - {"hint", 0, SURF_HINT, 0 }, // use as a primary splitter // server attributes - {"slick", 0, SURF_SLICK, 0 }, + {"slick", -1, SURF_SLICK, 0 }, {"noimpact", 0, SURF_NOIMPACT, 0 }, // don't make impact explosions or marks {"nomarks", 0, SURF_NOMARKS, 0 }, // don't make impact marks, but still explode - {"ladder", 0, SURF_LADDER, 0 }, - {"nodamage", 0, SURF_NODAMAGE, 0 }, - {"metalsteps", 0, SURF_METALSTEPS,0 }, - {"flesh", 0, SURF_FLESH, 0 }, - {"nosteps", 0, SURF_NOSTEPS, 0 }, - - // drawsurf attributes - {"nodraw", 0, SURF_NODRAW, 0 }, // don't generate a drawsurface (or a lightmap) - {"pointlight", 0, SURF_POINTLIGHT, 0 }, // sample lighting at vertexes - {"nolightmap", 0, SURF_NOLIGHTMAP,0 }, // don't generate a lightmap - {"nodlight", 0, SURF_NODLIGHT, 0 }, // don't ever add dynamic lights - {"dust", 0, SURF_DUST, 0} // leave a dust trail when walking on this surface + {"ladder", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_LADDER }, // climb up in it like water + {"abseil", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_ABSEIL }, // can abseil down this brush + + {"nodamage", -1, SURF_NODAMAGE, 0 }, + {"noimpact", -1, SURF_NOIMPACT, 0 }, /* don't make impact explosions or marks */ + {"nomarks", -1, SURF_NOMARKS, 0 }, /* don't make impact marks, but still explode */ + {"nodraw", -1, SURF_NODRAW, 0 }, /* don't generate a drawsurface (or a lightmap) */ + {"nosteps", -1, SURF_NOSTEPS, 0 }, + {"nodlight", -1, SURF_NODLIGHT, 0 }, /* don't ever add dynamic lights */ + {"metalsteps", -1, SURF_METALSTEPS,0 }, + {"nomiscents", -1, SURF_NOMISCENTS,0 }, /* No misc ents on this surface */ + {"forcefield", -1, SURF_FORCEFIELD,0 }, + {"forcesight", -1, SURF_FORCESIGHT,0 }, }; From 795934a5162f07bc4edc2aa2980048eee34701b9 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 11:24:29 -0400 Subject: [PATCH 032/708] Fixing some bad declarations (or lack thereof) in rend2 --- codemp/rd-rend2/tr_image.cpp | 6 +++--- codemp/rd-rend2/tr_local.h | 4 ++++ codemp/rd-rend2/tr_shader.cpp | 2 +- codemp/rd-vanilla/tr_shader.cpp | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 32fa8c18bc..82728256cd 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1560,7 +1560,7 @@ RawImage_ScaleToPower2 =============== */ -static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_height, int *inout_scaled_width, int *inout_scaled_height, imgType_t type, imgFlags_t flags, byte **resampledBuffer) +static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_height, int *inout_scaled_width, int *inout_scaled_height, imgType_t type, int flags, byte **resampledBuffer) { int width = *inout_width; int height = *inout_height; @@ -1909,7 +1909,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } -static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, imgFlags_t flags, qboolean subtexture ) +static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, int flags, qboolean subtexture ) { int dataFormat, dataType; @@ -2530,7 +2530,7 @@ Finds or loads the given image. Returns NULL if it fails, not a default image. ============== */ -image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags ) +image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) { image_t *image; int width, height; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6f7185f6cc..ab5e60cae8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2944,5 +2944,9 @@ void RE_InsertModelIntoHash(const char *name, model_t *mod); Ghoul2 Insert End */ +image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); +qhandle_t RE_RegisterShader( const char *name ); +qhandle_t RE_RegisterShaderNoMip( const char *name ); + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 74f05ded6b..a3a50441b2 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1526,7 +1526,7 @@ infoParm_t infoParms[] = { {"metalsteps", -1, SURF_METALSTEPS,0 }, {"nomiscents", -1, SURF_NOMISCENTS,0 }, /* No misc ents on this surface */ {"forcefield", -1, SURF_FORCEFIELD,0 }, - {"forcesight", -1, SURF_FORCESIGHT,0 }, + {"forcesight", -1, SURF_FORCESIGHT,0 } }; diff --git a/codemp/rd-vanilla/tr_shader.cpp b/codemp/rd-vanilla/tr_shader.cpp index b9a1f3a483..2d60361507 100644 --- a/codemp/rd-vanilla/tr_shader.cpp +++ b/codemp/rd-vanilla/tr_shader.cpp @@ -2462,7 +2462,7 @@ infoParm_t infoParms[] = { {"metalsteps", -1, SURF_METALSTEPS,0 }, {"nomiscents", -1, SURF_NOMISCENTS,0 }, /* No misc ents on this surface */ {"forcefield", -1, SURF_FORCEFIELD,0 }, - {"forcesight", -1, SURF_FORCESIGHT,0 }, // only visible with force sight + {"forcesight", -1, SURF_FORCESIGHT,0 } // only visible with force sight }; From 935c25fb5a1ad7330fde911cca4dbc97b69e5345 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 11:43:55 -0400 Subject: [PATCH 033/708] [rend2] Add support for the various RT_ types which are specific to JA. --- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_main.cpp | 34 +- codemp/rd-rend2/tr_surface.cpp | 734 ++++++++++++++++++++++++++++++++- 3 files changed, 765 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ab5e60cae8..d134ed103f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2947,6 +2947,7 @@ Ghoul2 Insert End image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); +image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ); #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 17ad764571..2a9b7df705 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1969,9 +1969,12 @@ static void R_AddEntitySurface (int entityNum) break; // don't draw anything case RT_SPRITE: case RT_BEAM: - case RT_LIGHTNING: - case RT_RAIL_CORE: - case RT_RAIL_RINGS: + case RT_ORIENTED_QUAD: + case RT_ELECTRICITY: + case RT_LINE: + case RT_ORIENTEDLINE: + case RT_CYLINDER: + case RT_SABER_GLOW: // self blood sprites, talk balloons, etc should not be drawn in the primary // view. We can't just do this check for all entities, because md3 // entities may still want to cast shadows from them @@ -2006,10 +2009,31 @@ static void R_AddEntitySurface (int entityNum) case MOD_BRUSH: R_AddBrushModelSurfaces( ent ); break; + /* + Ghoul 2 Insert Start + */ + case MOD_MDXM: + //g2r + if (ent->e.ghoul2) + R_AddGhoulSurfaces(ent); + /* + Ghoul 2 Insert End + */ case MOD_BAD: // null model axis if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { break; } + /* + Ghoul 2 Insert Start + */ + if( ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2)) ) + { + R_AddGhoulSurfaces( ent ); + break; + } + /* + Ghoul 2 Insert End + */ R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); break; default: @@ -2018,6 +2042,10 @@ static void R_AddEntitySurface (int entityNum) } } break; + case RT_ENT_CHAIN: + shader = R_GetShaderByHandle( ent->e.customShader ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false ); + break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index a1abf9f94d..b759dad92b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -274,6 +274,55 @@ static void RB_SurfaceSprite( void ) { RB_AddQuadStamp( ent->e.origin, left, up, colors ); } +/* +======================= +RB_SurfaceOrientedQuad +======================= +*/ +static void RB_SurfaceOrientedQuad( void ) +{ + vec3_t left, up; + float radius; + + // calculate the xyz locations for the four corners + radius = backEnd.currentEntity->e.radius; +// MakeNormalVectors( backEnd.currentEntity->e.axis[0], left, up ); + VectorCopy( backEnd.currentEntity->e.axis[1], left ); + VectorCopy( backEnd.currentEntity->e.axis[2], up ); + + if ( backEnd.currentEntity->e.rotation == 0 ) + { + VectorScale( left, radius, left ); + VectorScale( up, radius, up ); + } + else + { + vec3_t tempLeft, tempUp; + float s, c; + float ang; + + ang = M_PI * backEnd.currentEntity->e.rotation / 180; + s = sin( ang ); + c = cos( ang ); + + // Use a temp so we don't trash the values we'll need later + VectorScale( left, c * radius, tempLeft ); + VectorMA( tempLeft, -s * radius, up, tempLeft ); + + VectorScale( up, c * radius, tempUp ); + VectorMA( tempUp, s * radius, left, up ); // no need to use the temp anymore, so copy into the dest vector ( up ) + + // This was copied for safekeeping, we're done, so we can move it back to left + VectorCopy( tempLeft, left ); + } + + if ( backEnd.viewParms.isMirror ) + { + VectorSubtract( vec3_origin, left, left ); + } + + RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, backEnd.currentEntity->e.shaderRGBA ); +} /* ============= @@ -627,6 +676,647 @@ static void RB_SurfaceBeam( void ) tess.maxIndex = 0; } +//------------------ +// DoSprite +//------------------ +static void DoSprite( vec3_t origin, float radius, float rotation ) +{ + float s, c; + float ang; + vec3_t left, up; + + ang = M_PI * rotation / 180.0f; + s = sin( ang ); + c = cos( ang ); + + VectorScale( backEnd.viewParms.ori.axis[1], c * radius, left ); + VectorMA( left, -s * radius, backEnd.viewParms.ori.axis[2], left ); + + VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); + VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); + + if ( backEnd.viewParms.isMirror ) + { + VectorSubtract( vec3_origin, left, left ); + } + + RB_AddQuadStamp( origin, left, up, backEnd.currentEntity->e.shaderRGBA ); +} + +//------------------ +// RB_SurfaceSaber +//------------------ +static void RB_SurfaceSaberGlow() +{ + vec3_t end; + refEntity_t *e; + + e = &backEnd.currentEntity->e; + + // Render the glow part of the blade + for ( float i = e->saberLength; i > 0; i -= e->radius * 0.65f ) + { + VectorMA( e->origin, i, e->axis[0], end ); + + DoSprite( end, e->radius, 0.0f );//random() * 360.0f ); + e->radius += 0.017f; + } + + // Big hilt sprite + // Please don't kill me Pat...I liked the hilt glow blob, but wanted a subtle pulse.:) Feel free to ditch it if you don't like it. --Jeff + // Please don't kill me Jeff... The pulse is good, but now I want the halo bigger if the saber is shorter... --Pat + DoSprite( e->origin, 5.5f + random() * 0.25f, 0.0f );//random() * 360.0f ); +} + +/* +============== +RB_SurfaceLine +============== +*/ +// +// Values for a proper line render primitive... +// Width +// STScale (how many times to loop a texture) +// alpha +// RGB +// +// Values for proper line object... +// lifetime +// dscale +// startalpha, endalpha +// startRGB, endRGB +// + +static void DoLine( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth ) +{ + float spanWidth2; + int vbase; + + RB_CHECKOVERFLOW( 4, 6 ); + + vbase = tess.numVertexes; + + spanWidth2 = -spanWidth; + + VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25;//wtf??not sure why the code would be doing this + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); + + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; + tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 3; +} + +static void DoLine2( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth, float spanWidth2 ) +{ + int vbase; + + RB_CHECKOVERFLOW( 4, 6 ); + + vbase = tess.numVertexes; + + VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25;//wtf??not sure why the code would be doing this + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA( start, -spanWidth, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); + + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + VectorMA( end, -spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; + tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 3; +} + +static void DoLine_Oriented( const vec3_t start, const vec3_t end, const vec3_t up, float spanWidth ) +{ + float spanWidth2; + int vbase; + + vbase = tess.numVertexes; + + spanWidth2 = -spanWidth; + + // FIXME: use quad stamp? + VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = 0; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); + + tess.texCoords[tess.numVertexes][0][0] = 0; + tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = 1; + tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; + tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; + tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; + tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; + tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + tess.numVertexes++; + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 3; +} + +//----------------- +// RB_SurfaceLine +//----------------- +static void RB_SurfaceLine( void ) +{ + refEntity_t *e; + vec3_t right; + vec3_t start, end; + vec3_t v1, v2; + + e = &backEnd.currentEntity->e; + + VectorCopy( e->oldorigin, end ); + VectorCopy( e->origin, start ); + + // compute side vector + VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); + CrossProduct( v1, v2, right ); + VectorNormalize( right ); + + DoLine( start, end, right, e->radius); +} + +static void RB_SurfaceOrientedLine( void ) +{ + refEntity_t *e; + vec3_t right; + vec3_t start, end; + + e = &backEnd.currentEntity->e; + + VectorCopy( e->oldorigin, end ); + VectorCopy( e->origin, start ); + + // compute side vector + VectorNormalize( e->axis[1] ); + VectorCopy(e->axis[1], right); + DoLine_Oriented( start, end, right, e->data.line.width*0.5 ); +} + +/* +============== +RB_SurfaceCylinder +============== +*/ + +#define NUM_CYLINDER_SEGMENTS 32 + +// FIXME: use quad stamp? +static void DoCylinderPart(polyVert_t *verts) +{ + int vbase; + int i; + + RB_CHECKOVERFLOW( 4, 6 ); + + vbase = tess.numVertexes; + + for (i=0; i<4; i++) + { + VectorCopy( verts->xyz, tess.xyz[tess.numVertexes] ); + tess.texCoords[tess.numVertexes][0][0] = verts->st[0]; + tess.texCoords[tess.numVertexes][0][1] = verts->st[1]; + tess.vertexColors[tess.numVertexes][0] = verts->modulate[0]; + tess.vertexColors[tess.numVertexes][1] = verts->modulate[1]; + tess.vertexColors[tess.numVertexes][2] = verts->modulate[2]; + tess.vertexColors[tess.numVertexes][3] = verts->modulate[3]; + tess.numVertexes++; + verts++; + } + + tess.indexes[tess.numIndexes++] = vbase; + tess.indexes[tess.numIndexes++] = vbase + 1; + tess.indexes[tess.numIndexes++] = vbase + 2; + + tess.indexes[tess.numIndexes++] = vbase + 2; + tess.indexes[tess.numIndexes++] = vbase + 3; + tess.indexes[tess.numIndexes++] = vbase; +} + +// e->origin holds the bottom point +// e->oldorigin holds the top point +// e->radius holds the radius + +static void RB_SurfaceCylinder( void ) +{ + static polyVert_t lower_points[NUM_CYLINDER_SEGMENTS], upper_points[NUM_CYLINDER_SEGMENTS], verts[4]; + vec3_t vr, vu, midpoint, v1; + float detail, length; + int i; + int segments; + refEntity_t *e; + int nextSegment; + + e = &backEnd.currentEntity->e; + + //Work out the detail level of this cylinder + VectorAdd( e->origin, e->oldorigin, midpoint ); + VectorScale(midpoint, 0.5f, midpoint); // Average start and end + + VectorSubtract( midpoint, backEnd.viewParms.ori.origin, midpoint ); + length = VectorNormalize( midpoint ); + + // this doesn't need to be perfect....just a rough compensation for zoom level is enough + length *= (backEnd.viewParms.fovX / 90.0f); + + detail = 1 - ((float) length / 1024 ); + segments = NUM_CYLINDER_SEGMENTS * detail; + + // 3 is the absolute minimum, but the pop between 3-8 is too noticeable + if ( segments < 8 ) + { + segments = 8; + } + + if ( segments > NUM_CYLINDER_SEGMENTS ) + { + segments = NUM_CYLINDER_SEGMENTS; + } + + //Get the direction vector + MakeNormalVectors( e->axis[0], vr, vu ); + + VectorScale( vu, e->radius, v1 ); // size1 + VectorScale( vu, e->rotation, vu ); // size2 + + // Calculate the step around the cylinder + detail = 360.0f / (float)segments; + + for ( i = 0; i < segments; i++ ) + { + //Upper ring + RotatePointAroundVector( upper_points[i].xyz, e->axis[0], vu, detail * i ); + VectorAdd( upper_points[i].xyz, e->origin, upper_points[i].xyz ); + + //Lower ring + RotatePointAroundVector( lower_points[i].xyz, e->axis[0], v1, detail * i ); + VectorAdd( lower_points[i].xyz, e->oldorigin, lower_points[i].xyz ); + } + + // Calculate the texture coords so the texture can wrap around the whole cylinder + detail = 1.0f / (float)segments; + + for ( i = 0; i < segments; i++ ) + { + if ( i + 1 < segments ) + nextSegment = i + 1; + else + nextSegment = 0; + + VectorCopy( upper_points[i].xyz, verts[0].xyz ); + verts[0].st[1] = 1.0f; + verts[0].st[0] = detail * i; + verts[0].modulate[0] = (byte)(e->shaderRGBA[0]); + verts[0].modulate[1] = (byte)(e->shaderRGBA[1]); + verts[0].modulate[2] = (byte)(e->shaderRGBA[2]); + verts[0].modulate[3] = (byte)(e->shaderRGBA[3]); + + VectorCopy( lower_points[i].xyz, verts[1].xyz ); + verts[1].st[1] = 0.0f; + verts[1].st[0] = detail * i; + verts[1].modulate[0] = (byte)(e->shaderRGBA[0]); + verts[1].modulate[1] = (byte)(e->shaderRGBA[1]); + verts[1].modulate[2] = (byte)(e->shaderRGBA[2]); + verts[1].modulate[3] = (byte)(e->shaderRGBA[3]); + + VectorCopy( lower_points[nextSegment].xyz, verts[2].xyz ); + verts[2].st[1] = 0.0f; + verts[2].st[0] = detail * ( i + 1 ); + verts[2].modulate[0] = (byte)(e->shaderRGBA[0]); + verts[2].modulate[1] = (byte)(e->shaderRGBA[1]); + verts[2].modulate[2] = (byte)(e->shaderRGBA[2]); + verts[2].modulate[3] = (byte)(e->shaderRGBA[3]); + + VectorCopy( upper_points[nextSegment].xyz, verts[3].xyz ); + verts[3].st[1] = 1.0f; + verts[3].st[0] = detail * ( i + 1 ); + verts[3].modulate[0] = (byte)(e->shaderRGBA[0]); + verts[3].modulate[1] = (byte)(e->shaderRGBA[1]); + verts[3].modulate[2] = (byte)(e->shaderRGBA[2]); + verts[3].modulate[3] = (byte)(e->shaderRGBA[3]); + + DoCylinderPart(verts); + } +} + +static vec3_t sh1, sh2; +static float f_count; + +#define LIGHTNING_RECURSION_LEVEL 1 // was 2 + +// these functions are pretty crappy in terms of returning a nice range of rnd numbers, but it's probably good enough? +/*static int Q_rand( int *seed ) { + *seed = (69069 * *seed + 1); + return *seed; +} + +static float Q_random( int *seed ) { + return ( Q_rand( seed ) & 0xffff ) / (float)0x10000; +} + +static float Q_crandom( int *seed ) { + return 2.0F * ( Q_random( seed ) - 0.5f ); +} +*/ +// Up front, we create a random "shape", then apply that to each line segment...and then again to each of those segments...kind of like a fractal +//---------------------------------------------------------------------------- +static void CreateShape() +//---------------------------------------------------------------------------- +{ + VectorSet( sh1, 0.66f + crandom() * 0.1f, // fwd + 0.07f + crandom() * 0.025f, + 0.07f + crandom() * 0.025f ); + + // it seems to look best to have a point on one side of the ideal line, then the other point on the other side. + VectorSet( sh2, 0.33f + crandom() * 0.1f, // fwd + -sh1[1] + crandom() * 0.02f, // forcing point to be on the opposite side of the line -- right + -sh1[2] + crandom() * 0.02f );// up +} + +//---------------------------------------------------------------------------- +static void ApplyShape( vec3_t start, vec3_t end, vec3_t right, float sradius, float eradius, int count ) +//---------------------------------------------------------------------------- +{ + vec3_t point1, point2, fwd; + vec3_t rt, up; + float perc, dis; + + if ( count < 1 ) + { + // done recursing + DoLine2( start, end, right, sradius, eradius ); + return; + } + + CreateShape(); + + VectorSubtract( end, start, fwd ); + dis = VectorNormalize( fwd ) * 0.7f; + MakeNormalVectors( fwd, rt, up ); + + perc = sh1[0]; + + VectorScale( start, perc, point1 ); + VectorMA( point1, 1.0f - perc, end, point1 ); + VectorMA( point1, dis * sh1[1], rt, point1 ); + VectorMA( point1, dis * sh1[2], up, point1 ); + + // do a quick and dirty interpolation of the radius at that point + float rads1, rads2; + + rads1 = sradius * 0.666f + eradius * 0.333f; + rads2 = sradius * 0.333f + eradius * 0.666f; + + // recursion + ApplyShape( start, point1, right, sradius, rads1, count - 1 ); + + perc = sh2[0]; + + VectorScale( start, perc, point2 ); + VectorMA( point2, 1.0f - perc, end, point2 ); + VectorMA( point2, dis * sh2[1], rt, point2 ); + VectorMA( point2, dis * sh2[2], up, point2 ); + + // recursion + ApplyShape( point2, point1, right, rads1, rads2, count - 1 ); + ApplyShape( point2, end, right, rads2, eradius, count - 1 ); +} + +//---------------------------------------------------------------------------- +static void DoBoltSeg( vec3_t start, vec3_t end, vec3_t right, float radius ) +//---------------------------------------------------------------------------- +{ + refEntity_t *e; + vec3_t fwd, old; + vec3_t cur, off={10,10,10}; + vec3_t rt, up; + vec3_t temp; + int i; + float dis, oldPerc = 0.0f, perc, oldRadius, newRadius; + + e = &backEnd.currentEntity->e; + + VectorSubtract( end, start, fwd ); + dis = VectorNormalize( fwd ); + + MakeNormalVectors( fwd, rt, up ); + + VectorCopy( start, old ); + + oldRadius = newRadius = radius; + + for ( i = 20; i <= dis; i+= 20 ) + { + // because of our large step size, we may not actually draw to the end. In this case, fudge our percent so that we are basically complete + if ( i + 20 > dis ) + { + perc = 1.0f; + } + else + { + // percentage of the amount of line completed + perc = (float)i / dis; + } + + // create our level of deviation for this point + VectorScale( fwd, Q_crandom(&e->frame) * 3.0f, temp ); // move less in fwd direction, chaos also does not affect this + VectorMA( temp, Q_crandom(&e->frame) * 7.0f * e->axis[0][0], rt, temp ); // move more in direction perpendicular to line, angles is really the chaos + VectorMA( temp, Q_crandom(&e->frame) * 7.0f * e->axis[0][0], up, temp ); // move more in direction perpendicular to line + + // track our total level of offset from the ideal line + VectorAdd( off, temp, off ); + + // Move from start to end, always adding our current level of offset from the ideal line + // Even though we are adding a random offset.....by nature, we always move from exactly start....to end + VectorAdd( start, off, cur ); + VectorScale( cur, 1.0f - perc, cur ); + VectorMA( cur, perc, end, cur ); + + if ( e->renderfx & RF_TAPERED ) + { + // This does pretty close to perfect tapering since apply shape interpolates the old and new as it goes along. + // by using one minus the square, the radius stays fairly constant, then drops off quickly at the very point of the bolt + oldRadius = radius * (1.0f-oldPerc*oldPerc); + newRadius = radius * (1.0f-perc*perc); + } + + // Apply the random shape to our line seg to give it some micro-detail-jaggy-coolness. + ApplyShape( cur, old, right, newRadius, oldRadius, LIGHTNING_RECURSION_LEVEL ); + + // randomly split off to create little tendrils, but don't do it too close to the end and especially if we are not even of the forked variety + if ( ( e->renderfx & RF_FORKED ) && f_count > 0 && Q_random(&e->frame) > 0.94f && radius * (1.0f - perc) > 0.2f ) + { + vec3_t newDest; + + f_count--; + + // Pick a point somewhere between the current point and the final endpoint + VectorAdd( cur, e->oldorigin, newDest ); + VectorScale( newDest, 0.5f, newDest ); + + // And then add some crazy offset + for ( int t = 0; t < 3; t++ ) + { + newDest[t] += Q_crandom(&e->frame) * 80; + } + + // we could branch off using OLD and NEWDEST, but that would allow multiple forks...whereas, we just want simpler brancing + DoBoltSeg( cur, newDest, right, newRadius ); + } + + // Current point along the line becomes our new old attach point + VectorCopy( cur, old ); + oldPerc = perc; + } +} + +//------------------------------------------ +static void RB_SurfaceElectricity() +//------------------------------------------ +{ + refEntity_t *e; + vec3_t right, fwd; + vec3_t start, end; + vec3_t v1, v2; + float radius, perc = 1.0f, dis; + + e = &backEnd.currentEntity->e; + radius = e->radius; + + VectorCopy( e->origin, start ); + + VectorSubtract( e->oldorigin, start, fwd ); + dis = VectorNormalize( fwd ); + + // see if we should grow from start to end + if ( e->renderfx & RF_GROW ) + { + perc = 1.0f - ( e->axis[0][2]/*endTime*/ - tr.refdef.time ) / e->axis[0][1]/*duration*/; + + if ( perc > 1.0f ) + { + perc = 1.0f; + } + else if ( perc < 0.0f ) + { + perc = 0.0f; + } + } + + VectorMA( start, perc * dis, fwd, e->oldorigin ); + VectorCopy( e->oldorigin, end ); + + // compute side vector + VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); + CrossProduct( v1, v2, right ); + VectorNormalize( right ); + + DoBoltSeg( start, end, right, radius ); +} + //================================================================================ /* @@ -1335,10 +2025,52 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { case RT_SPRITE: RB_SurfaceSprite(); break; + case RT_ORIENTED_QUAD: + RB_SurfaceOrientedQuad(); + break; case RT_BEAM: RB_SurfaceBeam(); break; -#pragma error("HALT! You need to add cases for RT_ORIENTED_QUAD, RT_ELECTRICITY, RT_LINE, RT_ORIENTEDLINE, RT_SABER_GLOW, RT_CYLINDER and RT_ENT_CHAIN to RB_SurfaceEntity!!") + case RT_ELECTRICITY: + RB_SurfaceElectricity(); + break; + case RT_LINE: + RB_SurfaceLine(); + break; + case RT_ORIENTEDLINE: + RB_SurfaceOrientedLine(); + break; + case RT_SABER_GLOW: + RB_SurfaceSaberGlow(); + break; + case RT_CYLINDER: + RB_SurfaceCylinder(); + break; + case RT_ENT_CHAIN: + { + int i, count, start; + static trRefEntity_t tempEnt = *backEnd.currentEntity; + //rww - if not static then currentEntity is garbage because + //this is a local. This was not static in sof2.. but I guess + //they never check ce.renderfx so it didn't show up. + + start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; + count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; + assert(count > 0); + backEnd.currentEntity = &tempEnt; + + assert(backEnd.currentEntity->e.renderfx >= 0); + + for(i=0;ie, &backEnd.refdef.miniEntities[start+i], sizeof(backEnd.refdef.miniEntities[start+i])); + + assert(backEnd.currentEntity->e.renderfx >= 0); + + RB_SurfaceEntity(surfType); + } + } + break; default: RB_SurfaceAxis(); break; From cb80d2c8eeec92ba573af117897eb55e9cd853f2 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 13:10:48 -0400 Subject: [PATCH 034/708] Only issues in the lightmap stuff and ghoul2 for now --- codemp/rd-common/tr_types.h | 3 +++ codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_local.h | 3 ++- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 5 +++-- codemp/rd-rend2/tr_surface.cpp | 24 ++++++++++++------------ 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h index e23729b2b6..afe2169f05 100644 --- a/codemp/rd-common/tr_types.h +++ b/codemp/rd-common/tr_types.h @@ -350,6 +350,9 @@ typedef struct glconfig_s { // used CDS. qboolean isFullscreen; qboolean stereoEnabled; + + // specific to rend2 + int numTextureUnits; } glconfig_t; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 82728256cd..0779d85c09 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3342,7 +3342,7 @@ void R_SkinList_f( void ) { ri->Printf( PRINT_ALL, "%3i:%s\n", i, skin->name ); for ( j = 0 ; j < skin->numSurfaces ; j++ ) { ri->Printf( PRINT_ALL, " %s = %s\n", - skin->surfaces[j]->name, skin->surfaces[j]->shader->name ); + skin->surfaces[j]->name, ((shader_t*)skin->surfaces[j]->shader)->name ); } } ri->Printf (PRINT_ALL, "------------------\n"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d134ed103f..77de91d4be 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -305,7 +305,6 @@ typedef struct dlight_s { int additive; // texture detail is lost tho when the lightmap is dark } dlight_t; - // a trRefEntity_t has all the information passed in by // the client game, as well as some locally derived info typedef struct { @@ -2949,5 +2948,7 @@ qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ); +extern qboolean textureFilterAnisotropic; +extern int maxAnisotropy; #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 2a9b7df705..aadb621f01 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2044,7 +2044,7 @@ static void R_AddEntitySurface (int entityNum) break; case RT_ENT_CHAIN: shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, qfalse ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index a3a50441b2..fb42971c84 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3607,14 +3607,15 @@ static void ScanAndLoadShaderFiles( void ) break; } - if(!SkipBracedSection(&p)) + SkipBracedSection(&p); + /*if(!SkipBracedSection(&p)) { ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); ri->FS_FreeFile(buffers[i]); buffers[i] = NULL; break; - } + }*/ } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b759dad92b..3e8124104d 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -321,7 +321,7 @@ static void RB_SurfaceOrientedQuad( void ) VectorSubtract( vec3_origin, left, left ); } - RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, backEnd.currentEntity->e.shaderRGBA ); + RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, (float *)backEnd.currentEntity->e.shaderRGBA ); } /* @@ -689,18 +689,18 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) s = sin( ang ); c = cos( ang ); - VectorScale( backEnd.viewParms.ori.axis[1], c * radius, left ); - VectorMA( left, -s * radius, backEnd.viewParms.ori.axis[2], left ); + VectorScale( backEnd.viewParms.or.axis[1], c * radius, left ); + VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left ); - VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); - VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); + VectorScale( backEnd.viewParms.or.axis[2], c * radius, up ); + VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up ); if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); } - RB_AddQuadStamp( origin, left, up, backEnd.currentEntity->e.shaderRGBA ); + RB_AddQuadStamp( origin, left, up, (float *)backEnd.currentEntity->e.shaderRGBA ); } //------------------ @@ -930,8 +930,8 @@ static void RB_SurfaceLine( void ) VectorCopy( e->origin, start ); // compute side vector - VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); - VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); + VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); CrossProduct( v1, v2, right ); VectorNormalize( right ); @@ -1015,7 +1015,7 @@ static void RB_SurfaceCylinder( void ) VectorAdd( e->origin, e->oldorigin, midpoint ); VectorScale(midpoint, 0.5f, midpoint); // Average start and end - VectorSubtract( midpoint, backEnd.viewParms.ori.origin, midpoint ); + VectorSubtract( midpoint, backEnd.viewParms.or.origin, midpoint ); length = VectorNormalize( midpoint ); // this doesn't need to be perfect....just a rough compensation for zoom level is enough @@ -1309,8 +1309,8 @@ static void RB_SurfaceElectricity() VectorCopy( e->oldorigin, end ); // compute side vector - VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); - VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); + VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); CrossProduct( v1, v2, right ); VectorNormalize( right ); @@ -2063,7 +2063,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { for(i=0;ie, &backEnd.refdef.miniEntities[start+i], sizeof(backEnd.refdef.miniEntities[start+i])); + memcpy(&backEnd.currentEntity->e, &backEnd.refdef.entities[start+i].e, sizeof(backEnd.refdef.entities[start+i].e)); assert(backEnd.currentEntity->e.renderfx >= 0); From cfc6be1dd053e22b94d70452b6a900b2e987102e Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 13:19:04 -0400 Subject: [PATCH 035/708] [rend2] use the 0th lightmap until I get the system operational and can start worrying about differences in BSP format --- codemp/rd-rend2/tr_bsp.cpp | 58 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d097f089a0..50b26a2c5a 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -233,7 +233,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.worldDeluxeMapping = qtrue; for( i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); i < surfs->filelen / sizeof(dsurface_t); i++, surf++ ) { - int lightmapNum = LittleLong( surf->lightmapNum ); + int lightmapNum = LittleLong( surf->lightmapNum[0] ); if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { tr.worldDeluxeMapping = qfalse; @@ -669,7 +669,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, int numVerts, numTriangles, badTriangles; int realLightmapNum; - realLightmapNum = LittleLong( ds->lightmapNum ); + realLightmapNum = LittleLong( ds->lightmapNum[0] ); // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -718,8 +718,8 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); //cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); } - cv->verts[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0]), realLightmapNum); - cv->verts[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[1]), realLightmapNum); + cv->verts[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0][0]), realLightmapNum); + cv->verts[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[0][1]), realLightmapNum); if (hdrVertColors) { @@ -732,19 +732,19 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[0] + 1.0f; - color[1] = verts[i].color[1] + 1.0f; - color[2] = verts[i].color[2] + 1.0f; + color[0] = verts[i].color[0][0] + 1.0f; + color[1] = verts[i].color[0][1] + 1.0f; + color[2] = verts[i].color[0][2] + 1.0f; } else { - color[0] = verts[i].color[0]; - color[1] = verts[i].color[1]; - color[2] = verts[i].color[2]; + color[0] = verts[i].color[0][0]; + color[1] = verts[i].color[0][1]; + color[2] = verts[i].color[0][2]; } } - color[3] = verts[i].color[3] / 255.0f; + color[3] = verts[i].color[0][3] / 255.0f; R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); } @@ -821,7 +821,7 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, static surfaceType_t skipData = SF_SKIP; int realLightmapNum; - realLightmapNum = LittleLong( ds->lightmapNum ); + realLightmapNum = LittleLong( ds->lightmapNum[0] ); // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -862,8 +862,8 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, points[i].st[j] = LittleFloat(verts[i].st[j]); //points[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); } - points[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0]), realLightmapNum); - points[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[1]), realLightmapNum); + points[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0][0]), realLightmapNum); + points[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[0][1]), realLightmapNum); if (hdrVertColors) { @@ -876,18 +876,18 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[0] + 1.0f; - color[1] = verts[i].color[1] + 1.0f; - color[2] = verts[i].color[2] + 1.0f; + color[0] = verts[i].color[0][0] + 1.0f; + color[1] = verts[i].color[0][1] + 1.0f; + color[2] = verts[i].color[0][2] + 1.0f; } else { - color[0] = verts[i].color[0]; - color[1] = verts[i].color[1]; - color[2] = verts[i].color[2]; + color[0] = verts[i].color[0][0]; + color[1] = verts[i].color[0][1]; + color[2] = verts[i].color[0][2]; } } - color[3] = verts[i].color[3] / 255.0f; + color[3] = verts[i].color[0][3] / 255.0f; R_ColorShiftLightingFloats( color, points[i].vertexColors, 1.0f / 255.0f ); } @@ -963,7 +963,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor for(j = 0; j < 2; j++) { cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); - cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); + cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[0][j]); } if (hdrVertColors) @@ -977,18 +977,18 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[0] + 1.0f; - color[1] = verts[i].color[1] + 1.0f; - color[2] = verts[i].color[2] + 1.0f; + color[0] = verts[i].color[0][0] + 1.0f; + color[1] = verts[i].color[0][1] + 1.0f; + color[2] = verts[i].color[0][2] + 1.0f; } else { - color[0] = verts[i].color[0]; - color[1] = verts[i].color[1]; - color[2] = verts[i].color[2]; + color[0] = verts[i].color[0][0]; + color[1] = verts[i].color[0][1]; + color[2] = verts[i].color[0][2]; } } - color[3] = verts[i].color[3] / 255.0f; + color[3] = verts[i].color[0][3] / 255.0f; R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); } From f90a020e0d1d42302a5f521fe1cbde83863d27f4 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 17:22:17 -0400 Subject: [PATCH 036/708] [rend2] Fix some Ghoul2 issues --- codemp/rd-rend2/tr_ghoul2.cpp | 22 +++------- codemp/rd-rend2/tr_local.h | 78 +++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 87b93def45..82ddd7a8fd 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2456,7 +2456,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from newSurf->surfaceData = surface; } newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse, qfalse ); } // projection shadows work fine with personal models @@ -2468,7 +2468,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from CRenderableSurface *newSurf = new CRenderableSurface; newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse, qfalse ); } // don't add third_person objects if not viewing through a portal @@ -2477,7 +2477,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from CRenderableSurface *newSurf = new CRenderableSurface; newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, qfalse ); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2557,7 +2557,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, qfalse ); } } } @@ -3178,8 +3178,8 @@ static void RootMatrix(CGhoul2Info_v &ghoul2,int time,const vec3_t scale,mdxaBon extern cvar_t *r_shadowRange; static inline bool bInShadowRange(vec3_t location) { - const float c = DotProduct( tr.viewParms.ori.axis[0], tr.viewParms.ori.origin ); - const float dist = DotProduct( tr.viewParms.ori.axis[0], location ) - c; + const float c = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin ); + const float dist = DotProduct( tr.viewParms.or.axis[0], location ) - c; // return (dist < tr.distanceCull/1.5f); return (dist < r_shadowRange->value); @@ -3783,16 +3783,6 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) } } - - // NOTE: This is required because a ghoul model might need to be rendered twice a frame (don't cringe, - // it's not THAT bad), so we only delete it when doing the glow pass. Warning though, this assumes that - // the glow is rendered _second_!!! If that changes, change this! - extern bool g_bRenderGlowingObjects; - extern bool g_bDynamicGlowSupported; - if ( !tess.shader->hasGlow || g_bRenderGlowingObjects || !g_bDynamicGlowSupported || !r_DynamicGlow->integer ) - { - delete storeSurf; - } #endif tess.numVertexes += surface->numVerts; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 77de91d4be..31da66a102 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1174,6 +1174,13 @@ typedef enum { SF_MD4, SF_MDR, SF_IQM, +/* +Ghoul2 Insert Start +*/ + SF_MDX, +/* +Ghoul2 Insert End +*/ SF_FLARE, SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity SF_DISPLAY_LIST, @@ -2476,6 +2483,9 @@ typedef struct shaderCommands_s int numPasses; void (*currentStageIteratorFunc)( void ); shaderStage_t **xstages; + + // JA specific + bool fading; } shaderCommands_t; extern shaderCommands_t tess; @@ -2703,6 +2713,74 @@ int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, int startFrame, int endFrame, float frac, const char *tagName ); +/* +Ghoul2 Insert Start +*/ +#ifdef _MSC_VER +#pragma warning (disable: 4512) //default assignment operator could not be gened +#endif +class CRenderableSurface +{ +public: +#ifdef _G2_GORE + int ident; +#else + const int ident; // ident of this surface - required so the materials renderer knows what sort of surface this refers to +#endif + CBoneCache *boneCache; + mdxmSurface_t *surfaceData; // pointer to surface data loaded into file - only used by client renderer DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of wack on the game +#ifdef _G2_GORE + float *alternateTex; // alternate texture coordinates. + void *goreChain; + + float scale; + float fade; + float impactTime; // this is a number between 0 and 1 that dictates the progression of the bullet impact +#endif + +#ifdef _G2_GORE + CRenderableSurface& operator= ( const CRenderableSurface& src ) + { + ident = src.ident; + boneCache = src.boneCache; + surfaceData = src.surfaceData; + alternateTex = src.alternateTex; + goreChain = src.goreChain; + + return *this; + } +#endif + +CRenderableSurface(): + ident(SF_MDX), + boneCache(0), +#ifdef _G2_GORE + surfaceData(0), + alternateTex(0), + goreChain(0) +#else + surfaceData(0) +#endif + {} + +#ifdef _G2_GORE + void Init() + { + ident = SF_MDX; + boneCache=0; + surfaceData=0; + alternateTex=0; + goreChain=0; + } +#endif +}; + +void R_AddGhoulSurfaces( trRefEntity_t *ent ); +void RB_SurfaceGhoul( CRenderableSurface *surface ); +/* +Ghoul2 Insert End +*/ + /* ============================================================= From 9b9aed619a1bd9e8df692a24c4ec1114dad1adc4 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 17:35:58 -0400 Subject: [PATCH 037/708] [rend2] Added in missing cvar r_autolodscalevalue (and also applied it like how JA uses it) --- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_mesh.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 29795dcdaf..5dfb487cb4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -69,6 +69,7 @@ cvar_t *r_dlightBacks; cvar_t *r_lodbias; cvar_t *r_lodscale; +cvar_t *r_autolodscalevalue; cvar_t *r_norefresh; cvar_t *r_drawentities; @@ -1212,6 +1213,7 @@ void R_Register( void ) r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT ); + r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM ); ri->Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 31da66a102..6a33f2a8be 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -103,6 +103,7 @@ extern cvar_t *r_dlightBacks; extern cvar_t *r_lodbias; extern cvar_t *r_lodscale; +extern cvar_t *r_autolodscalevalue; extern cvar_t *r_norefresh; extern cvar_t *r_drawentities; diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 7f63845694..398fab7f68 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -204,7 +204,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { if ( ( projectedRadius = ProjectRadius( radius, ent->e.origin ) ) != 0 ) { - lodscale = r_lodscale->value; + lodscale = (r_lodscale->value+r_autolodscalevalue->integer); if (lodscale > 20) lodscale = 20; flod = 1.0f - projectedRadius * lodscale; } From 48ba66ca5e1adb1be83c6227ecd8e754d09d9fd0 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 17:41:58 -0400 Subject: [PATCH 038/708] [rend2] Added the rest of the GHOUL2 cvars that were missing. --- codemp/rd-rend2/tr_init.cpp | 59 +++++++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_local.h | 34 +++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5dfb487cb4..f319251a95 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -211,6 +211,40 @@ cvar_t *r_debugSort; cvar_t *r_printShaders; cvar_t *r_saveFontData; +/* +Ghoul2 Insert Start +*/ +#ifdef _DEBUG +cvar_t *r_noPrecacheGLA; +#endif + +cvar_t *r_noServerGhoul2; +cvar_t *r_Ghoul2AnimSmooth=0; +cvar_t *r_Ghoul2UnSqashAfterSmooth=0; +//cvar_t *r_Ghoul2UnSqash; +//cvar_t *r_Ghoul2TimeBase=0; from single player +//cvar_t *r_Ghoul2NoLerp; +//cvar_t *r_Ghoul2NoBlend; +//cvar_t *r_Ghoul2BlendMultiplier=0; + +cvar_t *broadsword=0; +cvar_t *broadsword_kickbones=0; +cvar_t *broadsword_kickorigin=0; +cvar_t *broadsword_playflop=0; +cvar_t *broadsword_dontstopanim=0; +cvar_t *broadsword_waitforshot=0; +cvar_t *broadsword_smallbbox=0; +cvar_t *broadsword_extra1=0; +cvar_t *broadsword_extra2=0; + +cvar_t *broadsword_effcorr=0; +cvar_t *broadsword_ragtobase=0; +cvar_t *broadsword_dircap=0; + +/* +Ghoul2 Insert End +*/ + cvar_t *r_marksOnTriangleMeshes; cvar_t *r_aviMotionJpegQuality; @@ -1294,6 +1328,31 @@ void R_Register( void ) r_maxpolys = ri->Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); +/* +Ghoul2 Insert Start +*/ +#ifdef _DEBUG + r_noPrecacheGLA = ri->Cvar_Get( "r_noPrecacheGLA", "0", CVAR_CHEAT ); +#endif + r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT ); + r_Ghoul2AnimSmooth = ri->Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE ); + r_Ghoul2UnSqashAfterSmooth = ri->Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE ); + broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_NONE ); + broadsword_kickbones = ri->Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE ); + broadsword_kickorigin = ri->Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE ); + broadsword_dontstopanim = ri->Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE ); + broadsword_waitforshot = ri->Cvar_Get( "broadsword_waitforshot", "0", CVAR_NONE ); + broadsword_playflop = ri->Cvar_Get( "broadsword_playflop", "1", CVAR_NONE ); + broadsword_smallbbox = ri->Cvar_Get( "broadsword_smallbbox", "0", CVAR_NONE ); + broadsword_extra1 = ri->Cvar_Get( "broadsword_extra1", "0", CVAR_NONE ); + broadsword_extra2 = ri->Cvar_Get( "broadsword_extra2", "0", CVAR_NONE ); + broadsword_effcorr = ri->Cvar_Get( "broadsword_effcorr", "1", CVAR_NONE ); + broadsword_ragtobase = ri->Cvar_Get( "broadsword_ragtobase", "2", CVAR_NONE ); + broadsword_dircap = ri->Cvar_Get( "broadsword_dircap", "64", CVAR_NONE ); +/* +Ghoul2 Insert End +*/ + // make sure all the commands added here are also // removed in R_Shutdown ri->Cmd_AddCommand( "imagelist", R_ImageList_f ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6a33f2a8be..4aa8392165 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -255,6 +255,40 @@ extern int max_polys; extern cvar_t *r_maxpolyverts; extern int max_polyverts; +/* +Ghoul2 Insert Start +*/ +#ifdef _DEBUG +extern cvar_t *r_noPrecacheGLA; +#endif + +extern cvar_t *r_noServerGhoul2; +extern cvar_t *r_Ghoul2AnimSmooth; +extern cvar_t *r_Ghoul2UnSqashAfterSmooth; +//extern cvar_t *r_Ghoul2UnSqash; +//extern cvar_t *r_Ghoul2TimeBase=0; from single player +//extern cvar_t *r_Ghoul2NoLerp; +//extern cvar_t *r_Ghoul2NoBlend; +//extern cvar_t *r_Ghoul2BlendMultiplier=0; + +extern cvar_t *broadsword; +extern cvar_t *broadsword_kickbones; +extern cvar_t *broadsword_kickorigin; +extern cvar_t *broadsword_playflop; +extern cvar_t *broadsword_dontstopanim; +extern cvar_t *broadsword_waitforshot; +extern cvar_t *broadsword_smallbbox; +extern cvar_t *broadsword_extra1; +extern cvar_t *broadsword_extra2; + +extern cvar_t *broadsword_effcorr; +extern cvar_t *broadsword_ragtobase; +extern cvar_t *broadsword_dircap; + +/* +Ghoul2 Insert End +*/ + /* End Cvars */ From 451550fda349d80f5b560850cb944cc5b8627e35 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 20:23:26 -0400 Subject: [PATCH 039/708] [rend2] fix for extension loading and some other misc errors --- codemp/rd-rend2/tr_extensions.cpp | 185 ++++++++++++++++-------------- codemp/rd-rend2/tr_ghoul2.cpp | 2 +- codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_mesh.cpp | 2 +- 4 files changed, 102 insertions(+), 89 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 8e4e068ffa..51e4f44963 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -21,9 +21,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_extensions.c - extensions needed by the renderer not in sdl_glimp.c +#include "tr_local.h" + +#ifndef _WIN32 #include "SDL/SDL.h" +#else +#include "../win32/glw_win.h" +extern glwstate_t glw_state; +#endif -#include "tr_local.h" +#ifdef _WIN32 +#define GETADDRESS(x) GetProcAddress(glw_state.hinstOpenGL, x) +#else +#define GETADDRESS(x) SDL_GL_GetProcAddress(x) +#endif // GL_EXT_draw_range_elements void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); @@ -195,7 +206,7 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawRangeElementsEXT = (void *) SDL_GL_GetProcAddress("glDrawRangeElementsEXT"); + qglDrawRangeElementsEXT = (void (__stdcall *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GETADDRESS("glDrawRangeElementsEXT"); if ( r_ext_draw_range_elements->integer) glRefConfig.drawRangeElements = qtrue; @@ -214,8 +225,8 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) SDL_GL_GetProcAddress("glMultiDrawArraysEXT"); - qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) SDL_GL_GetProcAddress("glMultiDrawElementsEXT"); + qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GETADDRESS("glMultiDrawArraysEXT"); + qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GETADDRESS("glMultiDrawElementsEXT"); if ( r_ext_multi_draw_arrays->integer ) glRefConfig.multiDrawArrays = qtrue; @@ -237,13 +248,13 @@ void GLimp_InitExtraExtensions() qglDisableVertexAttribArrayARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) SDL_GL_GetProcAddress("glVertexAttrib4fARB"); - qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) SDL_GL_GetProcAddress("glVertexAttrib4fvARB"); - qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) SDL_GL_GetProcAddress("glVertexAttribPointerARB"); + qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) GETADDRESS("glVertexAttrib4fARB"); + qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) GETADDRESS("glVertexAttrib4fvARB"); + qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GETADDRESS("glVertexAttribPointerARB"); qglEnableVertexAttribArrayARB = - (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) SDL_GL_GetProcAddress("glEnableVertexAttribArrayARB"); + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GETADDRESS("glEnableVertexAttribArrayARB"); qglDisableVertexAttribArrayARB = - (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) SDL_GL_GetProcAddress("glDisableVertexAttribArrayARB"); + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GETADDRESS("glDisableVertexAttribArrayARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexProgram = qtrue; @@ -267,15 +278,15 @@ void GLimp_InitExtraExtensions() qglGetBufferPointervARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) SDL_GL_GetProcAddress("glBindBufferARB"); - qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) SDL_GL_GetProcAddress("glDeleteBuffersARB"); - qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) SDL_GL_GetProcAddress("glGenBuffersARB"); - qglIsBufferARB = (PFNGLISBUFFERARBPROC) SDL_GL_GetProcAddress("glIsBufferARB"); - qglBufferDataARB = (PFNGLBUFFERDATAARBPROC) SDL_GL_GetProcAddress("glBufferDataARB"); - qglBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) SDL_GL_GetProcAddress("glBufferSubDataARB"); - qglGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) SDL_GL_GetProcAddress("glGetBufferSubDataARB"); - qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetBufferParameterivARB"); - qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) SDL_GL_GetProcAddress("glGetBufferPointervARB"); + qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) GETADDRESS("glBindBufferARB"); + qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GETADDRESS("glDeleteBuffersARB"); + qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GETADDRESS("glGenBuffersARB"); + qglIsBufferARB = (PFNGLISBUFFERARBPROC) GETADDRESS("glIsBufferARB"); + qglBufferDataARB = (PFNGLBUFFERDATAARBPROC) GETADDRESS("glBufferDataARB"); + qglBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) GETADDRESS("glBufferSubDataARB"); + qglGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) GETADDRESS("glGetBufferSubDataARB"); + qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GETADDRESS("glGetBufferParameterivARB"); + qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GETADDRESS("glGetBufferPointervARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexBufferObject = qtrue; } @@ -327,44 +338,44 @@ void GLimp_InitExtraExtensions() qglGetShaderSourceARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); - qglGetHandleARB = (PFNGLGETHANDLEARBPROC) SDL_GL_GetProcAddress("glGetHandleARB"); - qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) SDL_GL_GetProcAddress("glDetachObjectARB"); - qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); - qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); - qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); - qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); - qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); - qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); - qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); - qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) SDL_GL_GetProcAddress("glValidateProgramARB"); - qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); - qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) SDL_GL_GetProcAddress("glUniform2fARB"); - qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) SDL_GL_GetProcAddress("glUniform3fARB"); - qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) SDL_GL_GetProcAddress("glUniform4fARB"); - qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); - qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) SDL_GL_GetProcAddress("glUniform2iARB"); - qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) SDL_GL_GetProcAddress("glUniform3iARB"); - qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) SDL_GL_GetProcAddress("glUniform4iARB"); - qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) SDL_GL_GetProcAddress("glUniform1fvARB"); - qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) SDL_GL_GetProcAddress("glUniform2fvARB"); - qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) SDL_GL_GetProcAddress("glUniform3fvARB"); - qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) SDL_GL_GetProcAddress("glUniform4fvARB"); - qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) SDL_GL_GetProcAddress("glUniform2ivARB"); - qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) SDL_GL_GetProcAddress("glUniform3ivARB"); - qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) SDL_GL_GetProcAddress("glUniform4ivARB"); - qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix2fvARB"); - qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix3fvARB"); - qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) SDL_GL_GetProcAddress("glUniformMatrix4fvARB"); - qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterfvARB"); - qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); - qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); - qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) SDL_GL_GetProcAddress("glGetAttachedObjectsARB"); - qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); - qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) SDL_GL_GetProcAddress("glGetActiveUniformARB"); - qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) SDL_GL_GetProcAddress("glGetUniformfvARB"); - qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) SDL_GL_GetProcAddress("glGetUniformivARB"); - qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glGetShaderSourceARB"); + qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GETADDRESS("glDeleteObjectARB"); + qglGetHandleARB = (PFNGLGETHANDLEARBPROC) GETADDRESS("glGetHandleARB"); + qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) GETADDRESS("glDetachObjectARB"); + qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GETADDRESS("glCreateShaderObjectARB"); + qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GETADDRESS("glShaderSourceARB"); + qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GETADDRESS("glCompileShaderARB"); + qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GETADDRESS("glCreateProgramObjectARB"); + qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GETADDRESS("glAttachObjectARB"); + qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETADDRESS("glLinkProgramARB"); + qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETADDRESS("glUseProgramObjectARB"); + qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) GETADDRESS("glValidateProgramARB"); + qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) GETADDRESS("glUniform1fARB"); + qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) GETADDRESS("glUniform2fARB"); + qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) GETADDRESS("glUniform3fARB"); + qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) GETADDRESS("glUniform4fARB"); + qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) GETADDRESS("glUniform1iARB"); + qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) GETADDRESS("glUniform2iARB"); + qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) GETADDRESS("glUniform3iARB"); + qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) GETADDRESS("glUniform4iARB"); + qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) GETADDRESS("glUniform1fvARB"); + qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) GETADDRESS("glUniform2fvARB"); + qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) GETADDRESS("glUniform3fvARB"); + qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETADDRESS("glUniform4fvARB"); + qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) GETADDRESS("glUniform2ivARB"); + qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) GETADDRESS("glUniform3ivARB"); + qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) GETADDRESS("glUniform4ivARB"); + qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) GETADDRESS("glUniformMatrix2fvARB"); + qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) GETADDRESS("glUniformMatrix3fvARB"); + qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) GETADDRESS("glUniformMatrix4fvARB"); + qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) GETADDRESS("glGetObjectParameterfvARB"); + qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) GETADDRESS("glGetObjectParameterivARB"); + qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) GETADDRESS("glGetInfoLogARB"); + qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) GETADDRESS("glGetAttachedObjectsARB"); + qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETADDRESS("glGetUniformLocationARB"); + qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) GETADDRESS("glGetActiveUniformARB"); + qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) GETADDRESS("glGetUniformfvARB"); + qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) GETADDRESS("glGetUniformivARB"); + qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) GETADDRESS("glGetShaderSourceARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.shaderObjects = qtrue; } @@ -403,9 +414,9 @@ void GLimp_InitExtraExtensions() //glConfig.maxVertexSkinningBones = (int) Q_bound(0.0, (Q_max(glConfig.maxVertexUniforms - reservedComponents, 0) / 16), MAX_BONES); //glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ((glConfig.maxVertexSkinningBones >= 12) ? qtrue : qfalse); - qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glBindAttribLocationARB"); - qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) SDL_GL_GetProcAddress("glGetActiveAttribARB"); - qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetAttribLocationARB"); + qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GETADDRESS("glBindAttribLocationARB"); + qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GETADDRESS("glGetActiveAttribARB"); + qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GETADDRESS("glGetAttribLocationARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexShader = qtrue; } @@ -499,23 +510,23 @@ void GLimp_InitExtraExtensions() glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); - qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsRenderbufferEXT"); - qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindRenderbufferEXT"); - qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteRenderbuffersEXT"); - qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenRenderbuffersEXT"); - qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) SDL_GL_GetProcAddress("glRenderbufferStorageEXT"); - qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetRenderbufferParameterivEXT"); - qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsFramebufferEXT"); - qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindFramebufferEXT"); - qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteFramebuffersEXT"); - qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT"); - qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT"); - qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture1DEXT"); - qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture2DEXT"); - qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture3DEXT"); - qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT"); - qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); - qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) SDL_GL_GetProcAddress("glGenerateMipmapEXT"); + qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GETADDRESS("glIsRenderbufferEXT"); + qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GETADDRESS("glBindRenderbufferEXT"); + qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GETADDRESS("glDeleteRenderbuffersEXT"); + qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GETADDRESS("glGenRenderbuffersEXT"); + qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GETADDRESS("glRenderbufferStorageEXT"); + qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) GETADDRESS("glGetRenderbufferParameterivEXT"); + qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) GETADDRESS("glIsFramebufferEXT"); + qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GETADDRESS("glBindFramebufferEXT"); + qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GETADDRESS("glDeleteFramebuffersEXT"); + qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GETADDRESS("glGenFramebuffersEXT"); + qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GETADDRESS("glCheckFramebufferStatusEXT"); + qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) GETADDRESS("glFramebufferTexture1DEXT"); + qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GETADDRESS("glFramebufferTexture2DEXT"); + qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) GETADDRESS("glFramebufferTexture3DEXT"); + qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GETADDRESS("glFramebufferRenderbufferEXT"); + qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GETADDRESS("glGetFramebufferAttachmentParameterivEXT"); + qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GETADDRESS("glGenerateMipmapEXT"); if(r_ext_framebuffer_object->value) glRefConfig.framebufferObject = qtrue; @@ -545,14 +556,14 @@ void GLimp_InitExtraExtensions() glRefConfig.occlusionQuery = qfalse; if (GLimp_HaveExtension(extension)) { - qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) SDL_GL_GetProcAddress("glGenQueriesARB"); - qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) SDL_GL_GetProcAddress("glDeleteQueriesARB"); - qglIsQueryARB = (PFNGLISQUERYARBPROC) SDL_GL_GetProcAddress("glIsQueryARB"); - qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) SDL_GL_GetProcAddress("glBeginQueryARB"); - qglEndQueryARB = (PFNGLENDQUERYARBPROC) SDL_GL_GetProcAddress("glEndQueryARB"); - qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) SDL_GL_GetProcAddress("glGetQueryivARB"); - qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectivARB"); - qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) SDL_GL_GetProcAddress("glGetQueryObjectuivARB"); + qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GETADDRESS("glGenQueriesARB"); + qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GETADDRESS("glDeleteQueriesARB"); + qglIsQueryARB = (PFNGLISQUERYARBPROC) GETADDRESS("glIsQueryARB"); + qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GETADDRESS("glBeginQueryARB"); + qglEndQueryARB = (PFNGLENDQUERYARBPROC) GETADDRESS("glEndQueryARB"); + qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GETADDRESS("glGetQueryivARB"); + qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GETADDRESS("glGetQueryObjectivARB"); + qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GETADDRESS("glGetQueryObjectuivARB"); glRefConfig.occlusionQuery = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); } @@ -566,7 +577,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferBlit = qfalse; if (GLimp_HaveExtension(extension)) { - qglBlitFramebufferEXT = (void *)SDL_GL_GetProcAddress("glBlitFramebufferEXT"); + qglBlitFramebufferEXT = (void (__stdcall *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GETADDRESS("glBlitFramebufferEXT"); glRefConfig.framebufferBlit = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); } @@ -580,7 +591,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferMultisample = qfalse; if (GLimp_HaveExtension(extension)) { - qglRenderbufferStorageMultisampleEXT = SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); + qglRenderbufferStorageMultisampleEXT = (void (__stdcall *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GETADDRESS("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } @@ -639,7 +650,7 @@ void GLimp_InitExtraExtensions() qglDrawBuffersARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawBuffersARB = (void *) SDL_GL_GetProcAddress("glDrawBuffersARB"); + qglDrawBuffersARB = (void (__stdcall *)(GLsizei,const GLenum *)) GETADDRESS("glDrawBuffersARB"); ri->Printf(PRINT_ALL, result[1], extension); } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 82ddd7a8fd..a7091861a5 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4264,7 +4264,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean shader_t *sh; // get the shader name - sh = R_FindShader( surfInfo->shader, lightmapsNone, stylesDefault, qtrue ); + sh = R_FindShader( surfInfo->shader, LIGHTMAP_NONE, qtrue ); // insert it in the surface list if ( sh->defaultShader ) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 4aa8392165..42bee81af7 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3064,4 +3064,6 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT extern qboolean textureFilterAnisotropic; extern int maxAnisotropy; +float ProjectRadius( float r, vec3_t location ); + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 398fab7f68..7df00d6c36 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -static float ProjectRadius( float r, vec3_t location ) +float ProjectRadius( float r, vec3_t location ) { float pr; float dist; From 4ab3f5a3e10287373362349b30ca4690ae468cdc Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 20:35:21 -0400 Subject: [PATCH 040/708] [rend2] Fixed inconsistencies between R_inpvs and RE_UploadCinematic exports --- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_local.h | 4 ++-- codemp/rd-rend2/tr_world.cpp | 20 ++++++++++++-------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 2513e08ed3..22224f5176 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -850,7 +850,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * ri->Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); } - RE_UploadCinematic (w, h, cols, rows, data, client, dirty); + RE_UploadCinematic (cols, rows, data, client, dirty); if ( r_speeds->integer ) { end = ri->Milliseconds(); @@ -890,7 +890,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * RB_InstantQuad2(quadVerts, texCoords); } -void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty) { +void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qboolean dirty) { GL_Bind( tr.scratchImage[client] ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 42bee81af7..8ed9b90580 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2391,7 +2391,7 @@ extern glconfig_t glConfig; typedef _skinSurface_t skinSurface_t; void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); -void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); +void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qboolean dirty); void RE_BeginFrame( stereoFrame_t stereoFrame ); void RE_BeginRegistration( glconfig_t *glconfig ); @@ -2555,7 +2555,7 @@ WORLD MAP void R_AddBrushModelSurfaces( trRefEntity_t *e ); void R_AddWorldSurfaces( void ); -qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ); +qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ); /* diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 45863ac04e..5417cfcec0 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -645,17 +645,21 @@ static const byte *R_ClusterPVS (int cluster) { R_inPVS ================= */ -qboolean R_inPVS( const vec3_t p1, const vec3_t p2 ) { - mnode_t *leaf; - byte *vis; +qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ) { + int leafnum; + int cluster; + + leafnum = ri->CM_PointLeafnum (p1); + cluster = ri->CM_LeafCluster (leafnum); - leaf = R_PointInLeaf( p1 ); - vis = ri->CM_ClusterPVS( leaf->cluster ); // why not R_ClusterPVS ?? - leaf = R_PointInLeaf( p2 ); + //agh, the damn snapshot mask doesn't work for this + mask = (byte *) ri->CM_ClusterPVS (cluster); - if ( !(vis[leaf->cluster>>3] & (1<<(leaf->cluster&7))) ) { + leafnum = ri->CM_PointLeafnum (p2); + cluster = ri->CM_LeafCluster (leafnum); + if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) ) return qfalse; - } + return qtrue; } From 2fa20b98d477334004394c570f54b55d42e66517 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 21:48:57 -0400 Subject: [PATCH 041/708] [rend2] Okay, that should be the last of the compiler errors, now for the linker. --- codemp/rd-common/tr_font.cpp | 20 +++++++ codemp/rd-common/tr_font.h | 3 + codemp/rd-rend2/G2_API.cpp | 9 ++- codemp/rd-rend2/tr_ghoul2.cpp | 23 +------- codemp/rd-rend2/tr_init.cpp | 105 ++++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_main.cpp | 2 + codemp/rd-rend2/tr_model.cpp | 60 +++++++++++++++++++ codemp/rd-rend2/tr_shader.cpp | 9 +++ 9 files changed, 210 insertions(+), 23 deletions(-) diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index 1222024fac..7197904017 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -1740,5 +1740,25 @@ void R_ReloadFonts_f(void) } } +void R_InitFreeType(void) { +#ifdef BUILD_FREETYPE + if (FT_Init_FreeType( &ftLibrary )) { + ri.Printf(PRINT_WARNING, "R_InitFreeType: Unable to initialize FreeType.\n"); + } +#endif + // I DONT DO NOTHING +} + + +void R_DoneFreeType(void) { +#ifdef BUILD_FREETYPE + if (ftLibrary) { + FT_Done_FreeType( ftLibrary ); + ftLibrary = NULL; + } +#endif + // I DONT DO NOTHING +} + // end diff --git a/codemp/rd-common/tr_font.h b/codemp/rd-common/tr_font.h index 77a4f28875..854ef54c2d 100644 --- a/codemp/rd-common/tr_font.h +++ b/codemp/rd-common/tr_font.h @@ -27,4 +27,7 @@ unsigned int AnyLanguage_ReadCharFromString( const char *psText, int *piAdvanceC qboolean Language_IsAsian(void); qboolean Language_UsesSpaces(void); +void R_InitFreeType(void); +void R_DoneFreeType(void); + // end diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 89c8c77173..f2a132185f 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -558,7 +558,8 @@ qboolean G2_ShouldRegisterServer(void) qhandle_t G2API_PrecacheGhoul2Model( const char *fileName ) { if ( G2_ShouldRegisterServer() ) - return RE_RegisterServerModel( fileName ); + return 0; + //return RE_RegisterServerModel( fileName ); else return RE_RegisterModel( fileName ); } @@ -2588,7 +2589,8 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model if (ri->Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { - ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + ghlInfo->mModel = 0; + //ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); } else { @@ -2679,7 +2681,8 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode if (ri->Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { - ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + ghlInfo->mModel = 0; + //ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); } else { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a7091861a5..b35c62c079 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4162,16 +4162,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean int version; int size; mdxmSurfHierarchy_t *surfInfo; - -#if 0 //#ifndef _M_IX86 - int k; - int frameSize; - mdxmTag_t *tag; - mdxmTriangle_t *tri; - mdxmVertex_t *v; - mdxmFrame_t *cframe; - int *boneRef; -#endif pinmodel= (mdxmHeader_t *)buffer; // @@ -4196,8 +4186,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mod->dataSize += size; qboolean bAlreadyFound = qfalse; - mdxm = mod->mdxm = (mdxmHeader_t*) //Hunk_Alloc( size ); - RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); + mdxm = mod->mdxm = (mdxmHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); + //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); @@ -4640,14 +4630,7 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean size += (childNumber*(CHILD_PADDING*8)); //Allocate us some extra space so we can shift memory down. #endif //CREATE_LIMB_HIERARCHY - mdxa = mod->mdxa = (mdxaHeader_t*) //Hunk_Alloc( size ); - RE_RegisterModels_Malloc(size, - #ifdef CREATE_LIMB_HIERARCHY - NULL, // I think this'll work, can't really test on PC - #else - buffer, - #endif - mod_name, &bAlreadyFound, TAG_MODEL_GLA); + mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f319251a95..f6c1220fc7 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_init.c -- functions that are not called every frame #include "tr_local.h" +#include "G2_local.h" glconfig_t glConfig; glRefConfig_t glRefConfig; @@ -1550,6 +1551,11 @@ void RE_EndRegistration( void ) { } } +// HACK +extern qboolean gG2_GBMNoReconstruct; +extern qboolean gG2_GBMUseSPMethod; +static void G2API_BoltMatrixReconstruction( qboolean reconstruct ) { gG2_GBMNoReconstruct = (qboolean)!reconstruct; } +static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = spMethod; } /* @@@@@@@@@@@@@@@@@@@@@ @@ -1615,5 +1621,104 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.TakeVideoFrame = RE_TakeVideoFrame; + /* + Ghoul2 Insert Start + */ + re.G2API_AddBolt = G2API_AddBolt; + re.G2API_AddBoltSurfNum = G2API_AddBoltSurfNum; + re.G2API_AddSurface = G2API_AddSurface; + re.G2API_AnimateG2ModelsRag = G2API_AnimateG2ModelsRag; + re.G2API_AttachEnt = G2API_AttachEnt; + re.G2API_AttachG2Model = G2API_AttachG2Model; + re.G2API_AttachInstanceToEntNum = G2API_AttachInstanceToEntNum; + re.G2API_AbsurdSmoothing = G2API_AbsurdSmoothing; + re.G2API_BoltMatrixReconstruction = G2API_BoltMatrixReconstruction; + re.G2API_BoltMatrixSPMethod = G2API_BoltMatrixSPMethod; + re.G2API_CleanEntAttachments = G2API_CleanEntAttachments; + re.G2API_CleanGhoul2Models = G2API_CleanGhoul2Models; + re.G2API_ClearAttachedInstance = G2API_ClearAttachedInstance; + re.G2API_CollisionDetect = G2API_CollisionDetect; + re.G2API_CollisionDetectCache = G2API_CollisionDetectCache; + re.G2API_CopyGhoul2Instance = G2API_CopyGhoul2Instance; + re.G2API_CopySpecificG2Model = G2API_CopySpecificG2Model; + re.G2API_DetachG2Model = G2API_DetachG2Model; + re.G2API_DoesBoneExist = G2API_DoesBoneExist; + re.G2API_DuplicateGhoul2Instance = G2API_DuplicateGhoul2Instance; + re.G2API_FreeSaveBuffer = G2API_FreeSaveBuffer; + re.G2API_GetAnimFileName = G2API_GetAnimFileName; + re.G2API_GetAnimFileNameIndex = G2API_GetAnimFileNameIndex; + re.G2API_GetAnimRange = G2API_GetAnimRange; + re.G2API_GetBoltMatrix = G2API_GetBoltMatrix; + re.G2API_GetBoneAnim = G2API_GetBoneAnim; + re.G2API_GetBoneIndex = G2API_GetBoneIndex; + re.G2API_GetGhoul2ModelFlags = G2API_GetGhoul2ModelFlags; + re.G2API_GetGLAName = G2API_GetGLAName; + re.G2API_GetParentSurface = G2API_GetParentSurface; + re.G2API_GetRagBonePos = G2API_GetRagBonePos; + re.G2API_GetSurfaceIndex = G2API_GetSurfaceIndex; + re.G2API_GetSurfaceName = G2API_GetSurfaceName; + re.G2API_GetSurfaceOnOff = G2API_GetSurfaceOnOff; + re.G2API_GetSurfaceRenderStatus = G2API_GetSurfaceRenderStatus; + re.G2API_GetTime = G2API_GetTime; + re.G2API_Ghoul2Size = G2API_Ghoul2Size; + re.G2API_GiveMeVectorFromMatrix = G2API_GiveMeVectorFromMatrix; + re.G2API_HasGhoul2ModelOnIndex = G2API_HasGhoul2ModelOnIndex; + re.G2API_HaveWeGhoul2Models = G2API_HaveWeGhoul2Models; + re.G2API_IKMove = G2API_IKMove; + re.G2API_InitGhoul2Model = G2API_InitGhoul2Model; + re.G2API_IsPaused = G2API_IsPaused; + re.G2API_ListBones = G2API_ListBones; + re.G2API_ListSurfaces = G2API_ListSurfaces; + re.G2API_LoadGhoul2Models = G2API_LoadGhoul2Models; + re.G2API_LoadSaveCodeDestructGhoul2Info = G2API_LoadSaveCodeDestructGhoul2Info; + re.G2API_OverrideServerWithClientData = G2API_OverrideServerWithClientData; + re.G2API_PauseBoneAnim = G2API_PauseBoneAnim; + re.G2API_PrecacheGhoul2Model = G2API_PrecacheGhoul2Model; + re.G2API_RagEffectorGoal = G2API_RagEffectorGoal; + re.G2API_RagEffectorKick = G2API_RagEffectorKick; + re.G2API_RagForceSolve = G2API_RagForceSolve; + re.G2API_RagPCJConstraint = G2API_RagPCJConstraint; + re.G2API_RagPCJGradientSpeed = G2API_RagPCJGradientSpeed; + re.G2API_RemoveBolt = G2API_RemoveBolt; + re.G2API_RemoveBone = G2API_RemoveBone; + re.G2API_RemoveGhoul2Model = G2API_RemoveGhoul2Model; + re.G2API_RemoveGhoul2Models = G2API_RemoveGhoul2Models; + re.G2API_RemoveSurface = G2API_RemoveSurface; + re.G2API_ResetRagDoll = G2API_ResetRagDoll; + re.G2API_SaveGhoul2Models = G2API_SaveGhoul2Models; + re.G2API_SetBoltInfo = G2API_SetBoltInfo; + re.G2API_SetBoneAngles = G2API_SetBoneAngles; + re.G2API_SetBoneAnglesIndex = G2API_SetBoneAnglesIndex; + re.G2API_SetBoneAnglesMatrix = G2API_SetBoneAnglesMatrix; + re.G2API_SetBoneAnglesMatrixIndex = G2API_SetBoneAnglesMatrixIndex; + re.G2API_SetBoneAnim = G2API_SetBoneAnim; + re.G2API_SetBoneAnimIndex = G2API_SetBoneAnimIndex; + re.G2API_SetBoneIKState = G2API_SetBoneIKState; + re.G2API_SetGhoul2ModelIndexes = G2API_SetGhoul2ModelIndexes; + re.G2API_SetGhoul2ModelFlags = G2API_SetGhoul2ModelFlags; + re.G2API_SetLodBias = G2API_SetLodBias; + re.G2API_SetNewOrigin = G2API_SetNewOrigin; + re.G2API_SetRagDoll = G2API_SetRagDoll; + re.G2API_SetRootSurface = G2API_SetRootSurface; + re.G2API_SetShader = G2API_SetShader; + re.G2API_SetSkin = G2API_SetSkin; + re.G2API_SetSurfaceOnOff = G2API_SetSurfaceOnOff; + re.G2API_SetTime = G2API_SetTime; + re.G2API_SkinlessModel = G2API_SkinlessModel; + re.G2API_StopBoneAngles = G2API_StopBoneAngles; + re.G2API_StopBoneAnglesIndex = G2API_StopBoneAnglesIndex; + re.G2API_StopBoneAnim = G2API_StopBoneAnim; + re.G2API_StopBoneAnimIndex = G2API_StopBoneAnimIndex; + + #ifdef _G2_GORE + re.G2API_GetNumGoreMarks = G2API_GetNumGoreMarks; + re.G2API_AddSkinGore = G2API_AddSkinGore; + re.G2API_ClearSkinGore = G2API_ClearSkinGore; + #endif // _SOF2 + + /* + Ghoul2 Insert End + */ + return &re; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8ed9b90580..c9b5b4e38d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3065,5 +3065,7 @@ extern qboolean textureFilterAnisotropic; extern int maxAnisotropy; float ProjectRadius( float r, vec3_t location ); +void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke); +qboolean ShaderHashTableExists(void); #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index aadb621f01..f533981ada 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include // memcpy +#include "G2_local.h" + trGlobals_t tr; static float s_flipMatrix[16] = { diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index e25c2bd908..de40536410 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_models.c -- model loading and caching #include "tr_local.h" +#include #define LL(x) x=LittleLong(x) @@ -372,6 +373,65 @@ qhandle_t RE_RegisterModel( const char *name ) { return hModel; } +/* +==================== +RE_RegisterModels_StoreShaderRequest + +Cache shaders used by a model + +This stuff looks a bit messy, but it's kept here as black box, and nothing appears in any .H files for other +modules to worry about. I may make another module for this sometime. +==================== +*/ + +typedef pair StringOffsetAndShaderIndexDest_t; +typedef vector ShaderRegisterData_t; +struct CachedEndianedModelBinary_s +{ + void *pModelDiskImage; + int iAllocSize; // may be useful for mem-query, but I don't actually need it + ShaderRegisterData_t ShaderRegisterData; + int iLastLevelUsedOn; + int iPAKFileCheckSum; // else -1 if not from PAK + + + CachedEndianedModelBinary_s() + { + pModelDiskImage = 0; + iAllocSize = 0; + ShaderRegisterData.clear(); + iLastLevelUsedOn = -1; + iPAKFileCheckSum = -1; + } +}; +typedef struct CachedEndianedModelBinary_s CachedEndianedModelBinary_t; +typedef map CachedModels_t; +CachedModels_t *CachedModels = NULL; // the important cache item. + +void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke) +{ + char sModelName[MAX_QPATH]; + + assert(CachedModels); + + Q_strncpyz(sModelName,psModelFileName,sizeof(sModelName)); + Q_strlwr (sModelName); + + CachedEndianedModelBinary_t &ModelBin = (*CachedModels)[sModelName]; + + if (ModelBin.pModelDiskImage == NULL) + { + assert(0); // should never happen, means that we're being called on a model that wasn't loaded + } + else + { + int iNameOffset = psShaderName - (char *)ModelBin.pModelDiskImage; + int iPokeOffset = (char*) piShaderIndexPoke - (char *)ModelBin.pModelDiskImage; + + ModelBin.ShaderRegisterData.push_back( StringOffsetAndShaderIndexDest_t( iNameOffset,iPokeOffset) ); + } +} + /* ================= R_LoadMD3 diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index fb42971c84..96d0c930fb 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -39,6 +39,15 @@ static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); +qboolean ShaderHashTableExists(void) +{ + if (shaderTextHashTable[0][0]) + { + return qtrue; + } + return qfalse; +} + /* ================ return a hash value for the filename From 85e4b7e417d95ad631ade9b7de52fb4fc2179c5b Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 21:59:35 -0400 Subject: [PATCH 042/708] [rend2] updated CMakeLists.txt for rend2 --- codemp/rd-rend2/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 3afdd892df..6c9e06c7da 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -29,6 +29,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_fbo.cpp" "${MPDir}/rd-rend2/tr_fbo.h" "${MPDir}/rd-rend2/tr_flares.cpp" + "${MPDir}/rd-rend2/tr_ghoul2.cpp" "${MPDir}/rd-rend2/tr_glsl.cpp" "${MPDir}/rd-rend2/tr_image.cpp" "${MPDir}/rd-rend2/tr_init.cpp" @@ -63,6 +64,8 @@ set(MPRend2Files ${MPRend2Files} ${MPRend2Ghoul2Files}) set(MPRend2RdCommonFiles "${MPDir}/rd-common/mdx_format.h" "${MPDir}/rd-common/tr_types.h" + "${MPDir}/rd-common/tr_font.cpp" + "${MPDir}/rd-common/tr_font.h" "${MPDir}/rd-common/tr_public.h") source_group("rd-common" FILES ${MPRend2RdCommonFiles}) set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) From d9beaf491fc9bc0c7eb5f69a3451731cd03bff4d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 22:39:30 -0400 Subject: [PATCH 043/708] [rend2] Some minor linker error fixes --- codemp/rd-rend2/glsl/glsl_stringify.vbs | 18 ++++++++++++++++++ codemp/rd-rend2/tr_init.cpp | 10 ++++------ codemp/rd-rend2/tr_local.h | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 codemp/rd-rend2/glsl/glsl_stringify.vbs diff --git a/codemp/rd-rend2/glsl/glsl_stringify.vbs b/codemp/rd-rend2/glsl/glsl_stringify.vbs new file mode 100644 index 0000000000..34e4955320 --- /dev/null +++ b/codemp/rd-rend2/glsl/glsl_stringify.vbs @@ -0,0 +1,18 @@ +Dim fso, infile, outfile, line +Set fso = CreateObject("Scripting.FileSystemObject") +Set infile = fso.OpenTextFile(WScript.Arguments(0)) +Set outfile = fso.CreateTextFile(WScript.Arguments(1), True) + +outfile.WriteLine("const char *fallbackShader_" & fso.GetBaseName(WScript.Arguments(0)) & " =") +While Not infile.AtEndOfStream + line = infile.ReadLine + line = Replace(line, "\", "\\") + line = Replace(line, Chr(9), "\t") + line = Replace(line, Chr(34), "\" & chr(34)) + line = Chr(34) & line & "\n" & Chr(34) + outfile.WriteLine(line) +Wend +outfile.WriteLine(";") + +infile.Close +outfile.Close \ No newline at end of file diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f6c1220fc7..8bb8811369 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #include "G2_local.h" +bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez + glconfig_t glConfig; glRefConfig_t glRefConfig; qboolean textureFilterAnisotropic = qfalse; @@ -54,7 +56,7 @@ cvar_t *r_stereoSeparation; cvar_t *r_skipBackEnd; -cvar_t *r_stereoEnabled; +cvar_t *r_stereo; cvar_t *r_anaglyphMode; cvar_t *r_greyscale; @@ -1178,7 +1180,7 @@ void R_Register( void ) r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0); r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); - r_stereoEnabled = ri->Cvar_Get( "r_stereoEnabled", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_stereo = ri->Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH); r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); @@ -1265,10 +1267,6 @@ void R_Register( void ) r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); - r_railWidth = ri->Cvar_Get( "r_railWidth", "16", CVAR_ARCHIVE ); - r_railCoreWidth = ri->Cvar_Get( "r_railCoreWidth", "6", CVAR_ARCHIVE ); - r_railSegmentLength = ri->Cvar_Get( "r_railSegmentLength", "32", CVAR_ARCHIVE ); - r_ambientScale = ri->Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c9b5b4e38d..69156e64ea 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -87,7 +87,7 @@ extern cvar_t *r_stereoSeparation; extern cvar_t *r_skipBackEnd; -extern cvar_t *r_stereoEnabled; +extern cvar_t *r_stereo; extern cvar_t *r_anaglyphMode; extern cvar_t *r_greyscale; From 968adf0b60511ffdb19679b38a8732f10a68d574 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 8 Oct 2013 23:33:55 -0400 Subject: [PATCH 044/708] [rend2] Few more linker error fixes, calling it quits for the night --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_init.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 6c9e06c7da..680fb0c11b 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -66,6 +66,7 @@ set(MPRend2RdCommonFiles "${MPDir}/rd-common/tr_types.h" "${MPDir}/rd-common/tr_font.cpp" "${MPDir}/rd-common/tr_font.h" + "${MPDir}/rd-common/tr_noise.cpp" "${MPDir}/rd-common/tr_public.h") source_group("rd-common" FILES ${MPRend2RdCommonFiles}) set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 8bb8811369..28d3e667af 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1554,6 +1554,8 @@ extern qboolean gG2_GBMNoReconstruct; extern qboolean gG2_GBMUseSPMethod; static void G2API_BoltMatrixReconstruction( qboolean reconstruct ) { gG2_GBMNoReconstruct = (qboolean)!reconstruct; } static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = spMethod; } +extern IGhoul2InfoArray &TheGhoul2InfoArray(); +const CGhoul2Info NullG2; /* @@@@@@@@@@@@@@@@@@@@@ From 0fec49ddbc956ac9a19f702b65673df3ba52f13a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Wed, 9 Oct 2013 18:13:35 -0400 Subject: [PATCH 045/708] [rend2] Update glext.h and fix some function pointers. --- codemp/rd-rend2/glext.h | 13146 ++++++++++++++++++++++++++++ codemp/rd-rend2/qgl.h | 14 +- codemp/rd-rend2/tr_backend.cpp | 1 + codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_extensions.cpp | 8 +- codemp/rd-vanilla/tr_local.h | 2 +- 6 files changed, 13166 insertions(+), 7 deletions(-) create mode 100644 codemp/rd-rend2/glext.h diff --git a/codemp/rd-rend2/glext.h b/codemp/rd-rend2/glext.h new file mode 100644 index 0000000000..4adecc80cc --- /dev/null +++ b/codemp/rd-rend2/glext.h @@ -0,0 +1,13146 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** THIS FILE IS OBSOLETE. Please migrate away from using the +** ".spec" files and the headers generated from them to the +** XML Registry and headers generated from that. See +** http://www.opengl.org/registry/api/README.txt +** for more information. +** +** +** Copyright (c) 2007-2013 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated $Date: 2013-06-13 02:52:31 -0700 (Thu, 13 Jun 2013) $ */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 87 +/* Function declaration macros - to move into glplatform.h */ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_RESCALE_NORMAL 0x803A +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_TEXTURE_COORDS 0x8871 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 +#define GL_CLIP_DISTANCE6 0x3006 +#define GL_CLIP_DISTANCE7 0x3007 +#define GL_MAX_CLIP_DISTANCES 0x0D32 +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +/* Reuse tokens from ARB_depth_buffer_float */ +/* reuse GL_DEPTH_COMPONENT32F */ +/* reuse GL_DEPTH32F_STENCIL8 */ +/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_DEFAULT */ +/* reuse GL_FRAMEBUFFER_UNDEFINED */ +/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ +/* reuse GL_INDEX */ +/* reuse GL_MAX_RENDERBUFFER_SIZE */ +/* reuse GL_DEPTH_STENCIL */ +/* reuse GL_UNSIGNED_INT_24_8 */ +/* reuse GL_DEPTH24_STENCIL8 */ +/* reuse GL_TEXTURE_STENCIL_SIZE */ +/* reuse GL_TEXTURE_RED_TYPE */ +/* reuse GL_TEXTURE_GREEN_TYPE */ +/* reuse GL_TEXTURE_BLUE_TYPE */ +/* reuse GL_TEXTURE_ALPHA_TYPE */ +/* reuse GL_TEXTURE_DEPTH_TYPE */ +/* reuse GL_UNSIGNED_NORMALIZED */ +/* reuse GL_FRAMEBUFFER_BINDING */ +/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_BINDING */ +/* reuse GL_READ_FRAMEBUFFER */ +/* reuse GL_DRAW_FRAMEBUFFER */ +/* reuse GL_READ_FRAMEBUFFER_BINDING */ +/* reuse GL_RENDERBUFFER_SAMPLES */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* reuse GL_FRAMEBUFFER_COMPLETE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ +/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ +/* reuse GL_MAX_COLOR_ATTACHMENTS */ +/* reuse GL_COLOR_ATTACHMENT0 */ +/* reuse GL_COLOR_ATTACHMENT1 */ +/* reuse GL_COLOR_ATTACHMENT2 */ +/* reuse GL_COLOR_ATTACHMENT3 */ +/* reuse GL_COLOR_ATTACHMENT4 */ +/* reuse GL_COLOR_ATTACHMENT5 */ +/* reuse GL_COLOR_ATTACHMENT6 */ +/* reuse GL_COLOR_ATTACHMENT7 */ +/* reuse GL_COLOR_ATTACHMENT8 */ +/* reuse GL_COLOR_ATTACHMENT9 */ +/* reuse GL_COLOR_ATTACHMENT10 */ +/* reuse GL_COLOR_ATTACHMENT11 */ +/* reuse GL_COLOR_ATTACHMENT12 */ +/* reuse GL_COLOR_ATTACHMENT13 */ +/* reuse GL_COLOR_ATTACHMENT14 */ +/* reuse GL_COLOR_ATTACHMENT15 */ +/* reuse GL_DEPTH_ATTACHMENT */ +/* reuse GL_STENCIL_ATTACHMENT */ +/* reuse GL_FRAMEBUFFER */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_RENDERBUFFER_WIDTH */ +/* reuse GL_RENDERBUFFER_HEIGHT */ +/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ +/* reuse GL_STENCIL_INDEX1 */ +/* reuse GL_STENCIL_INDEX4 */ +/* reuse GL_STENCIL_INDEX8 */ +/* reuse GL_STENCIL_INDEX16 */ +/* reuse GL_RENDERBUFFER_RED_SIZE */ +/* reuse GL_RENDERBUFFER_GREEN_SIZE */ +/* reuse GL_RENDERBUFFER_BLUE_SIZE */ +/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ +/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ +/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ +/* reuse GL_MAX_SAMPLES */ +/* Reuse tokens from ARB_framebuffer_sRGB */ +/* reuse GL_FRAMEBUFFER_SRGB */ +/* Reuse tokens from ARB_half_float_vertex */ +/* reuse GL_HALF_FLOAT */ +/* Reuse tokens from ARB_map_buffer_range */ +/* reuse GL_MAP_READ_BIT */ +/* reuse GL_MAP_WRITE_BIT */ +/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ +/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ +/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ +/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ +/* Reuse tokens from ARB_texture_compression_rgtc */ +/* reuse GL_COMPRESSED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ +/* reuse GL_COMPRESSED_RG_RGTC2 */ +/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ +/* Reuse tokens from ARB_texture_rg */ +/* reuse GL_RG */ +/* reuse GL_RG_INTEGER */ +/* reuse GL_R8 */ +/* reuse GL_R16 */ +/* reuse GL_RG8 */ +/* reuse GL_RG16 */ +/* reuse GL_R16F */ +/* reuse GL_R32F */ +/* reuse GL_RG16F */ +/* reuse GL_RG32F */ +/* reuse GL_R8I */ +/* reuse GL_R8UI */ +/* reuse GL_R16I */ +/* reuse GL_R16UI */ +/* reuse GL_R32I */ +/* reuse GL_R32UI */ +/* reuse GL_RG8I */ +/* reuse GL_RG8UI */ +/* reuse GL_RG16I */ +/* reuse GL_RG16UI */ +/* reuse GL_RG32I */ +/* reuse GL_RG32UI */ +/* Reuse tokens from ARB_vertex_array_object */ +/* reuse GL_VERTEX_ARRAY_BINDING */ +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +/* Reuse tokens from ARB_framebuffer_object */ +/* reuse GL_TEXTURE_LUMINANCE_TYPE */ +/* reuse GL_TEXTURE_INTENSITY_TYPE */ +#endif + +#ifndef GL_VERSION_3_1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +/* Reuse tokens from ARB_copy_buffer */ +/* reuse GL_COPY_READ_BUFFER */ +/* reuse GL_COPY_WRITE_BUFFER */ +/* Reuse tokens from ARB_draw_instanced (none) */ +/* Reuse tokens from ARB_uniform_buffer_object */ +/* reuse GL_UNIFORM_BUFFER */ +/* reuse GL_UNIFORM_BUFFER_BINDING */ +/* reuse GL_UNIFORM_BUFFER_START */ +/* reuse GL_UNIFORM_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ +/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ +/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ +/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ +/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ +/* reuse GL_UNIFORM_TYPE */ +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_INDEX */ +/* reuse GL_UNIFORM_OFFSET */ +/* reuse GL_UNIFORM_ARRAY_STRIDE */ +/* reuse GL_UNIFORM_MATRIX_STRIDE */ +/* reuse GL_UNIFORM_IS_ROW_MAJOR */ +/* reuse GL_UNIFORM_BLOCK_BINDING */ +/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ +/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ +/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_INVALID_INDEX */ +#endif + +#ifndef GL_VERSION_3_2 +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +/* Reuse tokens from ARB_depth_clamp */ +/* reuse GL_DEPTH_CLAMP */ +/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ +/* Reuse tokens from ARB_fragment_coord_conventions (none) */ +/* Reuse tokens from ARB_provoking_vertex */ +/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +/* Reuse tokens from ARB_seamless_cube_map */ +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +/* Reuse tokens from ARB_sync */ +/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ +/* reuse GL_OBJECT_TYPE */ +/* reuse GL_SYNC_CONDITION */ +/* reuse GL_SYNC_STATUS */ +/* reuse GL_SYNC_FLAGS */ +/* reuse GL_SYNC_FENCE */ +/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ +/* reuse GL_UNSIGNALED */ +/* reuse GL_SIGNALED */ +/* reuse GL_ALREADY_SIGNALED */ +/* reuse GL_TIMEOUT_EXPIRED */ +/* reuse GL_CONDITION_SATISFIED */ +/* reuse GL_WAIT_FAILED */ +/* reuse GL_TIMEOUT_IGNORED */ +/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ +/* reuse GL_TIMEOUT_IGNORED */ +/* Reuse tokens from ARB_texture_multisample */ +/* reuse GL_SAMPLE_POSITION */ +/* reuse GL_SAMPLE_MASK */ +/* reuse GL_SAMPLE_MASK_VALUE */ +/* reuse GL_MAX_SAMPLE_MASK_WORDS */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_SAMPLES */ +/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ +/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ +/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ +/* reuse GL_MAX_INTEGER_SAMPLES */ +/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +/* Reuse tokens from ARB_blend_func_extended */ +/* reuse GL_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_COLOR */ +/* reuse GL_ONE_MINUS_SRC1_ALPHA */ +/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ +/* Reuse tokens from ARB_explicit_attrib_location (none) */ +/* Reuse tokens from ARB_occlusion_query2 */ +/* reuse GL_ANY_SAMPLES_PASSED */ +/* Reuse tokens from ARB_sampler_objects */ +/* reuse GL_SAMPLER_BINDING */ +/* Reuse tokens from ARB_shader_bit_encoding (none) */ +/* Reuse tokens from ARB_texture_rgb10_a2ui */ +/* reuse GL_RGB10_A2UI */ +/* Reuse tokens from ARB_texture_swizzle */ +/* reuse GL_TEXTURE_SWIZZLE_R */ +/* reuse GL_TEXTURE_SWIZZLE_G */ +/* reuse GL_TEXTURE_SWIZZLE_B */ +/* reuse GL_TEXTURE_SWIZZLE_A */ +/* reuse GL_TEXTURE_SWIZZLE_RGBA */ +/* Reuse tokens from ARB_timer_query */ +/* reuse GL_TIME_ELAPSED */ +/* reuse GL_TIMESTAMP */ +/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ +/* reuse GL_INT_2_10_10_10_REV */ +#endif + +#ifndef GL_VERSION_4_0 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +/* Reuse tokens from ARB_texture_query_lod (none) */ +/* Reuse tokens from ARB_draw_buffers_blend (none) */ +/* Reuse tokens from ARB_draw_indirect */ +/* reuse GL_DRAW_INDIRECT_BUFFER */ +/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_gpu_shader5 */ +/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ +/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ +/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ +/* Reuse tokens from ARB_gpu_shader_fp64 */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +/* Reuse tokens from ARB_shader_subroutine */ +/* reuse GL_ACTIVE_SUBROUTINES */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ +/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ +/* reuse GL_MAX_SUBROUTINES */ +/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +/* Reuse tokens from ARB_tessellation_shader */ +/* reuse GL_PATCHES */ +/* reuse GL_PATCH_VERTICES */ +/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ +/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ +/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ +/* reuse GL_TESS_GEN_MODE */ +/* reuse GL_TESS_GEN_SPACING */ +/* reuse GL_TESS_GEN_VERTEX_ORDER */ +/* reuse GL_TESS_GEN_POINT_MODE */ +/* reuse GL_ISOLINES */ +/* reuse GL_FRACTIONAL_ODD */ +/* reuse GL_FRACTIONAL_EVEN */ +/* reuse GL_MAX_PATCH_VERTICES */ +/* reuse GL_MAX_TESS_GEN_LEVEL */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ +/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_EVALUATION_SHADER */ +/* reuse GL_TESS_CONTROL_SHADER */ +/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ +/* Reuse tokens from ARB_transform_feedback2 */ +/* reuse GL_TRANSFORM_FEEDBACK */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ +/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ +/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ +/* Reuse tokens from ARB_transform_feedback3 */ +/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_VERSION_4_1 +/* Reuse tokens from ARB_ES2_compatibility */ +/* reuse GL_FIXED */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ +/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ +/* reuse GL_LOW_FLOAT */ +/* reuse GL_MEDIUM_FLOAT */ +/* reuse GL_HIGH_FLOAT */ +/* reuse GL_LOW_INT */ +/* reuse GL_MEDIUM_INT */ +/* reuse GL_HIGH_INT */ +/* reuse GL_SHADER_COMPILER */ +/* reuse GL_SHADER_BINARY_FORMATS */ +/* reuse GL_NUM_SHADER_BINARY_FORMATS */ +/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ +/* reuse GL_MAX_VARYING_VECTORS */ +/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ +/* reuse GL_RGB565 */ +/* Reuse tokens from ARB_get_program_binary */ +/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ +/* reuse GL_PROGRAM_BINARY_LENGTH */ +/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ +/* reuse GL_PROGRAM_BINARY_FORMATS */ +/* Reuse tokens from ARB_separate_shader_objects */ +/* reuse GL_VERTEX_SHADER_BIT */ +/* reuse GL_FRAGMENT_SHADER_BIT */ +/* reuse GL_GEOMETRY_SHADER_BIT */ +/* reuse GL_TESS_CONTROL_SHADER_BIT */ +/* reuse GL_TESS_EVALUATION_SHADER_BIT */ +/* reuse GL_ALL_SHADER_BITS */ +/* reuse GL_PROGRAM_SEPARABLE */ +/* reuse GL_ACTIVE_PROGRAM */ +/* reuse GL_PROGRAM_PIPELINE_BINDING */ +/* Reuse tokens from ARB_shader_precision (none) */ +/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ +/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ +/* reuse GL_MAX_VIEWPORTS */ +/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ +/* reuse GL_VIEWPORT_BOUNDS_RANGE */ +/* reuse GL_LAYER_PROVOKING_VERTEX */ +/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ +/* reuse GL_UNDEFINED_VERTEX */ +#endif + +#ifndef GL_VERSION_4_2 +/* Reuse tokens from ARB_base_instance (none) */ +/* Reuse tokens from ARB_shading_language_420pack (none) */ +/* Reuse tokens from ARB_transform_feedback_instanced (none) */ +/* Reuse tokens from ARB_compressed_texture_pixel_storage */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ +/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ +/* Reuse tokens from ARB_conservative_depth (none) */ +/* Reuse tokens from ARB_internalformat_query */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* Reuse tokens from ARB_map_buffer_alignment */ +/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ +/* Reuse tokens from ARB_shader_atomic_counters */ +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ +/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ +/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ +/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ +/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ +/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ +/* Reuse tokens from ARB_shader_image_load_store */ +/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ +/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ +/* reuse GL_UNIFORM_BARRIER_BIT */ +/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ +/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ +/* reuse GL_COMMAND_BARRIER_BIT */ +/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ +/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ +/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ +/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ +/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ +/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ +/* reuse GL_ALL_BARRIER_BITS */ +/* reuse GL_MAX_IMAGE_UNITS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +/* reuse GL_IMAGE_BINDING_NAME */ +/* reuse GL_IMAGE_BINDING_LEVEL */ +/* reuse GL_IMAGE_BINDING_LAYERED */ +/* reuse GL_IMAGE_BINDING_LAYER */ +/* reuse GL_IMAGE_BINDING_ACCESS */ +/* reuse GL_IMAGE_1D */ +/* reuse GL_IMAGE_2D */ +/* reuse GL_IMAGE_3D */ +/* reuse GL_IMAGE_2D_RECT */ +/* reuse GL_IMAGE_CUBE */ +/* reuse GL_IMAGE_BUFFER */ +/* reuse GL_IMAGE_1D_ARRAY */ +/* reuse GL_IMAGE_2D_ARRAY */ +/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_INT_IMAGE_1D */ +/* reuse GL_INT_IMAGE_2D */ +/* reuse GL_INT_IMAGE_3D */ +/* reuse GL_INT_IMAGE_2D_RECT */ +/* reuse GL_INT_IMAGE_CUBE */ +/* reuse GL_INT_IMAGE_BUFFER */ +/* reuse GL_INT_IMAGE_1D_ARRAY */ +/* reuse GL_INT_IMAGE_2D_ARRAY */ +/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D */ +/* reuse GL_UNSIGNED_INT_IMAGE_3D */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ +/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ +/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ +/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_MAX_IMAGE_SAMPLES */ +/* reuse GL_IMAGE_BINDING_FORMAT */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ +/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ +/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ +/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ +/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ +/* Reuse tokens from ARB_shading_language_packing (none) */ +/* Reuse tokens from ARB_texture_storage */ +/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ +#endif + +#ifndef GL_VERSION_4_3 +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ +/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ +/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ +/* Reuse tokens from ARB_ES3_compatibility */ +/* reuse GL_COMPRESSED_RGB8_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_ETC2 */ +/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ +/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ +/* reuse GL_COMPRESSED_R11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ +/* reuse GL_COMPRESSED_RG11_EAC */ +/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ +/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ +/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ +/* reuse GL_MAX_ELEMENT_INDEX */ +/* Reuse tokens from ARB_clear_buffer_object (none) */ +/* Reuse tokens from ARB_compute_shader */ +/* reuse GL_COMPUTE_SHADER */ +/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ +/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ +/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ +/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ +/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ +/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ +/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ +/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ +/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ +/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ +/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER */ +/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ +/* Reuse tokens from ARB_copy_image (none) */ +/* Reuse tokens from KHR_debug */ +/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ +/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ +/* reuse GL_DEBUG_CALLBACK_FUNCTION */ +/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ +/* reuse GL_DEBUG_SOURCE_API */ +/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ +/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ +/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ +/* reuse GL_DEBUG_SOURCE_APPLICATION */ +/* reuse GL_DEBUG_SOURCE_OTHER */ +/* reuse GL_DEBUG_TYPE_ERROR */ +/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ +/* reuse GL_DEBUG_TYPE_PORTABILITY */ +/* reuse GL_DEBUG_TYPE_PERFORMANCE */ +/* reuse GL_DEBUG_TYPE_OTHER */ +/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ +/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_LOGGED_MESSAGES */ +/* reuse GL_DEBUG_SEVERITY_HIGH */ +/* reuse GL_DEBUG_SEVERITY_MEDIUM */ +/* reuse GL_DEBUG_SEVERITY_LOW */ +/* reuse GL_DEBUG_TYPE_MARKER */ +/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ +/* reuse GL_DEBUG_TYPE_POP_GROUP */ +/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ +/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ +/* reuse GL_BUFFER */ +/* reuse GL_SHADER */ +/* reuse GL_PROGRAM */ +/* reuse GL_QUERY */ +/* reuse GL_PROGRAM_PIPELINE */ +/* reuse GL_SAMPLER */ +/* reuse GL_DISPLAY_LIST */ +/* reuse GL_MAX_LABEL_LENGTH */ +/* reuse GL_DEBUG_OUTPUT */ +/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +/* Reuse tokens from ARB_explicit_uniform_location */ +/* reuse GL_MAX_UNIFORM_LOCATIONS */ +/* Reuse tokens from ARB_framebuffer_no_attachments */ +/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ +/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ +/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ +/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ +/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ +/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ +/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ +/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ +/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ +/* Reuse tokens from ARB_internalformat_query2 */ +/* reuse GL_INTERNALFORMAT_SUPPORTED */ +/* reuse GL_INTERNALFORMAT_PREFERRED */ +/* reuse GL_INTERNALFORMAT_RED_SIZE */ +/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ +/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ +/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ +/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ +/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ +/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ +/* reuse GL_INTERNALFORMAT_RED_TYPE */ +/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ +/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ +/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ +/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ +/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ +/* reuse GL_MAX_WIDTH */ +/* reuse GL_MAX_HEIGHT */ +/* reuse GL_MAX_DEPTH */ +/* reuse GL_MAX_LAYERS */ +/* reuse GL_MAX_COMBINED_DIMENSIONS */ +/* reuse GL_COLOR_COMPONENTS */ +/* reuse GL_DEPTH_COMPONENTS */ +/* reuse GL_STENCIL_COMPONENTS */ +/* reuse GL_COLOR_RENDERABLE */ +/* reuse GL_DEPTH_RENDERABLE */ +/* reuse GL_STENCIL_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE */ +/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ +/* reuse GL_FRAMEBUFFER_BLEND */ +/* reuse GL_READ_PIXELS */ +/* reuse GL_READ_PIXELS_FORMAT */ +/* reuse GL_READ_PIXELS_TYPE */ +/* reuse GL_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_TEXTURE_IMAGE_TYPE */ +/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ +/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ +/* reuse GL_MIPMAP */ +/* reuse GL_MANUAL_GENERATE_MIPMAP */ +/* reuse GL_AUTO_GENERATE_MIPMAP */ +/* reuse GL_COLOR_ENCODING */ +/* reuse GL_SRGB_READ */ +/* reuse GL_SRGB_WRITE */ +/* reuse GL_FILTER */ +/* reuse GL_VERTEX_TEXTURE */ +/* reuse GL_TESS_CONTROL_TEXTURE */ +/* reuse GL_TESS_EVALUATION_TEXTURE */ +/* reuse GL_GEOMETRY_TEXTURE */ +/* reuse GL_FRAGMENT_TEXTURE */ +/* reuse GL_COMPUTE_TEXTURE */ +/* reuse GL_TEXTURE_SHADOW */ +/* reuse GL_TEXTURE_GATHER */ +/* reuse GL_TEXTURE_GATHER_SHADOW */ +/* reuse GL_SHADER_IMAGE_LOAD */ +/* reuse GL_SHADER_IMAGE_STORE */ +/* reuse GL_SHADER_IMAGE_ATOMIC */ +/* reuse GL_IMAGE_TEXEL_SIZE */ +/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ +/* reuse GL_IMAGE_PIXEL_FORMAT */ +/* reuse GL_IMAGE_PIXEL_TYPE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ +/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ +/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ +/* reuse GL_CLEAR_BUFFER */ +/* reuse GL_TEXTURE_VIEW */ +/* reuse GL_VIEW_COMPATIBILITY_CLASS */ +/* reuse GL_FULL_SUPPORT */ +/* reuse GL_CAVEAT_SUPPORT */ +/* reuse GL_IMAGE_CLASS_4_X_32 */ +/* reuse GL_IMAGE_CLASS_2_X_32 */ +/* reuse GL_IMAGE_CLASS_1_X_32 */ +/* reuse GL_IMAGE_CLASS_4_X_16 */ +/* reuse GL_IMAGE_CLASS_2_X_16 */ +/* reuse GL_IMAGE_CLASS_1_X_16 */ +/* reuse GL_IMAGE_CLASS_4_X_8 */ +/* reuse GL_IMAGE_CLASS_2_X_8 */ +/* reuse GL_IMAGE_CLASS_1_X_8 */ +/* reuse GL_IMAGE_CLASS_11_11_10 */ +/* reuse GL_IMAGE_CLASS_10_10_10_2 */ +/* reuse GL_VIEW_CLASS_128_BITS */ +/* reuse GL_VIEW_CLASS_96_BITS */ +/* reuse GL_VIEW_CLASS_64_BITS */ +/* reuse GL_VIEW_CLASS_48_BITS */ +/* reuse GL_VIEW_CLASS_32_BITS */ +/* reuse GL_VIEW_CLASS_24_BITS */ +/* reuse GL_VIEW_CLASS_16_BITS */ +/* reuse GL_VIEW_CLASS_8_BITS */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ +/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ +/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ +/* reuse GL_VIEW_CLASS_RGTC1_RED */ +/* reuse GL_VIEW_CLASS_RGTC2_RG */ +/* reuse GL_VIEW_CLASS_BPTC_UNORM */ +/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ +/* Reuse tokens from ARB_invalidate_subdata (none) */ +/* Reuse tokens from ARB_multi_draw_indirect (none) */ +/* Reuse tokens from ARB_program_interface_query */ +/* reuse GL_UNIFORM */ +/* reuse GL_UNIFORM_BLOCK */ +/* reuse GL_PROGRAM_INPUT */ +/* reuse GL_PROGRAM_OUTPUT */ +/* reuse GL_BUFFER_VARIABLE */ +/* reuse GL_SHADER_STORAGE_BLOCK */ +/* reuse GL_VERTEX_SUBROUTINE */ +/* reuse GL_TESS_CONTROL_SUBROUTINE */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE */ +/* reuse GL_GEOMETRY_SUBROUTINE */ +/* reuse GL_FRAGMENT_SUBROUTINE */ +/* reuse GL_COMPUTE_SUBROUTINE */ +/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ +/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ +/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ +/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ +/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ +/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ +/* reuse GL_ACTIVE_RESOURCES */ +/* reuse GL_MAX_NAME_LENGTH */ +/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ +/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_NAME_LENGTH */ +/* reuse GL_TYPE */ +/* reuse GL_ARRAY_SIZE */ +/* reuse GL_OFFSET */ +/* reuse GL_BLOCK_INDEX */ +/* reuse GL_ARRAY_STRIDE */ +/* reuse GL_MATRIX_STRIDE */ +/* reuse GL_IS_ROW_MAJOR */ +/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ +/* reuse GL_BUFFER_BINDING */ +/* reuse GL_BUFFER_DATA_SIZE */ +/* reuse GL_NUM_ACTIVE_VARIABLES */ +/* reuse GL_ACTIVE_VARIABLES */ +/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ +/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ +/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ +/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ +/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ +/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ +/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ +/* reuse GL_LOCATION */ +/* reuse GL_LOCATION_INDEX */ +/* reuse GL_IS_PER_PATCH */ +/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ +/* Reuse tokens from ARB_shader_storage_buffer_object */ +/* reuse GL_SHADER_STORAGE_BUFFER */ +/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ +/* reuse GL_SHADER_STORAGE_BUFFER_START */ +/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ +/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ +/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ +/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ +/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ +/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ +/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ +/* Reuse tokens from ARB_stencil_texturing */ +/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ +/* Reuse tokens from ARB_texture_buffer_range */ +/* reuse GL_TEXTURE_BUFFER_OFFSET */ +/* reuse GL_TEXTURE_BUFFER_SIZE */ +/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ +/* Reuse tokens from ARB_texture_query_levels (none) */ +/* Reuse tokens from ARB_texture_storage_multisample (none) */ +/* Reuse tokens from ARB_texture_view */ +/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ +/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ +/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ +/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ +/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ +/* Reuse tokens from ARB_vertex_attrib_binding */ +/* reuse GL_VERTEX_ATTRIB_BINDING */ +/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_VERTEX_BINDING_DIVISOR */ +/* reuse GL_VERTEX_BINDING_OFFSET */ +/* reuse GL_VERTEX_BINDING_STRIDE */ +/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ +/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +/* reuse GL_MAX_VARYING_COMPONENTS */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#endif + +#ifndef GL_ARB_compatibility +/* ARB_compatibility just defines tokens from core 3.0 */ +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#endif + +#ifndef GL_ARB_shader_texture_lod +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_DEPTH_CLAMP 0x864F +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + +#ifndef GL_ARB_sync +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#endif + +#ifndef GL_ARB_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_ARB_draw_buffers_blend +#endif + +#ifndef GL_ARB_sample_shading +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif + +#ifndef GL_ARB_texture_gather +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif + +#ifndef GL_ARB_texture_query_lod +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_SRC1_COLOR 0x88F9 +/* reuse GL_SRC1_ALPHA */ +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#endif + +#ifndef GL_ARB_explicit_attrib_location +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_SAMPLER_BINDING 0x8919 +#endif + +#ifndef GL_ARB_shader_bit_encoding +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_RGB10_A2UI 0x906F +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#endif + +#ifndef GL_ARB_timer_query +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ +#define GL_INT_2_10_10_10_REV 0x8D9F +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +/* reuse GL_MAX_VERTEX_STREAMS */ +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +/* reuse GL_UNIFORM_SIZE */ +/* reuse GL_UNIFORM_NAME_LENGTH */ +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +/* reuse GL_TRIANGLES */ +/* reuse GL_QUADS */ +#define GL_ISOLINES 0x8E7A +/* reuse GL_EQUAL */ +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +/* reuse GL_CCW */ +/* reuse GL_CW */ +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +/* reuse GL_RGB32F */ +/* reuse GL_RGB32UI */ +/* reuse GL_RGB32I */ +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#endif + +#ifndef GL_ARB_shader_precision +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +/* reuse GL_RGB32I */ +/* reuse GL_DOUBLE_VEC2 */ +/* reuse GL_DOUBLE_VEC3 */ +/* reuse GL_DOUBLE_VEC4 */ +/* reuse GL_DOUBLE_MAT2 */ +/* reuse GL_DOUBLE_MAT3 */ +/* reuse GL_DOUBLE_MAT4 */ +/* reuse GL_DOUBLE_MAT2x3 */ +/* reuse GL_DOUBLE_MAT2x4 */ +/* reuse GL_DOUBLE_MAT3x2 */ +/* reuse GL_DOUBLE_MAT3x4 */ +/* reuse GL_DOUBLE_MAT4x2 */ +/* reuse GL_DOUBLE_MAT4x3 */ +#endif + +#ifndef GL_ARB_viewport_array +/* reuse GL_SCISSOR_BOX */ +/* reuse GL_VIEWPORT */ +/* reuse GL_DEPTH_RANGE */ +/* reuse GL_SCISSOR_TEST */ +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +/* reuse GL_FIRST_VERTEX_CONVENTION */ +/* reuse GL_LAST_VERTEX_CONVENTION */ +/* reuse GL_PROVOKING_VERTEX */ +#endif + +#ifndef GL_ARB_cl_event +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +#endif + +#ifndef GL_ARB_debug_output +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +#endif + +#ifndef GL_ARB_robustness +/* reuse GL_NO_ERROR */ +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +#endif + +#ifndef GL_ARB_shader_stencil_export +#endif + +#ifndef GL_ARB_base_instance +#endif + +#ifndef GL_ARB_shading_language_420pack +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#endif + +#ifndef GL_ARB_conservative_depth +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#endif + +#ifndef GL_ARB_shading_language_packing +#endif + +#ifndef GL_ARB_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif + +#ifndef GL_KHR_debug +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_DISPLAY_LIST 0x82E7 +/* DISPLAY_LIST used in compatibility profile only */ +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +/* reuse GL_STACK_UNDERFLOW */ +/* reuse GL_STACK_OVERFLOW */ +#endif + +#ifndef GL_ARB_arrays_of_arrays +#endif + +#ifndef GL_ARB_clear_buffer_object +#endif + +#ifndef GL_ARB_compute_shader +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#endif + +#ifndef GL_ARB_copy_image +#endif + +#ifndef GL_ARB_texture_view +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#endif + +#ifndef GL_ARB_robustness_isolation +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#endif + +#ifndef GL_ARB_internalformat_query2 +/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ +/* reuse GL_NUM_SAMPLE_COUNTS */ +/* reuse GL_RENDERBUFFER */ +/* reuse GL_SAMPLES */ +/* reuse GL_TEXTURE_1D */ +/* reuse GL_TEXTURE_1D_ARRAY */ +/* reuse GL_TEXTURE_2D */ +/* reuse GL_TEXTURE_2D_ARRAY */ +/* reuse GL_TEXTURE_3D */ +/* reuse GL_TEXTURE_CUBE_MAP */ +/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ +/* reuse GL_TEXTURE_RECTANGLE */ +/* reuse GL_TEXTURE_BUFFER */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE */ +/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ +/* reuse GL_TEXTURE_COMPRESSED */ +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_SRGB_DECODE_ARB 0x8299 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#endif + +#ifndef GL_ARB_invalidate_subdata +#endif + +#ifndef GL_ARB_multi_draw_indirect +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +/* reuse GL_ATOMIC_COUNTER_BUFFER */ +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ +/* reuse GL_COMPATIBLE_SUBROUTINES */ +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#endif + +#ifndef GL_ARB_shader_image_size +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#endif + +#ifndef GL_ARB_texture_query_levels +#endif + +#ifndef GL_ARB_texture_storage_multisample +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_static_data +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_byte_coordinates +#endif + +#ifndef GL_OES_fixed_point +#define GL_FIXED_OES 0x140C +#endif + +#ifndef GL_OES_single_precision +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_OES_query_matrix +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F +#endif + +#ifndef GL_EXT_vertex_array_bgra +/* reuse GL_BGRA */ +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +#endif + +#ifndef GL_ATI_meminfo +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +#endif + +#ifndef GL_AMD_texture_texture4 +#endif + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +/* reuse GL_RED_SNORM */ +/* reuse GL_RG_SNORM */ +/* reuse GL_RGB_SNORM */ +/* reuse GL_RGBA_SNORM */ +/* reuse GL_R8_SNORM */ +/* reuse GL_RG8_SNORM */ +/* reuse GL_RGB8_SNORM */ +/* reuse GL_RGBA8_SNORM */ +/* reuse GL_R16_SNORM */ +/* reuse GL_RG16_SNORM */ +/* reuse GL_RGB16_SNORM */ +/* reuse GL_RGBA16_SNORM */ +/* reuse GL_SIGNED_NORMALIZED */ +#endif + +#ifndef GL_AMD_draw_buffers_blend +#endif + +#ifndef GL_APPLE_texture_range +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +/* reuse GL_STORAGE_CACHED_APPLE */ +/* reuse GL_STORAGE_SHARED_APPLE */ +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_RGB_422_APPLE 0x8A1F +/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ +/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ +#endif + +#ifndef GL_NV_video_capture +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +#endif + +#ifndef GL_NV_copy_image +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +#endif + +#ifndef GL_NV_texture_barrier +#endif + +#ifndef GL_AMD_shader_stencil_export +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ +#endif + +#ifndef GL_AMD_conservative_depth +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +/* reuse GL_DOUBLE */ +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +/* reuse GL_PATCHES */ +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +/* reuse GL_READ_WRITE */ +/* reuse GL_WRITE_ONLY */ +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +/* reuse GL_INT64_NV */ +/* reuse GL_UNSIGNED_INT64_NV */ +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_COLOR_SAMPLES_NV 0x8E20 +/* reuse GL_SAMPLES_ARB */ +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +#endif + +#ifndef GL_AMD_debug_output +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif + +#ifndef GL_NV_texture_multisample +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif + +#ifndef GL_AMD_sample_positions +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif + +#ifndef GL_AMD_multi_draw_indirect +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif + +#ifndef GL_NV_path_rendering +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +/* reuse GL_PRIMARY_COLOR */ +/* reuse GL_PRIMARY_COLOR_NV */ +/* reuse GL_SECONDARY_COLOR_NV */ +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#endif + +#ifndef GL_AMD_vertex_shader_layer +#endif + +#ifndef GL_NV_bindless_texture +#endif + +#ifndef GL_NV_shader_atomic_float +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif + +#ifndef GL_NV_compute_program5 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif + +#ifndef GL_NV_shader_storage_buffer_object +#endif + +#ifndef GL_NV_shader_atomic_counters +#endif + +#ifndef GL_NV_deep_texture3D +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif + +#ifndef GL_NVX_conditional_render +#endif + +#ifndef GL_AMD_sparse_texture +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +#endif + +#ifndef GL_AMD_shader_trinary_minmax +#endif + +#ifndef GL_INTEL_map_texture +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +#endif + +#ifndef GL_NV_draw_texture +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for program/shader text and shader object handles */ +typedef char GLcharARB; +typedef unsigned int GLhandleARB; +#endif + +/* GL type for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_ARB_sync +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef struct __GLsync *GLsync; +#endif + +#ifndef GL_ARB_cl_event +/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ +struct _cl_context; +struct _cl_event; +#endif + +#ifndef GL_ARB_debug_output +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_AMD_debug_output +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_KHR_debug +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +#endif + +#ifndef GL_NV_vdpau_interop +typedef GLintptr GLvdpauSurfaceNV; +#endif + +#ifndef GL_OES_fixed_point +/* GLint must be 32 bits, a relatively safe assumption on modern CPUs */ +typedef GLint GLfixed; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +/* OpenGL 3.0 also reuses entry points from these extensions: */ +/* ARB_framebuffer_object */ +/* ARB_map_buffer_range */ +/* ARB_vertex_array_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +/* OpenGL 3.1 also reuses entry points from these extensions: */ +/* ARB_copy_buffer */ +/* ARB_uniform_buffer_object */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +#endif + +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +/* OpenGL 3.2 also reuses entry points from these extensions: */ +/* ARB_draw_elements_base_vertex */ +/* ARB_provoking_vertex */ +/* ARB_sync */ +/* ARB_texture_multisample */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif + +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +/* OpenGL 3.3 also reuses entry points from these extensions: */ +/* ARB_blend_func_extended */ +/* ARB_sampler_objects */ +/* ARB_explicit_attrib_location, but it has none */ +/* ARB_occlusion_query2 (no entry points) */ +/* ARB_shader_bit_encoding (no entry points) */ +/* ARB_texture_rgb10_a2ui (no entry points) */ +/* ARB_texture_swizzle (no entry points) */ +/* ARB_timer_query */ +/* ARB_vertex_type_2_10_10_10_rev */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +/* OpenGL 4.0 also reuses entry points from these extensions: */ +/* ARB_texture_query_lod (no entry points) */ +/* ARB_draw_indirect */ +/* ARB_gpu_shader5 (no entry points) */ +/* ARB_gpu_shader_fp64 */ +/* ARB_shader_subroutine */ +/* ARB_tessellation_shader */ +/* ARB_texture_buffer_object_rgb32 (no entry points) */ +/* ARB_texture_cube_map_array (no entry points) */ +/* ARB_texture_gather (no entry points) */ +/* ARB_transform_feedback2 */ +/* ARB_transform_feedback3 */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +/* OpenGL 4.1 reuses entry points from these extensions: */ +/* ARB_ES2_compatibility */ +/* ARB_get_program_binary */ +/* ARB_separate_shader_objects */ +/* ARB_shader_precision (no entry points) */ +/* ARB_vertex_attrib_64bit */ +/* ARB_viewport_array */ +#endif + +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +/* OpenGL 4.2 reuses entry points from these extensions: */ +/* ARB_base_instance */ +/* ARB_shading_language_420pack (no entry points) */ +/* ARB_transform_feedback_instanced */ +/* ARB_compressed_texture_pixel_storage (no entry points) */ +/* ARB_conservative_depth (no entry points) */ +/* ARB_internalformat_query */ +/* ARB_map_buffer_alignment (no entry points) */ +/* ARB_shader_atomic_counters */ +/* ARB_shader_image_load_store */ +/* ARB_shading_language_packing (no entry points) */ +/* ARB_texture_storage */ +#endif + +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +/* OpenGL 4.3 reuses entry points from these extensions: */ +/* ARB_arrays_of_arrays (no entry points, GLSL only) */ +/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ +/* ARB_shader_image_size (no entry points, GLSL only) */ +/* ARB_ES3_compatibility (no entry points) */ +/* ARB_clear_buffer_object */ +/* ARB_compute_shader */ +/* ARB_copy_image */ +/* KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes) */ +/* ARB_explicit_uniform_location (no entry points) */ +/* ARB_framebuffer_no_attachments */ +/* ARB_internalformat_query2 */ +/* ARB_invalidate_subdata */ +/* ARB_multi_draw_indirect */ +/* ARB_program_interface_query */ +/* ARB_robust_buffer_access_behavior (no entry points) */ +/* ARB_shader_storage_buffer_object */ +/* ARB_stencil_texturing (no entry points) */ +/* ARB_texture_buffer_range */ +/* ARB_texture_query_levels (no entry points) */ +/* ARB_texture_storage_multisample */ +/* ARB_texture_view */ +/* ARB_vertex_attrib_binding */ +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +#endif + +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +#endif + +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif + +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif + +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); +#endif + +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +#endif + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif + +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +#endif + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); +#endif + +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif + +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +#endif + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#endif + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#endif + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#endif + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif + +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#endif + +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +#endif + +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif + +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif + +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +#endif + +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +#endif + +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); +#endif + +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif + +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +#endif + +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +#endif + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif + +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +#endif + +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +#endif + +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +#endif + +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); +#endif + +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); +#endif + +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +#endif + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +#endif + +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif + +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif + +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); +#endif + +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif + +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif + +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif + +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +#endif + +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif + +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif + +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); +#endif + +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +#endif + +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +#endif + +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif + +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif + +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif + +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +#endif + +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +#endif + +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif + +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +#endif + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif + +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +#endif + +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +/* This used to be SGIX prefix, which was an error in the header */ +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_byte_coordinates +#define GL_OES_byte_coordinates 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); +GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord2bOES (GLenum texture, GLbyte s, GLbyte t); +GLAPI void APIENTRY glMultiTexCoord2bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord3bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glMultiTexCoord3bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glMultiTexCoord4bOES (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glMultiTexCoord4bvOES (GLenum texture, const GLbyte *coords); +GLAPI void APIENTRY glTexCoord1bOES (GLbyte s); +GLAPI void APIENTRY glTexCoord1bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord2bOES (GLbyte s, GLbyte t); +GLAPI void APIENTRY glTexCoord2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); +GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); +#endif + +#ifndef GL_OES_fixed_point +#define GL_OES_fixed_point 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); +GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); +GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); +GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); +GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glIndexxOES (GLfixed component); +GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); +GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPassThroughxOES (GLfixed token); +GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); +GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); +GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex2xOES (GLfixed x); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); +#endif + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +#endif + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target); +typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +#endif + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#endif + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#endif + +#ifndef GL_NV_transform_feedback2 +#define GL_NV_transform_feedback2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedbackNV (void); +GLAPI void APIENTRY glResumeTransformFeedbackNV (void); +GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); +#endif + +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#endif + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#endif + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#endif + +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +#endif + +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#endif + +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); +#endif + +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#endif + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#endif + +#ifndef GL_NV_video_capture +#define GL_NV_video_capture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +GLAPI void APIENTRY glBindVideoCaptureStreamTextureNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +GLAPI void APIENTRY glEndVideoCaptureNV (GLuint video_capture_slot); +GLAPI void APIENTRY glGetVideoCaptureivNV (GLuint video_capture_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideoCaptureStreamfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVideoCaptureStreamdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); +#endif + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#endif + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#endif + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#endif + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#endif + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +#endif + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#endif + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif + +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#endif + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#endif + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +#endif + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif + +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +#endif + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif + +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +#endif + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#endif + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#endif + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#endif + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif + +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +#endif + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#endif + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +#endif + +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#endif + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#endif + +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#endif + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#endif + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#endif + +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#endif + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#endif + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI GLvoid* APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef GLvoid* (APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +#endif + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif + + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 80980dfc72..240974db3c 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -26,7 +26,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __QGL_H__ #define __QGL_H__ +#ifndef _WIN32 #include "SDL/SDL_opengl.h" +#else +#include +#include +#include "glext.h" + +#define APIENTRYP +#define GLsizeiptrARB size_t * +#define GLintptrARB int * +#define GLhandleARB unsigned int +#define GLcharARB char +#endif extern void (APIENTRYP qglActiveTextureARB) (GLenum texture); extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture); @@ -377,7 +389,7 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void); extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); // GL_EXT_multi_draw_arrays -extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, GLint *, GLsizei *, GLsizei); +extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, const GLint *, const GLsizei *, GLsizei); extern void (APIENTRY * qglMultiDrawElementsEXT) (GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei); // GL_ARB_shading_language_100 diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 22224f5176..41da5f8838 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ #include "tr_local.h" +#include "glext.h" backEndData_t *backEndData; backEndState_t backEnd; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 50b26a2c5a..3c19403523 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3189,7 +3189,7 @@ void R_MergeLeafSurfaces(void) R_BindIBO(ibo); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, (size_t *)(numIboIndexes * sizeof(*iboIndexes)), iboIndexes, GL_STATIC_DRAW_ARB); R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 51e4f44963..7ee72a4b5b 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -40,7 +40,7 @@ extern glwstate_t glw_state; void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); // GL_EXT_multi_draw_arrays -void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); void (APIENTRY * qglMultiDrawElementsEXT) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); // GL_ARB_vertex_shader @@ -282,9 +282,9 @@ void GLimp_InitExtraExtensions() qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GETADDRESS("glDeleteBuffersARB"); qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GETADDRESS("glGenBuffersARB"); qglIsBufferARB = (PFNGLISBUFFERARBPROC) GETADDRESS("glIsBufferARB"); - qglBufferDataARB = (PFNGLBUFFERDATAARBPROC) GETADDRESS("glBufferDataARB"); - qglBufferSubDataARB = (PFNGLBUFFERSUBDATAARBPROC) GETADDRESS("glBufferSubDataARB"); - qglGetBufferSubDataARB = (PFNGLGETBUFFERSUBDATAARBPROC) GETADDRESS("glGetBufferSubDataARB"); + qglBufferDataARB = (void (__stdcall *)(GLenum,GLsizeiptrARB,const GLvoid *,GLenum)) GETADDRESS("glBufferDataARB"); + qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,const GLvoid *)) GETADDRESS("glBufferSubDataARB"); + qglGetBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) GETADDRESS("glGetBufferSubDataARB"); qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GETADDRESS("glGetBufferParameterivARB"); qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GETADDRESS("glGetBufferPointervARB"); ri->Printf(PRINT_ALL, result[1], extension); diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index b0f1d3fe29..b9a6fd0c45 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -29,7 +29,7 @@ typedef unsigned int glIndex_t; #define MAX_STATES_PER_SHADER 32 #define MAX_STATE_NAME 32 -glconfig_t glConfig; +extern glconfig_t glConfig; typedef enum { From 6c1572b64b88a73ab7db43aef2586633370283d8 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 18:46:28 -0400 Subject: [PATCH 046/708] [rend2] Fixing the image loader. Made a batch script to create .cpp for the glsl shaders. Still have to manually merge the files. Some other conflicts resolved. --- code/rd-vanilla/tr_init.cpp | 2 +- codemp/rd-rend2/glext.h | 2 +- codemp/rd-rend2/glsl/makeglsl.bat | 28 + codemp/rd-rend2/glsl_shaders.cpp | 2100 +++++++++++++++++++++++++++++ codemp/rd-rend2/qgl.h | 5 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_extensions.cpp | 8 +- codemp/rd-rend2/tr_image.cpp | 105 -- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 15 +- 10 files changed, 2139 insertions(+), 130 deletions(-) create mode 100644 codemp/rd-rend2/glsl/makeglsl.bat create mode 100644 codemp/rd-rend2/glsl_shaders.cpp diff --git a/code/rd-vanilla/tr_init.cpp b/code/rd-vanilla/tr_init.cpp index 3d08f2a714..6770281c22 100644 --- a/code/rd-vanilla/tr_init.cpp +++ b/code/rd-vanilla/tr_init.cpp @@ -1575,7 +1575,7 @@ GetRefAPI */ extern void R_Resample(byte *source, int swidth, int sheight, byte *dest, int dwidth, int dheight, int components); extern void R_LoadDataImage( const char *name, byte **pic, int *width, int *height); -extern void R_LoadImage( const char *shortname, byte **pic, int *width, int *height, GLenum *format ); +extern void R_LoadImage( const char *shortname, byte **pic, int *width, int *height ); extern void R_CreateAutomapImage( const char *name, const byte *pic, int width, int height, qboolean mipmap, qboolean allowPicmip, qboolean allowTC, int glWrapClampMode ); extern void R_InvertImage(byte *data, int width, int height, int depth); diff --git a/codemp/rd-rend2/glext.h b/codemp/rd-rend2/glext.h index 4adecc80cc..d3c64c19f6 100644 --- a/codemp/rd-rend2/glext.h +++ b/codemp/rd-rend2/glext.h @@ -9656,7 +9656,7 @@ typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLsizei *first, const GLsizei *count, GLsizei primcount); typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); #endif diff --git a/codemp/rd-rend2/glsl/makeglsl.bat b/codemp/rd-rend2/glsl/makeglsl.bat new file mode 100644 index 0000000000..feee6fffa2 --- /dev/null +++ b/codemp/rd-rend2/glsl/makeglsl.bat @@ -0,0 +1,28 @@ +glsl_stringify.vbs bokeh_fp.glsl 1.cpp +glsl_stringify.vbs bokeh_vp.glsl 2.cpp +glsl_stringify.vbs calclevels4x_fp.glsl 3.cpp +glsl_stringify.vbs calclevels4x_vp.glsl 4.cpp +glsl_stringify.vbs depthblur_fp.glsl 5.cpp +glsl_stringify.vbs depthblur_vp.glsl 6.cpp +glsl_stringify.vbs dlight_fp.glsl 7.cpp +glsl_stringify.vbs dlight_vp.glsl 8.cpp +glsl_stringify.vbs down4x_fp.glsl 9.cpp +glsl_stringify.vbs down4x_vp.glsl 10.cpp +glsl_stringify.vbs fogpass_fp.glsl 11.cpp +glsl_stringify.vbs fogpass_vp.glsl 12.cpp +glsl_stringify.vbs generic_fp.glsl 13.cpp +glsl_stringify.vbs generic_vp.glsl 14.cpp +glsl_stringify.vbs lightall_fp.glsl 15.cpp +glsl_stringify.vbs lightall_vp.glsl 16.cpp +glsl_stringify.vbs pshadow_fp.glsl 17.cpp +glsl_stringify.vbs pshadow_vp.glsl 18.cpp +glsl_stringify.vbs shadowfill_fp.glsl 19.cpp +glsl_stringify.vbs shadowfill_vp.glsl 20.cpp +glsl_stringify.vbs shadowmask_fp.glsl 21.cpp +glsl_stringify.vbs shadowmask_vp.glsl 22.cpp +glsl_stringify.vbs ssao_fp.glsl 23.cpp +glsl_stringify.vbs ssao_vp.glsl 24.cpp +glsl_stringify.vbs texturecolor_fp.glsl 25.cpp +glsl_stringify.vbs texturecolor_vp.glsl 26.cpp +glsl_stringify.vbs tonemap_fp.glsl 27.cpp +glsl_stringify.vbs tonemap_vp.glsl 28.cpp \ No newline at end of file diff --git a/codemp/rd-rend2/glsl_shaders.cpp b/codemp/rd-rend2/glsl_shaders.cpp new file mode 100644 index 0000000000..071a820f2a --- /dev/null +++ b/codemp/rd-rend2/glsl_shaders.cpp @@ -0,0 +1,2100 @@ +#include "tr_local.h" + +const char *fallbackShader_bokeh_fp = +"uniform sampler2D u_TextureMap;\n" +"\n" +"uniform vec4 u_Color;\n" +"\n" +"uniform vec2 u_InvTexRes;\n" +"varying vec2 var_TexCoords;\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 color;\n" +"\tvec2 tc;\n" +"\n" +"#if 0\n" +"\tfloat c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture2D(u_TextureMap, tc);\n" +"\t\n" +"\tgl_FragColor = color * 0.04166667 * u_Color;\n" +"#endif\n" +"\n" +"\tfloat c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture2D(u_TextureMap, tc);\n" +"\t\n" +"\tgl_FragColor = color * 0.0625 * u_Color;\n" +"}\n" +; +const char *fallbackShader_bokeh_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_TexCoords;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" +"\tvar_TexCoords = attr_TexCoord0.st;\n" +"}\n" +; +const char *fallbackShader_calclevels4x_fp = +"uniform sampler2D u_TextureMap;\n" +"\n" +"uniform vec4 u_Color;\n" +"\n" +"uniform vec2 u_InvTexRes;\n" +"varying vec2 var_TexCoords;\n" +"\n" +"const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114);\n" +"\n" +"vec3 GetValues(vec2 offset, vec3 current)\n" +"{\n" +"\tvec3 minAvgMax;\n" +"\tvec2 tc = var_TexCoords + u_InvTexRes * offset; minAvgMax = texture2D(u_TextureMap, tc).rgb;\n" +"\n" +"#ifdef FIRST_PASS\n" +"\tfloat lumi = max(dot(LUMINANCE_VECTOR, minAvgMax), 0.000001);\n" +"\tfloat loglumi = clamp(log2(lumi), -10.0, 10.0);\n" +"\tminAvgMax = vec3(loglumi * 0.05 + 0.5);\n" +"#endif\n" +"\n" +"\treturn vec3(min(current.x, minAvgMax.x), current.y + minAvgMax.y, max(current.z, minAvgMax.z));\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tvec3 current = vec3(1.0, 0.0, 0.0);\n" +"\n" +"#ifdef FIRST_PASS\n" +"\tcurrent = GetValues(vec2( 0.0, 0.0), current);\n" +"#else\n" +"\tcurrent = GetValues(vec2(-1.5, -1.5), current);\n" +"\tcurrent = GetValues(vec2(-0.5, -1.5), current);\n" +"\tcurrent = GetValues(vec2( 0.5, -1.5), current);\n" +"\tcurrent = GetValues(vec2( 1.5, -1.5), current);\n" +"\t\n" +"\tcurrent = GetValues(vec2(-1.5, -0.5), current);\n" +"\tcurrent = GetValues(vec2(-0.5, -0.5), current);\n" +"\tcurrent = GetValues(vec2( 0.5, -0.5), current);\n" +"\tcurrent = GetValues(vec2( 1.5, -0.5), current);\n" +"\t\n" +"\tcurrent = GetValues(vec2(-1.5, 0.5), current);\n" +"\tcurrent = GetValues(vec2(-0.5, 0.5), current);\n" +"\tcurrent = GetValues(vec2( 0.5, 0.5), current);\n" +"\tcurrent = GetValues(vec2( 1.5, 0.5), current);\n" +"\n" +"\tcurrent = GetValues(vec2(-1.5, 1.5), current);\n" +"\tcurrent = GetValues(vec2(-0.5, 1.5), current);\n" +"\tcurrent = GetValues(vec2( 0.5, 1.5), current);\n" +"\tcurrent = GetValues(vec2( 1.5, 1.5), current);\n" +"\n" +"\tcurrent.y *= 0.0625;\n" +"#endif\n" +"\n" +"\tgl_FragColor = vec4(current, 1.0f);\n" +"}\n" +; +const char *fallbackShader_calclevels4x_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_TexCoords;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" +"\tvar_TexCoords = attr_TexCoord0.st;\n" +"}\n" +; +const char *fallbackShader_depthblur_fp = +"uniform sampler2D u_ScreenImageMap;\n" +"uniform sampler2D u_ScreenDepthMap;\n" +"\n" +"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" +"varying vec2 var_ScreenTex;\n" +"\n" +"//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033);\n" +"float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);\n" +"//float gauss[3] = float[3](0.60, 0.19, 0.0066);\n" +"#define GAUSS_SIZE 4\n" +"\n" +"float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)\n" +"{\n" +"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" +"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" +"}\n" +"\n" +"vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar)\n" +"{\n" +"\tfloat scale = 1.0 / 256.0;\n" +"\n" +"#if defined(USE_HORIZONTAL_BLUR)\n" +" vec2 direction = vec2(1.0, 0.0) * scale;\n" +"#else // if defined(USE_VERTICAL_BLUR)\n" +"\tvec2 direction = vec2(0.0, 1.0) * scale;\n" +"#endif\n" +"\t\n" +"\tfloat depthCenter = zFar * getLinearDepth(depthMap, tex, zFarDivZNear);\n" +"\tvec2 centerSlope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y));\n" +"\t\t\n" +"\tvec4 result = texture2D(imageMap, tex) * gauss[0];\n" +"\tfloat total = gauss[0];\n" +"\n" +"\tint i, j;\n" +"\tfor (i = 0; i < 2; i++)\n" +"\t{\n" +"\t\tfor (j = 1; j < GAUSS_SIZE; j++)\n" +"\t\t{\n" +"\t\t\tvec2 offset = direction * j;\n" +"\t\t\tfloat depthSample = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear);\n" +"\t\t\tfloat depthExpected = depthCenter + dot(centerSlope, offset);\n" +"\t\t\tif(abs(depthSample - depthExpected) < 5.0)\n" +"\t\t\t{\n" +"\t\t\t\tresult += texture2D(imageMap, tex + offset) * gauss[j];\n" +"\t\t\t\ttotal += gauss[j];\n" +"\t\t\t}\n" +"\t\t}\n" +"\t\t\n" +"\t\tdirection = -direction;\n" +"\t}\t\n" +"\t\t\n" +"\treturn result / total;\n" +"}\n" +"\n" +"void main()\n" +"{\t\t\n" +"\tgl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y);\n" +"}\n" +; +const char *fallbackShader_depthblur_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"varying vec2 var_ScreenTex;\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = attr_Position;\n" +"\tvar_ScreenTex = attr_TexCoord0.xy;\n" +"\t//vec2 screenCoords = gl_Position.xy / gl_Position.w;\n" +"\t//var_ScreenTex = screenCoords * 0.5 + 0.5;\n" +"}\n" +; +const char *fallbackShader_dlight_fp = +"uniform sampler2D u_DiffuseMap;\n" +"\n" +"varying vec2 var_Tex1;\n" +"varying vec4 var_Color;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 color = texture2D(u_DiffuseMap, var_Tex1);\n" +"\n" +"\tgl_FragColor = color * var_Color;\n" +"}\n" +; +const char *fallbackShader_dlight_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"attribute vec3 attr_Normal;\n" +"\n" +"uniform vec4 u_DlightInfo;\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"uniform int u_DeformGen;\n" +"uniform float u_DeformParams[5];\n" +"uniform float u_Time;\n" +"#endif\n" +"\n" +"uniform vec4 u_Color;\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_Tex1;\n" +"varying vec4 var_Color;\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" +"{\n" +"\tif (u_DeformGen == 0)\n" +"\t{\n" +"\t\treturn pos;\n" +"\t}\n" +"\n" +"\tfloat base = u_DeformParams[0];\n" +"\tfloat amplitude = u_DeformParams[1];\n" +"\tfloat phase = u_DeformParams[2];\n" +"\tfloat frequency = u_DeformParams[3];\n" +"\tfloat spread = u_DeformParams[4];\n" +"\n" +"\tif (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t}\n" +"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tphase += dot(pos.xyz, vec3(spread));\n" +"\t}\n" +"\n" +"\tfloat value = phase + (u_Time * frequency);\n" +"\tfloat func;\n" +"\n" +"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" +"\t{\n" +"\t\tfunc = sin(value * 2.0 * M_PI);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" +"\t{\n" +"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" +"\t{\n" +"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = fract(value);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = (1.0 - fract(value));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tfunc = sin(value);\n" +"\t}\n" +"\n" +"\treturn pos + normal * (base + func * amplitude);\n" +"}\n" +"#endif\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 position = attr_Position;\n" +"\tvec3 normal = attr_Normal;\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" +"#endif\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\t\t\n" +"\tvec3 dist = u_DlightInfo.xyz - position.xyz;\t\n" +"\n" +"\tvar_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5);\n" +"\tfloat dlightmod = step(0.0, dot(dist, normal));\n" +"\tdlightmod *= clamp(2.0 * (1.0 - abs(dist.z) * u_DlightInfo.a), 0.0, 1.0);\n" +"\t\n" +"\tvar_Color = u_Color * dlightmod;\n" +"}\n" +; +const char *fallbackShader_down4x_fp = +"uniform sampler2D u_TextureMap;\n" +"\n" +"uniform vec2 u_InvTexRes;\n" +"varying vec2 var_TexCoords;\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 color;\n" +"\tvec2 tc;\n" +"\t\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture2D(u_TextureMap, tc);\n" +"\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture2D(u_TextureMap, tc);\n" +"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture2D(u_TextureMap, tc);\n" +"\t\n" +"\tcolor *= 0.0625;\n" +"\t\n" +"\tgl_FragColor = color;\n" +"}\n" +; +const char *fallbackShader_down4x_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_TexCoords;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" +"\tvar_TexCoords = attr_TexCoord0.st;\n" +"}\n" +; +const char *fallbackShader_fogpass_fp = +"uniform vec4 u_Color;\n" +"\n" +"varying float var_Scale;\n" +"\n" +"void main()\n" +"{\n" +"\tgl_FragColor = u_Color;\n" +"\tgl_FragColor.a *= sqrt(clamp(var_Scale, 0.0, 1.0));\n" +"}\n" +; +const char *fallbackShader_fogpass_vp = +"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Normal;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"//#if defined(USE_VERTEX_ANIMATION)\n" +"attribute vec4 attr_Position2;\n" +"attribute vec3 attr_Normal2;\n" +"//#endif\n" +"\n" +"uniform vec4 u_FogDistance;\n" +"uniform vec4 u_FogDepth;\n" +"uniform float u_FogEyeT;\n" +"\n" +"//#if defined(USE_DEFORM_VERTEXES)\n" +"uniform int u_DeformGen;\n" +"uniform float u_DeformParams[5];\n" +"//#endif\n" +"\n" +"uniform float u_Time;\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"//#if defined(USE_VERTEX_ANIMATION)\n" +"uniform float u_VertexLerp;\n" +"//#endif\n" +"\n" +"varying float var_Scale;\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" +"{\n" +"\tif (u_DeformGen == 0)\n" +"\t{\n" +"\t\treturn pos;\n" +"\t}\n" +"\n" +"\tfloat base = u_DeformParams[0];\n" +"\tfloat amplitude = u_DeformParams[1];\n" +"\tfloat phase = u_DeformParams[2];\n" +"\tfloat frequency = u_DeformParams[3];\n" +"\tfloat spread = u_DeformParams[4];\n" +"\n" +"\tif (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t}\n" +"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tphase += dot(pos.xyz, vec3(spread));\n" +"\t}\n" +"\n" +"\tfloat value = phase + (u_Time * frequency);\n" +"\tfloat func;\n" +"\n" +"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" +"\t{\n" +"\t\tfunc = sin(value * 2.0 * M_PI);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" +"\t{\n" +"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" +"\t{\n" +"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = fract(value);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = (1.0 - fract(value));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tfunc = sin(value);\n" +"\t}\n" +"\n" +"\treturn pos + normal * (base + func * amplitude);\n" +"}\n" +"#endif\n" +"\n" +"float CalcFog(vec4 position)\n" +"{\n" +"\tfloat s = dot(position, u_FogDistance) * 8.0;\n" +"\tfloat t = dot(position, u_FogDepth);\n" +"\n" +"\tif (t < 1.0)\n" +"\t{\n" +"\t\tt = step(step(0.0, -u_FogEyeT), t);\n" +"\t}\n" +"\telse\n" +"\t{\n" +"\t\tt /= t - min(u_FogEyeT, 0.0);\n" +"\t}\n" +"\t\n" +"\treturn s * t;\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" +"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +"#else\n" +"\tvec4 position = attr_Position;\n" +"\tvec3 normal = attr_Normal;\n" +"#endif\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" +"#endif\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\n" +"\tvar_Scale = CalcFog(position);\n" +"}\n" +; +const char *fallbackShader_generic_fp = +"uniform sampler2D u_DiffuseMap;\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"uniform sampler2D u_LightMap;\n" +"\n" +"uniform int u_Texture1Env;\n" +"#endif\n" +"\n" +"varying vec2 var_DiffuseTex;\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"varying vec2 var_LightTex;\n" +"#endif\n" +"\n" +"varying vec4 var_Color;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 color = texture2D(u_DiffuseMap, var_DiffuseTex);\n" +"#if defined(USE_LIGHTMAP)\n" +"\tvec4 color2 = texture2D(u_LightMap, var_LightTex);\n" +" #if defined(RGBE_LIGHTMAP)\n" +"\tcolor2.rgb *= exp2(color2.a * 255.0 - 128.0);\n" +"\tcolor2.a = 1.0;\n" +" #endif\n" +"\n" +"\tif (u_Texture1Env == TEXENV_MODULATE)\n" +"\t{\n" +"\t\tcolor *= color2;\n" +"\t}\n" +"\telse if (u_Texture1Env == TEXENV_ADD)\n" +"\t{\n" +"\t\tcolor += color2;\n" +"\t}\n" +"\telse if (u_Texture1Env == TEXENV_REPLACE)\n" +"\t{\n" +"\t\tcolor = color2;\n" +"\t}\n" +"#endif\n" +"\n" +"\tgl_FragColor = color * var_Color;\n" +"}\n" +; +const char *fallbackShader_generic_vp = +"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Normal;\n" +"\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"attribute vec4 attr_Position2;\n" +"attribute vec3 attr_Normal2;\n" +"#endif\n" +"\n" +"attribute vec4 attr_Color;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)\n" +"attribute vec4 attr_TexCoord1;\n" +"#endif\n" +"\n" +"uniform vec4 u_DiffuseTexMatrix;\n" +"uniform vec4 u_DiffuseTexOffTurb;\n" +"\n" +"#if defined(USE_TCGEN) || defined(USE_RGBAGEN)\n" +"uniform vec3 u_ViewOrigin;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN)\n" +"uniform int u_TCGen0;\n" +"uniform vec3 u_TCGen0Vector0;\n" +"uniform vec3 u_TCGen0Vector1;\n" +"#endif\n" +"\n" +"#if defined(USE_FOG)\n" +"uniform vec4 u_FogDistance;\n" +"uniform vec4 u_FogDepth;\n" +"uniform float u_FogEyeT;\n" +"uniform vec4 u_FogColorMask;\n" +"#endif\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"uniform int u_DeformGen;\n" +"uniform float u_DeformParams[5];\n" +"uniform float u_Time;\n" +"#endif\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"uniform vec4 u_BaseColor;\n" +"uniform vec4 u_VertColor;\n" +"\n" +"#if defined(USE_RGBAGEN)\n" +"uniform int u_ColorGen;\n" +"uniform int u_AlphaGen;\n" +"uniform vec3 u_AmbientLight;\n" +"uniform vec3 u_DirectedLight;\n" +"uniform vec4 u_LightOrigin;\n" +"uniform float u_PortalRange;\n" +"#endif\n" +"\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"uniform float u_VertexLerp;\n" +"#endif\n" +"\n" +"varying vec2 var_DiffuseTex;\n" +"#if defined(USE_LIGHTMAP)\n" +"varying vec2 var_LightTex;\n" +"#endif\n" +"varying vec4 var_Color;\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" +"{\n" +"\tfloat base = u_DeformParams[0];\n" +"\tfloat amplitude = u_DeformParams[1];\n" +"\tfloat phase = u_DeformParams[2];\n" +"\tfloat frequency = u_DeformParams[3];\n" +"\tfloat spread = u_DeformParams[4];\n" +"\n" +"\tif (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t}\n" +"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tphase += dot(pos.xyz, vec3(spread));\n" +"\t}\n" +"\n" +"\tfloat value = phase + (u_Time * frequency);\n" +"\tfloat func;\n" +"\n" +"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" +"\t{\n" +"\t\tfunc = sin(value * 2.0 * M_PI);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" +"\t{\n" +"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" +"\t{\n" +"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = fract(value);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = (1.0 - fract(value));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tfunc = sin(value);\n" +"\t}\n" +"\n" +"\treturn pos + normal * (base + func * amplitude);\n" +"}\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN)\n" +"vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)\n" +"{\n" +"\tvec2 tex = attr_TexCoord0.st;\n" +"\n" +"\tif (TCGen == TCGEN_LIGHTMAP)\n" +"\t{\n" +"\t\ttex = attr_TexCoord1.st;\n" +"\t}\n" +"\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" +"\t{\n" +"\t\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" +"\t}\n" +"\telse if (TCGen == TCGEN_VECTOR)\n" +"\t{\n" +"\t\ttex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));\n" +"\t}\n" +"\t\n" +"\treturn tex;\n" +"}\n" +"#endif\n" +"\n" +"#if defined(USE_TCMOD)\n" +"vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)\n" +"{\n" +"\tfloat amplitude = offTurb.z;\n" +"\tfloat phase = offTurb.w;\n" +"\tvec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy;\n" +"\n" +"\tvec3 offsetPos = position / 1024.0;\n" +"\toffsetPos.x += offsetPos.z;\n" +"\t\n" +"\tvec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI);\n" +"\t\n" +"\treturn st2 + texOffset * amplitude;\t\n" +"}\n" +"#endif\n" +"\n" +"#if defined(USE_RGBAGEN)\n" +"vec4 CalcColor(vec3 position, vec3 normal)\n" +"{\n" +"\tvec4 color = u_VertColor * attr_Color + u_BaseColor;\n" +"\t\n" +"\tif (u_ColorGen == CGEN_LIGHTING_DIFFUSE)\n" +"\t{\n" +"\t\tfloat incoming = clamp(dot(normal, u_LightOrigin.xyz), 0.0, 1.0);\n" +"\n" +"\t\tcolor.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0);\n" +"\t}\n" +"\t\n" +"\tvec3 toView = u_ViewOrigin - position;\n" +"\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\n" +"\tif (u_AlphaGen == AGEN_LIGHTING_SPECULAR)\n" +"\t{\n" +"\t\tvec3 lightDir = normalize(vec3(-960.0, -1980.0, 96.0) - position.xyz);\n" +"\t\tvec3 halfangle = normalize(lightDir + viewer);\n" +"\t\t\n" +"\t\tcolor.a = pow(max(dot(normal, halfangle), 0.0), 8.0);\n" +"\t}\n" +"\telse if (u_AlphaGen == AGEN_PORTAL)\n" +"\t{\n" +"\t\tfloat alpha = length(toView) / u_PortalRange;\n" +"\n" +"\t\tcolor.a = clamp(alpha, 0.0, 1.0);\n" +"\t}\n" +"\telse if (u_AlphaGen == AGEN_FRESNEL)\n" +"\t{\n" +"\t\tcolor.a = 0.10 + 0.90 * pow(1.0 - dot(normal, viewer), 5);\n" +"\t}\n" +"\t\n" +"\treturn color;\n" +"}\n" +"#endif\n" +"\n" +"#if defined(USE_FOG)\n" +"float CalcFog(vec4 position)\n" +"{\n" +"\tfloat s = dot(position, u_FogDistance) * 8.0;\n" +"\tfloat t = dot(position, u_FogDepth);\n" +"\n" +"\tif (t < 1.0)\n" +"\t{\n" +"\t\tt = step(step(0.0, -u_FogEyeT), t);\n" +"\t}\n" +"\telse\n" +"\t{\n" +"\t\tt /= t - min(u_FogEyeT, 0.0);\n" +"\t}\n" +"\n" +"\treturn s * t;\n" +"}\n" +"#endif\n" +"\n" +"void main()\n" +"{\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" +"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +"#else\n" +"\tvec4 position = attr_Position;\n" +"\tvec3 normal = attr_Normal;\n" +"#endif\n" +"\n" +"#if defined(USE_DEFORM_VERTEXES)\n" +"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" +"#endif\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\n" +"#if defined(USE_TCGEN)\n" +"\tvec2 tex = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" +"#else\n" +"\tvec2 tex = attr_TexCoord0.st;\n" +"#endif\n" +"\n" +"#if defined(USE_TCMOD)\n" +"\tvar_DiffuseTex = ModTexCoords(tex, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" +"#else\n" +" var_DiffuseTex = tex;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"\tvar_LightTex = attr_TexCoord1.st;\n" +"#endif\n" +"\n" +"#if defined(USE_RGBAGEN)\n" +"\tvar_Color = CalcColor(position.xyz, normal);\n" +"#else\n" +"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" +"#endif\n" +"\n" +"#if defined(USE_FOG)\n" +"\tvar_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0));\n" +"#endif\n" +"}\n" +; +const char *fallbackShader_lightall_fp = +"uniform sampler2D u_DiffuseMap;\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"uniform sampler2D u_LightMap;\n" +"#endif\n" +"\n" +"#if defined(USE_NORMALMAP)\n" +"uniform sampler2D u_NormalMap;\n" +"#endif\n" +"\n" +"#if defined(USE_DELUXEMAP)\n" +"uniform sampler2D u_DeluxeMap;\n" +"#endif\n" +"\n" +"#if defined(USE_SPECULARMAP)\n" +"uniform sampler2D u_SpecularMap;\n" +"#endif\n" +"\n" +"#if defined(USE_SHADOWMAP)\n" +"uniform sampler2D u_ShadowMap;\n" +"#endif\n" +"\n" +"uniform vec3 u_ViewOrigin;\n" +"\n" +"#if defined(USE_TCGEN)\n" +"uniform int u_TCGen0;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT_VECTOR)\n" +"uniform vec4 u_LightOrigin;\n" +"uniform vec3 u_DirectedLight;\n" +"uniform vec3 u_AmbientLight;\n" +"uniform float u_LightRadius;\n" +"#endif\n" +"\n" +"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"uniform vec3 u_PrimaryLightColor;\n" +"uniform vec3 u_PrimaryLightAmbient;\n" +"uniform float u_PrimaryLightRadius;\n" +"#endif\n" +"\n" +"\n" +"#if defined(USE_LIGHT)\n" +"uniform vec2 u_MaterialInfo;\n" +"#endif\n" +"\n" +"varying vec2 var_DiffuseTex;\n" +"#if defined(USE_LIGHTMAP)\n" +"varying vec2 var_LightTex;\n" +"#endif\n" +"varying vec4 var_Color;\n" +"\n" +"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" +"varying vec3 var_Position;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" +"varying vec3 var_SampleToView;\n" +"#endif\n" +"\n" +"#if !defined(USE_FAST_LIGHT)\n" +"varying vec3 var_Normal;\n" +"#endif\n" +"\n" +"#if defined(USE_VERT_TANGENT_SPACE)\n" +"varying vec3 var_Tangent;\n" +"varying vec3 var_Bitangent;\n" +"#endif\n" +"\n" +"varying vec3 var_VertLight;\n" +"\n" +"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" +"varying vec3 var_LightDirection;\n" +"#endif\n" +"\n" +"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"varying vec3 var_PrimaryLightDirection;\n" +"#endif\n" +"\n" +"\n" +"#define EPSILON 0.00000001\n" +"\n" +"#if defined(USE_PARALLAXMAP)\n" +"float SampleHeight(sampler2D normalMap, vec2 t)\n" +"{\n" +" #if defined(SWIZZLE_NORMALMAP)\n" +"\treturn texture2D(normalMap, t).r;\n" +" #else\n" +"\treturn texture2D(normalMap, t).a;\n" +" #endif\n" +"}\n" +"\n" +"float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)\n" +"{\n" +"\tconst int linearSearchSteps = 16;\n" +"\tconst int binarySearchSteps = 6;\n" +"\n" +"\tfloat depthStep = 1.0 / float(linearSearchSteps);\n" +"\n" +"\t// current size of search window\n" +"\tfloat size = depthStep;\n" +"\n" +"\t// current depth position\n" +"\tfloat depth = 0.0;\n" +"\n" +"\t// best match found (starts with last position 1.0)\n" +"\tfloat bestDepth = 1.0;\n" +"\n" +"\t// search front to back for first point inside object\n" +"\tfor(int i = 0; i < linearSearchSteps - 1; ++i)\n" +"\t{\n" +"\t\tdepth += size;\n" +"\t\t\n" +"\t\tfloat t = 1.0 - SampleHeight(normalMap, dp + ds * depth);\n" +"\t\t\n" +"\t\tif(bestDepth > 0.996)\t\t// if no depth found yet\n" +"\t\t\tif(depth >= t)\n" +"\t\t\t\tbestDepth = depth;\t// store best depth\n" +"\t}\n" +"\n" +"\tdepth = bestDepth;\n" +"\t\n" +"\t// recurse around first point (depth) for closest match\n" +"\tfor(int i = 0; i < binarySearchSteps; ++i)\n" +"\t{\n" +"\t\tsize *= 0.5;\n" +"\n" +"\t\tfloat t = 1.0 - SampleHeight(normalMap, dp + ds * depth);\n" +"\t\t\n" +"\t\tif(depth >= t)\n" +"\t\t{\n" +"\t\t\tbestDepth = depth;\n" +"\t\t\tdepth -= 2.0 * size;\n" +"\t\t}\n" +"\n" +"\t\tdepth += size;\n" +"\t}\n" +"\n" +"\treturn bestDepth;\n" +"}\n" +"#endif\n" +"\n" +"vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, float shininess)\n" +"{\n" +" #if defined(USE_OREN_NAYAR) || defined(USE_TRIACE_OREN_NAYAR)\n" +"\tfloat gamma = dot(E, L) - NE * NL;\n" +"\tfloat B = 2.22222 + 0.1 * shininess;\n" +"\t\t\n" +" #if defined(USE_OREN_NAYAR)\n" +"\tfloat A = 1.0 - 1.0 / (2.0 + 0.33 * shininess);\n" +"\tgamma = clamp(gamma, 0.0, 1.0);\n" +" #endif\n" +"\t\n" +" #if defined(USE_TRIACE_OREN_NAYAR)\n" +"\tfloat A = 1.0 - 1.0 / (2.0 + 0.65 * shininess);\n" +"\n" +"\tif (gamma >= 0.0)\n" +" #endif\n" +"\t{\n" +"\t\tB *= max(max(NL, NE), EPSILON);\n" +"\t}\n" +"\n" +"\treturn diffuseAlbedo * (A + gamma / B);\n" +" #else\n" +"\treturn diffuseAlbedo;\n" +" #endif\n" +"}\n" +"\n" +"#if defined(USE_SPECULARMAP)\n" +"vec3 CalcSpecular(vec3 specularReflectance, float NH, float NL, float NE, float EH, float shininess)\n" +"{\n" +" #if defined(USE_BLINN) || defined(USE_TRIACE) || defined(USE_TORRANCE_SPARROW)\n" +"\tfloat blinn = pow(NH, shininess);\n" +" #endif\n" +"\n" +" #if defined(USE_BLINN)\n" +"\treturn specularReflectance * blinn;\n" +" #endif\n" +"\n" +" #if defined(USE_COOK_TORRANCE) || defined (USE_TRIACE) || defined (USE_TORRANCE_SPARROW)\n" +"\tvec3 fresnel = specularReflectance + (vec3(1.0) - specularReflectance) * pow(1.0 - EH, 5);\n" +" #endif\n" +"\n" +" #if defined(USE_COOK_TORRANCE) || defined(USE_TORRANCE_SPARROW)\n" +"\tfloat geo = 2.0 * NH * min(NE, NL);\n" +"\tgeo /= max(EH, geo);\n" +" #endif \n" +"\n" +" #if defined(USE_COOK_TORRANCE)\n" +"\tfloat m_sq = 2.0 / max(shininess, EPSILON);\n" +"\tfloat NH_sq = NH * NH;\n" +"\tfloat m_NH_sq = m_sq * NH_sq;\n" +"\tfloat beckmann = exp((NH_sq - 1.0) / max(m_NH_sq, EPSILON)) / max(4.0 * m_NH_sq * NH_sq, EPSILON);\n" +"\n" +"\treturn fresnel * geo * beckmann / max(NE, EPSILON);\n" +" #endif\n" +"\n" +" #if defined(USE_TRIACE)\n" +"\tfloat scale = 0.1248582 * shininess + 0.2691817;\n" +"\n" +"\treturn fresnel * scale * blinn / max(max(NL, NE), EPSILON);\n" +" #endif\n" +" \n" +" #if defined(USE_TORRANCE_SPARROW)\n" +"\tfloat scale = 0.125 * shininess + 1.0;\n" +"\n" +"\treturn fresnel * geo * scale * blinn / max(NE, EPSILON);\n" +" #endif\n" +"}\n" +"#endif\n" +"\n" +"void main()\n" +"{\n" +"#if !defined(USE_FAST_LIGHT) && (defined(USE_LIGHT) || defined(USE_NORMALMAP))\n" +"\tvec3 surfN = normalize(var_Normal);\n" +"#endif\n" +"\n" +"#if defined(USE_DELUXEMAP)\n" +"\tvec3 L = 2.0 * texture2D(u_DeluxeMap, var_LightTex).xyz - vec3(1.0);\n" +"\t//L += var_LightDirection * 0.0001;\n" +"#elif defined(USE_LIGHT)\n" +"\tvec3 L = var_LightDirection;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"\tvec4 lightSample = texture2D(u_LightMap, var_LightTex).rgba;\n" +" #if defined(RGBE_LIGHTMAP)\n" +"\tlightSample.rgb *= exp2(lightSample.a * 255.0 - 128.0);\n" +" #endif\n" +"\tvec3 lightColor = lightSample.rgb;\n" +"#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)\n" +" #if defined(USE_INVSQRLIGHT)\n" +"\tfloat intensity = 1.0 / dot(L, L);\n" +" #else\n" +"\tfloat intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0);\n" +" #endif\n" +"\n" +"\tvec3 lightColor = u_DirectedLight * intensity;\n" +"\tvec3 ambientColor = u_AmbientLight;\n" +"#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" +"\tvec3 lightColor = var_VertLight;\n" +"#endif\n" +"\t\n" +"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" +"\tvec3 E = normalize(var_SampleToView);\n" +"#endif\n" +"\tvec2 texCoords = var_DiffuseTex;\n" +"\n" +"\tfloat ambientDiff = 1.0;\n" +"\n" +"#if defined(USE_NORMALMAP)\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"\tmat3 tangentToWorld = mat3(var_Tangent, var_Bitangent, var_Normal);\n" +" #else\n" +"\tvec3 q0 = dFdx(var_Position);\n" +"\tvec3 q1 = dFdy(var_Position);\n" +"\tvec2 st0 = dFdx(texCoords);\n" +"\tvec2 st1 = dFdy(texCoords);\n" +"\tfloat dir = sign(st1.t * st0.s - st0.t * st1.s);\n" +"\n" +"\tvec3 tangent = normalize(q0 * st1.t - q1 * st0.t) * dir;\n" +"\tvec3 bitangent = -normalize(q0 * st1.s - q1 * st0.s) * dir;\n" +"\n" +"\tmat3 tangentToWorld = mat3(tangent, bitangent, var_Normal);\n" +" #endif\n" +"\n" +" #if defined(USE_PARALLAXMAP)\n" +"\tvec3 offsetDir = normalize(E * tangentToWorld);\n" +"\toffsetDir.xy *= -0.05 / offsetDir.z;\n" +"\n" +"\ttexCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap);\n" +" #endif\n" +"\tvec3 texN;\n" +" #if defined(SWIZZLE_NORMALMAP)\n" +"\ttexN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - 1.0;\n" +" #else\n" +"\ttexN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - 1.0;\n" +" #endif\n" +"\ttexN.z = sqrt(clamp(1.0 - dot(texN.xy, texN.xy), 0.0, 1.0));\n" +"\tvec3 N = tangentToWorld * texN;\n" +" #if defined(r_normalAmbient)\n" +"\tambientDiff = 0.781341 * texN.z + 0.218659;\n" +" #endif\n" +"#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) \n" +"\tvec3 N = surfN;\n" +"#endif\n" +"\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || (defined(USE_TCGEN) && defined(USE_NORMALMAP))\n" +"\tN = normalize(N);\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN) && defined(USE_NORMALMAP)\n" +"\tif (u_TCGen0 == TCGEN_ENVIRONMENT_MAPPED)\n" +"\t{\n" +"\t\ttexCoords = -reflect(E, N).yz * vec2(0.5, -0.5) + 0.5;\n" +"\t}\n" +"#endif\n" +"\n" +"\tvec4 diffuseAlbedo = texture2D(u_DiffuseMap, texCoords);\n" +"#if defined(USE_LIGHT) && defined(USE_GAMMA2_TEXTURES)\n" +"\tdiffuseAlbedo.rgb *= diffuseAlbedo.rgb;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT) && defined(USE_FAST_LIGHT)\n" +"\tgl_FragColor = diffuse.rgb;\n" +" #if defined(USE_LIGHTMAP) \n" +"\tgl_FragColor *= lightColor;\n" +" #endif\n" +"#elif defined(USE_LIGHT)\n" +"\tL = normalize(L);\n" +"\n" +"\tfloat surfNL = clamp(dot(surfN, L), 0.0, 1.0);\n" +"\t\n" +" #if defined(USE_SHADOWMAP) \n" +"\tvec2 shadowTex = gl_FragCoord.xy * r_FBufScale;\n" +"\tfloat shadowValue = texture2D(u_ShadowMap, shadowTex).r;\n" +"\n" +"\t// surfaces not facing the light are always shadowed\n" +"\tshadowValue *= step(0.0, dot(surfN, var_PrimaryLightDirection));\n" +" \n" +" #if defined(SHADOWMAP_MODULATE)\n" +"\t//vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor);\n" +"\tvec3 shadowColor = u_PrimaryLightAmbient * lightColor;\n" +"\n" +" #if 0\n" +"\t// Only shadow when the world light is parallel to the primary light\n" +"\tshadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDirection), 0.0, 1.0);\n" +" #endif\n" +"\tlightColor = mix(shadowColor, lightColor, shadowValue);\n" +" #endif\n" +" #endif\n" +"\n" +" #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)\n" +" #if defined(USE_STANDARD_DELUXEMAP)\n" +"\t// Standard deluxe mapping treats the light sample as fully directed\n" +"\t// and doesn't compensate for light angle attenuation.\n" +"\tvec3 ambientColor = vec3(0.0);\n" +" #else\n" +"\t// Separate the light sample into directed and ambient parts.\n" +"\t//\n" +"\t// ambientMax - if the cosine of the angle between the surface\n" +"\t// normal and the light is below this value, the light\n" +"\t// is fully ambient.\n" +"\t// directedMax - if the cosine of the angle between the surface\n" +"\t// normal and the light is above this value, the light\n" +"\t// is fully directed.\n" +"\tconst float ambientMax = 0.25;\n" +"\tconst float directedMax = 0.5;\n" +"\n" +"\tfloat directedScale = clamp((surfNL - ambientMax) / (directedMax - ambientMax), 0.0, 1.0);\n" +"\t\n" +"\t// Scale the directed portion to compensate for the baked-in\n" +"\t// light angle attenuation.\n" +"\tdirectedScale /= max(surfNL, ambientMax);\n" +"\t\n" +" #if defined(r_normalAmbient)\n" +"\tdirectedScale *= 1.0 - r_normalAmbient;\n" +" #endif\n" +"\n" +"\t// Recover any unused light as ambient\n" +"\tvec3 ambientColor = lightColor;\n" +"\tlightColor *= directedScale;\n" +"\tambientColor -= lightColor * surfNL;\n" +" #endif\n" +" #endif\n" +"\n" +"\tfloat NL = clamp(dot(N, L), 0.0, 1.0);\n" +"\tfloat NE = clamp(dot(N, E), 0.0, 1.0);\n" +"\n" +"\tfloat maxReflectance = u_MaterialInfo.x;\n" +"\tfloat shininess = u_MaterialInfo.y;\n" +"\n" +" #if defined(USE_SPECULARMAP)\n" +"\tvec4 specularReflectance = texture2D(u_SpecularMap, texCoords);\n" +"\tspecularReflectance.rgb *= maxReflectance;\n" +"\tshininess *= specularReflectance.a;\n" +"\t// adjust diffuse by specular reflectance, to maintain energy conservation\n" +"\tdiffuseAlbedo.rgb *= vec3(1.0) - specularReflectance.rgb;\n" +" #endif\n" +"\n" +"\tgl_FragColor.rgb = lightColor * NL * CalcDiffuse(diffuseAlbedo.rgb, N, L, E, NE, NL, shininess);\n" +"\tgl_FragColor.rgb += ambientDiff * ambientColor * diffuseAlbedo.rgb;\n" +" #if defined(USE_PRIMARY_LIGHT)\n" +"\tvec3 L2 = var_PrimaryLightDirection;\n" +"\tfloat NL2 = clamp(dot(N, L2), 0.0, 1.0);\n" +"\n" +" #if defined(USE_SHADOWMAP)\n" +"\tgl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess);\n" +" #else\n" +"\tgl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess);\n" +" #endif\n" +" #endif\n" +" \n" +" #if defined(USE_SPECULARMAP)\n" +"\tvec3 H = normalize(L + E);\n" +"\n" +"\tfloat EH = clamp(dot(E, H), 0.0, 1.0);\n" +"\tfloat NH = clamp(dot(N, H), 0.0, 1.0);\n" +"\n" +"\tgl_FragColor.rgb += lightColor * NL * CalcSpecular(specularReflectance.rgb, NH, NL, NE, EH, shininess);\n" +" \n" +" #if defined(r_normalAmbient)\n" +"\tvec3 ambientHalf = normalize(surfN + E);\n" +"\tfloat ambientSpec = max(dot(ambientHalf, N) + 0.5, 0.0);\n" +"\tambientSpec *= ambientSpec * 0.44;\n" +"\tgl_FragColor.rgb += specularReflectance.rgb * ambientSpec * ambientColor;\n" +" #endif\n" +"\n" +" #if defined(USE_PRIMARY_LIGHT)\n" +"\tvec3 H2 = normalize(L2 + E);\n" +"\tfloat EH2 = clamp(dot(E, H2), 0.0, 1.0);\n" +"\tfloat NH2 = clamp(dot(N, H2), 0.0, 1.0);\n" +"\n" +"\n" +" #if defined(USE_SHADOWMAP)\n" +"\tgl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess);\n" +" #else\n" +"\tgl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess);\n" +" #endif\n" +" #endif\n" +" #endif \n" +"#else\n" +"\tgl_FragColor.rgb = diffuseAlbedo.rgb;\n" +"#endif\n" +"\n" +"\tgl_FragColor.a = diffuseAlbedo.a;\n" +"\n" +"\tgl_FragColor *= var_Color;\n" +"}\n" +; +const char *fallbackShader_lightall_vp = +"attribute vec4 attr_TexCoord0;\n" +"#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)\n" +"attribute vec4 attr_TexCoord1;\n" +"#endif\n" +"attribute vec4 attr_Color;\n" +"\n" +"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Normal;\n" +"\n" +"#if defined(USE_VERT_TANGENT_SPACE)\n" +"attribute vec3 attr_Tangent;\n" +"attribute vec3 attr_Bitangent;\n" +"#endif\n" +"\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"attribute vec4 attr_Position2;\n" +"attribute vec3 attr_Normal2;\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"attribute vec3 attr_Tangent2;\n" +"attribute vec3 attr_Bitangent2;\n" +" #endif\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR)\n" +"attribute vec3 attr_LightDirection;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" +"uniform vec3 u_ViewOrigin;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN)\n" +"uniform int u_TCGen0;\n" +"uniform vec3 u_TCGen0Vector0;\n" +"uniform vec3 u_TCGen0Vector1;\n" +"#endif\n" +"\n" +"#if defined(USE_TCMOD)\n" +"uniform vec4 u_DiffuseTexMatrix;\n" +"uniform vec4 u_DiffuseTexOffTurb;\n" +"#endif\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"uniform vec4 u_BaseColor;\n" +"uniform vec4 u_VertColor;\n" +"\n" +"#if defined(USE_MODELMATRIX)\n" +"uniform mat4 u_ModelMatrix;\n" +"#endif\n" +"\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"uniform float u_VertexLerp;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT_VECTOR)\n" +"uniform vec4 u_LightOrigin;\n" +" #if defined(USE_FAST_LIGHT)\n" +"uniform vec3 u_DirectedLight;\n" +"uniform vec3 u_AmbientLight;\n" +"uniform float u_LightRadius;\n" +" #endif\n" +"#endif\n" +"\n" +"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"uniform vec4 u_PrimaryLightOrigin;\n" +"#endif\n" +"\n" +"varying vec2 var_DiffuseTex;\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"varying vec2 var_LightTex;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" +"varying vec3 var_SampleToView;\n" +"#endif\n" +"\n" +"varying vec4 var_Color;\n" +"\n" +"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" +"varying vec3 var_Position;\n" +"#endif\n" +"\n" +"\n" +"#if !defined(USE_FAST_LIGHT)\n" +"varying vec3 var_Normal;\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"varying vec3 var_Tangent;\n" +"varying vec3 var_Bitangent;\n" +" #endif\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" +"varying vec3 var_VertLight;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +"varying vec3 var_LightDirection;\n" +"#endif\n" +"\n" +"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"varying vec3 var_PrimaryLightDirection;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN)\n" +"vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)\n" +"{\n" +"\tvec2 tex = attr_TexCoord0.st;\n" +"\n" +"\tif (TCGen == TCGEN_LIGHTMAP)\n" +"\t{\n" +"\t\ttex = attr_TexCoord1.st;\n" +"\t}\n" +"\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" +"\t{\n" +"\t\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" +"\t}\n" +"\telse if (TCGen == TCGEN_VECTOR)\n" +"\t{\n" +"\t\ttex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));\n" +"\t}\n" +"\t\n" +"\treturn tex;\n" +"}\n" +"#endif\n" +"\n" +"#if defined(USE_TCMOD)\n" +"vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)\n" +"{\n" +"\tfloat amplitude = offTurb.z;\n" +"\tfloat phase = offTurb.w;\n" +"\tvec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy;\n" +"\n" +"\tvec3 offsetPos = vec3(0); //position / 1024.0;\n" +"\toffsetPos.x += offsetPos.z;\n" +"\t\n" +"\tvec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI);\n" +"\t\n" +"\treturn st2 + texOffset * amplitude;\t\n" +"}\n" +"#endif\n" +"\n" +"\n" +"void main()\n" +"{\n" +"#if defined(USE_VERTEX_ANIMATION)\n" +"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" +"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"\tvec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp));\n" +"\tvec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp));\n" +" #endif\n" +"#else\n" +"\tvec4 position = attr_Position;\n" +"\tvec3 normal = attr_Normal;\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"\tvec3 tangent = attr_Tangent;\n" +"\tvec3 bitangent = attr_Bitangent;\n" +" #endif\n" +"#endif\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\n" +"#if (defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +"\tvec3 L = attr_LightDirection;\n" +"#endif\n" +"\t\n" +"#if defined(USE_MODELMATRIX)\n" +"\tposition = u_ModelMatrix * position;\n" +"\tnormal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"\ttangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;\n" +"\tbitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz;\n" +" #endif\n" +"\n" +" #if defined(USE_LIGHTMAP) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +"\tL = (u_ModelMatrix * vec4(L, 0.0)).xyz;\n" +" #endif\n" +"#endif\n" +"\n" +"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" +"\tvar_Position = position.xyz;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" +"\tvar_SampleToView = u_ViewOrigin - position.xyz;\n" +"#endif\n" +"\n" +"#if defined(USE_TCGEN)\n" +"\tvec2 texCoords = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" +"#else\n" +"\tvec2 texCoords = attr_TexCoord0.st;\n" +"#endif\n" +"\n" +"#if defined(USE_TCMOD)\n" +"\tvar_DiffuseTex = ModTexCoords(texCoords, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" +"#else\n" +"\tvar_DiffuseTex = texCoords;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHTMAP)\n" +"\tvar_LightTex = attr_TexCoord1.st;\n" +"#endif\n" +"\n" +"#if !defined(USE_FAST_LIGHT)\n" +"\tvar_Normal = normal;\n" +" #if defined(USE_VERT_TANGENT_SPACE)\n" +"\tvar_Tangent = tangent;\n" +"\tvar_Bitangent = bitangent;\n" +" #endif\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" +" #if defined(USE_LIGHT_VECTOR)\n" +"\tvec3 L = u_LightOrigin.xyz - (position.xyz * u_LightOrigin.w);\n" +" #endif\n" +" #if !defined(USE_FAST_LIGHT)\n" +"\tvar_LightDirection = L;\n" +" #endif\n" +"#endif\n" +"\t\n" +"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" +"\tvar_VertLight = u_VertColor.rgb * attr_Color.rgb;\n" +"\tvar_Color.rgb = vec3(1.0);\n" +"\tvar_Color.a = u_VertColor.a * attr_Color.a + u_BaseColor.a;\n" +"#else\n" +"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT)\n" +" #if defined(USE_INVSQRLIGHT)\n" +"\tfloat intensity = 1.0 / dot(L, L);\n" +" #else\n" +"\tfloat intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0);\n" +" #endif\n" +"\tfloat NL = clamp(dot(normal, normalize(L)), 0.0, 1.0);\n" +"\n" +"\tvar_Color.rgb *= u_DirectedLight * intensity * NL + u_AmbientLight;\n" +"#endif\n" +"\n" +"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"\tvar_PrimaryLightDirection = u_PrimaryLightOrigin.xyz - (position.xyz * u_PrimaryLightOrigin.w);\n" +"#endif\t\n" +"}\n" +; +const char *fallbackShader_pshadow_fp = +"uniform sampler2D u_ShadowMap;\n" +"\n" +"uniform vec3 u_LightForward;\n" +"uniform vec3 u_LightUp;\n" +"uniform vec3 u_LightRight;\n" +"uniform vec4 u_LightOrigin;\n" +"uniform float u_LightRadius;\n" +"varying vec3 var_Position;\n" +"varying vec3 var_Normal;\n" +"\n" +"float sampleDistMap(sampler2D texMap, vec2 uv, float scale)\n" +"{\n" +"\tvec3 distv = texture2D(texMap, uv).xyz;\n" +"\treturn dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0)) * scale;\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tvec3 lightToPos = var_Position - u_LightOrigin.xyz;\n" +"\tvec2 st = vec2(-dot(u_LightRight, lightToPos), dot(u_LightUp, lightToPos));\n" +"\t\n" +"\tfloat fade = length(st);\n" +"\t\n" +"#if defined(USE_DISCARD)\n" +"\tif (fade >= 1.0)\n" +"\t{\n" +"\t\tdiscard;\n" +"\t}\n" +"#endif\n" +"\n" +"\tfade = clamp(8.0 - fade * 8.0, 0.0, 1.0);\n" +"\t\n" +"\tst = st * 0.5 + vec2(0.5);\n" +"\n" +"#if defined(USE_SOLID_PSHADOWS)\n" +"\tfloat intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0);\n" +"#else\n" +"\tfloat intensity = clamp((1.0 - dot(lightToPos, lightToPos) / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0);\n" +"#endif\n" +"\t\n" +"\tfloat lightDist = length(lightToPos);\n" +"\tfloat dist;\n" +"\n" +"#if defined(USE_DISCARD)\n" +"\tif (dot(u_LightForward, lightToPos) <= 0.0)\n" +"\t{\n" +"\t\tdiscard;\n" +"\t}\n" +"\n" +"\tif (dot(var_Normal, lightToPos) > 0.0)\n" +"\t{\n" +"\t\tdiscard;\n" +"\t}\n" +"#else\n" +"\tintensity *= max(sign(dot(u_LightForward, lightToPos)), 0.0);\n" +"\tintensity *= max(sign(-dot(var_Normal, lightToPos)), 0.0);\n" +"#endif\n" +"\n" +"\tintensity *= fade;\n" +"#if defined(USE_PCF)\n" +"\tfloat part;\n" +"\t\n" +"\tdist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, -1.0/512.0), u_LightRadius);\n" +"\tpart = max(sign(lightDist - dist), 0.0);\n" +"\n" +"\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, -1.0/512.0), u_LightRadius);\n" +"\tpart += max(sign(lightDist - dist), 0.0);\n" +"\n" +"\tdist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, 1.0/512.0), u_LightRadius);\n" +"\tpart += max(sign(lightDist - dist), 0.0);\n" +"\n" +"\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, 1.0/512.0), u_LightRadius);\n" +"\tpart += max(sign(lightDist - dist), 0.0);\n" +"\n" +" #if defined(USE_DISCARD)\n" +"\tif (part <= 0.0)\n" +"\t{\n" +"\t\tdiscard;\n" +"\t}\n" +" #endif\n" +"\n" +"\tintensity *= part * 0.25;\n" +"#else\n" +"\tdist = sampleDistMap(u_ShadowMap, st, u_LightRadius);\n" +"\n" +" #if defined(USE_DISCARD)\n" +"\tif (lightDist - dist <= 0.0)\n" +"\t{\n" +"\t\tdiscard;\n" +"\t}\n" +" #endif\n" +"\t\t\t\n" +"\tintensity *= max(sign(lightDist - dist), 0.0);\n" +"#endif\n" +"\t\t\n" +"\tgl_FragColor.rgb = vec3(0);\n" +"\tgl_FragColor.a = clamp(intensity, 0.0, 0.75);\n" +"}\n" +; +const char *fallbackShader_pshadow_vp = +"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Normal;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"varying vec3 var_Position;\n" +"varying vec3 var_Normal;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 position = attr_Position;\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\n" +"\tvar_Position = position.xyz;\n" +"\tvar_Normal = attr_Normal;\n" +"}\n" +; +const char *fallbackShader_shadowfill_fp = +"uniform vec4 u_LightOrigin;\n" +"uniform float u_LightRadius;\n" +"\n" +"varying vec3 var_Position;\n" +"\n" +"void main()\n" +"{\n" +"#if defined(USE_DEPTH)\n" +"\tfloat depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius;\n" +" #if 0\n" +"\t// 32 bit precision\n" +"\tconst vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1);\n" +"\tconst vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n" +"\t\n" +"\tvec4 comp;\n" +"\tcomp = depth * bitSh;\n" +"\tcomp.xyz = fract(comp.xyz);\n" +"\tcomp -= comp.xxyz * bitMsk;\n" +"\tgl_FragColor = comp;\n" +" #endif\n" +"\n" +" #if 1\n" +"\t// 24 bit precision\n" +"\tconst vec3 bitSh = vec3( 256 * 256, 256, 1);\n" +"\tconst vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0);\n" +"\t\n" +"\tvec3 comp;\n" +"\tcomp = depth * bitSh;\n" +"\tcomp.xy = fract(comp.xy);\n" +"\tcomp -= comp.xxy * bitMsk;\n" +"\tgl_FragColor = vec4(comp, 1.0);\n" +" #endif\n" +"\n" +" #if 0\n" +"\t// 8 bit precision\n" +"\tgl_FragColor = vec4(depth, depth, depth, 1);\n" +" #endif\n" +"#else\n" +"\tgl_FragColor = vec4(0, 0, 0, 1);\n" +"#endif\n" +"}\n" +; +const char *fallbackShader_shadowfill_vp = +"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Normal;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"//#if defined(USE_VERTEX_ANIMATION)\n" +"attribute vec4 attr_Position2;\n" +"attribute vec3 attr_Normal2;\n" +"//#endif\n" +"\n" +"//#if defined(USE_DEFORM_VERTEXES)\n" +"uniform int u_DeformGen;\n" +"uniform float u_DeformParams[5];\n" +"//#endif\n" +"\n" +"uniform float u_Time;\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"uniform mat4 u_ModelMatrix;\n" +"\n" +"//#if defined(USE_VERTEX_ANIMATION)\n" +"uniform float u_VertexLerp;\n" +"//#endif\n" +"\n" +"varying vec3 var_Position;\n" +"\n" +"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" +"{\n" +"\tif (u_DeformGen == 0)\n" +"\t{\n" +"\t\treturn pos;\n" +"\t}\n" +"\n" +"\tfloat base = u_DeformParams[0];\n" +"\tfloat amplitude = u_DeformParams[1];\n" +"\tfloat phase = u_DeformParams[2];\n" +"\tfloat frequency = u_DeformParams[3];\n" +"\tfloat spread = u_DeformParams[4];\n" +"\n" +"\tif (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t}\n" +"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tphase += dot(pos.xyz, vec3(spread));\n" +"\t}\n" +"\n" +"\tfloat value = phase + (u_Time * frequency);\n" +"\tfloat func;\n" +"\n" +"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" +"\t{\n" +"\t\tfunc = sin(value * 2.0 * M_PI);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" +"\t{\n" +"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" +"\t{\n" +"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = fract(value);\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" +"\t{\n" +"\t\tfunc = (1.0 - fract(value));\n" +"\t}\n" +"\telse if (u_DeformGen == DGEN_BULGE)\n" +"\t{\n" +"\t\tfunc = sin(value);\n" +"\t}\n" +"\n" +"\treturn pos + normal * (base + func * amplitude);\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" +"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +"\n" +"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" +"\n" +"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" +"\t\n" +"\tvar_Position = (u_ModelMatrix * position).xyz;\n" +"}\n" +; +const char *fallbackShader_shadowmask_fp = +"uniform sampler2D u_ScreenDepthMap;\n" +"\n" +"uniform sampler2D u_ShadowMap;\n" +"#if defined(USE_SHADOW_CASCADE)\n" +"uniform sampler2D u_ShadowMap2;\n" +"uniform sampler2D u_ShadowMap3;\n" +"#endif\n" +"\n" +"uniform mat4 u_ShadowMvp;\n" +"#if defined(USE_SHADOW_CASCADE)\n" +"uniform mat4 u_ShadowMvp2;\n" +"uniform mat4 u_ShadowMvp3;\n" +"#endif\n" +"\n" +"uniform vec3 u_ViewOrigin;\n" +"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" +"\n" +"varying vec2 var_DepthTex;\n" +"varying vec3 var_ViewDir;\n" +"\n" +"// Input: It uses texture coords as the random number seed.\n" +"// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.\n" +"// Author: Michael Pohoreski\n" +"// Copyright: Copyleft 2012 :-)\n" +"// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader\n" +"\n" +"float random( const vec2 p )\n" +"{\n" +" // We need irrationals for pseudo randomness.\n" +" // Most (all?) known transcendental numbers will (generally) work.\n" +" const vec2 r = vec2(\n" +" 23.1406926327792690, // e^pi (Gelfond's constant)\n" +" 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant)\n" +" //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) );\n" +" return mod( 123456789., 1e-7 + 256. * dot(p,r) ); \n" +"}\n" +"\n" +"float PCF(const sampler2D shadowmap, const vec2 st, const float dist)\n" +"{\n" +"\tfloat mult;\n" +"\tfloat scale = 2.0 / r_shadowMapSize;\n" +"\t\t\n" +"#if defined(USE_SHADOW_FILTER)\n" +"\tfloat r = random(var_DepthTex.xy);\n" +"\tfloat sinr = sin(r) * scale;\n" +"\tfloat cosr = cos(r) * scale;\n" +"\tmat2 rmat = mat2(cosr, sinr, -sinr, cosr);\n" +"\n" +"\tmult = step(dist, texture2D(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r);\n" +" #if defined(USE_SHADOW_FILTER2)\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r);\n" +"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r);\n" +"\n" +"\tmult *= 0.11111;\n" +" #else\n" +" mult *= 0.33333;\n" +" #endif\n" +"#else\n" +"\tmult = step(dist, texture2D(shadowmap, st).r);\n" +"#endif\n" +"\t\t\n" +"\treturn mult;\n" +"}\n" +"\n" +"float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear)\n" +"{\n" +"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" +"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tfloat result;\n" +"\t\n" +"\tfloat depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x);\n" +"\tfloat sampleZ = u_ViewInfo.y * depth;\n" +"\n" +"\tvec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * depth * 0.99, 1.0);\n" +"\t\n" +"\tvec4 shadowpos = u_ShadowMvp * biasPos;\n" +"\t\n" +"#if defined(USE_SHADOW_CASCADE)\n" +"\tconst float fadeTo = 1.0;\n" +"\tresult = fadeTo;\n" +"#else\n" +"\tresult = 0.0;\n" +"#endif\n" +"\n" +"\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" +"\t{\n" +"\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" +"\t\tresult = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z);\n" +"\t}\n" +"#if defined(USE_SHADOW_CASCADE)\n" +"\telse\n" +"\t{\n" +"\t\tshadowpos = u_ShadowMvp2 * biasPos;\n" +"\n" +"\t\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" +"\t\t{\n" +"\t\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" +"\t\t\tresult = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z);\n" +"\t\t}\n" +"\t\telse\n" +"\t\t{\n" +"\t\t\tshadowpos = u_ShadowMvp3 * biasPos;\n" +"\n" +"\t\t\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" +"\t\t\t{\n" +"\t\t\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" +"\t\t\t\tresult = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z);\n" +"\n" +"\t\t\t\tfloat fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0);\n" +"\t\t\t\tresult = mix(result, fadeTo, fade);\n" +"\t\t\t}\n" +"\t\t}\n" +"\t}\n" +"#endif\n" +"\t\t\n" +"\tgl_FragColor = vec4(vec3(result), 1.0);\n" +"}\n" +; +const char *fallbackShader_shadowmask_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform vec3 u_ViewForward;\n" +"uniform vec3 u_ViewLeft;\n" +"uniform vec3 u_ViewUp;\n" +"uniform vec4 u_ViewInfo; // zfar / znear\n" +"\n" +"varying vec2 var_DepthTex;\n" +"varying vec3 var_ViewDir;\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = attr_Position;\n" +"\tvec2 screenCoords = gl_Position.xy / gl_Position.w;\n" +"\tvar_DepthTex = attr_TexCoord0.xy;\n" +"\tvar_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y;\n" +"}\n" +; +const char *fallbackShader_ssao_fp = +"uniform sampler2D u_ScreenDepthMap;\n" +"\n" +"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" +"\n" +"varying vec2 var_ScreenTex;\n" +"\n" +"vec2 poissonDisc[9] = vec2[9](\n" +"vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386),\n" +"vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417),\n" +"vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181),\n" +"vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854),\n" +"vec2(0.7320465, 0.6317794)\n" +");\n" +"\n" +"// Input: It uses texture coords as the random number seed.\n" +"// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.\n" +"// Author: Michael Pohoreski\n" +"// Copyright: Copyleft 2012 :-)\n" +"// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader\n" +"\n" +"float random( const vec2 p )\n" +"{\n" +" // We need irrationals for pseudo randomness.\n" +" // Most (all?) known transcendental numbers will (generally) work.\n" +" const vec2 r = vec2(\n" +" 23.1406926327792690, // e^pi (Gelfond's constant)\n" +" 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant)\n" +" //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) );\n" +" return mod( 123456789., 1e-7 + 256. * dot(p,r) ); \n" +"}\n" +"\n" +"mat2 randomRotation( const vec2 p )\n" +"{\n" +"\tfloat r = random(p);\n" +"\tfloat sinr = sin(r);\n" +"\tfloat cosr = cos(r);\n" +"\treturn mat2(cosr, sinr, -sinr, cosr);\n" +"}\n" +"\n" +"float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)\n" +"{\n" +"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" +"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" +"}\n" +"\n" +"float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar)\n" +"{\n" +"\tfloat result = 0;\n" +"\n" +"\tfloat sampleZ = zFar * getLinearDepth(depthMap, tex, zFarDivZNear);\n" +"\n" +"\tvec2 expectedSlope = vec2(dFdx(sampleZ), dFdy(sampleZ)) / vec2(dFdx(tex.x), dFdy(tex.y));\n" +"\t\n" +"\tif (length(expectedSlope) > 5000.0)\n" +"\t\treturn 1.0;\n" +"\t\n" +"\tvec2 offsetScale = vec2(3.0 / sampleZ);\n" +"\t\n" +"\tmat2 rmat = randomRotation(tex);\n" +"\t\t\n" +"\tint i;\n" +"\tfor (i = 0; i < 3; i++)\n" +"\t{\n" +"\t\tvec2 offset = rmat * poissonDisc[i] * offsetScale;\n" +"\t\tfloat sampleZ2 = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear);\n" +"\n" +"\t\tif (abs(sampleZ - sampleZ2) > 20.0)\n" +"\t\t\tresult += 1.0;\n" +"\t\telse\n" +"\t\t{\n" +"\t\t\tfloat expectedZ = sampleZ + dot(expectedSlope, offset);\n" +"\t\t\tresult += step(expectedZ - 1.0, sampleZ2);\n" +"\t\t}\n" +"\t}\n" +"\t\n" +"\tresult *= 0.33333;\n" +"\t\n" +"\treturn result;\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tfloat result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y);\n" +"\t\t\t\n" +"\tgl_FragColor = vec4(vec3(result), 1.0);\n" +"}\n" +; +const char *fallbackShader_ssao_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"varying vec2 var_ScreenTex;\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = attr_Position;\n" +"\tvar_ScreenTex = attr_TexCoord0.xy;\n" +"\t//vec2 screenCoords = gl_Position.xy / gl_Position.w;\n" +"\t//var_ScreenTex = screenCoords * 0.5 + 0.5;\n" +"}\n" +; +const char *fallbackShader_texturecolor_fp = +"#version 120\n" +"\n" +"uniform sampler2D u_DiffuseMap;\n" +"uniform vec4 u_Color;\n" +"\n" +"varying vec2 var_Tex1;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_FragColor = texture2D(u_DiffuseMap, var_Tex1) * u_Color;\n" +"}\n" +; +const char *fallbackShader_texturecolor_vp = +"#version 120\n" +"\n" +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_Tex1;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" +"\tvar_Tex1 = attr_TexCoord0.st;\n" +"}\n" +; +const char *fallbackShader_tonemap_fp = +"uniform sampler2D u_TextureMap;\n" +"uniform sampler2D u_LevelsMap;\n" +"\n" +"uniform vec4 u_Color;\n" +"\n" +"uniform vec2 u_AutoExposureMinMax;\n" +"uniform vec3 u_ToneMinAvgMaxLinear;\n" +"\n" +"varying vec2 var_TexCoords;\n" +"\n" +"const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114);\n" +"\n" +"vec3 FilmicTonemap(vec3 x)\n" +"{\n" +"\tconst float SS = 0.22; // Shoulder Strength\n" +"\tconst float LS = 0.30; // Linear Strength\n" +"\tconst float LA = 0.10; // Linear Angle\n" +"\tconst float TS = 0.20; // Toe Strength\n" +"\tconst float TAN = 0.01; // Toe Angle Numerator\n" +"\tconst float TAD = 0.30; // Toe Angle Denominator\n" +"\t\n" +"\tvec3 SSxx = SS * x * x;\n" +"\tvec3 LSx = LS * x;\n" +"\tvec3 LALSx = LSx * LA;\n" +"\t\n" +"\treturn ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD;\n" +"\n" +"\t//return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD;\n" +"\n" +"}\n" +"\n" +"void main()\n" +"{\n" +"\tvec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color;\n" +"\tvec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb;\n" +"\tvec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x);\n" +"\t\t\n" +"\tfloat avgLum = exp2(logMinAvgMaxLum.y);\n" +"\t//float maxLum = exp2(logMinAvgMaxLum.z);\n" +"\n" +"\tcolor.rgb *= u_ToneMinAvgMaxLinear.y / avgLum;\n" +"\tcolor.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x));\n" +"\n" +"\tvec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x));\n" +"\tcolor.rgb = FilmicTonemap(color.rgb) * fWhite;\n" +"\t\n" +"\tgl_FragColor = clamp(color, 0.0, 1.0);\n" +"}\n" +; +const char *fallbackShader_tonemap_vp = +"attribute vec4 attr_Position;\n" +"attribute vec4 attr_TexCoord0;\n" +"\n" +"uniform mat4 u_ModelViewProjectionMatrix;\n" +"\n" +"varying vec2 var_TexCoords;\n" +"\n" +"\n" +"void main()\n" +"{\n" +"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" +"\tvar_TexCoords = attr_TexCoord0.st;\n" +"}\n" +; diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 240974db3c..6efb5dd7bd 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include "glext.h" -#define APIENTRYP #define GLsizeiptrARB size_t * #define GLintptrARB int * #define GLhandleARB unsigned int @@ -411,8 +410,8 @@ extern void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer); extern void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); extern void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); extern GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); -extern void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); -extern void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); +extern void (APIENTRY * qglBufferDataARB) (GLenum target, GLint size, const GLvoid * data, GLenum usage); +extern void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLint offset, GLint size, const GLvoid * data); extern void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); extern void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); extern void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3c19403523..171fe788f0 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3189,7 +3189,7 @@ void R_MergeLeafSurfaces(void) R_BindIBO(ibo); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, (size_t *)(numIboIndexes * sizeof(*iboIndexes)), iboIndexes, GL_STATIC_DRAW_ARB); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, (GLint)(numIboIndexes * sizeof(*iboIndexes)), iboIndexes, GL_STATIC_DRAW_ARB); R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 7ee72a4b5b..f645f0e0da 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -63,8 +63,8 @@ void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); -void (APIENTRY * qglBufferDataARB) (GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); -void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); +void (APIENTRY * qglBufferDataARB) (GLenum target, GLint size, const GLvoid * data, GLenum usage); +void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLint offset, GLint size, const GLvoid * data); void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); @@ -282,8 +282,8 @@ void GLimp_InitExtraExtensions() qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GETADDRESS("glDeleteBuffersARB"); qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GETADDRESS("glGenBuffersARB"); qglIsBufferARB = (PFNGLISBUFFERARBPROC) GETADDRESS("glIsBufferARB"); - qglBufferDataARB = (void (__stdcall *)(GLenum,GLsizeiptrARB,const GLvoid *,GLenum)) GETADDRESS("glBufferDataARB"); - qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,const GLvoid *)) GETADDRESS("glBufferSubDataARB"); + qglBufferDataARB = (void (__stdcall *)(GLenum,GLint,const GLvoid *,GLenum)) GETADDRESS("glBufferDataARB"); + qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLint,GLint,const GLvoid *)) GETADDRESS("glBufferSubDataARB"); qglGetBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) GETADDRESS("glGetBufferSubDataARB"); qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GETADDRESS("glGetBufferParameterivARB"); qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GETADDRESS("glGetBufferPointervARB"); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 0779d85c09..05bd3db60c 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2417,111 +2417,6 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri->Hunk_FreeTempMemory( resampledBuffer ); } -//=================================================================== - -typedef struct -{ - char *ext; - void (*ImageLoader)( const char *, unsigned char **, int *, int * ); -} imageExtToLoaderMap_t; - -// Note that the ordering indicates the order of preference used -// when there are multiple images of different formats available -static imageExtToLoaderMap_t imageLoaders[ ] = -{ - { "tga", R_LoadTGA }, - { "jpg", R_LoadJPG }, - { "jpeg", R_LoadJPG }, - { "png", R_LoadPNG }, - { "pcx", R_LoadPCX }, - { "bmp", R_LoadBMP } -}; - -static int numImageLoaders = ARRAY_LEN( imageLoaders ); - -/* -================= -R_LoadImage - -Loads any of the supported image types into a cannonical -32 bit format. -================= -*/ -void R_LoadImage( const char *name, byte **pic, int *width, int *height ) -{ - qboolean orgNameFailed = qfalse; - int orgLoader = -1; - int i; - char localName[ MAX_QPATH ]; - const char *ext; - char *altName; - - *pic = NULL; - *width = 0; - *height = 0; - - Q_strncpyz( localName, name, MAX_QPATH ); - - ext = COM_GetExtension( localName ); - - if( *ext ) - { - // Look for the correct loader and use it - for( i = 0; i < numImageLoaders; i++ ) - { - if( !Q_stricmp( ext, imageLoaders[ i ].ext ) ) - { - // Load - imageLoaders[ i ].ImageLoader( localName, pic, width, height ); - break; - } - } - - // A loader was found - if( i < numImageLoaders ) - { - if( *pic == NULL ) - { - // Loader failed, most likely because the file isn't there; - // try again without the extension - orgNameFailed = qtrue; - orgLoader = i; - COM_StripExtension( name, localName, MAX_QPATH ); - } - else - { - // Something loaded - return; - } - } - } - - // Try and find a suitable match using all - // the image formats supported - for( i = 0; i < numImageLoaders; i++ ) - { - if (i == orgLoader) - continue; - - altName = va( "%s.%s", localName, imageLoaders[ i ].ext ); - - // Load - imageLoaders[ i ].ImageLoader( altName, pic, width, height ); - - if( *pic ) - { - if( orgNameFailed ) - { - ri->Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", - name, altName ); - } - - break; - } - } -} - - /* =============== R_FindImageFile diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 28d3e667af..dbcbfdafb0 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1441,7 +1441,7 @@ void R_Init( void ) { R_InitFogTable(); R_NoiseInit(); - + R_ImageLoader_Init(); R_Register(); max_polys = r_maxpolys->integer; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 69156e64ea..89468ec085 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2816,20 +2816,6 @@ void RB_SurfaceGhoul( CRenderableSurface *surface ); Ghoul2 Insert End */ -/* -============================================================= - -IMAGE LOADERS - -============================================================= -*/ - -void R_LoadBMP( const char *name, byte **pic, int *width, int *height ); -void R_LoadJPG( const char *name, byte **pic, int *width, int *height ); -void R_LoadPCX( const char *name, byte **pic, int *width, int *height ); -void R_LoadPNG( const char *name, byte **pic, int *width, int *height ); -void R_LoadTGA( const char *name, byte **pic, int *width, int *height ); - /* ============================================================= ============================================================= @@ -3067,5 +3053,6 @@ extern int maxAnisotropy; float ProjectRadius( float r, vec3_t location ); void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke); qboolean ShaderHashTableExists(void); +extern void R_ImageLoader_Init(void); #endif //TR_LOCAL_H From a4361c11bb10a0cf1f28c3cdf4992f98c646347b Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 18:59:35 -0400 Subject: [PATCH 047/708] Minor JPEG edit, probably nobody will notice it (shh!) --- lib/jpeg-8c/jdatadst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jpeg-8c/jdatadst.c b/lib/jpeg-8c/jdatadst.c index 472d5f3241..c42233dd1a 100644 --- a/lib/jpeg-8c/jdatadst.c +++ b/lib/jpeg-8c/jdatadst.c @@ -128,7 +128,7 @@ empty_mem_output_buffer (j_compress_ptr cinfo) /* Try to allocate new buffer with double size */ nextsize = dest->bufsize * 2; - nextbuffer = malloc(nextsize); + nextbuffer = (JOCTET *)malloc(nextsize); if (nextbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); @@ -256,7 +256,7 @@ jpeg_mem_dest (j_compress_ptr cinfo, if (*outbuffer == NULL || *outsize == 0) { /* Allocate initial buffer */ - dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE); + dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE); if (dest->newbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); *outsize = OUTPUT_BUF_SIZE; From 33074420b518ab96761ec46b8fa9f76bf091933a Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 19:23:14 -0400 Subject: [PATCH 048/708] undo a4361c11bb10a0cf1f28c3cdf4992f98c646347b --- lib/jpeg-8c/jdatadst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/jpeg-8c/jdatadst.c b/lib/jpeg-8c/jdatadst.c index c42233dd1a..472d5f3241 100644 --- a/lib/jpeg-8c/jdatadst.c +++ b/lib/jpeg-8c/jdatadst.c @@ -128,7 +128,7 @@ empty_mem_output_buffer (j_compress_ptr cinfo) /* Try to allocate new buffer with double size */ nextsize = dest->bufsize * 2; - nextbuffer = (JOCTET *)malloc(nextsize); + nextbuffer = malloc(nextsize); if (nextbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); @@ -256,7 +256,7 @@ jpeg_mem_dest (j_compress_ptr cinfo, if (*outbuffer == NULL || *outsize == 0) { /* Allocate initial buffer */ - dest->newbuffer = *outbuffer = (unsigned char *)malloc(OUTPUT_BUF_SIZE); + dest->newbuffer = *outbuffer = malloc(OUTPUT_BUF_SIZE); if (dest->newbuffer == NULL) ERREXIT1(cinfo, JERR_OUT_OF_MEMORY, 10); *outsize = OUTPUT_BUF_SIZE; From 91958262e91867251b51dca78bf739cc38f572cb Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 20:11:12 -0400 Subject: [PATCH 049/708] [rend2] It compiles... --- codemp/rd-rend2/qgl.h | 364 +++++++++++++++++++++++++++++- codemp/rd-rend2/tr_animation.cpp | 101 +-------- codemp/rd-rend2/tr_extensions.cpp | 4 +- codemp/rd-rend2/tr_ghoul2.cpp | 7 +- codemp/rd-rend2/tr_init.cpp | 21 +- codemp/rd-rend2/tr_local.h | 10 +- codemp/rd-vanilla/tr_init.cpp | 70 ------ codemp/win32/win_qgl.cpp | 67 ++++++ 8 files changed, 454 insertions(+), 190 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 6efb5dd7bd..e92bbed0ca 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -48,7 +48,369 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void); //=========================================================================== +#ifdef _WIN32 +extern int ( WINAPI * qwglSwapIntervalEXT)( int interval ); +extern BOOL ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT); +extern HGLRC ( WINAPI * qwglCreateContext)(HDC); +extern HGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int); +extern BOOL ( WINAPI * qwglDeleteContext)(HGLRC); +extern HGLRC ( WINAPI * qwglGetCurrentContext)(VOID); +extern HDC ( WINAPI * qwglGetCurrentDC)(VOID); +extern PROC ( WINAPI * qwglGetProcAddress)(LPCSTR); +extern BOOL ( WINAPI * qwglMakeCurrent)(HDC, HGLRC); +extern BOOL ( WINAPI * qwglShareLists)(HGLRC, HGLRC); +extern BOOL ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD); + +extern BOOL ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT, + FLOAT, int, LPGLYPHMETRICSFLOAT); + +extern BOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT, + LPLAYERPLANEDESCRIPTOR); +extern int ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int, + CONST COLORREF *); +extern int ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int, + COLORREF *); +extern BOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL); +extern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT); + +extern void ( APIENTRY * qglAccum )(GLenum op, GLfloat value); +extern void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref); +extern GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences); +extern void ( APIENTRY * qglArrayElement )(GLint i); +extern void ( APIENTRY * qglBegin )(GLenum mode); +extern void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture); +extern void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); +extern void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor); +extern void ( APIENTRY * qglCallList )(GLuint list); +extern void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists); +extern void ( APIENTRY * qglClear )(GLbitfield mask); +extern void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +extern void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +extern void ( APIENTRY * qglClearDepth )(GLclampd depth); +extern void ( APIENTRY * qglClearIndex )(GLfloat c); +extern void ( APIENTRY * qglClearStencil )(GLint s); +extern void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation); +extern void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue); +extern void ( APIENTRY * qglColor3bv )(const GLbyte *v); +extern void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue); +extern void ( APIENTRY * qglColor3dv )(const GLdouble *v); +extern void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue); +extern void ( APIENTRY * qglColor3fv )(const GLfloat *v); +extern void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue); +extern void ( APIENTRY * qglColor3iv )(const GLint *v); +extern void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue); +extern void ( APIENTRY * qglColor3sv )(const GLshort *v); +extern void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue); +extern void ( APIENTRY * qglColor3ubv )(const GLubyte *v); +extern void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue); +extern void ( APIENTRY * qglColor3uiv )(const GLuint *v); +extern void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue); +extern void ( APIENTRY * qglColor3usv )(const GLushort *v); +extern void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +extern void ( APIENTRY * qglColor4bv )(const GLbyte *v); +extern void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +extern void ( APIENTRY * qglColor4dv )(const GLdouble *v); +extern void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +extern void ( APIENTRY * qglColor4fv )(const GLfloat *v); +extern void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha); +extern void ( APIENTRY * qglColor4iv )(const GLint *v); +extern void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha); +extern void ( APIENTRY * qglColor4sv )(const GLshort *v); +extern void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +extern void ( APIENTRY * qglColor4ubv )(const GLubyte *v); +extern void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha); +extern void ( APIENTRY * qglColor4uiv )(const GLuint *v); +extern void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha); +extern void ( APIENTRY * qglColor4usv )(const GLushort *v); +extern void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +extern void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode); +extern void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); +extern void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); +extern void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +extern void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +extern void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +extern void ( APIENTRY * qglCullFace )(GLenum mode); +extern void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range); +extern void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures); +extern void ( APIENTRY * qglDepthFunc )(GLenum func); +extern void ( APIENTRY * qglDepthMask )(GLboolean flag); +extern void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar); +extern void ( APIENTRY * qglDisable )(GLenum cap); +extern void ( APIENTRY * qglDisableClientState )(GLenum array); +extern void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count); +extern void ( APIENTRY * qglDrawBuffer )(GLenum mode); +extern void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); +extern void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +extern void ( APIENTRY * qglEdgeFlag )(GLboolean flag); +extern void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag); +extern void ( APIENTRY * qglEnable )(GLenum cap); +extern void ( APIENTRY * qglEnableClientState )(GLenum array); +extern void ( APIENTRY * qglEnd )(void); +extern void ( APIENTRY * qglEndList )(void); +extern void ( APIENTRY * qglEvalCoord1d )(GLdouble u); +extern void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u); +extern void ( APIENTRY * qglEvalCoord1f )(GLfloat u); +extern void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u); +extern void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v); +extern void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u); +extern void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v); +extern void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u); +extern void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2); +extern void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); +extern void ( APIENTRY * qglEvalPoint1 )(GLint i); +extern void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j); +extern void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer); +extern void ( APIENTRY * qglFinish )(void); +extern void ( APIENTRY * qglFlush )(void); +extern void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param); +extern void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglFogi )(GLenum pname, GLint param); +extern void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params); +extern void ( APIENTRY * qglFrontFace )(GLenum mode); +extern void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +extern GLuint ( APIENTRY * qglGenLists )(GLsizei range); +extern void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures); +extern void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params); +extern void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation); +extern void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params); +extern GLenum ( APIENTRY * qglGetError )(void); +extern void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v); +extern void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v); +extern void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v); +extern void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetPixelMapfv )(GLenum m, GLfloat *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglGetPixelMapuiv )(GLenum m, GLuint *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglGetPixelMapusv )(GLenum m, GLushort *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params); +extern void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask); +extern const GLubyte * ( APIENTRY * qglGetString )(GLenum name); +extern void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params); +extern void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +extern void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params); +extern void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params); +extern void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params); +extern void ( APIENTRY * qglHint )(GLenum target, GLenum mode); +extern void ( APIENTRY * qglIndexMask )(GLuint mask); +extern void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglIndexd )(GLdouble c); +extern void ( APIENTRY * qglIndexdv )(const GLdouble *c); +extern void ( APIENTRY * qglIndexf )(GLfloat c); +extern void ( APIENTRY * qglIndexfv )(const GLfloat *c); +extern void ( APIENTRY * qglIndexi )(GLint c); +extern void ( APIENTRY * qglIndexiv )(const GLint *c); +extern void ( APIENTRY * qglIndexs )(GLshort c); +extern void ( APIENTRY * qglIndexsv )(const GLshort *c); +extern void ( APIENTRY * qglIndexub )(GLubyte c); +extern void ( APIENTRY * qglIndexubv )(const GLubyte *c); +extern void ( APIENTRY * qglInitNames )(void); +extern void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer); +extern GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap); +extern GLboolean ( APIENTRY * qglIsList )(GLuint list); +extern GLboolean ( APIENTRY * qglIsTexture )(GLuint texture); +extern void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param); +extern void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param); +extern void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params); +extern void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param); +extern void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param); +extern void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params); +extern void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern); +extern void ( APIENTRY * qglLineWidth )(GLfloat width); +extern void ( APIENTRY * qglListBase )(GLuint base); +extern void ( APIENTRY * qglLoadIdentity )(void); +extern void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m); +extern void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m); +extern void ( APIENTRY * qglLoadName )(GLuint name); +extern void ( APIENTRY * qglLogicOp )(GLenum opcode); +extern void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +extern void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +extern void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +extern void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); +extern void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2); +extern void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2); +extern void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); +extern void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); +extern void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param); +extern void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param); +extern void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params); +extern void ( APIENTRY * qglMatrixMode )(GLenum mode); +extern void ( APIENTRY * qglMultMatrixd )(const GLdouble *m); +extern void ( APIENTRY * qglMultMatrixf )(const GLfloat *m); +extern void ( APIENTRY * qglNewList )(GLuint list, GLenum mode); +extern void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz); +extern void ( APIENTRY * qglNormal3bv )(const GLbyte *v); +extern void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz); +extern void ( APIENTRY * qglNormal3dv )(const GLdouble *v); +extern void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz); +extern void ( APIENTRY * qglNormal3fv )(const GLfloat *v); +extern void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz); +extern void ( APIENTRY * qglNormal3iv )(const GLint *v); +extern void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz); +extern void ( APIENTRY * qglNormal3sv )(const GLshort *v); +extern void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +extern void ( APIENTRY * qglPassThrough )(GLfloat token); +extern void ( APIENTRY * qglPixelMapfv )(GLenum m, GLsizei mapsize, const GLfloat *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglPixelMapuiv )(GLenum m, GLsizei mapsize, const GLuint *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglPixelMapusv )(GLenum m, GLsizei mapsize, const GLushort *values); //rwwRMG - map->m (avoid map type conflict) +extern void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param); +extern void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param); +extern void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param); +extern void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param); +extern void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor); +extern void ( APIENTRY * qglPointSize )(GLfloat size); +extern void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode); +extern void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units); +extern void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask); +extern void ( APIENTRY * qglPopAttrib )(void); +extern void ( APIENTRY * qglPopClientAttrib )(void); +extern void ( APIENTRY * qglPopMatrix )(void); +extern void ( APIENTRY * qglPopName )(void); +extern void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities); +extern void ( APIENTRY * qglPushAttrib )(GLbitfield mask); +extern void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask); +extern void ( APIENTRY * qglPushMatrix )(void); +extern void ( APIENTRY * qglPushName )(GLuint name); +extern void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y); +extern void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v); +extern void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y); +extern void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v); +extern void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y); +extern void ( APIENTRY * qglRasterPos2iv )(const GLint *v); +extern void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y); +extern void ( APIENTRY * qglRasterPos2sv )(const GLshort *v); +extern void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z); +extern void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v); +extern void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z); +extern void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v); +extern void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z); +extern void ( APIENTRY * qglRasterPos3iv )(const GLint *v); +extern void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z); +extern void ( APIENTRY * qglRasterPos3sv )(const GLshort *v); +extern void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v); +extern void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v); +extern void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w); +extern void ( APIENTRY * qglRasterPos4iv )(const GLint *v); +extern void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w); +extern void ( APIENTRY * qglRasterPos4sv )(const GLshort *v); +extern void ( APIENTRY * qglReadBuffer )(GLenum mode); +extern void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); +extern void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); +extern void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2); +extern void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); +extern void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2); +extern void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2); +extern void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2); +extern void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2); +extern void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2); +extern GLint ( APIENTRY * qglRenderMode )(GLenum mode); +extern void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +extern void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +extern void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z); +extern void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z); +extern void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height); +extern void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer); +extern void ( APIENTRY * qglShadeModel )(GLenum mode); +extern void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask); +extern void ( APIENTRY * qglStencilMask )(GLuint mask); +extern void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass); +extern void ( APIENTRY * qglTexCoord1d )(GLdouble s); +extern void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v); +extern void ( APIENTRY * qglTexCoord1f )(GLfloat s); +extern void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v); +extern void ( APIENTRY * qglTexCoord1i )(GLint s); +extern void ( APIENTRY * qglTexCoord1iv )(const GLint *v); +extern void ( APIENTRY * qglTexCoord1s )(GLshort s); +extern void ( APIENTRY * qglTexCoord1sv )(const GLshort *v); +extern void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t); +extern void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v); +extern void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t); +extern void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v); +extern void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t); +extern void ( APIENTRY * qglTexCoord2iv )(const GLint *v); +extern void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t); +extern void ( APIENTRY * qglTexCoord2sv )(const GLshort *v); +extern void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r); +extern void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v); +extern void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r); +extern void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v); +extern void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r); +extern void ( APIENTRY * qglTexCoord3iv )(const GLint *v); +extern void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r); +extern void ( APIENTRY * qglTexCoord3sv )(const GLshort *v); +extern void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q); +extern void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v); +extern void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q); +extern void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v); +extern void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q); +extern void ( APIENTRY * qglTexCoord4iv )(const GLint *v); +extern void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q); +extern void ( APIENTRY * qglTexCoord4sv )(const GLshort *v); +extern void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param); +extern void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param); +extern void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params); +extern void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param); +extern void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params); +extern void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param); +extern void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param); +extern void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params); +extern void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +extern void ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +extern void ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param); +extern void ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params); +extern void ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param); +extern void ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params); +extern void ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +extern void ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +extern void ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z); +extern void ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z); +extern void ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y); +extern void ( APIENTRY * qglVertex2dv )(const GLdouble *v); +extern void ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y); +extern void ( APIENTRY * qglVertex2fv )(const GLfloat *v); +extern void ( APIENTRY * qglVertex2i )(GLint x, GLint y); +extern void ( APIENTRY * qglVertex2iv )(const GLint *v); +extern void ( APIENTRY * qglVertex2s )(GLshort x, GLshort y); +extern void ( APIENTRY * qglVertex2sv )(const GLshort *v); +extern void ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z); +extern void ( APIENTRY * qglVertex3dv )(const GLdouble *v); +extern void ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z); +extern void ( APIENTRY * qglVertex3fv )(const GLfloat *v); +extern void ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z); +extern void ( APIENTRY * qglVertex3iv )(const GLint *v); +extern void ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z); +extern void ( APIENTRY * qglVertex3sv )(const GLshort *v); +extern void ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); +extern void ( APIENTRY * qglVertex4dv )(const GLdouble *v); +extern void ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); +extern void ( APIENTRY * qglVertex4fv )(const GLfloat *v); +extern void ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w); +extern void ( APIENTRY * qglVertex4iv )(const GLint *v); +extern void ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w); +extern void ( APIENTRY * qglVertex4sv )(const GLshort *v); +extern void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +extern void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height); +#else #define qglAccum glAccum #define qglAlphaFunc glAlphaFunc #define qglAreTexturesResident glAreTexturesResident @@ -383,7 +745,7 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void); #define qglVertex4sv glVertex4sv #define qglVertexPointer glVertexPointer #define qglViewport glViewport - +#endif //_WIN32 // GL_EXT_draw_range_elements extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index c1ddb4ecec..e5f36cd9a1 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -554,103 +554,4 @@ void RB_MDRSurfaceAnim( md4Surface_t *surface ) } tess.numVertexes += surface->numVerts; -} - - -#define MC_MASK_X ((1<<(MC_BITS_X))-1) -#define MC_MASK_Y ((1<<(MC_BITS_Y))-1) -#define MC_MASK_Z ((1<<(MC_BITS_Z))-1) -#define MC_MASK_VECT ((1<<(MC_BITS_VECT))-1) - -#define MC_SCALE_VECT (1.0f/(float)((1<<(MC_BITS_VECT-1))-2)) - -#define MC_POS_X (0) -#define MC_SHIFT_X (0) - -#define MC_POS_Y ((((MC_BITS_X))/8)) -#define MC_SHIFT_Y ((((MC_BITS_X)%8))) - -#define MC_POS_Z ((((MC_BITS_X+MC_BITS_Y))/8)) -#define MC_SHIFT_Z ((((MC_BITS_X+MC_BITS_Y)%8))) - -#define MC_POS_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z))/8)) -#define MC_SHIFT_V11 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z)%8))) - -#define MC_POS_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT))/8)) -#define MC_SHIFT_V12 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT)%8))) - -#define MC_POS_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2))/8)) -#define MC_SHIFT_V13 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*2)%8))) - -#define MC_POS_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3))/8)) -#define MC_SHIFT_V21 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*3)%8))) - -#define MC_POS_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4))/8)) -#define MC_SHIFT_V22 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*4)%8))) - -#define MC_POS_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5))/8)) -#define MC_SHIFT_V23 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*5)%8))) - -#define MC_POS_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6))/8)) -#define MC_SHIFT_V31 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*6)%8))) - -#define MC_POS_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7))/8)) -#define MC_SHIFT_V32 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*7)%8))) - -#define MC_POS_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8))/8)) -#define MC_SHIFT_V33 ((((MC_BITS_X+MC_BITS_Y+MC_BITS_Z+MC_BITS_VECT*8)%8))) - -void MC_UnCompress(float mat[3][4],const unsigned char * comp) -{ - int val; - - val=(int)((unsigned short *)(comp))[0]; - val-=1<<(MC_BITS_X-1); - mat[0][3]=((float)(val))*MC_SCALE_X; - - val=(int)((unsigned short *)(comp))[1]; - val-=1<<(MC_BITS_Y-1); - mat[1][3]=((float)(val))*MC_SCALE_Y; - - val=(int)((unsigned short *)(comp))[2]; - val-=1<<(MC_BITS_Z-1); - mat[2][3]=((float)(val))*MC_SCALE_Z; - - val=(int)((unsigned short *)(comp))[3]; - val-=1<<(MC_BITS_VECT-1); - mat[0][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[4]; - val-=1<<(MC_BITS_VECT-1); - mat[0][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[5]; - val-=1<<(MC_BITS_VECT-1); - mat[0][2]=((float)(val))*MC_SCALE_VECT; - - - val=(int)((unsigned short *)(comp))[6]; - val-=1<<(MC_BITS_VECT-1); - mat[1][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[7]; - val-=1<<(MC_BITS_VECT-1); - mat[1][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[8]; - val-=1<<(MC_BITS_VECT-1); - mat[1][2]=((float)(val))*MC_SCALE_VECT; - - - val=(int)((unsigned short *)(comp))[9]; - val-=1<<(MC_BITS_VECT-1); - mat[2][0]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[10]; - val-=1<<(MC_BITS_VECT-1); - mat[2][1]=((float)(val))*MC_SCALE_VECT; - - val=(int)((unsigned short *)(comp))[11]; - val-=1<<(MC_BITS_VECT-1); - mat[2][2]=((float)(val))*MC_SCALE_VECT; -} +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index f645f0e0da..1647beac64 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -507,8 +507,8 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferObject = qfalse; if( GLimp_HaveExtension( extension ) ) { - glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); - glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); + qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); + qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GETADDRESS("glIsRenderbufferEXT"); qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GETADDRESS("glBindRenderbufferEXT"); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index b35c62c079..7cd0a65e51 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3175,14 +3175,9 @@ static void RootMatrix(CGhoul2Info_v &ghoul2,int time,const vec3_t scale,mdxaBon retMatrix=identityMatrix; } -extern cvar_t *r_shadowRange; static inline bool bInShadowRange(vec3_t location) { - const float c = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin ); - const float dist = DotProduct( tr.viewParms.or.axis[0], location ) - c; - -// return (dist < tr.distanceCull/1.5f); - return (dist < r_shadowRange->value); + return false; } /* diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index dbcbfdafb0..d2c2d92efa 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -32,7 +32,7 @@ qboolean textureFilterAnisotropic = qfalse; int maxAnisotropy = 0; float displayAspect = 0.0f; -glstate_t glState; +glstate_s glState; static void GfxInfo_f( void ); static void GfxMemInfo_f( void ); @@ -41,10 +41,14 @@ static void GfxMemInfo_f( void ); cvar_t *com_altivec; #endif +cvar_t *se_language; + cvar_t *r_flareSize; cvar_t *r_flareFade; cvar_t *r_flareCoeff; +cvar_t *r_displayRefresh; + cvar_t *r_verbose; cvar_t *r_ignore; @@ -93,6 +97,7 @@ cvar_t *r_ext_compiled_vertex_array; cvar_t *r_ext_texture_env_add; cvar_t *r_ext_texture_filter_anisotropic; cvar_t *r_ext_max_anisotropy; +cvar_t *r_ext_preferred_tc_method; cvar_t *r_ext_draw_range_elements; cvar_t *r_ext_multi_draw_arrays; @@ -194,6 +199,7 @@ cvar_t *r_lodCurveError; cvar_t *r_fullscreen; cvar_t *r_noborder; +cvar_t *r_centerWindow; cvar_t *r_customwidth; cvar_t *r_customheight; @@ -377,7 +383,7 @@ vidmode_t r_vidModes[] = }; static int s_numVidModes = ARRAY_LEN( r_vidModes ); -qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) { +qboolean R_GetModeInfo( int *width, int *height, int mode ) { vidmode_t *vm; float pixelAspect; @@ -400,8 +406,6 @@ qboolean R_GetModeInfo( int *width, int *height, float *windowAspect, int mode ) pixelAspect = vm->pixelAspect; } - *windowAspect = (float)*width / ( *height * pixelAspect ); - return qtrue; } @@ -1069,6 +1073,9 @@ void GfxInfo_f( void ) { ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } + if ( r_displayRefresh ->integer ) { + ri->Printf( PRINT_ALL, "Display refresh set to %d\n", r_displayRefresh->integer ); + } if ( r_finish->integer ) { ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); } @@ -1145,6 +1152,7 @@ void R_Register( void ) r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_ext_preferred_tc_method = ri->Cvar_Get( "r_ext_preferred_tc_method", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); @@ -1173,6 +1181,7 @@ void R_Register( void ) r_mode = ri->Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); r_fullscreen = ri->Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); + r_noborder = ri->Cvar_Get( "r_noborder", "0", CVAR_ARCHIVE|CVAR_LATCH ); r_customwidth = ri->Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); r_customheight = ri->Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); r_customPixelAspect = ri->Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1242,6 +1251,8 @@ void R_Register( void ) r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); + r_displayRefresh = ri->Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH ); + ri->Cvar_CheckRange( r_displayRefresh, 0, 200, qtrue ); // // archived variables that can change at any time @@ -1352,6 +1363,8 @@ Ghoul2 Insert Start Ghoul2 Insert End */ + se_language = ri->Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART ); + // make sure all the commands added here are also // removed in R_Shutdown ri->Cmd_AddCommand( "imagelist", R_ImageList_f ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 89468ec085..400b656d7d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1828,7 +1828,7 @@ typedef struct { // the renderer front end should never modify glstate_t -typedef struct { +typedef struct glstate_s { int currenttextures[NUM_TEXTURE_BUNDLES]; int currenttmu; qboolean finishCalled; @@ -1954,7 +1954,7 @@ typedef struct { ** but may read fields that aren't dynamically modified ** by the frontend. */ -typedef struct { +typedef struct trGlobals_s { qboolean registered; // cleared at shutdown, set at beginRegistration int visIndex; @@ -2127,7 +2127,7 @@ typedef struct { extern backEndState_t backEnd; extern trGlobals_t tr; -extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init +extern glstate_s glState; // outside of TR since it shouldn't be cleared during ref re-init extern glRefConfig_t glRefConfig; // @@ -3022,10 +3022,6 @@ void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); void RE_BeginFrame( stereoFrame_t stereoFrame ); void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); -void RE_SaveJPG(char * filename, int quality, int image_width, int image_height, - unsigned char *image_buffer, int padding); -size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality, - int image_width, int image_height, byte *image_buffer, int padding); void RE_TakeVideoFrame( int width, int height, byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); diff --git a/codemp/rd-vanilla/tr_init.cpp b/codemp/rd-vanilla/tr_init.cpp index 95775c4ae0..fdbe821c25 100644 --- a/codemp/rd-vanilla/tr_init.cpp +++ b/codemp/rd-vanilla/tr_init.cpp @@ -200,76 +200,6 @@ cvar_t *se_language; cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; -#ifdef _WIN32 -void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t ); -void ( APIENTRY * qglActiveTextureARB )( GLenum texture ); -void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture ); - -void ( APIENTRY * qglLockArraysEXT)( GLint, GLint); -void ( APIENTRY * qglUnlockArraysEXT) ( void ); - -void ( APIENTRY * qglPointParameterfEXT)( GLenum, GLfloat); -void ( APIENTRY * qglPointParameterfvEXT)( GLenum, GLfloat *); - -//3d textures -rww -void ( APIENTRY * qglTexImage3DEXT) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -void ( APIENTRY * qglTexSubImage3DEXT) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); - - -// Declare Register Combiners function pointers. -PFNGLCOMBINERPARAMETERFVNV qglCombinerParameterfvNV = NULL; -PFNGLCOMBINERPARAMETERIVNV qglCombinerParameterivNV = NULL; -PFNGLCOMBINERPARAMETERFNV qglCombinerParameterfNV = NULL; -PFNGLCOMBINERPARAMETERINV qglCombinerParameteriNV = NULL; -PFNGLCOMBINERINPUTNV qglCombinerInputNV = NULL; -PFNGLCOMBINEROUTPUTNV qglCombinerOutputNV = NULL; -PFNGLFINALCOMBINERINPUTNV qglFinalCombinerInputNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERFVNV qglGetCombinerInputParameterfvNV = NULL; -PFNGLGETCOMBINERINPUTPARAMETERIVNV qglGetCombinerInputParameterivNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERFVNV qglGetCombinerOutputParameterfvNV = NULL; -PFNGLGETCOMBINEROUTPUTPARAMETERIVNV qglGetCombinerOutputParameterivNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERFVNV qglGetFinalCombinerInputParameterfvNV = NULL; -PFNGLGETFINALCOMBINERINPUTPARAMETERIVNV qglGetFinalCombinerInputParameterivNV = NULL; - -// Declare Pixel Format function pointers. -PFNWGLGETPIXELFORMATATTRIBIVARBPROC qwglGetPixelFormatAttribivARB = NULL; -PFNWGLGETPIXELFORMATATTRIBFVARBPROC qwglGetPixelFormatAttribfvARB = NULL; -PFNWGLCHOOSEPIXELFORMATARBPROC qwglChoosePixelFormatARB = NULL; - -// Declare Pixel Buffer function pointers. -PFNWGLCREATEPBUFFERARBPROC qwglCreatePbufferARB = NULL; -PFNWGLGETPBUFFERDCARBPROC qwglGetPbufferDCARB = NULL; -PFNWGLRELEASEPBUFFERDCARBPROC qwglReleasePbufferDCARB = NULL; -PFNWGLDESTROYPBUFFERARBPROC qwglDestroyPbufferARB = NULL; -PFNWGLQUERYPBUFFERARBPROC qwglQueryPbufferARB = NULL; - -// Declare Render-Texture function pointers. -PFNWGLBINDTEXIMAGEARBPROC qwglBindTexImageARB = NULL; -PFNWGLRELEASETEXIMAGEARBPROC qwglReleaseTexImageARB = NULL; -PFNWGLSETPBUFFERATTRIBARBPROC qwglSetPbufferAttribARB = NULL; - -// Declare Vertex and Fragment Program function pointers. -PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB = NULL; -PFNGLBINDPROGRAMARBPROC qglBindProgramARB = NULL; -PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB = NULL; -PFNGLGENPROGRAMSARBPROC qglGenProgramsARB = NULL; -PFNGLPROGRAMENVPARAMETER4DARBPROC qglProgramEnvParameter4dARB = NULL; -PFNGLPROGRAMENVPARAMETER4DVARBPROC qglProgramEnvParameter4dvARB = NULL; -PFNGLPROGRAMENVPARAMETER4FARBPROC qglProgramEnvParameter4fARB = NULL; -PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DARBPROC qglProgramLocalParameter4dARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4DVARBPROC qglProgramLocalParameter4dvARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FARBPROC qglProgramLocalParameter4fARB = NULL; -PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB = NULL; -PFNGLGETPROGRAMENVPARAMETERDVARBPROC qglGetProgramEnvParameterdvARB = NULL; -PFNGLGETPROGRAMENVPARAMETERFVARBPROC qglGetProgramEnvParameterfvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC qglGetProgramLocalParameterdvARB = NULL; -PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC qglGetProgramLocalParameterfvARB = NULL; -PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB = NULL; -PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB = NULL; -PFNGLISPROGRAMARBPROC qglIsProgramARB = NULL; -#endif - void RE_SetLightStyle(int style, int color); void RE_GetBModelVerts( int bmodelIndex, vec3_t *verts, vec3_t normal ); diff --git a/codemp/win32/win_qgl.cpp b/codemp/win32/win_qgl.cpp index 16c51f2ef4..47680673e9 100644 --- a/codemp/win32/win_qgl.cpp +++ b/codemp/win32/win_qgl.cpp @@ -379,6 +379,73 @@ void ( APIENTRY * qglVertex4sv )(const GLshort *v); void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height); +// Some from tr_init.cpp in rd-vanilla that really do belong here --eez +void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t ) = NULL; +void ( APIENTRY * qglActiveTextureARB )( GLenum texture ) = NULL; +void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture ) = NULL; + +void ( APIENTRY * qglLockArraysEXT)( GLint, GLint) = NULL; +void ( APIENTRY * qglUnlockArraysEXT) ( void ) = NULL; + +void ( APIENTRY * qglPointParameterfEXT)( GLenum, GLfloat) = NULL; +void ( APIENTRY * qglPointParameterfvEXT)( GLenum, GLfloat *) = NULL; + +//3d textures -rww +void ( APIENTRY * qglTexImage3DEXT) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *) = NULL; +void ( APIENTRY * qglTexSubImage3DEXT) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *) = NULL; + +// Declare Register Combiners function pointers. +PFNGLCOMBINERPARAMETERFVNV qglCombinerParameterfvNV = NULL; +PFNGLCOMBINERPARAMETERIVNV qglCombinerParameterivNV = NULL; +PFNGLCOMBINERPARAMETERFNV qglCombinerParameterfNV = NULL; +PFNGLCOMBINERPARAMETERINV qglCombinerParameteriNV = NULL; +PFNGLCOMBINERINPUTNV qglCombinerInputNV = NULL; +PFNGLCOMBINEROUTPUTNV qglCombinerOutputNV = NULL; +PFNGLFINALCOMBINERINPUTNV qglFinalCombinerInputNV = NULL; +PFNGLGETCOMBINERINPUTPARAMETERFVNV qglGetCombinerInputParameterfvNV = NULL; +PFNGLGETCOMBINERINPUTPARAMETERIVNV qglGetCombinerInputParameterivNV = NULL; +PFNGLGETCOMBINEROUTPUTPARAMETERFVNV qglGetCombinerOutputParameterfvNV = NULL; +PFNGLGETCOMBINEROUTPUTPARAMETERIVNV qglGetCombinerOutputParameterivNV = NULL; +PFNGLGETFINALCOMBINERINPUTPARAMETERFVNV qglGetFinalCombinerInputParameterfvNV = NULL; +PFNGLGETFINALCOMBINERINPUTPARAMETERIVNV qglGetFinalCombinerInputParameterivNV = NULL; + +// Declare Pixel Format function pointers. +PFNWGLGETPIXELFORMATATTRIBIVARBPROC qwglGetPixelFormatAttribivARB = NULL; +PFNWGLGETPIXELFORMATATTRIBFVARBPROC qwglGetPixelFormatAttribfvARB = NULL; +PFNWGLCHOOSEPIXELFORMATARBPROC qwglChoosePixelFormatARB = NULL; + +// Declare Pixel Buffer function pointers. +PFNWGLCREATEPBUFFERARBPROC qwglCreatePbufferARB = NULL; +PFNWGLGETPBUFFERDCARBPROC qwglGetPbufferDCARB = NULL; +PFNWGLRELEASEPBUFFERDCARBPROC qwglReleasePbufferDCARB = NULL; +PFNWGLDESTROYPBUFFERARBPROC qwglDestroyPbufferARB = NULL; +PFNWGLQUERYPBUFFERARBPROC qwglQueryPbufferARB = NULL; + +// Declare Render-Texture function pointers. +PFNWGLBINDTEXIMAGEARBPROC qwglBindTexImageARB = NULL; +PFNWGLRELEASETEXIMAGEARBPROC qwglReleaseTexImageARB = NULL; +PFNWGLSETPBUFFERATTRIBARBPROC qwglSetPbufferAttribARB = NULL; + +// Declare Vertex and Fragment Program function pointers. +PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB = NULL; +PFNGLBINDPROGRAMARBPROC qglBindProgramARB = NULL; +PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB = NULL; +PFNGLGENPROGRAMSARBPROC qglGenProgramsARB = NULL; +PFNGLPROGRAMENVPARAMETER4DARBPROC qglProgramEnvParameter4dARB = NULL; +PFNGLPROGRAMENVPARAMETER4DVARBPROC qglProgramEnvParameter4dvARB = NULL; +PFNGLPROGRAMENVPARAMETER4FARBPROC qglProgramEnvParameter4fARB = NULL; +PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB = NULL; +PFNGLPROGRAMLOCALPARAMETER4DARBPROC qglProgramLocalParameter4dARB = NULL; +PFNGLPROGRAMLOCALPARAMETER4DVARBPROC qglProgramLocalParameter4dvARB = NULL; +PFNGLPROGRAMLOCALPARAMETER4FARBPROC qglProgramLocalParameter4fARB = NULL; +PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB = NULL; +PFNGLGETPROGRAMENVPARAMETERDVARBPROC qglGetProgramEnvParameterdvARB = NULL; +PFNGLGETPROGRAMENVPARAMETERFVARBPROC qglGetProgramEnvParameterfvARB = NULL; +PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC qglGetProgramLocalParameterdvARB = NULL; +PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC qglGetProgramLocalParameterfvARB = NULL; +PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB = NULL; +PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB = NULL; +PFNGLISPROGRAMARBPROC qglIsProgramARB = NULL; static void ( APIENTRY * dllAccum )(GLenum op, GLfloat value); From ccf14277c60c6479caa0bd844d51e763113d9655 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 20:41:19 -0400 Subject: [PATCH 050/708] [rend2] Compiles, but not quite working yet. --- codemp/rd-rend2/tr_init.cpp | 14 ++++++-------- codemp/rd-rend2/tr_local.h | 8 ++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index d2c2d92efa..5ba9746f98 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1413,17 +1413,13 @@ void R_Init( void ) { Com_Memset( &tr, 0, sizeof( tr ) ); Com_Memset( &backEnd, 0, sizeof( backEnd ) ); Com_Memset( &tess, 0, sizeof( tess ) ); - - if(sizeof(glconfig_t) != 11332) - ri->Error( ERR_FATAL, "Mod ABI incompatible: sizeof(glconfig_t) == %u != 11332", (unsigned int) sizeof(glconfig_t)); + +#ifdef _WIN32 + tr.wv = (WinVars_t *)ri->GetWinVars(); +#endif // Swap_Init(); - if ( (intptr_t)tess.xyz & 15 ) { - ri->Printf( PRINT_WARNING, "tess.xyz not 16 byte aligned\n" ); - } - //Com_Memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); - // // init function tables // @@ -1576,6 +1572,7 @@ GetRefAPI @@@@@@@@@@@@@@@@@@@@@ */ +extern "C" { #ifdef USE_RENDERER_DLOPEN Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { #else @@ -1735,3 +1732,4 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { return &re; } +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 400b656d7d..fd6e0f91ef 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -36,6 +36,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "iqm.h" #include "qgl.h" +#ifdef _WIN32 +#include "win32\win_local.h" +#endif + #define GL_INDEX_TYPE GL_UNSIGNED_INT typedef unsigned int glIndex_t; @@ -2123,6 +2127,10 @@ typedef struct trGlobals_s { float sawToothTable[FUNCTABLE_SIZE]; float inverseSawToothTable[FUNCTABLE_SIZE]; float fogTable[FOG_TABLE_SIZE]; + +#ifdef _WIN32 + WinVars_t *wv; +#endif } trGlobals_t; extern backEndState_t backEnd; From 9670b68c8d48c51b45b537bacc100f03a82362a6 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 10 Oct 2013 22:44:25 -0400 Subject: [PATCH 051/708] [rend2] Compiles now without issue. Doesn't run correctly, please see upcoming issue that I will make on this. --- codemp/rd-rend2/SDL/SDL.h | 101 - codemp/rd-rend2/SDL/SDL_active.h | 63 - codemp/rd-rend2/SDL/SDL_audio.h | 284 - codemp/rd-rend2/SDL/SDL_byteorder.h | 29 - codemp/rd-rend2/SDL/SDL_cdrom.h | 202 - codemp/rd-rend2/SDL/SDL_config.h | 45 - codemp/rd-rend2/SDL/SDL_config_amiga.h | 80 - codemp/rd-rend2/SDL/SDL_config_dreamcast.h | 106 - codemp/rd-rend2/SDL/SDL_config_macos.h | 112 - codemp/rd-rend2/SDL/SDL_config_macosx.h | 150 - codemp/rd-rend2/SDL/SDL_config_minimal.h | 66 - codemp/rd-rend2/SDL/SDL_config_nds.h | 115 - codemp/rd-rend2/SDL/SDL_config_os2.h | 141 - codemp/rd-rend2/SDL/SDL_config_symbian.h | 146 - codemp/rd-rend2/SDL/SDL_config_win32.h | 183 - codemp/rd-rend2/SDL/SDL_copying.h | 22 - codemp/rd-rend2/SDL/SDL_cpuinfo.h | 69 - codemp/rd-rend2/SDL/SDL_endian.h | 214 - codemp/rd-rend2/SDL/SDL_error.h | 72 - codemp/rd-rend2/SDL/SDL_events.h | 356 -- codemp/rd-rend2/SDL/SDL_getenv.h | 28 - codemp/rd-rend2/SDL/SDL_joystick.h | 187 - codemp/rd-rend2/SDL/SDL_keyboard.h | 135 - codemp/rd-rend2/SDL/SDL_keysym.h | 326 - codemp/rd-rend2/SDL/SDL_loadso.h | 78 - codemp/rd-rend2/SDL/SDL_main.h | 106 - codemp/rd-rend2/SDL/SDL_mouse.h | 143 - codemp/rd-rend2/SDL/SDL_mutex.h | 177 - codemp/rd-rend2/SDL/SDL_name.h | 11 - codemp/rd-rend2/SDL/SDL_opengl.h | 6570 -------------------- codemp/rd-rend2/SDL/SDL_platform.h | 110 - codemp/rd-rend2/SDL/SDL_quit.h | 55 - codemp/rd-rend2/SDL/SDL_rwops.h | 155 - codemp/rd-rend2/SDL/SDL_stdinc.h | 620 -- codemp/rd-rend2/SDL/SDL_syswm.h | 226 - codemp/rd-rend2/SDL/SDL_thread.h | 115 - codemp/rd-rend2/SDL/SDL_timer.h | 125 - codemp/rd-rend2/SDL/SDL_types.h | 28 - codemp/rd-rend2/SDL/SDL_version.h | 91 - codemp/rd-rend2/SDL/SDL_video.h | 951 --- codemp/rd-rend2/SDL/begin_code.h | 196 - codemp/rd-rend2/SDL/close_code.h | 46 - codemp/rd-rend2/qgl.h | 204 + codemp/rd-rend2/tr_init.cpp | 80 +- codemp/rd-vanilla/qgl.h | 2 +- codemp/win32/win_glimp.cpp | 7 + 46 files changed, 282 insertions(+), 13046 deletions(-) delete mode 100644 codemp/rd-rend2/SDL/SDL.h delete mode 100644 codemp/rd-rend2/SDL/SDL_active.h delete mode 100644 codemp/rd-rend2/SDL/SDL_audio.h delete mode 100644 codemp/rd-rend2/SDL/SDL_byteorder.h delete mode 100644 codemp/rd-rend2/SDL/SDL_cdrom.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_amiga.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_dreamcast.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_macos.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_macosx.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_minimal.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_nds.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_os2.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_symbian.h delete mode 100644 codemp/rd-rend2/SDL/SDL_config_win32.h delete mode 100644 codemp/rd-rend2/SDL/SDL_copying.h delete mode 100644 codemp/rd-rend2/SDL/SDL_cpuinfo.h delete mode 100644 codemp/rd-rend2/SDL/SDL_endian.h delete mode 100644 codemp/rd-rend2/SDL/SDL_error.h delete mode 100644 codemp/rd-rend2/SDL/SDL_events.h delete mode 100644 codemp/rd-rend2/SDL/SDL_getenv.h delete mode 100644 codemp/rd-rend2/SDL/SDL_joystick.h delete mode 100644 codemp/rd-rend2/SDL/SDL_keyboard.h delete mode 100644 codemp/rd-rend2/SDL/SDL_keysym.h delete mode 100644 codemp/rd-rend2/SDL/SDL_loadso.h delete mode 100644 codemp/rd-rend2/SDL/SDL_main.h delete mode 100644 codemp/rd-rend2/SDL/SDL_mouse.h delete mode 100644 codemp/rd-rend2/SDL/SDL_mutex.h delete mode 100644 codemp/rd-rend2/SDL/SDL_name.h delete mode 100644 codemp/rd-rend2/SDL/SDL_opengl.h delete mode 100644 codemp/rd-rend2/SDL/SDL_platform.h delete mode 100644 codemp/rd-rend2/SDL/SDL_quit.h delete mode 100644 codemp/rd-rend2/SDL/SDL_rwops.h delete mode 100644 codemp/rd-rend2/SDL/SDL_stdinc.h delete mode 100644 codemp/rd-rend2/SDL/SDL_syswm.h delete mode 100644 codemp/rd-rend2/SDL/SDL_thread.h delete mode 100644 codemp/rd-rend2/SDL/SDL_timer.h delete mode 100644 codemp/rd-rend2/SDL/SDL_types.h delete mode 100644 codemp/rd-rend2/SDL/SDL_version.h delete mode 100644 codemp/rd-rend2/SDL/SDL_video.h delete mode 100644 codemp/rd-rend2/SDL/begin_code.h delete mode 100644 codemp/rd-rend2/SDL/close_code.h diff --git a/codemp/rd-rend2/SDL/SDL.h b/codemp/rd-rend2/SDL/SDL.h deleted file mode 100644 index 6087b7cdd4..0000000000 --- a/codemp/rd-rend2/SDL/SDL.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL.h - * Main include header for the SDL library - */ - -#ifndef _SDL_H -#define _SDL_H - -#include "SDL_main.h" -#include "SDL_stdinc.h" -#include "SDL_audio.h" -#include "SDL_cdrom.h" -#include "SDL_cpuinfo.h" -#include "SDL_endian.h" -#include "SDL_error.h" -#include "SDL_events.h" -#include "SDL_loadso.h" -#include "SDL_mutex.h" -#include "SDL_rwops.h" -#include "SDL_thread.h" -#include "SDL_timer.h" -#include "SDL_video.h" -#include "SDL_version.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @file SDL.h - * @note As of version 0.5, SDL is loaded dynamically into the application - */ - -/** @name SDL_INIT Flags - * These are the flags which may be passed to SDL_Init() -- you should - * specify the subsystems which you will be using in your application. - */ -/*@{*/ -#define SDL_INIT_TIMER 0x00000001 -#define SDL_INIT_AUDIO 0x00000010 -#define SDL_INIT_VIDEO 0x00000020 -#define SDL_INIT_CDROM 0x00000100 -#define SDL_INIT_JOYSTICK 0x00000200 -#define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ -#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ -#define SDL_INIT_EVERYTHING 0x0000FFFF -/*@}*/ - -/** This function loads the SDL dynamically linked library and initializes - * the subsystems specified by 'flags' (and those satisfying dependencies) - * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup - * signal handlers for some commonly ignored fatal signals (like SIGSEGV) - */ -extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); - -/** This function initializes specific SDL subsystems */ -extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); - -/** This function cleans up specific SDL subsystems */ -extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); - -/** This function returns mask of the specified subsystems which have - * been initialized. - * If 'flags' is 0, it returns a mask of all initialized subsystems. - */ -extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); - -/** This function cleans up all initialized subsystems and unloads the - * dynamically linked library. You should call it upon all exit conditions. - */ -extern DECLSPEC void SDLCALL SDL_Quit(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_H */ diff --git a/codemp/rd-rend2/SDL/SDL_active.h b/codemp/rd-rend2/SDL/SDL_active.h deleted file mode 100644 index cd854e8928..0000000000 --- a/codemp/rd-rend2/SDL/SDL_active.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_active.h - * Include file for SDL application focus event handling - */ - -#ifndef _SDL_active_h -#define _SDL_active_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @name The available application states */ -/*@{*/ -#define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ -#define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ -#define SDL_APPACTIVE 0x04 /**< The application is active */ -/*@}*/ - -/* Function prototypes */ -/** - * This function returns the current state of the application, which is a - * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and - * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to - * see your application, otherwise it has been iconified or disabled. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_active_h */ diff --git a/codemp/rd-rend2/SDL/SDL_audio.h b/codemp/rd-rend2/SDL/SDL_audio.h deleted file mode 100644 index e879c98966..0000000000 --- a/codemp/rd-rend2/SDL/SDL_audio.h +++ /dev/null @@ -1,284 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_audio.h - * Access to the raw audio mixing buffer for the SDL library - */ - -#ifndef _SDL_audio_h -#define _SDL_audio_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_endian.h" -#include "SDL_mutex.h" -#include "SDL_thread.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * When filling in the desired audio spec structure, - * - 'desired->freq' should be the desired audio frequency in samples-per-second. - * - 'desired->format' should be the desired audio format. - * - 'desired->samples' is the desired size of the audio buffer, in samples. - * This number should be a power of two, and may be adjusted by the audio - * driver to a value more suitable for the hardware. Good values seem to - * range between 512 and 8096 inclusive, depending on the application and - * CPU speed. Smaller values yield faster response time, but can lead - * to underflow if the application is doing heavy processing and cannot - * fill the audio buffer in time. A stereo sample consists of both right - * and left channels in LR ordering. - * Note that the number of samples is directly related to time by the - * following formula: ms = (samples*1000)/freq - * - 'desired->size' is the size in bytes of the audio buffer, and is - * calculated by SDL_OpenAudio(). - * - 'desired->silence' is the value used to set the buffer to silence, - * and is calculated by SDL_OpenAudio(). - * - 'desired->callback' should be set to a function that will be called - * when the audio device is ready for more data. It is passed a pointer - * to the audio buffer, and the length in bytes of the audio buffer. - * This function usually runs in a separate thread, and so you should - * protect data structures that it accesses by calling SDL_LockAudio() - * and SDL_UnlockAudio() in your code. - * - 'desired->userdata' is passed as the first parameter to your callback - * function. - * - * @note The calculated values in this structure are calculated by SDL_OpenAudio() - * - */ -typedef struct SDL_AudioSpec { - int freq; /**< DSP frequency -- samples per second */ - Uint16 format; /**< Audio data format */ - Uint8 channels; /**< Number of channels: 1 mono, 2 stereo */ - Uint8 silence; /**< Audio buffer silence value (calculated) */ - Uint16 samples; /**< Audio buffer size in samples (power of 2) */ - Uint16 padding; /**< Necessary for some compile environments */ - Uint32 size; /**< Audio buffer size in bytes (calculated) */ - /** - * This function is called when the audio device needs more data. - * - * @param[out] stream A pointer to the audio data buffer - * @param[in] len The length of the audio buffer in bytes. - * - * Once the callback returns, the buffer will no longer be valid. - * Stereo samples are stored in a LRLRLR ordering. - */ - void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len); - void *userdata; -} SDL_AudioSpec; - -/** - * @name Audio format flags - * defaults to LSB byte order - */ -/*@{*/ -#define AUDIO_U8 0x0008 /**< Unsigned 8-bit samples */ -#define AUDIO_S8 0x8008 /**< Signed 8-bit samples */ -#define AUDIO_U16LSB 0x0010 /**< Unsigned 16-bit samples */ -#define AUDIO_S16LSB 0x8010 /**< Signed 16-bit samples */ -#define AUDIO_U16MSB 0x1010 /**< As above, but big-endian byte order */ -#define AUDIO_S16MSB 0x9010 /**< As above, but big-endian byte order */ -#define AUDIO_U16 AUDIO_U16LSB -#define AUDIO_S16 AUDIO_S16LSB - -/** - * @name Native audio byte ordering - */ -/*@{*/ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define AUDIO_U16SYS AUDIO_U16LSB -#define AUDIO_S16SYS AUDIO_S16LSB -#else -#define AUDIO_U16SYS AUDIO_U16MSB -#define AUDIO_S16SYS AUDIO_S16MSB -#endif -/*@}*/ - -/*@}*/ - - -/** A structure to hold a set of audio conversion filters and buffers */ -typedef struct SDL_AudioCVT { - int needed; /**< Set to 1 if conversion possible */ - Uint16 src_format; /**< Source audio format */ - Uint16 dst_format; /**< Target audio format */ - double rate_incr; /**< Rate conversion increment */ - Uint8 *buf; /**< Buffer to hold entire audio data */ - int len; /**< Length of original audio buffer */ - int len_cvt; /**< Length of converted audio buffer */ - int len_mult; /**< buffer must be len*len_mult big */ - double len_ratio; /**< Given len, final size is len*len_ratio */ - void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format); - int filter_index; /**< Current audio conversion function */ -} SDL_AudioCVT; - - -/* Function prototypes */ - -/** - * @name Audio Init and Quit - * These functions are used internally, and should not be used unless you - * have a specific need to specify the audio driver you want to use. - * You should normally use SDL_Init() or SDL_InitSubSystem(). - */ -/*@{*/ -extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name); -extern DECLSPEC void SDLCALL SDL_AudioQuit(void); -/*@}*/ - -/** - * This function fills the given character buffer with the name of the - * current audio driver, and returns a pointer to it if the audio driver has - * been initialized. It returns NULL if no driver has been initialized. - */ -extern DECLSPEC char * SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); - -/** - * This function opens the audio device with the desired parameters, and - * returns 0 if successful, placing the actual hardware parameters in the - * structure pointed to by 'obtained'. If 'obtained' is NULL, the audio - * data passed to the callback function will be guaranteed to be in the - * requested format, and will be automatically converted to the hardware - * audio format if necessary. This function returns -1 if it failed - * to open the audio device, or couldn't set up the audio thread. - * - * The audio device starts out playing silence when it's opened, and should - * be enabled for playing by calling SDL_PauseAudio(0) when you are ready - * for your audio callback function to be called. Since the audio driver - * may modify the requested size of the audio buffer, you should allocate - * any local mixing buffers after you open the audio device. - * - * @sa SDL_AudioSpec - */ -extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained); - -typedef enum { - SDL_AUDIO_STOPPED = 0, - SDL_AUDIO_PLAYING, - SDL_AUDIO_PAUSED -} SDL_audiostatus; - -/** Get the current audio state */ -extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void); - -/** - * This function pauses and unpauses the audio callback processing. - * It should be called with a parameter of 0 after opening the audio - * device to start playing sound. This is so you can safely initialize - * data for your callback function after opening the audio device. - * Silence will be written to the audio device during the pause. - */ -extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on); - -/** - * This function loads a WAVE from the data source, automatically freeing - * that source if 'freesrc' is non-zero. For example, to load a WAVE file, - * you could do: - * @code SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...); @endcode - * - * If this function succeeds, it returns the given SDL_AudioSpec, - * filled with the audio data format of the wave data, and sets - * 'audio_buf' to a malloc()'d buffer containing the audio data, - * and sets 'audio_len' to the length of that audio buffer, in bytes. - * You need to free the audio buffer with SDL_FreeWAV() when you are - * done with it. - * - * This function returns NULL and sets the SDL error message if the - * wave file cannot be opened, uses an unknown data format, or is - * corrupt. Currently raw and MS-ADPCM WAVE files are supported. - */ -extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len); - -/** Compatibility convenience function -- loads a WAV from a file */ -#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \ - SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len) - -/** - * This function frees data previously allocated with SDL_LoadWAV_RW() - */ -extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf); - -/** - * This function takes a source format and rate and a destination format - * and rate, and initializes the 'cvt' structure with information needed - * by SDL_ConvertAudio() to convert a buffer of audio data from one format - * to the other. - * - * @return This function returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt, - Uint16 src_format, Uint8 src_channels, int src_rate, - Uint16 dst_format, Uint8 dst_channels, int dst_rate); - -/** - * Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(), - * created an audio buffer cvt->buf, and filled it with cvt->len bytes of - * audio data in the source format, this function will convert it in-place - * to the desired format. - * The data conversion may expand the size of the audio data, so the buffer - * cvt->buf should be allocated after the cvt structure is initialized by - * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long. - */ -extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt); - - -#define SDL_MIX_MAXVOLUME 128 -/** - * This takes two audio buffers of the playing audio format and mixes - * them, performing addition, volume adjustment, and overflow clipping. - * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME - * for full audio volume. Note this does not change hardware volume. - * This is provided for convenience -- you can mix your own audio data. - */ -extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume); - -/** - * @name Audio Locks - * The lock manipulated by these functions protects the callback function. - * During a LockAudio/UnlockAudio pair, you can be guaranteed that the - * callback function is not running. Do not call these from the callback - * function or you will cause deadlock. - */ -/*@{*/ -extern DECLSPEC void SDLCALL SDL_LockAudio(void); -extern DECLSPEC void SDLCALL SDL_UnlockAudio(void); -/*@}*/ - -/** - * This function shuts down audio processing and closes the audio device. - */ -extern DECLSPEC void SDLCALL SDL_CloseAudio(void); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_audio_h */ diff --git a/codemp/rd-rend2/SDL/SDL_byteorder.h b/codemp/rd-rend2/SDL/SDL_byteorder.h deleted file mode 100644 index 47332c3df7..0000000000 --- a/codemp/rd-rend2/SDL/SDL_byteorder.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_byteorder.h - * @deprecated Use SDL_endian.h instead - */ - -/* DEPRECATED */ -#include "SDL_endian.h" diff --git a/codemp/rd-rend2/SDL/SDL_cdrom.h b/codemp/rd-rend2/SDL/SDL_cdrom.h deleted file mode 100644 index febb19dcc7..0000000000 --- a/codemp/rd-rend2/SDL/SDL_cdrom.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_cdrom.h - * This is the CD-audio control API for Simple DirectMedia Layer - */ - -#ifndef _SDL_cdrom_h -#define _SDL_cdrom_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file SDL_cdrom.h - * In order to use these functions, SDL_Init() must have been called - * with the SDL_INIT_CDROM flag. This causes SDL to scan the system - * for CD-ROM drives, and load appropriate drivers. - */ - -/** The maximum number of CD-ROM tracks on a disk */ -#define SDL_MAX_TRACKS 99 - -/** @name Track Types - * The types of CD-ROM track possible - */ -/*@{*/ -#define SDL_AUDIO_TRACK 0x00 -#define SDL_DATA_TRACK 0x04 -/*@}*/ - -/** The possible states which a CD-ROM drive can be in. */ -typedef enum { - CD_TRAYEMPTY, - CD_STOPPED, - CD_PLAYING, - CD_PAUSED, - CD_ERROR = -1 -} CDstatus; - -/** Given a status, returns true if there's a disk in the drive */ -#define CD_INDRIVE(status) ((int)(status) > 0) - -typedef struct SDL_CDtrack { - Uint8 id; /**< Track number */ - Uint8 type; /**< Data or audio track */ - Uint16 unused; - Uint32 length; /**< Length, in frames, of this track */ - Uint32 offset; /**< Offset, in frames, from start of disk */ -} SDL_CDtrack; - -/** This structure is only current as of the last call to SDL_CDStatus() */ -typedef struct SDL_CD { - int id; /**< Private drive identifier */ - CDstatus status; /**< Current drive status */ - - /** The rest of this structure is only valid if there's a CD in drive */ - /*@{*/ - int numtracks; /**< Number of tracks on disk */ - int cur_track; /**< Current track position */ - int cur_frame; /**< Current frame offset within current track */ - SDL_CDtrack track[SDL_MAX_TRACKS+1]; - /*@}*/ -} SDL_CD; - -/** @name Frames / MSF Conversion Functions - * Conversion functions from frames to Minute/Second/Frames and vice versa - */ -/*@{*/ -#define CD_FPS 75 -#define FRAMES_TO_MSF(f, M,S,F) { \ - int value = f; \ - *(F) = value%CD_FPS; \ - value /= CD_FPS; \ - *(S) = value%60; \ - value /= 60; \ - *(M) = value; \ -} -#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F)) -/*@}*/ - -/* CD-audio API functions: */ - -/** - * Returns the number of CD-ROM drives on the system, or -1 if - * SDL_Init() has not been called with the SDL_INIT_CDROM flag. - */ -extern DECLSPEC int SDLCALL SDL_CDNumDrives(void); - -/** - * Returns a human-readable, system-dependent identifier for the CD-ROM. - * Example: - * - "/dev/cdrom" - * - "E:" - * - "/dev/disk/ide/1/master" - */ -extern DECLSPEC const char * SDLCALL SDL_CDName(int drive); - -/** - * Opens a CD-ROM drive for access. It returns a drive handle on success, - * or NULL if the drive was invalid or busy. This newly opened CD-ROM - * becomes the default CD used when other CD functions are passed a NULL - * CD-ROM handle. - * Drives are numbered starting with 0. Drive 0 is the system default CD-ROM. - */ -extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive); - -/** - * This function returns the current status of the given drive. - * If the drive has a CD in it, the table of contents of the CD and current - * play position of the CD will be stored in the SDL_CD structure. - */ -extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom); - -/** - * Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks' - * tracks and 'nframes' frames. If both 'ntrack' and 'nframe' are 0, play - * until the end of the CD. This function will skip data tracks. - * This function should only be called after calling SDL_CDStatus() to - * get track information about the CD. - * For example: - * @code - * // Play entire CD: - * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) - * SDL_CDPlayTracks(cdrom, 0, 0, 0, 0); - * // Play last track: - * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) { - * SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0); - * } - * // Play first and second track and 10 seconds of third track: - * if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) - * SDL_CDPlayTracks(cdrom, 0, 0, 2, 10); - * @endcode - * - * @return This function returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom, - int start_track, int start_frame, int ntracks, int nframes); - -/** - * Play the given CD starting at 'start' frame for 'length' frames. - * @return It returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length); - -/** Pause play - * @return returns 0, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom); - -/** Resume play - * @return returns 0, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom); - -/** Stop play - * @return returns 0, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom); - -/** Eject CD-ROM - * @return returns 0, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom); - -/** Closes the handle for the CD-ROM drive */ -extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_video_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config.h b/codemp/rd-rend2/SDL/SDL_config.h deleted file mode 100644 index a50810169c..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_h -#define _SDL_config_h - -#include "SDL_platform.h" - -/* Add any platform that doesn't build using the configure system */ -#if defined(__DREAMCAST__) -#include "SDL_config_dreamcast.h" -#elif defined(__MACOS__) -#include "SDL_config_macos.h" -#elif defined(__MACOSX__) -#include "SDL_config_macosx.h" -#elif defined(__SYMBIAN32__) -#include "SDL_config_symbian.h" /* must be before win32! */ -#elif defined(__WIN32__) -#include "SDL_config_win32.h" -#elif defined(__OS2__) -#include "SDL_config_os2.h" -#else -#include "SDL_config_minimal.h" -#endif /* platform config */ - -#endif /* _SDL_config_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_amiga.h b/codemp/rd-rend2/SDL/SDL_config_amiga.h deleted file mode 100644 index 23e0861928..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_amiga.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_amiga_h -#define _SDL_config_amiga_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#define SDL_HAS_64BIT_TYPE 1 - -/* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_AHI 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#define SDL_CDROM_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_AMIGA 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DUMMY 1 - -/* Enable various threading systems */ -#define SDL_THREAD_AMIGA 1 - -/* Enable various timer systems */ -#define SDL_TIMER_AMIGA 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 - -#endif /* _SDL_config_amiga_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_dreamcast.h b/codemp/rd-rend2/SDL/SDL_config_dreamcast.h deleted file mode 100644 index fb03098e72..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_dreamcast.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_dreamcast_h -#define _SDL_config_dreamcast_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -typedef unsigned long uintptr_t; -#define SDL_HAS_64BIT_TYPE 1 - -/* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 -#define HAVE_INDEX 1 -#define HAVE_RINDEX 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRICMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_DC 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#define SDL_CDROM_DC 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_DC 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_DUMMY 1 - -/* Enable various threading systems */ -#define SDL_THREAD_DC 1 - -/* Enable various timer systems */ -#define SDL_TIMER_DC 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DC 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -#endif /* _SDL_config_dreamcast_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_macos.h b/codemp/rd-rend2/SDL/SDL_config_macos.h deleted file mode 100644 index 4fe1715aa1..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_macos.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_macos_h -#define _SDL_config_macos_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#include - -typedef SInt8 int8_t; -typedef UInt8 uint8_t; -typedef SInt16 int16_t; -typedef UInt16 uint16_t; -typedef SInt32 int32_t; -typedef UInt32 uint32_t; -typedef SInt64 int64_t; -typedef UInt64 uint64_t; -typedef unsigned long uintptr_t; - -#define SDL_HAS_64BIT_TYPE 1 - -/* Useful headers */ -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_ITOA 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_SSCANF 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_SNDMGR 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#if TARGET_API_MAC_CARBON -#define SDL_CDROM_DUMMY 1 -#else -#define SDL_CDROM_MACOS 1 -#endif - -/* Enable various input drivers */ -#if TARGET_API_MAC_CARBON -#define SDL_JOYSTICK_DUMMY 1 -#else -#define SDL_JOYSTICK_MACOS 1 -#endif - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_MACOS 1 - -/* Enable various threading systems */ -#define SDL_THREADS_DISABLED 1 - -/* Enable various timer systems */ -#define SDL_TIMER_MACOS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1 -#define SDL_VIDEO_DRIVER_TOOLBOX 1 - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 - -#endif /* _SDL_config_macos_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_macosx.h b/codemp/rd-rend2/SDL/SDL_config_macosx.h deleted file mode 100644 index 84be61777c..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_macosx.h +++ /dev/null @@ -1,150 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_macosx_h -#define _SDL_config_macosx_h - -#include "SDL_platform.h" - -/* This gets us MAC_OS_X_VERSION_MIN_REQUIRED... */ -#include - -/* This is a set of defines to configure the SDL features */ - -#define SDL_HAS_64BIT_TYPE 1 - -/* Useful headers */ -/* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ -#if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) -#define HAVE_ALLOCA_H 1 -#endif -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_SIGACTION 1 -#define HAVE_SETJMP 1 -#define HAVE_NANOSLEEP 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_COREAUDIO 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#define SDL_CDROM_MACOSX 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_IOKIT 1 - -/* Enable various shared object loading systems */ -#ifdef __ppc__ -/* For Mac OS X 10.2 compatibility */ -#define SDL_LOADSO_DLCOMPAT 1 -#else -#define SDL_LOADSO_DLOPEN 1 -#endif - -/* Enable various threading systems */ -#define SDL_THREAD_PTHREAD 1 -#define SDL_THREAD_PTHREAD_RECURSIVE_MUTEX 1 - -/* Enable various timer systems */ -#define SDL_TIMER_UNIX 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#if ((defined TARGET_API_MAC_CARBON) && (TARGET_API_MAC_CARBON)) -#define SDL_VIDEO_DRIVER_TOOLBOX 1 -#else -#define SDL_VIDEO_DRIVER_QUARTZ 1 -#endif -#define SDL_VIDEO_DRIVER_DGA 1 -#define SDL_VIDEO_DRIVER_X11 1 -#define SDL_VIDEO_DRIVER_X11_DGAMOUSE 1 -#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "/usr/X11R6/lib/libXrender.1.dylib" -#define SDL_VIDEO_DRIVER_X11_VIDMODE 1 -#define SDL_VIDEO_DRIVER_X11_XINERAMA 1 -#define SDL_VIDEO_DRIVER_X11_XME 1 -#define SDL_VIDEO_DRIVER_X11_XRANDR 1 -#define SDL_VIDEO_DRIVER_X11_XV 1 - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 -#define SDL_VIDEO_OPENGL_GLX 1 - -/* Disable screensaver */ -#define SDL_VIDEO_DISABLE_SCREENSAVER 1 - -/* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 -#ifdef __ppc__ -#define SDL_ALTIVEC_BLITTERS 1 -#endif - -#endif /* _SDL_config_macosx_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_minimal.h b/codemp/rd-rend2/SDL/SDL_config_minimal.h deleted file mode 100644 index a08e190e2b..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_minimal.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_minimal_h -#define _SDL_config_minimal_h - -#include "SDL_platform.h" - -/* This is the minimal configuration that can be used to build SDL */ - -#include -#include -#include - -#if 0 -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned int size_t; -typedef unsigned long uintptr_t; -#endif - -/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ -#define SDL_CDROM_DISABLED 1 - -/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 - -/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 - -/* Enable the stub thread support (src/thread/generic/\*.c) */ -#define SDL_THREADS_DISABLED 1 - -/* Enable the stub timer support (src/timer/dummy/\*.c) */ -#define SDL_TIMERS_DISABLED 1 - -/* Enable the dummy video driver (src/video/dummy/\*.c) */ -#define SDL_VIDEO_DRIVER_DUMMY 1 - -#endif /* _SDL_config_minimal_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_nds.h b/codemp/rd-rend2/SDL/SDL_config_nds.h deleted file mode 100644 index cb4d61f692..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_nds.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_nds_h -#define _SDL_config_nds_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -/* General platform specific identifiers */ -#include "SDL_platform.h" - -/* C datatypes */ -#define SDL_HAS_64BIT_TYPE 1 - -/* Endianness */ -#define SDL_BYTEORDER 1234 - -/* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_SETJMP 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_NDS 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ -#define SDL_CDROM_DISABLED 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_NDS 1 - -/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 - -/* Enable the stub thread support (src/thread/generic/\*.c) */ -#define SDL_THREADS_DISABLED 1 - -/* Enable various timer systems */ -#define SDL_TIMER_NDS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_NDS 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 - -#endif /* _SDL_config_nds_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_os2.h b/codemp/rd-rend2/SDL/SDL_config_os2.h deleted file mode 100644 index 42edd20e89..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_os2.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_os2_h -#define _SDL_config_os2_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned int size_t; -typedef unsigned long uintptr_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; - -#define SDL_HAS_64BIT_TYPE 1 - -/* Use Watcom's LIBC */ -#define HAVE_LIBC 1 - -/* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_UNSETENV 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -#define HAVE__STRREV 1 -#define HAVE__STRUPR 1 -#define HAVE__STRLWR 1 -#define HAVE_INDEX 1 -#define HAVE_RINDEX 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_ITOA 1 -#define HAVE__LTOA 1 -#define HAVE__UITOA 1 -#define HAVE__ULTOA 1 -#define HAVE_STRTOL 1 -#define HAVE__I64TOA 1 -#define HAVE__UI64TOA 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE_STRICMP 1 -#define HAVE_STRCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_SETJMP 1 -#define HAVE_CLOCK_GETTIME 1 - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_DART 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#define SDL_CDROM_OS2 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_OS2 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_OS2 1 - -/* Enable various threading systems */ -#define SDL_THREAD_OS2 1 - -/* Enable various timer systems */ -#define SDL_TIMER_OS2 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_OS2FS 1 - -/* Enable OpenGL support */ -/* Nothing here yet for OS/2... :( */ - -/* Enable assembly routines where available */ -#define SDL_ASSEMBLY_ROUTINES 1 - -#endif /* _SDL_config_os2_h */ diff --git a/codemp/rd-rend2/SDL/SDL_config_symbian.h b/codemp/rd-rend2/SDL/SDL_config_symbian.h deleted file mode 100644 index e917ac6e7d..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_symbian.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* - -Symbian version Markus Mertama - -*/ - - -#ifndef _SDL_CONFIG_SYMBIAN_H -#define _SDL_CONFIG_SYMBIAN_H - -#include "SDL_platform.h" - -/* This is the minimal configuration that can be used to build SDL */ - - -#include -#include - - -#ifdef __GCCE__ -#define SYMBIAN32_GCCE -#endif - -#ifndef _SIZE_T_DEFINED -typedef unsigned int size_t; -#endif - -#ifndef _INTPTR_T_DECLARED -typedef unsigned int uintptr_t; -#endif - -#ifndef _INT8_T_DECLARED -typedef signed char int8_t; -#endif - -#ifndef _UINT8_T_DECLARED -typedef unsigned char uint8_t; -#endif - -#ifndef _INT16_T_DECLARED -typedef signed short int16_t; -#endif - -#ifndef _UINT16_T_DECLARED -typedef unsigned short uint16_t; -#endif - -#ifndef _INT32_T_DECLARED -typedef signed int int32_t; -#endif - -#ifndef _UINT32_T_DECLARED -typedef unsigned int uint32_t; -#endif - -#ifndef _INT64_T_DECLARED -typedef signed long long int64_t; -#endif - -#ifndef _UINT64_T_DECLARED -typedef unsigned long long uint64_t; -#endif - -#define SDL_AUDIO_DRIVER_EPOCAUDIO 1 - - -/* Enable the stub cdrom driver (src/cdrom/dummy/\*.c) */ -#define SDL_CDROM_DISABLED 1 - -/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 - -/* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DISABLED 1 - -#define SDL_THREAD_SYMBIAN 1 - -#define SDL_VIDEO_DRIVER_EPOC 1 - -#define SDL_VIDEO_OPENGL 0 - -#define SDL_HAS_64BIT_TYPE 1 - -#define HAVE_LIBC 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 - -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -/*#define HAVE_ALLOCA 1*/ -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRUPR 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_ITOA 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -/*#define HAVE__STRICMP 1*/ -#define HAVE__STRNICMP 1 -#define HAVE_SSCANF 1 -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 - - - -#endif /* _SDL_CONFIG_SYMBIAN_H */ diff --git a/codemp/rd-rend2/SDL/SDL_config_win32.h b/codemp/rd-rend2/SDL/SDL_config_win32.h deleted file mode 100644 index da2c15dd7e..0000000000 --- a/codemp/rd-rend2/SDL/SDL_config_win32.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_config_win32_h -#define _SDL_config_win32_h - -#include "SDL_platform.h" - -/* This is a set of defines to configure the SDL features */ - -#if defined(__GNUC__) || defined(__DMC__) -#define HAVE_STDINT_H 1 -#elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -#endif -#else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -#endif -typedef unsigned int uintptr_t; -#endif /* __GNUC__ || _MSC_VER */ -#define SDL_HAS_64BIT_TYPE 1 - -/* Enabled for SDL 1.2 (binary compatibility) */ -#define HAVE_LIBC 1 -#ifdef HAVE_LIBC -/* Useful headers */ -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#ifndef _WIN32_WCE -#define HAVE_SIGNAL_H 1 -#endif - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRREV 1 -#define HAVE__STRUPR 1 -#define HAVE__STRLWR 1 -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -#define HAVE_ITOA 1 -#define HAVE__LTOA 1 -#define HAVE__ULTOA 1 -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOLL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE__STRICMP 1 -#define HAVE__STRNICMP 1 -#define HAVE_SSCANF 1 -#else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#endif - -/* Enable various audio drivers */ -#ifndef _WIN32_WCE -#define SDL_AUDIO_DRIVER_DSOUND 1 -#endif -#define SDL_AUDIO_DRIVER_WAVEOUT 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various cdrom drivers */ -#ifdef _WIN32_WCE -#define SDL_CDROM_DISABLED 1 -#else -#define SDL_CDROM_WIN32 1 -#endif - -/* Enable various input drivers */ -#ifdef _WIN32_WCE -#define SDL_JOYSTICK_DISABLED 1 -#else -#define SDL_JOYSTICK_WINMM 1 -#endif - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WIN32 1 - -/* Enable various threading systems */ -#define SDL_THREAD_WIN32 1 - -/* Enable various timer systems */ -#ifdef _WIN32_WCE -#define SDL_TIMER_WINCE 1 -#else -#define SDL_TIMER_WIN32 1 -#endif - -/* Enable various video drivers */ -#ifdef _WIN32_WCE -#define SDL_VIDEO_DRIVER_GAPI 1 -#endif -#ifndef _WIN32_WCE -#define SDL_VIDEO_DRIVER_DDRAW 1 -#endif -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_WINDIB 1 - -/* Enable OpenGL support */ -#ifndef _WIN32_WCE -#define SDL_VIDEO_OPENGL 1 -#define SDL_VIDEO_OPENGL_WGL 1 -#endif - -/* Disable screensaver */ -#define SDL_VIDEO_DISABLE_SCREENSAVER 1 - -/* Enable assembly routines (Win64 doesn't have inline asm) */ -#ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 -#endif - -#endif /* _SDL_config_win32_h */ diff --git a/codemp/rd-rend2/SDL/SDL_copying.h b/codemp/rd-rend2/SDL/SDL_copying.h deleted file mode 100644 index b5b64f2994..0000000000 --- a/codemp/rd-rend2/SDL/SDL_copying.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - diff --git a/codemp/rd-rend2/SDL/SDL_cpuinfo.h b/codemp/rd-rend2/SDL/SDL_cpuinfo.h deleted file mode 100644 index 4200d6d170..0000000000 --- a/codemp/rd-rend2/SDL/SDL_cpuinfo.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_cpuinfo.h - * CPU feature detection for SDL - */ - -#ifndef _SDL_cpuinfo_h -#define _SDL_cpuinfo_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** This function returns true if the CPU has the RDTSC instruction */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); - -/** This function returns true if the CPU has MMX features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); - -/** This function returns true if the CPU has MMX Ext. features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); - -/** This function returns true if the CPU has 3DNow features */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); - -/** This function returns true if the CPU has 3DNow! Ext. features */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); - -/** This function returns true if the CPU has SSE features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); - -/** This function returns true if the CPU has SSE2 features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); - -/** This function returns true if the CPU has AltiVec features */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_cpuinfo_h */ diff --git a/codemp/rd-rend2/SDL/SDL_endian.h b/codemp/rd-rend2/SDL/SDL_endian.h deleted file mode 100644 index 068da918f4..0000000000 --- a/codemp/rd-rend2/SDL/SDL_endian.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_endian.h - * Functions for reading and writing endian-specific values - */ - -#ifndef _SDL_endian_h -#define _SDL_endian_h - -#include "SDL_stdinc.h" - -/** @name SDL_ENDIANs - * The two types of endianness - */ -/*@{*/ -#define SDL_LIL_ENDIAN 1234 -#define SDL_BIG_ENDIAN 4321 -/*@}*/ - -#ifndef SDL_BYTEORDER /* Not defined in SDL_config.h? */ -#ifdef __linux__ -#include -#define SDL_BYTEORDER __BYTE_ORDER -#else /* __linux __ */ -#if defined(__hppa__) || \ - defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || \ - (defined(__MIPS__) && defined(__MISPEB__)) || \ - defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || \ - defined(__sparc__) -#define SDL_BYTEORDER SDL_BIG_ENDIAN -#else -#define SDL_BYTEORDER SDL_LIL_ENDIAN -#endif -#endif /* __linux __ */ -#endif /* !SDL_BYTEORDER */ - - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @name SDL_Swap Functions - * Use inline functions for compilers that support them, and static - * functions for those that do not. Because these functions become - * static for compilers that do not support inline functions, this - * header should only be included in files that actually use them. - */ -/*@{*/ -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0" : "=q" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("xchgb %b0,%h0" : "=Q" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - int result; - - __asm__("rlwimi %0,%2,8,16,23" : "=&r" (result) : "0" (x >> 8), "r" (x)); - return (Uint16)result; -} -#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) -static __inline__ Uint16 SDL_Swap16(Uint16 x) -{ - __asm__("rorw #8,%0" : "=d" (x) : "0" (x) : "cc"); - return x; -} -#else -static __inline__ Uint16 SDL_Swap16(Uint16 x) { - return SDL_static_cast(Uint16, ((x<<8)|(x>>8))); -} -#endif - -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("bswap %0" : "=r" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("bswapl %0" : "=r" (x) : "0" (x)); - return x; -} -#elif defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__)) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - Uint32 result; - - __asm__("rlwimi %0,%2,24,16,23" : "=&r" (result) : "0" (x>>24), "r" (x)); - __asm__("rlwimi %0,%2,8,8,15" : "=&r" (result) : "0" (result), "r" (x)); - __asm__("rlwimi %0,%2,24,0,7" : "=&r" (result) : "0" (result), "r" (x)); - return result; -} -#elif defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) -static __inline__ Uint32 SDL_Swap32(Uint32 x) -{ - __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0" : "=d" (x) : "0" (x) : "cc"); - return x; -} -#else -static __inline__ Uint32 SDL_Swap32(Uint32 x) { - return SDL_static_cast(Uint32, ((x<<24)|((x<<8)&0x00FF0000)|((x>>8)&0x0000FF00)|(x>>24))); -} -#endif - -#ifdef SDL_HAS_64BIT_TYPE -#if defined(__GNUC__) && defined(__i386__) && \ - !(__GNUC__ == 2 && __GNUC_MINOR__ <= 95 /* broken gcc version */) -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - union { - struct { Uint32 a,b; } s; - Uint64 u; - } v; - v.u = x; - __asm__("bswapl %0 ; bswapl %1 ; xchgl %0,%1" - : "=r" (v.s.a), "=r" (v.s.b) - : "0" (v.s.a), "1" (v.s.b)); - return v.u; -} -#elif defined(__GNUC__) && defined(__x86_64__) -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - __asm__("bswapq %0" : "=r" (x) : "0" (x)); - return x; -} -#else -static __inline__ Uint64 SDL_Swap64(Uint64 x) -{ - Uint32 hi, lo; - - /* Separate into high and low 32-bit values and swap them */ - lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); - x >>= 32; - hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); - x = SDL_Swap32(lo); - x <<= 32; - x |= SDL_Swap32(hi); - return (x); -} -#endif -#else -/* This is mainly to keep compilers from complaining in SDL code. - * If there is no real 64-bit datatype, then compilers will complain about - * the fake 64-bit datatype that SDL provides when it compiles user code. - */ -#define SDL_Swap64(X) (X) -#endif /* SDL_HAS_64BIT_TYPE */ -/*@}*/ - -/** - * @name SDL_SwapLE and SDL_SwapBE Functions - * Byteswap item from the specified endianness to the native endianness - */ -/*@{*/ -#if SDL_BYTEORDER == SDL_LIL_ENDIAN -#define SDL_SwapLE16(X) (X) -#define SDL_SwapLE32(X) (X) -#define SDL_SwapLE64(X) (X) -#define SDL_SwapBE16(X) SDL_Swap16(X) -#define SDL_SwapBE32(X) SDL_Swap32(X) -#define SDL_SwapBE64(X) SDL_Swap64(X) -#else -#define SDL_SwapLE16(X) SDL_Swap16(X) -#define SDL_SwapLE32(X) SDL_Swap32(X) -#define SDL_SwapLE64(X) SDL_Swap64(X) -#define SDL_SwapBE16(X) (X) -#define SDL_SwapBE32(X) (X) -#define SDL_SwapBE64(X) (X) -#endif -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_endian_h */ diff --git a/codemp/rd-rend2/SDL/SDL_error.h b/codemp/rd-rend2/SDL/SDL_error.h deleted file mode 100644 index 4e1cce3b17..0000000000 --- a/codemp/rd-rend2/SDL/SDL_error.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_error.h - * Simple error message routines for SDL - */ - -#ifndef _SDL_error_h -#define _SDL_error_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @name Public functions - */ -/*@{*/ -extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); -extern DECLSPEC char * SDLCALL SDL_GetError(void); -extern DECLSPEC void SDLCALL SDL_ClearError(void); -/*@}*/ - -/** - * @name Private functions - * @internal Private error message function - used internally - */ -/*@{*/ -#define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) -#define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) -typedef enum { - SDL_ENOMEM, - SDL_EFREAD, - SDL_EFWRITE, - SDL_EFSEEK, - SDL_UNSUPPORTED, - SDL_LASTERROR -} SDL_errorcode; -extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_error_h */ diff --git a/codemp/rd-rend2/SDL/SDL_events.h b/codemp/rd-rend2/SDL/SDL_events.h deleted file mode 100644 index 94b4202518..0000000000 --- a/codemp/rd-rend2/SDL/SDL_events.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file SDL_events.h - * Include file for SDL event handling - */ - -#ifndef _SDL_events_h -#define _SDL_events_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_active.h" -#include "SDL_keyboard.h" -#include "SDL_mouse.h" -#include "SDL_joystick.h" -#include "SDL_quit.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @name General keyboard/mouse state definitions */ -/*@{*/ -#define SDL_RELEASED 0 -#define SDL_PRESSED 1 -/*@}*/ - -/** Event enumerations */ -typedef enum { - SDL_NOEVENT = 0, /**< Unused (do not remove) */ - SDL_ACTIVEEVENT, /**< Application loses/gains visibility */ - SDL_KEYDOWN, /**< Keys pressed */ - SDL_KEYUP, /**< Keys released */ - SDL_MOUSEMOTION, /**< Mouse moved */ - SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */ - SDL_MOUSEBUTTONUP, /**< Mouse button released */ - SDL_JOYAXISMOTION, /**< Joystick axis motion */ - SDL_JOYBALLMOTION, /**< Joystick trackball motion */ - SDL_JOYHATMOTION, /**< Joystick hat position change */ - SDL_JOYBUTTONDOWN, /**< Joystick button pressed */ - SDL_JOYBUTTONUP, /**< Joystick button released */ - SDL_QUIT, /**< User-requested quit */ - SDL_SYSWMEVENT, /**< System specific event */ - SDL_EVENT_RESERVEDA, /**< Reserved for future use.. */ - SDL_EVENT_RESERVEDB, /**< Reserved for future use.. */ - SDL_VIDEORESIZE, /**< User resized video mode */ - SDL_VIDEOEXPOSE, /**< Screen needs to be redrawn */ - SDL_EVENT_RESERVED2, /**< Reserved for future use.. */ - SDL_EVENT_RESERVED3, /**< Reserved for future use.. */ - SDL_EVENT_RESERVED4, /**< Reserved for future use.. */ - SDL_EVENT_RESERVED5, /**< Reserved for future use.. */ - SDL_EVENT_RESERVED6, /**< Reserved for future use.. */ - SDL_EVENT_RESERVED7, /**< Reserved for future use.. */ - /** Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */ - SDL_USEREVENT = 24, - /** This last event is only for bounding internal arrays - * It is the number of bits in the event mask datatype -- Uint32 - */ - SDL_NUMEVENTS = 32 -} SDL_EventType; - -/** @name Predefined event masks */ -/*@{*/ -#define SDL_EVENTMASK(X) (1<<(X)) -typedef enum { - SDL_ACTIVEEVENTMASK = SDL_EVENTMASK(SDL_ACTIVEEVENT), - SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN), - SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP), - SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN)| - SDL_EVENTMASK(SDL_KEYUP), - SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION), - SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN), - SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP), - SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION)| - SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)| - SDL_EVENTMASK(SDL_MOUSEBUTTONUP), - SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION), - SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION), - SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION), - SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN), - SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP), - SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION)| - SDL_EVENTMASK(SDL_JOYBALLMOTION)| - SDL_EVENTMASK(SDL_JOYHATMOTION)| - SDL_EVENTMASK(SDL_JOYBUTTONDOWN)| - SDL_EVENTMASK(SDL_JOYBUTTONUP), - SDL_VIDEORESIZEMASK = SDL_EVENTMASK(SDL_VIDEORESIZE), - SDL_VIDEOEXPOSEMASK = SDL_EVENTMASK(SDL_VIDEOEXPOSE), - SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT), - SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) -} SDL_EventMask ; -#define SDL_ALLEVENTS 0xFFFFFFFF -/*@}*/ - -/** Application visibility event structure */ -typedef struct SDL_ActiveEvent { - Uint8 type; /**< SDL_ACTIVEEVENT */ - Uint8 gain; /**< Whether given states were gained or lost (1/0) */ - Uint8 state; /**< A mask of the focus states */ -} SDL_ActiveEvent; - -/** Keyboard event structure */ -typedef struct SDL_KeyboardEvent { - Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ - Uint8 which; /**< The keyboard device index */ - Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ - SDL_keysym keysym; -} SDL_KeyboardEvent; - -/** Mouse motion event structure */ -typedef struct SDL_MouseMotionEvent { - Uint8 type; /**< SDL_MOUSEMOTION */ - Uint8 which; /**< The mouse device index */ - Uint8 state; /**< The current button state */ - Uint16 x, y; /**< The X/Y coordinates of the mouse */ - Sint16 xrel; /**< The relative motion in the X direction */ - Sint16 yrel; /**< The relative motion in the Y direction */ -} SDL_MouseMotionEvent; - -/** Mouse button event structure */ -typedef struct SDL_MouseButtonEvent { - Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ - Uint8 which; /**< The mouse device index */ - Uint8 button; /**< The mouse button index */ - Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ - Uint16 x, y; /**< The X/Y coordinates of the mouse at press time */ -} SDL_MouseButtonEvent; - -/** Joystick axis motion event structure */ -typedef struct SDL_JoyAxisEvent { - Uint8 type; /**< SDL_JOYAXISMOTION */ - Uint8 which; /**< The joystick device index */ - Uint8 axis; /**< The joystick axis index */ - Sint16 value; /**< The axis value (range: -32768 to 32767) */ -} SDL_JoyAxisEvent; - -/** Joystick trackball motion event structure */ -typedef struct SDL_JoyBallEvent { - Uint8 type; /**< SDL_JOYBALLMOTION */ - Uint8 which; /**< The joystick device index */ - Uint8 ball; /**< The joystick trackball index */ - Sint16 xrel; /**< The relative motion in the X direction */ - Sint16 yrel; /**< The relative motion in the Y direction */ -} SDL_JoyBallEvent; - -/** Joystick hat position change event structure */ -typedef struct SDL_JoyHatEvent { - Uint8 type; /**< SDL_JOYHATMOTION */ - Uint8 which; /**< The joystick device index */ - Uint8 hat; /**< The joystick hat index */ - Uint8 value; /**< The hat position value: - * SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP - * SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT - * SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN - * Note that zero means the POV is centered. - */ -} SDL_JoyHatEvent; - -/** Joystick button event structure */ -typedef struct SDL_JoyButtonEvent { - Uint8 type; /**< SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ - Uint8 which; /**< The joystick device index */ - Uint8 button; /**< The joystick button index */ - Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ -} SDL_JoyButtonEvent; - -/** The "window resized" event - * When you get this event, you are responsible for setting a new video - * mode with the new width and height. - */ -typedef struct SDL_ResizeEvent { - Uint8 type; /**< SDL_VIDEORESIZE */ - int w; /**< New width */ - int h; /**< New height */ -} SDL_ResizeEvent; - -/** The "screen redraw" event */ -typedef struct SDL_ExposeEvent { - Uint8 type; /**< SDL_VIDEOEXPOSE */ -} SDL_ExposeEvent; - -/** The "quit requested" event */ -typedef struct SDL_QuitEvent { - Uint8 type; /**< SDL_QUIT */ -} SDL_QuitEvent; - -/** A user-defined event type */ -typedef struct SDL_UserEvent { - Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ - int code; /**< User defined event code */ - void *data1; /**< User defined data pointer */ - void *data2; /**< User defined data pointer */ -} SDL_UserEvent; - -/** If you want to use this event, you should include SDL_syswm.h */ -struct SDL_SysWMmsg; -typedef struct SDL_SysWMmsg SDL_SysWMmsg; -typedef struct SDL_SysWMEvent { - Uint8 type; - SDL_SysWMmsg *msg; -} SDL_SysWMEvent; - -/** General event structure */ -typedef union SDL_Event { - Uint8 type; - SDL_ActiveEvent active; - SDL_KeyboardEvent key; - SDL_MouseMotionEvent motion; - SDL_MouseButtonEvent button; - SDL_JoyAxisEvent jaxis; - SDL_JoyBallEvent jball; - SDL_JoyHatEvent jhat; - SDL_JoyButtonEvent jbutton; - SDL_ResizeEvent resize; - SDL_ExposeEvent expose; - SDL_QuitEvent quit; - SDL_UserEvent user; - SDL_SysWMEvent syswm; -} SDL_Event; - - -/* Function prototypes */ - -/** Pumps the event loop, gathering events from the input devices. - * This function updates the event queue and internal input device state. - * This should only be run in the thread that sets the video mode. - */ -extern DECLSPEC void SDLCALL SDL_PumpEvents(void); - -typedef enum { - SDL_ADDEVENT, - SDL_PEEKEVENT, - SDL_GETEVENT -} SDL_eventaction; - -/** - * Checks the event queue for messages and optionally returns them. - * - * If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to - * the back of the event queue. - * If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front - * of the event queue, matching 'mask', will be returned and will not - * be removed from the queue. - * If 'action' is SDL_GETEVENT, up to 'numevents' events at the front - * of the event queue, matching 'mask', will be returned and will be - * removed from the queue. - * - * @return - * This function returns the number of events actually stored, or -1 - * if there was an error. - * - * This function is thread-safe. - */ -extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event *events, int numevents, - SDL_eventaction action, Uint32 mask); - -/** Polls for currently pending events, and returns 1 if there are any pending - * events, or 0 if there are none available. If 'event' is not NULL, the next - * event is removed from the queue and stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event); - -/** Waits indefinitely for the next available event, returning 1, or 0 if there - * was an error while waiting for events. If 'event' is not NULL, the next - * event is removed from the queue and stored in that area. - */ -extern DECLSPEC int SDLCALL SDL_WaitEvent(SDL_Event *event); - -/** Add an event to the event queue. - * This function returns 0 on success, or -1 if the event queue was full - * or there was some other error. - */ -extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event *event); - -/** @name Event Filtering */ -/*@{*/ -typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); -/** - * This function sets up a filter to process all events before they - * change internal state and are posted to the internal event queue. - * - * The filter is protypted as: - * @code typedef int (SDLCALL *SDL_EventFilter)(const SDL_Event *event); @endcode - * - * If the filter returns 1, then the event will be added to the internal queue. - * If it returns 0, then the event will be dropped from the queue, but the - * internal state will still be updated. This allows selective filtering of - * dynamically arriving events. - * - * @warning Be very careful of what you do in the event filter function, as - * it may run in a different thread! - * - * There is one caveat when dealing with the SDL_QUITEVENT event type. The - * event filter is only called when the window manager desires to close the - * application window. If the event filter returns 1, then the window will - * be closed, otherwise the window will remain open if possible. - * If the quit event is generated by an interrupt signal, it will bypass the - * internal queue and be delivered to the application at the next event poll. - */ -extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter); - -/** - * Return the current event filter - can be used to "chain" filters. - * If there is no event filter set, this function returns NULL. - */ -extern DECLSPEC SDL_EventFilter SDLCALL SDL_GetEventFilter(void); -/*@}*/ - -/** @name Event State */ -/*@{*/ -#define SDL_QUERY -1 -#define SDL_IGNORE 0 -#define SDL_DISABLE 0 -#define SDL_ENABLE 1 -/*@}*/ - -/** -* This function allows you to set the state of processing certain events. -* If 'state' is set to SDL_IGNORE, that event will be automatically dropped -* from the event queue and will not event be filtered. -* If 'state' is set to SDL_ENABLE, that event will be processed normally. -* If 'state' is set to SDL_QUERY, SDL_EventState() will return the -* current processing state of the specified event. -*/ -extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_events_h */ diff --git a/codemp/rd-rend2/SDL/SDL_getenv.h b/codemp/rd-rend2/SDL/SDL_getenv.h deleted file mode 100644 index bea630077c..0000000000 --- a/codemp/rd-rend2/SDL/SDL_getenv.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_getenv.h - * @deprecated Use SDL_stdinc.h instead - */ - -/* DEPRECATED */ -#include "SDL_stdinc.h" diff --git a/codemp/rd-rend2/SDL/SDL_joystick.h b/codemp/rd-rend2/SDL/SDL_joystick.h deleted file mode 100644 index 708d1a9f09..0000000000 --- a/codemp/rd-rend2/SDL/SDL_joystick.h +++ /dev/null @@ -1,187 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_joystick.h - * Include file for SDL joystick event handling - */ - -#ifndef _SDL_joystick_h -#define _SDL_joystick_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @file SDL_joystick.h - * @note In order to use these functions, SDL_Init() must have been called - * with the SDL_INIT_JOYSTICK flag. This causes SDL to scan the system - * for joysticks, and load appropriate drivers. - */ - -/** The joystick structure used to identify an SDL joystick */ -struct _SDL_Joystick; -typedef struct _SDL_Joystick SDL_Joystick; - -/* Function prototypes */ -/** - * Count the number of joysticks attached to the system - */ -extern DECLSPEC int SDLCALL SDL_NumJoysticks(void); - -/** - * Get the implementation dependent name of a joystick. - * - * This can be called before any joysticks are opened. - * If no name can be found, this function returns NULL. - */ -extern DECLSPEC const char * SDLCALL SDL_JoystickName(int device_index); - -/** - * Open a joystick for use. - * - * @param[in] device_index - * The index passed as an argument refers to - * the N'th joystick on the system. This index is the value which will - * identify this joystick in future joystick events. - * - * @return This function returns a joystick identifier, or NULL if an error occurred. - */ -extern DECLSPEC SDL_Joystick * SDLCALL SDL_JoystickOpen(int device_index); - -/** - * Returns 1 if the joystick has been opened, or 0 if it has not. - */ -extern DECLSPEC int SDLCALL SDL_JoystickOpened(int device_index); - -/** - * Get the device index of an opened joystick. - */ -extern DECLSPEC int SDLCALL SDL_JoystickIndex(SDL_Joystick *joystick); - -/** - * Get the number of general axis controls on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick); - -/** - * Get the number of trackballs on a joystick - * - * Joystick trackballs have only relative motion events associated - * with them and their state cannot be polled. - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick); - -/** - * Get the number of POV hats on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick); - -/** - * Get the number of buttons on a joystick - */ -extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick); - -/** - * Update the current state of the open joysticks. - * - * This is called automatically by the event loop if any joystick - * events are enabled. - */ -extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void); - -/** - * Enable/disable joystick event polling. - * - * If joystick events are disabled, you must call SDL_JoystickUpdate() - * yourself and check the state of the joystick when you want joystick - * information. - * - * @param[in] state The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE. - */ -extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state); - -/** - * Get the current state of an axis control on a joystick - * - * @param[in] axis The axis indices start at index 0. - * - * @return The state is a value ranging from -32768 to 32767. - */ -extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis); - -/** - * @name Hat Positions - * The return value of SDL_JoystickGetHat() is one of the following positions: - */ -/*@{*/ -#define SDL_HAT_CENTERED 0x00 -#define SDL_HAT_UP 0x01 -#define SDL_HAT_RIGHT 0x02 -#define SDL_HAT_DOWN 0x04 -#define SDL_HAT_LEFT 0x08 -#define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP) -#define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN) -#define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP) -#define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN) -/*@}*/ - -/** - * Get the current state of a POV hat on a joystick - * - * @param[in] hat The hat indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat); - -/** - * Get the ball axis change since the last poll - * - * @param[in] ball The ball indices start at index 0. - * - * @return This returns 0, or -1 if you passed it invalid parameters. - */ -extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy); - -/** - * Get the current state of a button on a joystick - * - * @param[in] button The button indices start at index 0. - */ -extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button); - -/** - * Close a joystick previously opened with SDL_JoystickOpen() - */ -extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_joystick_h */ diff --git a/codemp/rd-rend2/SDL/SDL_keyboard.h b/codemp/rd-rend2/SDL/SDL_keyboard.h deleted file mode 100644 index 9d7129c526..0000000000 --- a/codemp/rd-rend2/SDL/SDL_keyboard.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_keyboard.h - * Include file for SDL keyboard event handling - */ - -#ifndef _SDL_keyboard_h -#define _SDL_keyboard_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_keysym.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** Keysym structure - * - * - The scancode is hardware dependent, and should not be used by general - * applications. If no hardware scancode is available, it will be 0. - * - * - The 'unicode' translated character is only available when character - * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, - * this is a UNICODE character corresponding to the keypress. If the - * high 9 bits of the character are 0, then this maps to the equivalent - * ASCII character: - * @code - * char ch; - * if ( (keysym.unicode & 0xFF80) == 0 ) { - * ch = keysym.unicode & 0x7F; - * } else { - * An international character.. - * } - * @endcode - */ -typedef struct SDL_keysym { - Uint8 scancode; /**< hardware specific scancode */ - SDLKey sym; /**< SDL virtual keysym */ - SDLMod mod; /**< current key modifiers */ - Uint16 unicode; /**< translated character */ -} SDL_keysym; - -/** This is the mask which refers to all hotkey bindings */ -#define SDL_ALL_HOTKEYS 0xFFFFFFFF - -/* Function prototypes */ -/** - * Enable/Disable UNICODE translation of keyboard input. - * - * This translation has some overhead, so translation defaults off. - * - * @param[in] enable - * If 'enable' is 1, translation is enabled. - * If 'enable' is 0, translation is disabled. - * If 'enable' is -1, the translation state is not changed. - * - * @return It returns the previous state of keyboard translation. - */ -extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); - -#define SDL_DEFAULT_REPEAT_DELAY 500 -#define SDL_DEFAULT_REPEAT_INTERVAL 30 -/** - * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. - * - * @param[in] delay - * 'delay' is the initial delay in ms between the time when a key is - * pressed, and keyboard repeat begins. - * - * @param[in] interval - * 'interval' is the time in ms between keyboard repeat events. - * - * If 'delay' is set to 0, keyboard repeat is disabled. - */ -extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); -extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); - -/** - * Get a snapshot of the current state of the keyboard. - * Returns an array of keystates, indexed by the SDLK_* syms. - * Usage: - * @code - * Uint8 *keystate = SDL_GetKeyState(NULL); - * if ( keystate[SDLK_RETURN] ) //... \ is pressed. - * @endcode - */ -extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); - -/** - * Get the current key modifier state - */ -extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); - -/** - * Set the current key modifier state. - * This does not change the keyboard state, only the key modifier flags. - */ -extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); - -/** - * Get the name of an SDL virtual keysym - */ -extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_keyboard_h */ diff --git a/codemp/rd-rend2/SDL/SDL_keysym.h b/codemp/rd-rend2/SDL/SDL_keysym.h deleted file mode 100644 index f2ad12b81e..0000000000 --- a/codemp/rd-rend2/SDL/SDL_keysym.h +++ /dev/null @@ -1,326 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_keysym_h -#define _SDL_keysym_h - -/** What we really want is a mapping of every raw key on the keyboard. - * To support international keyboards, we use the range 0xA1 - 0xFF - * as international virtual keycodes. We'll follow in the footsteps of X11... - * @brief The names of the keys - */ -typedef enum { - /** @name ASCII mapped keysyms - * The keyboard syms have been cleverly chosen to map to ASCII - */ - /*@{*/ - SDLK_UNKNOWN = 0, - SDLK_FIRST = 0, - SDLK_BACKSPACE = 8, - SDLK_TAB = 9, - SDLK_CLEAR = 12, - SDLK_RETURN = 13, - SDLK_PAUSE = 19, - SDLK_ESCAPE = 27, - SDLK_SPACE = 32, - SDLK_EXCLAIM = 33, - SDLK_QUOTEDBL = 34, - SDLK_HASH = 35, - SDLK_DOLLAR = 36, - SDLK_AMPERSAND = 38, - SDLK_QUOTE = 39, - SDLK_LEFTPAREN = 40, - SDLK_RIGHTPAREN = 41, - SDLK_ASTERISK = 42, - SDLK_PLUS = 43, - SDLK_COMMA = 44, - SDLK_MINUS = 45, - SDLK_PERIOD = 46, - SDLK_SLASH = 47, - SDLK_0 = 48, - SDLK_1 = 49, - SDLK_2 = 50, - SDLK_3 = 51, - SDLK_4 = 52, - SDLK_5 = 53, - SDLK_6 = 54, - SDLK_7 = 55, - SDLK_8 = 56, - SDLK_9 = 57, - SDLK_COLON = 58, - SDLK_SEMICOLON = 59, - SDLK_LESS = 60, - SDLK_EQUALS = 61, - SDLK_GREATER = 62, - SDLK_QUESTION = 63, - SDLK_AT = 64, - /* - Skip uppercase letters - */ - SDLK_LEFTBRACKET = 91, - SDLK_BACKSLASH = 92, - SDLK_RIGHTBRACKET = 93, - SDLK_CARET = 94, - SDLK_UNDERSCORE = 95, - SDLK_BACKQUOTE = 96, - SDLK_a = 97, - SDLK_b = 98, - SDLK_c = 99, - SDLK_d = 100, - SDLK_e = 101, - SDLK_f = 102, - SDLK_g = 103, - SDLK_h = 104, - SDLK_i = 105, - SDLK_j = 106, - SDLK_k = 107, - SDLK_l = 108, - SDLK_m = 109, - SDLK_n = 110, - SDLK_o = 111, - SDLK_p = 112, - SDLK_q = 113, - SDLK_r = 114, - SDLK_s = 115, - SDLK_t = 116, - SDLK_u = 117, - SDLK_v = 118, - SDLK_w = 119, - SDLK_x = 120, - SDLK_y = 121, - SDLK_z = 122, - SDLK_DELETE = 127, - /* End of ASCII mapped keysyms */ - /*@}*/ - - /** @name International keyboard syms */ - /*@{*/ - SDLK_WORLD_0 = 160, /* 0xA0 */ - SDLK_WORLD_1 = 161, - SDLK_WORLD_2 = 162, - SDLK_WORLD_3 = 163, - SDLK_WORLD_4 = 164, - SDLK_WORLD_5 = 165, - SDLK_WORLD_6 = 166, - SDLK_WORLD_7 = 167, - SDLK_WORLD_8 = 168, - SDLK_WORLD_9 = 169, - SDLK_WORLD_10 = 170, - SDLK_WORLD_11 = 171, - SDLK_WORLD_12 = 172, - SDLK_WORLD_13 = 173, - SDLK_WORLD_14 = 174, - SDLK_WORLD_15 = 175, - SDLK_WORLD_16 = 176, - SDLK_WORLD_17 = 177, - SDLK_WORLD_18 = 178, - SDLK_WORLD_19 = 179, - SDLK_WORLD_20 = 180, - SDLK_WORLD_21 = 181, - SDLK_WORLD_22 = 182, - SDLK_WORLD_23 = 183, - SDLK_WORLD_24 = 184, - SDLK_WORLD_25 = 185, - SDLK_WORLD_26 = 186, - SDLK_WORLD_27 = 187, - SDLK_WORLD_28 = 188, - SDLK_WORLD_29 = 189, - SDLK_WORLD_30 = 190, - SDLK_WORLD_31 = 191, - SDLK_WORLD_32 = 192, - SDLK_WORLD_33 = 193, - SDLK_WORLD_34 = 194, - SDLK_WORLD_35 = 195, - SDLK_WORLD_36 = 196, - SDLK_WORLD_37 = 197, - SDLK_WORLD_38 = 198, - SDLK_WORLD_39 = 199, - SDLK_WORLD_40 = 200, - SDLK_WORLD_41 = 201, - SDLK_WORLD_42 = 202, - SDLK_WORLD_43 = 203, - SDLK_WORLD_44 = 204, - SDLK_WORLD_45 = 205, - SDLK_WORLD_46 = 206, - SDLK_WORLD_47 = 207, - SDLK_WORLD_48 = 208, - SDLK_WORLD_49 = 209, - SDLK_WORLD_50 = 210, - SDLK_WORLD_51 = 211, - SDLK_WORLD_52 = 212, - SDLK_WORLD_53 = 213, - SDLK_WORLD_54 = 214, - SDLK_WORLD_55 = 215, - SDLK_WORLD_56 = 216, - SDLK_WORLD_57 = 217, - SDLK_WORLD_58 = 218, - SDLK_WORLD_59 = 219, - SDLK_WORLD_60 = 220, - SDLK_WORLD_61 = 221, - SDLK_WORLD_62 = 222, - SDLK_WORLD_63 = 223, - SDLK_WORLD_64 = 224, - SDLK_WORLD_65 = 225, - SDLK_WORLD_66 = 226, - SDLK_WORLD_67 = 227, - SDLK_WORLD_68 = 228, - SDLK_WORLD_69 = 229, - SDLK_WORLD_70 = 230, - SDLK_WORLD_71 = 231, - SDLK_WORLD_72 = 232, - SDLK_WORLD_73 = 233, - SDLK_WORLD_74 = 234, - SDLK_WORLD_75 = 235, - SDLK_WORLD_76 = 236, - SDLK_WORLD_77 = 237, - SDLK_WORLD_78 = 238, - SDLK_WORLD_79 = 239, - SDLK_WORLD_80 = 240, - SDLK_WORLD_81 = 241, - SDLK_WORLD_82 = 242, - SDLK_WORLD_83 = 243, - SDLK_WORLD_84 = 244, - SDLK_WORLD_85 = 245, - SDLK_WORLD_86 = 246, - SDLK_WORLD_87 = 247, - SDLK_WORLD_88 = 248, - SDLK_WORLD_89 = 249, - SDLK_WORLD_90 = 250, - SDLK_WORLD_91 = 251, - SDLK_WORLD_92 = 252, - SDLK_WORLD_93 = 253, - SDLK_WORLD_94 = 254, - SDLK_WORLD_95 = 255, /* 0xFF */ - /*@}*/ - - /** @name Numeric keypad */ - /*@{*/ - SDLK_KP0 = 256, - SDLK_KP1 = 257, - SDLK_KP2 = 258, - SDLK_KP3 = 259, - SDLK_KP4 = 260, - SDLK_KP5 = 261, - SDLK_KP6 = 262, - SDLK_KP7 = 263, - SDLK_KP8 = 264, - SDLK_KP9 = 265, - SDLK_KP_PERIOD = 266, - SDLK_KP_DIVIDE = 267, - SDLK_KP_MULTIPLY = 268, - SDLK_KP_MINUS = 269, - SDLK_KP_PLUS = 270, - SDLK_KP_ENTER = 271, - SDLK_KP_EQUALS = 272, - /*@}*/ - - /** @name Arrows + Home/End pad */ - /*@{*/ - SDLK_UP = 273, - SDLK_DOWN = 274, - SDLK_RIGHT = 275, - SDLK_LEFT = 276, - SDLK_INSERT = 277, - SDLK_HOME = 278, - SDLK_END = 279, - SDLK_PAGEUP = 280, - SDLK_PAGEDOWN = 281, - /*@}*/ - - /** @name Function keys */ - /*@{*/ - SDLK_F1 = 282, - SDLK_F2 = 283, - SDLK_F3 = 284, - SDLK_F4 = 285, - SDLK_F5 = 286, - SDLK_F6 = 287, - SDLK_F7 = 288, - SDLK_F8 = 289, - SDLK_F9 = 290, - SDLK_F10 = 291, - SDLK_F11 = 292, - SDLK_F12 = 293, - SDLK_F13 = 294, - SDLK_F14 = 295, - SDLK_F15 = 296, - /*@}*/ - - /** @name Key state modifier keys */ - /*@{*/ - SDLK_NUMLOCK = 300, - SDLK_CAPSLOCK = 301, - SDLK_SCROLLOCK = 302, - SDLK_RSHIFT = 303, - SDLK_LSHIFT = 304, - SDLK_RCTRL = 305, - SDLK_LCTRL = 306, - SDLK_RALT = 307, - SDLK_LALT = 308, - SDLK_RMETA = 309, - SDLK_LMETA = 310, - SDLK_LSUPER = 311, /**< Left "Windows" key */ - SDLK_RSUPER = 312, /**< Right "Windows" key */ - SDLK_MODE = 313, /**< "Alt Gr" key */ - SDLK_COMPOSE = 314, /**< Multi-key compose key */ - /*@}*/ - - /** @name Miscellaneous function keys */ - /*@{*/ - SDLK_HELP = 315, - SDLK_PRINT = 316, - SDLK_SYSREQ = 317, - SDLK_BREAK = 318, - SDLK_MENU = 319, - SDLK_POWER = 320, /**< Power Macintosh power key */ - SDLK_EURO = 321, /**< Some european keyboards */ - SDLK_UNDO = 322, /**< Atari keyboard has Undo */ - /*@}*/ - - /* Add any other keys here */ - - SDLK_LAST -} SDLKey; - -/** Enumeration of valid key mods (possibly OR'd together) */ -typedef enum { - KMOD_NONE = 0x0000, - KMOD_LSHIFT= 0x0001, - KMOD_RSHIFT= 0x0002, - KMOD_LCTRL = 0x0040, - KMOD_RCTRL = 0x0080, - KMOD_LALT = 0x0100, - KMOD_RALT = 0x0200, - KMOD_LMETA = 0x0400, - KMOD_RMETA = 0x0800, - KMOD_NUM = 0x1000, - KMOD_CAPS = 0x2000, - KMOD_MODE = 0x4000, - KMOD_RESERVED = 0x8000 -} SDLMod; - -#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) -#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) -#define KMOD_ALT (KMOD_LALT|KMOD_RALT) -#define KMOD_META (KMOD_LMETA|KMOD_RMETA) - -#endif /* _SDL_keysym_h */ diff --git a/codemp/rd-rend2/SDL/SDL_loadso.h b/codemp/rd-rend2/SDL/SDL_loadso.h deleted file mode 100644 index 0c5e5362de..0000000000 --- a/codemp/rd-rend2/SDL/SDL_loadso.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_loadso.h - * System dependent library loading routines - */ - -/** @file SDL_loadso.h - * Some things to keep in mind: - * - These functions only work on C function names. Other languages may - * have name mangling and intrinsic language support that varies from - * compiler to compiler. - * - Make sure you declare your function pointers with the same calling - * convention as the actual library function. Your code will crash - * mysteriously if you do not do this. - * - Avoid namespace collisions. If you load a symbol from the library, - * it is not defined whether or not it goes into the global symbol - * namespace for the application. If it does and it conflicts with - * symbols in your code or other shared libraries, you will not get - * the results you expect. :) - */ - - -#ifndef _SDL_loadso_h -#define _SDL_loadso_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** - * This function dynamically loads a shared object and returns a pointer - * to the object handle (or NULL if there was an error). - * The 'sofile' parameter is a system dependent name of the object file. - */ -extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); - -/** - * Given an object handle, this function looks up the address of the - * named function in the shared object and returns it. This address - * is no longer valid after calling SDL_UnloadObject(). - */ -extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); - -/** Unload a shared object from memory */ -extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_loadso_h */ diff --git a/codemp/rd-rend2/SDL/SDL_main.h b/codemp/rd-rend2/SDL/SDL_main.h deleted file mode 100644 index ab50ef1e29..0000000000 --- a/codemp/rd-rend2/SDL/SDL_main.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_main_h -#define _SDL_main_h - -#include "SDL_stdinc.h" - -/** @file SDL_main.h - * Redefine main() on Win32 and MacOS so that it is called by winmain.c - */ - -#if defined(__WIN32__) || \ - (defined(__MWERKS__) && !defined(__BEOS__)) || \ - defined(__MACOS__) || defined(__MACOSX__) || \ - defined(__SYMBIAN32__) || defined(QWS) - -#ifdef __cplusplus -#define C_LINKAGE "C" -#else -#define C_LINKAGE -#endif /* __cplusplus */ - -/** The application's main() function must be called with C linkage, - * and should be declared like this: - * @code - * #ifdef __cplusplus - * extern "C" - * #endif - * int main(int argc, char *argv[]) - * { - * } - * @endcode - */ -#define main SDL_main - -/** The prototype for the application's main() function */ -extern C_LINKAGE int SDL_main(int argc, char *argv[]); - - -/** @name From the SDL library code -- needed for registering the app on Win32 */ -/*@{*/ -#ifdef __WIN32__ - -#include "begin_code.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** This should be called from your WinMain() function, if any */ -extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); -/** This can also be called, but is no longer necessary */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); -/** This can also be called, but is no longer necessary (SDL_Quit calls it) */ -extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif -/*@}*/ - -/** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ -/*@{*/ -#if defined(__MACOS__) - -#include "begin_code.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** Forward declaration so we don't need to include QuickDraw.h */ -struct QDGlobals; - -/** This should be called from your main() function, if any */ -extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); - -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif -/*@}*/ - -#endif /* Need to redefine main()? */ - -#endif /* _SDL_main_h */ diff --git a/codemp/rd-rend2/SDL/SDL_mouse.h b/codemp/rd-rend2/SDL/SDL_mouse.h deleted file mode 100644 index 7c563b94da..0000000000 --- a/codemp/rd-rend2/SDL/SDL_mouse.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_mouse.h - * Include file for SDL mouse event handling - */ - -#ifndef _SDL_mouse_h -#define _SDL_mouse_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_video.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct WMcursor WMcursor; /**< Implementation dependent */ -typedef struct SDL_Cursor { - SDL_Rect area; /**< The area of the mouse cursor */ - Sint16 hot_x, hot_y; /**< The "tip" of the cursor */ - Uint8 *data; /**< B/W cursor data */ - Uint8 *mask; /**< B/W cursor mask */ - Uint8 *save[2]; /**< Place to save cursor area */ - WMcursor *wm_cursor; /**< Window-manager cursor */ -} SDL_Cursor; - -/* Function prototypes */ -/** - * Retrieve the current state of the mouse. - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * current mouse cursor position. You can pass NULL for either x or y. - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetMouseState(int *x, int *y); - -/** - * Retrieve the current state of the mouse. - * The current button state is returned as a button bitmask, which can - * be tested using the SDL_BUTTON(X) macros, and x and y are set to the - * mouse deltas since the last call to SDL_GetRelativeMouseState(). - */ -extern DECLSPEC Uint8 SDLCALL SDL_GetRelativeMouseState(int *x, int *y); - -/** - * Set the position of the mouse cursor (generates a mouse motion event) - */ -extern DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y); - -/** - * Create a cursor using the specified data and mask (in MSB format). - * The cursor width must be a multiple of 8 bits. - * - * The cursor is created in black and white according to the following: - * data mask resulting pixel on screen - * 0 1 White - * 1 1 Black - * 0 0 Transparent - * 1 0 Inverted color if possible, black if not. - * - * Cursors created with this function must be freed with SDL_FreeCursor(). - */ -extern DECLSPEC SDL_Cursor * SDLCALL SDL_CreateCursor - (Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); - -/** - * Set the currently active cursor to the specified one. - * If the cursor is currently visible, the change will be immediately - * represented on the display. - */ -extern DECLSPEC void SDLCALL SDL_SetCursor(SDL_Cursor *cursor); - -/** - * Returns the currently active cursor. - */ -extern DECLSPEC SDL_Cursor * SDLCALL SDL_GetCursor(void); - -/** - * Deallocates a cursor created with SDL_CreateCursor(). - */ -extern DECLSPEC void SDLCALL SDL_FreeCursor(SDL_Cursor *cursor); - -/** - * Toggle whether or not the cursor is shown on the screen. - * The cursor start off displayed, but can be turned off. - * SDL_ShowCursor() returns 1 if the cursor was being displayed - * before the call, or 0 if it was not. You can query the current - * state by passing a 'toggle' value of -1. - */ -extern DECLSPEC int SDLCALL SDL_ShowCursor(int toggle); - -/*@{*/ -/** Used as a mask when testing buttons in buttonstate - * Button 1: Left mouse button - * Button 2: Middle mouse button - * Button 3: Right mouse button - * Button 4: Mouse wheel up (may also be a real button) - * Button 5: Mouse wheel down (may also be a real button) - */ -#define SDL_BUTTON(X) (1 << ((X)-1)) -#define SDL_BUTTON_LEFT 1 -#define SDL_BUTTON_MIDDLE 2 -#define SDL_BUTTON_RIGHT 3 -#define SDL_BUTTON_WHEELUP 4 -#define SDL_BUTTON_WHEELDOWN 5 -#define SDL_BUTTON_X1 6 -#define SDL_BUTTON_X2 7 -#define SDL_BUTTON_LMASK SDL_BUTTON(SDL_BUTTON_LEFT) -#define SDL_BUTTON_MMASK SDL_BUTTON(SDL_BUTTON_MIDDLE) -#define SDL_BUTTON_RMASK SDL_BUTTON(SDL_BUTTON_RIGHT) -#define SDL_BUTTON_X1MASK SDL_BUTTON(SDL_BUTTON_X1) -#define SDL_BUTTON_X2MASK SDL_BUTTON(SDL_BUTTON_X2) -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_mouse_h */ diff --git a/codemp/rd-rend2/SDL/SDL_mutex.h b/codemp/rd-rend2/SDL/SDL_mutex.h deleted file mode 100644 index c8da9b1a00..0000000000 --- a/codemp/rd-rend2/SDL/SDL_mutex.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_mutex_h -#define _SDL_mutex_h - -/** @file SDL_mutex.h - * Functions to provide thread synchronization primitives - * - * @note These are independent of the other SDL routines. - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** Synchronization functions which can time out return this value - * if they time out. - */ -#define SDL_MUTEX_TIMEDOUT 1 - -/** This is the timeout value which corresponds to never time out */ -#define SDL_MUTEX_MAXWAIT (~(Uint32)0) - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name Mutex functions */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/** The SDL mutex structure, defined in SDL_mutex.c */ -struct SDL_mutex; -typedef struct SDL_mutex SDL_mutex; - -/** Create a mutex, initialized unlocked */ -extern DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void); - -#define SDL_LockMutex(m) SDL_mutexP(m) -/** Lock the mutex - * @return 0, or -1 on error - */ -extern DECLSPEC int SDLCALL SDL_mutexP(SDL_mutex *mutex); - -#define SDL_UnlockMutex(m) SDL_mutexV(m) -/** Unlock the mutex - * @return 0, or -1 on error - * - * It is an error to unlock a mutex that has not been locked by - * the current thread, and doing so results in undefined behavior. - */ -extern DECLSPEC int SDLCALL SDL_mutexV(SDL_mutex *mutex); - -/** Destroy a mutex */ -extern DECLSPEC void SDLCALL SDL_DestroyMutex(SDL_mutex *mutex); - -/*@}*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name Semaphore functions */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/** The SDL semaphore structure, defined in SDL_sem.c */ -struct SDL_semaphore; -typedef struct SDL_semaphore SDL_sem; - -/** Create a semaphore, initialized with value, returns NULL on failure. */ -extern DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value); - -/** Destroy a semaphore */ -extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem); - -/** - * This function suspends the calling thread until the semaphore pointed - * to by sem has a positive count. It then atomically decreases the semaphore - * count. - */ -extern DECLSPEC int SDLCALL SDL_SemWait(SDL_sem *sem); - -/** Non-blocking variant of SDL_SemWait(). - * @return 0 if the wait succeeds, - * SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem *sem); - -/** Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if - * the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in - * the allotted time, and -1 on error. - * - * On some platforms this function is implemented by looping with a delay - * of 1 ms, and so should be avoided if possible. - */ -extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms); - -/** Atomically increases the semaphore's count (not blocking). - * @return 0, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_SemPost(SDL_sem *sem); - -/** Returns the current count of the semaphore */ -extern DECLSPEC Uint32 SDLCALL SDL_SemValue(SDL_sem *sem); - -/*@}*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name Condition_variable_functions */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*@{*/ -/** The SDL condition variable structure, defined in SDL_cond.c */ -struct SDL_cond; -typedef struct SDL_cond SDL_cond; -/*@}*/ - -/** Create a condition variable */ -extern DECLSPEC SDL_cond * SDLCALL SDL_CreateCond(void); - -/** Destroy a condition variable */ -extern DECLSPEC void SDLCALL SDL_DestroyCond(SDL_cond *cond); - -/** Restart one of the threads that are waiting on the condition variable, - * @return 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond *cond); - -/** Restart all threads that are waiting on the condition variable, - * @return 0 or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond *cond); - -/** Wait on the condition variable, unlocking the provided mutex. - * The mutex must be locked before entering this function! - * The mutex is re-locked once the condition variable is signaled. - * @return 0 when it is signaled, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_CondWait(SDL_cond *cond, SDL_mutex *mut); - -/** Waits for at most 'ms' milliseconds, and returns 0 if the condition - * variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not - * signaled in the allotted time, and -1 on error. - * On some platforms this function is implemented by looping with a delay - * of 1 ms, and so should be avoided if possible. - */ -extern DECLSPEC int SDLCALL SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms); - -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_mutex_h */ - diff --git a/codemp/rd-rend2/SDL/SDL_name.h b/codemp/rd-rend2/SDL/SDL_name.h deleted file mode 100644 index 511619af56..0000000000 --- a/codemp/rd-rend2/SDL/SDL_name.h +++ /dev/null @@ -1,11 +0,0 @@ - -#ifndef _SDLname_h_ -#define _SDLname_h_ - -#if defined(__STDC__) || defined(__cplusplus) -#define NeedFunctionPrototypes 1 -#endif - -#define SDL_NAME(X) SDL_##X - -#endif /* _SDLname_h_ */ diff --git a/codemp/rd-rend2/SDL/SDL_opengl.h b/codemp/rd-rend2/SDL/SDL_opengl.h deleted file mode 100644 index 3d791d69b3..0000000000 --- a/codemp/rd-rend2/SDL/SDL_opengl.h +++ /dev/null @@ -1,6570 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_opengl.h - * This is a simple file to encapsulate the OpenGL API headers - */ - -#include "SDL_config.h" - -#ifdef __WIN32__ -#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX -#define NOMINMAX /* Don't defined min() and max() */ -#endif -#include -#endif -#ifndef NO_SDL_GLEXT -#define __glext_h_ /* Don't let gl.h include glext.h */ -#endif -#if defined(__MACOSX__) -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#elif defined(__MACOS__) -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#else -#include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ -#endif -#ifndef NO_SDL_GLEXT -#undef __glext_h_ -#endif - -/** @name GLext.h - * This file taken from "GLext.h" from the Jeff Molofee OpenGL tutorials. - * It is included here because glext.h is not available on some systems. - * If you don't want this version included, simply define "NO_SDL_GLEXT" - */ -/*@{*/ -#ifndef NO_SDL_GLEXT -#if !defined(__glext_h_) && !defined(GL_GLEXT_LEGACY) -#define __glext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.1 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: This software was created using the -** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has -** not been independently verified as being compliant with the OpenGL(R) -** version 1.2.1 Specification. -*/ - -#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) -#define WIN32_LEAN_AND_MEAN 1 -#include -#endif - -#ifndef APIENTRY -#define APIENTRY -#endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * -#endif -#ifndef GLAPI -#define GLAPI extern -#endif - -/*************************************************************/ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated 2005/06/20 */ -/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */ -#define GL_GLEXT_VERSION 29 - -#ifndef GL_VERSION_1_2 -#define GL_UNSIGNED_BYTE_3_3_2 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2 0x8036 -#define GL_RESCALE_NORMAL 0x803A -#define GL_TEXTURE_BINDING_3D 0x806A -#define GL_PACK_SKIP_IMAGES 0x806B -#define GL_PACK_IMAGE_HEIGHT 0x806C -#define GL_UNPACK_SKIP_IMAGES 0x806D -#define GL_UNPACK_IMAGE_HEIGHT 0x806E -#define GL_TEXTURE_3D 0x806F -#define GL_PROXY_TEXTURE_3D 0x8070 -#define GL_TEXTURE_DEPTH 0x8071 -#define GL_TEXTURE_WRAP_R 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE 0x8073 -#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 -#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 -#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 -#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 -#define GL_BGR 0x80E0 -#define GL_BGRA 0x80E1 -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_TEXTURE_MIN_LOD 0x813A -#define GL_TEXTURE_MAX_LOD 0x813B -#define GL_TEXTURE_BASE_LEVEL 0x813C -#define GL_TEXTURE_MAX_LEVEL 0x813D -#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 -#define GL_SINGLE_COLOR 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR 0x81FA -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif - -#ifndef GL_VERSION_1_3 -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB -#define GL_MULTISAMPLE_BIT 0x20000000 -#define GL_NORMAL_MAP 0x8511 -#define GL_REFLECTION_MAP 0x8512 -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C -#define GL_COMPRESSED_ALPHA 0x84E9 -#define GL_COMPRESSED_LUMINANCE 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB -#define GL_COMPRESSED_INTENSITY 0x84EC -#define GL_COMPRESSED_RGB 0x84ED -#define GL_COMPRESSED_RGBA 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 -#define GL_TEXTURE_COMPRESSED 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 -#define GL_CLAMP_TO_BORDER 0x812D -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_SOURCE0_RGB 0x8580 -#define GL_SOURCE1_RGB 0x8581 -#define GL_SOURCE2_RGB 0x8582 -#define GL_SOURCE0_ALPHA 0x8588 -#define GL_SOURCE1_ALPHA 0x8589 -#define GL_SOURCE2_ALPHA 0x858A -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_SUBTRACT 0x84E7 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF -#endif - -#ifndef GL_VERSION_1_4 -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_GENERATE_MIPMAP 0x8191 -#define GL_GENERATE_MIPMAP_HINT 0x8192 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_DEPTH_COMPONENT24 0x81A6 -#define GL_DEPTH_COMPONENT32 0x81A7 -#define GL_MIRRORED_REPEAT 0x8370 -#define GL_FOG_COORDINATE_SOURCE 0x8450 -#define GL_FOG_COORDINATE 0x8451 -#define GL_FRAGMENT_DEPTH 0x8452 -#define GL_CURRENT_FOG_COORDINATE 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 -#define GL_FOG_COORDINATE_ARRAY 0x8457 -#define GL_COLOR_SUM 0x8458 -#define GL_CURRENT_SECONDARY_COLOR 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D -#define GL_SECONDARY_COLOR_ARRAY 0x845E -#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD -#define GL_TEXTURE_FILTER_CONTROL 0x8500 -#define GL_TEXTURE_LOD_BIAS 0x8501 -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 -#define GL_TEXTURE_DEPTH_SIZE 0x884A -#define GL_DEPTH_TEXTURE_MODE 0x884B -#define GL_TEXTURE_COMPARE_MODE 0x884C -#define GL_TEXTURE_COMPARE_FUNC 0x884D -#define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE -#define GL_FOG_COORD GL_FOG_COORDINATE -#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE -#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE -#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE -#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER -#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING -#define GL_SRC0_RGB GL_SOURCE0_RGB -#define GL_SRC1_RGB GL_SOURCE1_RGB -#define GL_SRC2_RGB GL_SOURCE2_RGB -#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA -#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA -#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_POINT_SPRITE 0x8861 -#define GL_COORD_REPLACE 0x8862 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_MAX_TEXTURE_COORDS 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A -#define GL_MAX_VARYING_FLOATS 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_SHADER_TYPE 0x8B4F -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_1D 0x8B5D -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_3D 0x8B5F -#define GL_SAMPLER_CUBE 0x8B60 -#define GL_SAMPLER_1D_SHADOW 0x8B61 -#define GL_SAMPLER_2D_SHADOW 0x8B62 -#define GL_DELETE_STATUS 0x8B80 -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D -#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 -#define GL_LOWER_LEFT 0x8CA1 -#define GL_UPPER_LEFT 0x8CA2 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_FfdMaskSGIX -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_SGIX_impact_pixel_texture -#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 -#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 -#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 -#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 -#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 -#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 -#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_FOG_SCALE_SGIX 0x81FC -#define GL_FOG_SCALE_VALUE_SGIX 0x81FD -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT GL_MODELVIEW -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_SGI_depth_pass_instrument -#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 -#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 -#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV -#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV -#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; /* native character */ -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -#ifdef __APPLE__ -typedef long GLintptr; -typedef long GLsizeiptr; -#else -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -#ifdef __APPLE__ -typedef long GLintptrARB; -typedef long GLsizeiptrARB; -#else -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for handling shader object handles and program/shader text */ -typedef char GLcharARB; /* native character */ -#if defined(__APPLE__) -typedef void *GLhandleARB; /* shader object handle */ -#else -typedef unsigned int GLhandleARB; /* shader object handle */ -#endif -#endif - -/* GL types for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); -GLAPI void APIENTRY glBlendEquation (GLenum); -GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogram (GLenum); -GLAPI void APIENTRY glResetMinmax (GLenum); -GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum); -GLAPI void APIENTRY glClientActiveTexture (GLenum); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); -GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glFogCoordf (GLfloat); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *); -GLAPI void APIENTRY glFogCoordd (GLdouble); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); -GLAPI void APIENTRY glPointParameteri (GLenum, GLint); -GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); -GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos2i (GLint, GLint); -GLAPI void APIENTRY glWindowPos2iv (const GLint *); -GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *); -GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); -GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); -GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3iv (const GLint *); -GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQuery (GLuint); -GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); -GLAPI void APIENTRY glEndQuery (GLenum); -GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); -GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint); -GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); -GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); -GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); -GLAPI void APIENTRY glAttachShader (GLuint, GLuint); -GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); -GLAPI void APIENTRY glCompileShader (GLuint); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum); -GLAPI void APIENTRY glDeleteProgram (GLuint); -GLAPI void APIENTRY glDeleteShader (GLuint); -GLAPI void APIENTRY glDetachShader (GLuint, GLuint); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); -GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); -GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); -GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgram (GLuint); -GLAPI GLboolean APIENTRY glIsShader (GLuint); -GLAPI void APIENTRY glLinkProgram (GLuint); -GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); -GLAPI void APIENTRY glUseProgram (GLuint); -GLAPI void APIENTRY glUniform1f (GLint, GLfloat); -GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1i (GLint, GLint); -GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glValidateProgram (GLuint); -GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); -GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); -GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); -GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); -GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); -GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexBlendARB (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); -GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); -GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); -GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); -GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); -GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); -GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); -GLAPI void APIENTRY glEndQueryARB (GLenum); -GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB); -GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); -GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glUniform1iARB (GLint, GLint); -GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); -GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); -GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); -GLAPI void APIENTRY glResetHistogramEXT (GLenum); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_EXT_color_matrix -#define GL_EXT_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); -GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint); -GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); -GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); -GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIX_texture_select -#define GL_SGIX_texture_select 1 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); -GLAPI void APIENTRY glDeformSGIX (GLbitfield); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); -GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); -GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); -GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum); -GLAPI void APIENTRY glTextureLightEXT (GLenum); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); -GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); -GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); -GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); -GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *); -GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); -GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); -GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); -GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 -#endif - -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); -#endif - -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); -#endif - -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif - -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif - -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif - -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif - -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); -#endif - -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif - -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif - -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif - -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); -GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif - -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 -#endif - -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif - -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif - -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); -GLAPI void APIENTRY glSamplePatternEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif - -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif - -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 -#endif - -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); -GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFinishFenceNV (GLuint); -GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); -GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); -GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 -#endif - -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 -#endif - -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); -GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); -GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); -GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif - -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 -#endif - -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif - -#ifndef GL_OML_resample -#define GL_OML_resample 1 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); -GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); -GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); -GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); -GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); -GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); -GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); -GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); -GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); -GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); -GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); -GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); -GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); -GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); -GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); -GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); -GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); -GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); -GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); -GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif - -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif - -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif - -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); -GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif - -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif - -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif - -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif - -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 -#endif - -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif - -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif - -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif - -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif - -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif - -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 -#endif - -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 -#endif - -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); -#endif - -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - - -#ifdef __cplusplus -} -#endif - -#endif -#endif /* NO_SDL_GLEXT */ -/*@}*/ diff --git a/codemp/rd-rend2/SDL/SDL_platform.h b/codemp/rd-rend2/SDL/SDL_platform.h deleted file mode 100644 index 48540a85d4..0000000000 --- a/codemp/rd-rend2/SDL/SDL_platform.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_platform.h - * Try to get a standard set of platform defines - */ - -#ifndef _SDL_platform_h -#define _SDL_platform_h - -#if defined(_AIX) -#undef __AIX__ -#define __AIX__ 1 -#endif -#if defined(__BEOS__) -#undef __BEOS__ -#define __BEOS__ 1 -#endif -#if defined(__HAIKU__) -#undef __HAIKU__ -#define __HAIKU__ 1 -#endif -#if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) -#undef __BSDI__ -#define __BSDI__ 1 -#endif -#if defined(_arch_dreamcast) -#undef __DREAMCAST__ -#define __DREAMCAST__ 1 -#endif -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) -#undef __FREEBSD__ -#define __FREEBSD__ 1 -#endif -#if defined(__HAIKU__) -#undef __HAIKU__ -#define __HAIKU__ 1 -#endif -#if defined(hpux) || defined(__hpux) || defined(__hpux__) -#undef __HPUX__ -#define __HPUX__ 1 -#endif -#if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) -#undef __IRIX__ -#define __IRIX__ 1 -#endif -#if defined(linux) || defined(__linux) || defined(__linux__) -#undef __LINUX__ -#define __LINUX__ 1 -#endif -#if defined(__APPLE__) -#undef __MACOSX__ -#define __MACOSX__ 1 -#elif defined(macintosh) -#undef __MACOS__ -#define __MACOS__ 1 -#endif -#if defined(__NetBSD__) -#undef __NETBSD__ -#define __NETBSD__ 1 -#endif -#if defined(__OpenBSD__) -#undef __OPENBSD__ -#define __OPENBSD__ 1 -#endif -#if defined(__OS2__) -#undef __OS2__ -#define __OS2__ 1 -#endif -#if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) -#undef __OSF__ -#define __OSF__ 1 -#endif -#if defined(__QNXNTO__) -#undef __QNXNTO__ -#define __QNXNTO__ 1 -#endif -#if defined(riscos) || defined(__riscos) || defined(__riscos__) -#undef __RISCOS__ -#define __RISCOS__ 1 -#endif -#if defined(__SVR4) -#undef __SOLARIS__ -#define __SOLARIS__ 1 -#endif -#if defined(WIN32) || defined(_WIN32) -#undef __WIN32__ -#define __WIN32__ 1 -#endif - -#endif /* _SDL_platform_h */ diff --git a/codemp/rd-rend2/SDL/SDL_quit.h b/codemp/rd-rend2/SDL/SDL_quit.h deleted file mode 100644 index abd2ec6c94..0000000000 --- a/codemp/rd-rend2/SDL/SDL_quit.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_quit.h - * Include file for SDL quit event handling - */ - -#ifndef _SDL_quit_h -#define _SDL_quit_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/** @file SDL_quit.h - * An SDL_QUITEVENT is generated when the user tries to close the application - * window. If it is ignored or filtered out, the window will remain open. - * If it is not ignored or filtered, it is queued normally and the window - * is allowed to close. When the window is closed, screen updates will - * complete, but have no effect. - * - * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) - * and SIGTERM (system termination request), if handlers do not already - * exist, that generate SDL_QUITEVENT events as well. There is no way - * to determine the cause of an SDL_QUITEVENT, but setting a signal - * handler in your application will override the default generation of - * quit events for that signal. - */ - -/** @file SDL_quit.h - * There are no functions directly affecting the quit event - */ - -#define SDL_QuitRequested() \ - (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) - -#endif /* _SDL_quit_h */ diff --git a/codemp/rd-rend2/SDL/SDL_rwops.h b/codemp/rd-rend2/SDL/SDL_rwops.h deleted file mode 100644 index 98361d7e19..0000000000 --- a/codemp/rd-rend2/SDL/SDL_rwops.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_rwops.h - * This file provides a general interface for SDL to read and write - * data sources. It can easily be extended to files, memory, etc. - */ - -#ifndef _SDL_rwops_h -#define _SDL_rwops_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the read/write operation structure -- very basic */ - -typedef struct SDL_RWops { - /** Seek to 'offset' relative to whence, one of stdio's whence values: - * SEEK_SET, SEEK_CUR, SEEK_END - * Returns the final offset in the data source. - */ - int (SDLCALL *seek)(struct SDL_RWops *context, int offset, int whence); - - /** Read up to 'maxnum' objects each of size 'size' from the data - * source to the area pointed at by 'ptr'. - * Returns the number of objects read, or -1 if the read failed. - */ - int (SDLCALL *read)(struct SDL_RWops *context, void *ptr, int size, int maxnum); - - /** Write exactly 'num' objects each of size 'objsize' from the area - * pointed at by 'ptr' to data source. - * Returns 'num', or -1 if the write failed. - */ - int (SDLCALL *write)(struct SDL_RWops *context, const void *ptr, int size, int num); - - /** Close and free an allocated SDL_FSops structure */ - int (SDLCALL *close)(struct SDL_RWops *context); - - Uint32 type; - union { -#if defined(__WIN32__) && !defined(__SYMBIAN32__) - struct { - int append; - void *h; - struct { - void *data; - int size; - int left; - } buffer; - } win32io; -#endif -#ifdef HAVE_STDIO_H - struct { - int autoclose; - FILE *fp; - } stdio; -#endif - struct { - Uint8 *base; - Uint8 *here; - Uint8 *stop; - } mem; - struct { - void *data1; - } unknown; - } hidden; - -} SDL_RWops; - - -/** @name Functions to create SDL_RWops structures from various data sources */ -/*@{*/ - -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFile(const char *file, const char *mode); - -#ifdef HAVE_STDIO_H -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromFP(FILE *fp, int autoclose); -#endif - -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromMem(void *mem, int size); -extern DECLSPEC SDL_RWops * SDLCALL SDL_RWFromConstMem(const void *mem, int size); - -extern DECLSPEC SDL_RWops * SDLCALL SDL_AllocRW(void); -extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area); - -/*@}*/ - -/** @name Seek Reference Points */ -/*@{*/ -#define RW_SEEK_SET 0 /**< Seek from the beginning of data */ -#define RW_SEEK_CUR 1 /**< Seek relative to current read point */ -#define RW_SEEK_END 2 /**< Seek relative to the end of data */ -/*@}*/ - -/** @name Macros to easily read and write from an SDL_RWops structure */ -/*@{*/ -#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence) -#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR) -#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n) -#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n) -#define SDL_RWclose(ctx) (ctx)->close(ctx) -/*@}*/ - -/** @name Read an item of the specified endianness and return in native format */ -/*@{*/ -extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops *src); -extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops *src); -extern DECLSPEC Uint32 SDLCALL SDL_ReadBE32(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadLE64(SDL_RWops *src); -extern DECLSPEC Uint64 SDLCALL SDL_ReadBE64(SDL_RWops *src); -/*@}*/ - -/** @name Write an item of native format to the specified endianness */ -/*@{*/ -extern DECLSPEC int SDLCALL SDL_WriteLE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteBE16(SDL_RWops *dst, Uint16 value); -extern DECLSPEC int SDLCALL SDL_WriteLE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteBE32(SDL_RWops *dst, Uint32 value); -extern DECLSPEC int SDLCALL SDL_WriteLE64(SDL_RWops *dst, Uint64 value); -extern DECLSPEC int SDLCALL SDL_WriteBE64(SDL_RWops *dst, Uint64 value); -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_rwops_h */ diff --git a/codemp/rd-rend2/SDL/SDL_stdinc.h b/codemp/rd-rend2/SDL/SDL_stdinc.h deleted file mode 100644 index 35a4fdde59..0000000000 --- a/codemp/rd-rend2/SDL/SDL_stdinc.h +++ /dev/null @@ -1,620 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_stdinc.h - * This is a general header that includes C language support - */ - -#ifndef _SDL_stdinc_h -#define _SDL_stdinc_h - -#include "SDL_config.h" - - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#ifdef HAVE_STDIO_H -#include -#endif -#if defined(STDC_HEADERS) -# include -# include -# include -#else -# if defined(HAVE_STDLIB_H) -# include -# elif defined(HAVE_MALLOC_H) -# include -# endif -# if defined(HAVE_STDDEF_H) -# include -# endif -# if defined(HAVE_STDARG_H) -# include -# endif -#endif -#ifdef HAVE_STRING_H -# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H) -# include -# endif -# include -#endif -#ifdef HAVE_STRINGS_H -# include -#endif -#if defined(HAVE_INTTYPES_H) -# include -#elif defined(HAVE_STDINT_H) -# include -#endif -#ifdef HAVE_CTYPE_H -# include -#endif -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -# include -#endif - -/** The number of elements in an array */ -#define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) -#define SDL_TABLESIZE(table) SDL_arraysize(table) - -/* Use proper C++ casts when compiled as C++ to be compatible with the option - -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */ -#ifdef __cplusplus -#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) -#define SDL_static_cast(type, expression) static_cast(expression) -#else -#define SDL_reinterpret_cast(type, expression) ((type)(expression)) -#define SDL_static_cast(type, expression) ((type)(expression)) -#endif - -/** @name Basic data types */ -/*@{*/ -typedef enum { - SDL_FALSE = 0, - SDL_TRUE = 1 -} SDL_bool; - -typedef int8_t Sint8; -typedef uint8_t Uint8; -typedef int16_t Sint16; -typedef uint16_t Uint16; -typedef int32_t Sint32; -typedef uint32_t Uint32; - -#ifdef SDL_HAS_64BIT_TYPE -typedef int64_t Sint64; -#ifndef SYMBIAN32_GCCE -typedef uint64_t Uint64; -#endif -#else -/* This is really just a hack to prevent the compiler from complaining */ -typedef struct { - Uint32 hi; - Uint32 lo; -} Uint64, Sint64; -#endif - -/*@}*/ - -/** @name Make sure the types really have the right sizes */ -/*@{*/ -#define SDL_COMPILE_TIME_ASSERT(name, x) \ - typedef int SDL_dummy_ ## name[(x) * 2 - 1] - -SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1); -SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1); -SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); -SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); -SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); -SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); -SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); -SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); -/*@}*/ - -/** @name Enum Size Check - * Check to make sure enums are the size of ints, for structure packing. - * For both Watcom C/C++ and Borland C/C++ the compiler option that makes - * enums having the size of an int must be enabled. - * This is "-b" for Borland C/C++ and "-ei" for Watcom C/C++ (v11). - */ -/* Enable enums always int in CodeWarrior (for MPW use "-enum int") */ -#ifdef __MWERKS__ -#pragma enumsalwaysint on -#endif - -typedef enum { - DUMMY_ENUM_VALUE -} SDL_DUMMY_ENUM; - -#ifndef __NDS__ -SDL_COMPILE_TIME_ASSERT(enum, sizeof(SDL_DUMMY_ENUM) == sizeof(int)); -#endif -/*@}*/ - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef HAVE_MALLOC -#define SDL_malloc malloc -#else -extern DECLSPEC void * SDLCALL SDL_malloc(size_t size); -#endif - -#ifdef HAVE_CALLOC -#define SDL_calloc calloc -#else -extern DECLSPEC void * SDLCALL SDL_calloc(size_t nmemb, size_t size); -#endif - -#ifdef HAVE_REALLOC -#define SDL_realloc realloc -#else -extern DECLSPEC void * SDLCALL SDL_realloc(void *mem, size_t size); -#endif - -#ifdef HAVE_FREE -#define SDL_free free -#else -extern DECLSPEC void SDLCALL SDL_free(void *mem); -#endif - -#if defined(HAVE_ALLOCA) && !defined(alloca) -# if defined(HAVE_ALLOCA_H) -# include -# elif defined(__GNUC__) -# define alloca __builtin_alloca -# elif defined(_MSC_VER) -# include -# define alloca _alloca -# elif defined(__WATCOMC__) -# include -# elif defined(__BORLANDC__) -# include -# elif defined(__DMC__) -# include -# elif defined(__AIX__) - #pragma alloca -# elif defined(__MRC__) - void *alloca (unsigned); -# else - char *alloca (); -# endif -#endif -#ifdef HAVE_ALLOCA -#define SDL_stack_alloc(type, count) (type*)alloca(sizeof(type)*(count)) -#define SDL_stack_free(data) -#else -#define SDL_stack_alloc(type, count) (type*)SDL_malloc(sizeof(type)*(count)) -#define SDL_stack_free(data) SDL_free(data) -#endif - -#ifdef HAVE_GETENV -#define SDL_getenv getenv -#else -extern DECLSPEC char * SDLCALL SDL_getenv(const char *name); -#endif - -#ifdef HAVE_PUTENV -#define SDL_putenv putenv -#else -extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); -#endif - -#ifdef HAVE_QSORT -#define SDL_qsort qsort -#else -extern DECLSPEC void SDLCALL SDL_qsort(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)); -#endif - -#ifdef HAVE_ABS -#define SDL_abs abs -#else -#define SDL_abs(X) ((X) < 0 ? -(X) : (X)) -#endif - -#define SDL_min(x, y) (((x) < (y)) ? (x) : (y)) -#define SDL_max(x, y) (((x) > (y)) ? (x) : (y)) - -#ifdef HAVE_CTYPE_H -#define SDL_isdigit(X) isdigit(X) -#define SDL_isspace(X) isspace(X) -#define SDL_toupper(X) toupper(X) -#define SDL_tolower(X) tolower(X) -#else -#define SDL_isdigit(X) (((X) >= '0') && ((X) <= '9')) -#define SDL_isspace(X) (((X) == ' ') || ((X) == '\t') || ((X) == '\r') || ((X) == '\n')) -#define SDL_toupper(X) (((X) >= 'a') && ((X) <= 'z') ? ('A'+((X)-'a')) : (X)) -#define SDL_tolower(X) (((X) >= 'A') && ((X) <= 'Z') ? ('a'+((X)-'A')) : (X)) -#endif - -#ifdef HAVE_MEMSET -#define SDL_memset memset -#else -extern DECLSPEC void * SDLCALL SDL_memset(void *dst, int c, size_t len); -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_memset4(dst, val, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; stosl\n\t" \ - : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ - : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memset4 -#define SDL_memset4(dst, val, len) \ -do { \ - unsigned _count = (len); \ - unsigned _n = (_count + 3) / 4; \ - Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ - Uint32 _val = (val); \ - if (len == 0) break; \ - switch (_count % 4) { \ - case 0: do { *_p++ = _val; \ - case 3: *_p++ = _val; \ - case 2: *_p++ = _val; \ - case 1: *_p++ = _val; \ - } while ( --_n ); \ - } \ -} while(0) -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl\n\t" \ - "testb $2,%b4\n\t" \ - "je 1f\n\t" \ - "movsw\n" \ - "1:\ttestb $1,%b4\n\t" \ - "je 2f\n\t" \ - "movsb\n" \ - "2:" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy -#ifdef HAVE_MEMCPY -#define SDL_memcpy memcpy -#elif defined(HAVE_BCOPY) -#define SDL_memcpy(d, s, n) bcopy((s), (d), (n)) -#else -extern DECLSPEC void * SDLCALL SDL_memcpy(void *dst, const void *src, size_t len); -#endif -#endif - -/* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) -#elif defined(__GNUC__) && defined(i386) -#define SDL_memcpy4(dst, src, len) \ -do { \ - int ecx, edi, esi; \ - __asm__ __volatile__ ( \ - "cld\n\t" \ - "rep ; movsl" \ - : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ - : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ - : "memory" ); \ -} while(0) -#endif -#ifndef SDL_memcpy4 -#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_revcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - char *dstp = SDL_static_cast(char *, dst); \ - char *srcp = SDL_static_cast(char *, src); \ - int n = (len); \ - if ( n >= 4 ) { \ - __asm__ __volatile__ ( \ - "std\n\t" \ - "rep ; movsl\n\t" \ - "cld\n\t" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (n >> 2), \ - "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ - : "memory" ); \ - } \ - switch (n & 3) { \ - case 3: dstp[2] = srcp[2]; \ - case 2: dstp[1] = srcp[1]; \ - case 1: dstp[0] = srcp[0]; \ - break; \ - default: \ - break; \ - } \ -} while(0) -#endif -#ifndef SDL_revcpy -extern DECLSPEC void * SDLCALL SDL_revcpy(void *dst, const void *src, size_t len); -#endif - -#ifdef HAVE_MEMMOVE -#define SDL_memmove memmove -#elif defined(HAVE_BCOPY) -#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) -#else -#define SDL_memmove(dst, src, len) \ -do { \ - if ( dst < src ) { \ - SDL_memcpy(dst, src, len); \ - } else { \ - SDL_revcpy(dst, src, len); \ - } \ -} while(0) -#endif - -#ifdef HAVE_MEMCMP -#define SDL_memcmp memcmp -#else -extern DECLSPEC int SDLCALL SDL_memcmp(const void *s1, const void *s2, size_t len); -#endif - -#ifdef HAVE_STRLEN -#define SDL_strlen strlen -#else -extern DECLSPEC size_t SDLCALL SDL_strlen(const char *string); -#endif - -#ifdef HAVE_STRLCPY -#define SDL_strlcpy strlcpy -#else -extern DECLSPEC size_t SDLCALL SDL_strlcpy(char *dst, const char *src, size_t maxlen); -#endif - -#ifdef HAVE_STRLCAT -#define SDL_strlcat strlcat -#else -extern DECLSPEC size_t SDLCALL SDL_strlcat(char *dst, const char *src, size_t maxlen); -#endif - -#ifdef HAVE_STRDUP -#define SDL_strdup strdup -#else -extern DECLSPEC char * SDLCALL SDL_strdup(const char *string); -#endif - -#ifdef HAVE__STRREV -#define SDL_strrev _strrev -#else -extern DECLSPEC char * SDLCALL SDL_strrev(char *string); -#endif - -#ifdef HAVE__STRUPR -#define SDL_strupr _strupr -#else -extern DECLSPEC char * SDLCALL SDL_strupr(char *string); -#endif - -#ifdef HAVE__STRLWR -#define SDL_strlwr _strlwr -#else -extern DECLSPEC char * SDLCALL SDL_strlwr(char *string); -#endif - -#ifdef HAVE_STRCHR -#define SDL_strchr strchr -#elif defined(HAVE_INDEX) -#define SDL_strchr index -#else -extern DECLSPEC char * SDLCALL SDL_strchr(const char *string, int c); -#endif - -#ifdef HAVE_STRRCHR -#define SDL_strrchr strrchr -#elif defined(HAVE_RINDEX) -#define SDL_strrchr rindex -#else -extern DECLSPEC char * SDLCALL SDL_strrchr(const char *string, int c); -#endif - -#ifdef HAVE_STRSTR -#define SDL_strstr strstr -#else -extern DECLSPEC char * SDLCALL SDL_strstr(const char *haystack, const char *needle); -#endif - -#ifdef HAVE_ITOA -#define SDL_itoa itoa -#else -#define SDL_itoa(value, string, radix) SDL_ltoa((long)value, string, radix) -#endif - -#ifdef HAVE__LTOA -#define SDL_ltoa _ltoa -#else -extern DECLSPEC char * SDLCALL SDL_ltoa(long value, char *string, int radix); -#endif - -#ifdef HAVE__UITOA -#define SDL_uitoa _uitoa -#else -#define SDL_uitoa(value, string, radix) SDL_ultoa((long)value, string, radix) -#endif - -#ifdef HAVE__ULTOA -#define SDL_ultoa _ultoa -#else -extern DECLSPEC char * SDLCALL SDL_ultoa(unsigned long value, char *string, int radix); -#endif - -#ifdef HAVE_STRTOL -#define SDL_strtol strtol -#else -extern DECLSPEC long SDLCALL SDL_strtol(const char *string, char **endp, int base); -#endif - -#ifdef HAVE_STRTOUL -#define SDL_strtoul strtoul -#else -extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); -#endif - -#ifdef SDL_HAS_64BIT_TYPE - -#ifdef HAVE__I64TOA -#define SDL_lltoa _i64toa -#else -extern DECLSPEC char* SDLCALL SDL_lltoa(Sint64 value, char *string, int radix); -#endif - -#ifdef HAVE__UI64TOA -#define SDL_ulltoa _ui64toa -#else -extern DECLSPEC char* SDLCALL SDL_ulltoa(Uint64 value, char *string, int radix); -#endif - -#ifdef HAVE_STRTOLL -#define SDL_strtoll strtoll -#else -extern DECLSPEC Sint64 SDLCALL SDL_strtoll(const char *string, char **endp, int base); -#endif - -#ifdef HAVE_STRTOULL -#define SDL_strtoull strtoull -#else -extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); -#endif - -#endif /* SDL_HAS_64BIT_TYPE */ - -#ifdef HAVE_STRTOD -#define SDL_strtod strtod -#else -extern DECLSPEC double SDLCALL SDL_strtod(const char *string, char **endp); -#endif - -#ifdef HAVE_ATOI -#define SDL_atoi atoi -#else -#define SDL_atoi(X) SDL_strtol(X, NULL, 0) -#endif - -#ifdef HAVE_ATOF -#define SDL_atof atof -#else -#define SDL_atof(X) SDL_strtod(X, NULL) -#endif - -#ifdef HAVE_STRCMP -#define SDL_strcmp strcmp -#else -extern DECLSPEC int SDLCALL SDL_strcmp(const char *str1, const char *str2); -#endif - -#ifdef HAVE_STRNCMP -#define SDL_strncmp strncmp -#else -extern DECLSPEC int SDLCALL SDL_strncmp(const char *str1, const char *str2, size_t maxlen); -#endif - -#ifdef HAVE_STRCASECMP -#define SDL_strcasecmp strcasecmp -#elif defined(HAVE__STRICMP) -#define SDL_strcasecmp _stricmp -#else -extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); -#endif - -#ifdef HAVE_STRNCASECMP -#define SDL_strncasecmp strncasecmp -#elif defined(HAVE__STRNICMP) -#define SDL_strncasecmp _strnicmp -#else -extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen); -#endif - -#ifdef HAVE_SSCANF -#define SDL_sscanf sscanf -#else -extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, const char *fmt, ...); -#endif - -#ifdef HAVE_SNPRINTF -#define SDL_snprintf snprintf -#else -extern DECLSPEC int SDLCALL SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...); -#endif - -#ifdef HAVE_VSNPRINTF -#define SDL_vsnprintf vsnprintf -#else -extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); -#endif - -/** @name SDL_ICONV Error Codes - * The SDL implementation of iconv() returns these error codes - */ -/*@{*/ -#define SDL_ICONV_ERROR (size_t)-1 -#define SDL_ICONV_E2BIG (size_t)-2 -#define SDL_ICONV_EILSEQ (size_t)-3 -#define SDL_ICONV_EINVAL (size_t)-4 -/*@}*/ - -#if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -#define SDL_iconv_t iconv_t -#define SDL_iconv_open iconv_open -#define SDL_iconv_close iconv_close -#else -typedef struct _SDL_iconv_t *SDL_iconv_t; -extern DECLSPEC SDL_iconv_t SDLCALL SDL_iconv_open(const char *tocode, const char *fromcode); -extern DECLSPEC int SDLCALL SDL_iconv_close(SDL_iconv_t cd); -#endif -extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft); -/** This function converts a string between encodings in one pass, returning a - * string that must be freed with SDL_free() or NULL on error. - */ -extern DECLSPEC char * SDLCALL SDL_iconv_string(const char *tocode, const char *fromcode, const char *inbuf, size_t inbytesleft); -#define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_stdinc_h */ diff --git a/codemp/rd-rend2/SDL/SDL_syswm.h b/codemp/rd-rend2/SDL/SDL_syswm.h deleted file mode 100644 index 78433c6aa4..0000000000 --- a/codemp/rd-rend2/SDL/SDL_syswm.h +++ /dev/null @@ -1,226 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_syswm.h - * Include file for SDL custom system window manager hooks - */ - -#ifndef _SDL_syswm_h -#define _SDL_syswm_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_version.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @file SDL_syswm.h - * Your application has access to a special type of event 'SDL_SYSWMEVENT', - * which contains window-manager specific information and arrives whenever - * an unhandled window event occurs. This event is ignored by default, but - * you can enable it with SDL_EventState() - */ -#ifdef SDL_PROTOTYPES_ONLY -struct SDL_SysWMinfo; -typedef struct SDL_SysWMinfo SDL_SysWMinfo; -#else - -/* This is the structure for custom window manager events */ -#if defined(SDL_VIDEO_DRIVER_X11) -#if defined(__APPLE__) && defined(__MACH__) -/* conflicts with Quickdraw.h */ -#define Cursor X11Cursor -#endif - -#include -#include - -#if defined(__APPLE__) && defined(__MACH__) -/* matches the re-define above */ -#undef Cursor -#endif - -/** These are the various supported subsystems under UNIX */ -typedef enum { - SDL_SYSWM_X11 -} SDL_SYSWM_TYPE; - -/** The UNIX custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union { - XEvent xevent; - } event; -}; - -/** The UNIX custom window manager information structure. - * When this structure is returned, it holds information about which - * low level system it is using, and will be one of SDL_SYSWM_TYPE. - */ -typedef struct SDL_SysWMinfo { - SDL_version version; - SDL_SYSWM_TYPE subsystem; - union { - struct { - Display *display; /**< The X11 display */ - Window window; /**< The X11 display window */ - /** These locking functions should be called around - * any X11 functions using the display variable, - * but not the gfxdisplay variable. - * They lock the event thread, so should not be - * called around event functions or from event filters. - */ - /*@{*/ - void (*lock_func)(void); - void (*unlock_func)(void); - /*@}*/ - - /** @name Introduced in SDL 1.0.2 */ - /*@{*/ - Window fswindow; /**< The X11 fullscreen window */ - Window wmwindow; /**< The X11 managed input window */ - /*@}*/ - - /** @name Introduced in SDL 1.2.12 */ - /*@{*/ - Display *gfxdisplay; /**< The X11 display to which rendering is done */ - /*@}*/ - } x11; - } info; -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_NANOX) -#include - -/** The generic custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/** The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version ; - GR_WINDOW_ID window ; /* The display window */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) -#define WIN32_LEAN_AND_MEAN -#include - -/** The windows custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - HWND hwnd; /**< The window for the message */ - UINT msg; /**< The type of message */ - WPARAM wParam; /**< WORD message parameter */ - LPARAM lParam; /**< LONG message parameter */ -}; - -/** The windows custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - HWND window; /**< The Win32 display window */ - HGLRC hglrc; /**< The OpenGL context, if any */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_RISCOS) - -/** RISC OS custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int eventCode; /**< The window for the message */ - int pollBlock[64]; -}; - -/** The RISC OS custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int wimpVersion; /**< Wimp version running under */ - int taskHandle; /**< The RISC OS task handle */ - int window; /**< The RISC OS display window */ -} SDL_SysWMinfo; - -#elif defined(SDL_VIDEO_DRIVER_PHOTON) -#include -#include - -/** The QNX custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/** The QNX custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int data; -} SDL_SysWMinfo; - -#else - -/** The generic custom event structure */ -struct SDL_SysWMmsg { - SDL_version version; - int data; -}; - -/** The generic custom window manager information structure */ -typedef struct SDL_SysWMinfo { - SDL_version version; - int data; -} SDL_SysWMinfo; - -#endif /* video driver type */ - -#endif /* SDL_PROTOTYPES_ONLY */ - -/* Function prototypes */ -/** - * This function gives you custom hooks into the window manager information. - * It fills the structure pointed to by 'info' with custom information and - * returns 0 if the function is not implemented, 1 if the function is - * implemented and no error occurred, and -1 if the version member of - * the 'info' structure is not filled in or not supported. - * - * You typically use this function like this: - * @code - * SDL_SysWMinfo info; - * SDL_VERSION(&info.version); - * if ( SDL_GetWMInfo(&info) ) { ... } - * @endcode - */ -extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_syswm_h */ diff --git a/codemp/rd-rend2/SDL/SDL_thread.h b/codemp/rd-rend2/SDL/SDL_thread.h deleted file mode 100644 index 9ebe00edd5..0000000000 --- a/codemp/rd-rend2/SDL/SDL_thread.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_thread_h -#define _SDL_thread_h - -/** @file SDL_thread.h - * Header for the SDL thread management routines - * - * @note These are independent of the other SDL routines. - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -/* Thread synchronization primitives */ -#include "SDL_mutex.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** The SDL thread structure, defined in SDL_thread.c */ -struct SDL_Thread; -typedef struct SDL_Thread SDL_Thread; - -/** Create a thread */ -#if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) -/** - * We compile SDL into a DLL on OS/2. This means, that it's the DLL which - * creates a new thread for the calling process with the SDL_CreateThread() - * API. There is a problem with this, that only the RTL of the SDL.DLL will - * be initialized for those threads, and not the RTL of the calling application! - * To solve this, we make a little hack here. - * We'll always use the caller's _beginthread() and _endthread() APIs to - * start a new thread. This way, if it's the SDL.DLL which uses this API, - * then the RTL of SDL.DLL will be used to create the new thread, and if it's - * the application, then the RTL of the application will be used. - * So, in short: - * Always use the _beginthread() and _endthread() of the calling runtime library! - */ -#define SDL_PASSED_BEGINTHREAD_ENDTHREAD -#ifndef _WIN32_WCE -#include /* This has _beginthread() and _endthread() defined! */ -#endif - -#ifdef __OS2__ -typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); -typedef void (*pfnSDL_CurrentEndThread)(void); -#else -typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall *func)(void *), void *arg, - unsigned, unsigned *threadID); -typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); -#endif - -extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); - -#ifdef __OS2__ -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) -#elif defined(_WIN32_WCE) -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) -#else -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) -#endif -#else -extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); -#endif - -/** Get the 32-bit thread identifier for the current thread */ -extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); - -/** Get the 32-bit thread identifier for the specified thread, - * equivalent to SDL_ThreadID() if the specified thread is NULL. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); - -/** Wait for a thread to finish. - * The return code for the thread function is placed in the area - * pointed to by 'status', if 'status' is not NULL. - */ -extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); - -/** Forcefully kill a thread without worrying about its state */ -extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); - - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_thread_h */ diff --git a/codemp/rd-rend2/SDL/SDL_timer.h b/codemp/rd-rend2/SDL/SDL_timer.h deleted file mode 100644 index d764d5f381..0000000000 --- a/codemp/rd-rend2/SDL/SDL_timer.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#ifndef _SDL_timer_h -#define _SDL_timer_h - -/** @file SDL_timer.h - * Header for the SDL time management routines - */ - -#include "SDL_stdinc.h" -#include "SDL_error.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** This is the OS scheduler timeslice, in milliseconds */ -#define SDL_TIMESLICE 10 - -/** This is the maximum resolution of the SDL timer on all platforms */ -#define TIMER_RESOLUTION 10 /**< Experimentally determined */ - -/** - * Get the number of milliseconds since the SDL library initialization. - * Note that this value wraps if the program runs for more than ~49 days. - */ -extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); - -/** Wait a specified number of milliseconds before returning */ -extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); - -/** Function prototype for the timer callback function */ -typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); - -/** - * Set a callback to run after the specified number of milliseconds has - * elapsed. The callback function is passed the current timer interval - * and returns the next timer interval. If the returned value is the - * same as the one passed in, the periodic alarm continues, otherwise a - * new alarm is scheduled. If the callback returns 0, the periodic alarm - * is cancelled. - * - * To cancel a currently running timer, call SDL_SetTimer(0, NULL); - * - * The timer callback function may run in a different thread than your - * main code, and so shouldn't call any functions from within itself. - * - * The maximum resolution of this timer is 10 ms, which means that if - * you request a 16 ms timer, your callback will run approximately 20 ms - * later on an unloaded system. If you wanted to set a flag signaling - * a frame update at 30 frames per second (every 33 ms), you might set a - * timer for 30 ms: - * @code SDL_SetTimer((33/10)*10, flag_update); @endcode - * - * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). - * - * Under UNIX, you should not use raise or use SIGALRM and this function - * in the same program, as it is implemented using setitimer(). You also - * should not use this function in multi-threaded applications as signals - * to multi-threaded apps have undefined behavior in some implementations. - * - * This function returns 0 if successful, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); - -/** @name New timer API - * New timer API, supports multiple timers - * Written by Stephane Peter - */ -/*@{*/ - -/** - * Function prototype for the new timer callback function. - * The callback function is passed the current timer interval and returns - * the next timer interval. If the returned value is the same as the one - * passed in, the periodic alarm continues, otherwise a new alarm is - * scheduled. If the callback returns 0, the periodic alarm is cancelled. - */ -typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); - -/** Definition of the timer ID type */ -typedef struct _SDL_TimerID *SDL_TimerID; - -/** Add a new timer to the pool of timers already running. - * Returns a timer ID, or NULL when an error occurs. - */ -extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); - -/** - * Remove one of the multiple timers knowing its ID. - * Returns a boolean value indicating success. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); - -/*@}*/ - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_timer_h */ diff --git a/codemp/rd-rend2/SDL/SDL_types.h b/codemp/rd-rend2/SDL/SDL_types.h deleted file mode 100644 index 79d8b28dd0..0000000000 --- a/codemp/rd-rend2/SDL/SDL_types.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_types.h - * @deprecated Use SDL_stdinc.h instead. - */ - -/* DEPRECATED */ -#include "SDL_stdinc.h" diff --git a/codemp/rd-rend2/SDL/SDL_version.h b/codemp/rd-rend2/SDL/SDL_version.h deleted file mode 100644 index fdc17c64c9..0000000000 --- a/codemp/rd-rend2/SDL/SDL_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_version.h - * This header defines the current SDL version - */ - -#ifndef _SDL_version_h -#define _SDL_version_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @name Version Number - * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL - */ -/*@{*/ -#define SDL_MAJOR_VERSION 1 -#define SDL_MINOR_VERSION 2 -#define SDL_PATCHLEVEL 15 -/*@}*/ - -typedef struct SDL_version { - Uint8 major; - Uint8 minor; - Uint8 patch; -} SDL_version; - -/** - * This macro can be used to fill a version structure with the compile-time - * version of the SDL library. - */ -#define SDL_VERSION(X) \ -{ \ - (X)->major = SDL_MAJOR_VERSION; \ - (X)->minor = SDL_MINOR_VERSION; \ - (X)->patch = SDL_PATCHLEVEL; \ -} - -/** This macro turns the version numbers into a numeric value: - * (1,2,3) -> (1203) - * This assumes that there will never be more than 100 patchlevels - */ -#define SDL_VERSIONNUM(X, Y, Z) \ - ((X)*1000 + (Y)*100 + (Z)) - -/** This is the version number macro for the current SDL version */ -#define SDL_COMPILEDVERSION \ - SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) - -/** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ -#define SDL_VERSION_ATLEAST(X, Y, Z) \ - (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) - -/** This function gets the version of the dynamically linked SDL library. - * it should NOT be used to fill a version structure, instead you should - * use the SDL_Version() macro. - */ -extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_version_h */ diff --git a/codemp/rd-rend2/SDL/SDL_video.h b/codemp/rd-rend2/SDL/SDL_video.h deleted file mode 100644 index f9c4e07025..0000000000 --- a/codemp/rd-rend2/SDL/SDL_video.h +++ /dev/null @@ -1,951 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_video.h - * Header file for access to the SDL raw framebuffer window - */ - -#ifndef _SDL_video_h -#define _SDL_video_h - -#include "SDL_stdinc.h" -#include "SDL_error.h" -#include "SDL_rwops.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @name Transparency definitions - * These define alpha as the opacity of a surface - */ -/*@{*/ -#define SDL_ALPHA_OPAQUE 255 -#define SDL_ALPHA_TRANSPARENT 0 -/*@}*/ - -/** @name Useful data types */ -/*@{*/ -typedef struct SDL_Rect { - Sint16 x, y; - Uint16 w, h; -} SDL_Rect; - -typedef struct SDL_Color { - Uint8 r; - Uint8 g; - Uint8 b; - Uint8 unused; -} SDL_Color; -#define SDL_Colour SDL_Color - -typedef struct SDL_Palette { - int ncolors; - SDL_Color *colors; -} SDL_Palette; -/*@}*/ - -/** Everything in the pixel format structure is read-only */ -typedef struct SDL_PixelFormat { - SDL_Palette *palette; - Uint8 BitsPerPixel; - Uint8 BytesPerPixel; - Uint8 Rloss; - Uint8 Gloss; - Uint8 Bloss; - Uint8 Aloss; - Uint8 Rshift; - Uint8 Gshift; - Uint8 Bshift; - Uint8 Ashift; - Uint32 Rmask; - Uint32 Gmask; - Uint32 Bmask; - Uint32 Amask; - - /** RGB color key information */ - Uint32 colorkey; - /** Alpha value information (per-surface alpha) */ - Uint8 alpha; -} SDL_PixelFormat; - -/** This structure should be treated as read-only, except for 'pixels', - * which, if not NULL, contains the raw pixel data for the surface. - */ -typedef struct SDL_Surface { - Uint32 flags; /**< Read-only */ - SDL_PixelFormat *format; /**< Read-only */ - int w, h; /**< Read-only */ - Uint16 pitch; /**< Read-only */ - void *pixels; /**< Read-write */ - int offset; /**< Private */ - - /** Hardware-specific surface info */ - struct private_hwdata *hwdata; - - /** clipping information */ - SDL_Rect clip_rect; /**< Read-only */ - Uint32 unused1; /**< for binary compatibility */ - - /** Allow recursive locks */ - Uint32 locked; /**< Private */ - - /** info for fast blit mapping to other surfaces */ - struct SDL_BlitMap *map; /**< Private */ - - /** format version, bumped at every change to invalidate blit maps */ - unsigned int format_version; /**< Private */ - - /** Reference count -- used when freeing surface */ - int refcount; /**< Read-mostly */ -} SDL_Surface; - -/** @name SDL_Surface Flags - * These are the currently supported flags for the SDL_surface - */ -/*@{*/ - -/** Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */ -/*@{*/ -#define SDL_SWSURFACE 0x00000000 /**< Surface is in system memory */ -#define SDL_HWSURFACE 0x00000001 /**< Surface is in video memory */ -#define SDL_ASYNCBLIT 0x00000004 /**< Use asynchronous blits if possible */ -/*@}*/ - -/** Available for SDL_SetVideoMode() */ -/*@{*/ -#define SDL_ANYFORMAT 0x10000000 /**< Allow any video depth/pixel-format */ -#define SDL_HWPALETTE 0x20000000 /**< Surface has exclusive palette */ -#define SDL_DOUBLEBUF 0x40000000 /**< Set up double-buffered video mode */ -#define SDL_FULLSCREEN 0x80000000 /**< Surface is a full screen display */ -#define SDL_OPENGL 0x00000002 /**< Create an OpenGL rendering context */ -#define SDL_OPENGLBLIT 0x0000000A /**< Create an OpenGL rendering context and use it for blitting */ -#define SDL_RESIZABLE 0x00000010 /**< This video mode may be resized */ -#define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ -/*@}*/ - -/** Used internally (read-only) */ -/*@{*/ -#define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */ -#define SDL_SRCCOLORKEY 0x00001000 /**< Blit uses a source color key */ -#define SDL_RLEACCELOK 0x00002000 /**< Private flag */ -#define SDL_RLEACCEL 0x00004000 /**< Surface is RLE encoded */ -#define SDL_SRCALPHA 0x00010000 /**< Blit uses source alpha blending */ -#define SDL_PREALLOC 0x01000000 /**< Surface uses preallocated memory */ -/*@}*/ - -/*@}*/ - -/** Evaluates to true if the surface needs to be locked before access */ -#define SDL_MUSTLOCK(surface) \ - (surface->offset || \ - ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0)) - -/** typedef for private surface blitting functions */ -typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect, - struct SDL_Surface *dst, SDL_Rect *dstrect); - - -/** Useful for determining the video hardware capabilities */ -typedef struct SDL_VideoInfo { - Uint32 hw_available :1; /**< Flag: Can you create hardware surfaces? */ - Uint32 wm_available :1; /**< Flag: Can you talk to a window manager? */ - Uint32 UnusedBits1 :6; - Uint32 UnusedBits2 :1; - Uint32 blit_hw :1; /**< Flag: Accelerated blits HW --> HW */ - Uint32 blit_hw_CC :1; /**< Flag: Accelerated blits with Colorkey */ - Uint32 blit_hw_A :1; /**< Flag: Accelerated blits with Alpha */ - Uint32 blit_sw :1; /**< Flag: Accelerated blits SW --> HW */ - Uint32 blit_sw_CC :1; /**< Flag: Accelerated blits with Colorkey */ - Uint32 blit_sw_A :1; /**< Flag: Accelerated blits with Alpha */ - Uint32 blit_fill :1; /**< Flag: Accelerated color fill */ - Uint32 UnusedBits3 :16; - Uint32 video_mem; /**< The total amount of video memory (in K) */ - SDL_PixelFormat *vfmt; /**< Value: The format of the video surface */ - int current_w; /**< Value: The current video mode width */ - int current_h; /**< Value: The current video mode height */ -} SDL_VideoInfo; - - -/** @name Overlay Formats - * The most common video overlay formats. - * For an explanation of these pixel formats, see: - * http://www.webartz.com/fourcc/indexyuv.htm - * - * For information on the relationship between color spaces, see: - * http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html - */ -/*@{*/ -#define SDL_YV12_OVERLAY 0x32315659 /**< Planar mode: Y + V + U (3 planes) */ -#define SDL_IYUV_OVERLAY 0x56555949 /**< Planar mode: Y + U + V (3 planes) */ -#define SDL_YUY2_OVERLAY 0x32595559 /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ -#define SDL_UYVY_OVERLAY 0x59565955 /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ -#define SDL_YVYU_OVERLAY 0x55595659 /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ -/*@}*/ - -/** The YUV hardware video overlay */ -typedef struct SDL_Overlay { - Uint32 format; /**< Read-only */ - int w, h; /**< Read-only */ - int planes; /**< Read-only */ - Uint16 *pitches; /**< Read-only */ - Uint8 **pixels; /**< Read-write */ - - /** @name Hardware-specific surface info */ - /*@{*/ - struct private_yuvhwfuncs *hwfuncs; - struct private_yuvhwdata *hwdata; - /*@{*/ - - /** @name Special flags */ - /*@{*/ - Uint32 hw_overlay :1; /**< Flag: This overlay hardware accelerated? */ - Uint32 UnusedBits :31; - /*@}*/ -} SDL_Overlay; - - -/** Public enumeration for setting the OpenGL window attributes. */ -typedef enum { - SDL_GL_RED_SIZE, - SDL_GL_GREEN_SIZE, - SDL_GL_BLUE_SIZE, - SDL_GL_ALPHA_SIZE, - SDL_GL_BUFFER_SIZE, - SDL_GL_DOUBLEBUFFER, - SDL_GL_DEPTH_SIZE, - SDL_GL_STENCIL_SIZE, - SDL_GL_ACCUM_RED_SIZE, - SDL_GL_ACCUM_GREEN_SIZE, - SDL_GL_ACCUM_BLUE_SIZE, - SDL_GL_ACCUM_ALPHA_SIZE, - SDL_GL_STEREO, - SDL_GL_MULTISAMPLEBUFFERS, - SDL_GL_MULTISAMPLESAMPLES, - SDL_GL_ACCELERATED_VISUAL, - SDL_GL_SWAP_CONTROL -} SDL_GLattr; - -/** @name flags for SDL_SetPalette() */ -/*@{*/ -#define SDL_LOGPAL 0x01 -#define SDL_PHYSPAL 0x02 -/*@}*/ - -/* Function prototypes */ - -/** - * @name Video Init and Quit - * These functions are used internally, and should not be used unless you - * have a specific need to specify the video driver you want to use. - * You should normally use SDL_Init() or SDL_InitSubSystem(). - */ -/*@{*/ -/** - * Initializes the video subsystem. Sets up a connection - * to the window manager, etc, and determines the current video mode and - * pixel format, but does not initialize a window or graphics mode. - * Note that event handling is activated by this routine. - * - * If you use both sound and video in your application, you need to call - * SDL_Init() before opening the sound device, otherwise under Win32 DirectX, - * you won't be able to set full-screen display modes. - */ -extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, Uint32 flags); -extern DECLSPEC void SDLCALL SDL_VideoQuit(void); -/*@}*/ - -/** - * This function fills the given character buffer with the name of the - * video driver, and returns a pointer to it if the video driver has - * been initialized. It returns NULL if no driver has been initialized. - */ -extern DECLSPEC char * SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); - -/** - * This function returns a pointer to the current display surface. - * If SDL is doing format conversion on the display surface, this - * function returns the publicly visible surface, not the real video - * surface. - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_GetVideoSurface(void); - -/** - * This function returns a read-only pointer to information about the - * video hardware. If this is called before SDL_SetVideoMode(), the 'vfmt' - * member of the returned structure will contain the pixel format of the - * "best" video mode. - */ -extern DECLSPEC const SDL_VideoInfo * SDLCALL SDL_GetVideoInfo(void); - -/** - * Check to see if a particular video mode is supported. - * It returns 0 if the requested mode is not supported under any bit depth, - * or returns the bits-per-pixel of the closest available mode with the - * given width and height. If this bits-per-pixel is different from the - * one used when setting the video mode, SDL_SetVideoMode() will succeed, - * but will emulate the requested bits-per-pixel with a shadow surface. - * - * The arguments to SDL_VideoModeOK() are the same ones you would pass to - * SDL_SetVideoMode() - */ -extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags); - -/** - * Return a pointer to an array of available screen dimensions for the - * given format and video flags, sorted largest to smallest. Returns - * NULL if there are no dimensions available for a particular format, - * or (SDL_Rect **)-1 if any dimension is okay for the given format. - * - * If 'format' is NULL, the mode list will be for the format given - * by SDL_GetVideoInfo()->vfmt - */ -extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags); - -/** - * Set up a video mode with the specified width, height and bits-per-pixel. - * - * If 'bpp' is 0, it is treated as the current display bits per pixel. - * - * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the - * requested bits-per-pixel, but will return whatever video pixel format is - * available. The default is to emulate the requested pixel format if it - * is not natively available. - * - * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in - * video memory, if possible, and you may have to call SDL_LockSurface() - * in order to access the raw framebuffer. Otherwise, the video surface - * will be created in system memory. - * - * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle - * updates asynchronously, but you must always lock before accessing pixels. - * SDL will wait for updates to complete before returning from the lock. - * - * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee - * that the colors set by SDL_SetColors() will be the colors you get. - * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all - * of the colors exactly the way they are requested, and you should look - * at the video surface structure to determine the actual palette. - * If SDL cannot guarantee that the colors you request can be set, - * i.e. if the colormap is shared, then the video surface may be created - * under emulation in system memory, overriding the SDL_HWSURFACE flag. - * - * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set - * a fullscreen video mode. The default is to create a windowed mode - * if the current graphics system has a window manager. - * If the SDL library is able to set a fullscreen video mode, this flag - * will be set in the surface that is returned. - * - * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up - * two surfaces in video memory and swap between them when you call - * SDL_Flip(). This is usually slower than the normal single-buffering - * scheme, but prevents "tearing" artifacts caused by modifying video - * memory while the monitor is refreshing. It should only be used by - * applications that redraw the entire screen on every update. - * - * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the - * window manager, if any, to resize the window at runtime. When this - * occurs, SDL will send a SDL_VIDEORESIZE event to you application, - * and you must respond to the event by re-calling SDL_SetVideoMode() - * with the requested size (or another size that suits the application). - * - * If SDL_NOFRAME is set in 'flags', the SDL library will create a window - * without any title bar or frame decoration. Fullscreen video modes have - * this flag set automatically. - * - * This function returns the video framebuffer surface, or NULL if it fails. - * - * If you rely on functionality provided by certain video flags, check the - * flags of the returned surface to make sure that functionality is available. - * SDL will fall back to reduced functionality if the exact flags you wanted - * are not available. - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_SetVideoMode - (int width, int height, int bpp, Uint32 flags); - -/** @name SDL_Update Functions - * These functions should not be called while 'screen' is locked. - */ -/*@{*/ -/** - * Makes sure the given list of rectangles is updated on the given screen. - */ -extern DECLSPEC void SDLCALL SDL_UpdateRects - (SDL_Surface *screen, int numrects, SDL_Rect *rects); -/** - * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire - * screen. - */ -extern DECLSPEC void SDLCALL SDL_UpdateRect - (SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); -/*@}*/ - -/** - * On hardware that supports double-buffering, this function sets up a flip - * and returns. The hardware will wait for vertical retrace, and then swap - * video buffers before the next video surface blit or lock will return. - * On hardware that doesn not support double-buffering, this is equivalent - * to calling SDL_UpdateRect(screen, 0, 0, 0, 0); - * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when - * setting the video mode for this function to perform hardware flipping. - * This function returns 0 if successful, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen); - -/** - * Set the gamma correction for each of the color channels. - * The gamma values range (approximately) between 0.1 and 10.0 - * - * If this function isn't supported directly by the hardware, it will - * be emulated using gamma ramps, if available. If successful, this - * function returns 0, otherwise it returns -1. - */ -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); - -/** - * Set the gamma translation table for the red, green, and blue channels - * of the video hardware. Each table is an array of 256 16-bit quantities, - * representing a mapping between the input and output for that channel. - * The input is the index into the array, and the output is the 16-bit - * gamma value at that index, scaled to the output color precision. - * - * You may pass NULL for any of the channels to leave it unchanged. - * If the call succeeds, it will return 0. If the display driver or - * hardware does not support gamma translation, or otherwise fails, - * this function will return -1. - */ -extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *green, const Uint16 *blue); - -/** - * Retrieve the current values of the gamma translation tables. - * - * You must pass in valid pointers to arrays of 256 16-bit quantities. - * Any of the pointers may be NULL to ignore that channel. - * If the call succeeds, it will return 0. If the display driver or - * hardware does not support gamma translation, or otherwise fails, - * this function will return -1. - */ -extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue); - -/** - * Sets a portion of the colormap for the given 8-bit surface. If 'surface' - * is not a palettized surface, this function does nothing, returning 0. - * If all of the colors were set as passed to SDL_SetColors(), it will - * return 1. If not all the color entries were set exactly as given, - * it will return 0, and you should look at the surface palette to - * determine the actual color palette. - * - * When 'surface' is the surface associated with the current display, the - * display colormap will be updated with the requested colors. If - * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors() - * will always return 1, and the palette is guaranteed to be set the way - * you desire, even if the window colormap has to be warped or run under - * emulation. - */ -extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface, - SDL_Color *colors, int firstcolor, int ncolors); - -/** - * Sets a portion of the colormap for a given 8-bit surface. - * 'flags' is one or both of: - * SDL_LOGPAL -- set logical palette, which controls how blits are mapped - * to/from the surface, - * SDL_PHYSPAL -- set physical palette, which controls how pixels look on - * the screen - * Only screens have physical palettes. Separate change of physical/logical - * palettes is only possible if the screen has SDL_HWPALETTE set. - * - * The return value is 1 if all colours could be set as requested, and 0 - * otherwise. - * - * SDL_SetColors() is equivalent to calling this function with - * flags = (SDL_LOGPAL|SDL_PHYSPAL). - */ -extern DECLSPEC int SDLCALL SDL_SetPalette(SDL_Surface *surface, int flags, - SDL_Color *colors, int firstcolor, - int ncolors); - -/** - * Maps an RGB triple to an opaque pixel value for a given pixel format - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGB -(const SDL_PixelFormat * const format, - const Uint8 r, const Uint8 g, const Uint8 b); - -/** - * Maps an RGBA quadruple to a pixel value for a given pixel format - */ -extern DECLSPEC Uint32 SDLCALL SDL_MapRGBA -(const SDL_PixelFormat * const format, - const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a); - -/** - * Maps a pixel value into the RGB components for a given pixel format - */ -extern DECLSPEC void SDLCALL SDL_GetRGB(Uint32 pixel, - const SDL_PixelFormat * const fmt, - Uint8 *r, Uint8 *g, Uint8 *b); - -/** - * Maps a pixel value into the RGBA components for a given pixel format - */ -extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, - const SDL_PixelFormat * const fmt, - Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); - -/** @sa SDL_CreateRGBSurface */ -#define SDL_AllocSurface SDL_CreateRGBSurface -/** - * Allocate and free an RGB surface (must be called after SDL_SetVideoMode) - * If the depth is 4 or 8 bits, an empty palette is allocated for the surface. - * If the depth is greater than 8 bits, the pixel format is set using the - * flags '[RGB]mask'. - * If the function runs out of memory, it will return NULL. - * - * The 'flags' tell what kind of surface to create. - * SDL_SWSURFACE means that the surface should be created in system memory. - * SDL_HWSURFACE means that the surface should be created in video memory, - * with the same format as the display surface. This is useful for surfaces - * that will not change much, to take advantage of hardware acceleration - * when being blitted to the display surface. - * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with - * this surface, but you must always lock it before accessing the pixels. - * SDL will wait for current blits to finish before returning from the lock. - * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits. - * If the hardware supports acceleration of colorkey blits between - * two surfaces in video memory, SDL will try to place the surface in - * video memory. If this isn't possible or if there is no hardware - * acceleration available, the surface will be placed in system memory. - * SDL_SRCALPHA means that the surface will be used for alpha blits and - * if the hardware supports hardware acceleration of alpha blits between - * two surfaces in video memory, to place the surface in video memory - * if possible, otherwise it will be placed in system memory. - * If the surface is created in video memory, blits will be _much_ faster, - * but the surface format must be identical to the video surface format, - * and the only way to access the pixels member of the surface is to use - * the SDL_LockSurface() and SDL_UnlockSurface() calls. - * If the requested surface actually resides in video memory, SDL_HWSURFACE - * will be set in the flags member of the returned surface. If for some - * reason the surface could not be placed in video memory, it will not have - * the SDL_HWSURFACE flag set, and will be created in system memory instead. - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface - (Uint32 flags, int width, int height, int depth, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); -/** @sa SDL_CreateRGBSurface */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, - int width, int height, int depth, int pitch, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); -extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface); - -/** - * SDL_LockSurface() sets up a surface for directly accessing the pixels. - * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write - * to and read from 'surface->pixels', using the pixel format stored in - * 'surface->format'. Once you are done accessing the surface, you should - * use SDL_UnlockSurface() to release it. - * - * Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates - * to 0, then you can read and write to the surface at any time, and the - * pixel format of the surface will not change. In particular, if the - * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you - * will not need to lock the display surface before accessing it. - * - * No operating system or library calls should be made between lock/unlock - * pairs, as critical system locks may be held during this time. - * - * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked. - */ -extern DECLSPEC int SDLCALL SDL_LockSurface(SDL_Surface *surface); -extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface); - -/** - * Load a surface from a seekable SDL data source (memory or file.) - * If 'freesrc' is non-zero, the source will be closed after being read. - * Returns the new surface, or NULL if there was an error. - * The new surface should be freed with SDL_FreeSurface(). - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc); - -/** Convenience macro -- load a surface from a file */ -#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1) - -/** - * Save a surface to a seekable SDL data source (memory or file.) - * If 'freedst' is non-zero, the source will be closed after being written. - * Returns 0 if successful or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SaveBMP_RW - (SDL_Surface *surface, SDL_RWops *dst, int freedst); - -/** Convenience macro -- save a surface to a file */ -#define SDL_SaveBMP(surface, file) \ - SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) - -/** - * Sets the color key (transparent pixel) in a blittable surface. - * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), - * 'key' will be the transparent pixel in the source image of a blit. - * SDL_RLEACCEL requests RLE acceleration for the surface if present, - * and removes RLE acceleration if absent. - * If 'flag' is 0, this function clears any current color key. - * This function returns 0, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SetColorKey - (SDL_Surface *surface, Uint32 flag, Uint32 key); - -/** - * This function sets the alpha value for the entire surface, as opposed to - * using the alpha component of each pixel. This value measures the range - * of transparency of the surface, 0 being completely transparent to 255 - * being completely opaque. An 'alpha' value of 255 causes blits to be - * opaque, the source pixels copied to the destination (the default). Note - * that per-surface alpha can be combined with colorkey transparency. - * - * If 'flag' is 0, alpha blending is disabled for the surface. - * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface. - * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the - * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed. - * - * The 'alpha' parameter is ignored for surfaces that have an alpha channel. - */ -extern DECLSPEC int SDLCALL SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); - -/** - * Sets the clipping rectangle for the destination surface in a blit. - * - * If the clip rectangle is NULL, clipping will be disabled. - * If the clip rectangle doesn't intersect the surface, the function will - * return SDL_FALSE and blits will be completely clipped. Otherwise the - * function returns SDL_TRUE and blits to the surface will be clipped to - * the intersection of the surface area and the clipping rectangle. - * - * Note that blits are automatically clipped to the edges of the source - * and destination surfaces. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect); - -/** - * Gets the clipping rectangle for the destination surface in a blit. - * 'rect' must be a pointer to a valid rectangle which will be filled - * with the correct values. - */ -extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect); - -/** - * Creates a new surface of the specified format, and then copies and maps - * the given surface to it so the blit of the converted surface will be as - * fast as possible. If this function fails, it returns NULL. - * - * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those - * semantics. You can also pass SDL_RLEACCEL in the flags parameter and - * SDL will try to RLE accelerate colorkey and alpha blits in the resulting - * surface. - * - * This function is used internally by SDL_DisplayFormat(). - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface - (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); - -/** - * This performs a fast blit from the source surface to the destination - * surface. It assumes that the source and destination rectangles are - * the same size. If either 'srcrect' or 'dstrect' are NULL, the entire - * surface (src or dst) is copied. The final blit rectangles are saved - * in 'srcrect' and 'dstrect' after all clipping is performed. - * If the blit is successful, it returns 0, otherwise it returns -1. - * - * The blit function should not be called on a locked surface. - * - * The blit semantics for surfaces with and without alpha and colorkey - * are defined as follows: - * - * RGBA->RGB: - * SDL_SRCALPHA set: - * alpha-blend (using alpha-channel). - * SDL_SRCCOLORKEY ignored. - * SDL_SRCALPHA not set: - * copy RGB. - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * RGB values of the source colour key, ignoring alpha in the - * comparison. - * - * RGB->RGBA: - * SDL_SRCALPHA set: - * alpha-blend (using the source per-surface alpha value); - * set destination alpha to opaque. - * SDL_SRCALPHA not set: - * copy RGB, set destination alpha to source per-surface alpha value. - * both: - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * source colour key. - * - * RGBA->RGBA: - * SDL_SRCALPHA set: - * alpha-blend (using the source alpha channel) the RGB values; - * leave destination alpha untouched. [Note: is this correct?] - * SDL_SRCCOLORKEY ignored. - * SDL_SRCALPHA not set: - * copy all of RGBA to the destination. - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * RGB values of the source colour key, ignoring alpha in the - * comparison. - * - * RGB->RGB: - * SDL_SRCALPHA set: - * alpha-blend (using the source per-surface alpha value). - * SDL_SRCALPHA not set: - * copy RGB. - * both: - * if SDL_SRCCOLORKEY set, only copy the pixels matching the - * source colour key. - * - * If either of the surfaces were in video memory, and the blit returns -2, - * the video memory was lost, so it should be reloaded with artwork and - * re-blitted: - * @code - * while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { - * while ( SDL_LockSurface(image) < 0 ) - * Sleep(10); - * -- Write image pixels to image->pixels -- - * SDL_UnlockSurface(image); - * } - * @endcode - * - * This happens under DirectX 5.0 when the system switches away from your - * fullscreen application. The lock will also fail until you have access - * to the video memory again. - * - * You should call SDL_BlitSurface() unless you know exactly how SDL - * blitting works internally and how to use the other blit functions. - */ -#define SDL_BlitSurface SDL_UpperBlit - -/** This is the public blit function, SDL_BlitSurface(), and it performs - * rectangle validation and clipping before passing it to SDL_LowerBlit() - */ -extern DECLSPEC int SDLCALL SDL_UpperBlit - (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); -/** This is a semi-private blit function and it performs low-level surface - * blitting only. - */ -extern DECLSPEC int SDLCALL SDL_LowerBlit - (SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - -/** - * This function performs a fast fill of the given rectangle with 'color' - * The given rectangle is clipped to the destination surface clip area - * and the final fill rectangle is saved in the passed in pointer. - * If 'dstrect' is NULL, the whole surface will be filled with 'color' - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * This function returns 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_FillRect - (SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); - -/** - * This function takes a surface and copies it to a new surface of the - * pixel format and colors of the video framebuffer, suitable for fast - * blitting onto the display surface. It calls SDL_ConvertSurface() - * - * If you want to take advantage of hardware colorkey or alpha blit - * acceleration, you should set the colorkey and alpha value before - * calling this function. - * - * If the conversion fails or runs out of memory, it returns NULL - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormat(SDL_Surface *surface); - -/** - * This function takes a surface and copies it to a new surface of the - * pixel format and colors of the video framebuffer (if possible), - * suitable for fast alpha blitting onto the display surface. - * The new surface will always have an alpha channel. - * - * If you want to take advantage of hardware colorkey or alpha blit - * acceleration, you should set the colorkey and alpha value before - * calling this function. - * - * If the conversion fails or runs out of memory, it returns NULL - */ -extern DECLSPEC SDL_Surface * SDLCALL SDL_DisplayFormatAlpha(SDL_Surface *surface); - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name YUV video surface overlay functions */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/** This function creates a video output overlay - * Calling the returned surface an overlay is something of a misnomer because - * the contents of the display surface underneath the area where the overlay - * is shown is undefined - it may be overwritten with the converted YUV data. - */ -extern DECLSPEC SDL_Overlay * SDLCALL SDL_CreateYUVOverlay(int width, int height, - Uint32 format, SDL_Surface *display); - -/** Lock an overlay for direct access, and unlock it when you are done */ -extern DECLSPEC int SDLCALL SDL_LockYUVOverlay(SDL_Overlay *overlay); -extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay); - -/** Blit a video overlay to the display surface. - * The contents of the video surface underneath the blit destination are - * not defined. - * The width and height of the destination rectangle may be different from - * that of the overlay, but currently only 2x scaling is supported. - */ -extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect); - -/** Free a video overlay */ -extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay *overlay); - -/*@}*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name OpenGL support functions. */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/** - * Dynamically load an OpenGL library, or the default one if path is NULL - * - * If you do this, you need to retrieve all of the GL functions used in - * your program from the dynamic library using SDL_GL_GetProcAddress(). - */ -extern DECLSPEC int SDLCALL SDL_GL_LoadLibrary(const char *path); - -/** - * Get the address of a GL function - */ -extern DECLSPEC void * SDLCALL SDL_GL_GetProcAddress(const char* proc); - -/** - * Set an attribute of the OpenGL subsystem before intialization. - */ -extern DECLSPEC int SDLCALL SDL_GL_SetAttribute(SDL_GLattr attr, int value); - -/** - * Get an attribute of the OpenGL subsystem from the windowing - * interface, such as glX. This is of course different from getting - * the values from SDL's internal OpenGL subsystem, which only - * stores the values you request before initialization. - * - * Developers should track the values they pass into SDL_GL_SetAttribute - * themselves if they want to retrieve these values. - */ -extern DECLSPEC int SDLCALL SDL_GL_GetAttribute(SDL_GLattr attr, int* value); - -/** - * Swap the OpenGL buffers, if double-buffering is supported. - */ -extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); - -/** @name OpenGL Internal Functions - * Internal functions that should not be called unless you have read - * and understood the source code for these functions. - */ -/*@{*/ -extern DECLSPEC void SDLCALL SDL_GL_UpdateRects(int numrects, SDL_Rect* rects); -extern DECLSPEC void SDLCALL SDL_GL_Lock(void); -extern DECLSPEC void SDLCALL SDL_GL_Unlock(void); -/*@}*/ - -/*@}*/ - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/** @name Window Manager Functions */ -/** These functions allow interaction with the window manager, if any. */ /*@{*/ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/** - * Sets the title and icon text of the display window (UTF-8 encoded) - */ -extern DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon); -/** - * Gets the title and icon text of the display window (UTF-8 encoded) - */ -extern DECLSPEC void SDLCALL SDL_WM_GetCaption(char **title, char **icon); - -/** - * Sets the icon for the display window. - * This function must be called before the first call to SDL_SetVideoMode(). - * It takes an icon surface, and a mask in MSB format. - * If 'mask' is NULL, the entire icon surface will be used as the icon. - */ -extern DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); - -/** - * This function iconifies the window, and returns 1 if it succeeded. - * If the function succeeds, it generates an SDL_APPACTIVE loss event. - * This function is a noop and returns 0 in non-windowed environments. - */ -extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void); - -/** - * Toggle fullscreen mode without changing the contents of the screen. - * If the display surface does not require locking before accessing - * the pixel information, then the memory pointers will not change. - * - * If this function was able to toggle fullscreen mode (change from - * running in a window to fullscreen, or vice-versa), it will return 1. - * If it is not implemented, or fails, it returns 0. - * - * The next call to SDL_SetVideoMode() will set the mode fullscreen - * attribute based on the flags parameter - if SDL_FULLSCREEN is not - * set, then the display will be windowed by default where supported. - * - * This is currently only implemented in the X11 video driver. - */ -extern DECLSPEC int SDLCALL SDL_WM_ToggleFullScreen(SDL_Surface *surface); - -typedef enum { - SDL_GRAB_QUERY = -1, - SDL_GRAB_OFF = 0, - SDL_GRAB_ON = 1, - SDL_GRAB_FULLSCREEN /**< Used internally */ -} SDL_GrabMode; -/** - * This function allows you to set and query the input grab state of - * the application. It returns the new input grab state. - * - * Grabbing means that the mouse is confined to the application window, - * and nearly all keyboard input is passed directly to the application, - * and not interpreted by a window manager, if any. - */ -extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode); - -/*@}*/ - -/** @internal Not in public API at the moment - do not use! */ -extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_video_h */ diff --git a/codemp/rd-rend2/SDL/begin_code.h b/codemp/rd-rend2/SDL/begin_code.h deleted file mode 100644 index 27e2f7bc75..0000000000 --- a/codemp/rd-rend2/SDL/begin_code.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** - * @file begin_code.h - * This file sets things up for C dynamic library function definitions, - * static inlined functions, and structures aligned at 4-byte alignment. - * If you don't like ugly C preprocessor code, don't look at this file. :) - */ - -/** - * @file begin_code.h - * This shouldn't be nested -- included it around code only. - */ -#ifdef _begin_code_h -#error Nested inclusion of begin_code.h -#endif -#define _begin_code_h - -/** - * @def DECLSPEC - * Some compilers use a special export keyword - */ -#ifndef DECLSPEC -# if defined(__BEOS__) || defined(__HAIKU__) -# if defined(__GNUC__) -# define DECLSPEC -# else -# define DECLSPEC __declspec(export) -# endif -# elif defined(__WIN32__) -# ifdef __BORLANDC__ -# ifdef BUILD_SDL -# define DECLSPEC -# else -# define DECLSPEC __declspec(dllimport) -# endif -# else -# define DECLSPEC __declspec(dllexport) -# endif -# elif defined(__OS2__) -# ifdef __WATCOMC__ -# ifdef BUILD_SDL -# define DECLSPEC __declspec(dllexport) -# else -# define DECLSPEC -# endif -# elif defined (__GNUC__) && __GNUC__ < 4 -# /* Added support for GCC-EMX = 4 -# define DECLSPEC __attribute__ ((visibility("default"))) -# else -# define DECLSPEC -# endif -# endif -#endif - -/** - * @def SDLCALL - * By default SDL uses the C calling convention - */ -#ifndef SDLCALL -# if defined(__WIN32__) && !defined(__GNUC__) -# define SDLCALL __cdecl -# elif defined(__OS2__) -# if defined (__GNUC__) && __GNUC__ < 4 -# /* Added support for GCC-EMX Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); - #endif // // latched and archived variables @@ -1181,7 +1177,7 @@ void R_Register( void ) r_mode = ri->Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); r_fullscreen = ri->Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); - r_noborder = ri->Cvar_Get( "r_noborder", "0", CVAR_ARCHIVE|CVAR_LATCH ); + r_centerWindow = ri->Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE|CVAR_LATCH ); r_customwidth = ri->Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); r_customheight = ri->Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); r_customPixelAspect = ri->Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1566,6 +1562,26 @@ static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = extern IGhoul2InfoArray &TheGhoul2InfoArray(); const CGhoul2Info NullG2; +// STUBS, REPLACEME +qhandle_t stub_RegisterServerModel( const char *name ) +{ + ri->Printf( PRINT_ALL, "stub_RegisterServerModel\n" ); + return 0; +} + +qhandle_t stub_RegisterServerSkin( const char *name ) +{ + ri->Printf( PRINT_ALL, "stub_RegisterServerSkin\n" ); + return 0; +} + +const char *stub_ShaderNameFromIndex( int index ) +{ + ri->Printf( PRINT_ALL, "stub_ShaderNameFromIndex\n" ); + return NULL; +} + + /* @@@@@@@@@@@@@@@@@@@@@ GetRefAPI @@ -1573,14 +1589,10 @@ GetRefAPI @@@@@@@@@@@@@@@@@@@@@ */ extern "C" { -#ifdef USE_RENDERER_DLOPEN Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { -#else -refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { -#endif - static refexport_t re; + assert( rimp ); ri = rimp; Com_Memset( &re, 0, sizeof( re ) ); @@ -1597,9 +1609,15 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.BeginRegistration = RE_BeginRegistration; re.RegisterModel = RE_RegisterModel; + // RE_RegisterServerModel + re.RegisterServerModel = stub_RegisterServerModel; re.RegisterSkin = RE_RegisterSkin; + // RE_RegisterServerSkin + re.RegisterServerSkin = stub_RegisterServerSkin; re.RegisterShader = RE_RegisterShader; re.RegisterShaderNoMip = RE_RegisterShaderNoMip; + // RE_ShaderNameFromIndex + re.ShaderNameFromIndex = stub_ShaderNameFromIndex; re.LoadWorld = RE_LoadWorldMap; re.SetWorldVisData = RE_SetWorldVisData; re.EndRegistration = RE_EndRegistration; @@ -1611,9 +1629,15 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.LerpTag = R_LerpTag; re.ModelBounds = R_ModelBounds; + // RE_RotatePic + // RE_RotatePic2 + re.ClearScene = RE_ClearScene; + // RE_ClearDecals re.AddRefEntityToScene = RE_AddRefEntityToScene; + // RE_AddMiniRefEntityToScene re.AddPolyToScene = RE_AddPolyToScene; + // RE_AddDecalToScene re.LightForPoint = R_LightForPoint; re.AddLightToScene = RE_AddLightToScene; re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene; @@ -1625,10 +1649,36 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.UploadCinematic = RE_UploadCinematic; re.RegisterFont = RE_RegisterFont; + // RE_Font_StrLenPixels + // RE_Font_StrLenChars + // RE_Font_HeightPixels + // RE_Font_DrawString + // Language_IsAsian + // Language_UsesSpaces + // AnyLanguage_ReadCharFromString re.RemapShader = R_RemapShader; re.GetEntityToken = R_GetEntityToken; re.inPVS = R_inPVS; + // RE_GetLightStyle + // RE_SetLightStyle + // RE_GetBModelVerts + + // SetRangedFog + // SetRefractionProperties + // GetDistanceCull + // GetRealRes + // R_AutomapElevationAdjustment + // R_InitializeWireframeAutomap + // RE_AddWeatherZone + // RE_WorldEffectCommand + // RE_InitRendererTerrain + // RE_RegisterMedia_LevelLoadBegin + // RE_RegisterMedia_LevelLoadEnd + // RE_RegisterMedia_GetLevel + // RE_RegisterImages_LevelLoadEnd + // RE_RegisterModels_LevelLoadEnd + re.TakeVideoFrame = RE_TakeVideoFrame; /* @@ -1730,6 +1780,16 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) { Ghoul2 Insert End */ + // R_LoadDataImage + // R_InvertImage + // R_Resample + // R_LoadImage + // R_CreateAutomapImage + // RE_SavePNG + + // TheGhoul2InfoArray + // G2VertSpaceServer + return &re; } } \ No newline at end of file diff --git a/codemp/rd-vanilla/qgl.h b/codemp/rd-vanilla/qgl.h index 3207a498db..2e647621ff 100644 --- a/codemp/rd-vanilla/qgl.h +++ b/codemp/rd-vanilla/qgl.h @@ -754,4 +754,4 @@ extern void (*qglXSwapBuffers)( Display *dpy, GLXDrawable drawable ); #endif // __linux__ || __FreeBSD__ // rb010123 -#endif // _WIN32 && __linux__ +#endif // _WIN32 && __linux__ \ No newline at end of file diff --git a/codemp/win32/win_glimp.cpp b/codemp/win32/win_glimp.cpp index d7517691ad..a5a0e7eec0 100644 --- a/codemp/win32/win_glimp.cpp +++ b/codemp/win32/win_glimp.cpp @@ -69,6 +69,13 @@ extern bool g_bDynamicGlowSupported; // reason it acts different on radeon! It's against the spec!). bool g_bTextureRectangleHack = false; +// nasty -- we need to extern some crap +extern cvar_t *r_centerWindow; +extern cvar_t *r_displayRefresh; +extern cvar_t *r_ext_preferred_tc_method; + +extern qboolean R_GetModeInfo( int *width, int *height, int mode ); + /* ** GLW_StartDriverAndSetMode */ From c220617c24437e1018cbfb56f223e6c5d7c798dc Mon Sep 17 00:00:00 2001 From: eezstreet Date: Fri, 11 Oct 2013 10:10:04 -0400 Subject: [PATCH 052/708] GETADDRESS -> qwglGetProcAddress --- codemp/rd-rend2/tr_extensions.cpp | 178 +++++++++++++++--------------- 1 file changed, 86 insertions(+), 92 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 1647beac64..28a844bd0c 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -30,12 +30,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA extern glwstate_t glw_state; #endif -#ifdef _WIN32 -#define GETADDRESS(x) GetProcAddress(glw_state.hinstOpenGL, x) -#else -#define GETADDRESS(x) SDL_GL_GetProcAddress(x) -#endif - // GL_EXT_draw_range_elements void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); @@ -206,7 +200,7 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawRangeElementsEXT = (void (__stdcall *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GETADDRESS("glDrawRangeElementsEXT"); + qglDrawRangeElementsEXT = (void (__stdcall *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))qwglGetProcAddress("glDrawRangeElementsEXT"); if ( r_ext_draw_range_elements->integer) glRefConfig.drawRangeElements = qtrue; @@ -225,8 +219,8 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GETADDRESS("glMultiDrawArraysEXT"); - qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GETADDRESS("glMultiDrawElementsEXT"); + qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) qwglGetProcAddress("glMultiDrawArraysEXT"); + qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) qwglGetProcAddress("glMultiDrawElementsEXT"); if ( r_ext_multi_draw_arrays->integer ) glRefConfig.multiDrawArrays = qtrue; @@ -248,13 +242,13 @@ void GLimp_InitExtraExtensions() qglDisableVertexAttribArrayARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) GETADDRESS("glVertexAttrib4fARB"); - qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) GETADDRESS("glVertexAttrib4fvARB"); - qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GETADDRESS("glVertexAttribPointerARB"); + qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) qwglGetProcAddress("glVertexAttrib4fARB"); + qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) qwglGetProcAddress("glVertexAttrib4fvARB"); + qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) qwglGetProcAddress("glVertexAttribPointerARB"); qglEnableVertexAttribArrayARB = - (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GETADDRESS("glEnableVertexAttribArrayARB"); + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) qwglGetProcAddress("glEnableVertexAttribArrayARB"); qglDisableVertexAttribArrayARB = - (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GETADDRESS("glDisableVertexAttribArrayARB"); + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) qwglGetProcAddress("glDisableVertexAttribArrayARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexProgram = qtrue; @@ -278,15 +272,15 @@ void GLimp_InitExtraExtensions() qglGetBufferPointervARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) GETADDRESS("glBindBufferARB"); - qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GETADDRESS("glDeleteBuffersARB"); - qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GETADDRESS("glGenBuffersARB"); - qglIsBufferARB = (PFNGLISBUFFERARBPROC) GETADDRESS("glIsBufferARB"); - qglBufferDataARB = (void (__stdcall *)(GLenum,GLint,const GLvoid *,GLenum)) GETADDRESS("glBufferDataARB"); - qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLint,GLint,const GLvoid *)) GETADDRESS("glBufferSubDataARB"); - qglGetBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) GETADDRESS("glGetBufferSubDataARB"); - qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GETADDRESS("glGetBufferParameterivARB"); - qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GETADDRESS("glGetBufferPointervARB"); + qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) qwglGetProcAddress("glBindBufferARB"); + qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) qwglGetProcAddress("glDeleteBuffersARB"); + qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) qwglGetProcAddress("glGenBuffersARB"); + qglIsBufferARB = (PFNGLISBUFFERARBPROC) qwglGetProcAddress("glIsBufferARB"); + qglBufferDataARB = (void (__stdcall *)(GLenum,GLint,const GLvoid *,GLenum)) qwglGetProcAddress("glBufferDataARB"); + qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLint,GLint,const GLvoid *)) qwglGetProcAddress("glBufferSubDataARB"); + qglGetBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) qwglGetProcAddress("glGetBufferSubDataARB"); + qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) qwglGetProcAddress("glGetBufferParameterivARB"); + qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) qwglGetProcAddress("glGetBufferPointervARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexBufferObject = qtrue; } @@ -338,44 +332,44 @@ void GLimp_InitExtraExtensions() qglGetShaderSourceARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GETADDRESS("glDeleteObjectARB"); - qglGetHandleARB = (PFNGLGETHANDLEARBPROC) GETADDRESS("glGetHandleARB"); - qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) GETADDRESS("glDetachObjectARB"); - qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GETADDRESS("glCreateShaderObjectARB"); - qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GETADDRESS("glShaderSourceARB"); - qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GETADDRESS("glCompileShaderARB"); - qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GETADDRESS("glCreateProgramObjectARB"); - qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GETADDRESS("glAttachObjectARB"); - qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETADDRESS("glLinkProgramARB"); - qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETADDRESS("glUseProgramObjectARB"); - qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) GETADDRESS("glValidateProgramARB"); - qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) GETADDRESS("glUniform1fARB"); - qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) GETADDRESS("glUniform2fARB"); - qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) GETADDRESS("glUniform3fARB"); - qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) GETADDRESS("glUniform4fARB"); - qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) GETADDRESS("glUniform1iARB"); - qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) GETADDRESS("glUniform2iARB"); - qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) GETADDRESS("glUniform3iARB"); - qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) GETADDRESS("glUniform4iARB"); - qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) GETADDRESS("glUniform1fvARB"); - qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) GETADDRESS("glUniform2fvARB"); - qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) GETADDRESS("glUniform3fvARB"); - qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETADDRESS("glUniform4fvARB"); - qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) GETADDRESS("glUniform2ivARB"); - qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) GETADDRESS("glUniform3ivARB"); - qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) GETADDRESS("glUniform4ivARB"); - qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) GETADDRESS("glUniformMatrix2fvARB"); - qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) GETADDRESS("glUniformMatrix3fvARB"); - qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) GETADDRESS("glUniformMatrix4fvARB"); - qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) GETADDRESS("glGetObjectParameterfvARB"); - qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) GETADDRESS("glGetObjectParameterivARB"); - qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) GETADDRESS("glGetInfoLogARB"); - qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) GETADDRESS("glGetAttachedObjectsARB"); - qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETADDRESS("glGetUniformLocationARB"); - qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) GETADDRESS("glGetActiveUniformARB"); - qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) GETADDRESS("glGetUniformfvARB"); - qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) GETADDRESS("glGetUniformivARB"); - qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) GETADDRESS("glGetShaderSourceARB"); + qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) qwglGetProcAddress("glDeleteObjectARB"); + qglGetHandleARB = (PFNGLGETHANDLEARBPROC) qwglGetProcAddress("glGetHandleARB"); + qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) qwglGetProcAddress("glDetachObjectARB"); + qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) qwglGetProcAddress("glCreateShaderObjectARB"); + qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) qwglGetProcAddress("glShaderSourceARB"); + qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) qwglGetProcAddress("glCompileShaderARB"); + qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) qwglGetProcAddress("glCreateProgramObjectARB"); + qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) qwglGetProcAddress("glAttachObjectARB"); + qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) qwglGetProcAddress("glLinkProgramARB"); + qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) qwglGetProcAddress("glUseProgramObjectARB"); + qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) qwglGetProcAddress("glValidateProgramARB"); + qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) qwglGetProcAddress("glUniform1fARB"); + qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) qwglGetProcAddress("glUniform2fARB"); + qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) qwglGetProcAddress("glUniform3fARB"); + qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) qwglGetProcAddress("glUniform4fARB"); + qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) qwglGetProcAddress("glUniform1iARB"); + qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) qwglGetProcAddress("glUniform2iARB"); + qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) qwglGetProcAddress("glUniform3iARB"); + qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) qwglGetProcAddress("glUniform4iARB"); + qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) qwglGetProcAddress("glUniform1fvARB"); + qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) qwglGetProcAddress("glUniform2fvARB"); + qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) qwglGetProcAddress("glUniform3fvARB"); + qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) qwglGetProcAddress("glUniform4fvARB"); + qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) qwglGetProcAddress("glUniform2ivARB"); + qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) qwglGetProcAddress("glUniform3ivARB"); + qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) qwglGetProcAddress("glUniform4ivARB"); + qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) qwglGetProcAddress("glUniformMatrix2fvARB"); + qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) qwglGetProcAddress("glUniformMatrix3fvARB"); + qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) qwglGetProcAddress("glUniformMatrix4fvARB"); + qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) qwglGetProcAddress("glGetObjectParameterfvARB"); + qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) qwglGetProcAddress("glGetObjectParameterivARB"); + qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) qwglGetProcAddress("glGetInfoLogARB"); + qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) qwglGetProcAddress("glGetAttachedObjectsARB"); + qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) qwglGetProcAddress("glGetUniformLocationARB"); + qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) qwglGetProcAddress("glGetActiveUniformARB"); + qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) qwglGetProcAddress("glGetUniformfvARB"); + qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) qwglGetProcAddress("glGetUniformivARB"); + qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) qwglGetProcAddress("glGetShaderSourceARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.shaderObjects = qtrue; } @@ -414,9 +408,9 @@ void GLimp_InitExtraExtensions() //glConfig.maxVertexSkinningBones = (int) Q_bound(0.0, (Q_max(glConfig.maxVertexUniforms - reservedComponents, 0) / 16), MAX_BONES); //glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ((glConfig.maxVertexSkinningBones >= 12) ? qtrue : qfalse); - qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GETADDRESS("glBindAttribLocationARB"); - qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GETADDRESS("glGetActiveAttribARB"); - qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GETADDRESS("glGetAttribLocationARB"); + qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) qwglGetProcAddress("glBindAttribLocationARB"); + qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) qwglGetProcAddress("glGetActiveAttribARB"); + qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) qwglGetProcAddress("glGetAttribLocationARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexShader = qtrue; } @@ -510,23 +504,23 @@ void GLimp_InitExtraExtensions() qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); - qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GETADDRESS("glIsRenderbufferEXT"); - qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GETADDRESS("glBindRenderbufferEXT"); - qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GETADDRESS("glDeleteRenderbuffersEXT"); - qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GETADDRESS("glGenRenderbuffersEXT"); - qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GETADDRESS("glRenderbufferStorageEXT"); - qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) GETADDRESS("glGetRenderbufferParameterivEXT"); - qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) GETADDRESS("glIsFramebufferEXT"); - qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GETADDRESS("glBindFramebufferEXT"); - qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GETADDRESS("glDeleteFramebuffersEXT"); - qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GETADDRESS("glGenFramebuffersEXT"); - qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GETADDRESS("glCheckFramebufferStatusEXT"); - qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) GETADDRESS("glFramebufferTexture1DEXT"); - qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GETADDRESS("glFramebufferTexture2DEXT"); - qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) GETADDRESS("glFramebufferTexture3DEXT"); - qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GETADDRESS("glFramebufferRenderbufferEXT"); - qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GETADDRESS("glGetFramebufferAttachmentParameterivEXT"); - qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GETADDRESS("glGenerateMipmapEXT"); + qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) qwglGetProcAddress("glIsRenderbufferEXT"); + qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) qwglGetProcAddress("glBindRenderbufferEXT"); + qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) qwglGetProcAddress("glDeleteRenderbuffersEXT"); + qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) qwglGetProcAddress("glGenRenderbuffersEXT"); + qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) qwglGetProcAddress("glRenderbufferStorageEXT"); + qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) qwglGetProcAddress("glGetRenderbufferParameterivEXT"); + qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) qwglGetProcAddress("glIsFramebufferEXT"); + qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) qwglGetProcAddress("glBindFramebufferEXT"); + qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) qwglGetProcAddress("glDeleteFramebuffersEXT"); + qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) qwglGetProcAddress("glGenFramebuffersEXT"); + qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) qwglGetProcAddress("glCheckFramebufferStatusEXT"); + qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) qwglGetProcAddress("glFramebufferTexture1DEXT"); + qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) qwglGetProcAddress("glFramebufferTexture2DEXT"); + qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) qwglGetProcAddress("glFramebufferTexture3DEXT"); + qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) qwglGetProcAddress("glFramebufferRenderbufferEXT"); + qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) qwglGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) qwglGetProcAddress("glGenerateMipmapEXT"); if(r_ext_framebuffer_object->value) glRefConfig.framebufferObject = qtrue; @@ -556,14 +550,14 @@ void GLimp_InitExtraExtensions() glRefConfig.occlusionQuery = qfalse; if (GLimp_HaveExtension(extension)) { - qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GETADDRESS("glGenQueriesARB"); - qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GETADDRESS("glDeleteQueriesARB"); - qglIsQueryARB = (PFNGLISQUERYARBPROC) GETADDRESS("glIsQueryARB"); - qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GETADDRESS("glBeginQueryARB"); - qglEndQueryARB = (PFNGLENDQUERYARBPROC) GETADDRESS("glEndQueryARB"); - qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GETADDRESS("glGetQueryivARB"); - qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GETADDRESS("glGetQueryObjectivARB"); - qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GETADDRESS("glGetQueryObjectuivARB"); + qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) qwglGetProcAddress("glGenQueriesARB"); + qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) qwglGetProcAddress("glDeleteQueriesARB"); + qglIsQueryARB = (PFNGLISQUERYARBPROC) qwglGetProcAddress("glIsQueryARB"); + qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) qwglGetProcAddress("glBeginQueryARB"); + qglEndQueryARB = (PFNGLENDQUERYARBPROC) qwglGetProcAddress("glEndQueryARB"); + qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) qwglGetProcAddress("glGetQueryivARB"); + qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) qwglGetProcAddress("glGetQueryObjectivARB"); + qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) qwglGetProcAddress("glGetQueryObjectuivARB"); glRefConfig.occlusionQuery = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); } @@ -577,7 +571,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferBlit = qfalse; if (GLimp_HaveExtension(extension)) { - qglBlitFramebufferEXT = (void (__stdcall *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GETADDRESS("glBlitFramebufferEXT"); + qglBlitFramebufferEXT = (void (__stdcall *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))qwglGetProcAddress("glBlitFramebufferEXT"); glRefConfig.framebufferBlit = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); } @@ -591,7 +585,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferMultisample = qfalse; if (GLimp_HaveExtension(extension)) { - qglRenderbufferStorageMultisampleEXT = (void (__stdcall *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GETADDRESS("glRenderbufferStorageMultisampleEXT"); + qglRenderbufferStorageMultisampleEXT = (void (__stdcall *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))qwglGetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } @@ -650,7 +644,7 @@ void GLimp_InitExtraExtensions() qglDrawBuffersARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawBuffersARB = (void (__stdcall *)(GLsizei,const GLenum *)) GETADDRESS("glDrawBuffersARB"); + qglDrawBuffersARB = (void (__stdcall *)(GLsizei,const GLenum *)) qwglGetProcAddress("glDrawBuffersARB"); ri->Printf(PRINT_ALL, result[1], extension); } From 8e6060a881d0e8f0cd9ae4937f805c28323670f1 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Fri, 11 Oct 2013 12:36:09 -0400 Subject: [PATCH 053/708] [rend2] Game now runs up to the main menu. Numerous visual artifacts, and game crashes on Character Create screen (due to lack of functioning G2) --- codemp/rd-rend2/tr_init.cpp | 46 ++++++++++++++++++++++++++++++------ codemp/rd-rend2/tr_local.h | 6 +++++ codemp/rd-rend2/tr_model.cpp | 11 ++++++--- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index ad9b29ed91..075d6c1bc8 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1581,6 +1581,33 @@ const char *stub_ShaderNameFromIndex( int index ) return NULL; } +void stub_RegisterMedia_LevelLoadBegin( const char *mapname, ForceReload_e eForceReload ) +{ + ri->Printf( PRINT_ALL, "stub_LevelLoadBegin\n"); +} + +void stub_RegisterMedia_LevelLoadEnd( void ) +{ + ri->Printf( PRINT_ALL, "stub_LevelLoadEnd\n"); +} + +int stub_RegisterMedia_GetLevel( void ) +{ + ri->Printf( PRINT_ALL, "stub_RegisterMedia_GetLevel\n"); + return 0; +} + +qboolean stub_RegisterImages_LevelLoadEnd( void ) +{ + ri->Printf( PRINT_ALL, "stub_RegisterImages_LevelLoadEnd\n"); + return qtrue; +} + +qboolean stub_RegisterModels_LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) +{ + ri->Printf( PRINT_ALL, "stub_RegisterModels_LevelLoadEnd\n"); + return qtrue; +} /* @@@@@@@@@@@@@@@@@@@@@ @@ -1649,13 +1676,13 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.UploadCinematic = RE_UploadCinematic; re.RegisterFont = RE_RegisterFont; - // RE_Font_StrLenPixels - // RE_Font_StrLenChars - // RE_Font_HeightPixels - // RE_Font_DrawString - // Language_IsAsian - // Language_UsesSpaces - // AnyLanguage_ReadCharFromString + re.Font_StrLenPixels = RE_Font_StrLenPixels; + re.Font_StrLenChars = RE_Font_StrLenChars; + re.Font_HeightPixels = RE_Font_HeightPixels; + re.Font_DrawString = RE_Font_DrawString; + re.Language_IsAsian = Language_IsAsian; + re.Language_UsesSpaces = Language_UsesSpaces; + re.AnyLanguage_ReadCharFromString = AnyLanguage_ReadCharFromString; re.RemapShader = R_RemapShader; re.GetEntityToken = R_GetEntityToken; re.inPVS = R_inPVS; @@ -1674,10 +1701,15 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { // RE_WorldEffectCommand // RE_InitRendererTerrain // RE_RegisterMedia_LevelLoadBegin + re.RegisterMedia_LevelLoadBegin = stub_RegisterMedia_LevelLoadBegin; // RE_RegisterMedia_LevelLoadEnd + re.RegisterMedia_LevelLoadEnd = stub_RegisterMedia_LevelLoadEnd; // RE_RegisterMedia_GetLevel + re.RegisterMedia_GetLevel = stub_RegisterMedia_GetLevel; // RE_RegisterImages_LevelLoadEnd + re.RegisterImages_LevelLoadEnd = stub_RegisterImages_LevelLoadEnd; // RE_RegisterModels_LevelLoadEnd + re.RegisterModels_LevelLoadEnd = stub_RegisterModels_LevelLoadEnd; re.TakeVideoFrame = RE_TakeVideoFrame; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fd6e0f91ef..609ed72584 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -35,6 +35,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_postprocess.h" #include "iqm.h" #include "qgl.h" +#include +#include #ifdef _WIN32 #include "win32\win_local.h" @@ -2131,6 +2133,9 @@ typedef struct trGlobals_s { #ifdef _WIN32 WinVars_t *wv; #endif + + // Specific to Jedi Academy + int numBSPModels; } trGlobals_t; extern backEndState_t backEnd; @@ -3059,4 +3064,5 @@ void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const cha qboolean ShaderHashTableExists(void); extern void R_ImageLoader_Init(void); + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index de40536410..4b3a1cea3b 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LL(x) x=LittleLong(x) + static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, int bufferSize, const char *modName); static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name ); static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); @@ -203,13 +204,17 @@ static modelExtToLoaderMap_t modelLoaders[ ] = { "iqm", R_RegisterIQM }, { "mdr", R_RegisterMDR }, { "md4", R_RegisterMD3 }, - { "md3", R_RegisterMD3 } + { "md3", R_RegisterMD3 }, + /* + Ghoul 2 Insert Start + */ + /* + Ghoul 2 Insert End + */ }; static int numModelLoaders = ARRAY_LEN(modelLoaders); -//=============================================================================== - /* ** R_GetModelByHandle */ From a2fa88d9540413d9b8a1b4f9c3c690474014c05a Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 11 Oct 2013 22:39:00 -0500 Subject: [PATCH 054/708] [MP] rend2: Add missing files to rend2 cmake. --- codemp/rd-rend2/CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 680fb0c11b..b5635fcaa7 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -17,6 +17,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_local.h" "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" + "${MPDir}/rd-rend2/glsl_shaders.cpp" "${MPDir}/rd-rend2/tr_animation.cpp" "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" @@ -63,9 +64,14 @@ set(MPRend2Files ${MPRend2Files} ${MPRend2Ghoul2Files}) set(MPRend2RdCommonFiles "${MPDir}/rd-common/mdx_format.h" - "${MPDir}/rd-common/tr_types.h" + "${MPDir}/rd-common/tr_common.h" "${MPDir}/rd-common/tr_font.cpp" "${MPDir}/rd-common/tr_font.h" + "${MPDir}/rd-common/tr_image_load.cpp" + "${MPDir}/rd-common/tr_image_manipulation.cpp" + "${MPDir}/rd-common/tr_image_jpg.cpp" + "${MPDir}/rd-common/tr_image_tga.cpp" + "${MPDir}/rd-common/tr_image_png.cpp" "${MPDir}/rd-common/tr_noise.cpp" "${MPDir}/rd-common/tr_public.h") source_group("rd-common" FILES ${MPRend2RdCommonFiles}) From fc6f5ff488b20aad9db22a1b6640612df13867c0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 11 Oct 2013 22:39:25 -0500 Subject: [PATCH 055/708] [MP] rend2: Add some more ref export stuff including ghoul2 array. --- codemp/rd-rend2/tr_init.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 075d6c1bc8..bb95563d83 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1559,6 +1559,14 @@ extern qboolean gG2_GBMNoReconstruct; extern qboolean gG2_GBMUseSPMethod; static void G2API_BoltMatrixReconstruction( qboolean reconstruct ) { gG2_GBMNoReconstruct = (qboolean)!reconstruct; } static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = spMethod; } + +static float GetDistanceCull( void ) { return 6000/*tr.distanceCull*/; } + +static void GetRealRes( int *w, int *h ) { + *w = glConfig.vidWidth; + *h = glConfig.vidHeight; +} + extern IGhoul2InfoArray &TheGhoul2InfoArray(); const CGhoul2Info NullG2; @@ -1812,14 +1820,14 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { Ghoul2 Insert End */ - // R_LoadDataImage - // R_InvertImage - // R_Resample - // R_LoadImage - // R_CreateAutomapImage - // RE_SavePNG + re.LoadDataImage = R_LoadDataImage; + re.InvertImage = R_InvertImage; + re.Resample = R_Resample; + re.LoadImageJA = R_LoadImage; + //re.CreateAutomapImage = R_CreateAutomapImage; + re.SavePNG = RE_SavePNG; - // TheGhoul2InfoArray + re.TheGhoul2InfoArray = TheGhoul2InfoArray; // G2VertSpaceServer return &re; From e484282019343c38c39b44bd4eecbaaf86a7d7de Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 11 Oct 2013 22:39:52 -0500 Subject: [PATCH 056/708] [MP] rend2: Fixed missing data = (byte*) in R_LoadMD3. --- codemp/rd-rend2/tr_model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 4b3a1cea3b..3dbb385d87 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -790,7 +790,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, ofs_st = dataSize; dataSize += surf->numVerts * sizeof(*texcoords); - Z_Malloc(dataSize, TAG_MODEL_MD3); + data = (byte *)Z_Malloc(dataSize, TAG_MODEL_MD3); verts = (vec3_t *)(data + ofs_xyz); normals = (vec3_t *)(data + ofs_normal); From bb43228685d149fc000cb0ab7dfbee1f0d61bee3 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 11 Oct 2013 22:45:19 -0500 Subject: [PATCH 057/708] [MP] rend2: Fixed the ortho width/height to match legacy. --- codemp/rd-rend2/tr_backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 41da5f8838..35dcb21b3e 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -793,7 +793,7 @@ void RB_SetGL2D (void) { qglViewport( 0, 0, width, height ); qglScissor( 0, 0, width, height ); - Matrix16Ortho(0, width, height, 0, 0, 1, matrix); + Matrix16Ortho(0, 640, 480, 0, 0, 1, matrix); GL_SetProjectionMatrix(matrix); Matrix16Identity(matrix); GL_SetModelviewMatrix(matrix); From 69f603b34a4233d22366ed92e9b1991745fe216d Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 11 Oct 2013 23:33:56 -0500 Subject: [PATCH 058/708] [MP] rend2: Use the correct folder for shaders. --- codemp/rd-rend2/tr_shader.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 96d0c930fb..14672571bd 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3550,7 +3550,7 @@ static void ScanAndLoadShaderFiles( void ) long sum = 0, summand; // scan for shader files - shaderFiles = ri->FS_ListFiles( "scripts", ".shader", &numShaderFiles ); + shaderFiles = ri->FS_ListFiles( "shaders", ".shader", &numShaderFiles ); if ( !shaderFiles || !numShaderFiles ) { @@ -3570,7 +3570,7 @@ static void ScanAndLoadShaderFiles( void ) // look for a .mtr file first { char *ext; - Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); + Com_sprintf( filename, sizeof( filename ), "shaders/%s", shaderFiles[i] ); if ( (ext = strrchr(filename, '.')) ) { strcpy(ext, ".mtr"); @@ -3578,7 +3578,7 @@ static void ScanAndLoadShaderFiles( void ) if ( ri->FS_ReadFile( filename, NULL ) <= 0 ) { - Com_sprintf( filename, sizeof( filename ), "scripts/%s", shaderFiles[i] ); + Com_sprintf( filename, sizeof( filename ), "shaders/%s", shaderFiles[i] ); } } From 4677997a9514a36084c5613ecff3d759bd1fe24a Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 12 Oct 2013 00:10:09 -0500 Subject: [PATCH 059/708] [MP] rend2: Use the JA font functions not freetype crap. --- codemp/rd-rend2/tr_init.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index bb95563d83..f77e983c27 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1478,9 +1478,9 @@ void R_Init( void ) { R_InitSkins(); - R_ModelInit(); + R_InitFonts(); - R_InitFreeType(); + R_ModelInit(); R_InitQueries(); @@ -1526,7 +1526,7 @@ void RE_Shutdown( qboolean destroyWindow ) { GLSL_ShutdownGPUShaders(); } - R_DoneFreeType(); + R_ShutdownFonts(); // shut down platform specific OpenGL stuff if ( destroyWindow ) { From dc9a6a3fed41fe8d055ca5ac3ec030b96ab5219c Mon Sep 17 00:00:00 2001 From: eezstreet Date: Sat, 12 Oct 2013 13:10:38 -0400 Subject: [PATCH 060/708] [rend2] Display splash screen on startup --- codemp/rd-rend2/tr_init.cpp | 60 +++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f77e983c27..c409e38298 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -262,6 +262,53 @@ int max_polys; cvar_t *r_maxpolyverts; int max_polyverts; + +extern void RB_SetGL2D (void); +void R_Splash() +{ + image_t *pImage = R_FindImageFile( "menu/splash", IMGTYPE_COLORALPHA, IMGFLAG_NONE); + qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + qglMatrixMode(GL_PROJECTION); + qglLoadIdentity (); + qglOrtho (0, 640, 480, 0, 0, 1); + qglMatrixMode(GL_MODELVIEW); + qglLoadIdentity (); + + GL_State( GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + + qglDisable( GL_CULL_FACE ); + qglDisable( GL_CLIP_PLANE0 ); + if (pImage ) + {//invalid paths? + GL_Bind( pImage ); + } + GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + + const int width = 640; + const int height = 480; + const float x1 = 320 - width / 2; + const float x2 = 320 + width / 2; + const float y1 = 240 - height / 2; + const float y2 = 240 + height / 2; + + + qglBegin (GL_TRIANGLE_STRIP); + qglTexCoord2f( 0, 0 ); + qglVertex2f(x1, y1); + qglTexCoord2f( 1 , 0 ); + qglVertex2f(x2, y1); + qglTexCoord2f( 0, 1 ); + qglVertex2f(x1, y2); + qglTexCoord2f( 1, 1 ); + qglVertex2f(x2, y2); + qglEnd(); + + GLimp_EndFrame(); +} + /* ** InitOpenGL ** @@ -304,10 +351,17 @@ static void InitOpenGL( void ) { glConfig.maxTextureSize = 0; } - } - // set default state - GL_SetDefaultState(); + // set default state + GL_SetDefaultState(); + R_Splash(); //get something on screen asap + GfxInfo_f(); + } + else + { + // set default state + GL_SetDefaultState(); + } } /* From b4b9c134970d6b502a014293d8f3c020d7c5fee6 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Sat, 12 Oct 2013 14:17:00 -0400 Subject: [PATCH 061/708] MP: [rend2] Added model loaders for GLM format, currently trigger asserts and are broken (for the moment) --- codemp/rd-rend2/tr_model.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 3dbb385d87..5257d0ba43 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -75,14 +75,26 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) continue; ident = LittleLong(* (unsigned *) buf.u); - if (ident == MD4_IDENT) - loaded = R_LoadMD4(mod, buf.u, name); - else + // HACK until we get the model/image caching to mirror JKA --eez + qboolean temp = qtrue; + qboolean &temp2 = temp; + switch(ident) { - if (ident == MD3_IDENT) + case MD4_IDENT: + loaded = R_LoadMD4(mod, buf.u, name); + break; + case MD3_IDENT: loaded = R_LoadMD3(mod, lod, buf.u, size, name); - else - ri->Printf(PRINT_WARNING,"R_RegisterMD3: unknown fileid for %s\n", name); + break; + case MDXA_IDENT: + loaded = R_LoadMDXA(mod, buf.u, name, temp2); + break; + case MDXM_IDENT: + loaded = R_LoadMDXM(mod, buf.u, name, temp2); + break; + default: + ri->Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); + break; } ri->FS_FreeFile(buf.v); @@ -208,6 +220,7 @@ static modelExtToLoaderMap_t modelLoaders[ ] = /* Ghoul 2 Insert Start */ + { "glm", R_RegisterMD3 }, /* Ghoul 2 Insert End */ From 4a3539fd7487427f8b81974bd2108b38fc12a5ba Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 12 Oct 2013 22:35:18 -0500 Subject: [PATCH 062/708] [MP] rend2: Some shader code fixes. Might make your main menu work now. NOTE: this includes some changes to COM_Parse and SkipBracedSection with _Depth suffix so as to not have to recompile all the other functions needing it. This change came from ioq3 by zturtleman, not sure if we will be keeping obviously. --- codemp/qcommon/q_shared.c | 59 +++++++++-- codemp/rd-rend2/tr_backend.cpp | 8 +- codemp/rd-rend2/tr_init.cpp | 30 +++--- codemp/rd-rend2/tr_local.h | 11 +- codemp/rd-rend2/tr_shader.cpp | 180 +++++++++++++++++++++++++++++---- 5 files changed, 240 insertions(+), 48 deletions(-) diff --git a/codemp/qcommon/q_shared.c b/codemp/qcommon/q_shared.c index 89e11a6123..bb661c62ac 100644 --- a/codemp/qcommon/q_shared.c +++ b/codemp/qcommon/q_shared.c @@ -326,15 +326,22 @@ PARSING static char com_token[MAX_TOKEN_CHARS]; static char com_parsename[MAX_TOKEN_CHARS]; static int com_lines; +static int com_tokenline; void COM_BeginParseSession( const char *name ) { - com_lines = 0; + com_lines = 1; + com_tokenline = 0; Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name); } int COM_GetCurrentParseLine( void ) { + if ( com_tokenline ) + { + return com_tokenline; + } + return com_lines; } @@ -352,7 +359,7 @@ void COM_ParseError( char *format, ... ) Q_vsnprintf (string, sizeof( string ), format, argptr); va_end (argptr); - Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string); + Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string); } void COM_ParseWarning( char *format, ... ) @@ -364,7 +371,7 @@ void COM_ParseWarning( char *format, ... ) Q_vsnprintf (string, sizeof( string ), format, argptr); va_end (argptr); - Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string); + Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string); } /* @@ -459,8 +466,9 @@ int COM_Compress( char *data_p ) { } } } + + *out = 0; } - *out = 0; return out - data_p; } @@ -473,6 +481,7 @@ char *COM_ParseExt( const char **data_p, qboolean allowLineBreaks ) data = *data_p; len = 0; com_token[0] = 0; + com_tokenline = 0; // make sure incoming data is valid if ( !data ) @@ -512,6 +521,10 @@ char *COM_ParseExt( const char **data_p, qboolean allowLineBreaks ) data += 2; while ( *data && ( *data != '*' || data[1] != '/' ) ) { + if ( *data == '\n' ) + { + com_lines++; + } data++; } if ( *data ) @@ -525,6 +538,9 @@ char *COM_ParseExt( const char **data_p, qboolean allowLineBreaks ) } } + // token starts on this line + com_tokenline = com_lines; + // handle quoted strings if (c == '\"') { @@ -538,6 +554,10 @@ char *COM_ParseExt( const char **data_p, qboolean allowLineBreaks ) *data_p = ( char * ) data; return com_token; } + if ( c == '\n' ) + { + com_lines++; + } if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; @@ -549,15 +569,13 @@ char *COM_ParseExt( const char **data_p, qboolean allowLineBreaks ) // parse a regular word do { - if (len < MAX_TOKEN_CHARS -1) + if (len < MAX_TOKEN_CHARS - 1) { com_token[len] = c; len++; } data++; c = *data; - if ( c == '\n' ) - com_lines++; } while (c>32); com_token[len] = 0; @@ -741,6 +759,33 @@ void SkipBracedSection (const char **program) { } while( depth && *program ); } +/* +================= +SkipBracedSection + +The next token should be an open brace or set depth to 1 if already parsed it. +Skips until a matching close brace is found. +Internal brace depths are properly skipped. +================= +*/ +qboolean SkipBracedSection_Depth (const char **program, int depth) { + char *token; + + do { + token = COM_ParseExt( program, qtrue ); + if( token[1] == 0 ) { + if( token[0] == '{' ) { + depth++; + } + else if( token[0] == '}' ) { + depth--; + } + } + } while( depth && *program ); + + return (qboolean)( depth == 0 ); +} + /* ================= SkipRestOfLine diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 35dcb21b3e..3ab2ac24db 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -391,14 +391,18 @@ void GL_State( unsigned long stateBits ) qglEnable( GL_ALPHA_TEST ); qglAlphaFunc( GL_GREATER, 0.0f ); break; - case GLS_ATEST_LT_80: + case GLS_ATEST_LT_128: qglEnable( GL_ALPHA_TEST ); qglAlphaFunc( GL_LESS, 0.5f ); break; - case GLS_ATEST_GE_80: + case GLS_ATEST_GE_128: qglEnable( GL_ALPHA_TEST ); qglAlphaFunc( GL_GEQUAL, 0.5f ); break; + case GLS_ATEST_GE_192: + qglEnable( GL_ALPHA_TEST ); + qglAlphaFunc( GL_GEQUAL, 0.75f ); + break; default: assert( 0 ); break; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c409e38298..fea510aec5 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -355,7 +355,6 @@ static void InitOpenGL( void ) // set default state GL_SetDefaultState(); R_Splash(); //get something on screen asap - GfxInfo_f(); } else { @@ -1420,6 +1419,7 @@ Ghoul2 Insert End ri->Cmd_AddCommand( "imagelist", R_ImageList_f ); ri->Cmd_AddCommand( "shaderlist", R_ShaderList_f ); ri->Cmd_AddCommand( "skinlist", R_SkinList_f ); + ri->Cmd_AddCommand( "fontlist", R_FontList_f ); ri->Cmd_AddCommand( "modellist", R_Modellist_f ); ri->Cmd_AddCommand( "modelist", R_ModeList_f ); ri->Cmd_AddCommand( "screenshot", R_ScreenShot_f ); @@ -1563,6 +1563,7 @@ void RE_Shutdown( qboolean destroyWindow ) { ri->Cmd_RemoveCommand ("imagelist"); ri->Cmd_RemoveCommand ("shaderlist"); ri->Cmd_RemoveCommand ("skinlist"); + ri->Cmd_RemoveCommand ("fontlist"); ri->Cmd_RemoveCommand ("gfxinfo"); ri->Cmd_RemoveCommand("minimize"); ri->Cmd_RemoveCommand( "modelist" ); @@ -1627,47 +1628,41 @@ const CGhoul2Info NullG2; // STUBS, REPLACEME qhandle_t stub_RegisterServerModel( const char *name ) { - ri->Printf( PRINT_ALL, "stub_RegisterServerModel\n" ); + //ri->Printf( PRINT_ALL, "stub_RegisterServerModel\n" ); return 0; } qhandle_t stub_RegisterServerSkin( const char *name ) { - ri->Printf( PRINT_ALL, "stub_RegisterServerSkin\n" ); + //ri->Printf( PRINT_ALL, "stub_RegisterServerSkin\n" ); return 0; } -const char *stub_ShaderNameFromIndex( int index ) -{ - ri->Printf( PRINT_ALL, "stub_ShaderNameFromIndex\n" ); - return NULL; -} - void stub_RegisterMedia_LevelLoadBegin( const char *mapname, ForceReload_e eForceReload ) { - ri->Printf( PRINT_ALL, "stub_LevelLoadBegin\n"); + //ri->Printf( PRINT_ALL, "stub_LevelLoadBegin\n"); } void stub_RegisterMedia_LevelLoadEnd( void ) { - ri->Printf( PRINT_ALL, "stub_LevelLoadEnd\n"); + //ri->Printf( PRINT_ALL, "stub_LevelLoadEnd\n"); } int stub_RegisterMedia_GetLevel( void ) { - ri->Printf( PRINT_ALL, "stub_RegisterMedia_GetLevel\n"); + //ri->Printf( PRINT_ALL, "stub_RegisterMedia_GetLevel\n"); return 0; } qboolean stub_RegisterImages_LevelLoadEnd( void ) { - ri->Printf( PRINT_ALL, "stub_RegisterImages_LevelLoadEnd\n"); + //ri->Printf( PRINT_ALL, "stub_RegisterImages_LevelLoadEnd\n"); return qtrue; } qboolean stub_RegisterModels_LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) { - ri->Printf( PRINT_ALL, "stub_RegisterModels_LevelLoadEnd\n"); + //ri->Printf( PRINT_ALL, "stub_RegisterModels_LevelLoadEnd\n"); return qtrue; } @@ -1705,8 +1700,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.RegisterServerSkin = stub_RegisterServerSkin; re.RegisterShader = RE_RegisterShader; re.RegisterShaderNoMip = RE_RegisterShaderNoMip; - // RE_ShaderNameFromIndex - re.ShaderNameFromIndex = stub_ShaderNameFromIndex; + re.ShaderNameFromIndex = RE_ShaderNameFromIndex; re.LoadWorld = RE_LoadWorldMap; re.SetWorldVisData = RE_SetWorldVisData; re.EndRegistration = RE_EndRegistration; @@ -1755,8 +1749,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { // SetRangedFog // SetRefractionProperties - // GetDistanceCull - // GetRealRes + re.GetDistanceCull = GetDistanceCull; + re.GetRealRes = GetRealRes; // R_AutomapElevationAdjustment // R_InitializeWireframeAutomap // RE_AddWeatherZone diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 609ed72584..29ca2bafe9 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -883,12 +883,12 @@ enum GLS_ATEST_GT_0 = (1 << 22), GLS_ATEST_LT_128 = (1 << 23), GLS_ATEST_GE_128 = (1 << 24), -// GLS_ATEST_GE_CUSTOM = (1 << 25), + GLS_ATEST_GE_192 = (1 << 25), GLS_ATEST_BITS = GLS_ATEST_GT_0 | GLS_ATEST_LT_128 - | GLS_ATEST_GE_128, -// | GLS_ATEST_GT_CUSTOM, + | GLS_ATEST_GE_128 + | GLS_ATEST_GE_192, GLS_REDMASK_FALSE = (1 << 26), GLS_GREENMASK_FALSE = (1 << 27), @@ -2392,7 +2392,8 @@ void GL_Cull( int cullType ); #define GLS_ATEST_GT_0 0x10000000 #define GLS_ATEST_LT_80 0x20000000 #define GLS_ATEST_GE_80 0x40000000 -#define GLS_ATEST_BITS 0x70000000 +#define GLS_ATEST_GE_C0 0x80000000 +#define GLS_ATEST_BITS 0xF0000000 #define GLS_DEFAULT GLS_DEPTHMASK_TRUE @@ -2426,6 +2427,7 @@ void R_GammaCorrect( byte *buffer, int bufSize ); void R_ImageList_f( void ); void R_SkinList_f( void ); +void R_FontList_f( void ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 const void *RB_TakeScreenshotCmd( const void *data ); void R_ScreenShot_f( void ); @@ -3054,6 +3056,7 @@ Ghoul2 Insert End image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); +const char *RE_ShaderNameFromIndex(int index); image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ); extern qboolean textureFilterAnisotropic; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 14672571bd..7b9c181751 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -169,11 +169,15 @@ static unsigned NameToAFunc( const char *funcname ) } else if ( !Q_stricmp( funcname, "LT128" ) ) { - return GLS_ATEST_LT_80; + return GLS_ATEST_LT_128; } else if ( !Q_stricmp( funcname, "GE128" ) ) { - return GLS_ATEST_GE_80; + return GLS_ATEST_GE_128; + } + else if ( !Q_stricmp( funcname, "GE192" ) ) + { + return GLS_ATEST_GE_192; } ri->Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); @@ -747,7 +751,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // animMap .... // - else if ( !Q_stricmp( token, "animMap" ) ) + else if ( !Q_stricmp( token, "animMap" ) || !Q_stricmp( token, "clampanimMap" ) || !Q_stricmp( token, "oneshotanimMap" ) ) { token = COM_ParseExt( text, qfalse ); if ( !token[0] ) @@ -837,6 +841,10 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) { depthFuncBits = GLS_DEPTHFUNC_EQUAL; } + else if ( !Q_stricmp( token, "disable" ) ) + { + depthFuncBits = GLS_DEPTHTEST_DISABLE; + } else { ri->Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); @@ -1026,6 +1034,14 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) { stage->rgbGen = CGEN_LIGHTING_DIFFUSE; } + else if ( !Q_stricmp( token, "lightingDiffuseEntity" ) ) + { + //if (shader.lightmapIndex[0] != LIGHTMAP_NONE) + //{ + // Com_Printf( S_COLOR_RED "ERROR: rgbGen lightingDiffuseEntity used on a misc_model! in shader '%s'\n", shader.name ); + //} + //stage->rgbGen = CGEN_LIGHTING_DIFFUSE_ENTITY; + } else if ( !Q_stricmp( token, "oneMinusVertex" ) ) { stage->rgbGen = CGEN_ONE_MINUS_VERTEX; @@ -1083,6 +1099,14 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) { stage->alphaGen = AGEN_ONE_MINUS_VERTEX; } + else if ( !Q_stricmp( token, "dot" ) ) + { + //stage->alphaGen = AGEN_DOT; + } + else if ( !Q_stricmp( token, "oneMinusDot" ) ) + { + //stage->alphaGen = AGEN_ONE_MINUS_DOT; + } else if ( !Q_stricmp( token, "portal" ) ) { stage->alphaGen = AGEN_PORTAL; @@ -1173,6 +1197,67 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } + // If this stage has glow... GLOWXXX + else if ( Q_stricmp( token, "glow" ) == 0 ) + { + //stage->glow = true; + + continue; + } + // + // surfaceSprites ... + // + else if ( !Q_stricmp( token, "surfaceSprites" ) ) + { + SkipRestOfLine( text ); + /*char buffer[1024] = ""; + + while ( 1 ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + break; + strcat( buffer, token ); + strcat( buffer, " " ); + } + + ParseSurfaceSprites( buffer, stage );*/ + + continue; + } + // + // ssFademax + // ssFadescale + // ssVariance + // ssHangdown + // ssAnyangle + // ssFaceup + // ssWind + // ssWindIdle + // ssDuration + // ssGrow + // ssWeather + // + else if (!Q_stricmpn(token, "ss", 2)) // <--- NOTE ONLY COMPARING FIRST TWO LETTERS + { + SkipRestOfLine( text ); + /*char buffer[1024] = ""; + char param[128]; + strcpy(param,token); + + while ( 1 ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + break; + strcat( buffer, token ); + strcat( buffer, " " ); + } + + ParseSurfaceSpritesOptional( param, buffer, stage );*/ + + continue; + } else { ri->Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); @@ -1467,7 +1552,7 @@ void ParseSort( const char **text ) { shader.sort = SS_ENVIRONMENT; } else if ( !Q_stricmp( token, "opaque" ) ) { shader.sort = SS_OPAQUE; - }else if ( !Q_stricmp( token, "decal" ) ) { + } else if ( !Q_stricmp( token, "decal" ) ) { shader.sort = SS_DECAL; } else if ( !Q_stricmp( token, "seeThrough" ) ) { shader.sort = SS_SEE_THROUGH; @@ -1479,17 +1564,58 @@ void ParseSort( const char **text ) { shader.sort = SS_NEAREST; } else if ( !Q_stricmp( token, "underwater" ) ) { shader.sort = SS_UNDERWATER; - } else { + } else if ( !Q_stricmp( token, "inside" ) ) { + //shader.sort = SS_INSIDE; + } else if ( !Q_stricmp( token, "mid_inside" ) ) { + //shader.sort = SS_MID_INSIDE; + } else if ( !Q_stricmp( token, "middle" ) ) { + //shader.sort = SS_MIDDLE; + } else if ( !Q_stricmp( token, "mid_outside" ) ) { + //shader.sort = SS_MID_OUTSIDE; + } else if ( !Q_stricmp( token, "outside" ) ) { + //shader.sort = SS_OUTSIDE; + } + else { shader.sort = atof( token ); } } +/* +================= +ParseMaterial +================= +*/ +const char *materialNames[MATERIAL_LAST] = +{ + MATERIALS +}; + +void ParseMaterial( const char **text ) +{ + char *token; + int i; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == 0 ) + { + Com_Printf (S_COLOR_YELLOW "WARNING: missing material in shader '%s'\n", shader.name ); + return; + } + for(i = 0; i < MATERIAL_LAST; i++) + { + if ( !Q_stricmp( token, materialNames[i] ) ) + { + shader.surfaceFlags |= i; + break; + } + } +} // this table is also present in q3map -typedef struct { - char *name; +typedef struct infoParm_s { + const char *name; int clearSolid, surfaceFlags, contents; } infoParm_t; @@ -1556,11 +1682,7 @@ static void ParseSurfaceParm( const char **text ) { if ( !Q_stricmp( token, infoParms[i].name ) ) { shader.surfaceFlags |= infoParms[i].surfaceFlags; shader.contentFlags |= infoParms[i].contents; -#if 0 - if ( infoParms[i].clearSolid ) { - si->contents &= ~CONTENTS_SOLID; - } -#endif + shader.contentFlags &= infoParms[i].clearSolid; break; } } @@ -1625,6 +1747,12 @@ static qboolean ParseShader( const char **text ) SkipRestOfLine( text ); continue; } + // material deprecated as of 11 Jan 01 + // material undeprecated as of 7 May 01 - q3map_material deprecated + else if ( !Q_stricmp( token, "material" ) || !Q_stricmp( token, "q3map_material" ) ) + { + ParseMaterial( text ); + } // sun parms else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { float a, b; @@ -1690,7 +1818,7 @@ static qboolean ParseShader( const char **text ) SkipRestOfLine( text ); continue; } - else if ( !Q_stricmp( token, "deformVertexes" ) ) { + else if ( !Q_stricmp( token, "deformvertexes" ) || !Q_stricmp( token, "deform" ) ) { ParseDeform( text ); continue; } @@ -1727,12 +1855,22 @@ static qboolean ParseShader( const char **text ) shader.noPicMip = qtrue; continue; } + else if ( !Q_stricmp( token, "noglfog" ) ) + { + //shader.fogPass = FP_NONE; + continue; + } // polygonOffset else if ( !Q_stricmp( token, "polygonOffset" ) ) { shader.polygonOffset = qtrue; continue; } + else if ( !Q_stricmp( token, "noTC" ) ) + { + //shader.noTC = true; + continue; + } // entityMergable, allowing sprite surfaces from multiple entities // to be merged into one batch. This is a savings for smoke // puffs and blood, but can't be used for anything where the @@ -2973,6 +3111,8 @@ static shader_t *FinishShader( void ) { //======================================================================================== +qboolean SkipBracedSection_Depth (const char **program, int depth); + /* ==================== FindShaderInShaderText @@ -3024,7 +3164,7 @@ static const char *FindShaderInShaderText( const char *shadername ) { } else { // skip the definition - SkipBracedSection( &p ); + SkipBracedSection_Depth( &p, 0 ); } } @@ -3443,6 +3583,13 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { return sh->index; } +//added for ui -rww +const char *RE_ShaderNameFromIndex(int index) +{ + assert(index >= 0 && index < tr.numShaders && tr.shaders[index]); + return tr.shaders[index]->name; +} + /* ==================== R_GetShaderByHandle @@ -3616,15 +3763,14 @@ static void ScanAndLoadShaderFiles( void ) break; } - SkipBracedSection(&p); - /*if(!SkipBracedSection(&p)) + if(!SkipBracedSection_Depth(&p, 1)) { ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); ri->FS_FreeFile(buffers[i]); buffers[i] = NULL; break; - }*/ + } } From 09ce79cf2b6bad0370857bc692f23e879e632333 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Mon, 14 Oct 2013 14:04:44 -0400 Subject: [PATCH 063/708] MP: [rend2] File caching system WIP. Causes some asserts but is 90% functional apparently --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_cache.cpp | 293 +++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_ghoul2.cpp | 5 +- codemp/rd-rend2/tr_init.cpp | 38 +---- codemp/rd-rend2/tr_local.h | 93 +++++++++++ codemp/rd-rend2/tr_model.cpp | 62 +++---- 6 files changed, 426 insertions(+), 66 deletions(-) create mode 100644 codemp/rd-rend2/tr_cache.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index b5635fcaa7..60d6a2a02b 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -21,6 +21,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_animation.cpp" "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" + "${MPDir}/rd-rend2/tr_cache.cpp" "${MPDir}/rd-rend2/tr_cmds.cpp" "${MPDir}/rd-rend2/tr_curve.cpp" "${MPDir}/rd-rend2/tr_extensions.cpp" diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp new file mode 100644 index 0000000000..17032678c9 --- /dev/null +++ b/codemp/rd-rend2/tr_cache.cpp @@ -0,0 +1,293 @@ +// tr_cache.cpp - Cache models, images, and more.. + +#include "tr_local.h" + +// This differs significantly from Raven's own caching code. +// For starters, we are allowed to use ri-> whatever because we don't care about running on dedicated (use rd-vanilla!) +using namespace std; + +CImageCacheManager *CImgCache = new CImageCacheManager(); +CModelCacheManager *CModelCache = new CModelCacheManager(); + +static int GetModelDataAllocSize(void) +{ + return Z_MemSize( TAG_MODEL_MD3) + + Z_MemSize( TAG_MODEL_GLM) + + Z_MemSize( TAG_MODEL_GLA); +} + +/* + * CCacheManager::SearchLoaded + * Return -1 if asset not currently loaded, return positive qhandle_t if found + */ +qhandle_t CCacheManager::SearchLoaded( const char *fileName ) +{ + loadedMap_t::iterator it = loaded.find(fileName); + if( it == loaded.end() ) + return -1; // asset not found + return it->second->handle; +} + +/* + * CCacheManager::InsertLoaded + * We have a loaded model/image, let's insert it into the list of loaded models + */ +void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) +{ + FileHash_t *fh = (FileHash_t *)ri->Hunk_Alloc( sizeof(FileHash_t), h_low ); + fh->handle = handle; + Q_strncpyz( fh->fileName, fileName, sizeof(fh->fileName) ); + pair fPair (fileName, fh); + loaded.insert(fPair); +} + +/* + * CCacheManager::LoadFile + * Load the file and chuck the contents into ppFileBuffer, OR + * if we're cached already, chuck cached contents into ppFileBuffer + * and set *pbAlreadyCached to qtrue (otherwise, *pbAlreadyCached = false) + */ +qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ) +{ + char sFileName[MAX_QPATH]; + + Q_strncpyz(sFileName, pFileName, MAX_QPATH); + Q_strlwr (sFileName); + + CachedFile_t *pFile; + pFile = cache[sFileName]; // this might cause an assert?? (I dunno, works fine in Raven code..) + + if(!pFile) + { + *pbAlreadyCached = qfalse; + ri->FS_ReadFile( pFileName, ppFileBuffer ); + qboolean bSuccess = !!(*ppFileBuffer)?qtrue:qfalse; + + if( bSuccess ) + ri->Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); + + return bSuccess; + } + else + { + *ppFileBuffer = pFile->pDiskImage; + *pbAlreadyCached = qtrue; + return qtrue; + } +} + +/* + * CCacheManager::Allocate + * Allocate appropriate memory for stuff dealing with cached images + * FIXME: only applies to models? + */ +void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ) +{ + int iChecksum; + char sModelName[MAX_QPATH]; + + /* Standard NULL checking. */ + if( !psModelFileName || !psModelFileName[0] ) + return NULL; + + if( !bAlreadyFound ) + return NULL; + + /* Convert psModelFileName to lowercase */ + Q_strncpyz(sModelName, psModelFileName, MAX_QPATH); + Q_strlwr (sModelName); + + CachedFile_t *pFile = cache[sModelName]; + + if( !pFile ) /* Doesn't exist, so we'll create a new object */ + pFile = new CachedFile_t(); + + if( !pFile->pDiskImage ) + { /* Create this image. */ + /* + * We aren't going to do that ugly VV hack that supposedly reduces mem overhead. + * Said hack can cause heap corruption (!) if not properly checked, and I suspect + * that I'll forget to do it later. Forgive me for not cutting down on overhead, + * but I figured it was marginal, considering it was designed in order to cut back + * on mem usage on machines that ran with like 64MB RAM... --eez + */ + pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); + pFile->pDiskImage = pvDiskBuffer; + pFile->iAllocSize = iSize; + + if( ri->FS_FileIsInPAK( psModelFileName, &iChecksum ) ) + pFile->iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ + + *bAlreadyFound = qfalse; + } + else + { + /* + * Already found it. + * TODO: shader caching. + */ + *bAlreadyFound = qtrue; + } + + return pFile->pDiskImage; +} + +/* + * CCacheManager::DeleteAll + * Clears out the cache (done on renderer shutdown I suppose) + */ +void CCacheManager::DeleteAll( void ) +{ + for( auto it = cache.begin(); it != cache.end(); ++it ) + { + Z_Free(it->second->pDiskImage); + cache.erase(it); + } +} + +/* + * CCacheManager::DumpNonPure + * Scans the cache for assets which don't match the checksum, and dumps + * those that don't match. + */ +void CCacheManager::DumpNonPure( void ) +{ + ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure():\n"); + + for(assetCache_t::iterator it = cache.begin(); it != cache.end(); /* empty */ ) + { + int iChecksum; + int iInPak = ri->FS_FileIsInPAK( it->first, &iChecksum ); + qboolean bEraseOccurred = qfalse; + + if( iInPak == -1 || iChecksum != it->second->iPAKChecksum ) + { + /* Erase the file because it doesn't match the checksum */ + ri->Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->first ); + + if( it->second->pDiskImage ) + Z_Free( it->second->pDiskImage ); + + cache.erase(it++); + bEraseOccurred = qtrue; + } + + if( !bEraseOccurred ) + ++it; + } + + ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); +} + +/* + * LevelLoadEnd virtual funcs + */ + +/* + * This function is /badly/ designed in vanilla. For starters, LETS NOT USE ANY INCREMENTERS BECAUSE THATS COOL + * Secondly, it randomly decides to keep track of the amount of model memory and break out of the loop if we run + * higher than r_modelpoolmegs...thing is, logically that doesn't make any sense, since you're freeing memory + * here, not allocating more of it. Fail. + */ +qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) +{ + //int iLoadedModelBytes = GetModelDataAllocSize(); + //const int iMaxModelBytes = r_modelpoolmegs->integer * 1024 * 1024; + qboolean bAtLeastOneModelFreed = qfalse; + + /*if( iLoadedModelBytes > iMaxModelBytes ) + { + Com_Printf("CModelCacheManager::LevelLoadEnd(): iLoadedModelBytes > iMaxModelBytes (raise r_modelpoolmegs?)\n"); + return bAtLeastOneModelFreed; + }*/ + + ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); + + for(auto it = cache.begin(); it != cache.end(); ++it) + { + CachedFile_t *pFile = it->second; + bool bDeleteThis = false; + + if( bDeleteEverythingNotUsedThisLevel ) + bDeleteThis = ( pFile->iLevelLastUsedOn != tr.currentLevel ); + else + bDeleteThis = ( pFile->iLevelLastUsedOn < tr.currentLevel ); + + if( bDeleteThis ) + { + const char *psModelName = it->first; + + ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", psModelName); + + if( pFile->pDiskImage ) + { + Z_Free( pFile->pDiskImage ); + bAtLeastOneModelFreed = qtrue; // FIXME: is this correct? shouldn't it be in the next lower scope? + } + // FIXME: like right here? + cache.erase(it); + } + } + + ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); + + return bAtLeastOneModelFreed; +} + +qboolean CImageCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel /* unused */ ) +{ + return qtrue; +} + +/* + * Wrappers for the above funcs so they export properly. + */ + +qboolean C_Models_LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ) +{ + return CModelCache->LevelLoadEnd( bDeleteEverythingNotUsedInThisLevel ); +} + +qboolean C_Images_LevelLoadEnd( void ) +{ + return CImgCache->LevelLoadEnd( qfalse ); +} + +/* + * These processes occur outside of the CacheManager class. They are exported by the renderer. + */ + +void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) +{ + static char sPrevMapName[MAX_QPATH]={0}; + bool bDeleteModels = eForceReload == eForceReload_MODELS || eForceReload == eForceReload_ALL; + + if( bDeleteModels ) + CModelCache->DeleteAll(); + else if( ri->Cvar_VariableIntegerValue( "sv_pure" ) ) + CModelCache->DumpNonPure(); + + tr.numBSPModels = 0; + + //R_Images_DeleteLightMaps(); + + /* If we're switching to the same level, don't increment current level */ + if (Q_stricmp( psMapName,sPrevMapName )) + { + Q_strncpyz( sPrevMapName, psMapName, sizeof(sPrevMapName) ); + tr.currentLevel++; + } +} + +int C_GetLevel( void ) +{ + return tr.currentLevel; +} + +void C_LevelLoadEnd( void ) +{ + CModelCache->LevelLoadEnd( qfalse ); + CImgCache->LevelLoadEnd( qfalse ); + ri->SND_RegisterAudio_LevelLoadEnd( qfalse ); + ri->S_RestartMusic(); +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 7cd0a65e51..d1ef9abe28 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4181,7 +4181,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mod->dataSize += size; qboolean bAlreadyFound = qfalse; - mdxm = mod->mdxm = (mdxmHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); + mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); @@ -4625,7 +4625,8 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean size += (childNumber*(CHILD_PADDING*8)); //Allocate us some extra space so we can shift memory down. #endif //CREATE_LIMB_HIERARCHY - mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); + //mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); + mdxa = mod->mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index fea510aec5..67e90b893f 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1638,34 +1638,6 @@ qhandle_t stub_RegisterServerSkin( const char *name ) return 0; } -void stub_RegisterMedia_LevelLoadBegin( const char *mapname, ForceReload_e eForceReload ) -{ - //ri->Printf( PRINT_ALL, "stub_LevelLoadBegin\n"); -} - -void stub_RegisterMedia_LevelLoadEnd( void ) -{ - //ri->Printf( PRINT_ALL, "stub_LevelLoadEnd\n"); -} - -int stub_RegisterMedia_GetLevel( void ) -{ - //ri->Printf( PRINT_ALL, "stub_RegisterMedia_GetLevel\n"); - return 0; -} - -qboolean stub_RegisterImages_LevelLoadEnd( void ) -{ - //ri->Printf( PRINT_ALL, "stub_RegisterImages_LevelLoadEnd\n"); - return qtrue; -} - -qboolean stub_RegisterModels_LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) -{ - //ri->Printf( PRINT_ALL, "stub_RegisterModels_LevelLoadEnd\n"); - return qtrue; -} - /* @@@@@@@@@@@@@@@@@@@@@ GetRefAPI @@ -1757,15 +1729,15 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { // RE_WorldEffectCommand // RE_InitRendererTerrain // RE_RegisterMedia_LevelLoadBegin - re.RegisterMedia_LevelLoadBegin = stub_RegisterMedia_LevelLoadBegin; + re.RegisterMedia_LevelLoadBegin = C_LevelLoadBegin; // RE_RegisterMedia_LevelLoadEnd - re.RegisterMedia_LevelLoadEnd = stub_RegisterMedia_LevelLoadEnd; + re.RegisterMedia_LevelLoadEnd = C_LevelLoadEnd; // RE_RegisterMedia_GetLevel - re.RegisterMedia_GetLevel = stub_RegisterMedia_GetLevel; + re.RegisterMedia_GetLevel = C_GetLevel; // RE_RegisterImages_LevelLoadEnd - re.RegisterImages_LevelLoadEnd = stub_RegisterImages_LevelLoadEnd; + re.RegisterImages_LevelLoadEnd = C_Images_LevelLoadEnd; // RE_RegisterModels_LevelLoadEnd - re.RegisterModels_LevelLoadEnd = stub_RegisterModels_LevelLoadEnd; + re.RegisterModels_LevelLoadEnd = C_Models_LevelLoadEnd; re.TakeVideoFrame = RE_TakeVideoFrame; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 29ca2bafe9..76495821aa 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -37,9 +37,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "qgl.h" #include #include +#include #ifdef _WIN32 #include "win32\win_local.h" +#include "qcommon\sstring.h" #endif #define GL_INDEX_TYPE GL_UNSIGNED_INT @@ -2136,6 +2138,7 @@ typedef struct trGlobals_s { // Specific to Jedi Academy int numBSPModels; + int currentLevel; } trGlobals_t; extern backEndState_t backEnd; @@ -3067,5 +3070,95 @@ void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const cha qboolean ShaderHashTableExists(void); extern void R_ImageLoader_Init(void); +// tr_cache.cpp + +/* + * FileHash_t + * This stores the loaded file information that we need on retrieval + */ +typedef struct FileHash_s +{ + char fileName[MAX_QPATH]; + qhandle_t handle; +} FileHash_t; + +/* + * CacheType_e + * Cache information specific to each file (FIXME: do we need?) + */ +enum CacheType_e +{ + CACHE_NONE, + CACHE_IMAGE, + CACHE_MODEL +}; + +/* + * CachedFile_t + * The actual data stored in the cache + */ +typedef struct CachedFile_s +{ + void *pDiskImage; // pointer to data loaded from disk + char fileName[MAX_QPATH]; // filename + int iLevelLastUsedOn; // level we last used this on + int iPAKChecksum; // -1 = not from PAK + int iAllocSize; // + + CacheType_e eCacheType; // determine which member of the uCache we're going to use + + CachedFile_s() + { + pDiskImage = NULL; + iLevelLastUsedOn = 0; + iPAKChecksum = -1; + eCacheType = CACHE_NONE; + memset(fileName, '\0', sizeof(fileName)); + iAllocSize = 0; + } +} CachedFile_t; + +/* assetCache_t and loadedMap_t are two definitions that are needed for the manager */ +typedef std::map assetCache_t; +typedef std::unordered_map loadedMap_t; + +/* The actual manager itself, which is used in the model and image loading routines. */ +class CCacheManager +{ +public: + qhandle_t SearchLoaded( const char *fileName ); + void InsertLoaded( const char *fileName, qhandle_t handle ); + + qboolean LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ); + void *Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ); + void DeleteAll( void ); + void DumpNonPure( void ); + + virtual qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ) = 0; +protected: + loadedMap_t loaded; + assetCache_t cache; +}; + +class CImageCacheManager : public CCacheManager +{ +public: + qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); +}; + +class CModelCacheManager : public CCacheManager +{ +public: + qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); +}; + +extern CImageCacheManager *CImgCache; +extern CModelCacheManager *CModelCache; + +qboolean C_Models_LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); +qboolean C_Images_LevelLoadEnd( void ); +void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload); +int C_GetLevel( void ); +void C_LevelLoadEnd( void ); #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 5257d0ba43..d9ec48e75e 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LL(x) x=LittleLong(x) -static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, int bufferSize, const char *modName); +static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, const char *modName); static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name ); static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); @@ -42,7 +42,6 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) unsigned *u; void *v; } buf; - int size; int lod; int ident; qboolean loaded = qfalse; @@ -70,27 +69,24 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) else Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); - size = ri->FS_ReadFile( namebuf, &buf.v ); - if(!buf.u) + qboolean bAlreadyCached = qfalse; + if( !CModelCache->LoadFile( namebuf, &buf.v, &bAlreadyCached ) ) continue; ident = LittleLong(* (unsigned *) buf.u); - // HACK until we get the model/image caching to mirror JKA --eez - qboolean temp = qtrue; - qboolean &temp2 = temp; switch(ident) { case MD4_IDENT: loaded = R_LoadMD4(mod, buf.u, name); break; case MD3_IDENT: - loaded = R_LoadMD3(mod, lod, buf.u, size, name); + loaded = R_LoadMD3(mod, lod, buf.u, name); break; case MDXA_IDENT: - loaded = R_LoadMDXA(mod, buf.u, name, temp2); + loaded = R_LoadMDXA(mod, buf.u, name, bAlreadyCached); break; case MDXM_IDENT: - loaded = R_LoadMDXM(mod, buf.u, name, temp2); + loaded = R_LoadMDXM(mod, buf.u, name, bAlreadyCached); break; default: ri->Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); @@ -296,18 +292,18 @@ qhandle_t RE_RegisterModel( const char *name ) { return 0; } + if( name[0] == '#' ) + { + // TODO: BSP models + return 0; + } + // // search the currently loaded models // - for ( hModel = 1 ; hModel < tr.numModels; hModel++ ) { - mod = tr.models[hModel]; - if ( !strcmp( mod->name, name ) ) { - if( mod->type == MOD_BAD ) { - return 0; - } - return hModel; - } - } + if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) + return hModel; + // allocate a new model_t @@ -455,7 +451,7 @@ void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const cha R_LoadMD3 ================= */ -static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, const char *modName) +static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modName) { int f, i, j, k; @@ -493,19 +489,23 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, int bufferSize, mod->type = MOD_MESH; size = LittleLong(md3Model->ofsEnd); mod->dataSize += size; - mdvModel = mod->mdv[lod] = (mdvModel_t *)ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); + //mdvModel = mod->mdv[lod] = (mdvModel_t *)ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); + qboolean bAlreadyFound = qfalse; + mdvModel = mod->mdv[lod] = (mdvModel_t *)CModelCache->Allocate( size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3 ); // Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); - - LL(md3Model->ident); - LL(md3Model->version); - LL(md3Model->numFrames); - LL(md3Model->numTags); - LL(md3Model->numSurfaces); - LL(md3Model->ofsFrames); - LL(md3Model->ofsTags); - LL(md3Model->ofsSurfaces); - LL(md3Model->ofsEnd); + if( !bAlreadyFound ) + { // HACK + LL(md3Model->ident); + LL(md3Model->version); + LL(md3Model->numFrames); + LL(md3Model->numTags); + LL(md3Model->numSurfaces); + LL(md3Model->ofsFrames); + LL(md3Model->ofsTags); + LL(md3Model->ofsSurfaces); + LL(md3Model->ofsEnd); + } if(md3Model->numFrames < 1) { From f79f98df3b3b8e21119ebb3ba4d9339002a3078f Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 13:33:44 -0400 Subject: [PATCH 064/708] MP: [rend2] Ported 00c1831edb4f5e0c6662d996171defbdc031dc88 from ioquake/ioq3 --- codemp/rd-rend2/tr_flares.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 2eb1ff873f..5615d1d947 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -353,7 +353,7 @@ void RB_RenderFlare( flare_t *f ) { VectorScale(f->color, f->drawIntensity * intensity, color); // Calculations for fogging - if(tr.world && f->fogNum < tr.world->numfogs) + if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) { tess.numVertexes = 1; VectorCopy(f->origin, tess.xyz[0]); From 7918eb172678378b70fe386eb8731a194536dfd3 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 13:36:37 -0400 Subject: [PATCH 065/708] MP: [rend2] Ported cb2fa48d65ab4f151a91c3ac4624f49e0600f49f from ioquake/ioq3 --- codemp/rd-rend2/tr_model.cpp | 24 ++++++++++++------------ codemp/rd-rend2/tr_model_iqm.cpp | 8 ++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index d9ec48e75e..13eec2c207 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -573,17 +573,17 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN LL(md3Surf->ofsXyzNormals); LL(md3Surf->ofsEnd); - if(md3Surf->numVerts > SHADER_MAX_VERTEXES) + if(md3Surf->numVerts >= SHADER_MAX_VERTEXES) { ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", - modName, SHADER_MAX_VERTEXES, md3Surf->name[0] ? md3Surf->name : "a surface", + modName, SHADER_MAX_VERTEXES - 1, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numVerts ); return qfalse; } - if(md3Surf->numTriangles * 3 > SHADER_MAX_INDEXES) + if(md3Surf->numTriangles * 3 >= SHADER_MAX_INDEXES) { ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", - modName, SHADER_MAX_INDEXES / 3, md3Surf->name[0] ? md3Surf->name : "a surface", + modName, ( SHADER_MAX_INDEXES / 3 ) - 1, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numTriangles ); return qfalse; } @@ -1074,17 +1074,17 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // numBoneReferences and BoneReferences generally seem to be unused // now do the checks that may fail. - if ( surf->numVerts > SHADER_MAX_VERTEXES ) + if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", + mod_name, SHADER_MAX_VERTEXES-1, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } - if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) + if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", - mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", + mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", surf->numTriangles ); return qfalse; } @@ -1291,15 +1291,15 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { LL(surf->ofsVerts); LL(surf->ofsEnd); - if ( surf->numVerts > SHADER_MAX_VERTEXES ) { + if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES, surf->name[0] ? surf->name : "a surface", + mod_name, SHADER_MAX_VERTEXES-1, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } - if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { + if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", - mod_name, SHADER_MAX_INDEXES / 3, surf->name[0] ? surf->name : "a surface", + mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", surf->numTriangles ); return qfalse; } diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 7e43b68b6c..bb69ef24f4 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -318,17 +318,17 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } // check ioq3 limits - if ( mesh->num_vertexes > SHADER_MAX_VERTEXES ) + if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES ) { ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES, meshName[0] ? meshName : "a surface", + mod_name, SHADER_MAX_VERTEXES-1, meshName[0] ? meshName : "a surface", mesh->num_vertexes ); return qfalse; } - if ( mesh->num_triangles*3 > SHADER_MAX_INDEXES ) + if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES ) { ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", - mod_name, SHADER_MAX_INDEXES / 3, meshName[0] ? meshName : "a surface", + mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface", mesh->num_triangles ); return qfalse; } From 2043740d09af4ed9d6a299f1af79b8fb78f3a9bf Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 13:38:47 -0400 Subject: [PATCH 066/708] MP: [rend2] Ported aa2ea68741f913b861c8e7ce6f0ac07a71c1f36a from ioquake/ioq3 --- codemp/rd-rend2/tr_model_iqm.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index bb69ef24f4..0197dd9959 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -953,10 +953,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { float jointMats[IQM_MAX_JOINTS * 12]; int i; - vec4_t *outXYZ = &tess.xyz[tess.numVertexes]; - vec4_t *outNormal = &tess.normal[tess.numVertexes]; - vec2_t (*outTexCoord)[2] = &tess.texCoords[tess.numVertexes]; - vec4_t *outColor = &tess.vertexColors[tess.numVertexes]; + vec4_t *outXYZ; + vec4_t *outNormal; + vec2_t (*outTexCoord)[2]; + vec4_t *outColor; int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; int oldframe = data->num_frames ? backEnd.currentEntity->e.oldframe % data->num_frames : 0; @@ -968,6 +968,11 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { RB_CHECKOVERFLOW( surf->num_vertexes, surf->num_triangles * 3 ); + outXYZ = &tess.xyz[tess.numVertexes]; + outNormal = &tess.normal[tess.numVertexes]; + outTexCoord = &tess.texCoords[tess.numVertexes]; + outColor = &tess.vertexColors[tess.numVertexes]; + // compute interpolated joint matrices if ( data->num_joints > 0 ) { ComputePoseMats( data, frame, oldframe, backlerp, jointMats ); From 0dc0798edce099685521007b6a80a5c94c0de72c Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 13:40:33 -0400 Subject: [PATCH 067/708] MP: [rend2] Ported 323e8b9921b50f785529e80ef83ddf632cddb881 from ioquake/ioq3 --- codemp/rd-rend2/tr_shade.cpp | 2 ++ codemp/rd-rend2/tr_world.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b73bcbae02..d90db517b8 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -415,6 +415,7 @@ static void ProjectDlightTexture( void ) { backEnd.pc.c_totalIndexes += tess.numIndexes; backEnd.pc.c_dlightIndexes += tess.numIndexes; + backEnd.pc.c_dlightVertexes += tess.numVertexes; } } @@ -874,6 +875,7 @@ static void ForwardDlight( void ) { backEnd.pc.c_totalIndexes += tess.numIndexes; backEnd.pc.c_dlightIndexes += tess.numIndexes; + backEnd.pc.c_dlightVertexes += tess.numVertexes; } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 5417cfcec0..2b9033a68d 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -218,6 +218,8 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { if ( dlightBits ) { tr.pc.c_dlightSurfaces++; + } else { + tr.pc.c_dlightSurfacesCulled++; } return dlightBits; From aad008288d68e7a2f65a9a4e0fe594c5902d2cdf Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 19:47:09 -0400 Subject: [PATCH 068/708] Ported 872465500e6952a611306f5c790ae7626ab73a27 to 01efe4a53890c102258e061ca9f18b742d127943 from ioquake/ioq3 --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 15 +- codemp/rd-rend2/glsl/generic_fp.glsl | 4 +- codemp/rd-rend2/glsl/generic_vp.glsl | 42 +- codemp/rd-rend2/glsl/lightall_fp.glsl | 521 ++++++++++------- codemp/rd-rend2/glsl/lightall_vp.glsl | 197 +++---- codemp/rd-rend2/glsl_shaders.cpp | 781 ++++++++++++++------------ codemp/rd-rend2/qgl.h | 5 + codemp/rd-rend2/tr_animation.cpp | 13 +- codemp/rd-rend2/tr_backend.cpp | 121 ++-- codemp/rd-rend2/tr_bsp.cpp | 764 ++++++++++++++++--------- codemp/rd-rend2/tr_extensions.cpp | 51 +- codemp/rd-rend2/tr_fbo.cpp | 14 + codemp/rd-rend2/tr_flares.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 10 +- codemp/rd-rend2/tr_glsl.cpp | 92 +-- codemp/rd-rend2/tr_image.cpp | 106 +++- codemp/rd-rend2/tr_init.cpp | 27 +- codemp/rd-rend2/tr_light.cpp | 33 +- codemp/rd-rend2/tr_local.h | 85 ++- codemp/rd-rend2/tr_main.cpp | 153 ++++- codemp/rd-rend2/tr_mesh.cpp | 5 +- codemp/rd-rend2/tr_model_iqm.cpp | 9 +- codemp/rd-rend2/tr_scene.cpp | 97 ++-- codemp/rd-rend2/tr_shade.cpp | 299 +++++----- codemp/rd-rend2/tr_shade_calc.cpp | 566 +------------------ codemp/rd-rend2/tr_shader.cpp | 100 +++- codemp/rd-rend2/tr_sky.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 11 +- codemp/rd-rend2/tr_vbo.cpp | 7 + codemp/rd-rend2/tr_world.cpp | 8 +- 30 files changed, 2237 insertions(+), 1905 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index f18bc7078c..ce0e015b3c 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -85,15 +85,12 @@ float CalcFog(vec4 position) float s = dot(position, u_FogDistance) * 8.0; float t = dot(position, u_FogDepth); - if (t < 1.0) - { - t = step(step(0.0, -u_FogEyeT), t); - } - else - { - t /= t - min(u_FogEyeT, 0.0); - } - + float eyeOutside = step(0.0, -u_FogEyeT); + float fogged = step(eyeOutside, t); + + t = max(t, 1e-6); + t *= fogged / (t - u_FogEyeT * eyeOutside); + return s * t; } diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index dea52e06a4..997d4daab0 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -20,8 +20,8 @@ void main() vec4 color = texture2D(u_DiffuseMap, var_DiffuseTex); #if defined(USE_LIGHTMAP) vec4 color2 = texture2D(u_LightMap, var_LightTex); - #if defined(RGBE_LIGHTMAP) - color2.rgb *= exp2(color2.a * 255.0 - 128.0); + #if defined(RGBM_LIGHTMAP) + color2.rgb *= 32.0 * color2.a; color2.a = 1.0; #endif diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 67360b1bfc..94e3c83e7c 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -17,7 +17,7 @@ uniform vec4 u_DiffuseTexMatrix; uniform vec4 u_DiffuseTexOffTurb; #if defined(USE_TCGEN) || defined(USE_RGBAGEN) -uniform vec3 u_ViewOrigin; +uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCGEN) @@ -48,7 +48,7 @@ uniform int u_ColorGen; uniform int u_AlphaGen; uniform vec3 u_AmbientLight; uniform vec3 u_DirectedLight; -uniform vec4 u_LightOrigin; +uniform vec3 u_ModelLightDir; uniform float u_PortalRange; #endif @@ -93,7 +93,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } else if (u_DeformGen == DGEN_WAVE_TRIANGLE) { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + func = 1.0 - abs(4.0 * fract(value + 0.25) - 2.0); } else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) { @@ -123,7 +123,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 } else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 viewer = normalize(u_LocalViewOrigin - position); tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; } else if (TCGen == TCGEN_VECTOR) @@ -158,30 +158,25 @@ vec4 CalcColor(vec3 position, vec3 normal) if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) { - float incoming = clamp(dot(normal, u_LightOrigin.xyz), 0.0, 1.0); + float incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0); color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); } - vec3 toView = u_ViewOrigin - position; - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 viewer = u_LocalViewOrigin - position; if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) { - vec3 lightDir = normalize(vec3(-960.0, -1980.0, 96.0) - position.xyz); - vec3 halfangle = normalize(lightDir + viewer); + vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position.xyz); + vec3 reflected = -reflect(lightDir, normal); - color.a = pow(max(dot(normal, halfangle), 0.0), 8.0); + color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); + color.a *= color.a; + color.a *= color.a; } else if (u_AlphaGen == AGEN_PORTAL) { - float alpha = length(toView) / u_PortalRange; - - color.a = clamp(alpha, 0.0, 1.0); - } - else if (u_AlphaGen == AGEN_FRESNEL) - { - color.a = 0.10 + 0.90 * pow(1.0 - dot(normal, viewer), 5); + color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); } return color; @@ -194,14 +189,11 @@ float CalcFog(vec4 position) float s = dot(position, u_FogDistance) * 8.0; float t = dot(position, u_FogDepth); - if (t < 1.0) - { - t = step(step(0.0, -u_FogEyeT), t); - } - else - { - t /= t - min(u_FogEyeT, 0.0); - } + float eyeOutside = step(0.0, -u_FogEyeT); + float fogged = step(eyeOutside, t); + + t = max(t, 1e-6); + t *= fogged / (t - u_FogEyeT * eyeOutside); return s * t; } diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 0b455dd66f..f223bb0cb4 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -20,73 +20,56 @@ uniform sampler2D u_SpecularMap; uniform sampler2D u_ShadowMap; #endif -uniform vec3 u_ViewOrigin; - -#if defined(USE_TCGEN) -uniform int u_TCGen0; +#if defined(USE_CUBEMAP) +uniform samplerCube u_CubeMap; #endif -#if defined(USE_LIGHT_VECTOR) -uniform vec4 u_LightOrigin; +#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) uniform vec3 u_DirectedLight; uniform vec3 u_AmbientLight; -uniform float u_LightRadius; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) uniform vec3 u_PrimaryLightColor; uniform vec3 u_PrimaryLightAmbient; -uniform float u_PrimaryLightRadius; #endif - -#if defined(USE_LIGHT) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) uniform vec2 u_MaterialInfo; #endif -varying vec2 var_DiffuseTex; -#if defined(USE_LIGHTMAP) -varying vec2 var_LightTex; -#endif -varying vec4 var_Color; - -#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) -varying vec3 var_Position; -#endif +varying vec4 var_TexCoords; -#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) -varying vec3 var_SampleToView; -#endif +varying vec4 var_Color; -#if !defined(USE_FAST_LIGHT) -varying vec3 var_Normal; +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) +varying vec4 var_Normal; +varying vec4 var_Tangent; +varying vec4 var_Bitangent; #endif -#if defined(USE_VERT_TANGENT_SPACE) -varying vec3 var_Tangent; -varying vec3 var_Bitangent; +#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) +varying vec3 var_LightColor; #endif -varying vec3 var_VertLight; - -#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) -varying vec3 var_LightDirection; +#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) +varying vec4 var_LightDir; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec3 var_PrimaryLightDirection; +varying vec4 var_PrimaryLightDir; #endif #define EPSILON 0.00000001 #if defined(USE_PARALLAXMAP) -float SampleHeight(sampler2D normalMap, vec2 t) +float SampleDepth(sampler2D normalMap, vec2 t) { #if defined(SWIZZLE_NORMALMAP) - return texture2D(normalMap, t).r; + return 1.0 - texture2D(normalMap, t).r; #else - return texture2D(normalMap, t).a; + return 1.0 - texture2D(normalMap, t).a; #endif } @@ -95,10 +78,8 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) const int linearSearchSteps = 16; const int binarySearchSteps = 6; - float depthStep = 1.0 / float(linearSearchSteps); - // current size of search window - float size = depthStep; + float size = 1.0 / float(linearSearchSteps); // current depth position float depth = 0.0; @@ -111,7 +92,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) { depth += size; - float t = 1.0 - SampleHeight(normalMap, dp + ds * depth); + float t = SampleDepth(normalMap, dp + ds * depth); if(bestDepth > 0.996) // if no depth found yet if(depth >= t) @@ -125,7 +106,7 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) { size *= 0.5; - float t = 1.0 - SampleHeight(normalMap, dp + ds * depth); + float t = SampleDepth(normalMap, dp + ds * depth); if(depth >= t) { @@ -157,7 +138,7 @@ vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, if (gamma >= 0.0) #endif { - B *= max(max(NL, NE), EPSILON); + B = max(B * max(NL, NE), EPSILON); } return diffuseAlbedo * (A + gamma / B); @@ -166,157 +147,233 @@ vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, #endif } -#if defined(USE_SPECULARMAP) -vec3 CalcSpecular(vec3 specularReflectance, float NH, float NL, float NE, float EH, float shininess) +vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) { - #if defined(USE_BLINN) || defined(USE_TRIACE) || defined(USE_TORRANCE_SPARROW) - float blinn = pow(NH, shininess); + #if 1 + // from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + vec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss; + t += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 ); + float a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z; + float a1 = t.w; + return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); + #elif 0 + // from http://seblagarde.wordpress.com/2011/08/17/hello-world/ + return mix(specular.rgb, max(specular.rgb, vec3(gloss)), CalcFresnel(NE)); + #else + // from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx + return mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss)); #endif +} - #if defined(USE_BLINN) - return specularReflectance * blinn; - #endif +float CalcBlinn(float NH, float shininess) +{ +#if 0 + // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ + float a = shininess + 0.775; + return exp(a * NH - a); +#else + return pow(NH, shininess); +#endif +} - #if defined(USE_COOK_TORRANCE) || defined (USE_TRIACE) || defined (USE_TORRANCE_SPARROW) - vec3 fresnel = specularReflectance + (vec3(1.0) - specularReflectance) * pow(1.0 - EH, 5); - #endif +float CalcGGX(float NH, float gloss) +{ + // from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf + float a_sq = exp2(gloss * -13.0 + 1.0); + float d = ((NH * NH) * (a_sq - 1.0) + 1.0); + return a_sq / (d * d); +} + +float CalcFresnel(float EH) +{ +#if 1 + // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + // not accurate, but fast + return exp2(-10.0 * EH); +#elif 0 + // From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ + return exp2((-5.55473 * EH - 6.98316) * EH); +#elif 0 + float blend = 1.0 - EH; + float blend2 = blend * blend; + blend *= blend2 * blend2; + + return blend; +#else + return pow(1.0 - EH, 5.0); +#endif +} - #if defined(USE_COOK_TORRANCE) || defined(USE_TORRANCE_SPARROW) +float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) +{ +#if 1 + // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + float k = min(1.0, gloss + 0.545); + return 1.0 / (k * EH * EH + (1.0 - k)); +#elif 0 + float roughness = exp2(gloss * -6.5); + + #if defined(USE_GGX) + // From http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf + float k = roughness + 1.0; + k *= k * 0.125; + #else + float k = roughness; + #endif + // Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf + // NL, NE in numerator factored out from cook-torrance + float k2 = 1.0 - k; + + float invGeo1 = NL * k2 + k; + float invGeo2 = NE * k2 + k; + + return 1.0 / (invGeo1 * invGeo2); +#else float geo = 2.0 * NH * min(NE, NL); geo /= max(EH, geo); - #endif - - #if defined(USE_COOK_TORRANCE) - float m_sq = 2.0 / max(shininess, EPSILON); - float NH_sq = NH * NH; - float m_NH_sq = m_sq * NH_sq; - float beckmann = exp((NH_sq - 1.0) / max(m_NH_sq, EPSILON)) / max(4.0 * m_NH_sq * NH_sq, EPSILON); + + return geo; +#endif +} - return fresnel * geo * beckmann / max(NE, EPSILON); - #endif - #if defined(USE_TRIACE) - float scale = 0.1248582 * shininess + 0.2691817; +vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess) +{ + float blinn = CalcBlinn(NH, shininess); + vec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH)); + float vis = CalcVisibility(NH, NL, NE, EH, gloss); - return fresnel * scale * blinn / max(max(NL, NE), EPSILON); + #if defined(USE_BLINN) + // Normalized Blinn-Phong + return specular * blinn * (shininess * 0.125 + 1.0); + #elif defined(USE_BLINN_FRESNEL) + // Normalized Blinn-Phong with Fresnel + return fSpecular * blinn * (shininess * 0.125 + 1.0); + #elif defined(USE_MCAULEY) + // Cook-Torrance as done by Stephen McAuley + // http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf + return fSpecular * blinn * (shininess * 0.25 + 0.125); + #elif defined(USE_GOTANDA) + // Neumann-Neumann as done by Yoshiharu Gotanda + // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf + return fSpecular * blinn * (shininess * 0.124858 + 0.269182) / max(max(NL, NE), EPSILON); + #elif defined(USE_LAZAROV) + // Cook-Torrance as done by Dimitar Lazarov + // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + return fSpecular * blinn * (shininess * 0.125 + 0.25) * vis; #endif - #if defined(USE_TORRANCE_SPARROW) - float scale = 0.125 * shininess + 1.0; + return vec3(0.0); +} - return fresnel * geo * scale * blinn / max(NE, EPSILON); - #endif + +float CalcLightAttenuation(vec3 dir, float sqrRadius) +{ + // point light at >0 radius, directional otherwise + float point = float(sqrRadius > 0.0); + + // inverse square light + float attenuation = sqrRadius / dot(dir, dir); + + // zero light at radius, approximating q3 style + // also don't attenuate directional light + attenuation = (0.5 * attenuation - 1.5) * point + 1.0; + + // clamp attenuation + #if defined(NO_LIGHT_CLAMP) + attenuation = max(attenuation, 0.0); + #else + attenuation = clamp(attenuation, 0.0, 1.0); + #endif + + return attenuation; } -#endif + void main() { -#if !defined(USE_FAST_LIGHT) && (defined(USE_LIGHT) || defined(USE_NORMALMAP)) - vec3 surfN = normalize(var_Normal); + vec3 L, N, E, H; + float NL, NH, NE, EH; + +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) + mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); #endif #if defined(USE_DELUXEMAP) - vec3 L = 2.0 * texture2D(u_DeluxeMap, var_LightTex).xyz - vec3(1.0); - //L += var_LightDirection * 0.0001; -#elif defined(USE_LIGHT) - vec3 L = var_LightDirection; + L = (2.0 * texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(1.0)); + #if defined(USE_TANGENT_SPACE_LIGHT) + L = L * tangentToWorld; + #endif +#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + L = var_LightDir.xyz; +#endif + +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) + E = normalize(vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w)); #endif #if defined(USE_LIGHTMAP) - vec4 lightSample = texture2D(u_LightMap, var_LightTex).rgba; - #if defined(RGBE_LIGHTMAP) - lightSample.rgb *= exp2(lightSample.a * 255.0 - 128.0); + vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw).rgba; + #if defined(RGBM_LIGHTMAP) + lightSample.rgb *= 32.0 * lightSample.a; #endif vec3 lightColor = lightSample.rgb; #elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) - #if defined(USE_INVSQRLIGHT) - float intensity = 1.0 / dot(L, L); - #else - float intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0); - #endif - - vec3 lightColor = u_DirectedLight * intensity; - vec3 ambientColor = u_AmbientLight; + vec3 lightColor = u_DirectedLight * CalcLightAttenuation(L, var_LightDir.w); + vec3 ambientColor = u_AmbientLight; #elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) - vec3 lightColor = var_VertLight; + vec3 lightColor = var_LightColor; #endif - -#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) - vec3 E = normalize(var_SampleToView); -#endif - vec2 texCoords = var_DiffuseTex; - float ambientDiff = 1.0; + vec2 texCoords = var_TexCoords.xy; -#if defined(USE_NORMALMAP) - #if defined(USE_VERT_TANGENT_SPACE) - mat3 tangentToWorld = mat3(var_Tangent, var_Bitangent, var_Normal); +#if defined(USE_PARALLAXMAP) + #if defined(USE_TANGENT_SPACE_LIGHT) + vec3 offsetDir = E; #else - vec3 q0 = dFdx(var_Position); - vec3 q1 = dFdy(var_Position); - vec2 st0 = dFdx(texCoords); - vec2 st1 = dFdy(texCoords); - float dir = sign(st1.t * st0.s - st0.t * st1.s); - - vec3 tangent = normalize(q0 * st1.t - q1 * st0.t) * dir; - vec3 bitangent = -normalize(q0 * st1.s - q1 * st0.s) * dir; - - mat3 tangentToWorld = mat3(tangent, bitangent, var_Normal); + vec3 offsetDir = E * tangentToWorld; #endif - #if defined(USE_PARALLAXMAP) - vec3 offsetDir = normalize(E * tangentToWorld); offsetDir.xy *= -0.05 / offsetDir.z; texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); - #endif - vec3 texN; - #if defined(SWIZZLE_NORMALMAP) - texN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - 1.0; - #else - texN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - 1.0; - #endif - texN.z = sqrt(clamp(1.0 - dot(texN.xy, texN.xy), 0.0, 1.0)); - vec3 N = tangentToWorld * texN; - #if defined(r_normalAmbient) - ambientDiff = 0.781341 * texN.z + 0.218659; - #endif -#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 N = surfN; -#endif - -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || (defined(USE_TCGEN) && defined(USE_NORMALMAP)) - N = normalize(N); #endif -#if defined(USE_TCGEN) && defined(USE_NORMALMAP) - if (u_TCGen0 == TCGEN_ENVIRONMENT_MAPPED) - { - texCoords = -reflect(E, N).yz * vec2(0.5, -0.5) + 0.5; - } + vec4 diffuse = texture2D(u_DiffuseMap, texCoords); +#if defined(USE_GAMMA2_TEXTURES) + diffuse.rgb *= diffuse.rgb; #endif - vec4 diffuseAlbedo = texture2D(u_DiffuseMap, texCoords); -#if defined(USE_LIGHT) && defined(USE_GAMMA2_TEXTURES) - diffuseAlbedo.rgb *= diffuseAlbedo.rgb; -#endif -#if defined(USE_LIGHT) && defined(USE_FAST_LIGHT) - gl_FragColor = diffuse.rgb; - #if defined(USE_LIGHTMAP) - gl_FragColor *= lightColor; +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_NORMALMAP) + #if defined(SWIZZLE_NORMALMAP) + N.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - vec2(1.0); + #else + N.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - vec2(1.0); + #endif + N.z = sqrt(1.0 - clamp(dot(N.xy, N.xy), 0.0, 1.0)); + #if !defined(USE_TANGENT_SPACE_LIGHT) + N = normalize(tangentToWorld * N); + #endif + #elif defined(USE_TANGENT_SPACE_LIGHT) + N = vec3(0.0, 0.0, 1.0); + #else + N = normalize(var_Normal.xyz); #endif -#elif defined(USE_LIGHT) + L = normalize(L); - float surfNL = clamp(dot(surfN, L), 0.0, 1.0); - #if defined(USE_SHADOWMAP) vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; float shadowValue = texture2D(u_ShadowMap, shadowTex).r; // surfaces not facing the light are always shadowed - shadowValue *= step(0.0, dot(surfN, var_PrimaryLightDirection)); + #if defined(USE_TANGENT_SPACE_LIGHT) + shadowValue *= step(0.0, var_PrimaryLightDir.z); + #else + shadowValue *= step(0.0, dot(var_Normal.xyz, var_PrimaryLightDir.xyz)); + #endif #if defined(SHADOWMAP_MODULATE) //vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor); @@ -324,106 +381,136 @@ void main() #if 0 // Only shadow when the world light is parallel to the primary light - shadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDirection), 0.0, 1.0); + shadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDir.xyz), 0.0, 1.0); #endif lightColor = mix(shadowColor, lightColor, shadowValue); #endif #endif #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) - #if defined(USE_STANDARD_DELUXEMAP) - // Standard deluxe mapping treats the light sample as fully directed - // and doesn't compensate for light angle attenuation. - vec3 ambientColor = vec3(0.0); - #else - // Separate the light sample into directed and ambient parts. - // - // ambientMax - if the cosine of the angle between the surface - // normal and the light is below this value, the light - // is fully ambient. - // directedMax - if the cosine of the angle between the surface - // normal and the light is above this value, the light - // is fully directed. - const float ambientMax = 0.25; - const float directedMax = 0.5; - - float directedScale = clamp((surfNL - ambientMax) / (directedMax - ambientMax), 0.0, 1.0); - - // Scale the directed portion to compensate for the baked-in - // light angle attenuation. - directedScale /= max(surfNL, ambientMax); - - #if defined(r_normalAmbient) - directedScale *= 1.0 - r_normalAmbient; - #endif - - // Recover any unused light as ambient vec3 ambientColor = lightColor; - lightColor *= directedScale; + + #if defined(USE_TANGENT_SPACE_LIGHT) + float surfNL = L.z; + #else + float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); + #endif + + // Scale the incoming light to compensate for the baked-in light angle + // attenuation. + lightColor /= max(surfNL, 0.25); + + // Recover any unused light as ambient, in case attenuation is over 4x or + // light is below the surface ambientColor -= lightColor * surfNL; - #endif #endif + + vec3 reflectance; - float NL = clamp(dot(N, L), 0.0, 1.0); - float NE = clamp(dot(N, E), 0.0, 1.0); - - float maxReflectance = u_MaterialInfo.x; - float shininess = u_MaterialInfo.y; + NL = clamp(dot(N, L), 0.0, 1.0); + NE = clamp(dot(N, E), 0.0, 1.0); #if defined(USE_SPECULARMAP) - vec4 specularReflectance = texture2D(u_SpecularMap, texCoords); - specularReflectance.rgb *= maxReflectance; - shininess *= specularReflectance.a; - // adjust diffuse by specular reflectance, to maintain energy conservation - diffuseAlbedo.rgb *= vec3(1.0) - specularReflectance.rgb; + vec4 specular = texture2D(u_SpecularMap, texCoords); + #if defined(USE_GAMMA2_TEXTURES) + specular.rgb *= specular.rgb; + #endif + #else + vec4 specular = vec4(1.0); #endif - gl_FragColor.rgb = lightColor * NL * CalcDiffuse(diffuseAlbedo.rgb, N, L, E, NE, NL, shininess); - gl_FragColor.rgb += ambientDiff * ambientColor * diffuseAlbedo.rgb; - #if defined(USE_PRIMARY_LIGHT) - vec3 L2 = var_PrimaryLightDirection; - float NL2 = clamp(dot(N, L2), 0.0, 1.0); + specular *= u_MaterialInfo.xxxy; + + float gloss = specular.a; + float shininess = exp2(gloss * 13.0); - #if defined(USE_SHADOWMAP) - gl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess); - #else - gl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess); - #endif + #if defined(SPECULAR_IS_METALLIC) + // diffuse is actually base color, and red of specular is metallicness + float metallic = specular.r; + + specular.rgb = vec3(0.04) + 0.96 * diffuse.rgb * metallic; + diffuse.rgb *= 1.0 - metallic; + #else + // adjust diffuse by specular reflectance, to maintain energy conservation + diffuse.rgb *= vec3(1.0) - specular.rgb; #endif - #if defined(USE_SPECULARMAP) - vec3 H = normalize(L + E); + + reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess); + + #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR) + float adjGloss = gloss; + float adjShininess = shininess; + + #if !defined(USE_LIGHT_VECTOR) + adjGloss *= r_deluxeSpecular; + adjShininess = exp2(adjGloss * 13.0); + #endif + + H = normalize(L + E); - float EH = clamp(dot(E, H), 0.0, 1.0); - float NH = clamp(dot(N, H), 0.0, 1.0); + EH = clamp(dot(E, H), 0.0, 1.0); + NH = clamp(dot(N, H), 0.0, 1.0); - gl_FragColor.rgb += lightColor * NL * CalcSpecular(specularReflectance.rgb, NH, NL, NE, EH, shininess); - - #if defined(r_normalAmbient) - vec3 ambientHalf = normalize(surfN + E); - float ambientSpec = max(dot(ambientHalf, N) + 0.5, 0.0); - ambientSpec *= ambientSpec * 0.44; - gl_FragColor.rgb += specularReflectance.rgb * ambientSpec * ambientColor; + #if !defined(USE_LIGHT_VECTOR) + reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess) * r_deluxeSpecular; + #else + reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess); #endif + #endif + + gl_FragColor.rgb = lightColor * reflectance * NL; + gl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb); + + #if defined(USE_CUBEMAP) + reflectance = EnvironmentBRDF(gloss, NE, specular.rgb); + + vec3 R = reflect(E, N); + #if defined(USE_TANGENT_SPACE_LIGHT) + R = tangentToWorld * R; + #endif + + vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb; + + #if defined(USE_LIGHTMAP) + cubeLightColor *= lightSample.rgb; + #elif defined (USE_LIGHT_VERTEX) + cubeLightColor *= var_LightColor; + #else + cubeLightColor *= lightColor * NL + ambientColor; + #endif + + //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb; + gl_FragColor.rgb += cubeLightColor * reflectance; + #endif - #if defined(USE_PRIMARY_LIGHT) - vec3 H2 = normalize(L2 + E); - float EH2 = clamp(dot(E, H2), 0.0, 1.0); - float NH2 = clamp(dot(N, H2), 0.0, 1.0); + #if defined(USE_PRIMARY_LIGHT) + L = var_PrimaryLightDir.xyz; //normalize(var_PrimaryLightDir.xyz); + NL = clamp(dot(N, L), 0.0, 1.0); + H = normalize(L + E); + EH = clamp(dot(E, H), 0.0, 1.0); + NH = clamp(dot(N, H), 0.0, 1.0); - #if defined(USE_SHADOWMAP) - gl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess); - #else - gl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess); - #endif + reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess); + reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss, shininess); + + lightColor = u_PrimaryLightColor; // * CalcLightAttenuation(L, u_PrimaryLightDir.w); + + #if defined(USE_SHADOWMAP) + lightColor *= shadowValue; #endif - #endif + + gl_FragColor.rgb += lightColor * reflectance * NL; + #endif + + gl_FragColor.a = diffuse.a; #else - gl_FragColor.rgb = diffuseAlbedo.rgb; + gl_FragColor = diffuse; + #if defined(USE_LIGHTMAP) + gl_FragColor.rgb *= lightColor; + #endif #endif - gl_FragColor.a = diffuseAlbedo.a; - gl_FragColor *= var_Color; } diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 03775caf42..ce83d10ae9 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -4,21 +4,16 @@ attribute vec4 attr_TexCoord1; #endif attribute vec4 attr_Color; -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec3 attr_Normal; - -#if defined(USE_VERT_TANGENT_SPACE) attribute vec3 attr_Tangent; attribute vec3 attr_Bitangent; -#endif #if defined(USE_VERTEX_ANIMATION) -attribute vec4 attr_Position2; +attribute vec3 attr_Position2; attribute vec3 attr_Normal2; - #if defined(USE_VERT_TANGENT_SPACE) attribute vec3 attr_Tangent2; attribute vec3 attr_Bitangent2; - #endif #endif #if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) @@ -27,6 +22,7 @@ attribute vec3 attr_LightDirection; #if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) uniform vec3 u_ViewOrigin; +uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCGEN) @@ -54,52 +50,38 @@ uniform float u_VertexLerp; #if defined(USE_LIGHT_VECTOR) uniform vec4 u_LightOrigin; - #if defined(USE_FAST_LIGHT) +uniform float u_LightRadius; uniform vec3 u_DirectedLight; + #if defined(USE_FAST_LIGHT) uniform vec3 u_AmbientLight; -uniform float u_LightRadius; #endif #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) uniform vec4 u_PrimaryLightOrigin; +uniform float u_PrimaryLightRadius; #endif -varying vec2 var_DiffuseTex; - -#if defined(USE_LIGHTMAP) -varying vec2 var_LightTex; -#endif - -#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) -varying vec3 var_SampleToView; -#endif +varying vec4 var_TexCoords; varying vec4 var_Color; -#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) -varying vec3 var_Position; -#endif - - -#if !defined(USE_FAST_LIGHT) -varying vec3 var_Normal; - #if defined(USE_VERT_TANGENT_SPACE) -varying vec3 var_Tangent; -varying vec3 var_Bitangent; - #endif +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) +varying vec4 var_Normal; +varying vec4 var_Tangent; +varying vec4 var_Bitangent; #endif #if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) -varying vec3 var_VertLight; +varying vec3 var_LightColor; #endif #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) -varying vec3 var_LightDirection; +varying vec4 var_LightDir; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec3 var_PrimaryLightDirection; +varying vec4 var_PrimaryLightDir; #endif #if defined(USE_TCGEN) @@ -113,7 +95,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 } else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) { - vec3 viewer = normalize(u_ViewOrigin - position); + vec3 viewer = normalize(u_LocalViewOrigin - position); tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; } else if (TCGen == TCGEN_VECTOR) @@ -132,7 +114,7 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) float phase = offTurb.w; vec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy; - vec3 offsetPos = vec3(0); //position / 1024.0; + vec3 offsetPos = position / 1024.0; offsetPos.x += offsetPos.z; vec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI); @@ -142,104 +124,127 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) #endif +float CalcLightAttenuation(vec3 dir, float sqrRadius) +{ + // point light at >0 radius, directional otherwise + float point = float(sqrRadius > 0.0); + + // inverse square light + float attenuation = sqrRadius / dot(dir, dir); + + // zero light at radius, approximating q3 style + // also don't attenuate directional light + attenuation = (0.5 * attenuation - 1.5) * point + 1.0; + + // clamp attenuation + #if defined(NO_LIGHT_CLAMP) + attenuation = max(attenuation, 0.0); + #else + attenuation = clamp(attenuation, 0.0, 1.0); + #endif + + return attenuation; +} + + void main() { #if defined(USE_VERTEX_ANIMATION) - vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); - #if defined(USE_VERT_TANGENT_SPACE) vec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp)); vec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp)); - #endif #else - vec4 position = attr_Position; + vec3 position = attr_Position; vec3 normal = attr_Normal; - #if defined(USE_VERT_TANGENT_SPACE) vec3 tangent = attr_Tangent; vec3 bitangent = attr_Bitangent; - #endif -#endif - - gl_Position = u_ModelViewProjectionMatrix * position; - -#if (defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) - vec3 L = attr_LightDirection; -#endif - -#if defined(USE_MODELMATRIX) - position = u_ModelMatrix * position; - normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; - #if defined(USE_VERT_TANGENT_SPACE) - tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; - bitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz; - #endif - - #if defined(USE_LIGHTMAP) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) - L = (u_ModelMatrix * vec4(L, 0.0)).xyz; - #endif -#endif - -#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE) - var_Position = position.xyz; -#endif - -#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) - var_SampleToView = u_ViewOrigin - position.xyz; #endif #if defined(USE_TCGEN) - vec2 texCoords = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 texCoords = attr_TexCoord0.st; #endif #if defined(USE_TCMOD) - var_DiffuseTex = ModTexCoords(texCoords, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); + var_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); #else - var_DiffuseTex = texCoords; + var_TexCoords.xy = texCoords; #endif -#if defined(USE_LIGHTMAP) - var_LightTex = attr_TexCoord1.st; + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + +#if defined(USE_MODELMATRIX) + position = (u_ModelMatrix * vec4(position, 1.0)).xyz; + normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; + tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; + bitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz; #endif -#if !defined(USE_FAST_LIGHT) - var_Normal = normal; - #if defined(USE_VERT_TANGENT_SPACE) - var_Tangent = tangent; - var_Bitangent = bitangent; +#if defined(USE_LIGHT_VECTOR) + vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); +#elif defined(USE_LIGHT) && !defined(USE_DELUXEMAP) + vec3 L = attr_LightDirection; + #if defined(USE_MODELMATRIX) + L = (u_ModelMatrix * vec4(L, 0.0)).xyz; #endif #endif -#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) - #if defined(USE_LIGHT_VECTOR) - vec3 L = u_LightOrigin.xyz - (position.xyz * u_LightOrigin.w); - #endif - #if !defined(USE_FAST_LIGHT) - var_LightDirection = L; - #endif +#if defined(USE_LIGHTMAP) + var_TexCoords.zw = attr_TexCoord1.st; #endif + var_Color = u_VertColor * attr_Color + u_BaseColor; #if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) - var_VertLight = u_VertColor.rgb * attr_Color.rgb; + var_LightColor = var_Color.rgb; var_Color.rgb = vec3(1.0); - var_Color.a = u_VertColor.a * attr_Color.a + u_BaseColor.a; -#else - var_Color = u_VertColor * attr_Color + u_BaseColor; #endif #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - #if defined(USE_INVSQRLIGHT) - float intensity = 1.0 / dot(L, L); - #else - float intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0); - #endif + float attenuation = CalcLightAttenuation(L, u_LightRadius * u_LightRadius); float NL = clamp(dot(normal, normalize(L)), 0.0, 1.0); - var_Color.rgb *= u_DirectedLight * intensity * NL + u_AmbientLight; + var_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) - var_PrimaryLightDirection = u_PrimaryLightOrigin.xyz - (position.xyz * u_PrimaryLightOrigin.w); -#endif + var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); + var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; +#endif + +#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) + #if defined(USE_LIGHT_VECTOR) + var_LightDir = vec4(L, u_LightRadius * u_LightRadius); + #else + var_LightDir = vec4(L, 0.0); + #endif +#endif + +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) + vec3 viewDir = u_ViewOrigin - position; +#endif + +#if defined(USE_TANGENT_SPACE_LIGHT) + mat3 tangentToWorld = mat3(tangent, bitangent, normal); + + #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) + var_PrimaryLightDir.xyz = var_PrimaryLightDir.xyz * tangentToWorld; + #endif + + #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) + var_LightDir.xyz = var_LightDir.xyz * tangentToWorld; + #endif + + #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) + viewDir = viewDir * tangentToWorld; + #endif +#endif + +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) + // store view direction in tangent space to save on varyings + var_Normal = vec4(normal, viewDir.x); + var_Tangent = vec4(tangent, viewDir.y); + var_Bitangent = vec4(bitangent, viewDir.z); +#endif } diff --git a/codemp/rd-rend2/glsl_shaders.cpp b/codemp/rd-rend2/glsl_shaders.cpp index 071a820f2a..864405ee1a 100644 --- a/codemp/rd-rend2/glsl_shaders.cpp +++ b/codemp/rd-rend2/glsl_shaders.cpp @@ -491,15 +491,12 @@ const char *fallbackShader_fogpass_vp = "\tfloat s = dot(position, u_FogDistance) * 8.0;\n" "\tfloat t = dot(position, u_FogDepth);\n" "\n" -"\tif (t < 1.0)\n" -"\t{\n" -"\t\tt = step(step(0.0, -u_FogEyeT), t);\n" -"\t}\n" -"\telse\n" -"\t{\n" -"\t\tt /= t - min(u_FogEyeT, 0.0);\n" -"\t}\n" -"\t\n" +"\tfloat eyeOutside = step(0.0, -u_FogEyeT);\n" +"\tfloat fogged = step(eyeOutside, t);\n" +"\t\t\n" +"\tt = max(t, 1e-6);\n" +"\tt *= fogged / (t - u_FogEyeT * eyeOutside);\n" +"\n" "\treturn s * t;\n" "}\n" "\n" @@ -545,8 +542,8 @@ const char *fallbackShader_generic_fp = "\tvec4 color = texture2D(u_DiffuseMap, var_DiffuseTex);\n" "#if defined(USE_LIGHTMAP)\n" "\tvec4 color2 = texture2D(u_LightMap, var_LightTex);\n" -" #if defined(RGBE_LIGHTMAP)\n" -"\tcolor2.rgb *= exp2(color2.a * 255.0 - 128.0);\n" +" #if defined(RGBM_LIGHTMAP)\n" +"\tcolor2.rgb *= 32.0 * color2.a;\n" "\tcolor2.a = 1.0;\n" " #endif\n" "\n" @@ -587,7 +584,7 @@ const char *fallbackShader_generic_vp = "uniform vec4 u_DiffuseTexOffTurb;\n" "\n" "#if defined(USE_TCGEN) || defined(USE_RGBAGEN)\n" -"uniform vec3 u_ViewOrigin;\n" +"uniform vec3 u_LocalViewOrigin;\n" "#endif\n" "\n" "#if defined(USE_TCGEN)\n" @@ -618,7 +615,7 @@ const char *fallbackShader_generic_vp = "uniform int u_AlphaGen;\n" "uniform vec3 u_AmbientLight;\n" "uniform vec3 u_DirectedLight;\n" -"uniform vec4 u_LightOrigin;\n" +"uniform vec3 u_ModelLightDir;\n" "uniform float u_PortalRange;\n" "#endif\n" "\n" @@ -663,7 +660,7 @@ const char *fallbackShader_generic_vp = "\t}\n" "\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" "\t{\n" -"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" +"\t\tfunc = 1.0 - abs(4.0 * fract(value + 0.25) - 2.0);\n" "\t}\n" "\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" "\t{\n" @@ -693,7 +690,7 @@ const char *fallbackShader_generic_vp = "\t}\n" "\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" "\t{\n" -"\t\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\t\tvec3 viewer = normalize(u_LocalViewOrigin - position);\n" "\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" "\t}\n" "\telse if (TCGen == TCGEN_VECTOR)\n" @@ -728,30 +725,25 @@ const char *fallbackShader_generic_vp = "\t\n" "\tif (u_ColorGen == CGEN_LIGHTING_DIFFUSE)\n" "\t{\n" -"\t\tfloat incoming = clamp(dot(normal, u_LightOrigin.xyz), 0.0, 1.0);\n" +"\t\tfloat incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0);\n" "\n" "\t\tcolor.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0);\n" "\t}\n" "\t\n" -"\tvec3 toView = u_ViewOrigin - position;\n" -"\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\tvec3 viewer = u_LocalViewOrigin - position;\n" "\n" "\tif (u_AlphaGen == AGEN_LIGHTING_SPECULAR)\n" "\t{\n" -"\t\tvec3 lightDir = normalize(vec3(-960.0, -1980.0, 96.0) - position.xyz);\n" -"\t\tvec3 halfangle = normalize(lightDir + viewer);\n" +"\t\tvec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position.xyz);\n" +"\t\tvec3 reflected = -reflect(lightDir, normal);\n" "\t\t\n" -"\t\tcolor.a = pow(max(dot(normal, halfangle), 0.0), 8.0);\n" +"\t\tcolor.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0);\n" +"\t\tcolor.a *= color.a;\n" +"\t\tcolor.a *= color.a;\n" "\t}\n" "\telse if (u_AlphaGen == AGEN_PORTAL)\n" "\t{\n" -"\t\tfloat alpha = length(toView) / u_PortalRange;\n" -"\n" -"\t\tcolor.a = clamp(alpha, 0.0, 1.0);\n" -"\t}\n" -"\telse if (u_AlphaGen == AGEN_FRESNEL)\n" -"\t{\n" -"\t\tcolor.a = 0.10 + 0.90 * pow(1.0 - dot(normal, viewer), 5);\n" +"\t\tcolor.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0);\n" "\t}\n" "\t\n" "\treturn color;\n" @@ -764,14 +756,11 @@ const char *fallbackShader_generic_vp = "\tfloat s = dot(position, u_FogDistance) * 8.0;\n" "\tfloat t = dot(position, u_FogDepth);\n" "\n" -"\tif (t < 1.0)\n" -"\t{\n" -"\t\tt = step(step(0.0, -u_FogEyeT), t);\n" -"\t}\n" -"\telse\n" -"\t{\n" -"\t\tt /= t - min(u_FogEyeT, 0.0);\n" -"\t}\n" +"\tfloat eyeOutside = step(0.0, -u_FogEyeT);\n" +"\tfloat fogged = step(eyeOutside, t);\n" +"\t\t\n" +"\tt = max(t, 1e-6);\n" +"\tt *= fogged / (t - u_FogEyeT * eyeOutside);\n" "\n" "\treturn s * t;\n" "}\n" @@ -843,73 +832,56 @@ const char *fallbackShader_lightall_fp = "uniform sampler2D u_ShadowMap;\n" "#endif\n" "\n" -"uniform vec3 u_ViewOrigin;\n" -"\n" -"#if defined(USE_TCGEN)\n" -"uniform int u_TCGen0;\n" +"#if defined(USE_CUBEMAP)\n" +"uniform samplerCube u_CubeMap;\n" "#endif\n" "\n" -"#if defined(USE_LIGHT_VECTOR)\n" -"uniform vec4 u_LightOrigin;\n" +"#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)\n" "uniform vec3 u_DirectedLight;\n" "uniform vec3 u_AmbientLight;\n" -"uniform float u_LightRadius;\n" "#endif\n" "\n" "#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" "uniform vec3 u_PrimaryLightColor;\n" "uniform vec3 u_PrimaryLightAmbient;\n" -"uniform float u_PrimaryLightRadius;\n" "#endif\n" "\n" -"\n" -"#if defined(USE_LIGHT)\n" +"#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" "uniform vec2 u_MaterialInfo;\n" "#endif\n" "\n" -"varying vec2 var_DiffuseTex;\n" -"#if defined(USE_LIGHTMAP)\n" -"varying vec2 var_LightTex;\n" -"#endif\n" -"varying vec4 var_Color;\n" -"\n" -"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" -"varying vec3 var_Position;\n" -"#endif\n" +"varying vec4 var_TexCoords;\n" "\n" -"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" -"varying vec3 var_SampleToView;\n" -"#endif\n" +"varying vec4 var_Color;\n" "\n" -"#if !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_Normal;\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"varying vec4 var_Normal;\n" +"varying vec4 var_Tangent;\n" +"varying vec4 var_Bitangent;\n" "#endif\n" "\n" -"#if defined(USE_VERT_TANGENT_SPACE)\n" -"varying vec3 var_Tangent;\n" -"varying vec3 var_Bitangent;\n" +"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" +"varying vec3 var_LightColor;\n" "#endif\n" "\n" -"varying vec3 var_VertLight;\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" -"varying vec3 var_LightDirection;\n" +"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +"varying vec4 var_LightDir;\n" "#endif\n" "\n" "#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"varying vec3 var_PrimaryLightDirection;\n" +"varying vec4 var_PrimaryLightDir;\n" "#endif\n" "\n" "\n" "#define EPSILON 0.00000001\n" "\n" "#if defined(USE_PARALLAXMAP)\n" -"float SampleHeight(sampler2D normalMap, vec2 t)\n" +"float SampleDepth(sampler2D normalMap, vec2 t)\n" "{\n" " #if defined(SWIZZLE_NORMALMAP)\n" -"\treturn texture2D(normalMap, t).r;\n" +"\treturn 1.0 - texture2D(normalMap, t).r;\n" " #else\n" -"\treturn texture2D(normalMap, t).a;\n" +"\treturn 1.0 - texture2D(normalMap, t).a;\n" " #endif\n" "}\n" "\n" @@ -918,10 +890,8 @@ const char *fallbackShader_lightall_fp = "\tconst int linearSearchSteps = 16;\n" "\tconst int binarySearchSteps = 6;\n" "\n" -"\tfloat depthStep = 1.0 / float(linearSearchSteps);\n" -"\n" "\t// current size of search window\n" -"\tfloat size = depthStep;\n" +"\tfloat size = 1.0 / float(linearSearchSteps);\n" "\n" "\t// current depth position\n" "\tfloat depth = 0.0;\n" @@ -934,7 +904,7 @@ const char *fallbackShader_lightall_fp = "\t{\n" "\t\tdepth += size;\n" "\t\t\n" -"\t\tfloat t = 1.0 - SampleHeight(normalMap, dp + ds * depth);\n" +"\t\tfloat t = SampleDepth(normalMap, dp + ds * depth);\n" "\t\t\n" "\t\tif(bestDepth > 0.996)\t\t// if no depth found yet\n" "\t\t\tif(depth >= t)\n" @@ -948,7 +918,7 @@ const char *fallbackShader_lightall_fp = "\t{\n" "\t\tsize *= 0.5;\n" "\n" -"\t\tfloat t = 1.0 - SampleHeight(normalMap, dp + ds * depth);\n" +"\t\tfloat t = SampleDepth(normalMap, dp + ds * depth);\n" "\t\t\n" "\t\tif(depth >= t)\n" "\t\t{\n" @@ -980,7 +950,7 @@ const char *fallbackShader_lightall_fp = "\tif (gamma >= 0.0)\n" " #endif\n" "\t{\n" -"\t\tB *= max(max(NL, NE), EPSILON);\n" +"\t\tB = max(B * max(NL, NE), EPSILON);\n" "\t}\n" "\n" "\treturn diffuseAlbedo * (A + gamma / B);\n" @@ -989,157 +959,233 @@ const char *fallbackShader_lightall_fp = " #endif\n" "}\n" "\n" -"#if defined(USE_SPECULARMAP)\n" -"vec3 CalcSpecular(vec3 specularReflectance, float NH, float NL, float NE, float EH, float shininess)\n" +"vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular)\n" "{\n" -" #if defined(USE_BLINN) || defined(USE_TRIACE) || defined(USE_TORRANCE_SPARROW)\n" -"\tfloat blinn = pow(NH, shininess);\n" +" #if 1\n" +"\t// from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" +"\tvec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss;\n" +"\tt += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 );\n" +"\tfloat a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z;\n" +"\tfloat a1 = t.w;\n" +"\treturn clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 );\n" +" #elif 0\n" +" // from http://seblagarde.wordpress.com/2011/08/17/hello-world/\n" +"\treturn mix(specular.rgb, max(specular.rgb, vec3(gloss)), CalcFresnel(NE));\n" +" #else\n" +" // from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx\n" +"\treturn mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss));\n" " #endif\n" +"}\n" "\n" -" #if defined(USE_BLINN)\n" -"\treturn specularReflectance * blinn;\n" -" #endif\n" +"float CalcBlinn(float NH, float shininess)\n" +"{\n" +"#if 0\n" +" // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/\n" +"\tfloat a = shininess + 0.775;\n" +" return exp(a * NH - a);\n" +"#else\n" +"\treturn pow(NH, shininess);\n" +"#endif\n" +"}\n" "\n" -" #if defined(USE_COOK_TORRANCE) || defined (USE_TRIACE) || defined (USE_TORRANCE_SPARROW)\n" -"\tvec3 fresnel = specularReflectance + (vec3(1.0) - specularReflectance) * pow(1.0 - EH, 5);\n" -" #endif\n" +"float CalcGGX(float NH, float gloss)\n" +"{\n" +"\t// from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" +"\tfloat a_sq = exp2(gloss * -13.0 + 1.0);\n" +"\tfloat d = ((NH * NH) * (a_sq - 1.0) + 1.0);\n" +"\treturn a_sq / (d * d);\n" +"}\n" +"\n" +"float CalcFresnel(float EH)\n" +"{\n" +"#if 1\n" +"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" +"\t// not accurate, but fast\n" +"\treturn exp2(-10.0 * EH);\n" +"#elif 0\n" +"\t// From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/\n" +"\treturn exp2((-5.55473 * EH - 6.98316) * EH);\n" +"#elif 0\n" +"\tfloat blend = 1.0 - EH;\n" +"\tfloat blend2 = blend * blend;\n" +"\tblend *= blend2 * blend2;\n" +"\t\n" +"\treturn blend;\n" +"#else\n" +"\treturn pow(1.0 - EH, 5.0);\n" +"#endif\n" +"}\n" "\n" -" #if defined(USE_COOK_TORRANCE) || defined(USE_TORRANCE_SPARROW)\n" +"float CalcVisibility(float NH, float NL, float NE, float EH, float gloss)\n" +"{\n" +"#if 1\n" +"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" +"\tfloat k = min(1.0, gloss + 0.545);\n" +"\treturn 1.0 / (k * EH * EH + (1.0 - k));\n" +"#elif 0\n" +"\tfloat roughness = exp2(gloss * -6.5);\n" +"\n" +" #if defined(USE_GGX)\n" +"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" +"\tfloat k = roughness + 1.0;\n" +"\tk *= k * 0.125;\n" +" #else\n" +" float k = roughness;\n" +" #endif\n" +"\t// Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" +"\t// NL, NE in numerator factored out from cook-torrance\n" +"\tfloat k2 = 1.0 - k;\n" +"\t\n" +"\tfloat invGeo1 = NL * k2 + k;\n" +"\tfloat invGeo2 = NE * k2 + k;\n" +"\t\n" +"\treturn 1.0 / (invGeo1 * invGeo2);\n" +"#else\n" "\tfloat geo = 2.0 * NH * min(NE, NL);\n" "\tgeo /= max(EH, geo);\n" -" #endif \n" -"\n" -" #if defined(USE_COOK_TORRANCE)\n" -"\tfloat m_sq = 2.0 / max(shininess, EPSILON);\n" -"\tfloat NH_sq = NH * NH;\n" -"\tfloat m_NH_sq = m_sq * NH_sq;\n" -"\tfloat beckmann = exp((NH_sq - 1.0) / max(m_NH_sq, EPSILON)) / max(4.0 * m_NH_sq * NH_sq, EPSILON);\n" +"\t\n" +"\treturn geo;\n" +"#endif\n" +"}\n" "\n" -"\treturn fresnel * geo * beckmann / max(NE, EPSILON);\n" -" #endif\n" "\n" -" #if defined(USE_TRIACE)\n" -"\tfloat scale = 0.1248582 * shininess + 0.2691817;\n" +"vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess)\n" +"{\n" +"\tfloat blinn = CalcBlinn(NH, shininess);\n" +"\tvec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH));\n" +"\tfloat vis = CalcVisibility(NH, NL, NE, EH, gloss);\n" "\n" -"\treturn fresnel * scale * blinn / max(max(NL, NE), EPSILON);\n" +" #if defined(USE_BLINN)\n" +" // Normalized Blinn-Phong\n" +"\treturn specular * blinn * (shininess * 0.125 + 1.0);\n" +" #elif defined(USE_BLINN_FRESNEL)\n" +" // Normalized Blinn-Phong with Fresnel\n" +"\treturn fSpecular * blinn * (shininess * 0.125 + 1.0);\n" +" #elif defined(USE_MCAULEY)\n" +" // Cook-Torrance as done by Stephen McAuley\n" +"\t// http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf\n" +"\treturn fSpecular * blinn * (shininess * 0.25 + 0.125);\n" +" #elif defined(USE_GOTANDA)\n" +" // Neumann-Neumann as done by Yoshiharu Gotanda\n" +"\t// http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf\n" +"\treturn fSpecular * blinn * (shininess * 0.124858 + 0.269182) / max(max(NL, NE), EPSILON);\n" +" #elif defined(USE_LAZAROV)\n" +" // Cook-Torrance as done by Dimitar Lazarov\n" +"\t// http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" +"\treturn fSpecular * blinn * (shininess * 0.125 + 0.25) * vis;\n" " #endif\n" " \n" -" #if defined(USE_TORRANCE_SPARROW)\n" -"\tfloat scale = 0.125 * shininess + 1.0;\n" +"\treturn vec3(0.0);\n" +"}\n" "\n" -"\treturn fresnel * geo * scale * blinn / max(NE, EPSILON);\n" -" #endif\n" +"\n" +"float CalcLightAttenuation(vec3 dir, float sqrRadius)\n" +"{\n" +"\t// point light at >0 radius, directional otherwise\n" +"\tfloat point = float(sqrRadius > 0.0);\n" +"\n" +"\t// inverse square light\n" +"\tfloat attenuation = sqrRadius / dot(dir, dir);\n" +"\n" +"\t// zero light at radius, approximating q3 style\n" +"\t// also don't attenuate directional light\n" +"\tattenuation = (0.5 * attenuation - 1.5) * point + 1.0;\n" +"\t\n" +"\t// clamp attenuation\n" +"\t#if defined(NO_LIGHT_CLAMP)\n" +"\tattenuation = max(attenuation, 0.0);\n" +"\t#else\n" +"\tattenuation = clamp(attenuation, 0.0, 1.0);\n" +"\t#endif\n" +"\t\n" +"\treturn attenuation;\n" "}\n" -"#endif\n" +"\n" "\n" "void main()\n" "{\n" -"#if !defined(USE_FAST_LIGHT) && (defined(USE_LIGHT) || defined(USE_NORMALMAP))\n" -"\tvec3 surfN = normalize(var_Normal);\n" +"\tvec3 L, N, E, H;\n" +"\tfloat NL, NH, NE, EH;\n" +"\t\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"\tmat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz);\n" "#endif\n" "\n" "#if defined(USE_DELUXEMAP)\n" -"\tvec3 L = 2.0 * texture2D(u_DeluxeMap, var_LightTex).xyz - vec3(1.0);\n" -"\t//L += var_LightDirection * 0.0001;\n" -"#elif defined(USE_LIGHT)\n" -"\tvec3 L = var_LightDirection;\n" +"\tL = (2.0 * texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(1.0));\n" +" #if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tL = L * tangentToWorld;\n" +" #endif\n" +"#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" +"\tL = var_LightDir.xyz;\n" +"#endif\n" +"\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"\tE = normalize(vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w));\n" "#endif\n" "\n" "#if defined(USE_LIGHTMAP)\n" -"\tvec4 lightSample = texture2D(u_LightMap, var_LightTex).rgba;\n" -" #if defined(RGBE_LIGHTMAP)\n" -"\tlightSample.rgb *= exp2(lightSample.a * 255.0 - 128.0);\n" +"\tvec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw).rgba;\n" +" #if defined(RGBM_LIGHTMAP)\n" +"\tlightSample.rgb *= 32.0 * lightSample.a;\n" " #endif\n" "\tvec3 lightColor = lightSample.rgb;\n" "#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)\n" -" #if defined(USE_INVSQRLIGHT)\n" -"\tfloat intensity = 1.0 / dot(L, L);\n" -" #else\n" -"\tfloat intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0);\n" -" #endif\n" -"\n" -"\tvec3 lightColor = u_DirectedLight * intensity;\n" -"\tvec3 ambientColor = u_AmbientLight;\n" +"\tvec3 lightColor = u_DirectedLight * CalcLightAttenuation(L, var_LightDir.w);\n" +"\tvec3 ambientColor = u_AmbientLight;\n" "#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"\tvec3 lightColor = var_VertLight;\n" -"#endif\n" -"\t\n" -"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" -"\tvec3 E = normalize(var_SampleToView);\n" +"\tvec3 lightColor = var_LightColor;\n" "#endif\n" -"\tvec2 texCoords = var_DiffuseTex;\n" "\n" -"\tfloat ambientDiff = 1.0;\n" +"\tvec2 texCoords = var_TexCoords.xy;\n" "\n" -"#if defined(USE_NORMALMAP)\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" -"\tmat3 tangentToWorld = mat3(var_Tangent, var_Bitangent, var_Normal);\n" +"#if defined(USE_PARALLAXMAP)\n" +" #if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tvec3 offsetDir = E;\n" " #else\n" -"\tvec3 q0 = dFdx(var_Position);\n" -"\tvec3 q1 = dFdy(var_Position);\n" -"\tvec2 st0 = dFdx(texCoords);\n" -"\tvec2 st1 = dFdy(texCoords);\n" -"\tfloat dir = sign(st1.t * st0.s - st0.t * st1.s);\n" -"\n" -"\tvec3 tangent = normalize(q0 * st1.t - q1 * st0.t) * dir;\n" -"\tvec3 bitangent = -normalize(q0 * st1.s - q1 * st0.s) * dir;\n" -"\n" -"\tmat3 tangentToWorld = mat3(tangent, bitangent, var_Normal);\n" +"\tvec3 offsetDir = E * tangentToWorld;\n" " #endif\n" "\n" -" #if defined(USE_PARALLAXMAP)\n" -"\tvec3 offsetDir = normalize(E * tangentToWorld);\n" "\toffsetDir.xy *= -0.05 / offsetDir.z;\n" "\n" "\ttexCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap);\n" -" #endif\n" -"\tvec3 texN;\n" -" #if defined(SWIZZLE_NORMALMAP)\n" -"\ttexN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - 1.0;\n" -" #else\n" -"\ttexN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - 1.0;\n" -" #endif\n" -"\ttexN.z = sqrt(clamp(1.0 - dot(texN.xy, texN.xy), 0.0, 1.0));\n" -"\tvec3 N = tangentToWorld * texN;\n" -" #if defined(r_normalAmbient)\n" -"\tambientDiff = 0.781341 * texN.z + 0.218659;\n" -" #endif\n" -"#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) \n" -"\tvec3 N = surfN;\n" -"#endif\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || (defined(USE_TCGEN) && defined(USE_NORMALMAP))\n" -"\tN = normalize(N);\n" "#endif\n" "\n" -"#if defined(USE_TCGEN) && defined(USE_NORMALMAP)\n" -"\tif (u_TCGen0 == TCGEN_ENVIRONMENT_MAPPED)\n" -"\t{\n" -"\t\ttexCoords = -reflect(E, N).yz * vec2(0.5, -0.5) + 0.5;\n" -"\t}\n" +"\tvec4 diffuse = texture2D(u_DiffuseMap, texCoords);\n" +"#if defined(USE_GAMMA2_TEXTURES)\n" +"\tdiffuse.rgb *= diffuse.rgb;\n" "#endif\n" "\n" -"\tvec4 diffuseAlbedo = texture2D(u_DiffuseMap, texCoords);\n" -"#if defined(USE_LIGHT) && defined(USE_GAMMA2_TEXTURES)\n" -"\tdiffuseAlbedo.rgb *= diffuseAlbedo.rgb;\n" -"#endif\n" "\n" -"#if defined(USE_LIGHT) && defined(USE_FAST_LIGHT)\n" -"\tgl_FragColor = diffuse.rgb;\n" -" #if defined(USE_LIGHTMAP) \n" -"\tgl_FragColor *= lightColor;\n" +"#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" +" #if defined(USE_NORMALMAP)\n" +" #if defined(SWIZZLE_NORMALMAP)\n" +"\tN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - vec2(1.0);\n" +" #else\n" +"\tN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - vec2(1.0);\n" +" #endif\n" +"\tN.z = sqrt(1.0 - clamp(dot(N.xy, N.xy), 0.0, 1.0));\n" +" #if !defined(USE_TANGENT_SPACE_LIGHT)\n" +" N = normalize(tangentToWorld * N);\n" +" #endif\n" +" #elif defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tN = vec3(0.0, 0.0, 1.0);\n" +" #else\n" +" N = normalize(var_Normal.xyz);\n" " #endif\n" -"#elif defined(USE_LIGHT)\n" +" \n" "\tL = normalize(L);\n" "\n" -"\tfloat surfNL = clamp(dot(surfN, L), 0.0, 1.0);\n" -"\t\n" " #if defined(USE_SHADOWMAP) \n" "\tvec2 shadowTex = gl_FragCoord.xy * r_FBufScale;\n" "\tfloat shadowValue = texture2D(u_ShadowMap, shadowTex).r;\n" "\n" "\t// surfaces not facing the light are always shadowed\n" -"\tshadowValue *= step(0.0, dot(surfN, var_PrimaryLightDirection));\n" +"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tshadowValue *= step(0.0, var_PrimaryLightDir.z);\n" +"\t#else\n" +"\tshadowValue *= step(0.0, dot(var_Normal.xyz, var_PrimaryLightDir.xyz));\n" +"\t#endif\n" " \n" " #if defined(SHADOWMAP_MODULATE)\n" "\t//vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor);\n" @@ -1147,107 +1193,137 @@ const char *fallbackShader_lightall_fp = "\n" " #if 0\n" "\t// Only shadow when the world light is parallel to the primary light\n" -"\tshadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDirection), 0.0, 1.0);\n" +"\tshadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDir.xyz), 0.0, 1.0);\n" " #endif\n" "\tlightColor = mix(shadowColor, lightColor, shadowValue);\n" " #endif\n" " #endif\n" "\n" " #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)\n" -" #if defined(USE_STANDARD_DELUXEMAP)\n" -"\t// Standard deluxe mapping treats the light sample as fully directed\n" -"\t// and doesn't compensate for light angle attenuation.\n" -"\tvec3 ambientColor = vec3(0.0);\n" -" #else\n" -"\t// Separate the light sample into directed and ambient parts.\n" -"\t//\n" -"\t// ambientMax - if the cosine of the angle between the surface\n" -"\t// normal and the light is below this value, the light\n" -"\t// is fully ambient.\n" -"\t// directedMax - if the cosine of the angle between the surface\n" -"\t// normal and the light is above this value, the light\n" -"\t// is fully directed.\n" -"\tconst float ambientMax = 0.25;\n" -"\tconst float directedMax = 0.5;\n" -"\n" -"\tfloat directedScale = clamp((surfNL - ambientMax) / (directedMax - ambientMax), 0.0, 1.0);\n" -"\t\n" -"\t// Scale the directed portion to compensate for the baked-in\n" -"\t// light angle attenuation.\n" -"\tdirectedScale /= max(surfNL, ambientMax);\n" -"\t\n" -" #if defined(r_normalAmbient)\n" -"\tdirectedScale *= 1.0 - r_normalAmbient;\n" -" #endif\n" -"\n" -"\t// Recover any unused light as ambient\n" "\tvec3 ambientColor = lightColor;\n" -"\tlightColor *= directedScale;\n" +"\t\n" +"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tfloat surfNL = L.z;\n" +"\t#else\n" +"\tfloat surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0);\n" +"\t#endif\n" +"\n" +"\t// Scale the incoming light to compensate for the baked-in light angle\n" +"\t// attenuation.\n" +"\tlightColor /= max(surfNL, 0.25);\n" +"\n" +"\t// Recover any unused light as ambient, in case attenuation is over 4x or\n" +"\t// light is below the surface\n" "\tambientColor -= lightColor * surfNL;\n" -" #endif\n" " #endif\n" +" \n" +"\tvec3 reflectance;\n" "\n" -"\tfloat NL = clamp(dot(N, L), 0.0, 1.0);\n" -"\tfloat NE = clamp(dot(N, E), 0.0, 1.0);\n" -"\n" -"\tfloat maxReflectance = u_MaterialInfo.x;\n" -"\tfloat shininess = u_MaterialInfo.y;\n" +"\tNL = clamp(dot(N, L), 0.0, 1.0);\n" +"\tNE = clamp(dot(N, E), 0.0, 1.0);\n" "\n" " #if defined(USE_SPECULARMAP)\n" -"\tvec4 specularReflectance = texture2D(u_SpecularMap, texCoords);\n" -"\tspecularReflectance.rgb *= maxReflectance;\n" -"\tshininess *= specularReflectance.a;\n" -"\t// adjust diffuse by specular reflectance, to maintain energy conservation\n" -"\tdiffuseAlbedo.rgb *= vec3(1.0) - specularReflectance.rgb;\n" +"\tvec4 specular = texture2D(u_SpecularMap, texCoords);\n" +" #if defined(USE_GAMMA2_TEXTURES)\n" +"\tspecular.rgb *= specular.rgb;\n" +" #endif\n" +" #else\n" +"\tvec4 specular = vec4(1.0);\n" " #endif\n" "\n" -"\tgl_FragColor.rgb = lightColor * NL * CalcDiffuse(diffuseAlbedo.rgb, N, L, E, NE, NL, shininess);\n" -"\tgl_FragColor.rgb += ambientDiff * ambientColor * diffuseAlbedo.rgb;\n" -" #if defined(USE_PRIMARY_LIGHT)\n" -"\tvec3 L2 = var_PrimaryLightDirection;\n" -"\tfloat NL2 = clamp(dot(N, L2), 0.0, 1.0);\n" +"\tspecular *= u_MaterialInfo.xxxy;\n" +"\t\n" +"\tfloat gloss = specular.a;\n" +"\tfloat shininess = exp2(gloss * 13.0);\n" "\n" -" #if defined(USE_SHADOWMAP)\n" -"\tgl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess);\n" -" #else\n" -"\tgl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcDiffuse(diffuseAlbedo.rgb, N, L2, E, NE, NL2, shininess);\n" -" #endif\n" +" #if defined(SPECULAR_IS_METALLIC)\n" +" // diffuse is actually base color, and red of specular is metallicness\n" +"\tfloat metallic = specular.r;\n" +"\t\n" +"\tspecular.rgb = vec3(0.04) + 0.96 * diffuse.rgb * metallic;\n" +"\tdiffuse.rgb *= 1.0 - metallic;\n" +" #else\n" +"\t// adjust diffuse by specular reflectance, to maintain energy conservation\n" +"\tdiffuse.rgb *= vec3(1.0) - specular.rgb;\n" " #endif\n" " \n" -" #if defined(USE_SPECULARMAP)\n" -"\tvec3 H = normalize(L + E);\n" +"\t\n" +"\treflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);\n" "\n" -"\tfloat EH = clamp(dot(E, H), 0.0, 1.0);\n" -"\tfloat NH = clamp(dot(N, H), 0.0, 1.0);\n" +" #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR)\n" +"\tfloat adjGloss = gloss;\n" +"\tfloat adjShininess = shininess;\n" +"\t\n" +"\t#if !defined(USE_LIGHT_VECTOR)\n" +"\tadjGloss *= r_deluxeSpecular;\n" +"\tadjShininess = exp2(adjGloss * 13.0);\n" +"\t#endif\n" +"\t\n" +"\tH = normalize(L + E);\n" "\n" -"\tgl_FragColor.rgb += lightColor * NL * CalcSpecular(specularReflectance.rgb, NH, NL, NE, EH, shininess);\n" -" \n" -" #if defined(r_normalAmbient)\n" -"\tvec3 ambientHalf = normalize(surfN + E);\n" -"\tfloat ambientSpec = max(dot(ambientHalf, N) + 0.5, 0.0);\n" -"\tambientSpec *= ambientSpec * 0.44;\n" -"\tgl_FragColor.rgb += specularReflectance.rgb * ambientSpec * ambientColor;\n" +"\tEH = clamp(dot(E, H), 0.0, 1.0);\n" +"\tNH = clamp(dot(N, H), 0.0, 1.0);\n" +"\n" +" #if !defined(USE_LIGHT_VECTOR)\n" +"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess) * r_deluxeSpecular;\n" +" #else\n" +"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess);\n" " #endif\n" +" #endif\n" +"\t\n" +"\tgl_FragColor.rgb = lightColor * reflectance * NL; \n" +"\tgl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb);\n" +"\t\n" +" #if defined(USE_CUBEMAP)\n" +"\treflectance = EnvironmentBRDF(gloss, NE, specular.rgb);\n" +"\n" +"\tvec3 R = reflect(E, N);\n" +"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tR = tangentToWorld * R;\n" +"\t#endif\n" +"\n" +" vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb;\n" +"\n" +"\t#if defined(USE_LIGHTMAP)\n" +"\tcubeLightColor *= lightSample.rgb;\n" +"\t#elif defined (USE_LIGHT_VERTEX)\n" +"\tcubeLightColor *= var_LightColor;\n" +"\t#else\n" +"\tcubeLightColor *= lightColor * NL + ambientColor;\n" +"\t#endif\n" +"\t\n" +"\t//gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb;\n" +"\tgl_FragColor.rgb += cubeLightColor * reflectance;\n" +" #endif\n" "\n" -" #if defined(USE_PRIMARY_LIGHT)\n" -"\tvec3 H2 = normalize(L2 + E);\n" -"\tfloat EH2 = clamp(dot(E, H2), 0.0, 1.0);\n" -"\tfloat NH2 = clamp(dot(N, H2), 0.0, 1.0);\n" +" #if defined(USE_PRIMARY_LIGHT)\n" +"\tL = var_PrimaryLightDir.xyz; //normalize(var_PrimaryLightDir.xyz);\n" +"\tNL = clamp(dot(N, L), 0.0, 1.0);\n" "\n" +"\tH = normalize(L + E);\n" +"\tEH = clamp(dot(E, H), 0.0, 1.0);\n" +"\tNH = clamp(dot(N, H), 0.0, 1.0);\n" "\n" -" #if defined(USE_SHADOWMAP)\n" -"\tgl_FragColor.rgb += u_PrimaryLightColor * shadowValue * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess);\n" -" #else\n" -"\tgl_FragColor.rgb += u_PrimaryLightColor * NL2 * CalcSpecular(specularReflectance.rgb, NH2, NL2, NE, EH2, shininess);\n" -" #endif\n" +"\treflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);\n" +"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss, shininess);\n" +"\n" +"\tlightColor = u_PrimaryLightColor; // * CalcLightAttenuation(L, u_PrimaryLightDir.w);\n" +"\t\n" +" #if defined(USE_SHADOWMAP)\n" +"\tlightColor *= shadowValue;\n" " #endif\n" -" #endif \n" +"\n" +"\tgl_FragColor.rgb += lightColor * reflectance * NL;\n" +" #endif\n" +"\n" +"\tgl_FragColor.a = diffuse.a;\n" "#else\n" -"\tgl_FragColor.rgb = diffuseAlbedo.rgb;\n" +"\tgl_FragColor = diffuse;\n" +" #if defined(USE_LIGHTMAP) \n" +"\tgl_FragColor.rgb *= lightColor;\n" +" #endif\n" "#endif\n" "\n" -"\tgl_FragColor.a = diffuseAlbedo.a;\n" -"\n" "\tgl_FragColor *= var_Color;\n" "}\n" ; @@ -1258,21 +1334,16 @@ const char *fallbackShader_lightall_vp = "#endif\n" "attribute vec4 attr_Color;\n" "\n" -"attribute vec4 attr_Position;\n" +"attribute vec3 attr_Position;\n" "attribute vec3 attr_Normal;\n" -"\n" -"#if defined(USE_VERT_TANGENT_SPACE)\n" "attribute vec3 attr_Tangent;\n" "attribute vec3 attr_Bitangent;\n" -"#endif\n" "\n" "#if defined(USE_VERTEX_ANIMATION)\n" -"attribute vec4 attr_Position2;\n" +"attribute vec3 attr_Position2;\n" "attribute vec3 attr_Normal2;\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" "attribute vec3 attr_Tangent2;\n" "attribute vec3 attr_Bitangent2;\n" -" #endif\n" "#endif\n" "\n" "#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR)\n" @@ -1281,6 +1352,7 @@ const char *fallbackShader_lightall_vp = "\n" "#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" "uniform vec3 u_ViewOrigin;\n" +"uniform vec3 u_LocalViewOrigin;\n" "#endif\n" "\n" "#if defined(USE_TCGEN)\n" @@ -1308,52 +1380,38 @@ const char *fallbackShader_lightall_vp = "\n" "#if defined(USE_LIGHT_VECTOR)\n" "uniform vec4 u_LightOrigin;\n" -" #if defined(USE_FAST_LIGHT)\n" +"uniform float u_LightRadius;\n" "uniform vec3 u_DirectedLight;\n" +" #if defined(USE_FAST_LIGHT)\n" "uniform vec3 u_AmbientLight;\n" -"uniform float u_LightRadius;\n" " #endif\n" "#endif\n" "\n" "#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" "uniform vec4 u_PrimaryLightOrigin;\n" +"uniform float u_PrimaryLightRadius;\n" "#endif\n" "\n" -"varying vec2 var_DiffuseTex;\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"varying vec2 var_LightTex;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" -"varying vec3 var_SampleToView;\n" -"#endif\n" +"varying vec4 var_TexCoords;\n" "\n" "varying vec4 var_Color;\n" "\n" -"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" -"varying vec3 var_Position;\n" -"#endif\n" -"\n" -"\n" -"#if !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_Normal;\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" -"varying vec3 var_Tangent;\n" -"varying vec3 var_Bitangent;\n" -" #endif\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"varying vec4 var_Normal;\n" +"varying vec4 var_Tangent;\n" +"varying vec4 var_Bitangent;\n" "#endif\n" "\n" "#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_VertLight;\n" +"varying vec3 var_LightColor;\n" "#endif\n" "\n" "#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_LightDirection;\n" +"varying vec4 var_LightDir;\n" "#endif\n" "\n" "#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"varying vec3 var_PrimaryLightDirection;\n" +"varying vec4 var_PrimaryLightDir;\n" "#endif\n" "\n" "#if defined(USE_TCGEN)\n" @@ -1367,7 +1425,7 @@ const char *fallbackShader_lightall_vp = "\t}\n" "\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" "\t{\n" -"\t\tvec3 viewer = normalize(u_ViewOrigin - position);\n" +"\t\tvec3 viewer = normalize(u_LocalViewOrigin - position);\n" "\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" "\t}\n" "\telse if (TCGen == TCGEN_VECTOR)\n" @@ -1386,7 +1444,7 @@ const char *fallbackShader_lightall_vp = "\tfloat phase = offTurb.w;\n" "\tvec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy;\n" "\n" -"\tvec3 offsetPos = vec3(0); //position / 1024.0;\n" +"\tvec3 offsetPos = position / 1024.0;\n" "\toffsetPos.x += offsetPos.z;\n" "\t\n" "\tvec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI);\n" @@ -1396,106 +1454,129 @@ const char *fallbackShader_lightall_vp = "#endif\n" "\n" "\n" +"float CalcLightAttenuation(vec3 dir, float sqrRadius)\n" +"{\n" +"\t// point light at >0 radius, directional otherwise\n" +"\tfloat point = float(sqrRadius > 0.0);\n" +"\n" +"\t// inverse square light\n" +"\tfloat attenuation = sqrRadius / dot(dir, dir);\n" +"\n" +"\t// zero light at radius, approximating q3 style\n" +"\t// also don't attenuate directional light\n" +"\tattenuation = (0.5 * attenuation - 1.5) * point + 1.0;\n" +"\t\n" +"\t// clamp attenuation\n" +"\t#if defined(NO_LIGHT_CLAMP)\n" +"\tattenuation = max(attenuation, 0.0);\n" +"\t#else\n" +"\tattenuation = clamp(attenuation, 0.0, 1.0);\n" +"\t#endif\n" +"\t\n" +"\treturn attenuation;\n" +"}\n" +"\n" +"\n" "void main()\n" "{\n" "#if defined(USE_VERTEX_ANIMATION)\n" -"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" +"\tvec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" "\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" "\tvec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp));\n" "\tvec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp));\n" -" #endif\n" "#else\n" -"\tvec4 position = attr_Position;\n" +"\tvec3 position = attr_Position;\n" "\tvec3 normal = attr_Normal;\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" "\tvec3 tangent = attr_Tangent;\n" "\tvec3 bitangent = attr_Bitangent;\n" -" #endif\n" -"#endif\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\n" -"#if (defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"\tvec3 L = attr_LightDirection;\n" -"#endif\n" -"\t\n" -"#if defined(USE_MODELMATRIX)\n" -"\tposition = u_ModelMatrix * position;\n" -"\tnormal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" -"\ttangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;\n" -"\tbitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz;\n" -" #endif\n" -"\n" -" #if defined(USE_LIGHTMAP) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"\tL = (u_ModelMatrix * vec4(L, 0.0)).xyz;\n" -" #endif\n" -"#endif\n" -"\n" -"#if defined(USE_NORMALMAP) && !defined(USE_VERT_TANGENT_SPACE)\n" -"\tvar_Position = position.xyz;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT))\n" -"\tvar_SampleToView = u_ViewOrigin - position.xyz;\n" "#endif\n" "\n" "#if defined(USE_TCGEN)\n" -"\tvec2 texCoords = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" +"\tvec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" "#else\n" "\tvec2 texCoords = attr_TexCoord0.st;\n" "#endif\n" "\n" "#if defined(USE_TCMOD)\n" -"\tvar_DiffuseTex = ModTexCoords(texCoords, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" +"\tvar_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" "#else\n" -"\tvar_DiffuseTex = texCoords;\n" +"\tvar_TexCoords.xy = texCoords;\n" "#endif\n" "\n" -"#if defined(USE_LIGHTMAP)\n" -"\tvar_LightTex = attr_TexCoord1.st;\n" +"\tgl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);\n" +"\n" +"#if defined(USE_MODELMATRIX)\n" +"\tposition = (u_ModelMatrix * vec4(position, 1.0)).xyz;\n" +"\tnormal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;\n" +"\ttangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;\n" +"\tbitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz;\n" "#endif\n" "\n" -"#if !defined(USE_FAST_LIGHT)\n" -"\tvar_Normal = normal;\n" -" #if defined(USE_VERT_TANGENT_SPACE)\n" -"\tvar_Tangent = tangent;\n" -"\tvar_Bitangent = bitangent;\n" +"#if defined(USE_LIGHT_VECTOR)\n" +"\tvec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);\n" +"#elif defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" +"\tvec3 L = attr_LightDirection;\n" +" #if defined(USE_MODELMATRIX)\n" +"\tL = (u_ModelMatrix * vec4(L, 0.0)).xyz;\n" " #endif\n" "#endif\n" "\n" -"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" -" #if defined(USE_LIGHT_VECTOR)\n" -"\tvec3 L = u_LightOrigin.xyz - (position.xyz * u_LightOrigin.w);\n" -" #endif\n" -" #if !defined(USE_FAST_LIGHT)\n" -"\tvar_LightDirection = L;\n" -" #endif\n" +"#if defined(USE_LIGHTMAP)\n" +"\tvar_TexCoords.zw = attr_TexCoord1.st;\n" "#endif\n" "\t\n" +"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" "#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"\tvar_VertLight = u_VertColor.rgb * attr_Color.rgb;\n" +"\tvar_LightColor = var_Color.rgb;\n" "\tvar_Color.rgb = vec3(1.0);\n" -"\tvar_Color.a = u_VertColor.a * attr_Color.a + u_BaseColor.a;\n" -"#else\n" -"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" "#endif\n" "\n" "#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT)\n" -" #if defined(USE_INVSQRLIGHT)\n" -"\tfloat intensity = 1.0 / dot(L, L);\n" -" #else\n" -"\tfloat intensity = clamp((1.0 - dot(L, L) / (u_LightRadius * u_LightRadius)) * 1.07, 0.0, 1.0);\n" -" #endif\n" +"\tfloat attenuation = CalcLightAttenuation(L, u_LightRadius * u_LightRadius);\n" "\tfloat NL = clamp(dot(normal, normalize(L)), 0.0, 1.0);\n" "\n" -"\tvar_Color.rgb *= u_DirectedLight * intensity * NL + u_AmbientLight;\n" +"\tvar_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight;\n" "#endif\n" "\n" "#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"\tvar_PrimaryLightDirection = u_PrimaryLightOrigin.xyz - (position.xyz * u_PrimaryLightOrigin.w);\n" -"#endif\t\n" +"\tvar_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w);\n" +"\tvar_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius;\n" +"#endif\n" +"\n" +"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +" #if defined(USE_LIGHT_VECTOR)\n" +"\tvar_LightDir = vec4(L, u_LightRadius * u_LightRadius);\n" +" #else\n" +"\tvar_LightDir = vec4(L, 0.0);\n" +" #endif\n" +"#endif\n" +"\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"\tvec3 viewDir = u_ViewOrigin - position;\n" +"#endif\n" +"\n" +"#if defined(USE_TANGENT_SPACE_LIGHT)\n" +"\tmat3 tangentToWorld = mat3(tangent, bitangent, normal);\n" +"\n" +" #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" +"\tvar_PrimaryLightDir.xyz = var_PrimaryLightDir.xyz * tangentToWorld;\n" +" #endif\n" +" \n" +" #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" +"\tvar_LightDir.xyz = var_LightDir.xyz * tangentToWorld;\n" +" #endif\n" +"\n" +" #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"\tviewDir = viewDir * tangentToWorld;\n" +" #endif\n" +"#endif\n" +"\n" +"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" +"\t// store view direction in tangent space to save on varyings\n" +"\tvar_Normal = vec4(normal, viewDir.x);\n" +"\tvar_Tangent = vec4(tangent, viewDir.y);\n" +"\tvar_Bitangent = vec4(bitangent, viewDir.z);\n" +"#endif\n" "}\n" ; const char *fallbackShader_pshadow_fp = @@ -2097,4 +2178,4 @@ const char *fallbackShader_tonemap_vp = "\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" "\tvar_TexCoords = attr_TexCoord0.st;\n" "}\n" -; +; \ No newline at end of file diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 1f19570953..41517774c4 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -1124,6 +1124,11 @@ extern void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); #define GL_DEPTH_CLAMP 0x864F #endif +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#endif + #if defined(WIN32) // WGL_ARB_create_context #ifndef WGL_ARB_create_context diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index e5f36cd9a1..3ee10ce061 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -43,15 +43,17 @@ void R_AddAnimSurfaces( trRefEntity_t *ent ) { md4Surface_t *surface; md4LOD_t *lod; shader_t *shader; + int cubemapIndex; int i; header = (md4Header_t *) tr.currentModel->modelData; lod = (md4LOD_t *)( (byte *)header + header->ofsLODs ); + cubemapIndex = R_CubemapForPoint(ent->e.origin); surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces ); for ( i = 0 ; i < lod->numSurfaces ; i++ ) { shader = R_GetShaderByHandle( surface->shaderIndex ); - R_AddDrawSurf( (surfaceType_t *)surface, shader, 0 /*fogNum*/, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, 0 /*fogNum*/, qfalse, qfalse, cubemapIndex ); surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd ); } } @@ -323,6 +325,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { int lodnum = 0; int fogNum = 0; int cull; + int cubemapIndex; qboolean personalModel; header = (mdrHeader_t *)tr.currentModel->modelData; @@ -384,6 +387,8 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { // fogNum? fogNum = R_MDRComputeFogNum( header, ent ); + cubemapIndex = R_CubemapForPoint(ent->e.origin); + surface = (mdrSurface_t *)( (byte *)lod + lod->ofsSurfaces ); for ( i = 0 ; i < lod->numSurfaces ; i++ ) @@ -419,7 +424,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, qfalse, 0 ); } // projection shadows work fine with personal models @@ -428,11 +433,11 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); } if (!personalModel) - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, qfalse, cubemapIndex ); surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3ab2ac24db..a2a57619a9 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -37,13 +37,13 @@ static float s_flipMatrix[16] = { /* -** GL_Bind2 +** GL_Bind */ -void GL_Bind2( image_t *image, GLenum type ) { +void GL_Bind( image_t *image ) { int texnum; if ( !image ) { - ri->Printf( PRINT_WARNING, "GL_Bind2: NULL image\n" ); + ri->Printf( PRINT_WARNING, "GL_Bind: NULL image\n" ); texnum = tr.defaultImage->texnum; } else { texnum = image->texnum; @@ -58,26 +58,13 @@ void GL_Bind2( image_t *image, GLenum type ) { image->frameUsed = tr.frameCount; } glState.currenttextures[glState.currenttmu] = texnum; - qglBindTexture (type, texnum); + if (image && image->flags & IMGFLAG_CUBEMAP) + qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); + else + qglBindTexture( GL_TEXTURE_2D, texnum ); } } -/* -** GL_Bind2 -*/ -void GL_Bind( image_t *image ) -{ - GL_Bind2( image, GL_TEXTURE_2D ); -} - -/* -** GL_BindCubemap -*/ -void GL_BindCubemap( image_t *image ) -{ - GL_Bind2( image, GL_TEXTURE_CUBE_MAP ); -} - /* ** GL_SelectTexture */ @@ -96,34 +83,6 @@ void GL_SelectTexture( int unit ) glState.currenttmu = unit; } - -/* -** GL_BindMultitexture -*/ -void GL_BindMultitexture( image_t *image0, GLuint env0, image_t *image1, GLuint env1 ) { - int texnum0, texnum1; - - texnum0 = image0->texnum; - texnum1 = image1->texnum; - - if ( r_nobind->integer && tr.dlightImage ) { // performance evaluation option - texnum0 = texnum1 = tr.dlightImage->texnum; - } - - if ( glState.currenttextures[1] != texnum1 ) { - GL_SelectTexture( 1 ); - image1->frameUsed = tr.frameCount; - glState.currenttextures[1] = texnum1; - qglBindTexture( GL_TEXTURE_2D, texnum1 ); - } - if ( glState.currenttextures[0] != texnum0 ) { - GL_SelectTexture( 0 ); - image0->frameUsed = tr.frameCount; - glState.currenttextures[0] = texnum0; - qglBindTexture( GL_TEXTURE_2D, texnum0 ); - } -} - /* ** GL_BindToTMU */ @@ -142,7 +101,11 @@ void GL_BindToTMU( image_t *image, int tmu ) if (image) image->frameUsed = tr.frameCount; glState.currenttextures[tmu] = texnum; - qglBindTexture( GL_TEXTURE_2D, texnum ); + + if (image && (image->flags & IMGFLAG_CUBEMAP)) + qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); + else + qglBindTexture( GL_TEXTURE_2D, texnum ); GL_SelectTexture( oldtmu ); } } @@ -501,6 +464,12 @@ void RB_BeginDrawingView (void) { else { FBO_Bind(backEnd.viewParms.targetFbo); + + // FIXME: hack for cubemap testing + if (backEnd.viewParms.targetFbo == tr.renderCubeFbo) + { + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); + } } } @@ -535,6 +504,13 @@ void RB_BeginDrawingView (void) { qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } + // clear to black for cube maps + if (backEnd.viewParms.targetFbo == tr.renderCubeFbo) + { + clearBits |= GL_COLOR_BUFFER_BIT; + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + } + qglClear( clearBits ); if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) ) @@ -586,6 +562,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { int entityNum, oldEntityNum; int dlighted, oldDlighted; int pshadowed, oldPshadowed; + int cubemapIndex, oldCubemapIndex; qboolean depthRange, oldDepthRange; int i; drawSurf_t *drawSurf; @@ -610,6 +587,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldDepthRange = qfalse; oldDlighted = qfalse; oldPshadowed = qfalse; + oldCubemapIndex = -1; oldSort = -1; depth[0] = 0.f; @@ -618,7 +596,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.pc.c_surfaces += numDrawSurfs; for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - if ( drawSurf->sort == oldSort ) { + if ( drawSurf->sort == oldSort && drawSurf->cubemapIndex == oldCubemapIndex) { if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) continue; @@ -628,22 +606,24 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } oldSort = drawSurf->sort; R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + cubemapIndex = drawSurf->cubemapIndex; // // change the tess parameters if needed // a "entityMergable" shader is a shader that can have surfaces from seperate // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed + if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed || cubemapIndex != oldCubemapIndex || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { if (oldShader != NULL) { RB_EndSurface(); } - RB_BeginSurface( shader, fogNum ); + RB_BeginSurface( shader, fogNum, cubemapIndex ); backEnd.pc.c_surfBatches++; oldShader = shader; oldFogNum = fogNum; oldDlighted = dlighted; oldPshadowed = pshadowed; + oldCubemapIndex = cubemapIndex; } if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) @@ -970,7 +950,7 @@ const void *RB_StretchPic ( const void *data ) { RB_EndSurface(); } backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0 ); + RB_BeginSurface( shader, 0, 0 ); } RB_CHECKOVERFLOW( 4, 6 ); @@ -1300,8 +1280,14 @@ const void *RB_DrawSurfs( const void *data ) { RB_RenderFlares(); } - //if (glRefConfig.framebufferObject) - //FBO_Bind(NULL); + if (glRefConfig.framebufferObject && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + { + FBO_Bind(NULL); + GL_SelectTexture(TB_CUBEMAP); + GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP); + qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); + GL_SelectTexture(0); + } return (const void *)(cmd + 1); } @@ -1575,7 +1561,7 @@ const void *RB_CapShadowMap(const void *data) GL_SelectTexture(0); if (cmd->cubeSide != -1) { - GL_BindCubemap(tr.shadowCubemaps[cmd->map]); + GL_Bind(tr.shadowCubemaps[cmd->map]); qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); } else @@ -1639,7 +1625,11 @@ const void *RB_PostProcess(const void *data) srcBox[2] = backEnd.viewParms.viewportWidth * tr.screenSsaoImage->width / (float)glConfig.vidWidth; srcBox[3] = backEnd.viewParms.viewportHeight * tr.screenSsaoImage->height / (float)glConfig.vidHeight; - FBO_BlitFromTexture(tr.screenSsaoImage, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + //FBO_BlitFromTexture(tr.screenSsaoImage, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + srcBox[1] = tr.screenSsaoImage->height - srcBox[1]; + srcBox[3] = -srcBox[3]; + + FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); } srcBox[0] = backEnd.viewParms.viewportX; @@ -1667,7 +1657,7 @@ const void *RB_PostProcess(const void *data) color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); color[3] = 1.0f; - FBO_Blit(srcFbo, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, color, 0); + FBO_Blit(srcFbo, srcBox, NULL, tr.screenScratchFbo, dstBox, NULL, color, 0); } } @@ -1706,6 +1696,21 @@ const void *RB_PostProcess(const void *data) FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); } +#if 0 + if (r_cubeMapping->integer && tr.numCubemaps) + { + vec4i_t dstBox; + int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.or.origin ); + + if(cubemapIndex) + { + VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256); + //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, tr.screenScratchFbo, dstBox, &tr.testcubeShader, NULL, 0); + FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1], NULL, NULL, tr.screenScratchFbo, dstBox, &tr.testcubeShader, NULL, 0); + } + } +#endif + backEnd.framePostProcessed = qtrue; return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 171fe788f0..a785c34394 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -143,47 +143,27 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) } -void ColorToRGBE(const vec3_t color, unsigned char rgbe[4]) +// Modified from http://graphicrants.blogspot.jp/2009/04/rgbm-color-encoding.html +void ColorToRGBM(const vec3_t color, unsigned char rgbm[4]) { vec3_t sample; float maxComponent; - int e; - VectorCopy(color, sample); + VectorScale(color, 1.0f / 32.0f, sample); - maxComponent = sample[0]; - if(sample[1] > maxComponent) - maxComponent = sample[1]; - if(sample[2] > maxComponent) - maxComponent = sample[2]; + maxComponent = MAX(sample[0], sample[1]); + maxComponent = MAX(maxComponent, sample[2]); + maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f); - if(maxComponent < 1e-32) - { - rgbe[0] = 0; - rgbe[1] = 0; - rgbe[2] = 0; - rgbe[3] = 0; - } - else - { -#if 0 - maxComponent = frexp(maxComponent, &e) * 255.0 / maxComponent; - rgbe[0] = (unsigned char) (sample[0] * maxComponent); - rgbe[1] = (unsigned char) (sample[1] * maxComponent); - rgbe[2] = (unsigned char) (sample[2] * maxComponent); - rgbe[3] = (unsigned char) (e + 128); -#else - e = ceil(log(maxComponent) / log(2.0f));//ceil(log2(maxComponent)); - VectorScale(sample, 1.0 / pow(2.0f, e)/*exp2(e)*/, sample); + rgbm[3] = (unsigned char) ceil(maxComponent * 255.0f); + maxComponent = 255.0f / rgbm[3]; - rgbe[0] = (unsigned char) (sample[0] * 255); - rgbe[1] = (unsigned char) (sample[1] * 255); - rgbe[2] = (unsigned char) (sample[2] * 255); - rgbe[3] = (unsigned char) (e + 128); -#endif - } -} + VectorScale(sample, maxComponent, sample); + rgbm[0] = (unsigned char) (sample[0] * 255); + rgbm[1] = (unsigned char) (sample[1] * 255); + rgbm[2] = (unsigned char) (sample[2] * 255); +} void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4]) { @@ -290,8 +270,13 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } - if (r_hdr->integer && glRefConfig.textureFloat && glRefConfig.halfFloatPixel) - textureInternalFormat = GL_RGBA16F_ARB; + if (r_hdr->integer) + { + if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) + textureInternalFormat = GL_RGBA16F_ARB; + else + textureInternalFormat = GL_RGBA8; + } if (r_mergeLightmaps->integer) { @@ -426,10 +411,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { VectorScale(color, lightScale, color); - if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel) + if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); else - ColorToRGBE(color, &image[j*4]); + ColorToRGBM(color, &image[j*4]); } else { @@ -524,11 +509,13 @@ static float FatPackU(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - if(tr.fatLightmapSize > 0) { - int x = lightmapnum % tr.fatLightmapStep; + int x; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + x = lightmapnum % tr.fatLightmapStep; return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x); } @@ -544,11 +531,13 @@ static float FatPackV(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - if(tr.fatLightmapSize > 0) { - int y = lightmapnum / tr.fatLightmapStep; + int y; + + lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); + + y = lightmapnum / tr.fatLightmapStep; return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y); } @@ -1801,6 +1790,12 @@ static int BSPSurfaceCompare(const void *a, const void *b) else if(aa->fogIndex > bb->fogIndex) return 1; + // by cubemapIndex + if(aa->cubemapIndex < bb->cubemapIndex) + return 1; + else if(aa->cubemapIndex > bb->cubemapIndex) + return 1; + return 0; } @@ -1835,10 +1830,10 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out) /* =============== -R_CreateWorldVBO +R_CreateWorldVBOs =============== */ -static void R_CreateWorldVBO(void) +static void R_CreateWorldVBOs(void) { int i, j, k; @@ -1848,73 +1843,28 @@ static void R_CreateWorldVBO(void) int numTriangles; srfTriangle_t *triangles; - int numSurfaces; - msurface_t *surface; + int numSortedSurfaces, numSurfaces; + msurface_t *surface, **firstSurf, **lastSurf, **currSurf; msurface_t **surfacesSorted; + VBO_t *vbo; + IBO_t *ibo; + int startTime, endTime; startTime = ri->Milliseconds(); - numVerts = 0; - numTriangles = 0; - numSurfaces = 0; - for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) + for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) { - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data; - - if(face->numVerts) - numVerts += face->numVerts; - - if(face->numTriangles) - numTriangles += face->numTriangles; - - numSurfaces++; - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *grid = (srfGridMesh_t *) surface->data; - - if(grid->numVerts) - numVerts += grid->numVerts; - - if(grid->numTriangles) - numTriangles += grid->numTriangles; - - numSurfaces++; - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *tri = (srfTriangles_t *) surface->data; - - if(tri->numVerts) - numVerts += tri->numVerts; - - if(tri->numTriangles) - numTriangles += tri->numTriangles; - - numSurfaces++; - } + if(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES) + numSortedSurfaces++; } - if(!numVerts || !numTriangles) - return; - - ri->Printf(PRINT_ALL, "...calculating world VBO ( %i verts %i tris )\n", numVerts, numTriangles); - - // create arrays - - verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); - - triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); - // presort surfaces - surfacesSorted = (msurface_t **)Z_Malloc(numSurfaces * sizeof(*surfacesSorted), TAG_BSP); + surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); j = 0; - for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces; k++, surface++) + for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) { if(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES) { @@ -1922,211 +1872,271 @@ static void R_CreateWorldVBO(void) } } - qsort(surfacesSorted, numSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); + qsort(surfacesSorted, numSortedSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); - // set up triangle indices - numVerts = 0; - numTriangles = 0; - for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) + k = 0; + for(firstSurf = lastSurf = surfacesSorted; firstSurf < &surfacesSorted[numSortedSurfaces]; firstSurf = lastSurf) { - if(*surface->data == SF_FACE) + while(lastSurf < &surfacesSorted[numSortedSurfaces] && (*lastSurf)->shader->sortedIndex == (*firstSurf)->shader->sortedIndex) + lastSurf++; + numVerts = numTriangles = numSurfaces = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + surface = *currSurf; + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data; + + if(face->numVerts) + numVerts += face->numVerts; - srf->firstIndex = numTriangles * 3; + if(face->numTriangles) + numTriangles += face->numTriangles; - if(srf->numTriangles) + numSurfaces++; + } + else if(*surface->data == SF_GRID) { - srfTriangle_t *tri; + srfGridMesh_t *grid = (srfGridMesh_t *) surface->data; - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; + if(grid->numVerts) + numVerts += grid->numVerts; - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) - { - for(j = 0; j < 3; j++) - { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); - } - } + if(grid->numTriangles) + numTriangles += grid->numTriangles; - numTriangles += srf->numTriangles; + numSurfaces++; } + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *tri = (srfTriangles_t *) surface->data; - if(srf->numVerts) - numVerts += srf->numVerts; + if(tri->numVerts) + numVerts += tri->numVerts; + + if(tri->numTriangles) + numTriangles += tri->numTriangles; + + numSurfaces++; + } } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; - srf->firstIndex = numTriangles * 3; + if(!numVerts || !numTriangles) + continue; + + ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numTriangles); - if(srf->numTriangles) + // create arrays + verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); + + // set up triangle indices + numVerts = 0; + numTriangles = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + { + surface = *currSurf; + if(*surface->data == SF_FACE) { - srfTriangle_t *tri; + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; + srf->firstIndex = numTriangles * 3; - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + if(srf->numTriangles) { - for(j = 0; j < 3; j++) + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } } + + numTriangles += srf->numTriangles; } - numTriangles += srf->numTriangles; + if(srf->numVerts) + numVerts += srf->numVerts; } + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + srf->firstIndex = numTriangles * 3; - if(srf->numVerts) - numVerts += srf->numVerts; - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; - - srf->firstIndex = numTriangles * 3; - - if(srf->numTriangles) + if(srf->numTriangles) + { + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + { + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } + } + + numTriangles += srf->numTriangles; + } + + if(srf->numVerts) + numVerts += srf->numVerts; + } + else if(*surface->data == SF_TRIANGLES) { - srfTriangle_t *tri; + srfTriangles_t *srf = (srfTriangles_t *) surface->data; - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; + srf->firstIndex = numTriangles * 3; - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) + if(srf->numTriangles) { - for(j = 0; j < 3; j++) + srfTriangle_t *tri; + + srf->minIndex = numVerts + srf->triangles->indexes[0]; + srf->maxIndex = numVerts + srf->triangles->indexes[0]; + + for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + for(j = 0; j < 3; j++) + { + triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; + srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); + srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); + } } + numTriangles += srf->numTriangles; } - numTriangles += srf->numTriangles; + if(srf->numVerts) + numVerts += srf->numVerts; } - - if(srf->numVerts) - numVerts += srf->numVerts; } - } - // build vertices - numVerts = 0; - for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) - { - if(*surface->data == SF_FACE) + // build vertices + numVerts = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + surface = *currSurf; + if(*surface->data == SF_FACE) + { + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; - srf->firstVert = numVerts; + srf->firstVert = numVerts; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) + if(srf->numVerts) { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } - numVerts += srf->numVerts; + numVerts += srf->numVerts; + } } - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; - srf->firstVert = numVerts; + srf->firstVert = numVerts; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) + if(srf->numVerts) { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } - numVerts += srf->numVerts; + numVerts += srf->numVerts; + } } - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; + else if(*surface->data == SF_TRIANGLES) + { + srfTriangles_t *srf = (srfTriangles_t *) surface->data; - srf->firstVert = numVerts; + srf->firstVert = numVerts; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) + if(srf->numVerts) { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + for(i = 0; i < srf->numVerts; i++) + { + CopyVert(&srf->verts[i], &verts[numVerts + i]); + } - numVerts += srf->numVerts; + numVerts += srf->numVerts; + } } } - } #ifdef USE_VERT_TANGENT_SPACE - s_worldData.vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", 0), numVerts, verts, + vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_TANGENT | ATTR_BITANGENT | ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); #else - s_worldData.vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", 0), numVerts, verts, + vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); #endif - s_worldData.ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", 0), numTriangles, triangles, VBO_USAGE_STATIC); - - endTime = ri->Milliseconds(); - ri->Printf(PRINT_ALL, "world VBO calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); + ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", k), numTriangles, triangles, VBO_USAGE_STATIC); - // point triangle surfaces to world VBO - for(k = 0, surface = surfacesSorted[k]; k < numSurfaces; k++, surface = surfacesSorted[k]) - { - if(*surface->data == SF_FACE) + // point triangle surfaces to VBO + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; - - if( srf->numVerts && srf->numTriangles) + surface = *currSurf; + if(*surface->data == SF_FACE) { - srf->vbo = s_worldData.vbo; - srf->ibo = s_worldData.ibo; - } - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; - if( srf->numVerts && srf->numTriangles) - { - srf->vbo = s_worldData.vbo; - srf->ibo = s_worldData.ibo; + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = vbo; + srf->ibo = ibo; + } } - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; + else if(*surface->data == SF_GRID) + { + srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; - if( srf->numVerts && srf->numTriangles) + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = vbo; + srf->ibo = ibo; + } + } + else if(*surface->data == SF_TRIANGLES) { - srf->vbo = s_worldData.vbo; - srf->ibo = s_worldData.ibo; + srfTriangles_t *srf = (srfTriangles_t *) surface->data; + + if( srf->numVerts && srf->numTriangles) + { + srf->vbo = vbo; + srf->ibo = ibo; + } } + } - } + ri->Hunk_FreeTempMemory(triangles); + ri->Hunk_FreeTempMemory(verts); + + k++; + } Z_Free(surfacesSorted); - ri->Hunk_FreeTempMemory(triangles); - ri->Hunk_FreeTempMemory(verts); + endTime = ri->Milliseconds(); + ri->Printf(PRINT_ALL, "world VBOs calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); } /* @@ -2811,6 +2821,192 @@ qboolean R_GetEntityToken( char *buffer, int size ) { } } +#ifndef MAX_SPAWN_VARS +#define MAX_SPAWN_VARS 64 +#endif + +// derived from G_ParseSpawnVars() in g_spawn.c +qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSpawnVars, char *spawnVars[MAX_SPAWN_VARS][2] ) +{ + char keyname[MAX_TOKEN_CHARS]; + char com_token[MAX_TOKEN_CHARS]; + int numSpawnVarChars = 0; + + *numSpawnVars = 0; + + // parse the opening brace + if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { + // end of spawn string + return qfalse; + } + if ( com_token[0] != '{' ) { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {",com_token ); + } + + // go through all the key / value pairs + while ( 1 ) { + int keyLength, tokenLength; + + // parse key + if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); + } + + if ( keyname[0] == '}' ) { + break; + } + + // parse value + if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); + break; + } + + if ( com_token[0] == '}' ) { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data" ); + break; + } + + if ( *numSpawnVars == MAX_SPAWN_VARS ) { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS" ); + break; + } + + keyLength = strlen(keyname) + 1; + tokenLength = strlen(com_token) + 1; + + if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) + { + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS" ); + break; + } + + strcpy(spawnVarChars + numSpawnVarChars, keyname); + spawnVars[ *numSpawnVars ][0] = spawnVarChars + numSpawnVarChars; + numSpawnVarChars += keyLength; + + strcpy(spawnVarChars + numSpawnVarChars, com_token); + spawnVars[ *numSpawnVars ][1] = spawnVarChars + numSpawnVarChars; + numSpawnVarChars += tokenLength; + + (*numSpawnVars)++; + } + + return qtrue; +} + +void R_LoadCubemapEntities(char *cubemapEntityName) +{ + char spawnVarChars[2048]; + int numSpawnVars; + char *spawnVars[MAX_SPAWN_VARS][2]; + int numCubemaps = 0; + + // count cubemaps + numCubemaps = 0; + + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + { + int i; + + for (i = 0; i < numSpawnVars; i++) + { + if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) + numCubemaps++; + } + } + + if (!numCubemaps) + return; + + tr.numCubemaps = numCubemaps; + tr.cubemapOrigins = (vec3_t *)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); + tr.cubemaps = (image_t **)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + + numCubemaps = 0; + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + { + int i; + qboolean isCubemap = qfalse; + qboolean positionSet = qfalse; + vec3_t origin; + + for (i = 0; i < numSpawnVars; i++) + { + if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) + isCubemap = qtrue; + + if (!Q_stricmp(spawnVars[i][0], "origin")) + { + sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]); + positionSet = qtrue; + } + } + + if (isCubemap && positionSet) + { + //ri.Printf(PRINT_ALL, "cubemap at %f %f %f\n", origin[0], origin[1], origin[2]); + VectorCopy(origin, tr.cubemapOrigins[numCubemaps]); + numCubemaps++; + } + } +} + +void R_AssignCubemapsToWorldSurfaces(void) +{ + world_t *w; + int i; + + w = &s_worldData; + + for (i = 0; i < w->numsurfaces; i++) + { + msurface_t *surf = &w->surfaces[i]; + vec3_t surfOrigin; + + if (surf->cullinfo.type & CULLINFO_SPHERE) + { + VectorCopy(surf->cullinfo.localOrigin, surfOrigin); + } + else if (surf->cullinfo.type & CULLINFO_BOX) + { + surfOrigin[0] = (surf->cullinfo.bounds[0][0] + surf->cullinfo.bounds[1][0]) * 0.5f; + surfOrigin[1] = (surf->cullinfo.bounds[0][1] + surf->cullinfo.bounds[1][1]) * 0.5f; + surfOrigin[2] = (surf->cullinfo.bounds[0][2] + surf->cullinfo.bounds[1][2]) * 0.5f; + } + else + { + //ri.Printf(PRINT_ALL, "surface %d has no cubemap\n", i); + continue; + } + + surf->cubemapIndex = R_CubemapForPoint(surfOrigin); + //ri.Printf(PRINT_ALL, "surface %d has cubemap %d\n", i, surf->cubemapIndex); + } +} + + +void R_RenderAllCubemaps(void) +{ + int i, j; + + for (i = 0; i < tr.numCubemaps; i++) + { + tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8); + } + + for (i = 0; i < tr.numCubemaps; i++) + { + for (j = 0; j < 6; j++) + { + RE_ClearScene(); + R_RenderCubemapSide(i, j, qfalse); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + } + } +} + /* ================= @@ -2826,6 +3022,7 @@ void R_MergeLeafSurfaces(void) int mergedSurfIndex; int numMergedSurfaces; int numUnmergedSurfaces; + VBO_t *vbo; IBO_t *ibo; msurface_t *mergedSurf; @@ -2845,14 +3042,6 @@ void R_MergeLeafSurfaces(void) s_worldData.surfacesViewCount[i] = -1; } - // create ibo - ibo = tr.ibos[tr.numIBOs++] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); - memset(ibo, 0, sizeof(*ibo)); - Q_strncpyz(ibo->name, "staticWorldMesh_IBO_mergedSurfs", sizeof(ibo->name)); - - // allocate more than we need - iboIndexes = outIboIndexes = (glIndex_t *)Z_Malloc(s_worldData.ibo->indexesSize, TAG_GENERAL); - // mark matching surfaces for (i = 0; i < s_worldData.numnodes - s_worldData.numDecisionNodes; i++) { @@ -2863,6 +3052,7 @@ void R_MergeLeafSurfaces(void) msurface_t *surf1; shader_t *shader1; int fogIndex1; + int cubemapIndex1; int surfNum1; surfNum1 = *(s_worldData.marksurfaces + leaf->firstmarksurface + j); @@ -2887,6 +3077,7 @@ void R_MergeLeafSurfaces(void) continue; fogIndex1 = surf1->fogIndex; + cubemapIndex1 = surf1->cubemapIndex; s_worldData.surfacesViewCount[surfNum1] = surfNum1; @@ -2895,6 +3086,7 @@ void R_MergeLeafSurfaces(void) msurface_t *surf2; shader_t *shader2; int fogIndex2; + int cubemapIndex2; int surfNum2; surfNum2 = *(s_worldData.marksurfaces + leaf->firstmarksurface + k); @@ -2917,6 +3109,11 @@ void R_MergeLeafSurfaces(void) if (fogIndex1 != fogIndex2) continue; + cubemapIndex2 = surf2->cubemapIndex; + + if (cubemapIndex1 != cubemapIndex2) + continue; + s_worldData.surfacesViewCount[surfNum2] = surfNum1; } } @@ -2978,6 +3175,9 @@ void R_MergeLeafSurfaces(void) s_worldData.viewSurfaces[i] = s_worldData.marksurfaces[i]; } + // need to be synched here + R_IssuePendingRenderCommands(); + // actually merge surfaces numIboIndexes = 0; mergedSurfIndex = 0; @@ -3000,6 +3200,26 @@ void R_MergeLeafSurfaces(void) surf1 = s_worldData.surfaces + i; + // retrieve vbo + switch(*surf1->data) + { + case SF_FACE: + vbo = ((srfSurfaceFace_t *)(surf1->data))->vbo; + break; + + case SF_GRID: + vbo = ((srfGridMesh_t *)(surf1->data))->vbo; + break; + + case SF_TRIANGLES: + vbo = ((srfTriangles_t *)(surf1->data))->vbo; + break; + + default: + vbo = NULL; + break; + } + // count verts, indexes, and surfaces numSurfsToMerge = 0; numTriangles = 0; @@ -3057,6 +3277,15 @@ void R_MergeLeafSurfaces(void) continue; } + // create ibo + ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + memset(ibo, 0, sizeof(*ibo)); + Q_strncpyz(ibo->name, va("staticWorldMesh_IBO_mergedSurfs%i", tr.numIBOs++), sizeof(ibo->name)); + numIboIndexes = 0; + + // allocate indexes + iboIndexes = outIboIndexes = ri.Malloc(numTriangles * 3 * sizeof(*outIboIndexes)); + // Merge surfaces (indexes) and calculate bounds ClearBounds(bounds[0], bounds[1]); firstIndex = numIboIndexes; @@ -3132,7 +3361,7 @@ void R_MergeLeafSurfaces(void) memset(vboSurf, 0, sizeof(*vboSurf)); vboSurf->surfaceType = SF_VBO_MESH; - vboSurf->vbo = s_worldData.vbo; + vboSurf->vbo = vbo; vboSurf->ibo = ibo; vboSurf->numIndexes = numTriangles * 3; @@ -3150,6 +3379,7 @@ void R_MergeLeafSurfaces(void) vboSurf->shader = surf1->shader; vboSurf->fogIndex = surf1->fogIndex; + vboSurf->cubemapIndex = surf1->cubemapIndex; VectorCopy(bounds[0], vboSurf->bounds[0]); VectorCopy(bounds[1], vboSurf->bounds[1]); @@ -3160,8 +3390,20 @@ void R_MergeLeafSurfaces(void) mergedSurf->cullinfo.type = CULLINFO_BOX; mergedSurf->data = (surfaceType_t *)vboSurf; mergedSurf->fogIndex = surf1->fogIndex; + mergedSurf->cubemapIndex = surf1->cubemapIndex; mergedSurf->shader = surf1->shader; + // finish up the ibo + qglGenBuffersARB(1, &ibo->indexesVBO); + + R_BindIBO(ibo); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); + R_BindNullIBO(); + + GL_CheckErrors(); + + Z_Free(iboIndexes); + // redirect view surfaces to this surf for (j = 0; j < numWorldSurfaces; j++) { @@ -3182,21 +3424,6 @@ void R_MergeLeafSurfaces(void) mergedSurf++; } - // finish up the ibo - R_IssuePendingRenderCommands(); - - qglGenBuffersARB(1, &ibo->indexesVBO); - - R_BindIBO(ibo); - - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, (GLint)(numIboIndexes * sizeof(*iboIndexes)), iboIndexes, GL_STATIC_DRAW_ARB); - - R_BindNullIBO(); - - GL_CheckErrors(); - - Z_Free(iboIndexes); - endTime = ri->Milliseconds(); ri->Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", @@ -3354,11 +3581,12 @@ void RE_LoadWorldMap( const char *name ) { { world_t *w; - w = &s_worldData; uint8_t *primaryLightGrid, *data; int lightGridSize; int i; + w = &s_worldData; + lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; primaryLightGrid = (uint8_t *)Z_Malloc(lightGridSize * sizeof(*primaryLightGrid), TAG_GENERAL); @@ -3536,8 +3764,24 @@ void RE_LoadWorldMap( const char *name ) { Z_Free(primaryLightGrid); } + // load cubemaps + if (r_cubeMapping->integer) + { + R_LoadCubemapEntities("misc_cubemap"); + if (!tr.numCubemaps) + { + // use deathmatch spawn points as cubemaps + R_LoadCubemapEntities("info_player_deathmatch"); + } + + if (tr.numCubemaps) + { + R_AssignCubemapsToWorldSurfaces(); + } + } + // create static VBOS from the world - R_CreateWorldVBO(); + R_CreateWorldVBOs(); if (r_mergeLeafSurfaces->integer) { R_MergeLeafSurfaces(); @@ -3552,5 +3796,11 @@ void RE_LoadWorldMap( const char *name ) { R_BindNullVBO(); R_BindNullIBO(); + // Render all cubemaps + if (r_cubeMapping->integer && tr.numCubemaps) + { + R_RenderAllCubemaps(); + } + ri->FS_FreeFile( buffer.v ); } diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 28a844bd0c..c4479213c0 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -596,19 +596,49 @@ void GLimp_InitExtraExtensions() // GL_EXT_texture_sRGB extension = "GL_EXT_texture_sRGB"; - glRefConfig.texture_srgb = qfalse; + glRefConfig.textureSrgb = qfalse; if (GLimp_HaveExtension(extension)) { if (r_srgb->integer) - glRefConfig.texture_srgb = qtrue; + glRefConfig.textureSrgb = qtrue; - ri->Printf(PRINT_ALL, result[glRefConfig.texture_srgb], extension); + ri->Printf(PRINT_ALL, result[glRefConfig.textureSrgb], extension); } else { ri->Printf(PRINT_ALL, result[2], extension); } + // GL_EXT_framebuffer_sRGB + extension = "GL_EXT_framebuffer_sRGB"; + glRefConfig.framebufferSrgb = qfalse; + if (GLimp_HaveExtension(extension)) + { + if (r_srgb->integer) + glRefConfig.framebufferSrgb = qtrue; + + ri->Printf(PRINT_ALL, result[glRefConfig.framebufferSrgb], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } + + // GL_EXT_texture_sRGB_decode + extension = "GL_EXT_texture_sRGB_decode"; + glRefConfig.textureSrgbDecode = qfalse; + if (GLimp_HaveExtension(extension)) + { + if (r_srgb->integer) + glRefConfig.textureSrgbDecode = qtrue; + + ri->Printf(PRINT_ALL, result[glRefConfig.textureSrgbDecode], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } + glRefConfig.textureCompression = TCR_NONE; // GL_EXT_texture_compression_latc @@ -665,4 +695,19 @@ void GLimp_InitExtraExtensions() { ri->Printf(PRINT_ALL, result[2], extension); } + + // GL_ARB_seamless_cube_map + extension = "GL_ARB_seamless_cube_map"; + glRefConfig.seamlessCubeMap = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + if (r_arb_seamless_cube_map->integer) + glRefConfig.seamlessCubeMap = qtrue; + + ri->Printf(PRINT_ALL, result[glRefConfig.seamlessCubeMap], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } } diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 19a4b8025d..c70c4ddc5a 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -579,6 +579,17 @@ void FBO_Init(void) R_CheckFBO(tr.screenSsaoFbo); } + tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); + FBO_Bind(tr.renderCubeFbo); + + //FBO_AttachTextureImage(tr.renderCubeImage, 0); + R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, tr.renderCubeImage->texnum, 0); + glState.currentFBO->colorImage[0] = tr.renderCubeImage; + + FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + + R_CheckFBO(tr.renderCubeFbo); + GL_CheckErrors(); FBO_Bind(NULL); @@ -783,7 +794,10 @@ void FBO_Blit(FBO_t *src, vec4i_t inSrcBox, vec2_t srcTexScale, FBO_t *dst, vec4 vec4i_t srcBox; if (!src) + { + ri->Printf(PRINT_WARNING, "Tried to blit from a NULL FBO!\n"); return; + } // framebuffers are 0 bottom, Y up. if (inSrcBox) diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 5615d1d947..5cd2cab714 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -370,7 +370,7 @@ void RB_RenderFlare( flare_t *f ) { iColor[1] = color[1] * fogFactors[1]; iColor[2] = color[2] * fogFactors[2]; - RB_BeginSurface( tr.flareShader, f->fogNum ); + RB_BeginSurface( tr.flareShader, f->fogNum, 0 ); // FIXME: use quadstamp? tess.xyz[tess.numVertexes][0] = f->windowX - size; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index d1ef9abe28..8f0dad2af0 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -8,6 +8,8 @@ #include "ghoul2/G2_gore.h" #endif +// FIXME: ghoul2 doesn't use cubemaps :( + #ifdef _MSC_VER #pragma warning (disable: 4512) //default assignment operator could not be gened #endif @@ -2456,7 +2458,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from newSurf->surfaceData = surface; } newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse, qfalse, 0 ); } // projection shadows work fine with personal models @@ -2468,7 +2470,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from CRenderableSurface *newSurf = new CRenderableSurface; newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); } // don't add third_person objects if not viewing through a portal @@ -2477,7 +2479,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from CRenderableSurface *newSurf = new CRenderableSurface; newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, qfalse, 0 ); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2557,7 +2559,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, qfalse ); + R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, qfalse, 0 ); } } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 28a8c87ea6..ac0929013e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -71,6 +71,7 @@ static uniformInfo_t uniformsInfo[] = { "u_TextureMap", GLSL_INT }, { "u_LevelsMap", GLSL_INT }, + { "u_CubeMap", GLSL_INT }, { "u_ScreenImageMap", GLSL_INT }, { "u_ScreenDepthMap", GLSL_INT }, @@ -105,6 +106,7 @@ static uniformInfo_t uniformsInfo[] = { "u_LightUp", GLSL_VEC3 }, { "u_LightRight", GLSL_VEC3 }, { "u_LightOrigin", GLSL_VEC4 }, + { "u_ModelLightDir", GLSL_VEC3 }, { "u_LightRadius", GLSL_FLOAT }, { "u_AmbientLight", GLSL_VEC3 }, { "u_DirectedLight", GLSL_VEC3 }, @@ -123,11 +125,12 @@ static uniformInfo_t uniformsInfo[] = { "u_VertexLerp" , GLSL_FLOAT }, { "u_MaterialInfo", GLSL_VEC2 }, - { "u_ViewInfo", GLSL_VEC4 }, - { "u_ViewOrigin", GLSL_VEC3 }, - { "u_ViewForward", GLSL_VEC3 }, - { "u_ViewLeft", GLSL_VEC3 }, - { "u_ViewUp", GLSL_VEC3 }, + { "u_ViewInfo", GLSL_VEC4 }, + { "u_ViewOrigin", GLSL_VEC3 }, + { "u_LocalViewOrigin", GLSL_VEC3 }, + { "u_ViewForward", GLSL_VEC3 }, + { "u_ViewLeft", GLSL_VEC3 }, + { "u_ViewUp", GLSL_VEC3 }, { "u_InvTexRes", GLSL_VEC2 }, { "u_AutoExposureMinMax", GLSL_VEC2 }, @@ -293,11 +296,9 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha "#define alphaGen_t\n" "#define AGEN_LIGHTING_SPECULAR %i\n" "#define AGEN_PORTAL %i\n" - "#define AGEN_FRESNEL %i\n" "#endif\n", AGEN_LIGHTING_SPECULAR, - AGEN_PORTAL, - AGEN_FRESNEL)); + AGEN_PORTAL)); Q_strcat(dest, size, va("#ifndef texenv_t\n" @@ -906,8 +907,8 @@ void GLSL_InitGPUShaders(void) if (i & GENERICDEF_USE_LIGHTMAP) Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) - Q_strcat(extradefines, 1024, "#define RGBE_LIGHTMAP\n"); + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) + Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) { @@ -997,37 +998,35 @@ void GLSL_InitGPUShaders(void) for (i = 0; i < LIGHTDEF_COUNT; i++) { // skip impossible combos - if ((i & LIGHTDEF_USE_NORMALMAP) && !r_normalMapping->integer) - continue; - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) continue; - if ((i & LIGHTDEF_USE_SPECULARMAP) && !r_specularMapping->integer) - continue; - if ((i & LIGHTDEF_USE_DELUXEMAP) && !r_deluxeMapping->integer) continue; - if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP) && (i & LIGHTDEF_USE_DELUXEMAP)) + if ((i & LIGHTDEF_USE_CUBEMAP) && !r_cubeMapping->integer) continue; - if (!(i & LIGHTDEF_USE_NORMALMAP) && (i & LIGHTDEF_USE_PARALLAXMAP)) + if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP) && (i & LIGHTDEF_USE_DELUXEMAP)) continue; - //if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHT_VECTOR)) if (!(i & LIGHTDEF_LIGHTTYPE_MASK)) { if (i & LIGHTDEF_USE_SHADOWMAP) continue; + if (i & LIGHTDEF_USE_CUBEMAP) + continue; } attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; extradefines[0] = '\0'; - if (r_normalAmbient->value > 0.003f) - Q_strcat(extradefines, 1024, va("#define r_normalAmbient %f\n", r_normalAmbient->value)); + if (r_deluxeSpecular->value > 0.000001f) + Q_strcat(extradefines, 1024, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); + + if (r_specularIsMetallic->value) + Q_strcat(extradefines, 1024, va("#define SPECULAR_IS_METALLIC\n")); if (r_dlightMode->integer >= 2) Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); @@ -1037,8 +1036,8 @@ void GLSL_InitGPUShaders(void) Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); } - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel)) - Q_strcat(extradefines, 1024, "#define RGBE_LIGHTMAP\n"); + if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) + Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (i & LIGHTDEF_LIGHTTYPE_MASK) { @@ -1065,7 +1064,7 @@ void GLSL_InitGPUShaders(void) } } - if ((i & LIGHTDEF_USE_NORMALMAP) && r_normalMapping->integer) + if (r_normalMapping->integer) { Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); @@ -1081,7 +1080,7 @@ void GLSL_InitGPUShaders(void) #endif } - if ((i & LIGHTDEF_USE_SPECULARMAP) && r_specularMapping->integer) + if (r_specularMapping->integer) { Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); @@ -1089,19 +1088,23 @@ void GLSL_InitGPUShaders(void) { case 1: default: - Q_strcat(extradefines, 1024, "#define USE_TRIACE\n"); + Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); break; case 2: - Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); + Q_strcat(extradefines, 1024, "#define USE_BLINN_FRESNEL\n"); break; case 3: - Q_strcat(extradefines, 1024, "#define USE_COOK_TORRANCE\n"); + Q_strcat(extradefines, 1024, "#define USE_MCAULEY\n"); break; case 4: - Q_strcat(extradefines, 1024, "#define USE_TORRANCE_SPARROW\n"); + Q_strcat(extradefines, 1024, "#define USE_GOTANDA\n"); + break; + + case 5: + Q_strcat(extradefines, 1024, "#define USE_LAZAROV\n"); break; } } @@ -1112,6 +1115,9 @@ void GLSL_InitGPUShaders(void) if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY) && r_parallaxMapping->integer) Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); + if ((i & LIGHTDEF_USE_CUBEMAP)) + Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n"); + if (i & LIGHTDEF_USE_SHADOWMAP) { Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); @@ -1134,7 +1140,7 @@ void GLSL_InitGPUShaders(void) attribs |= ATTR_POSITION2 | ATTR_NORMAL2; #ifdef USE_VERT_TANGENT_SPACE - if (i & LIGHTDEF_USE_NORMALMAP && r_normalMapping->integer) + if (r_normalMapping->integer) { attribs |= ATTR_TANGENT2 | ATTR_BITANGENT2; } @@ -1155,6 +1161,7 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); qglUseProgramObjectARB(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); @@ -1361,6 +1368,26 @@ void GLSL_InitGPUShaders(void) numEtcShaders++; } + #if 0 + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) + { + ri->Error(ERR_FATAL, "Could not load testcube shader!"); + } + + GLSL_InitUniforms(&tr.testcubeShader); + + qglUseProgramObjectARB(tr.testcubeShader.program); + GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.testcubeShader); + + numEtcShaders++; + #endif + endTime = ri->Milliseconds(); @@ -1669,7 +1696,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) // position/normal/tangent/bitangent are always set in case of animation oldFrame = glState.vertexAttribsOldFrame; newFrame = glState.vertexAttribsNewFrame; - animated = (qboolean)((oldFrame != newFrame) && (glState.vertexAttribsInterpolation > 0.0f)); + animated = glState.vertexAnimation; if((attribBits & ATTR_POSITION) && (!(glState.vertexAttribPointersSet & ATTR_POSITION) || animated)) { @@ -1802,7 +1829,6 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) { case AGEN_LIGHTING_SPECULAR: case AGEN_PORTAL: - case AGEN_FRESNEL: shaderAttribs |= GENERICDEF_USE_RGBAGEN; break; default: @@ -1819,7 +1845,7 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; } - if (glState.vertexAttribsInterpolation > 0.0f && backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + if (glState.vertexAnimation) { shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 05bd3db60c..adfeadff6f 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -401,7 +401,9 @@ static void RGBAtoNormal(const byte *in, byte *out, int width, int height, qbool for (x = 0; x < width; x++) { - *outbyte = (inbyte[0] >> 2) + (inbyte[1] >> 1) + (inbyte[2] >> 2); + byte result = (inbyte[0] >> 2) + (inbyte[1] >> 1) + (inbyte[2] >> 2); + result = result * result / 255; // Make linear + *outbyte = result; max = MAX(max, *outbyte); outbyte += 4; inbyte += 4; @@ -1849,7 +1851,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } } - if (glRefConfig.texture_srgb && (flags & IMGFLAG_SRGB)) + if (glRefConfig.textureSrgb && (flags & IMGFLAG_SRGB)) { switch(internalFormat) { @@ -2042,7 +2044,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } // Convert to RGB if sRGB textures aren't supported in hardware - if (!glRefConfig.texture_srgb && (flags & IMGFLAG_SRGB)) + if (!glRefConfig.textureSrgb && (flags & IMGFLAG_SRGB)) { byte *in = data; int c = width * height; @@ -2271,12 +2273,21 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT if (image->flags & IMGFLAG_CUBEMAP) { - GL_BindCubemap(image); + GL_Bind(image); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + if (image->flags & IMGFLAG_MIPMAP) + { + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + } + else + { + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); @@ -2285,6 +2296,9 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + if (image->flags & IMGFLAG_MIPMAP) + qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); + image->uploadWidth = width; image->uploadHeight = height; } @@ -2487,6 +2501,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) normalPic = (byte *)Z_Malloc(width * height * 4, TAG_GENERAL); RGBAtoNormal(pic, normalPic, width, height, (qboolean)(flags & IMGFLAG_CLAMPTOEDGE)); +#if 1 // Brighten up the original image to work with the normal map RGBAtoYCoCgA(pic, pic, width, height); for (y = 0; y < height; y++) @@ -2502,6 +2517,61 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) } } YCoCgAtoRGBA(pic, pic, width, height); +#else + // Blur original image's luma to work with the normal map + { + byte *blurPic; + + RGBAtoYCoCgA(pic, pic, width, height); + blurPic = ri.Malloc(width * height); + + for (y = 1; y < height - 1; y++) + { + byte *picbyte = pic + y * width * 4; + byte *blurbyte = blurPic + y * width; + + picbyte += 4; + blurbyte += 1; + + for (x = 1; x < width - 1; x++) + { + int result; + + result = *(picbyte - (width + 1) * 4) + *(picbyte - width * 4) + *(picbyte - (width - 1) * 4) + + *(picbyte - 1 * 4) + *(picbyte ) + *(picbyte + 1 * 4) + + *(picbyte + (width - 1) * 4) + *(picbyte + width * 4) + *(picbyte + (width + 1) * 4); + + result /= 9; + + *blurbyte = result; + picbyte += 4; + blurbyte += 1; + } + } + + // FIXME: do borders + + for (y = 1; y < height - 1; y++) + { + byte *picbyte = pic + y * width * 4; + byte *blurbyte = blurPic + y * width; + + picbyte += 4; + blurbyte += 1; + + for (x = 1; x < width - 1; x++) + { + picbyte[0] = *blurbyte; + picbyte += 4; + blurbyte += 1; + } + } + + ri->Free(blurPic); + + YCoCgAtoRGBA(pic, pic, width, height); + } +#endif R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); Z_Free( normalPic ); @@ -2693,6 +2763,9 @@ void R_CreateBuiltinImages( void ) { Com_Memset( data, 255, sizeof( data ) ); tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, 0); + Com_Memset( data, 128, sizeof( data ) ); + tr.greyImage = R_CreateImage("*grey", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, GL_RGBA8); + if (r_dlightMode->integer >= 2) { for( x = 0; x < MAX_DLIGHTS; x++) @@ -2725,7 +2798,7 @@ void R_CreateBuiltinImages( void ) { if (glRefConfig.framebufferObject) { - int width, height, hdrFormat; + int width, height, hdrFormat, rgbFormat; if(glRefConfig.textureNonPowerOfTwo) { @@ -2742,19 +2815,15 @@ void R_CreateBuiltinImages( void ) { if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat) hdrFormat = GL_RGB16F_ARB; + rgbFormat = GL_RGBA8; + tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); if (r_drawSunRays->integer) - tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); if (r_softOverbright->integer) - { - int format; - - format = GL_RGBA8; - - tr.screenScratchImage = R_CreateImage("*screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, format); - } + tr.screenScratchImage = R_CreateImage("*screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); if (glRefConfig.framebufferObject) { @@ -2814,6 +2883,8 @@ void R_CreateBuiltinImages( void ) { { tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); } + + tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); } } @@ -3172,6 +3243,11 @@ qhandle_t RE_RegisterSkin( const char *name ) { // parse the shader name token = CommaParse( &text_p ); + if ( skin->numSurfaces >= MD3_MAX_SURFACES ) { + ri->Printf( PRINT_WARNING, "WARNING: Ignoring surfaces in '%s', the max is %d surfaces!\n", name, MD3_MAX_SURFACES ); + break; + } + surf = skin->surfaces[ skin->numSurfaces ] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 67e90b893f..7d5696c6a3 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -112,6 +112,7 @@ cvar_t *r_cameraExposure; cvar_t *r_softOverbright; cvar_t *r_hdr; +cvar_t *r_floatLightmap; cvar_t *r_postProcess; cvar_t *r_toneMap; @@ -134,7 +135,11 @@ cvar_t *r_normalMapping; cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_parallaxMapping; -cvar_t *r_normalAmbient; +cvar_t *r_cubeMapping; +cvar_t *r_deluxeSpecular; +cvar_t *r_specularIsMetallic; +cvar_t *r_baseSpecular; +cvar_t *r_baseGloss; cvar_t *r_recalcMD3Normals; cvar_t *r_mergeLightmaps; cvar_t *r_dlightMode; @@ -217,6 +222,7 @@ cvar_t *r_debugLight; cvar_t *r_debugSort; cvar_t *r_printShaders; cvar_t *r_saveFontData; +cvar_t *r_arb_seamless_cube_map; /* Ghoul2 Insert Start @@ -1035,15 +1041,8 @@ void GL_SetDefaultState( void ) qglDisable( GL_CULL_FACE ); qglDisable( GL_BLEND ); - qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - qglClearDepth( 1.0 ); - - qglDrawBuffer( GL_FRONT ); - qglClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); - - qglDrawBuffer( GL_BACK ); - qglClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_ACCUM_BUFFER_BIT|GL_STENCIL_BUFFER_BIT ); + if (glRefConfig.seamlessCubeMap) + qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } /* @@ -1209,6 +1208,7 @@ void R_Register( void ) r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "0", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1245,6 +1245,7 @@ void R_Register( void ) r_softOverbright = ri->Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1269,7 +1270,11 @@ void R_Register( void ) r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_normalAmbient = ri->Cvar_Get( "r_normalAmbient", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_deluxeSpecular = ri->Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); + r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); r_dlightMode = ri->Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); r_recalcMD3Normals = ri->Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 777492ffcb..221da656cf 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -403,9 +403,12 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { ((byte *)&ent->ambientLightInt)[3] = 0xff; // transform the direction to local space - // no need to do this if using lightentity glsl shader VectorNormalize( lightDir ); VectorCopy(lightDir, ent->lightDir); + + ent->modelLightDir[0] = DotProduct( lightDir, ent->e.axis[0] ); + ent->modelLightDir[1] = DotProduct( lightDir, ent->e.axis[1] ); + ent->modelLightDir[2] = DotProduct( lightDir, ent->e.axis[2] ); } /* @@ -449,3 +452,31 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w return qtrue; } + +int R_CubemapForPoint( vec3_t point ) +{ + int cubemapIndex = -1; + + if (r_cubeMapping->integer && tr.numCubemaps) + { + int i; + vec_t shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; + + for (i = 0; i < tr.numCubemaps; i++) + { + vec3_t diff; + vec_t length; + + VectorSubtract(point, tr.cubemapOrigins[i], diff); + length = DotProduct(diff, diff); + + if (shortest > length) + { + shortest = length; + cubemapIndex = i; + } + } + } + + return cubemapIndex + 1; +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 76495821aa..640d052773 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -67,6 +67,8 @@ typedef unsigned int glIndex_t; #define MAX_CALC_PSHADOWS 64 #define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces #define PSHADOW_MAP_SIZE 512 +#define CUBE_MAP_MIPS 7 +#define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) #define USE_VERT_TANGENT_SPACE @@ -139,6 +141,7 @@ extern cvar_t *r_ext_framebuffer_object; extern cvar_t *r_ext_texture_float; extern cvar_t *r_arb_half_float_pixel; extern cvar_t *r_ext_framebuffer_multisample; +extern cvar_t *r_arb_seamless_cube_map; extern cvar_t *r_mergeMultidraws; extern cvar_t *r_mergeLeafSurfaces; @@ -358,7 +361,8 @@ typedef struct { qboolean needDlights; // true for bmodels that touch a dlight qboolean lightingCalculated; qboolean mirrored; // mirrored matrix, needs reversed culling - vec3_t lightDir; // normalized direction towards light + vec3_t lightDir; // normalized direction towards light, in world space + vec3_t modelLightDir; // normalized direction towards light, in model space vec3_t ambientLight; // color normalized to 0-255 int ambientLightInt; // 32 bit rgba packed vec3_t directedLight; @@ -514,8 +518,7 @@ typedef enum { AGEN_LIGHTING_SPECULAR, AGEN_WAVEFORM, AGEN_PORTAL, - AGEN_CONST, - AGEN_FRESNEL + AGEN_CONST } alphaGen_t; typedef enum { @@ -643,7 +646,8 @@ enum TB_SHADOWMAP2 = 3, TB_SPECULARMAP = 4, TB_SHADOWMAP = 5, - NUM_TEXTURE_BUNDLES = 6 + TB_CUBEMAP = 6, + NUM_TEXTURE_BUNDLES = 7 }; typedef enum @@ -980,13 +984,12 @@ enum LIGHTDEF_LIGHTTYPE_MASK = 0x0003, LIGHTDEF_ENTITY = 0x0004, LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, - LIGHTDEF_USE_NORMALMAP = 0x0010, - LIGHTDEF_USE_SPECULARMAP = 0x0020, - LIGHTDEF_USE_DELUXEMAP = 0x0040, - LIGHTDEF_USE_PARALLAXMAP = 0x0080, - LIGHTDEF_USE_SHADOWMAP = 0x0100, - LIGHTDEF_ALL = 0x01FF, - LIGHTDEF_COUNT = 0x0200 + LIGHTDEF_USE_DELUXEMAP = 0x0010, + LIGHTDEF_USE_PARALLAXMAP = 0x0020, + LIGHTDEF_USE_SHADOWMAP = 0x0040, + LIGHTDEF_USE_CUBEMAP = 0x0080, + LIGHTDEF_ALL = 0x00FF, + LIGHTDEF_COUNT = 0x0100 }; enum @@ -1010,6 +1013,7 @@ typedef enum UNIFORM_TEXTUREMAP, UNIFORM_LEVELSMAP, + UNIFORM_CUBEMAP, UNIFORM_SCREENIMAGEMAP, UNIFORM_SCREENDEPTHMAP, @@ -1044,6 +1048,7 @@ typedef enum UNIFORM_LIGHTUP, UNIFORM_LIGHTRIGHT, UNIFORM_LIGHTORIGIN, + UNIFORM_MODELLIGHTDIR, UNIFORM_LIGHTRADIUS, UNIFORM_AMBIENTLIGHT, UNIFORM_DIRECTEDLIGHT, @@ -1064,6 +1069,7 @@ typedef enum UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2 UNIFORM_VIEWORIGIN, + UNIFORM_LOCALVIEWORIGIN, UNIFORM_VIEWFORWARD, UNIFORM_VIEWLEFT, UNIFORM_VIEWUP, @@ -1166,12 +1172,14 @@ typedef struct { typedef enum { VPF_NONE = 0x00, - VPF_SHADOWMAP = 0x01, - VPF_DEPTHSHADOW = 0x02, - VPF_DEPTHCLAMP = 0x04, - VPF_ORTHOGRAPHIC = 0x08, - VPF_USESUNLIGHT = 0x10, - VPF_FARPLANEFRUSTUM = 0x20 + VPF_NOVIEWMODEL = 0x01, + VPF_SHADOWMAP = 0x02, + VPF_DEPTHSHADOW = 0x04, + VPF_DEPTHCLAMP = 0x08, + VPF_ORTHOGRAPHIC = 0x10, + VPF_USESUNLIGHT = 0x20, + VPF_FARPLANEFRUSTUM = 0x40, + VPF_NOCUBEMAPS = 0x80 } viewParmFlags_t; typedef struct { @@ -1186,6 +1194,8 @@ typedef struct { cplane_t portalPlane; // clip anything behind this if mirroring int viewportX, viewportY, viewportWidth, viewportHeight; FBO_t *targetFbo; + int targetFboLayer; + int targetFboCubemapIndex; float fovX, fovY; float projectionMatrix[16]; cplane_t frustum[5]; @@ -1235,7 +1245,8 @@ Ghoul2 Insert End } surfaceType_t; typedef struct drawSurf_s { - unsigned sort; // bit combination for fast compares + unsigned int sort; // bit combination for fast compares + int cubemapIndex; surfaceType_t *surface; // any of surface*_t } drawSurf_t; @@ -1447,6 +1458,7 @@ typedef struct srfVBOMesh_s struct shader_s *shader; // FIXME move this to somewhere else int fogIndex; + int cubemapIndex; // dynamic lighting information int dlightBits; @@ -1548,6 +1560,7 @@ typedef struct msurface_s { //int viewCount; // if == tr.viewCount, already added struct shader_s *shader; int fogIndex; + int cubemapIndex; cullinfo_t cullinfo; surfaceType_t *data; // any of srf*_t @@ -1599,9 +1612,6 @@ typedef struct { int numDecisionNodes; mnode_t *nodes; - VBO_t *vbo; - IBO_t *ibo; - int numWorldSurfaces; int numsurfaces; @@ -1848,6 +1858,7 @@ typedef struct glstate_s { uint32_t vertexAttribsNewFrame; uint32_t vertexAttribsOldFrame; float vertexAttribsInterpolation; + qboolean vertexAnimation; shaderProgram_t *currentProgram; FBO_t *currentFBO; VBO_t *currentVBO; @@ -1894,9 +1905,12 @@ typedef struct { qboolean framebufferMultisample; qboolean framebufferBlit; - qboolean texture_srgb; + qboolean textureSrgb; + qboolean framebufferSrgb; + qboolean textureSrgbDecode; qboolean depthClamp; + qboolean seamlessCubeMap; } glRefConfig_t; @@ -1990,6 +2004,7 @@ typedef struct trGlobals_s { image_t *dlightImage; // inverse-quare highlight for projective adding image_t *flareImage; image_t *whiteImage; // full of 0xff + image_t *greyImage; // full of 0x80 image_t *identityLightImage; // full of tr.identityLightByte image_t *shadowCubemaps[MAX_DLIGHTS]; @@ -2009,6 +2024,7 @@ typedef struct trGlobals_s { image_t *screenShadowImage; image_t *screenSsaoImage; image_t *hdrDepthImage; + image_t *renderCubeImage; image_t *textureDepthImage; @@ -2026,6 +2042,7 @@ typedef struct trGlobals_s { FBO_t *screenShadowFbo; FBO_t *screenSsaoFbo; FBO_t *hdrDepthFbo; + FBO_t *renderCubeFbo; shader_t *defaultShader; shader_t *shadowShader; @@ -2043,6 +2060,10 @@ typedef struct trGlobals_s { int fatLightmapSize; int fatLightmapStep; + int numCubemaps; + vec3_t *cubemapOrigins; + image_t **cubemaps; + trRefEntity_t *currentEntity; trRefEntity_t worldEntity; // point currentEntity at this when rendering world int currentEntityNum; @@ -2066,6 +2087,7 @@ typedef struct trGlobals_s { shaderProgram_t shadowmaskShader; shaderProgram_t ssaoShader; shaderProgram_t depthBlurShader[2]; + shaderProgram_t testcubeShader; // ----------------------------------------- @@ -2239,6 +2261,7 @@ extern cvar_t *r_mergeLeafSurfaces; extern cvar_t *r_softOverbright; extern cvar_t *r_hdr; +extern cvar_t *r_floatLightmap; extern cvar_t *r_postProcess; extern cvar_t *r_toneMap; @@ -2263,7 +2286,11 @@ extern cvar_t *r_normalMapping; extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; -extern cvar_t *r_normalAmbient; +extern cvar_t *r_cubeMapping; +extern cvar_t *r_deluxeSpecular; +extern cvar_t *r_specularIsMetallic; +extern cvar_t *r_baseSpecular; +extern cvar_t *r_baseGloss; extern cvar_t *r_dlightMode; extern cvar_t *r_pshadowDist; extern cvar_t *r_recalcMD3Normals; @@ -2310,6 +2337,7 @@ void R_RenderView( viewParms_t *parms ); void R_RenderDlightCubemaps(const refdef_t *fd); void R_RenderPshadowMaps(const refdef_t *fd); void R_RenderSunShadowMaps(const refdef_t *fd, int level); +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ); void R_AddMD3Surfaces( trRefEntity_t *e ); void R_AddNullModelSurfaces( trRefEntity_t *e ); @@ -2323,7 +2351,7 @@ void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, int *fogNum, int *dlightMap, int *pshadowMap ); void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap ); + int fogIndex, int dlightMap, int pshadowMap, int cubemap ); void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal, const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2); @@ -2349,7 +2377,6 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, ** GL wrapper/helper functions */ void GL_Bind( image_t *image ); -void GL_BindCubemap( image_t *image ); void GL_BindToTMU( image_t *image, int tmu ); void GL_SetDefaultState (void); void GL_SelectTexture( int unit ); @@ -2515,6 +2542,7 @@ typedef struct shaderCommands_s shader_t *shader; float shaderTime; int fogNum; + int cubemapIndex; int dlightBits; // or together of all vertexDlightBits int pshadowBits; @@ -2543,7 +2571,7 @@ typedef struct shaderCommands_s extern shaderCommands_t tess; -void RB_BeginSurface(shader_t *shader, int fogNum ); +void RB_BeginSurface(shader_t *shader, int fogNum, int cubemapIndex ); void RB_EndSurface(void); void RB_CheckOverflow( int verts, int indexes ); #define RB_CHECKOVERFLOW(v,i) if (tess.numVertexes + (v) >= SHADER_MAX_VERTEXES || tess.numIndexes + (i) >= SHADER_MAX_INDEXES ) {RB_CheckOverflow(v,i);} @@ -2603,6 +2631,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or ); int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); +int R_CubemapForPoint( vec3_t point ); /* @@ -2725,7 +2754,9 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ); void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); +void RE_BeginScene( const refdef_t *fd ); void RE_RenderScene( const refdef_t *fd ); +void RE_EndScene( void ); /* ============================================================= @@ -2855,7 +2886,7 @@ void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *dstTexCoords ); void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ); void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ); void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ); -void RB_CalcTurbulentTexMatrix( const waveForm_t *wf, matrix_t matrix ); +void RB_CalcTurbulentFactors( const waveForm_t *wf, float *amplitude, float *now ); void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ); void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index f533981ada..348721151e 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1609,7 +1609,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(); R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); - RB_BeginSurface( shader, fogNum ); + RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); assert( tess.numVertexes < 128 ); @@ -1727,6 +1727,9 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { return qfalse; // bad portal, no portalentity } + if (newParms.isMirror) + newParms.flags |= VPF_NOVIEWMODEL; + R_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin ); VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); @@ -1846,7 +1849,8 @@ R_AddDrawSurf ================= */ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap ) { + int fogIndex, int dlightMap, int pshadowMap, + int cubemap) { int index; // instead of checking for overflow, we just mask the index @@ -1857,6 +1861,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) | tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) | ((int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + tr.refdef.drawSurfs[index].cubemapIndex = cubemap; tr.refdef.drawSurfs[index].surface = surface; tr.refdef.numDrawSurfs++; } @@ -1960,8 +1965,7 @@ static void R_AddEntitySurface (int entityNum) // we don't want the hacked weapon position showing in // mirrors, because the true body position will already be drawn // - if ( (ent->e.renderfx & RF_FIRST_PERSON) && (tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) ) { + if ( (ent->e.renderfx & RF_FIRST_PERSON) && (tr.viewParms.flags & VPF_NOVIEWMODEL)) { return; } @@ -1984,7 +1988,7 @@ static void R_AddEntitySurface (int entityNum) return; } shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, 0 ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, 0, 0 /* cubeMap */ ); break; case RT_MODEL: @@ -1993,7 +1997,7 @@ static void R_AddEntitySurface (int entityNum) tr.currentModel = R_GetModelByHandle( ent->e.hModel ); if (!tr.currentModel) { - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0/* cubeMap */ ); } else { switch ( tr.currentModel->type ) { case MOD_MESH: @@ -2036,7 +2040,7 @@ static void R_AddEntitySurface (int entityNum) /* Ghoul 2 Insert End */ - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0 ); + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); @@ -2046,7 +2050,7 @@ static void R_AddEntitySurface (int entityNum) break; case RT_ENT_CHAIN: shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, qfalse ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, qfalse, 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); @@ -2216,7 +2220,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW); + shadowParms.flags = (int)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); shadowParms.zFar = tr.refdef.dlights[i].radius; VectorCopy( tr.refdef.dlights[i].origin, shadowParms.or.origin ); @@ -2520,7 +2524,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) if (glRefConfig.framebufferObject) shadowParms.targetFbo = tr.pshadowFbos[i]; - shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW); + shadowParms.flags = (viewParmFlags_t)( VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL ); shadowParms.zFar = shadow->lightRadius; VectorCopy(shadow->lightOrigin, shadowParms.or.origin); @@ -2865,7 +2869,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) if (glRefConfig.framebufferObject) shadowParms.targetFbo = tr.sunShadowFbo[level]; - shadowParms.flags = (viewParmFlags_t)(VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC); + shadowParms.flags = (viewParmFlags_t)( VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL ); shadowParms.zFar = lightviewBounds[1][0]; VectorCopy(lightOrigin, shadowParms.or.origin); @@ -2904,3 +2908,130 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]); } } + +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) +{ + refdef_t refdef; + viewParms_t parms; + float oldColorScale = tr.refdef.colorScale; + + memset( &refdef, 0, sizeof( refdef ) ); + refdef.rdflags = 0; + VectorCopy(tr.cubemapOrigins[cubemapIndex], refdef.vieworg); + + switch(cubemapSide) + { + case 0: + // -X + VectorSet( refdef.viewaxis[0], -1, 0, 0); + VectorSet( refdef.viewaxis[1], 0, 0, -1); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 1: + // +X + VectorSet( refdef.viewaxis[0], 1, 0, 0); + VectorSet( refdef.viewaxis[1], 0, 0, 1); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 2: + // -Y + VectorSet( refdef.viewaxis[0], 0, -1, 0); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 0, -1); + break; + case 3: + // +Y + VectorSet( refdef.viewaxis[0], 0, 1, 0); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 0, 1); + break; + case 4: + // -Z + VectorSet( refdef.viewaxis[0], 0, 0, -1); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 5: + // +Z + VectorSet( refdef.viewaxis[0], 0, 0, 1); + VectorSet( refdef.viewaxis[1], -1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + } + + refdef.fov_x = 90; + refdef.fov_y = 90; + + refdef.x = 0; + refdef.y = 0; + refdef.width = tr.renderCubeFbo->width; + refdef.height = tr.renderCubeFbo->height; + + refdef.time = 0; + + if (!subscene) + { + RE_BeginScene(&refdef); + + // FIXME: sun shadows aren't rendered correctly in cubemaps + // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first + if(0) //(glRefConfig.framebufferObject && (r_forceSun->integer || tr.sunShadows)) + { + R_RenderSunShadowMaps(&refdef, 0); + R_RenderSunShadowMaps(&refdef, 1); + R_RenderSunShadowMaps(&refdef, 2); + } + } + + + vec3_t ambient, directed, lightDir; + R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); + tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); + if (directed[0] + directed[1] + directed[2] == 0) + { + ri->Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); + } + + + Com_Memset( &parms, 0, sizeof( parms ) ); + + parms.viewportX = 0; + parms.viewportY = 0; + parms.viewportWidth = tr.renderCubeFbo->width; + parms.viewportHeight = tr.renderCubeFbo->height; + parms.isPortal = qfalse; + parms.isMirror = qtrue; + parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS; + + parms.fovX = 90; + parms.fovY = 90; + + VectorCopy( refdef.vieworg, parms.or.origin ); + VectorCopy( refdef.viewaxis[0], parms.or.axis[0] ); + VectorCopy( refdef.viewaxis[1], parms.or.axis[1] ); + VectorCopy( refdef.viewaxis[2], parms.or.axis[2] ); + + VectorCopy( refdef.vieworg, parms.pvsOrigin ); + + // FIXME: sun shadows aren't rendered correctly in cubemaps + // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first + if (0) //(r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + { + parms.flags = VPF_USESUNLIGHT; + } + + parms.targetFbo = tr.renderCubeFbo; + parms.targetFboLayer = cubemapSide; + parms.targetFboCubemapIndex = cubemapIndex; + + R_RenderView(&parms); + + if (subscene) + { + tr.refdef.colorScale = oldColorScale; + } + else + { + RE_EndScene(); + } +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 7df00d6c36..edcae2d7b3 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -288,6 +288,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { int cull; int lod; int fogNum; + int cubemapIndex; qboolean personalModel; // don't add third_person objects if not in a portal @@ -344,6 +345,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { // fogNum = R_ComputeFogNum( model, ent ); + cubemapIndex = R_CubemapForPoint(ent->e.origin); + // // draw all surfaces // @@ -387,7 +390,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, qfalse ); + R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, qfalse, cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 0197dd9959..b1fd8846de 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -786,6 +786,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { qboolean personalModel; int cull; int fogNum; + int cubemapIndex; shader_t *shader; skin_t *skin; @@ -838,6 +839,8 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { // fogNum = R_ComputeIQMFogNum( data, ent ); + cubemapIndex = R_CubemapForPoint(ent->e.origin); + for ( i = 0 ; i < data->num_surfaces ; i++ ) { if(ent->e.customShader) shader = R_GetShaderByHandle( ent->e.customShader ); @@ -866,7 +869,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, 0, 0 ); } // projection shadows work fine with personal models @@ -874,11 +877,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0, 0 ); } if( !personalModel ) { - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, 0, cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index ad7917ca7c..683e49ab86 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -99,7 +99,7 @@ void R_AddPolygonSurfaces( void ) { for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse ); + R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse, 0 /* cubemapIndex */ ); } } @@ -273,36 +273,8 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, flo RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue ); } -/* -@@@@@@@@@@@@@@@@@@@@@ -RE_RenderScene - -Draw a 3D view into a part of the window, then return -to 2D drawing. - -Rendering a scene may require multiple views to be rendered -to handle mirrors, -@@@@@@@@@@@@@@@@@@@@@ -*/ -void RE_RenderScene( const refdef_t *fd ) { - viewParms_t parms; - int startTime; - - if ( !tr.registered ) { - return; - } - GLimp_LogComment( "====== RE_RenderScene =====\n" ); - - if ( r_norefresh->integer ) { - return; - } - - startTime = ri->Milliseconds(); - - if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { - ri->Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); - } - +void RE_BeginScene(const refdef_t *fd) +{ Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) ); tr.refdef.x = fd->x; @@ -455,6 +427,48 @@ void RE_RenderScene( const refdef_t *fd ) { // each scene / view. tr.frameSceneNum++; tr.sceneCount++; +} + +void RE_EndScene() +{ + // the next scene rendered in this frame will tack on after this one + r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; + r_firstSceneEntity = r_numentities; + r_firstSceneDlight = r_numdlights; + r_firstScenePoly = r_numpolys; +} + +/* +@@@@@@@@@@@@@@@@@@@@@ +RE_RenderScene + +Draw a 3D view into a part of the window, then return +to 2D drawing. + +Rendering a scene may require multiple views to be rendered +to handle mirrors, +@@@@@@@@@@@@@@@@@@@@@ +*/ +void RE_RenderScene( const refdef_t *fd ) { + viewParms_t parms; + int startTime; + + if ( !tr.registered ) { + return; + } + GLimp_LogComment( "====== RE_RenderScene =====\n" ); + + if ( r_norefresh->integer ) { + return; + } + + startTime = ri->Milliseconds(); + + if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { + ri->Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); + } + + RE_BeginScene(fd); // SmileTheory: playing with shadow mapping if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2) @@ -476,6 +490,21 @@ void RE_RenderScene( const refdef_t *fd ) { R_RenderSunShadowMaps(fd, 2); } + // playing with cube maps + // this is where dynamic cubemaps would be rendered + if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL )) + { + int i, j; + + for (i = 0; i < tr.numCubemaps; i++) + { + for (j = 0; j < 6; j++) + { + R_RenderCubemapSide(i, j, qtrue); + } + } + } + // setup view parms for the initial view // // set up viewport @@ -511,11 +540,7 @@ void RE_RenderScene( const refdef_t *fd ) { if(!( fd->rdflags & RDF_NOWORLDMODEL )) R_AddPostProcessCmd(); - // the next scene rendered in this frame will tack on after this one - r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; - r_firstSceneEntity = r_numentities; - r_firstSceneDlight = r_numdlights; - r_firstScenePoly = r_numpolys; + RE_EndScene(); tr.frontEndMsec += ri->Milliseconds() - startTime; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index d90db517b8..e60c096d29 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -186,7 +186,7 @@ because a surface may be forced to perform a RB_End due to overflow. ============== */ -void RB_BeginSurface( shader_t *shader, int fogNum ) { +void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { shader_t *state = (shader->remappedShader) ? shader->remappedShader : shader; @@ -196,6 +196,7 @@ void RB_BeginSurface( shader_t *shader, int fogNum ) { tess.multiDrawPrimitives = 0; tess.shader = state; tess.fogNum = fogNum; + tess.cubemapIndex = cubemapIndex; tess.dlightBits = 0; // will be OR'd in by surface functions tess.pshadowBits = 0; // will be OR'd in by surface functions tess.xstages = state->stages; @@ -220,14 +221,22 @@ extern float EvalWaveForm( const waveForm_t *wf ); extern float EvalWaveFormClamped( const waveForm_t *wf ); -static void ComputeTexMatrix( shaderStage_t *pStage, int bundleNum, float *outmatrix) +static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatrix, float *outOffTurb) { int tm; - float matrix[16], currentmatrix[16]; + float matrix[6], currentmatrix[6]; textureBundle_t *bundle = &pStage->bundle[bundleNum]; - Matrix16Identity(outmatrix); - Matrix16Identity(currentmatrix); + matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = 0.0f; + matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = 0.0f; + + currentmatrix[0] = 1.0f; currentmatrix[2] = 0.0f; currentmatrix[4] = 0.0f; + currentmatrix[1] = 0.0f; currentmatrix[3] = 1.0f; currentmatrix[5] = 0.0f; + + outMatrix[0] = 1.0f; outMatrix[2] = 0.0f; + outMatrix[1] = 0.0f; outMatrix[3] = 1.0f; + + outOffTurb[0] = 0.0f; outOffTurb[1] = 0.0f; outOffTurb[2] = 0.0f; outOffTurb[3] = 0.0f; for ( tm = 0; tm < bundle->numTexMods ; tm++ ) { switch ( bundle->texMods[tm].type ) @@ -238,59 +247,73 @@ static void ComputeTexMatrix( shaderStage_t *pStage, int bundleNum, float *outma break; case TMOD_TURBULENT: - RB_CalcTurbulentTexMatrix( &bundle->texMods[tm].wave, - matrix ); - outmatrix[12] = matrix[12]; - outmatrix[13] = matrix[13]; - Matrix16Copy(outmatrix, currentmatrix); + RB_CalcTurbulentFactors(&bundle->texMods[tm].wave, &outOffTurb[2], &outOffTurb[3]); break; case TMOD_ENTITY_TRANSLATE: - RB_CalcScrollTexMatrix( backEnd.currentEntity->e.shaderTexCoord, - matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); + RB_CalcScrollTexMatrix( backEnd.currentEntity->e.shaderTexCoord, matrix ); break; case TMOD_SCROLL: RB_CalcScrollTexMatrix( bundle->texMods[tm].scroll, matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); break; case TMOD_SCALE: RB_CalcScaleTexMatrix( bundle->texMods[tm].scale, matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); break; case TMOD_STRETCH: RB_CalcStretchTexMatrix( &bundle->texMods[tm].wave, matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); break; case TMOD_TRANSFORM: RB_CalcTransformTexMatrix( &bundle->texMods[tm], matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); break; case TMOD_ROTATE: RB_CalcRotateTexMatrix( bundle->texMods[tm].rotateSpeed, matrix ); - Matrix16Multiply(matrix, currentmatrix, outmatrix); - Matrix16Copy(outmatrix, currentmatrix); break; default: ri->Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); break; } + + switch ( bundle->texMods[tm].type ) + { + case TMOD_NONE: + case TMOD_TURBULENT: + default: + break; + + case TMOD_ENTITY_TRANSLATE: + case TMOD_SCROLL: + case TMOD_SCALE: + case TMOD_STRETCH: + case TMOD_TRANSFORM: + case TMOD_ROTATE: + outMatrix[0] = matrix[0] * currentmatrix[0] + matrix[2] * currentmatrix[1]; + outMatrix[1] = matrix[1] * currentmatrix[0] + matrix[3] * currentmatrix[1]; + + outMatrix[2] = matrix[0] * currentmatrix[2] + matrix[2] * currentmatrix[3]; + outMatrix[3] = matrix[1] * currentmatrix[2] + matrix[3] * currentmatrix[3]; + + outOffTurb[0] = matrix[0] * currentmatrix[4] + matrix[2] * currentmatrix[5] + matrix[4]; + outOffTurb[1] = matrix[1] * currentmatrix[4] + matrix[3] * currentmatrix[5] + matrix[5]; + + currentmatrix[0] = outMatrix[0]; + currentmatrix[1] = outMatrix[1]; + currentmatrix[2] = outMatrix[2]; + currentmatrix[3] = outMatrix[3]; + currentmatrix[4] = outOffTurb[0]; + currentmatrix[5] = outOffTurb[1]; + break; + } } } @@ -422,44 +445,27 @@ static void ProjectDlightTexture( void ) { static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor ) { + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = 1.0f; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + // // rgbGen // switch ( pStage->rgbGen ) { - case CGEN_IDENTITY: - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; - break; case CGEN_IDENTITY_LIGHTING: baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; case CGEN_EXACT_VERTEX: - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 0.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 1.0f; - break; case CGEN_EXACT_VERTEX_LIT: baseColor[0] = baseColor[1] = @@ -476,11 +482,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[1] = pStage->constantColor[1] / 255.0f; baseColor[2] = pStage->constantColor[2] / 255.0f; baseColor[3] = pStage->constantColor[3] / 255.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; case CGEN_VERTEX: baseColor[0] = @@ -508,12 +509,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[0] = baseColor[1] = baseColor[2] = tr.identityLight; - baseColor[3] = 1.0f; vertColor[0] = vertColor[1] = vertColor[2] = -tr.identityLight; - vertColor[3] = 0.0f; break; case CGEN_FOG: { @@ -526,22 +525,11 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; } - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; case CGEN_WAVEFORM: baseColor[0] = baseColor[1] = baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; case CGEN_ENTITY: if (backEnd.currentEntity) @@ -551,11 +539,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[2] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[2] / 255.0f; baseColor[3] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; } - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; case CGEN_ONE_MINUS_ENTITY: if (backEnd.currentEntity) @@ -565,23 +548,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[2] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[2] / 255.0f; baseColor[3] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; } - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; + case CGEN_IDENTITY: case CGEN_LIGHTING_DIFFUSE: case CGEN_BAD: - baseColor[0] = - baseColor[1] = - baseColor[2] = - baseColor[3] = 1.0f; - - vertColor[0] = - vertColor[1] = - vertColor[2] = - vertColor[3] = 0.0f; break; } @@ -592,10 +562,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t { case AGEN_SKIP: break; - case AGEN_IDENTITY: - baseColor[3] = 1.0f; - vertColor[3] = 0.0f; - break; case AGEN_CONST: baseColor[3] = pStage->constantColor[3] / 255.0f; vertColor[3] = 0.0f; @@ -626,9 +592,9 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[3] = 1.0f; vertColor[3] = -1.0f; break; + case AGEN_IDENTITY: case AGEN_LIGHTING_SPECULAR: case AGEN_PORTAL: - case AGEN_FRESNEL: // Done entirely in vertex program baseColor[3] = 1.0f; vertColor[3] = 0.0f; @@ -748,7 +714,8 @@ static void ForwardDlight( void ) { dlight_t *dl; shaderProgram_t *sp; vec4_t vector; - matrix_t matrix; + vec4_t texMatrix; + vec4_t texOffTurb; if ( !( tess.dlightBits & ( 1 << l ) ) ) { continue; // this surface definately doesn't have any of this light @@ -775,6 +742,7 @@ static void ForwardDlight( void ) { GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); + GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -846,17 +814,13 @@ static void ForwardDlight( void ) { if (r_dlightMode->integer >= 2) { GL_SelectTexture(TB_SHADOWMAP); - GL_BindCubemap(tr.shadowCubemaps[l]); + GL_Bind(tr.shadowCubemaps[l]); GL_SelectTexture(0); } - ComputeTexMatrix( pStage, TB_DIFFUSEMAP, matrix ); - - VectorSet4(vector, matrix[0], matrix[1], matrix[4], matrix[5]); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); - - VectorSet4(vector, matrix[8], matrix[9], matrix[12], matrix[13]); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); + ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); @@ -981,7 +945,7 @@ static void RB_FogPass( void ) { if (deformGen != DGEN_NONE) index |= FOGDEF_USE_DEFORM_VERTEXES; - if (glState.vertexAttribsInterpolation) + if (glState.vertexAnimation) index |= FOGDEF_USE_VERTEX_ANIMATION; sp = &tr.fogShader[index]; @@ -1038,7 +1002,7 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) { unsigned int vertexAttribs = input->shader->vertexAttribs; - if(glState.vertexAttribsInterpolation > 0.0f) + if(glState.vertexAnimation) { vertexAttribs |= ATTR_POSITION2; if (vertexAttribs & ATTR_NORMAL) @@ -1057,7 +1021,6 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) static void RB_IterateStagesGeneric( shaderCommands_t *input ) { int stage; - matrix_t matrix; vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; float eyeT = 0; @@ -1073,6 +1036,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) { shaderStage_t *pStage = input->xstages[stage]; shaderProgram_t *sp; + vec4_t texMatrix; + vec4_t texOffTurb; if ( !pStage ) { @@ -1081,7 +1046,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (backEnd.depthFill) { - if (pStage->glslShaderGroup) + if (pStage->glslShaderGroup == tr.lightallShader) { int index = 0; @@ -1106,7 +1071,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; } - if (glState.vertexAttribsInterpolation > 0.0f && backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + if (glState.vertexAnimation) { shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; } @@ -1119,7 +1084,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) sp = &tr.genericShader[shaderAttribs]; } } - else if (pStage->glslShaderGroup) + else if (pStage->glslShaderGroup == tr.lightallShader) { int index = pStage->glslShaderIndex; @@ -1133,6 +1098,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) index |= LIGHTDEF_USE_SHADOWMAP; } + if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && (index & LIGHTDEF_LIGHTTYPE_MASK) && input->cubemapIndex) + { + index |= LIGHTDEF_USE_CUBEMAP; + } + if (r_lightmap->integer && index & LIGHTDEF_USE_LIGHTMAP) { index = LIGHTDEF_USE_LIGHTMAP; @@ -1140,10 +1110,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) sp = &pStage->glslShaderGroup[index]; - if (pStage->glslShaderGroup == tr.lightallShader) - { - backEnd.pc.c_lightallDraws++; - } + backEnd.pc.c_lightallDraws++; } else { @@ -1156,6 +1123,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); + GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -1177,39 +1145,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) { vec4_t baseColor; vec4_t vertColor; - qboolean tint = qtrue; - int stage2; ComputeShaderColors(pStage, baseColor, vertColor); - for ( stage2 = stage + 1; stage2 < MAX_SHADER_STAGES; stage2++ ) - { - shaderStage_t *pStage2 = input->xstages[stage2]; - unsigned int srcBlendBits; - //unsigned int dstBlendBits; - - if ( !pStage2 ) - { - break; - } - - srcBlendBits = pStage2->stateBits & GLS_SRCBLEND_BITS; - //dstBlendBits = pStage2->stateBits & GLS_DSTBLEND_BITS; - - if (srcBlendBits == GLS_SRCBLEND_DST_COLOR) - { - tint = qfalse; - break; - } - } - - if (!((tr.sunShadows || r_forceSun->integer) && tess.shader->sort <= SS_OPAQUE - && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) && tess.xstages[0]->glslShaderGroup == tr.lightallShader)) - { - tint = qfalse; - } - - if (tint) + if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { // use VectorScale to only scale first three values, not alpha VectorScale(baseColor, backEnd.refdef.colorScale, baseColor); @@ -1233,8 +1172,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) VectorCopy(backEnd.currentEntity->lightDir, vec); vec[3] = 0.0f; GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec); + GLSL_SetUniformVec3(sp, UNIFORM_MODELLIGHTDIR, backEnd.currentEntity->modelLightDir); - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 999999.0f); + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 0.0f); } if (pStage->alphaGen == AGEN_PORTAL) @@ -1254,16 +1194,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); } - ComputeTexMatrix( pStage, TB_DIFFUSEMAP, matrix ); - - { - vec4_t vector; - VectorSet4(vector, matrix[0], matrix[1], matrix[4], matrix[5]); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); - - VectorSet4(vector, matrix[8], matrix[9], matrix[12], matrix[13]); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); - } + ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); + GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); if (pStage->bundle[0].tcGen == TCGEN_VECTOR) @@ -1292,7 +1225,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) R_BindAnimatedImageToTMU( &pStage->bundle[TB_COLORMAP], TB_COLORMAP ); } - else if ( pStage->glslShaderGroup ) + else if ( pStage->glslShaderGroup == tr.lightallShader ) { int i; @@ -1308,13 +1241,27 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { - if (i == TB_LIGHTMAP) - { - R_BindAnimatedImageToTMU( &pStage->bundle[i], i); - } - else if (pStage->bundle[i].image[0]) + if (pStage->bundle[i].image[0]) { - GL_BindToTMU( tr.whiteImage, i); + switch(i) + { + case TB_LIGHTMAP: + R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], i); + break; + + case TB_DIFFUSEMAP: + case TB_SPECULARMAP: + case TB_SHADOWMAP: + case TB_CUBEMAP: + default: + GL_BindToTMU( tr.whiteImage, i); + break; + + case TB_NORMALMAP: + case TB_DELUXEMAP: + GL_BindToTMU( tr.greyImage, i); + break; + } } } } @@ -1322,13 +1269,27 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { - if (i == TB_LIGHTMAP) - { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); - } - else if (pStage->bundle[i].image[0]) + if (pStage->bundle[i].image[0]) { - GL_BindToTMU( tr.whiteImage, i); + switch(i) + { + case TB_LIGHTMAP: + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); + break; + + case TB_DIFFUSEMAP: + case TB_SPECULARMAP: + case TB_SHADOWMAP: + case TB_CUBEMAP: + default: + GL_BindToTMU( tr.whiteImage, i); + break; + + case TB_NORMALMAP: + case TB_DELUXEMAP: + GL_BindToTMU( tr.greyImage, i); + break; + } } } } @@ -1373,6 +1334,12 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, 0); } + // + // testing cube map + // + if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) + GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + // // draw // diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index b28a812ce5..1bb0a226fc 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -84,42 +84,16 @@ static float EvalWaveFormClamped( const waveForm_t *wf ) } /* -** RB_CalcStretchTexCoords +** RB_CalcStretchTexMatrix */ -void RB_CalcStretchTexCoords( const waveForm_t *wf, float *st ) -{ - float p; - texModInfo_t tmi; - - p = 1.0f / EvalWaveForm( wf ); - - tmi.matrix[0][0] = p; - tmi.matrix[1][0] = 0; - tmi.translate[0] = 0.5f - 0.5f * p; - - tmi.matrix[0][1] = 0; - tmi.matrix[1][1] = p; - tmi.translate[1] = 0.5f - 0.5f * p; - - RB_CalcTransformTexCoords( &tmi, st ); -} - void RB_CalcStretchTexMatrix( const waveForm_t *wf, float *matrix ) { float p; - texModInfo_t tmi; p = 1.0f / EvalWaveForm( wf ); - tmi.matrix[0][0] = p; - tmi.matrix[1][0] = 0; - tmi.translate[0] = 0.5f - 0.5f * p; - - tmi.matrix[0][1] = 0; - tmi.matrix[1][1] = p; - tmi.translate[1] = 0.5f - 0.5f * p; - - RB_CalcTransformTexMatrix( &tmi, matrix ); + matrix[0] = p; matrix[2] = 0; matrix[4] = 0.5f - 0.5f * p; + matrix[1] = 0; matrix[3] = p; matrix[5] = 0.5f - 0.5f * p; } /* @@ -618,88 +592,6 @@ COLORS */ -/* -** RB_CalcColorFromEntity -*/ -void RB_CalcColorFromEntity( unsigned char *dstColors ) -{ - int i; - int *pColors = ( int * ) dstColors; - int c; - - if ( !backEnd.currentEntity ) - return; - - c = * ( int * ) backEnd.currentEntity->e.shaderRGBA; - - for ( i = 0; i < tess.numVertexes; i++, pColors++ ) - { - *pColors = c; - } -} - -/* -** RB_CalcColorFromOneMinusEntity -*/ -void RB_CalcColorFromOneMinusEntity( unsigned char *dstColors ) -{ - int i; - int *pColors = ( int * ) dstColors; - unsigned char invModulate[4]; - int c; - - if ( !backEnd.currentEntity ) - return; - - invModulate[0] = 255 - backEnd.currentEntity->e.shaderRGBA[0]; - invModulate[1] = 255 - backEnd.currentEntity->e.shaderRGBA[1]; - invModulate[2] = 255 - backEnd.currentEntity->e.shaderRGBA[2]; - invModulate[3] = 255 - backEnd.currentEntity->e.shaderRGBA[3]; // this trashes alpha, but the AGEN block fixes it - - c = * ( int * ) invModulate; - - for ( i = 0; i < tess.numVertexes; i++, pColors++ ) - { - *pColors = c; - } -} - -/* -** RB_CalcAlphaFromEntity -*/ -void RB_CalcAlphaFromEntity( unsigned char *dstColors ) -{ - int i; - - if ( !backEnd.currentEntity ) - return; - - dstColors += 3; - - for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) - { - *dstColors = backEnd.currentEntity->e.shaderRGBA[3]; - } -} - -/* -** RB_CalcAlphaFromOneMinusEntity -*/ -void RB_CalcAlphaFromOneMinusEntity( unsigned char *dstColors ) -{ - int i; - - if ( !backEnd.currentEntity ) - return; - - dstColors += 3; - - for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) - { - *dstColors = 0xff - backEnd.currentEntity->e.shaderRGBA[3]; - } -} - /* ** RB_CalcWaveColorSingle */ @@ -723,29 +615,6 @@ float RB_CalcWaveColorSingle( const waveForm_t *wf ) return glow; } -/* -** RB_CalcWaveColor -*/ -void RB_CalcWaveColor( const waveForm_t *wf, unsigned char *dstColors ) -{ - int i; - int v; - float glow; - int *colors = ( int * ) dstColors; - byte color[4]; - - glow = RB_CalcWaveColorSingle( wf ); - - v = Q_ftol(255 * glow); - color[0] = color[1] = color[2] = v; - color[3] = 255; - v = *(int *)color; - - for ( i = 0; i < tess.numVertexes; i++, colors++ ) { - *colors = v; - } -} - /* ** RB_CalcWaveAlphaSingle */ @@ -754,25 +623,6 @@ float RB_CalcWaveAlphaSingle( const waveForm_t *wf ) return EvalWaveFormClamped( wf ); } -/* -** RB_CalcWaveAlpha -*/ -void RB_CalcWaveAlpha( const waveForm_t *wf, unsigned char *dstColors ) -{ - int i; - int v; - float glow; - - glow = EvalWaveFormClamped( wf ); - - v = 255 * glow; - - for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) - { - dstColors[3] = v; - } -} - /* ** RB_CalcModulateColorsByFog */ @@ -793,46 +643,6 @@ void RB_CalcModulateColorsByFog( unsigned char *colors ) { } } -/* -** RB_CalcModulateAlphasByFog -*/ -void RB_CalcModulateAlphasByFog( unsigned char *colors ) { - int i; - float texCoords[SHADER_MAX_VERTEXES][2]; - - // calculate texcoords so we can derive density - // this is not wasted, because it would only have - // been previously called if the surface was opaque - RB_CalcFogTexCoords( texCoords[0] ); - - for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { - float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); - colors[3] *= f; - } -} - -/* -** RB_CalcModulateRGBAsByFog -*/ -void RB_CalcModulateRGBAsByFog( unsigned char *colors ) { - int i; - float texCoords[SHADER_MAX_VERTEXES][2]; - - // calculate texcoords so we can derive density - // this is not wasted, because it would only have - // been previously called if the surface was opaque - RB_CalcFogTexCoords( texCoords[0] ); - - for ( i = 0; i < tess.numVertexes; i++, colors += 4 ) { - float f = 1.0 - R_FogFactor( texCoords[i][0], texCoords[i][1] ); - colors[0] *= f; - colors[1] *= f; - colors[2] *= f; - colors[3] *= f; - } -} - - /* ==================================================================== @@ -928,117 +738,27 @@ void RB_CalcFogTexCoords( float *st ) { } } - - /* -** RB_CalcEnvironmentTexCoords +** RB_CalcTurbulentFactors */ -void RB_CalcEnvironmentTexCoords( float *st ) +void RB_CalcTurbulentFactors( const waveForm_t *wf, float *amplitude, float *now ) { - int i; - float *v, *normal; - vec3_t viewer, reflected; - float d; - - v = tess.xyz[0]; - normal = tess.normal[0]; - - for (i = 0 ; i < tess.numVertexes ; i++, v += 4, normal += 4, st += 2 ) - { - VectorSubtract (backEnd.or.viewOrigin, v, viewer); - VectorNormalizeFast (viewer); - - d = DotProduct (normal, viewer); - - reflected[0] = normal[0]*2*d - viewer[0]; - reflected[1] = normal[1]*2*d - viewer[1]; - reflected[2] = normal[2]*2*d - viewer[2]; - - st[0] = 0.5 + reflected[1] * 0.5; - st[1] = 0.5 - reflected[2] * 0.5; - } + *now = wf->phase + tess.shaderTime * wf->frequency; + *amplitude = wf->amplitude; } /* -** RB_CalcTurbulentTexCoords +** RB_CalcScaleTexMatrix */ -void RB_CalcTurbulentTexCoords( const waveForm_t *wf, float *st ) -{ - int i; - float now; - - now = ( wf->phase + tess.shaderTime * wf->frequency ); - - for ( i = 0; i < tess.numVertexes; i++, st += 2 ) - { - float s = st[0]; - float t = st[1]; - - st[0] = s + tr.sinTable[ ( ( int ) ( ( ( tess.xyz[i][0] + tess.xyz[i][2] )* 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude; - st[1] = t + tr.sinTable[ ( ( int ) ( ( tess.xyz[i][1] * 1.0/128 * 0.125 + now ) * FUNCTABLE_SIZE ) ) & ( FUNCTABLE_MASK ) ] * wf->amplitude; - } -} - -void RB_CalcTurbulentTexMatrix( const waveForm_t *wf, matrix_t matrix ) -{ - float now; - - now = ( wf->phase + tess.shaderTime * wf->frequency ); - - // bit of a hack here, hide amplitude and now in the matrix - // the vertex program will extract them and perform a turbulent pass last if it's nonzero - - matrix[ 0] = 1.0f; matrix[ 4] = 0.0f; matrix[ 8] = 0.0f; matrix[12] = wf->amplitude; - matrix[ 1] = 0.0f; matrix[ 5] = 1.0f; matrix[ 9] = 0.0f; matrix[13] = now; - matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; - matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; -} - -/* -** RB_CalcScaleTexCoords -*/ -void RB_CalcScaleTexCoords( const float scale[2], float *st ) -{ - int i; - - for ( i = 0; i < tess.numVertexes; i++, st += 2 ) - { - st[0] *= scale[0]; - st[1] *= scale[1]; - } -} - void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ) { - matrix[ 0] = scale[0]; matrix[ 4] = 0.0f; matrix[ 8] = 0.0f; matrix[12] = 0.0f; - matrix[ 1] = 0.0f; matrix[ 5] = scale[1]; matrix[ 9] = 0.0f; matrix[13] = 0.0f; - matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; - matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; + matrix[0] = scale[0]; matrix[2] = 0.0f; matrix[4] = 0.0f; + matrix[1] = 0.0f; matrix[3] = scale[1]; matrix[5] = 0.0f; } /* -** RB_CalcScrollTexCoords +** RB_CalcScrollTexMatrix */ -void RB_CalcScrollTexCoords( const float scrollSpeed[2], float *st ) -{ - int i; - float timeScale = tess.shaderTime; - float adjustedScrollS, adjustedScrollT; - - adjustedScrollS = scrollSpeed[0] * timeScale; - adjustedScrollT = scrollSpeed[1] * timeScale; - - // clamp so coordinates don't continuously get larger, causing problems - // with hardware limits - adjustedScrollS = adjustedScrollS - floor( adjustedScrollS ); - adjustedScrollT = adjustedScrollT - floor( adjustedScrollT ); - - for ( i = 0; i < tess.numVertexes; i++, st += 2 ) - { - st[0] += adjustedScrollS; - st[1] += adjustedScrollT; - } -} void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ) { @@ -1053,73 +773,28 @@ void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ) adjustedScrollS = adjustedScrollS - floor( adjustedScrollS ); adjustedScrollT = adjustedScrollT - floor( adjustedScrollT ); - - matrix[ 0] = 1.0f; matrix[ 4] = 0.0f; matrix[ 8] = adjustedScrollS; matrix[12] = 0.0f; - matrix[ 1] = 0.0f; matrix[ 5] = 1.0f; matrix[ 9] = adjustedScrollT; matrix[13] = 0.0f; - matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; - matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; + matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = adjustedScrollS; + matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = adjustedScrollT; } /* -** RB_CalcTransformTexCoords +** RB_CalcTransformTexMatrix */ -void RB_CalcTransformTexCoords( const texModInfo_t *tmi, float *st ) -{ - int i; - - for ( i = 0; i < tess.numVertexes; i++, st += 2 ) - { - float s = st[0]; - float t = st[1]; - - st[0] = s * tmi->matrix[0][0] + t * tmi->matrix[1][0] + tmi->translate[0]; - st[1] = s * tmi->matrix[0][1] + t * tmi->matrix[1][1] + tmi->translate[1]; - } -} - void RB_CalcTransformTexMatrix( const texModInfo_t *tmi, float *matrix ) { - matrix[ 0] = tmi->matrix[0][0]; matrix[ 4] = tmi->matrix[1][0]; matrix[ 8] = tmi->translate[0]; matrix[12] = 0.0f; - matrix[ 1] = tmi->matrix[0][1]; matrix[ 5] = tmi->matrix[1][1]; matrix[ 9] = tmi->translate[1]; matrix[13] = 0.0f; - matrix[ 2] = 0.0f; matrix[ 6] = 0.0f; matrix[10] = 1.0f; matrix[14] = 0.0f; - matrix[ 3] = 0.0f; matrix[ 7] = 0.0f; matrix[11] = 0.0f; matrix[15] = 1.0f; + matrix[0] = tmi->matrix[0][0]; matrix[2] = tmi->matrix[1][0]; matrix[4] = tmi->translate[0]; + matrix[1] = tmi->matrix[0][1]; matrix[3] = tmi->matrix[1][1]; matrix[5] = tmi->translate[1]; } /* -** RB_CalcRotateTexCoords +** RB_CalcRotateTexMatrix */ -void RB_CalcRotateTexCoords( float degsPerSecond, float *st ) -{ - float timeScale = tess.shaderTime; - float degs; - int index; - float sinValue, cosValue; - texModInfo_t tmi; - - degs = -degsPerSecond * timeScale; - index = degs * ( FUNCTABLE_SIZE / 360.0f ); - - sinValue = tr.sinTable[ index & FUNCTABLE_MASK ]; - cosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ]; - - tmi.matrix[0][0] = cosValue; - tmi.matrix[1][0] = -sinValue; - tmi.translate[0] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; - - tmi.matrix[0][1] = sinValue; - tmi.matrix[1][1] = cosValue; - tmi.translate[1] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; - - RB_CalcTransformTexCoords( &tmi, st ); -} - void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ) { float timeScale = tess.shaderTime; float degs; int index; float sinValue, cosValue; - texModInfo_t tmi; degs = -degsPerSecond * timeScale; index = degs * ( FUNCTABLE_SIZE / 360.0f ); @@ -1127,213 +802,10 @@ void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ) sinValue = tr.sinTable[ index & FUNCTABLE_MASK ]; cosValue = tr.sinTable[ ( index + FUNCTABLE_SIZE / 4 ) & FUNCTABLE_MASK ]; - tmi.matrix[0][0] = cosValue; - tmi.matrix[1][0] = -sinValue; - tmi.translate[0] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; - - tmi.matrix[0][1] = sinValue; - tmi.matrix[1][1] = cosValue; - tmi.translate[1] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; - - RB_CalcTransformTexMatrix( &tmi, matrix ); -} -/* -** RB_CalcSpecularAlpha -** -** Calculates specular coefficient and places it in the alpha channel -*/ -vec3_t lightOrigin = { -960, 1980, 96 }; // FIXME: track dynamically - -void RB_CalcSpecularAlpha( unsigned char *alphas ) { - int i; - float *v, *normal; - vec3_t viewer, reflected; - float l, d; - int b; - vec3_t lightDir; - int numVertexes; - - v = tess.xyz[0]; - normal = tess.normal[0]; - - alphas += 3; - - numVertexes = tess.numVertexes; - for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4, alphas += 4) { - float ilength; - - VectorSubtract( lightOrigin, v, lightDir ); -// ilength = Q_rsqrt( DotProduct( lightDir, lightDir ) ); - VectorNormalizeFast( lightDir ); - - // calculate the specular color - d = DotProduct (normal, lightDir); -// d *= ilength; - - // we don't optimize for the d < 0 case since this tends to - // cause visual artifacts such as faceted "snapping" - reflected[0] = normal[0]*2*d - lightDir[0]; - reflected[1] = normal[1]*2*d - lightDir[1]; - reflected[2] = normal[2]*2*d - lightDir[2]; - - VectorSubtract (backEnd.or.viewOrigin, v, viewer); - ilength = Q_rsqrt( DotProduct( viewer, viewer ) ); - l = DotProduct (reflected, viewer); - l *= ilength; - - if (l < 0) { - b = 0; - } else { - l = l*l; - l = l*l; - b = l * 255; - if (b > 255) { - b = 255; - } - } - - *alphas = b; - } -} - -/* -** RB_CalcDiffuseColor -** -** The basic vertex lighting calc -*/ -#if idppc_altivec -static void RB_CalcDiffuseColor_altivec( unsigned char *colors ) -{ - int i; - float *v, *normal; - trRefEntity_t *ent; - int ambientLightInt; - vec3_t lightDir; - int numVertexes; - vector unsigned char vSel = VECCONST_UINT8(0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff); - vector float ambientLightVec; - vector float directedLightVec; - vector float lightDirVec; - vector float normalVec0, normalVec1; - vector float incomingVec0, incomingVec1, incomingVec2; - vector float zero, jVec; - vector signed int jVecInt; - vector signed short jVecShort; - vector unsigned char jVecChar, normalPerm; - ent = backEnd.currentEntity; - ambientLightInt = ent->ambientLightInt; - // A lot of this could be simplified if we made sure - // entities light info was 16-byte aligned. - jVecChar = vec_lvsl(0, ent->ambientLight); - ambientLightVec = vec_ld(0, (vector float *)ent->ambientLight); - jVec = vec_ld(11, (vector float *)ent->ambientLight); - ambientLightVec = vec_perm(ambientLightVec,jVec,jVecChar); - - jVecChar = vec_lvsl(0, ent->directedLight); - directedLightVec = vec_ld(0,(vector float *)ent->directedLight); - jVec = vec_ld(11,(vector float *)ent->directedLight); - directedLightVec = vec_perm(directedLightVec,jVec,jVecChar); - - jVecChar = vec_lvsl(0, ent->lightDir); - lightDirVec = vec_ld(0,(vector float *)ent->lightDir); - jVec = vec_ld(11,(vector float *)ent->lightDir); - lightDirVec = vec_perm(lightDirVec,jVec,jVecChar); - - zero = (vector float)vec_splat_s8(0); - VectorCopy( ent->lightDir, lightDir ); - - v = tess.xyz[0]; - normal = tess.normal[0]; - - normalPerm = vec_lvsl(0,normal); - numVertexes = tess.numVertexes; - for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) { - normalVec0 = vec_ld(0,(vector float *)normal); - normalVec1 = vec_ld(11,(vector float *)normal); - normalVec0 = vec_perm(normalVec0,normalVec1,normalPerm); - incomingVec0 = vec_madd(normalVec0, lightDirVec, zero); - incomingVec1 = vec_sld(incomingVec0,incomingVec0,4); - incomingVec2 = vec_add(incomingVec0,incomingVec1); - incomingVec1 = vec_sld(incomingVec1,incomingVec1,4); - incomingVec2 = vec_add(incomingVec2,incomingVec1); - incomingVec0 = vec_splat(incomingVec2,0); - incomingVec0 = vec_max(incomingVec0,zero); - normalPerm = vec_lvsl(12,normal); - jVec = vec_madd(incomingVec0, directedLightVec, ambientLightVec); - jVecInt = vec_cts(jVec,0); // RGBx - jVecShort = vec_pack(jVecInt,jVecInt); // RGBxRGBx - jVecChar = vec_packsu(jVecShort,jVecShort); // RGBxRGBxRGBxRGBx - jVecChar = vec_sel(jVecChar,vSel,vSel); // RGBARGBARGBARGBA replace alpha with 255 - vec_ste((vector unsigned int)jVecChar,0,(unsigned int *)&colors[i*4]); // store color - } -} -#endif - -static void RB_CalcDiffuseColor_scalar( unsigned char *colors ) -{ - int i, j; - float *v, *normal; - float incoming; - trRefEntity_t *ent; - int ambientLightInt; - vec3_t ambientLight; - vec3_t lightDir; - vec3_t directedLight; - int numVertexes; - ent = backEnd.currentEntity; - ambientLightInt = ent->ambientLightInt; - VectorCopy( ent->ambientLight, ambientLight ); - VectorCopy( ent->directedLight, directedLight ); - VectorCopy( ent->lightDir, lightDir ); - - v = tess.xyz[0]; - normal = tess.normal[0]; - - numVertexes = tess.numVertexes; - for (i = 0 ; i < numVertexes ; i++, v += 4, normal += 4) { - incoming = DotProduct (normal, lightDir); - if ( incoming <= 0 ) { - *(int *)&colors[i*4] = ambientLightInt; - continue; - } - j = Q_ftol(ambientLight[0] + incoming * directedLight[0]); - if ( j > 255 ) { - j = 255; - } - colors[i*4+0] = j; - - j = Q_ftol(ambientLight[1] + incoming * directedLight[1]); - if ( j > 255 ) { - j = 255; - } - colors[i*4+1] = j; - - j = Q_ftol(ambientLight[2] + incoming * directedLight[2]); - if ( j > 255 ) { - j = 255; - } - colors[i*4+2] = j; - - colors[i*4+3] = 255; - } -} - -void RB_CalcDiffuseColor( unsigned char *colors ) -{ -#if idppc_altivec - if (com_altivec->integer) { - // must be in a seperate function or G3 systems will crash. - RB_CalcDiffuseColor_altivec( colors ); - return; - } -#endif - RB_CalcDiffuseColor_scalar( colors ); + matrix[0] = cosValue; matrix[2] = -sinValue; matrix[4] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; + matrix[1] = sinValue; matrix[3] = cosValue; matrix[5] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; } - diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 7b9c181751..f363c63227 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -929,8 +929,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if(!Q_stricmp(token, "specularMap")) { stage->type = ST_SPECULARMAP; - stage->materialInfo[0] = 0.04f; - stage->materialInfo[1] = 256.0f; + stage->materialInfo[0] = 1.0f; + stage->materialInfo[1] = 1.0f; } else { @@ -956,6 +956,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if (!Q_stricmp(token, "specularexponent")) { + float exponent; + token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { @@ -963,6 +965,25 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } stage->materialInfo[1] = atof( token ); + + // Change shininess to gloss + // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl + exponent = CLAMP(exponent, 1.0, 8192.0); + stage->materialInfo[1] = log(exponent) / log(8192.0); + } + // + // gloss + // + else if ( !Q_stricmp( token, "gloss" ) ) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for gloss in shader '%s'\n", shader.name ); + continue; + } + + stage->materialInfo[1] = atof( token ); } // // rgbGen @@ -1121,10 +1142,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) shader.portalRange = atof( token ); } } - else if ( !Q_stricmp( token, "fresnel" ) ) - { - stage->alphaGen = AGEN_FRESNEL; - } else { ri->Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); @@ -2077,7 +2094,7 @@ static void ComputeVertexAttribs(void) shader.vertexAttribs |= ATTR_NORMAL; #ifdef USE_VERT_TANGENT_SPACE - if (pStage->glslShaderIndex & LIGHTDEF_USE_NORMALMAP) + if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && !(r_normalMapping->integer == 0 && r_specularMapping->integer == 0)) { shader.vertexAttribs |= ATTR_BITANGENT | ATTR_TANGENT; } @@ -2139,7 +2156,6 @@ static void ComputeVertexAttribs(void) switch(pStage->alphaGen) { case AGEN_LIGHTING_SPECULAR: - case AGEN_FRESNEL: shader.vertexAttribs |= ATTR_NORMAL; break; @@ -2343,7 +2359,6 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { //ri->Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; - defs |= LIGHTDEF_USE_NORMALMAP; if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; } @@ -2361,9 +2376,9 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (normalImg) { diffuse->bundle[TB_NORMALMAP] = diffuse->bundle[0]; + diffuse->bundle[TB_NORMALMAP].numImageAnimations = 0; diffuse->bundle[TB_NORMALMAP].image[0] = normalImg; - defs |= LIGHTDEF_USE_NORMALMAP; if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; } @@ -2378,7 +2393,6 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; diffuse->materialInfo[0] = specular->materialInfo[0]; diffuse->materialInfo[1] = specular->materialInfo[1]; - defs |= LIGHTDEF_USE_SPECULARMAP; } } @@ -2409,7 +2423,7 @@ static qboolean CollapseStagesToGLSL(void) { // if 2+ stages and first stage is lightmap, switch them // this makes it easier for the later bits to process - if (stages[0].active && stages[0].bundle[0].isLightmap && stages[1].active) + if (stages[0].active && stages[0].bundle[0].tcGen == TCGEN_LIGHTMAP && stages[1].active) { int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2446,7 +2460,7 @@ static qboolean CollapseStagesToGLSL(void) break; } - if (pStage->bundle[0].isLightmap) + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) { int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2463,6 +2477,7 @@ static qboolean CollapseStagesToGLSL(void) case TCGEN_TEXTURE: case TCGEN_LIGHTMAP: case TCGEN_ENVIRONMENT_MAPPED: + case TCGEN_VECTOR: break; default: skip = qtrue; @@ -2473,7 +2488,6 @@ static qboolean CollapseStagesToGLSL(void) { case AGEN_LIGHTING_SPECULAR: case AGEN_PORTAL: - case AGEN_FRESNEL: skip = qtrue; break; default: @@ -2498,7 +2512,7 @@ static qboolean CollapseStagesToGLSL(void) continue; // skip lightmaps - if (pStage->bundle[0].isLightmap) + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) continue; diffuse = pStage; @@ -2540,7 +2554,7 @@ static qboolean CollapseStagesToGLSL(void) break; case ST_COLORMAP: - if (pStage2->bundle[0].isLightmap) + if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP) { lightmap = pStage2; } @@ -2582,7 +2596,7 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[0].isLightmap) + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) { pStage->active = qfalse; } @@ -2636,7 +2650,7 @@ static qboolean CollapseStagesToGLSL(void) // convert any remaining lightmap stages to a lighting pass with a white texture // only do this with r_sunlightMode non-zero, as it's only for correct shadows. - if (r_sunlightMode->integer) + if (r_sunlightMode->integer && shader.numDeforms == 0) { for (i = 0; i < MAX_SHADER_STAGES; i++) { @@ -2645,7 +2659,10 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[TB_DIFFUSEMAP].isLightmap) + if (pStage->adjustColorsForFog) + continue; + + if (pStage->bundle[TB_DIFFUSEMAP].tcGen == TCGEN_LIGHTMAP) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; @@ -2654,10 +2671,55 @@ static qboolean CollapseStagesToGLSL(void) pStage->bundle[TB_LIGHTMAP] = pStage->bundle[TB_DIFFUSEMAP]; pStage->bundle[TB_DIFFUSEMAP].image[0] = tr.whiteImage; pStage->bundle[TB_DIFFUSEMAP].isLightmap = qfalse; + pStage->bundle[TB_DIFFUSEMAP].tcGen = TCGEN_TEXTURE; + } + } + } + + // convert any remaining lightingdiffuse stages to a lighting pass + if (shader.numDeforms == 0) + { + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->adjustColorsForFog) + continue; + + if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) + { + pStage->glslShaderGroup = tr.lightallShader; + pStage->glslShaderIndex = LIGHTDEF_USE_LIGHT_VECTOR; + + if (pStage->bundle[0].tcGen != TCGEN_TEXTURE || pStage->bundle[0].numTexMods != 0) + pStage->glslShaderIndex |= LIGHTDEF_USE_TCGEN_AND_TCMOD; } } } + // insert default normal and specular textures if necessary + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->glslShaderGroup != tr.lightallShader) + continue; + + if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) == 0) + continue; + + if (!pStage->bundle[TB_NORMALMAP].image[0] && r_normalMapping->integer) + { + pStage->bundle[TB_NORMALMAP].image[0] = tr.greyImage; + } + } + return (qboolean)numStages; } diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 97d9e9a096..0f3ff77205 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -449,7 +449,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max color[0] = color[1] = - color[2] = tr.identityLight; + color[2] = tr.identityLight * backEnd.refdef.colorScale; color[3] = 1.0f; GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); @@ -826,7 +826,7 @@ void RB_DrawSun( float scale, shader_t *shader ) { // farthest depth range qglDepthRange( 1.0, 1.0 ); - RB_BeginSurface( shader, 0 ); + RB_BeginSurface( shader, 0, 0 ); RB_AddQuadStamp(origin, vec1, vec2, colorWhite); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 3e8124104d..cd8f48acd9 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -63,7 +63,7 @@ void RB_CheckOverflow( int verts, int indexes ) { ri->Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); } - RB_BeginSurface(tess.shader, tess.fogNum ); + RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); } void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) @@ -71,7 +71,7 @@ void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) if (!(vbo == glState.currentVBO && ibo == glState.currentIBO) || tess.multiDrawPrimitives >= MAX_MULTIDRAW_PRIMITIVES) { RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum); + RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); R_BindVBO(vbo); R_BindIBO(ibo); @@ -1849,7 +1849,7 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { // if we don't have enough space for at least one strip, flush the buffer if ( vrows < 2 || irows < 1 ) { RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum ); + RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); } else { break; } @@ -2106,7 +2106,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) //RB_CheckVBOandIBO(surface->vbo, surface->ibo); RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum); + RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); @@ -2134,11 +2134,12 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) glState.vertexAttribsOldFrame = refEnt->oldframe; glState.vertexAttribsNewFrame = refEnt->frame; + glState.vertexAnimation = qtrue; RB_EndSurface(); // So we don't lerp surfaces that shouldn't be lerped - glState.vertexAttribsInterpolation = 0; + glState.vertexAnimation = qfalse; } static void RB_SurfaceDisplayList( srfDisplayList_t *surf ) { diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index d529af8134..b8415b2749 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -608,6 +608,7 @@ void R_BindVBO(VBO_t * vbo) glState.vertexAttribsInterpolation = 0; glState.vertexAttribsOldFrame = 0; glState.vertexAttribsNewFrame = 0; + glState.vertexAnimation = qfalse; qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); @@ -856,6 +857,9 @@ void RB_UpdateVBOs(unsigned int attribBits) { R_BindVBO(tess.vbo); + // orphan old buffer so we don't stall on it + qglBufferDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->vertexesSize, NULL, GL_DYNAMIC_DRAW_ARB); + if(attribBits & ATTR_BITS) { if(attribBits & ATTR_POSITION) @@ -923,6 +927,9 @@ void RB_UpdateVBOs(unsigned int attribBits) { R_BindIBO(tess.ibo); + // orphan old buffer so we don't stall on it + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tess.ibo->indexesSize, NULL, GL_DYNAMIC_DRAW_ARB); + qglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 2b9033a68d..0b6b37bb41 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -36,6 +36,10 @@ static qboolean R_CullSurface( msurface_t *surf ) { return qfalse; } + if ( *surf->data == SF_GRID && r_nocurves->integer ) { + return qtrue; + } + if (surf->cullinfo.type & CULLINFO_PLANE) { // Only true for SF_FACE, so treat like its own function @@ -333,7 +337,7 @@ static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits pshadowBits = ( pshadowBits != 0 ); } - R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, pshadowBits ); + R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, pshadowBits, surf->cubemapIndex ); } /* @@ -554,7 +558,7 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, } // add merged and unmerged surfaces - if (tr.world->viewSurfaces) + if (tr.world->viewSurfaces && !r_nocurves->integer) view = tr.world->viewSurfaces + node->firstmarksurface; else view = tr.world->marksurfaces + node->firstmarksurface; From e7464f616c1f28ec9ad04d200dbd6cd73ca266e6 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 20:26:56 -0400 Subject: [PATCH 069/708] MP: [rend2] Took @Xycaleth's suggestions to heart --- codemp/rd-rend2/tr_bsp.cpp | 4 +-- codemp/rd-rend2/tr_cache.cpp | 54 +++++++++++++++++------------------- codemp/rd-rend2/tr_local.h | 5 ++-- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a785c34394..97039f84de 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3278,13 +3278,13 @@ void R_MergeLeafSurfaces(void) } // create ibo - ibo = tr.ibos[tr.numIBOs] = ri.Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); memset(ibo, 0, sizeof(*ibo)); Q_strncpyz(ibo->name, va("staticWorldMesh_IBO_mergedSurfs%i", tr.numIBOs++), sizeof(ibo->name)); numIboIndexes = 0; // allocate indexes - iboIndexes = outIboIndexes = ri.Malloc(numTriangles * 3 * sizeof(*outIboIndexes)); + iboIndexes = outIboIndexes = (glIndex_t*)Z_Malloc(numTriangles * 3 * sizeof(*outIboIndexes), TAG_BSP); // Merge surfaces (indexes) and calculate bounds ClearBounds(bounds[0], bounds[1]); diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 17032678c9..76a5f55412 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -25,7 +25,7 @@ qhandle_t CCacheManager::SearchLoaded( const char *fileName ) loadedMap_t::iterator it = loaded.find(fileName); if( it == loaded.end() ) return -1; // asset not found - return it->second->handle; + return it->second.handle; } /* @@ -37,8 +37,7 @@ void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) FileHash_t *fh = (FileHash_t *)ri->Hunk_Alloc( sizeof(FileHash_t), h_low ); fh->handle = handle; Q_strncpyz( fh->fileName, fileName, sizeof(fh->fileName) ); - pair fPair (fileName, fh); - loaded.insert(fPair); + loaded.insert(make_pair(fileName, *fh)); } /* @@ -54,10 +53,10 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb Q_strncpyz(sFileName, pFileName, MAX_QPATH); Q_strlwr (sFileName); - CachedFile_t *pFile; + CachedFile_t pFile; pFile = cache[sFileName]; // this might cause an assert?? (I dunno, works fine in Raven code..) - if(!pFile) + if(1) { *pbAlreadyCached = qfalse; ri->FS_ReadFile( pFileName, ppFileBuffer ); @@ -70,7 +69,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb } else { - *ppFileBuffer = pFile->pDiskImage; + *ppFileBuffer = pFile.pDiskImage; *pbAlreadyCached = qtrue; return qtrue; } @@ -97,12 +96,9 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode Q_strncpyz(sModelName, psModelFileName, MAX_QPATH); Q_strlwr (sModelName); - CachedFile_t *pFile = cache[sModelName]; + CachedFile_t pFile = cache[sModelName]; - if( !pFile ) /* Doesn't exist, so we'll create a new object */ - pFile = new CachedFile_t(); - - if( !pFile->pDiskImage ) + if( !pFile.pDiskImage ) { /* Create this image. */ /* * We aren't going to do that ugly VV hack that supposedly reduces mem overhead. @@ -112,11 +108,11 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode * on mem usage on machines that ran with like 64MB RAM... --eez */ pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); - pFile->pDiskImage = pvDiskBuffer; - pFile->iAllocSize = iSize; + pFile.pDiskImage = pvDiskBuffer; + pFile.iAllocSize = iSize; if( ri->FS_FileIsInPAK( psModelFileName, &iChecksum ) ) - pFile->iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ + pFile.iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ *bAlreadyFound = qfalse; } @@ -129,7 +125,7 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode *bAlreadyFound = qtrue; } - return pFile->pDiskImage; + return pFile.pDiskImage; } /* @@ -140,8 +136,8 @@ void CCacheManager::DeleteAll( void ) { for( auto it = cache.begin(); it != cache.end(); ++it ) { - Z_Free(it->second->pDiskImage); - cache.erase(it); + Z_Free(it->second.pDiskImage); + it = cache.erase(it); } } @@ -157,18 +153,18 @@ void CCacheManager::DumpNonPure( void ) for(assetCache_t::iterator it = cache.begin(); it != cache.end(); /* empty */ ) { int iChecksum; - int iInPak = ri->FS_FileIsInPAK( it->first, &iChecksum ); + int iInPak = ri->FS_FileIsInPAK( it->first.c_str(), &iChecksum ); qboolean bEraseOccurred = qfalse; - if( iInPak == -1 || iChecksum != it->second->iPAKChecksum ) + if( iInPak == -1 || iChecksum != it->second.iPAKChecksum ) { /* Erase the file because it doesn't match the checksum */ ri->Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->first ); - if( it->second->pDiskImage ) - Z_Free( it->second->pDiskImage ); + if( it->second.pDiskImage ) + Z_Free( it->second.pDiskImage ); - cache.erase(it++); + it = cache.erase(it++); bEraseOccurred = qtrue; } @@ -205,27 +201,27 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThis for(auto it = cache.begin(); it != cache.end(); ++it) { - CachedFile_t *pFile = it->second; + CachedFile_t pFile = it->second; bool bDeleteThis = false; if( bDeleteEverythingNotUsedThisLevel ) - bDeleteThis = ( pFile->iLevelLastUsedOn != tr.currentLevel ); + bDeleteThis = ( pFile.iLevelLastUsedOn != tr.currentLevel ); else - bDeleteThis = ( pFile->iLevelLastUsedOn < tr.currentLevel ); + bDeleteThis = ( pFile.iLevelLastUsedOn < tr.currentLevel ); if( bDeleteThis ) { - const char *psModelName = it->first; + const char *psModelName = it->first.c_str(); ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", psModelName); - if( pFile->pDiskImage ) + if( pFile.pDiskImage ) { - Z_Free( pFile->pDiskImage ); + Z_Free( pFile.pDiskImage ); bAtLeastOneModelFreed = qtrue; // FIXME: is this correct? shouldn't it be in the next lower scope? } // FIXME: like right here? - cache.erase(it); + it = cache.erase(it); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 640d052773..c96db7d9da 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include #include +#include #ifdef _WIN32 #include "win32\win_local.h" @@ -3150,8 +3151,8 @@ typedef struct CachedFile_s } CachedFile_t; /* assetCache_t and loadedMap_t are two definitions that are needed for the manager */ -typedef std::map assetCache_t; -typedef std::unordered_map loadedMap_t; +typedef std::map assetCache_t; +typedef std::unordered_map loadedMap_t; /* The actual manager itself, which is used in the model and image loading routines. */ class CCacheManager From 138df66a0a59aa61d9939f829384eb074c0201d5 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 20:38:15 -0400 Subject: [PATCH 070/708] [MP] rend2: Fixed issue where it was re-loading stuff several times over. --- codemp/rd-rend2/tr_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 76a5f55412..0ff94696eb 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -56,7 +56,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb CachedFile_t pFile; pFile = cache[sFileName]; // this might cause an assert?? (I dunno, works fine in Raven code..) - if(1) + if(!pFile.pDiskImage) { *pbAlreadyCached = qfalse; ri->FS_ReadFile( pFileName, ppFileBuffer ); From 2698b73fc3c3a60486188619109004e58757932b Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 20:39:12 -0400 Subject: [PATCH 071/708] [MP] Removed unused variable gauntletHit from pmove_t --- codemp/game/bg_public.h | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index a2ce5e20a0..8497d5c8c2 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -460,7 +460,6 @@ typedef struct pmove_s { int tracemask; // collide against these types of surfaces int debugLevel; // if set, diagnostic output will be printed qboolean noFootsteps; // if the game is setup for no footsteps by the server - qboolean gauntletHit; // true if a gauntlet attack would actually hit something int framecount; From 6a09f4e6c87be2339fc7733fcf1d87e0ec6ab138 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Tue, 15 Oct 2013 23:22:54 -0400 Subject: [PATCH 072/708] MP: [rend2] Major improvements/fixes to the caching code. Now correctly caches shader requests from GLM models. GLAs now load correctly. --- codemp/rd-rend2/tr_cache.cpp | 103 +++++++++++++++++++++++++--------- codemp/rd-rend2/tr_ghoul2.cpp | 4 +- codemp/rd-rend2/tr_local.h | 9 +++ codemp/rd-rend2/tr_model.cpp | 87 ++++++---------------------- 4 files changed, 106 insertions(+), 97 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 0ff94696eb..731aad5564 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -53,17 +53,19 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb Q_strncpyz(sFileName, pFileName, MAX_QPATH); Q_strlwr (sFileName); - CachedFile_t pFile; - pFile = cache[sFileName]; // this might cause an assert?? (I dunno, works fine in Raven code..) + CachedFile_t &pFile = cache[sFileName]; if(!pFile.pDiskImage) { *pbAlreadyCached = qfalse; - ri->FS_ReadFile( pFileName, ppFileBuffer ); + int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); qboolean bSuccess = !!(*ppFileBuffer)?qtrue:qfalse; + const char **blah = (const char**)ppFileBuffer; if( bSuccess ) + { ri->Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); + } return bSuccess; } @@ -96,23 +98,19 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode Q_strncpyz(sModelName, psModelFileName, MAX_QPATH); Q_strlwr (sModelName); - CachedFile_t pFile = cache[sModelName]; + CachedFile_t *pFile = &cache[sModelName]; - if( !pFile.pDiskImage ) + if( !pFile->pDiskImage ) { /* Create this image. */ - /* - * We aren't going to do that ugly VV hack that supposedly reduces mem overhead. - * Said hack can cause heap corruption (!) if not properly checked, and I suspect - * that I'll forget to do it later. Forgive me for not cutting down on overhead, - * but I figured it was marginal, considering it was designed in order to cut back - * on mem usage on machines that ran with like 64MB RAM... --eez - */ - pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); - pFile.pDiskImage = pvDiskBuffer; - pFile.iAllocSize = iSize; + if( pvDiskBuffer ) + Z_MorphMallocTag( pvDiskBuffer, eTag ); + else + pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); + pFile->pDiskImage = pvDiskBuffer; + pFile->iAllocSize = iSize; if( ri->FS_FileIsInPAK( psModelFileName, &iChecksum ) ) - pFile.iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ + pFile->iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ *bAlreadyFound = qfalse; } @@ -125,7 +123,9 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode *bAlreadyFound = qtrue; } - return pFile.pDiskImage; + pFile->iLevelLastUsedOn = tr.currentLevel; + + return pFile->pDiskImage; } /* @@ -187,16 +187,8 @@ void CCacheManager::DumpNonPure( void ) */ qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) { - //int iLoadedModelBytes = GetModelDataAllocSize(); - //const int iMaxModelBytes = r_modelpoolmegs->integer * 1024 * 1024; qboolean bAtLeastOneModelFreed = qfalse; - /*if( iLoadedModelBytes > iMaxModelBytes ) - { - Com_Printf("CModelCacheManager::LevelLoadEnd(): iLoadedModelBytes > iMaxModelBytes (raise r_modelpoolmegs?)\n"); - return bAtLeastOneModelFreed; - }*/ - ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); for(auto it = cache.begin(); it != cache.end(); ++it) @@ -249,6 +241,67 @@ qboolean C_Images_LevelLoadEnd( void ) return CImgCache->LevelLoadEnd( qfalse ); } +/* + * Shader storage and retrieval, unique to the model caching + */ + +void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ) +{ + char sModelName[MAX_QPATH]; + + Q_strncpyz(sModelName, psModelFileName, sizeof(sModelName)); + Q_strlwr (sModelName); + + CachedFile_t &rFile = cache[sModelName]; + + if( rFile.pDiskImage == NULL ) + { + /* Shouldn't even happen. */ + assert(0); + return; + } + + int iNameOffset = psShaderName - (char *)rFile.pDiskImage; + int iPokeOffset = (char*) piShaderIndexPoke - (char *)rFile.pDiskImage; + + shaderCache.push_back( make_pair( iNameOffset, iPokeOffset ) ); +} + +void CModelCacheManager::AllocateShaders( const char *psFileName ) +{ + // if we already had this model entry, then re-register all the shaders it wanted... + // + char sModelName[MAX_QPATH]; + + Q_strncpyz(sModelName, psFileName, sizeof(sModelName)); + Q_strlwr (sModelName); + + CachedFile_t &rFile = cache[sModelName]; + + if( rFile.pDiskImage == NULL ) + { + /* Shouldn't even happen. */ + assert(0); + return; + } + + for( auto it = shaderCache.begin(); it != shaderCache.end(); ++it ) + { + int iShaderNameOffset = it->first; + int iShaderPokeOffset = it->second; + + char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; + int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; + + shader_t *sh = R_FindShader( psShaderName, 0, qtrue ); + + if ( sh->defaultShader ) + *piShaderPokePtr = 0; + else + *piShaderPokePtr = sh->index; + } +} + /* * These processes occur outside of the CacheManager class. They are exported by the renderer. */ diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 8f0dad2af0..6947c090fd 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4183,7 +4183,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mod->dataSize += size; qboolean bAlreadyFound = qfalse; - mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); + mdxm = mod->mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); @@ -4262,7 +4262,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean surfInfo->shaderIndex = sh->index; } - RE_RegisterModels_StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); + CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); // find the next surface surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + (size_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surfInfo->numChildren ] )); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c96db7d9da..53f29af69d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3154,6 +3154,10 @@ typedef struct CachedFile_s typedef std::map assetCache_t; typedef std::unordered_map loadedMap_t; +/* and shaderCache_t is needed for the model cache manager */ +typedef std::pair shaderCacheEntry_t; +typedef std::vector shaderCache_t; + /* The actual manager itself, which is used in the model and image loading routines. */ class CCacheManager { @@ -3167,6 +3171,7 @@ class CCacheManager void DumpNonPure( void ); virtual qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ) = 0; + protected: loadedMap_t loaded; assetCache_t cache; @@ -3182,6 +3187,10 @@ class CModelCacheManager : public CCacheManager { public: qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); + void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); + void AllocateShaders( const char *psFileName ); +private: + shaderCache_t shaderCache; }; extern CImageCacheManager *CImgCache; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 13eec2c207..919d446e11 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -38,10 +38,7 @@ R_RegisterMD3 */ qhandle_t R_RegisterMD3(const char *name, model_t *mod) { - union { - unsigned *u; - void *v; - } buf; + unsigned *buf; int lod; int ident; qboolean loaded = qfalse; @@ -70,30 +67,34 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); qboolean bAlreadyCached = qfalse; - if( !CModelCache->LoadFile( namebuf, &buf.v, &bAlreadyCached ) ) + if( !CModelCache->LoadFile( namebuf, (void**)&buf, &bAlreadyCached ) ) continue; + + const char *blah = (const char *)(*buf); + ident = *(unsigned *)buf; + if( !bAlreadyCached ) + ident = LittleLong(ident); - ident = LittleLong(* (unsigned *) buf.u); switch(ident) { case MD4_IDENT: - loaded = R_LoadMD4(mod, buf.u, name); + loaded = R_LoadMD4(mod, buf, name); break; case MD3_IDENT: - loaded = R_LoadMD3(mod, lod, buf.u, name); + loaded = R_LoadMD3(mod, lod, buf, name); break; case MDXA_IDENT: - loaded = R_LoadMDXA(mod, buf.u, name, bAlreadyCached); + loaded = R_LoadMDXA(mod, buf, name, bAlreadyCached); break; case MDXM_IDENT: - loaded = R_LoadMDXM(mod, buf.u, name, bAlreadyCached); + loaded = R_LoadMDXM(mod, buf, name, bAlreadyCached); break; default: ri->Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); break; } - ri->FS_FreeFile(buf.v); + ri->FS_FreeFile(buf); if(loaded) { @@ -217,6 +218,7 @@ static modelExtToLoaderMap_t modelLoaders[ ] = Ghoul 2 Insert Start */ { "glm", R_RegisterMD3 }, + { "gla", R_RegisterMD3 }, /* Ghoul 2 Insert End */ @@ -387,65 +389,6 @@ qhandle_t RE_RegisterModel( const char *name ) { return hModel; } -/* -==================== -RE_RegisterModels_StoreShaderRequest - -Cache shaders used by a model - -This stuff looks a bit messy, but it's kept here as black box, and nothing appears in any .H files for other -modules to worry about. I may make another module for this sometime. -==================== -*/ - -typedef pair StringOffsetAndShaderIndexDest_t; -typedef vector ShaderRegisterData_t; -struct CachedEndianedModelBinary_s -{ - void *pModelDiskImage; - int iAllocSize; // may be useful for mem-query, but I don't actually need it - ShaderRegisterData_t ShaderRegisterData; - int iLastLevelUsedOn; - int iPAKFileCheckSum; // else -1 if not from PAK - - - CachedEndianedModelBinary_s() - { - pModelDiskImage = 0; - iAllocSize = 0; - ShaderRegisterData.clear(); - iLastLevelUsedOn = -1; - iPAKFileCheckSum = -1; - } -}; -typedef struct CachedEndianedModelBinary_s CachedEndianedModelBinary_t; -typedef map CachedModels_t; -CachedModels_t *CachedModels = NULL; // the important cache item. - -void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke) -{ - char sModelName[MAX_QPATH]; - - assert(CachedModels); - - Q_strncpyz(sModelName,psModelFileName,sizeof(sModelName)); - Q_strlwr (sModelName); - - CachedEndianedModelBinary_t &ModelBin = (*CachedModels)[sModelName]; - - if (ModelBin.pModelDiskImage == NULL) - { - assert(0); // should never happen, means that we're being called on a model that wasn't loaded - } - else - { - int iNameOffset = psShaderName - (char *)ModelBin.pModelDiskImage; - int iPokeOffset = (char*) piShaderIndexPoke - (char *)ModelBin.pModelDiskImage; - - ModelBin.ShaderRegisterData.push_back( StringOffsetAndShaderIndexDest_t( iNameOffset,iPokeOffset) ); - } -} - /* ================= R_LoadMD3 @@ -506,6 +449,10 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN LL(md3Model->ofsSurfaces); LL(md3Model->ofsEnd); } + else + { + CModelCache->AllocateShaders( modName ); + } if(md3Model->numFrames < 1) { From 1ee07285eb94c80321d9376721bedf34733ba315 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Wed, 16 Oct 2013 12:53:20 -0400 Subject: [PATCH 073/708] MP: [rend2] Ghoul2 no longer crashes the game. Will load character creation screen, but no model displays. --- codemp/rd-rend2/tr_model.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 919d446e11..fed4c787ee 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -79,10 +79,13 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) { case MD4_IDENT: loaded = R_LoadMD4(mod, buf, name); + ri->FS_FreeFile(buf); break; case MD3_IDENT: loaded = R_LoadMD3(mod, lod, buf, name); + ri->FS_FreeFile(buf); break; + // Ghoul2 is hax, doesn't free the file buffer and doesn't afraid of anything case MDXA_IDENT: loaded = R_LoadMDXA(mod, buf, name, bAlreadyCached); break; @@ -93,8 +96,6 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) ri->Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); break; } - - ri->FS_FreeFile(buf); if(loaded) { From f755f34beb9fdf97ea54319d38ea1c21300f4977 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Wed, 16 Oct 2013 13:38:02 -0400 Subject: [PATCH 074/708] MP: [rend2] Correctly insert loaded models into the loaded cache, preventing a wall of console spam in character creation menu --- codemp/rd-rend2/tr_model.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index fed4c787ee..1f021a5a0b 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -315,6 +315,8 @@ qhandle_t RE_RegisterModel( const char *name ) { return 0; } + CModelCache->InsertLoaded( name, mod->index ); + // only set the name after the model has been successfully loaded Q_strncpyz( mod->name, name, sizeof( mod->name ) ); From 9461a2569e6843e9dff9fd0d0bb182f87b99d876 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 17 Oct 2013 22:38:10 -0400 Subject: [PATCH 075/708] MP: [rend2] G2 models now working to an extent. --- codemp/rd-rend2/tr_ghoul2.cpp | 39 ---- codemp/rd-rend2/tr_image.cpp | 284 ------------------------ codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_skin.cpp | 388 +++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_surface.cpp | 11 +- 5 files changed, 399 insertions(+), 325 deletions(-) create mode 100644 codemp/rd-rend2/tr_skin.cpp diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 6947c090fd..9a9f296a1b 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2434,45 +2434,6 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } - //rww - catch surfaces with bad shaders - //assert(shader != tr.defaultShader); - //Alright, this is starting to annoy me because of the state of the assets. Disabling for now. - // we will add shadows even if the main object isn't visible in the view - // stencil shadows can't do personal models unless I polyhedron clip - //using z-fail now so can do personal models -rww - if ( /*!RS.personalModel - && */r_shadows->integer == 2 -// && RS.fogNum == 0 - && (RS.renderfx & RF_SHADOW_PLANE ) - && !(RS.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) - && shader->sort == SS_OPAQUE ) - { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out - CRenderableSurface *newSurf = new CRenderableSurface; - if (surface->numVerts >= SHADER_MAX_VERTEXES/2) - { //we need numVerts*2 xyz slots free in tess to do shadow, if this surf is going to exceed that then let's try the lowest lod -rww - mdxmSurface_t *lowsurface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.currentModel->numLods-1); - newSurf->surfaceData = lowsurface; - } - else - { - newSurf->surfaceData = surface; - } - newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.shadowShader, 0, qfalse, qfalse, 0 ); - } - - // projection shadows work fine with personal models - if ( r_shadows->integer == 3 -// && RS.fogNum == 0 - && (RS.renderfx & RF_SHADOW_PLANE ) - && shader->sort == SS_OPAQUE ) - { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out - CRenderableSurface *newSurf = new CRenderableSurface; - newSurf->surfaceData = surface; - newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); - } - // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index adfeadff6f..b92d827ad8 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3036,287 +3036,3 @@ void R_DeleteTextures( void ) { qglBindTexture( GL_TEXTURE_2D, 0 ); } } - -/* -============================================================================ - -SKINS - -============================================================================ -*/ - -/* -================== -CommaParse - -This is unfortunate, but the skin files aren't -compatable with our normal parsing rules. -================== -*/ -static char *CommaParse( char **data_p ) { - int c = 0, len; - char *data; - static char com_token[MAX_TOKEN_CHARS]; - - data = *data_p; - len = 0; - com_token[0] = 0; - - // make sure incoming data is valid - if ( !data ) { - *data_p = NULL; - return com_token; - } - - while ( 1 ) { - // skip whitespace - while( (c = *data) <= ' ') { - if( !c ) { - break; - } - data++; - } - - - c = *data; - - // skip double slash comments - if ( c == '/' && data[1] == '/' ) - { - while (*data && *data != '\n') - data++; - } - // skip /* */ comments - else if ( c=='/' && data[1] == '*' ) - { - while ( *data && ( *data != '*' || data[1] != '/' ) ) - { - data++; - } - if ( *data ) - { - data += 2; - } - } - else - { - break; - } - } - - if ( c == 0 ) { - return ""; - } - - // handle quoted strings - if (c == '\"') - { - data++; - while (1) - { - c = *data++; - if (c=='\"' || !c) - { - com_token[len] = 0; - *data_p = ( char * ) data; - return com_token; - } - if (len < MAX_TOKEN_CHARS) - { - com_token[len] = c; - len++; - } - } - } - - // parse a regular word - do - { - if (len < MAX_TOKEN_CHARS) - { - com_token[len] = c; - len++; - } - data++; - c = *data; - } while (c>32 && c != ',' ); - - if (len == MAX_TOKEN_CHARS) - { -// ri->Printf (PRINT_DEVELOPER, "Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); - len = 0; - } - com_token[len] = 0; - - *data_p = ( char * ) data; - return com_token; -} - - -/* -=============== -RE_RegisterSkin - -=============== -*/ -qhandle_t RE_RegisterSkin( const char *name ) { - qhandle_t hSkin; - skin_t *skin; - skinSurface_t *surf; - union { - char *c; - void *v; - } text; - char *text_p; - char *token; - char surfName[MAX_QPATH]; - - if ( !name || !name[0] ) { - ri->Printf( PRINT_DEVELOPER, "Empty name passed to RE_RegisterSkin\n" ); - return 0; - } - - if ( strlen( name ) >= MAX_QPATH ) { - ri->Printf( PRINT_DEVELOPER, "Skin name exceeds MAX_QPATH\n" ); - return 0; - } - - - // see if the skin is already loaded - for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) { - skin = tr.skins[hSkin]; - if ( !Q_stricmp( skin->name, name ) ) { - if( skin->numSurfaces == 0 ) { - return 0; // default skin - } - return hSkin; - } - } - - // allocate a new skin - if ( tr.numSkins == MAX_SKINS ) { - ri->Printf( PRINT_WARNING, "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); - return 0; - } - tr.numSkins++; - skin = (skin_t *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); - tr.skins[hSkin] = skin; - Q_strncpyz( skin->name, name, sizeof( skin->name ) ); - skin->numSurfaces = 0; - - R_IssuePendingRenderCommands(); - - // If not a .skin file, load as a single shader - if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { - skin->numSurfaces = 1; - skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); - skin->surfaces[0]->shader = R_FindShader( name, LIGHTMAP_NONE, qtrue ); - return hSkin; - } - - // load and parse the skin file - ri->FS_ReadFile( name, &text.v ); - if ( !text.c ) { - return 0; - } - - text_p = text.c; - while ( text_p && *text_p ) { - // get surface name - token = CommaParse( &text_p ); - Q_strncpyz( surfName, token, sizeof( surfName ) ); - - if ( !token[0] ) { - break; - } - // lowercase the surface name so skin compares are faster - Q_strlwr( surfName ); - - if ( *text_p == ',' ) { - text_p++; - } - - if ( strstr( token, "tag_" ) ) { - continue; - } - - // parse the shader name - token = CommaParse( &text_p ); - - if ( skin->numSurfaces >= MD3_MAX_SURFACES ) { - ri->Printf( PRINT_WARNING, "WARNING: Ignoring surfaces in '%s', the max is %d surfaces!\n", name, MD3_MAX_SURFACES ); - break; - } - - surf = skin->surfaces[ skin->numSurfaces ] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); - Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); - surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); - skin->numSurfaces++; - } - - ri->FS_FreeFile( text.v ); - - - // never let a skin have 0 shaders - if ( skin->numSurfaces == 0 ) { - return 0; // use default skin - } - - return hSkin; -} - - -/* -=============== -R_InitSkins -=============== -*/ -void R_InitSkins( void ) { - skin_t *skin; - - tr.numSkins = 1; - - // make the default skin have all default shaders - skin = tr.skins[0] = (skin_t *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); - Q_strncpyz( skin->name, "", sizeof( skin->name ) ); - skin->numSurfaces = 1; - skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( *skin->surfaces ), h_low ); - skin->surfaces[0]->shader = tr.defaultShader; -} - -/* -=============== -R_GetSkinByHandle -=============== -*/ -skin_t *R_GetSkinByHandle( qhandle_t hSkin ) { - if ( hSkin < 1 || hSkin >= tr.numSkins ) { - return tr.skins[0]; - } - return tr.skins[ hSkin ]; -} - -/* -=============== -R_SkinList_f -=============== -*/ -void R_SkinList_f( void ) { - int i, j; - skin_t *skin; - - ri->Printf (PRINT_ALL, "------------------\n"); - - for ( i = 0 ; i < tr.numSkins ; i++ ) { - skin = tr.skins[i]; - - ri->Printf( PRINT_ALL, "%3i:%s\n", i, skin->name ); - for ( j = 0 ; j < skin->numSurfaces ; j++ ) { - ri->Printf( PRINT_ALL, " %s = %s\n", - skin->surfaces[j]->name, ((shader_t*)skin->surfaces[j]->shader)->name ); - } - } - ri->Printf (PRINT_ALL, "------------------\n"); -} - - diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 53f29af69d..68fdd104c4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3202,4 +3202,6 @@ void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload); int C_GetLevel( void ); void C_LevelLoadEnd( void ); +void RB_SurfaceGhoul( CRenderableSurface *surf ); + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp new file mode 100644 index 0000000000..87ea7a88a3 --- /dev/null +++ b/codemp/rd-rend2/tr_skin.cpp @@ -0,0 +1,388 @@ +#include "tr_local.h" + +/* +============================================================================ + +SKINS + +============================================================================ +*/ + +static char *CommaParse( char **data_p ); +//can't be dec'd here since we need it for non-dedicated builds now as well. + +/* +=============== +RE_RegisterSkin + +=============== +*/ + +shader_t *R_FindServerShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage ); +static char *CommaParse( char **data_p ); +/* +=============== +RE_SplitSkins +input = skinname, possibly being a macro for three skins +return= true if three part skins found +output= qualified names to three skins if return is true, undefined if false +=============== +*/ +bool RE_SplitSkins(const char *INname, char *skinhead, char *skintorso, char *skinlower) +{ //INname= "models/players/jedi_tf/|head01_skin1|torso01|lower01"; + if (strchr(INname, '|')) + { + char name[MAX_QPATH]; + strcpy(name, INname); + char *p = strchr(name, '|'); + *p=0; + p++; + //fill in the base path + strcpy (skinhead, name); + strcpy (skintorso, name); + strcpy (skinlower, name); + + //now get the the individual files + + //advance to second + char *p2 = strchr(p, '|'); + assert(p2); + if (!p2) + { + return false; + } + *p2=0; + p2++; + strcat (skinhead, p); + strcat (skinhead, ".skin"); + + + //advance to third + p = strchr(p2, '|'); + assert(p); + if (!p) + { + return false; + } + *p=0; + p++; + strcat (skintorso,p2); + strcat (skintorso, ".skin"); + + strcat (skinlower,p); + strcat (skinlower, ".skin"); + + return true; + } + return false; +} + +// given a name, go get the skin we want and return +qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) +{ + skin_t *skin; + skinSurface_t *surf; + char *text, *text_p; + char *token; + char surfName[MAX_QPATH]; + + // load and parse the skin file + ri->FS_ReadFile( name, (void **)&text ); + if ( !text ) { +#ifndef FINAL_BUILD + Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) failed to load!\n", name ); +#endif + return 0; + } + + assert (tr.skins[hSkin]); //should already be setup, but might be an 3part append + + skin = tr.skins[hSkin]; + + text_p = text; + while ( text_p && *text_p ) { + // get surface name + token = CommaParse( &text_p ); + Q_strncpyz( surfName, token, sizeof( surfName ) ); + + if ( !token[0] ) { + break; + } + // lowercase the surface name so skin compares are faster + Q_strlwr( surfName ); + + if ( *text_p == ',' ) { + text_p++; + } + + if ( !strncmp( token, "tag_", 4 ) ) { //these aren't in there, but just in case you load an id style one... + continue; + } + + // parse the shader name + token = CommaParse( &text_p ); + + if ( !strcmp( &surfName[strlen(surfName)-4], "_off") ) + { + if ( !strcmp( token ,"*off" ) ) + { + continue; //don't need these double offs + } + surfName[strlen(surfName)-4] = 0; //remove the "_off" + } + if ( (unsigned)skin->numSurfaces >= ARRAY_LEN( skin->surfaces ) ) + { + assert( ARRAY_LEN( skin->surfaces ) > (unsigned)skin->numSurfaces ); + Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) more than %d surfaces!\n", name, ARRAY_LEN( skin->surfaces ) ); + break; + } + surf = (skinSurface_t *) Hunk_Alloc( sizeof( *skin->surfaces[0] ), h_low ); + skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf; + + Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); + surf->shader = R_FindShader( token, 0, qtrue ); + skin->numSurfaces++; + } + + ri->FS_FreeFile( text ); + + + // never let a skin have 0 shaders + if ( skin->numSurfaces == 0 ) { + return 0; // use default skin + } + + return hSkin; +} + +qhandle_t RE_RegisterSkin( const char *name ) { + qhandle_t hSkin; + skin_t *skin; + + if ( !name || !name[0] ) { + Com_Printf( "Empty name passed to RE_RegisterSkin\n" ); + return 0; + } + + if ( strlen( name ) >= MAX_QPATH ) { + Com_Printf( "Skin name exceeds MAX_QPATH\n" ); + return 0; + } + + // see if the skin is already loaded + for ( hSkin = 1; hSkin < tr.numSkins ; hSkin++ ) { + skin = tr.skins[hSkin]; + if ( !Q_stricmp( skin->name, name ) ) { + if( skin->numSurfaces == 0 ) { + return 0; // default skin + } + return hSkin; + } + } + + // allocate a new skin + if ( tr.numSkins == MAX_SKINS ) { + Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) MAX_SKINS hit\n", name ); + return 0; + } + tr.numSkins++; + skin = (struct skin_s *)Hunk_Alloc( sizeof( skin_t ), h_low ); + tr.skins[hSkin] = skin; + Q_strncpyz( skin->name, name, sizeof( skin->name ) ); + skin->numSurfaces = 0; + + // make sure the render thread is stopped + R_IssuePendingRenderCommands(); + + // If not a .skin file, load as a single shader + if ( strcmp( name + strlen( name ) - 5, ".skin" ) ) { +/* skin->numSurfaces = 1; + skin->surfaces[0] = (skinSurface_t *)Hunk_Alloc( sizeof(skin->surfaces[0]), h_low ); + skin->surfaces[0]->shader = R_FindShader( name, lightmapsNone, stylesDefault, qtrue ); + return hSkin; +*/ + } + + char skinhead[MAX_QPATH]={0}; + char skintorso[MAX_QPATH]={0}; + char skinlower[MAX_QPATH]={0}; + if ( RE_SplitSkins(name, (char*)&skinhead, (char*)&skintorso, (char*)&skinlower ) ) + {//three part + hSkin = RE_RegisterIndividualSkin(skinhead, hSkin); + if (hSkin) + { + hSkin = RE_RegisterIndividualSkin(skintorso, hSkin); + if (hSkin) + { + hSkin = RE_RegisterIndividualSkin(skinlower, hSkin); + } + } + } + else + {//single skin + hSkin = RE_RegisterIndividualSkin(name, hSkin); + } + return(hSkin); +} + + + +/* +================== +CommaParse + +This is unfortunate, but the skin files aren't +compatable with our normal parsing rules. +================== +*/ +static char *CommaParse( char **data_p ) { + int c = 0, len; + char *data; + static char com_token[MAX_TOKEN_CHARS]; + + data = *data_p; + len = 0; + com_token[0] = 0; + + // make sure incoming data is valid + if ( !data ) { + *data_p = NULL; + return com_token; + } + + while ( 1 ) { + // skip whitespace + while( (c = *data) <= ' ') { + if( !c ) { + break; + } + data++; + } + + + c = *data; + + // skip double slash comments + if ( c == '/' && data[1] == '/' ) + { + while (*data && *data != '\n') + data++; + } + // skip /* */ comments + else if ( c=='/' && data[1] == '*' ) + { + while ( *data && ( *data != '*' || data[1] != '/' ) ) + { + data++; + } + if ( *data ) + { + data += 2; + } + } + else + { + break; + } + } + + if ( c == 0 ) { + return ""; + } + + // handle quoted strings + if (c == '\"') + { + data++; + while (1) + { + c = *data++; + if (c=='\"' || !c) + { + com_token[len] = 0; + *data_p = ( char * ) data; + return com_token; + } + if (len < MAX_TOKEN_CHARS) + { + com_token[len] = c; + len++; + } + } + } + + // parse a regular word + do + { + if (len < MAX_TOKEN_CHARS) + { + com_token[len] = c; + len++; + } + data++; + c = *data; + } while (c>32 && c != ',' ); + + if (len == MAX_TOKEN_CHARS) + { +// Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS); + len = 0; + } + com_token[len] = 0; + + *data_p = ( char * ) data; + return com_token; +} + +/* +=============== +R_InitSkins +=============== +*/ +void R_InitSkins( void ) { + skin_t *skin; + + tr.numSkins = 1; + + // make the default skin have all default shaders + skin = tr.skins[0] = (struct skin_s *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); + Q_strncpyz( skin->name, "", sizeof( skin->name ) ); + skin->numSurfaces = 1; + skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( skinSurface_t ), h_low ); + skin->surfaces[0]->shader = tr.defaultShader; +} + +/* +=============== +R_GetSkinByHandle +=============== +*/ +skin_t *R_GetSkinByHandle( qhandle_t hSkin ) { + if ( hSkin < 1 || hSkin >= tr.numSkins ) { + return tr.skins[0]; + } + return tr.skins[ hSkin ]; +} + +/* +=============== +R_SkinList_f +=============== +*/ +void R_SkinList_f( void ) { + int i, j; + skin_t *skin; + + Com_Printf ( "------------------\n"); + + for ( i = 0 ; i < tr.numSkins ; i++ ) { + skin = tr.skins[i]; + + Com_Printf ("%3i:%s\n", i, skin->name ); + for ( j = 0 ; j < skin->numSurfaces ; j++ ) { + Com_Printf (" %s = %s\n", + skin->surfaces[j]->name, ((shader_t* )skin->surfaces[j]->shader)->name ); + } + } + Com_Printf ( "------------------\n"); +} diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index cd8f48acd9..2600804c4b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2157,12 +2157,19 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, (void(*)(void*))RB_SurfaceFace, // SF_FACE, (void(*)(void*))RB_SurfaceGrid, // SF_GRID, - (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, - (void(*)(void*))RB_SurfacePolychain, // SF_POLY, + (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, + (void(*)(void*))RB_SurfacePolychain, // SF_POLY, (void(*)(void*))RB_SurfaceMesh, // SF_MDV, (void(*)(void*))RB_SurfaceAnim, // SF_MD4, (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, (void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM, + /* + Ghoul 2 Insert + */ + (void(*)(void*))RB_SurfaceGhoul, // SF_MDX, + /* + Ghoul 2 End + */ (void(*)(void*))RB_SurfaceFlare, // SF_FLARE, (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY (void(*)(void*))RB_SurfaceDisplayList, // SF_DISPLAY_LIST From 4e4fbd42080dfd0001101bb3ab14b8c786ca2871 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 17 Oct 2013 22:39:44 -0400 Subject: [PATCH 076/708] MP: [rend2] Update CMake. --- codemp/rd-rend2/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 60d6a2a02b..6acc0c3d86 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -49,6 +49,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_shade_calc.cpp" "${MPDir}/rd-rend2/tr_shader.cpp" "${MPDir}/rd-rend2/tr_shadows.cpp" + "${MPDir}/rd-rend2/tr_skin.cpp" "${MPDir}/rd-rend2/tr_sky.cpp" "${MPDir}/rd-rend2/tr_subs.cpp" "${MPDir}/rd-rend2/tr_surface.cpp" From fb835d2c3c6d4d0a29e025ced906b98dc398937d Mon Sep 17 00:00:00 2001 From: eezstreet Date: Thu, 17 Oct 2013 23:01:15 -0400 Subject: [PATCH 077/708] MP: [rend2] Made RF_MINLIGHT more akin to JKA --- codemp/rd-rend2/tr_light.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 221da656cf..eaaa5d23dd 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -354,13 +354,31 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // bonus items and view weapons have a fixed minimum add - if ( !r_hdr->integer /* ent->e.renderfx & RF_MINLIGHT */ ) { + if ( !r_hdr->integer ) { // give everything a minimum light add ent->ambientLight[0] += tr.identityLight * 32; ent->ambientLight[1] += tr.identityLight * 32; ent->ambientLight[2] += tr.identityLight * 32; } + if ( ent->e.renderfx & RF_MINLIGHT ) + { //the minlight flag is now for items rotating on their holo thing + if (ent->e.shaderRGBA[0] == 255 && + ent->e.shaderRGBA[1] == 255 && + ent->e.shaderRGBA[2] == 0) + { + ent->ambientLight[0] += tr.identityLight * 255; + ent->ambientLight[1] += tr.identityLight * 255; + ent->ambientLight[2] += tr.identityLight * 0; + } + else + { + ent->ambientLight[0] += tr.identityLight * 16; + ent->ambientLight[1] += tr.identityLight * 96; + ent->ambientLight[2] += tr.identityLight * 150; + } + } + // // modify the light by dynamic lights // From c51f2eb463eee08a16a1f99719bb57d4991b0d43 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 26 Oct 2013 02:06:16 +0100 Subject: [PATCH 078/708] Fixed cache and MD3 model loading Also made rd-dedicated buildable again. --- codemp/rd-dedicated/tr_local.h | 36 +++++++++++++++ codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_cache.cpp | 82 ++++++++++++++++++++-------------- codemp/rd-rend2/tr_local.h | 13 +++--- codemp/rd-rend2/tr_model.cpp | 2 +- 5 files changed, 93 insertions(+), 42 deletions(-) diff --git a/codemp/rd-dedicated/tr_local.h b/codemp/rd-dedicated/tr_local.h index f3cbe13dea..733af4437a 100644 --- a/codemp/rd-dedicated/tr_local.h +++ b/codemp/rd-dedicated/tr_local.h @@ -848,6 +848,42 @@ typedef struct world_s { //====================================================================== +typedef enum { + MOD_BAD, + MOD_BRUSH, + MOD_MESH, +/* +Ghoul2 Insert Start +*/ + MOD_MDXM, + MOD_MDXA +/* +Ghoul2 Insert End +*/ + +} modtype_t; + +typedef struct model_s { + char name[MAX_QPATH]; + modtype_t type; + int index; // model = tr.models[model->mod_index] + + int dataSize; // just for listing purposes + bmodel_t *bmodel; // only if type == MOD_BRUSH + md3Header_t *md3[MD3_MAX_LODS]; // only if type == MOD_MESH +/* +Ghoul2 Insert Start +*/ + mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file + mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file +/* +Ghoul2 Insert End +*/ + unsigned char numLods; + bool bspInstance; // model is a bsp instance +} model_t; + + #define MAX_MOD_KNOWN 1024 void R_ModelInit (void); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 97039f84de..a92f909b4a 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1843,7 +1843,7 @@ static void R_CreateWorldVBOs(void) int numTriangles; srfTriangle_t *triangles; - int numSortedSurfaces, numSurfaces; + int numSortedSurfaces = 0, numSurfaces; msurface_t *surface, **firstSurf, **lastSurf, **currSurf; msurface_t **surfacesSorted; diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 731aad5564..d3f05c7371 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -37,7 +37,7 @@ void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) FileHash_t *fh = (FileHash_t *)ri->Hunk_Alloc( sizeof(FileHash_t), h_low ); fh->handle = handle; Q_strncpyz( fh->fileName, fileName, sizeof(fh->fileName) ); - loaded.insert(make_pair(fileName, *fh)); + loaded.insert(make_pair(fileName, *fh)); } /* @@ -53,28 +53,26 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb Q_strncpyz(sFileName, pFileName, MAX_QPATH); Q_strlwr (sFileName); - CachedFile_t &pFile = cache[sFileName]; - - if(!pFile.pDiskImage) + auto cacheEntry = cache.find (sFileName); + if ( cacheEntry != cache.end() ) { - *pbAlreadyCached = qfalse; - int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); - qboolean bSuccess = !!(*ppFileBuffer)?qtrue:qfalse; - const char **blah = (const char**)ppFileBuffer; - - if( bSuccess ) - { - ri->Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); - } + *ppFileBuffer = cacheEntry->second.pDiskImage; + *pbAlreadyCached = qtrue; - return bSuccess; + return qtrue; } - else + + *pbAlreadyCached = qfalse; + + int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); + if ( *ppFileBuffer == nullptr ) { - *ppFileBuffer = pFile.pDiskImage; - *pbAlreadyCached = qtrue; - return qtrue; + return qfalse; } + + ri->Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); + + return qtrue; } /* @@ -98,10 +96,13 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode Q_strncpyz(sModelName, psModelFileName, MAX_QPATH); Q_strlwr (sModelName); - CachedFile_t *pFile = &cache[sModelName]; + CachedFile_t *pFile; + auto cacheEntry = cache.find (sModelName); - if( !pFile->pDiskImage ) + if (cacheEntry == cache.end()) { /* Create this image. */ + pFile = &cache[sModelName]; + if( pvDiskBuffer ) Z_MorphMallocTag( pvDiskBuffer, eTag ); else @@ -121,6 +122,7 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode * TODO: shader caching. */ *bAlreadyFound = qtrue; + pFile = &cacheEntry->second; } pFile->iLevelLastUsedOn = tr.currentLevel; @@ -137,7 +139,6 @@ void CCacheManager::DeleteAll( void ) for( auto it = cache.begin(); it != cache.end(); ++it ) { Z_Free(it->second.pDiskImage); - it = cache.erase(it); } } @@ -164,12 +165,12 @@ void CCacheManager::DumpNonPure( void ) if( it->second.pDiskImage ) Z_Free( it->second.pDiskImage ); - it = cache.erase(it++); - bEraseOccurred = qtrue; + it = cache.erase(it); } - - if( !bEraseOccurred ) + else + { ++it; + } } ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); @@ -191,7 +192,7 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThis ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); - for(auto it = cache.begin(); it != cache.end(); ++it) + for(auto it = cache.begin(); it != cache.end(); /* empty */) { CachedFile_t pFile = it->second; bool bDeleteThis = false; @@ -212,9 +213,13 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThis Z_Free( pFile.pDiskImage ); bAtLeastOneModelFreed = qtrue; // FIXME: is this correct? shouldn't it be in the next lower scope? } - // FIXME: like right here? + it = cache.erase(it); } + else + { + ++it; + } } ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); @@ -252,8 +257,13 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const Q_strncpyz(sModelName, psModelFileName, sizeof(sModelName)); Q_strlwr (sModelName); - CachedFile_t &rFile = cache[sModelName]; + auto cacheEntry = cache.find (sModelName); + if ( cacheEntry == cache.end() ) + { + return; + } + CachedFile_t &rFile = cacheEntry->second; if( rFile.pDiskImage == NULL ) { /* Shouldn't even happen. */ @@ -264,7 +274,7 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const int iNameOffset = psShaderName - (char *)rFile.pDiskImage; int iPokeOffset = (char*) piShaderIndexPoke - (char *)rFile.pDiskImage; - shaderCache.push_back( make_pair( iNameOffset, iPokeOffset ) ); + rFile.shaderCache.push_back( make_pair( iNameOffset, iPokeOffset ) ); } void CModelCacheManager::AllocateShaders( const char *psFileName ) @@ -276,7 +286,13 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) Q_strncpyz(sModelName, psFileName, sizeof(sModelName)); Q_strlwr (sModelName); - CachedFile_t &rFile = cache[sModelName]; + auto cacheEntry = cache.find (sModelName); + if ( cacheEntry == cache.end() ) + { + return; + } + + CachedFile_t &rFile = cacheEntry->second; if( rFile.pDiskImage == NULL ) { @@ -285,10 +301,10 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) return; } - for( auto it = shaderCache.begin(); it != shaderCache.end(); ++it ) + for( auto storedShader : rFile.shaderCache ) { - int iShaderNameOffset = it->first; - int iShaderPokeOffset = it->second; + int iShaderNameOffset = storedShader.first; + int iShaderPokeOffset = storedShader.second; char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 68fdd104c4..002d375dff 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3125,6 +3125,10 @@ enum CacheType_e CACHE_MODEL }; +/* and shaderCache_t is needed for the model cache manager */ +typedef std::pair shaderCacheEntry_t; +typedef std::vector shaderCache_t; + /* * CachedFile_t * The actual data stored in the cache @@ -3138,6 +3142,7 @@ typedef struct CachedFile_s int iAllocSize; // CacheType_e eCacheType; // determine which member of the uCache we're going to use + shaderCache_t shaderCache; CachedFile_s() { @@ -3145,7 +3150,7 @@ typedef struct CachedFile_s iLevelLastUsedOn = 0; iPAKChecksum = -1; eCacheType = CACHE_NONE; - memset(fileName, '\0', sizeof(fileName)); + fileName[0] = '\0'; iAllocSize = 0; } } CachedFile_t; @@ -3154,10 +3159,6 @@ typedef struct CachedFile_s typedef std::map assetCache_t; typedef std::unordered_map loadedMap_t; -/* and shaderCache_t is needed for the model cache manager */ -typedef std::pair shaderCacheEntry_t; -typedef std::vector shaderCache_t; - /* The actual manager itself, which is used in the model and image loading routines. */ class CCacheManager { @@ -3189,8 +3190,6 @@ class CModelCacheManager : public CCacheManager qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); void AllocateShaders( const char *psFileName ); -private: - shaderCache_t shaderCache; }; extern CImageCacheManager *CImgCache; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 1f021a5a0b..1fab4185bc 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -82,7 +82,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) ri->FS_FreeFile(buf); break; case MD3_IDENT: - loaded = R_LoadMD3(mod, lod, buf, name); + loaded = R_LoadMD3(mod, lod, buf, namebuf); ri->FS_FreeFile(buf); break; // Ghoul2 is hax, doesn't free the file buffer and doesn't afraid of anything From 48b8153d351ef7a2f866d50a6fc6781626d58441 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 26 Oct 2013 12:26:35 +0100 Subject: [PATCH 079/708] Fixed cache loading and model loading. --- codemp/rd-rend2/tr_bsp.cpp | 2 ++ codemp/rd-rend2/tr_cache.cpp | 46 ++++++++++++++++++++++++++++++++---- codemp/rd-rend2/tr_model.cpp | 29 +++++++++++++---------- 3 files changed, 61 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a92f909b4a..5a09a1a542 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2318,6 +2318,8 @@ static void R_LoadSubmodels( lump_t *l ) { out->bounds[1][j] = LittleFloat (in->maxs[j]); } + CModelCache->InsertLoaded (model->name, model->index); + out->firstSurface = LittleLong( in->firstSurface ); out->numSurfaces = LittleLong( in->numSurfaces ); diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index d3f05c7371..92b038fd74 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -34,12 +34,35 @@ qhandle_t CCacheManager::SearchLoaded( const char *fileName ) */ void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) { - FileHash_t *fh = (FileHash_t *)ri->Hunk_Alloc( sizeof(FileHash_t), h_low ); - fh->handle = handle; - Q_strncpyz( fh->fileName, fileName, sizeof(fh->fileName) ); - loaded.insert(make_pair(fileName, *fh)); + FileHash_t fh; + fh.handle = handle; + Q_strncpyz( fh.fileName, fileName, sizeof(fh.fileName) ); + loaded.insert(make_pair(fileName, fh)); } +static const byte FakeGLAFile[] = +{ + 0x32, 0x4C, 0x47, 0x41, 0x06, 0x00, 0x00, 0x00, 0x2A, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x01, 0x00, 0x00, 0x00, + 0x14, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x26, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x4D, 0x6F, 0x64, 0x56, 0x69, 0x65, 0x77, 0x20, + 0x69, 0x6E, 0x74, 0x65, 0x72, 0x6E, 0x61, 0x6C, 0x20, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6C, 0x74, + 0x00, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, + 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, + 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, + 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFD, 0xBF, 0xFE, 0x7F, 0xFE, 0x7F, 0xFE, 0x7F, + 0x00, 0x80, 0x00, 0x80, 0x00, 0x80 +}; + /* * CCacheManager::LoadFile * Load the file and chuck the contents into ppFileBuffer, OR @@ -64,6 +87,18 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb *pbAlreadyCached = qfalse; + // special case intercept first... + if (!strcmp (sDEFAULT_GLA_NAME ".gla", pFileName)) + { + // return fake params as though it was found on disk... + void *pvFakeGLAFile = Z_Malloc (sizeof (FakeGLAFile), TAG_FILESYS, qfalse); + + memcpy (pvFakeGLAFile, &FakeGLAFile[0], sizeof (FakeGLAFile)); + *ppFileBuffer = pvFakeGLAFile; + + return qtrue; + } + int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); if ( *ppFileBuffer == nullptr ) { @@ -140,6 +175,9 @@ void CCacheManager::DeleteAll( void ) { Z_Free(it->second.pDiskImage); } + + cache.clear(); + loaded.clear(); } /* diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 1fab4185bc..0aa6a4b51b 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -87,7 +87,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) break; // Ghoul2 is hax, doesn't free the file buffer and doesn't afraid of anything case MDXA_IDENT: - loaded = R_LoadMDXA(mod, buf, name, bAlreadyCached); + loaded = R_LoadMDXA(mod, buf, namebuf, bAlreadyCached); break; case MDXM_IDENT: loaded = R_LoadMDXM(mod, buf, name, bAlreadyCached); @@ -295,32 +295,33 @@ qhandle_t RE_RegisterModel( const char *name ) { return 0; } + // search the currently loaded models + if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) + return hModel; + + if ( name[0] == '*' ) + { + if ( strcmp (name, "*default.gla") != 0 ) + { + return 0; + } + } + if( name[0] == '#' ) { // TODO: BSP models return 0; } - // - // search the currently loaded models - // - if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) - return hModel; - - // allocate a new model_t - if ( ( mod = R_AllocModel() ) == NULL ) { ri->Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); return 0; } - CModelCache->InsertLoaded( name, mod->index ); - // only set the name after the model has been successfully loaded Q_strncpyz( mod->name, name, sizeof( mod->name ) ); - R_IssuePendingRenderCommands(); mod->type = MOD_BAD; @@ -360,6 +361,7 @@ qhandle_t RE_RegisterModel( const char *name ) { else { // Something loaded + CModelCache->InsertLoaded( name, hModel ); return mod->index; } } @@ -389,6 +391,7 @@ qhandle_t RE_RegisterModel( const char *name ) { } } + CModelCache->InsertLoaded( name, hModel ); return hModel; } @@ -1359,6 +1362,8 @@ void R_ModelInit( void ) { // leave a space for NULL model tr.numModels = 0; + CModelCache->DeleteAll(); + mod = R_AllocModel(); mod->type = MOD_BAD; } From 38600d15e8e3fca9df4733d999c222241585ca6d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 26 Oct 2013 17:54:27 +0100 Subject: [PATCH 080/708] Fix MD3 model loading, and stubbed entry points MD3 and MD4 models were incorrectly releasing their file buffers after loading the files. They are now handled the same way as Ghoul2, where the buffers are freed later on by the caching system. A few renderer entry points have also been stubbed out to allow maps to load. --- codemp/rd-rend2/tr_bsp.cpp | 6 ++++++ codemp/rd-rend2/tr_init.cpp | 26 ++++++++++++++------------ codemp/rd-rend2/tr_model.cpp | 3 --- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5a09a1a542..a9e1d44e57 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2813,6 +2813,12 @@ R_GetEntityToken qboolean R_GetEntityToken( char *buffer, int size ) { char *s; + if (size == -1) + { //force reset + s_worldData.entityParsePoint = s_worldData.entityString; + return qtrue; + } + s = COM_Parse( (const char **)&s_worldData.entityParsePoint ); Q_strncpyz( buffer, s, size ); if ( !s_worldData.entityParsePoint || !s[0] ) { diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 7d5696c6a3..a3cea1b026 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1643,6 +1643,13 @@ qhandle_t stub_RegisterServerSkin( const char *name ) return 0; } +qboolean stub_InitializeWireframeAutomap() { return qtrue; } +void stub_RE_GetLightStyle (int style, byte *color){} +void stub_RE_SetLightStyle (int style, int color){} +void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} +void stub_RE_WorldEffectCommand ( const char *cmd ){} +void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} + /* @@@@@@@@@@@@@@@@@@@@@ GetRefAPI @@ -1695,7 +1702,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.ClearScene = RE_ClearScene; // RE_ClearDecals re.AddRefEntityToScene = RE_AddRefEntityToScene; - // RE_AddMiniRefEntityToScene + re.AddMiniRefEntityToScene = stub_RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; // RE_AddDecalToScene re.LightForPoint = R_LightForPoint; @@ -1720,28 +1727,23 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.GetEntityToken = R_GetEntityToken; re.inPVS = R_inPVS; - // RE_GetLightStyle - // RE_SetLightStyle - // RE_GetBModelVerts + re.GetLightStyle = stub_RE_GetLightStyle; + re.SetLightStyle = stub_RE_SetLightStyle; + re.GetBModelVerts = stub_RE_GetBModelVerts; // SetRangedFog // SetRefractionProperties re.GetDistanceCull = GetDistanceCull; re.GetRealRes = GetRealRes; // R_AutomapElevationAdjustment - // R_InitializeWireframeAutomap - // RE_AddWeatherZone - // RE_WorldEffectCommand + re.InitializeWireframeAutomap = stub_InitializeWireframeAutomap; + // RE_AddWeatherZone; + re.WorldEffectCommand = stub_RE_WorldEffectCommand; // RE_InitRendererTerrain - // RE_RegisterMedia_LevelLoadBegin re.RegisterMedia_LevelLoadBegin = C_LevelLoadBegin; - // RE_RegisterMedia_LevelLoadEnd re.RegisterMedia_LevelLoadEnd = C_LevelLoadEnd; - // RE_RegisterMedia_GetLevel re.RegisterMedia_GetLevel = C_GetLevel; - // RE_RegisterImages_LevelLoadEnd re.RegisterImages_LevelLoadEnd = C_Images_LevelLoadEnd; - // RE_RegisterModels_LevelLoadEnd re.RegisterModels_LevelLoadEnd = C_Models_LevelLoadEnd; re.TakeVideoFrame = RE_TakeVideoFrame; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 0aa6a4b51b..a04f290d3b 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -79,13 +79,10 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) { case MD4_IDENT: loaded = R_LoadMD4(mod, buf, name); - ri->FS_FreeFile(buf); break; case MD3_IDENT: loaded = R_LoadMD3(mod, lod, buf, namebuf); - ri->FS_FreeFile(buf); break; - // Ghoul2 is hax, doesn't free the file buffer and doesn't afraid of anything case MDXA_IDENT: loaded = R_LoadMDXA(mod, buf, namebuf, bAlreadyCached); break; From 10c336c282443f748cded0b37c26dc186461a6f5 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Sat, 26 Oct 2013 13:15:54 -0400 Subject: [PATCH 081/708] MP: [rend2] Added in RotatePic functionality. --- codemp/rd-rend2/tr_backend.cpp | 114 +++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_cmds.cpp | 51 +++++++++++++++ codemp/rd-rend2/tr_local.h | 12 ++++ codemp/rd-rend2/tr_shader.cpp | 7 ++ 4 files changed, 184 insertions(+) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a2a57619a9..d46ae4ddbd 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1009,6 +1009,114 @@ const void *RB_StretchPic ( const void *data ) { return (const void *)(cmd + 1); } +/* +============= +RB_DrawRotatePic +============= +*/ +const void *RB_RotatePic ( const void *data ) +{ + const rotatePicCommand_t *cmd; + image_t *image; + shader_t *shader; + + cmd = (const rotatePicCommand_t *)data; + + shader = cmd->shader; + image = shader->stages[0]->bundle[0].image[0]; + + if ( image ) { + if ( !backEnd.projection2D ) { + RB_SetGL2D(); + } + + qglColor4ubv( backEnd.color2D ); + qglPushMatrix(); + + qglTranslatef(cmd->x+cmd->w,cmd->y,0); + qglRotatef(cmd->a, 0.0, 0.0, 1.0); + + GL_Bind( image ); + qglBegin (GL_QUADS); + qglTexCoord2f( cmd->s1, cmd->t1); + qglVertex2f( -cmd->w, 0 ); + qglTexCoord2f( cmd->s2, cmd->t1 ); + qglVertex2f( 0, 0 ); + qglTexCoord2f( cmd->s2, cmd->t2 ); + qglVertex2f( 0, cmd->h ); + qglTexCoord2f( cmd->s1, cmd->t2 ); + qglVertex2f( -cmd->w, cmd->h ); + qglEnd(); + + qglPopMatrix(); + } + + return (const void *)(cmd + 1); +} + +/* +============= +RB_DrawRotatePic2 +============= +*/ +const void *RB_RotatePic2 ( const void *data ) +{ + const rotatePicCommand_t *cmd; + image_t *image; + shader_t *shader; + + cmd = (const rotatePicCommand_t *)data; + + shader = cmd->shader; + + if ( shader->numUnfoggedPasses ) + { + image = shader->stages[0]->bundle[0].image[0]; + + if ( image ) + { + if ( !backEnd.projection2D ) + { + RB_SetGL2D(); + } + + // Get our current blend mode, etc. + GL_State( shader->stages[0]->stateBits ); + + qglColor4ubv( backEnd.color2D ); + qglPushMatrix(); + + // rotation point is going to be around the center of the passed in coordinates + qglTranslatef( cmd->x, cmd->y, 0 ); + qglRotatef( cmd->a, 0.0, 0.0, 1.0 ); + + GL_Bind( image ); + qglBegin( GL_QUADS ); + qglTexCoord2f( cmd->s1, cmd->t1); + qglVertex2f( -cmd->w * 0.5f, -cmd->h * 0.5f ); + + qglTexCoord2f( cmd->s2, cmd->t1 ); + qglVertex2f( cmd->w * 0.5f, -cmd->h * 0.5f ); + + qglTexCoord2f( cmd->s2, cmd->t2 ); + qglVertex2f( cmd->w * 0.5f, cmd->h * 0.5f ); + + qglTexCoord2f( cmd->s1, cmd->t2 ); + qglVertex2f( -cmd->w * 0.5f, cmd->h * 0.5f ); + qglEnd(); + + qglPopMatrix(); + + // Hmmm, this is not too cool + GL_State( GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + } + } + + return (const void *)(cmd + 1); +} + /* ============= @@ -1737,6 +1845,12 @@ void RB_ExecuteRenderCommands( const void *data ) { case RC_STRETCH_PIC: data = RB_StretchPic( data ); break; + case RC_ROTATE_PIC: + data = RB_RotatePic( data ); + break; + case RC_ROTATE_PIC2: + data = RB_RotatePic2( data ); + break; case RC_DRAW_SURFS: data = RB_DrawSurfs( data ); break; diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 7b1a020c1a..437af8f008 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -239,6 +239,57 @@ void RE_SetColor( const float *rgba ) { cmd->color[3] = rgba[3]; } +/* +============= +RE_RotatePic +============= +*/ +void RE_RotatePic ( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { + rotatePicCommand_t *cmd; + + cmd = (rotatePicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_ROTATE_PIC; + cmd->shader = R_GetShaderByHandle( hShader ); + cmd->x = x; + cmd->y = y; + cmd->w = w; + cmd->h = h; + cmd->s1 = s1; + cmd->t1 = t1; + cmd->s2 = s2; + cmd->t2 = t2; + cmd->a = a; +} + +/* +============= +RE_RotatePic2 +============= +*/ +void RE_RotatePic2 ( float x, float y, float w, float h, + float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { + rotatePicCommand_t *cmd; + + cmd = (rotatePicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) { + return; + } + cmd->commandId = RC_ROTATE_PIC2; + cmd->shader = R_GetShaderByHandle( hShader ); + cmd->x = x; + cmd->y = y; + cmd->w = w; + cmd->h = h; + cmd->s1 = s1; + cmd->t1 = t1; + cmd->s2 = s2; + cmd->t2 = t2; + cmd->a = a; +} /* ============= diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 002d375dff..d22b5aa928 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2967,6 +2967,16 @@ typedef struct { float s2, t2; } stretchPicCommand_t; +typedef struct rotatePicCommand_s { + int commandId; + shader_t *shader; + float x, y; + float w, h; + float s1, t1; + float s2, t2; + float a; +} rotatePicCommand_t; + typedef struct { int commandId; trRefdef_t refdef; @@ -3022,6 +3032,8 @@ typedef enum { RC_END_OF_LIST, RC_SET_COLOR, RC_STRETCH_PIC, + RC_ROTATE_PIC, + RC_ROTATE_PIC2, RC_DRAW_SURFS, RC_DRAW_BUFFER, RC_SWAP_BUFFERS, diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f363c63227..36bf198677 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2756,6 +2756,13 @@ static void FixRenderCommandList( int newShader ) { curCmd = (const void *)(sp_cmd + 1); break; } + case RC_ROTATE_PIC: + case RC_ROTATE_PIC2: + { + const rotatePicCommand_t *sp_cmd = (const rotatePicCommand_t *)curCmd; + curCmd = (const void *)(sp_cmd + 1); + break; + } case RC_DRAW_SURFS: { int i; From 438c1a6d714945476c085a4f55d747797a23cf03 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Sat, 26 Oct 2013 13:40:25 -0400 Subject: [PATCH 082/708] MP: [rend2] MSVC2010 compliancy --- codemp/rd-rend2/tr_cache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 92b038fd74..b386b8558e 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -339,10 +339,10 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) return; } - for( auto storedShader : rFile.shaderCache ) + for( auto storedShader = rFile.shaderCache.begin(); storedShader != rFile.shaderCache.end(); ++storedShader ) { - int iShaderNameOffset = storedShader.first; - int iShaderPokeOffset = storedShader.second; + int iShaderNameOffset = storedShader->first; + int iShaderPokeOffset = storedShader->second; char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; From 01bb15cbf0f9cdafb1e6581b578f0cd4c36b060a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 26 Oct 2013 19:19:27 +0100 Subject: [PATCH 083/708] Removed mdxm and mdxa from model_t mdxm and mdxa fields were unnecessary as the more generic modelData field should be used instead. --- codemp/rd-rend2/G2_API.cpp | 52 ++++++++++++++++++--------------- codemp/rd-rend2/G2_bolts.cpp | 9 +++--- codemp/rd-rend2/G2_bones.cpp | 33 +++++++++++---------- codemp/rd-rend2/G2_misc.cpp | 47 +++++++++++++++++------------ codemp/rd-rend2/G2_surfaces.cpp | 40 +++++++++++++------------ codemp/rd-rend2/tr_ghoul2.cpp | 44 ++++++++++++++++++---------- codemp/rd-rend2/tr_local.h | 9 ------ 7 files changed, 130 insertions(+), 104 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index f2a132185f..115e60bd64 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -933,7 +933,7 @@ qboolean G2API_DoesBoneExist(CGhoul2Info *ghlInfo, const char *boneName) { if (G2_SetupModelPointers(ghlInfo)) { //model is valid - mdxaHeader_t *mdxa = ghlInfo->currentModel->mdxa; + mdxaHeader_t *mdxa = (mdxaHeader_t *)ghlInfo->currentModel->modelData; if (mdxa) { //get the skeleton data and iterate through the bones int i; @@ -1933,7 +1933,7 @@ void G2API_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qh char *G2API_GetAnimFileNameIndex(qhandle_t modelIndex) { model_t *mod_m = R_GetModelByHandle(modelIndex); - return mod_m->mdxm->animName; + return ((mdxmHeader_t *)mod_m->modelData)->animName; } /************************************************************************************************ @@ -2035,7 +2035,7 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh { //reworked so we only alloc once! //if we have a pointer, but not a ghoul2_zonetransalloc flag, then that means //it is a miniheap pointer. Just stomp over it. - int iSize = g2.currentModel->mdxm->numSurfaces * 4; + int iSize = ((mdxmHeader_t *)g2.currentModel->modelData)->numSurfaces * 4; g2.mTransformedVertsArray = (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); } @@ -2338,17 +2338,20 @@ char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) model_t *mod = (model_t *)ghlInfo->currentModel; mdxmSurface_t *surf = 0; mdxmSurfHierarchy_t *surfInfo = 0; + mdxmHeader_t *mdxm; #ifndef FINAL_BUILD - if (!mod || !mod->mdxm) + if (!mod || !mod->modelData) { Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad model on instance %s.", ghlInfo->mFileName); } #endif + mdxm = (mdxmHeader_t *)mod->modelData; + //ok, I guess it's semi-valid for the user to be passing in surface > numSurfs because they don't know how many surfs a model //may have.. but how did they get that surf index to begin with? Oh well. - if (surfNumber < 0 || surfNumber >= mod->mdxm->numSurfaces) + if (surfNumber < 0 || surfNumber >= mdxm->numSurfaces) { Com_Printf("G2API_GetSurfaceName: You passed in an invalid surface number (%i) for model %s.\n", surfNumber, ghlInfo->mFileName); return noSurface; @@ -2359,12 +2362,12 @@ char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) if (surf) { #ifndef FINAL_BUILD - if (surf->thisSurfaceIndex < 0 || surf->thisSurfaceIndex >= mod->mdxm->numSurfaces) + if (surf->thisSurfaceIndex < 0 || surf->thisSurfaceIndex >= mdxm->numSurfaces) { Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad surf num (%i) on surf for instance %s.", surf->thisSurfaceIndex, ghlInfo->mFileName); } #endif - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mdxm + sizeof(mdxmHeader_t)); surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surf->thisSurfaceIndex]); return surfInfo->name; } @@ -2391,8 +2394,8 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); //return mod->mdxm->animName; - assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->mdxm); - return ghoul2[modelIndex].currentModel->mdxm->animName; + assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->modelData); + return ((mdxmHeader_t *)ghoul2[modelIndex].currentModel->modelData)->animName; } } return NULL; @@ -2476,14 +2479,15 @@ qboolean G2API_SkinlessModel(CGhoul2Info *g2) model_t *mod = (model_t *)g2->currentModel; if (mod && - mod->mdxm) + mod->modelData) { mdxmSurfHierarchy_t *surf; int i; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; - surf = (mdxmSurfHierarchy_t *) ( (byte *)mod->mdxm + mod->mdxm->ofsSurfHierarchy ); + surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for (i = 0; i < mod->mdxm->numSurfaces; i++) + for (i = 0; i < mdxm->numSurfaces; i++) { if (surf->shader && surf->shader[0]) { //found a surface with a shader name, ok. @@ -2599,20 +2603,21 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel); if (ghlInfo->currentModel) { - if (ghlInfo->currentModel->mdxm) + if (ghlInfo->currentModel->modelData) { + mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->modelData; if (ghlInfo->currentModelSize) { - if (ghlInfo->currentModelSize!=ghlInfo->currentModel->mdxm->ofsEnd) + if (ghlInfo->currentModelSize!=mdxm->ofsEnd) { Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); } } - ghlInfo->currentModelSize=ghlInfo->currentModel->mdxm->ofsEnd; - ghlInfo->animModel = R_GetModelByHandle(ghlInfo->currentModel->mdxm->animIndex); + ghlInfo->currentModelSize=mdxm->ofsEnd; + ghlInfo->animModel = R_GetModelByHandle(mdxm->animIndex); if (ghlInfo->animModel) { - ghlInfo->aHeader =ghlInfo->animModel->mdxa; + ghlInfo->aHeader = (mdxaHeader_t *)ghlInfo->animModel->modelData; if (ghlInfo->aHeader) { if (ghlInfo->currentAnimModelSize) @@ -2694,24 +2699,25 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode G2ERROR(ghlInfo->currentModel,va("NULL Model (glm) %s",ghlInfo->mFileName)); if (ghlInfo->currentModel) { - G2ERROR(ghlInfo->currentModel->mdxm,va("Model has no mdxm (glm) %s",ghlInfo->mFileName)); - if (ghlInfo->currentModel->mdxm) + G2ERROR(ghlInfo->currentModel->modelData,va("Model has no mdxm (glm) %s",ghlInfo->mFileName)); + if (ghlInfo->currentModel->modelData) { + mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->modelData; if (ghlInfo->currentModelSize) { - if (ghlInfo->currentModelSize!=ghlInfo->currentModel->mdxm->ofsEnd) + if (ghlInfo->currentModelSize!=mdxm->ofsEnd) { Com_Error(ERR_DROP, "Ghoul2 model was reloaded and has changed, map must be restarted.\n"); } } - ghlInfo->currentModelSize=ghlInfo->currentModel->mdxm->ofsEnd; + ghlInfo->currentModelSize=mdxm->ofsEnd; G2ERROR(ghlInfo->currentModelSize,va("Zero sized Model? (glm) %s",ghlInfo->mFileName)); - ghlInfo->animModel = R_GetModelByHandle(ghlInfo->currentModel->mdxm->animIndex); + ghlInfo->animModel = R_GetModelByHandle(mdxm->animIndex); G2ERROR(ghlInfo->animModel,va("NULL Model (gla) %s",ghlInfo->mFileName)); if (ghlInfo->animModel) { - ghlInfo->aHeader =ghlInfo->animModel->mdxa; + ghlInfo->aHeader = (mdxaHeader_t *)ghlInfo->animModel->modelData; G2ERROR(ghlInfo->aHeader,va("Model has no mdxa (gla) %s",ghlInfo->mFileName)); if (ghlInfo->aHeader) { diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index 9faf6ae94d..e23a601ee7 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -152,12 +152,13 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, // no, check to see if it's a bone then - offsets = (mdxaSkelOffsets_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t)); + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find - for (x=0; x< mod_a->mdxa->numBones; x++) + for (x=0; x< mdxa->numBones; x++) { - skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { @@ -166,7 +167,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, } // check to see we did actually make a match with a bone in the model - if (x == mod_a->mdxa->numBones) + if (x == mdxa->numBones) { // didn't find it? Error //assert(0&&x == mod_a->mdxa->numBones); diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 788ffc9441..767b281e74 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -25,8 +25,9 @@ int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) { mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[0]); + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[0]); // look through entire list for(size_t i=0; imdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) @@ -58,17 +59,18 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; boneInfo_t tempBone; + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; //rww - RAGDOLL_BEGIN memset(&tempBone, 0, sizeof(tempBone)); //rww - RAGDOLL_END - offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find - for (x=0; x< mod->mdxa->numBones; x++) + for (x=0; x< mdxa->numBones; x++) { - skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[x]); // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { @@ -77,7 +79,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) } // check to see we did actually make a match with a bone in the model - if (x == mod->mdxa->numBones) + if (x == mdxa->numBones) { // didn't find it? Error //assert(0); @@ -97,7 +99,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) // if this bone entry has info in it, bounce over it if (blist[i].boneNumber != -1) { - skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[i].boneNumber]); // if name is the same, we found it if (!Q_stricmp(skel->name, boneName)) { @@ -299,8 +301,9 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const Create_Matrix(newAngles, boneOverride); // figure out where the bone hirearchy info is - offsets = (mdxaSkelOffsets_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)mod->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[index].boneNumber]); + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; + offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[index].boneNumber]); Multiply_3x4Matrix(&temp1, boneOverride,&skel->BasePoseMatInv); Multiply_3x4Matrix(boneOverride,&skel->BasePoseMat, &temp1); @@ -567,7 +570,7 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons { mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); } - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); if (index != -1) @@ -962,7 +965,7 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1000,7 +1003,7 @@ qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1036,7 +1039,7 @@ qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -4859,7 +4862,7 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); return (G2_Find_Bone(mod_a, ghoul2->mBlist, boneName)); } diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index af997df82f..b7a96cb028 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -254,11 +254,12 @@ void G2_List_Model_Surfaces(const char *fileName) int i, x; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); mdxmSurfHierarchy_t *surf; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; - surf = (mdxmSurfHierarchy_t *) ( (byte *)mod_m->mdxm + mod_m->mdxm->ofsSurfHierarchy ); - mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mod_m->mdxm + mod_m->mdxm->ofsLODs + sizeof(mdxmLOD_t)); + surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); + mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mdxm + mdxm->ofsLODs + sizeof(mdxmLOD_t)); - for ( x = 0 ; x < mod_m->mdxm->numSurfaces ; x++) + for ( x = 0 ; x < mdxm->numSurfaces ; x++) { Com_Printf("Surface %i Name %s\n", x, surf->name); if ( r_verbose->integer ) @@ -283,10 +284,10 @@ void G2_List_Model_Bones(const char *fileName, int frame) mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->mdxm->animIndex); + model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); // mdxaFrame_t *aframe=0; // int frameSize; - mdxaHeader_t *header = mod_a->mdxa; + mdxaHeader_t *header = (mdxaHeader_t *)mod_a->modelData; // figure out where the offset list is offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); @@ -295,7 +296,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) // aframe = (mdxaFrame_t *)((byte *)header + header->ofsFrames + (frame * frameSize)); // walk each bone and list it's name - for (x=0; x< mod_a->mdxa->numBones; x++) + for (x=0; x< header->numBones; x++) { skel = (mdxaSkel_t *)((byte *)header + sizeof(mdxaHeader_t) + offsets->offsets[x]); Com_Printf("Bone %i Name %s\n", x, skel->name); @@ -331,10 +332,14 @@ qboolean G2_GetAnimFileName(const char *fileName, char **filename) // find the model we want model_t *mod = R_GetModelByHandle(RE_RegisterModel(fileName)); - if (mod && mod->mdxm && (mod->mdxm->animName[0] != 0)) + if (mod) { - *filename = mod->mdxm->animName; - return qtrue; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + if (mdxm && mdxm->animName[0] != 0) + { + *filename = mdxm->animName; + return qtrue; + } } return qfalse; } @@ -357,14 +362,15 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) } // assert(G2_MODEL_OK(&ghoul2)); + mdxmHeader_t *mdxm = (mdxmHeader_t *)ghoul2.currentModel->modelData; assert(ghoul2.currentModel); - assert(ghoul2.currentModel->mdxm); + assert(mdxm); //what about r_lodBias? // now ensure that we haven't selected a lod that doesn't exist for this model - if ( returnLod >= ghoul2.currentModel->mdxm->numLODs ) + if ( returnLod >= mdxm->numLODs ) { - returnLod = ghoul2.currentModel->mdxm->numLODs - 1; + returnLod = mdxm->numLODs - 1; } return returnLod; @@ -486,10 +492,10 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, { int i; assert(currentModel); - assert(currentModel->mdxm); + assert(currentModel->modelData); // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -600,17 +606,19 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, } #endif + mdxmHeader_t *mdxm = (mdxmHeader_t *)g.currentModel->modelData; + // give us space for the transformed vertex array to be put in if (!(g.mFlags & GHOUL2_ZONETRANSALLOC)) { //do not stomp if we're using zone space - g.mTransformedVertsArray = (size_t*)G2VertSpace->MiniHeapAlloc(g.currentModel->mdxm->numSurfaces * sizeof (size_t)); + g.mTransformedVertsArray = (size_t*)G2VertSpace->MiniHeapAlloc(mdxm->numSurfaces * sizeof (size_t)); if (!g.mTransformedVertsArray) { Com_Error(ERR_DROP, "Ran out of transform space for Ghoul2 Models. Adjust MiniHeapSize in SV_SpawnServer.\n"); } } - memset(g.mTransformedVertsArray, 0,g.currentModel->mdxm->numSurfaces * sizeof (size_t)); + memset(g.mTransformedVertsArray, 0,mdxm->numSurfaces * sizeof (size_t)); G2_FindOverrideSurface(-1,g.mSlist); //reset the quick surface override lookup; // recursively call the model surface transform @@ -1391,9 +1399,9 @@ static void G2_TraceSurfaces(CTraceSurface &TS) int i; // back track and get the surfinfo struct for this surface assert(TS.currentModel); - assert(TS.currentModel->mdxm); + assert(TS.currentModel->modelData); const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(TS.currentModel, TS.surfaceNum, TS.lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->modelData + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -1651,9 +1659,10 @@ void *G2_FindSurface(void *mod_t, int index, int lod) { // damn include file dependancies model_t *mod = (model_t *)mod_t; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; // point at first lod list - byte *current = (byte*)((size_t)mod->mdxm + (size_t)mod->mdxm->ofsLODs); + byte *current = (byte*)((size_t)mdxm + (size_t)mdxm->ofsLODs); int i; //walk the lods diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp index 155216df36..02d3ec2a9d 100644 --- a/codemp/rd-rend2/G2_surfaces.cpp +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -55,9 +55,10 @@ int G2_IsSurfaceLegal(void *mod, const char *surfaceName, int *flags) // damn include file dependancies mdxmSurfHierarchy_t *surf; model_t *mod_m = (model_t *)mod; - surf = (mdxmSurfHierarchy_t *) ( (byte *)mod_m->mdxm + mod_m->mdxm->ofsSurfHierarchy ); + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; + surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mod_m->mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surf->name)) { @@ -89,11 +90,11 @@ mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const int i = 0; // find the model we want model_t *mod = (model_t *)ghlInfo->currentModel; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->modelData + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo; // did we find a ghoul 2 model or not? - if (!mod->mdxm) + if (!mod->modelData) { assert(0); if (surfIndex) @@ -142,7 +143,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c model_t *mod = (model_t *)ghlInfo->currentModel; // did we find a ghoul 2 model or not? - if (!mod->mdxm) + if (!mod->modelData) { assert(0); return qfalse; @@ -219,9 +220,10 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur model_t *mod = (model_t *)ghlInfo->currentModel; int surfIndex = -1; mdxmSurface_t *surf = 0; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; // did we find a ghoul 2 model or not? - if (!mod->mdxm) + if (!mdxm) { return 0; } @@ -235,9 +237,9 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur } // ok, we didn't find it in the surface list. Lets look at the original surface then. - mdxmSurfHierarchy_t *surface = (mdxmSurfHierarchy_t *) ( (byte *)mod->mdxm + mod->mdxm->ofsSurfHierarchy ); + mdxmSurfHierarchy_t *surface = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); - for ( int i = 0 ; i < mod->mdxm->numSurfaces ; i++) + for ( int i = 0 ; i < mdxm->numSurfaces ; i++) { if (!Q_stricmp(surfaceName, surface->name)) { @@ -255,7 +257,7 @@ void G2_FindRecursiveSurface(model_t *currentModel, int surfaceNum, surfaceInfo_ { int i; mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -330,9 +332,11 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch model_t *mod_m = (model_t *)ghoul2[modelIndex].currentModel; model_t *mod_a = (model_t *)ghoul2[modelIndex].animModel; + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; // did we find a ghoul 2 model or not? - if (!mod_m->mdxm) + if (!mdxm) { return qfalse; } @@ -354,10 +358,10 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch // firstly, generate a list of active / on surfaces below the root point // gimme some space to put this list into - activeSurfaces = (int *)Z_Malloc(mod_m->mdxm->numSurfaces * 4, TAG_GHOUL2, qtrue); - memset(activeSurfaces, 0, (mod_m->mdxm->numSurfaces * 4)); - activeBones = (int *)Z_Malloc(mod_a->mdxa->numBones * 4, TAG_GHOUL2, qtrue); - memset(activeBones, 0, (mod_a->mdxa->numBones * 4)); + activeSurfaces = (int *)Z_Malloc(mdxm->numSurfaces * 4, TAG_GHOUL2, qtrue); + memset(activeSurfaces, 0, (mdxm->numSurfaces * 4)); + activeBones = (int *)Z_Malloc(mdxa->numBones * 4, TAG_GHOUL2, qtrue); + memset(activeBones, 0, (mdxa->numBones * 4)); G2_FindRecursiveSurface(mod_m, surf, ghoul2[modelIndex].mSlist, activeSurfaces); @@ -575,7 +579,7 @@ int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index) { model_t *mod = (model_t *)ghlInfo->currentModel; mdxmSurface_t *surf = 0; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->modelData + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = 0; // walk each surface and see if this index is listed in it's children @@ -599,8 +603,8 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int flags = 0;//, surfFlags = 0; int surfIndex = 0; assert(ghlInfo->currentModel); - assert(ghlInfo->currentModel->mdxm); - if (!ghlInfo->currentModel->mdxm) + assert(ghlInfo->currentModel->modelData); + if (!ghlInfo->currentModel->modelData) { return -1; } @@ -611,7 +615,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int surfNum = G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, surfaceName, &flags); if ( surfNum != -1 ) {//must be legal - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->modelData + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]); surfNum = surfInfo->parentIndex; // walk the surface hierarchy up until we hit the root diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 9a9f296a1b..84dd750ce1 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2003,7 +2003,7 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh assert(ghoul2.aHeader); assert(ghoul2.currentModel); - assert(ghoul2.currentModel->mdxm); + assert(ghoul2.currentModel->modelData); if (!aHeader->numBones) { assert(0); // this would be strange @@ -2388,10 +2388,10 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from #endif assert(RS.currentModel); - assert(RS.currentModel->mdxm); + assert(RS.currentModel->modelData); // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->modelData + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2558,7 +2558,7 @@ void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->mdxm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2608,13 +2608,15 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) { int i, j; int offFlags = 0; + mdxmHeader_t *mdxm = (mdxmHeader_t *)CBL.currentModel->modelData; // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)CBL.currentModel, CBL.surfaceNum, 0); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)CBL.currentModel->mdxm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mdxm + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); - const model_t *mod_a = R_GetModelByHandle(CBL.currentModel->mdxm->animIndex); - const mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t)); + const model_t *mod_a = R_GetModelByHandle(mdxm->animIndex); + mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; + const mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); const mdxaSkel_t *skel, *childSkel; // see if we have an override surface in the surface list @@ -2640,13 +2642,13 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) CBL.boneUsedList[iBoneIndex] = 1; // now go and check all the descendant bones attached to this bone and see if any have the always flag on them. If so, activate them - skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iBoneIndex]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iBoneIndex]); // for every child bone... for (j=0; j< skel->numChildren; j++) { // get the skel data struct for each child bone of the referenced bone - childSkel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[skel->children[j]]); + childSkel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[skel->children[j]]); // does it have the always on flag on? if (childSkel->flags & G2BONEFLAG_ALWAYSXFORM) @@ -2664,7 +2666,7 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) if (CBL.boneUsedList[iParentBone]) // no need to go higher break; CBL.boneUsedList[iParentBone] = 1; - skel = (mdxaSkel_t *)((byte *)mod_a->mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); + skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[iParentBone]); iParentBone = skel->parent; } } @@ -2762,15 +2764,16 @@ static void G2_Sort_Models(CGhoul2Info_v &ghoul2, int * const modelList, int * c void *G2_FindSurface_BC(const model_s *mod, int index, int lod) { + mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; assert(mod); - assert(mod->mdxm); + assert(mdxm); // point at first lod list - byte *current = (byte*)((intptr_t)mod->mdxm + (intptr_t)mod->mdxm->ofsLODs); + byte *current = (byte*)((intptr_t)mdxm + (intptr_t)mdxm->ofsLODs); int i; //walk the lods - assert(lod>=0&&lodmdxm->numLODs); + assert(lod>=0&&lodnumLODs); for (i=0; i=0&&indexmdxm->numSurfaces); + assert(index>=0&&indexnumSurfaces); current += indexes->offsets[index]; return (void *)current; @@ -4144,7 +4147,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mod->dataSize += size; qboolean bAlreadyFound = qfalse; - mdxm = mod->mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); + mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); + mod->modelData = mdxm; //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); @@ -4332,6 +4336,13 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean // find the next LOD lod = (mdxmLOD_t *)( (byte *)lod + lod->ofsEnd ); } + + // Make a copy on the GPU + for ( l = 0; i < mdxm->numLODs; l++ ) + { + + } + return qtrue; } @@ -4589,7 +4600,8 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean #endif //CREATE_LIMB_HIERARCHY //mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); - mdxa = mod->mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); + mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); + mod->modelData = mdxa; assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d22b5aa928..e63f123a6a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1758,15 +1758,6 @@ typedef struct model_s { mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM) -/* -Ghoul2 Insert Start -*/ - mdxmHeader_t *mdxm; // only if type == MOD_GL2M which is a GHOUL II Mesh file NOT a GHOUL II animation file - mdxaHeader_t *mdxa; // only if type == MOD_GL2A which is a GHOUL II Animation file -/* -Ghoul2 Insert End -*/ - int numLods; } model_t; From c4a678e237e068d20b439ef83f7e4d6623af7cf6 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 7 Nov 2013 18:56:25 +0000 Subject: [PATCH 084/708] Moved model data into a union. --- codemp/rd-rend2/G2_API.cpp | 30 ++++++++++++++-------------- codemp/rd-rend2/G2_bolts.cpp | 2 +- codemp/rd-rend2/G2_bones.cpp | 16 +++++++-------- codemp/rd-rend2/G2_misc.cpp | 22 ++++++++++----------- codemp/rd-rend2/G2_surfaces.cpp | 24 +++++++++++----------- codemp/rd-rend2/tr_animation.cpp | 4 ++-- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 18 ++++++++--------- codemp/rd-rend2/tr_local.h | 13 +++++++++--- codemp/rd-rend2/tr_main.cpp | 6 +++--- codemp/rd-rend2/tr_mesh.cpp | 14 ++++++------- codemp/rd-rend2/tr_model.cpp | 34 ++++++++++++++++---------------- codemp/rd-rend2/tr_model_iqm.cpp | 4 ++-- codemp/rd-rend2/tr_world.cpp | 2 +- 14 files changed, 99 insertions(+), 92 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 115e60bd64..6076dcfcf1 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -933,7 +933,7 @@ qboolean G2API_DoesBoneExist(CGhoul2Info *ghlInfo, const char *boneName) { if (G2_SetupModelPointers(ghlInfo)) { //model is valid - mdxaHeader_t *mdxa = (mdxaHeader_t *)ghlInfo->currentModel->modelData; + mdxaHeader_t *mdxa = ghlInfo->currentModel->data.gla; if (mdxa) { //get the skeleton data and iterate through the bones int i; @@ -1933,7 +1933,7 @@ void G2API_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qh char *G2API_GetAnimFileNameIndex(qhandle_t modelIndex) { model_t *mod_m = R_GetModelByHandle(modelIndex); - return ((mdxmHeader_t *)mod_m->modelData)->animName; + return mod_m->data.glm->animName; } /************************************************************************************************ @@ -2035,7 +2035,7 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh { //reworked so we only alloc once! //if we have a pointer, but not a ghoul2_zonetransalloc flag, then that means //it is a miniheap pointer. Just stomp over it. - int iSize = ((mdxmHeader_t *)g2.currentModel->modelData)->numSurfaces * 4; + int iSize = g2.currentModel->data.glm->numSurfaces * 4; g2.mTransformedVertsArray = (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); } @@ -2341,13 +2341,13 @@ char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) mdxmHeader_t *mdxm; #ifndef FINAL_BUILD - if (!mod || !mod->modelData) + if (!mod || !mod->data.glm) { Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad model on instance %s.", ghlInfo->mFileName); } #endif - mdxm = (mdxmHeader_t *)mod->modelData; + mdxm = (mdxmHeader_t *)mod->data.glm; //ok, I guess it's semi-valid for the user to be passing in surface > numSurfs because they don't know how many surfs a model //may have.. but how did they get that surf index to begin with? Oh well. @@ -2394,8 +2394,8 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); //return mod->mdxm->animName; - assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->modelData); - return ((mdxmHeader_t *)ghoul2[modelIndex].currentModel->modelData)->animName; + assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->data.glm); + return ghoul2[modelIndex].currentModel->data.glm->animName; } } return NULL; @@ -2479,11 +2479,11 @@ qboolean G2API_SkinlessModel(CGhoul2Info *g2) model_t *mod = (model_t *)g2->currentModel; if (mod && - mod->modelData) + mod->data.glm) { mdxmSurfHierarchy_t *surf; int i; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + mdxmHeader_t *mdxm = mod->data.glm; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); @@ -2603,9 +2603,9 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel); if (ghlInfo->currentModel) { - if (ghlInfo->currentModel->modelData) + if (ghlInfo->currentModel->data.glm) { - mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->modelData; + mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->data.glm; if (ghlInfo->currentModelSize) { if (ghlInfo->currentModelSize!=mdxm->ofsEnd) @@ -2617,7 +2617,7 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model ghlInfo->animModel = R_GetModelByHandle(mdxm->animIndex); if (ghlInfo->animModel) { - ghlInfo->aHeader = (mdxaHeader_t *)ghlInfo->animModel->modelData; + ghlInfo->aHeader = ghlInfo->animModel->data.gla; if (ghlInfo->aHeader) { if (ghlInfo->currentAnimModelSize) @@ -2700,9 +2700,9 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode if (ghlInfo->currentModel) { G2ERROR(ghlInfo->currentModel->modelData,va("Model has no mdxm (glm) %s",ghlInfo->mFileName)); - if (ghlInfo->currentModel->modelData) + if (ghlInfo->currentModel->data.glm) { - mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->modelData; + mdxmHeader_t *mdxm = ghlInfo->currentModel->data.glm; if (ghlInfo->currentModelSize) { if (ghlInfo->currentModelSize!=mdxm->ofsEnd) @@ -2717,7 +2717,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode G2ERROR(ghlInfo->animModel,va("NULL Model (gla) %s",ghlInfo->mFileName)); if (ghlInfo->animModel) { - ghlInfo->aHeader = (mdxaHeader_t *)ghlInfo->animModel->modelData; + ghlInfo->aHeader = ghlInfo->animModel->data.gla; G2ERROR(ghlInfo->aHeader,va("Model has no mdxa (gla) %s",ghlInfo->mFileName)); if (ghlInfo->aHeader) { diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index e23a601ee7..2f742a7fb7 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -152,7 +152,7 @@ int G2_Add_Bolt(CGhoul2Info *ghlInfo, boltInfo_v &bltlist, surfaceInfo_v &slist, // no, check to see if it's a bone then - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; + mdxaHeader_t *mdxa = mod_a->data.gla; offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); // walk the entire list of bones in the gla file for this model and see if any match the name of the bone we want to find diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 767b281e74..358bf2e3c3 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -25,7 +25,7 @@ int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName) { mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; + mdxaHeader_t *mdxa = mod->data.gla; offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[0]); @@ -59,7 +59,7 @@ int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName) mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; boneInfo_t tempBone; - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; + mdxaHeader_t *mdxa = mod->data.gla; //rww - RAGDOLL_BEGIN memset(&tempBone, 0, sizeof(tempBone)); @@ -301,7 +301,7 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const Create_Matrix(newAngles, boneOverride); // figure out where the bone hirearchy info is - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod->modelData; + mdxaHeader_t *mdxa = mod->data.gla; offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[index].boneNumber]); @@ -570,7 +570,7 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons { mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); } - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); if (index != -1) @@ -965,7 +965,7 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1003,7 +1003,7 @@ qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1039,7 +1039,7 @@ qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -4862,7 +4862,7 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); return (G2_Find_Bone(mod_a, ghoul2->mBlist, boneName)); } diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index b7a96cb028..e1e1998d4a 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -254,7 +254,7 @@ void G2_List_Model_Surfaces(const char *fileName) int i, x; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); mdxmSurfHierarchy_t *surf; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; + mdxmHeader_t *mdxm = mod_m->data.glm; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mdxm + mdxm->ofsLODs + sizeof(mdxmLOD_t)); @@ -284,10 +284,10 @@ void G2_List_Model_Bones(const char *fileName, int frame) mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(((mdxmHeader_t *)mod_m->modelData)->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); // mdxaFrame_t *aframe=0; // int frameSize; - mdxaHeader_t *header = (mdxaHeader_t *)mod_a->modelData; + mdxaHeader_t *header = mod_a->data.gla; // figure out where the offset list is offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); @@ -334,7 +334,7 @@ qboolean G2_GetAnimFileName(const char *fileName, char **filename) if (mod) { - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + mdxmHeader_t *mdxm = mod->data.glm; if (mdxm && mdxm->animName[0] != 0) { *filename = mdxm->animName; @@ -362,7 +362,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) } // assert(G2_MODEL_OK(&ghoul2)); - mdxmHeader_t *mdxm = (mdxmHeader_t *)ghoul2.currentModel->modelData; + mdxmHeader_t *mdxm = ghoul2.currentModel->data.glm; assert(ghoul2.currentModel); assert(mdxm); //what about r_lodBias? @@ -492,10 +492,10 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, { int i; assert(currentModel); - assert(currentModel->modelData); + assert(currentModel->data.glm); // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -606,7 +606,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, } #endif - mdxmHeader_t *mdxm = (mdxmHeader_t *)g.currentModel->modelData; + mdxmHeader_t *mdxm = g.currentModel->data.glm; // give us space for the transformed vertex array to be put in if (!(g.mFlags & GHOUL2_ZONETRANSALLOC)) @@ -1399,9 +1399,9 @@ static void G2_TraceSurfaces(CTraceSurface &TS) int i; // back track and get the surfinfo struct for this surface assert(TS.currentModel); - assert(TS.currentModel->modelData); + assert(TS.currentModel->data.glm); const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(TS.currentModel, TS.surfaceNum, TS.lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->modelData + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->data.glm + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -1659,7 +1659,7 @@ void *G2_FindSurface(void *mod_t, int index, int lod) { // damn include file dependancies model_t *mod = (model_t *)mod_t; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + mdxmHeader_t *mdxm = mod->data.glm; // point at first lod list byte *current = (byte*)((size_t)mdxm + (size_t)mdxm->ofsLODs); diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp index 02d3ec2a9d..dfe8330111 100644 --- a/codemp/rd-rend2/G2_surfaces.cpp +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -55,7 +55,7 @@ int G2_IsSurfaceLegal(void *mod, const char *surfaceName, int *flags) // damn include file dependancies mdxmSurfHierarchy_t *surf; model_t *mod_m = (model_t *)mod; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; + mdxmHeader_t *mdxm = mod_m->data.glm; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); for ( int i = 0 ; i < mdxm->numSurfaces ; i++) @@ -90,11 +90,11 @@ mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const int i = 0; // find the model we want model_t *mod = (model_t *)ghlInfo->currentModel; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->modelData + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo; // did we find a ghoul 2 model or not? - if (!mod->modelData) + if (!mod->data.glm) { assert(0); if (surfIndex) @@ -143,7 +143,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c model_t *mod = (model_t *)ghlInfo->currentModel; // did we find a ghoul 2 model or not? - if (!mod->modelData) + if (!mod->data.glm) { assert(0); return qfalse; @@ -220,7 +220,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur model_t *mod = (model_t *)ghlInfo->currentModel; int surfIndex = -1; mdxmSurface_t *surf = 0; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + mdxmHeader_t *mdxm = mod->data.glm; // did we find a ghoul 2 model or not? if (!mdxm) @@ -257,7 +257,7 @@ void G2_FindRecursiveSurface(model_t *currentModel, int surfaceNum, surfaceInfo_ { int i; mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -332,8 +332,8 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch model_t *mod_m = (model_t *)ghoul2[modelIndex].currentModel; model_t *mod_a = (model_t *)ghoul2[modelIndex].animModel; - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod_m->modelData; - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; + mdxmHeader_t *mdxm = mod_m->data.glm; + mdxaHeader_t *mdxa = mod_a->data.gla; // did we find a ghoul 2 model or not? if (!mdxm) @@ -579,7 +579,7 @@ int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index) { model_t *mod = (model_t *)ghlInfo->currentModel; mdxmSurface_t *surf = 0; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->modelData + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = 0; // walk each surface and see if this index is listed in it's children @@ -603,8 +603,8 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int flags = 0;//, surfFlags = 0; int surfIndex = 0; assert(ghlInfo->currentModel); - assert(ghlInfo->currentModel->modelData); - if (!ghlInfo->currentModel->modelData) + assert(ghlInfo->currentModel->data.glm); + if (!ghlInfo->currentModel->data.glm) { return -1; } @@ -615,7 +615,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int surfNum = G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, surfaceName, &flags); if ( surfNum != -1 ) {//must be legal - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->modelData + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->data.glm + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]); surfNum = surfInfo->parentIndex; // walk the surface hierarchy up until we hit the root diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 3ee10ce061..b4bfdcb4af 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -46,7 +46,7 @@ void R_AddAnimSurfaces( trRefEntity_t *ent ) { int cubemapIndex; int i; - header = (md4Header_t *) tr.currentModel->modelData; + header = (md4Header_t *) tr.currentModel->data.md4; lod = (md4LOD_t *)( (byte *)header + header->ofsLODs ); cubemapIndex = R_CubemapForPoint(ent->e.origin); @@ -328,7 +328,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { int cubemapIndex; qboolean personalModel; - header = (mdrHeader_t *)tr.currentModel->modelData; + header = (mdrHeader_t *)tr.currentModel->data.md4; personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a9e1d44e57..a20edf269e 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2310,7 +2310,7 @@ static void R_LoadSubmodels( lump_t *l ) { } model->type = MOD_BRUSH; - model->bmodel = out; + model->data.bmodel = out; Com_sprintf( model->name, sizeof( model->name ), "*%d", i ); for (j=0 ; j<3 ; j++) { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 84dd750ce1..afeb9eb6fb 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2003,7 +2003,7 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh assert(ghoul2.aHeader); assert(ghoul2.currentModel); - assert(ghoul2.currentModel->modelData); + assert(ghoul2.currentModel->data.glm); if (!aHeader->numBones) { assert(0); // this would be strange @@ -2388,10 +2388,10 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from #endif assert(RS.currentModel); - assert(RS.currentModel->modelData); + assert(RS.currentModel->data.glm); // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->modelData + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->data.glm + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2558,7 +2558,7 @@ void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->modelData + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2608,14 +2608,14 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) { int i, j; int offFlags = 0; - mdxmHeader_t *mdxm = (mdxmHeader_t *)CBL.currentModel->modelData; + mdxmHeader_t *mdxm = CBL.currentModel->data.glm; // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)CBL.currentModel, CBL.surfaceNum, 0); const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mdxm + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); const model_t *mod_a = R_GetModelByHandle(mdxm->animIndex); - mdxaHeader_t *mdxa = (mdxaHeader_t *)mod_a->modelData; + mdxaHeader_t *mdxa = mod_a->data.gla; const mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); const mdxaSkel_t *skel, *childSkel; @@ -2764,7 +2764,7 @@ static void G2_Sort_Models(CGhoul2Info_v &ghoul2, int * const modelList, int * c void *G2_FindSurface_BC(const model_s *mod, int index, int lod) { - mdxmHeader_t *mdxm = (mdxmHeader_t *)mod->modelData; + mdxmHeader_t *mdxm = mod->data.glm; assert(mod); assert(mdxm); @@ -4148,7 +4148,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); - mod->modelData = mdxm; + mod->data.glm = mdxm; //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); @@ -4601,7 +4601,7 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean //mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); - mod->modelData = mdxa; + mod->data.gla = mdxa; assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e63f123a6a..caa823e44c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1754,9 +1754,16 @@ typedef struct model_s { int index; // model = tr.models[model->index] int dataSize; // just for listing purposes - bmodel_t *bmodel; // only if type == MOD_BRUSH - mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH - void *modelData; // only if type == (MOD_MD4 | MOD_MDR | MOD_IQM) + union + { + bmodel_t *bmodel; // only if type == MOD_BRUSH + mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH + md4Header_t *md4; // only if type == MOD_MD4 + mdrHeader_t *mdr; // only if type == MOD_MDR + iqmData_t *iqm; // only if type == MOD_IQM + mdxmHeader_t *glm; // only if type == MOD_MDXM + mdxaHeader_t *gla; // only if type == MOD_MDXA + } data; int numLods; } model_t; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 348721151e..90d568e8ba 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2311,7 +2311,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) { case MOD_MESH: { - mdvFrame_t *frame = &model->mdv[0]->frames[ent->e.frame]; + mdvFrame_t *frame = &model->data.mdv[0]->frames[ent->e.frame]; radius = frame->radius * scale; } @@ -2326,7 +2326,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) case MOD_MDR: { // FIXME: never actually tested this - mdrHeader_t *header = (mdrHeader_t*)model->modelData; + mdrHeader_t *header = model->data.mdr; int frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); mdrFrame_t *frame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); @@ -2336,7 +2336,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) case MOD_IQM: { // FIXME: never actually tested this - iqmData_t *data = (iqmData_t *)model->modelData; + iqmData_t *data = model->data.iqm; vec3_t diag; float *framebounds; diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index edcae2d7b3..84011e2f9d 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -185,7 +185,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { if(tr.currentModel->type == MOD_MDR) { int frameSize; - mdr = (mdrHeader_t *) tr.currentModel->modelData; + mdr = tr.currentModel->data.mdr; frameSize = (size_t) (&((mdrFrame_t *)0)->bones[mdr->numBones]); mdrframe = (mdrFrame_t *) ((byte *) mdr + mdr->ofsFrames + frameSize * ent->e.frame); @@ -195,7 +195,7 @@ int R_ComputeLOD( trRefEntity_t *ent ) { else { //frame = ( md3Frame_t * ) ( ( ( unsigned char * ) tr.currentModel->md3[0] ) + tr.currentModel->md3[0]->ofsFrames ); - frame = tr.currentModel->mdv[0]->frames; + frame = tr.currentModel->data.mdv[0]->frames; frame += ent->e.frame; @@ -296,8 +296,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { - ent->e.frame %= tr.currentModel->mdv[0]->numFrames; - ent->e.oldframe %= tr.currentModel->mdv[0]->numFrames; + ent->e.frame %= tr.currentModel->data.mdv[0]->numFrames; + ent->e.oldframe %= tr.currentModel->data.mdv[0]->numFrames; } // @@ -306,9 +306,9 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { // when the surfaces are rendered, they don't need to be // range checked again. // - if ( (ent->e.frame >= tr.currentModel->mdv[0]->numFrames) + if ( (ent->e.frame >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.frame < 0) - || (ent->e.oldframe >= tr.currentModel->mdv[0]->numFrames) + || (ent->e.oldframe >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { ri->Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, @@ -322,7 +322,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { // lod = R_ComputeLOD( ent ); - model = tr.currentModel->mdv[lod]; + model = tr.currentModel->data.mdv[lod]; // // cull the entire model if merged bounding box of both frames diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index a04f290d3b..3b2aa12f18 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -110,7 +110,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) for(lod--; lod >= 0; lod--) { mod->numLods++; - mod->mdv[lod] = mod->mdv[lod + 1]; + mod->data.mdv[lod] = mod->data.mdv[lod + 1]; } return mod->index; @@ -437,7 +437,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN mod->dataSize += size; //mdvModel = mod->mdv[lod] = (mdvModel_t *)ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); qboolean bAlreadyFound = qfalse; - mdvModel = mod->mdv[lod] = (mdvModel_t *)CModelCache->Allocate( size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3 ); + mdvModel = mod->data.mdv[lod] = (mdvModel_t *)CModelCache->Allocate( size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3 ); // Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); if( !bAlreadyFound ) @@ -882,7 +882,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char } mod->dataSize += size; - mod->modelData = mdr = (mdrHeader_t*)ri->Hunk_Alloc( size, h_low ); + mod->data.mdr = mdr = (mdrHeader_t*)ri->Hunk_Alloc( size, h_low ); // Copy all the values over from the file and fix endian issues in the process, if necessary. @@ -1192,7 +1192,7 @@ static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { mod->type = MOD_MD4; size = LittleLong(pinmodel->ofsEnd); mod->dataSize += size; - mod->modelData = md4 = (md4Header_t *)ri->Hunk_Alloc( size, h_low ); + mod->data.md4 = md4 = (md4Header_t *)ri->Hunk_Alloc( size, h_low ); Com_Memcpy(md4, buffer, size); @@ -1382,7 +1382,7 @@ void R_Modellist_f( void ) { mod = tr.models[i]; lods = 1; for ( j = 1 ; j < MD3_MAX_LODS ; j++ ) { - if ( mod->mdv[j] && mod->mdv[j] != mod->mdv[j-1] ) { + if ( mod->data.mdv[j] && mod->data.mdv[j] != mod->data.mdv[j-1] ) { lods++; } } @@ -1485,17 +1485,17 @@ int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFram model_t *model; model = R_GetModelByHandle( handle ); - if ( !model->mdv[0] ) + if ( !model->data.mdv[0] ) { if(model->type == MOD_MDR) { start = &start_space; end = &end_space; - R_GetAnimTag((mdrHeader_t *) model->modelData, startFrame, tagName, start); - R_GetAnimTag((mdrHeader_t *) model->modelData, endFrame, tagName, end); + R_GetAnimTag((mdrHeader_t *) model->data.mdr, startFrame, tagName, start); + R_GetAnimTag((mdrHeader_t *) model->data.mdr, endFrame, tagName, end); } else if( model->type == MOD_IQM ) { - return R_IQMLerpTag( tag, (iqmData_t *)model->modelData, + return R_IQMLerpTag( tag, (iqmData_t *)model->data.iqm, startFrame, endFrame, frac, tagName ); } else { @@ -1508,8 +1508,8 @@ int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFram } else { - start = R_GetTag( model->mdv[0], startFrame, tagName ); - end = R_GetTag( model->mdv[0], endFrame, tagName ); + start = R_GetTag( model->data.mdv[0], startFrame, tagName ); + end = R_GetTag( model->data.mdv[0], endFrame, tagName ); if ( !start || !end ) { AxisClear( tag->axis ); VectorClear( tag->origin ); @@ -1544,15 +1544,15 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { model = R_GetModelByHandle( handle ); if(model->type == MOD_BRUSH) { - VectorCopy( model->bmodel->bounds[0], mins ); - VectorCopy( model->bmodel->bounds[1], maxs ); + VectorCopy( model->data.bmodel->bounds[0], mins ); + VectorCopy( model->data.bmodel->bounds[1], maxs ); return; } else if (model->type == MOD_MESH) { mdvModel_t *header; mdvFrame_t *frame; - header = model->mdv[0]; + header = model->data.mdv[0]; frame = header->frames; VectorCopy( frame->bounds[0], mins ); @@ -1563,7 +1563,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { md4Header_t *header; md4Frame_t *frame; - header = (md4Header_t *)model->modelData; + header = model->data.md4; frame = (md4Frame_t *) ((byte *)header + header->ofsFrames); VectorCopy( frame->bounds[0], mins ); @@ -1574,7 +1574,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { mdrHeader_t *header; mdrFrame_t *frame; - header = (mdrHeader_t *)model->modelData; + header = model->data.mdr; frame = (mdrFrame_t *) ((byte *)header + header->ofsFrames); VectorCopy( frame->bounds[0], mins ); @@ -1584,7 +1584,7 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { } else if(model->type == MOD_IQM) { iqmData_t *iqmData; - iqmData = (iqmData_t *)model->modelData; + iqmData = model->data.iqm; if(iqmData->bounds) { diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index b1fd8846de..b74a40c1cc 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -454,7 +454,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na mod->type = MOD_IQM; iqmData = (iqmData_t *)ri->Hunk_Alloc( size, h_low ); - mod->modelData = iqmData; + mod->data.iqm = iqmData; // fill header iqmData->num_vertexes = header->num_vertexes; @@ -790,7 +790,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { shader_t *shader; skin_t *skin; - data = (iqmData_t *)tr.currentModel->modelData; + data = tr.currentModel->data.iqm; surface = data->surfaces; // don't add third_person objects if not in a portal diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 0b6b37bb41..3694eda258 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -361,7 +361,7 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { pModel = R_GetModelByHandle( ent->e.hModel ); - bmodel = pModel->bmodel; + bmodel = pModel->data.bmodel; clip = R_CullLocalBox( bmodel->bounds ); if ( clip == CULL_OUT ) { From e472cb9ef4800519007f9368b8f17d9ce706768e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 11 Nov 2013 18:01:37 +0000 Subject: [PATCH 085/708] Rend2: fix handling of additional noise enums. GF_NOISE and GF_RAND are now handled properly. --- codemp/rd-rend2/tr_shade_calc.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 1bb0a226fc..1a82cc0d2d 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -61,6 +61,16 @@ static float EvalWaveForm( const waveForm_t *wf ) { float *table; + if ( wf->func == GF_NOISE ) { + return ( wf->base + R_NoiseGet4f( 0, 0, 0, ( backEnd.refdef.floatTime + wf->phase ) * wf->frequency ) * wf->amplitude ); + } else if (wf->func == GF_RAND) { + if( GetNoiseTime( backEnd.refdef.time + wf->phase ) <= wf->frequency ) { + return (wf->base + wf->amplitude); + } else { + return wf->base; + } + } + table = TableForFunc( wf->func ); return WAVEVALUE( table, wf->base, wf->amplitude, wf->phase, wf->frequency ); From cb3769063e7643a955940263e5d079fa8093e612 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 11 Nov 2013 18:02:39 +0000 Subject: [PATCH 086/708] Rend2: merged model data into union to save space The generic and non-generic model data pointers are now merged into a single union so save space. This should reduce the model_s struct by about a third. --- codemp/rd-rend2/G2_API.cpp | 25 ++++++++++++++----------- codemp/rd-rend2/G2_bones.cpp | 10 +++++----- codemp/rd-rend2/G2_misc.cpp | 20 ++++++++++---------- codemp/rd-rend2/G2_surfaces.cpp | 22 +++++++++++----------- codemp/rd-rend2/tr_ghoul2.cpp | 16 +++++++++------- codemp/rd-rend2/tr_init.cpp | 3 ++- codemp/rd-rend2/tr_local.h | 30 ++++++++++++++++-------------- 7 files changed, 67 insertions(+), 59 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 6076dcfcf1..78e665e262 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1933,7 +1933,7 @@ void G2API_SetGhoul2ModelIndexes(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qh char *G2API_GetAnimFileNameIndex(qhandle_t modelIndex) { model_t *mod_m = R_GetModelByHandle(modelIndex); - return mod_m->data.glm->animName; + return mod_m->data.glm->header->animName; } /************************************************************************************************ @@ -2035,7 +2035,7 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh { //reworked so we only alloc once! //if we have a pointer, but not a ghoul2_zonetransalloc flag, then that means //it is a miniheap pointer. Just stomp over it. - int iSize = g2.currentModel->data.glm->numSurfaces * 4; + int iSize = g2.currentModel->data.glm->header->numSurfaces * 4; g2.mTransformedVertsArray = (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); } @@ -2341,13 +2341,13 @@ char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) mdxmHeader_t *mdxm; #ifndef FINAL_BUILD - if (!mod || !mod->data.glm) + if (!mod || !mod->data.glm || !mod->data.glm->header) { Com_Error(ERR_DROP, "G2API_GetSurfaceName: Bad model on instance %s.", ghlInfo->mFileName); } #endif - mdxm = (mdxmHeader_t *)mod->data.glm; + mdxm = mod->data.glm->header; //ok, I guess it's semi-valid for the user to be passing in surface > numSurfs because they don't know how many surfs a model //may have.. but how did they get that surf index to begin with? Oh well. @@ -2395,7 +2395,7 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) //return mod->mdxm->animName; assert(ghoul2[modelIndex].currentModel && ghoul2[modelIndex].currentModel->data.glm); - return ghoul2[modelIndex].currentModel->data.glm->animName; + return ghoul2[modelIndex].currentModel->data.glm->header->animName; } } return NULL; @@ -2479,11 +2479,12 @@ qboolean G2API_SkinlessModel(CGhoul2Info *g2) model_t *mod = (model_t *)g2->currentModel; if (mod && - mod->data.glm) + mod->data.glm && + mod->data.glm->header) { mdxmSurfHierarchy_t *surf; int i; - mdxmHeader_t *mdxm = mod->data.glm; + mdxmHeader_t *mdxm = mod->data.glm->header; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); @@ -2603,9 +2604,10 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model ghlInfo->currentModel = R_GetModelByHandle(ghlInfo->mModel); if (ghlInfo->currentModel) { - if (ghlInfo->currentModel->data.glm) + if (ghlInfo->currentModel->data.glm && + ghlInfo->currentModel->data.glm->header) { - mdxmHeader_t *mdxm = (mdxmHeader_t *)ghlInfo->currentModel->data.glm; + mdxmHeader_t *mdxm = ghlInfo->currentModel->data.glm->header; if (ghlInfo->currentModelSize) { if (ghlInfo->currentModelSize!=mdxm->ofsEnd) @@ -2700,9 +2702,10 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode if (ghlInfo->currentModel) { G2ERROR(ghlInfo->currentModel->modelData,va("Model has no mdxm (glm) %s",ghlInfo->mFileName)); - if (ghlInfo->currentModel->data.glm) + if (ghlInfo->currentModel->data.glm && + ghlInfo->currentModel->data.glm->header) { - mdxmHeader_t *mdxm = ghlInfo->currentModel->data.glm; + mdxmHeader_t *mdxm = ghlInfo->currentModel->data.glm->header; if (ghlInfo->currentModelSize) { if (ghlInfo->currentModelSize!=mdxm->ofsEnd) diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 358bf2e3c3..d31b3d2f79 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -570,7 +570,7 @@ qboolean G2_Set_Bone_Angles_Matrix(const char *fileName, boneInfo_v &blist, cons { mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); } - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); if (index != -1) @@ -965,7 +965,7 @@ qboolean G2_Pause_Bone_Anim(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char qboolean G2_IsPaused(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1003,7 +1003,7 @@ qboolean G2_Stop_Bone_Anim_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Anim(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -1039,7 +1039,7 @@ qboolean G2_Stop_Bone_Angles_Index(boneInfo_v &blist, const int index) qboolean G2_Stop_Bone_Angles(const char *fileName, boneInfo_v &blist, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); int index = G2_Find_Bone(mod_a, blist, boneName); // did we find it? @@ -4862,7 +4862,7 @@ void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) int G2_Get_Bone_Index(CGhoul2Info *ghoul2, const char *boneName) { model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(ghoul2->mFileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); return (G2_Find_Bone(mod_a, ghoul2->mBlist, boneName)); } diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index e1e1998d4a..0c76e5b1e4 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -254,7 +254,7 @@ void G2_List_Model_Surfaces(const char *fileName) int i, x; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); mdxmSurfHierarchy_t *surf; - mdxmHeader_t *mdxm = mod_m->data.glm; + mdxmHeader_t *mdxm = mod_m->data.glm->header; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); mdxmSurface_t *surface = (mdxmSurface_t *)((byte *)mdxm + mdxm->ofsLODs + sizeof(mdxmLOD_t)); @@ -284,7 +284,7 @@ void G2_List_Model_Bones(const char *fileName, int frame) mdxaSkel_t *skel; mdxaSkelOffsets_t *offsets; model_t *mod_m = R_GetModelByHandle(RE_RegisterModel(fileName)); - model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->animIndex); + model_t *mod_a = R_GetModelByHandle(mod_m->data.glm->header->animIndex); // mdxaFrame_t *aframe=0; // int frameSize; mdxaHeader_t *header = mod_a->data.gla; @@ -334,7 +334,7 @@ qboolean G2_GetAnimFileName(const char *fileName, char **filename) if (mod) { - mdxmHeader_t *mdxm = mod->data.glm; + mdxmHeader_t *mdxm = mod->data.glm->header; if (mdxm && mdxm->animName[0] != 0) { *filename = mdxm->animName; @@ -362,7 +362,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) } // assert(G2_MODEL_OK(&ghoul2)); - mdxmHeader_t *mdxm = ghoul2.currentModel->data.glm; + mdxmHeader_t *mdxm = ghoul2.currentModel->data.glm->header; assert(ghoul2.currentModel); assert(mdxm); //what about r_lodBias? @@ -492,10 +492,10 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, { int i; assert(currentModel); - assert(currentModel->data.glm); + assert(currentModel->data.glm && currentModel->data.glm->header); // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void*)currentModel, surfaceNum, lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -606,7 +606,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, } #endif - mdxmHeader_t *mdxm = g.currentModel->data.glm; + mdxmHeader_t *mdxm = g.currentModel->data.glm->header; // give us space for the transformed vertex array to be put in if (!(g.mFlags & GHOUL2_ZONETRANSALLOC)) @@ -1399,9 +1399,9 @@ static void G2_TraceSurfaces(CTraceSurface &TS) int i; // back track and get the surfinfo struct for this surface assert(TS.currentModel); - assert(TS.currentModel->data.glm); + assert(TS.currentModel->data.glm && TS.currentModel->data.glm->header); const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(TS.currentModel, TS.surfaceNum, TS.lod); - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->data.glm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)TS.currentModel->data.glm->header + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -1659,7 +1659,7 @@ void *G2_FindSurface(void *mod_t, int index, int lod) { // damn include file dependancies model_t *mod = (model_t *)mod_t; - mdxmHeader_t *mdxm = mod->data.glm; + mdxmHeader_t *mdxm = mod->data.glm->header; // point at first lod list byte *current = (byte*)((size_t)mdxm + (size_t)mdxm->ofsLODs); diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp index dfe8330111..4634195e22 100644 --- a/codemp/rd-rend2/G2_surfaces.cpp +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -55,7 +55,7 @@ int G2_IsSurfaceLegal(void *mod, const char *surfaceName, int *flags) // damn include file dependancies mdxmSurfHierarchy_t *surf; model_t *mod_m = (model_t *)mod; - mdxmHeader_t *mdxm = mod_m->data.glm; + mdxmHeader_t *mdxm = mod_m->data.glm->header; surf = (mdxmSurfHierarchy_t *) ( (byte *)mdxm + mdxm->ofsSurfHierarchy ); for ( int i = 0 ; i < mdxm->numSurfaces ; i++) @@ -90,11 +90,11 @@ mdxmSurface_t *G2_FindSurface(CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const int i = 0; // find the model we want model_t *mod = (model_t *)ghlInfo->currentModel; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm->header + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo; // did we find a ghoul 2 model or not? - if (!mod->data.glm) + if (!mod->data.glm || !mod->data.glm->header) { assert(0); if (surfIndex) @@ -143,7 +143,7 @@ qboolean G2_SetSurfaceOnOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const c model_t *mod = (model_t *)ghlInfo->currentModel; // did we find a ghoul 2 model or not? - if (!mod->data.glm) + if (!mod->data.glm || !mod->data.glm->header) { assert(0); return qfalse; @@ -220,7 +220,7 @@ int G2_IsSurfaceOff (CGhoul2Info *ghlInfo, surfaceInfo_v &slist, const char *sur model_t *mod = (model_t *)ghlInfo->currentModel; int surfIndex = -1; mdxmSurface_t *surf = 0; - mdxmHeader_t *mdxm = mod->data.glm; + mdxmHeader_t *mdxm = mod->data.glm->header; // did we find a ghoul 2 model or not? if (!mdxm) @@ -257,7 +257,7 @@ void G2_FindRecursiveSurface(model_t *currentModel, int surfaceNum, surfaceInfo_ { int i; mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -332,7 +332,7 @@ qboolean G2_SetRootSurface(CGhoul2Info_v &ghoul2, const int modelIndex, const ch model_t *mod_m = (model_t *)ghoul2[modelIndex].currentModel; model_t *mod_a = (model_t *)ghoul2[modelIndex].animModel; - mdxmHeader_t *mdxm = mod_m->data.glm; + mdxmHeader_t *mdxm = mod_m->data.glm->header; mdxaHeader_t *mdxa = mod_a->data.gla; // did we find a ghoul 2 model or not? @@ -579,7 +579,7 @@ int G2_GetParentSurface(CGhoul2Info *ghlInfo, const int index) { model_t *mod = (model_t *)ghlInfo->currentModel; mdxmSurface_t *surf = 0; - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)mod->data.glm->header + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = 0; // walk each surface and see if this index is listed in it's children @@ -603,8 +603,8 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int flags = 0;//, surfFlags = 0; int surfIndex = 0; assert(ghlInfo->currentModel); - assert(ghlInfo->currentModel->data.glm); - if (!ghlInfo->currentModel->data.glm) + assert(ghlInfo->currentModel->data.glm && ghlInfo->currentModel->data.glm->header); + if (!ghlInfo->currentModel->data.glm || !ghlInfo->currentModel->data.glm->header) { return -1; } @@ -615,7 +615,7 @@ int G2_IsSurfaceRendered(CGhoul2Info *ghlInfo, const char *surfaceName, surfaceI int surfNum = G2_IsSurfaceLegal((model_t *)ghlInfo->currentModel, surfaceName, &flags); if ( surfNum != -1 ) {//must be legal - const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->data.glm + sizeof(mdxmHeader_t)); + const mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)ghlInfo->currentModel->data.glm->header + sizeof(mdxmHeader_t)); const mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surfNum]); surfNum = surfInfo->parentIndex; // walk the surface hierarchy up until we hit the root diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index afeb9eb6fb..d1fe6a3477 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2003,7 +2003,7 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh assert(ghoul2.aHeader); assert(ghoul2.currentModel); - assert(ghoul2.currentModel->data.glm); + assert(ghoul2.currentModel->data.glm && ghoul2.currentModel->data.glm->header); if (!aHeader->numBones) { assert(0); // this would be strange @@ -2388,10 +2388,10 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from #endif assert(RS.currentModel); - assert(RS.currentModel->data.glm); + assert(RS.currentModel->data.glm && RS.currentModel->data.glm->header); // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->data.glm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->data.glm->header + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2558,7 +2558,7 @@ void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, // back track and get the surfinfo struct for this surface mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm + sizeof(mdxmHeader_t)); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); // see if we have an override surface in the surface list @@ -2608,7 +2608,7 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) { int i, j; int offFlags = 0; - mdxmHeader_t *mdxm = CBL.currentModel->data.glm; + mdxmHeader_t *mdxm = CBL.currentModel->data.glm->header; // back track and get the surfinfo struct for this surface const mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)CBL.currentModel, CBL.surfaceNum, 0); @@ -2764,7 +2764,7 @@ static void G2_Sort_Models(CGhoul2Info_v &ghoul2, int * const modelList, int * c void *G2_FindSurface_BC(const model_s *mod, int index, int lod) { - mdxmHeader_t *mdxm = mod->data.glm; + mdxmHeader_t *mdxm = mod->data.glm->header; assert(mod); assert(mdxm); @@ -4148,7 +4148,9 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); - mod->data.glm = mdxm; + mod->data.glm = (mdxmData_t *)ri->Hunk_Alloc (sizeof (mdxmData_t), h_low); + mod->data.glm->header = mdxm; + //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); assert(bAlreadyCached == bAlreadyFound); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index a3cea1b026..5227ba72ff 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1649,6 +1649,7 @@ void stub_RE_SetLightStyle (int style, int color){} void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} +void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} /* @@@@@@@@@@@@@@@@@@@@@ @@ -1737,7 +1738,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.GetRealRes = GetRealRes; // R_AutomapElevationAdjustment re.InitializeWireframeAutomap = stub_InitializeWireframeAutomap; - // RE_AddWeatherZone; + re.AddWeatherZone = stub_RE_AddWeatherZone; re.WorldEffectCommand = stub_RE_WorldEffectCommand; // RE_InitRendererTerrain re.RegisterMedia_LevelLoadBegin = C_LevelLoadBegin; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index caa823e44c..bfd12674ca 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -466,7 +466,8 @@ typedef enum { GF_SAWTOOTH, GF_INVERSE_SAWTOOTH, - GF_NOISE + GF_NOISE, + GF_RAND } genFunc_t; @@ -1228,13 +1229,7 @@ typedef enum { SF_MD4, SF_MDR, SF_IQM, -/* -Ghoul2 Insert Start -*/ SF_MDX, -/* -Ghoul2 Insert End -*/ SF_FLARE, SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity SF_DISPLAY_LIST, @@ -1748,6 +1743,13 @@ Ghoul2 Insert End */ } modtype_t; +typedef struct mdxmData_s +{ + mdxmHeader_t *header; + + +} mdxmData_t; + typedef struct model_s { char name[MAX_QPATH]; modtype_t type; @@ -1756,13 +1758,13 @@ typedef struct model_s { int dataSize; // just for listing purposes union { - bmodel_t *bmodel; // only if type == MOD_BRUSH - mdvModel_t *mdv[MD3_MAX_LODS]; // only if type == MOD_MESH - md4Header_t *md4; // only if type == MOD_MD4 - mdrHeader_t *mdr; // only if type == MOD_MDR - iqmData_t *iqm; // only if type == MOD_IQM - mdxmHeader_t *glm; // only if type == MOD_MDXM - mdxaHeader_t *gla; // only if type == MOD_MDXA + bmodel_t *bmodel; // type == MOD_BRUSH + mdvModel_t *mdv[MD3_MAX_LODS]; // type == MOD_MESH + md4Header_t *md4; // type == MOD_MD4 + mdrHeader_t *mdr; // type == MOD_MDR + iqmData_t *iqm; // type == MOD_IQM + mdxmData_t *glm; // type == MOD_MDXM + mdxaHeader_t *gla; // type == MOD_MDXA } data; int numLods; From 8325f6cf11204401de0db4fbe6906d156efe6d0f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 14 Nov 2013 21:46:47 +0000 Subject: [PATCH 087/708] Fixed transparency and updated BSP code for RBSP Fixed objects which were transparent and being rendered even when occluded. Also updated some of the BSP code to use RBSP format properly. This includes things such as the lighting grid array. --- codemp/rd-rend2/tr_backend.cpp | 91 +++++++++++++++++++++------------- codemp/rd-rend2/tr_bsp.cpp | 63 ++++++++++++++++------- codemp/rd-rend2/tr_init.cpp | 32 ++++++++++-- codemp/rd-rend2/tr_light.cpp | 74 +++++++++++++++------------ codemp/rd-rend2/tr_local.h | 25 +++++++++- codemp/rd-rend2/tr_main.cpp | 10 ++++ codemp/rd-rend2/tr_shade.cpp | 52 ++++++++++++++++++- codemp/rd-rend2/tr_shader.cpp | 20 +++++--- 8 files changed, 272 insertions(+), 95 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index d46ae4ddbd..029168e05f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -563,7 +563,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { int dlighted, oldDlighted; int pshadowed, oldPshadowed; int cubemapIndex, oldCubemapIndex; - qboolean depthRange, oldDepthRange; + int depthRange, oldDepthRange; int i; drawSurf_t *drawSurf; int oldSort; @@ -584,7 +584,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.currentEntity = &tr.worldEntity; oldShader = NULL; oldFogNum = -1; - oldDepthRange = qfalse; + oldDepthRange = 0; oldDlighted = qfalse; oldPshadowed = qfalse; oldCubemapIndex = -1; @@ -634,7 +634,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // if ( entityNum != oldEntityNum ) { qboolean sunflare = qfalse; - depthRange = qfalse; + depthRange = 0; if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; @@ -651,10 +651,13 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); } - if(backEnd.currentEntity->e.renderfx & RF_DEPTHHACK) - { + if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { + // No depth at all, very rare but some things for seeing through walls + depthRange = 2; + } + else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { // hack the depth range to prevent view model from poking into walls - depthRange = qtrue; + depthRange = 1; } } else { backEnd.currentEntity = &tr.worldEntity; @@ -674,36 +677,56 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // if (oldDepthRange != depthRange) { - if (depthRange) - { - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) - { - viewParms_t temp = backEnd.viewParms; - - R_SetupProjection(&temp, r_znear->value, 0, qfalse); + switch ( depthRange ) { + default: + case 0: + if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + { + GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); + } - GL_SetProjectionMatrix( temp.projectionMatrix ); - } + if (!sunflare) + qglDepthRange (0, 1); - if(!oldDepthRange) - { depth[0] = 0; - depth[1] = 0.3f; - qglDepthRange (depth[0], depth[1]); - } - } - else - { - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) - { - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - } - - if (!sunflare) - qglDepthRange (0, 1); - - depth[0] = 0; - depth[1] = 1; + depth[1] = 1; + break; + + case 1: + if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + { + viewParms_t temp = backEnd.viewParms; + + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + + GL_SetProjectionMatrix( temp.projectionMatrix ); + } + + if(!oldDepthRange) + { + depth[0] = 0; + depth[1] = 0.3f; + qglDepthRange (depth[0], depth[1]); + } + break; + + case 2: + if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + { + viewParms_t temp = backEnd.viewParms; + + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + + GL_SetProjectionMatrix( temp.projectionMatrix ); + } + + if(!oldDepthRange) + { + depth[0] = 0.0f; + depth[1] = 0.0f; + qglDepthRange (depth[0], depth[1]); + } + break; } oldDepthRange = depthRange; @@ -734,7 +757,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); - qglDepthRange (0, 1); + //qglDepthRange (0, 1); } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a20edf269e..886487ca30 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2641,7 +2641,6 @@ R_LoadLightGrid void R_LoadLightGrid( lump_t *l ) { int i; vec3_t maxs; - int numGridPoints; world_t *w; float *wMins, *wMaxs; @@ -2660,21 +2659,23 @@ void R_LoadLightGrid( lump_t *l ) { w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1; } - numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; + int numGridDataElements = l->filelen / sizeof(*w->lightGridData); - if ( l->filelen != numGridPoints * 8 ) { - ri->Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" ); - w->lightGridData = NULL; - return; - } - - w->lightGridData = (byte *)ri->Hunk_Alloc( l->filelen, h_low ); + w->lightGridData = (mgrid_t *)ri->Hunk_Alloc( l->filelen, h_low ); Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits - for ( i = 0 ; i < numGridPoints ; i++ ) { - R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] ); - R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] ); + for ( i = 0 ; i < numGridDataElements ; i++ ) + { + for(int j = 0; j < MAXLIGHTMAPS; j++) + { + R_ColorShiftLightingBytes( + w->lightGridData[i].ambientLight[j], + w->lightGridData[i].ambientLight[j]); + R_ColorShiftLightingBytes( + w->lightGridData[i].directLight[j], + w->lightGridData[i].directLight[j]); + } } // load hdr lightgrid @@ -2695,14 +2696,14 @@ void R_LoadLightGrid( lump_t *l ) { //ri->Printf(PRINT_ALL, "found!\n"); - if (size != sizeof(float) * 6 * numGridPoints) + if (size != sizeof(float) * 6 * numGridDataElements) { - ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridPoints); + ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridDataElements); } w->hdrLightGrid = (float *)ri->Hunk_Alloc(size, h_low); - for (i = 0; i < numGridPoints ; i++) + for (i = 0; i < numGridDataElements ; i++) { w->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale; w->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale; @@ -2718,6 +2719,29 @@ void R_LoadLightGrid( lump_t *l ) { } } +/* +================ +R_LoadLightGridArray + +================ +*/ +void R_LoadLightGridArray( lump_t *l ) { + world_t *w; + + w = &s_worldData; + + w->numGridArrayElements = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; + + if ( (unsigned)l->filelen != w->numGridArrayElements * sizeof(*w->lightGridArray) ) { + Com_Printf (S_COLOR_YELLOW "WARNING: light grid array mismatch\n" ); + w->lightGridData = NULL; + return; + } + + w->lightGridArray = (unsigned short *)Hunk_Alloc( l->filelen, h_low ); + memcpy( w->lightGridArray, (void *)(fileBase + l->fileofs), l->filelen ); +} + /* ================ R_LoadEntities @@ -3580,11 +3604,10 @@ void RE_LoadWorldMap( const char *name ) { R_LoadSubmodels (&header->lumps[LUMP_MODELS]); R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); - - // determine vertex light directions - R_CalcVertexLightDirs(); + R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); // determine which parts of the map are in sunlight +#if 0 if (0) { world_t *w; @@ -3771,6 +3794,7 @@ void RE_LoadWorldMap( const char *name ) { Z_Free(primaryLightGrid); } +#endif // load cubemaps if (r_cubeMapping->integer) @@ -3800,6 +3824,9 @@ void RE_LoadWorldMap( const char *name ) { // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; + // determine vertex light directions + R_CalcVertexLightDirs(); + // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5227ba72ff..bff5098eb8 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1644,8 +1644,32 @@ qhandle_t stub_RegisterServerSkin( const char *name ) } qboolean stub_InitializeWireframeAutomap() { return qtrue; } -void stub_RE_GetLightStyle (int style, byte *color){} -void stub_RE_SetLightStyle (int style, int color){} + +void RE_GetLightStyle(int style, color4ub_t color) +{ + if (style >= MAX_LIGHT_STYLES) + { + Com_Error( ERR_FATAL, "RE_GetLightStyle: %d is out of range", (int)style ); + return; + } + + *(int *)color = *(int *)styleColors[style]; +} + +void RE_SetLightStyle(int style, int color) +{ + if (style >= MAX_LIGHT_STYLES) + { + Com_Error( ERR_FATAL, "RE_SetLightStyle: %d is out of range", (int)style ); + return; + } + + if (*(int*)styleColors[style] != color) + { + *(int *)styleColors[style] = color; + } +} + void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} @@ -1728,8 +1752,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.GetEntityToken = R_GetEntityToken; re.inPVS = R_inPVS; - re.GetLightStyle = stub_RE_GetLightStyle; - re.SetLightStyle = stub_RE_SetLightStyle; + re.GetLightStyle = RE_GetLightStyle; + re.SetLightStyle = RE_SetLightStyle; re.GetBModelVerts = stub_RE_GetBModelVerts; // SetRangedFog diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index eaaa5d23dd..76e40b3d3a 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -127,11 +127,11 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { vec3_t lightOrigin; int pos[3]; int i, j; - byte *gridData; float frac[3]; int gridStep[3]; vec3_t direction; float totalFactor; + unsigned short *startGridPos; if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { // seperate lightOrigins are needed so an object that is @@ -163,40 +163,45 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { assert( world->lightGridData ); // NULL with -nolight maps // trilerp the light value - gridStep[0] = 8; - gridStep[1] = 8 * world->lightGridBounds[0]; - gridStep[2] = 8 * world->lightGridBounds[0] * world->lightGridBounds[1]; - gridData = world->lightGridData + pos[0] * gridStep[0] - + pos[1] * gridStep[1] + pos[2] * gridStep[2]; + gridStep[0] = 1; + gridStep[1] = 1 * world->lightGridBounds[0]; + gridStep[2] = 1 * world->lightGridBounds[0] * world->lightGridBounds[1]; + startGridPos = tr.world->lightGridArray + (pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2]); totalFactor = 0; for ( i = 0 ; i < 8 ; i++ ) { float factor; - byte *data; + mgrid_t *data; + unsigned short *gridPos; int lat, lng; vec3_t normal; - qboolean ignore; + #if idppc float d0, d1, d2, d3, d4, d5; #endif + factor = 1.0; - data = gridData; - ignore = qfalse; + gridPos = startGridPos; + for ( j = 0 ; j < 3 ; j++ ) { if ( i & (1<= world->lightGridBounds[j] - 1) - { - ignore = qtrue; // ignore values outside lightgrid - } factor *= frac[j]; - data += gridStep[j]; + gridPos += gridStep[j]; } else { - factor *= (1.0f - frac[j]); + factor *= (1.0 - frac[j]); } } - if ( ignore ) + if (gridPos >= tr.world->lightGridArray + tr.world->numGridArrayElements) + {//we've gone off the array somehow continue; + } + + data = tr.world->lightGridData + *gridPos; + if ( data->styles[0] == LS_LSNONE ) + { + continue; // ignore samples in walls + } if (world->hdrLightGrid) { @@ -205,12 +210,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { continue; // ignore samples in walls } } - else - { - if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) { - continue; // ignore samples in walls - } - } + totalFactor += factor; #if idppc d0 = data[0]; d1 = data[1]; d2 = data[2]; @@ -239,17 +239,29 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { } else { - ent->ambientLight[0] += factor * data[0]; - ent->ambientLight[1] += factor * data[1]; - ent->ambientLight[2] += factor * data[2]; + for(j=0;jstyles[j] != LS_LSNONE) + { + const byte style= data->styles[j]; - ent->directedLight[0] += factor * data[3]; - ent->directedLight[1] += factor * data[4]; - ent->directedLight[2] += factor * data[5]; + ent->ambientLight[0] += factor * data->ambientLight[j][0] * styleColors[style][0] / 255.0f; + ent->ambientLight[1] += factor * data->ambientLight[j][1] * styleColors[style][1] / 255.0f; + ent->ambientLight[2] += factor * data->ambientLight[j][2] * styleColors[style][2] / 255.0f; + + ent->directedLight[0] += factor * data->directLight[j][0] * styleColors[style][0] / 255.0f; + ent->directedLight[1] += factor * data->directLight[j][1] * styleColors[style][1] / 255.0f; + ent->directedLight[2] += factor * data->directLight[j][2] * styleColors[style][2] / 255.0f; + } + else + { + break; + } + } } #endif - lat = data[7]; - lng = data[6]; + lat = data->latLong[1]; + lng = data->latLong[0]; lat *= (FUNCTABLE_SIZE/256); lng *= (FUNCTABLE_SIZE/256); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bfd12674ca..ed855e90ec 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -438,6 +438,12 @@ typedef enum { // in addition to alpha test SS_BANNER, + SS_INSIDE, // inside body parts (i.e. heart) + SS_MID_INSIDE, + SS_MIDDLE, + SS_MID_OUTSIDE, + SS_OUTSIDE, // outside body parts (i.e. ribs) + SS_FOG, SS_UNDERWATER, // for items that should be drawn in front of the water plane @@ -1589,6 +1595,15 @@ typedef struct { int numSurfaces; } bmodel_t; +typedef struct +{ + byte ambientLight[MAXLIGHTMAPS][3]; + byte directLight[MAXLIGHTMAPS][3]; + byte styles[MAXLIGHTMAPS]; + byte latLong[2]; +// byte pad[2]; // to align to a cache line +} mgrid_t; + typedef struct { char name[MAX_QPATH]; // ie: maps/tim_dm2.bsp char baseName[MAX_QPATH]; // ie: tim_dm2 @@ -1633,8 +1648,15 @@ typedef struct { vec3_t lightGridSize; vec3_t lightGridInverseSize; int lightGridBounds[3]; - byte *lightGridData; float *hdrLightGrid; + int lightGridOffsets[8]; + + vec3_t lightGridStep; + + mgrid_t *lightGridData; + word *lightGridArray; + int numGridArrayElements; + int numClusters; @@ -2571,6 +2593,7 @@ typedef struct shaderCommands_s } shaderCommands_t; extern shaderCommands_t tess; +extern color4ub_t styleColors[MAX_LIGHT_STYLES]; void RB_BeginSurface(shader_t *shader, int fogNum, int cubemapIndex ); void RB_EndSurface(void); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 90d568e8ba..e9c9b42542 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1853,6 +1853,16 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int cubemap) { int index; + if (tr.refdef.rdflags & RDF_NOFOG) + { + fogIndex = 0; + } + + if ( (shader->surfaceFlags & SURF_FORCESIGHT) /*&& !(tr.refdef.rdflags & RDF_ForceSightOn)*/ ) + { //if shader is only seen with ForceSight and we don't have ForceSight on, then don't draw + return; + } + // instead of checking for overflow, we just mask the index // so it wraps around index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index e60c096d29..9a952d1214 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -33,6 +33,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA This file deals with applying shaders to surface data in the tess struct. */ +color4ub_t styleColors[MAX_LIGHT_STYLES]; + /* ================== @@ -1018,6 +1020,18 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) return vertexAttribs; } +static void ForceAlpha (unsigned char *dstColors, int forceEntAlpha) +{ + int i; + + dstColors += 3; + + for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) + { + *dstColors = forceEntAlpha; + } +} + static void RB_IterateStagesGeneric( shaderCommands_t *input ) { int stage; @@ -1038,6 +1052,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) shaderProgram_t *sp; vec4_t texMatrix; vec4_t texOffTurb; + int stateBits; + int forceRGBGen = 0; if ( !pStage ) { @@ -1140,7 +1156,23 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); } - GL_State( pStage->stateBits ); + stateBits = pStage->stateBits; + + if ( backEnd.currentEntity ) + { + assert(backEnd.currentEntity->e.renderfx >= 0); + + if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) + { + // we want to be able to rip a hole in the thing being disintegrated, and by doing the depth-testing it avoids some kinds of artefacts, but will probably introduce others? + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE | GLS_ATEST_GE_C0; + } + + if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) + {//want to use RGBGen from ent + forceRGBGen = CGEN_ENTITY; + } + } { vec4_t baseColor; @@ -1340,6 +1372,24 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + if (backEnd.currentEntity && (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA)) + { + ForceAlpha((unsigned char *) tess.svars.colors, backEnd.currentEntity->e.shaderRGBA[3]); + if (backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH) + { //depth write, so faces through the model will be stomped over by nearer ones. this works because + //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. + GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE); + } + else + { + GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } + } + else + { + GL_State( stateBits ); + } + // // draw // diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 36bf198677..8f0b9b2746 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1582,15 +1582,15 @@ void ParseSort( const char **text ) { } else if ( !Q_stricmp( token, "underwater" ) ) { shader.sort = SS_UNDERWATER; } else if ( !Q_stricmp( token, "inside" ) ) { - //shader.sort = SS_INSIDE; + shader.sort = SS_INSIDE; } else if ( !Q_stricmp( token, "mid_inside" ) ) { - //shader.sort = SS_MID_INSIDE; + shader.sort = SS_MID_INSIDE; } else if ( !Q_stricmp( token, "middle" ) ) { - //shader.sort = SS_MIDDLE; + shader.sort = SS_MIDDLE; } else if ( !Q_stricmp( token, "mid_outside" ) ) { - //shader.sort = SS_MID_OUTSIDE; + shader.sort = SS_MID_OUTSIDE; } else if ( !Q_stricmp( token, "outside" ) ) { - //shader.sort = SS_OUTSIDE; + shader.sort = SS_OUTSIDE; } else { shader.sort = atof( token ); @@ -3122,7 +3122,15 @@ static shader_t *FinishShader( void ) { if ( pStage->stateBits & GLS_DEPTHMASK_TRUE ) { shader.sort = SS_SEE_THROUGH; } else { - shader.sort = SS_BLEND0; + if (( blendSrcBits == GLS_SRCBLEND_ONE ) && ( blendDstBits == GLS_DSTBLEND_ONE )) + { + // GL_ONE GL_ONE needs to come a bit later + shader.sort = SS_BLEND1; + } + else + { + shader.sort = SS_BLEND0; + } } } } From ccfe435fb1b2c769f048165618119e57de68659d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 20 Nov 2013 08:05:07 +0000 Subject: [PATCH 088/708] Initial implementation of Ghoul2 GPU rendering --- codemp/rd-rend2/glsl_shaders.cpp | 66 +++++- codemp/rd-rend2/tr_ghoul2.cpp | 372 ++++++++++++++++++++++++++++++- codemp/rd-rend2/tr_glsl.cpp | 289 ++++++++++++++++-------- codemp/rd-rend2/tr_local.h | 57 ++++- codemp/rd-rend2/tr_main.cpp | 15 +- codemp/rd-rend2/tr_shade.cpp | 29 +++ codemp/rd-rend2/tr_surface.cpp | 6 - codemp/rd-rend2/tr_vbo.cpp | 1 + 8 files changed, 704 insertions(+), 131 deletions(-) diff --git a/codemp/rd-rend2/glsl_shaders.cpp b/codemp/rd-rend2/glsl_shaders.cpp index 864405ee1a..e633ae7276 100644 --- a/codemp/rd-rend2/glsl_shaders.cpp +++ b/codemp/rd-rend2/glsl_shaders.cpp @@ -408,10 +408,13 @@ const char *fallbackShader_fogpass_vp = "attribute vec3 attr_Normal;\n" "attribute vec4 attr_TexCoord0;\n" "\n" -"//#if defined(USE_VERTEX_ANIMATION)\n" +"#if defined(USE_VERTEX_ANIMATION)\n" "attribute vec4 attr_Position2;\n" "attribute vec3 attr_Normal2;\n" -"//#endif\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"attribute vec4 attr_BoneIndexes;\n" +"attribute vec4 attr_BoneWeights;\n" +"#endif\n" "\n" "uniform vec4 u_FogDistance;\n" "uniform vec4 u_FogDepth;\n" @@ -425,9 +428,11 @@ const char *fallbackShader_fogpass_vp = "uniform float u_Time;\n" "uniform mat4 u_ModelViewProjectionMatrix;\n" "\n" -"//#if defined(USE_VERTEX_ANIMATION)\n" +"#if defined(USE_VERTEX_ANIMATION)\n" "uniform float u_VertexLerp;\n" -"//#endif\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"uniform mat4 u_BoneMatrices[80];\n" +"#endif\n" "\n" "varying float var_Scale;\n" "\n" @@ -505,6 +510,17 @@ const char *fallbackShader_fogpass_vp = "#if defined(USE_VERTEX_ANIMATION)\n" "\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" "\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"\tvec4 position = vec4(0.0);\n" +"\tvec4 normal4 = vec4(0.0);\n" +"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" +"\tfor (int i = 0; i < 4; i++) {\n" +"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" +"\n" +"\t\tposition += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i];\n" +"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" +"\t}\n" +"\tvec3 normal = normal4.xyz;\n" "#else\n" "\tvec4 position = attr_Position;\n" "\tvec3 normal = attr_Normal;\n" @@ -571,6 +587,9 @@ const char *fallbackShader_generic_vp = "#if defined(USE_VERTEX_ANIMATION)\n" "attribute vec4 attr_Position2;\n" "attribute vec3 attr_Normal2;\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"attribute vec4 attr_BoneIndexes;\n" +"attribute vec4 attr_BoneWeights;\n" "#endif\n" "\n" "attribute vec4 attr_Color;\n" @@ -621,6 +640,8 @@ const char *fallbackShader_generic_vp = "\n" "#if defined(USE_VERTEX_ANIMATION)\n" "uniform float u_VertexLerp;\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"uniform mat4 u_BoneMatrices[80];\n" "#endif\n" "\n" "varying vec2 var_DiffuseTex;\n" @@ -771,6 +792,17 @@ const char *fallbackShader_generic_vp = "#if defined(USE_VERTEX_ANIMATION)\n" "\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" "\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"\tvec4 position = vec4(0.0);\n" +"\tvec4 normal4 = vec4(0.0);\n" +"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" +"\tfor (int i = 0; i < 4; i++) {\n" +"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" +"\n" +"\t\tposition += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i];\n" +"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" +"\t}\n" +"\tvec3 normal = normal4.xyz;\n" "#else\n" "\tvec4 position = attr_Position;\n" "\tvec3 normal = attr_Normal;\n" @@ -1344,6 +1376,9 @@ const char *fallbackShader_lightall_vp = "attribute vec3 attr_Normal2;\n" "attribute vec3 attr_Tangent2;\n" "attribute vec3 attr_Bitangent2;\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"attribute vec4 attr_BoneIndexes;\n" +"attribute vec4 attr_BoneWeights;\n" "#endif\n" "\n" "#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR)\n" @@ -1376,6 +1411,8 @@ const char *fallbackShader_lightall_vp = "\n" "#if defined(USE_VERTEX_ANIMATION)\n" "uniform float u_VertexLerp;\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"uniform mat4 u_BoneMatrices[80];\n" "#endif\n" "\n" "#if defined(USE_LIGHT_VECTOR)\n" @@ -1484,6 +1521,27 @@ const char *fallbackShader_lightall_vp = "\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" "\tvec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp));\n" "\tvec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp));\n" +"#elif defined(USE_SKELETAL_ANIMATION)\n" +"\tvec4 position4 = vec4(0.0);\n" +"\tvec4 normal4 = vec4(0.0);\n" +"\tvec4 tangent4 = vec4(0.0);\n" +"\tvec4 bitangent4 = vec4(0.0);\n" +"\tvec4 originalPosition = vec4(attr_Position, 1.0);\n" +"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" +"\tvec4 originalTangent = vec4(attr_Tangent, 0.0);\n" +"\tvec4 originalBitangent = vec4(attr_Bitangent, 0.0);\n" +"\tfor (int i = 0; i < 4; i++) {\n" +"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" +"\n" +"\t\tposition4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i];\n" +"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" +"\t\ttangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i];\n" +"\t\tbitangent4 += (u_BoneMatrices[boneIndex] * originalBitangent) * attr_BoneWeights[i];\n" +"\t}\n" +"\tvec3 position = position4.xyz;\n" +"\tvec3 normal = normal4.xyz;\n" +"\tvec3 tangent = tangent4.xyz;\n" +"\tvec3 bitangent = bitangent4.xyz;\n" "#else\n" "\tvec3 position = attr_Position;\n" "\tvec3 normal = attr_Normal;\n" diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index d1fe6a3477..8b935d8fe5 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -740,11 +740,11 @@ class CRenderSurface #ifdef _G2_GORE boltInfo_v &initboltList, shader_t *initgore_shader, - CGoreSet *initgore_set): + CGoreSet *initgore_set #else - boltInfo_v &initboltList): + boltInfo_v &initboltList #endif - + ): surfaceNum(initsurfaceNum), rootSList(initrootSList), cust_shader(initcust_shader), @@ -2408,7 +2408,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from // if this surface is not off, add it to the shader render list if (!offFlags) - { + { if ( RS.cust_shader ) { shader = RS.cust_shader; @@ -2438,8 +2438,11 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from if ( !RS.personalModel ) { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out CRenderableSurface *newSurf = new CRenderableSurface; + newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; + assert (newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; + R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, qfalse, 0 ); #ifdef _G2_GORE @@ -3151,6 +3154,7 @@ static inline bool bInShadowRange(vec3_t location) R_AddGHOULSurfaces ============== */ + void R_AddGhoulSurfaces( trRefEntity_t *ent ) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_R_AddGHOULSurfaces.Start(); @@ -3283,14 +3287,37 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent ) { } } - CRenderSurface RS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, cust_shader, fogNum, personalModel, ghoul2[i].mBoneCache, ent->e.renderfx, skin, (model_t *)ghoul2[i].currentModel, whichLod, ghoul2[i].mBltlist, gore_shader, gore); + CRenderSurface RS (ghoul2[i].mSurfaceRoot, + ghoul2[i].mSlist, + cust_shader, + fogNum, + personalModel, + ghoul2[i].mBoneCache, + ent->e.renderfx, + skin, + (model_t *)ghoul2[i].currentModel, + whichLod, + ghoul2[i].mBltlist, + gore_shader, + gore); #else - CRenderSurface RS(ghoul2[i].mSurfaceRoot, ghoul2[i].mSlist, cust_shader, fogNum, personalModel, ghoul2[i].mBoneCache, ent->e.renderfx, skin, (model_t *)ghoul2[i].currentModel, whichLod, ghoul2[i].mBltlist); + CRenderSurface RS(ghoul2[i].mSurfaceRoot, + ghoul2[i].mSlist, + cust_shader, + fogNum, + personalModel, + ghoul2[i].mBoneCache, + ent->e.renderfx, + skin, + (model_t *)ghoul2[i].currentModel, + whichLod, + ghoul2[i].mBltlist); #endif if (!personalModel && (RS.renderfx & RF_SHADOW_PLANE) && !bInShadowRange(ent->e.origin)) { RS.renderfx |= RF_NOSHADOW; } + RenderSurfaces(RS); } } @@ -3400,10 +3427,99 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } +static void MDXABoneToMatrix ( const mdxaBone_t& bone, matrix_t& matrix ) +{ + matrix[0] = bone.matrix[0][0]; + matrix[1] = bone.matrix[1][0]; + matrix[2] = bone.matrix[2][0]; + matrix[3] = 0.0f; + + matrix[4] = bone.matrix[0][1]; + matrix[5] = bone.matrix[1][1]; + matrix[6] = bone.matrix[2][1]; + matrix[7] = 0.0f; + + matrix[8] = bone.matrix[0][2]; + matrix[9] = bone.matrix[1][2]; + matrix[10] = bone.matrix[2][2]; + matrix[11] = 0.0f; + + matrix[12] = bone.matrix[0][3]; + matrix[13] = bone.matrix[1][3]; + matrix[14] = bone.matrix[2][3]; + matrix[15] = 1.0f; +} + +void myGlMultMatrix( const float *a, const float *b, float *out ); +void R_MDXMRotateForEntity( const matrix_t *xform, const viewParms_t *viewParms, + orientationr_t *ori ) { +// float glMatrix[16]; + vec3_t delta; + float axisLength; + + + myGlMultMatrix( (float *)xform, viewParms->world.modelMatrix, ori->modelMatrix ); + + // calculate the viewer origin in the model's space + // needed for fog, specular, and environment mapping + VectorSubtract( viewParms->or.origin, ori->origin, delta ); + + // compensate for scale in the axes if necessary + /*if ( ent->e.nonNormalizedAxes ) { + axisLength = VectorLength( ent->e.axis[0] ); + if ( !axisLength ) { + axisLength = 0; + } else { + axisLength = 1.0f / axisLength; + } + } else */{ + axisLength = 1.0f; + } + + ori->viewOrigin[0] = DotProduct( delta, ori->axis[0] ) * axisLength; + ori->viewOrigin[1] = DotProduct( delta, ori->axis[1] ) * axisLength; + ori->viewOrigin[2] = DotProduct( delta, ori->axis[2] ) * axisLength; +} + //This is a slightly mangled version of the same function from the sof2sp base. //It provides a pretty significant performance increase over the existing one. void RB_SurfaceGhoul( CRenderableSurface *surf ) { +#if 1 + static matrix_t boneMatrices[80] = {}; + + mdxmVBOMesh_t *surface = surf->vboMesh; + + if(!surface->vbo || !surface->ibo) + return; + + RB_EndSurface(); + RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); + + R_BindVBO(surface->vbo); + R_BindIBO(surface->ibo); + + tess.useInternalVBO = qfalse; + + tess.numIndexes += surface->numIndexes; + tess.numVertexes += surface->numVertexes; + tess.minIndex = surface->minIndex; + tess.maxIndex = surface->maxIndex; + + for ( int i = 0; i < surf->boneCache->mFinalBones.size(); i++ ) + { + const mdxaBone_t& bone = surf->boneCache->EvalRender (i); + MDXABoneToMatrix (bone, boneMatrices[i]); + } + + glState.boneMatrices = boneMatrices; + glState.skeletalAnimation = qtrue; + + RB_EndSurface(); + + // So we don't lerp surfaces that shouldn't be lerped + glState.skeletalAnimation = qfalse; +#else #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_RB_SurfaceGhoul.Start(); #endif @@ -3751,6 +3867,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) #ifdef G2_PERFORMANCE_ANALYSIS G2Time_RB_SurfaceGhoul += G2PerformanceTimer_RB_SurfaceGhoul.End(); #endif +#endif } /* @@ -4232,7 +4349,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); // find the next surface - surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + (size_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surfInfo->numChildren ] )); + surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + offsetof (mdxmSurfHierarchy_t, childIndexes[surfInfo->numChildren]) ); } // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) @@ -4321,7 +4438,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean int *boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); for ( j = 0 ; j < surf->numBoneReferences ; j++ ) { - assert(boneRef[j] >= 0 && boneRef[j] < 72); if (boneRef[j] >= 0 && boneRef[j] < 72) { boneRef[j]=OldToNewRemapTable[boneRef[j]]; @@ -4340,9 +4456,245 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean } // Make a copy on the GPU - for ( l = 0; i < mdxm->numLODs; l++ ) + lod = (mdxmLOD_t *)((byte *)mdxm + mdxm->ofsLODs); + + mod->data.glm->vboModels = (mdxmVBOModel_t *)ri->Hunk_Alloc (sizeof (mdxmVBOModel_t) * mdxm->numLODs, h_low); + for ( l = 0; l < mdxm->numLODs; l++ ) { - + mdxmVBOModel_t *vboModel = &mod->data.glm->vboModels[l]; + mdxmVBOMesh_t *vboMeshes; + + vec3_t *verts; + vec3_t *normals; + vec2_t *texcoords; + vec4_t *bonerefs; + vec4_t *weights; +#ifdef USE_VERT_TANGENT_SPACE + vec3_t *tangents; + vec3_t *bitangents; +#endif + + byte *data; + int dataSize = 0; + int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights; +#ifdef USE_VERT_TANGENT_SPACE + int ofs_tangent, ofs_bitangent; +#endif + int stride = 0; + int numVerts = 0; + int numTriangles = 0; + + // +1 to add total vertex count + int *baseVertexes = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); + int *indexOffsets = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * mdxm->numSurfaces); + + vboModel->numVBOMeshes = mdxm->numSurfaces; + vboModel->vboMeshes = (mdxmVBOMesh_t *)ri->Hunk_Alloc (sizeof (mdxmVBOMesh_t) * mdxm->numSurfaces, h_low); + vboMeshes = vboModel->vboMeshes; + + surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); + + // Calculate the required size of the vertex buffer. + for ( int n = 0; n < mdxm->numSurfaces; n++ ) + { + baseVertexes[n] = numVerts; + indexOffsets[n] = numTriangles * 3; + + numVerts += surf->numVerts; + numTriangles += surf->numTriangles; + + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); + } + + baseVertexes[mdxm->numSurfaces] = numVerts; + + dataSize += numVerts * sizeof (*verts); + dataSize += numVerts * sizeof (*normals); + dataSize += numVerts * sizeof (*texcoords); + dataSize += numVerts * sizeof (*weights); + dataSize += numVerts * sizeof (*bonerefs); +#ifdef USE_VERT_TANGENT_SPACE + dataSize += numVerts * sizeof (*tangents); + dataSize += numVerts * sizeof (*bitangents); +#endif + + // Allocate and write to memory + data = (byte *)ri->Hunk_AllocateTempMemory (dataSize); + + verts = (vec3_t *)(data + stride); + ofsPosition = stride; + stride += sizeof (*verts); + + normals = (vec3_t *)(data + stride); + ofsNormals = stride; + stride += sizeof (*normals); + + texcoords = (vec2_t *)(data + stride); + ofsTexcoords = stride; + stride += sizeof (*texcoords); + + bonerefs = (vec4_t *)(data + stride); + ofsBoneRefs = stride; + stride += sizeof (*bonerefs); + + weights = (vec4_t *)(data + stride); + ofsWeights = stride; + stride += sizeof (*weights); + +#ifdef USE_VERT_TANGENT_SPACE + tangents = (vec3_t *)(data + stride); + ofs_tangent = stride; + stride += sizeof (*tangents); + + bitangents = (vec3_t *)(data + stride); + ofs_bitangent = stride; + stride += sizeof (*bitangents); +#endif + + surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); + + for ( int n = 0; n < mdxm->numSurfaces; n++ ) + { + // Positions and normals + mdxmVertex_t *v = (mdxmVertex_t *)((byte *)surf + surf->ofsVerts); + for ( int k = 0; k < surf->numVerts; k++ ) + { + VectorCopy (v[k].vertCoords, *verts); + VectorCopy (v[k].normal, *normals); +#ifdef USE_VERT_TANGENT_SPACE + VectorCopy (v[k].normal, *tangents); + VectorCopy (v[k].normal, *bitangents); +#endif + + verts = (vec3_t *)((byte *)verts + stride); + normals = (vec3_t *)((byte *)normals + stride); +#ifdef USE_VERT_TANGENT_SPACE + tangents = (vec3_t *)((byte *)tangents + stride); + bitangents = (vec3_t *)((byte *)bitangents + stride); +#endif + } + + // Weights + int *boneRefs = (int *)((byte *)surf + surf->ofsBoneReferences); + for ( int k = 0; k < surf->numVerts; k++ ) + { + int numWeights = G2_GetVertWeights (&v[k]); + for ( int w = 0; w < numWeights; w++ ) + { + (*weights)[w] = G2_GetVertBoneWeightNotSlow (&v[k], w); + (*bonerefs)[w] = (float)boneRefs[G2_GetVertBoneIndex (&v[k], w)]; + } + + // Fill in the rest of the info with zeroes. + for ( int w = numWeights; w < 4; w++ ) + { + (*weights)[w] = 0.0f; + (*bonerefs)[w] = 0.0f; + } + + weights = (vec4_t *)((byte *)weights + stride); + bonerefs = (vec4_t *)((byte *)bonerefs + stride); + } + + // Texture coordinates + mdxmVertexTexCoord_t *tc = (mdxmVertexTexCoord_t *)(v + surf->numVerts); + for ( int k = 0; k < surf->numVerts; k++ ) + { + (*texcoords)[0] = tc[k].texCoords[0]; + (*texcoords)[1] = tc[k].texCoords[1]; + + texcoords = (vec2_t *)((byte *)texcoords + stride); + } + + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); + } + + assert ((byte *)verts == (data + dataSize)); + + const char *modelName = strrchr (mdxm->name, '/'); + if (modelName == NULL) + { + modelName = mdxm->name; + } + + VBO_t *vbo = R_CreateVBO (va ("MDXM VBO LOD %d '%s'", l, modelName), data, dataSize, VBO_USAGE_STATIC); + + ri->Hunk_FreeTempMemory (data); + + vbo->ofs_xyz = ofsPosition; + vbo->ofs_normal = ofsNormals; + vbo->ofs_st = ofsTexcoords; + vbo->ofs_boneindexes = ofsBoneRefs; + vbo->ofs_boneweights = ofsWeights; +#ifdef USE_VERT_TANGENT_SPACE + vbo->ofs_tangent = ofs_tangent; + vbo->ofs_bitangent = ofs_bitangent; +#endif + + vbo->stride_xyz = stride; + vbo->stride_normal = stride; + vbo->stride_st = stride; + vbo->stride_boneindexes = stride; + vbo->stride_boneweights = stride; +#ifdef USE_VERT_TANGENT_SPACE + vbo->stride_tangent = stride; + vbo->stride_bitangent = stride; +#endif + + // Fill in the index buffer + srfTriangle_t *triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory (sizeof (srfTriangle_t) * numTriangles); + srfTriangle_t *triangle = triangles; + + surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); + + for ( int n = 0; n < mdxm->numSurfaces; n++ ) + { + mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); + + for ( int k = 0; k < surf->numTriangles; k++, triangle++ ) + { + triangle->indexes[0] = t[k].indexes[0] + baseVertexes[n]; + assert (triangle->indexes[0] >= 0 && triangle->indexes[0] < numVerts); + + triangle->indexes[1] = t[k].indexes[1] + baseVertexes[n]; + assert (triangle->indexes[1] >= 0 && triangle->indexes[1] < numVerts); + + triangle->indexes[2] = t[k].indexes[2] + baseVertexes[n]; + assert (triangle->indexes[2] >= 0 && triangle->indexes[2] < numVerts); + } + + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); + } + + assert (triangle == (triangles + numTriangles)); + + IBO_t *ibo = R_CreateIBO2 (va ("MDXM IBO LOD %d '%s'", l, modelName), numTriangles, triangles, VBO_USAGE_STATIC); + + ri->Hunk_FreeTempMemory (triangles); + + surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); + + for ( int n = 0; n < mdxm->numSurfaces; n++ ) + { + vboMeshes[n].vbo = vbo; + vboMeshes[n].ibo = ibo; + + vboMeshes[n].indexOffset = 0;//indexOffsets[n]; + vboMeshes[n].minIndex = 0;//baseVertexes[n]; + vboMeshes[n].maxIndex = numVerts;//baseVertexes[n + 1]; + vboMeshes[n].numVertexes = numVerts;//surf->numVerts; + vboMeshes[n].numIndexes = numTriangles * 3;//surf->numTriangles * 3; + + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); + } + + vboModel->vbo = vbo; + vboModel->ibo = ibo; + + ri->Hunk_FreeTempMemory (indexOffsets); + ri->Hunk_FreeTempMemory (baseVertexes); + + lod = (mdxmLOD_t *)((byte *)lod + lod->ofsEnd); } return qtrue; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ac0929013e..5088084d5e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -57,89 +57,92 @@ typedef struct uniformInfo_s { char *name; int type; + int size; } uniformInfo_t; // These must be in the same order as in uniform_t in tr_local.h. static uniformInfo_t uniformsInfo[] = { - { "u_DiffuseMap", GLSL_INT }, - { "u_LightMap", GLSL_INT }, - { "u_NormalMap", GLSL_INT }, - { "u_DeluxeMap", GLSL_INT }, - { "u_SpecularMap", GLSL_INT }, - - { "u_TextureMap", GLSL_INT }, - { "u_LevelsMap", GLSL_INT }, - { "u_CubeMap", GLSL_INT }, - - { "u_ScreenImageMap", GLSL_INT }, - { "u_ScreenDepthMap", GLSL_INT }, - - { "u_ShadowMap", GLSL_INT }, - { "u_ShadowMap2", GLSL_INT }, - { "u_ShadowMap3", GLSL_INT }, - - { "u_ShadowMvp", GLSL_MAT16 }, - { "u_ShadowMvp2", GLSL_MAT16 }, - { "u_ShadowMvp3", GLSL_MAT16 }, - - { "u_DiffuseTexMatrix", GLSL_VEC4 }, - { "u_DiffuseTexOffTurb", GLSL_VEC4 }, - { "u_Texture1Env", GLSL_INT }, - - { "u_TCGen0", GLSL_INT }, - { "u_TCGen0Vector0", GLSL_VEC3 }, - { "u_TCGen0Vector1", GLSL_VEC3 }, - - { "u_DeformGen", GLSL_INT }, - { "u_DeformParams", GLSL_FLOAT5 }, - - { "u_ColorGen", GLSL_INT }, - { "u_AlphaGen", GLSL_INT }, - { "u_Color", GLSL_VEC4 }, - { "u_BaseColor", GLSL_VEC4 }, - { "u_VertColor", GLSL_VEC4 }, - - { "u_DlightInfo", GLSL_VEC4 }, - { "u_LightForward", GLSL_VEC3 }, - { "u_LightUp", GLSL_VEC3 }, - { "u_LightRight", GLSL_VEC3 }, - { "u_LightOrigin", GLSL_VEC4 }, - { "u_ModelLightDir", GLSL_VEC3 }, - { "u_LightRadius", GLSL_FLOAT }, - { "u_AmbientLight", GLSL_VEC3 }, - { "u_DirectedLight", GLSL_VEC3 }, - - { "u_PortalRange", GLSL_FLOAT }, - - { "u_FogDistance", GLSL_VEC4 }, - { "u_FogDepth", GLSL_VEC4 }, - { "u_FogEyeT", GLSL_FLOAT }, - { "u_FogColorMask", GLSL_VEC4 }, - - { "u_ModelMatrix", GLSL_MAT16 }, - { "u_ModelViewProjectionMatrix", GLSL_MAT16 }, - - { "u_Time", GLSL_FLOAT }, - { "u_VertexLerp" , GLSL_FLOAT }, - { "u_MaterialInfo", GLSL_VEC2 }, - - { "u_ViewInfo", GLSL_VEC4 }, - { "u_ViewOrigin", GLSL_VEC3 }, - { "u_LocalViewOrigin", GLSL_VEC3 }, - { "u_ViewForward", GLSL_VEC3 }, - { "u_ViewLeft", GLSL_VEC3 }, - { "u_ViewUp", GLSL_VEC3 }, - - { "u_InvTexRes", GLSL_VEC2 }, - { "u_AutoExposureMinMax", GLSL_VEC2 }, - { "u_ToneMinAvgMaxLinear", GLSL_VEC3 }, - - { "u_PrimaryLightOrigin", GLSL_VEC4 }, - { "u_PrimaryLightColor", GLSL_VEC3 }, - { "u_PrimaryLightAmbient", GLSL_VEC3 }, - { "u_PrimaryLightRadius", GLSL_FLOAT } + { "u_DiffuseMap", GLSL_INT, 1 }, + { "u_LightMap", GLSL_INT, 1 }, + { "u_NormalMap", GLSL_INT, 1 }, + { "u_DeluxeMap", GLSL_INT, 1 }, + { "u_SpecularMap", GLSL_INT, 1 }, + + { "u_TextureMap", GLSL_INT, 1 }, + { "u_LevelsMap", GLSL_INT, 1 }, + { "u_CubeMap", GLSL_INT, 1 }, + + { "u_ScreenImageMap", GLSL_INT, 1 }, + { "u_ScreenDepthMap", GLSL_INT, 1 }, + + { "u_ShadowMap", GLSL_INT, 1 }, + { "u_ShadowMap2", GLSL_INT, 1 }, + { "u_ShadowMap3", GLSL_INT, 1 }, + + { "u_ShadowMvp", GLSL_MAT16, 1 }, + { "u_ShadowMvp2", GLSL_MAT16, 1 }, + { "u_ShadowMvp3", GLSL_MAT16, 1 }, + + { "u_DiffuseTexMatrix", GLSL_VEC4, 1 }, + { "u_DiffuseTexOffTurb", GLSL_VEC4, 1 }, + { "u_Texture1Env", GLSL_INT, 1 }, + + { "u_TCGen0", GLSL_INT, 1 }, + { "u_TCGen0Vector0", GLSL_VEC3, 1 }, + { "u_TCGen0Vector1", GLSL_VEC3, 1 }, + + { "u_DeformGen", GLSL_INT, 1 }, + { "u_DeformParams", GLSL_FLOAT5, 1 }, + + { "u_ColorGen", GLSL_INT, 1 }, + { "u_AlphaGen", GLSL_INT, 1 }, + { "u_Color", GLSL_VEC4, 1 }, + { "u_BaseColor", GLSL_VEC4, 1 }, + { "u_VertColor", GLSL_VEC4, 1 }, + + { "u_DlightInfo", GLSL_VEC4, 1 }, + { "u_LightForward", GLSL_VEC3, 1 }, + { "u_LightUp", GLSL_VEC3, 1 }, + { "u_LightRight", GLSL_VEC3, 1 }, + { "u_LightOrigin", GLSL_VEC4, 1 }, + { "u_ModelLightDir", GLSL_VEC3, 1 }, + { "u_LightRadius", GLSL_FLOAT, 1 }, + { "u_AmbientLight", GLSL_VEC3, 1 }, + { "u_DirectedLight", GLSL_VEC3, 1 }, + + { "u_PortalRange", GLSL_FLOAT, 1 }, + + { "u_FogDistance", GLSL_VEC4, 1 }, + { "u_FogDepth", GLSL_VEC4, 1 }, + { "u_FogEyeT", GLSL_FLOAT, 1 }, + { "u_FogColorMask", GLSL_VEC4, 1 }, + + { "u_ModelMatrix", GLSL_MAT16, 1 }, + { "u_ModelViewProjectionMatrix", GLSL_MAT16, 1 }, + + { "u_Time", GLSL_FLOAT, 1 }, + { "u_VertexLerp" , GLSL_FLOAT, 1 }, + { "u_MaterialInfo", GLSL_VEC2, 1 }, + + { "u_ViewInfo", GLSL_VEC4, 1 }, + { "u_ViewOrigin", GLSL_VEC3, 1 }, + { "u_LocalViewOrigin", GLSL_VEC3, 1 }, + { "u_ViewForward", GLSL_VEC3, 1 }, + { "u_ViewLeft", GLSL_VEC3, 1 }, + { "u_ViewUp", GLSL_VEC3, 1 }, + + { "u_InvTexRes", GLSL_VEC2, 1 }, + { "u_AutoExposureMinMax", GLSL_VEC2, 1 }, + { "u_ToneMinAvgMaxLinear", GLSL_VEC3, 1 }, + + { "u_PrimaryLightOrigin", GLSL_VEC4, 1 }, + { "u_PrimaryLightColor", GLSL_VEC3, 1 }, + { "u_PrimaryLightAmbient", GLSL_VEC3, 1 }, + { "u_PrimaryLightRadius", GLSL_FLOAT, 1 }, + + { "u_BoneMatrices", GLSL_MAT16, 80 }, }; @@ -557,6 +560,12 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int qglBindAttribLocationARB(program->program, ATTR_INDEX_BITANGENT2, "attr_Bitangent2"); #endif + if(attribs & ATTR_BONE_INDEXES) + qglBindAttribLocationARB(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); + + if(attribs & ATTR_BONE_WEIGHTS) + qglBindAttribLocationARB(program->program, ATTR_INDEX_BONE_WEIGHTS, "attr_BoneWeights"); + GLSL_LinkProgram(program->program); return 1; @@ -633,25 +642,25 @@ void GLSL_InitUniforms(shaderProgram_t *program) switch(uniformsInfo[i].type) { case GLSL_INT: - size += sizeof(GLint); + size += sizeof(GLint) * uniformsInfo[i].size; break; case GLSL_FLOAT: - size += sizeof(GLfloat); + size += sizeof(GLfloat) * uniformsInfo[i].size; break; case GLSL_FLOAT5: - size += sizeof(vec_t) * 5; + size += sizeof(vec_t) * 5 * uniformsInfo[i].size; break; case GLSL_VEC2: - size += sizeof(vec_t) * 2; + size += sizeof(vec_t) * 2 * uniformsInfo[i].size; break; case GLSL_VEC3: - size += sizeof(vec_t) * 3; + size += sizeof(vec_t) * 3 * uniformsInfo[i].size; break; case GLSL_VEC4: - size += sizeof(vec_t) * 4; + size += sizeof(vec_t) * 4 * uniformsInfo[i].size; break; case GLSL_MAT16: - size += sizeof(vec_t) * 16; + size += sizeof(vec_t) * 16 * uniformsInfo[i].size; break; default: break; @@ -813,7 +822,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ qglUniform1fvARB(uniforms[uniformNum], 5, v); } -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const matrix_t matrix) +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix) { GLint *uniforms = program->uniforms; vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); @@ -827,14 +836,18 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const mat return; } - if (Matrix16Compare(matrix, compare)) + if (memcmp (matrix, compare, sizeof (vec_t) * 16 * uniformsInfo[uniformNum].size) == 0) { return; } - Matrix16Copy(matrix, compare); + const matrix_t *m = (matrix_t *)matrix; + for (int i = 0; i < uniformsInfo[uniformNum].size; i++) + { + Matrix16Copy(m[i], compare); + } - qglUniformMatrix4fvARB(uniforms[uniformNum], 1, GL_FALSE, matrix); + qglUniformMatrix4fvARB(uniforms[uniformNum], uniformsInfo[uniformNum].size, GL_FALSE, matrix); } void GLSL_DeleteGPUShader(shaderProgram_t *program) @@ -864,6 +877,16 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) } } +static qboolean GLSL_ContainsInvalidPermutationForGeneric (int shaderCaps) +{ + if ((shaderCaps & (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) == (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) + { + return qtrue; + } + + return qfalse; +} + void GLSL_InitGPUShaders(void) { int startTime, endTime; @@ -879,7 +902,12 @@ void GLSL_InitGPUShaders(void) startTime = ri->Milliseconds(); for (i = 0; i < GENERICDEF_COUNT; i++) - { + { + if (GLSL_ContainsInvalidPermutationForGeneric (i)) + { + continue; + } + attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_NORMAL | ATTR_COLOR; extradefines[0] = '\0'; @@ -898,6 +926,12 @@ void GLSL_InitGPUShaders(void) attribs |= ATTR_POSITION2 | ATTR_NORMAL2; } + if (i & GENERICDEF_USE_SKELETAL_ANIMATION) + { + Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; + } + if (i & GENERICDEF_USE_FOG) Q_strcat(extradefines, 1024, "#define USE_FOG\n"); @@ -947,6 +981,11 @@ void GLSL_InitGPUShaders(void) for (i = 0; i < FOGDEF_COUNT; i++) { + if ((i & (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) == (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) + { + continue; + } + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; extradefines[0] = '\0'; @@ -956,6 +995,9 @@ void GLSL_InitGPUShaders(void) if (i & FOGDEF_USE_VERTEX_ANIMATION) Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + if (i & FOGDEF_USE_SKELETAL_ANIMATION) + Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + if (!GLSL_InitGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); @@ -1010,6 +1052,12 @@ void GLSL_InitGPUShaders(void) if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP) && (i & LIGHTDEF_USE_DELUXEMAP)) continue; + if ((i & (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) == (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) + continue; + + //if ((i & LIGHTDEF_ENTITY) && (i & (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) == 0) + //continue; + if (!(i & LIGHTDEF_LIGHTTYPE_MASK)) { if (i & LIGHTDEF_USE_SHADOWMAP) @@ -1136,7 +1184,17 @@ void GLSL_InitGPUShaders(void) if (i & LIGHTDEF_ENTITY) { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n"); + if (i & LIGHTDEF_USE_VERTEX_ANIMATION) + { + Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + } + else if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) + { + Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; + } + + Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; #ifdef USE_VERT_TANGENT_SPACE @@ -1418,6 +1476,8 @@ void GLSL_ShutdownGPUShaders(void) #endif qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); GLSL_BindNullProgram(); for ( i = 0; i < GENERICDEF_COUNT; i++) @@ -1676,6 +1736,34 @@ void GLSL_VertexAttribsState(uint32_t stateBits) } #endif + if(diff & ATTR_BONE_INDEXES) + { + if(stateBits & ATTR_BONE_INDEXES) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BONE_INDEXES )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BONE_INDEXES )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); + } + } + + if(diff & ATTR_BONE_WEIGHTS) + { + if(stateBits & ATTR_BONE_WEIGHTS) + { + GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BONE_WEIGHTS )\n"); + qglEnableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); + } + else + { + GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BONE_WEIGHTS )\n"); + qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); + } + } + glState.vertexAttribsState = stateBits; } @@ -1798,6 +1886,22 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) } #endif + if((attribBits & ATTR_BONE_INDEXES) && !(glState.vertexAttribPointersSet & ATTR_BONE_INDEXES)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_INDEXES )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, glState.currentVBO->stride_boneindexes, BUFFER_OFFSET(glState.currentVBO->ofs_boneindexes)); + glState.vertexAttribPointersSet |= ATTR_BONE_INDEXES; + } + + if((attribBits & ATTR_BONE_WEIGHTS) && !(glState.vertexAttribPointersSet & ATTR_BONE_WEIGHTS)) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_WEIGHTS )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, glState.currentVBO->stride_boneweights, BUFFER_OFFSET(glState.currentVBO->ofs_boneweights)); + glState.vertexAttribPointersSet |= ATTR_BONE_WEIGHTS; + } + } @@ -1850,6 +1954,11 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; } + if (glState.skeletalAnimation) + { + shaderAttribs |= GENERICDEF_USE_SKELETAL_ANIMATION; + } + if (pStage->bundle[0].numTexMods) { shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ed855e90ec..61e9bbc31a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -400,6 +400,9 @@ typedef struct VBO_s uint32_t ofs_tangent; uint32_t ofs_bitangent; #endif + uint32_t ofs_boneweights; + uint32_t ofs_boneindexes; + uint32_t stride_xyz; uint32_t stride_normal; uint32_t stride_st; @@ -410,6 +413,9 @@ typedef struct VBO_s uint32_t stride_tangent; uint32_t stride_bitangent; #endif + uint32_t stride_boneweights; + uint32_t stride_boneindexes; + uint32_t size_xyz; uint32_t size_normal; @@ -965,16 +971,18 @@ enum GENERICDEF_USE_FOG = 0x0008, GENERICDEF_USE_RGBAGEN = 0x0010, GENERICDEF_USE_LIGHTMAP = 0x0020, - GENERICDEF_ALL = 0x003F, - GENERICDEF_COUNT = 0x0040, + GENERICDEF_USE_SKELETAL_ANIMATION = 0x0040, + GENERICDEF_ALL = 0x007F, + GENERICDEF_COUNT = 0x0080, }; enum { FOGDEF_USE_DEFORM_VERTEXES = 0x0001, FOGDEF_USE_VERTEX_ANIMATION = 0x0002, - FOGDEF_ALL = 0x0003, - FOGDEF_COUNT = 0x0004, + FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, + FOGDEF_ALL = 0x0007, + FOGDEF_COUNT = 0x0008, }; enum @@ -996,8 +1004,10 @@ enum LIGHTDEF_USE_PARALLAXMAP = 0x0020, LIGHTDEF_USE_SHADOWMAP = 0x0040, LIGHTDEF_USE_CUBEMAP = 0x0080, - LIGHTDEF_ALL = 0x00FF, - LIGHTDEF_COUNT = 0x0100 + LIGHTDEF_USE_VERTEX_ANIMATION= 0x0100, + LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0200, + LIGHTDEF_ALL = 0x03FF, + LIGHTDEF_COUNT = 0x0400 }; enum @@ -1091,6 +1101,8 @@ typedef enum UNIFORM_PRIMARYLIGHTAMBIENT, UNIFORM_PRIMARYLIGHTRADIUS, + UNIFORM_BONE_MATRICES, + UNIFORM_COUNT } uniform_t; @@ -1765,11 +1777,35 @@ Ghoul2 Insert End */ } modtype_t; +typedef struct mdxmVBOMesh_s +{ + surfaceType_t surfaceType; + + int indexOffset; + int minIndex; + int maxIndex; + int numIndexes; + int numVertexes; + + VBO_t *vbo; + IBO_t *ibo; +} mdxmVBOMesh_t; + +typedef struct mdxmVBOModel_s +{ + int numVBOMeshes; + mdxmVBOMesh_t *vboMeshes; + + VBO_t *vbo; + IBO_t *ibo; +} mdxmVBOModel_t; + typedef struct mdxmData_s { mdxmHeader_t *header; - + // int numLODs; // available in header->numLODs + mdxmVBOModel_t *vboModels; } mdxmData_t; typedef struct model_s { @@ -1882,6 +1918,8 @@ typedef struct glstate_s { uint32_t vertexAttribsOldFrame; float vertexAttribsInterpolation; qboolean vertexAnimation; + qboolean skeletalAnimation; + matrix_t *boneMatrices; shaderProgram_t *currentProgram; FBO_t *currentFBO; VBO_t *currentVBO; @@ -2759,7 +2797,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const matrix_t matrix); +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix); shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); @@ -2836,6 +2874,7 @@ class CRenderableSurface const int ident; // ident of this surface - required so the materials renderer knows what sort of surface this refers to #endif CBoneCache *boneCache; + mdxmVBOMesh_t *vboMesh; mdxmSurface_t *surfaceData; // pointer to surface data loaded into file - only used by client renderer DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of wack on the game #ifdef _G2_GORE float *alternateTex; // alternate texture coordinates. @@ -2854,6 +2893,7 @@ class CRenderableSurface surfaceData = src.surfaceData; alternateTex = src.alternateTex; goreChain = src.goreChain; + vboMesh = src.vboMesh; return *this; } @@ -2879,6 +2919,7 @@ CRenderableSurface(): surfaceData=0; alternateTex=0; goreChain=0; + vboMesh = NULL; } #endif }; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index e9c9b42542..b38565a1f9 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2025,31 +2025,20 @@ static void R_AddEntitySurface (int entityNum) case MOD_BRUSH: R_AddBrushModelSurfaces( ent ); break; - /* - Ghoul 2 Insert Start - */ case MOD_MDXM: - //g2r if (ent->e.ghoul2) R_AddGhoulSurfaces(ent); - /* - Ghoul 2 Insert End - */ case MOD_BAD: // null model axis if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { break; } - /* - Ghoul 2 Insert Start - */ + if( ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2)) ) { R_AddGhoulSurfaces( ent ); break; } - /* - Ghoul 2 Insert End - */ + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0 /* cubeMap */ ); break; default: diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9a952d1214..4d5219716d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -949,6 +949,9 @@ static void RB_FogPass( void ) { if (glState.vertexAnimation) index |= FOGDEF_USE_VERTEX_ANIMATION; + + if (glState.skeletalAnimation) + index |= FOGDEF_USE_SKELETAL_ANIMATION; sp = &tr.fogShader[index]; } @@ -1017,6 +1020,12 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) } } + if (glState.skeletalAnimation) + { + vertexAttribs |= ATTR_BONE_WEIGHTS; + vertexAttribs |= ATTR_BONE_INDEXES; + } + return vertexAttribs; } @@ -1092,6 +1101,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; } + if (glState.skeletalAnimation) + { + shaderAttribs |= GENERICDEF_USE_SKELETAL_ANIMATION; + } + if (pStage->stateBits & GLS_ATEST_BITS) { shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; @@ -1107,6 +1121,16 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { index |= LIGHTDEF_ENTITY; + + if (glState.vertexAnimation) + { + index |= LIGHTDEF_USE_VERTEX_ANIMATION; + } + + if (glState.skeletalAnimation) + { + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + } } if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (index & LIGHTDEF_LIGHTTYPE_MASK)) @@ -1141,6 +1165,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); + if (glState.skeletalAnimation) + { + GLSL_SetUniformMatrix16 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0]); + } + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 2600804c4b..3ca81eadce 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2163,13 +2163,7 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceAnim, // SF_MD4, (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, (void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM, - /* - Ghoul 2 Insert - */ (void(*)(void*))RB_SurfaceGhoul, // SF_MDX, - /* - Ghoul 2 End - */ (void(*)(void*))RB_SurfaceFlare, // SF_FLARE, (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY (void(*)(void*))RB_SurfaceDisplayList, // SF_DISPLAY_LIST diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index b8415b2749..45acc371f6 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -609,6 +609,7 @@ void R_BindVBO(VBO_t * vbo) glState.vertexAttribsOldFrame = 0; glState.vertexAttribsNewFrame = 0; glState.vertexAnimation = qfalse; + glState.skeletalAnimation = qfalse; qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); From db7a9362b35c5ba364121ecb2138050340c567da Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 20 Nov 2013 22:48:19 +0000 Subject: [PATCH 089/708] Fixed Ghoul2 rendering using GPU. --- codemp/rd-rend2/tr_ghoul2.cpp | 11 ++++++----- codemp/rd-rend2/tr_glsl.cpp | 3 --- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 8b935d8fe5..401a1e838c 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3505,6 +3505,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.numVertexes += surface->numVertexes; tess.minIndex = surface->minIndex; tess.maxIndex = surface->maxIndex; + tess.firstIndex = surface->indexOffset; for ( int i = 0; i < surf->boneCache->mFinalBones.size(); i++ ) { @@ -4679,11 +4680,11 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vboMeshes[n].vbo = vbo; vboMeshes[n].ibo = ibo; - vboMeshes[n].indexOffset = 0;//indexOffsets[n]; - vboMeshes[n].minIndex = 0;//baseVertexes[n]; - vboMeshes[n].maxIndex = numVerts;//baseVertexes[n + 1]; - vboMeshes[n].numVertexes = numVerts;//surf->numVerts; - vboMeshes[n].numIndexes = numTriangles * 3;//surf->numTriangles * 3; + vboMeshes[n].indexOffset = indexOffsets[n]; + vboMeshes[n].minIndex = baseVertexes[n]; + vboMeshes[n].maxIndex = baseVertexes[n + 1]; + vboMeshes[n].numVertexes = surf->numVerts * 5; + vboMeshes[n].numIndexes = surf->numTriangles * 3; surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5088084d5e..a06e4f69a0 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1055,9 +1055,6 @@ void GLSL_InitGPUShaders(void) if ((i & (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) == (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) continue; - //if ((i & LIGHTDEF_ENTITY) && (i & (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) == 0) - //continue; - if (!(i & LIGHTDEF_LIGHTTYPE_MASK)) { if (i & LIGHTDEF_USE_SHADOWMAP) From 2ec283dbb72caeb7f0859c2681a176f29dcf6d74 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 21 Nov 2013 08:26:15 +0000 Subject: [PATCH 090/708] Small optimization to uniform updating. --- codemp/rd-rend2/tr_ghoul2.cpp | 41 +++++------------------------------ codemp/rd-rend2/tr_glsl.cpp | 18 +++++++-------- codemp/rd-rend2/tr_local.h | 3 ++- codemp/rd-rend2/tr_shade.cpp | 2 +- 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 401a1e838c..9a905389d8 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3450,37 +3450,6 @@ static void MDXABoneToMatrix ( const mdxaBone_t& bone, matrix_t& matrix ) matrix[15] = 1.0f; } -void myGlMultMatrix( const float *a, const float *b, float *out ); -void R_MDXMRotateForEntity( const matrix_t *xform, const viewParms_t *viewParms, - orientationr_t *ori ) { -// float glMatrix[16]; - vec3_t delta; - float axisLength; - - - myGlMultMatrix( (float *)xform, viewParms->world.modelMatrix, ori->modelMatrix ); - - // calculate the viewer origin in the model's space - // needed for fog, specular, and environment mapping - VectorSubtract( viewParms->or.origin, ori->origin, delta ); - - // compensate for scale in the axes if necessary - /*if ( ent->e.nonNormalizedAxes ) { - axisLength = VectorLength( ent->e.axis[0] ); - if ( !axisLength ) { - axisLength = 0; - } else { - axisLength = 1.0f / axisLength; - } - } else */{ - axisLength = 1.0f; - } - - ori->viewOrigin[0] = DotProduct( delta, ori->axis[0] ) * axisLength; - ori->viewOrigin[1] = DotProduct( delta, ori->axis[1] ) * axisLength; - ori->viewOrigin[2] = DotProduct( delta, ori->axis[2] ) * axisLength; -} - //This is a slightly mangled version of the same function from the sof2sp base. //It provides a pretty significant performance increase over the existing one. void RB_SurfaceGhoul( CRenderableSurface *surf ) @@ -3488,6 +3457,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) #if 1 static matrix_t boneMatrices[80] = {}; + mdxmSurface_t *surfData = surf->surfaceData; mdxmVBOMesh_t *surface = surf->vboMesh; if(!surface->vbo || !surface->ibo) @@ -3507,13 +3477,15 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.maxIndex = surface->maxIndex; tess.firstIndex = surface->indexOffset; - for ( int i = 0; i < surf->boneCache->mFinalBones.size(); i++ ) + int *boneReferences = (int *)((byte *)surfData + surfData->ofsBoneReferences); + for ( int i = 0; i < surfData->numBoneReferences; i++ ) { - const mdxaBone_t& bone = surf->boneCache->EvalRender (i); + const mdxaBone_t& bone = surf->boneCache->EvalRender (boneReferences[i]); MDXABoneToMatrix (bone, boneMatrices[i]); } glState.boneMatrices = boneMatrices; + glState.numBones = surfData->numBoneReferences; glState.skeletalAnimation = qtrue; RB_EndSurface(); @@ -4576,14 +4548,13 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean } // Weights - int *boneRefs = (int *)((byte *)surf + surf->ofsBoneReferences); for ( int k = 0; k < surf->numVerts; k++ ) { int numWeights = G2_GetVertWeights (&v[k]); for ( int w = 0; w < numWeights; w++ ) { (*weights)[w] = G2_GetVertBoneWeightNotSlow (&v[k], w); - (*bonerefs)[w] = (float)boneRefs[G2_GetVertBoneIndex (&v[k], w)]; + (*bonerefs)[w] = (float)G2_GetVertBoneIndex (&v[k], w); } // Fill in the rest of the info with zeroes. diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a06e4f69a0..7227fe03e3 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -822,10 +822,10 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ qglUniform1fvARB(uniforms[uniformNum], 5, v); } -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix) +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) { GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + vec_t *compare; if (uniforms[uniformNum] == -1) return; @@ -836,18 +836,18 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const flo return; } - if (memcmp (matrix, compare, sizeof (vec_t) * 16 * uniformsInfo[uniformNum].size) == 0) - { + if (uniformsInfo[uniformNum].size < numElements) return; - } - const matrix_t *m = (matrix_t *)matrix; - for (int i = 0; i < uniformsInfo[uniformNum].size; i++) + compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + if (memcmp (matrix, compare, sizeof (vec_t) * 16 * numElements) == 0) { - Matrix16Copy(m[i], compare); + return; } - qglUniformMatrix4fvARB(uniforms[uniformNum], uniformsInfo[uniformNum].size, GL_FALSE, matrix); + Com_Memcpy (compare, matrix, sizeof (vec_t) * 16 * numElements); + + qglUniformMatrix4fvARB(uniforms[uniformNum], numElements, GL_FALSE, matrix); } void GLSL_DeleteGPUShader(shaderProgram_t *program) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 61e9bbc31a..494ca8ab84 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1920,6 +1920,7 @@ typedef struct glstate_s { qboolean vertexAnimation; qboolean skeletalAnimation; matrix_t *boneMatrices; + int numBones; shaderProgram_t *currentProgram; FBO_t *currentFBO; VBO_t *currentVBO; @@ -2797,7 +2798,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix); +void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 4d5219716d..1e700eac42 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1167,7 +1167,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (glState.skeletalAnimation) { - GLSL_SetUniformMatrix16 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0]); + GLSL_SetUniformMatrix16 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); } GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); From 9b7a61016ee4b26c0b84d723648dc448356acc58 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 22 Nov 2013 08:02:12 +0000 Subject: [PATCH 091/708] Fixed drawing of rigt HUD. --- codemp/rd-rend2/tr_backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 029168e05f..5400fac465 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -121,6 +121,11 @@ void GL_Cull( int cullType ) { glState.faceCulling = cullType; + if ( backEnd.projection2D ) + { + return; + } + if ( cullType == CT_TWO_SIDED ) { qglDisable( GL_CULL_FACE ); From df34ba2c79759eb2cea6ce1bce6e94ddfb3e5111 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 26 Nov 2013 07:33:27 +0000 Subject: [PATCH 092/708] Fixed sky rendering --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 8f0b9b2746..e1cfc38a10 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1771,7 +1771,7 @@ static qboolean ParseShader( const char **text ) ParseMaterial( text ); } // sun parms - else if ( !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { + else if ( !Q_stricmp( token, "sun" ) || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) || !Q_stricmp( token, "q3gl2_sun" ) ) { float a, b; qboolean isGL2Sun = qfalse; From 2f64b55e503ae1ac772ed2aaa58c20f4c5c86502 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 26 Nov 2013 08:15:18 +0000 Subject: [PATCH 093/708] Fixed depth prepass and random noise keyword --- codemp/rd-rend2/tr_shade.cpp | 10 ++++++++++ codemp/rd-rend2/tr_shader.cpp | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 1e700eac42..b9ad30ef78 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1078,6 +1078,16 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { index |= LIGHTDEF_ENTITY; + + if (glState.vertexAnimation) + { + index |= LIGHTDEF_USE_VERTEX_ANIMATION; + } + + if (glState.skeletalAnimation) + { + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + } } if (pStage->stateBits & GLS_ATEST_BITS) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e1cfc38a10..df0c435e61 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -308,6 +308,10 @@ static genFunc_t NameToGenFunc( const char *funcname ) { return GF_NOISE; } + else if ( !Q_stricmp( funcname, "random" ) ) + { + return GF_RAND; + } ri->Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); return GF_SIN; From 2fbb609d95b953dd444658f69b815280ca8b5bb9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 27 Nov 2013 19:08:32 +0000 Subject: [PATCH 094/708] [Rend2] Initial fix for fog, sabers and shaders --- codemp/rd-rend2/tr_bsp.cpp | 67 +++++---- codemp/rd-rend2/tr_init.cpp | 4 +- codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_scene.cpp | 256 ++++++++++++++++++++++++++++++++- codemp/rd-rend2/tr_shader.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 10 +- 6 files changed, 307 insertions(+), 36 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 886487ca30..a66feec358 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2566,41 +2566,50 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { for ( i=0 ; ioriginalBrushNumber = LittleLong( fogs->brushNum ); - if ( (unsigned)out->originalBrushNumber >= brushesCount ) { - ri->Error( ERR_DROP, "fog brushNumber out of range" ); + if ( out->originalBrushNumber == -1 ) + { + out->bounds[0][0] = out->bounds[0][1] = out->bounds[0][2] = MIN_WORLD_COORD; + out->bounds[1][0] = out->bounds[1][1] = out->bounds[1][2] = MAX_WORLD_COORD; + firstSide = -1; } - brush = brushes + out->originalBrushNumber; + else + { + if ( (unsigned)out->originalBrushNumber >= brushesCount ) { + ri->Error( ERR_DROP, "fog brushNumber out of range" ); + } + brush = brushes + out->originalBrushNumber; - firstSide = LittleLong( brush->firstSide ); + firstSide = LittleLong( brush->firstSide ); - if ( (unsigned)firstSide > sidesCount - 6 ) { - ri->Error( ERR_DROP, "fog brush sideNumber out of range" ); - } + if ( (unsigned)firstSide > sidesCount - 6 ) { + ri->Error( ERR_DROP, "fog brush sideNumber out of range" ); + } - // brushes are always sorted with the axial sides first - sideNum = firstSide + 0; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist; + // brushes are always sorted with the axial sides first + sideNum = firstSide + 0; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist; - sideNum = firstSide + 1; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][0] = s_worldData.planes[ planeNum ].dist; + sideNum = firstSide + 1; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][0] = s_worldData.planes[ planeNum ].dist; - sideNum = firstSide + 2; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist; + sideNum = firstSide + 2; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist; - sideNum = firstSide + 3; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][1] = s_worldData.planes[ planeNum ].dist; + sideNum = firstSide + 3; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][1] = s_worldData.planes[ planeNum ].dist; - sideNum = firstSide + 4; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist; + sideNum = firstSide + 4; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist; - sideNum = firstSide + 5; - planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][2] = s_worldData.planes[ planeNum ].dist; + sideNum = firstSide + 5; + planeNum = LittleLong( sides[ sideNum ].planeNum ); + out->bounds[1][2] = s_worldData.planes[ planeNum ].dist; + } // get information from the shader for fog parameters shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue ); @@ -2617,10 +2626,8 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { // set the gradient vector sideNum = LittleLong( fogs->visibleSide ); - if ( sideNum == -1 ) { - out->hasSurface = qfalse; - } else { - out->hasSurface = qtrue; + out->hasSurface = qtrue; + if ( sideNum != -1 ) { planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum ); VectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface ); out->surface[3] = -s_worldData.planes[ planeNum ].dist; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index bff5098eb8..78bd7da197 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -188,6 +188,7 @@ cvar_t *r_shownormals; cvar_t *r_finish; cvar_t *r_clear; cvar_t *r_swapInterval; +cvar_t *r_markcount; cvar_t *r_textureMode; cvar_t *r_offsetFactor; cvar_t *r_offsetUnits; @@ -1329,6 +1330,7 @@ void R_Register( void ) r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); r_swapInterval = ri->Cvar_Get( "r_swapInterval", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE ); r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); @@ -1729,7 +1731,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.AddRefEntityToScene = RE_AddRefEntityToScene; re.AddMiniRefEntityToScene = stub_RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; - // RE_AddDecalToScene + re.AddDecalToScene = RE_AddDecalToScene; re.LightForPoint = R_LightForPoint; re.AddLightToScene = RE_AddLightToScene; re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 494ca8ab84..d8627d998d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -223,6 +223,7 @@ extern cvar_t *r_shownormals; extern cvar_t *r_finish; extern cvar_t *r_clear; extern cvar_t *r_swapInterval; +extern cvar_t *r_markcount; extern cvar_t *r_textureMode; extern cvar_t *r_offsetFactor; extern cvar_t *r_offsetUnits; @@ -2815,6 +2816,7 @@ void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); +void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary ); void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_BeginScene( const refdef_t *fd ); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 683e49ab86..3df8a398ee 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -78,7 +78,6 @@ void RE_ClearScene( void ) { DISCRETE POLYS =========================================================================== -*/ /* ===================== @@ -544,3 +543,258 @@ void RE_RenderScene( const refdef_t *fd ) { tr.frontEndMsec += ri->Milliseconds() - startTime; } + +enum +{ + DECALPOLY_TYPE_NORMAL, + DECALPOLY_TYPE_FADE, + DECALPOLY_TYPE_MAX +}; + +#define MAX_VERTS_ON_DECAL_POLY 10 +#define MAX_DECAL_POLYS 500 + +typedef struct decalPoly_s +{ + int time; + int fadetime; + qhandle_t shader; + float color[4]; + poly_t poly; + polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; + +} decalPoly_t; + +#define DECAL_FADE_TIME 1000 + +decalPoly_t* RE_AllocDecal ( int type ); + +static decalPoly_t re_decalPolys[DECALPOLY_TYPE_MAX][MAX_DECAL_POLYS]; + +static int re_decalPolyHead[DECALPOLY_TYPE_MAX]; +static int re_decalPolyTotal[DECALPOLY_TYPE_MAX]; + +/* +=================== +RE_ClearDecals + +This is called to remove all decals from the world +=================== +*/ + +void RE_ClearDecals ( void ) +{ + memset( re_decalPolys, 0, sizeof(re_decalPolys) ); + memset( re_decalPolyHead, 0, sizeof(re_decalPolyHead) ); + memset( re_decalPolyTotal, 0, sizeof(re_decalPolyTotal) ); +} + +void R_InitDecals ( void ) +{ + RE_ClearDecals ( ); +} + +void RE_FreeDecal ( int type, int index ) +{ + if ( !re_decalPolys[type][index].time ) + { + return; + } + + if ( type == DECALPOLY_TYPE_NORMAL ) + { + decalPoly_t* fade; + + fade = RE_AllocDecal ( DECALPOLY_TYPE_FADE ); + + memcpy ( fade, &re_decalPolys[type][index], sizeof(decalPoly_t) ); + + fade->time = tr.refdef.time; + fade->fadetime = tr.refdef.time + DECAL_FADE_TIME; + } + + re_decalPolys[type][index].time = 0; + + re_decalPolyTotal[type]--; +} + +/* +=================== +RE_AllocDecal + +Will allways succeed, even if it requires freeing an old active mark +=================== +*/ +decalPoly_t* RE_AllocDecal( int type ) +{ + decalPoly_t *le; + + // See if the cvar changed + if ( re_decalPolyTotal[type] > r_markcount->integer ) + { + RE_ClearDecals ( ); + } + + le = &re_decalPolys[type][re_decalPolyHead[type]]; + + // If it has no time its the first occasion its been used + if ( le->time ) + { + if ( le->time != tr.refdef.time ) + { + int i = re_decalPolyHead[type]; + + // since we are killing one that existed before, make sure we + // kill all the other marks that belong to the group + do + { + i++; + if ( i >= r_markcount->integer ) + { + i = 0; + } + + // Break out on the first one thats not part of the group + if ( re_decalPolys[type][i].time != le->time ) + { + break; + } + + RE_FreeDecal ( type, i ); + } + while ( i != re_decalPolyHead[type] ); + + RE_FreeDecal ( type, re_decalPolyHead[type] ); + } + else + { + RE_FreeDecal ( type, re_decalPolyHead[type] ); + } + } + + memset ( le, 0, sizeof(decalPoly_t) ); + le->time = tr.refdef.time; + + re_decalPolyTotal[type]++; + + // Move on to the next decal poly and wrap around if need be + re_decalPolyHead[type]++; + if ( re_decalPolyHead[type] >= r_markcount->integer ) + { + re_decalPolyHead[type] = 0; + } + + return le; +} + +/* +================= +RE_AddDecalToScene + +origin should be a point within a unit of the plane +dir should be the plane normal + +temporary marks will not be stored or randomly oriented, but immediately +passed to the renderer. +================= +*/ +#define MAX_DECAL_FRAGMENTS 128 +#define MAX_DECAL_POINTS 384 + +void RE_AddDecalToScene ( qhandle_t decalShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary ) +{ + vec3_t axis[3]; + float texCoordScale; + vec3_t originalPoints[4]; + byte colors[4]; + int i, j; + int numFragments; + markFragment_t markFragments[MAX_DECAL_FRAGMENTS], *mf; + vec3_t markPoints[MAX_DECAL_POINTS]; + vec3_t projection; + + assert(decalShader); + + if ( r_markcount->integer <= 0 && !temporary ) + { + return; + } + + if ( radius <= 0 ) + { + Com_Error( ERR_FATAL, "RE_AddDecalToScene: called with <= 0 radius" ); + } + + // create the texture axis + VectorNormalize2( dir, axis[0] ); + PerpendicularVector( axis[1], axis[0] ); + RotatePointAroundVector( axis[2], axis[0], axis[1], orientation ); + CrossProduct( axis[0], axis[2], axis[1] ); + + texCoordScale = 0.5 * 1.0 / radius; + + // create the full polygon + for ( i = 0 ; i < 3 ; i++ ) + { + originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; + originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; + originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i]; + originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i]; + } + + // get the fragments + VectorScale( dir, -20, projection ); + numFragments = R_MarkFragments( 4, (const vec3_t*)originalPoints, + projection, MAX_DECAL_POINTS, markPoints[0], + MAX_DECAL_FRAGMENTS, markFragments ); + + colors[0] = red * 255; + colors[1] = green * 255; + colors[2] = blue * 255; + colors[3] = alpha * 255; + + for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) + { + polyVert_t *v; + polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; + decalPoly_t *decal; + + // we have an upper limit on the complexity of polygons + // that we store persistantly + if ( mf->numPoints > MAX_VERTS_ON_DECAL_POLY ) + { + mf->numPoints = MAX_VERTS_ON_DECAL_POLY; + } + + for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) + { + vec3_t delta; + + VectorCopy( markPoints[mf->firstPoint + j], v->xyz ); + + VectorSubtract( v->xyz, origin, delta ); + v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale; + v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale; + + *(int *)v->modulate = *(int *)colors; + } + + // if it is a temporary (shadow) mark, add it immediately and forget about it + if ( temporary ) + { + RE_AddPolyToScene( decalShader, mf->numPoints, verts, 1 ); + continue; + } + + // otherwise save it persistantly + decal = RE_AllocDecal( DECALPOLY_TYPE_NORMAL ); + decal->time = tr.refdef.time; + decal->shader = decalShader; + decal->poly.numVerts = mf->numPoints; + decal->color[0] = red; + decal->color[1] = green; + decal->color[2] = blue; + decal->color[3] = alpha; + memcpy( decal->verts, verts, mf->numPoints * sizeof( verts[0] ) ); + } +} diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index df0c435e61..7492ebd7f3 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -968,7 +968,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); continue; } - stage->materialInfo[1] = atof( token ); + exponent = atof( token ); // Change shininess to gloss // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl @@ -2865,7 +2865,7 @@ static shader_t *GeneratePermanentShader( void ) { *newShader = shader; - if ( shader.sort <= SS_OPAQUE ) { + if ( shader.sort <= SS_SEE_THROUGH ) { newShader->fogPass = FP_EQUAL; } else if ( shader.contentFlags & CONTENTS_FOG ) { newShader->fogPass = FP_LE; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 3ca81eadce..d024b8745e 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -283,6 +283,7 @@ static void RB_SurfaceOrientedQuad( void ) { vec3_t left, up; float radius; + float color[4]; // calculate the xyz locations for the four corners radius = backEnd.currentEntity->e.radius; @@ -321,7 +322,9 @@ static void RB_SurfaceOrientedQuad( void ) VectorSubtract( vec3_origin, left, left ); } - RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, (float *)backEnd.currentEntity->e.shaderRGBA ); + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, color); + + RB_AddQuadStamp( backEnd.currentEntity->e.origin, left, up, color); } /* @@ -684,6 +687,7 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) float s, c; float ang; vec3_t left, up; + float color[4]; ang = M_PI * rotation / 180.0f; s = sin( ang ); @@ -700,7 +704,9 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) VectorSubtract( vec3_origin, left, left ); } - RB_AddQuadStamp( origin, left, up, (float *)backEnd.currentEntity->e.shaderRGBA ); + VectorScale4(backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, color); + + RB_AddQuadStamp( origin, left, up, color ); } //------------------ From c18e0652df436db107678bde6d6cf4d704ae7b5c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 27 Nov 2013 19:09:26 +0000 Subject: [PATCH 095/708] [Rend2] Initial fix for decals. --- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_scene.cpp | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 78bd7da197..5827fe9e38 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1543,6 +1543,8 @@ void R_Init( void ) { R_ModelInit(); + R_InitDecals(); + R_InitQueries(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d8627d998d..a104cb43e3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1833,6 +1833,8 @@ typedef struct model_s { #define MAX_MOD_KNOWN 1024 void R_ModelInit (void); +void R_InitDecals (void); + model_t *R_GetModelByHandle( qhandle_t hModel ); int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, float frac, const char *tagName ); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 3df8a398ee..e748e3468a 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -582,7 +582,7 @@ This is called to remove all decals from the world =================== */ -void RE_ClearDecals ( void ) +static void RE_ClearDecals ( void ) { memset( re_decalPolys, 0, sizeof(re_decalPolys) ); memset( re_decalPolyHead, 0, sizeof(re_decalPolyHead) ); @@ -594,7 +594,7 @@ void R_InitDecals ( void ) RE_ClearDecals ( ); } -void RE_FreeDecal ( int type, int index ) +static void RE_FreeDecal ( int type, int index ) { if ( !re_decalPolys[type][index].time ) { @@ -625,7 +625,7 @@ RE_AllocDecal Will allways succeed, even if it requires freeing an old active mark =================== */ -decalPoly_t* RE_AllocDecal( int type ) +static decalPoly_t* RE_AllocDecal( int type ) { decalPoly_t *le; From 4ebd7e7a7ef7b7a6aa1f692326bdc8517c2efb29 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 27 Nov 2013 22:00:48 +0000 Subject: [PATCH 096/708] [Rend2] Map colors from 0-255 range to 0-1 range Rend2 stores colours as floating point numbers in the 0 - 1 range, as opposed to the original renderer which stores colours as bytes in 0 - 255 range. This commit scales the colours down to the correct range and data type. --- codemp/rd-rend2/tr_surface.cpp | 65 +++++++--------------------------- 1 file changed, 13 insertions(+), 52 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index d024b8745e..1e74472b6b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -767,38 +767,26 @@ static void DoLine( const vec3_t start, const vec3_t end, const vec3_t up, float VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25;//wtf??not sure why the code would be doing this - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; tess.indexes[tess.numIndexes++] = vbase; @@ -821,38 +809,26 @@ static void DoLine2( const vec3_t start, const vec3_t end, const vec3_t up, floa VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25;//wtf??not sure why the code would be doing this - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( start, -spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, -spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1;//backEnd.currentEntity->e.shaderTexCoord[0]; tess.texCoords[tess.numVertexes][0][1] = 1;//backEnd.currentEntity->e.shaderTexCoord[1]; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3]; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; tess.indexes[tess.numIndexes++] = vbase; @@ -877,38 +853,26 @@ static void DoLine_Oriented( const vec3_t start, const vec3_t end, const vec3_t VectorMA( start, spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0];// * 0.25; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1];// * 0.25; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2];// * 0.25; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( start, spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, spanWidth, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; VectorMA( end, spanWidth2, up, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = 1; tess.texCoords[tess.numVertexes][0][1] = backEnd.currentEntity->e.data.line.stscale; - tess.vertexColors[tess.numVertexes][0] = backEnd.currentEntity->e.shaderRGBA[0]; - tess.vertexColors[tess.numVertexes][1] = backEnd.currentEntity->e.shaderRGBA[1]; - tess.vertexColors[tess.numVertexes][2] = backEnd.currentEntity->e.shaderRGBA[2]; - tess.vertexColors[tess.numVertexes][3] = backEnd.currentEntity->e.shaderRGBA[3];// * 0.25; + VectorScale4 (backEnd.currentEntity->e.shaderRGBA, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; tess.indexes[tess.numIndexes++] = vbase; @@ -984,10 +948,7 @@ static void DoCylinderPart(polyVert_t *verts) VectorCopy( verts->xyz, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = verts->st[0]; tess.texCoords[tess.numVertexes][0][1] = verts->st[1]; - tess.vertexColors[tess.numVertexes][0] = verts->modulate[0]; - tess.vertexColors[tess.numVertexes][1] = verts->modulate[1]; - tess.vertexColors[tess.numVertexes][2] = verts->modulate[2]; - tess.vertexColors[tess.numVertexes][3] = verts->modulate[3]; + VectorScale4 (verts->modulate, 1.0f / 255.0f, tess.vertexColors[tess.numVertexes]); tess.numVertexes++; verts++; } From baf35c8da5011eac96c91679fb48e0cb8f8f24e8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 27 Nov 2013 22:02:44 +0000 Subject: [PATCH 097/708] [Rend2] Corrected default shader creation. There was a small mistake when porting the vanilla renderer code to rend2 - when finding shaders, LIGHTMAP_NONE should be passed as the lightmap index, if a lightmap should not be used. Previously, 0 was passed, indicating that lightmap 0 should be used with the shader. --- codemp/rd-rend2/tr_cache.cpp | 2 +- codemp/rd-rend2/tr_skin.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index b386b8558e..d9719d7ee0 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -347,7 +347,7 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; - shader_t *sh = R_FindShader( psShaderName, 0, qtrue ); + shader_t *sh = R_FindShader( psShaderName, LIGHTMAP_NONE, qtrue ); if ( sh->defaultShader ) *piShaderPokePtr = 0; diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp index 87ea7a88a3..9e1ee85761 100644 --- a/codemp/rd-rend2/tr_skin.cpp +++ b/codemp/rd-rend2/tr_skin.cpp @@ -140,7 +140,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf; Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); - surf->shader = R_FindShader( token, 0, qtrue ); + surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); skin->numSurfaces++; } From 61a27bc7ea943666b53112d0a5ca40e4d72650e2 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 28 Nov 2013 19:40:39 +0000 Subject: [PATCH 098/708] [Rend2] Fixed alpha testing. For some reason, rend2 has #defines for GL state bits, as well as an enum. This caused in some cases for the enum to be used, and in other cases for the #define to be used. This commit removes the #defines in favour of the enum. --- codemp/rd-rend2/tr_local.h | 60 +++++++---------------------------- codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 2 +- 3 files changed, 14 insertions(+), 50 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a104cb43e3..5334aff4eb 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -897,31 +897,33 @@ enum GLS_DEPTHFUNC_LESS = (1 << 20), GLS_DEPTHFUNC_EQUAL = (1 << 21), + GLS_DEPTHFUNC_GREATER = (1 << 22), GLS_DEPTHFUNC_BITS = GLS_DEPTHFUNC_LESS - | GLS_DEPTHFUNC_EQUAL, + | GLS_DEPTHFUNC_EQUAL + | GLS_DEPTHFUNC_GREATER, - GLS_ATEST_GT_0 = (1 << 22), - GLS_ATEST_LT_128 = (1 << 23), - GLS_ATEST_GE_128 = (1 << 24), - GLS_ATEST_GE_192 = (1 << 25), + GLS_ATEST_GT_0 = (1 << 23), + GLS_ATEST_LT_128 = (1 << 24), + GLS_ATEST_GE_128 = (1 << 25), + GLS_ATEST_GE_192 = (1 << 26), GLS_ATEST_BITS = GLS_ATEST_GT_0 | GLS_ATEST_LT_128 | GLS_ATEST_GE_128 | GLS_ATEST_GE_192, - GLS_REDMASK_FALSE = (1 << 26), - GLS_GREENMASK_FALSE = (1 << 27), - GLS_BLUEMASK_FALSE = (1 << 28), - GLS_ALPHAMASK_FALSE = (1 << 29), + GLS_REDMASK_FALSE = (1 << 27), + GLS_GREENMASK_FALSE = (1 << 28), + GLS_BLUEMASK_FALSE = (1 << 29), + GLS_ALPHAMASK_FALSE = (1 << 30), GLS_COLORMASK_BITS = GLS_REDMASK_FALSE | GLS_GREENMASK_FALSE | GLS_BLUEMASK_FALSE | GLS_ALPHAMASK_FALSE, - GLS_STENCILTEST_ENABLE = (1 << 30), + GLS_STENCILTEST_ENABLE = (1 << 31), GLS_DEFAULT = GLS_DEPTHMASK_TRUE }; @@ -2454,44 +2456,6 @@ void GL_SetModelviewMatrix(matrix_t matrix); void GL_TexEnv( int env ); void GL_Cull( int cullType ); -#define GLS_SRCBLEND_ZERO 0x00000001 -#define GLS_SRCBLEND_ONE 0x00000002 -#define GLS_SRCBLEND_DST_COLOR 0x00000003 -#define GLS_SRCBLEND_ONE_MINUS_DST_COLOR 0x00000004 -#define GLS_SRCBLEND_SRC_ALPHA 0x00000005 -#define GLS_SRCBLEND_ONE_MINUS_SRC_ALPHA 0x00000006 -#define GLS_SRCBLEND_DST_ALPHA 0x00000007 -#define GLS_SRCBLEND_ONE_MINUS_DST_ALPHA 0x00000008 -#define GLS_SRCBLEND_ALPHA_SATURATE 0x00000009 -#define GLS_SRCBLEND_BITS 0x0000000f - -#define GLS_DSTBLEND_ZERO 0x00000010 -#define GLS_DSTBLEND_ONE 0x00000020 -#define GLS_DSTBLEND_SRC_COLOR 0x00000030 -#define GLS_DSTBLEND_ONE_MINUS_SRC_COLOR 0x00000040 -#define GLS_DSTBLEND_SRC_ALPHA 0x00000050 -#define GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA 0x00000060 -#define GLS_DSTBLEND_DST_ALPHA 0x00000070 -#define GLS_DSTBLEND_ONE_MINUS_DST_ALPHA 0x00000080 -#define GLS_DSTBLEND_BITS 0x000000f0 - -#define GLS_DEPTHMASK_TRUE 0x00000100 - -#define GLS_POLYMODE_LINE 0x00001000 - -#define GLS_DEPTHTEST_DISABLE 0x00010000 -#define GLS_DEPTHFUNC_EQUAL 0x00020000 -#define GLS_DEPTHFUNC_GREATER 0x00040000 -#define GLS_DEPTHFUNC_BITS 0x00060000 - -#define GLS_ATEST_GT_0 0x10000000 -#define GLS_ATEST_LT_80 0x20000000 -#define GLS_ATEST_GE_80 0x40000000 -#define GLS_ATEST_GE_C0 0x80000000 -#define GLS_ATEST_BITS 0xF0000000 - -#define GLS_DEFAULT GLS_DEPTHMASK_TRUE - #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b9ad30ef78..aa4c609169 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1204,7 +1204,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) { // we want to be able to rip a hole in the thing being disintegrated, and by doing the depth-testing it avoids some kinds of artefacts, but will probably introduce others? - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE | GLS_ATEST_GE_C0; + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE | GLS_ATEST_GE_192; } if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 7492ebd7f3..a12be915c7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -608,7 +608,7 @@ ParseStage static qboolean ParseStage( shaderStage_t *stage, const char **text ) { char *token; - int depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; + unsigned depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; qboolean depthMaskExplicit = qfalse; stage->active = qtrue; From 062f4ba7ba80a3f398040c0828956aabcc363378 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 29 Nov 2013 07:47:29 +0000 Subject: [PATCH 099/708] [Rend2] Linked up the RotatePic commands. This will fix crashing when using vehicles and possibly in other scenarios too. --- codemp/rd-rend2/tr_backend.cpp | 208 ++++++++++++++++++++++++--------- codemp/rd-rend2/tr_init.cpp | 12 +- codemp/rd-rend2/tr_local.h | 7 +- codemp/rd-rend2/tr_shader.cpp | 11 +- 4 files changed, 168 insertions(+), 70 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5400fac465..8a8c5f9b42 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1047,38 +1047,94 @@ const void *RB_RotatePic ( const void *data ) const rotatePicCommand_t *cmd; image_t *image; shader_t *shader; + int numVerts; + int numIndexes; + vec3_t point, rotatedPoint; + vec3_t axis = { 0.0f, 0.0f, 1.0f }; + vec3_t xlat; cmd = (const rotatePicCommand_t *)data; + // FIXME: HUGE hack + if (glRefConfig.framebufferObject) + { + if (!tr.renderFbo || backEnd.framePostProcessed) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + + RB_SetGL2D(); + shader = cmd->shader; image = shader->stages[0]->bundle[0].image[0]; - - if ( image ) { - if ( !backEnd.projection2D ) { - RB_SetGL2D(); + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0, 0 ); + } + + RB_CHECKOVERFLOW( 4, 6 ); + numVerts = tess.numVertexes; + numIndexes = tess.numIndexes; - qglColor4ubv( backEnd.color2D ); - qglPushMatrix(); + tess.numVertexes += 4; + tess.numIndexes += 6; - qglTranslatef(cmd->x+cmd->w,cmd->y,0); - qglRotatef(cmd->a, 0.0, 0.0, 1.0); - - GL_Bind( image ); - qglBegin (GL_QUADS); - qglTexCoord2f( cmd->s1, cmd->t1); - qglVertex2f( -cmd->w, 0 ); - qglTexCoord2f( cmd->s2, cmd->t1 ); - qglVertex2f( 0, 0 ); - qglTexCoord2f( cmd->s2, cmd->t2 ); - qglVertex2f( 0, cmd->h ); - qglTexCoord2f( cmd->s1, cmd->t2 ); - qglVertex2f( -cmd->w, cmd->h ); - qglEnd(); - - qglPopMatrix(); + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; + + { + vec4_t color; + + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); } + VectorSet (xlat, cmd->x, cmd->y, 0.0f); + + VectorSet (point, -cmd->w, 0.0f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts]); + + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; + + VectorSet (point, 0.0f, 0.0f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 1]); + + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + + VectorSet (point, 0.0f, cmd->h, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 2]); + + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + + VectorSet (point, -cmd->w, cmd->h, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 3]); + + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + return (const void *)(cmd + 1); } @@ -1092,55 +1148,93 @@ const void *RB_RotatePic2 ( const void *data ) const rotatePicCommand_t *cmd; image_t *image; shader_t *shader; + int numVerts; + int numIndexes; + vec3_t point, rotatedPoint; + vec3_t axis = { 0.0f, 0.0f, 1.0f }; + vec3_t xlat; cmd = (const rotatePicCommand_t *)data; + // FIXME: HUGE hack + if (glRefConfig.framebufferObject) + { + if (!tr.renderFbo || backEnd.framePostProcessed) + { + FBO_Bind(tr.screenScratchFbo); + } + else + { + FBO_Bind(tr.renderFbo); + } + } + + RB_SetGL2D(); + shader = cmd->shader; + image = shader->stages[0]->bundle[0].image[0]; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); + } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0, 0 ); + } - if ( shader->numUnfoggedPasses ) - { - image = shader->stages[0]->bundle[0].image[0]; + RB_CHECKOVERFLOW( 4, 6 ); + numVerts = tess.numVertexes; + numIndexes = tess.numIndexes; + + tess.numVertexes += 4; + tess.numIndexes += 6; + + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; - if ( image ) { - if ( !backEnd.projection2D ) - { - RB_SetGL2D(); - } + vec4_t color; - // Get our current blend mode, etc. - GL_State( shader->stages[0]->stateBits ); + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - qglColor4ubv( backEnd.color2D ); - qglPushMatrix(); + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); + } - // rotation point is going to be around the center of the passed in coordinates - qglTranslatef( cmd->x, cmd->y, 0 ); - qglRotatef( cmd->a, 0.0, 0.0, 1.0 ); - - GL_Bind( image ); - qglBegin( GL_QUADS ); - qglTexCoord2f( cmd->s1, cmd->t1); - qglVertex2f( -cmd->w * 0.5f, -cmd->h * 0.5f ); + VectorSet (xlat, cmd->x, cmd->y, 0.0f); - qglTexCoord2f( cmd->s2, cmd->t1 ); - qglVertex2f( cmd->w * 0.5f, -cmd->h * 0.5f ); + VectorSet (point, -cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts]); - qglTexCoord2f( cmd->s2, cmd->t2 ); - qglVertex2f( cmd->w * 0.5f, cmd->h * 0.5f ); + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; - qglTexCoord2f( cmd->s1, cmd->t2 ); - qglVertex2f( -cmd->w * 0.5f, cmd->h * 0.5f ); - qglEnd(); - - qglPopMatrix(); + VectorSet (point, cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 1]); - // Hmmm, this is not too cool - GL_State( GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); - } - } + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + + VectorSet (point, cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 2]); + + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + + VectorSet (point, -cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); + RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 3]); + + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5827fe9e38..5e2be598c5 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1535,7 +1535,7 @@ void R_Init( void ) { R_InitVBOs(); - R_InitShaders(); + R_InitShaders (qfalse); R_InitSkins(); @@ -1725,8 +1725,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.LerpTag = R_LerpTag; re.ModelBounds = R_ModelBounds; - // RE_RotatePic - // RE_RotatePic2 + re.DrawRotatePic = RE_RotatePic; + re.DrawRotatePic2 = RE_RotatePic2; re.ClearScene = RE_ClearScene; // RE_ClearDecals @@ -1777,9 +1777,9 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.TakeVideoFrame = RE_TakeVideoFrame; - /* - Ghoul2 Insert Start - */ + re.InitSkins = R_InitSkins; + re.InitShaders = R_InitShaders; + re.G2API_AddBolt = G2API_AddBolt; re.G2API_AddBoltSurfNum = G2API_AddBoltSurfNum; re.G2API_AddSurface = G2API_AddSurface; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5334aff4eb..57e3c45eb7 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2510,7 +2510,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag shader_t *R_GetShaderByHandle( qhandle_t hShader ); shader_t *R_GetShaderByState( int index, long *cycleTime ); shader_t *R_FindShaderByName( const char *name ); -void R_InitShaders( void ); +void R_InitShaders( qboolean server ); void R_ShaderList_f( void ); void R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset); @@ -3113,8 +3113,9 @@ void R_AddCapShadowmapCmd( int dlight, int cubeSide ); void R_AddPostProcessCmd (void); void RE_SetColor( const float *rgba ); -void RE_StretchPic ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, qhandle_t hShader ); +void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); +void RE_RotatePic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a, qhandle_t hShader ); +void RE_RotatePic2 ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); void RE_BeginFrame( stereoFrame_t stereoFrame ); void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); void RE_TakeVideoFrame( int width, int height, diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index a12be915c7..6ea5f65468 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4005,14 +4005,17 @@ static void CreateExternalShaders( void ) { R_InitShaders ================== */ -void R_InitShaders( void ) { +void R_InitShaders( qboolean server ) { ri->Printf( PRINT_ALL, "Initializing Shaders\n" ); Com_Memset(hashTable, 0, sizeof(hashTable)); - CreateInternalShaders(); + if ( !server ) + { + CreateInternalShaders(); - ScanAndLoadShaderFiles(); + ScanAndLoadShaderFiles(); - CreateExternalShaders(); + CreateExternalShaders(); + } } From 2e461f1fea89ebd1d8054555ab80cc36a799471e Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 29 Nov 2013 16:31:19 -0600 Subject: [PATCH 100/708] [MP] Rend2: Merged some vanilla changes. --- codemp/rd-rend2/tr_backend.cpp | 4 +- codemp/rd-rend2/tr_extramath.h | 2 +- codemp/rd-rend2/tr_glsl.cpp | 24 +++++----- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_light.cpp | 4 +- codemp/rd-rend2/tr_local.h | 42 ++++++++--------- codemp/rd-rend2/tr_marks.cpp | 2 +- codemp/rd-rend2/tr_model_iqm.cpp | 8 ++-- codemp/rd-rend2/tr_shader.cpp | 80 +++++++++++++++----------------- 9 files changed, 80 insertions(+), 88 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 8a8c5f9b42..657da542c6 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -189,9 +189,9 @@ void GL_TexEnv( int env ) ** This routine is responsible for setting the most commonly changed state ** in Q3. */ -void GL_State( unsigned long stateBits ) +void GL_State( uint32_t stateBits ) { - unsigned long diff = stateBits ^ glState.glStateBits; + uint32_t diff = stateBits ^ glState.glStateBits; if ( !diff ) { diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index 99e17c1a05..079de8d506 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef __TR_EXTRAMATH_H__ #define __TR_EXTRAMATH_H__ -typedef vec_t matrix_t[16]; +typedef float matrix_t[16]; typedef int vec2i_t[2]; typedef int vec3i_t[3]; typedef int vec4i_t[4]; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 7227fe03e3..75c7d2dadb 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -648,19 +648,19 @@ void GLSL_InitUniforms(shaderProgram_t *program) size += sizeof(GLfloat) * uniformsInfo[i].size; break; case GLSL_FLOAT5: - size += sizeof(vec_t) * 5 * uniformsInfo[i].size; + size += sizeof(float) * 5 * uniformsInfo[i].size; break; case GLSL_VEC2: - size += sizeof(vec_t) * 2 * uniformsInfo[i].size; + size += sizeof(float) * 2 * uniformsInfo[i].size; break; case GLSL_VEC3: - size += sizeof(vec_t) * 3 * uniformsInfo[i].size; + size += sizeof(float) * 3 * uniformsInfo[i].size; break; case GLSL_VEC4: - size += sizeof(vec_t) * 4 * uniformsInfo[i].size; + size += sizeof(float) * 4 * uniformsInfo[i].size; break; case GLSL_MAT16: - size += sizeof(vec_t) * 16 * uniformsInfo[i].size; + size += sizeof(float) * 16 * uniformsInfo[i].size; break; default: break; @@ -728,7 +728,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v) { GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); if (uniforms[uniformNum] == -1) return; @@ -753,7 +753,7 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v) { GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); if (uniforms[uniformNum] == -1) return; @@ -777,7 +777,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v) { GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); if (uniforms[uniformNum] == -1) return; @@ -801,7 +801,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v) { GLint *uniforms = program->uniforms; - vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); if (uniforms[uniformNum] == -1) return; @@ -825,7 +825,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) { GLint *uniforms = program->uniforms; - vec_t *compare; + float *compare; if (uniforms[uniformNum] == -1) return; @@ -840,12 +840,12 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const flo return; compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); - if (memcmp (matrix, compare, sizeof (vec_t) * 16 * numElements) == 0) + if (memcmp (matrix, compare, sizeof (float) * 16 * numElements) == 0) { return; } - Com_Memcpy (compare, matrix, sizeof (vec_t) * 16 * numElements); + Com_Memcpy (compare, matrix, sizeof (float) * 16 * numElements); qglUniformMatrix4fvARB(uniforms[uniformNum], numElements, GL_FALSE, matrix); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5e2be598c5..ceb9f364d2 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1674,7 +1674,7 @@ void RE_SetLightStyle(int style, int color) } } -void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} +void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 76e40b3d3a..5800f60d45 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -490,12 +490,12 @@ int R_CubemapForPoint( vec3_t point ) if (r_cubeMapping->integer && tr.numCubemaps) { int i; - vec_t shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; + float shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; for (i = 0; i < tr.numCubemaps; i++) { vec3_t diff; - vec_t length; + float length; VectorSubtract(point, tr.cubemapOrigins[i], diff); length = DotProduct(diff, diff); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 57e3c45eb7..09c0ddbccd 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -696,7 +696,7 @@ typedef struct { byte constantColor[4]; // for CGEN_CONST and AGEN_CONST - unsigned stateBits; // GLS_xxxx mask + uint32_t stateBits; // GLS_xxxx mask acff_t adjustColorsForFog; @@ -1916,7 +1916,7 @@ typedef struct glstate_s { qboolean finishCalled; int texEnv[2]; int faceCulling; - unsigned long glStateBits; + uint32_t glStateBits; uint32_t vertexAttribsState; uint32_t vertexAttribPointersSet; uint32_t vertexAttribsNewFrame; @@ -2450,7 +2450,7 @@ void GL_SelectTexture( int unit ); void GL_TextureMode( const char *string ); void GL_CheckErrs( char *file, int line ); #define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__) -void GL_State( unsigned long stateVector ); +void GL_State( uint32_t stateVector ); void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); void GL_TexEnv( int env ); @@ -2959,22 +2959,22 @@ RENDERER BACK END COMMAND QUEUE #define MAX_RENDER_COMMANDS 0x40000 -typedef struct { +typedef struct renderCommandList_s { byte cmds[MAX_RENDER_COMMANDS]; int used; } renderCommandList_t; -typedef struct { +typedef struct setColorCommand_s { int commandId; float color[4]; } setColorCommand_t; -typedef struct { +typedef struct drawBufferCommand_s { int commandId; int buffer; } drawBufferCommand_t; -typedef struct { +typedef struct subImageCommand_s { int commandId; image_t *image; int width; @@ -2982,16 +2982,16 @@ typedef struct { void *data; } subImageCommand_t; -typedef struct { +typedef struct swapBuffersCommand_s { int commandId; } swapBuffersCommand_t; -typedef struct { +typedef struct endFrameCommand_s { int commandId; int buffer; } endFrameCommand_t; -typedef struct { +typedef struct stretchPicCommand_s { int commandId; shader_t *shader; float x, y; @@ -3010,7 +3010,7 @@ typedef struct rotatePicCommand_s { float a; } rotatePicCommand_t; -typedef struct { +typedef struct drawSurfsCommand_s { int commandId; trRefdef_t refdef; viewParms_t viewParms; @@ -3018,7 +3018,7 @@ typedef struct { int numDrawSurfs; } drawSurfsCommand_t; -typedef struct { +typedef struct screenShotCommand_s { int commandId; int x; int y; @@ -3028,7 +3028,7 @@ typedef struct { qboolean jpeg; } screenshotCommand_t; -typedef struct { +typedef struct videoFrameCommand_s { int commandId; int width; int height; @@ -3037,25 +3037,23 @@ typedef struct { qboolean motionJpeg; } videoFrameCommand_t; -typedef struct -{ +typedef struct colorMaskCommand_s { int commandId; GLboolean rgba[4]; } colorMaskCommand_t; -typedef struct -{ +typedef struct clearDepthCommand_s { int commandId; } clearDepthCommand_t; -typedef struct { +typedef struct capShadowmapCommand_s { int commandId; int map; int cubeSide; } capShadowmapCommand_t; -typedef struct { +typedef struct postProcessCommand_s { int commandId; trRefdef_t refdef; viewParms_t viewParms; @@ -3086,8 +3084,8 @@ typedef enum { #define MAX_POLYVERTS 3000 // all of the information needed by the back end must be -// contained in a backEndData_t -typedef struct { +// contained in a backEndData_t. +typedef struct backEndData_s { drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; trRefEntity_t entities[MAX_REFENTITIES]; @@ -3100,7 +3098,7 @@ typedef struct { extern int max_polys; extern int max_polyverts; -extern backEndData_t *backEndData; // the second one may not be allocated +extern backEndData_t *backEndData; void *R_GetCommandBuffer( int bytes ); diff --git a/codemp/rd-rend2/tr_marks.cpp b/codemp/rd-rend2/tr_marks.cpp index 4d0705656c..4bee7a0054 100644 --- a/codemp/rd-rend2/tr_marks.cpp +++ b/codemp/rd-rend2/tr_marks.cpp @@ -40,7 +40,7 @@ Out must have space for two more vertexes than in #define SIDE_ON 2 static void R_ChopPolyBehindPlane( int numInPoints, vec3_t inPoints[MAX_VERTS_ON_POLY], int *numOutPoints, vec3_t outPoints[MAX_VERTS_ON_POLY], - vec3_t normal, vec_t dist, vec_t epsilon) { + vec3_t normal, float dist, float epsilon) { float dists[MAX_VERTS_ON_POLY+4] = { 0 }; int sides[MAX_VERTS_ON_POLY+4] = { 0 }; int counts[3]; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index b74a40c1cc..491329d39e 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -691,7 +691,7 @@ R_CullIQM */ static int R_CullIQM( iqmData_t *data, trRefEntity_t *ent ) { vec3_t bounds[2]; - vec_t *oldBounds, *newBounds; + float *oldBounds, *newBounds; int i; if (!data->bounds) { @@ -733,11 +733,11 @@ R_ComputeIQMFogNum int R_ComputeIQMFogNum( iqmData_t *data, trRefEntity_t *ent ) { int i, j; fog_t *fog; - const vec_t *bounds; - const vec_t defaultBounds[6] = { -8, -8, -8, 8, 8, 8 }; + const float *bounds; + const float defaultBounds[6] = { -8, -8, -8, 8, 8, 8 }; vec3_t diag, center; vec3_t localOrigin; - vec_t radius; + float radius; if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { return 0; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 6ea5f65468..8dd7ae6745 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1637,52 +1637,46 @@ void ParseMaterial( const char **text ) typedef struct infoParm_s { const char *name; - int clearSolid, surfaceFlags, contents; + uint32_t clearSolid, surfaceFlags, contents; } infoParm_t; infoParm_t infoParms[] = { - {"nonsolid", ~CONTENTS_SOLID, 0, 0 }, - {"nonopaque", ~CONTENTS_OPAQUE, 0, 0 }, - // server relevant contents - {"water", ~CONTENTS_SOLID, 0, CONTENTS_WATER }, - {"slime", ~CONTENTS_SOLID, 0, CONTENTS_SLIME }, // mildly damaging - {"lava", ~CONTENTS_SOLID, 0, CONTENTS_LAVA }, // very damaging - {"shotclip", ~CONTENTS_SOLID, 0, CONTENTS_SHOTCLIP }, - {"playerclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_PLAYERCLIP }, - {"monsterclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_MONSTERCLIP }, - {"botclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_BOTCLIP }, - {"trigger", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_TRIGGER }, - - // utility relevant attributes - {"trans", -1, 0, CONTENTS_TRANSLUCENT }, // don't eat contained surfaces - {"detail", -1, 0, CONTENTS_DETAIL }, // don't include in structural bsp - {"terrain", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_TERRAIN }, /* use special terrain collsion */ - {"outside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_OUTSIDE }, // volume is considered to be in the outside (i.e. not indoors) - {"inside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_INSIDE }, // volume is considered to be inside (i.e. indoors) - - - {"fog", ~CONTENTS_SOLID, 0, CONTENTS_FOG}, // carves surfaces entering - {"sky", -1, SURF_SKY, 0 }, // emit light from an environment map - {"lightfilter", 0, SURF_LIGHTFILTER, 0 }, // filter light going through it - {"alphashadow", 0, SURF_ALPHASHADOW, 0 }, // test light on a per-pixel basis - - // server attributes - {"slick", -1, SURF_SLICK, 0 }, - {"noimpact", 0, SURF_NOIMPACT, 0 }, // don't make impact explosions or marks - {"nomarks", 0, SURF_NOMARKS, 0 }, // don't make impact marks, but still explode - {"ladder", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_LADDER }, // climb up in it like water - {"abseil", ~(CONTENTS_SOLID|CONTENTS_OPAQUE),0,CONTENTS_ABSEIL }, // can abseil down this brush - - {"nodamage", -1, SURF_NODAMAGE, 0 }, - {"noimpact", -1, SURF_NOIMPACT, 0 }, /* don't make impact explosions or marks */ - {"nomarks", -1, SURF_NOMARKS, 0 }, /* don't make impact marks, but still explode */ - {"nodraw", -1, SURF_NODRAW, 0 }, /* don't generate a drawsurface (or a lightmap) */ - {"nosteps", -1, SURF_NOSTEPS, 0 }, - {"nodlight", -1, SURF_NODLIGHT, 0 }, /* don't ever add dynamic lights */ - {"metalsteps", -1, SURF_METALSTEPS,0 }, - {"nomiscents", -1, SURF_NOMISCENTS,0 }, /* No misc ents on this surface */ - {"forcefield", -1, SURF_FORCEFIELD,0 }, - {"forcesight", -1, SURF_FORCESIGHT,0 } + // Game content Flags + { "nonsolid", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_NONE }, // special hack to clear solid flag + { "nonopaque", ~CONTENTS_OPAQUE, SURF_NONE, CONTENTS_NONE }, // special hack to clear opaque flag + { "lava", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_LAVA }, // very damaging + { "slime", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_SLIME }, // mildly damaging + { "water", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_WATER }, // + { "fog", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_FOG}, // carves surfaces entering + { "shotclip", ~CONTENTS_SOLID, SURF_NONE, CONTENTS_SHOTCLIP }, // block shots, but not people + { "playerclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_PLAYERCLIP }, // block only the player + { "monsterclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_MONSTERCLIP }, // + { "botclip", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_BOTCLIP }, // for bots + { "trigger", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_TRIGGER }, // + { "nodrop", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_NODROP }, // don't drop items or leave bodies (death fog, lava, etc) + { "terrain", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_TERRAIN }, // use special terrain collsion + { "ladder", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_LADDER }, // climb up in it like water + { "abseil", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_ABSEIL }, // can abseil down this brush + { "outside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_OUTSIDE }, // volume is considered to be in the outside (i.e. not indoors) + { "inside", ~(CONTENTS_SOLID|CONTENTS_OPAQUE), SURF_NONE, CONTENTS_INSIDE }, // volume is considered to be inside (i.e. indoors) + + { "detail", CONTENTS_ALL, SURF_NONE, CONTENTS_DETAIL }, // don't include in structural bsp + { "trans", CONTENTS_ALL, SURF_NONE, CONTENTS_TRANSLUCENT }, // surface has an alpha component + + /* Game surface flags */ + { "sky", CONTENTS_ALL, SURF_SKY, CONTENTS_NONE }, // emit light from an environment map + { "slick", CONTENTS_ALL, SURF_SLICK, CONTENTS_NONE }, // + + { "nodamage", CONTENTS_ALL, SURF_NODAMAGE, CONTENTS_NONE }, // + { "noimpact", CONTENTS_ALL, SURF_NOIMPACT, CONTENTS_NONE }, // don't make impact explosions or marks + { "nomarks", CONTENTS_ALL, SURF_NOMARKS, CONTENTS_NONE }, // don't make impact marks, but still explode + { "nodraw", CONTENTS_ALL, SURF_NODRAW, CONTENTS_NONE }, // don't generate a drawsurface (or a lightmap) + { "nosteps", CONTENTS_ALL, SURF_NOSTEPS, CONTENTS_NONE }, // + { "nodlight", CONTENTS_ALL, SURF_NODLIGHT, CONTENTS_NONE }, // don't ever add dynamic lights + { "metalsteps", CONTENTS_ALL, SURF_METALSTEPS, CONTENTS_NONE }, // + { "nomiscents", CONTENTS_ALL, SURF_NOMISCENTS, CONTENTS_NONE }, // No misc ents on this surface + { "forcefield", CONTENTS_ALL, SURF_FORCEFIELD, CONTENTS_NONE }, // + { "forcesight", CONTENTS_ALL, SURF_FORCESIGHT, CONTENTS_NONE }, // only visible with force sight }; From 8acf256d21991f89aa9abfc3f7a53b4377709e32 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Fri, 29 Nov 2013 18:18:09 -0500 Subject: [PATCH 101/708] [MP] rend2: fixed miniRefEntity stub / EFX now working --- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_scene.cpp | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index ceb9f364d2..6a7bb7ac73 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1731,7 +1731,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.ClearScene = RE_ClearScene; // RE_ClearDecals re.AddRefEntityToScene = RE_AddRefEntityToScene; - re.AddMiniRefEntityToScene = stub_RE_AddMiniRefEntityToScene; + re.AddMiniRefEntityToScene = RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; re.AddDecalToScene = RE_AddDecalToScene; re.LightForPoint = R_LightForPoint; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 09c0ddbccd..1aadbc97f0 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2781,6 +2781,7 @@ void R_InitNextFrame( void ); void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); +void RE_AddMiniRefEntityToScene( const miniRefEntity_t *miniRefEnt ); void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary ); void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index e748e3468a..6dc115ba9c 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -224,6 +224,24 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { r_numentities++; } +/* +===================== +RE_AddMiniRefEntityToScene + +1:1 with how vanilla does it --eez +===================== +*/ +void RE_AddMiniRefEntityToScene( const miniRefEntity_t *miniRefEnt ) { + refEntity_t entity; + if(!tr.registered) + return; + if(!miniRefEnt) + return; + memset(&entity, 0, sizeof(entity)); + memcpy(&entity, miniRefEnt, sizeof(*miniRefEnt)); + RE_AddRefEntityToScene(&entity); +} + /* ===================== From 2f780fe8f847335d886a7311790d93a71aaa8ca8 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 29 Nov 2013 17:16:46 -0600 Subject: [PATCH 102/708] [MP] Rend2: struct naming from vanilla. --- codemp/rd-rend2/tr_local.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 1aadbc97f0..2668de3665 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -355,7 +355,7 @@ typedef struct dlight_s { // a trRefEntity_t has all the information passed in by // the client game, as well as some locally derived info -typedef struct { +typedef struct trRefEntity_s { refEntity_t e; float axisLength; // compensate for non-normalized axis From 460e79f00add119bdd876bdc293aa09b4c88fae7 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 29 Nov 2013 18:12:14 -0600 Subject: [PATCH 103/708] [MP] Rend2: use NULL instead of nullptr in CCacheManager::LoadFile to be consistent and not forcefully require vs2010 here. --- codemp/rd-rend2/tr_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index d9719d7ee0..4d9bd11632 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -100,7 +100,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb } int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); - if ( *ppFileBuffer == nullptr ) + if ( *ppFileBuffer == NULL ) { return qfalse; } From 90f6ae1eefb45f1126a762b650646fb85c72d35b Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 30 Nov 2013 09:44:05 -0600 Subject: [PATCH 104/708] [MP] Rend2: Bye bye md4 models. --- codemp/qcommon/qfiles.h | 86 +-------------- codemp/rd-rend2/tr_animation.cpp | 145 +------------------------- codemp/rd-rend2/tr_init.cpp | 43 ++++++-- codemp/rd-rend2/tr_local.h | 16 +-- codemp/rd-rend2/tr_main.cpp | 9 -- codemp/rd-rend2/tr_model.cpp | 174 +------------------------------ codemp/rd-rend2/tr_surface.cpp | 1 - 7 files changed, 46 insertions(+), 428 deletions(-) diff --git a/codemp/qcommon/qfiles.h b/codemp/qcommon/qfiles.h index bb88652f62..241bd8a0e3 100644 --- a/codemp/qcommon/qfiles.h +++ b/codemp/qcommon/qfiles.h @@ -149,95 +149,11 @@ typedef struct md3Header_s { /* ============================================================================== -MD4 file format +MDR file format ============================================================================== */ -#define MD4_IDENT (('4'<<24)+('P'<<16)+('D'<<8)+'I') -#define MD4_VERSION 1 -#define MD4_MAX_BONES 128 - -typedef struct { - int boneIndex; // these are indexes into the boneReferences, - float boneWeight; // not the global per-frame bone list - vec3_t offset; -} md4Weight_t; - -typedef struct { - vec3_t normal; - vec2_t texCoords; - int numWeights; - md4Weight_t weights[1]; // variable sized -} md4Vertex_t; - -typedef struct { - int indexes[3]; -} md4Triangle_t; - -typedef struct { - int ident; - - char name[MAX_QPATH]; // polyset name - char shader[MAX_QPATH]; - int shaderIndex; // for in-game use - - int ofsHeader; // this will be a negative number - - int numVerts; - int ofsVerts; - - int numTriangles; - int ofsTriangles; - - // Bone references are a set of ints representing all the bones - // present in any vertex weights for this surface. This is - // needed because a model may have surfaces that need to be - // drawn at different sort times, and we don't want to have - // to re-interpolate all the bones for each surface. - int numBoneReferences; - int ofsBoneReferences; - - int ofsEnd; // next surface follows -} md4Surface_t; - -typedef struct { - float matrix[3][4]; -} md4Bone_t; - -typedef struct { - vec3_t bounds[2]; // bounds of all surfaces of all LOD's for this frame - vec3_t localOrigin; // midpoint of bounds, used for sphere cull - float radius; // dist from localOrigin to corner - md4Bone_t bones[1]; // [numBones] -} md4Frame_t; - -typedef struct { - int numSurfaces; - int ofsSurfaces; // first surface, others follow - int ofsEnd; // next lod follows -} md4LOD_t; - -typedef struct { - int ident; - int version; - - char name[MAX_QPATH]; // model name - - // frames and bones are shared by all levels of detail - int numFrames; - int numBones; - int ofsBoneNames; // char name[ MAX_QPATH ] - int ofsFrames; // md4Frame_t[numFrames] - - // each level of detail has completely separate sets of surfaces - int numLODs; - int ofsLODs; - - int ofsEnd; // end of file -} md4Header_t; - - /* * Here are the definitions for Ravensoft's model format of md4. Raven stores their * playermodels in .mdr files, in some games, which are pretty much like the md4 diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index b4bfdcb4af..8e5440ce81 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -33,143 +33,6 @@ frame. */ -/* -============== -R_AddAnimSurfaces -============== -*/ -void R_AddAnimSurfaces( trRefEntity_t *ent ) { - md4Header_t *header; - md4Surface_t *surface; - md4LOD_t *lod; - shader_t *shader; - int cubemapIndex; - int i; - - header = (md4Header_t *) tr.currentModel->data.md4; - lod = (md4LOD_t *)( (byte *)header + header->ofsLODs ); - cubemapIndex = R_CubemapForPoint(ent->e.origin); - - surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces ); - for ( i = 0 ; i < lod->numSurfaces ; i++ ) { - shader = R_GetShaderByHandle( surface->shaderIndex ); - R_AddDrawSurf( (surfaceType_t *)surface, shader, 0 /*fogNum*/, qfalse, qfalse, cubemapIndex ); - surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd ); - } -} - -/* -============== -RB_SurfaceAnim -============== -*/ -void RB_SurfaceAnim( md4Surface_t *surface ) { - int i, j, k; - float frontlerp, backlerp; - int *triangles; - int indexes; - int baseIndex, baseVertex; - int numVerts; - md4Vertex_t *v; - md4Bone_t bones[MD4_MAX_BONES]; - md4Bone_t *bonePtr, *bone; - md4Header_t *header; - md4Frame_t *frame; - md4Frame_t *oldFrame; - int frameSize; - - - if ( backEnd.currentEntity->e.oldframe == backEnd.currentEntity->e.frame ) { - backlerp = 0; - frontlerp = 1; - } else { - backlerp = backEnd.currentEntity->e.backlerp; - frontlerp = 1.0f - backlerp; - } - header = (md4Header_t *)((byte *)surface + surface->ofsHeader); - - frameSize = (size_t)( &((md4Frame_t *)0)->bones[ header->numBones ] ); - - frame = (md4Frame_t *)((byte *)header + header->ofsFrames + - backEnd.currentEntity->e.frame * frameSize ); - oldFrame = (md4Frame_t *)((byte *)header + header->ofsFrames + - backEnd.currentEntity->e.oldframe * frameSize ); - - RB_CheckOverflow( surface->numVerts, surface->numTriangles * 3 ); - - triangles = (int *) ((byte *)surface + surface->ofsTriangles); - indexes = surface->numTriangles * 3; - baseIndex = tess.numIndexes; - baseVertex = tess.numVertexes; - for (j = 0 ; j < indexes ; j++) { - tess.indexes[baseIndex + j] = baseIndex + triangles[j]; - } - tess.numIndexes += indexes; - - // - // lerp all the needed bones - // - if ( !backlerp ) { - // no lerping needed - bonePtr = frame->bones; - } else { - bonePtr = bones; - for ( i = 0 ; i < header->numBones*12 ; i++ ) { - ((float *)bonePtr)[i] = frontlerp * ((float *)frame->bones)[i] - + backlerp * ((float *)oldFrame->bones)[i]; - } - } - - // - // deform the vertexes by the lerped bones - // - numVerts = surface->numVerts; - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts + 12); - v = (md4Vertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < numVerts; j++ ) { - vec3_t tempVert, tempNormal; - md4Weight_t *w; - - VectorClear( tempVert ); - VectorClear( tempNormal ); - w = v->weights; - for ( k = 0 ; k < v->numWeights ; k++, w++ ) { - bone = bonePtr + w->boneIndex; - - tempVert[0] += w->boneWeight * ( DotProduct( bone->matrix[0], w->offset ) + bone->matrix[0][3] ); - tempVert[1] += w->boneWeight * ( DotProduct( bone->matrix[1], w->offset ) + bone->matrix[1][3] ); - tempVert[2] += w->boneWeight * ( DotProduct( bone->matrix[2], w->offset ) + bone->matrix[2][3] ); - - tempNormal[0] += w->boneWeight * DotProduct( bone->matrix[0], v->normal ); - tempNormal[1] += w->boneWeight * DotProduct( bone->matrix[1], v->normal ); - tempNormal[2] += w->boneWeight * DotProduct( bone->matrix[2], v->normal ); - } - - tess.xyz[baseVertex + j][0] = tempVert[0]; - tess.xyz[baseVertex + j][1] = tempVert[1]; - tess.xyz[baseVertex + j][2] = tempVert[2]; - - tess.normal[baseVertex + j][0] = tempNormal[0]; - tess.normal[baseVertex + j][1] = tempNormal[1]; - tess.normal[baseVertex + j][2] = tempNormal[2]; - - tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; - tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; - - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 ); - v = (md4Vertex_t *)&v->weights[v->numWeights]; - } - - tess.numVertexes += surface->numVerts; -} - - // copied and adapted from tr_mesh.c @@ -198,7 +61,7 @@ static int R_MDRCullModel( mdrHeader_t *header, trRefEntity_t *ent ) { switch ( R_CullLocalPointAndRadius( newFrame->localOrigin, newFrame->radius ) ) { // Ummm... yeah yeah I know we don't really have an md3 here.. but we pretend - // we do. After all, the purpose of md4s are not that different, are they? + // we do. After all, the purpose of mdrs are not that different, are they? case CULL_OUT: tr.pc.c_sphere_cull_md3_out++; @@ -328,7 +191,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { int cubemapIndex; qboolean personalModel; - header = (mdrHeader_t *)tr.currentModel->data.md4; + header = (mdrHeader_t *)tr.currentModel->data.mdr; personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); @@ -448,7 +311,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { RB_MDRSurfaceAnim ============== */ -void RB_MDRSurfaceAnim( md4Surface_t *surface ) +void RB_MDRSurfaceAnim( mdrSurface_t *surface ) { int i, j, k; float frontlerp, backlerp; @@ -460,7 +323,7 @@ void RB_MDRSurfaceAnim( md4Surface_t *surface ) mdrHeader_t *header; mdrFrame_t *frame; mdrFrame_t *oldFrame; - mdrBone_t bones[MD4_MAX_BONES], *bonePtr, *bone; + mdrBone_t bones[MDR_MAX_BONES], *bonePtr, *bone; int frameSize; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 6a7bb7ac73..5ec4a786a8 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -603,11 +603,26 @@ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) ri->Hunk_FreeTempMemory(allbuf); } -/* +/* ================== -RB_TakeScreenshotJPEG +R_TakeScreenshotPNG ================== */ +void R_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName ) { + byte *buffer; + size_t offset = 0; + int padlen; + + buffer = RB_ReadPixels( x, y, width, height, &offset, &padlen ); + RE_SavePNG( fileName, buffer, width, height, 3 ); + ri->Hunk_FreeTempMemory( buffer ); +} + +/* +================== +RB_TakeScreenshotJPEG +================== +*/ void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) { @@ -640,11 +655,17 @@ const void *RB_TakeScreenshotCmd( const void *data ) { if(tess.numIndexes) RB_EndSurface(); - if (cmd->jpeg) - RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); - else - RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName); - + switch( cmd->format ) { + case SSF_JPEG: + RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); + break; + case SSF_TGA: + RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); + break; + case SSF_PNG: + break; + } + return (const void *)(cmd + 1); } @@ -653,7 +674,7 @@ const void *RB_TakeScreenshotCmd( const void *data ) { R_TakeScreenshot ================== */ -void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean jpeg ) { +void R_TakeScreenshot( int x, int y, int width, int height, char *name, screenshotFormat_t format ) { static char fileName[MAX_OSPATH]; // bad things if two screenshots per frame? screenshotCommand_t *cmd; @@ -669,7 +690,7 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, qboolean cmd->height = height; Q_strncpyz( fileName, name, sizeof(fileName) ); cmd->fileName = fileName; - cmd->jpeg = jpeg; + cmd->format = format; } /* @@ -1674,7 +1695,7 @@ void RE_SetLightStyle(int style, int color) } } -void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} +void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} @@ -1731,7 +1752,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.ClearScene = RE_ClearScene; // RE_ClearDecals re.AddRefEntityToScene = RE_AddRefEntityToScene; - re.AddMiniRefEntityToScene = RE_AddMiniRefEntityToScene; + re.AddMiniRefEntityToScene = stub_RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; re.AddDecalToScene = RE_AddDecalToScene; re.LightForPoint = R_LightForPoint; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2668de3665..6860065639 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1247,7 +1247,6 @@ typedef enum { SF_TRIANGLES, SF_POLY, SF_MDV, - SF_MD4, SF_MDR, SF_IQM, SF_MDX, @@ -1767,7 +1766,6 @@ typedef enum { MOD_BAD, MOD_BRUSH, MOD_MESH, - MOD_MD4, MOD_MDR, MOD_IQM, /* @@ -1821,7 +1819,6 @@ typedef struct model_s { { bmodel_t *bmodel; // type == MOD_BRUSH mdvModel_t *mdv[MD3_MAX_LODS]; // type == MOD_MESH - md4Header_t *md4; // type == MOD_MD4 mdrHeader_t *mdr; // type == MOD_MDR iqmData_t *iqm; // type == MOD_IQM mdxmData_t *glm; // type == MOD_MDXM @@ -2817,11 +2814,8 @@ ANIMATED MODELS ============================================================= */ -// void R_MakeAnimModel( model_t *model ); haven't seen this one really, so not needed I guess. -void R_AddAnimSurfaces( trRefEntity_t *ent ); -void RB_SurfaceAnim( md4Surface_t *surfType ); void R_MDRAddAnimSurfaces( trRefEntity_t *ent ); -void RB_MDRSurfaceAnim( md4Surface_t *surface ); +void RB_MDRSurfaceAnim( mdrSurface_t *surface ); qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name ); void R_AddIQMSurfaces( trRefEntity_t *ent ); void RB_IQMSurfaceAnim( surfaceType_t *surface ); @@ -3019,6 +3013,12 @@ typedef struct drawSurfsCommand_s { int numDrawSurfs; } drawSurfsCommand_t; +typedef enum { + SSF_JPEG, + SSF_TGA, + SSF_PNG +} screenshotFormat_t; + typedef struct screenShotCommand_s { int commandId; int x; @@ -3026,7 +3026,7 @@ typedef struct screenShotCommand_s { int width; int height; char *fileName; - qboolean jpeg; + screenshotFormat_t format; } screenshotCommand_t; typedef struct videoFrameCommand_s { diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index b38565a1f9..04b4d10320 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2013,9 +2013,6 @@ static void R_AddEntitySurface (int entityNum) case MOD_MESH: R_AddMD3Surfaces( ent ); break; - case MOD_MD4: - R_AddAnimSurfaces( ent ); - break; case MOD_MDR: R_MDRAddAnimSurfaces( ent ); break; @@ -2316,12 +2313,6 @@ void R_RenderPshadowMaps(const refdef_t *fd) } break; - case MOD_MD4: - { - // FIXME: actually calculate the radius and bounds, this is a horrible hack - radius = r_pshadowDist->value / 2.0f; - } - break; case MOD_MDR: { // FIXME: never actually tested this diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 3b2aa12f18..990aeb386f 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA static qboolean R_LoadMD3(model_t *mod, int lod, void *buffer, const char *modName); -static qboolean R_LoadMD4(model_t *mod, void *buffer, const char *name ); static qboolean R_LoadMDR(model_t *mod, void *buffer, int filesize, const char *name ); /* @@ -77,9 +76,6 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) switch(ident) { - case MD4_IDENT: - loaded = R_LoadMD4(mod, buf, name); - break; case MD3_IDENT: loaded = R_LoadMD3(mod, lod, buf, namebuf); break; @@ -210,7 +206,6 @@ static modelExtToLoaderMap_t modelLoaders[ ] = { { "iqm", R_RegisterIQM }, { "mdr", R_RegisterMDR }, - { "md4", R_RegisterMD3 }, { "md3", R_RegisterMD3 }, /* Ghoul 2 Insert Start @@ -864,7 +859,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char LL(pinmodel->ofsFrames); // This is a model that uses some type of compressed Bones. We don't want to uncompress every bone for each rendered frame - // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target md4. + // over and over again, we'll uncompress it in this function already, so we must adjust the size of the target mdr. if(pinmodel->ofsFrames < 0) { // mdrFrame_t is larger than mdrCompFrame_t: @@ -1161,162 +1156,6 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char return qtrue; } -/* -================= -R_LoadMD4 -================= -*/ - -static qboolean R_LoadMD4( model_t *mod, void *buffer, const char *mod_name ) { - int i, j, k, lodindex; - md4Header_t *pinmodel, *md4; - md4Frame_t *frame; - md4LOD_t *lod; - md4Surface_t *surf; - md4Triangle_t *tri; - md4Vertex_t *v; - int version; - int size; - shader_t *sh; - int frameSize; - - pinmodel = (md4Header_t *)buffer; - - version = LittleLong (pinmodel->version); - if (version != MD4_VERSION) { - ri->Printf( PRINT_WARNING, "R_LoadMD4: %s has wrong version (%i should be %i)\n", - mod_name, version, MD4_VERSION); - return qfalse; - } - - mod->type = MOD_MD4; - size = LittleLong(pinmodel->ofsEnd); - mod->dataSize += size; - mod->data.md4 = md4 = (md4Header_t *)ri->Hunk_Alloc( size, h_low ); - - Com_Memcpy(md4, buffer, size); - - LL(md4->ident); - LL(md4->version); - LL(md4->numFrames); - LL(md4->numBones); - LL(md4->numLODs); - LL(md4->ofsFrames); - LL(md4->ofsLODs); - md4->ofsEnd = size; - - if ( md4->numFrames < 1 ) { - ri->Printf( PRINT_WARNING, "R_LoadMD4: %s has no frames\n", mod_name ); - return qfalse; - } - - // we don't need to swap tags in the renderer, they aren't used - - // swap all the frames - frameSize = (size_t)( &((md4Frame_t *)0)->bones[ md4->numBones ] ); - for ( i = 0 ; i < md4->numFrames ; i++) { - frame = (md4Frame_t *) ( (byte *)md4 + md4->ofsFrames + i * frameSize ); - frame->radius = LittleFloat( frame->radius ); - for ( j = 0 ; j < 3 ; j++ ) { - frame->bounds[0][j] = LittleFloat( frame->bounds[0][j] ); - frame->bounds[1][j] = LittleFloat( frame->bounds[1][j] ); - frame->localOrigin[j] = LittleFloat( frame->localOrigin[j] ); - } - for ( j = 0 ; j < md4->numBones * sizeof( md4Bone_t ) / 4 ; j++ ) { - ((float *)frame->bones)[j] = LittleFloat( ((float *)frame->bones)[j] ); - } - } - - // swap all the LOD's - lod = (md4LOD_t *) ( (byte *)md4 + md4->ofsLODs ); - for ( lodindex = 0 ; lodindex < md4->numLODs ; lodindex++ ) { - - // swap all the surfaces - surf = (md4Surface_t *) ( (byte *)lod + lod->ofsSurfaces ); - for ( i = 0 ; i < lod->numSurfaces ; i++) { - LL(surf->ident); - LL(surf->numTriangles); - LL(surf->ofsTriangles); - LL(surf->numVerts); - LL(surf->ofsVerts); - LL(surf->ofsEnd); - - if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i verts on %s (%i).\n", - mod_name, SHADER_MAX_VERTEXES-1, surf->name[0] ? surf->name : "a surface", - surf->numVerts ); - return qfalse; - } - if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadMD4: %s has more than %i triangles on %s (%i).\n", - mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", - surf->numTriangles ); - return qfalse; - } - - // change to surface identifier - surf->ident = SF_MD4; - - // lowercase the surface name so skin compares are faster - Q_strlwr( surf->name ); - - // register the shaders - sh = R_FindShader( surf->shader, LIGHTMAP_NONE, qtrue ); - if ( sh->defaultShader ) { - surf->shaderIndex = 0; - } else { - surf->shaderIndex = sh->index; - } - - // swap all the triangles - tri = (md4Triangle_t *) ( (byte *)surf + surf->ofsTriangles ); - for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) { - LL(tri->indexes[0]); - LL(tri->indexes[1]); - LL(tri->indexes[2]); - } - - // swap all the vertexes - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts + 12); - v = (md4Vertex_t *) ( (byte *)surf + surf->ofsVerts); - for ( j = 0 ; j < surf->numVerts ; j++ ) { - v->normal[0] = LittleFloat( v->normal[0] ); - v->normal[1] = LittleFloat( v->normal[1] ); - v->normal[2] = LittleFloat( v->normal[2] ); - - v->texCoords[0] = LittleFloat( v->texCoords[0] ); - v->texCoords[1] = LittleFloat( v->texCoords[1] ); - - v->numWeights = LittleLong( v->numWeights ); - - for ( k = 0 ; k < v->numWeights ; k++ ) { - v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex ); - v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight ); - v->weights[k].offset[0] = LittleFloat( v->weights[k].offset[0] ); - v->weights[k].offset[1] = LittleFloat( v->weights[k].offset[1] ); - v->weights[k].offset[2] = LittleFloat( v->weights[k].offset[2] ); - } - // FIXME - // This makes TFC's skeletons work. Shouldn't be necessary anymore, but left - // in for reference. - //v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights] + 12 ); - v = (md4Vertex_t *)( ( byte * )&v->weights[v->numWeights]); - } - - // find the next surface - surf = (md4Surface_t *)( (byte *)surf + surf->ofsEnd ); - } - - // find the next LOD - lod = (md4LOD_t *)( (byte *)lod + lod->ofsEnd ); - } - - return qtrue; -} - //============================================================================= @@ -1558,17 +1397,6 @@ void R_ModelBounds( qhandle_t handle, vec3_t mins, vec3_t maxs ) { VectorCopy( frame->bounds[0], mins ); VectorCopy( frame->bounds[1], maxs ); - return; - } else if (model->type == MOD_MD4) { - md4Header_t *header; - md4Frame_t *frame; - - header = model->data.md4; - frame = (md4Frame_t *) ((byte *)header + header->ofsFrames); - - VectorCopy( frame->bounds[0], mins ); - VectorCopy( frame->bounds[1], maxs ); - return; } else if (model->type == MOD_MDR) { mdrHeader_t *header; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 1e74472b6b..320617193c 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2127,7 +2127,6 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, (void(*)(void*))RB_SurfacePolychain, // SF_POLY, (void(*)(void*))RB_SurfaceMesh, // SF_MDV, - (void(*)(void*))RB_SurfaceAnim, // SF_MD4, (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, (void(*)(void*))RB_IQMSurfaceAnim, // SF_IQM, (void(*)(void*))RB_SurfaceGhoul, // SF_MDX, From 973b34a2bd60b2a780deb9163930d79b883f6583 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 30 Nov 2013 11:32:01 -0600 Subject: [PATCH 105/708] [MP] Rend2: Fix a remaining vec_t instance. --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5ec4a786a8..c05b666951 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1695,7 +1695,7 @@ void RE_SetLightStyle(int style, int color) } } -void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, vec_t *normal) {} +void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} From 12d65e1d8b2b3dab9fd9d653cfa7849c1511775c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 30 Nov 2013 11:45:16 -0600 Subject: [PATCH 106/708] [MP] Rend2: Fix mini ref ent merge fail. --- codemp/rd-rend2/tr_init.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c05b666951..382a632a16 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1697,7 +1697,6 @@ void RE_SetLightStyle(int style, int color) void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} -void stub_RE_AddMiniRefEntityToScene ( const miniRefEntity_t *ent ) {} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} /* @@ -1752,7 +1751,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.ClearScene = RE_ClearScene; // RE_ClearDecals re.AddRefEntityToScene = RE_AddRefEntityToScene; - re.AddMiniRefEntityToScene = stub_RE_AddMiniRefEntityToScene; + re.AddMiniRefEntityToScene = RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; re.AddDecalToScene = RE_AddDecalToScene; re.LightForPoint = R_LightForPoint; From 89ce6d53593862ec3c8e895589acc5f4ffb0d76b Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 30 Nov 2013 11:46:41 -0600 Subject: [PATCH 107/708] [MP] Rend2: Fully migrate the proper screenshot code and then some to rend2. --- codemp/rd-rend2/tr_init.cpp | 194 +++++++++++++++--------------------- codemp/rd-rend2/tr_local.h | 4 +- 2 files changed, 82 insertions(+), 116 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 382a632a16..b1a4c92114 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -608,12 +608,18 @@ void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) R_TakeScreenshotPNG ================== */ -void R_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName ) { +void RB_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName ) { byte *buffer; - size_t offset = 0; + size_t offset = 0, memcount; int padlen; buffer = RB_ReadPixels( x, y, width, height, &offset, &padlen ); + memcount = (width * 3 + padlen) * height; + + // gamma correct + if(glConfig.deviceSupportsGamma) + R_GammaCorrect(buffer + offset, memcount); + RE_SavePNG( fileName, buffer, width, height, 3 ); ri->Hunk_FreeTempMemory( buffer ); } @@ -663,6 +669,7 @@ const void *RB_TakeScreenshotCmd( const void *data ) { RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); break; case SSF_PNG: + RB_TakeScreenshotPNG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); break; } @@ -698,49 +705,14 @@ void R_TakeScreenshot( int x, int y, int width, int height, char *name, screensh R_ScreenshotFilename ================== */ -void R_ScreenshotFilename( int lastNumber, char *fileName ) { - int a,b,c,d; - - if ( lastNumber < 0 || lastNumber > 9999 ) { - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.tga" ); - return; - } +void R_ScreenshotFilename( char *buf, int bufSize, const char *ext ) { + time_t rawtime; + char timeStr[32] = {0}; // should really only reach ~19 chars - a = lastNumber / 1000; - lastNumber -= a*1000; - b = lastNumber / 100; - lastNumber -= b*100; - c = lastNumber / 10; - lastNumber -= c*10; - d = lastNumber; + time( &rawtime ); + strftime( timeStr, sizeof( timeStr ), "%Y-%m-%d_%H-%M-%S", localtime( &rawtime ) ); // or gmtime - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.tga" - , a, b, c, d ); -} - -/* -================== -R_ScreenshotFilename -================== -*/ -void R_ScreenshotFilenameJPEG( int lastNumber, char *fileName ) { - int a,b,c,d; - - if ( lastNumber < 0 || lastNumber > 9999 ) { - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot9999.jpg" ); - return; - } - - a = lastNumber / 1000; - lastNumber -= a*1000; - b = lastNumber / 100; - lastNumber -= b*100; - c = lastNumber / 10; - lastNumber -= c*10; - d = lastNumber; - - Com_sprintf( fileName, MAX_OSPATH, "screenshots/shot%i%i%i%i.jpg" - , a, b, c, d ); + Com_sprintf( buf, bufSize, "screenshots/shot%s%s", timeStr, ext ); } /* @@ -812,7 +784,7 @@ void R_LevelShot( void ) { /* ================== -R_ScreenShot_f +R_ScreenShotTGA_f screenshot screenshot [silent] @@ -822,111 +794,101 @@ screenshot [filename] Doesn't print the pacifier message if there is a second arg ================== */ -void R_ScreenShot_f (void) { - char checkname[MAX_OSPATH]; - static int lastNumber = -1; - qboolean silent; +void R_ScreenShotTGA_f (void) { + char checkname[MAX_OSPATH] = {0}; + qboolean silent = qfalse; if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) silent = qtrue; - } else { - silent = qfalse; - } if ( ri->Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.tga", ri->Cmd_Argv( 1 ) ); - } else { - // scan for a free filename - - // if we have saved a previous screenshot, don't scan - // again, because recording demo avis can involve - // thousands of shots - if ( lastNumber == -1 ) { - lastNumber = 0; - } - // scan for a free number - for ( ; lastNumber <= 9999 ; lastNumber++ ) { - R_ScreenshotFilename( lastNumber, checkname ); - - if (!ri->FS_FileExists( checkname )) - { - break; // file doesn't exist - } - } + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.tga", ri->Cmd_Argv( 1 ) ); + } + else { + // timestamp the file + R_ScreenshotFilename( checkname, sizeof( checkname ), ".tga" ); - if ( lastNumber >= 9999 ) { - ri->Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + if ( ri->FS_FileExists( checkname ) ) { + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } - - lastNumber++; } - R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qfalse ); + R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_TGA ); - if ( !silent ) { + if ( !silent ) ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); +} + +void R_ScreenShotPNG_f (void) { + char checkname[MAX_OSPATH] = {0}; + qboolean silent = qfalse; + + if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { + R_LevelShot(); + return; + } + + if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) + silent = qtrue; + + if ( ri->Cmd_Argc() == 2 && !silent ) { + // explicit filename + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.png", ri->Cmd_Argv( 1 ) ); + } + else { + // timestamp the file + R_ScreenshotFilename( checkname, sizeof( checkname ), ".png" ); + + if ( ri->FS_FileExists( checkname ) ) { + Com_Printf( "ScreenShot: Couldn't create a file\n"); + return; + } } -} + + R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_PNG ); + + if ( !silent ) + ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); +} void R_ScreenShotJPEG_f (void) { - char checkname[MAX_OSPATH]; - static int lastNumber = -1; - qboolean silent; + char checkname[MAX_OSPATH] = {0}; + qboolean silent = qfalse; if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) { + if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) silent = qtrue; - } else { - silent = qfalse; - } if ( ri->Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, MAX_OSPATH, "screenshots/%s.jpg", ri->Cmd_Argv( 1 ) ); - } else { - // scan for a free filename - - // if we have saved a previous screenshot, don't scan - // again, because recording demo avis can involve - // thousands of shots - if ( lastNumber == -1 ) { - lastNumber = 0; - } - // scan for a free number - for ( ; lastNumber <= 9999 ; lastNumber++ ) { - R_ScreenshotFilenameJPEG( lastNumber, checkname ); - - if (!ri->FS_FileExists( checkname )) - { - break; // file doesn't exist - } - } + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.jpg", ri->Cmd_Argv( 1 ) ); + } + else { + // timestamp the file + R_ScreenshotFilename( checkname, sizeof( checkname ), ".jpg" ); - if ( lastNumber == 10000 ) { - ri->Printf (PRINT_ALL, "ScreenShot: Couldn't create a file\n"); + if ( ri->FS_FileExists( checkname ) ) { + Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } - - lastNumber++; } - R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, qtrue ); + R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_JPEG ); - if ( !silent ) { + if ( !silent ) ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); - } -} +} //============================================================================ @@ -1450,8 +1412,9 @@ Ghoul2 Insert End ri->Cmd_AddCommand( "fontlist", R_FontList_f ); ri->Cmd_AddCommand( "modellist", R_Modellist_f ); ri->Cmd_AddCommand( "modelist", R_ModeList_f ); - ri->Cmd_AddCommand( "screenshot", R_ScreenShot_f ); - ri->Cmd_AddCommand( "screenshotJPEG", R_ScreenShotJPEG_f ); + ri->Cmd_AddCommand( "screenshot", R_ScreenShotJPEG_f ); + ri->Cmd_AddCommand( "screenshot_png", R_ScreenShotPNG_f ); + ri->Cmd_AddCommand( "screenshot_tga", R_ScreenShotTGA_f ); ri->Cmd_AddCommand( "gfxinfo", GfxInfo_f ); ri->Cmd_AddCommand( "minimize", GLimp_Minimize ); ri->Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); @@ -1588,8 +1551,9 @@ void RE_Shutdown( qboolean destroyWindow ) { ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); ri->Cmd_RemoveCommand ("modellist"); - ri->Cmd_RemoveCommand ("screenshotJPEG"); ri->Cmd_RemoveCommand ("screenshot"); + ri->Cmd_RemoveCommand ("screenshot_png"); + ri->Cmd_RemoveCommand ("screenshot_tga"); ri->Cmd_RemoveCommand ("imagelist"); ri->Cmd_RemoveCommand ("shaderlist"); ri->Cmd_RemoveCommand ("skinlist"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6860065639..0b5c79c244 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2486,7 +2486,9 @@ void R_SkinList_f( void ); void R_FontList_f( void ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 const void *RB_TakeScreenshotCmd( const void *data ); -void R_ScreenShot_f( void ); +void R_ScreenShotTGA_f( void ); +void R_ScreenShotPNG_f( void ); +void R_ScreenShotJPEG_f( void ); void R_InitFogTable( void ); float R_FogFactor( float s, float t ); From 855736c347965ee046531601df34ec223ac3dcf2 Mon Sep 17 00:00:00 2001 From: eezstreet Date: Sun, 1 Dec 2013 17:43:25 -0800 Subject: [PATCH 108/708] [MP/SP] Cleaned up renderer API calls --- code/rd-common/tr_public.h | 335 ++++++++++++++++------------------- codemp/rd-common/tr_public.h | 50 +++--- 2 files changed, 181 insertions(+), 204 deletions(-) diff --git a/code/rd-common/tr_public.h b/code/rd-common/tr_public.h index e5ad8edfba..05fab12872 100644 --- a/code/rd-common/tr_public.h +++ b/code/rd-common/tr_public.h @@ -144,7 +144,7 @@ typedef struct { // called before the library is unloaded // if the system is just reconfiguring, pass destroyWindow = qfalse, // which will keep the screen from flashing to the desktop. - void (*Shutdown)( qboolean destroyWindow ); + void (*Shutdown) ( qboolean destroyWindow ); // All data that will be used in a level should be // registered before rendering any frames to prevent disk hits, @@ -155,235 +155,212 @@ typedef struct { // and returns the current gl configuration, including screen width // and height, which can be used by the client to intelligently // size display elements - void (*BeginRegistration)( glconfig_t *config ); - qhandle_t (*RegisterModel)( const char *name ); - qhandle_t (*RegisterSkin)( const char *name ); - int (*GetAnimationCFG)(const char *psCFGFilename, char *psDest, int iDestSize); - qhandle_t (*RegisterShader)( const char *name ); - qhandle_t (*RegisterShaderNoMip)( const char *name ); - void (*LoadWorld)( const char *name ); - void (*R_LoadImage)( const char *name, byte **pic, int *width, int *height ); + void (*BeginRegistration) ( glconfig_t *config ); + qhandle_t (*RegisterModel) ( const char *name ); + qhandle_t (*RegisterSkin) ( const char *name ); + int (*GetAnimationCFG) ( const char *psCFGFilename, char *psDest, int iDestSize ); // NOT IN MP + qhandle_t (*RegisterShader) ( const char *name ); + qhandle_t (*RegisterShaderNoMip) ( const char *name ); + void (*LoadWorld) ( const char *name ); + void (*R_LoadImage) ( const char *name, byte **pic, int *width, int *height ); // (possibly) NOT IN MP // these two functions added to help with the new model alloc scheme... // - void (*RegisterMedia_LevelLoadBegin)(const char *psMapName, ForceReload_e eForceReload, qboolean bAllowScreenDissolve); - void (*RegisterMedia_LevelLoadEnd)(void); - int (*RegisterMedia_GetLevel)(void); - qboolean (*RegisterModels_LevelLoadEnd)(qboolean bDeleteEverythingNotUsedThisLevel ); - qboolean (*RegisterImages_LevelLoadEnd)(void); + void (*RegisterMedia_LevelLoadBegin) ( const char *psMapName, ForceReload_e eForceReload, qboolean bAllowScreenDissolve ); + void (*RegisterMedia_LevelLoadEnd) ( void ); + int (*RegisterMedia_GetLevel) ( void ); + qboolean (*RegisterModels_LevelLoadEnd) ( qboolean bDeleteEverythingNotUsedThisLevel ); + qboolean (*RegisterImages_LevelLoadEnd) ( void ); // the vis data is a large enough block of data that we go to the trouble // of sharing it with the clipmodel subsystem - void (*SetWorldVisData)( const byte *vis ); + void (*SetWorldVisData) ( const byte *vis ); // EndRegistration will draw a tiny polygon with each texture, forcing // them to be loaded into card memory - void (*EndRegistration)( void ); + void (*EndRegistration) ( void ); // a scene is built up by calls to R_ClearScene and the various R_Add functions. // Nothing is drawn until R_RenderScene is called. - void (*ClearScene)( void ); - void (*AddRefEntityToScene)( const refEntity_t *re ); - void (*AddPolyToScene)( qhandle_t hShader , int numVerts, const polyVert_t *verts ); - void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b ); - void (*RenderScene)( const refdef_t *fd ); - qboolean(*GetLighting)( const vec3_t org, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir); - - void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1 - void (*DrawStretchPic) ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white - void (*DrawRotatePic) ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, float a1, qhandle_t hShader ); // 0 = white - void (*DrawRotatePic2) ( float x, float y, float w, float h, - float s1, float t1, float s2, float t2, float a1, qhandle_t hShader ); // 0 = white - void (*LAGoggles)(void); - void (*Scissor) ( float x, float y, float w, float h); // 0 = white + void (*ClearScene) ( void ); + void (*AddRefEntityToScene) ( const refEntity_t *re ); + void (*AddPolyToScene) ( qhandle_t hShader , int numVerts, const polyVert_t *verts ); + void (*AddLightToScene) ( const vec3_t org, float intensity, float r, float g, float b ); + void (*RenderScene) ( const refdef_t *fd ); + qboolean (*GetLighting) ( const vec3_t org, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); // NOT IN MP + + void (*SetColor) ( const float *rgba ); // NULL = 1,1,1,1 + void (*DrawStretchPic) ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); + void (*DrawRotatePic) ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader ); + void (*DrawRotatePic2) ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a1, qhandle_t hShader ); + void (*LAGoggles) ( void ); // NOT IN MP + void (*Scissor) ( float x, float y, float w, float h); // NOT IN MP // Draw images for cinematic rendering, pass as 32 bit rgba - void (*DrawStretchRaw) (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); - void (*UploadCinematic) (int cols, int rows, const byte *data, int client, qboolean dirty); + void (*DrawStretchRaw) ( int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty ); + void (*UploadCinematic) ( int cols, int rows, const byte *data, int client, qboolean dirty ); - void (*BeginFrame)( stereoFrame_t stereoFrame ); + void (*BeginFrame) ( stereoFrame_t stereoFrame ); // if the pointers are not NULL, timing info will be returned - void (*EndFrame)( int *frontEndMsec, int *backEndMsec ); + void (*EndFrame) ( int *frontEndMsec, int *backEndMsec ); - qboolean (*ProcessDissolve)(void); - qboolean (*InitDissolve)(qboolean bForceCircularExtroWipe); + qboolean (*ProcessDissolve) ( void ); // NOT IN MP + qboolean (*InitDissolve) ( qboolean bForceCircularExtroWipe ); // NOT IN MP // for use with save-games mainly... - void (*GetScreenShot)(byte *data, int w, int h); + void (*GetScreenShot) ( byte *data, int w, int h ); // NOT IN MP // this is so you can get access to raw pixels from a graphics format (TGA/JPG/BMP etc), // currently only the save game uses it (to make raw shots for the autosaves) // - byte* (*TempRawImage_ReadFromFile)(const char *psLocalFilename, int *piWidth, int *piHeight, byte *pbReSampleBuffer, qboolean qbVertFlip); - void (*TempRawImage_CleanUp)(); + byte* (*TempRawImage_ReadFromFile) ( const char *psLocalFilename, int *piWidth, int *piHeight, byte *pbReSampleBuffer, qboolean qbVertFlip ); // NOT IN MP + void (*TempRawImage_CleanUp) ( ); //misc stuff - int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection, - int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); + int (*MarkFragments) ( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ); //model stuff - void (*LerpTag)( orientation_t *tag, qhandle_t model, int startFrame, int endFrame, - float frac, const char *tagName ); - void (*ModelBounds)( qhandle_t model, vec3_t mins, vec3_t maxs ); + void (*LerpTag) ( orientation_t *tag, qhandle_t model, int startFrame, int endFrame, float frac, const char *tagName ); + void (*ModelBounds) ( qhandle_t model, vec3_t mins, vec3_t maxs ); - void (*GetLightStyle)(int style, color4ub_t color); - void (*SetLightStyle)(int style, int color); + void (*GetLightStyle) ( int style, color4ub_t color ); + void (*SetLightStyle) ( int style, int color ); - void (*GetBModelVerts)( int bmodelIndex, vec3_t *vec, vec3_t normal ); - void (*WorldEffectCommand)(const char *command); - void (*GetModelBounds)(refEntity_t *refEnt, vec3_t bounds1, vec3_t bounds2); + void (*GetBModelVerts) ( int bmodelIndex, vec3_t *vec, vec3_t normal ); + void (*WorldEffectCommand) ( const char *command ); + void (*GetModelBounds) ( refEntity_t *refEnt, vec3_t bounds1, vec3_t bounds2 ); - int (*RegisterFont)(const char *name); + int (*RegisterFont) ( const char *name ); - int (*Font_HeightPixels)(const int index, const float scale); - int (*Font_StrLenPixels)(const char *s, const int index, const float scale); - void (*Font_DrawString)(int x, int y, const char *s, const float *rgba, const int iFontHandle, int iMaxPixelWidth, const float scale); - int (*Font_StrLenChars) (const char *s); - qboolean (*Language_IsAsian) (void); - qboolean (*Language_UsesSpaces) (void); - unsigned int (*AnyLanguage_ReadCharFromString)( char *psText, int * piAdvanceCount, qboolean *pbIsTrailingPunctuation /* = NULL */); - unsigned int (*AnyLanguage_ReadCharFromString2)( char **psText, qboolean *pbIsTrailingPunctuation /* = NULL */); + int (*Font_HeightPixels) ( const int index, const float scale ); + int (*Font_StrLenPixels) ( const char *s, const int index, const float scale ); + void (*Font_DrawString) ( int x, int y, const char *s, const float *rgba, const int iFontHandle, int iMaxPixelWidth, const float scale ); + int (*Font_StrLenChars) ( const char *s ); + qboolean (*Language_IsAsian) ( void ); + qboolean (*Language_UsesSpaces) ( void ); + unsigned int (*AnyLanguage_ReadCharFromString) ( char *psText, int * piAdvanceCount, qboolean *pbIsTrailingPunctuation ); + unsigned int (*AnyLanguage_ReadCharFromString2) ( char **psText, qboolean *pbIsTrailingPunctuation ); // NOT IN MP // Misc - void (*R_Resample)(byte *source, int swidth, int sheight, byte *dest, int dwidth, int dheight, int components); - void (*R_LoadDataImage)(const char *name, byte **pic, int *width, int *height); - void (*R_InvertImage)(byte *data, int width, int height, int depth); - void (*R_InitWorldEffects)(void); - void (*R_CreateAutomapImage)( const char *name, const byte *pic, int width, int height, - qboolean mipmap, qboolean allowPicmip, qboolean allowTC, qboolean glWrapClampMode ); - void (*R_ClearStuffToStopGhoul2CrashingThings)(void); - qboolean (*R_inPVS)(vec3_t p1, vec3_t p2); + void (*R_Resample) ( byte *source, int swidth, int sheight, byte *dest, int dwidth, int dheight, int components ); // NOT IN MP + void (*R_LoadDataImage) ( const char *name, byte **pic, int *width, int *height ); // NOT IN MP + void (*R_InvertImage) ( byte *data, int width, int height, int depth ); // NOT IN MP + void (*R_InitWorldEffects) ( void ); // NOT IN MP + void (*R_CreateAutomapImage) ( const char *name, const byte *pic, int width, int height, qboolean mipmap, qboolean allowPicmip, qboolean allowTC, qboolean glWrapClampMode ); // NOT IN MP + void (*R_ClearStuffToStopGhoul2CrashingThings) ( void ); // NOT IN MP + qboolean (*R_inPVS) ( vec3_t p1, vec3_t p2 ); - void (*SVModelInit)(void); + void (*SVModelInit) ( void ); // RMG - void (*InitRendererTerrain)( const char *info ); + void (*InitRendererTerrain) ( const char *info ); // Distortion effects - float* (*tr_distortionAlpha)( void ); - float* (*tr_distortionStretch)( void ); - qboolean* (*tr_distortionPrePost)( void ); - qboolean* (*tr_distortionNegate)( void ); + float* (*tr_distortionAlpha) ( void ); // NOT IN MP + float* (*tr_distortionStretch) ( void ); // NOT IN MP + qboolean* (*tr_distortionPrePost) ( void ); // NOT IN MP + qboolean* (*tr_distortionNegate) ( void ); // NOT IN MP // Weather effects - bool (*GetWindVector)( vec3_t windVector, vec3_t atPoint ); - bool (*GetWindGusting)( vec3_t atpoint ); - bool (*IsOutside)( vec3_t pos ); - float (*IsOutsideCausingPain)( vec3_t pos ); - float (*GetChanceOfSaberFizz)( void ); - bool (*IsShaking)( vec3_t pos ); - void (*AddWeatherZone)( vec3_t mins, vec3_t maxs ); - bool (*SetTempGlobalFogColor)( vec3_t color ); + bool (*GetWindVector) ( vec3_t windVector, vec3_t atPoint ); // NOT IN MP + bool (*GetWindGusting) ( vec3_t atpoint ); // NOT IN MP + bool (*IsOutside) ( vec3_t pos ); // NOT IN MP + float (*IsOutsideCausingPain) ( vec3_t pos ); // NOT IN MP + float (*GetChanceOfSaberFizz) ( void ); // NOT IN MP + bool (*IsShaking) ( vec3_t pos ); // NOT IN MP + void (*AddWeatherZone) ( vec3_t mins, vec3_t maxs ); // NOT IN MP + bool (*SetTempGlobalFogColor) ( vec3_t color ); // NOT IN MP - void (*SetRangedFog)(float dist); + void (*SetRangedFog) ( float dist ); // GHOUL 2 - IGhoul2InfoArray &(*TheGhoul2InfoArray)(void); + IGhoul2InfoArray &(*TheGhoul2InfoArray) ( void ); // GHOUL 2 API - int (*G2API_AddBolt)(CGhoul2Info *ghlInfo, const char *boneName); - int (*G2API_AddBoltSurfNum)(CGhoul2Info *ghlInfo, const int surfIndex); - int (*G2API_AddSurface)(CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, - float BarycentricI, float BarycentricJ, int lod); - void (*G2API_AnimateG2Models)(CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params); - qboolean (*G2API_AttachEnt)(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum); - qboolean (*G2API_AttachG2Model)(CGhoul2Info *ghlInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int toModel); - void (*G2API_CollisionDetect)(CCollisionRecord *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, - const vec3_t position, int AframeNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, - CMiniHeap *, EG2_Collision eG2TraceType, int useLod, float fRadius); - void (*G2API_CleanGhoul2Models)(CGhoul2Info_v &ghoul2); - void (*G2API_CopyGhoul2Instance)(CGhoul2Info_v &ghoul2From, CGhoul2Info_v &ghoul2To, int modelIndex); - void (*G2API_DetachEnt)(int *boltInfo); - qboolean (*G2API_DetachG2Model)(CGhoul2Info *ghlInfo); - qboolean (*G2API_GetAnimFileName)(CGhoul2Info *ghlInfo, char **filename); - char* (*G2API_GetAnimFileNameIndex)(qhandle_t modelIndex); - char* (*G2API_GetAnimFileInternalNameIndex)(qhandle_t modelIndex); - int (*G2API_GetAnimIndex)(CGhoul2Info *ghlInfo); - qboolean (*G2API_GetAnimRange)(CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame); - qboolean (*G2API_GetAnimRangeIndex)(CGhoul2Info *ghlInfo, const int boneIndex, int *startFrame, int *endFrame); - qboolean (*G2API_GetBoneAnim)(CGhoul2Info *ghlInfo, const char *boneName, const int AcurrentTime, - float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int *); - qboolean (*G2API_GetBoneAnimIndex)(CGhoul2Info *ghlInfo, const int iBoneIndex, const int AcurrentTime, - float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int *); - int (*G2API_GetBoneIndex)(CGhoul2Info *ghlInfo, const char *boneName, qboolean bAddIfNotFound); - qboolean (*G2API_GetBoltMatrix)(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, - const vec3_t angles, const vec3_t position, const int AframeNum, qhandle_t *modelList, const vec3_t scale); - int (*G2API_GetGhoul2ModelFlags)(CGhoul2Info *ghlInfo); - char* (*G2API_GetGLAName)(CGhoul2Info *ghlInfo); - int (*G2API_GetParentSurface)(CGhoul2Info *ghlInfo, const int index); - qboolean (*G2API_GetRagBonePos)(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, - vec3_t entPos, vec3_t entScale); - int (*G2API_GetSurfaceIndex)(CGhoul2Info *ghlInfo, const char *surfaceName); - char* (*G2API_GetSurfaceName)(CGhoul2Info *ghlInfo, int surfNumber); - int (*G2API_GetSurfaceRenderStatus)(CGhoul2Info *ghlInfo, const char *surfaceName); - int (*G2API_GetTime)(int argTime); - void (*G2API_GiveMeVectorFromMatrix)(mdxaBone_t &boltMatrix, Eorientations flags, vec3_t &vec); - int (*G2API_HaveWeGhoul2Models)(CGhoul2Info_v &ghoul2); - qboolean (*G2API_IKMove)(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params); - int (*G2API_InitGhoul2Model)(CGhoul2Info_v &ghoul2, const char *fileName, int modelIndex, - qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias); - qboolean (*G2API_IsPaused)(CGhoul2Info *ghlInfo, const char *boneName); - void (*G2API_ListBones)(CGhoul2Info *ghlInfo, int frame); - void (*G2API_ListSurfaces)(CGhoul2Info *ghlInfo); - void (*G2API_LoadGhoul2Models)(CGhoul2Info_v &ghoul2, char *buffer); - void (*G2API_LoadSaveCodeDestructGhoul2Info)(CGhoul2Info_v &ghoul2); - qboolean (*G2API_PauseBoneAnim)(CGhoul2Info *ghlInfo, const char *boneName, const int AcurrentTime); - qboolean (*G2API_PauseBoneAnimIndex)(CGhoul2Info *ghlInfo, const int boneIndex, const int AcurrentTime); - qhandle_t (*G2API_PrecacheGhoul2Model)(const char *fileName); - qboolean (*G2API_RagEffectorGoal)(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos); - qboolean (*G2API_RagEffectorKick)(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity); - qboolean (*G2API_RagForceSolve)(CGhoul2Info_v &ghoul2, qboolean force); - qboolean (*G2API_RagPCJConstraint)(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max); - qboolean (*G2API_RagPCJGradientSpeed)(CGhoul2Info_v &ghoul2, const char *boneName, const float speed); - qboolean (*G2API_RemoveBolt)(CGhoul2Info *ghlInfo, const int index); - qboolean (*G2API_RemoveBone)(CGhoul2Info *ghlInfo, const char *boneName); - qboolean (*G2API_RemoveGhoul2Model)(CGhoul2Info_v &ghlInfo, const int modelIndex); - qboolean (*G2API_RemoveSurface)(CGhoul2Info *ghlInfo, const int index); - void (*G2API_SaveGhoul2Models)(CGhoul2Info_v &ghoul2); - qboolean (*G2API_SetAnimIndex)(CGhoul2Info *ghlInfo, const int index); - qboolean (*G2API_SetBoneAnim)(CGhoul2Info *ghlInfo, const char *boneName, const int startFrame, const int endFrame, - const int flags, const float animSpeed, const int AcurrentTime, const float setFrame, const int blendTime); - qboolean (*G2API_SetBoneAnimIndex)(CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, - const int flags, const float animSpeed, const int AcurrentTime, const float setFrame, const int blendTime); - qboolean (*G2API_SetBoneAngles)(CGhoul2Info *ghlInfo, const char *boneName, const vec3_t angles, const int flags, - const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, - int blendTime, int AcurrentTime); - qboolean (*G2API_SetBoneAnglesIndex)(CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, - const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, - int blendTime, int AcurrentTime); - qboolean (*G2API_SetBoneAnglesMatrix)(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, - const int flags, qhandle_t *modelList, int blendTime, int AcurrentTime); - qboolean (*G2API_SetBoneAnglesMatrixIndex)(CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, - const int flags, qhandle_t *modelList, int blandeTime, int AcurrentTime); - qboolean (*G2API_SetBoneIKState)(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, - sharedSetBoneIKStateParams_t *params); - qboolean (*G2API_SetGhoul2ModelFlags)(CGhoul2Info *ghlInfo, const int flags); - void (*G2API_SetGhoul2ModelIndexes)(CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList); - qboolean (*G2API_SetLodBias)(CGhoul2Info *ghlInfo, int lodBias); - qboolean (*G2API_SetNewOrigin)(CGhoul2Info *ghlInfo, const int boltIndex); - void (*G2API_SetRagDoll)(CGhoul2Info_v &ghoul2, CRagDollParams *parms); - qboolean (*G2API_SetRootSurface)(CGhoul2Info_v &ghlInfo, const int modelIndex, const char *surfaceName); - qboolean (*G2API_SetShader)(CGhoul2Info *ghlInfo, qhandle_t customShader); - qboolean (*G2API_SetSkin)(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin); - qboolean (*G2API_SetSurfaceOnOff)(CGhoul2Info *ghlInfo, const char *surfaceName, const int flags); - void (*G2API_SetTime)(int currentTime, int clock); - qboolean (*G2API_StopBoneAnim)(CGhoul2Info *ghlInfo, const char *boneName); - qboolean (*G2API_StopBoneAnimIndex)(CGhoul2Info *ghlInfo, const int index); - qboolean (*G2API_StopBoneAngles)(CGhoul2Info *ghlInfo, const char *boneName); - qboolean (*G2API_StopBoneAnglesIndex)(CGhoul2Info *ghlInfo, const int index); + int (*G2API_AddBolt) ( CGhoul2Info *ghlInfo, const char *boneName ); + int (*G2API_AddBoltSurfNum) ( CGhoul2Info *ghlInfo, const int surfIndex ); + int (*G2API_AddSurface) ( CGhoul2Info *ghlInfo, int surfaceNumber, int polyNumber, float BarycentricI, float BarycentricJ, int lod ); + void (*G2API_AnimateG2Models) ( CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params ); + qboolean (*G2API_AttachEnt) ( int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum ); + qboolean (*G2API_AttachG2Model) ( CGhoul2Info *ghlInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int toModel ); + void (*G2API_CleanGhoul2Models) ( CGhoul2Info_v &ghoul2 ); + void (*G2API_CollisionDetect) ( CCollisionRecord *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int AframeNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *, EG2_Collision eG2TraceType, int useLod, float fRadius ); + void (*G2API_CopyGhoul2Instance) ( CGhoul2Info_v &ghoul2From, CGhoul2Info_v &ghoul2To, int modelIndex ); + void (*G2API_DetachEnt) ( int *boltInfo ); // NOT IN MP + qboolean (*G2API_DetachG2Model) ( CGhoul2Info *ghlInfo ); + qboolean (*G2API_GetAnimFileName) ( CGhoul2Info *ghlInfo, char **filename ); + char* (*G2API_GetAnimFileNameIndex) ( qhandle_t modelIndex ); + char* (*G2API_GetAnimFileInternalNameIndex) ( qhandle_t modelIndex ); + int (*G2API_GetAnimIndex) ( CGhoul2Info *ghlInfo ); + qboolean (*G2API_GetAnimRange) ( CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame ); + qboolean (*G2API_GetAnimRangeIndex) ( CGhoul2Info *ghlInfo, const int boneIndex, int *startFrame, int *endFrame ); // NOT IN MP + qboolean (*G2API_GetBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName, const int AcurrentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int * ); + qboolean (*G2API_GetBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int iBoneIndex, const int AcurrentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int * ); // NOT IN MP + int (*G2API_GetBoneIndex) ( CGhoul2Info *ghlInfo, const char *boneName, qboolean bAddIfNotFound ); + qboolean (*G2API_GetBoltMatrix) ( CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int AframeNum, qhandle_t *modelList, const vec3_t scale ); + int (*G2API_GetGhoul2ModelFlags) ( CGhoul2Info *ghlInfo ); + char* (*G2API_GetGLAName) ( CGhoul2Info *ghlInfo ); + int (*G2API_GetParentSurface) ( CGhoul2Info *ghlInfo, const int index ); + qboolean (*G2API_GetRagBonePos) ( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale ); + int (*G2API_GetSurfaceIndex) ( CGhoul2Info *ghlInfo, const char *surfaceName ); + char* (*G2API_GetSurfaceName) ( CGhoul2Info *ghlInfo, int surfNumber ); + int (*G2API_GetSurfaceRenderStatus) ( CGhoul2Info *ghlInfo, const char *surfaceName ); + int (*G2API_GetTime) ( int argTime ); + void (*G2API_GiveMeVectorFromMatrix) ( mdxaBone_t &boltMatrix, Eorientations flags, vec3_t &vec ); + int (*G2API_HaveWeGhoul2Models) ( CGhoul2Info_v &ghoul2 ); + qboolean (*G2API_IKMove) ( CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params ); + int (*G2API_InitGhoul2Model) ( CGhoul2Info_v &ghoul2, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias ); + qboolean (*G2API_IsPaused) ( CGhoul2Info *ghlInfo, const char *boneName ); + void (*G2API_ListBones) ( CGhoul2Info *ghlInfo, int frame ); + void (*G2API_ListSurfaces) ( CGhoul2Info *ghlInfo ); + void (*G2API_LoadGhoul2Models) ( CGhoul2Info_v &ghoul2, char *buffer ); + void (*G2API_LoadSaveCodeDestructGhoul2Info) ( CGhoul2Info_v &ghoul2 ); + qboolean (*G2API_PauseBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName, const int AcurrentTime ); + qboolean (*G2API_PauseBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int boneIndex, const int AcurrentTime ); // NOT IN MP + qhandle_t (*G2API_PrecacheGhoul2Model) ( const char *fileName ); + qboolean (*G2API_RagEffectorGoal) ( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos ); + qboolean (*G2API_RagEffectorKick) ( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t velocity ); + qboolean (*G2API_RagForceSolve) ( CGhoul2Info_v &ghoul2, qboolean force ); + qboolean (*G2API_RagPCJConstraint) ( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max ); + qboolean (*G2API_RagPCJGradientSpeed) ( CGhoul2Info_v &ghoul2, const char *boneName, const float speed ); + qboolean (*G2API_RemoveBolt) ( CGhoul2Info *ghlInfo, const int index ); + qboolean (*G2API_RemoveBone) ( CGhoul2Info *ghlInfo, const char *boneName ); + qboolean (*G2API_RemoveGhoul2Model) ( CGhoul2Info_v &ghlInfo, const int modelIndex ); + qboolean (*G2API_RemoveSurface) ( CGhoul2Info *ghlInfo, const int index ); + void (*G2API_SaveGhoul2Models) ( CGhoul2Info_v &ghoul2 ); + qboolean (*G2API_SetAnimIndex) ( CGhoul2Info *ghlInfo, const int index ); // NOT IN MP + qboolean (*G2API_SetBoneAngles) ( CGhoul2Info *ghlInfo, const char *boneName, const vec3_t angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int AcurrentTime ); + qboolean (*G2API_SetBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, int blendTime, int AcurrentTime ); + qboolean (*G2API_SetBoneAnglesMatrix) ( CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int AcurrentTime ); + qboolean (*G2API_SetBoneAnglesMatrixIndex) ( CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blandeTime, int AcurrentTime ); + qboolean (*G2API_SetBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int AcurrentTime, const float setFrame, const int blendTime ); + qboolean (*G2API_SetBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int AcurrentTime, const float setFrame, const int blendTime ); + qboolean (*G2API_SetBoneIKState) ( CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params ); + qboolean (*G2API_SetGhoul2ModelFlags) ( CGhoul2Info *ghlInfo, const int flags ); + void (*G2API_SetGhoul2ModelIndexes) ( CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList ); + qboolean (*G2API_SetLodBias) ( CGhoul2Info *ghlInfo, int lodBias ); + qboolean (*G2API_SetNewOrigin) ( CGhoul2Info *ghlInfo, const int boltIndex ); + void (*G2API_SetRagDoll) ( CGhoul2Info_v &ghoul2, CRagDollParams *parms ); + qboolean (*G2API_SetRootSurface) ( CGhoul2Info_v &ghlInfo, const int modelIndex, const char *surfaceName ); + qboolean (*G2API_SetShader) ( CGhoul2Info *ghlInfo, qhandle_t customShader ); + qboolean (*G2API_SetSkin) ( CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin ); + qboolean (*G2API_SetSurfaceOnOff) ( CGhoul2Info *ghlInfo, const char *surfaceName, const int flags ); + void (*G2API_SetTime) ( int currentTime, int clock ); + qboolean (*G2API_StopBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName ); + qboolean (*G2API_StopBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int index ); + qboolean (*G2API_StopBoneAngles) ( CGhoul2Info *ghlInfo, const char *boneName ); + qboolean (*G2API_StopBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index ); #ifdef _G2_GORE - void (*G2API_AddSkinGore)(CGhoul2Info_v &ghoul2, SSkinGoreData &gore); - void (*G2API_ClearSkinGore)(CGhoul2Info_v &ghoul2); + void (*G2API_AddSkinGore) ( CGhoul2Info_v &ghoul2, SSkinGoreData &gore ); + void (*G2API_ClearSkinGore) ( CGhoul2Info_v &ghoul2 ); #endif - // Performance analysis (perform anal) - void (*G2Time_ResetTimers)(void); - void (*G2Time_ReportTimers)(void); + // Performance analysis (perform anal)..not in MP + void (*G2Time_ResetTimers) ( void ); + void (*G2Time_ReportTimers) ( void ); } refexport_t; diff --git a/codemp/rd-common/tr_public.h b/codemp/rd-common/tr_public.h index bfe85a7fa7..ba016e490e 100644 --- a/codemp/rd-common/tr_public.h +++ b/codemp/rd-common/tr_public.h @@ -29,9 +29,9 @@ typedef struct refexport_s { // size display elements void (*BeginRegistration) ( glconfig_t *config ); qhandle_t (*RegisterModel) ( const char *name ); - qhandle_t (*RegisterServerModel) ( const char *name ); + qhandle_t (*RegisterServerModel) ( const char *name ); // NOT IN SP qhandle_t (*RegisterSkin) ( const char *name ); - qhandle_t (*RegisterServerSkin) ( const char *name ); + qhandle_t (*RegisterServerSkin) ( const char *name ); // NOT IN SP qhandle_t (*RegisterShader) ( const char *name ); qhandle_t (*RegisterShaderNoMip) ( const char *name ); const char * (*ShaderNameFromIndex) ( int index ); @@ -130,23 +130,23 @@ typedef struct refexport_s { void (*G2API_AnimateG2ModelsRag) ( CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params ); qboolean (*G2API_AttachEnt) ( int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum ); qboolean (*G2API_AttachG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel ); - void (*G2API_AttachInstanceToEntNum) ( CGhoul2Info_v &ghoul2, int entityNum, qboolean server ); - void (*G2API_AbsurdSmoothing) ( CGhoul2Info_v &ghoul2, qboolean status ); - void (*G2API_BoltMatrixReconstruction) ( qboolean reconstruct ); - void (*G2API_BoltMatrixSPMethod) ( qboolean spMethod ); - void (*G2API_CleanEntAttachments) ( void ); + void (*G2API_AttachInstanceToEntNum) ( CGhoul2Info_v &ghoul2, int entityNum, qboolean server ); // NOT IN SP + void (*G2API_AbsurdSmoothing) ( CGhoul2Info_v &ghoul2, qboolean status ); // NOT IN SP + void (*G2API_BoltMatrixReconstruction) ( qboolean reconstruct ); // NOT IN SP + void (*G2API_BoltMatrixSPMethod) ( qboolean spMethod ); // NOT IN SP + void (*G2API_CleanEntAttachments) ( void ); // NOT IN SP void (*G2API_CleanGhoul2Models) ( CGhoul2Info_v **ghoul2Ptr ); - void (*G2API_ClearAttachedInstance) ( int entityNum ); + void (*G2API_ClearAttachedInstance) ( int entityNum ); // NOT IN SP void (*G2API_CollisionDetect) ( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius ); - void (*G2API_CollisionDetectCache) ( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius ); + void (*G2API_CollisionDetectCache) ( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius ); // NOT IN SP int (*G2API_CopyGhoul2Instance) ( CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int modelIndex ); - void (*G2API_CopySpecificG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo ); + void (*G2API_CopySpecificG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo ); // NOT IN SP qboolean (*G2API_DetachG2Model) ( CGhoul2Info *ghlInfo ); - qboolean (*G2API_DoesBoneExist) ( CGhoul2Info *ghlInfo, const char *boneName ); - void (*G2API_DuplicateGhoul2Instance) ( CGhoul2Info_v &g2From, CGhoul2Info_v **g2To ); - void (*G2API_FreeSaveBuffer) ( char *buffer ); + qboolean (*G2API_DoesBoneExist) ( CGhoul2Info *ghlInfo, const char *boneName ); // NOT IN SP + void (*G2API_DuplicateGhoul2Instance) ( CGhoul2Info_v &g2From, CGhoul2Info_v **g2To ); // NOT IN SP + void (*G2API_FreeSaveBuffer) ( char *buffer ); // NOT IN SP qboolean (*G2API_GetAnimFileName) ( CGhoul2Info *ghlInfo, char **filename ); - char * (*G2API_GetAnimFileNameIndex) ( qhandle_t modelIndex ); + char * (*G2API_GetAnimFileNameIndex) ( qhandle_t modelIndex ); // NOT IN SP qboolean (*G2API_GetAnimRange) ( CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame ); qboolean (*G2API_GetBoltMatrix) ( CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ); qboolean (*G2API_GetBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList ); @@ -160,9 +160,9 @@ typedef struct refexport_s { int (*G2API_GetSurfaceOnOff) ( CGhoul2Info *ghlInfo, const char *surfaceName ); int (*G2API_GetSurfaceRenderStatus) ( CGhoul2Info *ghlInfo, const char *surfaceName ); int (*G2API_GetTime) ( int argTime ); - int (*G2API_Ghoul2Size) ( CGhoul2Info_v &ghoul2 ); + int (*G2API_Ghoul2Size) ( CGhoul2Info_v &ghoul2 ); // NOT IN SP void (*G2API_GiveMeVectorFromMatrix) ( mdxaBone_t *boltMatrix, Eorientations flags, vec3_t vec ); - qboolean (*G2API_HasGhoul2ModelOnIndex) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); + qboolean (*G2API_HasGhoul2ModelOnIndex) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); // NOT IN SP qboolean (*G2API_HaveWeGhoul2Models) ( CGhoul2Info_v &ghoul2 ); qboolean (*G2API_IKMove) ( CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params ); int (*G2API_InitGhoul2Model) ( CGhoul2Info_v **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias ); @@ -171,7 +171,7 @@ typedef struct refexport_s { void (*G2API_ListSurfaces) ( CGhoul2Info *ghlInfo ); void (*G2API_LoadGhoul2Models) ( CGhoul2Info_v &ghoul2, char *buffer ); void (*G2API_LoadSaveCodeDestructGhoul2Info) ( CGhoul2Info_v &ghoul2 ); - qboolean (*G2API_OverrideServerWithClientData) ( CGhoul2Info *serverInstance ); + qboolean (*G2API_OverrideServerWithClientData) ( CGhoul2Info *serverInstance ); // NOT IN SP qboolean (*G2API_PauseBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName, const int currentTime ); qhandle_t (*G2API_PrecacheGhoul2Model) ( const char *fileName ); qboolean (*G2API_RagEffectorGoal) ( CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos ); @@ -182,11 +182,11 @@ typedef struct refexport_s { qboolean (*G2API_RemoveBolt) ( CGhoul2Info *ghlInfo, const int index ); qboolean (*G2API_RemoveBone) ( CGhoul2Info *ghlInfo, const char *boneName ); qboolean (*G2API_RemoveGhoul2Model) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); - qboolean (*G2API_RemoveGhoul2Models) ( CGhoul2Info_v **ghlRemove ); + qboolean (*G2API_RemoveGhoul2Models) ( CGhoul2Info_v **ghlRemove ); // NOT IN SP qboolean (*G2API_RemoveSurface) ( CGhoul2Info *ghlInfo, const int index ); - void (*G2API_ResetRagDoll) ( CGhoul2Info_v &ghoul2 ); + void (*G2API_ResetRagDoll) ( CGhoul2Info_v &ghoul2 ); // NOT IN SP qboolean (*G2API_SaveGhoul2Models) ( CGhoul2Info_v &ghoul2, char **buffer, int *size ); - void (*G2API_SetBoltInfo) ( CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo ); + void (*G2API_SetBoltInfo) ( CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo ); // NOT IN SP qboolean (*G2API_SetBoneAngles) ( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ); qboolean (*G2API_SetBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, int blendTime, int currentTime ); qboolean (*G2API_SetBoneAnglesMatrix) ( CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int currentTime ); @@ -194,8 +194,8 @@ typedef struct refexport_s { qboolean (*G2API_SetBoneAnim) ( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame /*= -1*/, const int blendTime /*= -1*/ ); qboolean (*G2API_SetBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int index, const int startFrame, const int endFrame, const int flags, const float animSpeed, const int currentTime, const float setFrame, const int blendTime ); qboolean (*G2API_SetBoneIKState) ( CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params ); - void (*G2API_SetGhoul2ModelIndexes) ( CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList ); qboolean (*G2API_SetGhoul2ModelFlags) ( CGhoul2Info *ghlInfo, const int flags ); + void (*G2API_SetGhoul2ModelIndexes) ( CGhoul2Info_v &ghoul2, qhandle_t *modelList, qhandle_t *skinList ); qboolean (*G2API_SetLodBias) ( CGhoul2Info *ghlInfo, int lodBias ); qboolean (*G2API_SetNewOrigin) ( CGhoul2Info_v &ghoul2, const int boltIndex ); void (*G2API_SetRagDoll) ( CGhoul2Info_v &ghoul2, CRagDollParams *parms ); @@ -204,14 +204,14 @@ typedef struct refexport_s { qboolean (*G2API_SetSkin) ( CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin ); qboolean (*G2API_SetSurfaceOnOff) ( CGhoul2Info_v &ghoul2, const char *surfaceName, const int flags ); void (*G2API_SetTime) ( int currentTime, int clock ); - qboolean (*G2API_SkinlessModel) ( CGhoul2Info *g2 ); - qboolean (*G2API_StopBoneAngles) ( CGhoul2Info *ghlInfo, const char *boneName ); - qboolean (*G2API_StopBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index ); + qboolean (*G2API_SkinlessModel) ( CGhoul2Info *g2 ); // NOT IN SP qboolean (*G2API_StopBoneAnim) ( CGhoul2Info *ghlInfo, const char *boneName ); qboolean (*G2API_StopBoneAnimIndex) ( CGhoul2Info *ghlInfo, const int index ); + qboolean (*G2API_StopBoneAngles) ( CGhoul2Info *ghlInfo, const char *boneName ); + qboolean (*G2API_StopBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index ); #ifdef _G2_GORE - int (*G2API_GetNumGoreMarks) ( CGhoul2Info *g2 ); + int (*G2API_GetNumGoreMarks) ( CGhoul2Info *g2 ); // NOT IN SP void (*G2API_AddSkinGore) ( CGhoul2Info_v &ghoul2, SSkinGoreData &gore ); void (*G2API_ClearSkinGore) ( CGhoul2Info_v &ghoul2 ); #endif // _SOF2 From 79225b6b08529f559c47fc42a3208bbfda3b95d4 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 1 Dec 2013 17:27:24 -0600 Subject: [PATCH 109/708] [MP] Rend2: Hopefully fix to a degree, local server running with rend2 by implementing the necessary server functions. --- codemp/rd-rend2/G2_API.cpp | 9 +- codemp/rd-rend2/tr_init.cpp | 22 +- codemp/rd-rend2/tr_local.h | 3 + codemp/rd-rend2/tr_model.cpp | 422 ++++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_shader.cpp | 166 ++++++++----- codemp/rd-rend2/tr_skin.cpp | 35 ++- 6 files changed, 572 insertions(+), 85 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 78e665e262..e80f4d25ac 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -558,8 +558,7 @@ qboolean G2_ShouldRegisterServer(void) qhandle_t G2API_PrecacheGhoul2Model( const char *fileName ) { if ( G2_ShouldRegisterServer() ) - return 0; - //return RE_RegisterServerModel( fileName ); + return RE_RegisterServerModel( fileName ); else return RE_RegisterModel( fileName ); } @@ -2594,8 +2593,7 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model if (ri->Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { - ghlInfo->mModel = 0; - //ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); } else { @@ -2688,8 +2686,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode if (ri->Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { - ghlInfo->mModel = 0; - //ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); + ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); } else { diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b1a4c92114..0c88d7235d 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1611,6 +1611,8 @@ static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = static float GetDistanceCull( void ) { return 6000/*tr.distanceCull*/; } +extern void R_SVModelInit( void ); //tr_model.cpp + static void GetRealRes( int *w, int *h ) { *w = glConfig.vidWidth; *h = glConfig.vidHeight; @@ -1620,18 +1622,6 @@ extern IGhoul2InfoArray &TheGhoul2InfoArray(); const CGhoul2Info NullG2; // STUBS, REPLACEME -qhandle_t stub_RegisterServerModel( const char *name ) -{ - //ri->Printf( PRINT_ALL, "stub_RegisterServerModel\n" ); - return 0; -} - -qhandle_t stub_RegisterServerSkin( const char *name ) -{ - //ri->Printf( PRINT_ALL, "stub_RegisterServerSkin\n" ); - return 0; -} - qboolean stub_InitializeWireframeAutomap() { return qtrue; } void RE_GetLightStyle(int style, color4ub_t color) @@ -1690,11 +1680,9 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.BeginRegistration = RE_BeginRegistration; re.RegisterModel = RE_RegisterModel; - // RE_RegisterServerModel - re.RegisterServerModel = stub_RegisterServerModel; + re.RegisterServerModel = RE_RegisterServerModel; re.RegisterSkin = RE_RegisterSkin; - // RE_RegisterServerSkin - re.RegisterServerSkin = stub_RegisterServerSkin; + re.RegisterServerSkin = RE_RegisterServerSkin; re.RegisterShader = RE_RegisterShader; re.RegisterShaderNoMip = RE_RegisterShaderNoMip; re.ShaderNameFromIndex = RE_ShaderNameFromIndex; @@ -1763,6 +1751,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.InitSkins = R_InitSkins; re.InitShaders = R_InitShaders; + re.SVModelInit = R_SVModelInit; + re.HunkClearCrap = RE_HunkClearCrap; re.G2API_AddBolt = G2API_AddBolt; re.G2API_AddBoltSurfNum = G2API_AddBoltSurfNum; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 0b5c79c244..30cb6927a5 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2467,7 +2467,9 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ); void RE_BeginRegistration( glconfig_t *glconfig ); void RE_LoadWorldMap( const char *mapname ); void RE_SetWorldVisData( const byte *vis ); +qhandle_t RE_RegisterServerModel( const char *name ); qhandle_t RE_RegisterModel( const char *name ); +qhandle_t RE_RegisterServerSkin( const char *name ); qhandle_t RE_RegisterSkin( const char *name ); void RE_Shutdown( qboolean destroyWindow ); @@ -2501,6 +2503,7 @@ skin_t *R_GetSkinByHandle( qhandle_t hSkin ); int R_ComputeLOD( trRefEntity_t *ent ); const void *RB_TakeVideoFrameCmd( const void *data ); +void RE_HunkClearCrap(void); // // tr_shader.c diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 990aeb386f..38b4f757c5 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -387,6 +387,413 @@ qhandle_t RE_RegisterModel( const char *name ) { return hModel; } +//rww - Please forgive me for all of the below. Feel free to destroy it and replace it with something better. +//You obviously can't touch anything relating to shaders or ri-> functions here in case a dedicated +//server is running, which is the entire point of having these seperate functions. If anything major +//is changed in the non-server-only versions of these functions it would be wise to incorporate it +//here as well. + +/* +================= +R_LoadMDXA_Server - load a Ghoul 2 animation file +================= +*/ +qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { + + mdxaHeader_t *pinmodel, *mdxa; + int version; + int size; + + pinmodel = (mdxaHeader_t *)buffer; + // + // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... + // + version = (pinmodel->version); + size = (pinmodel->ofsEnd); + + if (!bAlreadyCached) + { + LL(version); + LL(size); + } + + if (version != MDXA_VERSION) { + return qfalse; + } + + mod->type = MOD_MDXA; + mod->dataSize += size; + + qboolean bAlreadyFound = qfalse; + mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); + mod->data.gla = mdxa; + + assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? + + if (!bAlreadyFound) + { + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // we've hijacked that memory block... + // + // Aaaargh. Kill me now... + // + bAlreadyCached = qtrue; + assert( mdxa == buffer ); +// memcpy( mdxa, buffer, size ); // and don't do this now, since it's the same thing + + LL(mdxa->ident); + LL(mdxa->version); + LL(mdxa->numFrames); + LL(mdxa->numBones); + LL(mdxa->ofsFrames); + LL(mdxa->ofsEnd); + } + + if ( mdxa->numFrames < 1 ) { + return qfalse; + } + + if (bAlreadyFound) + { + return qtrue; // All done, stop here, do not LittleLong() etc. Do not pass go... + } + + return qtrue; +} + +/* +================= +R_LoadMDXM_Server - load a Ghoul 2 Mesh file +================= +*/ +qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { + int i,l, j; + mdxmHeader_t *pinmodel, *mdxm; + mdxmLOD_t *lod; + mdxmSurface_t *surf; + int version; + int size; + //shader_t *sh; + mdxmSurfHierarchy_t *surfInfo; + + pinmodel= (mdxmHeader_t *)buffer; + // + // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... + // + version = (pinmodel->version); + size = (pinmodel->ofsEnd); + + if (!bAlreadyCached) + { + LL(version); + LL(size); + } + + if (version != MDXM_VERSION) { + return qfalse; + } + + mod->type = MOD_MDXM; + mod->dataSize += size; + + qboolean bAlreadyFound = qfalse; + mdxm = (mdxmHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM ); + mod->data.glm = (mdxmData_t *)ri->Hunk_Alloc (sizeof (mdxmData_t), h_low); + mod->data.glm->header = mdxm; + + assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? + + if (!bAlreadyFound) + { + // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the + // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // we've hijacked that memory block... + // + // Aaaargh. Kill me now... + // + bAlreadyCached = qtrue; + assert( mdxm == buffer ); +// memcpy( mdxm, buffer, size ); // and don't do this now, since it's the same thing + + LL(mdxm->ident); + LL(mdxm->version); + LL(mdxm->numLODs); + LL(mdxm->ofsLODs); + LL(mdxm->numSurfaces); + LL(mdxm->ofsSurfHierarchy); + LL(mdxm->ofsEnd); + } + + // first up, go load in the animation file we need that has the skeletal animation info for this model + mdxm->animIndex = RE_RegisterServerModel(va ("%s.gla",mdxm->animName)); + if (!mdxm->animIndex) + { + return qfalse; + } + + mod->numLods = mdxm->numLODs -1 ; //copy this up to the model for ease of use - it wil get inced after this. + + if (bAlreadyFound) + { + return qtrue; // All done. Stop, go no further, do not LittleLong(), do not pass Go... + } + + surfInfo = (mdxmSurfHierarchy_t *)( (byte *)mdxm + mdxm->ofsSurfHierarchy); + for ( i = 0 ; i < mdxm->numSurfaces ; i++) + { + LL(surfInfo->numChildren); + LL(surfInfo->parentIndex); + + // do all the children indexs + for (j=0; jnumChildren; j++) + { + LL(surfInfo->childIndexes[j]); + } + + // We will not be using shaders on the server. + //sh = 0; + // insert it in the surface list + + surfInfo->shaderIndex = 0; + + CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); + + // find the next surface + surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + (intptr_t)( &((mdxmSurfHierarchy_t *)0)->childIndexes[ surfInfo->numChildren ] )); + } + + // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) + lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); + for ( l = 0 ; l < mdxm->numLODs ; l++) + { + int triCount = 0; + + LL(lod->ofsEnd); + // swap all the surfaces + surf = (mdxmSurface_t *) ( (byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t)) ); + for ( i = 0 ; i < mdxm->numSurfaces ; i++) + { + LL(surf->numTriangles); + LL(surf->ofsTriangles); + LL(surf->numVerts); + LL(surf->ofsVerts); + LL(surf->ofsEnd); + LL(surf->ofsHeader); + LL(surf->numBoneReferences); + LL(surf->ofsBoneReferences); +// LL(surf->maxVertBoneWeights); + + triCount += surf->numTriangles; + + if ( surf->numVerts > SHADER_MAX_VERTEXES ) { + return qfalse; + } + if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { + return qfalse; + } + + // change to surface identifier + surf->ident = SF_MDX; + + // register the shaders + + // find the next surface + surf = (mdxmSurface_t *)( (byte *)surf + surf->ofsEnd ); + } + + // find the next LOD + lod = (mdxmLOD_t *)( (byte *)lod + lod->ofsEnd ); + } + + return qtrue; +} + +/* +==================== +R_RegisterMDX_Server +==================== +*/ +qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) +{ + unsigned *buf; + int lod; + int ident; + qboolean loaded = qfalse; + int numLoaded; + char filename[MAX_QPATH], namebuf[MAX_QPATH+20]; + char *fext, defex[] = "md3"; + + numLoaded = 0; + + strcpy(filename, name); + + fext = strchr(filename, '.'); + if(!fext) + fext = defex; + else + { + *fext = '\0'; + fext++; + } + + for (lod = MD3_MAX_LODS - 1 ; lod >= 0 ; lod--) + { + if(lod) + Com_sprintf(namebuf, sizeof(namebuf), "%s_%d.%s", filename, lod, fext); + else + Com_sprintf(namebuf, sizeof(namebuf), "%s.%s", filename, fext); + + qboolean bAlreadyCached = qfalse; + if( !CModelCache->LoadFile( namebuf, (void**)&buf, &bAlreadyCached ) ) + continue; + + const char *blah = (const char *)(*buf); + ident = *(unsigned *)buf; + if( !bAlreadyCached ) + ident = LittleLong(ident); + + switch(ident) + { + case MDXA_IDENT: + loaded = R_LoadMDXA_Server(mod, buf, namebuf, bAlreadyCached); + break; + case MDXM_IDENT: + loaded = R_LoadMDXM_Server(mod, buf, namebuf, bAlreadyCached); + break; + default: + //ri->Printf(PRINT_WARNING, "R_RegisterMDX_Server: unknown ident for %s\n", name); + break; + } + + if(loaded) + { + mod->numLods++; + numLoaded++; + } + else + break; + } + + if(numLoaded) + { + // duplicate into higher lod spots that weren't + // loaded, in case the user changes r_lodbias on the fly + for(lod--; lod >= 0; lod--) + { + mod->numLods++; + mod->data.mdv[lod] = mod->data.mdv[lod + 1]; + } + + return mod->index; + } + +/*#ifdef _DEBUG + ri->Printf(PRINT_WARNING,"R_RegisterMDX_Server: couldn't load %s\n", name); +#endif*/ + + mod->type = MOD_BAD; + return 0; +} + +// Note that the ordering indicates the order of preference used +// when there are multiple models of different formats available +static modelExtToLoaderMap_t serverModelLoaders[ ] = +{ + /* + Ghoul 2 Insert Start + */ + { "glm", R_RegisterMDX_Server }, + { "gla", R_RegisterMDX_Server }, + /* + Ghoul 2 Insert End + */ +}; + +static int numServerModelLoaders = ARRAY_LEN(serverModelLoaders); + +qhandle_t RE_RegisterServerModel( const char *name ) { + model_t *mod; + qhandle_t hModel; + int i; + char localName[ MAX_QPATH ]; + const char *ext; + + if (!r_noServerGhoul2) + { //keep it from choking when it gets to these checks in the g2 code. Registering all r_ cvars for the server would be a Bad Thing though. + r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", 0); + } + + if ( !name || !name[0] ) { + return 0; + } + + if ( strlen( name ) >= MAX_QPATH ) { + return 0; + } + + // search the currently loaded models + if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) + return hModel; + + if ( name[0] == '*' ) + { + if ( strcmp (name, "*default.gla") != 0 ) + { + return 0; + } + } + + // allocate a new model_t + if ( ( mod = R_AllocModel() ) == NULL ) { + ri->Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); + return 0; + } + + // only set the name after the model has been successfully loaded + Q_strncpyz( mod->name, name, sizeof( mod->name ) ); + + R_IssuePendingRenderCommands(); + + mod->type = MOD_BAD; + mod->numLods = 0; + + // + // load the files + // + Q_strncpyz( localName, name, MAX_QPATH ); + + ext = COM_GetExtension( localName ); + + if( *ext ) + { + // Look for the correct loader and use it + for( i = 0; i < numServerModelLoaders; i++ ) + { + if( !Q_stricmp( ext, serverModelLoaders[ i ].ext ) ) + { + // Load + hModel = serverModelLoaders[ i ].ModelLoader( localName, mod ); + break; + } + } + + // A loader was found + if( i < numServerModelLoaders ) + { + if( hModel ) + { + // Something loaded + CModelCache->InsertLoaded( name, hModel ); + return mod->index; + } + } + } + + CModelCache->InsertLoaded( name, hModel ); + return hModel; +} + /* ================= R_LoadMD3 @@ -1187,6 +1594,11 @@ void RE_BeginRegistration( glconfig_t *glconfigOut ) { //============================================================================= +void R_SVModelInit() +{ + R_ModelInit(); +} + /* =============== R_ModelInit @@ -1204,6 +1616,16 @@ void R_ModelInit( void ) { mod->type = MOD_BAD; } +extern void KillTheShaderHashTable(void); +void RE_HunkClearCrap(void) +{ //get your dirty sticky assets off me, you damn dirty hunk! + KillTheShaderHashTable(); + tr.numModels = 0; + CModelCache->DeleteAll(); + tr.numShaders = 0; + tr.numSkins = 0; +} + /* ================ diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 8dd7ae6745..c7e2328b01 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -39,9 +39,14 @@ static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); +void KillTheShaderHashTable(void) +{ + memset(shaderTextHashTable, 0, sizeof(shaderTextHashTable)); +} + qboolean ShaderHashTableExists(void) { - if (shaderTextHashTable[0][0]) + if (shaderTextHashTable[0]) { return qtrue; } @@ -2732,73 +2737,76 @@ to be rendered with bad shaders. To fix this, need to go through all render comm sortedIndex. ============== */ +extern bool gServerSkinHack; static void FixRenderCommandList( int newShader ) { - renderCommandList_t *cmdList = &backEndData->commands; + if( !gServerSkinHack ) { + renderCommandList_t *cmdList = &backEndData->commands; - if( cmdList ) { - const void *curCmd = cmdList->cmds; + if( cmdList ) { + const void *curCmd = cmdList->cmds; - while ( 1 ) { - curCmd = PADP(curCmd, sizeof(void *)); + while ( 1 ) { + curCmd = PADP(curCmd, sizeof(void *)); - switch ( *(const int *)curCmd ) { - case RC_SET_COLOR: - { - const setColorCommand_t *sc_cmd = (const setColorCommand_t *)curCmd; - curCmd = (const void *)(sc_cmd + 1); - break; - } - case RC_STRETCH_PIC: - { - const stretchPicCommand_t *sp_cmd = (const stretchPicCommand_t *)curCmd; - curCmd = (const void *)(sp_cmd + 1); - break; - } - case RC_ROTATE_PIC: - case RC_ROTATE_PIC2: - { - const rotatePicCommand_t *sp_cmd = (const rotatePicCommand_t *)curCmd; + switch ( *(const int *)curCmd ) { + case RC_SET_COLOR: + { + const setColorCommand_t *sc_cmd = (const setColorCommand_t *)curCmd; + curCmd = (const void *)(sc_cmd + 1); + break; + } + case RC_STRETCH_PIC: + { + const stretchPicCommand_t *sp_cmd = (const stretchPicCommand_t *)curCmd; curCmd = (const void *)(sp_cmd + 1); break; - } - case RC_DRAW_SURFS: - { - int i; - drawSurf_t *drawSurf; - shader_t *shader; - int fogNum; - int entityNum; - int dlightMap; - int pshadowMap; - int sortedIndex; - const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; - - for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &pshadowMap ); - sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); - if( sortedIndex >= newShader ) { - sortedIndex++; - drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; } + case RC_ROTATE_PIC: + case RC_ROTATE_PIC2: + { + const rotatePicCommand_t *sp_cmd = (const rotatePicCommand_t *)curCmd; + curCmd = (const void *)(sp_cmd + 1); + break; + } + case RC_DRAW_SURFS: + { + int i; + drawSurf_t *drawSurf; + shader_t *shader; + int fogNum; + int entityNum; + int dlightMap; + int pshadowMap; + int sortedIndex; + const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; + + for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &pshadowMap ); + sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); + if( sortedIndex >= newShader ) { + sortedIndex++; + drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + } + } + curCmd = (const void *)(ds_cmd + 1); + break; + } + case RC_DRAW_BUFFER: + { + const drawBufferCommand_t *db_cmd = (const drawBufferCommand_t *)curCmd; + curCmd = (const void *)(db_cmd + 1); + break; + } + case RC_SWAP_BUFFERS: + { + const swapBuffersCommand_t *sb_cmd = (const swapBuffersCommand_t *)curCmd; + curCmd = (const void *)(sb_cmd + 1); + break; + } + case RC_END_OF_LIST: + default: + return; } - curCmd = (const void *)(ds_cmd + 1); - break; - } - case RC_DRAW_BUFFER: - { - const drawBufferCommand_t *db_cmd = (const drawBufferCommand_t *)curCmd; - curCmd = (const void *)(db_cmd + 1); - break; - } - case RC_SWAP_BUFFERS: - { - const swapBuffersCommand_t *sb_cmd = (const swapBuffersCommand_t *)curCmd; - curCmd = (const void *)(sb_cmd + 1); - break; - } - case RC_END_OF_LIST: - default: - return; } } } @@ -3466,6 +3474,44 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag return FinishShader(); } +shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipRawImage ) +{ + char strippedName[MAX_QPATH]; + int hash; + shader_t *sh; + + if ( name[0] == 0 ) { + return tr.defaultShader; + } + + COM_StripExtension( name, strippedName, sizeof( strippedName ) ); + + hash = generateHashValue(strippedName, FILE_HASH_SIZE); + + // + // see if the shader is already loaded + // + for (sh = hashTable[hash]; sh; sh = sh->next) { + // NOTE: if there was no shader or image available with the name strippedName + // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we + // have to check all default shaders otherwise for every call to R_FindShader + // with that same strippedName a new default shader is created. + if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && + !Q_stricmp(sh->name, strippedName)) { + // match found + return sh; + } + } + + // clear the global shader + Com_Memset( &shader, 0, sizeof( shader ) ); + Com_Memset( &stages, 0, sizeof( stages ) ); + Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); + shader.lightmapIndex = lightmapIndex; + + shader.defaultShader = qtrue; + return FinishShader(); +} qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) { int i, hash; diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp index 9e1ee85761..3d8082df6e 100644 --- a/codemp/rd-rend2/tr_skin.cpp +++ b/codemp/rd-rend2/tr_skin.cpp @@ -18,7 +18,10 @@ RE_RegisterSkin =============== */ -shader_t *R_FindServerShader( const char *name, const int *lightmapIndex, const byte *styles, qboolean mipRawImage ); +bool gServerSkinHack = false; + + +shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipRawImage ); static char *CommaParse( char **data_p ); /* =============== @@ -140,7 +143,9 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) skin->surfaces[skin->numSurfaces] = (_skinSurface_t *)surf; Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); - surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); + + if (gServerSkinHack) surf->shader = R_FindServerShader( token, LIGHTMAP_NONE, qtrue ); + else surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); skin->numSurfaces++; } @@ -232,7 +237,7 @@ qhandle_t RE_RegisterSkin( const char *name ) { CommaParse This is unfortunate, but the skin files aren't -compatable with our normal parsing rules. +compatible with our normal parsing rules. ================== */ static char *CommaParse( char **data_p ) { @@ -334,6 +339,30 @@ static char *CommaParse( char **data_p ) { return com_token; } +/* +=============== +RE_RegisterServerSkin + +Mangled version of the above function to load .skin files on the server. +=============== +*/ +qhandle_t RE_RegisterServerSkin( const char *name ) { + qhandle_t r; + + if (ri->Cvar_VariableIntegerValue( "cl_running" ) && + ri->Com_TheHunkMarkHasBeenMade() && + ShaderHashTableExists()) + { //If the client is running then we can go straight into the normal registerskin func + return RE_RegisterSkin(name); + } + + gServerSkinHack = true; + r = RE_RegisterSkin(name); + gServerSkinHack = false; + + return r; +} + /* =============== R_InitSkins From 4e69df5169450db4907b11c7b52218999addc1d4 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 1 Dec 2013 18:11:26 -0600 Subject: [PATCH 110/708] [MP] Rend2: Progress for RF_RGB_TINT. Still doesn't actually work though. Ignore the 0 being passed within ForwardDlight this is not really used in the normal r_dlightMode. --- codemp/rd-rend2/tr_shade.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index aa4c609169..5944e5186e 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -445,7 +445,7 @@ static void ProjectDlightTexture( void ) { } -static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor ) +static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t baseColor, vec4_t vertColor ) { baseColor[0] = baseColor[1] = @@ -460,7 +460,12 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t // // rgbGen // - switch ( pStage->rgbGen ) + if ( !forceRGBGen ) + { + forceRGBGen = pStage->rgbGen; + } + + switch ( forceRGBGen ) { case CGEN_IDENTITY_LIGHTING: baseColor[0] = @@ -565,8 +570,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t case AGEN_SKIP: break; case AGEN_CONST: - baseColor[3] = pStage->constantColor[3] / 255.0f; - vertColor[3] = 0.0f; + if ( forceRGBGen != CGEN_CONST ) { + baseColor[3] = pStage->constantColor[3] / 255.0f; + vertColor[3] = 0.0f; + } break; case AGEN_WAVEFORM: baseColor[3] = RB_CalcWaveAlphaSingle( &pStage->alphaWave ); @@ -587,8 +594,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[3] = 0.0f; break; case AGEN_VERTEX: - baseColor[3] = 0.0f; - vertColor[3] = 1.0f; + if ( forceRGBGen != CGEN_VERTEX ) { + baseColor[3] = 0.0f; + vertColor[3] = 1.0f; + } break; case AGEN_ONE_MINUS_VERTEX: baseColor[3] = 1.0f; @@ -771,7 +780,7 @@ static void ForwardDlight( void ) { vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor); + ComputeShaderColors(pStage, 0, baseColor, vertColor); GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); @@ -1217,7 +1226,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor); + ComputeShaderColors(pStage, forceRGBGen, baseColor, vertColor); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { @@ -1253,7 +1262,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); } - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); + GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, forceRGBGen ? forceRGBGen : pStage->rgbGen); GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); if ( input->fogNum ) From da74c5c91860124d1ef2bd4b55f75eae479b5773 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 3 Dec 2013 07:26:44 +0000 Subject: [PATCH 111/708] Added ClearDecals export. --- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_scene.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 0c88d7235d..c3bcc109d4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1701,7 +1701,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.DrawRotatePic2 = RE_RotatePic2; re.ClearScene = RE_ClearScene; - // RE_ClearDecals + re.ClearDecals = RE_ClearDecals; re.AddRefEntityToScene = RE_AddRefEntityToScene; re.AddMiniRefEntityToScene = RE_AddMiniRefEntityToScene; re.AddPolyToScene = RE_AddPolyToScene; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 30cb6927a5..2ae535a2be 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1833,6 +1833,7 @@ typedef struct model_s { void R_ModelInit (void); void R_InitDecals (void); +void RE_ClearDecals ( void ); model_t *R_GetModelByHandle( qhandle_t hModel ); int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 6dc115ba9c..f225cf7f1a 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -600,7 +600,7 @@ This is called to remove all decals from the world =================== */ -static void RE_ClearDecals ( void ) +void RE_ClearDecals ( void ) { memset( re_decalPolys, 0, sizeof(re_decalPolys) ); memset( re_decalPolyHead, 0, sizeof(re_decalPolyHead) ); From e71d7484489ed4cc7c5d39832a41234c075ff29f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 Dec 2013 22:45:58 +0000 Subject: [PATCH 112/708] [Rend2] Fix lightingDiffuseEntity shader keyword. The lightingDiffuseEntity keyword was being silently ignored. This commit restores its functionality to the same as the vanilla renderer. --- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 93 ++++++++++++++++++++++------------- codemp/rd-rend2/tr_shader.cpp | 17 ++++--- 3 files changed, 70 insertions(+), 41 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2ae535a2be..b4b4c26018 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -549,6 +549,7 @@ typedef enum { CGEN_ONE_MINUS_VERTEX, CGEN_WAVEFORM, // programmatically generated CGEN_LIGHTING_DIFFUSE, + CGEN_LIGHTING_DIFFUSE_ENTITY, // diffuse lighting * entity CGEN_FOG, // standard fog CGEN_CONST // fixed color } colorGen_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 5944e5186e..f8f624779e 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -445,8 +445,11 @@ static void ProjectDlightTexture( void ) { } -static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t baseColor, vec4_t vertColor ) +static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, colorGen_t *forceRGBGen, alphaGen_t *forceAlphaGen ) { + colorGen_t rgbGen = pStage->rgbGen; + alphaGen_t alphaGen = pStage->alphaGen; + baseColor[0] = baseColor[1] = baseColor[2] = @@ -457,15 +460,17 @@ static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t vertColor[2] = vertColor[3] = 0.0f; - // - // rgbGen - // - if ( !forceRGBGen ) + if ( forceRGBGen != NULL && *forceRGBGen != CGEN_BAD ) { - forceRGBGen = pStage->rgbGen; + rgbGen = *forceRGBGen; } - switch ( forceRGBGen ) + if ( forceAlphaGen != NULL && *forceAlphaGen != AGEN_IDENTITY ) + { + alphaGen = *forceAlphaGen; + } + + switch ( rgbGen ) { case CGEN_IDENTITY_LIGHTING: baseColor[0] = @@ -539,12 +544,19 @@ static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t baseColor[2] = RB_CalcWaveColorSingle( &pStage->rgbWave ); break; case CGEN_ENTITY: + case CGEN_LIGHTING_DIFFUSE_ENTITY: if (backEnd.currentEntity) { baseColor[0] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[0] / 255.0f; baseColor[1] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[1] / 255.0f; baseColor[2] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[2] / 255.0f; baseColor[3] = ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; + + if ( alphaGen == AGEN_IDENTITY && + backEnd.currentEntity->e.shaderRGBA[3] == 255 ) + { + alphaGen = AGEN_SKIP; + } } break; case CGEN_ONE_MINUS_ENTITY: @@ -565,12 +577,12 @@ static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t // // alphaGen // - switch ( pStage->alphaGen ) + switch ( alphaGen ) { case AGEN_SKIP: break; case AGEN_CONST: - if ( forceRGBGen != CGEN_CONST ) { + if ( rgbGen != CGEN_CONST ) { baseColor[3] = pStage->constantColor[3] / 255.0f; vertColor[3] = 0.0f; } @@ -594,7 +606,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t vertColor[3] = 0.0f; break; case AGEN_VERTEX: - if ( forceRGBGen != CGEN_VERTEX ) { + if ( rgbGen != CGEN_VERTEX ) { baseColor[3] = 0.0f; vertColor[3] = 1.0f; } @@ -612,6 +624,16 @@ static void ComputeShaderColors( shaderStage_t *pStage, int forceRGBGen, vec4_t break; } + if ( forceAlphaGen != NULL ) + { + *forceAlphaGen = alphaGen; + } + + if ( forceRGBGen != NULL ) + { + *forceRGBGen = rgbGen; + } + // FIXME: find some way to implement this. #if 0 // if in greyscale rendering mode turn all color values into greyscale. @@ -780,7 +802,7 @@ static void ForwardDlight( void ) { vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, 0, baseColor, vertColor); + ComputeShaderColors(pStage, baseColor, vertColor, NULL, NULL); GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); @@ -1071,7 +1093,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) vec4_t texMatrix; vec4_t texOffTurb; int stateBits; - int forceRGBGen = 0; + colorGen_t forceRGBGen = CGEN_BAD; + alphaGen_t forceAlphaGen = AGEN_IDENTITY; + float forceAlpha = 0.0f; if ( !pStage ) { @@ -1220,13 +1244,25 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) {//want to use RGBGen from ent forceRGBGen = CGEN_ENTITY; } + + if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) + { + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) + { //depth write, so faces through the model will be stomped over by nearer ones. this works because + //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. + stateBits |= GLS_DEPTHMASK_TRUE; + } + } } + GL_State( stateBits ); + { vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, forceRGBGen, baseColor, vertColor); + ComputeShaderColors(pStage, baseColor, vertColor, &forceRGBGen, &forceAlphaGen); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { @@ -1235,11 +1271,18 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) VectorScale(vertColor, backEnd.refdef.colorScale, vertColor); } + if ( backEnd.currentEntity != NULL && + (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) ) + { + vertColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; + } + GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); } - if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) + if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || + pStage->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) { vec4_t vec; @@ -1262,8 +1305,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); } - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, forceRGBGen ? forceRGBGen : pStage->rgbGen); - GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); + GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, forceRGBGen); + GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, forceAlphaGen); if ( input->fogNum ) { @@ -1420,24 +1463,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); - if (backEnd.currentEntity && (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA)) - { - ForceAlpha((unsigned char *) tess.svars.colors, backEnd.currentEntity->e.shaderRGBA[3]); - if (backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH) - { //depth write, so faces through the model will be stomped over by nearer ones. this works because - //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. - GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE); - } - else - { - GL_State(GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } - } - else - { - GL_State( stateBits ); - } - // // draw // diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c7e2328b01..98844ec329 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1066,11 +1066,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else if ( !Q_stricmp( token, "lightingDiffuseEntity" ) ) { - //if (shader.lightmapIndex[0] != LIGHTMAP_NONE) - //{ - // Com_Printf( S_COLOR_RED "ERROR: rgbGen lightingDiffuseEntity used on a misc_model! in shader '%s'\n", shader.name ); - //} - //stage->rgbGen = CGEN_LIGHTING_DIFFUSE_ENTITY; + if (shader.lightmapIndex != LIGHTMAP_NONE) + { + Com_Printf( S_COLOR_RED "ERROR: rgbGen lightingDiffuseEntity used on a misc_model! in shader '%s'\n", shader.name ); + } + stage->rgbGen = CGEN_LIGHTING_DIFFUSE_ENTITY; } else if ( !Q_stricmp( token, "oneMinusVertex" ) ) { @@ -2149,6 +2149,7 @@ static void ComputeVertexAttribs(void) break; case CGEN_LIGHTING_DIFFUSE: + case CGEN_LIGHTING_DIFFUSE_ENTITY: shader.vertexAttribs |= ATTR_NORMAL; break; @@ -2577,7 +2578,8 @@ static qboolean CollapseStagesToGLSL(void) } diffuselit = qfalse; - if (diffuse->rgbGen == CGEN_LIGHTING_DIFFUSE) + if (diffuse->rgbGen == CGEN_LIGHTING_DIFFUSE || + diffuse->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) { diffuselit = qtrue; } @@ -2692,7 +2694,8 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE) + if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || + pStage->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHT_VECTOR; From 27a0858f36f76fa72a631477f6f648888aa28c5f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 Dec 2013 22:48:27 +0000 Subject: [PATCH 113/708] [Rend2] Fix surface sorting for post-renders. Surfaces with the renderfx bit RF_DISTORTION, RF_FORCEPOST or RF_FORCE_ENT_ALPHA should be drawn after all other surfaces. This commit sorts the surfaces properly such that these surfaces are drawn last. --- codemp/rd-rend2/tr_animation.cpp | 6 +++--- codemp/rd-rend2/tr_ghoul2.cpp | 4 ++-- codemp/rd-rend2/tr_local.h | 12 ++++++++---- codemp/rd-rend2/tr_main.cpp | 28 ++++++++++++++++++++-------- codemp/rd-rend2/tr_mesh.cpp | 2 +- codemp/rd-rend2/tr_model_iqm.cpp | 6 +++--- codemp/rd-rend2/tr_scene.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 6 +++--- codemp/rd-rend2/tr_world.cpp | 6 +++--- 9 files changed, 44 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 8e5440ce81..f7f3f2415c 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -287,7 +287,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, qfalse, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); } // projection shadows work fine with personal models @@ -296,11 +296,11 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, qfalse, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); } if (!personalModel) - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, qfalse, cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 9a905389d8..e98c4b8f07 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2443,7 +2443,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, qfalse, 0 ); + R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 ); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2523,7 +2523,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, qfalse, 0 ); + R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 ); } } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b4b4c26018..5f4897fd56 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1878,13 +1878,16 @@ the bits are allocated as follows: 1 : pshadow flag 0 : dlight flag */ -#define QSORT_FOGNUM_SHIFT 2 -#define QSORT_REFENTITYNUM_SHIFT 7 +#define QSORT_FOGNUM_SHIFT 1 +#define QSORT_REFENTITYNUM_SHIFT 6 #define QSORT_SHADERNUM_SHIFT (QSORT_REFENTITYNUM_SHIFT+REFENTITYNUM_BITS) #if (QSORT_SHADERNUM_SHIFT+SHADERNUM_BITS) > 32 #error "Need to update sorting, too many bits." #endif -#define QSORT_PSHADOW_SHIFT 1 +#define QSORT_POSTRENDER_SHIFT (QSORT_SHADERNUM_SHIFT + SHADERNUM_BITS) +#if QSORT_POSTRENDER_SHIFT >= 32 + #error "Sort field needs to be expanded" +#endif extern int gl_filter_min, gl_filter_max; @@ -2417,7 +2420,8 @@ void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, int *fogNum, int *dlightMap, int *pshadowMap ); void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap, int cubemap ); + int fogIndex, int dlightMap, int postRender, int cubemap ); +bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal, const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 04b4d10320..4539e548b1 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1843,13 +1843,25 @@ static void R_RadixSort( drawSurf_t *source, int size ) //========================================================================================== +bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ) +{ + if ( refEntityNum == REFENTITYNUM_WORLD ) + { + return false; + } + + return (refEntity->e.renderfx & RF_DISTORTION) || + (refEntity->e.renderfx & RF_FORCEPOST) || + (refEntity->e.renderfx & RF_FORCE_ENT_ALPHA); +} + /* ================= R_AddDrawSurf ================= */ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int pshadowMap, + int fogIndex, int dlightMap, int postRender, int cubemap) { int index; @@ -1870,7 +1882,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, // compared quickly during the qsorting process tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) | tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) - | ((int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + | ((int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; tr.refdef.drawSurfs[index].cubemapIndex = cubemap; tr.refdef.drawSurfs[index].surface = surface; tr.refdef.numDrawSurfs++; @@ -1882,11 +1894,11 @@ R_DecomposeSort ================= */ void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *pshadowMap ) { + int *fogNum, int *dlightMap, int *postRender ) { *fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31; *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ]; *entityNum = ( sort >> QSORT_REFENTITYNUM_SHIFT ) & REFENTITYNUM_MASK; - *pshadowMap = (sort >> QSORT_PSHADOW_SHIFT ) & 1; + *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & 1; *dlightMap = sort & 1; } @@ -1998,7 +2010,7 @@ static void R_AddEntitySurface (int entityNum) return; } shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, 0, 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); break; case RT_MODEL: @@ -2007,7 +2019,7 @@ static void R_AddEntitySurface (int entityNum) tr.currentModel = R_GetModelByHandle( ent->e.hModel ); if (!tr.currentModel) { - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0/* cubeMap */ ); + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0/* cubeMap */ ); } else { switch ( tr.currentModel->type ) { case MOD_MESH: @@ -2036,7 +2048,7 @@ static void R_AddEntitySurface (int entityNum) break; } - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, 0, 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); @@ -2046,7 +2058,7 @@ static void R_AddEntitySurface (int entityNum) break; case RT_ENT_CHAIN: shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, qfalse, 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 84011e2f9d..7bfc299bda 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -390,7 +390,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, qfalse, cubemapIndex ); + R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 491329d39e..266d3e5259 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -869,7 +869,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); } // projection shadows work fine with personal models @@ -877,11 +877,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, 0, 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); } if( !personalModel ) { - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, 0, cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index f225cf7f1a..53bef8c27a 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -98,7 +98,7 @@ void R_AddPolygonSurfaces( void ) { for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse, 0 /* cubemapIndex */ ); + R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 /* cubemapIndex */ ); } } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 98844ec329..748ccde430 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2779,16 +2779,16 @@ static void FixRenderCommandList( int newShader ) { int fogNum; int entityNum; int dlightMap; - int pshadowMap; + int postRender; int sortedIndex; const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &pshadowMap ); + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &postRender ); sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)pshadowMap << QSORT_PSHADOW_SHIFT) | (int)dlightMap; + drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; } } curCmd = (const void *)(ds_cmd + 1); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 3694eda258..4a3c1c30c5 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -332,12 +332,12 @@ static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits } // check for pshadows - /*if ( pshadowBits ) */{ + /*if ( pshadowBits ) *//*{ pshadowBits = R_PshadowSurface( surf, pshadowBits); pshadowBits = ( pshadowBits != 0 ); - } + }*/ - R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, pshadowBits, surf->cubemapIndex ); + R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), surf->cubemapIndex ); } /* From 14091cb18b0d0684bf61ae008d9c797445f96776 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 6 Dec 2013 20:03:15 +0000 Subject: [PATCH 114/708] [Rend2] Fixed MD3 model rendering with CGEN_ENTITY Some MD3 models were not being rendered correctly and had obvious colour artifacts. This was caused by the MD3 model choosing a generic GLSL shader - the generic shader expects the colour attribute, but this is not provided by MD3 models. The colour attribute has been disabled when rendering MD3 models, which fixes this problem. --- codemp/rd-rend2/tr_shade.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f8f624779e..8267c510f0 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1040,6 +1040,7 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) if(glState.vertexAnimation) { + vertexAttribs &= ~ATTR_COLOR; vertexAttribs |= ATTR_POSITION2; if (vertexAttribs & ATTR_NORMAL) { From f53dc5597aaf79066a664ad1021d9c588c6452e0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 6 Dec 2013 21:41:06 +0000 Subject: [PATCH 115/708] [Rend2] Filled in more of the ref API Added the following entry points: * SetRangedFog * SetDistortionProperties --- codemp/rd-rend2/tr_init.cpp | 5 +++-- codemp/rd-rend2/tr_local.h | 3 +++ codemp/rd-rend2/tr_world.cpp | 5 +++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c3bcc109d4..af62568ba8 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1652,6 +1652,7 @@ void RE_SetLightStyle(int style, int color) void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} +static void RE_SetRefractionProperties ( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate ) { } /* @@@@@@@@@@@@@@@@@@@@@ @@ -1732,8 +1733,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.SetLightStyle = RE_SetLightStyle; re.GetBModelVerts = stub_RE_GetBModelVerts; - // SetRangedFog - // SetRefractionProperties + re.SetRangedFog = RE_SetRangedFog; + re.SetRefractionProperties = RE_SetRefractionProperties; re.GetDistanceCull = GetDistanceCull; re.GetRealRes = GetRealRes; // R_AutomapElevationAdjustment diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5f4897fd56..e7fa145402 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2223,6 +2223,8 @@ typedef struct trGlobals_s { float inverseSawToothTable[FUNCTABLE_SIZE]; float fogTable[FOG_TABLE_SIZE]; + float rangedFog; + #ifdef _WIN32 WinVars_t *wv; #endif @@ -2468,6 +2470,7 @@ typedef _skinSurface_t skinSurface_t; void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *data, int client, qboolean dirty); void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qboolean dirty); +void RE_SetRangedFog ( float range ); void RE_BeginFrame( stereoFrame_t stereoFrame ); void RE_BeginRegistration( glconfig_t *glconfig ); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 4a3c1c30c5..715717ba45 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -382,6 +382,11 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { } } +void RE_SetRangedFog ( float range ) +{ + tr.rangedFog = range; +} + /* ============================================================= From 49a03962c16d45d193024fd9422247a5c0b23306 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 6 Dec 2013 21:42:09 +0000 Subject: [PATCH 116/708] [Rend2] Fixed RotatePic2 RotatePic2 was rotating the image the wrong way! --- codemp/rd-rend2/tr_backend.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 657da542c6..bc21c94a55 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1209,28 +1209,28 @@ const void *RB_RotatePic2 ( const void *data ) VectorSet (xlat, cmd->x, cmd->y, 0.0f); VectorSet (point, -cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts]); tess.texCoords[ numVerts ][0][0] = cmd->s1; tess.texCoords[ numVerts ][0][1] = cmd->t1; VectorSet (point, cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 1]); tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; VectorSet (point, cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 2]); tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; VectorSet (point, -cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); + RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 3]); tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; From aaccb2f90f495f5159e544d0418cf1ab50be097e Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 6 Dec 2013 20:29:46 -0600 Subject: [PATCH 117/708] [MP] Rend2: Fix support for clampanimmap. Implement ClearGlobalShader and use it. --- codemp/rd-rend2/tr_local.h | 7 +++++ codemp/rd-rend2/tr_shader.cpp | 50 ++++++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e7fa145402..58e64b5ced 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -327,6 +327,13 @@ typedef enum IMGFLAG_GENNORMALMAP = 0x0100, } imgFlags_t; +typedef enum +{ + ANIMMAP_NORMAL, + ANIMMAP_CLAMP, + ANIMMAP_ONESHOT +} animMapType_t; + typedef struct image_s { char imgName[MAX_QPATH]; // game path, including extension int width, height; // source image diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 748ccde430..76cf15f1df 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -53,6 +53,20 @@ qboolean ShaderHashTableExists(void) return qfalse; } +static void ClearGlobalShader(void) +{ + int i; + + memset( &shader, 0, sizeof( shader ) ); + memset( &stages, 0, sizeof( stages ) ); + for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { + stages[i].bundle[0].texMods = texMods[i]; + //stages[i].mGLFogColorOverride = GLFOGOVERRIDE_NONE; + } + + shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; +} + /* ================ return a hash value for the filename @@ -380,10 +394,10 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) ParseTexMod =================== */ -static void ParseTexMod( char *_text, shaderStage_t *stage ) +static void ParseTexMod( const char *_text, shaderStage_t *stage ) { const char *token; - const char **text = (const char **)&_text; + const char **text = &_text; texModInfo_t *tmi; if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { @@ -604,6 +618,18 @@ static void ParseTexMod( char *_text, shaderStage_t *stage ) } } +static animMapType_t AnimMapType( const char *token ) +{ + if ( !Q_stricmp( token, "clampanimMap" ) ) { return ANIMMAP_CLAMP; } + else if ( !Q_stricmp( token, "oneshotanimMap" ) ) { return ANIMMAP_ONESHOT; } + else { return ANIMMAP_NORMAL; } +} + +static const char *animMapNames[] = { + "animMap", + "clapanimMap", + "oneshotanimMap" +}; /* =================== @@ -762,10 +788,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if ( !Q_stricmp( token, "animMap" ) || !Q_stricmp( token, "clampanimMap" ) || !Q_stricmp( token, "oneshotanimMap" ) ) { + animMapType_t type = AnimMapType( token ); token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'animMmap' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for '%s' keyword in shader '%s'\n", animMapNames[type], shader.name ); return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); @@ -780,7 +807,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } num = stage->bundle[0].numImageAnimations; if ( num < MAX_IMAGE_ANIMATIONS ) { - int flags = IMGFLAG_NONE; + int flags = type == ANIMMAP_CLAMP ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -3366,13 +3393,9 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag } // clear the global shader - Com_Memset( &shader, 0, sizeof( shader ) ); - Com_Memset( &stages, 0, sizeof( stages ) ); + ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); shader.lightmapIndex = lightmapIndex; - for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { - stages[i].bundle[0].texMods = texMods[i]; - } // // attempt to define shader from an explicit parameter file @@ -3507,8 +3530,7 @@ shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipR } // clear the global shader - Com_Memset( &shader, 0, sizeof( shader ) ); - Com_Memset( &stages, 0, sizeof( stages ) ); + ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); shader.lightmapIndex = lightmapIndex; @@ -3546,13 +3568,9 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ } // clear the global shader - Com_Memset( &shader, 0, sizeof( shader ) ); - Com_Memset( &stages, 0, sizeof( stages ) ); + ClearGlobalShader(); Q_strncpyz(shader.name, name, sizeof(shader.name)); shader.lightmapIndex = lightmapIndex; - for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { - stages[i].bundle[0].texMods = texMods[i]; - } // // create the default shading commands From d9b217fb343b2a3ec0e6623318df811ac9f1f737 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 6 Dec 2013 20:41:24 -0600 Subject: [PATCH 118/708] [MP] Rend2: Implement oneshotanimmap and RF_SETANIMINDEX. --- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 34 +++++++++++++++++++++++++++------- codemp/rd-rend2/tr_shader.cpp | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 58e64b5ced..d7620290e0 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -653,6 +653,7 @@ typedef struct { int videoMapHandle; qboolean isLightmap; + qboolean oneShotAnimMap; qboolean vertexLightmap; qboolean isVideoMap; } textureBundle_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 8267c510f0..3a369e1b67 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -116,15 +116,35 @@ static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { return; } - // it is necessary to do this messy calc to make sure animations line up - // exactly with waveforms of the same frequency - index = Q_ftol(tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE); - index >>= FUNCTABLE_SIZE2; + if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) + { + index = backEnd.currentEntity->e.skinNum; + } + else + { + // it is necessary to do this messy calc to make sure animations line up + // exactly with waveforms of the same frequency + index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); + index >>= FUNCTABLE_SIZE2; + + if ( index < 0 ) { + index = 0; // may happen with shader time offsets + } + } - if ( index < 0 ) { - index = 0; // may happen with shader time offsets + if ( bundle->oneShotAnimMap ) + { + if ( index >= bundle->numImageAnimations ) + { + // stick on last frame + index = bundle->numImageAnimations - 1; + } + } + else + { + // loop + index %= bundle->numImageAnimations; } - index %= bundle->numImageAnimations; GL_BindToTMU( bundle->image[ index ], tmu ); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 76cf15f1df..227d9c21fc 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -796,6 +796,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); + stage->bundle[0].oneShotAnimMap = (qboolean)(type == ANIMMAP_ONESHOT); // parse up to MAX_IMAGE_ANIMATIONS animations while ( 1 ) { From e9812b27f2e40a503b60fe6f5f3476f248ee9bf8 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 6 Dec 2013 20:42:23 -0600 Subject: [PATCH 119/708] [MP] Rend2: Remove a couple of unused i variables from a previous commit. --- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 227d9c21fc..ed6faf7b67 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3355,7 +3355,7 @@ most world construction surfaces. */ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; - int i, hash, flags; + int hash, flags; const char *shaderText; image_t *image; shader_t *sh; @@ -3540,7 +3540,7 @@ shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipR } qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) { - int i, hash; + int hash; shader_t *sh; hash = generateHashValue(name, FILE_HASH_SIZE); From 89821cd95fb6c62ad108ef7a9ff23552061923f6 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 6 Dec 2013 22:00:34 -0600 Subject: [PATCH 120/708] [MP] Rend2: ParseSkyParms sync with vanilla. --- codemp/rd-rend2/tr_shader.cpp | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ed6faf7b67..f8337c8010 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1525,8 +1525,8 @@ skyParms =============== */ static void ParseSkyParms( const char **text ) { - char *token; - static char *suf[6] = {"rt", "bk", "lf", "ft", "up", "dn"}; + char *token; + static const char *suf[6] = {"rt", "lf", "bk", "ft", "up", "dn"}; char pathname[MAX_QPATH]; int i; int imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; @@ -1542,12 +1542,14 @@ static void ParseSkyParms( const char **text ) { } if ( strcmp( token, "-" ) ) { for (i=0 ; i<6 ; i++) { - Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" - , token, suf[i] ); + Com_sprintf( pathname, sizeof(pathname), "%s_%s", token, suf[i] ); shader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags | IMGFLAG_CLAMPTOEDGE ); if ( !shader.sky.outerbox[i] ) { - shader.sky.outerbox[i] = tr.defaultImage; + if ( i ) + shader.sky.outerbox[i] = shader.sky.outerbox[i-1]; //not found, so let's use the previous image + else + shader.sky.outerbox[i] = tr.defaultImage; } } } @@ -1555,7 +1557,7 @@ static void ParseSkyParms( const char **text ) { // cloudheight token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing cloudheight in shader '%s'\n", shader.name ); return; } shader.sky.cloudHeight = atof( token ); @@ -1564,22 +1566,10 @@ static void ParseSkyParms( const char **text ) { } R_InitSkyTexCoords( shader.sky.cloudHeight ); - // innerbox token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); - return; - } if ( strcmp( token, "-" ) ) { - for (i=0 ; i<6 ; i++) { - Com_sprintf( pathname, sizeof(pathname), "%s_%s.tga" - , token, suf[i] ); - shader.sky.innerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags ); - if ( !shader.sky.innerbox[i] ) { - shader.sky.innerbox[i] = tr.defaultImage; - } - } + ri->Printf( PRINT_WARNING, "WARNING: in shader '%s' 'skyParms', innerbox is not supported!", shader.name ); } shader.isSky = qtrue; From fc946870e613a431e6c84f600d224708b6b2beb1 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 6 Dec 2013 23:00:11 -0600 Subject: [PATCH 121/708] [MP] Rend2: Implement noTC shader command. --- codemp/rd-rend2/tr_local.h | 3 ++- codemp/rd-rend2/tr_shader.cpp | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d7620290e0..974ab2ba94 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -733,7 +733,7 @@ typedef enum { typedef struct { float cloudHeight; - image_t *outerbox[6], *innerbox[6]; + image_t *outerbox[6]; } skyParms_t; typedef struct { @@ -777,6 +777,7 @@ typedef struct shader_s { qboolean polygonOffset; // set for decals and other items that must be offset qboolean noMipMaps; // for console fonts, 2D elements, etc. qboolean noPicMip; // for images that must always be full resolution + qboolean noTC; // for images that don't want to be texture compressed (eg skies) fogPass_t fogPass; // draw a blended pass, possibly with depth test equals diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f8337c8010..9bc67437de 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -711,6 +711,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!shader.noPicMip) flags |= IMGFLAG_PICMIP; + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) { type = IMGTYPE_NORMAL; @@ -758,6 +761,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!shader.noPicMip) flags |= IMGFLAG_PICMIP; + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) { type = IMGTYPE_NORMAL; @@ -819,6 +825,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (r_srgb->integer) flags |= IMGFLAG_SRGB; + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + stage->bundle[0].image[num] = R_FindImageFile( token, IMGTYPE_COLORALPHA, flags ); if ( !stage->bundle[0].image[num] ) { @@ -1531,6 +1540,9 @@ static void ParseSkyParms( const char **text ) { int i; int imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + if (shader.noTC) + imgFlags |= IMGFLAG_NO_COMPRESSION; + if (r_srgb->integer) imgFlags |= IMGFLAG_SRGB; @@ -1906,7 +1918,7 @@ static qboolean ParseShader( const char **text ) } else if ( !Q_stricmp( token, "noTC" ) ) { - //shader.noTC = true; + shader.noTC = qtrue; continue; } // entityMergable, allowing sprite surfaces from multiple entities From 10dcee0ea6f611ad830403dff37a70e8b00d1ca0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 7 Dec 2013 08:32:02 -0600 Subject: [PATCH 122/708] [MP] Rend2: Fixed sky to match vanilla correctly. --- codemp/rd-rend2/tr_sky.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 0f3ff77205..b165cf5208 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -357,7 +357,7 @@ static void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXY } } -static int sky_texorder[6] = {0,2,1,3,4,5}; +static int sky_texorder[6] = {0,1,2,3,4,5}; static vec3_t s_skyPoints[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; From 393d375ea55a3ad0b0d674ba6772612179b5565c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 7 Dec 2013 08:39:42 -0600 Subject: [PATCH 123/708] [MP] Rend2: Don't bother using the shifted array for sky since its in order now. --- codemp/rd-rend2/tr_sky.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index b165cf5208..84d74a66bf 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -357,7 +357,6 @@ static void MakeSkyVec( float s, float t, int axis, float outSt[2], vec3_t outXY } } -static int sky_texorder[6] = {0,1,2,3,4,5}; static vec3_t s_skyPoints[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1]; static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; @@ -543,7 +542,7 @@ static void DrawSkyBox( shader_t *shader ) } } - DrawSkySide( shader->sky.outerbox[sky_texorder[i]], + DrawSkySide( shader->sky.outerbox[i], sky_mins_subd, sky_maxs_subd ); } From 42457d3f750103848029598a515656fac13ef574 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 8 Dec 2013 08:32:20 -0600 Subject: [PATCH 124/708] [MP] Rend2: Some fixes for the default shaders. Add distortion shader stub. It is just default shader so, it will appear as such with cloak. /cg_saberTrail 2. This ensures it will always be 2 like the cgame expects. --- codemp/rd-rend2/tr_shader.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 9bc67437de..d87bf3e538 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4008,6 +4008,10 @@ static void CreateInternalShaders( void ) { Q_strncpyz( shader.name, "", sizeof( shader.name ) ); shader.lightmapIndex = LIGHTMAP_NONE; + for ( int i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { + stages[i].bundle[0].texMods = texMods[i]; + } + stages[0].bundle[0].image[0] = tr.defaultImage; stages[0].active = qtrue; stages[0].stateBits = GLS_DEFAULT; @@ -4015,8 +4019,15 @@ static void CreateInternalShaders( void ) { // shadow shader is just a marker Q_strncpyz( shader.name, "", sizeof( shader.name ) ); - shader.sort = SS_STENCIL_SHADOW; + shader.sort = SS_BANNER; //SS_STENCIL_SHADOW; tr.shadowShader = FinishShader(); + + // distortion shader is just a marker + Q_strncpyz( shader.name, "internal_distortion", sizeof( shader.name ) ); + shader.sort = SS_BLEND0; + shader.defaultShader = qfalse; + tr.distortionShader = FinishShader(); + shader.defaultShader = qtrue; } static void CreateExternalShaders( void ) { From e737d3bcef9dbb3a140588564c4fea1eef7ed914 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 8 Dec 2013 18:32:28 -0600 Subject: [PATCH 125/708] [MP] Rend2: Missing distortionShader. --- codemp/rd-rend2/tr_local.h | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 974ab2ba94..45a0f73c77 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2124,6 +2124,7 @@ typedef struct trGlobals_s { shader_t *defaultShader; shader_t *shadowShader; + shader_t *distortionShader; shader_t *projectionShadowShader; shader_t *flareShader; From ff0a80af00ae18b2bdfc9e4d661ed33fdc52715f Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 8 Dec 2013 18:34:27 -0600 Subject: [PATCH 126/708] [MP] Rend2: Merge ioquake/ioq3@e01b66aef5ac89052ef4766010bc265d20637760 Fix glsl DEFORM_BULGE calculation --- codemp/rd-rend2/glsl_shaders.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl_shaders.cpp b/codemp/rd-rend2/glsl_shaders.cpp index e633ae7276..8d4f86a8f1 100644 --- a/codemp/rd-rend2/glsl_shaders.cpp +++ b/codemp/rd-rend2/glsl_shaders.cpp @@ -282,7 +282,7 @@ const char *fallbackShader_dlight_vp = "\n" "\tif (u_DeformGen == DGEN_BULGE)\n" "\t{\n" -"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t\tphase *= st.x;\n" "\t}\n" "\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" "\t{\n" @@ -452,7 +452,7 @@ const char *fallbackShader_fogpass_vp = "\n" "\tif (u_DeformGen == DGEN_BULGE)\n" "\t{\n" -"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t\tphase *= st.x;\n" "\t}\n" "\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" "\t{\n" @@ -661,7 +661,7 @@ const char *fallbackShader_generic_vp = "\n" "\tif (u_DeformGen == DGEN_BULGE)\n" "\t{\n" -"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t\tphase *= st.x;\n" "\t}\n" "\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" "\t{\n" @@ -1840,7 +1840,7 @@ const char *fallbackShader_shadowfill_vp = "\n" "\tif (u_DeformGen == DGEN_BULGE)\n" "\t{\n" -"\t\tphase *= M_PI * 0.25 * st.x;\n" +"\t\tphase *= st.x;\n" "\t}\n" "\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" "\t{\n" From 1276d100fdc7a00c4a625dd00e39c38cd20946fc Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 9 Dec 2013 12:30:08 -0600 Subject: [PATCH 127/708] [MP] Rend2: Make levelshot command work the same as vanilla. --- codemp/rd-rend2/tr_init.cpp | 40 +++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index af62568ba8..485fb4c420 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -719,50 +719,52 @@ void R_ScreenshotFilename( char *buf, int bufSize, const char *ext ) { ==================== R_LevelShot -levelshots are specialized 128*128 thumbnails for +levelshots are specialized 256*256 thumbnails for the menu system, sampled down from full screen distorted images ==================== */ -void R_LevelShot( void ) { +#define LEVELSHOTSIZE 256 +static void R_LevelShot( void ) { char checkname[MAX_OSPATH]; byte *buffer; byte *source, *allsource; byte *src, *dst; - size_t offset = 0; + size_t offset = 0; int padlen; int x, y; int r, g, b; float xScale, yScale; int xx, yy; - Com_sprintf(checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName); + Com_sprintf( checkname, sizeof(checkname), "levelshots/%s.tga", tr.world->baseName ); allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); source = allsource + offset; - buffer = (byte *)ri->Hunk_AllocateTempMemory(128 * 128*3 + 18); + buffer = (byte *)ri->Hunk_AllocateTempMemory(LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18); Com_Memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type - buffer[12] = 128; - buffer[14] = 128; + buffer[12] = LEVELSHOTSIZE & 255; + buffer[13] = LEVELSHOTSIZE >> 8; + buffer[14] = LEVELSHOTSIZE & 255; + buffer[15] = LEVELSHOTSIZE >> 8; buffer[16] = 24; // pixel size // resample from source - xScale = glConfig.vidWidth / 512.0f; - yScale = glConfig.vidHeight / 384.0f; - for ( y = 0 ; y < 128 ; y++ ) { - for ( x = 0 ; x < 128 ; x++ ) { + xScale = glConfig.vidWidth / (4.0*LEVELSHOTSIZE); + yScale = glConfig.vidHeight / (3.0*LEVELSHOTSIZE); + for ( y = 0 ; y < LEVELSHOTSIZE ; y++ ) { + for ( x = 0 ; x < LEVELSHOTSIZE ; x++ ) { r = g = b = 0; for ( yy = 0 ; yy < 3 ; yy++ ) { for ( xx = 0 ; xx < 4 ; xx++ ) { - src = source + (3 * glConfig.vidWidth + padlen) * (int)((y*3 + yy) * yScale) + - 3 * (int) ((x*4 + xx) * xScale); + src = source + 3 * ( glConfig.vidWidth * (int)( (y*3+yy)*yScale ) + (int)( (x*4+xx)*xScale ) ); r += src[0]; g += src[1]; b += src[2]; } } - dst = buffer + 18 + 3 * ( y * 128 + x ); + dst = buffer + 18 + 3 * ( y * LEVELSHOTSIZE + x ); dst[0] = b / 12; dst[1] = g / 12; dst[2] = r / 12; @@ -770,14 +772,14 @@ void R_LevelShot( void ) { } // gamma correct - if ( glConfig.deviceSupportsGamma ) { - R_GammaCorrect( buffer + 18, 128 * 128 * 3 ); + if ( ( tr.overbrightBits > 0 ) && glConfig.deviceSupportsGamma ) { + R_GammaCorrect( buffer + 18, LEVELSHOTSIZE * LEVELSHOTSIZE * 3 ); } - ri->FS_WriteFile( checkname, buffer, 128 * 128*3 + 18 ); + ri->FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 ); - ri->Hunk_FreeTempMemory(buffer); - ri->Hunk_FreeTempMemory(allsource); + ri->Hunk_FreeTempMemory( buffer ); + ri->Hunk_FreeTempMemory( allsource ); ri->Printf( PRINT_ALL, "Wrote %s\n", checkname ); } From 22cb50a91dcc59d4dd0d1d59eb52a2916c0c1bed Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Dec 2013 08:58:23 +0000 Subject: [PATCH 128/708] [Rend2] Fix Ghoul2 models being rendered twice --- codemp/rd-rend2/tr_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 4539e548b1..994be20f08 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2037,6 +2037,7 @@ static void R_AddEntitySurface (int entityNum) case MOD_MDXM: if (ent->e.ghoul2) R_AddGhoulSurfaces(ent); + break; case MOD_BAD: // null model axis if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { break; From 45292b1e6caa1ae451a00e4f3d72efbae6d4afb0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Dec 2013 08:58:47 +0000 Subject: [PATCH 129/708] [Rend2] Fix out of bounds access The normal map generation code was accessing out of array bounds. This commit fixes the problem. --- codemp/rd-rend2/tr_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b92d827ad8..ad3e9592b4 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -463,11 +463,11 @@ static void RGBAtoNormal(const byte *in, byte *out, int width, int height, qbool if (clampToEdge) { - src_x = CLAMP(src_x, 0, height - 1); + src_x = CLAMP(src_x, 0, width - 1); } else { - src_x = (src_x + height) % height; + src_x = (src_x + width) % width; } s[i++] = *(out + (src_y * width + src_x) * 4 + 3); From 49a602390e6d40a244c8abb487e23f6f1d1ba525 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 13 Dec 2013 23:24:50 +0000 Subject: [PATCH 130/708] [Rend2] glsl_shaders.cpp is now autogenerated. Added a new target to the CMake files to pack all of the .glsl files in the glsl/ folder into a single .cpp file. This will be automatically run every time the rend2 library is built, and if any of the .glsl files have changed. --- codemp/rd-rend2/CMakeLists.txt | 15 +++- codemp/rd-rend2/glsl/compact.cpp | 124 +++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 codemp/rd-rend2/glsl/compact.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 6acc0c3d86..7e68ddd008 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -17,7 +17,6 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_local.h" "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" - "${MPDir}/rd-rend2/glsl_shaders.cpp" "${MPDir}/rd-rend2/tr_animation.cpp" "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" @@ -58,6 +57,10 @@ set(MPRend2Files ) source_group("renderer" FILES ${MPRend2Files}) +file(GLOB MPRend2GLSLFiles "${MPDir}/rd-rend2/glsl/*.glsl") +source_group("renderer\\glsl" FILES ${MPRend2GLSLFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2GLSLFiles}) + set(MPRend2Ghoul2Files "${MPDir}/ghoul2/G2_gore.cpp" "${MPDir}/ghoul2/G2_gore.h") @@ -156,6 +159,9 @@ else(WIN32) set(MPRend2Files ${MPRend2Files} ${MPRend2SysFiles}) endif(WIN32) +source_group("renderer" FILES ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) +set(MPRend2Files ${MPRend2Files} ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OpenJKLibDir}) add_library(${MPRend2} SHARED ${MPRend2Files}) @@ -180,3 +186,10 @@ set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS_DEBUG "${SharedD set_target_properties(${MPRend2} PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") set_target_properties(${MPRend2} PROPERTIES PROJECT_LABEL "MP Rend2 Renderer") target_link_libraries(${MPRend2} ${MPRend2Libraries}) + +# GLSL shader file generator +add_executable(compact_glsl ${MPDir}/rd-rend2/glsl/compact.cpp) +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp + COMMAND compact_glsl ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp ${MPRend2GLSLFiles} + DEPENDS compact_glsl ${MPRend2GLSLFiles}) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp new file mode 100644 index 0000000000..60ff15ad51 --- /dev/null +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -0,0 +1,124 @@ +#include +#include +#include +#include +#include + +typedef std::vector string_list; + +bool should_be_escaped ( char c ) +{ + switch ( c ) + { + case '\\': + case '"': + return true; + default: + return false; + } +} + +std::string& escape_string ( std::string& s ) +{ + int escapable_characters = std::count_if (s.begin(), s.end(), should_be_escaped); + if ( escapable_characters == 0 ) + { + return s; + } + + if ( s.capacity() < s.length() + escapable_characters ) + { + // Grow if necessary. + s.resize (s.length() + escapable_characters); + } + + std::string::iterator it = s.begin(); + while ( it != s.end() ) + { + char c = *it; + if ( should_be_escaped (c) ) + { + std::cout << "escaped something\n"; + it = s.insert (it, '\\'); + it += 2; + } + else + { + ++it; + } + } + + return s; +} + +bool ends_with ( const std::string& s, const std::string& suffix ) +{ + return s.compare (s.length() - suffix.length(), suffix.length(), suffix) == 0; +} + +int main ( int argc, char *argv[] ) +{ + string_list args (argv, argv + argc); + + if ( args.empty() ) + { + std::cerr << "No GLSL files were given.\n"; + return EXIT_FAILURE; + } + + if ( args.size() < 3 ) + { + // 0 = exe, 1 = outfile, 2+ = glsl files + return EXIT_FAILURE; + } + + std::string& outFile = args[1]; + string_list glslFiles (args.begin() + 2, args.end()); + + std::cout << "Outputting to " << outFile << '\n'; + + std::string output = "#include \"tr_local.h\"\n\n"; + + std::string line; + for ( string_list::const_iterator it = glslFiles.begin(); + it != glslFiles.end(); ++it ) + { + // Get shader name from file name + if ( !ends_with (*it, ".glsl") ) + { + std::cerr << *it << " doesn't end with .glsl extension.\n"; + continue; + } + + std::string::size_type lastSlash = it->find_last_of ("\\/"); + std::string shaderName (it->begin() + lastSlash + 1, it->end() - 5); + + // Write, one line at a time to the output + std::ifstream fs (it->c_str(), std::ios::in); + if ( !fs ) + { + std::cerr << *it << " could not be opened.\n"; + continue; + } + + output += "const char *fallbackShader_" + shaderName + " = \""; + while ( std::getline (fs, line) ) + { + if ( line.empty() ) + { + continue; + } + + output += escape_string (line) + "\\n\\\n"; + } + output += "\";\n\n"; + } + + std::ofstream ofs (outFile, std::ios::out); + if ( !ofs ) + { + std::cerr << "Could not create file " << outFile << '\n'; + } + + ofs << output; +} \ No newline at end of file From 8555caeb13e2b9aad9665386acd9cfa56efa15a8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 14 Dec 2013 00:02:00 +0000 Subject: [PATCH 131/708] [Rend2] Updated GLSL files for skeletal animation. --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 27 +++++++++++++++++++++---- codemp/rd-rend2/glsl/generic_vp.glsl | 19 ++++++++++++++++++ codemp/rd-rend2/glsl/lightall_vp.glsl | 29 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index ce0e015b3c..8690c033bb 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -2,10 +2,13 @@ attribute vec4 attr_Position; attribute vec3 attr_Normal; attribute vec4 attr_TexCoord0; -//#if defined(USE_VERTEX_ANIMATION) +#if defined(USE_VERTEX_ANIMATION) attribute vec4 attr_Position2; attribute vec3 attr_Normal2; -//#endif +#elif defined(USE_SKELETAL_ANIMATION) +attribute vec4 attr_BoneIndexes; +attribute vec4 attr_BoneWeights; +#endif uniform vec4 u_FogDistance; uniform vec4 u_FogDepth; @@ -19,9 +22,11 @@ uniform float u_DeformParams[5]; uniform float u_Time; uniform mat4 u_ModelViewProjectionMatrix; -//#if defined(USE_VERTEX_ANIMATION) +#if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; -//#endif +#elif defined(USE_SKELETAL_ANIMATION) +uniform mat4 u_BoneMatrices[80]; +#endif varying float var_Scale; @@ -99,6 +104,20 @@ void main() #if defined(USE_VERTEX_ANIMATION) vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); +#elif defined(USE_SKELETAL_ANIMATION) + vec4 position = vec4(0.0); + vec4 normal4 = vec4(0.0); + vec4 originalNormal = vec4(attr_Normal, 0.0); + + for (int i = 0; i < 4; i++) + { + int boneIndex = int(attr_BoneIndexes[i]); + + position += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i]; + normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + } + + vec3 normal = normal4.xyz; #else vec4 position = attr_Position; vec3 normal = attr_Normal; diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 94e3c83e7c..4106898590 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -4,6 +4,9 @@ attribute vec3 attr_Normal; #if defined(USE_VERTEX_ANIMATION) attribute vec4 attr_Position2; attribute vec3 attr_Normal2; +#elif defined(USE_SKELETAL_ANIMATION) +attribute vec4 attr_BoneIndexes; +attribute vec4 attr_BoneWeights; #endif attribute vec4 attr_Color; @@ -54,6 +57,8 @@ uniform float u_PortalRange; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; +#elif defined(USE_SKELETAL_ANIMATION) +uniform mat4 u_BoneMatrices[80]; #endif varying vec2 var_DiffuseTex; @@ -204,6 +209,20 @@ void main() #if defined(USE_VERTEX_ANIMATION) vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); +#elif defined(USE_SKELETAL_ANIMATION) + vec4 position = vec4(0.0); + vec4 normal4 = vec4(0.0); + vec4 originalNormal = vec4(attr_Normal, 0.0); + + for (int i = 0; i < 4; i++) + { + int boneIndex = int(attr_BoneIndexes[i]); + + position += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i]; + normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + } + + vec3 normal = normal4.xyz; #else vec4 position = attr_Position; vec3 normal = attr_Normal; diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index ce83d10ae9..4fa28e7a77 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -14,6 +14,9 @@ attribute vec3 attr_Position2; attribute vec3 attr_Normal2; attribute vec3 attr_Tangent2; attribute vec3 attr_Bitangent2; +#elif defined(USE_SKELETAL_ANIMATION) +attribute vec4 attr_BoneIndexes; +attribute vec4 attr_BoneWeights; #endif #if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) @@ -46,6 +49,8 @@ uniform mat4 u_ModelMatrix; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; +#elif defined(USE_SKELETAL_ANIMATION) +uniform mat4 u_BoneMatrices[80]; #endif #if defined(USE_LIGHT_VECTOR) @@ -154,6 +159,30 @@ void main() vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); vec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp)); vec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp)); +#elif defined(USE_SKELETAL_ANIMATION) + vec4 position4 = vec4(0.0); + vec4 normal4 = vec4(0.0); + vec4 tangent4 = vec4(0.0); + vec4 bitangent4 = vec4(0.0); + vec4 originalPosition = vec4(attr_Position, 1.0); + vec4 originalNormal = vec4(attr_Normal, 0.0); + vec4 originalTangent = vec4(attr_Tangent, 0.0); + vec4 originalBitangent = vec4(attr_Bitangent, 0.0); + + for (int i = 0; i < 4; i++) + { + int boneIndex = int(attr_BoneIndexes[i]); + + position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; + normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + tangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i]; + bitangent4 += (u_BoneMatrices[boneIndex] * originalBitangent) * attr_BoneWeights[i]; + } + + vec3 position = position4.xyz; + vec3 normal = normal4.xyz; + vec3 tangent = tangent4.xyz; + vec3 bitangent = bitangent4.xyz; #else vec3 position = attr_Position; vec3 normal = attr_Normal; From 888786b5d290d44d192e3d14e3f73a978eec8dfc Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 14 Dec 2013 12:57:17 -0600 Subject: [PATCH 132/708] [MP] Rend2: Updating rend2 to latest codebase from ioq3. tr_ghoul2 does not compiled, too confusing for me. --- codemp/rd-rend2/glsl/bokeh_vp.glsl | 4 +- codemp/rd-rend2/glsl/calclevels4x_vp.glsl | 4 +- codemp/rd-rend2/glsl/dlight_vp.glsl | 18 +- codemp/rd-rend2/glsl/down4x_vp.glsl | 4 +- codemp/rd-rend2/glsl/fogpass_fp.glsl | 2 +- codemp/rd-rend2/glsl/fogpass_vp.glsl | 54 +- codemp/rd-rend2/glsl/generic_fp.glsl | 2 + codemp/rd-rend2/glsl/generic_vp.glsl | 70 +- codemp/rd-rend2/glsl/lightall_fp.glsl | 287 ++++--- codemp/rd-rend2/glsl/lightall_vp.glsl | 148 ++-- codemp/rd-rend2/glsl/pshadow_vp.glsl | 10 +- codemp/rd-rend2/glsl/shadowfill_vp.glsl | 21 +- codemp/rd-rend2/glsl/texturecolor_fp.glsl | 2 +- codemp/rd-rend2/glsl/texturecolor_vp.glsl | 4 +- codemp/rd-rend2/glsl/tonemap_vp.glsl | 4 +- codemp/rd-rend2/tr_animation.cpp | 4 +- codemp/rd-rend2/tr_backend.cpp | 70 +- codemp/rd-rend2/tr_bsp.cpp | 954 +++++++++------------- codemp/rd-rend2/tr_cmds.cpp | 6 - codemp/rd-rend2/tr_curve.cpp | 165 ++-- codemp/rd-rend2/tr_extensions.cpp | 15 + codemp/rd-rend2/tr_fbo.cpp | 34 +- codemp/rd-rend2/tr_flares.cpp | 37 +- codemp/rd-rend2/tr_ghoul2.cpp | 12 +- codemp/rd-rend2/tr_glsl.cpp | 242 ++---- codemp/rd-rend2/tr_image.cpp | 28 +- codemp/rd-rend2/tr_init.cpp | 14 +- codemp/rd-rend2/tr_light.cpp | 59 +- codemp/rd-rend2/tr_local.h | 303 ++----- codemp/rd-rend2/tr_main.cpp | 344 +++----- codemp/rd-rend2/tr_marks.cpp | 24 +- codemp/rd-rend2/tr_mesh.cpp | 2 +- codemp/rd-rend2/tr_model.cpp | 70 +- codemp/rd-rend2/tr_model_iqm.cpp | 184 +++-- codemp/rd-rend2/tr_postprocess.cpp | 40 +- codemp/rd-rend2/tr_scene.cpp | 45 +- codemp/rd-rend2/tr_shade.cpp | 223 ++--- codemp/rd-rend2/tr_shade_calc.cpp | 65 +- codemp/rd-rend2/tr_shader.cpp | 65 +- codemp/rd-rend2/tr_shadows.cpp | 4 +- codemp/rd-rend2/tr_sky.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 161 ++-- codemp/rd-rend2/tr_vbo.cpp | 192 +++-- codemp/rd-rend2/tr_world.cpp | 44 +- 44 files changed, 1834 insertions(+), 2210 deletions(-) diff --git a/codemp/rd-rend2/glsl/bokeh_vp.glsl b/codemp/rd-rend2/glsl/bokeh_vp.glsl index 5ca4160080..bdaa74af8e 100644 --- a/codemp/rd-rend2/glsl/bokeh_vp.glsl +++ b/codemp/rd-rend2/glsl/bokeh_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; uniform mat4 u_ModelViewProjectionMatrix; @@ -8,6 +8,6 @@ varying vec2 var_TexCoords; void main() { - gl_Position = u_ModelViewProjectionMatrix * attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_TexCoords = attr_TexCoord0.st; } diff --git a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl index 5ca4160080..bdaa74af8e 100644 --- a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; uniform mat4 u_ModelViewProjectionMatrix; @@ -8,6 +8,6 @@ varying vec2 var_TexCoords; void main() { - gl_Position = u_ModelViewProjectionMatrix * attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_TexCoords = attr_TexCoord0.st; } diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index d9fd71d061..9566a04c26 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; attribute vec3 attr_Normal; @@ -32,7 +32,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) if (u_DeformGen == DGEN_BULGE) { - phase *= M_PI * 0.25 * st.x; + phase *= st.x; } else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) { @@ -48,7 +48,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } else if (u_DeformGen == DGEN_WAVE_SQUARE) { - func = sign(sin(value * 2.0 * M_PI)); + func = sign(0.5 - fract(value)); } else if (u_DeformGen == DGEN_WAVE_TRIANGLE) { @@ -62,7 +62,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) { func = (1.0 - fract(value)); } - else if (u_DeformGen == DGEN_BULGE) + else // if (u_DeformGen == DGEN_BULGE) { func = sin(value); } @@ -73,16 +73,16 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) void main() { - vec4 position = attr_Position; - vec3 normal = attr_Normal; + vec3 position = attr_Position; + vec3 normal = attr_Normal * 2.0 - vec3(1.0); #if defined(USE_DEFORM_VERTEXES) - position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); + position = DeformPosition(position, normal, attr_TexCoord0.st); #endif - gl_Position = u_ModelViewProjectionMatrix * position; + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - vec3 dist = u_DlightInfo.xyz - position.xyz; + vec3 dist = u_DlightInfo.xyz - position; var_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5); float dlightmod = step(0.0, dot(dist, normal)); diff --git a/codemp/rd-rend2/glsl/down4x_vp.glsl b/codemp/rd-rend2/glsl/down4x_vp.glsl index 5ca4160080..bdaa74af8e 100644 --- a/codemp/rd-rend2/glsl/down4x_vp.glsl +++ b/codemp/rd-rend2/glsl/down4x_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; uniform mat4 u_ModelViewProjectionMatrix; @@ -8,6 +8,6 @@ varying vec2 var_TexCoords; void main() { - gl_Position = u_ModelViewProjectionMatrix * attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_TexCoords = attr_TexCoord0.st; } diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl index 91884304d5..e2ad465ba3 100644 --- a/codemp/rd-rend2/glsl/fogpass_fp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_fp.glsl @@ -5,5 +5,5 @@ varying float var_Scale; void main() { gl_FragColor = u_Color; - gl_FragColor.a *= sqrt(clamp(var_Scale, 0.0, 1.0)); + gl_FragColor.a = sqrt(clamp(var_Scale, 0.0, 1.0)); } diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index 8690c033bb..2d5a2c5de1 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -1,9 +1,10 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec3 attr_Normal; + attribute vec4 attr_TexCoord0; #if defined(USE_VERTEX_ANIMATION) -attribute vec4 attr_Position2; +attribute vec3 attr_Position2; attribute vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) attribute vec4 attr_BoneIndexes; @@ -14,10 +15,10 @@ uniform vec4 u_FogDistance; uniform vec4 u_FogDepth; uniform float u_FogEyeT; -//#if defined(USE_DEFORM_VERTEXES) +#if defined(USE_DEFORM_VERTEXES) uniform int u_DeformGen; uniform float u_DeformParams[5]; -//#endif +#endif uniform float u_Time; uniform mat4 u_ModelViewProjectionMatrix; @@ -28,6 +29,8 @@ uniform float u_VertexLerp; uniform mat4 u_BoneMatrices[80]; #endif +uniform vec4 u_Color; + varying float var_Scale; #if defined(USE_DEFORM_VERTEXES) @@ -46,7 +49,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) if (u_DeformGen == DGEN_BULGE) { - phase *= M_PI * 0.25 * st.x; + phase *= st.x; } else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) { @@ -62,7 +65,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } else if (u_DeformGen == DGEN_WAVE_SQUARE) { - func = sign(sin(value * 2.0 * M_PI)); + func = sign(0.5 - fract(value)); } else if (u_DeformGen == DGEN_WAVE_TRIANGLE) { @@ -76,7 +79,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) { func = (1.0 - fract(value)); } - else if (u_DeformGen == DGEN_BULGE) + else // if (u_DeformGen == DGEN_BULGE) { func = sin(value); } @@ -85,15 +88,15 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } #endif -float CalcFog(vec4 position) +float CalcFog(vec3 position) { - float s = dot(position, u_FogDistance) * 8.0; - float t = dot(position, u_FogDepth); + float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; + float t = dot(vec4(position, 1.0), u_FogDepth); + + float eyeOutside = float(u_FogEyeT < 0.0); + float fogged = float(t >= eyeOutside); - float eyeOutside = step(0.0, -u_FogEyeT); - float fogged = step(eyeOutside, t); - - t = max(t, 1e-6); + t += 1e-6; t *= fogged / (t - u_FogEyeT * eyeOutside); return s * t; @@ -102,32 +105,35 @@ float CalcFog(vec4 position) void main() { #if defined(USE_VERTEX_ANIMATION) - vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) - vec4 position = vec4(0.0); + vec3 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); + vec4 originalPosition = vec4(attr_Position, 1.0); vec4 originalNormal = vec4(attr_Normal, 0.0); for (int i = 0; i < 4; i++) { int boneIndex = int(attr_BoneIndexes[i]); - position += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i]; + position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; } - vec3 normal = normal4.xyz; + vec3 position = position4.xyz; + vec3 normal = normalize(normal4.xyz - vec3(0.5)); #else - vec4 position = attr_Position; - vec3 normal = attr_Normal; + vec3 position = attr_Position; + vec3 normal = attr_Normal * 2.0 - vec3(1.0); #endif #if defined(USE_DEFORM_VERTEXES) - position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); + position = DeformPosition(position, normal, attr_TexCoord0.st); #endif - gl_Position = u_ModelViewProjectionMatrix * position; + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - var_Scale = CalcFog(position); + var_Scale = CalcFog(position) * u_Color.a * u_Color.a; } diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index 997d4daab0..f485797fb3 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -37,6 +37,8 @@ void main() { color = color2; } + + //color = color * (u_Texture1Env.xxxx + color2 * u_Texture1Env.z) + color2 * u_Texture1Env.y; #endif gl_FragColor = color * var_Color; diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 4106898590..61d92b1002 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -1,8 +1,8 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec3 attr_Normal; #if defined(USE_VERTEX_ANIMATION) -attribute vec4 attr_Position2; +attribute vec3 attr_Position2; attribute vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) attribute vec4 attr_BoneIndexes; @@ -78,7 +78,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) if (u_DeformGen == DGEN_BULGE) { - phase *= M_PI * 0.25 * st.x; + phase *= st.x; } else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) { @@ -94,11 +94,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } else if (u_DeformGen == DGEN_WAVE_SQUARE) { - func = sign(sin(value * 2.0 * M_PI)); + func = sign(fract(0.5 - value)); } else if (u_DeformGen == DGEN_WAVE_TRIANGLE) { - func = 1.0 - abs(4.0 * fract(value + 0.25) - 2.0); + func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; } else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) { @@ -108,7 +108,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) { func = (1.0 - fract(value)); } - else if (u_DeformGen == DGEN_BULGE) + else // if (u_DeformGen == DGEN_BULGE) { func = sin(value); } @@ -129,7 +129,9 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) { vec3 viewer = normalize(u_LocalViewOrigin - position); - tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; } else if (TCGen == TCGEN_VECTOR) { @@ -144,13 +146,14 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) { float amplitude = offTurb.z; - float phase = offTurb.w; - vec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy; + float phase = offTurb.w * 2.0 * M_PI; + vec2 st2; + st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); + st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); - vec3 offsetPos = position / 1024.0; - offsetPos.x += offsetPos.z; + vec2 offsetPos = vec2(position.x + position.z, position.y); - vec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI); + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); return st2 + texOffset * amplitude; } @@ -172,7 +175,7 @@ vec4 CalcColor(vec3 position, vec3 normal) if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) { - vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position.xyz); + vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); vec3 reflected = -reflect(lightDir, normal); color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); @@ -189,15 +192,15 @@ vec4 CalcColor(vec3 position, vec3 normal) #endif #if defined(USE_FOG) -float CalcFog(vec4 position) +float CalcFog(vec3 position) { - float s = dot(position, u_FogDistance) * 8.0; - float t = dot(position, u_FogDepth); + float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; + float t = dot(vec4(position, 1.0), u_FogDepth); - float eyeOutside = step(0.0, -u_FogEyeT); - float fogged = step(eyeOutside, t); - - t = max(t, 1e-6); + float eyeOutside = float(u_FogEyeT < 0.0); + float fogged = float(t < eyeOutside); + + t += 1e-6; t *= fogged / (t - u_FogEyeT * eyeOutside); return s * t; @@ -207,41 +210,44 @@ float CalcFog(vec4 position) void main() { #if defined(USE_VERTEX_ANIMATION) - vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) - vec4 position = vec4(0.0); + vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); + vec4 originalPosition = vec4(attr_Position, 1.0); vec4 originalNormal = vec4(attr_Normal, 0.0); for (int i = 0; i < 4; i++) { int boneIndex = int(attr_BoneIndexes[i]); - position += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i]; + position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; } - vec3 normal = normal4.xyz; + vec3 position = position4.xyz; + vec3 normal = normalize(normal4.xyz - vec3(0.5)); #else - vec4 position = attr_Position; - vec3 normal = attr_Normal; + vec3 position = attr_Position; + vec3 normal = attr_Normal * 2.0 - vec3(1.0); #endif #if defined(USE_DEFORM_VERTEXES) - position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); + position = DeformPosition(position, normal, attr_TexCoord0.st); #endif - gl_Position = u_ModelViewProjectionMatrix * position; + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); #if defined(USE_TCGEN) - vec2 tex = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1); + vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); #else vec2 tex = attr_TexCoord0.st; #endif #if defined(USE_TCMOD) - var_DiffuseTex = ModTexCoords(tex, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); + var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); #else var_DiffuseTex = tex; #endif @@ -251,7 +257,7 @@ void main() #endif #if defined(USE_RGBAGEN) - var_Color = CalcColor(position.xyz, normal); + var_Color = CalcColor(position, normal); #else var_Color = u_VertColor * attr_Color + u_BaseColor; #endif diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index f223bb0cb4..7d9449b9b8 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -24,6 +24,10 @@ uniform sampler2D u_ShadowMap; uniform samplerCube u_CubeMap; #endif +#if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) +uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube +#endif + #if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) uniform vec3 u_DirectedLight; uniform vec3 u_AmbientLight; @@ -42,17 +46,22 @@ varying vec4 var_TexCoords; varying vec4 var_Color; -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) -varying vec4 var_Normal; -varying vec4 var_Tangent; -varying vec4 var_Bitangent; +#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) + #if defined(USE_VERT_TANGENT_SPACE) +varying vec4 var_Normal; +varying vec4 var_Tangent; +varying vec4 var_Bitangent; + #else +varying vec3 var_Normal; +varying vec3 var_ViewDir; + #endif #endif #if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) varying vec3 var_LightColor; #endif -#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) varying vec4 var_LightDir; #endif @@ -167,12 +176,31 @@ vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) float CalcBlinn(float NH, float shininess) { +#if defined(USE_BLINN) || defined(USE_BLINN_FRESNEL) + // Normalized Blinn-Phong + float norm = shininess * 0.125 + 1.0; +#elif defined(USE_MCAULEY) + // Cook-Torrance as done by Stephen McAuley + // http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf + float norm = shininess * 0.25 + 0.125; +#elif defined(USE_GOTANDA) + // Neumann-Neumann as done by Yoshiharu Gotanda + // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf + float norm = shininess * 0.124858 + 0.269182; +#elif defined(USE_LAZAROV) + // Cook-Torrance as done by Dimitar Lazarov + // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + float norm = shininess * 0.125 + 0.25; +#else + float norm = 1.0; +#endif + #if 0 - // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ + // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ float a = shininess + 0.775; - return exp(a * NH - a); + return norm * exp(a * NH - a); #else - return pow(NH, shininess); + return norm * pow(NH, shininess); #endif } @@ -206,120 +234,122 @@ float CalcFresnel(float EH) float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) { -#if 1 - // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf +#if defined(USE_GOTANDA) + // Neumann-Neumann as done by Yoshiharu Gotanda + // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf + return 1.0 / max(max(NL, NE), EPSILON); +#elif defined(USE_LAZAROV) + // Cook-Torrance as done by Dimitar Lazarov + // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf float k = min(1.0, gloss + 0.545); - return 1.0 / (k * EH * EH + (1.0 - k)); -#elif 0 + return 1.0 / (k * (EH * EH - 1.0) + 1.0); +#elif defined(USE_GGX) float roughness = exp2(gloss * -6.5); - #if defined(USE_GGX) - // From http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf - float k = roughness + 1.0; - k *= k * 0.125; - #else - float k = roughness; - #endif // Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf // NL, NE in numerator factored out from cook-torrance + float k = roughness + 1.0; + k *= k * 0.125; + float k2 = 1.0 - k; float invGeo1 = NL * k2 + k; float invGeo2 = NE * k2 + k; - + return 1.0 / (invGeo1 * invGeo2); #else - float geo = 2.0 * NH * min(NE, NL); - geo /= max(EH, geo); - - return geo; + return 1.0; #endif } vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess) { - float blinn = CalcBlinn(NH, shininess); +#if defined(USE_GGX) + float distrib = CalcGGX(NH, gloss); +#else + float distrib = CalcBlinn(NH, shininess); +#endif + +#if defined(USE_BLINN) + vec3 fSpecular = specular; +#else vec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH)); +#endif + float vis = CalcVisibility(NH, NL, NE, EH, gloss); - #if defined(USE_BLINN) - // Normalized Blinn-Phong - return specular * blinn * (shininess * 0.125 + 1.0); - #elif defined(USE_BLINN_FRESNEL) - // Normalized Blinn-Phong with Fresnel - return fSpecular * blinn * (shininess * 0.125 + 1.0); - #elif defined(USE_MCAULEY) - // Cook-Torrance as done by Stephen McAuley - // http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf - return fSpecular * blinn * (shininess * 0.25 + 0.125); - #elif defined(USE_GOTANDA) - // Neumann-Neumann as done by Yoshiharu Gotanda - // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf - return fSpecular * blinn * (shininess * 0.124858 + 0.269182) / max(max(NL, NE), EPSILON); - #elif defined(USE_LAZAROV) - // Cook-Torrance as done by Dimitar Lazarov - // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - return fSpecular * blinn * (shininess * 0.125 + 0.25) * vis; - #endif - - return vec3(0.0); + return fSpecular * (distrib * vis); } -float CalcLightAttenuation(vec3 dir, float sqrRadius) +float CalcLightAttenuation(float point, float normDist) { - // point light at >0 radius, directional otherwise - float point = float(sqrRadius > 0.0); - - // inverse square light - float attenuation = sqrRadius / dot(dir, dir); - - // zero light at radius, approximating q3 style + // zero light at 1.0, approximating q3 style // also don't attenuate directional light - attenuation = (0.5 * attenuation - 1.5) * point + 1.0; - + float attenuation = (0.5 * normDist - 1.5) * point + 1.0; + // clamp attenuation #if defined(NO_LIGHT_CLAMP) attenuation = max(attenuation, 0.0); #else attenuation = clamp(attenuation, 0.0, 1.0); #endif - + return attenuation; } +// from http://www.thetenthplanet.de/archives/1180 +mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) +{ + // get edge vectors of the pixel triangle + vec3 dp1 = dFdx( p ); + vec3 dp2 = dFdy( p ); + vec2 duv1 = dFdx( uv ); + vec2 duv2 = dFdy( uv ); + + // solve the linear system + vec3 dp2perp = cross( dp2, N ); + vec3 dp1perp = cross( N, dp1 ); + vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; + vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; + + // construct a scale-invariant frame + float invmax = inversesqrt( max( dot(T,T), dot(B,B) ) ); + return mat3( T * invmax, B * invmax, N ); +} void main() { vec3 L, N, E, H; float NL, NH, NE, EH; - -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) - mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); -#endif -#if defined(USE_DELUXEMAP) - L = (2.0 * texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(1.0)); - #if defined(USE_TANGENT_SPACE_LIGHT) - L = L * tangentToWorld; +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_VERT_TANGENT_SPACE) + mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); + E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); + #else + mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, var_TexCoords.xy); + E = var_ViewDir; #endif -#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - L = var_LightDir.xyz; -#endif -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) - E = normalize(vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w)); + E = normalize(E); + + L = var_LightDir.xyz; + #if defined(USE_DELUXEMAP) + L += (texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; + #endif + float sqrLightDist = dot(L, L); #endif #if defined(USE_LIGHTMAP) - vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw).rgba; + vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw); + vec3 lightColor = lightSample.rgb; #if defined(RGBM_LIGHTMAP) - lightSample.rgb *= 32.0 * lightSample.a; + lightColor *= 32.0 * lightSample.a; #endif - vec3 lightColor = lightSample.rgb; #elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) - vec3 lightColor = u_DirectedLight * CalcLightAttenuation(L, var_LightDir.w); + vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); vec3 ambientColor = u_AmbientLight; #elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) vec3 lightColor = var_LightColor; @@ -328,11 +358,7 @@ void main() vec2 texCoords = var_TexCoords.xy; #if defined(USE_PARALLAXMAP) - #if defined(USE_TANGENT_SPACE_LIGHT) - vec3 offsetDir = E; - #else - vec3 offsetDir = E * tangentToWorld; - #endif + vec3 offsetDir = normalize(E * tangentToWorld); offsetDir.xy *= -0.05 / offsetDir.z; @@ -348,33 +374,27 @@ void main() #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_NORMALMAP) #if defined(SWIZZLE_NORMALMAP) - N.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - vec2(1.0); + N.xy = texture2D(u_NormalMap, texCoords).ag - vec2(0.5); #else - N.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - vec2(1.0); - #endif - N.z = sqrt(1.0 - clamp(dot(N.xy, N.xy), 0.0, 1.0)); - #if !defined(USE_TANGENT_SPACE_LIGHT) - N = normalize(tangentToWorld * N); + N.xy = texture2D(u_NormalMap, texCoords).rg - vec2(0.5); #endif - #elif defined(USE_TANGENT_SPACE_LIGHT) - N = vec3(0.0, 0.0, 1.0); + N.xy *= u_EnableTextures.x; + N.z = sqrt((0.25 - N.x * N.x) - N.y * N.y); + N = tangentToWorld * N; #else - N = normalize(var_Normal.xyz); + N = var_Normal.xyz; #endif - - L = normalize(L); + + N = normalize(N); + L /= sqrt(sqrLightDist); #if defined(USE_SHADOWMAP) vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; float shadowValue = texture2D(u_ShadowMap, shadowTex).r; // surfaces not facing the light are always shadowed - #if defined(USE_TANGENT_SPACE_LIGHT) - shadowValue *= step(0.0, var_PrimaryLightDir.z); - #else - shadowValue *= step(0.0, dot(var_Normal.xyz, var_PrimaryLightDir.xyz)); - #endif - + shadowValue *= float(dot(var_Normal.xyz, var_PrimaryLightDir.xyz) > 0.0); + #if defined(SHADOWMAP_MODULATE) //vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor); vec3 shadowColor = u_PrimaryLightAmbient * lightColor; @@ -389,12 +409,7 @@ void main() #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) vec3 ambientColor = lightColor; - - #if defined(USE_TANGENT_SPACE_LIGHT) - float surfNL = L.z; - #else float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); - #endif // Scale the incoming light to compensate for the baked-in light angle // attenuation. @@ -410,43 +425,41 @@ void main() NL = clamp(dot(N, L), 0.0, 1.0); NE = clamp(dot(N, E), 0.0, 1.0); + vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) - vec4 specular = texture2D(u_SpecularMap, texCoords); + specular += texture2D(u_SpecularMap, texCoords) * u_EnableTextures.z - u_EnableTextures.zzzz; #if defined(USE_GAMMA2_TEXTURES) specular.rgb *= specular.rgb; #endif - #else - vec4 specular = vec4(1.0); #endif specular *= u_MaterialInfo.xxxy; - + float gloss = specular.a; float shininess = exp2(gloss * 13.0); #if defined(SPECULAR_IS_METALLIC) - // diffuse is actually base color, and red of specular is metallicness + // diffuse is actually base color, and red of specular is metallicness float metallic = specular.r; - - specular.rgb = vec3(0.04) + 0.96 * diffuse.rgb * metallic; + + specular.rgb = (0.96 * metallic) * diffuse.rgb + vec3(0.04); diffuse.rgb *= 1.0 - metallic; #else // adjust diffuse by specular reflectance, to maintain energy conservation diffuse.rgb *= vec3(1.0) - specular.rgb; #endif - - + reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess); #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR) float adjGloss = gloss; float adjShininess = shininess; - - #if !defined(USE_LIGHT_VECTOR) + + #if !defined(USE_LIGHT_VECTOR) adjGloss *= r_deluxeSpecular; adjShininess = exp2(adjGloss * 13.0); - #endif - + #endif + H = normalize(L + E); EH = clamp(dot(E, H), 0.0, 1.0); @@ -458,19 +471,16 @@ void main() reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess); #endif #endif - - gl_FragColor.rgb = lightColor * reflectance * NL; + + gl_FragColor.rgb = lightColor * reflectance * NL; gl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb); - + #if defined(USE_CUBEMAP) reflectance = EnvironmentBRDF(gloss, NE, specular.rgb); vec3 R = reflect(E, N); - #if defined(USE_TANGENT_SPACE_LIGHT) - R = tangentToWorld * R; - #endif - vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb; + vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; #if defined(USE_LIGHTMAP) cubeLightColor *= lightSample.rgb; @@ -479,29 +489,40 @@ void main() #else cubeLightColor *= lightColor * NL + ambientColor; #endif - - //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb; + + //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb * u_EnableTextures.w; gl_FragColor.rgb += cubeLightColor * reflectance; #endif #if defined(USE_PRIMARY_LIGHT) - L = var_PrimaryLightDir.xyz; //normalize(var_PrimaryLightDir.xyz); - NL = clamp(dot(N, L), 0.0, 1.0); + vec3 L2, H2; + float NL2, EH2, NH2; - H = normalize(L + E); - EH = clamp(dot(E, H), 0.0, 1.0); - NH = clamp(dot(N, H), 0.0, 1.0); + L2 = var_PrimaryLightDir.xyz; - reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess); - reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss, shininess); + // enable when point lights are supported as primary lights + //sqrLightDist = dot(L2, L2); + //L2 /= sqrt(sqrLightDist); + + NL2 = clamp(dot(N, L2), 0.0, 1.0); + + H2 = normalize(L2 + E); + EH2 = clamp(dot(E, H2), 0.0, 1.0); + NH2 = clamp(dot(N, H2), 0.0, 1.0); + + reflectance = CalcDiffuse(diffuse.rgb, N, L2, E, NE, NL2, shininess); + reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss, shininess); + + lightColor = u_PrimaryLightColor; + + // enable when point lights are supported as primary lights + //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); - lightColor = u_PrimaryLightColor; // * CalcLightAttenuation(L, u_PrimaryLightDir.w); - #if defined(USE_SHADOWMAP) lightColor *= shadowValue; #endif - gl_FragColor.rgb += lightColor * reflectance * NL; + gl_FragColor.rgb += lightColor * reflectance * NL2; #endif gl_FragColor.a = diffuse.a; diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 4fa28e7a77..31f1a10e69 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -6,14 +6,16 @@ attribute vec4 attr_Color; attribute vec3 attr_Position; attribute vec3 attr_Normal; -attribute vec3 attr_Tangent; -attribute vec3 attr_Bitangent; +#if defined(USE_VERT_TANGENT_SPACE) +attribute vec4 attr_Tangent; +#endif #if defined(USE_VERTEX_ANIMATION) attribute vec3 attr_Position2; attribute vec3 attr_Normal2; -attribute vec3 attr_Tangent2; -attribute vec3 attr_Bitangent2; + #if defined(USE_VERT_TANGENT_SPACE) +attribute vec4 attr_Tangent2; + #endif #elif defined(USE_SKELETAL_ANIMATION) attribute vec4 attr_BoneIndexes; attribute vec4 attr_BoneWeights; @@ -23,15 +25,19 @@ attribute vec4 attr_BoneWeights; attribute vec3 attr_LightDirection; #endif -#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(USE_DELUXEMAP) +uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube +#endif + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) uniform vec3 u_ViewOrigin; -uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCGEN) uniform int u_TCGen0; uniform vec3 u_TCGen0Vector0; uniform vec3 u_TCGen0Vector1; +uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCMOD) @@ -56,8 +62,8 @@ uniform mat4 u_BoneMatrices[80]; #if defined(USE_LIGHT_VECTOR) uniform vec4 u_LightOrigin; uniform float u_LightRadius; -uniform vec3 u_DirectedLight; #if defined(USE_FAST_LIGHT) +uniform vec3 u_DirectedLight; uniform vec3 u_AmbientLight; #endif #endif @@ -71,17 +77,22 @@ varying vec4 var_TexCoords; varying vec4 var_Color; -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_VERT_TANGENT_SPACE) varying vec4 var_Normal; varying vec4 var_Tangent; varying vec4 var_Bitangent; + #else +varying vec3 var_Normal; +varying vec3 var_ViewDir; + #endif #endif #if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) varying vec3 var_LightColor; #endif -#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) varying vec4 var_LightDir; #endif @@ -101,13 +112,15 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) { vec3 viewer = normalize(u_LocalViewOrigin - position); - tex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5; + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; } else if (TCGen == TCGEN_VECTOR) { tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); } - + return tex; } #endif @@ -116,38 +129,33 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) { float amplitude = offTurb.z; - float phase = offTurb.w; - vec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy; - - vec3 offsetPos = position / 1024.0; - offsetPos.x += offsetPos.z; - - vec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI); - + float phase = offTurb.w * 2.0 * M_PI; + vec2 st2; + st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); + st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); + + vec2 offsetPos = vec2(position.x + position.z, position.y); + + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); + return st2 + texOffset * amplitude; } #endif -float CalcLightAttenuation(vec3 dir, float sqrRadius) +float CalcLightAttenuation(float point, float normDist) { - // point light at >0 radius, directional otherwise - float point = float(sqrRadius > 0.0); - - // inverse square light - float attenuation = sqrRadius / dot(dir, dir); - - // zero light at radius, approximating q3 style + // zero light at 1.0, approximating q3 style // also don't attenuate directional light - attenuation = (0.5 * attenuation - 1.5) * point + 1.0; - + float attenuation = (0.5 * normDist - 1.5) * point + 1.0; + // clamp attenuation #if defined(NO_LIGHT_CLAMP) attenuation = max(attenuation, 0.0); #else attenuation = clamp(attenuation, 0.0, 1.0); #endif - + return attenuation; } @@ -155,19 +163,18 @@ float CalcLightAttenuation(vec3 dir, float sqrRadius) void main() { #if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); - vec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp)); - vec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp)); + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); + #endif #elif defined(USE_SKELETAL_ANIMATION) vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); vec4 tangent4 = vec4(0.0); - vec4 bitangent4 = vec4(0.0); vec4 originalPosition = vec4(attr_Position, 1.0); vec4 originalNormal = vec4(attr_Normal, 0.0); vec4 originalTangent = vec4(attr_Tangent, 0.0); - vec4 originalBitangent = vec4(attr_Bitangent, 0.0); for (int i = 0; i < 4; i++) { @@ -176,18 +183,22 @@ void main() position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; tangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i]; - bitangent4 += (u_BoneMatrices[boneIndex] * originalBitangent) * attr_BoneWeights[i]; } vec3 position = position4.xyz; vec3 normal = normal4.xyz; vec3 tangent = tangent4.xyz; - vec3 bitangent = bitangent4.xyz; #else vec3 position = attr_Position; vec3 normal = attr_Normal; - vec3 tangent = attr_Tangent; - vec3 bitangent = attr_Bitangent; + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 tangent = attr_Tangent.xyz; + #endif +#endif + + normal = normal * 2.0 - vec3(1.0); +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + tangent = tangent * 2.0 - vec3(1.0); #endif #if defined(USE_TCGEN) @@ -205,16 +216,21 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); #if defined(USE_MODELMATRIX) - position = (u_ModelMatrix * vec4(position, 1.0)).xyz; - normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; - tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; - bitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz; + position = (u_ModelMatrix * vec4(position, 1.0)).xyz; + normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; + #endif +#endif + +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); #endif #if defined(USE_LIGHT_VECTOR) vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); -#elif defined(USE_LIGHT) && !defined(USE_DELUXEMAP) - vec3 L = attr_LightDirection; +#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 L = attr_LightDirection * 2.0 - vec3(1.0); #if defined(USE_MODELMATRIX) L = (u_ModelMatrix * vec4(L, 0.0)).xyz; #endif @@ -223,7 +239,7 @@ void main() #if defined(USE_LIGHTMAP) var_TexCoords.zw = attr_TexCoord1.st; #endif - + var_Color = u_VertColor * attr_Color + u_BaseColor; #if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) var_LightColor = var_Color.rgb; @@ -231,10 +247,11 @@ void main() #endif #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - float attenuation = CalcLightAttenuation(L, u_LightRadius * u_LightRadius); - float NL = clamp(dot(normal, normalize(L)), 0.0, 1.0); + float sqrLightDist = dot(L, L); + float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); + float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); - var_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight; + var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) @@ -242,38 +259,27 @@ void main() var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; #endif -#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_LIGHT_VECTOR) var_LightDir = vec4(L, u_LightRadius * u_LightRadius); #else var_LightDir = vec4(L, 0.0); #endif -#endif - -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) - vec3 viewDir = u_ViewOrigin - position; -#endif - -#if defined(USE_TANGENT_SPACE_LIGHT) - mat3 tangentToWorld = mat3(tangent, bitangent, normal); - - #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) - var_PrimaryLightDir.xyz = var_PrimaryLightDir.xyz * tangentToWorld; - #endif - - #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT) - var_LightDir.xyz = var_LightDir.xyz * tangentToWorld; - #endif - - #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) - viewDir = viewDir * tangentToWorld; + #if defined(USE_DELUXEMAP) + var_LightDir -= u_EnableTextures.y * var_LightDir; #endif #endif -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 viewDir = u_ViewOrigin - position; + #if defined(USE_VERT_TANGENT_SPACE) // store view direction in tangent space to save on varyings var_Normal = vec4(normal, viewDir.x); var_Tangent = vec4(tangent, viewDir.y); var_Bitangent = vec4(bitangent, viewDir.z); + #else + var_Normal = normal; + var_ViewDir = viewDir; + #endif #endif } diff --git a/codemp/rd-rend2/glsl/pshadow_vp.glsl b/codemp/rd-rend2/glsl/pshadow_vp.glsl index 0e0e3b3d3d..0f9940cd4e 100644 --- a/codemp/rd-rend2/glsl/pshadow_vp.glsl +++ b/codemp/rd-rend2/glsl/pshadow_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec3 attr_Normal; uniform mat4 u_ModelViewProjectionMatrix; @@ -8,10 +8,8 @@ varying vec3 var_Normal; void main() { - vec4 position = attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - gl_Position = u_ModelViewProjectionMatrix * position; - - var_Position = position.xyz; - var_Normal = attr_Normal; + var_Position = attr_Position; + var_Normal = attr_Normal * 2.0 - vec3(1.0); } diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl index 10802ecaf7..7a5cc571a1 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -1,9 +1,9 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec3 attr_Normal; attribute vec4 attr_TexCoord0; //#if defined(USE_VERTEX_ANIMATION) -attribute vec4 attr_Position2; +attribute vec3 attr_Position2; attribute vec3 attr_Normal2; //#endif @@ -38,7 +38,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) if (u_DeformGen == DGEN_BULGE) { - phase *= M_PI * 0.25 * st.x; + phase *= st.x; } else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) { @@ -54,7 +54,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } else if (u_DeformGen == DGEN_WAVE_SQUARE) { - func = sign(sin(value * 2.0 * M_PI)); + func = sign(0.5 - fract(value)); } else if (u_DeformGen == DGEN_WAVE_TRIANGLE) { @@ -68,7 +68,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) { func = (1.0 - fract(value)); } - else if (u_DeformGen == DGEN_BULGE) + else // if (u_DeformGen == DGEN_BULGE) { func = sin(value); } @@ -78,12 +78,13 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) void main() { - vec4 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp)); + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + normal = normalize(normal - vec3(0.5)); - position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st); + position = DeformPosition(position, normal, attr_TexCoord0.st); - gl_Position = u_ModelViewProjectionMatrix * position; + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - var_Position = (u_ModelMatrix * position).xyz; + var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz; } diff --git a/codemp/rd-rend2/glsl/texturecolor_fp.glsl b/codemp/rd-rend2/glsl/texturecolor_fp.glsl index 5646b511c7..e077e7daf2 100644 --- a/codemp/rd-rend2/glsl/texturecolor_fp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_fp.glsl @@ -3,7 +3,7 @@ uniform sampler2D u_DiffuseMap; uniform vec4 u_Color; -varying vec2 var_Tex1; +varying vec2 var_Tex1; void main() diff --git a/codemp/rd-rend2/glsl/texturecolor_vp.glsl b/codemp/rd-rend2/glsl/texturecolor_vp.glsl index ae26a18e84..7a5750a564 100644 --- a/codemp/rd-rend2/glsl/texturecolor_vp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_vp.glsl @@ -1,6 +1,6 @@ #version 120 -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; uniform mat4 u_ModelViewProjectionMatrix; @@ -10,6 +10,6 @@ varying vec2 var_Tex1; void main() { - gl_Position = u_ModelViewProjectionMatrix * attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_Tex1 = attr_TexCoord0.st; } diff --git a/codemp/rd-rend2/glsl/tonemap_vp.glsl b/codemp/rd-rend2/glsl/tonemap_vp.glsl index 5ca4160080..bdaa74af8e 100644 --- a/codemp/rd-rend2/glsl/tonemap_vp.glsl +++ b/codemp/rd-rend2/glsl/tonemap_vp.glsl @@ -1,4 +1,4 @@ -attribute vec4 attr_Position; +attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; uniform mat4 u_ModelViewProjectionMatrix; @@ -8,6 +8,6 @@ varying vec2 var_TexCoords; void main() { - gl_Position = u_ModelViewProjectionMatrix * attr_Position; + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_TexCoords = attr_TexCoord0.st; } diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index f7f3f2415c..a6d8e6f49e 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -411,9 +411,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) tess.xyz[baseVertex + j][1] = tempVert[1]; tess.xyz[baseVertex + j][2] = tempVert[2]; - tess.normal[baseVertex + j][0] = tempNormal[0]; - tess.normal[baseVertex + j][1] = tempNormal[1]; - tess.normal[baseVertex + j][2] = tempNormal[2]; + tess.normal[baseVertex + j] = R_VboPackTangent(tempNormal); tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index bc21c94a55..1759849387 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -101,7 +101,7 @@ void GL_BindToTMU( image_t *image, int tmu ) if (image) image->frameUsed = tr.frameCount; glState.currenttextures[tmu] = texnum; - + if (image && (image->flags & IMGFLAG_CUBEMAP)) qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); else @@ -459,7 +459,7 @@ void RB_BeginDrawingView (void) { { if (!tr.renderFbo || (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -473,6 +473,7 @@ void RB_BeginDrawingView (void) { // FIXME: hack for cubemap testing if (backEnd.viewParms.targetFbo == tr.renderCubeFbo) { + //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); } } @@ -846,6 +847,10 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * } R_IssuePendingRenderCommands(); + if ( tess.numIndexes ) { + RB_EndSurface(); + } + // we definately want to sync every frame for the cinematics qglFinish(); @@ -875,7 +880,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * { if (!tr.renderFbo || backEnd.framePostProcessed) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -962,7 +967,7 @@ const void *RB_StretchPic ( const void *data ) { { if (!tr.renderFbo || backEnd.framePostProcessed) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -1060,7 +1065,7 @@ const void *RB_RotatePic ( const void *data ) { if (!tr.renderFbo || backEnd.framePostProcessed) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -1161,7 +1166,7 @@ const void *RB_RotatePic2 ( const void *data ) { if (!tr.renderFbo || backEnd.framePostProcessed) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -1661,7 +1666,7 @@ const void *RB_ClearDepth(const void *data) { if (!tr.renderFbo || backEnd.framePostProcessed) { - FBO_Bind(tr.screenScratchFbo); + FBO_Bind(NULL); } else { @@ -1730,32 +1735,13 @@ const void *RB_SwapBuffers( const void *data ) { { // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - FBO_FastBlit(tr.msaaResolveFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } else if (tr.renderFbo) { - FBO_FastBlit(tr.renderFbo, NULL, tr.screenScratchFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } } - - if (tr.screenScratchFbo) - { - vec4_t color; - - color[0] = - color[1] = - color[2] = pow(2.0f, tr.overbrightBits); //exp2(tr.overbrightBits); - color[3] = 1.0f; - - // turn off colormask when copying final image - if (backEnd.colorMask[0] || backEnd.colorMask[1] || backEnd.colorMask[2] || backEnd.colorMask[3]) - qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - FBO_Blit(tr.screenScratchFbo, NULL, NULL, NULL, NULL, NULL, color, 0); - - if (backEnd.colorMask[0] || backEnd.colorMask[1] || backEnd.colorMask[2] || backEnd.colorMask[3]) - qglColorMask(!backEnd.colorMask[0], !backEnd.colorMask[1], !backEnd.colorMask[2], !backEnd.colorMask[3]); - } } if ( !glState.finishCalled ) { @@ -1872,11 +1858,11 @@ const void *RB_PostProcess(const void *data) if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) { autoExposure = (qboolean)(r_autoExposure->integer || r_forceAutoExposure->integer); - RB_ToneMap(srcFbo, srcBox, tr.screenScratchFbo, dstBox, autoExposure); + RB_ToneMap(srcFbo, srcBox, NULL, dstBox, autoExposure); } else if (r_cameraExposure->value == 0.0f) { - FBO_FastBlit(srcFbo, srcBox, tr.screenScratchFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST); + FBO_FastBlit(srcFbo, srcBox, NULL, dstBox, GL_COLOR_BUFFER_BIT, GL_NEAREST); } else { @@ -1887,15 +1873,15 @@ const void *RB_PostProcess(const void *data) color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); color[3] = 1.0f; - FBO_Blit(srcFbo, srcBox, NULL, tr.screenScratchFbo, dstBox, NULL, color, 0); + FBO_Blit(srcFbo, srcBox, NULL, NULL, dstBox, NULL, color, 0); } } if (r_drawSunRays->integer) - RB_SunRays(tr.screenScratchFbo, srcBox, tr.screenScratchFbo, dstBox); + RB_SunRays(NULL, srcBox, NULL, dstBox); if (1) - RB_BokehBlur(tr.screenScratchFbo, srcBox, tr.screenScratchFbo, dstBox, backEnd.refdef.blurFactor); + RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); else RB_GaussianBlur(backEnd.refdef.blurFactor); @@ -1903,27 +1889,27 @@ const void *RB_PostProcess(const void *data) { vec4i_t dstBox; VectorSet4(dstBox, 0, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); VectorSet4(dstBox, 128, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); VectorSet4(dstBox, 256, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); } if (0) { vec4i_t dstBox; VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); VectorSet4(dstBox, 512, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); } if (0) { vec4i_t dstBox; VectorSet4(dstBox, 256, glConfig.vidHeight - 256, 256, 256); - FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, tr.screenScratchFbo, dstBox, NULL, NULL, 0); + FBO_BlitFromTexture(tr.sunRaysImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); } #if 0 @@ -1932,11 +1918,11 @@ const void *RB_PostProcess(const void *data) vec4i_t dstBox; int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.or.origin ); - if(cubemapIndex) + if (cubemapIndex) { VectorSet4(dstBox, 0, glConfig.vidHeight - 256, 256, 256); - //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, tr.screenScratchFbo, dstBox, &tr.testcubeShader, NULL, 0); - FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1], NULL, NULL, tr.screenScratchFbo, dstBox, &tr.testcubeShader, NULL, 0); + //FBO_BlitFromTexture(tr.renderCubeImage, NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); + FBO_BlitFromTexture(tr.cubemaps[cubemapIndex - 1], NULL, NULL, NULL, dstBox, &tr.testcubeShader, NULL, 0); } } #endif diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a66feec358..cabf35b919 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -653,9 +653,9 @@ ParseFace */ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { int i, j; - srfSurfaceFace_t *cv; - srfTriangle_t *tri; - int numVerts, numTriangles, badTriangles; + srfBspSurface_t *cv; + glIndex_t *tri; + int numVerts, numIndexes, badTriangles; int realLightmapNum; realLightmapNum = LittleLong( ds->lightmapNum[0] ); @@ -676,14 +676,14 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, surf->shader = tr.defaultShader; } - numTriangles = LittleLong(ds->numIndexes) / 3; + numIndexes = LittleLong(ds->numIndexes); //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); - cv = (srfSurfaceFace_t *)surf->data; + cv = (srfBspSurface_t *)surf->data; cv->surfaceType = SF_FACE; - cv->numTriangles = numTriangles; - cv->triangles = (srfTriangle_t *)ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->numIndexes = numIndexes; + cv->indexes = (glIndex_t *)ri->Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); cv->numVerts = numVerts; cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); @@ -741,39 +741,39 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, // copy triangles badTriangles = 0; indexes += LittleLong(ds->firstIndex); - for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) { for(j = 0; j < 3; j++) { - tri->indexes[j] = LittleLong(indexes[i * 3 + j]); + tri[j] = LittleLong(indexes[i + j]); - if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) + if(tri[j] >= numVerts) { ri->Error(ERR_DROP, "Bad index in face surface"); } } - if ((tri->indexes[0] == tri->indexes[1]) || (tri->indexes[1] == tri->indexes[2]) || (tri->indexes[0] == tri->indexes[2])) + if ((tri[0] == tri[1]) || (tri[1] == tri[2]) || (tri[0] == tri[2])) { - tri--; + tri -= 3; badTriangles++; } } if (badTriangles) { - ri->Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); - cv->numTriangles -= badTriangles; + ri->Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); + cv->numIndexes -= badTriangles * 3; } // take the plane information from the lightmap vector for ( i = 0 ; i < 3 ; i++ ) { - cv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); + cv->cullPlane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] ); } - cv->plane.dist = DotProduct( cv->verts[0].xyz, cv->plane.normal ); - SetPlaneSignbits( &cv->plane ); - cv->plane.type = PlaneTypeForNormal( cv->plane.normal ); - surf->cullinfo.plane = cv->plane; + cv->cullPlane.dist = DotProduct( cv->verts[0].xyz, cv->cullPlane.normal ); + SetPlaneSignbits( &cv->cullPlane ); + cv->cullPlane.type = PlaneTypeForNormal( cv->cullPlane.normal ); + surf->cullinfo.plane = cv->cullPlane; surf->data = (surfaceType_t *)cv; @@ -782,11 +782,11 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, { srfVert_t *dv[3]; - for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) { - dv[0] = &cv->verts[tri->indexes[0]]; - dv[1] = &cv->verts[tri->indexes[1]]; - dv[2] = &cv->verts[tri->indexes[2]]; + dv[0] = &cv->verts[tri[0]]; + dv[1] = &cv->verts[tri[1]]; + dv[2] = &cv->verts[tri[2]]; R_CalcTangentVectors(dv); } @@ -801,7 +801,7 @@ ParseMesh =============== */ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { - srfGridMesh_t *grid; + srfBspSurface_t *grid; int i, j; int width, height, numPoints; srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE]; @@ -904,10 +904,10 @@ ParseTriSurf =============== */ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { - srfTriangles_t *cv; - srfTriangle_t *tri; + srfBspSurface_t *cv; + glIndex_t *tri; int i, j; - int numVerts, numTriangles, badTriangles; + int numVerts, numIndexes, badTriangles; // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -919,14 +919,14 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor } numVerts = LittleLong(ds->numVerts); - numTriangles = LittleLong(ds->numIndexes) / 3; + numIndexes = LittleLong(ds->numIndexes); //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); - cv = (srfTriangles_t *)surf->data; + cv = (srfBspSurface_t *)surf->data; cv->surfaceType = SF_TRIANGLES; - cv->numTriangles = numTriangles; - cv->triangles = (srfTriangle_t *)ri->Hunk_Alloc(numTriangles * sizeof(cv->triangles[0]), h_low); + cv->numIndexes = numIndexes; + cv->indexes = (glIndex_t *)ri->Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); cv->numVerts = numVerts; cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); @@ -985,29 +985,29 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor // copy triangles badTriangles = 0; indexes += LittleLong(ds->firstIndex); - for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) { for(j = 0; j < 3; j++) { - tri->indexes[j] = LittleLong(indexes[i * 3 + j]); + tri[j] = LittleLong(indexes[i + j]); - if(tri->indexes[j] < 0 || tri->indexes[j] >= numVerts) + if(tri[j] >= numVerts) { ri->Error(ERR_DROP, "Bad index in face surface"); } } - if ((tri->indexes[0] == tri->indexes[1]) || (tri->indexes[1] == tri->indexes[2]) || (tri->indexes[0] == tri->indexes[2])) + if ((tri[0] == tri[1]) || (tri[1] == tri[2]) || (tri[0] == tri[2])) { - tri--; + tri -= 3; badTriangles++; } } if (badTriangles) { - ri->Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numTriangles, numVerts, numTriangles - badTriangles); - cv->numTriangles -= badTriangles; + ri->Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); + cv->numIndexes -= badTriangles * 3; } #ifdef USE_VERT_TANGENT_SPACE @@ -1015,11 +1015,11 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor { srfVert_t *dv[3]; - for(i = 0, tri = cv->triangles; i < numTriangles; i++, tri++) + for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) { - dv[0] = &cv->verts[tri->indexes[0]]; - dv[1] = &cv->verts[tri->indexes[1]]; - dv[2] = &cv->verts[tri->indexes[2]]; + dv[0] = &cv->verts[tri[0]]; + dv[1] = &cv->verts[tri[1]]; + dv[2] = &cv->verts[tri[2]]; R_CalcTangentVectors(dv); } @@ -1066,7 +1066,7 @@ R_MergedWidthPoints returns true if there are grid points merged on a width edge ================= */ -int R_MergedWidthPoints(srfGridMesh_t *grid, int offset) { +int R_MergedWidthPoints(srfBspSurface_t *grid, int offset) { int i, j; for (i = 1; i < grid->width-1; i++) { @@ -1087,7 +1087,7 @@ R_MergedHeightPoints returns true if there are grid points merged on a height edge ================= */ -int R_MergedHeightPoints(srfGridMesh_t *grid, int offset) { +int R_MergedHeightPoints(srfBspSurface_t *grid, int offset) { int i, j; for (i = 1; i < grid->height-1; i++) { @@ -1110,13 +1110,13 @@ NOTE: never sync LoD through grid edges with merged points! FIXME: write generalized version that also avoids cracks between a patch and one that meets half way? ================= */ -void R_FixSharedVertexLodError_r( int start, srfGridMesh_t *grid1 ) { +void R_FixSharedVertexLodError_r( int start, srfBspSurface_t *grid1 ) { int j, k, l, m, n, offset1, offset2, touch; - srfGridMesh_t *grid2; + srfBspSurface_t *grid2; for ( j = start; j < s_worldData.numsurfaces; j++ ) { // - grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data; + grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; // if this surface is not a grid if ( grid2->surfaceType != SF_GRID ) continue; // if the LOD errors are already fixed for this patch @@ -1224,11 +1224,11 @@ If this is not the case this function will still do its job but won't fix the hi */ void R_FixSharedVertexLodError( void ) { int i; - srfGridMesh_t *grid1; + srfBspSurface_t *grid1; for ( i = 0; i < s_worldData.numsurfaces; i++ ) { // - grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data; + grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; // if this surface is not a grid if ( grid1->surfaceType != SF_GRID ) continue; @@ -1250,11 +1250,11 @@ R_StitchPatches */ int R_StitchPatches( int grid1num, int grid2num ) { float *v1, *v2; - srfGridMesh_t *grid1, *grid2; + srfBspSurface_t *grid1, *grid2; int k, l, m, n, offset1, offset2, row, column; - grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data; - grid2 = (srfGridMesh_t *) s_worldData.surfaces[grid2num].data; + grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; + grid2 = (srfBspSurface_t *) s_worldData.surfaces[grid2num].data; for (n = 0; n < 2; n++) { // if (n) offset1 = (grid1->height-1) * grid1->width; @@ -1665,13 +1665,13 @@ might still appear at that side. */ int R_TryStitchingPatch( int grid1num ) { int j, numstitches; - srfGridMesh_t *grid1, *grid2; + srfBspSurface_t *grid1, *grid2; numstitches = 0; - grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data; + grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; for ( j = 0; j < s_worldData.numsurfaces; j++ ) { // - grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data; + grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; // if this surface is not a grid if ( grid2->surfaceType != SF_GRID ) continue; // grids in the same LOD group should have the exact same lod radius @@ -1696,7 +1696,7 @@ R_StitchAllPatches */ void R_StitchAllPatches( void ) { int i, stitched, numstitches; - srfGridMesh_t *grid1; + srfBspSurface_t *grid1; numstitches = 0; do @@ -1704,7 +1704,7 @@ void R_StitchAllPatches( void ) { stitched = qfalse; for ( i = 0; i < s_worldData.numsurfaces; i++ ) { // - grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data; + grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; // if this surface is not a grid if ( grid1->surfaceType != SF_GRID ) continue; @@ -1729,17 +1729,17 @@ R_MovePatchSurfacesToHunk */ void R_MovePatchSurfacesToHunk(void) { int i, size; - srfGridMesh_t *grid, *hunkgrid; + srfBspSurface_t *grid, *hunkgrid; for ( i = 0; i < s_worldData.numsurfaces; i++ ) { // - grid = (srfGridMesh_t *) s_worldData.surfaces[i].data; + grid = (srfBspSurface_t *) s_worldData.surfaces[i].data; // if this surface is not a grid if ( grid->surfaceType != SF_GRID ) continue; // size = sizeof(*grid); - hunkgrid = (srfGridMesh_t *)ri->Hunk_Alloc(size, h_low); + hunkgrid = (srfBspSurface_t *)ri->Hunk_Alloc(size, h_low); Com_Memcpy(hunkgrid, grid, size); hunkgrid->widthLodError = (float *)ri->Hunk_Alloc( grid->width * 4, h_low ); @@ -1748,9 +1748,9 @@ void R_MovePatchSurfacesToHunk(void) { hunkgrid->heightLodError = (float *)ri->Hunk_Alloc( grid->height * 4, h_low ); Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 ); - hunkgrid->numTriangles = grid->numTriangles; - hunkgrid->triangles = (srfTriangle_t *)ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); - Com_Memcpy(hunkgrid->triangles, grid->triangles, grid->numTriangles * sizeof(srfTriangle_t)); + hunkgrid->numIndexes = grid->numIndexes; + hunkgrid->indexes = (glIndex_t *)ri->Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); + Com_Memcpy(hunkgrid->indexes, grid->indexes, grid->numIndexes * sizeof(glIndex_t)); hunkgrid->numVerts = grid->numVerts; hunkgrid->verts = (srfVert_t *)ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); @@ -1792,10 +1792,12 @@ static int BSPSurfaceCompare(const void *a, const void *b) // by cubemapIndex if(aa->cubemapIndex < bb->cubemapIndex) - return 1; + return -1; + else if(aa->cubemapIndex > bb->cubemapIndex) return 1; + return 0; } @@ -1809,12 +1811,14 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out) out->xyz[j] = in->xyz[j]; #ifdef USE_VERT_TANGENT_SPACE out->tangent[j] = in->tangent[j]; - out->bitangent[j] = in->bitangent[j]; + //out->bitangent[j] = in->bitangent[j]; #endif out->normal[j] = in->normal[j]; out->lightdir[j] = in->lightdir[j]; } + out->tangent[3] = in->tangent[3]; + for(j = 0; j < 2; j++) { out->st[j] = in->st[j]; @@ -1840,294 +1844,185 @@ static void R_CreateWorldVBOs(void) int numVerts; srfVert_t *verts; - int numTriangles; - srfTriangle_t *triangles; + int numIndexes; + glIndex_t *indexes; - int numSortedSurfaces = 0, numSurfaces; + int numSortedSurfaces, numSurfaces; msurface_t *surface, **firstSurf, **lastSurf, **currSurf; msurface_t **surfacesSorted; VBO_t *vbo; IBO_t *ibo; + int maxVboSize = 4 * 1024 * 1024; + int maxIboSize = 4 * 1024 * 1024; + int startTime, endTime; startTime = ri->Milliseconds(); + // count surfaces + numSortedSurfaces = 0; for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) { - if(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES) - numSortedSurfaces++; - } + srfBspSurface_t *bspSurf; + shader_t *shader = surface->shader; - // presort surfaces - surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); + if (shader->isPortal) + continue; - j = 0; - for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) - { - if(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES) - { - surfacesSorted[j++] = surface; - } - } + if (shader->isSky) + continue; - qsort(surfacesSorted, numSortedSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); + if (ShaderRequiresCPUDeforms(shader)) + continue; - k = 0; - for(firstSurf = lastSurf = surfacesSorted; firstSurf < &surfacesSorted[numSortedSurfaces]; firstSurf = lastSurf) - { - while(lastSurf < &surfacesSorted[numSortedSurfaces] && (*lastSurf)->shader->sortedIndex == (*firstSurf)->shader->sortedIndex) - lastSurf++; - numVerts = numTriangles = numSurfaces = 0; - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) - { - surface = *currSurf; - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *face = (srfSurfaceFace_t *) surface->data; - - if(face->numVerts) - numVerts += face->numVerts; + // check for this now so we can use srfBspSurface_t* universally in the rest of the function + if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) + continue; - if(face->numTriangles) - numTriangles += face->numTriangles; + bspSurf = (srfBspSurface_t *) surface->data; - numSurfaces++; - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *grid = (srfGridMesh_t *) surface->data; + if (!bspSurf->numIndexes || !bspSurf->numVerts) + continue; - if(grid->numVerts) - numVerts += grid->numVerts; + numSortedSurfaces++; + } - if(grid->numTriangles) - numTriangles += grid->numTriangles; + // presort surfaces + surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); - numSurfaces++; - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *tri = (srfTriangles_t *) surface->data; + j = 0; + for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) + { + srfBspSurface_t *bspSurf; + shader_t *shader = surface->shader; - if(tri->numVerts) - numVerts += tri->numVerts; + if (shader->isPortal) + continue; - if(tri->numTriangles) - numTriangles += tri->numTriangles; + if (shader->isSky) + continue; - numSurfaces++; - } - } + if (ShaderRequiresCPUDeforms(shader)) + continue; - if(!numVerts || !numTriangles) + // check for this now so we can use srfBspSurface_t* universally in the rest of the function + if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) continue; - ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numTriangles); + bspSurf = (srfBspSurface_t *) surface->data; - // create arrays - verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); - triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory(numTriangles * sizeof(srfTriangle_t)); - - // set up triangle indices - numVerts = 0; - numTriangles = 0; - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) - { - surface = *currSurf; - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + if (!bspSurf->numIndexes || !bspSurf->numVerts) + continue; - srf->firstIndex = numTriangles * 3; + surfacesSorted[j++] = surface; + } - if(srf->numTriangles) - { - srfTriangle_t *tri; - - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; - - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) - { - for(j = 0; j < 3; j++) - { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); - } - } + qsort(surfacesSorted, numSortedSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); - numTriangles += srf->numTriangles; - } + k = 0; + for(firstSurf = lastSurf = surfacesSorted; firstSurf < &surfacesSorted[numSortedSurfaces]; firstSurf = lastSurf) + { + int currVboSize, currIboSize; - if(srf->numVerts) - numVerts += srf->numVerts; - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; - srf->firstIndex = numTriangles * 3; + // Find range of surfaces to merge by: + // - Collecting a number of surfaces which fit under maxVboSize/maxIboSize, or + // - All the surfaces with a single shader which go over maxVboSize/maxIboSize + currVboSize = currIboSize = 0; + while (currVboSize < maxVboSize && currIboSize < maxIboSize && lastSurf < &surfacesSorted[numSortedSurfaces]) + { + int addVboSize, addIboSize, currShaderIndex; - if(srf->numTriangles) - { - srfTriangle_t *tri; - - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; - - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) - { - for(j = 0; j < 3; j++) - { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); - } - } - - numTriangles += srf->numTriangles; - } - - if(srf->numVerts) - numVerts += srf->numVerts; - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; + addVboSize = addIboSize = 0; + currShaderIndex = (*lastSurf)->shader->sortedIndex; - srf->firstIndex = numTriangles * 3; + for(currSurf = lastSurf; currSurf < &surfacesSorted[numSortedSurfaces] && (*currSurf)->shader->sortedIndex == currShaderIndex; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - if(srf->numTriangles) - { - srfTriangle_t *tri; + addVboSize += bspSurf->numVerts * sizeof(srfVert_t); + addIboSize += bspSurf->numIndexes * sizeof(glIndex_t); + } - srf->minIndex = numVerts + srf->triangles->indexes[0]; - srf->maxIndex = numVerts + srf->triangles->indexes[0]; + if ((currVboSize != 0 && addVboSize + currVboSize > maxVboSize) + || (currIboSize != 0 && addIboSize + currIboSize > maxIboSize)) + break; - for(i = 0, tri = srf->triangles; i < srf->numTriangles; i++, tri++) - { - for(j = 0; j < 3; j++) - { - triangles[numTriangles + i].indexes[j] = numVerts + tri->indexes[j]; - srf->minIndex = MIN(srf->minIndex, numVerts + tri->indexes[j]); - srf->maxIndex = MAX(srf->maxIndex, numVerts + tri->indexes[j]); - } - } - numTriangles += srf->numTriangles; - } + lastSurf = currSurf; - if(srf->numVerts) - numVerts += srf->numVerts; - } + currVboSize += addVboSize; + currIboSize += addIboSize; } - // build vertices - numVerts = 0; - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + // count verts/indexes/surfaces + numVerts = 0; + numIndexes = 0; + numSurfaces = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) { - surface = *currSurf; - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - srf->firstVert = numVerts; + numVerts += bspSurf->numVerts; + numIndexes += bspSurf->numIndexes; + numSurfaces++; + } - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); - numVerts += srf->numVerts; - } - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + // create arrays + verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); - srf->firstVert = numVerts; + // set up indices and copy vertices + numVerts = 0; + numIndexes = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + glIndex_t *surfIndex; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + bspSurf->firstIndex = numIndexes; + bspSurf->minIndex = numVerts + bspSurf->indexes[0]; + bspSurf->maxIndex = numVerts + bspSurf->indexes[0]; - numVerts += srf->numVerts; - } - } - else if(*surface->data == SF_TRIANGLES) + for(i = 0, surfIndex = bspSurf->indexes; i < bspSurf->numIndexes; i++, surfIndex++) { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; - - srf->firstVert = numVerts; + indexes[numIndexes++] = numVerts + *surfIndex; + bspSurf->minIndex = MIN(bspSurf->minIndex, numVerts + *surfIndex); + bspSurf->maxIndex = MAX(bspSurf->maxIndex, numVerts + *surfIndex); + } - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - CopyVert(&srf->verts[i], &verts[numVerts + i]); - } + bspSurf->firstVert = numVerts; - numVerts += srf->numVerts; - } + for(i = 0; i < bspSurf->numVerts; i++) + { + CopyVert(&bspSurf->verts[i], &verts[numVerts++]); } } #ifdef USE_VERT_TANGENT_SPACE vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, - ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_TANGENT | ATTR_BITANGENT | - ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); + ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_TANGENT | + ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); #else vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, - ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | - ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); + ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | + ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); #endif - ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", k), numTriangles, triangles, VBO_USAGE_STATIC); + ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", k), numIndexes, indexes, VBO_USAGE_STATIC); - // point triangle surfaces to VBO + // point bsp surfaces to VBO for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) { - surface = *currSurf; - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; - - if( srf->numVerts && srf->numTriangles) - { - srf->vbo = vbo; - srf->ibo = ibo; - } - } - else if(*surface->data == SF_GRID) - { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; - - if( srf->numVerts && srf->numTriangles) - { - srf->vbo = vbo; - srf->ibo = ibo; - } - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; - - if( srf->numVerts && srf->numTriangles) - { - srf->vbo = vbo; - srf->ibo = ibo; - } - } + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + bspSurf->vbo = vbo; + bspSurf->ibo = ibo; } - ri->Hunk_FreeTempMemory(triangles); + ri->Hunk_FreeTempMemory(indexes); ri->Hunk_FreeTempMemory(verts); k++; @@ -2201,7 +2096,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // Two passes, allocate surfaces first, then load them full of data // This ensures surfaces are close together to reduce L2 cache misses when using VBOs, - // which don't actually use the verts and tris + // which don't actually use the verts and indexes in = (dsurface_t *)(fileBase + surfs->fileofs); out = s_worldData.surfaces; for ( i = 0 ; i < count ; i++, in++, out++ ) { @@ -2210,10 +2105,10 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // FIXME: do this break; case MST_TRIANGLE_SOUP: - out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfTriangles_t), h_low); + out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfBspSurface_t), h_low); break; case MST_PLANAR: - out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfSurfaceFace_t), h_low); + out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfBspSurface_t), h_low); break; case MST_FLARE: out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfFlare_t), h_low); @@ -2230,13 +2125,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { case MST_PATCH: ParseMesh ( in, dv, hdrVertColors, out ); { - srfGridMesh_t *surface = (srfGridMesh_t *)out->data; + srfBspSurface_t *surface = (srfBspSurface_t *)out->data; out->cullinfo.type = CULLINFO_BOX | CULLINFO_SPHERE; - VectorCopy(surface->meshBounds[0], out->cullinfo.bounds[0]); - VectorCopy(surface->meshBounds[1], out->cullinfo.bounds[1]); - VectorCopy(surface->localOrigin, out->cullinfo.localOrigin); - out->cullinfo.radius = surface->meshRadius; + VectorCopy(surface->cullBounds[0], out->cullinfo.bounds[0]); + VectorCopy(surface->cullBounds[1], out->cullinfo.bounds[1]); + VectorCopy(surface->cullOrigin, out->cullinfo.localOrigin); + out->cullinfo.radius = surface->cullRadius; } numMeshes++; break; @@ -2937,113 +2832,112 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp void R_LoadCubemapEntities(char *cubemapEntityName) { char spawnVarChars[2048]; - int numSpawnVars; - char *spawnVars[MAX_SPAWN_VARS][2]; + int numSpawnVars; + char *spawnVars[MAX_SPAWN_VARS][2]; int numCubemaps = 0; - // count cubemaps - numCubemaps = 0; - - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) - { - int i; - - for (i = 0; i < numSpawnVars; i++) - { - if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) - numCubemaps++; - } - } - - if (!numCubemaps) - return; - - tr.numCubemaps = numCubemaps; - tr.cubemapOrigins = (vec3_t *)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); - tr.cubemaps = (image_t **)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); - - numCubemaps = 0; - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) - { - int i; - qboolean isCubemap = qfalse; - qboolean positionSet = qfalse; - vec3_t origin; - - for (i = 0; i < numSpawnVars; i++) - { - if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) - isCubemap = qtrue; - - if (!Q_stricmp(spawnVars[i][0], "origin")) - { - sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]); - positionSet = qtrue; - } - } - - if (isCubemap && positionSet) - { - //ri.Printf(PRINT_ALL, "cubemap at %f %f %f\n", origin[0], origin[1], origin[2]); - VectorCopy(origin, tr.cubemapOrigins[numCubemaps]); - numCubemaps++; - } + // count cubemaps + numCubemaps = 0; + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + { + int i; + + for (i = 0; i < numSpawnVars; i++) + { + if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) + numCubemaps++; + } + } + + if (!numCubemaps) + return; + + tr.numCubemaps = numCubemaps; + tr.cubemapOrigins = (vec3_t *)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); + tr.cubemaps = (image_t **)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + + numCubemaps = 0; + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + { + int i; + qboolean isCubemap = qfalse; + qboolean positionSet = qfalse; + vec3_t origin; + + for (i = 0; i < numSpawnVars; i++) + { + if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) + isCubemap = qtrue; + + if (!Q_stricmp(spawnVars[i][0], "origin")) + { + sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]); + positionSet = qtrue; + } + } + + if (isCubemap && positionSet) + { + //ri.Printf(PRINT_ALL, "cubemap at %f %f %f\n", origin[0], origin[1], origin[2]); + VectorCopy(origin, tr.cubemapOrigins[numCubemaps]); + numCubemaps++; + } } } -void R_AssignCubemapsToWorldSurfaces(void) -{ - world_t *w; - int i; - - w = &s_worldData; - - for (i = 0; i < w->numsurfaces; i++) - { - msurface_t *surf = &w->surfaces[i]; - vec3_t surfOrigin; - - if (surf->cullinfo.type & CULLINFO_SPHERE) - { - VectorCopy(surf->cullinfo.localOrigin, surfOrigin); - } - else if (surf->cullinfo.type & CULLINFO_BOX) - { - surfOrigin[0] = (surf->cullinfo.bounds[0][0] + surf->cullinfo.bounds[1][0]) * 0.5f; - surfOrigin[1] = (surf->cullinfo.bounds[0][1] + surf->cullinfo.bounds[1][1]) * 0.5f; - surfOrigin[2] = (surf->cullinfo.bounds[0][2] + surf->cullinfo.bounds[1][2]) * 0.5f; - } - else - { - //ri.Printf(PRINT_ALL, "surface %d has no cubemap\n", i); - continue; - } - - surf->cubemapIndex = R_CubemapForPoint(surfOrigin); - //ri.Printf(PRINT_ALL, "surface %d has cubemap %d\n", i, surf->cubemapIndex); - } -} - - -void R_RenderAllCubemaps(void) -{ - int i, j; - - for (i = 0; i < tr.numCubemaps; i++) - { - tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8); - } - - for (i = 0; i < tr.numCubemaps; i++) - { - for (j = 0; j < 6; j++) - { - RE_ClearScene(); - R_RenderCubemapSide(i, j, qfalse); - R_IssuePendingRenderCommands(); - R_InitNextFrame(); - } - } +void R_AssignCubemapsToWorldSurfaces(void) +{ + world_t *w; + int i; + + w = &s_worldData; + + for (i = 0; i < w->numsurfaces; i++) + { + msurface_t *surf = &w->surfaces[i]; + vec3_t surfOrigin; + + if (surf->cullinfo.type & CULLINFO_SPHERE) + { + VectorCopy(surf->cullinfo.localOrigin, surfOrigin); + } + else if (surf->cullinfo.type & CULLINFO_BOX) + { + surfOrigin[0] = (surf->cullinfo.bounds[0][0] + surf->cullinfo.bounds[1][0]) * 0.5f; + surfOrigin[1] = (surf->cullinfo.bounds[0][1] + surf->cullinfo.bounds[1][1]) * 0.5f; + surfOrigin[2] = (surf->cullinfo.bounds[0][2] + surf->cullinfo.bounds[1][2]) * 0.5f; + } + else + { + //ri.Printf(PRINT_ALL, "surface %d has no cubemap\n", i); + continue; + } + + surf->cubemapIndex = R_CubemapForPoint(surfOrigin); + //ri.Printf(PRINT_ALL, "surface %d has cubemap %d\n", i, surf->cubemapIndex); + } +} + + +void R_RenderAllCubemaps(void) +{ + int i, j; + + for (i = 0; i < tr.numCubemaps; i++) + { + tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8); + } + + for (i = 0; i < tr.numCubemaps; i++) + { + for (j = 0; j < 6; j++) + { + RE_ClearScene(); + R_RenderCubemapSide(i, j, qfalse); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + } + } } @@ -3228,109 +3122,61 @@ void R_MergeLeafSurfaces(void) vec3_t bounds[2]; int numSurfsToMerge; - int numTriangles; + int numIndexes; int numVerts; int firstIndex; - srfVBOMesh_t *vboSurf; + srfBspSurface_t *vboSurf; if (s_worldData.surfacesViewCount[i] != i) continue; surf1 = s_worldData.surfaces + i; - // retrieve vbo - switch(*surf1->data) - { - case SF_FACE: - vbo = ((srfSurfaceFace_t *)(surf1->data))->vbo; - break; - - case SF_GRID: - vbo = ((srfGridMesh_t *)(surf1->data))->vbo; - break; - - case SF_TRIANGLES: - vbo = ((srfTriangles_t *)(surf1->data))->vbo; - break; - - default: - vbo = NULL; - break; - } + // retrieve vbo + vbo = ((srfBspSurface_t *)(surf1->data))->vbo; // count verts, indexes, and surfaces numSurfsToMerge = 0; - numTriangles = 0; + numIndexes = 0; numVerts = 0; - for (j = 0; j < numWorldSurfaces; j++) + for (j = i; j < numWorldSurfaces; j++) { msurface_t *surf2; + srfBspSurface_t *bspSurf; if (s_worldData.surfacesViewCount[j] != i) continue; surf2 = s_worldData.surfaces + j; - switch(*surf2->data) - { - case SF_FACE: - { - srfSurfaceFace_t *face; - - face = (srfSurfaceFace_t *) surf2->data; - numTriangles += face->numTriangles; - numVerts += face->numVerts; - } - break; - - case SF_GRID: - { - srfGridMesh_t *grid; - - grid = (srfGridMesh_t *) surf2->data; - numTriangles += grid->numTriangles; - numVerts += grid->numVerts; - } - break; - - case SF_TRIANGLES: - { - srfTriangles_t *tris; - - tris = (srfTriangles_t *) surf2->data; - numTriangles += tris->numTriangles; - numVerts += tris->numVerts; - } - break; - - default: - break; - } - + bspSurf = (srfBspSurface_t *) surf2->data; + numIndexes += bspSurf->numIndexes; + numVerts += bspSurf->numVerts; numSurfsToMerge++; } - if (numVerts == 0 || numTriangles == 0 || numSurfsToMerge < 2) + if (numVerts == 0 || numIndexes == 0 || numSurfsToMerge < 2) { continue; } - // create ibo - ibo = tr.ibos[tr.numIBOs] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); - memset(ibo, 0, sizeof(*ibo)); - Q_strncpyz(ibo->name, va("staticWorldMesh_IBO_mergedSurfs%i", tr.numIBOs++), sizeof(ibo->name)); - numIboIndexes = 0; - - // allocate indexes - iboIndexes = outIboIndexes = (glIndex_t*)Z_Malloc(numTriangles * 3 * sizeof(*outIboIndexes), TAG_BSP); + // create ibo + ibo = tr.ibos[tr.numIBOs] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); + memset(ibo, 0, sizeof(*ibo)); + Q_strncpyz(ibo->name, va("staticWorldMesh_IBO_mergedSurfs%i", tr.numIBOs++), sizeof(ibo->name)); + numIboIndexes = 0; + + // allocate indexes + iboIndexes = outIboIndexes = (glIndex_t*)Z_Malloc(numIndexes * sizeof(*outIboIndexes), TAG_BSP); // Merge surfaces (indexes) and calculate bounds ClearBounds(bounds[0], bounds[1]); firstIndex = numIboIndexes; - for (j = 0; j < numWorldSurfaces; j++) + for (j = i; j < numWorldSurfaces; j++) { msurface_t *surf2; + srfBspSurface_t *bspSurf; if (s_worldData.surfacesViewCount[j] != i) continue; @@ -3340,88 +3186,37 @@ void R_MergeLeafSurfaces(void) AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]); AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]); - switch(*surf2->data) + bspSurf = (srfBspSurface_t *) surf2->data; + for (k = 0; k < bspSurf->numIndexes; k++) { - case SF_FACE: - { - srfSurfaceFace_t *face; - - face = (srfSurfaceFace_t *) surf2->data; - - for (k = 0; k < face->numTriangles; k++) - { - *outIboIndexes++ = face->triangles[k].indexes[0] + face->firstVert; - *outIboIndexes++ = face->triangles[k].indexes[1] + face->firstVert; - *outIboIndexes++ = face->triangles[k].indexes[2] + face->firstVert; - numIboIndexes += 3; - } - } - break; - - case SF_GRID: - { - srfGridMesh_t *grid; - - grid = (srfGridMesh_t *) surf2->data; - - for (k = 0; k < grid->numTriangles; k++) - { - *outIboIndexes++ = grid->triangles[k].indexes[0] + grid->firstVert; - *outIboIndexes++ = grid->triangles[k].indexes[1] + grid->firstVert; - *outIboIndexes++ = grid->triangles[k].indexes[2] + grid->firstVert; - numIboIndexes += 3; - } - } - break; - - case SF_TRIANGLES: - { - srfTriangles_t *tris; - - tris = (srfTriangles_t *) surf2->data; - - for (k = 0; k < tris->numTriangles; k++) - { - *outIboIndexes++ = tris->triangles[k].indexes[0] + tris->firstVert; - *outIboIndexes++ = tris->triangles[k].indexes[1] + tris->firstVert; - *outIboIndexes++ = tris->triangles[k].indexes[2] + tris->firstVert; - numIboIndexes += 3; - } - } - break; - - // never happens, but silences a compile warning - default: - break; + *outIboIndexes++ = bspSurf->indexes[k] + bspSurf->firstVert; + numIboIndexes++; } + break; } - vboSurf = (srfVBOMesh_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); + vboSurf = (srfBspSurface_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); memset(vboSurf, 0, sizeof(*vboSurf)); vboSurf->surfaceType = SF_VBO_MESH; vboSurf->vbo = vbo; vboSurf->ibo = ibo; - vboSurf->numIndexes = numTriangles * 3; + vboSurf->numIndexes = numIndexes; vboSurf->numVerts = numVerts; vboSurf->firstIndex = firstIndex; vboSurf->minIndex = *(iboIndexes + firstIndex); vboSurf->maxIndex = *(iboIndexes + firstIndex); - for (j = 1; j < numTriangles * 3; j++) + for (j = 0; j < numIndexes; j++) { vboSurf->minIndex = MIN(vboSurf->minIndex, *(iboIndexes + firstIndex + j)); vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j)); } - vboSurf->shader = surf1->shader; - vboSurf->fogIndex = surf1->fogIndex; - vboSurf->cubemapIndex = surf1->cubemapIndex; - - VectorCopy(bounds[0], vboSurf->bounds[0]); - VectorCopy(bounds[1], vboSurf->bounds[1]); + VectorCopy(bounds[0], vboSurf->cullBounds[0]); + VectorCopy(bounds[1], vboSurf->cullBounds[1]); VectorCopy(bounds[0], mergedSurf->cullinfo.bounds[0]); VectorCopy(bounds[1], mergedSurf->cullinfo.bounds[1]); @@ -3432,15 +3227,15 @@ void R_MergeLeafSurfaces(void) mergedSurf->cubemapIndex = surf1->cubemapIndex; mergedSurf->shader = surf1->shader; - // finish up the ibo - qglGenBuffersARB(1, &ibo->indexesVBO); - - R_BindIBO(ibo); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); - R_BindNullIBO(); - - GL_CheckErrors(); - + // finish up the ibo + qglGenBuffersARB(1, &ibo->indexesVBO); + + R_BindIBO(ibo); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); + R_BindNullIBO(); + + GL_CheckErrors(); + Z_Free(iboIndexes); // redirect view surfaces to this surf @@ -3483,41 +3278,20 @@ void R_CalcVertexLightDirs( void ) for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) { - if(*surface->data == SF_FACE) - { - srfSurfaceFace_t *srf = (srfSurfaceFace_t *) surface->data; + srfBspSurface_t *bspSurf = (srfBspSurface_t *) surface->data; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); - } - } - } - else if(*surface->data == SF_GRID) + switch(bspSurf->surfaceType) { - srfGridMesh_t *srf = (srfGridMesh_t *) surface->data; + case SF_FACE: + case SF_GRID: + case SF_TRIANGLES: + for(i = 0; i < bspSurf->numVerts; i++) + R_LightDirForPoint( bspSurf->verts[i].xyz, bspSurf->verts[i].lightdir, bspSurf->verts[i].normal, &s_worldData ); - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); - } - } - } - else if(*surface->data == SF_TRIANGLES) - { - srfTriangles_t *srf = (srfTriangles_t *) surface->data; + break; - if(srf->numVerts) - { - for(i = 0; i < srf->numVerts; i++) - { - R_LightDirForPoint( srf->verts[i].xyz, srf->verts[i].lightdir, srf->verts[i].normal, &s_worldData ); - } - } + default: + break; } } } @@ -3613,6 +3387,9 @@ void RE_LoadWorldMap( const char *name ) { R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); + // determine vertex light directions + R_CalcVertexLightDirs(); + // determine which parts of the map are in sunlight #if 0 if (0) @@ -3803,21 +3580,21 @@ void RE_LoadWorldMap( const char *name ) { } #endif - // load cubemaps - if (r_cubeMapping->integer) - { - R_LoadCubemapEntities("misc_cubemap"); - if (!tr.numCubemaps) - { - // use deathmatch spawn points as cubemaps - R_LoadCubemapEntities("info_player_deathmatch"); - } - - if (tr.numCubemaps) - { - R_AssignCubemapsToWorldSurfaces(); - } - } + // load cubemaps + if (r_cubeMapping->integer) + { + R_LoadCubemapEntities("misc_cubemap"); + if (!tr.numCubemaps) + { + // use deathmatch spawn points as cubemaps + R_LoadCubemapEntities("info_player_deathmatch"); + } + + if (tr.numCubemaps) + { + R_AssignCubemapsToWorldSurfaces(); + } + } // create static VBOS from the world R_CreateWorldVBOs(); @@ -3831,18 +3608,15 @@ void RE_LoadWorldMap( const char *name ) { // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; - // determine vertex light directions - R_CalcVertexLightDirs(); - // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); - // Render all cubemaps - if (r_cubeMapping->integer && tr.numCubemaps) - { - R_RenderAllCubemaps(); - } + // Render all cubemaps + if (r_cubeMapping->integer && tr.numCubemaps) + { + R_RenderAllCubemaps(); + } ri->FS_FreeFile( buffer.v ); } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 437af8f008..57cab75f28 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -493,12 +493,6 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { qglClear(GL_COLOR_BUFFER_BIT); } - if (tr.screenScratchFbo) - { - FBO_Bind(tr.screenScratchFbo); - qglClear(GL_COLOR_BUFFER_BIT); - } - FBO_Bind(NULL); } diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 3e7e428331..9a0f8807af 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -25,14 +25,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA /* This file does all of the processing necessary to turn a raw grid of points -read from the map file into a srfGridMesh_t ready for rendering. +read from the map file into a srfBspSurface_t ready for rendering. The level of detail solution is direction independent, based only on subdivided distance from the true curve. Only a single entry point: -srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, +srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { */ @@ -213,13 +213,13 @@ static int neighbors[8][2] = { } #ifdef USE_VERT_TANGENT_SPACE -static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int numTriangles, - srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) +static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int numIndexes, + glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) { int i, j; srfVert_t *dv[3]; static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE]; - srfTriangle_t *tri; + glIndex_t *tri; // FIXME: use more elegant way for(i = 0; i < width; i++) @@ -231,53 +231,15 @@ static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRI } } - for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + for(i = 0, tri = indexes; i < numIndexes; i += 3, tri += 3) { - dv[0] = &ctrl2[tri->indexes[0]]; - dv[1] = &ctrl2[tri->indexes[1]]; - dv[2] = &ctrl2[tri->indexes[2]]; + dv[0] = &ctrl2[tri[0]]; + dv[1] = &ctrl2[tri[1]]; + dv[2] = &ctrl2[tri[2]]; R_CalcTangentVectors(dv); } -#if 0 - for(i = 0; i < (width * height); i++) - { - dv0 = &ctrl2[i]; - - VectorNormalize(dv0->normal); -#if 0 - VectorNormalize(dv0->tangent); - VectorNormalize(dv0->bitangent); -#else - d = DotProduct(dv0->tangent, dv0->normal); - VectorMA(dv0->tangent, -d, dv0->normal, dv0->tangent); - VectorNormalize(dv0->tangent); - - d = DotProduct(dv0->bitangent, dv0->normal); - VectorMA(dv0->bitangent, -d, dv0->normal, dv0->bitangent); - VectorNormalize(dv0->bitangent); -#endif - } -#endif - - -#if 0 - // do another extra smoothing for normals to avoid flat shading - for(i = 0; i < (width * height); i++) - { - for(j = 0; j < (width * height); j++) - { - if(R_CompareVert(&ctrl2[i], &ctrl2[j], qfalse)) - { - VectorAdd(ctrl2[i].normal, ctrl2[j].normal, ctrl2[i].normal); - } - } - - VectorNormalize(ctrl2[i].normal); - } -#endif - for(i = 0; i < width; i++) { for(j = 0; j < height; j++) @@ -285,26 +247,25 @@ static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRI dv[0] = &ctrl2[j * width + i]; dv[1] = &ctrl[j][i]; - VectorCopy(dv[0]->tangent, dv[1]->tangent); - VectorCopy(dv[0]->bitangent, dv[1]->bitangent); + VectorCopy4(dv[0]->tangent, dv[1]->tangent); } } } #endif -static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], - srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) +static int MakeMeshIndexes(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], + glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) { int i, j; - int numTriangles; + int numIndexes; int w, h; srfVert_t *dv; static srfVert_t ctrl2[MAX_GRID_SIZE * MAX_GRID_SIZE]; h = height - 1; w = width - 1; - numTriangles = 0; + numIndexes = 0; for(i = 0; i < h; i++) { for(j = 0; j < w; j++) @@ -317,20 +278,16 @@ static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE v3 = v2 + width; v4 = v3 + 1; - triangles[numTriangles].indexes[0] = v2; - triangles[numTriangles].indexes[1] = v3; - triangles[numTriangles].indexes[2] = v1; - numTriangles++; + indexes[numIndexes++] = v2; + indexes[numIndexes++] = v3; + indexes[numIndexes++] = v1; - triangles[numTriangles].indexes[0] = v1; - triangles[numTriangles].indexes[1] = v3; - triangles[numTriangles].indexes[2] = v4; - numTriangles++; + indexes[numIndexes++] = v1; + indexes[numIndexes++] = v3; + indexes[numIndexes++] = v4; } } - R_CalcSurfaceTriangleNeighbors(numTriangles, triangles); - // FIXME: use more elegant way for(i = 0; i < width; i++) { @@ -341,9 +298,7 @@ static int MakeMeshTriangles(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE } } - R_CalcSurfaceTrianglePlanes(numTriangles, triangles, ctrl2); - - return numTriangles; + return numIndexes; } @@ -420,19 +375,19 @@ static void PutPointsOnCurve( srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], R_CreateSurfaceGridMesh ================= */ -srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, +srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], float errorTable[2][MAX_GRID_SIZE], - int numTriangles, srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]) { + int numIndexes, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) { int i, j, size; srfVert_t *vert; vec3_t tmpVec; - srfGridMesh_t *grid; + srfBspSurface_t *grid; // copy the results out to a grid size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri->Hunk_Alloc*/ (srfGridMesh_t *)Z_Malloc( size, TAG_GRIDMESH ); + grid = /*ri->Hunk_Alloc*/ (srfBspSurface_t *)Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); grid->widthLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( width * 4, TAG_GRIDMESH ); @@ -441,9 +396,9 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->heightLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( height * 4, TAG_GRIDMESH ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); - grid->numTriangles = numTriangles; - grid->triangles = (srfTriangle_t *)Z_Malloc(grid->numTriangles * sizeof(srfTriangle_t), TAG_GRIDMESH); - Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); + grid->numIndexes = numIndexes; + grid->indexes = (glIndex_t *)Z_Malloc(grid->numIndexes * sizeof(glIndex_t), TAG_GRIDMESH); + Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); grid->numVerts = (width * height); grid->verts = (srfVert_t *)Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); @@ -457,9 +412,9 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->heightLodError = ri->Hunk_Alloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); - grid->numTriangles = numTriangles; - grid->triangles = ri->Hunk_Alloc(grid->numTriangles * sizeof(srfTriangle_t), h_low); - Com_Memcpy(grid->triangles, triangles, numTriangles * sizeof(srfTriangle_t)); + grid->numIndexes = numIndexes; + grid->indexes = (glIndex_t *)ri->Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); + Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); grid->numVerts = (width * height); grid->verts = ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); @@ -468,23 +423,23 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, grid->width = width; grid->height = height; grid->surfaceType = SF_GRID; - ClearBounds( grid->meshBounds[0], grid->meshBounds[1] ); + ClearBounds( grid->cullBounds[0], grid->cullBounds[1] ); for ( i = 0 ; i < width ; i++ ) { for ( j = 0 ; j < height ; j++ ) { vert = &grid->verts[j*width+i]; *vert = ctrl[j][i]; - AddPointToBounds( vert->xyz, grid->meshBounds[0], grid->meshBounds[1] ); + AddPointToBounds( vert->xyz, grid->cullBounds[0], grid->cullBounds[1] ); } } // compute local origin and bounds - VectorAdd( grid->meshBounds[0], grid->meshBounds[1], grid->localOrigin ); - VectorScale( grid->localOrigin, 0.5f, grid->localOrigin ); - VectorSubtract( grid->meshBounds[0], grid->localOrigin, tmpVec ); - grid->meshRadius = VectorLength( tmpVec ); + VectorAdd( grid->cullBounds[0], grid->cullBounds[1], grid->cullOrigin ); + VectorScale( grid->cullOrigin, 0.5f, grid->cullOrigin ); + VectorSubtract( grid->cullBounds[0], grid->cullOrigin, tmpVec ); + grid->cullRadius = VectorLength( tmpVec ); - VectorCopy( grid->localOrigin, grid->lodOrigin ); - grid->lodRadius = grid->meshRadius; + VectorCopy( grid->cullOrigin, grid->lodOrigin ); + grid->lodRadius = grid->cullRadius; // return grid; } @@ -494,10 +449,10 @@ srfGridMesh_t *R_CreateSurfaceGridMesh(int width, int height, R_FreeSurfaceGridMesh ================= */ -void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) { +void R_FreeSurfaceGridMesh( srfBspSurface_t *grid ) { Z_Free(grid->widthLodError); Z_Free(grid->heightLodError); - Z_Free(grid->triangles); + Z_Free(grid->indexes); Z_Free(grid->verts); Z_Free(grid); } @@ -507,7 +462,7 @@ void R_FreeSurfaceGridMesh( srfGridMesh_t *grid ) { R_SubdividePatchToGrid ================= */ -srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, +srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { int i, j, k, l; srfVert_t_cleared( prev ); @@ -518,8 +473,8 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, int t; srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; float errorTable[2][MAX_GRID_SIZE]; - int numTriangles; - static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + int numIndexes; + static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; int consecutiveComplete; for ( i = 0 ; i < width ; i++ ) { @@ -673,16 +628,16 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, } #endif - // calculate triangles - numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + // calculate indexes + numIndexes = MakeMeshIndexes(width, height, ctrl, indexes); // calculate normals MakeMeshNormals( width, height, ctrl ); #ifdef USE_VERT_TANGENT_SPACE - MakeMeshTangentVectors(width, height, ctrl, numTriangles, triangles); + MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes); #endif - return R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); + return R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes); } /* @@ -690,15 +645,15 @@ srfGridMesh_t *R_SubdividePatchToGrid( int width, int height, R_GridInsertColumn =============== */ -srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec3_t point, float loderror ) { +srfBspSurface_t *R_GridInsertColumn( srfBspSurface_t *grid, int column, int row, vec3_t point, float loderror ) { int i, j; int width, height, oldwidth; srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; float errorTable[2][MAX_GRID_SIZE]; float lodRadius; vec3_t lodOrigin; - int numTriangles; - static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + int numIndexes; + static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; oldwidth = 0; width = grid->width + 1; @@ -728,8 +683,8 @@ srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec // put all the aproximating points on the curve //PutPointsOnCurve( ctrl, width, height ); - // calculate triangles - numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + // calculate indexes + numIndexes = MakeMeshIndexes(width, height, ctrl, indexes); // calculate normals MakeMeshNormals( width, height, ctrl ); @@ -739,7 +694,7 @@ srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec // free the old grid R_FreeSurfaceGridMesh(grid); // create a new grid - grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); + grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes); grid->lodRadius = lodRadius; VectorCopy(lodOrigin, grid->lodOrigin); return grid; @@ -750,15 +705,15 @@ srfGridMesh_t *R_GridInsertColumn( srfGridMesh_t *grid, int column, int row, vec R_GridInsertRow =============== */ -srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t point, float loderror ) { +srfBspSurface_t *R_GridInsertRow( srfBspSurface_t *grid, int row, int column, vec3_t point, float loderror ) { int i, j; int width, height, oldheight; srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE]; float errorTable[2][MAX_GRID_SIZE]; float lodRadius; vec3_t lodOrigin; - int numTriangles; - static srfTriangle_t triangles[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2]; + int numIndexes; + static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; oldheight = 0; width = grid->width; @@ -788,8 +743,8 @@ srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t // put all the aproximating points on the curve //PutPointsOnCurve( ctrl, width, height ); - // calculate triangles - numTriangles = MakeMeshTriangles(width, height, ctrl, triangles); + // calculate indexes + numIndexes = MakeMeshIndexes(width, height, ctrl, indexes); // calculate normals MakeMeshNormals( width, height, ctrl ); @@ -799,7 +754,7 @@ srfGridMesh_t *R_GridInsertRow( srfGridMesh_t *grid, int row, int column, vec3_t // free the old grid R_FreeSurfaceGridMesh(grid); // create a new grid - grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numTriangles, triangles); + grid = R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes); grid->lodRadius = lodRadius; VectorCopy(lodOrigin, grid->lodOrigin); return grid; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index c4479213c0..1863ce54be 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -710,4 +710,19 @@ void GLimp_InitExtraExtensions() { ri->Printf(PRINT_ALL, result[2], extension); } + + // GL_ARB_vertex_type_2_10_10_10_rev + extension = "GL_ARB_vertex_type_2_10_10_10_rev"; + glRefConfig.packedNormalDataType = GL_UNSIGNED_BYTE; + if( GLimp_HaveExtension( extension ) ) + { + if (r_arb_vertex_type_2_10_10_10_rev->integer) + glRefConfig.packedNormalDataType = GL_UNSIGNED_INT_2_10_10_10_REV; + + ri->Printf(PRINT_ALL, result[r_arb_vertex_type_2_10_10_10_rev->integer ? 1 : 0], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } } diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index c70c4ddc5a..68d6090774 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -526,22 +526,6 @@ void FBO_Init(void) R_CheckFBO(tr.targetLevelsFbo); } - if (r_softOverbright->integer) - { - //tr.screenScratchFbo = FBO_Create("_screenscratch", width, height); - tr.screenScratchFbo = FBO_Create("_screenscratch", tr.screenScratchImage->width, tr.screenScratchImage->height); - FBO_Bind(tr.screenScratchFbo); - - //FBO_CreateBuffer(tr.screenScratchFbo, format, 0, 0); - FBO_AttachTextureImage(tr.screenScratchImage, 0); - - // FIXME: hack: share zbuffer between render fbo and pre-screen fbo - //FBO_CreateBuffer(tr.screenScratchFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - - R_CheckFBO(tr.screenScratchFbo); - } - for (i = 0; i < 2; i++) { tr.quarterFbo[i] = FBO_Create(va("_quarter%d", i), tr.quarterImage[i]->width, tr.quarterImage[i]->height); @@ -579,16 +563,18 @@ void FBO_Init(void) R_CheckFBO(tr.screenSsaoFbo); } - tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); - FBO_Bind(tr.renderCubeFbo); - - //FBO_AttachTextureImage(tr.renderCubeImage, 0); - R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, tr.renderCubeImage->texnum, 0); - glState.currentFBO->colorImage[0] = tr.renderCubeImage; + { + tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); + FBO_Bind(tr.renderCubeFbo); + + //FBO_AttachTextureImage(tr.renderCubeImage, 0); + R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, tr.renderCubeImage->texnum, 0); + glState.currentFBO->colorImage[0] = tr.renderCubeImage; - FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); - R_CheckFBO(tr.renderCubeFbo); + R_CheckFBO(tr.renderCubeFbo); + } GL_CheckErrors(); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 5cd2cab714..e2da488b7d 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -86,6 +86,19 @@ flare_t *r_activeFlares, *r_inactiveFlares; int flareCoeff; +/* +================== +R_SetFlareCoeff +================== +*/ +static void R_SetFlareCoeff( void ) { + + if(r_flareCoeff->value == 0.0f) + flareCoeff = atof(FLARE_STDCOEFF); + else + flareCoeff = r_flareCoeff->value; +} + /* ================== R_ClearFlares @@ -102,6 +115,8 @@ void R_ClearFlares( void ) { r_flareStructs[i].next = r_inactiveFlares; r_inactiveFlares = &r_flareStructs[i]; } + + R_SetFlareCoeff(); } @@ -262,6 +277,7 @@ void RB_TestFlare( flare_t *f ) { qboolean visible; float fade; float screenZ; + FBO_t *oldFbo; backEnd.pc.c_flareTests++; @@ -269,9 +285,22 @@ void RB_TestFlare( flare_t *f ) { // don't bother with another sync glState.finishCalled = qfalse; + // if we're doing multisample rendering, read from the correct FBO + oldFbo = glState.currentFBO; + if (tr.msaaResolveFbo) + { + FBO_Bind(tr.msaaResolveFbo); + } + // read back the z buffer contents qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); + // if we're doing multisample rendering, switch to the old FBO + if (tr.msaaResolveFbo) + { + FBO_Bind(oldFbo); + } + screenZ = backEnd.viewParms.projectionMatrix[14] / ( ( 2*depth - 1 ) * backEnd.viewParms.projectionMatrix[11] - backEnd.viewParms.projectionMatrix[10] ); @@ -352,7 +381,7 @@ void RB_RenderFlare( flare_t *f ) { VectorScale(f->color, f->drawIntensity * intensity, color); -// Calculations for fogging + // Calculations for fogging if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) { tess.numVertexes = 1; @@ -451,11 +480,7 @@ void RB_RenderFlares (void) { if(r_flareCoeff->modified) { - if(r_flareCoeff->value == 0.0f) - flareCoeff = atof(FLARE_STDCOEFF); - else - flareCoeff = r_flareCoeff->value; - + R_SetFlareCoeff(); r_flareCoeff->modified = qfalse; } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index e98c4b8f07..179ffe0b28 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4444,14 +4444,13 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vec4_t *weights; #ifdef USE_VERT_TANGENT_SPACE vec3_t *tangents; - vec3_t *bitangents; #endif byte *data; int dataSize = 0; int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights; #ifdef USE_VERT_TANGENT_SPACE - int ofs_tangent, ofs_bitangent; + int ofs_tangent; #endif int stride = 0; int numVerts = 0; @@ -4488,7 +4487,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean dataSize += numVerts * sizeof (*bonerefs); #ifdef USE_VERT_TANGENT_SPACE dataSize += numVerts * sizeof (*tangents); - dataSize += numVerts * sizeof (*bitangents); #endif // Allocate and write to memory @@ -4518,10 +4516,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean tangents = (vec3_t *)(data + stride); ofs_tangent = stride; stride += sizeof (*tangents); - - bitangents = (vec3_t *)(data + stride); - ofs_bitangent = stride; - stride += sizeof (*bitangents); #endif surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4536,14 +4530,12 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean VectorCopy (v[k].normal, *normals); #ifdef USE_VERT_TANGENT_SPACE VectorCopy (v[k].normal, *tangents); - VectorCopy (v[k].normal, *bitangents); #endif verts = (vec3_t *)((byte *)verts + stride); normals = (vec3_t *)((byte *)normals + stride); #ifdef USE_VERT_TANGENT_SPACE tangents = (vec3_t *)((byte *)tangents + stride); - bitangents = (vec3_t *)((byte *)bitangents + stride); #endif } @@ -4600,7 +4592,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vbo->ofs_boneweights = ofsWeights; #ifdef USE_VERT_TANGENT_SPACE vbo->ofs_tangent = ofs_tangent; - vbo->ofs_bitangent = ofs_bitangent; #endif vbo->stride_xyz = stride; @@ -4610,7 +4601,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vbo->stride_boneweights = stride; #ifdef USE_VERT_TANGENT_SPACE vbo->stride_tangent = stride; - vbo->stride_bitangent = stride; #endif // Fill in the index buffer diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 75c7d2dadb..c65db31592 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -85,6 +85,7 @@ static uniformInfo_t uniformsInfo[] = { "u_ShadowMvp2", GLSL_MAT16, 1 }, { "u_ShadowMvp3", GLSL_MAT16, 1 }, + { "u_EnableTextures", GLSL_VEC4, 1 }, { "u_DiffuseTexMatrix", GLSL_VEC4, 1 }, { "u_DiffuseTexOffTurb", GLSL_VEC4, 1 }, { "u_Texture1Env", GLSL_INT, 1 }, @@ -529,9 +530,6 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int #ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT) qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); - - if(attribs & ATTR_BITANGENT) - qglBindAttribLocationARB(program->program, ATTR_INDEX_BITANGENT, "attr_Bitangent"); #endif if(attribs & ATTR_NORMAL) @@ -555,9 +553,6 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int #ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT2) qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); - - if(attribs & ATTR_BITANGENT2) - qglBindAttribLocationARB(program->program, ATTR_INDEX_BITANGENT2, "attr_Bitangent2"); #endif if(attribs & ATTR_BONE_INDEXES) @@ -1039,30 +1034,19 @@ void GLSL_InitGPUShaders(void) for (i = 0; i < LIGHTDEF_COUNT; i++) { + int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; + qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); + // skip impossible combos if ((i & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) continue; - if ((i & LIGHTDEF_USE_DELUXEMAP) && !r_deluxeMapping->integer) - continue; - - if ((i & LIGHTDEF_USE_CUBEMAP) && !r_cubeMapping->integer) + if (!lightType && (i & LIGHTDEF_USE_PARALLAXMAP)) continue; - if (!((i & LIGHTDEF_LIGHTTYPE_MASK) == LIGHTDEF_USE_LIGHTMAP) && (i & LIGHTDEF_USE_DELUXEMAP)) + if (!lightType && (i & LIGHTDEF_USE_SHADOWMAP)) continue; - if ((i & (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) == (LIGHTDEF_USE_VERTEX_ANIMATION | LIGHTDEF_USE_SKELETAL_ANIMATION)) - continue; - - if (!(i & LIGHTDEF_LIGHTTYPE_MASK)) - { - if (i & LIGHTDEF_USE_SHADOWMAP) - continue; - if (i & LIGHTDEF_USE_CUBEMAP) - continue; - } - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; extradefines[0] = '\0'; @@ -1071,30 +1055,30 @@ void GLSL_InitGPUShaders(void) Q_strcat(extradefines, 1024, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); if (r_specularIsMetallic->value) - Q_strcat(extradefines, 1024, va("#define SPECULAR_IS_METALLIC\n")); + Q_strcat(extradefines, 1024, "#define SPECULAR_IS_METALLIC\n"); if (r_dlightMode->integer >= 2) Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); if (1) - { Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); - } if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); - if (i & LIGHTDEF_LIGHTTYPE_MASK) + if (lightType) { Q_strcat(extradefines, 1024, "#define USE_LIGHT\n"); - if (r_normalMapping->integer == 0 && r_specularMapping->integer == 0) + if (fastLight) Q_strcat(extradefines, 1024, "#define USE_FAST_LIGHT\n"); - switch (i & LIGHTDEF_LIGHTTYPE_MASK) + switch (lightType) { case LIGHTDEF_USE_LIGHTMAP: Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); + if (r_deluxeMapping->integer && !fastLight) + Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); attribs |= ATTR_LIGHTCOORD | ATTR_LIGHTDIRECTION; break; case LIGHTDEF_USE_LIGHT_VECTOR: @@ -1107,61 +1091,58 @@ void GLSL_InitGPUShaders(void) default: break; } - } - if (r_normalMapping->integer) - { - Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); + if (r_normalMapping->integer) + { + Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); - if (r_normalMapping->integer == 2) - Q_strcat(extradefines, 1024, "#define USE_OREN_NAYAR\n"); + if (r_normalMapping->integer == 2) + Q_strcat(extradefines, 1024, "#define USE_OREN_NAYAR\n"); - if (r_normalMapping->integer == 3) - Q_strcat(extradefines, 1024, "#define USE_TRIACE_OREN_NAYAR\n"); + if (r_normalMapping->integer == 3) + Q_strcat(extradefines, 1024, "#define USE_TRIACE_OREN_NAYAR\n"); #ifdef USE_VERT_TANGENT_SPACE - Q_strcat(extradefines, 1024, "#define USE_VERT_TANGENT_SPACE\n"); - attribs |= ATTR_TANGENT | ATTR_BITANGENT; + Q_strcat(extradefines, 1024, "#define USE_VERT_TANGENT_SPACE\n"); + attribs |= ATTR_TANGENT; #endif - } - if (r_specularMapping->integer) - { - Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); + if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY) && r_parallaxMapping->integer) + Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); + } - switch (r_specularMapping->integer) + if (r_specularMapping->integer) { - case 1: - default: - Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); - break; - - case 2: - Q_strcat(extradefines, 1024, "#define USE_BLINN_FRESNEL\n"); - break; - - case 3: - Q_strcat(extradefines, 1024, "#define USE_MCAULEY\n"); - break; - - case 4: - Q_strcat(extradefines, 1024, "#define USE_GOTANDA\n"); - break; - - case 5: - Q_strcat(extradefines, 1024, "#define USE_LAZAROV\n"); - break; + Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); + + switch (r_specularMapping->integer) + { + case 1: + default: + Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); + break; + + case 2: + Q_strcat(extradefines, 1024, "#define USE_BLINN_FRESNEL\n"); + break; + + case 3: + Q_strcat(extradefines, 1024, "#define USE_MCAULEY\n"); + break; + + case 4: + Q_strcat(extradefines, 1024, "#define USE_GOTANDA\n"); + break; + + case 5: + Q_strcat(extradefines, 1024, "#define USE_LAZAROV\n"); + break; + } } - } - - if ((i & LIGHTDEF_USE_DELUXEMAP) && r_deluxeMapping->integer) - Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY) && r_parallaxMapping->integer) - Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); - - if ((i & LIGHTDEF_USE_CUBEMAP)) - Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n"); + if (r_cubeMapping->integer) + Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n"); + } if (i & LIGHTDEF_USE_SHADOWMAP) { @@ -1197,7 +1178,7 @@ void GLSL_InitGPUShaders(void) #ifdef USE_VERT_TANGENT_SPACE if (r_normalMapping->integer) { - attribs |= ATTR_TANGENT2 | ATTR_BITANGENT2; + attribs |= ATTR_TANGENT2; } #endif } @@ -1423,25 +1404,25 @@ void GLSL_InitGPUShaders(void) numEtcShaders++; } - #if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) - { - ri->Error(ERR_FATAL, "Could not load testcube shader!"); - } - - GLSL_InitUniforms(&tr.testcubeShader); - - qglUseProgramObjectARB(tr.testcubeShader.program); - GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - qglUseProgramObjectARB(0); - - GLSL_FinishGPUShader(&tr.testcubeShader); - - numEtcShaders++; - #endif +#if 0 + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) + { + ri->Error(ERR_FATAL, "Could not load testcube shader!"); + } + + GLSL_InitUniforms(&tr.testcubeShader); + + qglUseProgramObjectARB(tr.testcubeShader.program); + GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.testcubeShader); + + numEtcShaders++; +#endif endTime = ri->Milliseconds(); @@ -1464,12 +1445,10 @@ void GLSL_ShutdownGPUShaders(void) qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL); #ifdef USE_VERT_TANGENT_SPACE qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); #endif qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); #ifdef USE_VERT_TANGENT_SPACE qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); #endif qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); @@ -1631,20 +1610,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits) qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); } } - - if(diff & ATTR_BITANGENT) - { - if(stateBits & ATTR_BITANGENT) - { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BITANGENT )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BITANGENT )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT); - } - } #endif if(diff & ATTR_COLOR) @@ -1717,20 +1682,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits) qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); } } - - if(diff & ATTR_BITANGENT2) - { - if(stateBits & ATTR_BITANGENT2) - { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BITANGENT2 )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BITANGENT2 )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BITANGENT2); - } - } #endif if(diff & ATTR_BONE_INDEXES) @@ -1768,17 +1719,18 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { qboolean animated; int newFrame, oldFrame; + VBO_t *vbo = glState.currentVBO; - if(!glState.currentVBO) + if(!vbo) { ri->Error(ERR_FATAL, "GL_VertexAttribPointers: no VBO bound"); return; } // don't just call LogComment, or we will get a call to va() every frame! - GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", glState.currentVBO->name)); + GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", vbo->name)); - // position/normal/tangent/bitangent are always set in case of animation + // position/normal/tangent are always set in case of animation oldFrame = glState.vertexAttribsOldFrame; newFrame = glState.vertexAttribsNewFrame; animated = glState.vertexAnimation; @@ -1787,7 +1739,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, glState.currentVBO->stride_xyz, BUFFER_OFFSET(glState.currentVBO->ofs_xyz + newFrame * glState.currentVBO->size_xyz)); + qglVertexAttribPointerARB(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + newFrame * vbo->size_xyz)); glState.vertexAttribPointersSet |= ATTR_POSITION; } @@ -1795,7 +1747,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, glState.currentVBO->stride_st, BUFFER_OFFSET(glState.currentVBO->ofs_st)); + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st)); glState.vertexAttribPointersSet |= ATTR_TEXCOORD; } @@ -1803,7 +1755,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, glState.currentVBO->stride_lightmap, BUFFER_OFFSET(glState.currentVBO->ofs_lightmap)); + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_lightmap, BUFFER_OFFSET(vbo->ofs_lightmap)); glState.vertexAttribPointersSet |= ATTR_LIGHTCOORD; } @@ -1811,7 +1763,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 3, GL_FLOAT, 0, glState.currentVBO->stride_normal, BUFFER_OFFSET(glState.currentVBO->ofs_normal + newFrame * glState.currentVBO->size_normal)); + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL; } @@ -1820,24 +1772,16 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 3, GL_FLOAT, 0, glState.currentVBO->stride_tangent, BUFFER_OFFSET(glState.currentVBO->ofs_tangent + newFrame * glState.currentVBO->size_normal)); // FIXME + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT; } - - if((attribBits & ATTR_BITANGENT) && (!(glState.vertexAttribPointersSet & ATTR_BITANGENT) || animated)) - { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BITANGENT )\n"); - - qglVertexAttribPointerARB(ATTR_INDEX_BITANGENT, 3, GL_FLOAT, 0, glState.currentVBO->stride_bitangent, BUFFER_OFFSET(glState.currentVBO->ofs_bitangent + newFrame * glState.currentVBO->size_normal)); // FIXME - glState.vertexAttribPointersSet |= ATTR_BITANGENT; - } #endif if((attribBits & ATTR_COLOR) && !(glState.vertexAttribPointersSet & ATTR_COLOR)) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_COLOR )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, glState.currentVBO->stride_vertexcolor, BUFFER_OFFSET(glState.currentVBO->ofs_vertexcolor)); + qglVertexAttribPointerARB(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, vbo->stride_vertexcolor, BUFFER_OFFSET(vbo->ofs_vertexcolor)); glState.vertexAttribPointersSet |= ATTR_COLOR; } @@ -1845,7 +1789,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 3, GL_FLOAT, 0, glState.currentVBO->stride_lightdir, BUFFER_OFFSET(glState.currentVBO->ofs_lightdir)); + qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); glState.vertexAttribPointersSet |= ATTR_LIGHTDIRECTION; } @@ -1853,7 +1797,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, glState.currentVBO->stride_xyz, BUFFER_OFFSET(glState.currentVBO->ofs_xyz + oldFrame * glState.currentVBO->size_xyz)); + qglVertexAttribPointerARB(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + oldFrame * vbo->size_xyz)); glState.vertexAttribPointersSet |= ATTR_POSITION2; } @@ -1861,7 +1805,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 3, GL_FLOAT, 0, glState.currentVBO->stride_normal, BUFFER_OFFSET(glState.currentVBO->ofs_normal + oldFrame * glState.currentVBO->size_normal)); + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL2; } @@ -1870,24 +1814,16 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 3, GL_FLOAT, 0, glState.currentVBO->stride_tangent, BUFFER_OFFSET(glState.currentVBO->ofs_tangent + oldFrame * glState.currentVBO->size_normal)); // FIXME + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT2; } - - if((attribBits & ATTR_BITANGENT2) && (!(glState.vertexAttribPointersSet & ATTR_BITANGENT2) || animated)) - { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BITANGENT2 )\n"); - - qglVertexAttribPointerARB(ATTR_INDEX_BITANGENT2, 3, GL_FLOAT, 0, glState.currentVBO->stride_bitangent, BUFFER_OFFSET(glState.currentVBO->ofs_bitangent + oldFrame * glState.currentVBO->size_normal)); // FIXME - glState.vertexAttribPointersSet |= ATTR_BITANGENT2; - } #endif if((attribBits & ATTR_BONE_INDEXES) && !(glState.vertexAttribPointersSet & ATTR_BONE_INDEXES)) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_INDEXES )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, glState.currentVBO->stride_boneindexes, BUFFER_OFFSET(glState.currentVBO->ofs_boneindexes)); + qglVertexAttribPointerARB(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, vbo->stride_boneindexes, BUFFER_OFFSET(vbo->ofs_boneindexes)); glState.vertexAttribPointersSet |= ATTR_BONE_INDEXES; } @@ -1895,7 +1831,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, glState.currentVBO->stride_boneweights, BUFFER_OFFSET(glState.currentVBO->ofs_boneweights)); + qglVertexAttribPointerARB(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, vbo->stride_boneweights, BUFFER_OFFSET(vbo->ofs_boneweights)); glState.vertexAttribPointersSet |= ATTR_BONE_WEIGHTS; } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index ad3e9592b4..1e7d204fe7 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2278,15 +2278,15 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - if (image->flags & IMGFLAG_MIPMAP) - { - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - } - else - { - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + if (image->flags & IMGFLAG_MIPMAP) + { + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + } + else + { + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); @@ -2763,9 +2763,6 @@ void R_CreateBuiltinImages( void ) { Com_Memset( data, 255, sizeof( data ) ); tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, 0); - Com_Memset( data, 128, sizeof( data ) ); - tr.greyImage = R_CreateImage("*grey", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, GL_RGBA8); - if (r_dlightMode->integer >= 2) { for( x = 0; x < MAX_DLIGHTS; x++) @@ -2813,7 +2810,7 @@ void R_CreateBuiltinImages( void ) { hdrFormat = GL_RGBA8; if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat) - hdrFormat = GL_RGB16F_ARB; + hdrFormat = GL_RGBA16F_ARB; rgbFormat = GL_RGBA8; @@ -2822,9 +2819,6 @@ void R_CreateBuiltinImages( void ) { if (r_drawSunRays->integer) tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - if (r_softOverbright->integer) - tr.screenScratchImage = R_CreateImage("*screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - if (glRefConfig.framebufferObject) { tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); @@ -2835,7 +2829,7 @@ void R_CreateBuiltinImages( void ) { unsigned short sdata[4]; void *p; - if (hdrFormat == GL_RGB16F_ARB) + if (hdrFormat == GL_RGBA16F_ARB) { sdata[0] = FloatToHalf(0.0f); sdata[1] = FloatToHalf(0.45f); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 485fb4c420..1b1f05465b 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -32,7 +32,7 @@ qboolean textureFilterAnisotropic = qfalse; int maxAnisotropy = 0; float displayAspect = 0.0f; -glstate_s glState; +glstate_t glState; static void GfxInfo_f( void ); static void GfxMemInfo_f( void ); @@ -103,6 +103,8 @@ cvar_t *r_ext_framebuffer_object; cvar_t *r_ext_texture_float; cvar_t *r_arb_half_float_pixel; cvar_t *r_ext_framebuffer_multisample; +cvar_t *r_arb_seamless_cube_map; +cvar_t *r_arb_vertex_type_2_10_10_10_rev; cvar_t *r_mergeMultidraws; cvar_t *r_mergeLeafSurfaces; @@ -135,10 +137,10 @@ cvar_t *r_normalMapping; cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_parallaxMapping; -cvar_t *r_cubeMapping; -cvar_t *r_deluxeSpecular; -cvar_t *r_specularIsMetallic; -cvar_t *r_baseSpecular; +cvar_t *r_cubeMapping; +cvar_t *r_deluxeSpecular; +cvar_t *r_specularIsMetallic; +cvar_t *r_baseSpecular; cvar_t *r_baseGloss; cvar_t *r_recalcMD3Normals; cvar_t *r_mergeLightmaps; @@ -223,7 +225,6 @@ cvar_t *r_debugLight; cvar_t *r_debugSort; cvar_t *r_printShaders; cvar_t *r_saveFontData; -cvar_t *r_arb_seamless_cube_map; /* Ghoul2 Insert Start @@ -1195,6 +1196,7 @@ void R_Register( void ) r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "0", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 5800f60d45..70fb5d5b6d 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -94,12 +94,17 @@ void R_DlightBmodel( bmodel_t *bmodel ) { for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { surf = tr.world->surfaces + bmodel->firstSurface + i; - if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->dlightBits = mask; - } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->dlightBits = mask; - } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->dlightBits = mask; + switch(*surf->data) + { + case SF_FACE: + case SF_GRID: + case SF_TRIANGLES: + case SF_VBO_MESH: + ((srfBspSurface_t *)surf->data)->dlightBits = mask; + break; + + default: + break; } } } @@ -483,30 +488,30 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w return qtrue; } -int R_CubemapForPoint( vec3_t point ) -{ - int cubemapIndex = -1; +int R_CubemapForPoint( vec3_t point ) +{ + int cubemapIndex = -1; - if (r_cubeMapping->integer && tr.numCubemaps) - { - int i; - float shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; + if (r_cubeMapping->integer && tr.numCubemaps) + { + int i; + float shortest = (float)WORLD_SIZE * (float)WORLD_SIZE; - for (i = 0; i < tr.numCubemaps; i++) - { - vec3_t diff; - float length; + for (i = 0; i < tr.numCubemaps; i++) + { + vec3_t diff; + float length; - VectorSubtract(point, tr.cubemapOrigins[i], diff); - length = DotProduct(diff, diff); + VectorSubtract(point, tr.cubemapOrigins[i], diff); + length = DotProduct(diff, diff); - if (shortest > length) - { - shortest = length; - cubemapIndex = i; - } - } - } + if (shortest > length) + { + shortest = length; + cubemapIndex = i; + } + } + } - return cubemapIndex + 1; + return cubemapIndex + 1; } \ No newline at end of file diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 45a0f73c77..49f3b0dc56 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -56,10 +56,6 @@ typedef unsigned int glIndex_t; #define SHADERNUM_BITS 14 #define MAX_SHADERS (1<st[0] + 10.0f; t = dv[i]->st[1]; @@ -477,12 +479,16 @@ qboolean R_CalcTangentVectors(srfVert_t * dv[3]) bary[1] = ((dv[2]->st[0] - s) * (dv[0]->st[1] - t) - (dv[0]->st[0] - s) * (dv[2]->st[1] - t)) / bb; bary[2] = ((dv[0]->st[0] - s) * (dv[1]->st[1] - t) - (dv[1]->st[0] - s) * (dv[0]->st[1] - t)) / bb; - dv[i]->bitangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; - dv[i]->bitangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; - dv[i]->bitangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; + bitangent[0] = bary[0] * dv[0]->xyz[0] + bary[1] * dv[1]->xyz[0] + bary[2] * dv[2]->xyz[0]; + bitangent[1] = bary[0] * dv[0]->xyz[1] + bary[1] * dv[1]->xyz[1] + bary[2] * dv[2]->xyz[1]; + bitangent[2] = bary[0] * dv[0]->xyz[2] + bary[1] * dv[1]->xyz[2] + bary[2] * dv[2]->xyz[2]; + + VectorSubtract(bitangent, dv[i]->xyz, bitangent); + VectorNormalize(bitangent); - VectorSubtract(dv[i]->bitangent, dv[i]->xyz, dv[i]->bitangent); - VectorNormalize(dv[i]->bitangent); + // store bitangent handedness + CrossProduct(dv[i]->normal, dv[i]->tangent, nxt); + dv[i]->tangent[3] = (DotProduct(nxt, bitangent) < 0.0f) ? -1.0f : 1.0f; // debug code //% Sys_FPrintf( SYS_VRB, "%d S: (%f %f %f) T: (%f %f %f)\n", i, @@ -494,99 +500,6 @@ qboolean R_CalcTangentVectors(srfVert_t * dv[3]) #endif -/* -================= -R_FindSurfaceTriangleWithEdge - -Recoded from Q2E -================= -*/ -static int R_FindSurfaceTriangleWithEdge(int numTriangles, srfTriangle_t * triangles, int start, int end, int ignore) -{ - srfTriangle_t *tri; - int count, match; - int i; - - count = 0; - match = -1; - - for(i = 0, tri = triangles; i < numTriangles; i++, tri++) - { - if((tri->indexes[0] == start && tri->indexes[1] == end) || - (tri->indexes[1] == start && tri->indexes[2] == end) || (tri->indexes[2] == start && tri->indexes[0] == end)) - { - if(i != ignore) - { - match = i; - } - - count++; - } - else if((tri->indexes[1] == start && tri->indexes[0] == end) || - (tri->indexes[2] == start && tri->indexes[1] == end) || (tri->indexes[0] == start && tri->indexes[2] == end)) - { - count++; - } - } - - // detect edges shared by three triangles and make them seams - if(count > 2) - { - match = -1; - } - - return match; -} - - -/* -================= -R_CalcSurfaceTriangleNeighbors - -Recoded from Q2E -================= -*/ -void R_CalcSurfaceTriangleNeighbors(int numTriangles, srfTriangle_t * triangles) -{ - int i; - srfTriangle_t *tri; - - for(i = 0, tri = triangles; i < numTriangles; i++, tri++) - { - tri->neighbors[0] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[1], tri->indexes[0], i); - tri->neighbors[1] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[2], tri->indexes[1], i); - tri->neighbors[2] = R_FindSurfaceTriangleWithEdge(numTriangles, triangles, tri->indexes[0], tri->indexes[2], i); - } -} - -/* -================= -R_CalcSurfaceTrianglePlanes -================= -*/ -void R_CalcSurfaceTrianglePlanes(int numTriangles, srfTriangle_t * triangles, srfVert_t * verts) -{ - int i; - srfTriangle_t *tri; - - for(i = 0, tri = triangles; i < numTriangles; i++, tri++) - { - float *v1, *v2, *v3; - vec3_t d1, d2; - - v1 = verts[tri->indexes[0]].xyz; - v2 = verts[tri->indexes[1]].xyz; - v3 = verts[tri->indexes[2]].xyz; - - VectorSubtract(v2, v1, d1); - VectorSubtract(v3, v1, d2); - - CrossProduct(d2, d1, tri->plane); - tri->plane[3] = DotProduct(tri->plane, v1); - } -} - - /* ================= R_CullLocalBox @@ -1367,7 +1280,7 @@ R_PlaneForSurface ============= */ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { - srfTriangles_t *tri; + srfBspSurface_t *tri; srfPoly_t *poly; srfVert_t *v1, *v2, *v3; vec4_t plane4; @@ -1379,13 +1292,13 @@ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { } switch (*surfType) { case SF_FACE: - *plane = ((srfSurfaceFace_t *)surfType)->plane; + *plane = ((srfBspSurface_t *)surfType)->cullPlane; return; case SF_TRIANGLES: - tri = (srfTriangles_t *)surfType; - v1 = tri->verts + tri->triangles[0].indexes[0]; - v2 = tri->verts + tri->triangles[0].indexes[1]; - v3 = tri->verts + tri->triangles[0].indexes[2]; + tri = (srfBspSurface_t *)surfType; + v1 = tri->verts + tri->indexes[0]; + v2 = tri->verts + tri->indexes[1]; + v3 = tri->verts + tri->indexes[2]; PlaneFromPoints( plane4, v1->xyz, v2->xyz, v3->xyz ); VectorCopy( plane4, plane->normal ); plane->dist = plane4[3]; @@ -1651,7 +1564,8 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 for ( i = 0; i < tess.numIndexes; i += 3 ) { - vec3_t normal; + vec3_t normal, tNormal; + float len; VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal ); @@ -1662,7 +1576,9 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 shortest = len; } - if ( DotProduct( normal, tess.normal[tess.indexes[i]] ) >= 0 ) + R_VboUnpackNormal(tNormal, tess.normal[tess.indexes[i]]); + + if ( DotProduct( normal, tNormal ) >= 0 ) { numTriangles--; } @@ -2912,129 +2828,129 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) } } -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) -{ - refdef_t refdef; - viewParms_t parms; - float oldColorScale = tr.refdef.colorScale; - - memset( &refdef, 0, sizeof( refdef ) ); - refdef.rdflags = 0; - VectorCopy(tr.cubemapOrigins[cubemapIndex], refdef.vieworg); - - switch(cubemapSide) - { - case 0: - // -X - VectorSet( refdef.viewaxis[0], -1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, -1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 1: - // +X - VectorSet( refdef.viewaxis[0], 1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, 1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 2: - // -Y - VectorSet( refdef.viewaxis[0], 0, -1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, -1); - break; - case 3: - // +Y - VectorSet( refdef.viewaxis[0], 0, 1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, 1); - break; - case 4: - // -Z - VectorSet( refdef.viewaxis[0], 0, 0, -1); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - case 5: - // +Z - VectorSet( refdef.viewaxis[0], 0, 0, 1); - VectorSet( refdef.viewaxis[1], -1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); - break; - } +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) +{ + refdef_t refdef; + viewParms_t parms; + float oldColorScale = tr.refdef.colorScale; - refdef.fov_x = 90; - refdef.fov_y = 90; + memset( &refdef, 0, sizeof( refdef ) ); + refdef.rdflags = 0; + VectorCopy(tr.cubemapOrigins[cubemapIndex], refdef.vieworg); - refdef.x = 0; - refdef.y = 0; - refdef.width = tr.renderCubeFbo->width; - refdef.height = tr.renderCubeFbo->height; + switch(cubemapSide) + { + case 0: + // -X + VectorSet( refdef.viewaxis[0], -1, 0, 0); + VectorSet( refdef.viewaxis[1], 0, 0, -1); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 1: + // +X + VectorSet( refdef.viewaxis[0], 1, 0, 0); + VectorSet( refdef.viewaxis[1], 0, 0, 1); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 2: + // -Y + VectorSet( refdef.viewaxis[0], 0, -1, 0); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 0, -1); + break; + case 3: + // +Y + VectorSet( refdef.viewaxis[0], 0, 1, 0); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 0, 1); + break; + case 4: + // -Z + VectorSet( refdef.viewaxis[0], 0, 0, -1); + VectorSet( refdef.viewaxis[1], 1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + case 5: + // +Z + VectorSet( refdef.viewaxis[0], 0, 0, 1); + VectorSet( refdef.viewaxis[1], -1, 0, 0); + VectorSet( refdef.viewaxis[2], 0, 1, 0); + break; + } - refdef.time = 0; + refdef.fov_x = 90; + refdef.fov_y = 90; - if (!subscene) - { - RE_BeginScene(&refdef); + refdef.x = 0; + refdef.y = 0; + refdef.width = tr.renderCubeFbo->width; + refdef.height = tr.renderCubeFbo->height; - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if(0) //(glRefConfig.framebufferObject && (r_forceSun->integer || tr.sunShadows)) - { - R_RenderSunShadowMaps(&refdef, 0); - R_RenderSunShadowMaps(&refdef, 1); - R_RenderSunShadowMaps(&refdef, 2); - } - } + refdef.time = 0; + if (!subscene) + { + RE_BeginScene(&refdef); - vec3_t ambient, directed, lightDir; - R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); - tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); - if (directed[0] + directed[1] + directed[2] == 0) - { - ri->Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); - } + // FIXME: sun shadows aren't rendered correctly in cubemaps + // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first + if(0) //(glRefConfig.framebufferObject && (r_forceSun->integer || tr.sunShadows)) + { + R_RenderSunShadowMaps(&refdef, 0); + R_RenderSunShadowMaps(&refdef, 1); + R_RenderSunShadowMaps(&refdef, 2); + } + } + { + vec3_t ambient, directed, lightDir; + R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); + tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); + if (directed[0] + directed[1] + directed[2] == 0) + { + ri->Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); + } + } - Com_Memset( &parms, 0, sizeof( parms ) ); + Com_Memset( &parms, 0, sizeof( parms ) ); - parms.viewportX = 0; - parms.viewportY = 0; - parms.viewportWidth = tr.renderCubeFbo->width; - parms.viewportHeight = tr.renderCubeFbo->height; - parms.isPortal = qfalse; - parms.isMirror = qtrue; - parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS; + parms.viewportX = 0; + parms.viewportY = 0; + parms.viewportWidth = tr.renderCubeFbo->width; + parms.viewportHeight = tr.renderCubeFbo->height; + parms.isPortal = qfalse; + parms.isMirror = qtrue; + parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS; - parms.fovX = 90; - parms.fovY = 90; + parms.fovX = 90; + parms.fovY = 90; - VectorCopy( refdef.vieworg, parms.or.origin ); - VectorCopy( refdef.viewaxis[0], parms.or.axis[0] ); - VectorCopy( refdef.viewaxis[1], parms.or.axis[1] ); - VectorCopy( refdef.viewaxis[2], parms.or.axis[2] ); + VectorCopy( refdef.vieworg, parms.or.origin ); + VectorCopy( refdef.viewaxis[0], parms.or.axis[0] ); + VectorCopy( refdef.viewaxis[1], parms.or.axis[1] ); + VectorCopy( refdef.viewaxis[2], parms.or.axis[2] ); - VectorCopy( refdef.vieworg, parms.pvsOrigin ); + VectorCopy( refdef.vieworg, parms.pvsOrigin ); - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if (0) //(r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) - { - parms.flags = VPF_USESUNLIGHT; - } + // FIXME: sun shadows aren't rendered correctly in cubemaps + // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first + if (0) //(r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + { + parms.flags = VPF_USESUNLIGHT; + } - parms.targetFbo = tr.renderCubeFbo; - parms.targetFboLayer = cubemapSide; - parms.targetFboCubemapIndex = cubemapIndex; + parms.targetFbo = tr.renderCubeFbo; + parms.targetFboLayer = cubemapSide; + parms.targetFboCubemapIndex = cubemapIndex; - R_RenderView(&parms); + R_RenderView(&parms); - if (subscene) - { - tr.refdef.colorScale = oldColorScale; - } - else - { - RE_EndScene(); - } + if (subscene) + { + tr.refdef.colorScale = oldColorScale; + } + else + { + RE_EndScene(); + } } \ No newline at end of file diff --git a/codemp/rd-rend2/tr_marks.cpp b/codemp/rd-rend2/tr_marks.cpp index 4bee7a0054..6e12616d13 100644 --- a/codemp/rd-rend2/tr_marks.cpp +++ b/codemp/rd-rend2/tr_marks.cpp @@ -268,8 +268,8 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio vec3_t clipPoints[2][MAX_VERTS_ON_POLY]; int numClipPoints; float *v; - srfGridMesh_t *cv; - srfTriangle_t *tri; + srfBspSurface_t *cv; + glIndex_t *tri; srfVert_t *dv; vec3_t normal; vec3_t projectionDir; @@ -327,7 +327,7 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio if (*surfaces[i] == SF_GRID) { - cv = (srfGridMesh_t *) surfaces[i]; + cv = (srfBspSurface_t *) surfaces[i]; for ( m = 0 ; m < cv->height - 1 ; m++ ) { for ( n = 0 ; n < cv->width - 1 ; n++ ) { // We triangulate the grid and chop all triangles within @@ -407,19 +407,19 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio } else if (*surfaces[i] == SF_FACE) { - srfSurfaceFace_t *surf = ( srfSurfaceFace_t * ) surfaces[i]; + srfBspSurface_t *surf = ( srfBspSurface_t * ) surfaces[i]; // check the normal of this face - if (DotProduct(surf->plane.normal, projectionDir) > -0.5) { + if (DotProduct(surf->cullPlane.normal, projectionDir) > -0.5) { continue; } - for(k = 0, tri = surf->triangles; k < surf->numTriangles; k++, tri++) + for(k = 0, tri = surf->indexes; k < surf->numIndexes; k += 3, tri += 3) { for(j = 0; j < 3; j++) { - v = surf->verts[tri->indexes[j]].xyz; - VectorMA(v, MARKER_OFFSET, surf->plane.normal, clipPoints[0][j]); + v = surf->verts[tri[j]].xyz; + VectorMA(v, MARKER_OFFSET, surf->cullPlane.normal, clipPoints[0][j]); } // add the fragments of this face @@ -435,14 +435,14 @@ int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projectio } else if(*surfaces[i] == SF_TRIANGLES && r_marksOnTriangleMeshes->integer) { - srfTriangles_t *surf = (srfTriangles_t *) surfaces[i]; + srfBspSurface_t *surf = (srfBspSurface_t *) surfaces[i]; - for(k = 0, tri = surf->triangles; k < surf->numTriangles; k++, tri++) + for(k = 0, tri = surf->indexes; k < surf->numIndexes; k += 3, tri += 3) { for(j = 0; j < 3; j++) { - v = surf->verts[tri->indexes[j]].xyz; - VectorMA(v, MARKER_OFFSET, surf->verts[tri->indexes[j]].normal, clipPoints[0][j]); + v = surf->verts[tri[j]].xyz; + VectorMA(v, MARKER_OFFSET, surf->verts[tri[j]].normal, clipPoints[0][j]); } // add the fragments of this face diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 7bfc299bda..d1beed78d9 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -float ProjectRadius( float r, vec3_t location ) +static float ProjectRadius( float r, vec3_t location ) { float pr; float dist; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 38b4f757c5..90c291c853 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -816,7 +816,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN mdvFrame_t *frame; mdvSurface_t *surf;//, *surface; int *shaderIndex; - srfTriangle_t *tri; + glIndex_t *tri; mdvVertex_t *v; mdvSt_t *st; mdvTag_t *tag; @@ -981,19 +981,17 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN } // swap all the triangles - surf->numTriangles = md3Surf->numTriangles; - surf->triangles = tri = (srfTriangle_t *)ri->Hunk_Alloc(sizeof(*tri) * md3Surf->numTriangles, h_low); + surf->numIndexes = md3Surf->numTriangles; + surf->indexes = tri = (glIndex_t *)ri->Hunk_Alloc(sizeof(*tri) * 3 * md3Surf->numTriangles, h_low); md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); - for(j = 0; j < md3Surf->numTriangles; j++, tri++, md3Tri++) + for(j = 0; j < md3Surf->numTriangles; j++, tri += 3, md3Tri++) { - tri->indexes[0] = LittleLong(md3Tri->indexes[0]); - tri->indexes[1] = LittleLong(md3Tri->indexes[1]); - tri->indexes[2] = LittleLong(md3Tri->indexes[2]); + tri[0] = LittleLong(md3Tri->indexes[0]); + tri[1] = LittleLong(md3Tri->indexes[1]); + tri[2] = LittleLong(md3Tri->indexes[2]); } - R_CalcSurfaceTriangleNeighbors(surf->numTriangles, surf->triangles); - // swap all the XyzNormals surf->numVerts = md3Surf->numVerts; surf->verts = v = (mdvVertex_t *)ri->Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); @@ -1055,15 +1053,15 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN for(f = 0; f < mdvModel->numFrames; f++) { - for(j = 0, tri = surf->triangles; j < surf->numTriangles; j++, tri++) + for(j = 0, tri = surf->indexes; j < surf->numIndexes; j += 3, tri += 3) { - v0 = surf->verts[surf->numVerts * f + tri->indexes[0]].xyz; - v1 = surf->verts[surf->numVerts * f + tri->indexes[1]].xyz; - v2 = surf->verts[surf->numVerts * f + tri->indexes[2]].xyz; + v0 = surf->verts[surf->numVerts * f + tri[0]].xyz; + v1 = surf->verts[surf->numVerts * f + tri[1]].xyz; + v2 = surf->verts[surf->numVerts * f + tri[2]].xyz; - t0 = surf->st[tri->indexes[0]].st; - t1 = surf->st[tri->indexes[1]].st; - t2 = surf->st[tri->indexes[2]].st; + t0 = surf->st[tri[0]].st; + t1 = surf->st[tri[1]].st; + t2 = surf->st[tri[2]].st; if (!r_recalcMD3Normals->integer) VectorCopy(v->normal, normal); @@ -1081,15 +1079,15 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN { float *v; - v = surf->verts[surf->numVerts * f + tri->indexes[k]].tangent; + v = surf->verts[surf->numVerts * f + tri[k]].tangent; VectorAdd(v, tangent, v); - v = surf->verts[surf->numVerts * f + tri->indexes[k]].bitangent; + v = surf->verts[surf->numVerts * f + tri[k]].bitangent; VectorAdd(v, bitangent, v); if (r_recalcMD3Normals->integer) { - v = surf->verts[surf->numVerts * f + tri->indexes[k]].normal; + v = surf->verts[surf->numVerts * f + tri[k]].normal; VectorAdd(v, normal, v); } } @@ -1121,11 +1119,10 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN for (i = 0; i < mdvModel->numSurfaces; i++, vboSurf++, surf++) { vec3_t *verts; - vec3_t *normals; vec2_t *texcoords; + uint32_t *normals; #ifdef USE_VERT_TANGENT_SPACE - vec3_t *tangents; - vec3_t *bitangents; + uint32_t *tangents; #endif byte *data; @@ -1133,7 +1130,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN int ofs_xyz, ofs_normal, ofs_st; #ifdef USE_VERT_TANGENT_SPACE - int ofs_tangent, ofs_bitangent; + int ofs_tangent; #endif dataSize = 0; @@ -1147,9 +1144,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN #ifdef USE_VERT_TANGENT_SPACE ofs_tangent = dataSize; dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents); - - ofs_bitangent = dataSize; - dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*bitangents); #endif ofs_st = dataSize; @@ -1158,21 +1152,27 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN data = (byte *)Z_Malloc(dataSize, TAG_MODEL_MD3); verts = (vec3_t *)(data + ofs_xyz); - normals = (vec3_t *)(data + ofs_normal); + normals = (uint32_t *)(data + ofs_normal); #ifdef USE_VERT_TANGENT_SPACE - tangents = (vec3_t *)(data + ofs_tangent); - bitangents = (vec3_t *)(data + ofs_bitangent); + tangents = (uint32_t *)(data + ofs_tangent); #endif texcoords = (vec2_t *)(data + ofs_st); v = surf->verts; for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) { + vec3_t nxt; + vec4_t tangent; + VectorCopy(v->xyz, verts[j]); - VectorCopy(v->normal, normals[j]); + + normals[j] = R_VboPackNormal(v->normal); #ifdef USE_VERT_TANGENT_SPACE - VectorCopy(v->tangent, tangents[j]); - VectorCopy(v->bitangent, bitangents[j]); + CrossProduct(v->normal, v->tangent, nxt); + VectorCopy(v->tangent, tangent); + tangent[3] = (DotProduct(nxt, v->bitangent) < 0.0f) ? -1.0f : 1.0f; + + tangents[j] = R_VboPackTangent(tangent); #endif } @@ -1185,7 +1185,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->surfaceType = SF_VBO_MDVMESH; vboSurf->mdvModel = mdvModel; vboSurf->mdvSurface = surf; - vboSurf->numIndexes = surf->numTriangles * 3; + vboSurf->numIndexes = surf->numIndexes; vboSurf->numVerts = surf->numVerts; vboSurf->minIndex = 0; @@ -1197,7 +1197,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->vbo->ofs_normal = ofs_normal; #ifdef USE_VERT_TANGENT_SPACE vboSurf->vbo->ofs_tangent = ofs_tangent; - vboSurf->vbo->ofs_bitangent = ofs_bitangent; #endif vboSurf->vbo->ofs_st = ofs_st; @@ -1205,7 +1204,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->vbo->stride_normal = sizeof(*normals); #ifdef USE_VERT_TANGENT_SPACE vboSurf->vbo->stride_tangent = sizeof(*tangents); - vboSurf->vbo->stride_bitangent = sizeof(*bitangents); #endif vboSurf->vbo->stride_st = sizeof(*st); @@ -1214,7 +1212,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN Z_Free(data); - vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numTriangles, surf->triangles, VBO_USAGE_STATIC); + vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numIndexes, surf->indexes, VBO_USAGE_STATIC); } } diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 266d3e5259..3de5b990b3 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -25,6 +25,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LL(x) x=LittleLong(x) +// 3x4 identity matrix +static float identityMatrix[12] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0 +}; + static qboolean IQM_CheckRange( iqmHeader_t *header, int offset, int count,int size ) { // return true if the range specified by offset, count and size @@ -143,6 +150,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na iqmData_t *iqmData; srfIQModel_t *surface; char meshName[MAX_QPATH]; + byte blendIndexesType, blendWeightsType; if( filesize < sizeof(iqmHeader_t) ) { return qfalse; @@ -198,6 +206,8 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na return qfalse; } + blendIndexesType = blendWeightsType = IQM_UBYTE; + // check and swap vertex arrays if( IQM_CheckRange( header, header->ofs_vertexarrays, header->num_vertexarrays, @@ -264,11 +274,20 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } break; case IQM_BLENDINDEXES: + if( (vertexarray->format != IQM_INT && + vertexarray->format != IQM_UBYTE) || + vertexarray->size != 4 ) { + return qfalse; + } + blendIndexesType = vertexarray->format; + break; case IQM_BLENDWEIGHTS: - if( vertexarray->format != IQM_UBYTE || + if( (vertexarray->format != IQM_FLOAT && + vertexarray->format != IQM_UBYTE) || vertexarray->size != 4 ) { return qfalse; } + blendWeightsType = vertexarray->format; break; case IQM_COLOR: if( vertexarray->format != IQM_UBYTE || @@ -343,7 +362,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } } - if( header->num_poses != header->num_joints ) { + if( header->num_poses != header->num_joints && header->num_poses != 0 ) { + ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has %d poses and %d joints, must have the same number or 0 poses\n", + mod_name, header->num_poses, header->num_joints ); return qfalse; } @@ -379,7 +400,10 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na joint_names += strlen( (char *)header + header->ofs_text + joint->name ) + 1; } + } + if ( header->num_poses ) + { // check and swap poses if( IQM_CheckRange( header, header->ofs_poses, header->num_poses, sizeof(iqmPose_t) ) ) { @@ -438,7 +462,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na size = sizeof(iqmData_t); size += header->num_meshes * sizeof( srfIQModel_t ); size += header->num_joints * 12 * sizeof( float ); // joint mats - size += header->num_joints * header->num_frames * 12 * sizeof( float ); // pose mats + size += header->num_poses * header->num_frames * 12 * sizeof( float ); // pose mats if(header->ofs_bounds) size += header->num_frames * 6 * sizeof(float); // model bounds size += header->num_vertexes * 3 * sizeof(float); // positions @@ -446,12 +470,18 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na size += header->num_vertexes * 3 * sizeof(float); // normals size += header->num_vertexes * 4 * sizeof(float); // tangents size += header->num_vertexes * 4 * sizeof(byte); // blendIndexes - size += header->num_vertexes * 4 * sizeof(byte); // blendWeights size += header->num_vertexes * 4 * sizeof(byte); // colors size += header->num_joints * sizeof(int); // parents size += header->num_triangles * 3 * sizeof(int); // triangles size += joint_names; // joint names + // blendWeights + if (blendWeightsType == IQM_FLOAT) { + size += header->num_vertexes * 4 * sizeof(float); + } else { + size += header->num_vertexes * 4 * sizeof(byte); + } + mod->type = MOD_IQM; iqmData = (iqmData_t *)ri->Hunk_Alloc( size, h_low ); mod->data.iqm = iqmData; @@ -462,28 +492,40 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na iqmData->num_frames = header->num_frames; iqmData->num_surfaces = header->num_meshes; iqmData->num_joints = header->num_joints; + iqmData->num_poses = header->num_poses; + iqmData->blendWeightsType = blendWeightsType; iqmData->surfaces = (srfIQModel_t *)(iqmData + 1); iqmData->jointMats = (float *) (iqmData->surfaces + iqmData->num_surfaces); iqmData->poseMats = iqmData->jointMats + 12 * header->num_joints; if(header->ofs_bounds) { - iqmData->bounds = iqmData->poseMats + 12 * header->num_joints * header->num_frames; + iqmData->bounds = iqmData->poseMats + 12 * header->num_poses * header->num_frames; iqmData->positions = iqmData->bounds + 6 * header->num_frames; } else - iqmData->positions = iqmData->poseMats + 12 * header->num_joints * header->num_frames; + iqmData->positions = iqmData->poseMats + 12 * header->num_poses * header->num_frames; iqmData->texcoords = iqmData->positions + 3 * header->num_vertexes; iqmData->normals = iqmData->texcoords + 2 * header->num_vertexes; iqmData->tangents = iqmData->normals + 3 * header->num_vertexes; iqmData->blendIndexes = (byte *)(iqmData->tangents + 4 * header->num_vertexes); - iqmData->blendWeights = iqmData->blendIndexes + 4 * header->num_vertexes; - iqmData->colors = iqmData->blendWeights + 4 * header->num_vertexes; + + if(blendWeightsType == IQM_FLOAT) { + iqmData->blendWeights.f = (float *)(iqmData->blendIndexes + 4 * header->num_vertexes); + iqmData->colors = (byte *)(iqmData->blendWeights.f + 4 * header->num_vertexes); + } else { + iqmData->blendWeights.b = iqmData->blendIndexes + 4 * header->num_vertexes; + iqmData->colors = iqmData->blendWeights.b + 4 * header->num_vertexes; + } + iqmData->jointParents = (int *)(iqmData->colors + 4 * header->num_vertexes); iqmData->triangles = iqmData->jointParents + header->num_joints; iqmData->names = (char *)(iqmData->triangles + 3 * header->num_triangles); if ( header->num_joints == 0 ) - iqmData->jointMats = iqmData->poseMats = NULL; + iqmData->jointMats = NULL; + + if ( header->num_poses == 0 ) + iqmData->poseMats = NULL; // calculate joint matrices and their inverses // joint inverses are needed only until the pose matrices are calculated @@ -620,14 +662,27 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na n * sizeof(float) ); break; case IQM_BLENDINDEXES: - Com_Memcpy( iqmData->blendIndexes, - (byte *)header + vertexarray->offset, - n * sizeof(byte) ); + if( blendIndexesType == IQM_INT ) { + int *data = (int*)((byte*)header + vertexarray->offset); + for ( j = 0; j < n; j++ ) { + iqmData->blendIndexes[j] = (byte)data[j]; + } + } else { + Com_Memcpy( iqmData->blendIndexes, + (byte *)header + vertexarray->offset, + n * sizeof(byte) ); + } break; case IQM_BLENDWEIGHTS: - Com_Memcpy( iqmData->blendWeights, - (byte *)header + vertexarray->offset, - n * sizeof(byte) ); + if( blendWeightsType == IQM_FLOAT ) { + Com_Memcpy( iqmData->blendWeights.f, + (byte *)header + vertexarray->offset, + n * sizeof(float) ); + } else { + Com_Memcpy( iqmData->blendWeights.b, + (byte *)header + vertexarray->offset, + n * sizeof(byte) ); + } break; case IQM_COLOR: Com_Memcpy( iqmData->colors, @@ -895,9 +950,21 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, int *joint = data->jointParents; int i; - if ( oldframe == frame ) { - mat1 = data->poseMats + 12 * data->num_joints * frame; + if ( data->num_poses == 0 ) { for( i = 0; i < data->num_joints; i++, joint++ ) { + if( *joint >= 0 ) { + Matrix34Multiply( mat + 12 * *joint, + identityMatrix, mat + 12*i ); + } else { + Com_Memcpy( mat + 12*i, identityMatrix, 12 * sizeof(float) ); + } + } + return; + } + + if ( oldframe == frame ) { + mat1 = data->poseMats + 12 * data->num_poses * frame; + for( i = 0; i < data->num_poses; i++, joint++ ) { if( *joint >= 0 ) { Matrix34Multiply( mat + 12 * *joint, mat1 + 12*i, mat + 12*i ); @@ -906,10 +973,10 @@ static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, } } } else { - mat1 = data->poseMats + 12 * data->num_joints * frame; - mat2 = data->poseMats + 12 * data->num_joints * oldframe; + mat1 = data->poseMats + 12 * data->num_poses * frame; + mat2 = data->poseMats + 12 * data->num_poses * oldframe; - for( i = 0; i < data->num_joints; i++, joint++ ) { + for( i = 0; i < data->num_poses; i++, joint++ ) { if( *joint >= 0 ) { float tmpMat[12]; InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, @@ -957,7 +1024,10 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { int i; vec4_t *outXYZ; - vec4_t *outNormal; + uint32_t *outNormal; +#ifdef USE_VERT_TANGENT_SPACE + uint32_t *outTangent; +#endif vec2_t (*outTexCoord)[2]; vec4_t *outColor; @@ -973,11 +1043,14 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { outXYZ = &tess.xyz[tess.numVertexes]; outNormal = &tess.normal[tess.numVertexes]; +#ifdef USE_VERT_TANGENT_SPACE + outTangent = &tess.tangent[tess.numVertexes]; +#endif outTexCoord = &tess.texCoords[tess.numVertexes]; outColor = &tess.vertexColors[tess.numVertexes]; // compute interpolated joint matrices - if ( data->num_joints > 0 ) { + if ( data->num_poses > 0 ) { ComputePoseMats( data, frame, oldframe, backlerp, jointMats ); } @@ -988,28 +1061,31 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { float vtxMat[12]; float nrmMat[9]; int vtx = i + surf->first_vertex; + float blendWeights[4]; + int numWeights; + + for ( numWeights = 0; numWeights < 4; numWeights++ ) { + if ( data->blendWeightsType == IQM_FLOAT ) + blendWeights[numWeights] = data->blendWeights.f[4*vtx + numWeights]; + else + blendWeights[numWeights] = (float)data->blendWeights.b[4*vtx + numWeights] / 255.0f; - if ( data->num_joints == 0 || data->blendWeights[4*vtx] <= 0 ) { + if ( blendWeights[numWeights] <= 0 ) + break; + } + + if ( data->num_poses == 0 || numWeights == 0 ) { // no blend joint, use identity matrix. - for( j = 0; j < 3; j++ ) { - for( k = 0; k < 4; k++ ) - vtxMat[4*j+k] = ( k == j ) ? 1 : 0; - } + Com_Memcpy( vtxMat, identityMatrix, 12 * sizeof (float) ); } else { // compute the vertex matrix by blending the up to // four blend weights - for( k = 0; k < 12; k++ ) - vtxMat[k] = data->blendWeights[4*vtx] - * jointMats[12*data->blendIndexes[4*vtx] + k]; - for( j = 1; j < 4; j++ ) { - if( data->blendWeights[4*vtx + j] <= 0 ) - break; - for( k = 0; k < 12; k++ ) - vtxMat[k] += data->blendWeights[4*vtx + j] - * jointMats[12*data->blendIndexes[4*vtx + j] + k]; + Com_Memset( vtxMat, 0, 12 * sizeof (float) ); + for( j = 0; j < numWeights; j++ ) { + for( k = 0; k < 12; k++ ) { + vtxMat[k] += blendWeights[j] * jointMats[12*data->blendIndexes[4*vtx + j] + k]; + } } - for( k = 0; k < 12; k++ ) - vtxMat[k] *= 1.0f / 255.0f; } // compute the normal matrix as transpose of the adjoint @@ -1046,19 +1122,25 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vtxMat[11]; (*outXYZ)[3] = 1.0f; - (*outNormal)[0] = - nrmMat[ 0] * data->normals[3*vtx+0] + - nrmMat[ 1] * data->normals[3*vtx+1] + - nrmMat[ 2] * data->normals[3*vtx+2]; - (*outNormal)[1] = - nrmMat[ 3] * data->normals[3*vtx+0] + - nrmMat[ 4] * data->normals[3*vtx+1] + - nrmMat[ 5] * data->normals[3*vtx+2]; - (*outNormal)[2] = - nrmMat[ 6] * data->normals[3*vtx+0] + - nrmMat[ 7] * data->normals[3*vtx+1] + - nrmMat[ 8] * data->normals[3*vtx+2]; - (*outNormal)[3] = 0.0f; + { + vec3_t normal; + vec4_t tangent; + + normal[0] = DotProduct(&nrmMat[0], &data->normals[3*vtx]); + normal[1] = DotProduct(&nrmMat[3], &data->normals[3*vtx]); + normal[2] = DotProduct(&nrmMat[6], &data->normals[3*vtx]); + + *outNormal = R_VboPackNormal(normal); + +#ifdef USE_VERT_TANGENT_SPACE + tangent[0] = DotProduct(&nrmMat[0], &data->tangents[4*vtx]); + tangent[1] = DotProduct(&nrmMat[3], &data->tangents[4*vtx]); + tangent[2] = DotProduct(&nrmMat[6], &data->tangents[4*vtx]); + tangent[3] = data->tangents[4*vtx+3]; + + *outTangent++ = R_VboPackTangent(tangent); +#endif + } (*outColor)[0] = data->colors[4*vtx+0] / 255.0f; (*outColor)[1] = data->colors[4*vtx+1] / 255.0f; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index cd21cf68ec..1548f51118 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -255,10 +255,20 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc float s1 = iscale + s0; float t1 = iscale + t0; - srcBox[0] = s0 * srcFbo->width; - srcBox[1] = t0 * srcFbo->height; - srcBox[2] = (s1 - s0) * srcFbo->width; - srcBox[3] = (t1 - t0) * srcFbo->height; + if (srcFbo) + { + srcBox[0] = s0 * srcFbo->width; + srcBox[1] = t0 * srcFbo->height; + srcBox[2] = (s1 - s0) * srcFbo->width; + srcBox[3] = (t1 - t0) * srcFbo->height; + } + else + { + srcBox[0] = s0 * glConfig.vidWidth; + srcBox[1] = t0 * glConfig.vidHeight; + srcBox[2] = (s1 - s0) * glConfig.vidWidth; + srcBox[3] = (t1 - t0) * glConfig.vidHeight; + } FBO_Blit(srcFbo, srcBox, texScale, dstFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE ); @@ -351,10 +361,20 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) VectorSet4(color, mul, mul, mul, 1); - rayBox[0] = srcBox[0] * tr.sunRaysFbo->width / srcFbo->width; - rayBox[1] = srcBox[1] * tr.sunRaysFbo->height / srcFbo->height; - rayBox[2] = srcBox[2] * tr.sunRaysFbo->width / srcFbo->width; - rayBox[3] = srcBox[3] * tr.sunRaysFbo->height / srcFbo->height; + if (srcFbo) + { + rayBox[0] = srcBox[0] * tr.sunRaysFbo->width / srcFbo->width; + rayBox[1] = srcBox[1] * tr.sunRaysFbo->height / srcFbo->height; + rayBox[2] = srcBox[2] * tr.sunRaysFbo->width / srcFbo->width; + rayBox[3] = srcBox[3] * tr.sunRaysFbo->height / srcFbo->height; + } + else + { + rayBox[0] = srcBox[0] * tr.sunRaysFbo->width / glConfig.vidWidth; + rayBox[1] = srcBox[1] * tr.sunRaysFbo->height / glConfig.vidHeight; + rayBox[2] = srcBox[2] * tr.sunRaysFbo->width / glConfig.vidWidth; + rayBox[3] = srcBox[3] * tr.sunRaysFbo->height / glConfig.vidHeight; + } quarterBox[0] = 0; quarterBox[1] = tr.quarterFbo[0]->height; @@ -480,7 +500,7 @@ void RB_GaussianBlur(float blur) VectorSet4(color, 1, 1, 1, 1); // first, downsample the framebuffer - FBO_FastBlit(tr.screenScratchFbo, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); // set the alpha channel @@ -498,6 +518,6 @@ void RB_GaussianBlur(float blur) VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight); color[3] = factor; - FBO_Blit(tr.textureScratchFbo[0], srcBox, texScale, tr.screenScratchFbo, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + FBO_Blit(tr.textureScratchFbo[0], srcBox, texScale, NULL, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } } diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 53bef8c27a..ead9920b56 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -78,6 +78,7 @@ void RE_ClearScene( void ) { DISCRETE POLYS =========================================================================== +*/ /* ===================== @@ -290,7 +291,7 @@ void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, flo RE_AddDynamicLightToScene( org, intensity, r, g, b, qtrue ); } -void RE_BeginScene(const refdef_t *fd) +void RE_BeginScene(const refdef_t *fd) { Com_Memcpy( tr.refdef.text, fd->text, sizeof( tr.refdef.text ) ); @@ -446,13 +447,13 @@ void RE_BeginScene(const refdef_t *fd) tr.sceneCount++; } -void RE_EndScene() -{ - // the next scene rendered in this frame will tack on after this one - r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; - r_firstSceneEntity = r_numentities; - r_firstSceneDlight = r_numdlights; - r_firstScenePoly = r_numpolys; +void RE_EndScene() +{ + // the next scene rendered in this frame will tack on after this one + r_firstSceneDrawSurf = tr.refdef.numDrawSurfs; + r_firstSceneEntity = r_numentities; + r_firstSceneDlight = r_numdlights; + r_firstScenePoly = r_numpolys; } /* @@ -507,20 +508,20 @@ void RE_RenderScene( const refdef_t *fd ) { R_RenderSunShadowMaps(fd, 2); } - // playing with cube maps - // this is where dynamic cubemaps would be rendered - if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL )) - { - int i, j; - - for (i = 0; i < tr.numCubemaps; i++) - { - for (j = 0; j < 6; j++) - { - R_RenderCubemapSide(i, j, qtrue); - } - } - } + // playing with cube maps + // this is where dynamic cubemaps would be rendered + if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL )) + { + int i, j; + + for (i = 0; i < tr.numCubemaps; i++) + { + for (j = 0; j < 6; j++) + { + R_RenderCubemapSide(i, j, qtrue); + } + } + } // setup view parms for the initial view // diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 3a369e1b67..396b514ba1 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -46,9 +46,9 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { if (glRefConfig.drawRangeElements) - qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); else - qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE))); + qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); } @@ -249,16 +249,16 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr float matrix[6], currentmatrix[6]; textureBundle_t *bundle = &pStage->bundle[bundleNum]; - matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = 0.0f; - matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = 0.0f; - - currentmatrix[0] = 1.0f; currentmatrix[2] = 0.0f; currentmatrix[4] = 0.0f; - currentmatrix[1] = 0.0f; currentmatrix[3] = 1.0f; currentmatrix[5] = 0.0f; - - outMatrix[0] = 1.0f; outMatrix[2] = 0.0f; - outMatrix[1] = 0.0f; outMatrix[3] = 1.0f; + matrix[0] = 1.0f; matrix[2] = 0.0f; matrix[4] = 0.0f; + matrix[1] = 0.0f; matrix[3] = 1.0f; matrix[5] = 0.0f; + + currentmatrix[0] = 1.0f; currentmatrix[2] = 0.0f; currentmatrix[4] = 0.0f; + currentmatrix[1] = 0.0f; currentmatrix[3] = 1.0f; currentmatrix[5] = 0.0f; - outOffTurb[0] = 0.0f; outOffTurb[1] = 0.0f; outOffTurb[2] = 0.0f; outOffTurb[3] = 0.0f; + outMatrix[0] = 1.0f; outMatrix[2] = 0.0f; + outMatrix[1] = 0.0f; outMatrix[3] = 1.0f; + + outOffTurb[0] = 0.0f; outOffTurb[1] = 0.0f; outOffTurb[2] = 0.0f; outOffTurb[3] = 0.0f; for ( tm = 0; tm < bundle->numTexMods ; tm++ ) { switch ( bundle->texMods[tm].type ) @@ -306,36 +306,36 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr break; } - switch ( bundle->texMods[tm].type ) - { - case TMOD_NONE: - case TMOD_TURBULENT: - default: - break; - - case TMOD_ENTITY_TRANSLATE: - case TMOD_SCROLL: - case TMOD_SCALE: - case TMOD_STRETCH: - case TMOD_TRANSFORM: - case TMOD_ROTATE: - outMatrix[0] = matrix[0] * currentmatrix[0] + matrix[2] * currentmatrix[1]; - outMatrix[1] = matrix[1] * currentmatrix[0] + matrix[3] * currentmatrix[1]; - - outMatrix[2] = matrix[0] * currentmatrix[2] + matrix[2] * currentmatrix[3]; - outMatrix[3] = matrix[1] * currentmatrix[2] + matrix[3] * currentmatrix[3]; - - outOffTurb[0] = matrix[0] * currentmatrix[4] + matrix[2] * currentmatrix[5] + matrix[4]; - outOffTurb[1] = matrix[1] * currentmatrix[4] + matrix[3] * currentmatrix[5] + matrix[5]; - - currentmatrix[0] = outMatrix[0]; - currentmatrix[1] = outMatrix[1]; - currentmatrix[2] = outMatrix[2]; - currentmatrix[3] = outMatrix[3]; - currentmatrix[4] = outOffTurb[0]; - currentmatrix[5] = outOffTurb[1]; - break; - } + switch ( bundle->texMods[tm].type ) + { + case TMOD_NONE: + case TMOD_TURBULENT: + default: + break; + + case TMOD_ENTITY_TRANSLATE: + case TMOD_SCROLL: + case TMOD_SCALE: + case TMOD_STRETCH: + case TMOD_TRANSFORM: + case TMOD_ROTATE: + outMatrix[0] = matrix[0] * currentmatrix[0] + matrix[2] * currentmatrix[1]; + outMatrix[1] = matrix[1] * currentmatrix[0] + matrix[3] * currentmatrix[1]; + + outMatrix[2] = matrix[0] * currentmatrix[2] + matrix[2] * currentmatrix[3]; + outMatrix[3] = matrix[1] * currentmatrix[2] + matrix[3] * currentmatrix[3]; + + outOffTurb[0] = matrix[0] * currentmatrix[4] + matrix[2] * currentmatrix[5] + matrix[4]; + outOffTurb[1] = matrix[1] * currentmatrix[4] + matrix[3] * currentmatrix[5] + matrix[5]; + + currentmatrix[0] = outMatrix[0]; + currentmatrix[1] = outMatrix[1]; + currentmatrix[2] = outMatrix[2]; + currentmatrix[3] = outMatrix[3]; + currentmatrix[4] = outOffTurb[0]; + currentmatrix[5] = outOffTurb[1]; + break; + } } } @@ -465,7 +465,7 @@ static void ProjectDlightTexture( void ) { } -static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, colorGen_t *forceRGBGen, alphaGen_t *forceAlphaGen ) +static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend, colorGen_t *forceRGBGen, alphaGen_t *forceAlphaGen ) { colorGen_t rgbGen = pStage->rgbGen; alphaGen_t alphaGen = pStage->alphaGen; @@ -653,6 +653,23 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t { *forceRGBGen = rgbGen; } + + // multiply color by overbrightbits if this isn't a blend + if (r_softOverbright->integer && tr.overbrightBits + && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) + && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) + && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) + && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_ONE_MINUS_SRC_COLOR)) + { + float scale = 1 << tr.overbrightBits; + + baseColor[0] *= scale; + baseColor[1] *= scale; + baseColor[2] *= scale; + vertColor[0] *= scale; + vertColor[1] *= scale; + vertColor[2] *= scale; + } // FIXME: find some way to implement this. #if 0 @@ -783,7 +800,7 @@ static void ForwardDlight( void ) { { int index = pStage->glslShaderIndex; - index &= ~(LIGHTDEF_LIGHTTYPE_MASK | LIGHTDEF_USE_DELUXEMAP); + index &= ~LIGHTDEF_LIGHTTYPE_MASK; index |= LIGHTDEF_USE_LIGHT_VECTOR; sp = &tr.lightallShader[index]; @@ -822,7 +839,7 @@ static void ForwardDlight( void ) { vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor, NULL, NULL); + ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE, NULL, NULL); GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); @@ -1067,7 +1084,6 @@ static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) vertexAttribs |= ATTR_NORMAL2; #ifdef USE_VERT_TANGENT_SPACE vertexAttribs |= ATTR_TANGENT2; - vertexAttribs |= ATTR_BITANGENT2; #endif } } @@ -1202,11 +1218,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) index |= LIGHTDEF_USE_SHADOWMAP; } - if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && (index & LIGHTDEF_LIGHTTYPE_MASK) && input->cubemapIndex) - { - index |= LIGHTDEF_USE_CUBEMAP; - } - if (r_lightmap->integer && index & LIGHTDEF_USE_LIGHTMAP) { index = LIGHTDEF_USE_LIGHTMAP; @@ -1283,7 +1294,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) vec4_t baseColor; vec4_t vertColor; - ComputeShaderColors(pStage, baseColor, vertColor, &forceRGBGen, &forceAlphaGen); + ComputeShaderColors(pStage, baseColor, vertColor, stateBits, &forceRGBGen, &forceAlphaGen); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { @@ -1372,6 +1383,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) else if ( pStage->glslShaderGroup == tr.lightallShader ) { int i; + vec4_t enableTextures; if ((backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { @@ -1381,72 +1393,78 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformVec4(sp, UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); } + VectorSet4(enableTextures, 0, 0, 0, 0); if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && pStage->bundle[TB_LIGHTMAP].image[0]) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { - if (pStage->bundle[i].image[0]) - { - switch(i) - { - case TB_LIGHTMAP: - R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], i); - break; - - case TB_DIFFUSEMAP: - case TB_SPECULARMAP: - case TB_SHADOWMAP: - case TB_CUBEMAP: - default: - GL_BindToTMU( tr.whiteImage, i); - break; - - case TB_NORMALMAP: - case TB_DELUXEMAP: - GL_BindToTMU( tr.greyImage, i); - break; - } - } + if (i == TB_LIGHTMAP) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], i); + else + GL_BindToTMU( tr.whiteImage, i ); } } else if (r_lightmap->integer == 3 && pStage->bundle[TB_DELUXEMAP].image[0]) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { - if (pStage->bundle[i].image[0]) - { - switch(i) - { - case TB_LIGHTMAP: - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); - break; - - case TB_DIFFUSEMAP: - case TB_SPECULARMAP: - case TB_SHADOWMAP: - case TB_CUBEMAP: - default: - GL_BindToTMU( tr.whiteImage, i); - break; - - case TB_NORMALMAP: - case TB_DELUXEMAP: - GL_BindToTMU( tr.greyImage, i); - break; - } - } + if (i == TB_LIGHTMAP) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); + else + GL_BindToTMU( tr.whiteImage, i ); } } else { - for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) + qboolean light = (qboolean)((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) != 0); + qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); + + if (pStage->bundle[TB_DIFFUSEMAP].image[0]) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + + if (pStage->bundle[TB_LIGHTMAP].image[0]) + R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], TB_LIGHTMAP); + + // bind textures that are sampled and used in the glsl shader, and + // bind whiteImage to textures that are sampled but zeroed in the glsl shader + // + // alternatives: + // - use the last bound texture + // -> costs more to sample a higher res texture then throw out the result + // - disable texture sampling in glsl shader with #ifdefs, as before + // -> increases the number of shaders that must be compiled + // + if (light && !fastLight) { - if (pStage->bundle[i].image[0]) + if (pStage->bundle[TB_NORMALMAP].image[0]) + { + R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + enableTextures[0] = 1.0f; + } + else if (r_normalMapping->integer) + GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); + + if (pStage->bundle[TB_DELUXEMAP].image[0]) + { + R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], TB_DELUXEMAP); + enableTextures[1] = 1.0f; + } + else if (r_deluxeMapping->integer) + GL_BindToTMU( tr.whiteImage, TB_DELUXEMAP ); + + if (pStage->bundle[TB_SPECULARMAP].image[0]) { - R_BindAnimatedImageToTMU( &pStage->bundle[i], i); + R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); + enableTextures[2] = 1.0f; } + else if (r_specularMapping->integer) + GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); } + + enableTextures[3] = (r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex) ? 1.0f : 0.0f; } + + GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); } else if ( pStage->bundle[1].image[0] != 0 ) { @@ -1468,12 +1486,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) // // set state // - if ( pStage->bundle[0].vertexLightmap && (r_vertexLight->integer && !r_uiFullScreen->integer) && r_lightmap->integer ) - { - GL_BindToTMU( tr.whiteImage, 0 ); - } - else - R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); + R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, 0); } @@ -1497,7 +1510,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) } // allow skipping out to show just lightmaps during development - if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap || pStage->bundle[0].vertexLightmap ) ) + if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) { break; } diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 1a82cc0d2d..3bd05ca30f 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -126,27 +126,27 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) vec3_t offset; float scale; float *xyz = ( float * ) tess.xyz; - float *normal = ( float * ) tess.normal; + uint32_t *normal = ( uint32_t * ) tess.normal; float *table; if ( ds->deformationWave.frequency == 0 ) { scale = EvalWaveForm( &ds->deformationWave ); - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal++ ) { - VectorScale( normal, scale, offset ); + R_VboUnpackNormal(offset, *normal); - xyz[0] += offset[0]; - xyz[1] += offset[1]; - xyz[2] += offset[2]; + xyz[0] += offset[0] * scale; + xyz[1] += offset[1] * scale; + xyz[2] += offset[2] * scale; } } else { table = TableForFunc( ds->deformationWave.func ); - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal++ ) { float off = ( xyz[0] + xyz[1] + xyz[2] ) * ds->deformationSpread; @@ -155,11 +155,11 @@ void RB_CalcDeformVertexes( deformStage_t *ds ) ds->deformationWave.phase + off, ds->deformationWave.frequency ); - VectorScale( normal, scale, offset ); - - xyz[0] += offset[0]; - xyz[1] += offset[1]; - xyz[2] += offset[2]; + R_VboUnpackNormal(offset, *normal); + + xyz[0] += offset[0] * scale; + xyz[1] += offset[1] * scale; + xyz[2] += offset[2] * scale; } } } @@ -175,25 +175,31 @@ void RB_CalcDeformNormals( deformStage_t *ds ) { int i; float scale; float *xyz = ( float * ) tess.xyz; - float *normal = ( float * ) tess.normal; + uint32_t *normal = ( uint32_t * ) tess.normal; + + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal++ ) { + vec3_t fNormal; + + R_VboUnpackNormal(fNormal, *normal); - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, normal += 4 ) { scale = 0.98f; scale = R_NoiseGet4f( xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, tess.shaderTime * ds->deformationWave.frequency ); - normal[ 0 ] += ds->deformationWave.amplitude * scale; + fNormal[ 0 ] += ds->deformationWave.amplitude * scale; scale = 0.98f; scale = R_NoiseGet4f( 100 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, tess.shaderTime * ds->deformationWave.frequency ); - normal[ 1 ] += ds->deformationWave.amplitude * scale; + fNormal[ 1 ] += ds->deformationWave.amplitude * scale; scale = 0.98f; scale = R_NoiseGet4f( 200 + xyz[0] * scale, xyz[1] * scale, xyz[2] * scale, tess.shaderTime * ds->deformationWave.frequency ); - normal[ 2 ] += ds->deformationWave.amplitude * scale; + fNormal[ 2 ] += ds->deformationWave.amplitude * scale; + + VectorNormalizeFast( fNormal ); - VectorNormalizeFast( normal ); + *normal = R_VboPackNormal(fNormal); } } @@ -207,22 +213,25 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) { int i; const float *st = ( const float * ) tess.texCoords[0]; float *xyz = ( float * ) tess.xyz; - float *normal = ( float * ) tess.normal; + uint32_t *normal = ( uint32_t * ) tess.normal; float now; now = backEnd.refdef.time * ds->bulgeSpeed * 0.001f; - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal += 4 ) { + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal++ ) { int off; float scale; + vec3_t fNormal; + + R_VboUnpackNormal(fNormal, *normal); off = (float)( FUNCTABLE_SIZE / (M_PI*2) ) * ( st[0] * ds->bulgeWidth + now ); scale = tr.sinTable[ off & FUNCTABLE_MASK ] * ds->bulgeHeight; - xyz[0] += normal[0] * scale; - xyz[1] += normal[1] * scale; - xyz[2] += normal[2] * scale; + xyz[0] += fNormal[0] * scale; + xyz[1] += fNormal[1] * scale; + xyz[2] += fNormal[2] * scale; } } @@ -272,11 +281,14 @@ void DeformText( const char *text ) { float color[4]; float bottom, top; vec3_t mid; + vec3_t fNormal; height[0] = 0; height[1] = 0; height[2] = -1; - CrossProduct( tess.normal[0], height, width ); + + R_VboUnpackNormal(fNormal, tess.normal[0]); + CrossProduct( fNormal, height, width ); // find the midpoint of the box VectorClear( mid ); @@ -769,7 +781,6 @@ void RB_CalcScaleTexMatrix( const float scale[2], float *matrix ) /* ** RB_CalcScrollTexMatrix */ - void RB_CalcScrollTexMatrix( const float scrollSpeed[2], float *matrix ) { float timeScale = tess.shaderTime; @@ -815,7 +826,3 @@ void RB_CalcRotateTexMatrix( float degsPerSecond, float *matrix ) matrix[0] = cosValue; matrix[2] = -sinValue; matrix[4] = 0.5 - 0.5 * cosValue + 0.5 * sinValue; matrix[1] = sinValue; matrix[3] = cosValue; matrix[5] = 0.5 - 0.5 * sinValue - 0.5 * cosValue; } - - - - diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index d87bf3e538..f54b420952 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2129,7 +2129,7 @@ static void ComputeVertexAttribs(void) #ifdef USE_VERT_TANGENT_SPACE if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && !(r_normalMapping->integer == 0 && r_specularMapping->integer == 0)) { - shader.vertexAttribs |= ATTR_BITANGENT | ATTR_TANGENT; + shader.vertexAttribs |= ATTR_TANGENT; } #endif @@ -2383,7 +2383,6 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, //ri->Printf(PRINT_ALL, ", deluxemap"); diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex]; - defs |= LIGHTDEF_USE_DELUXEMAP; } if (r_normalMapping->integer) @@ -2701,8 +2700,6 @@ static qboolean CollapseStagesToGLSL(void) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; - if (r_deluxeMapping->integer && tr.worldDeluxeMapping) - pStage->glslShaderIndex |= LIGHTDEF_USE_DELUXEMAP; pStage->bundle[TB_LIGHTMAP] = pStage->bundle[TB_DIFFUSEMAP]; pStage->bundle[TB_DIFFUSEMAP].image[0] = tr.whiteImage; pStage->bundle[TB_DIFFUSEMAP].isLightmap = qfalse; @@ -2736,25 +2733,28 @@ static qboolean CollapseStagesToGLSL(void) } } - // insert default normal and specular textures if necessary - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->glslShaderGroup != tr.lightallShader) - continue; + // insert default material info if needed + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->glslShaderGroup != tr.lightallShader) + continue; + + if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) == 0) + continue; - if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) == 0) - continue; - - if (!pStage->bundle[TB_NORMALMAP].image[0] && r_normalMapping->integer) + if (!pStage->bundle[TB_SPECULARMAP].image[0] && r_specularMapping->integer) { - pStage->bundle[TB_NORMALMAP].image[0] = tr.greyImage; + if (!pStage->materialInfo[0]) + pStage->materialInfo[0] = r_baseSpecular->value; + if (!pStage->materialInfo[1]) + pStage->materialInfo[1] = r_baseGloss->value; } - } + } return (qboolean)numStages; } @@ -3036,11 +3036,7 @@ from the current global working shader */ static shader_t *FinishShader( void ) { int stage; - qboolean hasLightmapStage; - qboolean vertexLightmap; - - hasLightmapStage = qfalse; - vertexLightmap = qfalse; + qboolean hasLightmapStage = qfalse; // // set sky stuff appropriate @@ -3114,15 +3110,6 @@ static shader_t *FinishShader( void ) { } } - - // not a true lightmap but we want to leave existing - // behaviour in place and not print out a warning - //if (pStage->rgbGen == CGEN_VERTEX) { - // vertexLightmap = qtrue; - //} - - - // // determine sort order and fog color adjustment // @@ -3197,13 +3184,9 @@ static shader_t *FinishShader( void ) { stage = CollapseStagesToGLSL(); if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) { - if (vertexLightmap) { - ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has VERTEX forced lightmap!\n", shader.name ); - } else { - ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); - // Don't set this, it will just add duplicate shaders to the hash - //shader.lightmapIndex = LIGHTMAP_NONE; - } + ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); + // Don't set this, it will just add duplicate shaders to the hash + //shader.lightmapIndex = LIGHTMAP_NONE; } diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index bd6d5d2aa8..f412b00d3e 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -162,7 +162,7 @@ void RB_ShadowTessEnd( void ) { return; } - if ( r_stencilbits->integer < 4 ) { + if ( glConfig.stencilBits < 4 ) { return; } @@ -265,7 +265,7 @@ void RB_ShadowFinish( void ) { if ( r_shadows->integer != 2 ) { return; } - if ( r_stencilbits->integer < 4 ) { + if ( glConfig.stencilBits < 4 ) { return; } qglEnable( GL_STENCIL_TEST ); diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 84d74a66bf..8054d87d51 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -448,7 +448,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max color[0] = color[1] = - color[2] = tr.identityLight * backEnd.refdef.colorScale; + color[2] = (r_softOverbright->integer ? 1.0 : tr.identityLight) * backEnd.refdef.colorScale; color[3] = 1.0f; GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); @@ -467,7 +467,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex, tess.minIndex, tess.maxIndex); - //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(GL_INDEX_TYPE))); + //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(glIndex_t))); //R_BindNullVBO(); //R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 320617193c..3587ce8f27 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -124,11 +124,11 @@ void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], // constant normal all the way around VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal ); - VectorCopy(normal, tess.normal[ndx]); - VectorCopy(normal, tess.normal[ndx+1]); - VectorCopy(normal, tess.normal[ndx+2]); - VectorCopy(normal, tess.normal[ndx+3]); - + tess.normal[ndx] = + tess.normal[ndx+1] = + tess.normal[ndx+2] = + tess.normal[ndx+3] = R_VboPackNormal(normal); + // standard square texture coordinates VectorSet2(tess.texCoords[ndx ][0], s1, t1); VectorSet2(tess.texCoords[ndx ][1], s1, t1); @@ -363,30 +363,30 @@ static void RB_SurfacePolychain( srfPoly_t *p ) { tess.numVertexes = numv; } -static void RB_SurfaceVertsAndTris( int numVerts, srfVert_t *verts, int numTriangles, srfTriangle_t *triangles, int dlightBits, int pshadowBits) +static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIndexes, glIndex_t *indexes, int dlightBits, int pshadowBits) { int i; - srfTriangle_t *tri; + glIndex_t *inIndex; srfVert_t *dv; - float *xyz, *normal, *texCoords, *lightCoords, *lightdir; + float *xyz, *texCoords, *lightCoords; + uint32_t *lightdir; + uint32_t *normal; #ifdef USE_VERT_TANGENT_SPACE - float *tangent, *bitangent; + uint32_t *tangent; #endif - glIndex_t *index; + glIndex_t *outIndex; float *color; RB_CheckVBOandIBO(tess.vbo, tess.ibo); - RB_CHECKOVERFLOW( numVerts, numTriangles * 3 ); + RB_CHECKOVERFLOW( numVerts, numIndexes ); - tri = triangles; - index = &tess.indexes[ tess.numIndexes ]; - for ( i = 0 ; i < numTriangles ; i++, tri++ ) { - *index++ = tess.numVertexes + tri->indexes[0]; - *index++ = tess.numVertexes + tri->indexes[1]; - *index++ = tess.numVertexes + tri->indexes[2]; + inIndex = indexes; + outIndex = &tess.indexes[ tess.numIndexes ]; + for ( i = 0 ; i < numIndexes ; i++ ) { + *outIndex++ = tess.numVertexes + *inIndex++; } - tess.numIndexes += numTriangles * 3; + tess.numIndexes += numIndexes; if ( tess.shader->vertexAttribs & ATTR_POSITION ) { @@ -399,26 +399,18 @@ static void RB_SurfaceVertsAndTris( int numVerts, srfVert_t *verts, int numTrian if ( tess.shader->vertexAttribs & ATTR_NORMAL ) { dv = verts; - normal = tess.normal[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, normal+=4 ) - VectorCopy(dv->normal, normal); + normal = &tess.normal[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, normal++ ) + *normal = R_VboPackNormal(dv->normal); } #ifdef USE_VERT_TANGENT_SPACE if ( tess.shader->vertexAttribs & ATTR_TANGENT ) { dv = verts; - tangent = tess.tangent[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, tangent+=4 ) - VectorCopy(dv->tangent, tangent); - } - - if ( tess.shader->vertexAttribs & ATTR_BITANGENT ) - { - dv = verts; - bitangent = tess.bitangent[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, bitangent+=4 ) - VectorCopy(dv->bitangent, bitangent); + tangent = &tess.tangent[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, tangent++ ) + *tangent = R_VboPackTangent(dv->tangent); } #endif @@ -449,9 +441,9 @@ static void RB_SurfaceVertsAndTris( int numVerts, srfVert_t *verts, int numTrian if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) { dv = verts; - lightdir = tess.lightdir[ tess.numVertexes ]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightdir+=4 ) - VectorCopy(dv->lightdir, lightdir); + lightdir = &tess.lightdir[ tess.numVertexes ]; + for ( i = 0 ; i < numVerts ; i++, dv++, lightdir++ ) + *lightdir = R_VboPackNormal(dv->lightdir); } #if 0 // nothing even uses vertex dlightbits @@ -489,8 +481,8 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex // merge this into any existing multidraw primitives mergeForward = -1; mergeBack = -1; - firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(GL_INDEX_TYPE)); - lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(GL_INDEX_TYPE)); + firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)); + lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(glIndex_t)); if (r_mergeMultidraws->integer) { @@ -574,15 +566,15 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex RB_SurfaceTriangles ============= */ -static void RB_SurfaceTriangles( srfTriangles_t *srf ) { - if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, +static void RB_SurfaceTriangles( srfBspSurface_t *srf ) { + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } - RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles, - srf->triangles, srf->dlightBits, srf->pshadowBits); + RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, + srf->indexes, srf->dlightBits, srf->pshadowBits); } @@ -1286,6 +1278,7 @@ static void RB_SurfaceElectricity() //================================================================================ +#if 0 /* ** VectorArrayNormalize * @@ -1341,12 +1334,14 @@ static void VectorArrayNormalize(vec4_t *normals, unsigned int count) #endif } +#endif /* ** LerpMeshVertexes */ +#if 0 #if idppc_altivec static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) { @@ -1476,6 +1471,7 @@ static void LerpMeshVertexes_altivec(md3Surface_t *surf, float backlerp) } } #endif +#endif static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) { @@ -1575,14 +1571,15 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], numVerts); } #endif - float *outXyz, *outNormal; + float *outXyz; + uint32_t *outNormal; mdvVertex_t *newVerts; int vertNum; newVerts = surf->verts + backEnd.currentEntity->e.frame * surf->numVerts; outXyz = tess.xyz[tess.numVertexes]; - outNormal = tess.normal[tess.numVertexes]; + outNormal = &tess.normal[tess.numVertexes]; if (backlerp == 0) { @@ -1592,11 +1589,16 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) { + vec3_t normal; + VectorCopy(newVerts->xyz, outXyz); - VectorCopy(newVerts->normal, outNormal); + VectorCopy(newVerts->normal, normal); + + *outNormal = R_VboPackNormal(normal); + newVerts++; outXyz += 4; - outNormal += 4; + outNormal++; } } else @@ -1611,15 +1613,19 @@ static void LerpMeshVertexes_scalar(mdvSurface_t *surf, float backlerp) for (vertNum=0 ; vertNum < surf->numVerts ; vertNum++) { + vec3_t normal; + VectorLerp(newVerts->xyz, oldVerts->xyz, backlerp, outXyz); - VectorLerp(newVerts->normal, oldVerts->normal, backlerp, outNormal); - //VectorNormalize(outNormal); + VectorLerp(newVerts->normal, oldVerts->normal, backlerp, normal); + VectorNormalize(normal); + + *outNormal = R_VboPackNormal(normal); + newVerts++; oldVerts++; outXyz += 4; - outNormal += 4; + outNormal++; } - VectorArrayNormalize((vec4_t *)tess.normal[tess.numVertexes], surf->numVerts); } } @@ -1647,9 +1653,7 @@ RB_SurfaceMesh static void RB_SurfaceMesh(mdvSurface_t *surface) { int j; float backlerp; - srfTriangle_t *triangles; mdvSt_t *texCoords; - int indexes; int Bob, Doug; int numVerts; @@ -1659,20 +1663,16 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) { backlerp = backEnd.currentEntity->e.backlerp; } - RB_CHECKOVERFLOW( surface->numVerts, surface->numTriangles*3 ); + RB_CHECKOVERFLOW( surface->numVerts, surface->numIndexes ); LerpMeshVertexes (surface, backlerp); - triangles = surface->triangles; - indexes = surface->numTriangles * 3; Bob = tess.numIndexes; Doug = tess.numVertexes; - for (j = 0 ; j < surface->numTriangles ; j++) { - tess.indexes[Bob + j*3 + 0] = Doug + triangles[j].indexes[0]; - tess.indexes[Bob + j*3 + 1] = Doug + triangles[j].indexes[1]; - tess.indexes[Bob + j*3 + 2] = Doug + triangles[j].indexes[2]; + for (j = 0 ; j < surface->numIndexes ; j++) { + tess.indexes[Bob + j] = Doug + surface->indexes[j]; } - tess.numIndexes += indexes; + tess.numIndexes += surface->numIndexes; texCoords = surface->st; @@ -1693,15 +1693,15 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) { RB_SurfaceFace ============== */ -static void RB_SurfaceFace( srfSurfaceFace_t *srf ) { - if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, +static void RB_SurfaceFace( srfBspSurface_t *srf ) { + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } - RB_SurfaceVertsAndTris(srf->numVerts, srf->verts, srf->numTriangles, - srf->triangles, srf->dlightBits, srf->pshadowBits); + RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, + srf->indexes, srf->dlightBits, srf->pshadowBits); } @@ -1742,15 +1742,16 @@ RB_SurfaceGrid Just copy the grid of points and triangulate ============= */ -static void RB_SurfaceGrid( srfGridMesh_t *srf ) { +static void RB_SurfaceGrid( srfBspSurface_t *srf ) { int i, j; float *xyz; float *texCoords, *lightCoords; - float *normal; + uint32_t *normal; #ifdef USE_VERT_TANGENT_SPACE - float *tangent, *bitangent; + uint32_t *tangent; #endif - float *color, *lightdir; + float *color; + uint32_t *lightdir; srfVert_t *dv; int rows, irows, vrows; int used; @@ -1763,7 +1764,7 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { int pshadowBits; //int *vDlightBits; - if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numTriangles * 3, + if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; @@ -1833,15 +1834,14 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { numVertexes = tess.numVertexes; xyz = tess.xyz[numVertexes]; - normal = tess.normal[numVertexes]; + normal = &tess.normal[numVertexes]; #ifdef USE_VERT_TANGENT_SPACE - tangent = tess.tangent[numVertexes]; - bitangent = tess.bitangent[numVertexes]; + tangent = &tess.tangent[numVertexes]; #endif texCoords = tess.texCoords[numVertexes][0]; lightCoords = tess.texCoords[numVertexes][1]; color = tess.vertexColors[numVertexes]; - lightdir = tess.lightdir[numVertexes]; + lightdir = &tess.lightdir[numVertexes]; //vDlightBits = &tess.vertexDlightBits[numVertexes]; for ( i = 0 ; i < rows ; i++ ) { @@ -1857,21 +1857,13 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { if ( tess.shader->vertexAttribs & ATTR_NORMAL ) { - VectorCopy(dv->normal, normal); - normal += 4; + *normal++ = R_VboPackNormal(dv->normal); } #ifdef USE_VERT_TANGENT_SPACE if ( tess.shader->vertexAttribs & ATTR_TANGENT ) { - VectorCopy(dv->tangent, tangent); - tangent += 4; - } - - if ( tess.shader->vertexAttribs & ATTR_BITANGENT ) - { - VectorCopy(dv->bitangent, bitangent); - bitangent += 4; + *tangent++ = R_VboPackTangent(dv->tangent); } #endif if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) @@ -1894,8 +1886,7 @@ static void RB_SurfaceGrid( srfGridMesh_t *srf ) { if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) { - VectorCopy(dv->lightdir, lightdir); - lightdir += 4; + *lightdir++ = R_VboPackNormal(dv->lightdir); } //*vDlightBits++ = dlightBits; @@ -2054,7 +2045,7 @@ static void RB_SurfaceFlare(srfFlare_t *surf) RB_AddFlare(surf, tess.fogNum, surf->origin, surf->color, surf->normal); } -static void RB_SurfaceVBOMesh(srfVBOMesh_t * srf) +static void RB_SurfaceVBOMesh(srfBspSurface_t * srf) { RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qfalse ); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 45acc371f6..b22c7a8d5a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -22,6 +22,75 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_vbo.c #include "tr_local.h" + +uint32_t R_VboPackTangent(vec4_t v) +{ + if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) + { + return (((uint32_t)(v[3] * 1.5f + 2.0f )) << 30) + | (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(v[0] * 511.5f + 512.0f))); + } + else + { + return (((uint32_t)(v[3] * 127.5f + 128.0f)) << 24) + | (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16) + | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8) + | (((uint32_t)(v[0] * 127.5f + 128.0f))); + } +} + +uint32_t R_VboPackNormal(vec3_t v) +{ + if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) + { + return (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(v[0] * 511.5f + 512.0f))); + } + else + { + return (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16) + | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8) + | (((uint32_t)(v[0] * 127.5f + 128.0f))); + } +} + +void R_VboUnpackTangent(vec4_t v, uint32_t b) +{ + if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) + { + v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[3] = ((b >> 30) & 0x3) * 1.0f/1.5f - 1.0f; + } + else + { + v[0] = ((b) & 0xff) * 1.0f/127.5f - 1.0f; + v[1] = ((b >> 8) & 0xff) * 1.0f/127.5f - 1.0f; + v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f; + v[3] = ((b >> 24) & 0xff) * 1.0f/127.5f - 1.0f; + } +} + +void R_VboUnpackNormal(vec3_t v, uint32_t b) +{ + if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) + { + v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; + } + else + { + v[0] = ((b) & 0xff) * 1.0f/127.5f - 1.0f; + v[1] = ((b >> 8) & 0xff) * 1.0f/127.5f - 1.0f; + v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f; + } +} + /* ============ R_CreateVBO @@ -142,20 +211,14 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert if(stateBits & ATTR_NORMAL) { vbo->ofs_normal = dataSize; - dataSize += sizeof(verts[0].normal); + dataSize += sizeof(uint32_t); } #ifdef USE_VERT_TANGENT_SPACE if(stateBits & ATTR_TANGENT) { vbo->ofs_tangent = dataSize; - dataSize += sizeof(verts[0].tangent); - } - - if(stateBits & ATTR_BITANGENT) - { - vbo->ofs_bitangent = dataSize; - dataSize += sizeof(verts[0].bitangent); + dataSize += sizeof(uint32_t); } #endif @@ -180,14 +243,13 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert if(stateBits & ATTR_LIGHTDIRECTION) { vbo->ofs_lightdir = dataSize; - dataSize += sizeof(verts[0].lightdir); + dataSize += sizeof(uint32_t); } vbo->stride_xyz = dataSize; vbo->stride_normal = dataSize; #ifdef USE_VERT_TANGENT_SPACE vbo->stride_tangent = dataSize; - vbo->stride_bitangent = dataSize; #endif vbo->stride_st = dataSize; vbo->stride_lightmap = dataSize; @@ -211,23 +273,22 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // normal if(stateBits & ATTR_NORMAL) { - memcpy(data + dataOfs, &verts[i].normal, sizeof(verts[i].normal)); - dataOfs += sizeof(verts[i].normal); + uint32_t *p = (uint32_t *)(data + dataOfs); + + *p = R_VboPackNormal(verts[i].normal); + + dataOfs += sizeof(uint32_t); } #ifdef USE_VERT_TANGENT_SPACE // tangent if(stateBits & ATTR_TANGENT) { - memcpy(data + dataOfs, &verts[i].tangent, sizeof(verts[i].tangent)); - dataOfs += sizeof(verts[i].tangent); - } + uint32_t *p = (uint32_t *)(data + dataOfs); - // bitangent - if(stateBits & ATTR_BITANGENT) - { - memcpy(data + dataOfs, &verts[i].bitangent, sizeof(verts[i].bitangent)); - dataOfs += sizeof(verts[i].bitangent); + *p = R_VboPackTangent(verts[i].tangent); + + dataOfs += sizeof(uint32_t); } #endif @@ -255,8 +316,11 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert // feed vertex light directions if(stateBits & ATTR_LIGHTDIRECTION) { - memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir)); - dataOfs += sizeof(verts[i].lightdir); + uint32_t *p = (uint32_t *)(data + dataOfs); + + *p = R_VboPackNormal(verts[i].lightdir); + + dataOfs += sizeof(uint32_t); } } } @@ -267,18 +331,13 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert if(stateBits & ATTR_NORMAL) { - dataSize += sizeof(verts[0].normal); + dataSize += sizeof(uint32_t); } #ifdef USE_VERT_TANGENT_SPACE if(stateBits & ATTR_TANGENT) { - dataSize += sizeof(verts[0].tangent); - } - - if(stateBits & ATTR_BITANGENT) - { - dataSize += sizeof(verts[0].bitangent); + dataSize += sizeof(uint32_t); } #endif @@ -299,7 +358,7 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert if(stateBits & ATTR_LIGHTDIRECTION) { - dataSize += sizeof(verts[0].lightdir); + dataSize += sizeof(uint32_t); } // create VBO @@ -311,7 +370,6 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->ofs_normal = 0; #ifdef USE_VERT_TANGENT_SPACE vbo->ofs_tangent = 0; - vbo->ofs_bitangent = 0; #endif vbo->ofs_st = 0; vbo->ofs_lightmap = 0; @@ -319,15 +377,14 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->ofs_lightdir = 0; vbo->stride_xyz = sizeof(verts[0].xyz); - vbo->stride_normal = sizeof(verts[0].normal); + vbo->stride_normal = sizeof(uint32_t); #ifdef USE_VERT_TANGENT_SPACE - vbo->stride_tangent = sizeof(verts[0].tangent); - vbo->stride_bitangent = sizeof(verts[0].bitangent); + vbo->stride_tangent = sizeof(uint32_t); #endif vbo->stride_vertexcolor = sizeof(verts[0].vertexColors); vbo->stride_st = sizeof(verts[0].st); vbo->stride_lightmap = sizeof(verts[0].lightmap); - vbo->stride_lightdir = sizeof(verts[0].lightdir); + vbo->stride_lightdir = sizeof(uint32_t); //ri->Printf(PRINT_ALL, "2CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); @@ -345,8 +402,11 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->ofs_normal = dataOfs; for (i = 0; i < numVertexes; i++) { - memcpy(data + dataOfs, &verts[i].normal, sizeof(verts[i].normal)); - dataOfs += sizeof(verts[i].normal); + uint32_t *p = (uint32_t *)(data + dataOfs); + + *p = R_VboPackNormal(verts[i].normal); + + dataOfs += sizeof(uint32_t); } } @@ -357,19 +417,11 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->ofs_tangent = dataOfs; for (i = 0; i < numVertexes; i++) { - memcpy(data + dataOfs, &verts[i].tangent, sizeof(verts[i].tangent)); - dataOfs += sizeof(verts[i].tangent); - } - } + uint32_t *p = (uint32_t *)(data + dataOfs); - // bitangent - if(stateBits & ATTR_BITANGENT) - { - vbo->ofs_bitangent = dataOfs; - for (i = 0; i < numVertexes; i++) - { - memcpy(data + dataOfs, &verts[i].bitangent, sizeof(verts[i].bitangent)); - dataOfs += sizeof(verts[i].bitangent); + *p = R_VboPackTangent(verts[i].tangent); + + dataOfs += sizeof(uint32_t); } } #endif @@ -413,8 +465,11 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert vbo->ofs_lightdir = dataOfs; for (i = 0; i < numVertexes; i++) { - memcpy(data + dataOfs, &verts[i].lightdir, sizeof(verts[i].lightdir)); - dataOfs += sizeof(verts[i].lightdir); + uint32_t *p = (uint32_t *)(data + dataOfs); + + *p = R_VboPackNormal(verts[i].lightdir); + + dataOfs += sizeof(uint32_t); } } } @@ -501,17 +556,14 @@ IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, v R_CreateIBO2 ============ */ -IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * triangles, vboUsage_t usage) +IBO_t *R_CreateIBO2(const char *name, int numIndexes, glIndex_t * inIndexes, vboUsage_t usage) { IBO_t *ibo; - int i, j; + int i; - byte *indexes; + glIndex_t *indexes; int indexesSize; - int indexesOfs; - srfTriangle_t *tri; - glIndex_t index; int glUsage; switch (usage) @@ -529,7 +581,7 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * return NULL; } - if(!numTriangles) + if(!numIndexes) return NULL; if(strlen(name) >= MAX_QPATH) @@ -548,18 +600,12 @@ IBO_t *R_CreateIBO2(const char *name, int numTriangles, srfTriangle_t * Q_strncpyz(ibo->name, name, sizeof(ibo->name)); - indexesSize = numTriangles * 3 * sizeof(int); - indexes = (byte *)ri->Hunk_AllocateTempMemory(indexesSize); - indexesOfs = 0; + indexesSize = numIndexes * sizeof(glIndex_t); + indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(indexesSize); - for(i = 0, tri = triangles; i < numTriangles; i++, tri++) + for(i = 0; i < numIndexes; i++) { - for(j = 0; j < 3; j++) - { - index = tri->indexes[j]; - memcpy(indexes + indexesOfs, &index, sizeof(glIndex_t)); - indexesOfs += sizeof(glIndex_t); - } + indexes[i] = inIndexes[i]; } ibo->indexesSize = indexesSize; @@ -701,7 +747,6 @@ void R_InitVBOs(void) dataSize += sizeof(tess.normal[0]); #ifdef USE_VERT_TANGENT_SPACE dataSize += sizeof(tess.tangent[0]); - dataSize += sizeof(tess.bitangent[0]); #endif dataSize += sizeof(tess.vertexColors[0]); dataSize += sizeof(tess.texCoords[0][0]) * 2; @@ -716,7 +761,6 @@ void R_InitVBOs(void) tess.vbo->ofs_normal = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; #ifdef USE_VERT_TANGENT_SPACE tess.vbo->ofs_tangent = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; - tess.vbo->ofs_bitangent = offset; offset += sizeof(tess.bitangent[0]) * SHADER_MAX_VERTEXES; #endif // these next two are actually interleaved tess.vbo->ofs_st = offset; @@ -730,7 +774,6 @@ void R_InitVBOs(void) tess.vbo->stride_normal = sizeof(tess.normal[0]); #ifdef USE_VERT_TANGENT_SPACE tess.vbo->stride_tangent = sizeof(tess.tangent[0]); - tess.vbo->stride_bitangent = sizeof(tess.bitangent[0]); #endif tess.vbo->stride_vertexcolor = sizeof(tess.vertexColors[0]); tess.vbo->stride_st = sizeof(tess.texCoords[0][0]) * 2; @@ -888,12 +931,6 @@ void RB_UpdateVBOs(unsigned int attribBits) //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); } - - if(attribBits & ATTR_BITANGENT) - { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0]), tess.bitangent); - } #endif if(attribBits & ATTR_COLOR) @@ -915,7 +952,6 @@ void RB_UpdateVBOs(unsigned int attribBits) qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); #ifdef USE_VERT_TANGENT_SPACE qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_bitangent, tess.numVertexes * sizeof(tess.bitangent[0]), tess.bitangent); #endif qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 715717ba45..af5b8b05a0 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -208,16 +208,18 @@ static int R_DlightSurface( msurface_t *surf, int dlightBits ) { } } - if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->dlightBits = dlightBits; - } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->dlightBits = dlightBits; - } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->dlightBits = dlightBits; - } else if ( *surf->data == SF_VBO_MESH ) { - ((srfVBOMesh_t *)surf->data)->dlightBits = dlightBits; - } else { - dlightBits = 0; + switch(*surf->data) + { + case SF_FACE: + case SF_GRID: + case SF_TRIANGLES: + case SF_VBO_MESH: + ((srfBspSurface_t *)surf->data)->dlightBits = dlightBits; + break; + + default: + dlightBits = 0; + break; } if ( dlightBits ) { @@ -292,16 +294,18 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { } } - if ( *surf->data == SF_FACE ) { - ((srfSurfaceFace_t *)surf->data)->pshadowBits = pshadowBits; - } else if ( *surf->data == SF_GRID ) { - ((srfGridMesh_t *)surf->data)->pshadowBits = pshadowBits; - } else if ( *surf->data == SF_TRIANGLES ) { - ((srfTriangles_t *)surf->data)->pshadowBits = pshadowBits; - } else if ( *surf->data == SF_VBO_MESH ) { - ((srfVBOMesh_t *)surf->data)->pshadowBits = pshadowBits; - } else { - pshadowBits = 0; + switch(*surf->data) + { + case SF_FACE: + case SF_GRID: + case SF_TRIANGLES: + case SF_VBO_MESH: + ((srfBspSurface_t *)surf->data)->pshadowBits = pshadowBits; + break; + + default: + pshadowBits = 0; + break; } if ( pshadowBits ) { From 1ae10e9ebea37555373105784bb57a225003b0d0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 14 Dec 2013 13:54:37 -0600 Subject: [PATCH 133/708] [MP] Rend2: Fix md3 models. --- codemp/rd-rend2/tr_model.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 90c291c853..57abc33b42 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -981,7 +981,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN } // swap all the triangles - surf->numIndexes = md3Surf->numTriangles; + surf->numIndexes = md3Surf->numTriangles * 3; surf->indexes = tri = (glIndex_t *)ri->Hunk_Alloc(sizeof(*tri) * 3 * md3Surf->numTriangles, h_low); md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); From 7ad7620907b8ed3aa4591d95601899831ff4c395 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 14 Dec 2013 21:05:38 +0000 Subject: [PATCH 134/708] [Rend2] Fixed remaining bugs from previous commits This includes fixing the loading and rendering of Ghoul2 models, as well as a crash on map-load. --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 6 ++-- codemp/rd-rend2/glsl/generic_vp.glsl | 4 +-- codemp/rd-rend2/glsl/lightall_vp.glsl | 14 +++++++--- codemp/rd-rend2/tr_bsp.cpp | 6 ++-- codemp/rd-rend2/tr_ghoul2.cpp | 40 +++++++++++++-------------- codemp/rd-rend2/tr_mesh.cpp | 2 +- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index 2d5a2c5de1..b3421f5669 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -109,10 +109,10 @@ void main() vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) - vec3 position4 = vec4(0.0); + vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal, 0.0); + vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); for (int i = 0; i < 4; i++) { @@ -123,7 +123,7 @@ void main() } vec3 position = position4.xyz; - vec3 normal = normalize(normal4.xyz - vec3(0.5)); + vec3 normal = normalize(normal4.xyz); #else vec3 position = attr_Position; vec3 normal = attr_Normal * 2.0 - vec3(1.0); diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 61d92b1002..df690c5753 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -217,7 +217,7 @@ void main() vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal, 0.0); + vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); for (int i = 0; i < 4; i++) { @@ -228,7 +228,7 @@ void main() } vec3 position = position4.xyz; - vec3 normal = normalize(normal4.xyz - vec3(0.5)); + vec3 normal = normalize(normal4.xyz); #else vec3 position = attr_Position; vec3 normal = attr_Normal * 2.0 - vec3(1.0); diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 31f1a10e69..3d8d96cd47 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -171,10 +171,12 @@ void main() #elif defined(USE_SKELETAL_ANIMATION) vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); - vec4 tangent4 = vec4(0.0); vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal, 0.0); - vec4 originalTangent = vec4(attr_Tangent, 0.0); + vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec4 tangent4 = vec4(0.0); + vec4 originalTangent = vec4(attr_Tangent.xyz, 0.0); +#endif for (int i = 0; i < 4; i++) { @@ -182,12 +184,16 @@ void main() position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) tangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i]; +#endif } vec3 position = position4.xyz; - vec3 normal = normal4.xyz; + vec3 normal = normalize (normal4.xyz); +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) vec3 tangent = tangent4.xyz; +#endif #else vec3 position = attr_Position; vec3 normal = attr_Normal; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index cabf35b919..874be836a2 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3387,9 +3387,6 @@ void RE_LoadWorldMap( const char *name ) { R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); - // determine vertex light directions - R_CalcVertexLightDirs(); - // determine which parts of the map are in sunlight #if 0 if (0) @@ -3608,6 +3605,9 @@ void RE_LoadWorldMap( const char *name ) { // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; + // determine vertex light directions + R_CalcVertexLightDirs(); + // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 179ffe0b28..9bc61f8869 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4438,12 +4438,12 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean mdxmVBOMesh_t *vboMeshes; vec3_t *verts; - vec3_t *normals; + uint32_t *normals; vec2_t *texcoords; vec4_t *bonerefs; vec4_t *weights; #ifdef USE_VERT_TANGENT_SPACE - vec3_t *tangents; + uint32_t *tangents; #endif byte *data; @@ -4496,7 +4496,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean ofsPosition = stride; stride += sizeof (*verts); - normals = (vec3_t *)(data + stride); + normals = (uint32_t *)(data + stride); ofsNormals = stride; stride += sizeof (*normals); @@ -4513,7 +4513,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean stride += sizeof (*weights); #ifdef USE_VERT_TANGENT_SPACE - tangents = (vec3_t *)(data + stride); + tangents = (uint32_t *)(data + stride); ofs_tangent = stride; stride += sizeof (*tangents); #endif @@ -4527,15 +4527,15 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean for ( int k = 0; k < surf->numVerts; k++ ) { VectorCopy (v[k].vertCoords, *verts); - VectorCopy (v[k].normal, *normals); + *normals = R_VboPackNormal (v[k].normal); #ifdef USE_VERT_TANGENT_SPACE - VectorCopy (v[k].normal, *tangents); + *tangents = R_VboPackNormal (v[k].normal); #endif verts = (vec3_t *)((byte *)verts + stride); - normals = (vec3_t *)((byte *)normals + stride); + normals = (uint32_t *)((byte *)normals + stride); #ifdef USE_VERT_TANGENT_SPACE - tangents = (vec3_t *)((byte *)tangents + stride); + tangents = (uint32_t *)((byte *)tangents + stride); #endif } @@ -4604,8 +4604,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean #endif // Fill in the index buffer - srfTriangle_t *triangles = (srfTriangle_t *)ri->Hunk_AllocateTempMemory (sizeof (srfTriangle_t) * numTriangles); - srfTriangle_t *triangle = triangles; + glIndex_t *indices = (glIndex_t *)ri->Hunk_AllocateTempMemory (sizeof (glIndex_t) * numTriangles * 3); + glIndex_t *index = indices; surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4613,26 +4613,26 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean { mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); - for ( int k = 0; k < surf->numTriangles; k++, triangle++ ) + for ( int k = 0; k < surf->numTriangles; k++, index += 3 ) { - triangle->indexes[0] = t[k].indexes[0] + baseVertexes[n]; - assert (triangle->indexes[0] >= 0 && triangle->indexes[0] < numVerts); + index[0] = t[k].indexes[0] + baseVertexes[n]; + assert (index[0] >= 0 && index[0] < numVerts); - triangle->indexes[1] = t[k].indexes[1] + baseVertexes[n]; - assert (triangle->indexes[1] >= 0 && triangle->indexes[1] < numVerts); + index[1] = t[k].indexes[1] + baseVertexes[n]; + assert (index[1] >= 0 && index[1] < numVerts); - triangle->indexes[2] = t[k].indexes[2] + baseVertexes[n]; - assert (triangle->indexes[2] >= 0 && triangle->indexes[2] < numVerts); + index[2] = t[k].indexes[2] + baseVertexes[n]; + assert (index[2] >= 0 && index[2] < numVerts); } surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } - assert (triangle == (triangles + numTriangles)); + assert (index == (indices + numTriangles * 3)); - IBO_t *ibo = R_CreateIBO2 (va ("MDXM IBO LOD %d '%s'", l, modelName), numTriangles, triangles, VBO_USAGE_STATIC); + IBO_t *ibo = R_CreateIBO2 (va ("MDXM IBO LOD %d '%s'", l, modelName), numTriangles * 3, indices, VBO_USAGE_STATIC); - ri->Hunk_FreeTempMemory (triangles); + ri->Hunk_FreeTempMemory (indices); surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index d1beed78d9..7bfc299bda 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -static float ProjectRadius( float r, vec3_t location ) +float ProjectRadius( float r, vec3_t location ) { float pr; float dist; From 4140e0a998c3d32212fb265839d2c7a76bf4ff99 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 14 Dec 2013 21:15:14 +0000 Subject: [PATCH 135/708] [Rend2] Correctly fixed map crash --- codemp/rd-rend2/tr_bsp.cpp | 8 ++++---- codemp/rd-rend2/tr_light.cpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 874be836a2..1c0aa139bb 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3271,7 +3271,7 @@ void R_MergeLeafSurfaces(void) } -void R_CalcVertexLightDirs( void ) +static void R_CalcVertexLightDirs( void ) { int i, k; msurface_t *surface; @@ -3386,6 +3386,9 @@ void RE_LoadWorldMap( const char *name ) { R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); + + // determine vertex light directions + R_CalcVertexLightDirs(); // determine which parts of the map are in sunlight #if 0 @@ -3605,9 +3608,6 @@ void RE_LoadWorldMap( const char *name ) { // only set tr.world now that we know the entire level has loaded properly tr.world = &s_worldData; - // determine vertex light directions - R_CalcVertexLightDirs(); - // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 70fb5d5b6d..aec66a1280 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -171,7 +171,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { gridStep[0] = 1; gridStep[1] = 1 * world->lightGridBounds[0]; gridStep[2] = 1 * world->lightGridBounds[0] * world->lightGridBounds[1]; - startGridPos = tr.world->lightGridArray + (pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2]); + startGridPos = world->lightGridArray + (pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2]); totalFactor = 0; for ( i = 0 ; i < 8 ; i++ ) { @@ -197,12 +197,12 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { } } - if (gridPos >= tr.world->lightGridArray + tr.world->numGridArrayElements) + if (gridPos >= world->lightGridArray + world->numGridArrayElements) {//we've gone off the array somehow continue; } - data = tr.world->lightGridData + *gridPos; + data = world->lightGridData + *gridPos; if ( data->styles[0] == LS_LSNONE ) { continue; // ignore samples in walls From 1fb52f2bcc837d070ad6d915988ec48dd18c375d Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 14 Dec 2013 15:44:02 -0600 Subject: [PATCH 136/708] [MP] Rend2: Some static functions, and use of const for R_LoadCubemapEntities. --- codemp/rd-rend2/tr_bsp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 1c0aa139bb..3bd55f7bb9 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2760,7 +2760,7 @@ qboolean R_GetEntityToken( char *buffer, int size ) { #endif // derived from G_ParseSpawnVars() in g_spawn.c -qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSpawnVars, char *spawnVars[MAX_SPAWN_VARS][2] ) +static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSpawnVars, char *spawnVars[MAX_SPAWN_VARS][2] ) { char keyname[MAX_TOKEN_CHARS]; char com_token[MAX_TOKEN_CHARS]; @@ -2829,7 +2829,7 @@ qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int *numSp return qtrue; } -void R_LoadCubemapEntities(char *cubemapEntityName) +static void R_LoadCubemapEntities(const char *cubemapEntityName) { char spawnVarChars[2048]; int numSpawnVars; @@ -2885,7 +2885,7 @@ void R_LoadCubemapEntities(char *cubemapEntityName) } } -void R_AssignCubemapsToWorldSurfaces(void) +static void R_AssignCubemapsToWorldSurfaces(void) { world_t *w; int i; @@ -2919,7 +2919,7 @@ void R_AssignCubemapsToWorldSurfaces(void) } -void R_RenderAllCubemaps(void) +static void R_RenderAllCubemaps(void) { int i, j; From afc49e5053259dcc51beaf436e1408b1aafeb32e Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 15 Dec 2013 22:53:07 -0600 Subject: [PATCH 137/708] [MP] Rend2: Removed unnecessary glsl_stringify.vbs and makeglsl.bat files. Replaced by CMake pre-build step that has been added in a previous commit. --- codemp/rd-rend2/glsl/glsl_stringify.vbs | 18 ---------------- codemp/rd-rend2/glsl/makeglsl.bat | 28 ------------------------- 2 files changed, 46 deletions(-) delete mode 100644 codemp/rd-rend2/glsl/glsl_stringify.vbs delete mode 100644 codemp/rd-rend2/glsl/makeglsl.bat diff --git a/codemp/rd-rend2/glsl/glsl_stringify.vbs b/codemp/rd-rend2/glsl/glsl_stringify.vbs deleted file mode 100644 index 34e4955320..0000000000 --- a/codemp/rd-rend2/glsl/glsl_stringify.vbs +++ /dev/null @@ -1,18 +0,0 @@ -Dim fso, infile, outfile, line -Set fso = CreateObject("Scripting.FileSystemObject") -Set infile = fso.OpenTextFile(WScript.Arguments(0)) -Set outfile = fso.CreateTextFile(WScript.Arguments(1), True) - -outfile.WriteLine("const char *fallbackShader_" & fso.GetBaseName(WScript.Arguments(0)) & " =") -While Not infile.AtEndOfStream - line = infile.ReadLine - line = Replace(line, "\", "\\") - line = Replace(line, Chr(9), "\t") - line = Replace(line, Chr(34), "\" & chr(34)) - line = Chr(34) & line & "\n" & Chr(34) - outfile.WriteLine(line) -Wend -outfile.WriteLine(";") - -infile.Close -outfile.Close \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/makeglsl.bat b/codemp/rd-rend2/glsl/makeglsl.bat deleted file mode 100644 index feee6fffa2..0000000000 --- a/codemp/rd-rend2/glsl/makeglsl.bat +++ /dev/null @@ -1,28 +0,0 @@ -glsl_stringify.vbs bokeh_fp.glsl 1.cpp -glsl_stringify.vbs bokeh_vp.glsl 2.cpp -glsl_stringify.vbs calclevels4x_fp.glsl 3.cpp -glsl_stringify.vbs calclevels4x_vp.glsl 4.cpp -glsl_stringify.vbs depthblur_fp.glsl 5.cpp -glsl_stringify.vbs depthblur_vp.glsl 6.cpp -glsl_stringify.vbs dlight_fp.glsl 7.cpp -glsl_stringify.vbs dlight_vp.glsl 8.cpp -glsl_stringify.vbs down4x_fp.glsl 9.cpp -glsl_stringify.vbs down4x_vp.glsl 10.cpp -glsl_stringify.vbs fogpass_fp.glsl 11.cpp -glsl_stringify.vbs fogpass_vp.glsl 12.cpp -glsl_stringify.vbs generic_fp.glsl 13.cpp -glsl_stringify.vbs generic_vp.glsl 14.cpp -glsl_stringify.vbs lightall_fp.glsl 15.cpp -glsl_stringify.vbs lightall_vp.glsl 16.cpp -glsl_stringify.vbs pshadow_fp.glsl 17.cpp -glsl_stringify.vbs pshadow_vp.glsl 18.cpp -glsl_stringify.vbs shadowfill_fp.glsl 19.cpp -glsl_stringify.vbs shadowfill_vp.glsl 20.cpp -glsl_stringify.vbs shadowmask_fp.glsl 21.cpp -glsl_stringify.vbs shadowmask_vp.glsl 22.cpp -glsl_stringify.vbs ssao_fp.glsl 23.cpp -glsl_stringify.vbs ssao_vp.glsl 24.cpp -glsl_stringify.vbs texturecolor_fp.glsl 25.cpp -glsl_stringify.vbs texturecolor_vp.glsl 26.cpp -glsl_stringify.vbs tonemap_fp.glsl 27.cpp -glsl_stringify.vbs tonemap_vp.glsl 28.cpp \ No newline at end of file From 7aba271df9b0f7c5142d34ab8682a61a12fb9466 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 15 Dec 2013 23:01:56 -0600 Subject: [PATCH 138/708] [MP] Rend2: Remove unused rd-rend2/glsl_shaders.cpp --- codemp/rd-rend2/glsl_shaders.cpp | 2239 ------------------------------ 1 file changed, 2239 deletions(-) delete mode 100644 codemp/rd-rend2/glsl_shaders.cpp diff --git a/codemp/rd-rend2/glsl_shaders.cpp b/codemp/rd-rend2/glsl_shaders.cpp deleted file mode 100644 index 8d4f86a8f1..0000000000 --- a/codemp/rd-rend2/glsl_shaders.cpp +++ /dev/null @@ -1,2239 +0,0 @@ -#include "tr_local.h" - -const char *fallbackShader_bokeh_fp = -"uniform sampler2D u_TextureMap;\n" -"\n" -"uniform vec4 u_Color;\n" -"\n" -"uniform vec2 u_InvTexRes;\n" -"varying vec2 var_TexCoords;\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 color;\n" -"\tvec2 tc;\n" -"\n" -"#if 0\n" -"\tfloat c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture2D(u_TextureMap, tc);\n" -"\t\n" -"\tgl_FragColor = color * 0.04166667 * u_Color;\n" -"#endif\n" -"\n" -"\tfloat c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture2D(u_TextureMap, tc);\n" -"\t\n" -"\tgl_FragColor = color * 0.0625 * u_Color;\n" -"}\n" -; -const char *fallbackShader_bokeh_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_TexCoords;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" -"\tvar_TexCoords = attr_TexCoord0.st;\n" -"}\n" -; -const char *fallbackShader_calclevels4x_fp = -"uniform sampler2D u_TextureMap;\n" -"\n" -"uniform vec4 u_Color;\n" -"\n" -"uniform vec2 u_InvTexRes;\n" -"varying vec2 var_TexCoords;\n" -"\n" -"const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114);\n" -"\n" -"vec3 GetValues(vec2 offset, vec3 current)\n" -"{\n" -"\tvec3 minAvgMax;\n" -"\tvec2 tc = var_TexCoords + u_InvTexRes * offset; minAvgMax = texture2D(u_TextureMap, tc).rgb;\n" -"\n" -"#ifdef FIRST_PASS\n" -"\tfloat lumi = max(dot(LUMINANCE_VECTOR, minAvgMax), 0.000001);\n" -"\tfloat loglumi = clamp(log2(lumi), -10.0, 10.0);\n" -"\tminAvgMax = vec3(loglumi * 0.05 + 0.5);\n" -"#endif\n" -"\n" -"\treturn vec3(min(current.x, minAvgMax.x), current.y + minAvgMax.y, max(current.z, minAvgMax.z));\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tvec3 current = vec3(1.0, 0.0, 0.0);\n" -"\n" -"#ifdef FIRST_PASS\n" -"\tcurrent = GetValues(vec2( 0.0, 0.0), current);\n" -"#else\n" -"\tcurrent = GetValues(vec2(-1.5, -1.5), current);\n" -"\tcurrent = GetValues(vec2(-0.5, -1.5), current);\n" -"\tcurrent = GetValues(vec2( 0.5, -1.5), current);\n" -"\tcurrent = GetValues(vec2( 1.5, -1.5), current);\n" -"\t\n" -"\tcurrent = GetValues(vec2(-1.5, -0.5), current);\n" -"\tcurrent = GetValues(vec2(-0.5, -0.5), current);\n" -"\tcurrent = GetValues(vec2( 0.5, -0.5), current);\n" -"\tcurrent = GetValues(vec2( 1.5, -0.5), current);\n" -"\t\n" -"\tcurrent = GetValues(vec2(-1.5, 0.5), current);\n" -"\tcurrent = GetValues(vec2(-0.5, 0.5), current);\n" -"\tcurrent = GetValues(vec2( 0.5, 0.5), current);\n" -"\tcurrent = GetValues(vec2( 1.5, 0.5), current);\n" -"\n" -"\tcurrent = GetValues(vec2(-1.5, 1.5), current);\n" -"\tcurrent = GetValues(vec2(-0.5, 1.5), current);\n" -"\tcurrent = GetValues(vec2( 0.5, 1.5), current);\n" -"\tcurrent = GetValues(vec2( 1.5, 1.5), current);\n" -"\n" -"\tcurrent.y *= 0.0625;\n" -"#endif\n" -"\n" -"\tgl_FragColor = vec4(current, 1.0f);\n" -"}\n" -; -const char *fallbackShader_calclevels4x_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_TexCoords;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" -"\tvar_TexCoords = attr_TexCoord0.st;\n" -"}\n" -; -const char *fallbackShader_depthblur_fp = -"uniform sampler2D u_ScreenImageMap;\n" -"uniform sampler2D u_ScreenDepthMap;\n" -"\n" -"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" -"varying vec2 var_ScreenTex;\n" -"\n" -"//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033);\n" -"float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044);\n" -"//float gauss[3] = float[3](0.60, 0.19, 0.0066);\n" -"#define GAUSS_SIZE 4\n" -"\n" -"float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)\n" -"{\n" -"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" -"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" -"}\n" -"\n" -"vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFarDivZNear, float zFar)\n" -"{\n" -"\tfloat scale = 1.0 / 256.0;\n" -"\n" -"#if defined(USE_HORIZONTAL_BLUR)\n" -" vec2 direction = vec2(1.0, 0.0) * scale;\n" -"#else // if defined(USE_VERTICAL_BLUR)\n" -"\tvec2 direction = vec2(0.0, 1.0) * scale;\n" -"#endif\n" -"\t\n" -"\tfloat depthCenter = zFar * getLinearDepth(depthMap, tex, zFarDivZNear);\n" -"\tvec2 centerSlope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y));\n" -"\t\t\n" -"\tvec4 result = texture2D(imageMap, tex) * gauss[0];\n" -"\tfloat total = gauss[0];\n" -"\n" -"\tint i, j;\n" -"\tfor (i = 0; i < 2; i++)\n" -"\t{\n" -"\t\tfor (j = 1; j < GAUSS_SIZE; j++)\n" -"\t\t{\n" -"\t\t\tvec2 offset = direction * j;\n" -"\t\t\tfloat depthSample = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear);\n" -"\t\t\tfloat depthExpected = depthCenter + dot(centerSlope, offset);\n" -"\t\t\tif(abs(depthSample - depthExpected) < 5.0)\n" -"\t\t\t{\n" -"\t\t\t\tresult += texture2D(imageMap, tex + offset) * gauss[j];\n" -"\t\t\t\ttotal += gauss[j];\n" -"\t\t\t}\n" -"\t\t}\n" -"\t\t\n" -"\t\tdirection = -direction;\n" -"\t}\t\n" -"\t\t\n" -"\treturn result / total;\n" -"}\n" -"\n" -"void main()\n" -"{\t\t\n" -"\tgl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y);\n" -"}\n" -; -const char *fallbackShader_depthblur_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"varying vec2 var_ScreenTex;\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = attr_Position;\n" -"\tvar_ScreenTex = attr_TexCoord0.xy;\n" -"\t//vec2 screenCoords = gl_Position.xy / gl_Position.w;\n" -"\t//var_ScreenTex = screenCoords * 0.5 + 0.5;\n" -"}\n" -; -const char *fallbackShader_dlight_fp = -"uniform sampler2D u_DiffuseMap;\n" -"\n" -"varying vec2 var_Tex1;\n" -"varying vec4 var_Color;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 color = texture2D(u_DiffuseMap, var_Tex1);\n" -"\n" -"\tgl_FragColor = color * var_Color;\n" -"}\n" -; -const char *fallbackShader_dlight_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"attribute vec3 attr_Normal;\n" -"\n" -"uniform vec4 u_DlightInfo;\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"uniform int u_DeformGen;\n" -"uniform float u_DeformParams[5];\n" -"uniform float u_Time;\n" -"#endif\n" -"\n" -"uniform vec4 u_Color;\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_Tex1;\n" -"varying vec4 var_Color;\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" -"{\n" -"\tif (u_DeformGen == 0)\n" -"\t{\n" -"\t\treturn pos;\n" -"\t}\n" -"\n" -"\tfloat base = u_DeformParams[0];\n" -"\tfloat amplitude = u_DeformParams[1];\n" -"\tfloat phase = u_DeformParams[2];\n" -"\tfloat frequency = u_DeformParams[3];\n" -"\tfloat spread = u_DeformParams[4];\n" -"\n" -"\tif (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tphase *= st.x;\n" -"\t}\n" -"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tphase += dot(pos.xyz, vec3(spread));\n" -"\t}\n" -"\n" -"\tfloat value = phase + (u_Time * frequency);\n" -"\tfloat func;\n" -"\n" -"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" -"\t{\n" -"\t\tfunc = sin(value * 2.0 * M_PI);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" -"\t{\n" -"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" -"\t{\n" -"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = fract(value);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = (1.0 - fract(value));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tfunc = sin(value);\n" -"\t}\n" -"\n" -"\treturn pos + normal * (base + func * amplitude);\n" -"}\n" -"#endif\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 position = attr_Position;\n" -"\tvec3 normal = attr_Normal;\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" -"#endif\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\t\t\n" -"\tvec3 dist = u_DlightInfo.xyz - position.xyz;\t\n" -"\n" -"\tvar_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5);\n" -"\tfloat dlightmod = step(0.0, dot(dist, normal));\n" -"\tdlightmod *= clamp(2.0 * (1.0 - abs(dist.z) * u_DlightInfo.a), 0.0, 1.0);\n" -"\t\n" -"\tvar_Color = u_Color * dlightmod;\n" -"}\n" -; -const char *fallbackShader_down4x_fp = -"uniform sampler2D u_TextureMap;\n" -"\n" -"uniform vec2 u_InvTexRes;\n" -"varying vec2 var_TexCoords;\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 color;\n" -"\tvec2 tc;\n" -"\t\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture2D(u_TextureMap, tc);\n" -"\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture2D(u_TextureMap, tc);\n" -"\ttc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture2D(u_TextureMap, tc);\n" -"\t\n" -"\tcolor *= 0.0625;\n" -"\t\n" -"\tgl_FragColor = color;\n" -"}\n" -; -const char *fallbackShader_down4x_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_TexCoords;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" -"\tvar_TexCoords = attr_TexCoord0.st;\n" -"}\n" -; -const char *fallbackShader_fogpass_fp = -"uniform vec4 u_Color;\n" -"\n" -"varying float var_Scale;\n" -"\n" -"void main()\n" -"{\n" -"\tgl_FragColor = u_Color;\n" -"\tgl_FragColor.a *= sqrt(clamp(var_Scale, 0.0, 1.0));\n" -"}\n" -; -const char *fallbackShader_fogpass_vp = -"attribute vec4 attr_Position;\n" -"attribute vec3 attr_Normal;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"attribute vec4 attr_Position2;\n" -"attribute vec3 attr_Normal2;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"attribute vec4 attr_BoneIndexes;\n" -"attribute vec4 attr_BoneWeights;\n" -"#endif\n" -"\n" -"uniform vec4 u_FogDistance;\n" -"uniform vec4 u_FogDepth;\n" -"uniform float u_FogEyeT;\n" -"\n" -"//#if defined(USE_DEFORM_VERTEXES)\n" -"uniform int u_DeformGen;\n" -"uniform float u_DeformParams[5];\n" -"//#endif\n" -"\n" -"uniform float u_Time;\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"uniform float u_VertexLerp;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"uniform mat4 u_BoneMatrices[80];\n" -"#endif\n" -"\n" -"varying float var_Scale;\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" -"{\n" -"\tif (u_DeformGen == 0)\n" -"\t{\n" -"\t\treturn pos;\n" -"\t}\n" -"\n" -"\tfloat base = u_DeformParams[0];\n" -"\tfloat amplitude = u_DeformParams[1];\n" -"\tfloat phase = u_DeformParams[2];\n" -"\tfloat frequency = u_DeformParams[3];\n" -"\tfloat spread = u_DeformParams[4];\n" -"\n" -"\tif (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tphase *= st.x;\n" -"\t}\n" -"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tphase += dot(pos.xyz, vec3(spread));\n" -"\t}\n" -"\n" -"\tfloat value = phase + (u_Time * frequency);\n" -"\tfloat func;\n" -"\n" -"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" -"\t{\n" -"\t\tfunc = sin(value * 2.0 * M_PI);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" -"\t{\n" -"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" -"\t{\n" -"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = fract(value);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = (1.0 - fract(value));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tfunc = sin(value);\n" -"\t}\n" -"\n" -"\treturn pos + normal * (base + func * amplitude);\n" -"}\n" -"#endif\n" -"\n" -"float CalcFog(vec4 position)\n" -"{\n" -"\tfloat s = dot(position, u_FogDistance) * 8.0;\n" -"\tfloat t = dot(position, u_FogDepth);\n" -"\n" -"\tfloat eyeOutside = step(0.0, -u_FogEyeT);\n" -"\tfloat fogged = step(eyeOutside, t);\n" -"\t\t\n" -"\tt = max(t, 1e-6);\n" -"\tt *= fogged / (t - u_FogEyeT * eyeOutside);\n" -"\n" -"\treturn s * t;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" -"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"\tvec4 position = vec4(0.0);\n" -"\tvec4 normal4 = vec4(0.0);\n" -"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" -"\tfor (int i = 0; i < 4; i++) {\n" -"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" -"\n" -"\t\tposition += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i];\n" -"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" -"\t}\n" -"\tvec3 normal = normal4.xyz;\n" -"#else\n" -"\tvec4 position = attr_Position;\n" -"\tvec3 normal = attr_Normal;\n" -"#endif\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" -"#endif\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\n" -"\tvar_Scale = CalcFog(position);\n" -"}\n" -; -const char *fallbackShader_generic_fp = -"uniform sampler2D u_DiffuseMap;\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"uniform sampler2D u_LightMap;\n" -"\n" -"uniform int u_Texture1Env;\n" -"#endif\n" -"\n" -"varying vec2 var_DiffuseTex;\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"varying vec2 var_LightTex;\n" -"#endif\n" -"\n" -"varying vec4 var_Color;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 color = texture2D(u_DiffuseMap, var_DiffuseTex);\n" -"#if defined(USE_LIGHTMAP)\n" -"\tvec4 color2 = texture2D(u_LightMap, var_LightTex);\n" -" #if defined(RGBM_LIGHTMAP)\n" -"\tcolor2.rgb *= 32.0 * color2.a;\n" -"\tcolor2.a = 1.0;\n" -" #endif\n" -"\n" -"\tif (u_Texture1Env == TEXENV_MODULATE)\n" -"\t{\n" -"\t\tcolor *= color2;\n" -"\t}\n" -"\telse if (u_Texture1Env == TEXENV_ADD)\n" -"\t{\n" -"\t\tcolor += color2;\n" -"\t}\n" -"\telse if (u_Texture1Env == TEXENV_REPLACE)\n" -"\t{\n" -"\t\tcolor = color2;\n" -"\t}\n" -"#endif\n" -"\n" -"\tgl_FragColor = color * var_Color;\n" -"}\n" -; -const char *fallbackShader_generic_vp = -"attribute vec4 attr_Position;\n" -"attribute vec3 attr_Normal;\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"attribute vec4 attr_Position2;\n" -"attribute vec3 attr_Normal2;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"attribute vec4 attr_BoneIndexes;\n" -"attribute vec4 attr_BoneWeights;\n" -"#endif\n" -"\n" -"attribute vec4 attr_Color;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)\n" -"attribute vec4 attr_TexCoord1;\n" -"#endif\n" -"\n" -"uniform vec4 u_DiffuseTexMatrix;\n" -"uniform vec4 u_DiffuseTexOffTurb;\n" -"\n" -"#if defined(USE_TCGEN) || defined(USE_RGBAGEN)\n" -"uniform vec3 u_LocalViewOrigin;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN)\n" -"uniform int u_TCGen0;\n" -"uniform vec3 u_TCGen0Vector0;\n" -"uniform vec3 u_TCGen0Vector1;\n" -"#endif\n" -"\n" -"#if defined(USE_FOG)\n" -"uniform vec4 u_FogDistance;\n" -"uniform vec4 u_FogDepth;\n" -"uniform float u_FogEyeT;\n" -"uniform vec4 u_FogColorMask;\n" -"#endif\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"uniform int u_DeformGen;\n" -"uniform float u_DeformParams[5];\n" -"uniform float u_Time;\n" -"#endif\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"uniform vec4 u_BaseColor;\n" -"uniform vec4 u_VertColor;\n" -"\n" -"#if defined(USE_RGBAGEN)\n" -"uniform int u_ColorGen;\n" -"uniform int u_AlphaGen;\n" -"uniform vec3 u_AmbientLight;\n" -"uniform vec3 u_DirectedLight;\n" -"uniform vec3 u_ModelLightDir;\n" -"uniform float u_PortalRange;\n" -"#endif\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"uniform float u_VertexLerp;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"uniform mat4 u_BoneMatrices[80];\n" -"#endif\n" -"\n" -"varying vec2 var_DiffuseTex;\n" -"#if defined(USE_LIGHTMAP)\n" -"varying vec2 var_LightTex;\n" -"#endif\n" -"varying vec4 var_Color;\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" -"{\n" -"\tfloat base = u_DeformParams[0];\n" -"\tfloat amplitude = u_DeformParams[1];\n" -"\tfloat phase = u_DeformParams[2];\n" -"\tfloat frequency = u_DeformParams[3];\n" -"\tfloat spread = u_DeformParams[4];\n" -"\n" -"\tif (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tphase *= st.x;\n" -"\t}\n" -"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tphase += dot(pos.xyz, vec3(spread));\n" -"\t}\n" -"\n" -"\tfloat value = phase + (u_Time * frequency);\n" -"\tfloat func;\n" -"\n" -"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" -"\t{\n" -"\t\tfunc = sin(value * 2.0 * M_PI);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" -"\t{\n" -"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" -"\t{\n" -"\t\tfunc = 1.0 - abs(4.0 * fract(value + 0.25) - 2.0);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = fract(value);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = (1.0 - fract(value));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tfunc = sin(value);\n" -"\t}\n" -"\n" -"\treturn pos + normal * (base + func * amplitude);\n" -"}\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN)\n" -"vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)\n" -"{\n" -"\tvec2 tex = attr_TexCoord0.st;\n" -"\n" -"\tif (TCGen == TCGEN_LIGHTMAP)\n" -"\t{\n" -"\t\ttex = attr_TexCoord1.st;\n" -"\t}\n" -"\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" -"\t{\n" -"\t\tvec3 viewer = normalize(u_LocalViewOrigin - position);\n" -"\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" -"\t}\n" -"\telse if (TCGen == TCGEN_VECTOR)\n" -"\t{\n" -"\t\ttex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));\n" -"\t}\n" -"\t\n" -"\treturn tex;\n" -"}\n" -"#endif\n" -"\n" -"#if defined(USE_TCMOD)\n" -"vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)\n" -"{\n" -"\tfloat amplitude = offTurb.z;\n" -"\tfloat phase = offTurb.w;\n" -"\tvec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy;\n" -"\n" -"\tvec3 offsetPos = position / 1024.0;\n" -"\toffsetPos.x += offsetPos.z;\n" -"\t\n" -"\tvec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI);\n" -"\t\n" -"\treturn st2 + texOffset * amplitude;\t\n" -"}\n" -"#endif\n" -"\n" -"#if defined(USE_RGBAGEN)\n" -"vec4 CalcColor(vec3 position, vec3 normal)\n" -"{\n" -"\tvec4 color = u_VertColor * attr_Color + u_BaseColor;\n" -"\t\n" -"\tif (u_ColorGen == CGEN_LIGHTING_DIFFUSE)\n" -"\t{\n" -"\t\tfloat incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0);\n" -"\n" -"\t\tcolor.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0);\n" -"\t}\n" -"\t\n" -"\tvec3 viewer = u_LocalViewOrigin - position;\n" -"\n" -"\tif (u_AlphaGen == AGEN_LIGHTING_SPECULAR)\n" -"\t{\n" -"\t\tvec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position.xyz);\n" -"\t\tvec3 reflected = -reflect(lightDir, normal);\n" -"\t\t\n" -"\t\tcolor.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0);\n" -"\t\tcolor.a *= color.a;\n" -"\t\tcolor.a *= color.a;\n" -"\t}\n" -"\telse if (u_AlphaGen == AGEN_PORTAL)\n" -"\t{\n" -"\t\tcolor.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0);\n" -"\t}\n" -"\t\n" -"\treturn color;\n" -"}\n" -"#endif\n" -"\n" -"#if defined(USE_FOG)\n" -"float CalcFog(vec4 position)\n" -"{\n" -"\tfloat s = dot(position, u_FogDistance) * 8.0;\n" -"\tfloat t = dot(position, u_FogDepth);\n" -"\n" -"\tfloat eyeOutside = step(0.0, -u_FogEyeT);\n" -"\tfloat fogged = step(eyeOutside, t);\n" -"\t\t\n" -"\tt = max(t, 1e-6);\n" -"\tt *= fogged / (t - u_FogEyeT * eyeOutside);\n" -"\n" -"\treturn s * t;\n" -"}\n" -"#endif\n" -"\n" -"void main()\n" -"{\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" -"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"\tvec4 position = vec4(0.0);\n" -"\tvec4 normal4 = vec4(0.0);\n" -"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" -"\tfor (int i = 0; i < 4; i++) {\n" -"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" -"\n" -"\t\tposition += (u_BoneMatrices[boneIndex] * attr_Position) * attr_BoneWeights[i];\n" -"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" -"\t}\n" -"\tvec3 normal = normal4.xyz;\n" -"#else\n" -"\tvec4 position = attr_Position;\n" -"\tvec3 normal = attr_Normal;\n" -"#endif\n" -"\n" -"#if defined(USE_DEFORM_VERTEXES)\n" -"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" -"#endif\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\n" -"#if defined(USE_TCGEN)\n" -"\tvec2 tex = GenTexCoords(u_TCGen0, position.xyz, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" -"#else\n" -"\tvec2 tex = attr_TexCoord0.st;\n" -"#endif\n" -"\n" -"#if defined(USE_TCMOD)\n" -"\tvar_DiffuseTex = ModTexCoords(tex, position.xyz, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" -"#else\n" -" var_DiffuseTex = tex;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"\tvar_LightTex = attr_TexCoord1.st;\n" -"#endif\n" -"\n" -"#if defined(USE_RGBAGEN)\n" -"\tvar_Color = CalcColor(position.xyz, normal);\n" -"#else\n" -"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" -"#endif\n" -"\n" -"#if defined(USE_FOG)\n" -"\tvar_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0));\n" -"#endif\n" -"}\n" -; -const char *fallbackShader_lightall_fp = -"uniform sampler2D u_DiffuseMap;\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"uniform sampler2D u_LightMap;\n" -"#endif\n" -"\n" -"#if defined(USE_NORMALMAP)\n" -"uniform sampler2D u_NormalMap;\n" -"#endif\n" -"\n" -"#if defined(USE_DELUXEMAP)\n" -"uniform sampler2D u_DeluxeMap;\n" -"#endif\n" -"\n" -"#if defined(USE_SPECULARMAP)\n" -"uniform sampler2D u_SpecularMap;\n" -"#endif\n" -"\n" -"#if defined(USE_SHADOWMAP)\n" -"uniform sampler2D u_ShadowMap;\n" -"#endif\n" -"\n" -"#if defined(USE_CUBEMAP)\n" -"uniform samplerCube u_CubeMap;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)\n" -"uniform vec3 u_DirectedLight;\n" -"uniform vec3 u_AmbientLight;\n" -"#endif\n" -"\n" -"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"uniform vec3 u_PrimaryLightColor;\n" -"uniform vec3 u_PrimaryLightAmbient;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" -"uniform vec2 u_MaterialInfo;\n" -"#endif\n" -"\n" -"varying vec4 var_TexCoords;\n" -"\n" -"varying vec4 var_Color;\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"varying vec4 var_Normal;\n" -"varying vec4 var_Tangent;\n" -"varying vec4 var_Bitangent;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_LightColor;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"varying vec4 var_LightDir;\n" -"#endif\n" -"\n" -"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"varying vec4 var_PrimaryLightDir;\n" -"#endif\n" -"\n" -"\n" -"#define EPSILON 0.00000001\n" -"\n" -"#if defined(USE_PARALLAXMAP)\n" -"float SampleDepth(sampler2D normalMap, vec2 t)\n" -"{\n" -" #if defined(SWIZZLE_NORMALMAP)\n" -"\treturn 1.0 - texture2D(normalMap, t).r;\n" -" #else\n" -"\treturn 1.0 - texture2D(normalMap, t).a;\n" -" #endif\n" -"}\n" -"\n" -"float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap)\n" -"{\n" -"\tconst int linearSearchSteps = 16;\n" -"\tconst int binarySearchSteps = 6;\n" -"\n" -"\t// current size of search window\n" -"\tfloat size = 1.0 / float(linearSearchSteps);\n" -"\n" -"\t// current depth position\n" -"\tfloat depth = 0.0;\n" -"\n" -"\t// best match found (starts with last position 1.0)\n" -"\tfloat bestDepth = 1.0;\n" -"\n" -"\t// search front to back for first point inside object\n" -"\tfor(int i = 0; i < linearSearchSteps - 1; ++i)\n" -"\t{\n" -"\t\tdepth += size;\n" -"\t\t\n" -"\t\tfloat t = SampleDepth(normalMap, dp + ds * depth);\n" -"\t\t\n" -"\t\tif(bestDepth > 0.996)\t\t// if no depth found yet\n" -"\t\t\tif(depth >= t)\n" -"\t\t\t\tbestDepth = depth;\t// store best depth\n" -"\t}\n" -"\n" -"\tdepth = bestDepth;\n" -"\t\n" -"\t// recurse around first point (depth) for closest match\n" -"\tfor(int i = 0; i < binarySearchSteps; ++i)\n" -"\t{\n" -"\t\tsize *= 0.5;\n" -"\n" -"\t\tfloat t = SampleDepth(normalMap, dp + ds * depth);\n" -"\t\t\n" -"\t\tif(depth >= t)\n" -"\t\t{\n" -"\t\t\tbestDepth = depth;\n" -"\t\t\tdepth -= 2.0 * size;\n" -"\t\t}\n" -"\n" -"\t\tdepth += size;\n" -"\t}\n" -"\n" -"\treturn bestDepth;\n" -"}\n" -"#endif\n" -"\n" -"vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, float shininess)\n" -"{\n" -" #if defined(USE_OREN_NAYAR) || defined(USE_TRIACE_OREN_NAYAR)\n" -"\tfloat gamma = dot(E, L) - NE * NL;\n" -"\tfloat B = 2.22222 + 0.1 * shininess;\n" -"\t\t\n" -" #if defined(USE_OREN_NAYAR)\n" -"\tfloat A = 1.0 - 1.0 / (2.0 + 0.33 * shininess);\n" -"\tgamma = clamp(gamma, 0.0, 1.0);\n" -" #endif\n" -"\t\n" -" #if defined(USE_TRIACE_OREN_NAYAR)\n" -"\tfloat A = 1.0 - 1.0 / (2.0 + 0.65 * shininess);\n" -"\n" -"\tif (gamma >= 0.0)\n" -" #endif\n" -"\t{\n" -"\t\tB = max(B * max(NL, NE), EPSILON);\n" -"\t}\n" -"\n" -"\treturn diffuseAlbedo * (A + gamma / B);\n" -" #else\n" -"\treturn diffuseAlbedo;\n" -" #endif\n" -"}\n" -"\n" -"vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular)\n" -"{\n" -" #if 1\n" -"\t// from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" -"\tvec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss;\n" -"\tt += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 );\n" -"\tfloat a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z;\n" -"\tfloat a1 = t.w;\n" -"\treturn clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 );\n" -" #elif 0\n" -" // from http://seblagarde.wordpress.com/2011/08/17/hello-world/\n" -"\treturn mix(specular.rgb, max(specular.rgb, vec3(gloss)), CalcFresnel(NE));\n" -" #else\n" -" // from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx\n" -"\treturn mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss));\n" -" #endif\n" -"}\n" -"\n" -"float CalcBlinn(float NH, float shininess)\n" -"{\n" -"#if 0\n" -" // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/\n" -"\tfloat a = shininess + 0.775;\n" -" return exp(a * NH - a);\n" -"#else\n" -"\treturn pow(NH, shininess);\n" -"#endif\n" -"}\n" -"\n" -"float CalcGGX(float NH, float gloss)\n" -"{\n" -"\t// from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" -"\tfloat a_sq = exp2(gloss * -13.0 + 1.0);\n" -"\tfloat d = ((NH * NH) * (a_sq - 1.0) + 1.0);\n" -"\treturn a_sq / (d * d);\n" -"}\n" -"\n" -"float CalcFresnel(float EH)\n" -"{\n" -"#if 1\n" -"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" -"\t// not accurate, but fast\n" -"\treturn exp2(-10.0 * EH);\n" -"#elif 0\n" -"\t// From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/\n" -"\treturn exp2((-5.55473 * EH - 6.98316) * EH);\n" -"#elif 0\n" -"\tfloat blend = 1.0 - EH;\n" -"\tfloat blend2 = blend * blend;\n" -"\tblend *= blend2 * blend2;\n" -"\t\n" -"\treturn blend;\n" -"#else\n" -"\treturn pow(1.0 - EH, 5.0);\n" -"#endif\n" -"}\n" -"\n" -"float CalcVisibility(float NH, float NL, float NE, float EH, float gloss)\n" -"{\n" -"#if 1\n" -"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" -"\tfloat k = min(1.0, gloss + 0.545);\n" -"\treturn 1.0 / (k * EH * EH + (1.0 - k));\n" -"#elif 0\n" -"\tfloat roughness = exp2(gloss * -6.5);\n" -"\n" -" #if defined(USE_GGX)\n" -"\t// From http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" -"\tfloat k = roughness + 1.0;\n" -"\tk *= k * 0.125;\n" -" #else\n" -" float k = roughness;\n" -" #endif\n" -"\t// Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf\n" -"\t// NL, NE in numerator factored out from cook-torrance\n" -"\tfloat k2 = 1.0 - k;\n" -"\t\n" -"\tfloat invGeo1 = NL * k2 + k;\n" -"\tfloat invGeo2 = NE * k2 + k;\n" -"\t\n" -"\treturn 1.0 / (invGeo1 * invGeo2);\n" -"#else\n" -"\tfloat geo = 2.0 * NH * min(NE, NL);\n" -"\tgeo /= max(EH, geo);\n" -"\t\n" -"\treturn geo;\n" -"#endif\n" -"}\n" -"\n" -"\n" -"vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess)\n" -"{\n" -"\tfloat blinn = CalcBlinn(NH, shininess);\n" -"\tvec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH));\n" -"\tfloat vis = CalcVisibility(NH, NL, NE, EH, gloss);\n" -"\n" -" #if defined(USE_BLINN)\n" -" // Normalized Blinn-Phong\n" -"\treturn specular * blinn * (shininess * 0.125 + 1.0);\n" -" #elif defined(USE_BLINN_FRESNEL)\n" -" // Normalized Blinn-Phong with Fresnel\n" -"\treturn fSpecular * blinn * (shininess * 0.125 + 1.0);\n" -" #elif defined(USE_MCAULEY)\n" -" // Cook-Torrance as done by Stephen McAuley\n" -"\t// http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf\n" -"\treturn fSpecular * blinn * (shininess * 0.25 + 0.125);\n" -" #elif defined(USE_GOTANDA)\n" -" // Neumann-Neumann as done by Yoshiharu Gotanda\n" -"\t// http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf\n" -"\treturn fSpecular * blinn * (shininess * 0.124858 + 0.269182) / max(max(NL, NE), EPSILON);\n" -" #elif defined(USE_LAZAROV)\n" -" // Cook-Torrance as done by Dimitar Lazarov\n" -"\t// http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf\n" -"\treturn fSpecular * blinn * (shininess * 0.125 + 0.25) * vis;\n" -" #endif\n" -" \n" -"\treturn vec3(0.0);\n" -"}\n" -"\n" -"\n" -"float CalcLightAttenuation(vec3 dir, float sqrRadius)\n" -"{\n" -"\t// point light at >0 radius, directional otherwise\n" -"\tfloat point = float(sqrRadius > 0.0);\n" -"\n" -"\t// inverse square light\n" -"\tfloat attenuation = sqrRadius / dot(dir, dir);\n" -"\n" -"\t// zero light at radius, approximating q3 style\n" -"\t// also don't attenuate directional light\n" -"\tattenuation = (0.5 * attenuation - 1.5) * point + 1.0;\n" -"\t\n" -"\t// clamp attenuation\n" -"\t#if defined(NO_LIGHT_CLAMP)\n" -"\tattenuation = max(attenuation, 0.0);\n" -"\t#else\n" -"\tattenuation = clamp(attenuation, 0.0, 1.0);\n" -"\t#endif\n" -"\t\n" -"\treturn attenuation;\n" -"}\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tvec3 L, N, E, H;\n" -"\tfloat NL, NH, NE, EH;\n" -"\t\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"\tmat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz);\n" -"#endif\n" -"\n" -"#if defined(USE_DELUXEMAP)\n" -"\tL = (2.0 * texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(1.0));\n" -" #if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tL = L * tangentToWorld;\n" -" #endif\n" -"#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" -"\tL = var_LightDir.xyz;\n" -"#endif\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"\tE = normalize(vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w));\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"\tvec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw).rgba;\n" -" #if defined(RGBM_LIGHTMAP)\n" -"\tlightSample.rgb *= 32.0 * lightSample.a;\n" -" #endif\n" -"\tvec3 lightColor = lightSample.rgb;\n" -"#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT)\n" -"\tvec3 lightColor = u_DirectedLight * CalcLightAttenuation(L, var_LightDir.w);\n" -"\tvec3 ambientColor = u_AmbientLight;\n" -"#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"\tvec3 lightColor = var_LightColor;\n" -"#endif\n" -"\n" -"\tvec2 texCoords = var_TexCoords.xy;\n" -"\n" -"#if defined(USE_PARALLAXMAP)\n" -" #if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tvec3 offsetDir = E;\n" -" #else\n" -"\tvec3 offsetDir = E * tangentToWorld;\n" -" #endif\n" -"\n" -"\toffsetDir.xy *= -0.05 / offsetDir.z;\n" -"\n" -"\ttexCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap);\n" -"#endif\n" -"\n" -"\tvec4 diffuse = texture2D(u_DiffuseMap, texCoords);\n" -"#if defined(USE_GAMMA2_TEXTURES)\n" -"\tdiffuse.rgb *= diffuse.rgb;\n" -"#endif\n" -"\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" -" #if defined(USE_NORMALMAP)\n" -" #if defined(SWIZZLE_NORMALMAP)\n" -"\tN.xy = 2.0 * texture2D(u_NormalMap, texCoords).ag - vec2(1.0);\n" -" #else\n" -"\tN.xy = 2.0 * texture2D(u_NormalMap, texCoords).rg - vec2(1.0);\n" -" #endif\n" -"\tN.z = sqrt(1.0 - clamp(dot(N.xy, N.xy), 0.0, 1.0));\n" -" #if !defined(USE_TANGENT_SPACE_LIGHT)\n" -" N = normalize(tangentToWorld * N);\n" -" #endif\n" -" #elif defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tN = vec3(0.0, 0.0, 1.0);\n" -" #else\n" -" N = normalize(var_Normal.xyz);\n" -" #endif\n" -" \n" -"\tL = normalize(L);\n" -"\n" -" #if defined(USE_SHADOWMAP) \n" -"\tvec2 shadowTex = gl_FragCoord.xy * r_FBufScale;\n" -"\tfloat shadowValue = texture2D(u_ShadowMap, shadowTex).r;\n" -"\n" -"\t// surfaces not facing the light are always shadowed\n" -"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tshadowValue *= step(0.0, var_PrimaryLightDir.z);\n" -"\t#else\n" -"\tshadowValue *= step(0.0, dot(var_Normal.xyz, var_PrimaryLightDir.xyz));\n" -"\t#endif\n" -" \n" -" #if defined(SHADOWMAP_MODULATE)\n" -"\t//vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor);\n" -"\tvec3 shadowColor = u_PrimaryLightAmbient * lightColor;\n" -"\n" -" #if 0\n" -"\t// Only shadow when the world light is parallel to the primary light\n" -"\tshadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDir.xyz), 0.0, 1.0);\n" -" #endif\n" -"\tlightColor = mix(shadowColor, lightColor, shadowValue);\n" -" #endif\n" -" #endif\n" -"\n" -" #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX)\n" -"\tvec3 ambientColor = lightColor;\n" -"\t\n" -"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tfloat surfNL = L.z;\n" -"\t#else\n" -"\tfloat surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0);\n" -"\t#endif\n" -"\n" -"\t// Scale the incoming light to compensate for the baked-in light angle\n" -"\t// attenuation.\n" -"\tlightColor /= max(surfNL, 0.25);\n" -"\n" -"\t// Recover any unused light as ambient, in case attenuation is over 4x or\n" -"\t// light is below the surface\n" -"\tambientColor -= lightColor * surfNL;\n" -" #endif\n" -" \n" -"\tvec3 reflectance;\n" -"\n" -"\tNL = clamp(dot(N, L), 0.0, 1.0);\n" -"\tNE = clamp(dot(N, E), 0.0, 1.0);\n" -"\n" -" #if defined(USE_SPECULARMAP)\n" -"\tvec4 specular = texture2D(u_SpecularMap, texCoords);\n" -" #if defined(USE_GAMMA2_TEXTURES)\n" -"\tspecular.rgb *= specular.rgb;\n" -" #endif\n" -" #else\n" -"\tvec4 specular = vec4(1.0);\n" -" #endif\n" -"\n" -"\tspecular *= u_MaterialInfo.xxxy;\n" -"\t\n" -"\tfloat gloss = specular.a;\n" -"\tfloat shininess = exp2(gloss * 13.0);\n" -"\n" -" #if defined(SPECULAR_IS_METALLIC)\n" -" // diffuse is actually base color, and red of specular is metallicness\n" -"\tfloat metallic = specular.r;\n" -"\t\n" -"\tspecular.rgb = vec3(0.04) + 0.96 * diffuse.rgb * metallic;\n" -"\tdiffuse.rgb *= 1.0 - metallic;\n" -" #else\n" -"\t// adjust diffuse by specular reflectance, to maintain energy conservation\n" -"\tdiffuse.rgb *= vec3(1.0) - specular.rgb;\n" -" #endif\n" -" \n" -"\t\n" -"\treflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);\n" -"\n" -" #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR)\n" -"\tfloat adjGloss = gloss;\n" -"\tfloat adjShininess = shininess;\n" -"\t\n" -"\t#if !defined(USE_LIGHT_VECTOR)\n" -"\tadjGloss *= r_deluxeSpecular;\n" -"\tadjShininess = exp2(adjGloss * 13.0);\n" -"\t#endif\n" -"\t\n" -"\tH = normalize(L + E);\n" -"\n" -"\tEH = clamp(dot(E, H), 0.0, 1.0);\n" -"\tNH = clamp(dot(N, H), 0.0, 1.0);\n" -"\n" -" #if !defined(USE_LIGHT_VECTOR)\n" -"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess) * r_deluxeSpecular;\n" -" #else\n" -"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess);\n" -" #endif\n" -" #endif\n" -"\t\n" -"\tgl_FragColor.rgb = lightColor * reflectance * NL; \n" -"\tgl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb);\n" -"\t\n" -" #if defined(USE_CUBEMAP)\n" -"\treflectance = EnvironmentBRDF(gloss, NE, specular.rgb);\n" -"\n" -"\tvec3 R = reflect(E, N);\n" -"\t#if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tR = tangentToWorld * R;\n" -"\t#endif\n" -"\n" -" vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb;\n" -"\n" -"\t#if defined(USE_LIGHTMAP)\n" -"\tcubeLightColor *= lightSample.rgb;\n" -"\t#elif defined (USE_LIGHT_VERTEX)\n" -"\tcubeLightColor *= var_LightColor;\n" -"\t#else\n" -"\tcubeLightColor *= lightColor * NL + ambientColor;\n" -"\t#endif\n" -"\t\n" -"\t//gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb;\n" -"\tgl_FragColor.rgb += cubeLightColor * reflectance;\n" -" #endif\n" -"\n" -" #if defined(USE_PRIMARY_LIGHT)\n" -"\tL = var_PrimaryLightDir.xyz; //normalize(var_PrimaryLightDir.xyz);\n" -"\tNL = clamp(dot(N, L), 0.0, 1.0);\n" -"\n" -"\tH = normalize(L + E);\n" -"\tEH = clamp(dot(E, H), 0.0, 1.0);\n" -"\tNH = clamp(dot(N, H), 0.0, 1.0);\n" -"\n" -"\treflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess);\n" -"\treflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss, shininess);\n" -"\n" -"\tlightColor = u_PrimaryLightColor; // * CalcLightAttenuation(L, u_PrimaryLightDir.w);\n" -"\t\n" -" #if defined(USE_SHADOWMAP)\n" -"\tlightColor *= shadowValue;\n" -" #endif\n" -"\n" -"\tgl_FragColor.rgb += lightColor * reflectance * NL;\n" -" #endif\n" -"\n" -"\tgl_FragColor.a = diffuse.a;\n" -"#else\n" -"\tgl_FragColor = diffuse;\n" -" #if defined(USE_LIGHTMAP) \n" -"\tgl_FragColor.rgb *= lightColor;\n" -" #endif\n" -"#endif\n" -"\n" -"\tgl_FragColor *= var_Color;\n" -"}\n" -; -const char *fallbackShader_lightall_vp = -"attribute vec4 attr_TexCoord0;\n" -"#if defined(USE_LIGHTMAP) || defined(USE_TCGEN)\n" -"attribute vec4 attr_TexCoord1;\n" -"#endif\n" -"attribute vec4 attr_Color;\n" -"\n" -"attribute vec3 attr_Position;\n" -"attribute vec3 attr_Normal;\n" -"attribute vec3 attr_Tangent;\n" -"attribute vec3 attr_Bitangent;\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"attribute vec3 attr_Position2;\n" -"attribute vec3 attr_Normal2;\n" -"attribute vec3 attr_Tangent2;\n" -"attribute vec3 attr_Bitangent2;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"attribute vec4 attr_BoneIndexes;\n" -"attribute vec4 attr_BoneWeights;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR)\n" -"attribute vec3 attr_LightDirection;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN) || defined(USE_NORMALMAP) || defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)\n" -"uniform vec3 u_ViewOrigin;\n" -"uniform vec3 u_LocalViewOrigin;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN)\n" -"uniform int u_TCGen0;\n" -"uniform vec3 u_TCGen0Vector0;\n" -"uniform vec3 u_TCGen0Vector1;\n" -"#endif\n" -"\n" -"#if defined(USE_TCMOD)\n" -"uniform vec4 u_DiffuseTexMatrix;\n" -"uniform vec4 u_DiffuseTexOffTurb;\n" -"#endif\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"uniform vec4 u_BaseColor;\n" -"uniform vec4 u_VertColor;\n" -"\n" -"#if defined(USE_MODELMATRIX)\n" -"uniform mat4 u_ModelMatrix;\n" -"#endif\n" -"\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"uniform float u_VertexLerp;\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"uniform mat4 u_BoneMatrices[80];\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VECTOR)\n" -"uniform vec4 u_LightOrigin;\n" -"uniform float u_LightRadius;\n" -"uniform vec3 u_DirectedLight;\n" -" #if defined(USE_FAST_LIGHT)\n" -"uniform vec3 u_AmbientLight;\n" -" #endif\n" -"#endif\n" -"\n" -"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"uniform vec4 u_PrimaryLightOrigin;\n" -"uniform float u_PrimaryLightRadius;\n" -"#endif\n" -"\n" -"varying vec4 var_TexCoords;\n" -"\n" -"varying vec4 var_Color;\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"varying vec4 var_Normal;\n" -"varying vec4 var_Tangent;\n" -"varying vec4 var_Bitangent;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"varying vec3 var_LightColor;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"varying vec4 var_LightDir;\n" -"#endif\n" -"\n" -"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"varying vec4 var_PrimaryLightDir;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN)\n" -"vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1)\n" -"{\n" -"\tvec2 tex = attr_TexCoord0.st;\n" -"\n" -"\tif (TCGen == TCGEN_LIGHTMAP)\n" -"\t{\n" -"\t\ttex = attr_TexCoord1.st;\n" -"\t}\n" -"\telse if (TCGen == TCGEN_ENVIRONMENT_MAPPED)\n" -"\t{\n" -"\t\tvec3 viewer = normalize(u_LocalViewOrigin - position);\n" -"\t\ttex = -reflect(viewer, normal).yz * vec2(0.5, -0.5) + 0.5;\n" -"\t}\n" -"\telse if (TCGen == TCGEN_VECTOR)\n" -"\t{\n" -"\t\ttex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1));\n" -"\t}\n" -"\t\n" -"\treturn tex;\n" -"}\n" -"#endif\n" -"\n" -"#if defined(USE_TCMOD)\n" -"vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb)\n" -"{\n" -"\tfloat amplitude = offTurb.z;\n" -"\tfloat phase = offTurb.w;\n" -"\tvec2 st2 = vec2(dot(st, texMatrix.xz), dot(st, texMatrix.yw)) + offTurb.xy;\n" -"\n" -"\tvec3 offsetPos = position / 1024.0;\n" -"\toffsetPos.x += offsetPos.z;\n" -"\t\n" -"\tvec2 texOffset = sin((offsetPos.xy + vec2(phase)) * 2.0 * M_PI);\n" -"\t\n" -"\treturn st2 + texOffset * amplitude;\t\n" -"}\n" -"#endif\n" -"\n" -"\n" -"float CalcLightAttenuation(vec3 dir, float sqrRadius)\n" -"{\n" -"\t// point light at >0 radius, directional otherwise\n" -"\tfloat point = float(sqrRadius > 0.0);\n" -"\n" -"\t// inverse square light\n" -"\tfloat attenuation = sqrRadius / dot(dir, dir);\n" -"\n" -"\t// zero light at radius, approximating q3 style\n" -"\t// also don't attenuate directional light\n" -"\tattenuation = (0.5 * attenuation - 1.5) * point + 1.0;\n" -"\t\n" -"\t// clamp attenuation\n" -"\t#if defined(NO_LIGHT_CLAMP)\n" -"\tattenuation = max(attenuation, 0.0);\n" -"\t#else\n" -"\tattenuation = clamp(attenuation, 0.0, 1.0);\n" -"\t#endif\n" -"\t\n" -"\treturn attenuation;\n" -"}\n" -"\n" -"\n" -"void main()\n" -"{\n" -"#if defined(USE_VERTEX_ANIMATION)\n" -"\tvec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" -"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" -"\tvec3 tangent = normalize(mix(attr_Tangent, attr_Tangent2, u_VertexLerp));\n" -"\tvec3 bitangent = normalize(mix(attr_Bitangent, attr_Bitangent2, u_VertexLerp));\n" -"#elif defined(USE_SKELETAL_ANIMATION)\n" -"\tvec4 position4 = vec4(0.0);\n" -"\tvec4 normal4 = vec4(0.0);\n" -"\tvec4 tangent4 = vec4(0.0);\n" -"\tvec4 bitangent4 = vec4(0.0);\n" -"\tvec4 originalPosition = vec4(attr_Position, 1.0);\n" -"\tvec4 originalNormal = vec4(attr_Normal, 0.0);\n" -"\tvec4 originalTangent = vec4(attr_Tangent, 0.0);\n" -"\tvec4 originalBitangent = vec4(attr_Bitangent, 0.0);\n" -"\tfor (int i = 0; i < 4; i++) {\n" -"\t\tint boneIndex = int(attr_BoneIndexes[i]);\n" -"\n" -"\t\tposition4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i];\n" -"\t\tnormal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i];\n" -"\t\ttangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i];\n" -"\t\tbitangent4 += (u_BoneMatrices[boneIndex] * originalBitangent) * attr_BoneWeights[i];\n" -"\t}\n" -"\tvec3 position = position4.xyz;\n" -"\tvec3 normal = normal4.xyz;\n" -"\tvec3 tangent = tangent4.xyz;\n" -"\tvec3 bitangent = bitangent4.xyz;\n" -"#else\n" -"\tvec3 position = attr_Position;\n" -"\tvec3 normal = attr_Normal;\n" -"\tvec3 tangent = attr_Tangent;\n" -"\tvec3 bitangent = attr_Bitangent;\n" -"#endif\n" -"\n" -"#if defined(USE_TCGEN)\n" -"\tvec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);\n" -"#else\n" -"\tvec2 texCoords = attr_TexCoord0.st;\n" -"#endif\n" -"\n" -"#if defined(USE_TCMOD)\n" -"\tvar_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb);\n" -"#else\n" -"\tvar_TexCoords.xy = texCoords;\n" -"#endif\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);\n" -"\n" -"#if defined(USE_MODELMATRIX)\n" -"\tposition = (u_ModelMatrix * vec4(position, 1.0)).xyz;\n" -"\tnormal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;\n" -"\ttangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;\n" -"\tbitangent = (u_ModelMatrix * vec4(bitangent, 0.0)).xyz;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VECTOR)\n" -"\tvec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);\n" -"#elif defined(USE_LIGHT) && !defined(USE_DELUXEMAP)\n" -"\tvec3 L = attr_LightDirection;\n" -" #if defined(USE_MODELMATRIX)\n" -"\tL = (u_ModelMatrix * vec4(L, 0.0)).xyz;\n" -" #endif\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHTMAP)\n" -"\tvar_TexCoords.zw = attr_TexCoord1.st;\n" -"#endif\n" -"\t\n" -"\tvar_Color = u_VertColor * attr_Color + u_BaseColor;\n" -"#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT)\n" -"\tvar_LightColor = var_Color.rgb;\n" -"\tvar_Color.rgb = vec3(1.0);\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT)\n" -"\tfloat attenuation = CalcLightAttenuation(L, u_LightRadius * u_LightRadius);\n" -"\tfloat NL = clamp(dot(normal, normalize(L)), 0.0, 1.0);\n" -"\n" -"\tvar_Color.rgb *= u_DirectedLight * attenuation * NL + u_AmbientLight;\n" -"#endif\n" -"\n" -"#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"\tvar_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w);\n" -"\tvar_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius;\n" -"#endif\n" -"\n" -"#if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -" #if defined(USE_LIGHT_VECTOR)\n" -"\tvar_LightDir = vec4(L, u_LightRadius * u_LightRadius);\n" -" #else\n" -"\tvar_LightDir = vec4(L, 0.0);\n" -" #endif\n" -"#endif\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"\tvec3 viewDir = u_ViewOrigin - position;\n" -"#endif\n" -"\n" -"#if defined(USE_TANGENT_SPACE_LIGHT)\n" -"\tmat3 tangentToWorld = mat3(tangent, bitangent, normal);\n" -"\n" -" #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP)\n" -"\tvar_PrimaryLightDir.xyz = var_PrimaryLightDir.xyz * tangentToWorld;\n" -" #endif\n" -" \n" -" #if defined(USE_LIGHT) && !defined(USE_DELUXEMAP) && !defined(USE_FAST_LIGHT)\n" -"\tvar_LightDir.xyz = var_LightDir.xyz * tangentToWorld;\n" -" #endif\n" -"\n" -" #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"\tviewDir = viewDir * tangentToWorld;\n" -" #endif\n" -"#endif\n" -"\n" -"#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) || defined(USE_PARALLAXMAP)\n" -"\t// store view direction in tangent space to save on varyings\n" -"\tvar_Normal = vec4(normal, viewDir.x);\n" -"\tvar_Tangent = vec4(tangent, viewDir.y);\n" -"\tvar_Bitangent = vec4(bitangent, viewDir.z);\n" -"#endif\n" -"}\n" -; -const char *fallbackShader_pshadow_fp = -"uniform sampler2D u_ShadowMap;\n" -"\n" -"uniform vec3 u_LightForward;\n" -"uniform vec3 u_LightUp;\n" -"uniform vec3 u_LightRight;\n" -"uniform vec4 u_LightOrigin;\n" -"uniform float u_LightRadius;\n" -"varying vec3 var_Position;\n" -"varying vec3 var_Normal;\n" -"\n" -"float sampleDistMap(sampler2D texMap, vec2 uv, float scale)\n" -"{\n" -"\tvec3 distv = texture2D(texMap, uv).xyz;\n" -"\treturn dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0)) * scale;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tvec3 lightToPos = var_Position - u_LightOrigin.xyz;\n" -"\tvec2 st = vec2(-dot(u_LightRight, lightToPos), dot(u_LightUp, lightToPos));\n" -"\t\n" -"\tfloat fade = length(st);\n" -"\t\n" -"#if defined(USE_DISCARD)\n" -"\tif (fade >= 1.0)\n" -"\t{\n" -"\t\tdiscard;\n" -"\t}\n" -"#endif\n" -"\n" -"\tfade = clamp(8.0 - fade * 8.0, 0.0, 1.0);\n" -"\t\n" -"\tst = st * 0.5 + vec2(0.5);\n" -"\n" -"#if defined(USE_SOLID_PSHADOWS)\n" -"\tfloat intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0);\n" -"#else\n" -"\tfloat intensity = clamp((1.0 - dot(lightToPos, lightToPos) / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0);\n" -"#endif\n" -"\t\n" -"\tfloat lightDist = length(lightToPos);\n" -"\tfloat dist;\n" -"\n" -"#if defined(USE_DISCARD)\n" -"\tif (dot(u_LightForward, lightToPos) <= 0.0)\n" -"\t{\n" -"\t\tdiscard;\n" -"\t}\n" -"\n" -"\tif (dot(var_Normal, lightToPos) > 0.0)\n" -"\t{\n" -"\t\tdiscard;\n" -"\t}\n" -"#else\n" -"\tintensity *= max(sign(dot(u_LightForward, lightToPos)), 0.0);\n" -"\tintensity *= max(sign(-dot(var_Normal, lightToPos)), 0.0);\n" -"#endif\n" -"\n" -"\tintensity *= fade;\n" -"#if defined(USE_PCF)\n" -"\tfloat part;\n" -"\t\n" -"\tdist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, -1.0/512.0), u_LightRadius);\n" -"\tpart = max(sign(lightDist - dist), 0.0);\n" -"\n" -"\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, -1.0/512.0), u_LightRadius);\n" -"\tpart += max(sign(lightDist - dist), 0.0);\n" -"\n" -"\tdist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, 1.0/512.0), u_LightRadius);\n" -"\tpart += max(sign(lightDist - dist), 0.0);\n" -"\n" -"\tdist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, 1.0/512.0), u_LightRadius);\n" -"\tpart += max(sign(lightDist - dist), 0.0);\n" -"\n" -" #if defined(USE_DISCARD)\n" -"\tif (part <= 0.0)\n" -"\t{\n" -"\t\tdiscard;\n" -"\t}\n" -" #endif\n" -"\n" -"\tintensity *= part * 0.25;\n" -"#else\n" -"\tdist = sampleDistMap(u_ShadowMap, st, u_LightRadius);\n" -"\n" -" #if defined(USE_DISCARD)\n" -"\tif (lightDist - dist <= 0.0)\n" -"\t{\n" -"\t\tdiscard;\n" -"\t}\n" -" #endif\n" -"\t\t\t\n" -"\tintensity *= max(sign(lightDist - dist), 0.0);\n" -"#endif\n" -"\t\t\n" -"\tgl_FragColor.rgb = vec3(0);\n" -"\tgl_FragColor.a = clamp(intensity, 0.0, 0.75);\n" -"}\n" -; -const char *fallbackShader_pshadow_vp = -"attribute vec4 attr_Position;\n" -"attribute vec3 attr_Normal;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"varying vec3 var_Position;\n" -"varying vec3 var_Normal;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 position = attr_Position;\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\n" -"\tvar_Position = position.xyz;\n" -"\tvar_Normal = attr_Normal;\n" -"}\n" -; -const char *fallbackShader_shadowfill_fp = -"uniform vec4 u_LightOrigin;\n" -"uniform float u_LightRadius;\n" -"\n" -"varying vec3 var_Position;\n" -"\n" -"void main()\n" -"{\n" -"#if defined(USE_DEPTH)\n" -"\tfloat depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius;\n" -" #if 0\n" -"\t// 32 bit precision\n" -"\tconst vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1);\n" -"\tconst vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n" -"\t\n" -"\tvec4 comp;\n" -"\tcomp = depth * bitSh;\n" -"\tcomp.xyz = fract(comp.xyz);\n" -"\tcomp -= comp.xxyz * bitMsk;\n" -"\tgl_FragColor = comp;\n" -" #endif\n" -"\n" -" #if 1\n" -"\t// 24 bit precision\n" -"\tconst vec3 bitSh = vec3( 256 * 256, 256, 1);\n" -"\tconst vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0);\n" -"\t\n" -"\tvec3 comp;\n" -"\tcomp = depth * bitSh;\n" -"\tcomp.xy = fract(comp.xy);\n" -"\tcomp -= comp.xxy * bitMsk;\n" -"\tgl_FragColor = vec4(comp, 1.0);\n" -" #endif\n" -"\n" -" #if 0\n" -"\t// 8 bit precision\n" -"\tgl_FragColor = vec4(depth, depth, depth, 1);\n" -" #endif\n" -"#else\n" -"\tgl_FragColor = vec4(0, 0, 0, 1);\n" -"#endif\n" -"}\n" -; -const char *fallbackShader_shadowfill_vp = -"attribute vec4 attr_Position;\n" -"attribute vec3 attr_Normal;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"//#if defined(USE_VERTEX_ANIMATION)\n" -"attribute vec4 attr_Position2;\n" -"attribute vec3 attr_Normal2;\n" -"//#endif\n" -"\n" -"//#if defined(USE_DEFORM_VERTEXES)\n" -"uniform int u_DeformGen;\n" -"uniform float u_DeformParams[5];\n" -"//#endif\n" -"\n" -"uniform float u_Time;\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"uniform mat4 u_ModelMatrix;\n" -"\n" -"//#if defined(USE_VERTEX_ANIMATION)\n" -"uniform float u_VertexLerp;\n" -"//#endif\n" -"\n" -"varying vec3 var_Position;\n" -"\n" -"vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)\n" -"{\n" -"\tif (u_DeformGen == 0)\n" -"\t{\n" -"\t\treturn pos;\n" -"\t}\n" -"\n" -"\tfloat base = u_DeformParams[0];\n" -"\tfloat amplitude = u_DeformParams[1];\n" -"\tfloat phase = u_DeformParams[2];\n" -"\tfloat frequency = u_DeformParams[3];\n" -"\tfloat spread = u_DeformParams[4];\n" -"\n" -"\tif (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tphase *= st.x;\n" -"\t}\n" -"\telse // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tphase += dot(pos.xyz, vec3(spread));\n" -"\t}\n" -"\n" -"\tfloat value = phase + (u_Time * frequency);\n" -"\tfloat func;\n" -"\n" -"\tif (u_DeformGen == DGEN_WAVE_SIN)\n" -"\t{\n" -"\t\tfunc = sin(value * 2.0 * M_PI);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SQUARE)\n" -"\t{\n" -"\t\tfunc = sign(sin(value * 2.0 * M_PI));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_TRIANGLE)\n" -"\t{\n" -"\t\tfunc = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0;\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = fract(value);\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH)\n" -"\t{\n" -"\t\tfunc = (1.0 - fract(value));\n" -"\t}\n" -"\telse if (u_DeformGen == DGEN_BULGE)\n" -"\t{\n" -"\t\tfunc = sin(value);\n" -"\t}\n" -"\n" -"\treturn pos + normal * (base + func * amplitude);\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 position = mix(attr_Position, attr_Position2, u_VertexLerp);\n" -"\tvec3 normal = normalize(mix(attr_Normal, attr_Normal2, u_VertexLerp));\n" -"\n" -"\tposition.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);\n" -"\n" -"\tgl_Position = u_ModelViewProjectionMatrix * position;\n" -"\t\n" -"\tvar_Position = (u_ModelMatrix * position).xyz;\n" -"}\n" -; -const char *fallbackShader_shadowmask_fp = -"uniform sampler2D u_ScreenDepthMap;\n" -"\n" -"uniform sampler2D u_ShadowMap;\n" -"#if defined(USE_SHADOW_CASCADE)\n" -"uniform sampler2D u_ShadowMap2;\n" -"uniform sampler2D u_ShadowMap3;\n" -"#endif\n" -"\n" -"uniform mat4 u_ShadowMvp;\n" -"#if defined(USE_SHADOW_CASCADE)\n" -"uniform mat4 u_ShadowMvp2;\n" -"uniform mat4 u_ShadowMvp3;\n" -"#endif\n" -"\n" -"uniform vec3 u_ViewOrigin;\n" -"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" -"\n" -"varying vec2 var_DepthTex;\n" -"varying vec3 var_ViewDir;\n" -"\n" -"// Input: It uses texture coords as the random number seed.\n" -"// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.\n" -"// Author: Michael Pohoreski\n" -"// Copyright: Copyleft 2012 :-)\n" -"// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader\n" -"\n" -"float random( const vec2 p )\n" -"{\n" -" // We need irrationals for pseudo randomness.\n" -" // Most (all?) known transcendental numbers will (generally) work.\n" -" const vec2 r = vec2(\n" -" 23.1406926327792690, // e^pi (Gelfond's constant)\n" -" 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant)\n" -" //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) );\n" -" return mod( 123456789., 1e-7 + 256. * dot(p,r) ); \n" -"}\n" -"\n" -"float PCF(const sampler2D shadowmap, const vec2 st, const float dist)\n" -"{\n" -"\tfloat mult;\n" -"\tfloat scale = 2.0 / r_shadowMapSize;\n" -"\t\t\n" -"#if defined(USE_SHADOW_FILTER)\n" -"\tfloat r = random(var_DepthTex.xy);\n" -"\tfloat sinr = sin(r) * scale;\n" -"\tfloat cosr = cos(r) * scale;\n" -"\tmat2 rmat = mat2(cosr, sinr, -sinr, cosr);\n" -"\n" -"\tmult = step(dist, texture2D(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r);\n" -" #if defined(USE_SHADOW_FILTER2)\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r);\n" -"\tmult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r);\n" -"\n" -"\tmult *= 0.11111;\n" -" #else\n" -" mult *= 0.33333;\n" -" #endif\n" -"#else\n" -"\tmult = step(dist, texture2D(shadowmap, st).r);\n" -"#endif\n" -"\t\t\n" -"\treturn mult;\n" -"}\n" -"\n" -"float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear)\n" -"{\n" -"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" -"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tfloat result;\n" -"\t\n" -"\tfloat depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x);\n" -"\tfloat sampleZ = u_ViewInfo.y * depth;\n" -"\n" -"\tvec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * depth * 0.99, 1.0);\n" -"\t\n" -"\tvec4 shadowpos = u_ShadowMvp * biasPos;\n" -"\t\n" -"#if defined(USE_SHADOW_CASCADE)\n" -"\tconst float fadeTo = 1.0;\n" -"\tresult = fadeTo;\n" -"#else\n" -"\tresult = 0.0;\n" -"#endif\n" -"\n" -"\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" -"\t{\n" -"\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" -"\t\tresult = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z);\n" -"\t}\n" -"#if defined(USE_SHADOW_CASCADE)\n" -"\telse\n" -"\t{\n" -"\t\tshadowpos = u_ShadowMvp2 * biasPos;\n" -"\n" -"\t\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" -"\t\t{\n" -"\t\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" -"\t\t\tresult = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z);\n" -"\t\t}\n" -"\t\telse\n" -"\t\t{\n" -"\t\t\tshadowpos = u_ShadowMvp3 * biasPos;\n" -"\n" -"\t\t\tif (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w)))))\n" -"\t\t\t{\n" -"\t\t\t\tshadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5;\n" -"\t\t\t\tresult = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z);\n" -"\n" -"\t\t\t\tfloat fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0);\n" -"\t\t\t\tresult = mix(result, fadeTo, fade);\n" -"\t\t\t}\n" -"\t\t}\n" -"\t}\n" -"#endif\n" -"\t\t\n" -"\tgl_FragColor = vec4(vec3(result), 1.0);\n" -"}\n" -; -const char *fallbackShader_shadowmask_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform vec3 u_ViewForward;\n" -"uniform vec3 u_ViewLeft;\n" -"uniform vec3 u_ViewUp;\n" -"uniform vec4 u_ViewInfo; // zfar / znear\n" -"\n" -"varying vec2 var_DepthTex;\n" -"varying vec3 var_ViewDir;\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = attr_Position;\n" -"\tvec2 screenCoords = gl_Position.xy / gl_Position.w;\n" -"\tvar_DepthTex = attr_TexCoord0.xy;\n" -"\tvar_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y;\n" -"}\n" -; -const char *fallbackShader_ssao_fp = -"uniform sampler2D u_ScreenDepthMap;\n" -"\n" -"uniform vec4 u_ViewInfo; // zfar / znear, zfar\n" -"\n" -"varying vec2 var_ScreenTex;\n" -"\n" -"vec2 poissonDisc[9] = vec2[9](\n" -"vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386),\n" -"vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417),\n" -"vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181),\n" -"vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854),\n" -"vec2(0.7320465, 0.6317794)\n" -");\n" -"\n" -"// Input: It uses texture coords as the random number seed.\n" -"// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive.\n" -"// Author: Michael Pohoreski\n" -"// Copyright: Copyleft 2012 :-)\n" -"// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader\n" -"\n" -"float random( const vec2 p )\n" -"{\n" -" // We need irrationals for pseudo randomness.\n" -" // Most (all?) known transcendental numbers will (generally) work.\n" -" const vec2 r = vec2(\n" -" 23.1406926327792690, // e^pi (Gelfond's constant)\n" -" 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant)\n" -" //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) );\n" -" return mod( 123456789., 1e-7 + 256. * dot(p,r) ); \n" -"}\n" -"\n" -"mat2 randomRotation( const vec2 p )\n" -"{\n" -"\tfloat r = random(p);\n" -"\tfloat sinr = sin(r);\n" -"\tfloat cosr = cos(r);\n" -"\treturn mat2(cosr, sinr, -sinr, cosr);\n" -"}\n" -"\n" -"float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear)\n" -"{\n" -"\t\tfloat sampleZDivW = texture2D(depthMap, tex).r;\n" -"\t\treturn 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW);\n" -"}\n" -"\n" -"float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZNear, const float zFar)\n" -"{\n" -"\tfloat result = 0;\n" -"\n" -"\tfloat sampleZ = zFar * getLinearDepth(depthMap, tex, zFarDivZNear);\n" -"\n" -"\tvec2 expectedSlope = vec2(dFdx(sampleZ), dFdy(sampleZ)) / vec2(dFdx(tex.x), dFdy(tex.y));\n" -"\t\n" -"\tif (length(expectedSlope) > 5000.0)\n" -"\t\treturn 1.0;\n" -"\t\n" -"\tvec2 offsetScale = vec2(3.0 / sampleZ);\n" -"\t\n" -"\tmat2 rmat = randomRotation(tex);\n" -"\t\t\n" -"\tint i;\n" -"\tfor (i = 0; i < 3; i++)\n" -"\t{\n" -"\t\tvec2 offset = rmat * poissonDisc[i] * offsetScale;\n" -"\t\tfloat sampleZ2 = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear);\n" -"\n" -"\t\tif (abs(sampleZ - sampleZ2) > 20.0)\n" -"\t\t\tresult += 1.0;\n" -"\t\telse\n" -"\t\t{\n" -"\t\t\tfloat expectedZ = sampleZ + dot(expectedSlope, offset);\n" -"\t\t\tresult += step(expectedZ - 1.0, sampleZ2);\n" -"\t\t}\n" -"\t}\n" -"\t\n" -"\tresult *= 0.33333;\n" -"\t\n" -"\treturn result;\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tfloat result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y);\n" -"\t\t\t\n" -"\tgl_FragColor = vec4(vec3(result), 1.0);\n" -"}\n" -; -const char *fallbackShader_ssao_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"varying vec2 var_ScreenTex;\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = attr_Position;\n" -"\tvar_ScreenTex = attr_TexCoord0.xy;\n" -"\t//vec2 screenCoords = gl_Position.xy / gl_Position.w;\n" -"\t//var_ScreenTex = screenCoords * 0.5 + 0.5;\n" -"}\n" -; -const char *fallbackShader_texturecolor_fp = -"#version 120\n" -"\n" -"uniform sampler2D u_DiffuseMap;\n" -"uniform vec4 u_Color;\n" -"\n" -"varying vec2 var_Tex1;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_FragColor = texture2D(u_DiffuseMap, var_Tex1) * u_Color;\n" -"}\n" -; -const char *fallbackShader_texturecolor_vp = -"#version 120\n" -"\n" -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_Tex1;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" -"\tvar_Tex1 = attr_TexCoord0.st;\n" -"}\n" -; -const char *fallbackShader_tonemap_fp = -"uniform sampler2D u_TextureMap;\n" -"uniform sampler2D u_LevelsMap;\n" -"\n" -"uniform vec4 u_Color;\n" -"\n" -"uniform vec2 u_AutoExposureMinMax;\n" -"uniform vec3 u_ToneMinAvgMaxLinear;\n" -"\n" -"varying vec2 var_TexCoords;\n" -"\n" -"const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114);\n" -"\n" -"vec3 FilmicTonemap(vec3 x)\n" -"{\n" -"\tconst float SS = 0.22; // Shoulder Strength\n" -"\tconst float LS = 0.30; // Linear Strength\n" -"\tconst float LA = 0.10; // Linear Angle\n" -"\tconst float TS = 0.20; // Toe Strength\n" -"\tconst float TAN = 0.01; // Toe Angle Numerator\n" -"\tconst float TAD = 0.30; // Toe Angle Denominator\n" -"\t\n" -"\tvec3 SSxx = SS * x * x;\n" -"\tvec3 LSx = LS * x;\n" -"\tvec3 LALSx = LSx * LA;\n" -"\t\n" -"\treturn ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD;\n" -"\n" -"\t//return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD;\n" -"\n" -"}\n" -"\n" -"void main()\n" -"{\n" -"\tvec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color;\n" -"\tvec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb;\n" -"\tvec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x);\n" -"\t\t\n" -"\tfloat avgLum = exp2(logMinAvgMaxLum.y);\n" -"\t//float maxLum = exp2(logMinAvgMaxLum.z);\n" -"\n" -"\tcolor.rgb *= u_ToneMinAvgMaxLinear.y / avgLum;\n" -"\tcolor.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x));\n" -"\n" -"\tvec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x));\n" -"\tcolor.rgb = FilmicTonemap(color.rgb) * fWhite;\n" -"\t\n" -"\tgl_FragColor = clamp(color, 0.0, 1.0);\n" -"}\n" -; -const char *fallbackShader_tonemap_vp = -"attribute vec4 attr_Position;\n" -"attribute vec4 attr_TexCoord0;\n" -"\n" -"uniform mat4 u_ModelViewProjectionMatrix;\n" -"\n" -"varying vec2 var_TexCoords;\n" -"\n" -"\n" -"void main()\n" -"{\n" -"\tgl_Position = u_ModelViewProjectionMatrix * attr_Position;\n" -"\tvar_TexCoords = attr_TexCoord0.st;\n" -"}\n" -; \ No newline at end of file From 4c8216b91f1353317da4b0a91ca2e52212da4339 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Tue, 17 Dec 2013 23:13:58 -0600 Subject: [PATCH 139/708] [MP] Rend2: Avoid enum type (imgFlags_t) for bit flag usage because of C++. --- codemp/rd-rend2/tr_image.cpp | 6 +++--- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shader.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 1e7d204fe7..fdc5d71ccd 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1728,7 +1728,7 @@ static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) return qfalse; } -static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean lightMap, imgType_t type, imgFlags_t flags) +static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean lightMap, imgType_t type, int flags) { int samples = 3; GLenum internalFormat = GL_RGB; @@ -2159,7 +2159,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } -static void EmptyTexture( int width, int height, imgType_t type, imgFlags_t flags, +static void EmptyTexture( int width, int height, imgType_t type, int flags, qboolean lightMap, GLenum internalFormat, int *pUploadWidth, int *pUploadHeight ) { int scaled_width, scaled_height; @@ -2238,7 +2238,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT tr.numImages++; image->type = type; - image->flags = (imgFlags_t)flags; + image->flags = flags; strcpy (image->imgName, name); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 49f3b0dc56..4cac2b1465 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -342,7 +342,7 @@ typedef struct image_s { int TMU; // only needed for voodoo2 imgType_t type; - imgFlags_t flags; + int flags; struct image_s* next; } image_t; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f54b420952..b64386ad5d 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2399,7 +2399,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { char normalName[MAX_QPATH]; image_t *normalImg; - imgFlags_t normalFlags = (imgFlags_t)((diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE); + int normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; COM_StripExtension(diffuseImg->imgName, normalName, MAX_QPATH); Q_strcat(normalName, MAX_QPATH, "_n"); From b8e4f8732cb27064715da4dd79ed8016e611963c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 18 Dec 2013 13:04:36 -0600 Subject: [PATCH 140/708] [MP] Rend2: Fix invalid references to pshadow bits. --- codemp/rd-rend2/tr_backend.cpp | 12 ++++++------ codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1759849387..9bfeebdb88 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -567,7 +567,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { int fogNum, oldFogNum; int entityNum, oldEntityNum; int dlighted, oldDlighted; - int pshadowed, oldPshadowed; + int postRender, oldPostRender; int cubemapIndex, oldCubemapIndex; int depthRange, oldDepthRange; int i; @@ -591,8 +591,8 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldShader = NULL; oldFogNum = -1; oldDepthRange = 0; - oldDlighted = qfalse; - oldPshadowed = qfalse; + oldDlighted = 0; + oldPostRender = 0; oldCubemapIndex = -1; oldSort = -1; @@ -611,14 +611,14 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { continue; } oldSort = drawSurf->sort; - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); cubemapIndex = drawSurf->cubemapIndex; // // change the tess parameters if needed // a "entityMergable" shader is a shader that can have surfaces from seperate // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || pshadowed != oldPshadowed || cubemapIndex != oldCubemapIndex + if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || postRender != oldPostRender || cubemapIndex != oldCubemapIndex || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { if (oldShader != NULL) { RB_EndSurface(); @@ -628,7 +628,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { oldShader = shader; oldFogNum = fogNum; oldDlighted = dlighted; - oldPshadowed = pshadowed; + oldPostRender = postRender; oldCubemapIndex = cubemapIndex; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 4cac2b1465..8767b7f48c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2316,7 +2316,7 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e ); void R_AddPolygonSurfaces( void ); void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *pshadowMap ); + int *fogNum, int *dlightMap, int *postRender ); void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 4384472404..3ee15c9d66 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1513,7 +1513,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 shader_t *shader; int fogNum; int dlighted; - int pshadowed; + int postRender; vec4_t clip, eye; int i; unsigned int pointOr = 0; @@ -1521,7 +1521,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(); - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); @@ -1828,7 +1828,7 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { int fogNum; int entityNum; int dlighted; - int pshadowed; + int postRender; int i; //ri->Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); @@ -1860,7 +1860,7 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { // check for any pass through drawing, which // may cause another view to be rendered first for ( i = 0 ; i < numDrawSurfs ; i++ ) { - R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted, &pshadowed ); + R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); if ( shader->sort > SS_PORTAL ) { break; From 21ef75ccee273fe7a4e7035c1878531e4aa114b6 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 18 Dec 2013 15:31:36 -0600 Subject: [PATCH 141/708] [MP] Rend2: Fix decals so they actually get rendered. Moved decals code to tr_decals.cpp ala vanilla. --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_decals.cpp | 299 +++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_local.h | 8 +- codemp/rd-rend2/tr_scene.cpp | 260 +--------------------------- 4 files changed, 310 insertions(+), 258 deletions(-) create mode 100644 codemp/rd-rend2/tr_decals.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 7e68ddd008..9860cc8e5e 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -23,6 +23,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_cache.cpp" "${MPDir}/rd-rend2/tr_cmds.cpp" "${MPDir}/rd-rend2/tr_curve.cpp" + "${MPDir}/rd-rend2/tr_decals.cpp" "${MPDir}/rd-rend2/tr_extensions.cpp" "${MPDir}/rd-rend2/tr_extramath.cpp" "${MPDir}/rd-rend2/tr_extramath.h" diff --git a/codemp/rd-rend2/tr_decals.cpp b/codemp/rd-rend2/tr_decals.cpp new file mode 100644 index 0000000000..6bf4222da7 --- /dev/null +++ b/codemp/rd-rend2/tr_decals.cpp @@ -0,0 +1,299 @@ +#include "tr_local.h" + +#define MAX_VERTS_ON_DECAL_POLY 10 +#define MAX_DECAL_POLYS 500 + +typedef struct decalPoly_s +{ + int time; + int fadetime; + qhandle_t shader; + float color[4]; + poly_t poly; + polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; +} decalPoly_t; + +enum +{ + DECALPOLY_TYPE_NORMAL, + DECALPOLY_TYPE_FADE, + DECALPOLY_TYPE_MAX +}; + +#define DECAL_FADE_TIME 1000 + +decalPoly_t* RE_AllocDecal( int type ); + +static decalPoly_t re_decalPolys[DECALPOLY_TYPE_MAX][MAX_DECAL_POLYS]; + +static int re_decalPolyHead[DECALPOLY_TYPE_MAX]; +static int re_decalPolyTotal[DECALPOLY_TYPE_MAX]; + +/* +=================== +RE_ClearDecals + +This is called to remove all decals from the world +=================== +*/ +void RE_ClearDecals( void ) { + memset( re_decalPolys, 0, sizeof(re_decalPolys) ); + memset( re_decalPolyHead, 0, sizeof(re_decalPolyHead) ); + memset( re_decalPolyTotal, 0, sizeof(re_decalPolyTotal) ); +} + +void R_InitDecals( void ) { + RE_ClearDecals(); +} + +void RE_FreeDecal( int type, int index ) { + if ( !re_decalPolys[type][index].time ) + return; + + if ( type == DECALPOLY_TYPE_NORMAL ) { + decalPoly_t* fade; + + fade = RE_AllocDecal( DECALPOLY_TYPE_FADE ); + + memcpy( fade, &re_decalPolys[type][index], sizeof( decalPoly_t ) ); + + fade->time = tr.refdef.time; + fade->fadetime = tr.refdef.time + DECAL_FADE_TIME; + } + + re_decalPolys[type][index].time = 0; + + re_decalPolyTotal[type]--; +} + +/* +=================== +RE_AllocDecal + +Will allways succeed, even if it requires freeing an old active mark +=================== +*/ +decalPoly_t* RE_AllocDecal( int type ) { + decalPoly_t *le; + + // See if the cvar changed + if ( re_decalPolyTotal[type] > r_markcount->integer ) + RE_ClearDecals(); + + le = &re_decalPolys[type][re_decalPolyHead[type]]; + + // If it has no time its the first occasion its been used + if ( le->time ) { + if ( le->time != tr.refdef.time ) { + int i = re_decalPolyHead[type]; + + // since we are killing one that existed before, make sure we + // kill all the other marks that belong to the group + do { + i++; + if ( i >= r_markcount->integer ) + i = 0; + + // Break out on the first one thats not part of the group + if ( re_decalPolys[type][i].time != le->time ) + break; + + RE_FreeDecal ( type, i ); + } while ( i != re_decalPolyHead[type] ); + + RE_FreeDecal( type, re_decalPolyHead[type] ); + } + else + RE_FreeDecal( type, re_decalPolyHead[type] ); + } + + memset( le, 0, sizeof(decalPoly_t) ); + le->time = tr.refdef.time; + + re_decalPolyTotal[type]++; + + // Move on to the next decal poly and wrap around if need be + re_decalPolyHead[type]++; + if ( re_decalPolyHead[type] >= r_markcount->integer ) + re_decalPolyHead[type] = 0; + + return le; +} + +/* +================= +RE_AddDecalToScene + +origin should be a point within a unit of the plane +dir should be the plane normal + +temporary marks will not be stored or randomly oriented, but immediately +passed to the renderer. +================= +*/ +#define MAX_DECAL_FRAGMENTS 128 +#define MAX_DECAL_POINTS 384 + +void RE_AddDecalToScene( qhandle_t decalShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary ) +{ + matrix3_t axis; + float texCoordScale; + vec3_t originalPoints[4]; + byte colors[4]; + int i, j; + int numFragments; + markFragment_t markFragments[MAX_DECAL_FRAGMENTS], *mf; + vec3_t markPoints[MAX_DECAL_POINTS]; + vec3_t projection; + + assert(decalShader); + + if ( r_markcount->integer <= 0 && !temporary ) + return; + + if ( radius <= 0 ) + Com_Error( ERR_FATAL, "RE_AddDecalToScene: called with <= 0 radius" ); + + // create the texture axis + VectorNormalize2( dir, axis[0] ); + PerpendicularVector( axis[1], axis[0] ); + RotatePointAroundVector( axis[2], axis[0], axis[1], orientation ); + CrossProduct( axis[0], axis[2], axis[1] ); + + texCoordScale = 0.5 * 1.0 / radius; + + // create the full polygon + for ( i = 0 ; i < 3 ; i++ ) + { + originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; + originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; + originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i]; + originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i]; + } + + // get the fragments + VectorScale( dir, -20, projection ); + numFragments = R_MarkFragments( 4, (const vec3_t*)originalPoints, + projection, MAX_DECAL_POINTS, markPoints[0], + MAX_DECAL_FRAGMENTS, markFragments ); + + colors[0] = red * 255; + colors[1] = green * 255; + colors[2] = blue * 255; + colors[3] = alpha * 255; + + for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) + { + polyVert_t *v; + polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; + decalPoly_t *decal; + + // we have an upper limit on the complexity of polygons + // that we store persistantly + if ( mf->numPoints > MAX_VERTS_ON_DECAL_POLY ) + mf->numPoints = MAX_VERTS_ON_DECAL_POLY; + + for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) + { + vec3_t delta; + + VectorCopy( markPoints[mf->firstPoint + j], v->xyz ); + + VectorSubtract( v->xyz, origin, delta ); + v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale; + v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale; + + *(int *)v->modulate = *(int *)colors; + } + + // if it is a temporary (shadow) mark, add it immediately and forget about it + if ( temporary ) + { + RE_AddPolyToScene( decalShader, mf->numPoints, verts, 1 ); + continue; + } + + // otherwise save it persistantly + decal = RE_AllocDecal( DECALPOLY_TYPE_NORMAL ); + decal->time = tr.refdef.time; + decal->shader = decalShader; + decal->poly.numVerts = mf->numPoints; + decal->color[0] = red; + decal->color[1] = green; + decal->color[2] = blue; + decal->color[3] = alpha; + memcpy( decal->verts, verts, mf->numPoints * sizeof( verts[0] ) ); + } +} + +/* +=============== +R_AddDecals +=============== +*/ +void R_AddDecals( void ) +{ + int decalPoly; + int type; + static int lastMarkCount = -1; + + if ( r_markcount->integer != lastMarkCount ) { + if ( lastMarkCount != -1 ) + RE_ClearDecals(); + + lastMarkCount = r_markcount->integer; + } + + if ( r_markcount->integer <= 0 ) + return; + + for ( type = DECALPOLY_TYPE_NORMAL; type < DECALPOLY_TYPE_MAX; type ++ ) + { + decalPoly = re_decalPolyHead[type]; + + do + { + decalPoly_t* p = &re_decalPolys[type][decalPoly]; + + if ( p->time ) + { + if ( p->fadetime ) + { + int t; + + // fade all marks out with time + t = tr.refdef.time - p->time; + if ( t < DECAL_FADE_TIME ) + { + float fade; + int j; + + fade = 255.0f * (1.0f - ((float)t / DECAL_FADE_TIME)); + + for ( j = 0 ; j < p->poly.numVerts ; j++ ) + { + p->verts[j].modulate[3] = fade; + } + + RE_AddPolyToScene( p->shader, p->poly.numVerts, p->verts, 1 ); + } + else + { + RE_FreeDecal ( type, decalPoly ); + } + } + else + { + RE_AddPolyToScene( p->shader, p->poly.numVerts, p->verts, 1 ); + } + } + + decalPoly++; + if ( decalPoly >= r_markcount->integer ) + { + decalPoly = 0; + } + } + while ( decalPoly != re_decalPolyHead[type] ); + } +} diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8767b7f48c..ee55aee9c3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1728,8 +1728,6 @@ typedef struct model_s { #define MAX_MOD_KNOWN 1024 void R_ModelInit (void); -void R_InitDecals (void); -void RE_ClearDecals ( void ); model_t *R_GetModelByHandle( qhandle_t hModel ); int R_LerpTag( orientation_t *tag, qhandle_t handle, int startFrame, int endFrame, @@ -2694,7 +2692,6 @@ void RE_ClearScene( void ); void RE_AddRefEntityToScene( const refEntity_t *ent ); void RE_AddMiniRefEntityToScene( const miniRefEntity_t *miniRefEnt ); void RE_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts, int num ); -void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary ); void RE_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_AddAdditiveLightToScene( const vec3_t org, float intensity, float r, float g, float b ); void RE_BeginScene( const refdef_t *fd ); @@ -3030,6 +3027,11 @@ void RE_InsertModelIntoHash(const char *name, model_t *mod); Ghoul2 Insert End */ +void R_InitDecals( void ); +void RE_ClearDecals( void ); +void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t dir, float orientation, float r, float g, float b, float a, qboolean alphaFade, float radius, qboolean temporary ); +void R_AddDecals( void ); + image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index ead9920b56..63fe26cf65 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -425,6 +425,11 @@ void RE_BeginScene(const refdef_t *fd) tr.refdef.num_dlights = r_numdlights - r_firstSceneDlight; tr.refdef.dlights = &backEndData->dlights[r_firstSceneDlight]; + // Add the decals here because decals add polys and we need to ensure + // that the polys are added before the the renderer is prepared + if ( !(tr.refdef.rdflags & RDF_NOWORLDMODEL) ) + R_AddDecals(); + tr.refdef.numPolys = r_numpolys - r_firstScenePoly; tr.refdef.polys = &backEndData->polys[r_firstScenePoly]; @@ -562,258 +567,3 @@ void RE_RenderScene( const refdef_t *fd ) { tr.frontEndMsec += ri->Milliseconds() - startTime; } - -enum -{ - DECALPOLY_TYPE_NORMAL, - DECALPOLY_TYPE_FADE, - DECALPOLY_TYPE_MAX -}; - -#define MAX_VERTS_ON_DECAL_POLY 10 -#define MAX_DECAL_POLYS 500 - -typedef struct decalPoly_s -{ - int time; - int fadetime; - qhandle_t shader; - float color[4]; - poly_t poly; - polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; - -} decalPoly_t; - -#define DECAL_FADE_TIME 1000 - -decalPoly_t* RE_AllocDecal ( int type ); - -static decalPoly_t re_decalPolys[DECALPOLY_TYPE_MAX][MAX_DECAL_POLYS]; - -static int re_decalPolyHead[DECALPOLY_TYPE_MAX]; -static int re_decalPolyTotal[DECALPOLY_TYPE_MAX]; - -/* -=================== -RE_ClearDecals - -This is called to remove all decals from the world -=================== -*/ - -void RE_ClearDecals ( void ) -{ - memset( re_decalPolys, 0, sizeof(re_decalPolys) ); - memset( re_decalPolyHead, 0, sizeof(re_decalPolyHead) ); - memset( re_decalPolyTotal, 0, sizeof(re_decalPolyTotal) ); -} - -void R_InitDecals ( void ) -{ - RE_ClearDecals ( ); -} - -static void RE_FreeDecal ( int type, int index ) -{ - if ( !re_decalPolys[type][index].time ) - { - return; - } - - if ( type == DECALPOLY_TYPE_NORMAL ) - { - decalPoly_t* fade; - - fade = RE_AllocDecal ( DECALPOLY_TYPE_FADE ); - - memcpy ( fade, &re_decalPolys[type][index], sizeof(decalPoly_t) ); - - fade->time = tr.refdef.time; - fade->fadetime = tr.refdef.time + DECAL_FADE_TIME; - } - - re_decalPolys[type][index].time = 0; - - re_decalPolyTotal[type]--; -} - -/* -=================== -RE_AllocDecal - -Will allways succeed, even if it requires freeing an old active mark -=================== -*/ -static decalPoly_t* RE_AllocDecal( int type ) -{ - decalPoly_t *le; - - // See if the cvar changed - if ( re_decalPolyTotal[type] > r_markcount->integer ) - { - RE_ClearDecals ( ); - } - - le = &re_decalPolys[type][re_decalPolyHead[type]]; - - // If it has no time its the first occasion its been used - if ( le->time ) - { - if ( le->time != tr.refdef.time ) - { - int i = re_decalPolyHead[type]; - - // since we are killing one that existed before, make sure we - // kill all the other marks that belong to the group - do - { - i++; - if ( i >= r_markcount->integer ) - { - i = 0; - } - - // Break out on the first one thats not part of the group - if ( re_decalPolys[type][i].time != le->time ) - { - break; - } - - RE_FreeDecal ( type, i ); - } - while ( i != re_decalPolyHead[type] ); - - RE_FreeDecal ( type, re_decalPolyHead[type] ); - } - else - { - RE_FreeDecal ( type, re_decalPolyHead[type] ); - } - } - - memset ( le, 0, sizeof(decalPoly_t) ); - le->time = tr.refdef.time; - - re_decalPolyTotal[type]++; - - // Move on to the next decal poly and wrap around if need be - re_decalPolyHead[type]++; - if ( re_decalPolyHead[type] >= r_markcount->integer ) - { - re_decalPolyHead[type] = 0; - } - - return le; -} - -/* -================= -RE_AddDecalToScene - -origin should be a point within a unit of the plane -dir should be the plane normal - -temporary marks will not be stored or randomly oriented, but immediately -passed to the renderer. -================= -*/ -#define MAX_DECAL_FRAGMENTS 128 -#define MAX_DECAL_POINTS 384 - -void RE_AddDecalToScene ( qhandle_t decalShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary ) -{ - vec3_t axis[3]; - float texCoordScale; - vec3_t originalPoints[4]; - byte colors[4]; - int i, j; - int numFragments; - markFragment_t markFragments[MAX_DECAL_FRAGMENTS], *mf; - vec3_t markPoints[MAX_DECAL_POINTS]; - vec3_t projection; - - assert(decalShader); - - if ( r_markcount->integer <= 0 && !temporary ) - { - return; - } - - if ( radius <= 0 ) - { - Com_Error( ERR_FATAL, "RE_AddDecalToScene: called with <= 0 radius" ); - } - - // create the texture axis - VectorNormalize2( dir, axis[0] ); - PerpendicularVector( axis[1], axis[0] ); - RotatePointAroundVector( axis[2], axis[0], axis[1], orientation ); - CrossProduct( axis[0], axis[2], axis[1] ); - - texCoordScale = 0.5 * 1.0 / radius; - - // create the full polygon - for ( i = 0 ; i < 3 ; i++ ) - { - originalPoints[0][i] = origin[i] - radius * axis[1][i] - radius * axis[2][i]; - originalPoints[1][i] = origin[i] + radius * axis[1][i] - radius * axis[2][i]; - originalPoints[2][i] = origin[i] + radius * axis[1][i] + radius * axis[2][i]; - originalPoints[3][i] = origin[i] - radius * axis[1][i] + radius * axis[2][i]; - } - - // get the fragments - VectorScale( dir, -20, projection ); - numFragments = R_MarkFragments( 4, (const vec3_t*)originalPoints, - projection, MAX_DECAL_POINTS, markPoints[0], - MAX_DECAL_FRAGMENTS, markFragments ); - - colors[0] = red * 255; - colors[1] = green * 255; - colors[2] = blue * 255; - colors[3] = alpha * 255; - - for ( i = 0, mf = markFragments ; i < numFragments ; i++, mf++ ) - { - polyVert_t *v; - polyVert_t verts[MAX_VERTS_ON_DECAL_POLY]; - decalPoly_t *decal; - - // we have an upper limit on the complexity of polygons - // that we store persistantly - if ( mf->numPoints > MAX_VERTS_ON_DECAL_POLY ) - { - mf->numPoints = MAX_VERTS_ON_DECAL_POLY; - } - - for ( j = 0, v = verts ; j < mf->numPoints ; j++, v++ ) - { - vec3_t delta; - - VectorCopy( markPoints[mf->firstPoint + j], v->xyz ); - - VectorSubtract( v->xyz, origin, delta ); - v->st[0] = 0.5 + DotProduct( delta, axis[1] ) * texCoordScale; - v->st[1] = 0.5 + DotProduct( delta, axis[2] ) * texCoordScale; - - *(int *)v->modulate = *(int *)colors; - } - - // if it is a temporary (shadow) mark, add it immediately and forget about it - if ( temporary ) - { - RE_AddPolyToScene( decalShader, mf->numPoints, verts, 1 ); - continue; - } - - // otherwise save it persistantly - decal = RE_AllocDecal( DECALPOLY_TYPE_NORMAL ); - decal->time = tr.refdef.time; - decal->shader = decalShader; - decal->poly.numVerts = mf->numPoints; - decal->color[0] = red; - decal->color[1] = green; - decal->color[2] = blue; - decal->color[3] = alpha; - memcpy( decal->verts, verts, mf->numPoints * sizeof( verts[0] ) ); - } -} From cd7b011aeab0efce2c0e0ede0c48c7f9c8a6eca2 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 18 Dec 2013 18:06:52 -0600 Subject: [PATCH 142/708] [MP] Rend2: r_swapInterval only requires CVAR_LATCH with SDL. --- codemp/rd-rend2/tr_init.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 1b1f05465b..c22de0fe33 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1170,6 +1170,12 @@ void GfxMemInfo_f( void ) } } +#ifdef _WIN32 +#define SWAPINTERVAL_FLAGS CVAR_ARCHIVE +#else +#define SWAPINTERVAL_FLAGS CVAR_ARCHIVE | CVAR_LATCH +#endif + /* =============== R_Register @@ -1316,7 +1322,7 @@ void R_Register( void ) r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); r_swapInterval = ri->Cvar_Get( "r_swapInterval", "0", - CVAR_ARCHIVE | CVAR_LATCH ); + SWAPINTERVAL_FLAGS ); r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE ); r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); From 35f160b76317dcfa6b41bc320d0b6fba4ed6af78 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 18 Dec 2013 18:14:24 -0600 Subject: [PATCH 143/708] [MP] Rend2: Add range check for r_subdivisions. Fix range check for r_displayRefresh. --- codemp/rd-rend2/tr_init.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c22de0fe33..2fd74508ae 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1232,6 +1232,7 @@ void R_Register( void ) r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0); r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); + ri->Cvar_CheckRange( r_subdivisions, 4, 80, qfalse ); r_stereo = ri->Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH); r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); @@ -1300,7 +1301,7 @@ void R_Register( void ) r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); r_displayRefresh = ri->Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH ); - ri->Cvar_CheckRange( r_displayRefresh, 0, 200, qtrue ); + ri->Cvar_CheckRange( r_displayRefresh, 0, 240, qtrue ); // // archived variables that can change at any time From 458ba7cf2eb98077c7869830a33fa4bad4db793e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 21 Dec 2013 00:34:54 +0000 Subject: [PATCH 144/708] [Rend2] Changes for light styles and lightmaps This commit adds the majority of code for supporting multiple lightmaps and light styles. Remaining work for this, is to change the light map texture coordinates of the map surface depending on the shader being used. --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 2 +- codemp/rd-rend2/glsl/generic_vp.glsl | 2 +- codemp/rd-rend2/glsl/lightall_vp.glsl | 2 +- codemp/rd-rend2/tr_bsp.cpp | 201 ++++++++++-------- codemp/rd-rend2/tr_cache.cpp | 2 +- codemp/rd-rend2/tr_curve.cpp | 15 +- codemp/rd-rend2/tr_ghoul2.cpp | 2 +- codemp/rd-rend2/tr_glsl.cpp | 6 + codemp/rd-rend2/tr_init.cpp | 11 +- codemp/rd-rend2/tr_local.h | 22 +- codemp/rd-rend2/tr_model.cpp | 4 +- codemp/rd-rend2/tr_model_iqm.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 3 + codemp/rd-rend2/tr_shader.cpp | 290 ++++++++++++++++++++------ codemp/rd-rend2/tr_skin.cpp | 6 +- codemp/rd-rend2/tr_surface.cpp | 8 +- 16 files changed, 404 insertions(+), 174 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index b3421f5669..c1c751444d 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -26,7 +26,7 @@ uniform mat4 u_ModelViewProjectionMatrix; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[80]; +uniform mat4 u_BoneMatrices[20]; #endif uniform vec4 u_Color; diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index df690c5753..0638cc4380 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -58,7 +58,7 @@ uniform float u_PortalRange; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[80]; +uniform mat4 u_BoneMatrices[20]; #endif varying vec2 var_DiffuseTex; diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 3d8d96cd47..b381bb137f 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -56,7 +56,7 @@ uniform mat4 u_ModelMatrix; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[80]; +uniform mat4 u_BoneMatrices[20]; #endif #if defined(USE_LIGHT_VECTOR) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3bd55f7bb9..bae4867bed 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -211,13 +211,19 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { else { tr.worldDeluxeMapping = qtrue; + + // Check that none of the deluxe maps are referenced by any of the map surfaces. for( i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); - i < surfs->filelen / sizeof(dsurface_t); i++, surf++ ) { - int lightmapNum = LittleLong( surf->lightmapNum[0] ); + tr.worldDeluxeMapping && i < surfs->filelen / sizeof(dsurface_t); + i++, surf++ ) { + for ( int j = 0; j < MAXLIGHTMAPS; j++ ) + { + int lightmapNum = LittleLong( surf->lightmapNum[j] ); - if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { - tr.worldDeluxeMapping = qfalse; - break; + if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { + tr.worldDeluxeMapping = qfalse; + break; + } } } } @@ -227,13 +233,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { if (tr.worldDeluxeMapping) numLightmaps >>= 1; - if(numLightmaps == 1) - { - //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason. - //this avoids this, but isn't the correct solution. - numLightmaps++; - } - else if (r_mergeLightmaps->integer && numLightmaps >= 1024 ) + if (r_mergeLightmaps->integer && numLightmaps >= 1024 ) { // FIXME: fat light maps don't support more than 1024 light maps ri->Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n"); @@ -618,9 +618,10 @@ static void R_LoadVisibility( lump_t *l ) { ShaderForShaderNum =============== */ -static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { +static shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNums, const byte *lightmapStyles, const byte *vertexStyles ) { shader_t *shader; dshader_t *dsh; + const byte *styles = lightmapStyles; int _shaderNum = LittleLong( shaderNum ); if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) { @@ -628,15 +629,20 @@ static shader_t *ShaderForShaderNum( int shaderNum, int lightmapNum ) { } dsh = &s_worldData.shaders[ _shaderNum ]; + if ( lightmapNums[0] == LIGHTMAP_BY_VERTEX ) { + styles = vertexStyles; + } + if ( r_vertexLight->integer ) { - lightmapNum = LIGHTMAP_BY_VERTEX; + lightmapNums = lightmapsVertex; + styles = vertexStyles; } if ( r_fullbright->integer ) { - lightmapNum = LIGHTMAP_WHITEIMAGE; + lightmapNums = lightmapsFullBright; } - shader = R_FindShader( dsh->shader, lightmapNum, qtrue ); + shader = R_FindShader( dsh->shader, lightmapNums, styles, qtrue ); // if the shader had errors, just use default shader if ( shader->defaultShader ) { @@ -656,15 +662,18 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, srfBspSurface_t *cv; glIndex_t *tri; int numVerts, numIndexes, badTriangles; - int realLightmapNum; + int realLightmapNum[MAXLIGHTMAPS]; - realLightmapNum = LittleLong( ds->lightmapNum[0] ); + for ( j = 0; j < MAXLIGHTMAPS; j++ ) + { + realLightmapNum[j] = FatLightmap (LittleLong (ds->lightmapNum[j])); + } // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); + surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -701,41 +710,46 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, cv->verts[i].xyz[j] = LittleFloat(verts[i].xyz[j]); cv->verts[i].normal[j] = LittleFloat(verts[i].normal[j]); } + AddPointToBounds(cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); + for(j = 0; j < 2; j++) { cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); - //cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); } - cv->verts[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0][0]), realLightmapNum); - cv->verts[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[0][1]), realLightmapNum); - if (hdrVertColors) + for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; - } - else - { - //hack: convert LDR vertex colors to HDR - if (r_hdr->integer) + cv->verts[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), realLightmapNum[j]); + cv->verts[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), realLightmapNum[j]); + + if (hdrVertColors) { - color[0] = verts[i].color[0][0] + 1.0f; - color[1] = verts[i].color[0][1] + 1.0f; - color[2] = verts[i].color[0][2] + 1.0f; + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; } else { - color[0] = verts[i].color[0][0]; - color[1] = verts[i].color[0][1]; - color[2] = verts[i].color[0][2]; + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[j][0] + 1.0f; + color[1] = verts[i].color[j][1] + 1.0f; + color[2] = verts[i].color[j][2] + 1.0f; + } + else + { + color[0] = verts[i].color[j][0]; + color[1] = verts[i].color[j][1]; + color[2] = verts[i].color[j][2]; + } + } + color[3] = verts[i].color[j][3] / 255.0f; + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], 1.0f / 255.0f ); } - color[3] = verts[i].color[0][3] / 255.0f; - - R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); } // copy triangles @@ -808,15 +822,18 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, vec3_t bounds[2]; vec3_t tmpVec; static surfaceType_t skipData = SF_SKIP; - int realLightmapNum; + int realLightmapNum[MAXLIGHTMAPS]; - realLightmapNum = LittleLong( ds->lightmapNum[0] ); + for ( j = 0; j < MAXLIGHTMAPS; j++ ) + { + realLightmapNum[j] = FatLightmap (LittleLong (ds->lightmapNum[j])); + } // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, FatLightmap(realLightmapNum) ); + surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -849,36 +866,39 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, for(j = 0; j < 2; j++) { points[i].st[j] = LittleFloat(verts[i].st[j]); - //points[i].lightmap[j] = LittleFloat(verts[i].lightmap[j]); } - points[i].lightmap[0] = FatPackU(LittleFloat(verts[i].lightmap[0][0]), realLightmapNum); - points[i].lightmap[1] = FatPackV(LittleFloat(verts[i].lightmap[0][1]), realLightmapNum); - if (hdrVertColors) - { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; - } - else + for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - //hack: convert LDR vertex colors to HDR - if (r_hdr->integer) + points[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), realLightmapNum[j]); + points[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), realLightmapNum[j]); + + if (hdrVertColors) { - color[0] = verts[i].color[0][0] + 1.0f; - color[1] = verts[i].color[0][1] + 1.0f; - color[2] = verts[i].color[0][2] + 1.0f; + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; } else { - color[0] = verts[i].color[0][0]; - color[1] = verts[i].color[0][1]; - color[2] = verts[i].color[0][2]; + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[j][0] + 1.0f; + color[1] = verts[i].color[j][1] + 1.0f; + color[2] = verts[i].color[j][2] + 1.0f; + } + else + { + color[0] = verts[i].color[j][0]; + color[1] = verts[i].color[j][1]; + color[2] = verts[i].color[j][2]; + } } - } - color[3] = verts[i].color[0][3] / 255.0f; + color[3] = verts[i].color[j][3] / 255.0f; - R_ColorShiftLightingFloats( color, points[i].vertexColors, 1.0f / 255.0f ); + R_ColorShiftLightingFloats( color, points[i].vertexColors[j], 1.0f / 255.0f ); + } } // pre-tesseleate @@ -913,7 +933,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); + surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -952,34 +972,39 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor for(j = 0; j < 2; j++) { cv->verts[i].st[j] = LittleFloat(verts[i].st[j]); - cv->verts[i].lightmap[j] = LittleFloat(verts[i].lightmap[0][j]); } - if (hdrVertColors) - { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; - } - else + for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - //hack: convert LDR vertex colors to HDR - if (r_hdr->integer) + cv->verts[i].lightmap[j][0] = LittleFloat(verts[i].lightmap[j][0]); + cv->verts[i].lightmap[j][1] = LittleFloat(verts[i].lightmap[j][1]); + + if (hdrVertColors) { - color[0] = verts[i].color[0][0] + 1.0f; - color[1] = verts[i].color[0][1] + 1.0f; - color[2] = verts[i].color[0][2] + 1.0f; + color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; + color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; + color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; } else { - color[0] = verts[i].color[0][0]; - color[1] = verts[i].color[0][1]; - color[2] = verts[i].color[0][2]; + //hack: convert LDR vertex colors to HDR + if (r_hdr->integer) + { + color[0] = verts[i].color[j][0] + 1.0f; + color[1] = verts[i].color[j][1] + 1.0f; + color[2] = verts[i].color[j][2] + 1.0f; + } + else + { + color[0] = verts[i].color[j][0]; + color[1] = verts[i].color[j][1]; + color[2] = verts[i].color[j][2]; + } } - } - color[3] = verts[i].color[0][3] / 255.0f; + color[3] = verts[i].color[j][3] / 255.0f; - R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors, 1.0f / 255.0f ); + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], 1.0f / 255.0f ); + } } // copy triangles @@ -1040,7 +1065,7 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX ); + surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -1822,12 +1847,12 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out) for(j = 0; j < 2; j++) { out->st[j] = in->st[j]; - out->lightmap[j] = in->lightmap[j]; + Com_Memcpy (out->lightmap[j], in->lightmap[j], sizeof (out->lightmap[0])); } for(j = 0; j < 4; j++) { - out->vertexColors[j] = in->vertexColors[j]; + Com_Memcpy (out->vertexColors[j], in->vertexColors[j], sizeof (out->vertexColors[0])); } } @@ -2507,7 +2532,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { } // get information from the shader for fog parameters - shader = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue ); + shader = R_FindShader( fogs->shader, lightmapsNone, stylesDefault, qtrue ); out->parms = shader->fogParms; diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 4d9bd11632..055fdfa2ba 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -347,7 +347,7 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; - shader_t *sh = R_FindShader( psShaderName, LIGHTMAP_NONE, qtrue ); + shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue ); if ( sh->defaultShader ) *piShaderPokePtr = 0; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 9a0f8807af..4dc3ee227c 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -51,13 +51,16 @@ static void LerpDrawVert( srfVert_t *a, srfVert_t *b, srfVert_t *out ) { out->st[0] = 0.5f * (a->st[0] + b->st[0]); out->st[1] = 0.5f * (a->st[1] + b->st[1]); - out->lightmap[0] = 0.5f * (a->lightmap[0] + b->lightmap[0]); - out->lightmap[1] = 0.5f * (a->lightmap[1] + b->lightmap[1]); + for ( int i = 0; i < MAXLIGHTMAPS; i++ ) + { + out->lightmap[i][0] = 0.5f * (a->lightmap[i][0] + b->lightmap[i][0]); + out->lightmap[i][1] = 0.5f * (a->lightmap[i][1] + b->lightmap[i][1]); - out->vertexColors[0] = 0.5f * (a->vertexColors[0] + b->vertexColors[0]); - out->vertexColors[1] = 0.5f * (a->vertexColors[1] + b->vertexColors[1]); - out->vertexColors[2] = 0.5f * (a->vertexColors[2] + b->vertexColors[2]); - out->vertexColors[3] = 0.5f * (a->vertexColors[3] + b->vertexColors[3]); + out->vertexColors[i][0] = 0.5f * (a->vertexColors[i][0] + b->vertexColors[i][0]); + out->vertexColors[i][1] = 0.5f * (a->vertexColors[i][1] + b->vertexColors[i][1]); + out->vertexColors[i][2] = 0.5f * (a->vertexColors[i][2] + b->vertexColors[i][2]); + out->vertexColors[i][3] = 0.5f * (a->vertexColors[i][3] + b->vertexColors[i][3]); + } } /* diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 9bc61f8869..5d4c8b2058 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4308,7 +4308,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean shader_t *sh; // get the shader name - sh = R_FindShader( surfInfo->shader, LIGHTMAP_NONE, qtrue ); + sh = R_FindShader( surfInfo->shader, lightmapsNone, stylesDefault, qtrue ); // insert it in the surface list if ( sh->defaultShader ) { diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c65db31592..b6d1322831 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -277,12 +277,18 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha va("#ifndef tcGen_t\n" "#define tcGen_t\n" "#define TCGEN_LIGHTMAP %i\n" + "#define TCGEN_LIGHTMAP1 %i\n" + "#define TCGEN_LIGHTMAP2 %i\n" + "#define TCGEN_LIGHTMAP3 %i\n" "#define TCGEN_TEXTURE %i\n" "#define TCGEN_ENVIRONMENT_MAPPED %i\n" "#define TCGEN_FOG %i\n" "#define TCGEN_VECTOR %i\n" "#endif\n", TCGEN_LIGHTMAP, + TCGEN_LIGHTMAP1, + TCGEN_LIGHTMAP2, + TCGEN_LIGHTMAP3, TCGEN_TEXTURE, TCGEN_ENVIRONMENT_MAPPED, TCGEN_FOG, diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 2fd74508ae..5346f9ff4a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1449,6 +1449,8 @@ void R_ShutDownQueries(void) qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } +void RE_SetLightStyle (int style, int color); + /* =============== R_Init @@ -1519,6 +1521,11 @@ void R_Init( void ) { backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); R_InitNextFrame(); + for ( int i = 0; i < MAXLIGHTMAPS; i++ ) + { + RE_SetLightStyle (i, -1); + } + InitOpenGL(); R_InitImages(); @@ -1639,7 +1646,7 @@ void RE_GetLightStyle(int style, color4ub_t color) { if (style >= MAX_LIGHT_STYLES) { - Com_Error( ERR_FATAL, "RE_GetLightStyle: %d is out of range", (int)style ); + Com_Error( ERR_FATAL, "RE_GetLightStyle: %d is out of range", style ); return; } @@ -1650,7 +1657,7 @@ void RE_SetLightStyle(int style, int color) { if (style >= MAX_LIGHT_STYLES) { - Com_Error( ERR_FATAL, "RE_SetLightStyle: %d is out of range", (int)style ); + Com_Error( ERR_FATAL, "RE_SetLightStyle: %d is out of range", style ); return; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ee55aee9c3..243f219b80 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -552,13 +552,17 @@ typedef enum { CGEN_LIGHTING_DIFFUSE, CGEN_LIGHTING_DIFFUSE_ENTITY, // diffuse lighting * entity CGEN_FOG, // standard fog - CGEN_CONST // fixed color + CGEN_CONST, // fixed color + CGEN_LIGHTMAPSTYLE, // lightmap style } colorGen_t; typedef enum { TCGEN_BAD, TCGEN_IDENTITY, // clear to 0,0 TCGEN_LIGHTMAP, + TCGEN_LIGHTMAP1, + TCGEN_LIGHTMAP2, + TCGEN_LIGHTMAP3, TCGEN_TEXTURE, TCGEN_ENVIRONMENT_MAPPED, TCGEN_FOG, @@ -703,6 +707,7 @@ typedef struct { acff_t adjustColorsForFog; qboolean isDetail; + int lightmapStyle; stageType_t type; struct shaderProgram_s *glslShaderGroup; @@ -737,7 +742,8 @@ typedef struct { typedef struct shader_s { char name[MAX_QPATH]; // game path, including extension - int lightmapIndex; // for a shader to match, both name and lightmapIndex must match + int lightmapIndex[MAXLIGHTMAPS]; // for a shader to match, both name and all lightmapIndex must match + byte styles[MAXLIGHTMAPS]; int index; // this shader == tr.shaders[index] int sortedIndex; // this shader == tr.sortedShaders[sortedIndex] @@ -1279,13 +1285,13 @@ typedef struct { vec3_t xyz; vec2_t st; - vec2_t lightmap; + vec2_t lightmap[MAXLIGHTMAPS]; vec3_t normal; #ifdef USE_VERT_TANGENT_SPACE vec4_t tangent; #endif vec3_t lightdir; - vec4_t vertexColors; + vec4_t vertexColors[MAXLIGHTMAPS]; #if DEBUG_OPTIMIZEVERTICES unsigned int id; @@ -2410,7 +2416,13 @@ void RE_HunkClearCrap(void); // // tr_shader.c // -shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ); +extern const int lightmapsNone[MAXLIGHTMAPS]; +extern const int lightmaps2d[MAXLIGHTMAPS]; +extern const int lightmapsVertex[MAXLIGHTMAPS]; +extern const int lightmapsFullBright[MAXLIGHTMAPS]; +extern const byte stylesDefault[MAXLIGHTMAPS]; + +shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ); shader_t *R_GetShaderByHandle( qhandle_t hShader ); shader_t *R_GetShaderByState( int index, long *cycleTime ); shader_t *R_FindShaderByName( const char *name ); diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 57abc33b42..3a9a26c7fa 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -969,7 +969,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN { shader_t *sh; - sh = R_FindShader(md3Shader->name, LIGHTMAP_NONE, qtrue); + sh = R_FindShader(md3Shader->name, lightmapsNone, stylesDefault, qtrue); if(sh->defaultShader) { *shaderIndex = 0; @@ -1442,7 +1442,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char Q_strlwr( surf->name ); // register the shaders - sh = R_FindShader(surf->shader, LIGHTMAP_NONE, qtrue); + sh = R_FindShader(surf->shader, lightmapsNone, stylesDefault, qtrue); if ( sh->defaultShader ) { surf->shaderIndex = 0; } else { diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 3de5b990b3..dc68142497 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -622,7 +622,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na surface->surfaceType = SF_IQM; Q_strncpyz(surface->name, str + mesh->name, sizeof (surface->name)); Q_strlwr(surface->name); // lowercase the surface name so skin compares are faster - surface->shader = R_FindShader( str + mesh->material, LIGHTMAP_NONE, qtrue ); + surface->shader = R_FindShader( str + mesh->material, lightmapsNone, stylesDefault, qtrue ); if( surface->shader->defaultShader ) surface->shader = tr.defaultShader; surface->data = iqmData; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 396b514ba1..529dec052d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -588,6 +588,9 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[3] = 1.0f - ((unsigned char *)backEnd.currentEntity->e.shaderRGBA)[3] / 255.0f; } break; + case CGEN_LIGHTMAPSTYLE: + VectorScale4 (styleColors[pStage->lightmapStyle], 1.0f / 255.0f, baseColor); + break; case CGEN_IDENTITY: case CGEN_LIGHTING_DIFFUSE: case CGEN_BAD: diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index b64386ad5d..dc15add593 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -37,7 +37,47 @@ static shader_t* hashTable[FILE_HASH_SIZE]; #define MAX_SHADERTEXT_HASH 2048 static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; -qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ); +const int lightmapsNone[MAXLIGHTMAPS] = +{ + LIGHTMAP_NONE, + LIGHTMAP_NONE, + LIGHTMAP_NONE, + LIGHTMAP_NONE +}; + +const int lightmaps2d[MAXLIGHTMAPS] = +{ + LIGHTMAP_2D, + LIGHTMAP_2D, + LIGHTMAP_2D, + LIGHTMAP_2D +}; + +const int lightmapsVertex[MAXLIGHTMAPS] = +{ + LIGHTMAP_BY_VERTEX, + LIGHTMAP_BY_VERTEX, + LIGHTMAP_BY_VERTEX, + LIGHTMAP_BY_VERTEX +}; + +const int lightmapsFullBright[MAXLIGHTMAPS] = +{ + LIGHTMAP_WHITEIMAGE, + LIGHTMAP_WHITEIMAGE, + LIGHTMAP_WHITEIMAGE, + LIGHTMAP_WHITEIMAGE +}; + +const byte stylesDefault[MAXLIGHTMAPS] = +{ + LS_NORMAL, + LS_LSNONE, + LS_LSNONE, + LS_LSNONE +}; + +qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndexes, const byte *styles ); void KillTheShaderHashTable(void) { @@ -103,7 +143,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh = R_FindShaderByName( shaderName ); if (sh == NULL || sh == tr.defaultShader) { - h = RE_RegisterShaderLightMap(shaderName, 0); + h = RE_RegisterShaderLightMap(shaderName, 0, stylesDefault); sh = R_GetShaderByHandle(h); } if (sh == NULL || sh == tr.defaultShader) { @@ -113,7 +153,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh2 = R_FindShaderByName( newShaderName ); if (sh2 == NULL || sh2 == tr.defaultShader) { - h = RE_RegisterShaderLightMap(newShaderName, 0); + h = RE_RegisterShaderLightMap(newShaderName, 0, stylesDefault); sh2 = R_GetShaderByHandle(h); } @@ -677,10 +717,10 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "$lightmap" ) ) { stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex < 0 ) { + if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { stage->bundle[0].image[0] = tr.whiteImage; } else { - stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; } continue; } @@ -693,10 +733,10 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex < 0 ) { + if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { stage->bundle[0].image[0] = tr.whiteImage; } else { - stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex]; + stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } continue; } @@ -1103,7 +1143,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else if ( !Q_stricmp( token, "lightingDiffuseEntity" ) ) { - if (shader.lightmapIndex != LIGHTMAP_NONE) + if (shader.lightmapIndex[0] != LIGHTMAP_NONE) { Com_Printf( S_COLOR_RED "ERROR: rgbGen lightingDiffuseEntity used on a misc_model! in shader '%s'\n", shader.name ); } @@ -2157,6 +2197,9 @@ static void ComputeVertexAttribs(void) shader.vertexAttribs |= ATTR_TEXCOORD; break; case TCGEN_LIGHTMAP: + case TCGEN_LIGHTMAP1: + case TCGEN_LIGHTMAP2: + case TCGEN_LIGHTMAP3: shader.vertexAttribs |= ATTR_LIGHTCOORD; break; case TCGEN_ENVIRONMENT_MAPPED: @@ -2382,7 +2425,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { //ri->Printf(PRINT_ALL, ", deluxemap"); diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; - diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex]; + diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } if (r_normalMapping->integer) @@ -2456,7 +2499,10 @@ static qboolean CollapseStagesToGLSL(void) { // if 2+ stages and first stage is lightmap, switch them // this makes it easier for the later bits to process - if (stages[0].active && stages[0].bundle[0].tcGen == TCGEN_LIGHTMAP && stages[1].active) + if (stages[0].active && + stages[0].bundle[0].tcGen >= TCGEN_LIGHTMAP && + stages[0].bundle[0].tcGen <= TCGEN_LIGHTMAP3 && + stages[1].active) { int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2493,7 +2539,7 @@ static qboolean CollapseStagesToGLSL(void) break; } - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2509,6 +2555,9 @@ static qboolean CollapseStagesToGLSL(void) { case TCGEN_TEXTURE: case TCGEN_LIGHTMAP: + case TCGEN_LIGHTMAP1: + case TCGEN_LIGHTMAP2: + case TCGEN_LIGHTMAP3: case TCGEN_ENVIRONMENT_MAPPED: case TCGEN_VECTOR: break; @@ -2545,7 +2594,7 @@ static qboolean CollapseStagesToGLSL(void) continue; // skip lightmaps - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) continue; diffuse = pStage; @@ -2587,7 +2636,7 @@ static qboolean CollapseStagesToGLSL(void) break; case ST_COLORMAP: - if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { lightmap = pStage2; } @@ -2600,7 +2649,7 @@ static qboolean CollapseStagesToGLSL(void) tcgen = qfalse; if (diffuse->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED - || diffuse->bundle[0].tcGen == TCGEN_LIGHTMAP + || (diffuse->bundle[0].tcGen >= TCGEN_LIGHTMAP && diffuse->bundle[0].tcGen <= TCGEN_LIGHTMAP3) || diffuse->bundle[0].tcGen == TCGEN_VECTOR) { tcgen = qtrue; @@ -2630,7 +2679,7 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { pStage->active = qfalse; } @@ -2696,7 +2745,7 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->bundle[TB_DIFFUSEMAP].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; @@ -2989,7 +3038,7 @@ static void VertexLightingCollapse( void ) { stages[0].bundle[0] = bestStage->bundle[0]; stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); stages[0].stateBits |= GLS_DEPTHMASK_TRUE; - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + if ( shader.lightmapIndex[0] == LIGHTMAP_NONE ) { stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; } else { stages[0].rgbGen = CGEN_EXACT_VERTEX; @@ -3026,6 +3075,33 @@ static void VertexLightingCollapse( void ) { } } +int FindFirstLightmapStage ( const shaderStage_t *stages, int numStages ) +{ + for ( int i = 0; i < numStages; i++ ) + { + const shaderStage_t *stage = &stages[i]; + if ( stage->active && stage->bundle[0].isLightmap ) + { + return i; + } + } + + return numStages; +} + +int GetNumStylesInShader ( const shader_t *shader ) +{ + for ( int i = 0; i < MAXLIGHTMAPS; i++ ) + { + if ( shader->styles[i] >= LS_UNUSED ) + { + return i - 1; + } + } + + return 0; +} + /* ========================= FinishShader @@ -3035,7 +3111,8 @@ from the current global working shader ========================= */ static shader_t *FinishShader( void ) { - int stage; + int stage, firstLightmapStage; + shaderStage_t *lmStage; qboolean hasLightmapStage = qfalse; // @@ -3052,6 +3129,78 @@ static shader_t *FinishShader( void ) { shader.sort = SS_DECAL; } + firstLightmapStage = FindFirstLightmapStage (stages, MAX_SHADER_STAGES); + lmStage = &stages[firstLightmapStage]; + + if ( firstLightmapStage != MAX_SHADER_STAGES ) + { + if ( shader.lightmapIndex[0] == LIGHTMAP_BY_VERTEX ) + { + if ( firstLightmapStage == 0 ) + { + // Shift all stages above it down 1. + memmove (lmStage, + lmStage + 1, + sizeof (shaderStage_t) * (MAX_SHADER_STAGES - firstLightmapStage - 1)); + memset (stages + MAX_SHADER_STAGES - 1, 0, sizeof (shaderStage_t)); + + // Set state bits back to default on the over-written stage. + lmStage->stateBits = GLS_DEFAULT; + } + + lmStage->rgbGen = CGEN_EXACT_VERTEX; + lmStage->alphaGen = AGEN_SKIP; + + firstLightmapStage = MAX_SHADER_STAGES; + } + } + + if ( firstLightmapStage != MAX_SHADER_STAGES ) + { + int numStyles = GetNumStylesInShader (&shader); + + if ( numStyles > 0 ) + { + // Move back all stages, after the first lightmap stage, by 'numStyles' elements. + memmove (lmStage + numStyles, + lmStage + 1, + sizeof (shaderStage_t) * (MAX_SHADER_STAGES - firstLightmapStage - numStyles - 1)); + + // Insert new shader stages after first lightmap stage + for ( int i = 1; i <= numStyles; i++ ) + { + shaderStage_t *stage = lmStage + i; + + // Duplicate first lightmap stage into this stage. + *stage = *lmStage; + + if ( shader.lightmapIndex[i] == LIGHTMAP_BY_VERTEX ) + { + stage->bundle[0].image[0] = tr.whiteImage; + } + else if ( shader.lightmapIndex[i] < 0 ) + { + Com_Error (ERR_DROP, "FinishShader: light style with no lightmap or vertex style in shader %s.\n", shader.name); + } + else + { + stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[i]]; + stage->bundle[0].tcGen = (texCoordGen_t)(TCGEN_LIGHTMAP + i); + } + + stage->rgbGen = CGEN_LIGHTMAPSTYLE; + stage->stateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS); + stage->stateBits |= GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; + } + } + + // Set all the light styles for the lightmap stages. + for ( int i = 0; i <= numStyles; i++ ) + { + lmStage[i].lightmapStyle = shader.styles[i]; + } + } + // // set appropriate stage information // @@ -3309,6 +3458,34 @@ shader_t *R_FindShaderByName( const char *name ) { return tr.defaultShader; } +static qboolean IsShader ( const shader_t *sh, const char *name, const int *lightmapIndexes, const byte *styles ) +{ + if ( Q_stricmp (sh->name, name) != 0 ) + { + return qfalse; + } + + if ( sh->defaultShader ) + { + return qtrue; + } + + for ( int i = 0; i < MAXLIGHTMAPS; i++ ) + { + if ( sh->lightmapIndex[i] != lightmapIndexes[i] ) + { + return qfalse; + } + + if ( sh->styles[i] != styles[i] ) + { + return qfalse; + } + } + + return qtrue; +} + /* =============== @@ -3338,7 +3515,7 @@ most world construction surfaces. =============== */ -shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImage ) { +shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; int hash, flags; const char *shaderText; @@ -3351,12 +3528,12 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // use (fullbright) vertex lighting if the bsp file doesn't have // lightmaps - if ( lightmapIndex >= 0 && lightmapIndex >= tr.numLightmaps ) { - lightmapIndex = LIGHTMAP_BY_VERTEX; - } else if ( lightmapIndex < LIGHTMAP_2D ) { + if ( lightmapIndexes[0] >= 0 && lightmapIndexes[0] >= tr.numLightmaps ) { + lightmapIndexes = lightmapsVertex; + } else if ( lightmapIndexes[0] < LIGHTMAP_2D ) { // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex]) - ri->Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndex ); - lightmapIndex = LIGHTMAP_BY_VERTEX; + ri->Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndexes[0] ); + lightmapIndexes = lightmapsVertex; } COM_StripExtension(name, strippedName, sizeof(strippedName)); @@ -3371,8 +3548,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we // have to check all default shaders otherwise for every call to R_FindShader // with that same strippedName a new default shader is created. - if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && - !Q_stricmp(sh->name, strippedName)) { + if ( IsShader (sh, strippedName, lightmapIndexes, styles) ) { // match found return sh; } @@ -3381,7 +3557,8 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // clear the global shader ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); - shader.lightmapIndex = lightmapIndex; + Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); + Com_Memcpy (shader.styles, styles, sizeof (shader.styles)); // // attempt to define shader from an explicit parameter file @@ -3435,20 +3612,20 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag // // create the default shading commands // - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + if ( shader.lightmapIndex[0] == LIGHTMAP_NONE ) { // dynamic colors at vertexes stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_BY_VERTEX ) { // explicit colors at vertexes stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; stages[0].rgbGen = CGEN_EXACT_VERTEX; stages[0].alphaGen = AGEN_SKIP; stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_2D ) { // GUI elements stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; @@ -3457,7 +3634,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag stages[0].stateBits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_WHITEIMAGE ) { // fullbright level stages[0].bundle[0].image[0] = tr.whiteImage; stages[0].active = qtrue; @@ -3470,7 +3647,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; } else { // two pass lightmap - stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; stages[0].bundle[0].isLightmap = qtrue; stages[0].active = qtrue; stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation @@ -3486,7 +3663,7 @@ shader_t *R_FindShader( const char *name, int lightmapIndex, qboolean mipRawImag return FinishShader(); } -shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipRawImage ) +shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) { char strippedName[MAX_QPATH]; int hash; @@ -3508,8 +3685,7 @@ shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipR // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we // have to check all default shaders otherwise for every call to R_FindShader // with that same strippedName a new default shader is created. - if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && - !Q_stricmp(sh->name, strippedName)) { + if ( IsShader (sh, name, lightmapIndexes, styles) ) { // match found return sh; } @@ -3518,13 +3694,13 @@ shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipR // clear the global shader ClearGlobalShader(); Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); - shader.lightmapIndex = lightmapIndex; + Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); shader.defaultShader = qtrue; return FinishShader(); } -qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_t *image, qboolean mipRawImage) { +qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexes, const byte *styles, image_t *image, qboolean mipRawImage) { int hash; shader_t *sh; @@ -3533,8 +3709,8 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ // probably not necessary since this function // only gets called from tr_font.c with lightmapIndex == LIGHTMAP_2D // but better safe than sorry. - if ( lightmapIndex >= tr.numLightmaps ) { - lightmapIndex = LIGHTMAP_WHITEIMAGE; + if ( lightmapIndexes[0] >= tr.numLightmaps ) { + lightmapIndexes = lightmapsFullBright; } // @@ -3545,9 +3721,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ // then a default shader is created with lightmapIndex == LIGHTMAP_NONE, so we // have to check all default shaders otherwise for every call to R_FindShader // with that same strippedName a new default shader is created. - if ( (sh->lightmapIndex == lightmapIndex || sh->defaultShader) && - // index by name - !Q_stricmp(sh->name, name)) { + if ( IsShader (sh, name, lightmapIndexes, styles) ) { // match found return sh->index; } @@ -3556,25 +3730,25 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ // clear the global shader ClearGlobalShader(); Q_strncpyz(shader.name, name, sizeof(shader.name)); - shader.lightmapIndex = lightmapIndex; + Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); // // create the default shading commands // - if ( shader.lightmapIndex == LIGHTMAP_NONE ) { + if ( shader.lightmapIndex[0] == LIGHTMAP_NONE ) { // dynamic colors at vertexes stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; stages[0].rgbGen = CGEN_LIGHTING_DIFFUSE; stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_BY_VERTEX ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_BY_VERTEX ) { // explicit colors at vertexes stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; stages[0].rgbGen = CGEN_EXACT_VERTEX; stages[0].alphaGen = AGEN_SKIP; stages[0].stateBits = GLS_DEFAULT; - } else if ( shader.lightmapIndex == LIGHTMAP_2D ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_2D ) { // GUI elements stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; @@ -3583,7 +3757,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ stages[0].stateBits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } else if ( shader.lightmapIndex == LIGHTMAP_WHITEIMAGE ) { + } else if ( shader.lightmapIndex[0] == LIGHTMAP_WHITEIMAGE ) { // fullbright level stages[0].bundle[0].image[0] = tr.whiteImage; stages[0].active = qtrue; @@ -3596,7 +3770,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, int lightmapIndex, image_ stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; } else { // two pass lightmap - stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex]; + stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; stages[0].bundle[0].isLightmap = qtrue; stages[0].active = qtrue; stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation @@ -3625,7 +3799,7 @@ This should really only be used for explicit shaders, because there is no way to ask for different implicit lighting modes (vertex, lightmap, etc) ==================== */ -qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { +qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndexes, const byte *styles ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { @@ -3633,7 +3807,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, int lightmapIndex ) { return 0; } - sh = R_FindShader( name, lightmapIndex, qtrue ); + sh = R_FindShader( name, lightmapIndexes, styles, qtrue ); // we want to return 0 if the shader failed to // load for some reason, but R_FindShader should @@ -3667,7 +3841,7 @@ qhandle_t RE_RegisterShader( const char *name ) { return 0; } - sh = R_FindShader( name, LIGHTMAP_2D, qtrue ); + sh = R_FindShader( name, lightmaps2d, stylesDefault, qtrue ); // we want to return 0 if the shader failed to // load for some reason, but R_FindShader should @@ -3697,7 +3871,7 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { return 0; } - sh = R_FindShader( name, LIGHTMAP_2D, qfalse ); + sh = R_FindShader( name, lightmaps2d, stylesDefault, qfalse ); // we want to return 0 if the shader failed to // load for some reason, but R_FindShader should @@ -3990,7 +4164,7 @@ static void CreateInternalShaders( void ) { Q_strncpyz( shader.name, "", sizeof( shader.name ) ); - shader.lightmapIndex = LIGHTMAP_NONE; + Com_Memcpy (shader.lightmapIndex, lightmapsNone, sizeof (shader.lightmapIndex)); for ( int i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { stages[i].bundle[0].texMods = texMods[i]; } @@ -4014,8 +4188,8 @@ static void CreateInternalShaders( void ) { } static void CreateExternalShaders( void ) { - tr.projectionShadowShader = R_FindShader( "projectionShadow", LIGHTMAP_NONE, qtrue ); - tr.flareShader = R_FindShader( "flareShader", LIGHTMAP_NONE, qtrue ); + tr.projectionShadowShader = R_FindShader( "projectionShadow", lightmapsNone, stylesDefault, qtrue ); + tr.flareShader = R_FindShader( "flareShader", lightmapsNone, stylesDefault, qtrue ); // Hack to make fogging work correctly on flares. Fog colors are calculated // in tr_flare.c already. @@ -4030,9 +4204,9 @@ static void CreateExternalShaders( void ) { } } - tr.sunShader = R_FindShader( "sun", LIGHTMAP_NONE, qtrue ); + tr.sunShader = R_FindShader( "sun", lightmapsNone, stylesDefault, qtrue ); - tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", LIGHTMAP_NONE, qtrue); + tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", lightmapsNone, stylesDefault, qtrue); // HACK: if sunflare is missing, make one using the flare image or dlight image if (tr.sunFlareShader->defaultShader) @@ -4049,7 +4223,7 @@ static void CreateExternalShaders( void ) { Q_strncpyz( shader.name, "gfx/2d/sunflare", sizeof( shader.name ) ); - shader.lightmapIndex = LIGHTMAP_NONE; + Com_Memcpy (shader.lightmapIndex, lightmapsNone, sizeof (shader.lightmapIndex)); stages[0].bundle[0].image[0] = image; stages[0].active = qtrue; stages[0].stateBits = GLS_DEFAULT; diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp index 3d8082df6e..4b1cfa96e0 100644 --- a/codemp/rd-rend2/tr_skin.cpp +++ b/codemp/rd-rend2/tr_skin.cpp @@ -21,7 +21,7 @@ RE_RegisterSkin bool gServerSkinHack = false; -shader_t *R_FindServerShader( const char *name, int lightmapIndex, qboolean mipRawImage ); +shader_t *R_FindServerShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ) ; static char *CommaParse( char **data_p ); /* =============== @@ -144,8 +144,8 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) Q_strncpyz( surf->name, surfName, sizeof( surf->name ) ); - if (gServerSkinHack) surf->shader = R_FindServerShader( token, LIGHTMAP_NONE, qtrue ); - else surf->shader = R_FindShader( token, LIGHTMAP_NONE, qtrue ); + if (gServerSkinHack) surf->shader = R_FindServerShader( token, lightmapsNone, stylesDefault, qtrue ); + else surf->shader = R_FindShader( token, lightmapsNone, stylesDefault, qtrue ); skin->numSurfaces++; } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 3587ce8f27..384dd2b504 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -427,7 +427,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn dv = verts; lightCoords = tess.texCoords[ tess.numVertexes ][1]; for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=4 ) - VectorCopy2(dv->lightmap, lightCoords); + VectorCopy2(dv->lightmap[0], lightCoords); } if ( tess.shader->vertexAttribs & ATTR_COLOR ) @@ -435,7 +435,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn dv = verts; color = tess.vertexColors[ tess.numVertexes ]; for ( i = 0 ; i < numVerts ; i++, dv++, color+=4 ) - VectorCopy4(dv->vertexColors, color); + VectorCopy4(dv->vertexColors[0], color); } if ( tess.shader->vertexAttribs & ATTR_LIGHTDIRECTION ) @@ -1874,13 +1874,13 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) { - VectorCopy2(dv->lightmap, lightCoords); + VectorCopy2(dv->lightmap[0], lightCoords); lightCoords += 4; } if ( tess.shader->vertexAttribs & ATTR_COLOR ) { - VectorCopy4(dv->vertexColors, color); + VectorCopy4(dv->vertexColors[0], color); color += 4; } From 9568f2b1e3282ba18d9dfaa043de2e33693c17bf Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 21 Dec 2013 18:45:56 +0000 Subject: [PATCH 145/708] [Rend2] Fix few problems with lightmap code. This commit fixes a few things with the new light style code. It also disables lightmap merging for now as this was broken by the multiple lightmaps commit. --- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5346f9ff4a..81c6cb4698 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1273,7 +1273,7 @@ void R_Register( void ) r_dlightMode = ri->Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); r_recalcMD3Normals = ri->Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index dc15add593..d73073a9dc 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3099,7 +3099,7 @@ int GetNumStylesInShader ( const shader_t *shader ) } } - return 0; + return MAXLIGHTMAPS - 1; } /* @@ -3148,7 +3148,7 @@ static shader_t *FinishShader( void ) { lmStage->stateBits = GLS_DEFAULT; } - lmStage->rgbGen = CGEN_EXACT_VERTEX; + lmStage->rgbGen = CGEN_EXACT_VERTEX_LIT; lmStage->alphaGen = AGEN_SKIP; firstLightmapStage = MAX_SHADER_STAGES; From 6cf7244cc171ea2b62c0fd46ece840f087b1e158 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 21 Dec 2013 22:08:04 +0000 Subject: [PATCH 146/708] [Rend2] Added normal map support for ghoul2 models --- codemp/rd-rend2/tr_ghoul2.cpp | 81 ++++++++++++++++++++++++++++++++--- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 5d4c8b2058..7257bd4624 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4456,6 +4456,11 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean int numVerts = 0; int numTriangles = 0; +#ifdef USE_VERT_TANGENT_SPACE + vec3_t *tangentsf; + vec3_t *bitangentsf; +#endif + // +1 to add total vertex count int *baseVertexes = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); int *indexOffsets = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * mdxm->numSurfaces); @@ -4480,6 +4485,11 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean baseVertexes[mdxm->numSurfaces] = numVerts; +#ifdef USE_VERT_TANGENT_SPACE + tangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts); + bitangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts);; +#endif + dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); @@ -4524,19 +4534,14 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean { // Positions and normals mdxmVertex_t *v = (mdxmVertex_t *)((byte *)surf + surf->ofsVerts); + for ( int k = 0; k < surf->numVerts; k++ ) { VectorCopy (v[k].vertCoords, *verts); *normals = R_VboPackNormal (v[k].normal); -#ifdef USE_VERT_TANGENT_SPACE - *tangents = R_VboPackNormal (v[k].normal); -#endif verts = (vec3_t *)((byte *)verts + stride); normals = (uint32_t *)((byte *)normals + stride); -#ifdef USE_VERT_TANGENT_SPACE - tangents = (uint32_t *)((byte *)tangents + stride); -#endif } // Weights @@ -4570,6 +4575,68 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean texcoords = (vec2_t *)((byte *)texcoords + stride); } +#ifdef USE_VERT_TANGENT_SPACE + mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); + for ( int k = 0; k < surf->numTriangles; k++ ) + { + int index[3]; + float *v0, *v1, *v2; + float *uv0, *uv1, *uv2; + vec3_t normal = { 0.0f, 0.0f, 0.0f }; + vec3_t tangent = { 0.0f, 0.0f, 0.0f }; + vec3_t bitangent = { 0.0f, 0.0f, 0.0f }; + + index[0] = t[k].indexes[0]; + index[1] = t[k].indexes[1]; + index[2] = t[k].indexes[2]; + + v0 = v[index[0]].vertCoords; + v1 = v[index[1]].vertCoords; + v2 = v[index[2]].vertCoords; + + uv0 = tc[index[0]].texCoords; + uv1 = tc[index[1]].texCoords; + uv2 = tc[index[2]].texCoords; + + VectorAdd (normal, v[index[0]].normal, normal); + VectorAdd (normal, v[index[1]].normal, normal); + VectorAdd (normal, v[index[2]].normal, normal); + VectorNormalize (normal); + + R_CalcTangentSpace (tangent, bitangent, normal, v0, v1, v2, uv0, uv1, uv2); + + for ( int i = 0; i < 3; i++ ) + { + VectorAdd (tangentsf[baseVertexes[n] + index[i]], + tangent, + tangentsf[baseVertexes[n] + index[i]]); + + VectorAdd (bitangentsf[baseVertexes[n] + index[i]], + bitangent, + bitangentsf[baseVertexes[n] + index[i]]); + } + } + + // Finally add it to the vertex buffer data + for ( int k = 0; k < surf->numVerts; k++ ) + { + vec3_t& tangent = tangentsf[baseVertexes[n] + k]; + vec3_t& bitangent = bitangentsf[baseVertexes[n] + k]; + vec3_t NxT; + vec4_t T; + + VectorNormalize (tangent); + VectorNormalize (bitangent); + + CrossProduct (v[k].normal, tangent, NxT); + VectorCopy (tangent, T); + T[3] = DotProduct (NxT, bitangent) < 0.0f ? -1.0f : 1.0f; + + *tangents = R_VboPackTangent (T); + tangents = (uint32_t *)((byte *)tangents + stride); + } +#endif + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } @@ -4584,6 +4651,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean VBO_t *vbo = R_CreateVBO (va ("MDXM VBO LOD %d '%s'", l, modelName), data, dataSize, VBO_USAGE_STATIC); ri->Hunk_FreeTempMemory (data); + ri->Hunk_FreeTempMemory (tangentsf); + ri->Hunk_FreeTempMemory (bitangentsf); vbo->ofs_xyz = ofsPosition; vbo->ofs_normal = ofsNormals; From 8b0449e342139de5f6e292f36b9042897aa8fc0f Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 27 Dec 2013 18:36:47 -0600 Subject: [PATCH 147/708] [MP] Rend2: Merge fog fix from vanilla. --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index d73073a9dc..ac17dd76ba 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2867,7 +2867,7 @@ static void FixRenderCommandList( int newShader ) { sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | entityNum | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; + drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | (entityNum << QSORT_REFENTITYNUM_SHIFT) | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; } } curCmd = (const void *)(ds_cmd + 1); From 2a818965bca60ad21c01a095def763e28075afff Mon Sep 17 00:00:00 2001 From: redsaurus Date: Thu, 26 Dec 2013 18:28:55 +0000 Subject: [PATCH 148/708] [MP] rend2: OSX support --- codemp/rd-rend2/qgl.h | 2 +- codemp/rd-rend2/tr_backend.cpp | 20 +- codemp/rd-rend2/tr_extensions.cpp | 176 +++++++++--------- codemp/rd-rend2/tr_flares.cpp | 6 +- codemp/rd-rend2/tr_light.cpp | 12 +- codemp/rd-rend2/tr_local.h | 10 +- codemp/rd-rend2/tr_main.cpp | 282 ++++++++++++++--------------- codemp/rd-rend2/tr_mesh.cpp | 4 +- codemp/rd-rend2/tr_postprocess.cpp | 4 +- codemp/rd-rend2/tr_scene.cpp | 8 +- codemp/rd-rend2/tr_shade.cpp | 44 ++--- codemp/rd-rend2/tr_shade_calc.cpp | 46 ++--- codemp/rd-rend2/tr_shadows.cpp | 8 +- codemp/rd-rend2/tr_sky.cpp | 12 +- codemp/rd-rend2/tr_surface.cpp | 48 ++--- codemp/rd-rend2/tr_world.cpp | 4 +- 16 files changed, 344 insertions(+), 342 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 41517774c4..091e571615 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define __QGL_H__ #ifndef _WIN32 -#include "SDL/SDL_opengl.h" +#include #else #include #include diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 9bfeebdb88..1094ebb244 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -545,10 +545,10 @@ void RB_BeginDrawingView (void) { plane[2] = backEnd.viewParms.portalPlane.normal[2]; plane[3] = backEnd.viewParms.portalPlane.dist; - plane2[0] = DotProduct (backEnd.viewParms.or.axis[0], plane); - plane2[1] = DotProduct (backEnd.viewParms.or.axis[1], plane); - plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane); - plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3]; + plane2[0] = DotProduct (backEnd.viewParms.ori.axis[0], plane); + plane2[1] = DotProduct (backEnd.viewParms.ori.axis[1], plane); + plane2[2] = DotProduct (backEnd.viewParms.ori.axis[2], plane); + plane2[3] = DotProduct (plane, backEnd.viewParms.ori.origin) - plane[3]; #endif GL_SetModelviewMatrix( s_flipMatrix ); } @@ -650,11 +650,11 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; // set up the transformation matrix - R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.or ); + R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); // set up the dynamic lighting if needed if ( backEnd.currentEntity->needDlights ) { - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); } if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { @@ -668,14 +668,14 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } else { backEnd.currentEntity = &tr.worldEntity; backEnd.refdef.floatTime = originalTime; - backEnd.or = backEnd.viewParms.world; + backEnd.ori = backEnd.viewParms.world; // we have to reset the shaderTime as well otherwise image animations on // the world (like water) continue with the wrong frame tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or ); + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); } - GL_SetModelviewMatrix( backEnd.or.modelMatrix ); + GL_SetModelviewMatrix( backEnd.ori.modelMatrix ); // // change depthrange. Also change projection matrix so first person weapon does not look like coming @@ -1916,7 +1916,7 @@ const void *RB_PostProcess(const void *data) if (r_cubeMapping->integer && tr.numCubemaps) { vec4i_t dstBox; - int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.or.origin ); + int cubemapIndex = R_CubemapForPoint( backEnd.viewParms.ori.origin ); if (cubemapIndex) { diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 1863ce54be..3f02be9020 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -24,10 +24,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #ifndef _WIN32 -#include "SDL/SDL.h" +#include +#define GL_GetProcAddress SDL_GL_GetProcAddress #else #include "../win32/glw_win.h" extern glwstate_t glw_state; +#define GL_GetProcAddress qwglGetProcAddress #endif // GL_EXT_draw_range_elements @@ -200,7 +202,7 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawRangeElementsEXT = (void (__stdcall *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))qwglGetProcAddress("glDrawRangeElementsEXT"); + qglDrawRangeElementsEXT = (void (QCALL *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GL_GetProcAddress("glDrawRangeElementsEXT"); if ( r_ext_draw_range_elements->integer) glRefConfig.drawRangeElements = qtrue; @@ -219,8 +221,8 @@ void GLimp_InitExtraExtensions() qglMultiDrawElementsEXT = NULL; if( GLimp_HaveExtension( extension ) ) { - qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) qwglGetProcAddress("glMultiDrawArraysEXT"); - qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) qwglGetProcAddress("glMultiDrawElementsEXT"); + qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GL_GetProcAddress("glMultiDrawArraysEXT"); + qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GL_GetProcAddress("glMultiDrawElementsEXT"); if ( r_ext_multi_draw_arrays->integer ) glRefConfig.multiDrawArrays = qtrue; @@ -242,13 +244,13 @@ void GLimp_InitExtraExtensions() qglDisableVertexAttribArrayARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) qwglGetProcAddress("glVertexAttrib4fARB"); - qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) qwglGetProcAddress("glVertexAttrib4fvARB"); - qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) qwglGetProcAddress("glVertexAttribPointerARB"); + qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) GL_GetProcAddress("glVertexAttrib4fARB"); + qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) GL_GetProcAddress("glVertexAttrib4fvARB"); + qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GL_GetProcAddress("glVertexAttribPointerARB"); qglEnableVertexAttribArrayARB = - (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) qwglGetProcAddress("glEnableVertexAttribArrayARB"); + (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GL_GetProcAddress("glEnableVertexAttribArrayARB"); qglDisableVertexAttribArrayARB = - (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) qwglGetProcAddress("glDisableVertexAttribArrayARB"); + (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GL_GetProcAddress("glDisableVertexAttribArrayARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexProgram = qtrue; @@ -272,15 +274,15 @@ void GLimp_InitExtraExtensions() qglGetBufferPointervARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) qwglGetProcAddress("glBindBufferARB"); - qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) qwglGetProcAddress("glDeleteBuffersARB"); - qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) qwglGetProcAddress("glGenBuffersARB"); - qglIsBufferARB = (PFNGLISBUFFERARBPROC) qwglGetProcAddress("glIsBufferARB"); - qglBufferDataARB = (void (__stdcall *)(GLenum,GLint,const GLvoid *,GLenum)) qwglGetProcAddress("glBufferDataARB"); - qglBufferSubDataARB = (void (__stdcall *)(GLenum,GLint,GLint,const GLvoid *)) qwglGetProcAddress("glBufferSubDataARB"); - qglGetBufferSubDataARB = (void (__stdcall *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) qwglGetProcAddress("glGetBufferSubDataARB"); - qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) qwglGetProcAddress("glGetBufferParameterivARB"); - qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) qwglGetProcAddress("glGetBufferPointervARB"); + qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) GL_GetProcAddress("glBindBufferARB"); + qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GL_GetProcAddress("glDeleteBuffersARB"); + qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GL_GetProcAddress("glGenBuffersARB"); + qglIsBufferARB = (PFNGLISBUFFERARBPROC) GL_GetProcAddress("glIsBufferARB"); + qglBufferDataARB = (void (QCALL *)(GLenum,GLint,const GLvoid *,GLenum)) GL_GetProcAddress("glBufferDataARB"); + qglBufferSubDataARB = (void (QCALL *)(GLenum,GLint,GLint,const GLvoid *)) GL_GetProcAddress("glBufferSubDataARB"); + qglGetBufferSubDataARB = (void (QCALL *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) GL_GetProcAddress("glGetBufferSubDataARB"); + qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GL_GetProcAddress("glGetBufferParameterivARB"); + qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GL_GetProcAddress("glGetBufferPointervARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexBufferObject = qtrue; } @@ -332,44 +334,44 @@ void GLimp_InitExtraExtensions() qglGetShaderSourceARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) qwglGetProcAddress("glDeleteObjectARB"); - qglGetHandleARB = (PFNGLGETHANDLEARBPROC) qwglGetProcAddress("glGetHandleARB"); - qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) qwglGetProcAddress("glDetachObjectARB"); - qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) qwglGetProcAddress("glCreateShaderObjectARB"); - qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) qwglGetProcAddress("glShaderSourceARB"); - qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) qwglGetProcAddress("glCompileShaderARB"); - qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) qwglGetProcAddress("glCreateProgramObjectARB"); - qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) qwglGetProcAddress("glAttachObjectARB"); - qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) qwglGetProcAddress("glLinkProgramARB"); - qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) qwglGetProcAddress("glUseProgramObjectARB"); - qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) qwglGetProcAddress("glValidateProgramARB"); - qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) qwglGetProcAddress("glUniform1fARB"); - qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) qwglGetProcAddress("glUniform2fARB"); - qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) qwglGetProcAddress("glUniform3fARB"); - qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) qwglGetProcAddress("glUniform4fARB"); - qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) qwglGetProcAddress("glUniform1iARB"); - qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) qwglGetProcAddress("glUniform2iARB"); - qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) qwglGetProcAddress("glUniform3iARB"); - qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) qwglGetProcAddress("glUniform4iARB"); - qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) qwglGetProcAddress("glUniform1fvARB"); - qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) qwglGetProcAddress("glUniform2fvARB"); - qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) qwglGetProcAddress("glUniform3fvARB"); - qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) qwglGetProcAddress("glUniform4fvARB"); - qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) qwglGetProcAddress("glUniform2ivARB"); - qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) qwglGetProcAddress("glUniform3ivARB"); - qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) qwglGetProcAddress("glUniform4ivARB"); - qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) qwglGetProcAddress("glUniformMatrix2fvARB"); - qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) qwglGetProcAddress("glUniformMatrix3fvARB"); - qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) qwglGetProcAddress("glUniformMatrix4fvARB"); - qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) qwglGetProcAddress("glGetObjectParameterfvARB"); - qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) qwglGetProcAddress("glGetObjectParameterivARB"); - qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) qwglGetProcAddress("glGetInfoLogARB"); - qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) qwglGetProcAddress("glGetAttachedObjectsARB"); - qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) qwglGetProcAddress("glGetUniformLocationARB"); - qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) qwglGetProcAddress("glGetActiveUniformARB"); - qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) qwglGetProcAddress("glGetUniformfvARB"); - qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) qwglGetProcAddress("glGetUniformivARB"); - qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) qwglGetProcAddress("glGetShaderSourceARB"); + qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GL_GetProcAddress("glDeleteObjectARB"); + qglGetHandleARB = (PFNGLGETHANDLEARBPROC) GL_GetProcAddress("glGetHandleARB"); + qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) GL_GetProcAddress("glDetachObjectARB"); + qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GL_GetProcAddress("glCreateShaderObjectARB"); + qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GL_GetProcAddress("glShaderSourceARB"); + qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GL_GetProcAddress("glCompileShaderARB"); + qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GL_GetProcAddress("glCreateProgramObjectARB"); + qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GL_GetProcAddress("glAttachObjectARB"); + qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GL_GetProcAddress("glLinkProgramARB"); + qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GL_GetProcAddress("glUseProgramObjectARB"); + qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) GL_GetProcAddress("glValidateProgramARB"); + qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) GL_GetProcAddress("glUniform1fARB"); + qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) GL_GetProcAddress("glUniform2fARB"); + qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) GL_GetProcAddress("glUniform3fARB"); + qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) GL_GetProcAddress("glUniform4fARB"); + qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) GL_GetProcAddress("glUniform1iARB"); + qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) GL_GetProcAddress("glUniform2iARB"); + qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) GL_GetProcAddress("glUniform3iARB"); + qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) GL_GetProcAddress("glUniform4iARB"); + qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) GL_GetProcAddress("glUniform1fvARB"); + qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) GL_GetProcAddress("glUniform2fvARB"); + qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) GL_GetProcAddress("glUniform3fvARB"); + qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GL_GetProcAddress("glUniform4fvARB"); + qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) GL_GetProcAddress("glUniform2ivARB"); + qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) GL_GetProcAddress("glUniform3ivARB"); + qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) GL_GetProcAddress("glUniform4ivARB"); + qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) GL_GetProcAddress("glUniformMatrix2fvARB"); + qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) GL_GetProcAddress("glUniformMatrix3fvARB"); + qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) GL_GetProcAddress("glUniformMatrix4fvARB"); + qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) GL_GetProcAddress("glGetObjectParameterfvARB"); + qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) GL_GetProcAddress("glGetObjectParameterivARB"); + qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) GL_GetProcAddress("glGetInfoLogARB"); + qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) GL_GetProcAddress("glGetAttachedObjectsARB"); + qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GL_GetProcAddress("glGetUniformLocationARB"); + qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) GL_GetProcAddress("glGetActiveUniformARB"); + qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) GL_GetProcAddress("glGetUniformfvARB"); + qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) GL_GetProcAddress("glGetUniformivARB"); + qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) GL_GetProcAddress("glGetShaderSourceARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.shaderObjects = qtrue; } @@ -408,9 +410,9 @@ void GLimp_InitExtraExtensions() //glConfig.maxVertexSkinningBones = (int) Q_bound(0.0, (Q_max(glConfig.maxVertexUniforms - reservedComponents, 0) / 16), MAX_BONES); //glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ((glConfig.maxVertexSkinningBones >= 12) ? qtrue : qfalse); - qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) qwglGetProcAddress("glBindAttribLocationARB"); - qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) qwglGetProcAddress("glGetActiveAttribARB"); - qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) qwglGetProcAddress("glGetAttribLocationARB"); + qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GL_GetProcAddress("glBindAttribLocationARB"); + qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GL_GetProcAddress("glGetActiveAttribARB"); + qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GL_GetProcAddress("glGetAttribLocationARB"); ri->Printf(PRINT_ALL, result[1], extension); //glRefConfig.vertexShader = qtrue; } @@ -504,23 +506,23 @@ void GLimp_InitExtraExtensions() qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); - qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) qwglGetProcAddress("glIsRenderbufferEXT"); - qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) qwglGetProcAddress("glBindRenderbufferEXT"); - qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) qwglGetProcAddress("glDeleteRenderbuffersEXT"); - qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) qwglGetProcAddress("glGenRenderbuffersEXT"); - qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) qwglGetProcAddress("glRenderbufferStorageEXT"); - qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) qwglGetProcAddress("glGetRenderbufferParameterivEXT"); - qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) qwglGetProcAddress("glIsFramebufferEXT"); - qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) qwglGetProcAddress("glBindFramebufferEXT"); - qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) qwglGetProcAddress("glDeleteFramebuffersEXT"); - qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) qwglGetProcAddress("glGenFramebuffersEXT"); - qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) qwglGetProcAddress("glCheckFramebufferStatusEXT"); - qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) qwglGetProcAddress("glFramebufferTexture1DEXT"); - qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) qwglGetProcAddress("glFramebufferTexture2DEXT"); - qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) qwglGetProcAddress("glFramebufferTexture3DEXT"); - qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) qwglGetProcAddress("glFramebufferRenderbufferEXT"); - qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) qwglGetProcAddress("glGetFramebufferAttachmentParameterivEXT"); - qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) qwglGetProcAddress("glGenerateMipmapEXT"); + qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GL_GetProcAddress("glIsRenderbufferEXT"); + qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress("glBindRenderbufferEXT"); + qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress("glDeleteRenderbuffersEXT"); + qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress("glGenRenderbuffersEXT"); + qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress("glRenderbufferStorageEXT"); + qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) GL_GetProcAddress("glGetRenderbufferParameterivEXT"); + qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) GL_GetProcAddress("glIsFramebufferEXT"); + qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT"); + qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glDeleteFramebuffersEXT"); + qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT"); + qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress("glCheckFramebufferStatusEXT"); + qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) GL_GetProcAddress("glFramebufferTexture1DEXT"); + qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress("glFramebufferTexture2DEXT"); + qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) GL_GetProcAddress("glFramebufferTexture3DEXT"); + qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress("glFramebufferRenderbufferEXT"); + qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); + qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GL_GetProcAddress("glGenerateMipmapEXT"); if(r_ext_framebuffer_object->value) glRefConfig.framebufferObject = qtrue; @@ -550,14 +552,14 @@ void GLimp_InitExtraExtensions() glRefConfig.occlusionQuery = qfalse; if (GLimp_HaveExtension(extension)) { - qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) qwglGetProcAddress("glGenQueriesARB"); - qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) qwglGetProcAddress("glDeleteQueriesARB"); - qglIsQueryARB = (PFNGLISQUERYARBPROC) qwglGetProcAddress("glIsQueryARB"); - qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) qwglGetProcAddress("glBeginQueryARB"); - qglEndQueryARB = (PFNGLENDQUERYARBPROC) qwglGetProcAddress("glEndQueryARB"); - qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) qwglGetProcAddress("glGetQueryivARB"); - qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) qwglGetProcAddress("glGetQueryObjectivARB"); - qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) qwglGetProcAddress("glGetQueryObjectuivARB"); + qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GL_GetProcAddress("glGenQueriesARB"); + qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GL_GetProcAddress("glDeleteQueriesARB"); + qglIsQueryARB = (PFNGLISQUERYARBPROC) GL_GetProcAddress("glIsQueryARB"); + qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GL_GetProcAddress("glBeginQueryARB"); + qglEndQueryARB = (PFNGLENDQUERYARBPROC) GL_GetProcAddress("glEndQueryARB"); + qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GL_GetProcAddress("glGetQueryivARB"); + qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GL_GetProcAddress("glGetQueryObjectivARB"); + qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GL_GetProcAddress("glGetQueryObjectuivARB"); glRefConfig.occlusionQuery = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); } @@ -571,7 +573,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferBlit = qfalse; if (GLimp_HaveExtension(extension)) { - qglBlitFramebufferEXT = (void (__stdcall *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))qwglGetProcAddress("glBlitFramebufferEXT"); + qglBlitFramebufferEXT = (void (QCALL *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GL_GetProcAddress("glBlitFramebufferEXT"); glRefConfig.framebufferBlit = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); } @@ -585,7 +587,7 @@ void GLimp_InitExtraExtensions() glRefConfig.framebufferMultisample = qfalse; if (GLimp_HaveExtension(extension)) { - qglRenderbufferStorageMultisampleEXT = (void (__stdcall *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))qwglGetProcAddress("glRenderbufferStorageMultisampleEXT"); + qglRenderbufferStorageMultisampleEXT = (void (QCALL *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.framebufferMultisample = qtrue; ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); } @@ -674,7 +676,7 @@ void GLimp_InitExtraExtensions() qglDrawBuffersARB = NULL; if( GLimp_HaveExtension( extension ) ) { - qglDrawBuffersARB = (void (__stdcall *)(GLsizei,const GLenum *)) qwglGetProcAddress("glDrawBuffersARB"); + qglDrawBuffersARB = (void (QCALL *)(GLsizei,const GLenum *)) GL_GetProcAddress("glDrawBuffersARB"); ri->Printf(PRINT_ALL, result[1], extension); } diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index e2da488b7d..a609f97fa6 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -138,7 +138,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t if(normal && (normal[0] || normal[1] || normal[2])) { - VectorSubtract( backEnd.viewParms.or.origin, point, local ); + VectorSubtract( backEnd.viewParms.ori.origin, point, local ); VectorNormalizeFast(local); d = DotProduct(local, normal); @@ -149,7 +149,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t // if the point is off the screen, don't bother adding it // calculate screen coordinates and depth - R_TransformModelToClip( point, backEnd.or.modelMatrix, + R_TransformModelToClip( point, backEnd.ori.modelMatrix, backEnd.viewParms.projectionMatrix, eye, clip ); // check to see if the point is completely off screen @@ -487,7 +487,7 @@ void RB_RenderFlares (void) { // Reset currentEntity to world so that any previously referenced entities // don't have influence on the rendering of these flares (i.e. RF_ renderer flags). backEnd.currentEntity = &tr.worldEntity; - backEnd.or = backEnd.viewParms.world; + backEnd.ori = backEnd.viewParms.world; // RB_AddDlightFlares(); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index aec66a1280..46cfb6a392 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -39,15 +39,15 @@ Used by both the front end (for DlightBmodel) and the back end (before doing the lighting calculation) =============== */ -void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or) { +void R_TransformDlights( int count, dlight_t *dl, orientationr_t *ori) { int i; vec3_t temp; for ( i = 0 ; i < count ; i++, dl++ ) { - VectorSubtract( dl->origin, or->origin, temp ); - dl->transformed[0] = DotProduct( temp, or->axis[0] ); - dl->transformed[1] = DotProduct( temp, or->axis[1] ); - dl->transformed[2] = DotProduct( temp, or->axis[2] ); + VectorSubtract( dl->origin, ori->origin, temp ); + dl->transformed[0] = DotProduct( temp, ori->axis[0] ); + dl->transformed[1] = DotProduct( temp, ori->axis[1] ); + dl->transformed[2] = DotProduct( temp, ori->axis[2] ); } } @@ -65,7 +65,7 @@ void R_DlightBmodel( bmodel_t *bmodel ) { msurface_t *surf; // transform all the lights - R_TransformDlights( tr.refdef.num_dlights, tr.refdef.dlights, &tr.or ); + R_TransformDlights( tr.refdef.num_dlights, tr.refdef.dlights, &tr.ori ); mask = 0; for ( i=0 ; iinteger, but set to 0 if no hw gamma - orientationr_t or; // for current entity + orientationr_t ori; // for current entity trRefdef_t refdef; @@ -2342,7 +2342,7 @@ int R_CullPointAndRadius( const vec3_t origin, float radius ); int R_CullLocalPointAndRadius( const vec3_t origin, float radius ); void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum); -void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *or ); +void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *ori ); /* ** GL wrapper/helper functions @@ -2573,7 +2573,7 @@ LIGHTS void R_DlightBmodel( bmodel_t *bmodel ); void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); -void R_TransformDlights( int count, dlight_t *dl, orientationr_t *or ); +void R_TransformDlights( int count, dlight_t *dl, orientationr_t *ori ); int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); int R_CubemapForPoint( vec3_t point ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 3ee15c9d66..7a9ca37a67 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -527,10 +527,10 @@ int R_CullLocalBox(vec3_t localBounds[2]) { v[1] = bounds[(i>>1)&1][1]; v[2] = bounds[(i>>2)&1][2]; - VectorCopy( tr.or.origin, transformed[i] ); - VectorMA( transformed[i], v[0], tr.or.axis[0], transformed[i] ); - VectorMA( transformed[i], v[1], tr.or.axis[1], transformed[i] ); - VectorMA( transformed[i], v[2], tr.or.axis[2], transformed[i] ); + VectorCopy( tr.ori.origin, transformed[i] ); + VectorMA( transformed[i], v[0], tr.ori.axis[0], transformed[i] ); + VectorMA( transformed[i], v[1], tr.ori.axis[1], transformed[i] ); + VectorMA( transformed[i], v[2], tr.ori.axis[2], transformed[i] ); } // check against frustum planes @@ -700,9 +700,9 @@ R_LocalNormalToWorld ================= */ void R_LocalNormalToWorld (const vec3_t local, vec3_t world) { - world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0]; - world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1]; - world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2]; + world[0] = local[0] * tr.ori.axis[0][0] + local[1] * tr.ori.axis[1][0] + local[2] * tr.ori.axis[2][0]; + world[1] = local[0] * tr.ori.axis[0][1] + local[1] * tr.ori.axis[1][1] + local[2] * tr.ori.axis[2][1]; + world[2] = local[0] * tr.ori.axis[0][2] + local[1] * tr.ori.axis[1][2] + local[2] * tr.ori.axis[2][2]; } /* @@ -712,9 +712,9 @@ R_LocalPointToWorld ================= */ void R_LocalPointToWorld (const vec3_t local, vec3_t world) { - world[0] = local[0] * tr.or.axis[0][0] + local[1] * tr.or.axis[1][0] + local[2] * tr.or.axis[2][0] + tr.or.origin[0]; - world[1] = local[0] * tr.or.axis[0][1] + local[1] * tr.or.axis[1][1] + local[2] * tr.or.axis[2][1] + tr.or.origin[1]; - world[2] = local[0] * tr.or.axis[0][2] + local[1] * tr.or.axis[1][2] + local[2] * tr.or.axis[2][2] + tr.or.origin[2]; + world[0] = local[0] * tr.ori.axis[0][0] + local[1] * tr.ori.axis[1][0] + local[2] * tr.ori.axis[2][0] + tr.ori.origin[0]; + world[1] = local[0] * tr.ori.axis[0][1] + local[1] * tr.ori.axis[1][1] + local[2] * tr.ori.axis[2][1] + tr.ori.origin[1]; + world[2] = local[0] * tr.ori.axis[0][2] + local[1] * tr.ori.axis[1][2] + local[2] * tr.ori.axis[2][2] + tr.ori.origin[2]; } /* @@ -724,9 +724,9 @@ R_WorldToLocal ================= */ void R_WorldToLocal (const vec3_t world, vec3_t local) { - local[0] = DotProduct(world, tr.or.axis[0]); - local[1] = DotProduct(world, tr.or.axis[1]); - local[2] = DotProduct(world, tr.or.axis[2]); + local[0] = DotProduct(world, tr.ori.axis[0]); + local[1] = DotProduct(world, tr.ori.axis[1]); + local[2] = DotProduct(world, tr.ori.axis[2]); } /* @@ -806,48 +806,48 @@ Called by both the front end and the back end ================= */ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, - orientationr_t *or ) { + orientationr_t *ori ) { float glMatrix[16]; vec3_t delta; float axisLength; if ( ent->e.reType != RT_MODEL ) { - *or = viewParms->world; + *ori = viewParms->world; return; } - VectorCopy( ent->e.origin, or->origin ); + VectorCopy( ent->e.origin, ori->origin ); - VectorCopy( ent->e.axis[0], or->axis[0] ); - VectorCopy( ent->e.axis[1], or->axis[1] ); - VectorCopy( ent->e.axis[2], or->axis[2] ); + VectorCopy( ent->e.axis[0], ori->axis[0] ); + VectorCopy( ent->e.axis[1], ori->axis[1] ); + VectorCopy( ent->e.axis[2], ori->axis[2] ); - glMatrix[0] = or->axis[0][0]; - glMatrix[4] = or->axis[1][0]; - glMatrix[8] = or->axis[2][0]; - glMatrix[12] = or->origin[0]; + glMatrix[0] = ori->axis[0][0]; + glMatrix[4] = ori->axis[1][0]; + glMatrix[8] = ori->axis[2][0]; + glMatrix[12] = ori->origin[0]; - glMatrix[1] = or->axis[0][1]; - glMatrix[5] = or->axis[1][1]; - glMatrix[9] = or->axis[2][1]; - glMatrix[13] = or->origin[1]; + glMatrix[1] = ori->axis[0][1]; + glMatrix[5] = ori->axis[1][1]; + glMatrix[9] = ori->axis[2][1]; + glMatrix[13] = ori->origin[1]; - glMatrix[2] = or->axis[0][2]; - glMatrix[6] = or->axis[1][2]; - glMatrix[10] = or->axis[2][2]; - glMatrix[14] = or->origin[2]; + glMatrix[2] = ori->axis[0][2]; + glMatrix[6] = ori->axis[1][2]; + glMatrix[10] = ori->axis[2][2]; + glMatrix[14] = ori->origin[2]; glMatrix[3] = 0; glMatrix[7] = 0; glMatrix[11] = 0; glMatrix[15] = 1; - Matrix16Copy(glMatrix, or->transformMatrix); - myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix ); + Matrix16Copy(glMatrix, ori->transformMatrix); + myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, ori->modelMatrix ); // calculate the viewer origin in the model's space // needed for fog, specular, and environment mapping - VectorSubtract( viewParms->or.origin, or->origin, delta ); + VectorSubtract( viewParms->ori.origin, ori->origin, delta ); // compensate for scale in the axes if necessary if ( ent->e.nonNormalizedAxes ) { @@ -861,9 +861,9 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, axisLength = 1.0f; } - or->viewOrigin[0] = DotProduct( delta, or->axis[0] ) * axisLength; - or->viewOrigin[1] = DotProduct( delta, or->axis[1] ) * axisLength; - or->viewOrigin[2] = DotProduct( delta, or->axis[2] ) * axisLength; + ori->viewOrigin[0] = DotProduct( delta, ori->axis[0] ) * axisLength; + ori->viewOrigin[1] = DotProduct( delta, ori->axis[1] ) * axisLength; + ori->viewOrigin[2] = DotProduct( delta, ori->axis[2] ) * axisLength; } /* @@ -878,28 +878,28 @@ void R_RotateForViewer (void) float viewerMatrix[16]; vec3_t origin; - Com_Memset (&tr.or, 0, sizeof(tr.or)); - tr.or.axis[0][0] = 1; - tr.or.axis[1][1] = 1; - tr.or.axis[2][2] = 1; - VectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin); + Com_Memset (&tr.ori, 0, sizeof(tr.ori)); + tr.ori.axis[0][0] = 1; + tr.ori.axis[1][1] = 1; + tr.ori.axis[2][2] = 1; + VectorCopy (tr.viewParms.ori.origin, tr.ori.viewOrigin); // transform by the camera placement - VectorCopy( tr.viewParms.or.origin, origin ); + VectorCopy( tr.viewParms.ori.origin, origin ); - viewerMatrix[0] = tr.viewParms.or.axis[0][0]; - viewerMatrix[4] = tr.viewParms.or.axis[0][1]; - viewerMatrix[8] = tr.viewParms.or.axis[0][2]; + viewerMatrix[0] = tr.viewParms.ori.axis[0][0]; + viewerMatrix[4] = tr.viewParms.ori.axis[0][1]; + viewerMatrix[8] = tr.viewParms.ori.axis[0][2]; viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8]; - viewerMatrix[1] = tr.viewParms.or.axis[1][0]; - viewerMatrix[5] = tr.viewParms.or.axis[1][1]; - viewerMatrix[9] = tr.viewParms.or.axis[1][2]; + viewerMatrix[1] = tr.viewParms.ori.axis[1][0]; + viewerMatrix[5] = tr.viewParms.ori.axis[1][1]; + viewerMatrix[9] = tr.viewParms.ori.axis[1][2]; viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9]; - viewerMatrix[2] = tr.viewParms.or.axis[2][0]; - viewerMatrix[6] = tr.viewParms.or.axis[2][1]; - viewerMatrix[10] = tr.viewParms.or.axis[2][2]; + viewerMatrix[2] = tr.viewParms.ori.axis[2][0]; + viewerMatrix[6] = tr.viewParms.ori.axis[2][1]; + viewerMatrix[10] = tr.viewParms.ori.axis[2][2]; viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10]; viewerMatrix[3] = 0; @@ -909,9 +909,9 @@ void R_RotateForViewer (void) // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) - myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix ); + myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelMatrix ); - tr.viewParms.world = tr.or; + tr.viewParms.world = tr.ori; } @@ -967,7 +967,7 @@ static void R_SetFarClip( void ) v[2] = tr.viewParms.visBounds[1][2]; } - VectorSubtract( v, tr.viewParms.or.origin, vecTo ); + VectorSubtract( v, tr.viewParms.ori.origin, vecTo ); distance = vecTo[0] * vecTo[0] + vecTo[1] * vecTo[1] + vecTo[2] * vecTo[2]; @@ -996,44 +996,44 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa if(stereoSep == 0 && xmin == -xmax) { // symmetric case can be simplified - VectorCopy(dest->or.origin, ofsorigin); + VectorCopy(dest->ori.origin, ofsorigin); length = sqrt(xmax * xmax + zProj * zProj); oppleg = xmax / length; adjleg = zProj / length; - VectorScale(dest->or.axis[0], oppleg, dest->frustum[0].normal); - VectorMA(dest->frustum[0].normal, adjleg, dest->or.axis[1], dest->frustum[0].normal); + VectorScale(dest->ori.axis[0], oppleg, dest->frustum[0].normal); + VectorMA(dest->frustum[0].normal, adjleg, dest->ori.axis[1], dest->frustum[0].normal); - VectorScale(dest->or.axis[0], oppleg, dest->frustum[1].normal); - VectorMA(dest->frustum[1].normal, -adjleg, dest->or.axis[1], dest->frustum[1].normal); + VectorScale(dest->ori.axis[0], oppleg, dest->frustum[1].normal); + VectorMA(dest->frustum[1].normal, -adjleg, dest->ori.axis[1], dest->frustum[1].normal); } else { - // In stereo rendering, due to the modification of the projection matrix, dest->or.origin is not the + // In stereo rendering, due to the modification of the projection matrix, dest->ori.origin is not the // actual origin that we're rendering so offset the tip of the view pyramid. - VectorMA(dest->or.origin, stereoSep, dest->or.axis[1], ofsorigin); + VectorMA(dest->ori.origin, stereoSep, dest->ori.axis[1], ofsorigin); oppleg = xmax + stereoSep; length = sqrt(oppleg * oppleg + zProj * zProj); - VectorScale(dest->or.axis[0], oppleg / length, dest->frustum[0].normal); - VectorMA(dest->frustum[0].normal, zProj / length, dest->or.axis[1], dest->frustum[0].normal); + VectorScale(dest->ori.axis[0], oppleg / length, dest->frustum[0].normal); + VectorMA(dest->frustum[0].normal, zProj / length, dest->ori.axis[1], dest->frustum[0].normal); oppleg = xmin + stereoSep; length = sqrt(oppleg * oppleg + zProj * zProj); - VectorScale(dest->or.axis[0], -oppleg / length, dest->frustum[1].normal); - VectorMA(dest->frustum[1].normal, -zProj / length, dest->or.axis[1], dest->frustum[1].normal); + VectorScale(dest->ori.axis[0], -oppleg / length, dest->frustum[1].normal); + VectorMA(dest->frustum[1].normal, -zProj / length, dest->ori.axis[1], dest->frustum[1].normal); } length = sqrt(ymax * ymax + zProj * zProj); oppleg = ymax / length; adjleg = zProj / length; - VectorScale(dest->or.axis[0], oppleg, dest->frustum[2].normal); - VectorMA(dest->frustum[2].normal, adjleg, dest->or.axis[2], dest->frustum[2].normal); + VectorScale(dest->ori.axis[0], oppleg, dest->frustum[2].normal); + VectorMA(dest->frustum[2].normal, adjleg, dest->ori.axis[2], dest->frustum[2].normal); - VectorScale(dest->or.axis[0], oppleg, dest->frustum[3].normal); - VectorMA(dest->frustum[3].normal, -adjleg, dest->or.axis[2], dest->frustum[3].normal); + VectorScale(dest->ori.axis[0], oppleg, dest->frustum[3].normal); + VectorMA(dest->frustum[3].normal, -adjleg, dest->ori.axis[2], dest->frustum[3].normal); for (i=0 ; i<4 ; i++) { dest->frustum[i].type = PLANE_NON_AXIAL; @@ -1045,8 +1045,8 @@ void R_SetupFrustum (viewParms_t *dest, float xmin, float xmax, float ymax, floa { vec3_t farpoint; - VectorMA(ofsorigin, zFar, dest->or.axis[0], farpoint); - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(ofsorigin, zFar, dest->ori.axis[0], farpoint); + VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); dest->frustum[4].type = PLANE_NON_AXIAL; dest->frustum[4].dist = DotProduct (farpoint, dest->frustum[4].normal); @@ -1142,10 +1142,10 @@ void R_SetupProjectionZ(viewParms_t *dest) plane[2] = dest->portalPlane.normal[2]; plane[3] = dest->portalPlane.dist; - plane2[0] = -DotProduct (dest->or.axis[1], plane); - plane2[1] = DotProduct (dest->or.axis[2], plane); - plane2[2] = -DotProduct (dest->or.axis[0], plane); - plane2[3] = DotProduct (plane, dest->or.origin) - plane[3]; + plane2[0] = -DotProduct (dest->ori.axis[1], plane); + plane2[1] = DotProduct (dest->ori.axis[2], plane); + plane2[2] = -DotProduct (dest->ori.axis[0], plane); + plane2[3] = DotProduct (plane, dest->ori.origin) - plane[3]; // Lengyel, Eric. "Modifying the Projection Matrix to Perform Oblique Near-plane Clipping". // Terathon Software 3D Graphics Library, 2004. http://www.terathon.com/code/oblique.html @@ -1211,24 +1211,24 @@ void R_SetupProjectionOrtho(viewParms_t *dest, vec3_t viewBounds[2]) dest->projectionMatrix[11] = 0; dest->projectionMatrix[15] = 1; - VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->or.origin, viewBounds[0][1], dest->frustum[0].normal, pop); + VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->ori.origin, viewBounds[0][1], dest->frustum[0].normal, pop); dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->or.origin, -viewBounds[1][1], dest->frustum[1].normal, pop); + VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->ori.origin, -viewBounds[1][1], dest->frustum[1].normal, pop); dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->or.origin, viewBounds[0][2], dest->frustum[2].normal, pop); + VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->ori.origin, viewBounds[0][2], dest->frustum[2].normal, pop); dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->or.origin, -viewBounds[1][2], dest->frustum[3].normal, pop); + VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->ori.origin, -viewBounds[1][2], dest->frustum[3].normal, pop); dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->or.origin, -viewBounds[1][0], dest->frustum[4].normal, pop); + VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->ori.origin, -viewBounds[1][0], dest->frustum[4].normal, pop); dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); for (i = 0; i < 5; i++) @@ -1344,15 +1344,15 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, tr.currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); + R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.ori ); // rotate the plane, but keep the non-rotated version for matching // against the portalSurface entities R_LocalNormalToWorld( originalPlane.normal, plane.normal ); - plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); + plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.ori.origin ); // translate the original plane - originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); + originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.ori.origin ); } else { plane = originalPlane; } @@ -1462,15 +1462,15 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) tr.currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.or ); + R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.ori ); // rotate the plane, but keep the non-rotated version for matching // against the portalSurface entities R_LocalNormalToWorld( originalPlane.normal, plane.normal ); - plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.or.origin ); + plane.dist = originalPlane.dist + DotProduct( plane.normal, tr.ori.origin ); // translate the original plane - originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.or.origin ); + originalPlane.dist = originalPlane.dist + DotProduct( originalPlane.normal, tr.ori.origin ); } // locate the portal entity closest to this plane. @@ -1532,7 +1532,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 int j; unsigned int pointFlags = 0; - R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); + R_TransformModelToClip( tess.xyz[i], tr.ori.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); for ( j = 0; j < 3; j++ ) { @@ -1568,7 +1568,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 float len; - VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.or.origin, normal ); + VectorSubtract( tess.xyz[tess.indexes[i]], tr.viewParms.ori.origin, normal ); len = VectorLengthSquared( normal ); // lose the sqrt if ( len < shortest ) @@ -1646,14 +1646,14 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { if (newParms.isMirror) newParms.flags |= VPF_NOVIEWMODEL; - R_MirrorPoint (oldParms.or.origin, &surface, &camera, newParms.or.origin ); + R_MirrorPoint (oldParms.ori.origin, &surface, &camera, newParms.ori.origin ); VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); - R_MirrorVector (oldParms.or.axis[0], &surface, &camera, newParms.or.axis[0]); - R_MirrorVector (oldParms.or.axis[1], &surface, &camera, newParms.or.axis[1]); - R_MirrorVector (oldParms.or.axis[2], &surface, &camera, newParms.or.axis[2]); + R_MirrorVector (oldParms.ori.axis[0], &surface, &camera, newParms.ori.axis[0]); + R_MirrorVector (oldParms.ori.axis[1], &surface, &camera, newParms.ori.axis[1]); + R_MirrorVector (oldParms.ori.axis[2], &surface, &camera, newParms.ori.axis[2]); // OPTIMIZE: restrict the viewport on the mirrored view @@ -1930,8 +1930,8 @@ static void R_AddEntitySurface (int entityNum) break; case RT_MODEL: - // we must set up parts of tr.or for model culling - R_RotateForEntity( ent, &tr.viewParms, &tr.or ); + // we must set up parts of tr.ori for model culling + R_RotateForEntity( ent, &tr.viewParms, &tr.ori ); tr.currentModel = R_GetModelByHandle( ent->e.hModel ); if (!tr.currentModel) { @@ -2148,7 +2148,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.flags = (int)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); shadowParms.zFar = tr.refdef.dlights[i].radius; - VectorCopy( tr.refdef.dlights[i].origin, shadowParms.or.origin ); + VectorCopy( tr.refdef.dlights[i].origin, shadowParms.ori.origin ); for (j = 0; j < 6; j++) { @@ -2156,39 +2156,39 @@ void R_RenderDlightCubemaps(const refdef_t *fd) { case 0: // -X - VectorSet( shadowParms.or.axis[0], -1, 0, 0); - VectorSet( shadowParms.or.axis[1], 0, 0, -1); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); + VectorSet( shadowParms.ori.axis[0], -1, 0, 0); + VectorSet( shadowParms.ori.axis[1], 0, 0, -1); + VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; case 1: // +X - VectorSet( shadowParms.or.axis[0], 1, 0, 0); - VectorSet( shadowParms.or.axis[1], 0, 0, 1); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); + VectorSet( shadowParms.ori.axis[0], 1, 0, 0); + VectorSet( shadowParms.ori.axis[1], 0, 0, 1); + VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; case 2: // -Y - VectorSet( shadowParms.or.axis[0], 0, -1, 0); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 0, -1); + VectorSet( shadowParms.ori.axis[0], 0, -1, 0); + VectorSet( shadowParms.ori.axis[1], 1, 0, 0); + VectorSet( shadowParms.ori.axis[2], 0, 0, -1); break; case 3: // +Y - VectorSet( shadowParms.or.axis[0], 0, 1, 0); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 0, 1); + VectorSet( shadowParms.ori.axis[0], 0, 1, 0); + VectorSet( shadowParms.ori.axis[1], 1, 0, 0); + VectorSet( shadowParms.ori.axis[2], 0, 0, 1); break; case 4: // -Z - VectorSet( shadowParms.or.axis[0], 0, 0, -1); - VectorSet( shadowParms.or.axis[1], 1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); + VectorSet( shadowParms.ori.axis[0], 0, 0, -1); + VectorSet( shadowParms.ori.axis[1], 1, 0, 0); + VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; case 5: // +Z - VectorSet( shadowParms.or.axis[0], 0, 0, 1); - VectorSet( shadowParms.or.axis[1], -1, 0, 0); - VectorSet( shadowParms.or.axis[2], 0, 1, 0); + VectorSet( shadowParms.ori.axis[0], 0, 0, 1); + VectorSet( shadowParms.ori.axis[1], -1, 0, 0); + VectorSet( shadowParms.ori.axis[2], 0, 1, 0); break; } @@ -2446,11 +2446,11 @@ void R_RenderPshadowMaps(const refdef_t *fd) shadowParms.flags = (viewParmFlags_t)( VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL ); shadowParms.zFar = shadow->lightRadius; - VectorCopy(shadow->lightOrigin, shadowParms.or.origin); + VectorCopy(shadow->lightOrigin, shadowParms.ori.origin); - VectorCopy(shadow->lightViewAxis[0], shadowParms.or.axis[0]); - VectorCopy(shadow->lightViewAxis[1], shadowParms.or.axis[1]); - VectorCopy(shadow->lightViewAxis[2], shadowParms.or.axis[2]); + VectorCopy(shadow->lightViewAxis[0], shadowParms.ori.axis[0]); + VectorCopy(shadow->lightViewAxis[1], shadowParms.ori.axis[1]); + VectorCopy(shadow->lightViewAxis[2], shadowParms.ori.axis[2]); { tr.viewCount++; @@ -2496,24 +2496,24 @@ void R_RenderPshadowMaps(const refdef_t *fd) dest->projectionMatrix[11] = 0; dest->projectionMatrix[15] = 1; - VectorScale(dest->or.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); + VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - VectorScale(dest->or.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); + VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - VectorScale(dest->or.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); + VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - VectorScale(dest->or.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->or.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); + VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - VectorScale(dest->or.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->or.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); + VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->ori.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); for (j = 0; j < 5; j++) @@ -2791,11 +2791,11 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) shadowParms.flags = (viewParmFlags_t)( VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL ); shadowParms.zFar = lightviewBounds[1][0]; - VectorCopy(lightOrigin, shadowParms.or.origin); + VectorCopy(lightOrigin, shadowParms.ori.origin); - VectorCopy(lightViewAxis[0], shadowParms.or.axis[0]); - VectorCopy(lightViewAxis[1], shadowParms.or.axis[1]); - VectorCopy(lightViewAxis[2], shadowParms.or.axis[2]); + VectorCopy(lightViewAxis[0], shadowParms.ori.axis[0]); + VectorCopy(lightViewAxis[1], shadowParms.ori.axis[1]); + VectorCopy(lightViewAxis[2], shadowParms.ori.axis[2]); VectorCopy(lightOrigin, shadowParms.pvsOrigin ); @@ -2925,10 +2925,10 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) parms.fovX = 90; parms.fovY = 90; - VectorCopy( refdef.vieworg, parms.or.origin ); - VectorCopy( refdef.viewaxis[0], parms.or.axis[0] ); - VectorCopy( refdef.viewaxis[1], parms.or.axis[1] ); - VectorCopy( refdef.viewaxis[2], parms.or.axis[2] ); + VectorCopy( refdef.vieworg, parms.ori.origin ); + VectorCopy( refdef.viewaxis[0], parms.ori.axis[0] ); + VectorCopy( refdef.viewaxis[1], parms.ori.axis[1] ); + VectorCopy( refdef.viewaxis[2], parms.ori.axis[2] ); VectorCopy( refdef.vieworg, parms.pvsOrigin ); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 7bfc299bda..60deca0f5a 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -31,8 +31,8 @@ float ProjectRadius( float r, vec3_t location ) vec3_t p; float projected[4]; - c = DotProduct( tr.viewParms.or.axis[0], tr.viewParms.or.origin ); - dist = DotProduct( tr.viewParms.or.axis[0], location ) - c; + c = DotProduct( tr.viewParms.ori.axis[0], tr.viewParms.ori.origin ); + dist = DotProduct( tr.viewParms.ori.axis[0], location ) - c; if ( dist <= 0 ) return 0; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 1548f51118..f564b0c079 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -319,7 +319,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) matrix_t mvp; vec4_t pos, hpos; - dot = DotProduct(tr.sunDirection, backEnd.viewParms.or.axis[0]); + dot = DotProduct(tr.sunDirection, backEnd.viewParms.ori.axis[0]); if (dot < cutoff) return; @@ -331,7 +331,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) float dist; matrix_t trans, model, mvp; - Matrix16Translation( backEnd.viewParms.or.origin, trans ); + Matrix16Translation( backEnd.viewParms.ori.origin, trans ); Matrix16Multiply( backEnd.viewParms.world.modelMatrix, trans, model ); Matrix16Multiply(backEnd.viewParms.projectionMatrix, model, mvp); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 63fe26cf65..0ff71d8dc9 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -546,10 +546,10 @@ void RE_RenderScene( const refdef_t *fd ) { parms.stereoFrame = tr.refdef.stereoFrame; - VectorCopy( fd->vieworg, parms.or.origin ); - VectorCopy( fd->viewaxis[0], parms.or.axis[0] ); - VectorCopy( fd->viewaxis[1], parms.or.axis[1] ); - VectorCopy( fd->viewaxis[2], parms.or.axis[2] ); + VectorCopy( fd->vieworg, parms.ori.origin ); + VectorCopy( fd->viewaxis[0], parms.ori.axis[0] ); + VectorCopy( fd->viewaxis[1], parms.ori.axis[1] ); + VectorCopy( fd->viewaxis[2], parms.ori.axis[2] ); VectorCopy( fd->vieworg, parms.pvsOrigin ); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 529dec052d..77d30c2d3f 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -702,26 +702,26 @@ static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, fl fog = tr.world->fogs + tess.fogNum; - VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); - fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; - fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); + VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local ); + fogDistanceVector[0] = -backEnd.ori.modelMatrix[2]; + fogDistanceVector[1] = -backEnd.ori.modelMatrix[6]; + fogDistanceVector[2] = -backEnd.ori.modelMatrix[10]; + fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] ); // scale the fog vectors based on the fog's thickness VectorScale4(fogDistanceVector, fog->tcScale, fogDistanceVector); // rotate the gradient vector for this orientation if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + - fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + - fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + - fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; - fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); - - *eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; + fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + + fog->surface[1] * backEnd.ori.axis[0][1] + fog->surface[2] * backEnd.ori.axis[0][2]; + fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] + + fog->surface[1] * backEnd.ori.axis[1][1] + fog->surface[2] * backEnd.ori.axis[1][2]; + fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] + + fog->surface[1] * backEnd.ori.axis[2][1] + fog->surface[2] * backEnd.ori.axis[2][2]; + fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.ori.origin, fog->surface ); + + *eyeT = DotProduct( backEnd.ori.viewOrigin, fogDepthVector ) + fogDepthVector[3]; } else { *eyeT = 1; // non-surface fog always has eye inside } @@ -814,8 +814,8 @@ static void ForwardDlight( void ) { GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); + GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -873,7 +873,7 @@ static void ForwardDlight( void ) { // where they aren't rendered GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); if (pStage->bundle[TB_DIFFUSEMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); @@ -1240,8 +1240,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin); + GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); if (glState.skeletalAnimation) { @@ -1367,7 +1367,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); } - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo); @@ -1540,7 +1540,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -1551,7 +1551,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } - VectorCopy(backEnd.viewParms.or.origin, vector); + VectorCopy(backEnd.viewParms.ori.origin, vector); vector[3] = 1.0f; GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, backEnd.viewParms.zFar); diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 3bd05ca30f..a739b70b6f 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -351,9 +351,9 @@ GlobalVectorToLocal ================== */ static void GlobalVectorToLocal( const vec3_t in, vec3_t out ) { - out[0] = DotProduct( in, backEnd.or.axis[0] ); - out[1] = DotProduct( in, backEnd.or.axis[1] ); - out[2] = DotProduct( in, backEnd.or.axis[2] ); + out[0] = DotProduct( in, backEnd.ori.axis[0] ); + out[1] = DotProduct( in, backEnd.ori.axis[1] ); + out[2] = DotProduct( in, backEnd.ori.axis[2] ); } /* @@ -386,11 +386,11 @@ static void AutospriteDeform( void ) { tess.firstIndex = 0; if ( backEnd.currentEntity != &tr.worldEntity ) { - GlobalVectorToLocal( backEnd.viewParms.or.axis[1], leftDir ); - GlobalVectorToLocal( backEnd.viewParms.or.axis[2], upDir ); + GlobalVectorToLocal( backEnd.viewParms.ori.axis[1], leftDir ); + GlobalVectorToLocal( backEnd.viewParms.ori.axis[2], upDir ); } else { - VectorCopy( backEnd.viewParms.or.axis[1], leftDir ); - VectorCopy( backEnd.viewParms.or.axis[2], upDir ); + VectorCopy( backEnd.viewParms.ori.axis[1], leftDir ); + VectorCopy( backEnd.viewParms.ori.axis[2], upDir ); } for ( i = 0 ; i < oldVerts ; i+=4 ) { @@ -459,9 +459,9 @@ static void Autosprite2Deform( void ) { } if ( backEnd.currentEntity != &tr.worldEntity ) { - GlobalVectorToLocal( backEnd.viewParms.or.axis[0], forward ); + GlobalVectorToLocal( backEnd.viewParms.ori.axis[0], forward ); } else { - VectorCopy( backEnd.viewParms.or.axis[0], forward ); + VectorCopy( backEnd.viewParms.ori.axis[0], forward ); } // this is a lot of work for two triangles... @@ -695,11 +695,11 @@ void RB_CalcFogTexCoords( float *st ) { fog = tr.world->fogs + tess.fogNum; // all fogging distance is based on world Z units - VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local ); - fogDistanceVector[0] = -backEnd.or.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.or.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.or.modelMatrix[10]; - fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] ); + VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local ); + fogDistanceVector[0] = -backEnd.ori.modelMatrix[2]; + fogDistanceVector[1] = -backEnd.ori.modelMatrix[6]; + fogDistanceVector[2] = -backEnd.ori.modelMatrix[10]; + fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] ); // scale the fog vectors based on the fog's thickness fogDistanceVector[0] *= fog->tcScale; @@ -709,15 +709,15 @@ void RB_CalcFogTexCoords( float *st ) { // rotate the gradient vector for this orientation if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.or.axis[0][0] + - fog->surface[1] * backEnd.or.axis[0][1] + fog->surface[2] * backEnd.or.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.or.axis[1][0] + - fog->surface[1] * backEnd.or.axis[1][1] + fog->surface[2] * backEnd.or.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.or.axis[2][0] + - fog->surface[1] * backEnd.or.axis[2][1] + fog->surface[2] * backEnd.or.axis[2][2]; - fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.or.origin, fog->surface ); - - eyeT = DotProduct( backEnd.or.viewOrigin, fogDepthVector ) + fogDepthVector[3]; + fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + + fog->surface[1] * backEnd.ori.axis[0][1] + fog->surface[2] * backEnd.ori.axis[0][2]; + fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] + + fog->surface[1] * backEnd.ori.axis[1][1] + fog->surface[2] * backEnd.ori.axis[1][2]; + fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] + + fog->surface[1] * backEnd.ori.axis[2][1] + fog->surface[2] * backEnd.ori.axis[2][2]; + fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.ori.origin, fog->surface ); + + eyeT = DotProduct( backEnd.ori.viewOrigin, fogDepthVector ) + fogDepthVector[3]; } else { eyeT = 1; // non-surface fog always has eye inside } diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index f412b00d3e..e735d37674 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -314,11 +314,11 @@ void RB_ProjectionShadowDeform( void ) { xyz = ( float * ) tess.xyz; - ground[0] = backEnd.or.axis[0][2]; - ground[1] = backEnd.or.axis[1][2]; - ground[2] = backEnd.or.axis[2][2]; + ground[0] = backEnd.ori.axis[0][2]; + ground[1] = backEnd.ori.axis[1][2]; + ground[2] = backEnd.ori.axis[2][2]; - groundDist = backEnd.or.origin[2] - backEnd.currentEntity->e.shadowPlane; + groundDist = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; VectorCopy( backEnd.currentEntity->lightDir, lightDir ); d = DotProduct( lightDir, ground ); diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 8054d87d51..ac936826a0 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -269,7 +269,7 @@ void RB_ClipSkyPolygons( shaderCommands_t *input ) for (j = 0 ; j < 3 ; j++) { VectorSubtract( input->xyz[input->indexes[i+j]], - backEnd.viewParms.or.origin, + backEnd.viewParms.ori.origin, p[j] ); } ClipSkyPolygon( 3, p[0], 0 ); @@ -562,7 +562,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad { for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) { - VectorAdd( s_skyPoints[t][s], backEnd.viewParms.or.origin, tess.xyz[tess.numVertexes] ); + VectorAdd( s_skyPoints[t][s], backEnd.viewParms.ori.origin, tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; @@ -802,12 +802,12 @@ void RB_DrawSun( float scale, shader_t *shader ) { } //qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); - //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); + //qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]); { // FIXME: this could be a lot cleaner matrix_t translation, modelview; - Matrix16Translation( backEnd.viewParms.or.origin, translation ); + Matrix16Translation( backEnd.viewParms.ori.origin, translation ); Matrix16Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview ); GL_SetModelviewMatrix( modelview ); } @@ -871,14 +871,14 @@ void RB_StageIteratorSky( void ) { matrix_t oldmodelview; GL_State( 0 ); - //qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]); + //qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]); { // FIXME: this could be a lot cleaner matrix_t trans, product; Matrix16Copy( glState.modelview, oldmodelview ); - Matrix16Translation( backEnd.viewParms.or.origin, trans ); + Matrix16Translation( backEnd.viewParms.ori.origin, trans ); Matrix16Multiply( glState.modelview, trans, product ); GL_SetModelviewMatrix( product ); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 384dd2b504..d3d38f08b9 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -122,7 +122,7 @@ void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], // constant normal all the way around - VectorSubtract( vec3_origin, backEnd.viewParms.or.axis[0], normal ); + VectorSubtract( vec3_origin, backEnd.viewParms.ori.axis[0], normal ); tess.normal[ndx] = tess.normal[ndx+1] = @@ -249,8 +249,8 @@ static void RB_SurfaceSprite( void ) { // calculate the xyz locations for the four corners radius = ent->e.radius; if ( ent->e.rotation == 0 ) { - VectorScale( backEnd.viewParms.or.axis[1], radius, left ); - VectorScale( backEnd.viewParms.or.axis[2], radius, up ); + VectorScale( backEnd.viewParms.ori.axis[1], radius, left ); + VectorScale( backEnd.viewParms.ori.axis[2], radius, up ); } else { float s, c; float ang; @@ -259,11 +259,11 @@ static void RB_SurfaceSprite( void ) { s = sin( ang ); c = cos( ang ); - VectorScale( backEnd.viewParms.or.axis[1], c * radius, left ); - VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left ); + VectorScale( backEnd.viewParms.ori.axis[1], c * radius, left ); + VectorMA( left, -s * radius, backEnd.viewParms.ori.axis[2], left ); - VectorScale( backEnd.viewParms.or.axis[2], c * radius, up ); - VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up ); + VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); + VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); } if ( backEnd.viewParms.isMirror ) { VectorSubtract( vec3_origin, left, left ); @@ -685,11 +685,11 @@ static void DoSprite( vec3_t origin, float radius, float rotation ) s = sin( ang ); c = cos( ang ); - VectorScale( backEnd.viewParms.or.axis[1], c * radius, left ); - VectorMA( left, -s * radius, backEnd.viewParms.or.axis[2], left ); + VectorScale( backEnd.viewParms.ori.axis[1], c * radius, left ); + VectorMA( left, -s * radius, backEnd.viewParms.ori.axis[2], left ); - VectorScale( backEnd.viewParms.or.axis[2], c * radius, up ); - VectorMA( up, s * radius, backEnd.viewParms.or.axis[1], up ); + VectorScale( backEnd.viewParms.ori.axis[2], c * radius, up ); + VectorMA( up, s * radius, backEnd.viewParms.ori.axis[1], up ); if ( backEnd.viewParms.isMirror ) { @@ -892,8 +892,8 @@ static void RB_SurfaceLine( void ) VectorCopy( e->origin, start ); // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); + VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); CrossProduct( v1, v2, right ); VectorNormalize( right ); @@ -974,7 +974,7 @@ static void RB_SurfaceCylinder( void ) VectorAdd( e->origin, e->oldorigin, midpoint ); VectorScale(midpoint, 0.5f, midpoint); // Average start and end - VectorSubtract( midpoint, backEnd.viewParms.or.origin, midpoint ); + VectorSubtract( midpoint, backEnd.viewParms.ori.origin, midpoint ); length = VectorNormalize( midpoint ); // this doesn't need to be perfect....just a rough compensation for zoom level is enough @@ -1268,8 +1268,8 @@ static void RB_SurfaceElectricity() VectorCopy( e->oldorigin, end ); // compute side vector - VectorSubtract( start, backEnd.viewParms.or.origin, v1 ); - VectorSubtract( end, backEnd.viewParms.or.origin, v2 ); + VectorSubtract( start, backEnd.viewParms.ori.origin, v1 ); + VectorSubtract( end, backEnd.viewParms.ori.origin, v2 ); CrossProduct( v1, v2, right ); VectorNormalize( right ); @@ -1714,15 +1714,15 @@ static float LodErrorForVolume( vec3_t local, float radius ) { return 0; } - world[0] = local[0] * backEnd.or.axis[0][0] + local[1] * backEnd.or.axis[1][0] + - local[2] * backEnd.or.axis[2][0] + backEnd.or.origin[0]; - world[1] = local[0] * backEnd.or.axis[0][1] + local[1] * backEnd.or.axis[1][1] + - local[2] * backEnd.or.axis[2][1] + backEnd.or.origin[1]; - world[2] = local[0] * backEnd.or.axis[0][2] + local[1] * backEnd.or.axis[1][2] + - local[2] * backEnd.or.axis[2][2] + backEnd.or.origin[2]; + world[0] = local[0] * backEnd.ori.axis[0][0] + local[1] * backEnd.ori.axis[1][0] + + local[2] * backEnd.ori.axis[2][0] + backEnd.ori.origin[0]; + world[1] = local[0] * backEnd.ori.axis[0][1] + local[1] * backEnd.ori.axis[1][1] + + local[2] * backEnd.ori.axis[2][1] + backEnd.ori.origin[1]; + world[2] = local[0] * backEnd.ori.axis[0][2] + local[1] * backEnd.ori.axis[1][2] + + local[2] * backEnd.ori.axis[2][2] + backEnd.ori.origin[2]; - VectorSubtract( world, backEnd.viewParms.or.origin, world ); - d = DotProduct( world, backEnd.viewParms.or.axis[0] ); + VectorSubtract( world, backEnd.viewParms.ori.origin, world ); + d = DotProduct( world, backEnd.viewParms.ori.axis[0] ); if ( d < 0 ) { d = -d; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index af5b8b05a0..9710e1d6a5 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -80,7 +80,7 @@ static qboolean R_CullSurface( msurface_t *surf ) { // do proper cull for orthographic projection if (tr.viewParms.flags & VPF_ORTHOGRAPHIC) { - d = DotProduct(tr.viewParms.or.axis[0], surf->cullinfo.plane.normal); + d = DotProduct(tr.viewParms.ori.axis[0], surf->cullinfo.plane.normal); if ( ct == CT_FRONT_SIDED ) { if (d > 0) return qtrue; @@ -91,7 +91,7 @@ static qboolean R_CullSurface( msurface_t *surf ) { return qfalse; } - d = DotProduct (tr.or.viewOrigin, surf->cullinfo.plane.normal); + d = DotProduct (tr.ori.viewOrigin, surf->cullinfo.plane.normal); // don't cull exactly on the plane, because there are levels of rounding // through the BSP, ICD, and hardware that may cause pixel gaps if an From 97683239b19196b632dc2d593f54756d29cbaf67 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 20 Jan 2014 11:28:21 -0600 Subject: [PATCH 149/708] [MP] Rend2: Ensure tess struct is 16 byte aligned on win32 platforms too. --- codemp/rd-rend2/tr_local.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6796d43733..4d37797c06 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2462,7 +2462,7 @@ typedef struct stageVars #define MAX_MULTIDRAW_PRIMITIVES 16384 -typedef struct shaderCommands_s +struct shaderCommands_s { glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); @@ -2511,8 +2511,13 @@ typedef struct shaderCommands_s // JA specific bool fading; -} shaderCommands_t; +}; +#ifdef _WIN32 + typedef __declspec(align(16)) shaderCommands_s shaderCommands_t; +#else + typedef struct shaderCommands_s shaderCommands_t; +#endif extern shaderCommands_t tess; extern color4ub_t styleColors[MAX_LIGHT_STYLES]; From a4f77fbedd6b6c735a21434f77306250d9f6b21a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Jan 2014 07:50:37 +0000 Subject: [PATCH 150/708] Merged some of the changes from ioq3 rend2. * OpenGL2: Add r_ignoreDstAlpha. * Make GL2 MDR code use R_VboPackNormal for normal * Fix GL2 deluxemap 0,0,0 to 127,127,127 * Don't create images/framebuffers that won't be used * don't call va each frame in GLSL_VertexAttribPointers * Fix OpenGL2 non-HDR map surface over brighting --- codemp/rd-rend2/tr_animation.cpp | 2 +- codemp/rd-rend2/tr_backend.cpp | 24 ++++++++----- codemp/rd-rend2/tr_bsp.cpp | 25 ++++++++++--- codemp/rd-rend2/tr_fbo.cpp | 61 ++++++++++++++++++-------------- codemp/rd-rend2/tr_glsl.cpp | 5 ++- codemp/rd-rend2/tr_image.cpp | 23 ++++++++---- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_scene.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 6 ++-- codemp/rd-rend2/tr_shader.cpp | 20 +++++++++++ 12 files changed, 118 insertions(+), 55 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index a6d8e6f49e..5f3bd27ce0 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -411,7 +411,7 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) tess.xyz[baseVertex + j][1] = tempVert[1]; tess.xyz[baseVertex + j][2] = tempVert[2]; - tess.normal[baseVertex + j] = R_VboPackTangent(tempNormal); + tess.normal[baseVertex + j] = R_VboPackNormal(tempNormal); tess.texCoords[baseVertex + j][0][0] = v->texCoords[0]; tess.texCoords[baseVertex + j][0][1] = v->texCoords[1]; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1094ebb244..c6ad2ce2fe 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -471,7 +471,7 @@ void RB_BeginDrawingView (void) { FBO_Bind(backEnd.viewParms.targetFbo); // FIXME: hack for cubemap testing - if (backEnd.viewParms.targetFbo == tr.renderCubeFbo) + if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); @@ -511,7 +511,7 @@ void RB_BeginDrawingView (void) { } // clear to black for cube maps - if (backEnd.viewParms.targetFbo == tr.renderCubeFbo) + if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); @@ -1300,7 +1300,7 @@ const void *RB_DrawSurfs( const void *data ) { FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0); } - if (backEnd.viewParms.flags & VPF_USESUNLIGHT) + if (r_sunlightMode->integer && backEnd.viewParms.flags & VPF_USESUNLIGHT) { vec4_t quadVerts[4]; vec2_t texCoords[4]; @@ -1515,7 +1515,7 @@ const void *RB_DrawSurfs( const void *data ) { RB_RenderFlares(); } - if (glRefConfig.framebufferObject && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + if (glRefConfig.framebufferObject && tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { FBO_Bind(NULL); GL_SelectTexture(TB_CUBEMAP); @@ -1777,13 +1777,19 @@ const void *RB_CapShadowMap(const void *data) GL_SelectTexture(0); if (cmd->cubeSide != -1) { - GL_Bind(tr.shadowCubemaps[cmd->map]); - qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + if (tr.shadowCubemaps[cmd->map] != NULL) + { + GL_Bind(tr.shadowCubemaps[cmd->map]); + qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + } } else { - GL_Bind(tr.pshadowMaps[cmd->map]); - qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + if (tr.pshadowMaps[cmd->map] != NULL) + { + GL_Bind(tr.pshadowMaps[cmd->map]); + qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + } } } @@ -1885,7 +1891,7 @@ const void *RB_PostProcess(const void *data) else RB_GaussianBlur(backEnd.refdef.blurFactor); - if (0) + if (0 && r_sunlightMode->integer) { vec4i_t dstBox; VectorSet4(dstBox, 0, 0, 128, 128); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index bae4867bed..a568a84ff9 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -128,17 +128,32 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { /* =============== -R_ColorShiftLightingBytes +R_ColorShiftLightingFloats =============== */ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) { + float r, g, b; + scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); - out[0] = in[0] * scale; - out[1] = in[1] * scale; - out[2] = in[2] * scale; + r = in[0] * scale; + g = in[1] * scale; + b = in[2] * scale; + + if ( !r_hdr->integer && (r > 1 || g > 1 || b > 1) ) + { + float max = max (max (r, g), b); + + r /= max; + g /= max; + b /= max; + } + + out[0] = r; + out[1] = g; + out[2] = b; out[3] = in[3]; } @@ -472,7 +487,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { image[j*4+2] = buf_p[j*3+2]; // make 0,0,0 into 127,127,127 - if ((image[j*4+0] == 0) && (image[j*4+0] == 0) && (image[j*4+2] == 0)) + if ((image[j*4+0] == 0) && (image[j*4+1] == 0) && (image[j*4+2] == 0)) { image[j*4+0] = image[j*4+1] = diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 68d6090774..08495f8098 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -465,34 +465,49 @@ void FBO_Init(void) } // FIXME: Don't use separate color/depth buffers for a shadow buffer - for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) +#if MAX_DRAWN_PSHADOWS > 0 + if (tr.pshadowMaps[0] != NULL) { - tr.pshadowFbos[i] = FBO_Create(va("_shadowmap%d", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); - FBO_Bind(tr.pshadowFbos[i]); + for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) + { + tr.pshadowFbos[i] = FBO_Create(va("_shadowmap%d", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); + FBO_Bind(tr.pshadowFbos[i]); - //FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); - FBO_AttachTextureImage(tr.pshadowMaps[i], 0); + //FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); + FBO_AttachTextureImage(tr.pshadowMaps[i], 0); - FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24_ARB, 0, 0); - //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); + FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24_ARB, 0, 0); + //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); - R_CheckFBO(tr.pshadowFbos[i]); + R_CheckFBO(tr.pshadowFbos[i]); + } } +#endif - for ( i = 0; i < 3; i++) + if (tr.sunShadowDepthImage[0] != NULL) { - tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height); - FBO_Bind(tr.sunShadowFbo[i]); + for ( i = 0; i < 3; i++) + { + tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height); + FBO_Bind(tr.sunShadowFbo[i]); + + //FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0); + //FBO_AttachTextureImage(tr.sunShadowImage, 0); + qglDrawBuffer(GL_NONE); + qglReadBuffer(GL_NONE); + + //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); - //FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0); - //FBO_AttachTextureImage(tr.sunShadowImage, 0); - qglDrawBuffer(GL_NONE); - qglReadBuffer(GL_NONE); + R_CheckFBO(tr.sunShadowFbo[i]); + } - //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); - R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); + tr.screenShadowFbo = FBO_Create("_screenshadow", tr.screenShadowImage->width, tr.screenShadowImage->height); + FBO_Bind(tr.screenShadowFbo); + + FBO_AttachTextureImage(tr.screenShadowImage, 0); - R_CheckFBO(tr.sunShadowFbo[i]); + R_CheckFBO(tr.screenShadowFbo); } for (i = 0; i < 2; i++) @@ -537,15 +552,6 @@ void FBO_Init(void) R_CheckFBO(tr.quarterFbo[i]); } - { - tr.screenShadowFbo = FBO_Create("_screenshadow", tr.screenShadowImage->width, tr.screenShadowImage->height); - FBO_Bind(tr.screenShadowFbo); - - FBO_AttachTextureImage(tr.screenShadowImage, 0); - - R_CheckFBO(tr.screenShadowFbo); - } - if (r_ssao->integer) { tr.hdrDepthFbo = FBO_Create("_hdrDepth", tr.hdrDepthImage->width, tr.hdrDepthImage->height); @@ -563,6 +569,7 @@ void FBO_Init(void) R_CheckFBO(tr.screenSsaoFbo); } + if (tr.renderCubeImage != NULL) { tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); FBO_Bind(tr.renderCubeFbo); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index b6d1322831..3d2eb8bc00 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1734,7 +1734,10 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) } // don't just call LogComment, or we will get a call to va() every frame! - GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", vbo->name)); + if (r_logFile->integer) + { + GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", vbo->name)); + } // position/normal/tangent are always set in case of animation oldFrame = glState.vertexAttribsOldFrame; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index fdc5d71ccd..34528cc5b7 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2860,25 +2860,34 @@ void R_CreateBuiltinImages( void ) { tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } - tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - if (r_ssao->integer) { tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB); } - for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) + if (r_shadows->integer == 4) { - tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) + { + tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } } - for ( x = 0; x < 3; x++) + if (r_sunlightMode->integer) { - tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + for ( x = 0; x < 3; x++) + { + tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + } + + tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } - tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); + if (r_cubeMapping->integer) + { + tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); + } } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 81c6cb4698..b581fd9ba6 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -162,6 +162,7 @@ cvar_t *r_shadowMapSize; cvar_t *r_shadowCascadeZNear; cvar_t *r_shadowCascadeZFar; cvar_t *r_shadowCascadeZBias; +cvar_t *r_ignoreDstAlpha; cvar_t *r_ignoreGLErrors; cvar_t *r_logFile; @@ -1292,6 +1293,7 @@ void R_Register( void ) r_shadowCascadeZNear = ri->Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH ); r_shadowCascadeZFar = ri->Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH ); r_shadowCascadeZBias = ri->Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH ); + r_ignoreDstAlpha = ri->Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH ); // // temporary latched variables that can only change over a restart diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 4d37797c06..3f9a0e9b37 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -191,6 +191,7 @@ extern cvar_t *r_shadowMapSize; extern cvar_t *r_shadowCascadeZNear; extern cvar_t *r_shadowCascadeZFar; extern cvar_t *r_shadowCascadeZBias; +extern cvar_t *r_ignoreDstAlpha; extern cvar_t *r_ignoreGLErrors; extern cvar_t *r_logFile; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 7a9ca37a67..430baff9cd 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2894,7 +2894,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) // FIXME: sun shadows aren't rendered correctly in cubemaps // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if(0) //(glRefConfig.framebufferObject && (r_forceSun->integer || tr.sunShadows)) + if(0) //(glRefConfig.framebufferObject && r_sunlightMode->integer && (r_forceSun->integer || tr.sunShadows)) { R_RenderSunShadowMaps(&refdef, 0); R_RenderSunShadowMaps(&refdef, 1); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 0ff71d8dc9..02bf443980 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -506,7 +506,7 @@ void RE_RenderScene( const refdef_t *fd ) { } // playing with even more shadows - if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) + if(glRefConfig.framebufferObject && r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) { R_RenderSunShadowMaps(fd, 0); R_RenderSunShadowMaps(fd, 1); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 77d30c2d3f..cdcc13d67c 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1388,7 +1388,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) int i; vec4_t enableTextures; - if ((backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) + if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP); GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); @@ -1699,8 +1699,8 @@ void RB_StageIteratorGeneric( void ) // // pshadows! // - if (glRefConfig.framebufferObject && tess.pshadowBits && tess.shader->sort <= SS_OPAQUE - && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { + if (glRefConfig.framebufferObject && r_shadows->integer == 4 && tess.pshadowBits && + tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) { ProjectPshadowVBOGLSL(); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ac17dd76ba..23b2621807 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -277,10 +277,20 @@ static int NameToSrcBlendMode( const char *name ) } else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) { + if ( r_ignoreDstAlpha->integer ) + { + return GLS_DSTBLEND_ONE; + } + return GLS_SRCBLEND_DST_ALPHA; } else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) { + if ( r_ignoreDstAlpha->integer ) + { + return GLS_DSTBLEND_ZERO; + } + return GLS_SRCBLEND_ONE_MINUS_DST_ALPHA; } else if ( !Q_stricmp( name, "GL_SRC_ALPHA_SATURATE" ) ) @@ -317,10 +327,20 @@ static int NameToDstBlendMode( const char *name ) } else if ( !Q_stricmp( name, "GL_DST_ALPHA" ) ) { + if ( r_ignoreDstAlpha->integer ) + { + return GLS_DSTBLEND_ONE; + } + return GLS_DSTBLEND_DST_ALPHA; } else if ( !Q_stricmp( name, "GL_ONE_MINUS_DST_ALPHA" ) ) { + if ( r_ignoreDstAlpha->integer ) + { + return GLS_DSTBLEND_ZERO; + } + return GLS_DSTBLEND_ONE_MINUS_DST_ALPHA; } else if ( !Q_stricmp( name, "GL_SRC_COLOR" ) ) From 2e666f0f8c75e1287c45c0bb0d472721834bbbeb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 9 Feb 2014 23:10:11 +0000 Subject: [PATCH 151/708] [MP] Rend2: removed some unncessary comments --- codemp/rd-common/tr_public.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/codemp/rd-common/tr_public.h b/codemp/rd-common/tr_public.h index 573ec21abd..ae23ada3f0 100644 --- a/codemp/rd-common/tr_public.h +++ b/codemp/rd-common/tr_public.h @@ -29,9 +29,9 @@ typedef struct refexport_s { // size display elements void (*BeginRegistration) ( glconfig_t *config ); qhandle_t (*RegisterModel) ( const char *name ); - qhandle_t (*RegisterServerModel) ( const char *name ); // NOT IN SP + qhandle_t (*RegisterServerModel) ( const char *name ); qhandle_t (*RegisterSkin) ( const char *name ); - qhandle_t (*RegisterServerSkin) ( const char *name ); // NOT IN SP + qhandle_t (*RegisterServerSkin) ( const char *name ); qhandle_t (*RegisterShader) ( const char *name ); qhandle_t (*RegisterShaderNoMip) ( const char *name ); const char * (*ShaderNameFromIndex) ( int index ); @@ -130,23 +130,23 @@ typedef struct refexport_s { void (*G2API_AnimateG2ModelsRag) ( CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params ); qboolean (*G2API_AttachEnt) ( int *boltInfo, CGhoul2Info_v& ghoul2, int modelIndex, int toBoltIndex, int entNum, int toModelNum ); qboolean (*G2API_AttachG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel ); - void (*G2API_AttachInstanceToEntNum) ( CGhoul2Info_v &ghoul2, int entityNum, qboolean server ); // NOT IN SP - void (*G2API_AbsurdSmoothing) ( CGhoul2Info_v &ghoul2, qboolean status ); // NOT IN SP - void (*G2API_BoltMatrixReconstruction) ( qboolean reconstruct ); // NOT IN SP - void (*G2API_BoltMatrixSPMethod) ( qboolean spMethod ); // NOT IN SP - void (*G2API_CleanEntAttachments) ( void ); // NOT IN SP + void (*G2API_AttachInstanceToEntNum) ( CGhoul2Info_v &ghoul2, int entityNum, qboolean server ); + void (*G2API_AbsurdSmoothing) ( CGhoul2Info_v &ghoul2, qboolean status ); + void (*G2API_BoltMatrixReconstruction) ( qboolean reconstruct ); + void (*G2API_BoltMatrixSPMethod) ( qboolean spMethod ); + void (*G2API_CleanEntAttachments) ( void ); void (*G2API_CleanGhoul2Models) ( CGhoul2Info_v **ghoul2Ptr ); void (*G2API_ClearAttachedInstance) ( int entityNum ); void (*G2API_CollisionDetect) ( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius ); void (*G2API_CollisionDetectCache) ( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius ); int (*G2API_CopyGhoul2Instance) ( CGhoul2Info_v &g2From, CGhoul2Info_v &g2To, int modelIndex ); - void (*G2API_CopySpecificG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo ); // NOT IN SP + void (*G2API_CopySpecificG2Model) ( CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int modelTo ); qboolean (*G2API_DetachG2Model) ( CGhoul2Info *ghlInfo ); qboolean (*G2API_DoesBoneExist) ( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName ); void (*G2API_DuplicateGhoul2Instance) ( CGhoul2Info_v &g2From, CGhoul2Info_v **g2To ); void (*G2API_FreeSaveBuffer) ( char *buffer ); qboolean (*G2API_GetAnimFileName) ( CGhoul2Info *ghlInfo, char **filename ); - char * (*G2API_GetAnimFileNameIndex) ( qhandle_t modelIndex ); // NOT IN SP + char * (*G2API_GetAnimFileNameIndex) ( qhandle_t modelIndex ); qboolean (*G2API_GetAnimRange) ( CGhoul2Info *ghlInfo, const char *boneName, int *startFrame, int *endFrame ); qboolean (*G2API_GetBoltMatrix) ( CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ); qboolean (*G2API_GetBoneAnim) ( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, qhandle_t *modelList ); @@ -161,9 +161,9 @@ typedef struct refexport_s { int (*G2API_GetSurfaceOnOff) ( CGhoul2Info *ghlInfo, const char *surfaceName ); int (*G2API_GetSurfaceRenderStatus) ( CGhoul2Info_v& ghoul2, int modelIndex, const char *surfaceName ); int (*G2API_GetTime) ( int argTime ); - int (*G2API_Ghoul2Size) ( CGhoul2Info_v &ghoul2 ); // NOT IN SP + int (*G2API_Ghoul2Size) ( CGhoul2Info_v &ghoul2 ); void (*G2API_GiveMeVectorFromMatrix) ( mdxaBone_t *boltMatrix, Eorientations flags, vec3_t vec ); - qboolean (*G2API_HasGhoul2ModelOnIndex) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); // NOT IN SP + qboolean (*G2API_HasGhoul2ModelOnIndex) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); qboolean (*G2API_HaveWeGhoul2Models) ( CGhoul2Info_v &ghoul2 ); qboolean (*G2API_IKMove) ( CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params ); int (*G2API_InitGhoul2Model) ( CGhoul2Info_v **ghoul2Ptr, const char *fileName, int modelIndex, qhandle_t customSkin, qhandle_t customShader, int modelFlags, int lodBias ); @@ -184,11 +184,11 @@ typedef struct refexport_s { qboolean (*G2API_RemoveBolt) ( CGhoul2Info *ghlInfo, const int index ); qboolean (*G2API_RemoveBone) ( CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName ); qboolean (*G2API_RemoveGhoul2Model) ( CGhoul2Info_v **ghlRemove, const int modelIndex ); - qboolean (*G2API_RemoveGhoul2Models) ( CGhoul2Info_v **ghlRemove ); // NOT IN SP + qboolean (*G2API_RemoveGhoul2Models) ( CGhoul2Info_v **ghlRemove ); qboolean (*G2API_RemoveSurface) ( CGhoul2Info *ghlInfo, const int index ); - void (*G2API_ResetRagDoll) ( CGhoul2Info_v &ghoul2 ); // NOT IN SP + void (*G2API_ResetRagDoll) ( CGhoul2Info_v &ghoul2 ); qboolean (*G2API_SaveGhoul2Models) ( CGhoul2Info_v &ghoul2, char **buffer, int *size ); - void (*G2API_SetBoltInfo) ( CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo ); // NOT IN SP + void (*G2API_SetBoltInfo) ( CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo ); qboolean (*G2API_SetBoneAngles) ( CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ); qboolean (*G2API_SetBoneAnglesIndex) ( CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, const Eorientations yaw, const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, int blendTime, int currentTime ); qboolean (*G2API_SetBoneAnglesMatrix) ( CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, const int flags, qhandle_t *modelList, int blendTime, int currentTime ); From 546d286b3fa78a7fc3a7af4cf7a65a0440c0d92c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 9 Feb 2014 23:19:09 +0000 Subject: [PATCH 152/708] [MP] Rend2: Merge fixes/changes from rd-vanilla --- codemp/rd-rend2/CMakeLists.txt | 2 +- codemp/rd-rend2/G2_API.cpp | 282 +++++++++++++++++++++++++++++--- codemp/rd-rend2/G2_bolts.cpp | 2 +- codemp/rd-rend2/G2_bones.cpp | 2 +- codemp/rd-rend2/G2_misc.cpp | 16 +- codemp/rd-rend2/G2_surfaces.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 19 ++- codemp/rd-rend2/tr_main.cpp | 2 +- 9 files changed, 283 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 18d75e4ac1..d8ca1f6f59 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -14,7 +14,6 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_API.cpp" "${MPDir}/rd-rend2/G2_bolts.cpp" "${MPDir}/rd-rend2/G2_bones.cpp" - "${MPDir}/rd-rend2/G2_local.h" "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" "${MPDir}/rd-rend2/tr_animation.cpp" @@ -64,6 +63,7 @@ set(MPRend2Files ${MPRend2Files} ${MPRend2GLSLFiles}) set(MPRend2Ghoul2Files "${MPDir}/ghoul2/g2_local.h" + "${MPDir}/ghoul2/ghoul2_shared.h" "${MPDir}/ghoul2/G2_gore.cpp" "${MPDir}/ghoul2/G2_gore.h") source_group("ghoul2" FILES ${MPRend2Ghoul2Files}) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index e80f4d25ac..193c413ccc 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1,5 +1,5 @@ #include "ghoul2/G2.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" #include "qcommon/MiniHeap.h" //rww - RAGDOLL_BEGIN @@ -218,11 +218,12 @@ void G2API_CleanEntAttachments(void) void CopyBoneCache(CBoneCache *to, CBoneCache *from); #endif -qboolean G2API_OverrideServerWithClientData(CGhoul2Info *serverInstance) +qboolean G2API_OverrideServerWithClientData(CGhoul2Info_v& ghoul2, int modelIndex) { #ifndef _G2_LISTEN_SERVER_OPT return qfalse; #else + CGhoul2Info *serverInstance = &ghoul2[modelIndex]; CGhoul2Info *clientInstance; if (ri->Cvar_VariableIntegerValue( "dedicated" )) @@ -284,6 +285,98 @@ qboolean G2API_OverrideServerWithClientData(CGhoul2Info *serverInstance) #define G2_INDEX_MASK (MAX_G2_MODELS-1) +static size_t GetSizeOfGhoul2Info ( const CGhoul2Info& g2Info ) +{ + size_t size = 0; + + // This is pretty ugly, but we don't want to save everything in the CGhoul2Info object. + size += offsetof (CGhoul2Info, mTransformedVertsArray) - offsetof (CGhoul2Info, mModelindex); + + // Surface vector + size + size += sizeof (int); + size += g2Info.mSlist.size() * sizeof (surfaceInfo_t); + + // Bone vector + size + size += sizeof (int); + size += g2Info.mBlist.size() * sizeof (boneInfo_t); + + // Bolt vector + size + size += sizeof (int); + size += g2Info.mBltlist.size() * sizeof (boltInfo_t); + + return size; +} + +static size_t SerializeGhoul2Info ( char *buffer, const CGhoul2Info& g2Info ) +{ + char *base = buffer; + size_t blockSize; + + // Oh the ugliness... + blockSize = offsetof (CGhoul2Info, mTransformedVertsArray) - offsetof (CGhoul2Info, mModelindex); + memcpy (buffer, &g2Info.mModelindex, blockSize); + buffer += blockSize; + + // Surfaces vector + size + *(int *)buffer = g2Info.mSlist.size(); + buffer += sizeof (int); + + blockSize = g2Info.mSlist.size() * sizeof (surfaceInfo_t); + memcpy (buffer, g2Info.mSlist.data(), g2Info.mSlist.size() * sizeof (surfaceInfo_t)); + buffer += blockSize; + + // Bones vector + size + *(int *)buffer = g2Info.mBlist.size(); + buffer += sizeof (int); + + blockSize = g2Info.mBlist.size() * sizeof (boneInfo_t); + memcpy (buffer, g2Info.mBlist.data(), g2Info.mBlist.size() * sizeof (boneInfo_t)); + buffer += blockSize; + + // Bolts vector + size + *(int *)buffer = g2Info.mBltlist.size(); + buffer += sizeof (int); + + blockSize = g2Info.mBltlist.size() * sizeof (boltInfo_t); + memcpy (buffer, g2Info.mBltlist.data(), g2Info.mBltlist.size() * sizeof (boltInfo_t)); + buffer += blockSize; + + return static_cast(buffer - base); +} + +static size_t DeserializeGhoul2Info ( const char *buffer, CGhoul2Info& g2Info ) +{ + const char *base = buffer; + size_t size; + + size = offsetof (CGhoul2Info, mTransformedVertsArray) - offsetof (CGhoul2Info, mModelindex); + memcpy (&g2Info.mModelindex, buffer, size); + buffer += size; + + // Surfaces vector + size = *(int *)buffer; + buffer += sizeof (int); + + g2Info.mSlist.assign ((surfaceInfo_t *)buffer, (surfaceInfo_t *)buffer + size); + buffer += sizeof (surfaceInfo_t) * size; + + // Bones vector + size = *(int *)buffer; + buffer += sizeof (int); + + g2Info.mBlist.assign ((boneInfo_t *)buffer, (boneInfo_t *)buffer + size); + buffer += sizeof (boneInfo_t) * size; + + // Bolt vector + size = *(int *)buffer; + buffer += sizeof (int); + + g2Info.mBltlist.assign ((boltInfo_t *)buffer, (boltInfo_t *)buffer + size); + buffer += sizeof (boltInfo_t) * size; + + return static_cast(buffer - base); +} + class Ghoul2InfoArray : public IGhoul2InfoArray { vector mInfos[MAX_G2_MODELS]; @@ -323,6 +416,94 @@ class Ghoul2InfoArray : public IGhoul2InfoArray mFreeIndecies.push_back(i); } } + + size_t GetSerializedSize() const + { + size_t size = 0; + + size += sizeof (int); // size of mFreeIndecies linked list + size += mFreeIndecies.size() * sizeof (int); + + size += sizeof (mIds); + + for ( size_t i = 0; i < MAX_G2_MODELS; i++ ) + { + size += sizeof (int); // size of the mInfos[i] vector + + for ( size_t j = 0; j < mInfos[i].size(); j++ ) + { + size += GetSizeOfGhoul2Info (mInfos[i][j]); + } + } + + return size; + } + + size_t Serialize ( char *buffer ) const + { + char *base = buffer; + + // Free indices + *(int *)buffer = mFreeIndecies.size(); + buffer += sizeof (int); + + std::copy (mFreeIndecies.begin(), mFreeIndecies.end(), (int *)buffer); + buffer += sizeof (int) * mFreeIndecies.size(); + + // IDs + memcpy (buffer, mIds, sizeof (mIds)); + buffer += sizeof (mIds); + + // Ghoul2 infos + for ( size_t i = 0; i < MAX_G2_MODELS; i++ ) + { + *(int *)buffer = mInfos[i].size(); + buffer += sizeof (int); + + for ( size_t j = 0; j < mInfos[i].size(); j++ ) + { + buffer += SerializeGhoul2Info (buffer, mInfos[i][j]); + } + } + + return static_cast(buffer - base); + } + + size_t Deserialize ( const char *buffer, size_t size ) + { + const char *base = buffer; + size_t count; + + // Free indices + count = *(int *)buffer; + buffer += sizeof (int); + + mFreeIndecies.assign ((int *)buffer, (int *)buffer + count); + buffer += sizeof (int) * count; + + // IDs + memcpy (mIds, buffer, sizeof (mIds)); + buffer += sizeof (mIds); + + // Ghoul2 infos + for ( size_t i = 0; i < MAX_G2_MODELS; i++ ) + { + mInfos[i].clear(); + + count = *(int *)buffer; + buffer += sizeof (int); + + mInfos[i].resize (count); + + for ( size_t j = 0; j < count; j++ ) + { + buffer += DeserializeGhoul2Info (buffer, mInfos[i][j]); + } + } + + return static_cast(buffer - base); + } + #if G2API_DEBUG ~Ghoul2InfoArray() { @@ -399,15 +580,11 @@ class Ghoul2InfoArray : public IGhoul2InfoArray } vector &Get(int handle) { - static vector null; assert(handle>0); //null handle assert((handle&G2_INDEX_MASK)>=0&&(handle&G2_INDEX_MASK)=MAX_G2_MODELS||mIds[handle&G2_INDEX_MASK]!=handle) - { - null.clear(); - return null; - } + assert(!(handle<=0||(handle&G2_INDEX_MASK)<0||(handle&G2_INDEX_MASK)>=MAX_G2_MODELS||mIds[handle&G2_INDEX_MASK]!=handle)); + return mInfos[handle&G2_INDEX_MASK]; } const vector &Get(int handle) const @@ -456,6 +633,42 @@ IGhoul2InfoArray &TheGhoul2InfoArray() return *singleton; } +#define PERSISTENT_G2DATA "g2infoarray" + +void RestoreGhoul2InfoArray() +{ + if (singleton == NULL) + { + // Create the ghoul2 info array + TheGhoul2InfoArray(); + + size_t size; + const void *data = ri->PD_Load (PERSISTENT_G2DATA, &size); + if ( data == NULL ) + { + return; + } + + size_t read = singleton->Deserialize ((const char *)data, size); + Z_Free ((void *)data); + + assert (read == size); + } +} + +void SaveGhoul2InfoArray() +{ + size_t size = singleton->GetSerializedSize(); + void *data = Z_Malloc (size, TAG_GHOUL2); + size_t written = singleton->Serialize ((char *)data); + + assert (written == size); + + if ( !ri->PD_Store (PERSISTENT_G2DATA, data, size) ) + { + Com_Printf (S_COLOR_RED "ERROR: Failed to store persistent renderer data.\n"); + } +} void Ghoul2InfoArray_Free(void) { @@ -518,8 +731,6 @@ void G2API_CleanGhoul2Models(CGhoul2Info_v **ghoul2Ptr) G2API_ClearSkinGore ( ghoul2 ); #endif - ghoul2.~CGhoul2Info_v(); - #ifdef _FULL_G2_LEAK_CHECKING if (g_G2AllocServer) { @@ -646,8 +857,10 @@ qboolean G2API_SetLodBias(CGhoul2Info *ghlInfo, int lodBias) } void G2_SetSurfaceOnOffFromSkin (CGhoul2Info *ghlInfo, qhandle_t renderSkin); -qboolean G2API_SetSkin(CGhoul2Info *ghlInfo, qhandle_t customSkin, qhandle_t renderSkin) +qboolean G2API_SetSkin(CGhoul2Info_v& ghoul2, int modelIndex, qhandle_t customSkin, qhandle_t renderSkin) { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (ghlInfo) { ghlInfo->mCustomSkin = customSkin; @@ -739,8 +952,10 @@ int G2API_GetParentSurface(CGhoul2Info *ghlInfo, const int index) return -1; } -int G2API_GetSurfaceRenderStatus(CGhoul2Info *ghlInfo, const char *surfaceName) +int G2API_GetSurfaceRenderStatus(CGhoul2Info_v& ghoul2, int modelIndex, const char *surfaceName) { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) { return G2_IsSurfaceRendered(ghlInfo, surfaceName, ghlInfo->mSlist); @@ -928,8 +1143,10 @@ qboolean G2API_RemoveGhoul2Models(CGhoul2Info_v **ghlRemove) } //check if a bone exists on skeleton without actually adding to the bone list -rww -qboolean G2API_DoesBoneExist(CGhoul2Info *ghlInfo, const char *boneName) +qboolean G2API_DoesBoneExist(CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName) { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) { //model is valid mdxaHeader_t *mdxa = ghlInfo->currentModel->data.gla; @@ -1105,13 +1322,16 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch return qfalse; } -qboolean G2API_GetBoneAnim(CGhoul2Info *ghlInfo, const char *boneName, const int currentTime, float *currentFrame, +qboolean G2API_GetBoneAnim(CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName, const int currentTime, float *currentFrame, int *startFrame, int *endFrame, int *flags, float *animSpeed, int *modelList) { assert(startFrame!=endFrame); //this is bad assert(startFrame!=flags); //this is bad assert(endFrame!=flags); //this is bad assert(currentFrame!=animSpeed); //this is bad + + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) { int aCurrentTime=G2API_GetTime(currentTime); @@ -1381,8 +1601,10 @@ void G2API_ResetRagDoll(CGhoul2Info_v &ghoul2) } //rww - RAGDOLL_END -qboolean G2API_RemoveBone(CGhoul2Info *ghlInfo, const char *boneName) +qboolean G2API_RemoveBone(CGhoul2Info_v& ghoul2, int modelIndex, const char *boneName) { + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) { // ensure we flush the cache @@ -1670,8 +1892,10 @@ qboolean G2API_DetachG2Model(CGhoul2Info *ghlInfo) return qfalse; } -qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info *ghlInfoTo, int toBoltIndex, int entNum, int toModelNum) +qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info_v& ghoul2, int modelIndex, int toBoltIndex, int entNum, int toModelNum) { + CGhoul2Info *ghlInfoTo = &ghoul2[modelIndex]; + if (boltInfo && G2_SetupModelPointers(ghlInfoTo)) { // make sure we have a model to attach, a model to attach to, and a bolt on that model @@ -2003,7 +2227,7 @@ static inline bool G2_NeedRetransform(CGhoul2Info *g2, int frameNum) } void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, - int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius) + int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius) { //this will store off the transformed verts for the next trace - this is slower, but for models that do not animate //frequently it is much much faster. -rww #if 0 // UNUSED @@ -2094,7 +2318,7 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh void G2API_CollisionDetect(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, - int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, CMiniHeap *G2VertSpace, int traceFlags, int useLod, float fRadius) + int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius) { /* if (1) @@ -2329,9 +2553,11 @@ void G2API_DuplicateGhoul2Instance(CGhoul2Info_v &g2From, CGhoul2Info_v **g2To) return; } -char *G2API_GetSurfaceName(CGhoul2Info *ghlInfo, int surfNumber) +char *G2API_GetSurfaceName(CGhoul2Info_v& ghoul2, int modelIndex, int surfNumber) { static char noSurface[1] = ""; + CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(ghlInfo)) { model_t *mod = (model_t *)ghlInfo->currentModel; @@ -2471,8 +2697,10 @@ void G2API_LoadSaveCodeDestructGhoul2Info(CGhoul2Info_v &ghoul2) } //see if surfs have any shader info... -qboolean G2API_SkinlessModel(CGhoul2Info *g2) +qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) { + CGhoul2Info *g2 = &ghoul2[modelIndex]; + if (G2_SetupModelPointers(g2)) { model_t *mod = (model_t *)g2->currentModel; @@ -2508,8 +2736,10 @@ qboolean G2API_SkinlessModel(CGhoul2Info *g2) void ResetGoreTag(); // put here to reduce coupling //way of seeing how many marks are on a model currently -rww -int G2API_GetNumGoreMarks(CGhoul2Info *g2) +int G2API_GetNumGoreMarks(CGhoul2Info_v& ghoul2, int modelIndex) { + CGhoul2Info *g2 = &ghoul2[modelIndex]; + if (g2->mGoreSetTag) { CGoreSet *goreSet = FindGoreSet(g2->mGoreSetTag); @@ -2762,3 +2992,13 @@ qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2) // returns true if any mod } return (qboolean)ret; } + +qboolean G2API_IsGhoul2InfovValid (CGhoul2Info_v& ghoul2) +{ + return (qboolean)ghoul2.IsValid(); +} + +const char *G2API_GetModelName ( CGhoul2Info_v& ghoul2, int modelIndex ) +{ + return ghoul2[modelIndex].mFileName; +} diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index 2f742a7fb7..d3ddfb382e 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -1,5 +1,5 @@ #include "ghoul2/G2.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" //===================================================================================================================== // Bolt List handling routines - so entities can attach themselves to any part of the model in question diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index d31b3d2f79..049c88f187 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -1,7 +1,7 @@ #include "qcommon/matcomp.h" #include "ghoul2/G2.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" //rww - RAGDOLL_BEGIN #ifndef __linux__ diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 0c76e5b1e4..76832e599e 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -2,7 +2,7 @@ #include "ghoul2/G2.h" #include "qcommon/MiniHeap.h" #include "server/server.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" #ifdef _G2_GORE #include "ghoul2/G2_gore.h" @@ -376,7 +376,7 @@ int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod) return returnLod; } -void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, CMiniHeap *G2VertSpace, size_t *TransformedVertsArray,CBoneCache *boneCache) +void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertsArray,CBoneCache *boneCache) { int j, k; mdxmVertex_t *v; @@ -488,7 +488,7 @@ void R_TransformEachSurface( const mdxmSurface_t *surface, vec3_t scale, CMiniHe } void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, - CBoneCache *boneCache, const model_t *currentModel, int lod, vec3_t scale, CMiniHeap *G2VertSpace, size_t *TransformedVertArray, bool secondTimeAround) + CBoneCache *boneCache, const model_t *currentModel, int lod, vec3_t scale, IHeapAllocator *G2VertSpace, size_t *TransformedVertArray, bool secondTimeAround) { int i; assert(currentModel); @@ -530,9 +530,9 @@ void G2_TransformSurfaces(int surfaceNum, surfaceInfo_v &rootSList, // main calling point for the model transform for collision detection. At this point all of the skeleton has been transformed. #ifdef _G2_GORE -void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod, bool ApplyGore) +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, IHeapAllocator *G2VertSpace, int useLod, bool ApplyGore) #else -void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, CMiniHeap *G2VertSpace, int useLod) +void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, IHeapAllocator *G2VertSpace, int useLod) #endif { int i, lod; @@ -1916,9 +1916,3 @@ void G2_LerpAngles(CGhoul2Info_v &ghoul2,CGhoul2Info_v &nextGhoul2, float interp } } } - -//Raz: Chucking this in here from ghoul2_shared -IGhoul2InfoArray &TheGhoul2InfoArray(); -IGhoul2InfoArray &_TheGhoul2InfoArray( void ) { - return TheGhoul2InfoArray(); -} diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp index 4634195e22..89fdc6f4f9 100644 --- a/codemp/rd-rend2/G2_surfaces.cpp +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -1,6 +1,6 @@ #include "rd-common/tr_types.h" #include "ghoul2/G2.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" #ifdef _MSC_VER #pragma warning(disable : 4512) //assignment op could not be genereated #endif diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 7257bd4624..5f624c97c7 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3,7 +3,7 @@ #include "qcommon/matcomp.h" #include "qcommon/qcommon.h" #include "ghoul2/G2.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" #ifdef _G2_GORE #include "ghoul2/G2_gore.h" #endif diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b581fd9ba6..b9022925f4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_init.c -- functions that are not called every frame #include "tr_local.h" -#include "G2_local.h" +#include "ghoul2/g2_local.h" bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez @@ -1556,6 +1556,8 @@ void R_Init( void ) { if ( err != GL_NO_ERROR ) ri->Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); + RestoreGhoul2InfoArray(); + // print info GfxInfo_f(); ri->Printf( PRINT_ALL, "----- finished R_Init -----\n" ); @@ -1566,7 +1568,7 @@ void R_Init( void ) { RE_Shutdown =============== */ -void RE_Shutdown( qboolean destroyWindow ) { +void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); @@ -1593,6 +1595,11 @@ void RE_Shutdown( qboolean destroyWindow ) { R_DeleteTextures(); R_ShutdownVBOs(); GLSL_ShutdownGPUShaders(); + + if ( restarting ) + { + SaveGhoul2InfoArray(); + } } R_ShutdownFonts(); @@ -1638,9 +1645,6 @@ static void GetRealRes( int *w, int *h ) { *h = glConfig.vidHeight; } -extern IGhoul2InfoArray &TheGhoul2InfoArray(); -const CGhoul2Info NullG2; - // STUBS, REPLACEME qboolean stub_InitializeWireframeAutomap() { return qtrue; } @@ -1804,6 +1808,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.G2API_GetBoneIndex = G2API_GetBoneIndex; re.G2API_GetGhoul2ModelFlags = G2API_GetGhoul2ModelFlags; re.G2API_GetGLAName = G2API_GetGLAName; + re.G2API_GetModelName = G2API_GetModelName; re.G2API_GetParentSurface = G2API_GetParentSurface; re.G2API_GetRagBonePos = G2API_GetRagBonePos; re.G2API_GetSurfaceIndex = G2API_GetSurfaceIndex; @@ -1817,6 +1822,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.G2API_HaveWeGhoul2Models = G2API_HaveWeGhoul2Models; re.G2API_IKMove = G2API_IKMove; re.G2API_InitGhoul2Model = G2API_InitGhoul2Model; + re.G2API_IsGhoul2InfovValid = G2API_IsGhoul2InfovValid; re.G2API_IsPaused = G2API_IsPaused; re.G2API_ListBones = G2API_ListBones; re.G2API_ListSurfaces = G2API_ListSurfaces; @@ -1878,9 +1884,6 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { //re.CreateAutomapImage = R_CreateAutomapImage; re.SavePNG = RE_SavePNG; - re.TheGhoul2InfoArray = TheGhoul2InfoArray; - // G2VertSpaceServer - return &re; } } \ No newline at end of file diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 430baff9cd..e87c1c0d78 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include // memcpy -#include "G2_local.h" +#include "ghoul2/g2_local.h" trGlobals_t tr; From 0e5a806022e1913fe1aa222b967432fafd74dc37 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 12 Feb 2014 07:35:33 +0000 Subject: [PATCH 153/708] [MP] Fixed compile errors in renderers. Not exactly sure how they came about... --- codemp/rd-dedicated/G2_bolts.cpp | 1 + codemp/rd-rend2/G2_API.cpp | 1 + codemp/rd-rend2/G2_bolts.cpp | 1 + codemp/rd-rend2/G2_bones.cpp | 1 + codemp/rd-rend2/G2_misc.cpp | 1 + codemp/rd-rend2/G2_surfaces.cpp | 1 + codemp/rd-vanilla/G2_bolts.cpp | 1 + 7 files changed, 7 insertions(+) diff --git a/codemp/rd-dedicated/G2_bolts.cpp b/codemp/rd-dedicated/G2_bolts.cpp index 9e9061fc42..94f4412441 100644 --- a/codemp/rd-dedicated/G2_bolts.cpp +++ b/codemp/rd-dedicated/G2_bolts.cpp @@ -7,6 +7,7 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" //===================================================================================================================== // Bolt List handling routines - so entities can attach themselves to any part of the model in question diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 193c413ccc..9fb0a3904c 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1,6 +1,7 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" #include "qcommon/MiniHeap.h" +#include "tr_local.h" //rww - RAGDOLL_BEGIN #include "ghoul2/G2_gore.h" diff --git a/codemp/rd-rend2/G2_bolts.cpp b/codemp/rd-rend2/G2_bolts.cpp index d3ddfb382e..cddbc5a067 100644 --- a/codemp/rd-rend2/G2_bolts.cpp +++ b/codemp/rd-rend2/G2_bolts.cpp @@ -1,5 +1,6 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" //===================================================================================================================== // Bolt List handling routines - so entities can attach themselves to any part of the model in question diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 049c88f187..383832c945 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -2,6 +2,7 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" //rww - RAGDOLL_BEGIN #ifndef __linux__ diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 76832e599e..594eb9d90a 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -3,6 +3,7 @@ #include "qcommon/MiniHeap.h" #include "server/server.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" #ifdef _G2_GORE #include "ghoul2/G2_gore.h" diff --git a/codemp/rd-rend2/G2_surfaces.cpp b/codemp/rd-rend2/G2_surfaces.cpp index 89fdc6f4f9..9fe81bf606 100644 --- a/codemp/rd-rend2/G2_surfaces.cpp +++ b/codemp/rd-rend2/G2_surfaces.cpp @@ -1,6 +1,7 @@ #include "rd-common/tr_types.h" #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" #ifdef _MSC_VER #pragma warning(disable : 4512) //assignment op could not be genereated #endif diff --git a/codemp/rd-vanilla/G2_bolts.cpp b/codemp/rd-vanilla/G2_bolts.cpp index ae63d69eee..e8a17474c5 100644 --- a/codemp/rd-vanilla/G2_bolts.cpp +++ b/codemp/rd-vanilla/G2_bolts.cpp @@ -1,5 +1,6 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" //===================================================================================================================== // Bolt List handling routines - so entities can attach themselves to any part of the model in question From 4fa753e0e39ced72341d9552a58a5e5fd0760f27 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 13 Feb 2014 22:04:28 +0000 Subject: [PATCH 154/708] [MP] Rend2: Allow parallax on non-map surfaces Parallax mapping was previously disabled on entities, as well as stages marked with lightingDiffuse/lightingDiffuseEntity. This commit removes this restriction. --- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3d2eb8bc00..a741cde3da 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1113,7 +1113,7 @@ void GLSL_InitGPUShaders(void) attribs |= ATTR_TANGENT; #endif - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !(i & LIGHTDEF_ENTITY) && r_parallaxMapping->integer) + if ((i & LIGHTDEF_USE_PARALLAXMAP) && r_parallaxMapping->integer) Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 23b2621807..d8f5c79219 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2793,8 +2793,16 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || pStage->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) { - pStage->glslShaderGroup = tr.lightallShader; - pStage->glslShaderIndex = LIGHTDEF_USE_LIGHT_VECTOR; + if (pStage->glslShaderGroup != tr.lightallShader) + { + pStage->glslShaderGroup = tr.lightallShader; + pStage->glslShaderIndex = LIGHTDEF_USE_LIGHT_VECTOR; + } + else if (!(pStage->glslShaderIndex & LIGHTDEF_USE_LIGHT_VECTOR)) + { + pStage->glslShaderIndex &= ~LIGHTDEF_LIGHTTYPE_MASK; + pStage->glslShaderIndex |= LIGHTDEF_USE_LIGHT_VECTOR; + } if (pStage->bundle[0].tcGen != TCGEN_TEXTURE || pStage->bundle[0].numTexMods != 0) pStage->glslShaderIndex |= LIGHTDEF_USE_TCGEN_AND_TCMOD; From 129e14506583e531087ba51563e91ed97e6115b0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 14 Feb 2014 00:06:00 -0600 Subject: [PATCH 155/708] [MP] Rend2: Use correct dlight image. --- codemp/rd-rend2/tr_image.cpp | 54 ++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 34528cc5b7..d5a4425f15 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2591,30 +2591,42 @@ R_CreateDlightImage */ #define DLIGHT_SIZE 16 static void R_CreateDlightImage( void ) { - int x,y; - byte data[DLIGHT_SIZE][DLIGHT_SIZE][4]; - int b; - - // make a centered inverse-square falloff blob for dynamic lighting - for (x=0 ; x 255) { - b = 255; - } else if ( b < 75 ) { - b = 0; + int width, height; + byte *pic; + + R_LoadImage("gfx/2d/dlight", &pic, &width, &height); + if (pic) + { + tr.dlightImage = R_CreateImage("*dlight", pic, width, height, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); + Z_Free(pic); + } + else + { // if we dont get a successful load + int x,y; + byte data[DLIGHT_SIZE][DLIGHT_SIZE][4]; + int b; + + // make a centered inverse-square falloff blob for dynamic lighting + for (x=0 ; x 255) { + b = 255; + } else if ( b < 75 ) { + b = 0; + } + data[y][x][0] = + data[y][x][1] = + data[y][x][2] = b; + data[y][x][3] = 255; } - data[y][x][0] = - data[y][x][1] = - data[y][x][2] = b; - data[y][x][3] = 255; } + tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); } - tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); } From 9af3fce5fa47202ff3b1121d46826da187e9cf37 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 14 Feb 2014 00:08:04 -0600 Subject: [PATCH 156/708] [MP] Rend2: Remove altivec unused q3 stuff. --- codemp/rd-rend2/tr_init.cpp | 4 ---- codemp/rd-rend2/tr_shade.cpp | 3 --- codemp/rd-rend2/tr_shade_calc.cpp | 3 --- codemp/rd-rend2/tr_surface.cpp | 3 --- 4 files changed, 13 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b9022925f4..e9d41812d0 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -37,8 +37,6 @@ glstate_t glState; static void GfxInfo_f( void ); static void GfxMemInfo_f( void ); -cvar_t *com_altivec; - cvar_t *se_language; cvar_t *r_flareSize; @@ -1184,8 +1182,6 @@ R_Register */ void R_Register( void ) { - com_altivec = ri->Cvar_Get("com_altivec", "1", CVAR_ARCHIVE); - // // latched and archived variables // diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index cdcc13d67c..24cdd578bc 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -22,9 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_shade.c #include "tr_local.h" -#if idppc_altivec && !defined(MACOS_X) -#include -#endif /* diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index a739b70b6f..6b9025d186 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -22,9 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_shade_calc.c #include "tr_local.h" -#if idppc_altivec && !defined(MACOS_X) -#include -#endif #define WAVEVALUE( table, base, amplitude, phase, freq ) ((base) + table[ Q_ftol( ( ( (phase) + tess.shaderTime * (freq) ) * FUNCTABLE_SIZE ) ) & FUNCTABLE_MASK ] * (amplitude)) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index d3d38f08b9..d49ec7c80a 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -21,9 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_surf.c #include "tr_local.h" -#if idppc_altivec && !defined(MACOS_X) -#include -#endif /* From a41f13d44c5e7ece130cc2f5b5b7abeacf8ed338 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 14 Feb 2014 11:26:54 -0600 Subject: [PATCH 157/708] [MP] Rend2: Use r_ext_compress_textures instead of r_ext_compressed_textures for the actual cvar name to match vanilla renderer. --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index e9d41812d0..a66279df02 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1186,7 +1186,7 @@ void R_Register( void ) // latched and archived variables // r_allowExtensions = ri->Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compressed_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compress_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); From 5c45e0e8029122375cfeb36882a680c5f91f49f6 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 14 Feb 2014 13:07:14 -0600 Subject: [PATCH 158/708] [MP] Rend2: Merged some stuff from ioq3 rend2 that helps with r_floatLightmap being off. OpenGL2: Set RGBM to use a multiplier of 1, and only use it with HDR lightmaps. OpenGL2: Fix bug in ColorToRGBM(). OpenGL2: Oops, set lightmap alpha to 1. --- codemp/rd-rend2/glsl/generic_fp.glsl | 2 +- codemp/rd-rend2/glsl/lightall_fp.glsl | 2 +- codemp/rd-rend2/tr_bsp.cpp | 90 ++++++++++++++------------- 3 files changed, 48 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index f485797fb3..aefa33c3fa 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -21,7 +21,7 @@ void main() #if defined(USE_LIGHTMAP) vec4 color2 = texture2D(u_LightMap, var_LightTex); #if defined(RGBM_LIGHTMAP) - color2.rgb *= 32.0 * color2.a; + color2.rgb *= color2.a; color2.a = 1.0; #endif diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 7d9449b9b8..d31c39dfbe 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -346,7 +346,7 @@ void main() vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw); vec3 lightColor = lightSample.rgb; #if defined(RGBM_LIGHTMAP) - lightColor *= 32.0 * lightSample.a; + lightColor *= lightSample.a; #endif #elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a568a84ff9..2ef1d001db 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -164,7 +164,7 @@ void ColorToRGBM(const vec3_t color, unsigned char rgbm[4]) vec3_t sample; float maxComponent; - VectorScale(color, 1.0f / 32.0f, sample); + VectorCopy(color, sample); maxComponent = MAX(sample[0], sample[1]); maxComponent = MAX(maxComponent, sample[2]); @@ -325,7 +325,6 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { { char filename[MAX_QPATH]; byte *hdrLightmap = NULL; - float lightScale = 1.0f; int size = 0; // look for hdr lightmaps @@ -382,55 +381,58 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3; } - lightScale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits - 8); //exp2(r_mapOverBrightBits->integer - tr.overbrightBits - 8); - for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) { - if (r_hdr->integer) + if (hdrLightmap) { - float color[3]; + vec4_t color; - if (hdrLightmap) - { #if 0 // HDRFILE_RGBE - float exponent = exp2(buf_p[j*4+3] - 128); + float exponent = exp2(buf_p[j*4+3] - 128); - color[0] = buf_p[j*4+0] * exponent; - color[1] = buf_p[j*4+1] * exponent; - color[2] = buf_p[j*4+2] * exponent; + color[0] = buf_p[j*4+0] * exponent; + color[1] = buf_p[j*4+1] * exponent; + color[2] = buf_p[j*4+2] * exponent; #else // HDRFILE_FLOAT - memcpy(color, &buf_p[j*12], 12); + memcpy(color, &buf_p[j*12], 12); - color[0] = LittleFloat(color[0]); - color[1] = LittleFloat(color[1]); - color[2] = LittleFloat(color[2]); + color[0] = LittleFloat(color[0]); + color[1] = LittleFloat(color[1]); + color[2] = LittleFloat(color[2]); #endif - } - else - { - //hack: convert LDR lightmap to HDR one - color[0] = (buf_p[j*3+0] + 1.0f); - color[1] = (buf_p[j*3+1] + 1.0f); - color[2] = (buf_p[j*3+2] + 1.0f); - - // if under an arbitrary value (say 12) grey it out - // this prevents weird splotches in dimly lit areas - if (color[0] + color[1] + color[2] < 12.0f) - { - float avg = (color[0] + color[1] + color[2]) * 0.3333f; - color[0] = avg; - color[1] = avg; - color[2] = avg; - } - } + color[3] = 1.0f; - VectorScale(color, lightScale, color); + R_ColorShiftLightingFloats(color, color, 1.0f/255.0f); if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); else ColorToRGBM(color, &image[j*4]); } + else if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) + { + vec4_t color; + + //hack: convert LDR lightmap to HDR one + color[0] = MAX(buf_p[j*3+0], 0.499f); + color[1] = MAX(buf_p[j*3+1], 0.499f); + color[2] = MAX(buf_p[j*3+2], 0.499f); + + // if under an arbitrary value (say 12) grey it out + // this prevents weird splotches in dimly lit areas + if (color[0] + color[1] + color[2] < 12.0f) + { + float avg = (color[0] + color[1] + color[2]) * 0.3333f; + color[0] = avg; + color[1] = avg; + color[2] = avg; + } + color[3] = 1.0f; + + R_ColorShiftLightingFloats(color, color, 1.0f/255.0f); + + ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); + } else { if ( r_lightmap->integer == 2 ) @@ -749,9 +751,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[j][0] + 1.0f; - color[1] = verts[i].color[j][1] + 1.0f; - color[2] = verts[i].color[j][2] + 1.0f; + color[0] = MAX(verts[i].color[j][0], 0.499f); + color[1] = MAX(verts[i].color[j][1], 0.499f); + color[2] = MAX(verts[i].color[j][2], 0.499f); } else { @@ -899,9 +901,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[j][0] + 1.0f; - color[1] = verts[i].color[j][1] + 1.0f; - color[2] = verts[i].color[j][2] + 1.0f; + color[0] = MAX(verts[i].color[j][0], 0.499f); + color[1] = MAX(verts[i].color[j][1], 0.499f); + color[2] = MAX(verts[i].color[j][2], 0.499f); } else { @@ -1005,9 +1007,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor //hack: convert LDR vertex colors to HDR if (r_hdr->integer) { - color[0] = verts[i].color[j][0] + 1.0f; - color[1] = verts[i].color[j][1] + 1.0f; - color[2] = verts[i].color[j][2] + 1.0f; + color[0] = MAX(verts[i].color[j][0], 0.499f); + color[1] = MAX(verts[i].color[j][1], 0.499f); + color[2] = MAX(verts[i].color[j][2], 0.499f); } else { From e2936dec61c2acdcd7fafa914e1c0ad84205512f Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 15 Feb 2014 01:25:07 -0600 Subject: [PATCH 159/708] [MP] Rend2: Merge ioquake/ioq3@5fabc28dff78f2c9908bc4b915f904c82436627c : OpenGL2: Fix rendering when r_hdr = 0 and r_floatLightmap = 1 --- codemp/rd-rend2/tr_bsp.cpp | 15 ++++++--------- codemp/rd-rend2/tr_extensions.cpp | 3 +++ codemp/rd-rend2/tr_glsl.cpp | 4 ++-- codemp/rd-rend2/tr_local.h | 2 ++ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 2ef1d001db..f53e9daa81 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -285,13 +285,10 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } - if (r_hdr->integer) - { - if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) - textureInternalFormat = GL_RGBA16F_ARB; - else - textureInternalFormat = GL_RGBA8; - } + if (glRefConfig.floatLightmap) + textureInternalFormat = GL_RGBA16F_ARB; + else + textureInternalFormat = GL_RGBA8; if (r_mergeLightmaps->integer) { @@ -404,12 +401,12 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { R_ColorShiftLightingFloats(color, color, 1.0f/255.0f); - if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) + if (glRefConfig.floatLightmap) ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); else ColorToRGBM(color, &image[j*4]); } - else if (glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer) + else if (glRefConfig.floatLightmap) { vec4_t color; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 3f02be9020..e6f344ebe7 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -727,4 +727,7 @@ void GLimp_InitExtraExtensions() { ri->Printf(PRINT_ALL, result[2], extension); } + + // use float lightmaps? + glRefConfig.floatLightmap = (qboolean)(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer && r_hdr->integer); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a741cde3da..5d0ff506f9 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -942,7 +942,7 @@ void GLSL_InitGPUShaders(void) if (i & GENERICDEF_USE_LIGHTMAP) Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) + if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) @@ -1069,7 +1069,7 @@ void GLSL_InitGPUShaders(void) if (1) Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); - if (r_hdr->integer && !(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer)) + if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); if (lightType) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3f9a0e9b37..7190723138 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1882,6 +1882,8 @@ typedef struct { qboolean seamlessCubeMap; GLenum packedNormalDataType; + + qboolean floatLightmap; } glRefConfig_t; From b0eab406fd008201c71d7f31bc8f9b03dbc3dcac Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 15 Feb 2014 01:25:45 -0600 Subject: [PATCH 160/708] [MP] Rend2: Use correct defaults for r_overBrightBits and r_mapOverBrightBits to be in line with vanilla renderer. --- codemp/rd-rend2/tr_init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index a66279df02..a1b3b84470 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1216,7 +1216,7 @@ void R_Register( void ) r_depthbits = ri->Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_multisample = ri->Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); ri->Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); - r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ignorehwgamma = ri->Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); r_mode = ri->Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); r_fullscreen = ri->Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); @@ -1295,7 +1295,7 @@ void R_Register( void ) // temporary latched variables that can only change over a restart // r_fullbright = ri->Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); - r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "2", CVAR_LATCH ); + r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH ); r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); r_displayRefresh = ri->Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH ); From c7d031aea43a3b38597590181a61630202ea8457 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 17 Feb 2014 10:24:09 -0600 Subject: [PATCH 161/708] [MP] Rend2: Add in distancecull support and check for automap with far clip. --- codemp/rd-rend2/tr_bsp.cpp | 6 ++++++ codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_main.cpp | 17 ++++++++++------- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f53e9daa81..5b45c44bc7 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2700,6 +2700,8 @@ void R_LoadEntities( lump_t *l ) { w->lightGridSize[1] = 64; w->lightGridSize[2] = 128; + tr.distanceCull = 6000;//DEFAULT_DISTANCE_CULL; + p = (char *)(fileBase + l->fileofs); // store for reference by the cgame @@ -2756,6 +2758,10 @@ void R_LoadEntities( lump_t *l ) { R_RemapShader(value, s, "0"); continue; } + if (!Q_stricmp(keyname, "distanceCull")) { + sscanf(value, "%f", &tr.distanceCull ); + continue; + } // check for a different grid size if (!Q_stricmp(keyname, "gridsize")) { sscanf(value, "%f %f %f", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] ); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index a1b3b84470..ce385b5869 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1632,7 +1632,7 @@ extern qboolean gG2_GBMUseSPMethod; static void G2API_BoltMatrixReconstruction( qboolean reconstruct ) { gG2_GBMNoReconstruct = (qboolean)!reconstruct; } static void G2API_BoltMatrixSPMethod( qboolean spMethod ) { gG2_GBMUseSPMethod = spMethod; } -static float GetDistanceCull( void ) { return 6000/*tr.distanceCull*/; } +static float GetDistanceCull( void ) { return tr.distanceCull; } extern void R_SVModelInit( void ); //tr_model.cpp diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7190723138..81b3e9f61b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2126,6 +2126,7 @@ typedef struct trGlobals_s { float fogTable[FOG_TABLE_SIZE]; float rangedFog; + float distanceCull, distanceCullSquared; //rwwRMG - added #ifdef _WIN32 WinVars_t *wv; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index e87c1c0d78..a9b34d2115 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -926,18 +926,20 @@ static void R_SetFarClip( void ) // if not rendering the world (icons, menus, etc) // set a 2k far clip plane if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { - tr.viewParms.zFar = 2048; + // override the zfar then + if ( tr.refdef.rdflags & RDF_AUTOMAP ) + tr.viewParms.zFar = 32768.0f; + else + tr.viewParms.zFar = 2048.0f; return; } // // set far clipping planes dynamically // - farthestCornerDistance = 0; for ( i = 0; i < 8; i++ ) { vec3_t v; - vec3_t vecTo; float distance; if ( i & 1 ) @@ -967,16 +969,17 @@ static void R_SetFarClip( void ) v[2] = tr.viewParms.visBounds[1][2]; } - VectorSubtract( v, tr.viewParms.ori.origin, vecTo ); - - distance = vecTo[0] * vecTo[0] + vecTo[1] * vecTo[1] + vecTo[2] * vecTo[2]; + distance = DistanceSquared( tr.viewParms.ori.origin, v ); if ( distance > farthestCornerDistance ) { farthestCornerDistance = distance; } } - tr.viewParms.zFar = sqrt( farthestCornerDistance ); + // Bring in the zFar to the distanceCull distance + // The sky renders at zFar so need to move it out a little + // ...and make sure there is a minimum zfar to prevent problems + tr.viewParms.zFar = Com_Clamp(2048.0f, tr.distanceCull * (1.732), sqrtf( farthestCornerDistance )); } /* From 353acceebb7dd3200027559c30f1a1e9b25edb25 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 17 Feb 2014 10:24:53 -0600 Subject: [PATCH 162/708] [MP] Rend2: Update some cvar defaults and flags with rend2 to match vanilla. --- codemp/rd-rend2/tr_init.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index ce385b5869..9fae138c8e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1205,10 +1205,10 @@ void R_Register( void ) "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ext_max_anisotropy = ri->Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); - r_picmip = ri->Cvar_Get ("r_picmip", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); + ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); - ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_colorbits = ri->Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1218,9 +1218,9 @@ void R_Register( void ) ri->Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_ignorehwgamma = ri->Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_mode = ri->Cvar_Get( "r_mode", "-2", CVAR_ARCHIVE | CVAR_LATCH ); - r_fullscreen = ri->Cvar_Get( "r_fullscreen", "1", CVAR_ARCHIVE ); - r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE); + r_mode = ri->Cvar_Get( "r_mode", "4", CVAR_ARCHIVE | CVAR_LATCH ); + r_fullscreen = ri->Cvar_Get( "r_fullscreen", "0", CVAR_ARCHIVE|CVAR_LATCH ); + r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE|CVAR_LATCH); r_centerWindow = ri->Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE|CVAR_LATCH ); r_customwidth = ri->Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); r_customheight = ri->Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); @@ -1308,8 +1308,8 @@ void R_Register( void ) r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT ); - r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM ); ri->Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); + r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM ); r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); r_ignoreGLErrors = ri->Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); From 798f7e97afd918ff3e3dd09698b980ac54329347 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Feb 2014 21:23:40 +0000 Subject: [PATCH 163/708] [MP] Rend2: increase max animation images to 32. This now matches the vanilla renderer. --- codemp/rd-rend2/tr_local.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7190723138..5aa2643bfc 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -637,7 +637,7 @@ typedef struct { } texModInfo_t; -#define MAX_IMAGE_ANIMATIONS 8 +#define MAX_IMAGE_ANIMATIONS (32) typedef struct { image_t *image[MAX_IMAGE_ANIMATIONS]; From 96ac60b43baeba3cf0b6b566cda723c9a871b78f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Feb 2014 21:24:55 +0000 Subject: [PATCH 164/708] [MP] Rend2: Fixed bug in lightmap collapsing. --- codemp/rd-rend2/tr_shade.cpp | 6 +- codemp/rd-rend2/tr_shader.cpp | 164 +++++++++++++++++++++++++++++++--- 2 files changed, 154 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 24cdd578bc..1b81ae90b7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1071,9 +1071,9 @@ static void RB_FogPass( void ) { } -static unsigned int RB_CalcShaderVertexAttribs( shaderCommands_t *input ) +static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) { - unsigned int vertexAttribs = input->shader->vertexAttribs; + unsigned int vertexAttribs = shader->vertexAttribs; if(glState.vertexAnimation) { @@ -1598,7 +1598,7 @@ void RB_StageIteratorGeneric( void ) RB_DeformTessGeometry(); } - vertexAttribs = RB_CalcShaderVertexAttribs( input ); + vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); if (tess.useInternalVBO) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index d8f5c79219..4bbd20ea34 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -738,6 +738,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) { stage->bundle[0].isLightmap = qtrue; if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { +#ifndef FINAL_BUILD + ri->Printf (PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); +#endif stage->bundle[0].image[0] = tr.whiteImage; } else { stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; @@ -2509,10 +2512,27 @@ static qboolean CollapseStagesToGLSL(void) int i, j, numStages; qboolean skip = qfalse; + ri->Printf (PRINT_DEVELOPER, "Collapsing stages for shader '%s'\n", shader.name); + // skip shaders with deforms if (shader.numDeforms != 0) { skip = qtrue; + ri->Printf (PRINT_DEVELOPER, "> Shader has vertex deformations. Aborting stage collapsing\n"); + } + + ri->Printf (PRINT_DEVELOPER, "> Original shader stage order:\n"); + + for ( int i = 0; i < MAX_SHADER_STAGES; i++ ) + { + shaderStage_t *stage = &stages[i]; + + if ( !stage->active ) + { + continue; + } + + ri->Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); } if (!skip) @@ -2520,8 +2540,7 @@ static qboolean CollapseStagesToGLSL(void) // if 2+ stages and first stage is lightmap, switch them // this makes it easier for the later bits to process if (stages[0].active && - stages[0].bundle[0].tcGen >= TCGEN_LIGHTMAP && - stages[0].bundle[0].tcGen <= TCGEN_LIGHTMAP3 && + stages[0].bundle[0].tcGen == TCGEN_LIGHTMAP && stages[1].active) { int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2539,6 +2558,10 @@ static qboolean CollapseStagesToGLSL(void) stages[0].stateBits = stateBits0; stages[1].stateBits = stateBits1; + + ri->Printf (PRINT_DEVELOPER, "> Swapped first and second stage.\n"); + ri->Printf (PRINT_DEVELOPER, "-> First stage is now: %s\n", stages[0].bundle[0].image[0]->imgName); + ri->Printf (PRINT_DEVELOPER, "-> Second stage is now: %s\n", stages[1].bundle[0].image[0]->imgName); } } } @@ -2559,7 +2582,7 @@ static qboolean CollapseStagesToGLSL(void) break; } - if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) { int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2600,6 +2623,22 @@ static qboolean CollapseStagesToGLSL(void) if (!skip) { + shaderStage_t *lightmaps[MAX_SHADER_STAGES] = {}; + size_t numLightmapStages = 0; + + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + + if (!pStage->active) + continue; + + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + { + lightmaps[i] = pStage; + } + } + for (i = 0; i < MAX_SHADER_STAGES; i++) { shaderStage_t *pStage = &stages[i]; @@ -2623,6 +2662,7 @@ static qboolean CollapseStagesToGLSL(void) specular = NULL; lightmap = NULL; + // we have a diffuse map, find matching normal, specular, and lightmap for (j = i + 1; j < MAX_SHADER_STAGES; j++) { @@ -2656,9 +2696,11 @@ static qboolean CollapseStagesToGLSL(void) break; case ST_COLORMAP: - if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3) + if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP && pStage2->rgbGen != pStage->rgbGen) { + ri->Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); lightmap = pStage2; + lightmaps[j] = NULL; } break; @@ -2699,7 +2741,7 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) + if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP && lightmaps[i] == NULL) { pStage->active = qfalse; } @@ -2765,7 +2807,7 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3) + if (pStage->bundle[TB_DIFFUSEMAP].tcGen == TCGEN_LIGHTMAP) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; @@ -2833,6 +2875,20 @@ static qboolean CollapseStagesToGLSL(void) } } + ri->Printf (PRINT_DEVELOPER, "> New shader stage order:\n"); + + for ( int i = 0; i < MAX_SHADER_STAGES; i++ ) + { + shaderStage_t *stage = &stages[i]; + + if ( !stage->active ) + { + continue; + } + + ri->Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); + } + return (qboolean)numStages; } @@ -3139,8 +3195,7 @@ from the current global working shader ========================= */ static shader_t *FinishShader( void ) { - int stage, firstLightmapStage; - shaderStage_t *lmStage; + int stage; qboolean hasLightmapStage = qfalse; // @@ -3157,6 +3212,10 @@ static shader_t *FinishShader( void ) { shader.sort = SS_DECAL; } +#if 0 + int firstLightmapStage; + shaderStage_t *lmStage; + firstLightmapStage = FindFirstLightmapStage (stages, MAX_SHADER_STAGES); lmStage = &stages[firstLightmapStage]; @@ -3166,20 +3225,21 @@ static shader_t *FinishShader( void ) { { if ( firstLightmapStage == 0 ) { - // Shift all stages above it down 1. + /*// Shift all stages above it down 1. memmove (lmStage, lmStage + 1, sizeof (shaderStage_t) * (MAX_SHADER_STAGES - firstLightmapStage - 1)); memset (stages + MAX_SHADER_STAGES - 1, 0, sizeof (shaderStage_t)); // Set state bits back to default on the over-written stage. - lmStage->stateBits = GLS_DEFAULT; + lmStage->stateBits = GLS_DEFAULT;*/ + ri->Printf (PRINT_ALL, "Shader '%s' has first stage as lightmap by vertex.\n", shader.name); } - lmStage->rgbGen = CGEN_EXACT_VERTEX_LIT; + /*lmStage->rgbGen = CGEN_EXACT_VERTEX_LIT; lmStage->alphaGen = AGEN_SKIP; - firstLightmapStage = MAX_SHADER_STAGES; + firstLightmapStage = MAX_SHADER_STAGES;*/ } } @@ -3187,7 +3247,8 @@ static shader_t *FinishShader( void ) { { int numStyles = GetNumStylesInShader (&shader); - if ( numStyles > 0 ) + ri->Printf (PRINT_ALL, "Shader '%s' has %d stages with light styles.\n", shader.name, numStyles); + /*if ( numStyles > 0 ) { // Move back all stages, after the first lightmap stage, by 'numStyles' elements. memmove (lmStage + numStyles, @@ -3226,8 +3287,85 @@ static shader_t *FinishShader( void ) { for ( int i = 0; i <= numStyles; i++ ) { lmStage[i].lightmapStyle = shader.styles[i]; + }*/ + } +#else + int lmStage; + for(lmStage = 0; lmStage < MAX_SHADER_STAGES; lmStage++) + { + shaderStage_t *pStage = &stages[lmStage]; + if (pStage->active && pStage->bundle[0].isLightmap) + { + break; + } + } + + if (lmStage < MAX_SHADER_STAGES) + { + if (shader.lightmapIndex[0] == LIGHTMAP_BY_VERTEX) + { + if (lmStage == 0) //< MAX_SHADER_STAGES-1) + {//copy the rest down over the lightmap slot + memmove(&stages[lmStage], &stages[lmStage+1], sizeof(shaderStage_t) * (MAX_SHADER_STAGES-lmStage-1)); + memset(&stages[MAX_SHADER_STAGES-1], 0, sizeof(shaderStage_t)); + //change blending on the moved down stage + stages[lmStage].stateBits = GLS_DEFAULT; + } + //change anything that was moved down (or the *white if LM is first) to use vertex color + stages[lmStage].rgbGen = CGEN_EXACT_VERTEX; + stages[lmStage].alphaGen = AGEN_SKIP; + lmStage = MAX_SHADER_STAGES; //skip the style checking below + } + } + + if (lmStage < MAX_SHADER_STAGES)// && !r_fullbright->value) + { + int numStyles; + int i; + + for(numStyles=0;numStyles= LS_UNUSED) + { + break; + } + } + numStyles--; + if (numStyles > 0) + { + for(i=MAX_SHADER_STAGES-1;i>lmStage+numStyles;i--) + { + stages[i] = stages[i-numStyles]; + } + + for(i=0;i Date: Mon, 24 Feb 2014 21:56:50 +0000 Subject: [PATCH 165/708] [MP] Rend2: Change vec4 texcoords to vec2. --- codemp/rd-rend2/glsl/dlight_vp.glsl | 2 +- codemp/rd-rend2/glsl/fogpass_vp.glsl | 2 +- codemp/rd-rend2/glsl/generic_vp.glsl | 4 ++-- codemp/rd-rend2/glsl/lightall_vp.glsl | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index 9566a04c26..c8a961d3ec 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -1,5 +1,5 @@ attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +attribute vec2 attr_TexCoord0; attribute vec3 attr_Normal; uniform vec4 u_DlightInfo; diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index c1c751444d..e3aaf2dae7 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -1,7 +1,7 @@ attribute vec3 attr_Position; attribute vec3 attr_Normal; -attribute vec4 attr_TexCoord0; +attribute vec2 attr_TexCoord0; #if defined(USE_VERTEX_ANIMATION) attribute vec3 attr_Position2; diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 0638cc4380..f890af85c1 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -10,10 +10,10 @@ attribute vec4 attr_BoneWeights; #endif attribute vec4 attr_Color; -attribute vec4 attr_TexCoord0; +attribute vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -attribute vec4 attr_TexCoord1; +attribute vec2 attr_TexCoord1; #endif uniform vec4 u_DiffuseTexMatrix; diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index b381bb137f..3df09f0bcf 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -1,6 +1,6 @@ -attribute vec4 attr_TexCoord0; +attribute vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -attribute vec4 attr_TexCoord1; +attribute vec2 attr_TexCoord1; #endif attribute vec4 attr_Color; From 7585d8f62efdbc5dcd55b0aae03b7dcb98f83f23 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Feb 2014 21:57:35 +0000 Subject: [PATCH 166/708] [MP] Rend2: Simplified vertex attribute enums. Also only use light coord attribute when lightmap is considered. --- codemp/rd-rend2/tr_glsl.cpp | 5 ++++- codemp/rd-rend2/tr_local.h | 26 +++++++++++++------------- codemp/rd-rend2/tr_shader.cpp | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5d0ff506f9..4ceea43462 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -909,7 +909,7 @@ void GLSL_InitGPUShaders(void) continue; } - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_NORMAL | ATTR_COLOR; + attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_NORMAL | ATTR_COLOR; extradefines[0] = '\0'; if (i & GENERICDEF_USE_DEFORM_VERTEXES) @@ -940,7 +940,10 @@ void GLSL_InitGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_RGBAGEN\n"); if (i & GENERICDEF_USE_LIGHTMAP) + { Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); + attribs |= ATTR_LIGHTCOORD; + } if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5aa2643bfc..e2341460cc 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -824,21 +824,21 @@ static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) enum { - ATTR_INDEX_POSITION = 0, - ATTR_INDEX_TEXCOORD0 = 1, - ATTR_INDEX_TEXCOORD1 = 2, - ATTR_INDEX_TANGENT = 3, - ATTR_INDEX_NORMAL = 4, - ATTR_INDEX_COLOR = 5, - ATTR_INDEX_PAINTCOLOR = 6, - ATTR_INDEX_LIGHTDIRECTION = 7, - ATTR_INDEX_BONE_INDEXES = 8, - ATTR_INDEX_BONE_WEIGHTS = 9, + ATTR_INDEX_POSITION, + ATTR_INDEX_TEXCOORD0, + ATTR_INDEX_TEXCOORD1, + ATTR_INDEX_TANGENT, + ATTR_INDEX_NORMAL, + ATTR_INDEX_COLOR, + ATTR_INDEX_PAINTCOLOR, + ATTR_INDEX_LIGHTDIRECTION, + ATTR_INDEX_BONE_INDEXES, + ATTR_INDEX_BONE_WEIGHTS, // GPU vertex animations - ATTR_INDEX_POSITION2 = 10, - ATTR_INDEX_TANGENT2 = 11, - ATTR_INDEX_NORMAL2 = 12 + ATTR_INDEX_POSITION2, + ATTR_INDEX_TANGENT2, + ATTR_INDEX_NORMAL2 }; enum diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4bbd20ea34..f913683e9e 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2696,7 +2696,7 @@ static qboolean CollapseStagesToGLSL(void) break; case ST_COLORMAP: - if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP && pStage2->rgbGen != pStage->rgbGen) + if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP && pStage2->rgbGen != CGEN_EXACT_VERTEX) { ri->Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); lightmap = pStage2; From 71811573194750b2e22346febe5e76b165418ed5 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Tue, 4 Mar 2014 14:21:23 -0600 Subject: [PATCH 167/708] [MP] Rend2: rend2 is now up to date through ioq3 rend2 commits. Latest being "OpenGL2: Add normalScale and parallaxDepth stage keywords and helper cvars." --- codemp/rd-rend2/glsl/lightall_fp.glsl | 35 ++++-- codemp/rd-rend2/glsl/shadowmask_fp.glsl | 9 +- codemp/rd-rend2/tr_animation.cpp | 3 +- codemp/rd-rend2/tr_ghoul2.cpp | 3 +- codemp/rd-rend2/tr_glsl.cpp | 7 +- codemp/rd-rend2/tr_image.cpp | 42 +------ codemp/rd-rend2/tr_init.cpp | 10 +- codemp/rd-rend2/tr_local.h | 15 ++- codemp/rd-rend2/tr_shade.cpp | 29 ++++- codemp/rd-rend2/tr_shader.cpp | 145 +++++++++++++++++++----- codemp/rd-rend2/tr_sky.cpp | 2 +- 11 files changed, 203 insertions(+), 97 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index d31c39dfbe..9d09737425 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -25,7 +25,8 @@ uniform samplerCube u_CubeMap; #endif #if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) -uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube +// y = deluxe, w = cube +uniform vec4 u_EnableTextures; #endif #if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) @@ -39,7 +40,8 @@ uniform vec3 u_PrimaryLightAmbient; #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec2 u_MaterialInfo; +uniform vec4 u_NormalScale; +uniform vec4 u_SpecularScale; #endif varying vec4 var_TexCoords; @@ -167,7 +169,7 @@ vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); #elif 0 // from http://seblagarde.wordpress.com/2011/08/17/hello-world/ - return mix(specular.rgb, max(specular.rgb, vec3(gloss)), CalcFresnel(NE)); + return specular + CalcFresnel(NE) * clamp(vec3(gloss) - specular, 0.0, 1.0); #else // from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx return mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss)); @@ -360,7 +362,7 @@ void main() #if defined(USE_PARALLAXMAP) vec3 offsetDir = normalize(E * tangentToWorld); - offsetDir.xy *= -0.05 / offsetDir.z; + offsetDir.xy *= -u_NormalScale.a / offsetDir.z; texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); #endif @@ -378,8 +380,8 @@ void main() #else N.xy = texture2D(u_NormalMap, texCoords).rg - vec2(0.5); #endif - N.xy *= u_EnableTextures.x; - N.z = sqrt((0.25 - N.x * N.x) - N.y * N.y); + N.xy *= u_NormalScale.xy; + N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); N = tangentToWorld * N; #else N = var_Normal.xyz; @@ -425,15 +427,16 @@ void main() NL = clamp(dot(N, L), 0.0, 1.0); NE = clamp(dot(N, E), 0.0, 1.0); - vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) - specular += texture2D(u_SpecularMap, texCoords) * u_EnableTextures.z - u_EnableTextures.zzzz; + vec4 specular = texture2D(u_SpecularMap, texCoords); #if defined(USE_GAMMA2_TEXTURES) specular.rgb *= specular.rgb; #endif + #else + vec4 specular = vec4(1.0); #endif - specular *= u_MaterialInfo.xxxy; + specular *= u_SpecularScale; float gloss = specular.a; float shininess = exp2(gloss * 13.0); @@ -473,7 +476,21 @@ void main() #endif gl_FragColor.rgb = lightColor * reflectance * NL; + +#if 0 + vec3 aSpecular = EnvironmentBRDF(gloss, NE, specular.rgb); + + // do ambient as two hemisphere lights, one straight up one straight down + float hemiDiffuseUp = N.z * 0.5 + 0.5; + float hemiDiffuseDown = 1.0 - hemiDiffuseUp; + float hemiSpecularUp = mix(hemiDiffuseUp, float(N.z >= 0.0), gloss); + float hemiSpecularDown = 1.0 - hemiSpecularUp; + + gl_FragColor.rgb += ambientColor * 0.75 * (diffuse.rgb * hemiDiffuseUp + aSpecular * hemiSpecularUp); + gl_FragColor.rgb += ambientColor * 0.25 * (diffuse.rgb * hemiDiffuseDown + aSpecular * hemiSpecularDown); +#else gl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb); +#endif #if defined(USE_CUBEMAP) reflectance = EnvironmentBRDF(gloss, NE, specular.rgb); diff --git a/codemp/rd-rend2/glsl/shadowmask_fp.glsl b/codemp/rd-rend2/glsl/shadowmask_fp.glsl index 4bac5ccdd8..b489fef549 100644 --- a/codemp/rd-rend2/glsl/shadowmask_fp.glsl +++ b/codemp/rd-rend2/glsl/shadowmask_fp.glsl @@ -18,6 +18,10 @@ uniform vec4 u_ViewInfo; // zfar / znear, zfar varying vec2 var_DepthTex; varying vec3 var_ViewDir; +// depth is GL_DEPTH_COMPONENT24 +// so the maximum error is 1.0 / 2^24 +#define DEPTH_MAX_ERROR 0.000000059604644775390625 + // Input: It uses texture coords as the random number seed. // Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. // Author: Michael Pohoreski @@ -39,7 +43,7 @@ float PCF(const sampler2D shadowmap, const vec2 st, const float dist) { float mult; float scale = 2.0 / r_shadowMapSize; - + #if defined(USE_SHADOW_FILTER) float r = random(var_DepthTex.xy); float sinr = sin(r) * scale; @@ -71,6 +75,7 @@ float PCF(const sampler2D shadowmap, const vec2 st, const float dist) float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear) { float sampleZDivW = texture2D(depthMap, tex).r; + sampleZDivW -= DEPTH_MAX_ERROR; return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } @@ -81,7 +86,7 @@ void main() float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x); float sampleZ = u_ViewInfo.y * depth; - vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * depth * 0.99, 1.0); + vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); vec4 shadowpos = u_ShadowMvp * biasPos; diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 5f3bd27ce0..1840f279b6 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -193,7 +193,8 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { header = (mdrHeader_t *)tr.currentModel->data.mdr; - personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal + || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 5f624c97c7..1fcc9cd26a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3201,7 +3201,8 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent ) { RootMatrix(ghoul2,currentTime, ent->e.modelScale,rootMatrix); // don't add third_person objects if not in a portal - personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal); + personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal + || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); int modelList[256]; assert(ghoul2.size()<=255); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 4ceea43462..4ac2011ff9 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -123,9 +123,10 @@ static uniformInfo_t uniformsInfo[] = { "u_ModelMatrix", GLSL_MAT16, 1 }, { "u_ModelViewProjectionMatrix", GLSL_MAT16, 1 }, - { "u_Time", GLSL_FLOAT, 1 }, - { "u_VertexLerp" , GLSL_FLOAT, 1 }, - { "u_MaterialInfo", GLSL_VEC2, 1 }, + { "u_Time", GLSL_FLOAT, 1 }, + { "u_VertexLerp" , GLSL_FLOAT, 1 }, + { "u_NormalScale", GLSL_VEC4, 1 }, + { "u_SpecularScale", GLSL_VEC4, 1 }, { "u_ViewInfo", GLSL_VEC4, 1 }, { "u_ViewOrigin", GLSL_VEC3, 1 }, diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d5a4425f15..adbea44b68 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2913,44 +2913,20 @@ void R_SetColorMappings( void ) { int i, j; float g; int inf; - int shift; // setup the overbright lighting tr.overbrightBits = r_overBrightBits->integer; - if ( !glConfig.deviceSupportsGamma ) { - tr.overbrightBits = 0; // need hardware gamma for overbright - } - - // never overbright in windowed mode without soft overbright - if ( !glConfig.isFullscreen && !r_softOverbright->integer ) - { - tr.overbrightBits = 0; - } - // never overbright with tonemapping - if ( r_toneMap->integer && r_hdr->integer ) - { - tr.overbrightBits = 0; - } - - // allow 2 overbright bits in 24 bit, but only 1 in 16 bit - if ( glConfig.colorBits > 16 ) { - if ( tr.overbrightBits > 2 ) { - tr.overbrightBits = 2; - } - } else { - if ( tr.overbrightBits > 1 ) { - tr.overbrightBits = 1; - } - } - if ( tr.overbrightBits < 0 ) { + // allow 2 overbright bits + if ( tr.overbrightBits > 2 ) { + tr.overbrightBits = 2; + } else if ( tr.overbrightBits < 0 ) { tr.overbrightBits = 0; } tr.identityLight = 1.0f / ( 1 << tr.overbrightBits ); tr.identityLightByte = 255 * tr.identityLight; - if ( r_intensity->value <= 1 ) { ri->Cvar_Set( "r_intensity", "1" ); } @@ -2963,14 +2939,6 @@ void R_SetColorMappings( void ) { g = r_gamma->value; - shift = tr.overbrightBits; - - // no shift with soft overbright - if (r_softOverbright->integer) - { - shift = 0; - } - for ( i = 0; i < 256; i++ ) { int i2; @@ -2988,7 +2956,7 @@ void R_SetColorMappings( void ) { } else { inf = 255 * pow ( i2/255.0f, 1.0f / g ) + 0.5f; } - inf <<= shift; + if (inf < 0) { inf = 0; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 9fae138c8e..1db5fa2060 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -109,8 +109,6 @@ cvar_t *r_mergeLeafSurfaces; cvar_t *r_cameraExposure; -cvar_t *r_softOverbright; - cvar_t *r_hdr; cvar_t *r_floatLightmap; cvar_t *r_postProcess; @@ -138,6 +136,9 @@ cvar_t *r_parallaxMapping; cvar_t *r_cubeMapping; cvar_t *r_deluxeSpecular; cvar_t *r_specularIsMetallic; +cvar_t *r_baseNormalX; +cvar_t *r_baseNormalY; +cvar_t *r_baseParallax; cvar_t *r_baseSpecular; cvar_t *r_baseGloss; cvar_t *r_recalcMD3Normals; @@ -1234,8 +1235,6 @@ void R_Register( void ) r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); - r_softOverbright = ri->Cvar_Get( "r_softOverbright", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); @@ -1265,6 +1264,9 @@ void R_Register( void ) r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_deluxeSpecular = ri->Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH ); r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH ); r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); r_dlightMode = ri->Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e80fdd8e1d..26cb7d8799 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -145,8 +145,6 @@ extern cvar_t *r_mergeLeafSurfaces; extern cvar_t *r_cameraExposure; -extern cvar_t *r_softOverbright; - extern cvar_t *r_hdr; extern cvar_t *r_postProcess; @@ -713,7 +711,10 @@ typedef struct { stageType_t type; struct shaderProgram_s *glslShaderGroup; int glslShaderIndex; - vec2_t materialInfo; + + vec4_t normalScale; + vec4_t specularScale; + } shaderStage_t; struct shaderCommands_s; @@ -1074,7 +1075,8 @@ typedef enum UNIFORM_TIME, UNIFORM_VERTEXLERP, - UNIFORM_MATERIALINFO, + UNIFORM_NORMALSCALE, + UNIFORM_SPECULARSCALE, UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2 UNIFORM_VIEWORIGIN, @@ -2234,8 +2236,6 @@ extern cvar_t *r_anaglyphMode; extern cvar_t *r_mergeMultidraws; extern cvar_t *r_mergeLeafSurfaces; -extern cvar_t *r_softOverbright; - extern cvar_t *r_hdr; extern cvar_t *r_floatLightmap; extern cvar_t *r_postProcess; @@ -2265,6 +2265,9 @@ extern cvar_t *r_parallaxMapping; extern cvar_t *r_cubeMapping; extern cvar_t *r_deluxeSpecular; extern cvar_t *r_specularIsMetallic; +extern cvar_t *r_baseNormalX; +extern cvar_t *r_baseNormalY; +extern cvar_t *r_baseParallax; extern cvar_t *r_baseSpecular; extern cvar_t *r_baseGloss; extern cvar_t *r_dlightMode; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 1b81ae90b7..4e03f54421 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -655,7 +655,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t } // multiply color by overbrightbits if this isn't a blend - if (r_softOverbright->integer && tr.overbrightBits + if (tr.overbrightBits && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_DST_COLOR) && !((blend & GLS_SRCBLEND_BITS) == GLS_SRCBLEND_ONE_MINUS_DST_COLOR) && !((blend & GLS_DSTBLEND_BITS) == GLS_DSTBLEND_SRC_COLOR) @@ -864,7 +864,8 @@ static void ForwardDlight( void ) { GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); - GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo); + GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); + GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light // where they aren't rendered @@ -875,11 +876,32 @@ static void ForwardDlight( void ) { if (pStage->bundle[TB_DIFFUSEMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + // bind textures that are sampled and used in the glsl shader, and + // bind whiteImage to textures that are sampled but zeroed in the glsl shader + // + // alternatives: + // - use the last bound texture + // -> costs more to sample a higher res texture then throw out the result + // - disable texture sampling in glsl shader with #ifdefs, as before + // -> increases the number of shaders that must be compiled + // + if (pStage->bundle[TB_NORMALMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + else if (r_normalMapping->integer) + GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); if (pStage->bundle[TB_SPECULARMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); + else if (r_specularMapping->integer) + GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); + + { + vec4_t enableTextures; + + VectorSet4(enableTextures, 0.0f, 0.0f, 0.0f, 0.0f); + GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); + } if (r_dlightMode->integer >= 2) { @@ -1366,7 +1388,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); - GLSL_SetUniformVec2(sp, UNIFORM_MATERIALINFO, pStage->materialInfo); + GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); + GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f913683e9e..e89d09f6fe 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -102,6 +102,13 @@ static void ClearGlobalShader(void) for ( i = 0 ; i < MAX_SHADER_STAGES ; i++ ) { stages[i].bundle[0].texMods = texMods[i]; //stages[i].mGLFogColorOverride = GLFOGOVERRIDE_NONE; + + // default normal/specular + VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f); + stages[i].specularScale[0] = + stages[i].specularScale[1] = + stages[i].specularScale[2] = r_baseSpecular->value; + stages[i].specularScale[3] = r_baseGloss->value; } shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; @@ -1027,6 +1034,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if(!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "bumpMap")) { stage->type = ST_NORMALMAP; + VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); } else if(!Q_stricmp(token, "normalParallaxMap") || !Q_stricmp(token, "bumpParallaxMap")) { @@ -1034,12 +1042,12 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->type = ST_NORMALPARALLAXMAP; else stage->type = ST_NORMALMAP; + VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); } else if(!Q_stricmp(token, "specularMap")) { stage->type = ST_SPECULARMAP; - stage->materialInfo[0] = 1.0f; - stage->materialInfo[1] = 1.0f; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); } else { @@ -1058,7 +1066,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); continue; } - stage->materialInfo[0] = atof( token ); + stage->specularScale[0] = + stage->specularScale[1] = + stage->specularScale[2] = atof( token ); } // // specularExponent @@ -1078,7 +1088,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // Change shininess to gloss // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl exponent = CLAMP(exponent, 1.0, 8192.0); - stage->materialInfo[1] = log(exponent) / log(8192.0); + stage->specularScale[3] = log(exponent) / log(8192.0); } // // gloss @@ -1092,7 +1102,102 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->materialInfo[1] = atof( token ); + stage->specularScale[3] = atof( token ); + } + // + // parallaxDepth + // + else if (!Q_stricmp(token, "parallaxdepth")) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for parallaxDepth in shader '%s'\n", shader.name ); + continue; + } + + stage->normalScale[3] = atof( token ); + } + // + // normalScale + // or normalScale + // or normalScale + // + else if (!Q_stricmp(token, "normalscale")) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for normalScale in shader '%s'\n", shader.name ); + continue; + } + + stage->normalScale[0] = atof( token ); + + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + // one value, applies to X/Y + stage->normalScale[1] = stage->normalScale[0]; + continue; + } + + stage->normalScale[1] = atof( token ); + + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + // two values, no height + continue; + } + + stage->normalScale[3] = atof( token ); + } + // + // specularScale + // or specularScale + // or specularScale + // + else if (!Q_stricmp(token, "specularscale")) + { + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); + continue; + } + + stage->specularScale[0] = atof( token ); + + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); + continue; + } + + stage->specularScale[1] = atof( token ); + + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + // two values, rgb then gloss + stage->specularScale[3] = stage->specularScale[1]; + stage->specularScale[1] = + stage->specularScale[2] = stage->specularScale[0]; + continue; + } + + stage->specularScale[2] = atof( token ); + + token = COM_ParseExt(text, qfalse); + if ( token[0] == 0 ) + { + // three values, rgb + continue; + } + + stage->specularScale[2] = atof( token ); } // // rgbGen @@ -2460,6 +2565,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; + + VectorCopy4(normal->normalScale, diffuse->normalScale); } else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0])) { @@ -2480,6 +2587,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; + + VectorSet4(diffuse->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); } } } @@ -2490,8 +2599,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { //ri->Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; - diffuse->materialInfo[0] = specular->materialInfo[0]; - diffuse->materialInfo[1] = specular->materialInfo[1]; + VectorCopy4(specular->specularScale, diffuse->specularScale); } } @@ -2852,29 +2960,6 @@ static qboolean CollapseStagesToGLSL(void) } } - // insert default material info if needed - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->glslShaderGroup != tr.lightallShader) - continue; - - if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) == 0) - continue; - - if (!pStage->bundle[TB_SPECULARMAP].image[0] && r_specularMapping->integer) - { - if (!pStage->materialInfo[0]) - pStage->materialInfo[0] = r_baseSpecular->value; - if (!pStage->materialInfo[1]) - pStage->materialInfo[1] = r_baseGloss->value; - } - } - ri->Printf (PRINT_DEVELOPER, "> New shader stage order:\n"); for ( int i = 0; i < MAX_SHADER_STAGES; i++ ) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index ac936826a0..e8851cdd86 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -448,7 +448,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max color[0] = color[1] = - color[2] = (r_softOverbright->integer ? 1.0 : tr.identityLight) * backEnd.refdef.colorScale; + color[2] = backEnd.refdef.colorScale; color[3] = 1.0f; GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); From 3236911f74428d8efe764629bae028d7c5889dfc Mon Sep 17 00:00:00 2001 From: Ensiform Date: Wed, 5 Mar 2014 20:40:36 -0600 Subject: [PATCH 168/708] [MP] Rend2: Always add minimum light to be like vanilla. Might make some refents like players and models a bit brighter than before when hdr was on. --- codemp/rd-rend2/tr_light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 46cfb6a392..f4ed5b0fa9 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -371,7 +371,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // bonus items and view weapons have a fixed minimum add - if ( !r_hdr->integer ) { + if ( 1/*!r_hdr->integer*/ ) { // give everything a minimum light add ent->ambientLight[0] += tr.identityLight * 32; ent->ambientLight[1] += tr.identityLight * 32; From 381aaa933f98f77e0b7fc5a4a89576bea0be43f9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Mar 2014 09:06:18 +0000 Subject: [PATCH 169/708] [MP] Rend2: Applied some updates from ioq3's rend2 This commit includes ioquake/ioq3@e7f4354, ioquake/ioq3@b98e6d5, ioquake/ioq3@5a3e10d, ioquake/ioq3@c8c7bb1 and ioquake/ioq3@07290a7. --- codemp/rd-rend2/tr_bsp.cpp | 26 ++++++++++++++------------ codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5b45c44bc7..a7e13ce7cf 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -142,7 +142,7 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) g = in[1] * scale; b = in[2] * scale; - if ( !r_hdr->integer && (r > 1 || g > 1 || b > 1) ) + if ( r > 1.0f || g > 1.0f || b > 1.0f ) { float max = max (max (r, g), b); @@ -2792,7 +2792,7 @@ qboolean R_GetEntityToken( char *buffer, int size ) { s = COM_Parse( (const char **)&s_worldData.entityParsePoint ); Q_strncpyz( buffer, s, size ); - if ( !s_worldData.entityParsePoint || !s[0] ) { + if ( !s_worldData.entityParsePoint && !s[0] ) { s_worldData.entityParsePoint = s_worldData.entityString; return qfalse; } else { @@ -2819,7 +2819,8 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int return qfalse; } if ( com_token[0] != '{' ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {",com_token ); + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); + return qfalse; } // go through all the key / value pairs @@ -2828,7 +2829,8 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int // parse key if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( keyname[0] == '}' ) { @@ -2837,18 +2839,18 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace" ); - break; + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + return qfalse; } if ( com_token[0] == '}' ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data" ); - break; + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); + return qfalse; } if ( *numSpawnVars == MAX_SPAWN_VARS ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS" ); - break; + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); + return qfalse; } keyLength = strlen(keyname) + 1; @@ -2856,8 +2858,8 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS" ); - break; + ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); + return qfalse; } strcpy(spawnVarChars + numSpawnVarChars, keyname); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index a9b34d2115..912e081e3f 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2909,7 +2909,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) vec3_t ambient, directed, lightDir; R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); - if (directed[0] + directed[1] + directed[2] == 0) + if (cubemapSide == 0 && (directed[0] + directed[1] + directed[2] == 0)) { ri->Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e89d09f6fe..532335677f 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -913,7 +913,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMmap' keyword in shader '%s'\n", shader.name ); + ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); return qfalse; } stage->bundle[0].videoMapHandle = ri->CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); From f913487a9f7d46e270504fffaefb103e7fc5bdb4 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 22 Mar 2014 14:44:19 +0000 Subject: [PATCH 170/708] [MP] Rend2: Fix compile error under OSX. --- codemp/rd-rend2/tr_bsp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a7e13ce7cf..4da43dd085 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -144,11 +144,11 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) if ( r > 1.0f || g > 1.0f || b > 1.0f ) { - float max = max (max (r, g), b); + float high = max (max (r, g), b); - r /= max; - g /= max; - b /= max; + r /= high; + g /= high; + b /= high; } out[0] = r; From 61dc3d1ef59e88fa48d8a905e308c904383b2dcb Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 23 Mar 2014 19:35:14 -0500 Subject: [PATCH 171/708] [MP] Rend2: Update to ioquake/ioq3@375f6247d4faf4a2a4d14885213d1cf7516b453d , ioquake/ioq3@b099255748edaec547242e7f165c4016a8bad69b Also fixes bug where leftover `len` variable was being set still for no reason in R_LoadVisibility. --- codemp/rd-rend2/glsl/lightall_fp.glsl | 18 +++++++++-- codemp/rd-rend2/tr_bsp.cpp | 6 +--- codemp/rd-rend2/tr_glsl.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 4 +-- codemp/rd-rend2/tr_shade.cpp | 13 ++++++++ codemp/rd-rend2/tr_world.cpp | 45 ++++++++------------------- 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 9d09737425..ee4129ef8a 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -44,6 +44,13 @@ uniform vec4 u_NormalScale; uniform vec4 u_SpecularScale; #endif +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(USE_CUBEMAP) +uniform vec4 u_CubeMapInfo; +#endif +#endif + + varying vec4 var_TexCoords; varying vec4 var_Color; @@ -323,19 +330,20 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) void main() { + vec3 viewDir; vec3 L, N, E, H; float NL, NH, NE, EH; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_VERT_TANGENT_SPACE) mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); - E = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); + viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); #else mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, var_TexCoords.xy); - E = var_ViewDir; + viewDir = var_ViewDir; #endif - E = normalize(E); + E = normalize(viewDir); L = var_LightDir.xyz; #if defined(USE_DELUXEMAP) @@ -497,6 +505,10 @@ void main() vec3 R = reflect(E, N); + // parallax corrected cubemap (cheaper trick) + // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; + vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; #if defined(USE_LIGHTMAP) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 4da43dd085..d2f336eebf 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -598,11 +598,7 @@ static void R_LoadVisibility( lump_t *l ) { int len; byte *buf; - len = ( s_worldData.numClusters + 63 ) & ~63; - s_worldData.novis = (byte *)ri->Hunk_Alloc( len, h_low ); - Com_Memset( s_worldData.novis, 0xff, len ); - - len = l->filelen; + len = l->filelen; if ( !len ) { return; } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 4ac2011ff9..f39f3ecda9 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -144,6 +144,8 @@ static uniformInfo_t uniformsInfo[] = { "u_PrimaryLightAmbient", GLSL_VEC3, 1 }, { "u_PrimaryLightRadius", GLSL_FLOAT, 1 }, + { "u_CubeMapInfo", GLSL_VEC4, 1 }, + { "u_BoneMatrices", GLSL_MAT16, 80 }, }; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 26cb7d8799..9bc35ce01b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1094,6 +1094,8 @@ typedef enum UNIFORM_PRIMARYLIGHTAMBIENT, UNIFORM_PRIMARYLIGHTRADIUS, + UNIFORM_CUBEMAPINFO, + UNIFORM_BONE_MATRICES, UNIFORM_COUNT @@ -1582,8 +1584,6 @@ typedef struct { int clusterBytes; const byte *vis; // may be passed in by CM_LoadMap to save space - byte *novis; // clusterBytes of 0xff - char *entityString; char *entityParsePoint; } world_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 4e03f54421..fac34035b3 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1518,8 +1518,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) // testing cube map // if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) + { + vec4_t vec; + GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.or.origin[0]; + vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.or.origin[1]; + vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.or.origin[2]; + vec[3] = 1.0f; + + VectorScale4(vec, 1.0f / 1000.0f, vec); + + GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); + } + // // draw // diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 9710e1d6a5..1a093f0a6a 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -649,7 +649,7 @@ R_ClusterPVS */ static const byte *R_ClusterPVS (int cluster) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { - return tr.world->novis; + return NULL; } return tr.world->vis + cluster * tr.world->clusterBytes; @@ -707,29 +707,21 @@ static void R_MarkLeaves (void) { for(i = 0; i < MAX_VISCOUNTS; i++) { - if(tr.visClusters[i] == cluster) + // if the areamask or r_showcluster was modified, invalidate all visclusters + // this caused doors to open into undrawn areas + if (tr.refdef.areamaskModified || r_showcluster->modified) { - //tr.visIndex = i; - break; + tr.visClusters[i] = -2; } - } - - // if r_showcluster was just turned on, remark everything - if(i != MAX_VISCOUNTS && !tr.refdef.areamaskModified && !r_showcluster->modified)// && !r_dynamicBspOcclusionCulling->modified) - { - if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + else if(tr.visClusters[i] == cluster) { - ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + { + ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + } + tr.visIndex = i; + return; } - tr.visIndex = i; - return; - } - - // if the areamask was modified, invalidate all visclusters - // this caused doors to open into undrawn areas - if (tr.refdef.areamaskModified) - { - memset(tr.visClusters, -2, sizeof(tr.visClusters)); } tr.visIndex = (tr.visIndex + 1) % MAX_VISCOUNTS; @@ -743,17 +735,6 @@ static void R_MarkLeaves (void) { } } - // set all nodes to visible if there is no vis - // this caused some levels to simply not render - if (r_novis->integer || !tr.world->vis || tr.visClusters[tr.visIndex] == -1) { - for (i=0 ; inumnodes ; i++) { - if (tr.world->nodes[i].contents != CONTENTS_SOLID) { - tr.world->nodes[i].visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; - } - } - return; - } - vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); for (i=0,leaf=tr.world->nodes ; inumnodes ; i++, leaf++) { @@ -763,7 +744,7 @@ static void R_MarkLeaves (void) { } // check general pvs - if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) { + if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) { continue; } From 8ff116eeff79186767f47e9cfff45d7707ec2fe0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 23 Mar 2014 19:51:23 -0500 Subject: [PATCH 172/708] [MP] Rend2: Make sure to use ri-> here instead of ri. Oops. --- codemp/rd-rend2/tr_world.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 1a093f0a6a..c93c32c6a0 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -717,7 +717,7 @@ static void R_MarkLeaves (void) { { if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) { - ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); } tr.visIndex = i; return; From 95d4e6e6f0ec0246987778b5dd899b9b18f554d4 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 23 Mar 2014 19:53:02 -0500 Subject: [PATCH 173/708] [MP] Rend2: Accidental merge of backEnd.viewParms.or should be backEnd.viewParms.ori. --- codemp/rd-rend2/tr_shade.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index fac34035b3..c90555fd4f 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1523,9 +1523,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); - vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.or.origin[0]; - vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.or.origin[1]; - vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.or.origin[2]; + vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.ori.origin[0]; + vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.ori.origin[1]; + vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.ori.origin[2]; vec[3] = 1.0f; VectorScale4(vec, 1.0f / 1000.0f, vec); From 3962bd343e703f964fa0928ad051e695257682e5 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 23 Mar 2014 20:02:24 -0500 Subject: [PATCH 174/708] [MP] Rend2: Always clamp check ambientlight even when hdr is on. --- codemp/rd-rend2/tr_light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index f4ed5b0fa9..f3b95198c8 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -418,7 +418,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // clamp ambient - if ( !r_hdr->integer ) + //if ( !r_hdr->integer ) { for ( i = 0 ; i < 3 ; i++ ) { if ( ent->ambientLight[i] > tr.identityLightByte ) { From 4d7a9107de342d8eb1bb5e3a745a2d1fc432ed65 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 22 Mar 2014 15:01:51 +0000 Subject: [PATCH 175/708] [MP] Rend2: Fix more build warnings under OSX. --- codemp/rd-rend2/tr_cache.cpp | 10 +--------- codemp/rd-rend2/tr_curve.cpp | 10 +++++++--- codemp/rd-rend2/tr_local.h | 6 ------ codemp/rd-rend2/tr_model.cpp | 2 -- codemp/rd-rend2/tr_shade.cpp | 13 ------------- codemp/rd-rend2/tr_shader.cpp | 1 - 6 files changed, 8 insertions(+), 34 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 055fdfa2ba..40ee815313 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -9,13 +9,6 @@ using namespace std; CImageCacheManager *CImgCache = new CImageCacheManager(); CModelCacheManager *CModelCache = new CModelCacheManager(); -static int GetModelDataAllocSize(void) -{ - return Z_MemSize( TAG_MODEL_MD3) + - Z_MemSize( TAG_MODEL_GLM) + - Z_MemSize( TAG_MODEL_GLA); -} - /* * CCacheManager::SearchLoaded * Return -1 if asset not currently loaded, return positive qhandle_t if found @@ -100,7 +93,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb } int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); - if ( *ppFileBuffer == NULL ) + if ( len == -1 || *ppFileBuffer == NULL ) { return qfalse; } @@ -193,7 +186,6 @@ void CCacheManager::DumpNonPure( void ) { int iChecksum; int iInPak = ri->FS_FileIsInPAK( it->first.c_str(), &iChecksum ); - qboolean bEraseOccurred = qfalse; if( iInPak == -1 || iChecksum != it->second.iPAKChecksum ) { diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 4dc3ee227c..9741c9d510 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -468,9 +468,9 @@ R_SubdividePatchToGrid srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, srfVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE] ) { int i, j, k, l; - srfVert_t_cleared( prev ); - srfVert_t_cleared( next ); - srfVert_t_cleared( mid ); + srfVert_t prev; + srfVert_t next; + srfVert_t mid; float len, maxLen; int dir; int t; @@ -479,6 +479,10 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, int numIndexes; static glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]; int consecutiveComplete; + + Com_Memset (&prev, 0, sizeof (prev)); + Com_Memset (&next, 0, sizeof (next)); + Com_Memset (&mid, 0, sizeof (mid)); for ( i = 0 ; i < width ; i++ ) { for ( j = 0 ; j < height ; j++ ) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9bc35ce01b..bfa4fc9a78 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1303,12 +1303,6 @@ typedef struct #endif } srfVert_t; -#ifdef USE_VERT_TANGENT_SPACE -#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}} -#else -#define srfVert_t_cleared(x) srfVert_t (x) = {{0, 0, 0}, {0, 0}, {0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0, 0}} -#endif - // srfBspSurface_t covers SF_GRID, SF_TRIANGLES, SF_POLY, and SF_VBO_MESH typedef struct srfBspSurface_s { diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 3a9a26c7fa..7448544fcf 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -69,7 +69,6 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) if( !CModelCache->LoadFile( namebuf, (void**)&buf, &bAlreadyCached ) ) continue; - const char *blah = (const char *)(*buf); ident = *(unsigned *)buf; if( !bAlreadyCached ) ident = LittleLong(ident); @@ -648,7 +647,6 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) if( !CModelCache->LoadFile( namebuf, (void**)&buf, &bAlreadyCached ) ) continue; - const char *blah = (const char *)(*buf); ident = *(unsigned *)buf; if( !bAlreadyCached ) ident = LittleLong(ident); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c90555fd4f..f9b4d07334 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1119,18 +1119,6 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -static void ForceAlpha (unsigned char *dstColors, int forceEntAlpha) -{ - int i; - - dstColors += 3; - - for ( i = 0; i < tess.numVertexes; i++, dstColors += 4 ) - { - *dstColors = forceEntAlpha; - } -} - static void RB_IterateStagesGeneric( shaderCommands_t *input ) { int stage; @@ -1154,7 +1142,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) int stateBits; colorGen_t forceRGBGen = CGEN_BAD; alphaGen_t forceAlphaGen = AGEN_IDENTITY; - float forceAlpha = 0.0f; if ( !pStage ) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 532335677f..64e4491799 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2732,7 +2732,6 @@ static qboolean CollapseStagesToGLSL(void) if (!skip) { shaderStage_t *lightmaps[MAX_SHADER_STAGES] = {}; - size_t numLightmapStages = 0; for (i = 0; i < MAX_SHADER_STAGES; i++) { From 1a4c9ab096543c152d27984635c12b8db57c24fa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Mar 2014 15:45:27 +0000 Subject: [PATCH 176/708] [MP] Fix negative index offset on x64 systems --- codemp/qcommon/cm_load.cpp | 27 +++++++++++---------------- codemp/qcommon/cm_local.h | 4 ++-- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/codemp/qcommon/cm_load.cpp b/codemp/qcommon/cm_load.cpp index ca80a990af..851ab1a436 100644 --- a/codemp/qcommon/cm_load.cpp +++ b/codemp/qcommon/cm_load.cpp @@ -1127,27 +1127,22 @@ int CM_ModelContents_Actual( clipHandle_t model, clipMap_t *cm ) cmod = CM_ClipHandleToModel( model, &cm ); //MCG ADDED - return the contents, too - if( cmod->leaf.numLeafBrushes ) // check for brush + + for ( i = 0; i < cmod->leaf.numLeafBrushes; i++ ) { - int brushNum; - for ( i = cmod->leaf.firstLeafBrush; i < cmod->leaf.firstLeafBrush+cmod->leaf.numLeafBrushes; i++ ) - { - brushNum = cm->leafbrushes[i]; - contents |= cm->brushes[brushNum].contents; - } + int brushNum = cm->leafbrushes[cmod->leaf.firstLeafBrush + i]; + contents |= cm->brushes[brushNum].contents; } - if( cmod->leaf.numLeafSurfaces ) // if not brush, check for patch + + for ( i = 0; i < cmod->leaf.numLeafSurfaces; i++ ) { - int surfaceNum; - for ( i = cmod->leaf.firstLeafSurface; i < cmod->leaf.firstLeafSurface+cmod->leaf.numLeafSurfaces; i++ ) - { - surfaceNum = cm->leafsurfaces[i]; - if ( cm->surfaces[surfaceNum] != NULL ) - {//HERNH? How could we have a null surf within our cmod->leaf.numLeafSurfaces? - contents |= cm->surfaces[surfaceNum]->contents; - } + int surfaceNum = cm->leafsurfaces[cmod->leaf.firstLeafSurface + i]; + if ( cm->surfaces[surfaceNum] != NULL ) + {//HERNH? How could we have a null surf within our cmod->leaf.numLeafSurfaces? + contents |= cm->surfaces[surfaceNum]->contents; } } + return contents; } diff --git a/codemp/qcommon/cm_local.h b/codemp/qcommon/cm_local.h index b32de23483..0c63464420 100644 --- a/codemp/qcommon/cm_local.h +++ b/codemp/qcommon/cm_local.h @@ -21,10 +21,10 @@ typedef struct cLeaf_s { int cluster; int area; - int firstLeafBrush; + ptrdiff_t firstLeafBrush; int numLeafBrushes; - int firstLeafSurface; + ptrdiff_t firstLeafSurface; int numLeafSurfaces; } cLeaf_t; From fa31150ad10a4071488f43b4240892271fcedc20 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Mar 2014 15:47:13 +0000 Subject: [PATCH 177/708] [SP] Fix negative index offset in x64 systems --- code/qcommon/cm_load.cpp | 28 +++++++++++----------------- code/qcommon/cm_local.h | 4 ++-- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/code/qcommon/cm_load.cpp b/code/qcommon/cm_load.cpp index 7395a600dd..73973230ae 100644 --- a/code/qcommon/cm_load.cpp +++ b/code/qcommon/cm_load.cpp @@ -1235,27 +1235,21 @@ int CM_ModelContents_Actual( clipHandle_t model, clipMap_t *cm ) cmod = CM_ClipHandleToModel( model, &cm ); //MCG ADDED - return the contents, too - if( cmod->leaf.numLeafBrushes ) // check for brush + for ( i = 0; i < cmod->leaf.numLeafBrushes; i++ ) { - int brushNum; - for ( i = cmod->leaf.firstLeafBrush; i < cmod->leaf.firstLeafBrush+cmod->leaf.numLeafBrushes; i++ ) - { - brushNum = cm->leafbrushes[i]; - contents |= cm->brushes[brushNum].contents; - } + int brushNum = cm->leafbrushes[cmod->leaf.firstLeafBrush + i]; + contents |= cm->brushes[brushNum].contents; } - if( cmod->leaf.numLeafSurfaces ) // if not brush, check for patch - { - int surfaceNum; - for ( i = cmod->leaf.firstLeafSurface; i < cmod->leaf.firstLeafSurface+cmod->leaf.numLeafSurfaces; i++ ) - { - surfaceNum = cm->leafsurfaces[i]; - if ( cm->surfaces[surfaceNum] != NULL ) - {//HERNH? How could we have a null surf within our cmod->leaf.numLeafSurfaces? - contents |= cm->surfaces[surfaceNum]->contents; - } + + for ( i = 0; i < cmod->leaf.numLeafSurfaces; i++ ) + { + int surfaceNum = cm->leafsurfaces[cmod->leaf.firstLeafSurface + i]; + if ( cm->surfaces[surfaceNum] != NULL ) + {//HERNH? How could we have a null surf within our cmod->leaf.numLeafSurfaces? + contents |= cm->surfaces[surfaceNum]->contents; } } + return contents; } diff --git a/code/qcommon/cm_local.h b/code/qcommon/cm_local.h index 7a5ef21c1f..972a1f4558 100644 --- a/code/qcommon/cm_local.h +++ b/code/qcommon/cm_local.h @@ -40,10 +40,10 @@ typedef struct { int cluster; int area; - int firstLeafBrush; + ptrdiff_t firstLeafBrush; int numLeafBrushes; - int firstLeafSurface; + ptrdiff_t firstLeafSurface; int numLeafSurfaces; } cLeaf_t; From 11c48c4b58978afdab665f7d9ed47942b0a0817b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 25 Mar 2014 14:51:59 +0000 Subject: [PATCH 178/708] [MP] Rend2: Fix anisotropic texture filtering. --- codemp/rd-rend2/tr_image.cpp | 18 ++++++++---------- codemp/rd-rend2/tr_init.cpp | 6 +----- codemp/rd-rend2/tr_local.h | 4 ---- codemp/sdl/sdl_glimp.cpp | 5 ++--- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index adbea44b68..976a96e33b 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2134,18 +2134,17 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla if (flags & IMGFLAG_MIPMAP) { - if ( textureFilterAnisotropic ) + if (r_ext_texture_filter_anisotropic->integer > 1 && glConfig.maxTextureFilterAnisotropy > 0) + { qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - (GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) ); + (GLint)Com_Clamp( 1, glConfig.maxTextureFilterAnisotropy, r_ext_texture_filter_anisotropic->integer ) ); + } qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); } else { - if ( textureFilterAnisotropic ) - qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 ); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } @@ -2173,18 +2172,17 @@ static void EmptyTexture( int width, int height, imgType_t type, int flags, if (flags & IMGFLAG_MIPMAP) { - if ( textureFilterAnisotropic ) + if (r_ext_texture_filter_anisotropic->integer > 1 && glConfig.maxTextureFilterAnisotropy > 0.0f) + { qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - (GLint)Com_Clamp( 1, maxAnisotropy, r_ext_max_anisotropy->integer ) ); + (GLint)Com_Clamp( 1, glConfig.maxTextureFilterAnisotropy, r_ext_texture_filter_anisotropic->integer ) ); + } qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); } else { - if ( textureFilterAnisotropic ) - qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 ); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 1db5fa2060..e678752c6e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -28,8 +28,6 @@ bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp fro glconfig_t glConfig; glRefConfig_t glRefConfig; -qboolean textureFilterAnisotropic = qfalse; -int maxAnisotropy = 0; float displayAspect = 0.0f; glstate_t glState; @@ -92,7 +90,6 @@ cvar_t *r_ext_multitexture; cvar_t *r_ext_compiled_vertex_array; cvar_t *r_ext_texture_env_add; cvar_t *r_ext_texture_filter_anisotropic; -cvar_t *r_ext_max_anisotropy; cvar_t *r_ext_preferred_tc_method; cvar_t *r_ext_draw_range_elements; @@ -1203,8 +1200,7 @@ void R_Register( void ) r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", - "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_max_anisotropy = ri->Cvar_Get( "r_ext_max_anisotropy", "2", CVAR_ARCHIVE | CVAR_LATCH ); + "16", CVAR_ARCHIVE | CVAR_LATCH ); r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bfa4fc9a78..18aa59b2a8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -130,7 +130,6 @@ extern cvar_t *r_ext_multitexture; extern cvar_t *r_ext_compiled_vertex_array; extern cvar_t *r_ext_texture_env_add; extern cvar_t *r_ext_texture_filter_anisotropic; -extern cvar_t *r_ext_max_anisotropy; extern cvar_t *r_ext_draw_range_elements; extern cvar_t *r_ext_multi_draw_arrays; @@ -3056,9 +3055,6 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ); const char *RE_ShaderNameFromIndex(int index); image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ); -extern qboolean textureFilterAnisotropic; -extern int maxAnisotropy; - float ProjectRadius( float r, vec3_t location ); void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke); qboolean ShaderHashTableExists(void); diff --git a/codemp/sdl/sdl_glimp.cpp b/codemp/sdl/sdl_glimp.cpp index ee87b68b7b..b98fbe0c5b 100644 --- a/codemp/sdl/sdl_glimp.cpp +++ b/codemp/sdl/sdl_glimp.cpp @@ -697,16 +697,15 @@ static void GLimp_InitExtensions( void ) { Com_Printf ("...ignoring GL_EXT_texture_filter_anisotropic\n" ); } - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) { - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic", glConfig.maxTextureFilterAnisotropy ); } } else { Com_Printf ("...GL_EXT_texture_filter_anisotropic not found\n" ); - ri->Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); } // GL_EXT_clamp_to_edge From 9bbfb187da5f6ba4f923cc37ee73f150d2f85eb0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 25 Mar 2014 15:45:21 +0000 Subject: [PATCH 179/708] [MP] Rend2: Refactored normal map generation code --- codemp/rd-rend2/tr_image.cpp | 210 ++++++++++++++++++----------------- 1 file changed, 108 insertions(+), 102 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 976a96e33b..ccaac55c50 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2238,7 +2238,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT image->type = type; image->flags = flags; - strcpy (image->imgName, name); + Q_strncpyz (image->imgName, name, sizeof (image->imgName)); image->width = width; image->height = height; @@ -2429,6 +2429,109 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri->Hunk_FreeTempMemory( resampledBuffer ); } +static void R_CreateNormalMap ( const char *name, byte *pic, int width, int height, int flags ) +{ + char normalName[MAX_QPATH]; + image_t *normalImage; + int normalWidth, normalHeight; + int normalFlags; + + normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + + COM_StripExtension(name, normalName, MAX_QPATH); + Q_strcat(normalName, MAX_QPATH, "_n"); + + // find normalmap in case it's there + normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); + + // if not, generate it + if (normalImage == NULL) + { + byte *normalPic; + int x, y; + + normalWidth = width; + normalHeight = height; + normalPic = (byte *)Z_Malloc(width * height * 4, TAG_GENERAL); + RGBAtoNormal(pic, normalPic, width, height, (qboolean)(flags & IMGFLAG_CLAMPTOEDGE)); + +#if 1 + // Brighten up the original image to work with the normal map + RGBAtoYCoCgA(pic, pic, width, height); + for (y = 0; y < height; y++) + { + byte *picbyte = pic + y * width * 4; + byte *normbyte = normalPic + y * width * 4; + for (x = 0; x < width; x++) + { + int div = MAX(normbyte[2] - 127, 16); + picbyte[0] = CLAMP(picbyte[0] * 128 / div, 0, 255); + picbyte += 4; + normbyte += 4; + } + } + YCoCgAtoRGBA(pic, pic, width, height); +#else + // Blur original image's luma to work with the normal map + { + byte *blurPic; + + RGBAtoYCoCgA(pic, pic, width, height); + blurPic = ri.Malloc(width * height); + + for (y = 1; y < height - 1; y++) + { + byte *picbyte = pic + y * width * 4; + byte *blurbyte = blurPic + y * width; + + picbyte += 4; + blurbyte += 1; + + for (x = 1; x < width - 1; x++) + { + int result; + + result = *(picbyte - (width + 1) * 4) + *(picbyte - width * 4) + *(picbyte - (width - 1) * 4) + + *(picbyte - 1 * 4) + *(picbyte ) + *(picbyte + 1 * 4) + + *(picbyte + (width - 1) * 4) + *(picbyte + width * 4) + *(picbyte + (width + 1) * 4); + + result /= 9; + + *blurbyte = result; + picbyte += 4; + blurbyte += 1; + } + } + + // FIXME: do borders + + for (y = 1; y < height - 1; y++) + { + byte *picbyte = pic + y * width * 4; + byte *blurbyte = blurPic + y * width; + + picbyte += 4; + blurbyte += 1; + + for (x = 1; x < width - 1; x++) + { + picbyte[0] = *blurbyte; + picbyte += 4; + blurbyte += 1; + } + } + + ri->Free(blurPic); + + YCoCgAtoRGBA(pic, pic, width, height); + } +#endif + + R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); + Z_Free( normalPic ); + } +} + /* =============== R_FindImageFile @@ -2473,110 +2576,13 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) return NULL; } - if (r_normalMapping->integer && !(type == IMGTYPE_NORMAL) && (flags & IMGFLAG_PICMIP) && (flags & IMGFLAG_MIPMAP) && (flags & IMGFLAG_GENNORMALMAP)) + if (r_normalMapping->integer && !(type == IMGTYPE_NORMAL) && + (flags & IMGFLAG_PICMIP) && (flags & IMGFLAG_MIPMAP) && (flags & IMGFLAG_GENNORMALMAP)) { - char normalName[MAX_QPATH]; - image_t *normalImage; - int normalWidth, normalHeight; - int normalFlags; - - normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; - - COM_StripExtension(name, normalName, MAX_QPATH); - Q_strcat(normalName, MAX_QPATH, "_n"); - - // find normalmap in case it's there - normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); - - // if not, generate it - if (normalImage == NULL) - { - byte *normalPic; - int x, y; - - normalWidth = width; - normalHeight = height; - normalPic = (byte *)Z_Malloc(width * height * 4, TAG_GENERAL); - RGBAtoNormal(pic, normalPic, width, height, (qboolean)(flags & IMGFLAG_CLAMPTOEDGE)); - -#if 1 - // Brighten up the original image to work with the normal map - RGBAtoYCoCgA(pic, pic, width, height); - for (y = 0; y < height; y++) - { - byte *picbyte = pic + y * width * 4; - byte *normbyte = normalPic + y * width * 4; - for (x = 0; x < width; x++) - { - int div = MAX(normbyte[2] - 127, 16); - picbyte[0] = CLAMP(picbyte[0] * 128 / div, 0, 255); - picbyte += 4; - normbyte += 4; - } - } - YCoCgAtoRGBA(pic, pic, width, height); -#else - // Blur original image's luma to work with the normal map - { - byte *blurPic; - - RGBAtoYCoCgA(pic, pic, width, height); - blurPic = ri.Malloc(width * height); - - for (y = 1; y < height - 1; y++) - { - byte *picbyte = pic + y * width * 4; - byte *blurbyte = blurPic + y * width; - - picbyte += 4; - blurbyte += 1; - - for (x = 1; x < width - 1; x++) - { - int result; - - result = *(picbyte - (width + 1) * 4) + *(picbyte - width * 4) + *(picbyte - (width - 1) * 4) + - *(picbyte - 1 * 4) + *(picbyte ) + *(picbyte + 1 * 4) + - *(picbyte + (width - 1) * 4) + *(picbyte + width * 4) + *(picbyte + (width + 1) * 4); - - result /= 9; - - *blurbyte = result; - picbyte += 4; - blurbyte += 1; - } - } - - // FIXME: do borders - - for (y = 1; y < height - 1; y++) - { - byte *picbyte = pic + y * width * 4; - byte *blurbyte = blurPic + y * width; - - picbyte += 4; - blurbyte += 1; - - for (x = 1; x < width - 1; x++) - { - picbyte[0] = *blurbyte; - picbyte += 4; - blurbyte += 1; - } - } - - ri->Free(blurPic); - - YCoCgAtoRGBA(pic, pic, width, height); - } -#endif - - R_CreateImage( normalName, normalPic, normalWidth, normalHeight, IMGTYPE_NORMAL, normalFlags, 0 ); - Z_Free( normalPic ); - } + R_CreateNormalMap( name, pic, width, height, flags ); } - image = R_CreateImage( ( char * ) name, pic, width, height, type, flags, 0 ); + image = R_CreateImage( name, pic, width, height, type, flags, 0 ); Z_Free( pic ); return image; } From e56874b7b99c728e8c537584b287a86aaf42547b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 25 Mar 2014 19:17:14 +0000 Subject: [PATCH 180/708] [MP] Rend2: Removed latch flag from aniso cvar This commit removes the CVAR_LATCH flag from r_ext_texture_filter_anisotropic to match the behaviour of the vanilla renderer. --- codemp/rd-rend2/tr_cmds.cpp | 3 ++- codemp/rd-rend2/tr_image.cpp | 43 ++++++++++++++++++++++++++++-------- codemp/rd-rend2/tr_init.cpp | 4 +--- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 57cab75f28..e9d35d8940 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -424,10 +424,11 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // // texturemode stuff // - if ( r_textureMode->modified ) { + if ( r_textureMode->modified || r_ext_texture_filter_anisotropic->modified ) { R_IssuePendingRenderCommands(); GL_TextureMode( r_textureMode->string ); r_textureMode->modified = qfalse; + r_ext_texture_filter_anisotropic->modified = qfalse; } // diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index ccaac55c50..37659ff729 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -102,6 +102,11 @@ void GL_TextureMode( const char *string ) { gl_filter_min = modes[i].minimize; gl_filter_max = modes[i].maximize; + + if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) + { + ri->Cvar_SetValue ("r_ext_texture_filter_anisotropic", glConfig.maxTextureFilterAnisotropy); + } // change all the existing mipmap texture objects for ( i = 0 ; i < tr.numImages ; i++ ) { @@ -110,6 +115,18 @@ void GL_TextureMode( const char *string ) { GL_Bind (glt); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); + + if ( r_ext_texture_filter_anisotropic->value > 0.0f ) + { + if ( glConfig.maxTextureFilterAnisotropy > 1.0f ) + { + qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, r_ext_texture_filter_anisotropic->value); + } + else + { + qglTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1.0f); + } + } } } } @@ -1941,9 +1958,8 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei if (flags & IMGFLAG_MIPMAP) { - int miplevel; - - miplevel = 0; + int miplevel = 0; + while (width > 1 || height > 1) { if (data) @@ -1994,6 +2010,10 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } } +static bool IsPowerOfTwo ( int i ) +{ + return (i & (i - 1)) == 0; +} /* =============== @@ -2007,11 +2027,15 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla { byte *scaledBuffer = NULL; byte *resampledBuffer = NULL; - int scaled_width, scaled_height; + int scaled_width = width; + int scaled_height = height; int i, c; byte *scan; - RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); + if ( !IsPowerOfTwo (width) || !IsPowerOfTwo (height) ) + { + RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); + } scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); @@ -2134,10 +2158,10 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla if (flags & IMGFLAG_MIPMAP) { - if (r_ext_texture_filter_anisotropic->integer > 1 && glConfig.maxTextureFilterAnisotropy > 0) + if (r_ext_texture_filter_anisotropic->value > 1.0f && glConfig.maxTextureFilterAnisotropy > 0.0f) { - qglTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, - (GLint)Com_Clamp( 1, glConfig.maxTextureFilterAnisotropy, r_ext_texture_filter_anisotropic->integer ) ); + qglTexParameterf ( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, + Com_Clamp( 1.0f, glConfig.maxTextureFilterAnisotropy, r_ext_texture_filter_anisotropic->value ) ); } qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); @@ -2582,8 +2606,9 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) R_CreateNormalMap( name, pic, width, height, flags ); } - image = R_CreateImage( name, pic, width, height, type, flags, 0 ); + image = R_CreateImage( name, pic, width, height, type, flags, GL_RGBA8 ); Z_Free( pic ); + return image; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index e678752c6e..6b1da62440 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1198,9 +1198,7 @@ void R_Register( void ) r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); - - r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", - "16", CVAR_ARCHIVE | CVAR_LATCH ); + r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE ); r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); From 9d8a4237c9b1988477ed028d8545d8240c33d126 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Tue, 25 Mar 2014 14:53:06 -0500 Subject: [PATCH 181/708] [MP] Rend2: Delete lightmaps on level start to match vanilla. --- codemp/rd-rend2/tr_cache.cpp | 27 +++++++++++++++++++++++++++ codemp/rd-rend2/tr_local.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 40ee815313..e2cca45269 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -173,6 +173,32 @@ void CCacheManager::DeleteAll( void ) loaded.clear(); } +void CImageCacheManager::DeleteLightMaps( void ) +{ + for( auto it = cache.begin(); it != cache.end(); /* empty */ ) + { + CachedFile_t pFile = it->second; + if( pFile.fileName[0] == '*' && strstr(pFile.fileName, "lightmap") ) + { + if( pFile.pDiskImage ) + Z_Free( pFile.pDiskImage ); + + it = cache.erase(it); + } + else if( pFile.fileName[0] == '_' && strstr(pFile.fileName, "fatlightmap") ) + { + if( pFile.pDiskImage ) + Z_Free( pFile.pDiskImage ); + + it = cache.erase(it); + } + else + { + ++it; + } + } +} + /* * CCacheManager::DumpNonPure * Scans the cache for assets which don't match the checksum, and dumps @@ -364,6 +390,7 @@ void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) tr.numBSPModels = 0; + CImgCache->DeleteLightMaps(); //R_Images_DeleteLightMaps(); /* If we're switching to the same level, don't increment current level */ diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 18aa59b2a8..612aa3872b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3140,6 +3140,8 @@ class CImageCacheManager : public CCacheManager { public: qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); + + void DeleteLightMaps( void ); }; class CModelCacheManager : public CCacheManager From f66accd6c6e3823f15bd5fe497b7f61eb10ef9db Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 25 Mar 2014 20:16:24 +0000 Subject: [PATCH 182/708] [MP] Rend2: Added missing virtual destructor --- codemp/rd-rend2/tr_local.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 612aa3872b..15b61dd21d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3121,6 +3121,8 @@ typedef std::unordered_map loadedMap_t; class CCacheManager { public: + virtual ~CCacheManager() {} + qhandle_t SearchLoaded( const char *fileName ); void InsertLoaded( const char *fileName, qhandle_t handle ); From a0f59383e353ad53aa2c7f8f018e702a9dcb7d52 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Mar 2014 17:56:05 +0000 Subject: [PATCH 183/708] [MP] Rend2: Fix default specular scale. This fixes the specular scale when stage specularmap is used. --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 64e4491799..df9195612f 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1047,7 +1047,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if(!Q_stricmp(token, "specularMap")) { stage->type = ST_SPECULARMAP; - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + VectorSet4(stage->specularScale, r_baseSpecular->integer, r_baseSpecular->integer, r_baseSpecular->integer, 1.0f); } else { From 595ea81af2383efec643fee4237256b14186c6b0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Mar 2014 22:28:50 +0000 Subject: [PATCH 184/708] [MP] Rend2: Improvements to GLSL shader compiling Modern GL drivers are essentially asynchronous. Previously, each GLSL shader was compiled, and then checked for valid compilation, but this removes the benefits of the asynchronous nature of the driver. The take advantage of modern drivers, we tell the driver to compile all our GLSL shaders at the beginning of start up, and then we query for all the compile statuses at the end of start up. --- codemp/rd-rend2/tr_glsl.cpp | 585 ++++++++++++++++++++++++------------ codemp/rd-rend2/tr_init.cpp | 3 +- codemp/rd-rend2/tr_local.h | 10 +- 3 files changed, 395 insertions(+), 203 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index f39f3ecda9..5359309cfe 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -339,40 +339,17 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha Q_strcat(dest, size, "#line 0\n"); } -static int GLSL_CompileGPUShader(GLhandleARB program, GLhandleARB *prevShader, const GLcharARB *buffer, int size, GLenum shaderType) +static int GLSL_EnqueueCompileGPUShader(GLhandleARB program, GLhandleARB *prevShader, const GLcharARB *buffer, int size, GLenum shaderType) { - GLint compiled; GLhandleARB shader; shader = qglCreateShaderObjectARB(shaderType); - qglShaderSourceARB(shader, 1, (const GLcharARB **)&buffer, &size); + qglShaderSourceARB(shader, 1, &buffer, &size); // compile shader qglCompileShaderARB(shader); - // check if shader compiled - qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); - if(!compiled) - { - GLSL_PrintShaderSource(shader); - GLSL_PrintInfoLog(shader, qfalse); - ri->Error(ERR_DROP, "Couldn't compile shader"); - return 0; - } - - //GLSL_PrintInfoLog(shader, qtrue); - //GLSL_PrintShaderSource(shader); - - if (*prevShader) - { - qglDetachObjectARB(program, *prevShader); - qglDeleteObjectARB(*prevShader); - } - - // attach shader to program - qglAttachObjectARB(program, shader); - *prevShader = shader; return 1; @@ -490,36 +467,70 @@ static void GLSL_ShowProgramUniforms(GLhandleARB program) qglUseProgramObjectARB(0); } -static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) +static int GLSL_BeginLoadGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) { - ri->Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); + size_t nameBufSize = strlen (name) + 1; - if(strlen(name) >= MAX_QPATH) - { - ri->Error(ERR_DROP, "GLSL_InitGPUShader2: \"%s\" is too long", name); - } + ri->Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); - Q_strncpyz(program->name, name, sizeof(program->name)); + program->name = (char *)Z_Malloc (nameBufSize, TAG_GENERAL); + Q_strncpyz(program->name, name, nameBufSize); program->program = qglCreateProgramObjectARB(); program->attribs = attribs; - if (!(GLSL_CompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER_ARB))) + if (!(GLSL_EnqueueCompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER_ARB))) { - ri->Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); + ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); qglDeleteObjectARB(program->program); return 0; } if(fpCode) { - if(!(GLSL_CompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER_ARB))) + if(!(GLSL_EnqueueCompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER_ARB))) { - ri->Printf(PRINT_ALL, "GLSL_InitGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); + ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); qglDeleteObjectARB(program->program); return 0; } } + + return 1; +} + +static bool GLSL_IsGPUShaderCompiled (GLhandleARB shader) +{ + GLint compiled; + + qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); + if(!compiled) + { + GLSL_PrintShaderSource(shader); + GLSL_PrintInfoLog(shader, qfalse); + ri->Error(ERR_DROP, "Couldn't compile shader"); + return qfalse; + } + + return qtrue; +} + +static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) +{ + uint32_t attribs = program->attribs; + + if (!GLSL_IsGPUShaderCompiled (program->vertexShader)) + { + return false; + } + + if (!GLSL_IsGPUShaderCompiled (program->fragmentShader)) + { + return false; + } + + qglAttachObjectARB(program->program, program->vertexShader); + qglAttachObjectARB(program->program, program->fragmentShader); if(attribs & ATTR_POSITION) qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION, "attr_Position"); @@ -572,10 +583,19 @@ static int GLSL_InitGPUShader2(shaderProgram_t * program, const char *name, int GLSL_LinkProgram(program->program); - return 1; + // Won't be needing these anymore... + qglDetachObjectARB (program->program, program->vertexShader); + qglDetachObjectARB (program->program, program->fragmentShader); + + qglDeleteObjectARB (program->vertexShader); + qglDeleteObjectARB (program->fragmentShader); + + program->vertexShader = program->fragmentShader = 0; + + return true; } -static int GLSL_InitGPUShader(shaderProgram_t * program, const char *name, +static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, int attribs, qboolean fragmentShader, const GLcharARB *extra, qboolean addHeader, const char *fallback_vp, const char *fallback_fp) { @@ -583,7 +603,6 @@ static int GLSL_InitGPUShader(shaderProgram_t * program, const char *name, char fpCode[32000]; char *postHeader; int size; - int result; size = sizeof(vpCode); if (addHeader) @@ -622,16 +641,19 @@ static int GLSL_InitGPUShader(shaderProgram_t * program, const char *name, } } - result = GLSL_InitGPUShader2(program, name, attribs, vpCode, fragmentShader ? fpCode : NULL); - - return result; + return GLSL_BeginLoadGPUShader2(program, name, attribs, vpCode, fragmentShader ? fpCode : NULL); } void GLSL_InitUniforms(shaderProgram_t *program) { int i, size; - GLint *uniforms = program->uniforms; + GLint *uniforms; + + program->uniforms = (GLint *)Z_Malloc (UNIFORM_COUNT * sizeof (*program->uniforms), TAG_GENERAL); + program->uniformBufferOffsets = (short *)Z_Malloc (UNIFORM_COUNT * sizeof (*program->uniformBufferOffsets), TAG_GENERAL); + + uniforms = program->uniforms; size = 0; for (i = 0; i < UNIFORM_COUNT; i++) @@ -858,46 +880,57 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) { if(program->program) { - if (program->vertexShader) - { - qglDetachObjectARB(program->program, program->vertexShader); - qglDeleteObjectARB(program->vertexShader); - } - - if (program->fragmentShader) - { - qglDetachObjectARB(program->program, program->fragmentShader); - qglDeleteObjectARB(program->fragmentShader); - } - qglDeleteObjectARB(program->program); - if (program->uniformBuffer) - { - Z_Free(program->uniformBuffer); - } + Z_Free (program->name); + Z_Free (program->uniformBuffer); + Z_Free (program->uniformBufferOffsets); + Z_Free (program->uniforms); Com_Memset(program, 0, sizeof(*program)); } } -static qboolean GLSL_ContainsInvalidPermutationForGeneric (int shaderCaps) +static bool GLSL_IsValidPermutationForGeneric (int shaderCaps) { if ((shaderCaps & (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) == (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) { - return qtrue; + return false; + } + + return true; +} + +static bool GLSL_IsValidPermutationForFog (int shaderCaps) +{ + if ((shaderCaps & (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) == (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) + { + return false; } - return qfalse; + return true; } -void GLSL_InitGPUShaders(void) +static bool GLSL_IsValidPermutationForLight (int lightType, int shaderCaps) { - int startTime, endTime; + if ((shaderCaps & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) + return false; + + if (!lightType && (shaderCaps & LIGHTDEF_USE_PARALLAXMAP)) + return false; + + if (!lightType && (shaderCaps & LIGHTDEF_USE_SHADOWMAP)) + return false; + + return true; +} + +int GLSL_BeginLoadGPUShaders(void) +{ + int startTime; int i; char extradefines[1024]; int attribs; - int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); @@ -907,7 +940,7 @@ void GLSL_InitGPUShaders(void) for (i = 0; i < GENERICDEF_COUNT; i++) { - if (GLSL_ContainsInvalidPermutationForGeneric (i)) + if (!GLSL_IsValidPermutationForGeneric (i)) { continue; } @@ -951,44 +984,23 @@ void GLSL_InitGPUShaders(void) if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); - if (!GLSL_InitGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); } - - GLSL_InitUniforms(&tr.genericShader[i]); - - qglUseProgramObjectARB(tr.genericShader[i].program); - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - qglUseProgramObjectARB(0); - - GLSL_FinishGPUShader(&tr.genericShader[i]); - - numGenShaders++; } attribs = ATTR_POSITION | ATTR_TEXCOORD; - if (!GLSL_InitGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) { ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); } - - GLSL_InitUniforms(&tr.textureColorShader); - - qglUseProgramObjectARB(tr.textureColorShader.program); - GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); - - GLSL_FinishGPUShader(&tr.textureColorShader); - - numEtcShaders++; for (i = 0; i < FOGDEF_COUNT; i++) { - if ((i & (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) == (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) + if (!GLSL_IsValidPermutationForFog (i)) { continue; } @@ -1005,15 +1017,10 @@ void GLSL_InitGPUShaders(void) if (i & FOGDEF_USE_SKELETAL_ANIMATION) Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); - if (!GLSL_InitGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } - - GLSL_InitUniforms(&tr.fogShader[i]); - GLSL_FinishGPUShader(&tr.fogShader[i]); - - numEtcShaders++; } @@ -1027,20 +1034,10 @@ void GLSL_InitGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); } - if (!GLSL_InitGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); } - - GLSL_InitUniforms(&tr.dlightShader[i]); - - qglUseProgramObjectARB(tr.dlightShader[i].program); - GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); - - GLSL_FinishGPUShader(&tr.dlightShader[i]); - - numEtcShaders++; } @@ -1050,14 +1047,10 @@ void GLSL_InitGPUShaders(void) qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); // skip impossible combos - if ((i & LIGHTDEF_USE_PARALLAXMAP) && !r_parallaxMapping->integer) - continue; - - if (!lightType && (i & LIGHTDEF_USE_PARALLAXMAP)) - continue; - - if (!lightType && (i & LIGHTDEF_USE_SHADOWMAP)) + if (!GLSL_IsValidPermutationForLight (lightType, i)) + { continue; + } attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; @@ -1195,11 +1188,248 @@ void GLSL_InitGPUShaders(void) #endif } - if (!GLSL_InitGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); } + } + + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; + + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) + { + ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); + } + + attribs = ATTR_POSITION | ATTR_NORMAL; + extradefines[0] = '\0'; + + Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); + + if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) + { + ri->Error(ERR_FATAL, "Could not load pshadow shader!"); + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) + { + ri->Error(ERR_FATAL, "Could not load down4x shader!"); + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) + { + ri->Error(ERR_FATAL, "Could not load bokeh shader!"); + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) + { + ri->Error(ERR_FATAL, "Could not load tonemap shader!"); + } + + + for (i = 0; i < 2; i++) + { + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!i) + Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); + + if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) + { + ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); + } + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (r_shadowFilter->integer >= 1) + Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER\n"); + + if (r_shadowFilter->integer >= 2) + Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n"); + + Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n"); + + Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); + Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); + + + if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) + { + ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); + } + + + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) + { + ri->Error(ERR_FATAL, "Could not load ssao shader!"); + } + + + for (i = 0; i < 2; i++) + { + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (i & 1) + Q_strcat(extradefines, 1024, "#define USE_VERTICAL_BLUR\n"); + else + Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); + + + if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) + { + ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); + } + } + +#if 0 + attribs = ATTR_POSITION | ATTR_TEXCOORD; + extradefines[0] = '\0'; + + if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) + { + ri->Error(ERR_FATAL, "Could not load testcube shader!"); + } + + GLSL_InitUniforms(&tr.testcubeShader); + + qglUseProgramObjectARB(tr.testcubeShader.program); + GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.testcubeShader); + + numEtcShaders++; +#endif + + return startTime; +} + +void GLSL_EndLoadGPUShaders ( int startTime ) +{ + int i; + int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; + + for (i = 0; i < GENERICDEF_COUNT; i++) + { + if (!GLSL_IsValidPermutationForGeneric (i)) + { + continue; + } + + if (!GLSL_EndLoadGPUShader(&tr.genericShader[i])) + { + ri->Error(ERR_FATAL, "Could not load fogpass shader!"); + } + + GLSL_InitUniforms(&tr.genericShader[i]); + + qglUseProgramObjectARB(tr.genericShader[i].program); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); + qglUseProgramObjectARB(0); + +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.genericShader[i]); +#endif + + numGenShaders++; + } + + if (!GLSL_EndLoadGPUShader (&tr.textureColorShader)) + { + ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); + } + + GLSL_InitUniforms(&tr.textureColorShader); + + qglUseProgramObjectARB(tr.textureColorShader.program); + GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + + GLSL_FinishGPUShader(&tr.textureColorShader); + + numEtcShaders++; + + for (i = 0; i < FOGDEF_COUNT; i++) + { + if (!GLSL_IsValidPermutationForFog (i)) + { + continue; + } + if (!GLSL_EndLoadGPUShader(&tr.fogShader[i])) + { + ri->Error(ERR_FATAL, "Could not load fogpass shader!"); + } + + GLSL_InitUniforms(&tr.fogShader[i]); +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.fogShader[i]); +#endif + + numEtcShaders++; + } + + + for (i = 0; i < DLIGHTDEF_COUNT; i++) + { + if (!GLSL_EndLoadGPUShader(&tr.dlightShader[i])) + { + ri->Error(ERR_FATAL, "Could not load dlight shader!"); + } + + GLSL_InitUniforms(&tr.dlightShader[i]); + + qglUseProgramObjectARB(tr.dlightShader[i].program); + GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + qglUseProgramObjectARB(0); + +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.dlightShader[i]); +#endif + + numEtcShaders++; + } + + + for (i = 0; i < LIGHTDEF_COUNT; i++) + { + int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; + qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); + + // skip impossible combos + if (!GLSL_IsValidPermutationForLight (lightType, i)) + { + continue; + } + + if (!GLSL_EndLoadGPUShader(&tr.lightallShader[i])) + { + ri->Error(ERR_FATAL, "Could not load lightall shader!"); + } + GLSL_InitUniforms(&tr.lightallShader[i]); qglUseProgramObjectARB(tr.lightallShader[i].program); @@ -1212,31 +1442,26 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.lightallShader[i]); - +#endif + numLightShaders++; } - - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; - - extradefines[0] = '\0'; - if (!GLSL_InitGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) + if (!GLSL_EndLoadGPUShader(&tr.shadowmapShader)) { ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } - + GLSL_InitUniforms(&tr.shadowmapShader); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.shadowmapShader); +#endif numEtcShaders++; - attribs = ATTR_POSITION | ATTR_NORMAL; - extradefines[0] = '\0'; - - Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); - - if (!GLSL_InitGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) + if (!GLSL_EndLoadGPUShader(&tr.pshadowShader)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } @@ -1247,15 +1472,13 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.pshadowShader); - +#endif + numEtcShaders++; - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) + if (!GLSL_EndLoadGPUShader(&tr.down4xShader)) { ri->Error(ERR_FATAL, "Could not load down4x shader!"); } @@ -1266,38 +1489,34 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.down4xShader); - +#endif + numEtcShaders++; - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) + if (!GLSL_EndLoadGPUShader(&tr.bokehShader)) { ri->Error(ERR_FATAL, "Could not load bokeh shader!"); } - + GLSL_InitUniforms(&tr.bokehShader); qglUseProgramObjectARB(tr.bokehShader.program); GLSL_SetUniformInt(&tr.bokehShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.bokehShader); - +#endif + numEtcShaders++; - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) + if (!GLSL_EndLoadGPUShader(&tr.tonemapShader)) { ri->Error(ERR_FATAL, "Could not load tonemap shader!"); } - + GLSL_InitUniforms(&tr.tonemapShader); qglUseProgramObjectARB(tr.tonemapShader.program); @@ -1305,52 +1524,33 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.tonemapShader); - +#endif + numEtcShaders++; - for (i = 0; i < 2; i++) { - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!i) - Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); - - if (!GLSL_InitGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) + if (!GLSL_EndLoadGPUShader(&tr.calclevels4xShader[i])) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); } - + GLSL_InitUniforms(&tr.calclevels4xShader[i]); qglUseProgramObjectARB(tr.calclevels4xShader[i].program); GLSL_SetUniformInt(&tr.calclevels4xShader[i], UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); - +#endif + numEtcShaders++; } - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (r_shadowFilter->integer >= 1) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER\n"); - - if (r_shadowFilter->integer >= 2) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n"); - - Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n"); - - Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); - Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - - - if (!GLSL_InitGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) + if (!GLSL_EndLoadGPUShader(&tr.shadowmaskShader)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } @@ -1364,15 +1564,13 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.shadowmaskShader); - +#endif + numEtcShaders++; - - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) + if (!GLSL_EndLoadGPUShader(&tr.ssaoShader)) { ri->Error(ERR_FATAL, "Could not load ssao shader!"); } @@ -1383,27 +1581,19 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.ssaoShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.ssaoShader); +#endif numEtcShaders++; - for (i = 0; i < 2; i++) { - attribs = ATTR_POSITION | ATTR_TEXCOORD; - extradefines[0] = '\0'; - - if (i & 1) - Q_strcat(extradefines, 1024, "#define USE_VERTICAL_BLUR\n"); - else - Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); - - - if (!GLSL_InitGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) + if (!GLSL_EndLoadGPUShader(&tr.depthBlurShader[i])) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } - + GLSL_InitUniforms(&tr.depthBlurShader[i]); qglUseProgramObjectARB(tr.depthBlurShader[i].program); @@ -1411,7 +1601,9 @@ void GLSL_InitGPUShaders(void) GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENDEPTHMAP, TB_LIGHTMAP); qglUseProgramObjectARB(0); +#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.depthBlurShader[i]); +#endif numEtcShaders++; } @@ -1436,12 +1628,9 @@ void GLSL_InitGPUShaders(void) numEtcShaders++; #endif - - endTime = ri->Milliseconds(); - ri->Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, - numEtcShaders, (endTime - startTime) / 1000.0); + numEtcShaders, (ri->Milliseconds() - startTime) / 1000.0); } void GLSL_ShutdownGPUShaders(void) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 6b1da62440..53f7fd32cf 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1527,7 +1527,7 @@ void R_Init( void ) { if (glRefConfig.framebufferObject) FBO_Init(); - GLSL_InitGPUShaders(); + int shadersStartTime = GLSL_BeginLoadGPUShaders(); R_InitVBOs(); @@ -1543,6 +1543,7 @@ void R_Init( void ) { R_InitQueries(); + GLSL_EndLoadGPUShaders (shadersStartTime); err = qglGetError(); if ( err != GL_NO_ERROR ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 612aa3872b..8321b8fc4b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1104,7 +1104,7 @@ typedef enum // GLSL vertex and one GLSL fragment shader typedef struct shaderProgram_s { - char name[MAX_QPATH]; + char *name; GLhandleARB program; GLhandleARB vertexShader; @@ -1112,8 +1112,9 @@ typedef struct shaderProgram_s uint32_t attribs; // vertex array attributes // uniform parameters - GLint uniforms[UNIFORM_COUNT]; - short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms + int numUniforms; + GLint *uniforms; + short *uniformBufferOffsets; char *uniformBuffer; } shaderProgram_t; @@ -2678,7 +2679,8 @@ GLSL ============================================================ */ -void GLSL_InitGPUShaders(void); +int GLSL_BeginLoadGPUShaders(void); +void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); void GLSL_VertexAttribsState(uint32_t stateBits); void GLSL_VertexAttribPointers(uint32_t attribBits); From 0069a035e1e3cb29736cb43f469a0dd7e43b2ca6 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Mar 2014 13:01:56 +0000 Subject: [PATCH 185/708] [MP] Rend2: Fix gloss not being set correctly --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index df9195612f..36ce7a8289 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1197,7 +1197,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[2] = atof( token ); + stage->specularScale[3] = atof( token ); } // // rgbGen From 93871529dabd5e495bbcf296e7c3ff7b36123051 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Mar 2014 13:02:22 +0000 Subject: [PATCH 186/708] [MP] Rend2: Clamp shadow scale for q3gl2 to [0, 1] Values outside this range for shadow scale mess things up really badly (can have shadows lighter than lit areas, for example). --- codemp/rd-rend2/tr_shader.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 36ce7a8289..02fafccb53 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2014,6 +2014,17 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qfalse ); tr.sunShadowScale = atof(token); + + if (tr.sunShadowScale < 0.0f) + { + ri->Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 0.0.\n"); + tr.sunShadowScale = 0.0f; + } + else if (tr.sunShadowScale > 1.0f) + { + ri->Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 1.0.\n"); + tr.sunShadowScale = 1.0f; + } } SkipRestOfLine( text ); From 452438414a91d6ed6d9d46b1d25c166441e92201 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Mar 2014 14:07:26 +0000 Subject: [PATCH 187/708] [MP] Rend2: Minor refactoring for readability --- codemp/rd-rend2/tr_world.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index c93c32c6a0..e9cd391bc7 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -791,13 +791,8 @@ void R_AddWorldSurfaces (void) { ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); // perform frustum culling and flag all the potentially visible surfaces - if ( tr.refdef.num_dlights > 32 ) { - tr.refdef.num_dlights = 32 ; - } - - if ( tr.refdef.num_pshadows > 32 ) { - tr.refdef.num_pshadows = 32 ; - } + tr.refdef.num_dlights = min (tr.refdef.num_dlights, 32) ; + tr.refdef.num_pshadows = min (tr.refdef.num_pshadows, 32) ; planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; From 1a60c097051003a1ee9d0522c0ff15968f412f9e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 30 Mar 2014 19:26:10 +0100 Subject: [PATCH 188/708] [MP] Rend2: Fix incorrect lightmaps on restart Occasionally, map lightmaps looked incorrect after reloading the same map. When updating the sampler uniform, the recorded value of that uniform is compared before updating the uniform. However, on shader program creation, the uniform values were not zeroed, which occasionally prevented the uniform from being updated correctly. --- codemp/rd-rend2/tr_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5359309cfe..55c453ea3f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -693,7 +693,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) } } - program->uniformBuffer = (char *)Z_Malloc(size, TAG_SHADERTEXT); + program->uniformBuffer = (char *)Z_Malloc(size, TAG_SHADERTEXT, qtrue); } void GLSL_FinishGPUShader(shaderProgram_t *program) From 2dd004e9e8d9a49c2b6b4164f0172f176c4b3e97 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 30 Mar 2014 20:19:32 -0500 Subject: [PATCH 189/708] [MP] Rend2: Hide surface sprite stages for now instead of drawing the sprites on the original plane (flat). Mimics behavior of having r_surfaceSprites set to 0. --- codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_shade.cpp | 5 +++++ codemp/rd-rend2/tr_shader.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8321b8fc4b..6de7f13beb 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -714,6 +714,8 @@ typedef struct { vec4_t normalScale; vec4_t specularScale; + qboolean isSurfaceSprite; + } shaderStage_t; struct shaderCommands_s; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f9b4d07334..9956bb2040 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1148,6 +1148,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) break; } + if ( pStage->isSurfaceSprite ) + { + continue; + } + if (backEnd.depthFill) { if (pStage->glslShaderGroup == tr.lightallShader) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 02fafccb53..f464085959 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1440,6 +1440,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if ( !Q_stricmp( token, "surfaceSprites" ) ) { + // Mark this stage as a surface sprite so we can skip it for now + stage->isSurfaceSprite = qtrue; SkipRestOfLine( text ); /*char buffer[1024] = ""; From 5b3e5de54b3aada6bb3cee803a2073ae2c08a483 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 12 Apr 2014 22:37:41 -0500 Subject: [PATCH 190/708] [MP] Rend2: Remove r_dlightBacks. It was unused in rend2 and is removed in vanilla due to some cheat use already. --- codemp/rd-rend2/tr_init.cpp | 2 -- codemp/rd-rend2/tr_local.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 53f7fd32cf..f752e827eb 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -66,7 +66,6 @@ cvar_t *r_inGameVideo; cvar_t *r_fastsky; cvar_t *r_drawSun; cvar_t *r_dynamiclight; -cvar_t *r_dlightBacks; cvar_t *r_lodbias; cvar_t *r_lodscale; @@ -1313,7 +1312,6 @@ void R_Register( void ) r_inGameVideo = ri->Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE ); r_drawSun = ri->Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); - r_dlightBacks = ri->Cvar_Get( "r_dlightBacks", "1", CVAR_ARCHIVE ); r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); r_swapInterval = ri->Cvar_Get( "r_swapInterval", "0", diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6de7f13beb..1342b8fe0f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -106,7 +106,6 @@ extern cvar_t *r_inGameVideo; extern cvar_t *r_fastsky; extern cvar_t *r_drawSun; extern cvar_t *r_dynamiclight; -extern cvar_t *r_dlightBacks; extern cvar_t *r_lodbias; extern cvar_t *r_lodscale; @@ -2169,7 +2168,6 @@ extern cvar_t *r_inGameVideo; // controls whether in game video should be dra extern cvar_t *r_fastsky; // controls whether sky should be cleared or drawn extern cvar_t *r_drawSun; // controls drawing of sun quad extern cvar_t *r_dynamiclight; // dynamic lights enabled/disabled -extern cvar_t *r_dlightBacks; // dlight non-facing surfaces for continuity extern cvar_t *r_norefresh; // bypasses the ref rendering extern cvar_t *r_drawentities; // disable/enable entity rendering From ddb54f4ec3b5544fcea391838c84b33210010918 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Apr 2014 20:52:46 +0100 Subject: [PATCH 191/708] [MP] Rend2: Variety of changes/improvements * Removed alternative specular lighting models. Only GGX remains now. * Added support for HDR cubemaps. * Ghoul2 models now use cubemaps for IBL. * Changed default r_baseGloss to 0.1 (was 0.3) * Changed default r_dlightMode to 1 (was 0) --- codemp/rd-rend2/glsl/lightall_fp.glsl | 81 +-------------------------- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 8 ++- codemp/rd-rend2/tr_ghoul2.cpp | 6 +- codemp/rd-rend2/tr_glsl.cpp | 24 -------- codemp/rd-rend2/tr_image.cpp | 12 ++-- codemp/rd-rend2/tr_init.cpp | 4 +- codemp/rd-rend2/tr_local.h | 3 +- codemp/rd-rend2/tr_main.cpp | 2 +- 9 files changed, 25 insertions(+), 117 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index ee4129ef8a..25a1a6d6b1 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -139,32 +139,6 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) } #endif -vec3 CalcDiffuse(vec3 diffuseAlbedo, vec3 N, vec3 L, vec3 E, float NE, float NL, float shininess) -{ - #if defined(USE_OREN_NAYAR) || defined(USE_TRIACE_OREN_NAYAR) - float gamma = dot(E, L) - NE * NL; - float B = 2.22222 + 0.1 * shininess; - - #if defined(USE_OREN_NAYAR) - float A = 1.0 - 1.0 / (2.0 + 0.33 * shininess); - gamma = clamp(gamma, 0.0, 1.0); - #endif - - #if defined(USE_TRIACE_OREN_NAYAR) - float A = 1.0 - 1.0 / (2.0 + 0.65 * shininess); - - if (gamma >= 0.0) - #endif - { - B = max(B * max(NL, NE), EPSILON); - } - - return diffuseAlbedo * (A + gamma / B); - #else - return diffuseAlbedo; - #endif -} - vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) { #if 1 @@ -183,36 +157,6 @@ vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) #endif } -float CalcBlinn(float NH, float shininess) -{ -#if defined(USE_BLINN) || defined(USE_BLINN_FRESNEL) - // Normalized Blinn-Phong - float norm = shininess * 0.125 + 1.0; -#elif defined(USE_MCAULEY) - // Cook-Torrance as done by Stephen McAuley - // http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf - float norm = shininess * 0.25 + 0.125; -#elif defined(USE_GOTANDA) - // Neumann-Neumann as done by Yoshiharu Gotanda - // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf - float norm = shininess * 0.124858 + 0.269182; -#elif defined(USE_LAZAROV) - // Cook-Torrance as done by Dimitar Lazarov - // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - float norm = shininess * 0.125 + 0.25; -#else - float norm = 1.0; -#endif - -#if 0 - // from http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ - float a = shininess + 0.775; - return norm * exp(a * NH - a); -#else - return norm * pow(NH, shininess); -#endif -} - float CalcGGX(float NH, float gloss) { // from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf @@ -243,16 +187,6 @@ float CalcFresnel(float EH) float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) { -#if defined(USE_GOTANDA) - // Neumann-Neumann as done by Yoshiharu Gotanda - // http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf - return 1.0 / max(max(NL, NE), EPSILON); -#elif defined(USE_LAZAROV) - // Cook-Torrance as done by Dimitar Lazarov - // http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - float k = min(1.0, gloss + 0.545); - return 1.0 / (k * (EH * EH - 1.0) + 1.0); -#elif defined(USE_GGX) float roughness = exp2(gloss * -6.5); // Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf @@ -266,25 +200,14 @@ float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) float invGeo2 = NE * k2 + k; return 1.0 / (invGeo1 * invGeo2); -#else - return 1.0; -#endif } vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess) { -#if defined(USE_GGX) float distrib = CalcGGX(NH, gloss); -#else - float distrib = CalcBlinn(NH, shininess); -#endif -#if defined(USE_BLINN) - vec3 fSpecular = specular; -#else vec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH)); -#endif float vis = CalcVisibility(NH, NL, NE, EH, gloss); @@ -460,7 +383,7 @@ void main() diffuse.rgb *= vec3(1.0) - specular.rgb; #endif - reflectance = CalcDiffuse(diffuse.rgb, N, L, E, NE, NL, shininess); + reflectance = diffuse.rgb; #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR) float adjGloss = gloss; @@ -539,7 +462,7 @@ void main() EH2 = clamp(dot(E, H2), 0.0, 1.0); NH2 = clamp(dot(N, H2), 0.0, 1.0); - reflectance = CalcDiffuse(diffuse.rgb, N, L2, E, NE, NL2, shininess); + reflectance = diffuse.rgb; reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss, shininess); lightColor = u_PrimaryLightColor; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c6ad2ce2fe..7e6a3e29af 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1814,7 +1814,7 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (!glRefConfig.framebufferObject || !r_postProcess->integer) + if (!glRefConfig.framebufferObject || !r_postProcess->integer || (tr.viewParms.flags & VPF_NOPOSTPROCESS)) { // do nothing return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d2f336eebf..178d5b6e5a 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2965,10 +2965,16 @@ static void R_AssignCubemapsToWorldSurfaces(void) static void R_RenderAllCubemaps(void) { int i, j; + GLenum cubemapFormat = GL_RGBA8; + + if ( r_hdr->integer ) + { + cubemapFormat = GL_RGBA16F; + } for (i = 0; i < tr.numCubemaps; i++) { - tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, GL_RGBA8); + tr.cubemaps[i] = R_CreateImage (va ("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); } for (i = 0; i < tr.numCubemaps; i++) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 1fcc9cd26a..b09f516fe9 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2434,6 +2434,8 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } + int cubemapIndex = R_CubemapForPoint (tr.currentEntity->e.origin); + // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out @@ -2443,7 +2445,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf( (surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 ); + R_AddDrawSurf ((surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), cubemapIndex); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2523,7 +2525,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf( (surfaceType_t *)newSurf2,gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 ); + R_AddDrawSurf ((surfaceType_t *)newSurf2, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), cubemapIndex); } } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 55c453ea3f..b8cefeee42 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1119,30 +1119,6 @@ int GLSL_BeginLoadGPUShaders(void) if (r_specularMapping->integer) { Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); - - switch (r_specularMapping->integer) - { - case 1: - default: - Q_strcat(extradefines, 1024, "#define USE_BLINN\n"); - break; - - case 2: - Q_strcat(extradefines, 1024, "#define USE_BLINN_FRESNEL\n"); - break; - - case 3: - Q_strcat(extradefines, 1024, "#define USE_MCAULEY\n"); - break; - - case 4: - Q_strcat(extradefines, 1024, "#define USE_GOTANDA\n"); - break; - - case 5: - Q_strcat(extradefines, 1024, "#define USE_LAZAROV\n"); - break; - } } if (r_cubeMapping->integer) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 37659ff729..0456dc4936 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2311,12 +2311,12 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); if (image->flags & IMGFLAG_MIPMAP) qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 53f7fd32cf..f385f406fb 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1262,8 +1262,8 @@ void R_Register( void ) r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH ); r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); - r_dlightMode = ri->Cvar_Get( "r_dlightMode", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.1", CVAR_ARCHIVE | CVAR_LATCH ); + r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); r_recalcMD3Normals = ri->Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6de7f13beb..7d48ea6953 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1196,7 +1196,8 @@ typedef enum { VPF_ORTHOGRAPHIC = 0x10, VPF_USESUNLIGHT = 0x20, VPF_FARPLANEFRUSTUM = 0x40, - VPF_NOCUBEMAPS = 0x80 + VPF_NOCUBEMAPS = 0x80, + VPF_NOPOSTPROCESS = 0x100 } viewParmFlags_t; typedef struct { diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 912e081e3f..5c3ba7bb05 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2923,7 +2923,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) parms.viewportHeight = tr.renderCubeFbo->height; parms.isPortal = qfalse; parms.isMirror = qtrue; - parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS; + parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS | VPF_NOPOSTPROCESS; parms.fovX = 90; parms.fovY = 90; From 6c2fa53bb7fc162c76a36c39e9444ccfe1dff2ee Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 17 Apr 2014 21:28:08 +0100 Subject: [PATCH 192/708] [MP] Rend2: Selectively picked changes from ioq3 This commit selectively picks changes from ioq3's rend2 regarding cubemap normalization which wasn't necessary. --- codemp/rd-rend2/glsl/lightall_fp.glsl | 68 +++++++++++++-------------- codemp/rd-rend2/glsl/lightall_vp.glsl | 9 +--- codemp/rd-rend2/tr_main.cpp | 10 +--- 3 files changed, 36 insertions(+), 51 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 25a1a6d6b1..beb4fdb20c 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -66,9 +66,7 @@ varying vec3 var_ViewDir; #endif #endif -#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) -varying vec3 var_LightColor; -#endif +varying vec3 var_N; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) varying vec4 var_LightDir; @@ -253,9 +251,9 @@ mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) void main() { - vec3 viewDir; + vec3 viewDir, lightColor, ambientColor; vec3 L, N, E, H; - float NL, NH, NE, EH; + float NL, NH, NE, EH, attenuation; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_VERT_TANGENT_SPACE) @@ -276,16 +274,10 @@ void main() #endif #if defined(USE_LIGHTMAP) - vec4 lightSample = texture2D(u_LightMap, var_TexCoords.zw); - vec3 lightColor = lightSample.rgb; + vec4 lightmapColor = texture2D(u_LightMap, var_TexCoords.zw); #if defined(RGBM_LIGHTMAP) - lightColor *= lightSample.a; + lightmapColor.rgb *= lightmapColor.a; #endif -#elif defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) - vec3 lightColor = u_DirectedLight * CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); - vec3 ambientColor = u_AmbientLight; -#elif defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) - vec3 lightColor = var_LightColor; #endif vec2 texCoords = var_TexCoords.xy; @@ -305,6 +297,19 @@ void main() #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + ambientColor = vec3 (0.0); + attenuation = 1.0; + + #if defined(USE_LIGHTMAP) + lightColor = lightmapColor.rgb * var_Color.rgb; + #elif defined(USE_LIGHT_VECTOR) + lightColor = u_DirectedLight * var_Color.rgb; + ambientColor = u_AmbientLight * var_Color.rgb; + attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); + #elif defined(USE_LIGHT_VERTEX) + lightColor = var_Color.rgb; + #endif + #if defined(USE_NORMALMAP) #if defined(SWIZZLE_NORMALMAP) N.xy = texture2D(u_NormalMap, texCoords).ag - vec2(0.5); @@ -341,7 +346,7 @@ void main() #endif #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) - vec3 ambientColor = lightColor; + ambientColor = lightColor; float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); // Scale the incoming light to compensate for the baked-in light angle @@ -350,7 +355,7 @@ void main() // Recover any unused light as ambient, in case attenuation is over 4x or // light is below the surface - ambientColor -= lightColor * surfNL; + ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0); #endif vec3 reflectance; @@ -406,7 +411,7 @@ void main() #endif #endif - gl_FragColor.rgb = lightColor * reflectance * NL; + gl_FragColor.rgb = lightColor * reflectance * (attenuation * NL); #if 0 vec3 aSpecular = EnvironmentBRDF(gloss, NE, specular.rgb); @@ -430,20 +435,13 @@ void main() // parallax corrected cubemap (cheaper trick) // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ - R += u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; + vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - vec3 cubeLightColor = textureCubeLod(u_CubeMap, R, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; - - #if defined(USE_LIGHTMAP) - cubeLightColor *= lightSample.rgb; - #elif defined (USE_LIGHT_VERTEX) - cubeLightColor *= var_LightColor; - #else - cubeLightColor *= lightColor * NL + ambientColor; - #endif + vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; - //gl_FragColor.rgb += diffuse.rgb * textureCubeLod(u_CubeMap, N, 7.0).rgb * u_EnableTextures.w; - gl_FragColor.rgb += cubeLightColor * reflectance; + gl_FragColor.rgb = cubeLightColor * reflectance; + gl_FragColor.a = 1.0; + return; #endif #if defined(USE_PRIMARY_LIGHT) @@ -465,7 +463,7 @@ void main() reflectance = diffuse.rgb; reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss, shininess); - lightColor = u_PrimaryLightColor; + lightColor = u_PrimaryLightColor * var_Color.rgb; // enable when point lights are supported as primary lights //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); @@ -474,16 +472,18 @@ void main() lightColor *= shadowValue; #endif + // enable when point lights are supported as primary lights + //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); + gl_FragColor.rgb += lightColor * reflectance * NL2; #endif - gl_FragColor.a = diffuse.a; #else - gl_FragColor = diffuse; + lightColor = var_Color.rgb; #if defined(USE_LIGHTMAP) - gl_FragColor.rgb *= lightColor; + lightColor *= lightmapColor.rgb; #endif #endif - - gl_FragColor *= var_Color; + + gl_FragColor = vec4 (diffuse.rgb * lightColor, diffuse.a * var_Color.a); } diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 3df09f0bcf..4a56addae6 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -77,6 +77,7 @@ varying vec4 var_TexCoords; varying vec4 var_Color; +varying vec3 var_N; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_VERT_TANGENT_SPACE) varying vec4 var_Normal; @@ -88,10 +89,6 @@ varying vec3 var_ViewDir; #endif #endif -#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) -varying vec3 var_LightColor; -#endif - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) varying vec4 var_LightDir; #endif @@ -247,10 +244,6 @@ void main() #endif var_Color = u_VertColor * attr_Color + u_BaseColor; -#if defined(USE_LIGHT_VERTEX) && !defined(USE_FAST_LIGHT) - var_LightColor = var_Color.rgb; - var_Color.rgb = vec3(1.0); -#endif #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) float sqrLightDist = dot(L, L); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 5c3ba7bb05..906865e8f0 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2905,15 +2905,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) } } - { - vec3_t ambient, directed, lightDir; - R_LightForPoint(tr.refdef.vieworg, ambient, directed, lightDir); - tr.refdef.colorScale = 766.0f / (directed[0] + directed[1] + directed[2] + 1.0f); - if (cubemapSide == 0 && (directed[0] + directed[1] + directed[2] == 0)) - { - ri->Printf(PRINT_ALL, "cubemap %d (%f, %f, %f) is outside the lightgrid!\n", cubemapIndex, tr.refdef.vieworg[0], tr.refdef.vieworg[1], tr.refdef.vieworg[2]); - } - } + tr.refdef.colorScale = 1.0f; Com_Memset( &parms, 0, sizeof( parms ) ); From eef4a492ada1b87c1fab609261aa881ac2af8b3c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 18 Apr 2014 09:46:22 +0100 Subject: [PATCH 193/708] [MP] Rend2: Revert some debugging changes to GLSL --- codemp/rd-rend2/glsl/lightall_fp.glsl | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index beb4fdb20c..ec7b73796e 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -440,8 +440,6 @@ void main() vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; gl_FragColor.rgb = cubeLightColor * reflectance; - gl_FragColor.a = 1.0; - return; #endif #if defined(USE_PRIMARY_LIGHT) From 6372490e5b313cbd5e5b9b6a124848f083d5cfa3 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 20 Apr 2014 14:04:51 +0100 Subject: [PATCH 194/708] [MP] Rend2: Fix for new extensions handling This commit adds the additional needed variables introduced by the GL extensions fix. This commit also makes clear the problems with the modular renderer system in that not all renderer state is isolated to each renderer as it should be. --- codemp/rd-rend2/tr_extensions.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 3 ++- codemp/rd-rend2/tr_local.h | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index e6f344ebe7..496a3dc23b 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -183,7 +183,7 @@ void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); static qboolean GLimp_HaveExtension(const char *ext) { - const char *ptr = Q_stristr( glConfig.extensions_string, ext ); + const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); if (ptr == NULL) return qfalse; ptr += strlen(ext); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index e897a785ad..3148f526f0 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez glconfig_t glConfig; +glconfigExt_t glConfigExt; glRefConfig_t glRefConfig; float displayAspect = 0.0f; @@ -1072,7 +1073,7 @@ void GfxInfo_f( void ) ri->Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); ri->Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); ri->Printf( PRINT_ALL, "GL_EXTENSIONS: " ); - R_PrintLongString( glConfig.extensions_string ); + R_PrintLongString( glConfigExt.originalExtensionString ); ri->Printf( PRINT_ALL, "\n" ); ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index aed2cdd42a..56bf731420 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2135,6 +2135,13 @@ typedef struct trGlobals_s { int currentLevel; } trGlobals_t; +struct glconfigExt_t +{ + glconfig_t *glConfig; + + const char *originalExtensionString; +}; + extern backEndState_t backEnd; extern trGlobals_t tr; extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init @@ -2366,6 +2373,7 @@ void GL_Cull( int cullType ); #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) extern glconfig_t glConfig; +extern glconfigExt_t glConfigExt; typedef _skinSurface_t skinSurface_t; From 6e1c9272f4f35f91859fef16b3790371e90680ee Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 20 Apr 2014 14:26:55 +0100 Subject: [PATCH 195/708] [MP] Rend2: Fix crash when remapping shaders. --- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f464085959..d85658f455 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -150,7 +150,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh = R_FindShaderByName( shaderName ); if (sh == NULL || sh == tr.defaultShader) { - h = RE_RegisterShaderLightMap(shaderName, 0, stylesDefault); + h = RE_RegisterShaderLightMap (shaderName, lightmapsNone, stylesDefault); sh = R_GetShaderByHandle(h); } if (sh == NULL || sh == tr.defaultShader) { @@ -160,7 +160,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh2 = R_FindShaderByName( newShaderName ); if (sh2 == NULL || sh2 == tr.defaultShader) { - h = RE_RegisterShaderLightMap(newShaderName, 0, stylesDefault); + h = RE_RegisterShaderLightMap (newShaderName, lightmapsNone, stylesDefault); sh2 = R_GetShaderByHandle(h); } From 4f86f86f038134b6563a2a95032883fafa1fc70c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 20 Apr 2014 23:59:37 -0500 Subject: [PATCH 196/708] [MP] Rend2: RMG fixes for rend2 branch. --- codemp/rd-rend2/tr_init.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 3148f526f0..7bd2f4ef25 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1757,7 +1757,6 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.InitializeWireframeAutomap = stub_InitializeWireframeAutomap; re.AddWeatherZone = stub_RE_AddWeatherZone; re.WorldEffectCommand = stub_RE_WorldEffectCommand; - // RE_InitRendererTerrain re.RegisterMedia_LevelLoadBegin = C_LevelLoadBegin; re.RegisterMedia_LevelLoadEnd = C_LevelLoadEnd; re.RegisterMedia_GetLevel = C_GetLevel; @@ -1869,13 +1868,6 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { Ghoul2 Insert End */ - re.LoadDataImage = R_LoadDataImage; - re.InvertImage = R_InvertImage; - re.Resample = R_Resample; - re.LoadImageJA = R_LoadImage; - //re.CreateAutomapImage = R_CreateAutomapImage; - re.SavePNG = RE_SavePNG; - return &re; } } \ No newline at end of file From c30e1cae5382bd51118cc97a14bf21453d50f0ea Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 10 May 2014 14:50:41 +0100 Subject: [PATCH 197/708] [MP] Updated files to compile with recent changes --- codemp/rd-rend2/CMakeLists.txt | 37 +++++++++++++++++++++++++++------- codemp/rd-rend2/G2_misc.cpp | 21 ------------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index d8ca1f6f59..ef87b8cc19 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -75,7 +75,6 @@ set(MPRend2RdCommonFiles "${MPDir}/rd-common/tr_font.cpp" "${MPDir}/rd-common/tr_font.h" "${MPDir}/rd-common/tr_image_load.cpp" - "${MPDir}/rd-common/tr_image_manipulation.cpp" "${MPDir}/rd-common/tr_image_jpg.cpp" "${MPDir}/rd-common/tr_image_tga.cpp" "${MPDir}/rd-common/tr_image_png.cpp" @@ -123,13 +122,37 @@ else(UseInternalPNG) endif(UseInternalPNG) if(UseInternalZlib) - # zlib.lib is included for windows - find_library(ZlibLibrary NAMES zlib PATHS ${OpenJKLibDir}) - if(NOT ZlibLibrary) - message(FATAL_ERROR "UseInternalZlib enabled, but lib/zlib.lib not found!") - endif(NOT ZlibLibrary) + set(MPRend2ZLibFiles + "${OpenJKLibDir}/zlib/adler32.c" + "${OpenJKLibDir}/zlib/compress.c" + "${OpenJKLibDir}/zlib/crc32.c" + "${OpenJKLibDir}/zlib/deflate.c" + "${OpenJKLibDir}/zlib/gzclose.c" + "${OpenJKLibDir}/zlib/gzlib.c" + "${OpenJKLibDir}/zlib/gzread.c" + "${OpenJKLibDir}/zlib/gzwrite.c" + "${OpenJKLibDir}/zlib/infback.c" + "${OpenJKLibDir}/zlib/inffast.c" + "${OpenJKLibDir}/zlib/inflate.c" + "${OpenJKLibDir}/zlib/inftrees.c" + "${OpenJKLibDir}/zlib/trees.c" + "${OpenJKLibDir}/zlib/uncompr.c" + "${OpenJKLibDir}/zlib/zutil.c" + "${OpenJKLibDir}/zlib/crc32.h" + "${OpenJKLibDir}/zlib/deflate.h" + "${OpenJKLibDir}/zlib/gzguts.h" + "${OpenJKLibDir}/zlib/inffast.h" + "${OpenJKLibDir}/zlib/inffixed.h" + "${OpenJKLibDir}/zlib/inflate.h" + "${OpenJKLibDir}/zlib/inftrees.h" + "${OpenJKLibDir}/zlib/trees.h" + "${OpenJKLibDir}/zlib/zconf.h" + "${OpenJKLibDir}/zlib/zlib.h" + "${OpenJKLibDir}/zlib/zutil.h") + source_group("zlib" FILES ${MPRend2ZLibFiles}) + set(MPRend2Files ${MPRend2Files} ${MPRend2ZLibFiles}) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} "${OpenJKLibDir}/zlib") - set(MPRend2Libraries ${MPRend2Libraries} ${ZlibLibrary}) else(UseInternalZlib) find_package(ZLIB REQUIRED) set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${ZLIB_INCLUDE_DIR}) diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 594eb9d90a..530c5a5fc0 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -1784,27 +1784,6 @@ void G2_FreeSaveBuffer(char *buffer) Z_Free(buffer); } -int G2_FindConfigStringSpace(char *name, int start, int max) -{ - char s[MAX_STRING_CHARS]; - int i; - for ( i=1 ; iSV_GetConfigstring( start + i, s, sizeof( s ) ); - if ( !s[0] ) - { - break; - } - if ( !Q_stricmp( s, name ) ) - { - return i; - } - } - - ri->SV_SetConfigstring(start + i, name); - return i; -} - qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); From 9d0e75dc9cd2709532dbbfa23653039797980d05 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 10 May 2014 18:20:52 +0100 Subject: [PATCH 198/708] [MP] Rend2: Fix incorrect shading. This commit fixes some incorrect shading, caused when badly copying a commit from ioq3/rend2 --- codemp/rd-rend2/glsl/lightall_fp.glsl | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index ec7b73796e..cdcc96db6e 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -66,8 +66,6 @@ varying vec3 var_ViewDir; #endif #endif -varying vec3 var_N; - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) varying vec4 var_LightDir; #endif @@ -291,23 +289,20 @@ void main() #endif vec4 diffuse = texture2D(u_DiffuseMap, texCoords); -#if defined(USE_GAMMA2_TEXTURES) - diffuse.rgb *= diffuse.rgb; -#endif - #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - ambientColor = vec3 (0.0); - attenuation = 1.0; - #if defined(USE_LIGHTMAP) lightColor = lightmapColor.rgb * var_Color.rgb; + ambientColor = vec3 (0.0); + attenuation = 1.0; #elif defined(USE_LIGHT_VECTOR) lightColor = u_DirectedLight * var_Color.rgb; ambientColor = u_AmbientLight * var_Color.rgb; attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); #elif defined(USE_LIGHT_VERTEX) lightColor = var_Color.rgb; + ambientColor = vec3 (0.0); + attenuation = 1.0; #endif #if defined(USE_NORMALMAP) @@ -365,9 +360,6 @@ void main() #if defined(USE_SPECULARMAP) vec4 specular = texture2D(u_SpecularMap, texCoords); - #if defined(USE_GAMMA2_TEXTURES) - specular.rgb *= specular.rgb; - #endif #else vec4 specular = vec4(1.0); #endif @@ -481,7 +473,9 @@ void main() #if defined(USE_LIGHTMAP) lightColor *= lightmapColor.rgb; #endif + + gl_FragColor.rgb = diffuse.rgb * lightColor; #endif - gl_FragColor = vec4 (diffuse.rgb * lightColor, diffuse.a * var_Color.a); + gl_FragColor.a = diffuse.a * var_Color.a; } From abe2e3a063ec795829cbe0539224100980aa95e9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 18 May 2014 18:35:09 +0100 Subject: [PATCH 199/708] [MP] Rend2: Simplified buffer creation code. This commit removes the second variations of the CreateVBO and CreateIBO functions, in favour of requiring the caller to pass in the vertex data in the format they need it. This is in preparation for allowing for more generic usage of vertex buffers and vertex formats. --- codemp/rd-rend2/tr_bsp.cpp | 71 ++++- codemp/rd-rend2/tr_ghoul2.cpp | 6 +- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_local.h | 10 +- codemp/rd-rend2/tr_model.cpp | 4 +- codemp/rd-rend2/tr_vbo.cpp | 512 +++------------------------------- 6 files changed, 100 insertions(+), 505 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 178d5b6e5a..12fae5fbeb 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1866,6 +1866,18 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out) } } +struct packedVertex_t +{ + vec3_t position; + uint32_t normal; +#ifdef USE_VERT_TANGENT_SPACE + uint32_t tangent; +#endif + vec2_t texcoord; + vec2_t lightmapCoords[MAXLIGHTMAPS]; + vec4_t colors[MAXLIGHTMAPS]; + uint32_t lightDirection; +}; /* =============== @@ -1877,7 +1889,7 @@ static void R_CreateWorldVBOs(void) int i, j, k; int numVerts; - srfVert_t *verts; + packedVertex_t *verts; int numIndexes; glIndex_t *indexes; @@ -2006,7 +2018,7 @@ static void R_CreateWorldVBOs(void) ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); // create arrays - verts = (srfVert_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(srfVert_t)); + verts = (packedVertex_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); // set up indices and copy vertices @@ -2032,21 +2044,53 @@ static void R_CreateWorldVBOs(void) for(i = 0; i < bspSurf->numVerts; i++) { - CopyVert(&bspSurf->verts[i], &verts[numVerts++]); + packedVertex_t& vert = verts[numVerts++]; + + VectorCopy (bspSurf->verts[i].xyz, vert.position); + vert.normal = R_VboPackNormal (bspSurf->verts[i].normal); +#ifdef USE_VERT_TANGENT_SPACE + vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); +#endif + VectorCopy2 (bspSurf->verts[i].st, vert.texcoord); + + for (int j = 0; j < MAXLIGHTMAPS; j++) + { + VectorCopy2 (bspSurf->verts[i].lightmap[j], vert.lightmapCoords[j]); + } + + for (int j = 0; j < MAXLIGHTMAPS; j++) + { + VectorCopy4 (bspSurf->verts[i].vertexColors[j], vert.colors[j]); + } + + vert.lightDirection = R_VboPackNormal (bspSurf->verts[i].lightdir); } } + vbo = R_CreateVBO((byte *)verts, sizeof (packedVertex_t) * numVerts, VBO_USAGE_STATIC); + ibo = R_CreateIBO((byte *)indexes, numIndexes * sizeof (glIndex_t), VBO_USAGE_STATIC); + + // Setup the offsets and strides + vbo->ofs_xyz = offsetof (packedVertex_t, position); + vbo->ofs_normal = offsetof (packedVertex_t, normal); #ifdef USE_VERT_TANGENT_SPACE - vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, - ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | ATTR_TANGENT | - ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); -#else - vbo = R_CreateVBO2(va("staticBspModel0_VBO %i", k), numVerts, verts, - ATTR_POSITION | ATTR_TEXCOORD | ATTR_LIGHTCOORD | - ATTR_NORMAL | ATTR_COLOR | ATTR_LIGHTDIRECTION, VBO_USAGE_STATIC); + vbo->ofs_tangent = offsetof (packedVertex_t, tangent); #endif - - ibo = R_CreateIBO2(va("staticBspModel0_IBO %i", k), numIndexes, indexes, VBO_USAGE_STATIC); + vbo->ofs_st = offsetof (packedVertex_t, texcoord); + vbo->ofs_lightmap = offsetof (packedVertex_t, lightmapCoords); + vbo->ofs_vertexcolor = offsetof (packedVertex_t, colors); + vbo->ofs_lightdir = offsetof (packedVertex_t, lightDirection); + + const size_t packedVertexSize = sizeof (packedVertex_t); + vbo->stride_xyz = packedVertexSize; + vbo->stride_normal = packedVertexSize; +#ifdef USE_VERT_TANGENT_SPACE + vbo->stride_tangent = packedVertexSize; +#endif + vbo->stride_st = packedVertexSize; + vbo->stride_lightmap = packedVertexSize; + vbo->stride_vertexcolor = packedVertexSize; + vbo->stride_lightdir = packedVertexSize; // point bsp surfaces to VBO for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) @@ -3211,9 +3255,8 @@ void R_MergeLeafSurfaces(void) } // create ibo - ibo = tr.ibos[tr.numIBOs] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs++] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); memset(ibo, 0, sizeof(*ibo)); - Q_strncpyz(ibo->name, va("staticWorldMesh_IBO_mergedSurfs%i", tr.numIBOs++), sizeof(ibo->name)); numIboIndexes = 0; // allocate indexes diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index b09f516fe9..054b23229c 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4651,7 +4651,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean modelName = mdxm->name; } - VBO_t *vbo = R_CreateVBO (va ("MDXM VBO LOD %d '%s'", l, modelName), data, dataSize, VBO_USAGE_STATIC); + VBO_t *vbo = R_CreateVBO (data, dataSize, VBO_USAGE_STATIC); ri->Hunk_FreeTempMemory (data); ri->Hunk_FreeTempMemory (tangentsf); @@ -4702,7 +4702,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean assert (index == (indices + numTriangles * 3)); - IBO_t *ibo = R_CreateIBO2 (va ("MDXM IBO LOD %d '%s'", l, modelName), numTriangles * 3, indices, VBO_USAGE_STATIC); + IBO_t *ibo = R_CreateIBO ((byte *)indices, sizeof (glIndex_t) * numTriangles * 3, VBO_USAGE_STATIC); ri->Hunk_FreeTempMemory (indices); @@ -4716,7 +4716,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vboMeshes[n].indexOffset = indexOffsets[n]; vboMeshes[n].minIndex = baseVertexes[n]; vboMeshes[n].maxIndex = baseVertexes[n + 1]; - vboMeshes[n].numVertexes = surf->numVerts * 5; + vboMeshes[n].numVertexes = surf->numVerts; vboMeshes[n].numIndexes = surf->numTriangles * 3; surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index b8cefeee42..e57764574a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1907,7 +1907,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) // don't just call LogComment, or we will get a call to va() every frame! if (r_logFile->integer) { - GLimp_LogComment(va("--- GL_VertexAttribPointers( %s ) ---\n", vbo->name)); + GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); } // position/normal/tangent are always set in case of animation diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 73ff5b5a74..7ba331e0d4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -387,8 +387,6 @@ typedef enum typedef struct VBO_s { - char name[MAX_QPATH]; - uint32_t vertexesVBO; int vertexesSize; // amount of memory data allocated for all vertices in bytes uint32_t ofs_xyz; @@ -423,8 +421,6 @@ typedef struct VBO_s typedef struct IBO_s { - char name[MAX_QPATH]; - uint32_t indexesVBO; int indexesSize; // amount of memory data allocated for all triangles in bytes // uint32_t ofsIndexes; @@ -2661,11 +2657,9 @@ uint32_t R_VboPackNormal(vec3_t v); void R_VboUnpackTangent(vec4_t v, uint32_t b); void R_VboUnpackNormal(vec3_t v, uint32_t b); -VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, vboUsage_t usage); -VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vertexes, uint32_t stateBits, vboUsage_t usage); +VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage); -IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, vboUsage_t usage); -IBO_t *R_CreateIBO2(const char *name, int numIndexes, glIndex_t * inIndexes, vboUsage_t usage); +IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage); void R_BindVBO(VBO_t * vbo); void R_BindNullVBO(void); diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 7448544fcf..b8c77d8607 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1189,7 +1189,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->minIndex = 0; vboSurf->maxIndex = surf->numVerts; - vboSurf->vbo = R_CreateVBO(va("staticMD3Mesh_VBO '%s'", surf->name), data, dataSize, VBO_USAGE_STATIC); + vboSurf->vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); vboSurf->vbo->ofs_xyz = ofs_xyz; vboSurf->vbo->ofs_normal = ofs_normal; @@ -1210,7 +1210,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN Z_Free(data); - vboSurf->ibo = R_CreateIBO2(va("staticMD3Mesh_IBO %s", surf->name), surf->numIndexes, surf->indexes, VBO_USAGE_STATIC); + vboSurf->ibo = R_CreateIBO ((byte *)surf->indexes, sizeof (glIndex_t) * surf->numIndexes, VBO_USAGE_STATIC); } } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index b22c7a8d5a..35918f4c6f 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -91,106 +91,34 @@ void R_VboUnpackNormal(vec3_t v, uint32_t b) } } -/* -============ -R_CreateVBO -============ -*/ -VBO_t *R_CreateVBO(const char *name, byte * vertexes, int vertexesSize, vboUsage_t usage) +static GLenum GetGLBufferUsage ( vboUsage_t usage ) { - VBO_t *vbo; - int glUsage; - switch (usage) { case VBO_USAGE_STATIC: - glUsage = GL_STATIC_DRAW_ARB; - break; + return GL_STATIC_DRAW_ARB; case VBO_USAGE_DYNAMIC: - glUsage = GL_DYNAMIC_DRAW_ARB; - break; + return GL_DYNAMIC_DRAW_ARB; default: - Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); - return NULL; + ri->Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); + return GL_INVALID_OPERATION; } - - if(strlen(name) >= MAX_QPATH) - { - ri->Error(ERR_DROP, "R_CreateVBO: \"%s\" is too long", name); - } - - if ( tr.numVBOs == MAX_VBOS ) { - ri->Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); - } - - R_IssuePendingRenderCommands(); - - vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri->Hunk_Alloc(sizeof(*vbo), h_low); - tr.numVBOs++; - - memset(vbo, 0, sizeof(*vbo)); - - Q_strncpyz(vbo->name, name, sizeof(vbo->name)); - - vbo->vertexesSize = vertexesSize; - - qglGenBuffersARB(1, &vbo->vertexesVBO); - - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); - qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexesSize, vertexes, glUsage); - - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - - glState.currentVBO = NULL; - - GL_CheckErrors(); - - return vbo; } /* ============ -R_CreateVBO2 +R_CreateVBO ============ */ -VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * verts, unsigned int stateBits, vboUsage_t usage) +VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) { VBO_t *vbo; - int i; - - byte *data; - int dataSize; - int dataOfs; - - int glUsage; - - switch (usage) - { - case VBO_USAGE_STATIC: - glUsage = GL_STATIC_DRAW_ARB; - break; - - case VBO_USAGE_DYNAMIC: - glUsage = GL_DYNAMIC_DRAW_ARB; - break; - - default: - Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); - return NULL; - } - - if(!numVertexes) - return NULL; - - if(strlen(name) >= MAX_QPATH) - { - ri->Error(ERR_DROP, "R_CreateVBO2: \"%s\" is too long", name); - } + int glUsage = GetGLBufferUsage (usage); if ( tr.numVBOs == MAX_VBOS ) { - ri->Error( ERR_DROP, "R_CreateVBO2: MAX_VBOS hit"); + ri->Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); } R_IssuePendingRenderCommands(); @@ -200,287 +128,12 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert memset(vbo, 0, sizeof(*vbo)); - Q_strncpyz(vbo->name, name, sizeof(vbo->name)); - - if (usage == VBO_USAGE_STATIC) - { - // since these vertex attributes are never altered, interleave them - vbo->ofs_xyz = 0; - dataSize = sizeof(verts[0].xyz); - - if(stateBits & ATTR_NORMAL) - { - vbo->ofs_normal = dataSize; - dataSize += sizeof(uint32_t); - } - -#ifdef USE_VERT_TANGENT_SPACE - if(stateBits & ATTR_TANGENT) - { - vbo->ofs_tangent = dataSize; - dataSize += sizeof(uint32_t); - } -#endif - - if(stateBits & ATTR_TEXCOORD) - { - vbo->ofs_st = dataSize; - dataSize += sizeof(verts[0].st); - } - - if(stateBits & ATTR_LIGHTCOORD) - { - vbo->ofs_lightmap = dataSize; - dataSize += sizeof(verts[0].lightmap); - } - - if(stateBits & ATTR_COLOR) - { - vbo->ofs_vertexcolor = dataSize; - dataSize += sizeof(verts[0].vertexColors); - } - - if(stateBits & ATTR_LIGHTDIRECTION) - { - vbo->ofs_lightdir = dataSize; - dataSize += sizeof(uint32_t); - } - - vbo->stride_xyz = dataSize; - vbo->stride_normal = dataSize; -#ifdef USE_VERT_TANGENT_SPACE - vbo->stride_tangent = dataSize; -#endif - vbo->stride_st = dataSize; - vbo->stride_lightmap = dataSize; - vbo->stride_vertexcolor = dataSize; - vbo->stride_lightdir = dataSize; - - // create VBO - dataSize *= numVertexes; - data = (byte *)ri->Hunk_AllocateTempMemory(dataSize); - dataOfs = 0; - - //ri->Printf(PRINT_ALL, "CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, - //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); - - for (i = 0; i < numVertexes; i++) - { - // xyz - memcpy(data + dataOfs, &verts[i].xyz, sizeof(verts[i].xyz)); - dataOfs += sizeof(verts[i].xyz); - - // normal - if(stateBits & ATTR_NORMAL) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackNormal(verts[i].normal); - - dataOfs += sizeof(uint32_t); - } - -#ifdef USE_VERT_TANGENT_SPACE - // tangent - if(stateBits & ATTR_TANGENT) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackTangent(verts[i].tangent); - - dataOfs += sizeof(uint32_t); - } -#endif - - // vertex texcoords - if(stateBits & ATTR_TEXCOORD) - { - memcpy(data + dataOfs, &verts[i].st, sizeof(verts[i].st)); - dataOfs += sizeof(verts[i].st); - } - - // feed vertex lightmap texcoords - if(stateBits & ATTR_LIGHTCOORD) - { - memcpy(data + dataOfs, &verts[i].lightmap, sizeof(verts[i].lightmap)); - dataOfs += sizeof(verts[i].lightmap); - } - - // feed vertex colors - if(stateBits & ATTR_COLOR) - { - memcpy(data + dataOfs, &verts[i].vertexColors, sizeof(verts[i].vertexColors)); - dataOfs += sizeof(verts[i].vertexColors); - } - - // feed vertex light directions - if(stateBits & ATTR_LIGHTDIRECTION) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackNormal(verts[i].lightdir); - - dataOfs += sizeof(uint32_t); - } - } - } - else - { - // since these vertex attributes may be changed, put them in flat arrays - dataSize = sizeof(verts[0].xyz); - - if(stateBits & ATTR_NORMAL) - { - dataSize += sizeof(uint32_t); - } - -#ifdef USE_VERT_TANGENT_SPACE - if(stateBits & ATTR_TANGENT) - { - dataSize += sizeof(uint32_t); - } -#endif - - if(stateBits & ATTR_TEXCOORD) - { - dataSize += sizeof(verts[0].st); - } - - if(stateBits & ATTR_LIGHTCOORD) - { - dataSize += sizeof(verts[0].lightmap); - } - - if(stateBits & ATTR_COLOR) - { - dataSize += sizeof(verts[0].vertexColors); - } - - if(stateBits & ATTR_LIGHTDIRECTION) - { - dataSize += sizeof(uint32_t); - } - - // create VBO - dataSize *= numVertexes; - data = (byte *)ri->Hunk_AllocateTempMemory(dataSize); - dataOfs = 0; - - vbo->ofs_xyz = 0; - vbo->ofs_normal = 0; -#ifdef USE_VERT_TANGENT_SPACE - vbo->ofs_tangent = 0; -#endif - vbo->ofs_st = 0; - vbo->ofs_lightmap = 0; - vbo->ofs_vertexcolor = 0; - vbo->ofs_lightdir = 0; - - vbo->stride_xyz = sizeof(verts[0].xyz); - vbo->stride_normal = sizeof(uint32_t); -#ifdef USE_VERT_TANGENT_SPACE - vbo->stride_tangent = sizeof(uint32_t); -#endif - vbo->stride_vertexcolor = sizeof(verts[0].vertexColors); - vbo->stride_st = sizeof(verts[0].st); - vbo->stride_lightmap = sizeof(verts[0].lightmap); - vbo->stride_lightdir = sizeof(uint32_t); - - //ri->Printf(PRINT_ALL, "2CreateVBO: %d, %d %d %d %d %d, %d %d %d %d %d\n", dataSize, vbo->ofs_xyz, vbo->ofs_normal, vbo->ofs_st, vbo->ofs_lightmap, vbo->ofs_vertexcolor, - //vbo->stride_xyz, vbo->stride_normal, vbo->stride_st, vbo->stride_lightmap, vbo->stride_vertexcolor); - - // xyz - for (i = 0; i < numVertexes; i++) - { - memcpy(data + dataOfs, &verts[i].xyz, sizeof(verts[i].xyz)); - dataOfs += sizeof(verts[i].xyz); - } - - // normal - if(stateBits & ATTR_NORMAL) - { - vbo->ofs_normal = dataOfs; - for (i = 0; i < numVertexes; i++) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackNormal(verts[i].normal); - - dataOfs += sizeof(uint32_t); - } - } - -#ifdef USE_VERT_TANGENT_SPACE - // tangent - if(stateBits & ATTR_TANGENT) - { - vbo->ofs_tangent = dataOfs; - for (i = 0; i < numVertexes; i++) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackTangent(verts[i].tangent); - - dataOfs += sizeof(uint32_t); - } - } -#endif - - // vertex texcoords - if(stateBits & ATTR_TEXCOORD) - { - vbo->ofs_st = dataOfs; - for (i = 0; i < numVertexes; i++) - { - memcpy(data + dataOfs, &verts[i].st, sizeof(verts[i].st)); - dataOfs += sizeof(verts[i].st); - } - } - - // feed vertex lightmap texcoords - if(stateBits & ATTR_LIGHTCOORD) - { - vbo->ofs_lightmap = dataOfs; - for (i = 0; i < numVertexes; i++) - { - memcpy(data + dataOfs, &verts[i].lightmap, sizeof(verts[i].lightmap)); - dataOfs += sizeof(verts[i].lightmap); - } - } - - // feed vertex colors - if(stateBits & ATTR_COLOR) - { - vbo->ofs_vertexcolor = dataOfs; - for (i = 0; i < numVertexes; i++) - { - memcpy(data + dataOfs, &verts[i].vertexColors, sizeof(verts[i].vertexColors)); - dataOfs += sizeof(verts[i].vertexColors); - } - } - - // feed vertex lightdirs - if(stateBits & ATTR_LIGHTDIRECTION) - { - vbo->ofs_lightdir = dataOfs; - for (i = 0; i < numVertexes; i++) - { - uint32_t *p = (uint32_t *)(data + dataOfs); - - *p = R_VboPackNormal(verts[i].lightdir); - - dataOfs += sizeof(uint32_t); - } - } - } - - - vbo->vertexesSize = dataSize; + vbo->vertexesSize = vertexesSize; qglGenBuffersARB(1, &vbo->vertexesVBO); qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); - qglBufferDataARB(GL_ARRAY_BUFFER_ARB, dataSize, data, glUsage); + qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexesSize, vertexes, glUsage); qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); @@ -488,41 +141,18 @@ VBO_t *R_CreateVBO2(const char *name, int numVertexes, srfVert_t * vert GL_CheckErrors(); - ri->Hunk_FreeTempMemory(data); - return vbo; } - /* ============ R_CreateIBO ============ */ -IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, vboUsage_t usage) +IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) { IBO_t *ibo; - int glUsage; - - switch (usage) - { - case VBO_USAGE_STATIC: - glUsage = GL_STATIC_DRAW_ARB; - break; - - case VBO_USAGE_DYNAMIC: - glUsage = GL_DYNAMIC_DRAW_ARB; - break; - - default: - Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); - return NULL; - } - - if(strlen(name) >= MAX_QPATH) - { - ri->Error(ERR_DROP, "R_CreateIBO: \"%s\" is too long", name); - } + int glUsage = GetGLBufferUsage (usage); if ( tr.numIBOs == MAX_IBOS ) { ri->Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); @@ -533,81 +163,6 @@ IBO_t *R_CreateIBO(const char *name, byte * indexes, int indexesSize, v ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); tr.numIBOs++; - Q_strncpyz(ibo->name, name, sizeof(ibo->name)); - - ibo->indexesSize = indexesSize; - - qglGenBuffersARB(1, &ibo->indexesVBO); - - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexesSize, indexes, glUsage); - - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); - - glState.currentIBO = NULL; - - GL_CheckErrors(); - - return ibo; -} - -/* -============ -R_CreateIBO2 -============ -*/ -IBO_t *R_CreateIBO2(const char *name, int numIndexes, glIndex_t * inIndexes, vboUsage_t usage) -{ - IBO_t *ibo; - int i; - - glIndex_t *indexes; - int indexesSize; - - int glUsage; - - switch (usage) - { - case VBO_USAGE_STATIC: - glUsage = GL_STATIC_DRAW_ARB; - break; - - case VBO_USAGE_DYNAMIC: - glUsage = GL_DYNAMIC_DRAW_ARB; - break; - - default: - Com_Error(ERR_FATAL, "bad vboUsage_t given: %i", usage); - return NULL; - } - - if(!numIndexes) - return NULL; - - if(strlen(name) >= MAX_QPATH) - { - ri->Error(ERR_DROP, "R_CreateIBO2: \"%s\" is too long", name); - } - - if ( tr.numIBOs == MAX_IBOS ) { - ri->Error( ERR_DROP, "R_CreateIBO2: MAX_IBOS hit"); - } - - R_IssuePendingRenderCommands(); - - ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); - tr.numIBOs++; - - Q_strncpyz(ibo->name, name, sizeof(ibo->name)); - - indexesSize = numIndexes * sizeof(glIndex_t); - indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(indexesSize); - - for(i = 0; i < numIndexes; i++) - { - indexes[i] = inIndexes[i]; - } - ibo->indexesSize = indexesSize; qglGenBuffersARB(1, &ibo->indexesVBO); @@ -621,8 +176,6 @@ IBO_t *R_CreateIBO2(const char *name, int numIndexes, glIndex_t * inInd GL_CheckErrors(); - ri->Hunk_FreeTempMemory(indexes); - return ibo; } @@ -753,7 +306,7 @@ void R_InitVBOs(void) dataSize += sizeof(tess.lightdir[0]); dataSize *= SHADER_MAX_VERTEXES; - tess.vbo = R_CreateVBO("tessVertexArray_VBO", NULL, dataSize, VBO_USAGE_DYNAMIC); + tess.vbo = R_CreateVBO(NULL, dataSize, VBO_USAGE_DYNAMIC); offset = 0; @@ -782,7 +335,7 @@ void R_InitVBOs(void) dataSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; - tess.ibo = R_CreateIBO("tessVertexArray_IBO", NULL, dataSize, VBO_USAGE_DYNAMIC); + tess.ibo = R_CreateIBO(NULL, dataSize, VBO_USAGE_DYNAMIC); R_BindNullVBO(); R_BindNullIBO(); @@ -848,36 +401,42 @@ void R_VBOList_f(void) int vertexesSize = 0; int indexesSize = 0; - ri->Printf(PRINT_ALL, " size name\n"); - ri->Printf(PRINT_ALL, "----------------------------------------------------------\n"); + ri->Printf (PRINT_ALL, " vertex buffers\n"); + ri->Printf (PRINT_ALL, "----------------\n\n"); + + ri->Printf(PRINT_ALL, " id size (MB)\n"); + ri->Printf(PRINT_ALL, "---------------\n"); for(i = 0; i < tr.numVBOs; i++) { vbo = tr.vbos[i]; - ri->Printf(PRINT_ALL, "%d.%02d MB %s\n", vbo->vertexesSize / (1024 * 1024), - (vbo->vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024), vbo->name); + ri->Printf(PRINT_ALL, " %4i %4.2f\n", i, vbo->vertexesSize / (1024.0f * 1024.0f)); vertexesSize += vbo->vertexesSize; } + ri->Printf(PRINT_ALL, " %d total buffers\n", tr.numVBOs); + ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", vertexesSize / (1024.0f * 1024.0f)); + + + ri->Printf (PRINT_ALL, " index buffers\n"); + ri->Printf (PRINT_ALL, "---------------\n\n"); + + ri->Printf(PRINT_ALL, " id size (MB)\n"); + ri->Printf(PRINT_ALL, "---------------\n"); + for(i = 0; i < tr.numIBOs; i++) { ibo = tr.ibos[i]; - ri->Printf(PRINT_ALL, "%d.%02d MB %s\n", ibo->indexesSize / (1024 * 1024), - (ibo->indexesSize % (1024 * 1024)) * 100 / (1024 * 1024), ibo->name); + ri->Printf(PRINT_ALL, " %4i %4.2f\n", i, ibo->indexesSize / (1024.0f * 1024.0f)); indexesSize += ibo->indexesSize; } - ri->Printf(PRINT_ALL, " %i total VBOs\n", tr.numVBOs); - ri->Printf(PRINT_ALL, " %d.%02d MB total vertices memory\n", vertexesSize / (1024 * 1024), - (vertexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); - - ri->Printf(PRINT_ALL, " %i total IBOs\n", tr.numIBOs); - ri->Printf(PRINT_ALL, " %d.%02d MB total triangle indices memory\n", indexesSize / (1024 * 1024), - (indexesSize % (1024 * 1024)) * 100 / (1024 * 1024)); + ri->Printf(PRINT_ALL, " %d total buffers\n", tr.numIBOs); + ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", indexesSize / (1024.0f * 1024.0f)); } @@ -892,7 +451,7 @@ Update the default VBO to replace the client side vertex arrays */ void RB_UpdateVBOs(unsigned int attribBits) { -// GLimp_LogComment("--- RB_UpdateVBOs ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- RB_UpdateVBOs ---\n"); backEnd.pc.c_dynamicVboDraws++; @@ -956,7 +515,6 @@ void RB_UpdateVBOs(unsigned int attribBits) qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); } - } // update the default IBO From ae22f077052ab3a0fa87f67582fea76f0cfb684f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 21 May 2014 21:28:04 +0100 Subject: [PATCH 200/708] [MP] Rend2: Fix multiple lightmaps --- codemp/rd-rend2/glsl/generic_vp.glsl | 2 +- codemp/rd-rend2/glsl/lightall_vp.glsl | 2 +- codemp/rd-rend2/tr_bsp.cpp | 11 ++-- codemp/rd-rend2/tr_glsl.cpp | 85 +++++++++++++++------------ codemp/rd-rend2/tr_local.h | 14 ++--- codemp/rd-rend2/tr_shade.cpp | 75 +++++++++++++++++++++++ codemp/rd-rend2/tr_shader.cpp | 26 ++++---- codemp/rd-rend2/tr_sky.cpp | 6 +- codemp/rd-rend2/tr_surface.cpp | 12 ++-- codemp/rd-rend2/tr_vbo.cpp | 13 ++-- 10 files changed, 167 insertions(+), 79 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index f890af85c1..d80b0d3653 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -122,7 +122,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 { vec2 tex = attr_TexCoord0.st; - if (TCGen == TCGEN_LIGHTMAP) + if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3) { tex = attr_TexCoord1.st; } diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 4a56addae6..9e6b500c2b 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -102,7 +102,7 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 { vec2 tex = attr_TexCoord0.st; - if (TCGen == TCGEN_LIGHTMAP) + if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3) { tex = attr_TexCoord1.st; } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 12fae5fbeb..97db439a2f 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1873,8 +1873,7 @@ struct packedVertex_t #ifdef USE_VERT_TANGENT_SPACE uint32_t tangent; #endif - vec2_t texcoord; - vec2_t lightmapCoords[MAXLIGHTMAPS]; + vec2_t texcoords[1 + MAXLIGHTMAPS]; vec4_t colors[MAXLIGHTMAPS]; uint32_t lightDirection; }; @@ -2051,11 +2050,11 @@ static void R_CreateWorldVBOs(void) #ifdef USE_VERT_TANGENT_SPACE vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); #endif - VectorCopy2 (bspSurf->verts[i].st, vert.texcoord); + VectorCopy2 (bspSurf->verts[i].st, vert.texcoords[0]); for (int j = 0; j < MAXLIGHTMAPS; j++) { - VectorCopy2 (bspSurf->verts[i].lightmap[j], vert.lightmapCoords[j]); + VectorCopy2 (bspSurf->verts[i].lightmap[j], vert.texcoords[1 + j]); } for (int j = 0; j < MAXLIGHTMAPS; j++) @@ -2076,8 +2075,7 @@ static void R_CreateWorldVBOs(void) #ifdef USE_VERT_TANGENT_SPACE vbo->ofs_tangent = offsetof (packedVertex_t, tangent); #endif - vbo->ofs_st = offsetof (packedVertex_t, texcoord); - vbo->ofs_lightmap = offsetof (packedVertex_t, lightmapCoords); + vbo->ofs_st = offsetof (packedVertex_t, texcoords); vbo->ofs_vertexcolor = offsetof (packedVertex_t, colors); vbo->ofs_lightdir = offsetof (packedVertex_t, lightDirection); @@ -2088,7 +2086,6 @@ static void R_CreateWorldVBOs(void) vbo->stride_tangent = packedVertexSize; #endif vbo->stride_st = packedVertexSize; - vbo->stride_lightmap = packedVertexSize; vbo->stride_vertexcolor = packedVertexSize; vbo->stride_lightdir = packedVertexSize; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e57764574a..c769af3b71 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -253,7 +253,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha // va("#ifndef r_NormalScale\n#define r_NormalScale %f\n#endif\n", r_normalScale->value)); - Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846f\n#endif\n"); + Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n"); //Q_strcat(dest, size, va("#ifndef MAX_SHADOWMAPS\n#define MAX_SHADOWMAPS %i\n#endif\n", MAX_SHADOWMAPS)); @@ -535,18 +535,12 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) if(attribs & ATTR_POSITION) qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION, "attr_Position"); - if(attribs & ATTR_TEXCOORD) + if(attribs & ATTR_TEXCOORD0) qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD0, "attr_TexCoord0"); - if(attribs & ATTR_LIGHTCOORD) + if(attribs & ATTR_TEXCOORD1) qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); -// if(attribs & ATTR_TEXCOORD2) -// qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD2, "attr_TexCoord2"); - -// if(attribs & ATTR_TEXCOORD3) -// qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD3, "attr_TexCoord3"); - #ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT) qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); @@ -945,7 +939,7 @@ int GLSL_BeginLoadGPUShaders(void) continue; } - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_NORMAL | ATTR_COLOR; + attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_NORMAL | ATTR_COLOR; extradefines[0] = '\0'; if (i & GENERICDEF_USE_DEFORM_VERTEXES) @@ -978,7 +972,7 @@ int GLSL_BeginLoadGPUShaders(void) if (i & GENERICDEF_USE_LIGHTMAP) { Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - attribs |= ATTR_LIGHTCOORD; + attribs |= ATTR_TEXCOORD1; } if (r_hdr->integer && !glRefConfig.floatLightmap) @@ -991,7 +985,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) { @@ -1005,7 +999,7 @@ int GLSL_BeginLoadGPUShaders(void) continue; } - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (i & FOGDEF_USE_DEFORM_VERTEXES) @@ -1026,7 +1020,7 @@ int GLSL_BeginLoadGPUShaders(void) for (i = 0; i < DLIGHTDEF_COUNT; i++) { - attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) @@ -1052,7 +1046,7 @@ int GLSL_BeginLoadGPUShaders(void) continue; } - attribs = ATTR_POSITION | ATTR_TEXCOORD | ATTR_COLOR | ATTR_NORMAL; + attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_COLOR | ATTR_NORMAL; extradefines[0] = '\0'; @@ -1084,7 +1078,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); if (r_deluxeMapping->integer && !fastLight) Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); - attribs |= ATTR_LIGHTCOORD | ATTR_LIGHTDIRECTION; + attribs |= ATTR_TEXCOORD1 | ATTR_LIGHTDIRECTION; break; case LIGHTDEF_USE_LIGHT_VECTOR: Q_strcat(extradefines, 1024, "#define USE_LIGHT_VECTOR\n"); @@ -1170,7 +1164,7 @@ int GLSL_BeginLoadGPUShaders(void) } } - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; @@ -1190,7 +1184,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) @@ -1199,7 +1193,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) @@ -1208,7 +1202,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) @@ -1219,7 +1213,7 @@ int GLSL_BeginLoadGPUShaders(void) for (i = 0; i < 2; i++) { - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!i) @@ -1232,7 +1226,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (r_shadowFilter->integer >= 1) @@ -1253,7 +1247,7 @@ int GLSL_BeginLoadGPUShaders(void) } - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) @@ -1264,7 +1258,7 @@ int GLSL_BeginLoadGPUShaders(void) for (i = 0; i < 2; i++) { - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (i & 1) @@ -1280,7 +1274,7 @@ int GLSL_BeginLoadGPUShaders(void) } #if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) @@ -1585,7 +1579,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) } #if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD; + attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) @@ -1731,9 +1725,9 @@ void GLSL_VertexAttribsState(uint32_t stateBits) } } - if(diff & ATTR_TEXCOORD) + if(diff & ATTR_TEXCOORD0) { - if(stateBits & ATTR_TEXCOORD) + if(stateBits & ATTR_TEXCOORD0) { GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TEXCOORD )\n"); qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); @@ -1745,9 +1739,9 @@ void GLSL_VertexAttribsState(uint32_t stateBits) } } - if(diff & ATTR_LIGHTCOORD) + if(diff & ATTR_TEXCOORD1) { - if(stateBits & ATTR_LIGHTCOORD) + if(stateBits & ATTR_TEXCOORD1) { GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_LIGHTCOORD )\n"); qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); @@ -1892,6 +1886,25 @@ void GLSL_VertexAttribsState(uint32_t stateBits) glState.vertexAttribsState = stateBits; } +void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) +{ + VBO_t *vbo = glState.currentVBO; + + if ( attribBits & ATTR_TEXCOORD0 ) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + } + + if ( attribBits & ATTR_TEXCOORD1 ) + { + GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); + + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + } +} + void GLSL_VertexAttribPointers(uint32_t attribBits) { qboolean animated; @@ -1923,20 +1936,20 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) glState.vertexAttribPointersSet |= ATTR_POSITION; } - if((attribBits & ATTR_TEXCOORD) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD)) + if((attribBits & ATTR_TEXCOORD0) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD0)) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st)); - glState.vertexAttribPointersSet |= ATTR_TEXCOORD; + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + glState.vertexAttribPointersSet |= ATTR_TEXCOORD0; } - if((attribBits & ATTR_LIGHTCOORD) && !(glState.vertexAttribPointersSet & ATTR_LIGHTCOORD)) + if((attribBits & ATTR_TEXCOORD1) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD1)) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_lightmap, BUFFER_OFFSET(vbo->ofs_lightmap)); - glState.vertexAttribPointersSet |= ATTR_LIGHTCOORD; + qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + glState.vertexAttribPointersSet |= ATTR_TEXCOORD1; } if((attribBits & ATTR_NORMAL) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL) || animated)) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7ba331e0d4..c6c0d810c4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -392,7 +392,6 @@ typedef struct VBO_s uint32_t ofs_xyz; uint32_t ofs_normal; uint32_t ofs_st; - uint32_t ofs_lightmap; uint32_t ofs_vertexcolor; uint32_t ofs_lightdir; #ifdef USE_VERT_TANGENT_SPACE @@ -404,7 +403,6 @@ typedef struct VBO_s uint32_t stride_xyz; uint32_t stride_normal; uint32_t stride_st; - uint32_t stride_lightmap; uint32_t stride_vertexcolor; uint32_t stride_lightdir; #ifdef USE_VERT_TANGENT_SPACE @@ -415,8 +413,6 @@ typedef struct VBO_s uint32_t size_xyz; uint32_t size_normal; - - int attribs; } VBO_t; typedef struct IBO_s @@ -920,8 +916,8 @@ enum enum { ATTR_POSITION = 0x0001, - ATTR_TEXCOORD = 0x0002, - ATTR_LIGHTCOORD = 0x0004, + ATTR_TEXCOORD0 = 0x0002, + ATTR_TEXCOORD1 = 0x0004, ATTR_TANGENT = 0x0008, ATTR_NORMAL = 0x0010, ATTR_COLOR = 0x0020, @@ -937,8 +933,8 @@ enum ATTR_DEFAULT = ATTR_POSITION, ATTR_BITS = ATTR_POSITION | - ATTR_TEXCOORD | - ATTR_LIGHTCOORD | + ATTR_TEXCOORD0 | + ATTR_TEXCOORD1 | ATTR_TANGENT | ATTR_NORMAL | ATTR_COLOR | @@ -1818,6 +1814,7 @@ typedef struct glstate_s { uint32_t vertexAttribsNewFrame; uint32_t vertexAttribsOldFrame; float vertexAttribsInterpolation; + int vertexAttribsTexCoordOffset[2]; qboolean vertexAnimation; qboolean skeletalAnimation; matrix_t *boneMatrices; @@ -2686,6 +2683,7 @@ int GLSL_BeginLoadGPUShaders(void); void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); void GLSL_VertexAttribsState(uint32_t stateBits); +void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ); void GLSL_VertexAttribPointers(uint32_t attribBits); void GLSL_BindProgram(shaderProgram_t * program); void GLSL_BindNullProgram(void); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9956bb2040..dd5a694917 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1119,6 +1119,79 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } +static void UpdateTexCoords ( const shaderStage_t *stage ) +{ + uint32_t updateAttribs = 0; + if ( stage->bundle[0].image[0] != NULL ) + { + switch (stage->bundle[0].tcGen) + { + case TCGEN_LIGHTMAP: + case TCGEN_LIGHTMAP1: + case TCGEN_LIGHTMAP2: + case TCGEN_LIGHTMAP3: + { + int newLightmapIndex = stage->bundle[0].tcGen - TCGEN_LIGHTMAP + 1; + if (newLightmapIndex != glState.vertexAttribsTexCoordOffset[0]) + { + glState.vertexAttribsTexCoordOffset[0] = newLightmapIndex; + updateAttribs |= ATTR_TEXCOORD0; + } + + break; + } + + case TCGEN_TEXTURE: + if (glState.vertexAttribsTexCoordOffset[0] != 0) + { + glState.vertexAttribsTexCoordOffset[0] = 0; + updateAttribs |= ATTR_TEXCOORD0; + } + break; + + default: + break; + } + } + + if ( stage->bundle[TB_LIGHTMAP].image[0] != NULL ) + { + switch (stage->bundle[TB_LIGHTMAP].tcGen) + { + case TCGEN_LIGHTMAP: + case TCGEN_LIGHTMAP1: + case TCGEN_LIGHTMAP2: + case TCGEN_LIGHTMAP3: + { + int newLightmapIndex = stage->bundle[TB_LIGHTMAP].tcGen - TCGEN_LIGHTMAP + 1; + if (newLightmapIndex != glState.vertexAttribsTexCoordOffset[1]) + { + glState.vertexAttribsTexCoordOffset[1] = newLightmapIndex; + updateAttribs |= ATTR_TEXCOORD1; + } + + break; + } + + case TCGEN_TEXTURE: + if (glState.vertexAttribsTexCoordOffset[1] != 0) + { + glState.vertexAttribsTexCoordOffset[1] = 0; + updateAttribs |= ATTR_TEXCOORD1; + } + break; + + default: + break; + } + } + + if ( updateAttribs != 0 ) + { + GLSL_UpdateTexCoordVertexAttribPointers (updateAttribs); + } +} + static void RB_IterateStagesGeneric( shaderCommands_t *input ) { int stage; @@ -1302,6 +1375,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) } } + UpdateTexCoords (pStage); + GL_State( stateBits ); { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index d85658f455..ab8ae5428c 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2251,7 +2251,7 @@ static void ComputeVertexAttribs(void) if (shader.defaultShader) { - shader.vertexAttribs |= ATTR_TEXCOORD; + shader.vertexAttribs |= ATTR_TEXCOORD0; return; } @@ -2264,7 +2264,7 @@ static void ComputeVertexAttribs(void) switch (ds->deformation) { case DEFORM_BULGE: - shader.vertexAttribs |= ATTR_NORMAL | ATTR_TEXCOORD; + shader.vertexAttribs |= ATTR_NORMAL | ATTR_TEXCOORD0; break; case DEFORM_AUTOSPRITE: @@ -2335,13 +2335,13 @@ static void ComputeVertexAttribs(void) switch(pStage->bundle[i].tcGen) { case TCGEN_TEXTURE: - shader.vertexAttribs |= ATTR_TEXCOORD; + shader.vertexAttribs |= ATTR_TEXCOORD0; break; case TCGEN_LIGHTMAP: case TCGEN_LIGHTMAP1: case TCGEN_LIGHTMAP2: case TCGEN_LIGHTMAP3: - shader.vertexAttribs |= ATTR_LIGHTCOORD; + shader.vertexAttribs |= ATTR_TEXCOORD1; break; case TCGEN_ENVIRONMENT_MAPPED: shader.vertexAttribs |= ATTR_NORMAL; @@ -2661,7 +2661,8 @@ static qboolean CollapseStagesToGLSL(void) // if 2+ stages and first stage is lightmap, switch them // this makes it easier for the later bits to process if (stages[0].active && - stages[0].bundle[0].tcGen == TCGEN_LIGHTMAP && + stages[0].bundle[0].tcGen >= TCGEN_LIGHTMAP && + stages[0].bundle[0].tcGen <= TCGEN_LIGHTMAP3 && stages[1].active) { int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2703,7 +2704,8 @@ static qboolean CollapseStagesToGLSL(void) break; } - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && + pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); @@ -2753,7 +2755,7 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) { lightmaps[i] = pStage; } @@ -2816,7 +2818,9 @@ static qboolean CollapseStagesToGLSL(void) break; case ST_COLORMAP: - if (pStage2->bundle[0].tcGen == TCGEN_LIGHTMAP && pStage2->rgbGen != CGEN_EXACT_VERTEX) + if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && + pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && + pStage2->rgbGen != CGEN_EXACT_VERTEX) { ri->Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); lightmap = pStage2; @@ -2861,7 +2865,9 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage->active) continue; - if (pStage->bundle[0].tcGen == TCGEN_LIGHTMAP && lightmaps[i] == NULL) + if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && + pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && + lightmaps[i] == NULL) { pStage->active = qfalse; } @@ -2927,7 +2933,7 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->bundle[TB_DIFFUSEMAP].tcGen == TCGEN_LIGHTMAP) + if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3) { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index e8851cdd86..8488e8bdbf 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -420,12 +420,12 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max tess.maxIndex = tess.numVertexes; // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function - RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD); + RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); /* { shaderProgram_t *sp = &tr.textureColorShader; - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); @@ -441,7 +441,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max shaderProgram_t *sp = &tr.lightallShader[0]; vec4_t vector; - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index d49ec7c80a..3aee826b5f 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -200,9 +200,9 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) tess.minIndex = 0; tess.maxIndex = 3; - RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD); + RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); @@ -411,7 +411,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn } #endif - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { dv = verts; texCoords = tess.texCoords[ tess.numVertexes ][0]; @@ -419,7 +419,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn VectorCopy2(dv->st, texCoords); } - if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD1 ) { dv = verts; lightCoords = tess.texCoords[ tess.numVertexes ][1]; @@ -1863,13 +1863,13 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { *tangent++ = R_VboPackTangent(dv->tangent); } #endif - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD ) + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { VectorCopy2(dv->st, texCoords); texCoords += 4; } - if ( tess.shader->vertexAttribs & ATTR_LIGHTCOORD ) + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD1 ) { VectorCopy2(dv->lightmap[0], lightCoords); lightCoords += 4; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 35918f4c6f..6141238543 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -112,7 +112,7 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) R_CreateVBO ============ */ -VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) +VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) { VBO_t *vbo; int glUsage = GetGLBufferUsage (usage); @@ -149,7 +149,7 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) R_CreateIBO ============ */ -IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) +IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) { IBO_t *ibo; int glUsage = GetGLBufferUsage (usage); @@ -207,6 +207,8 @@ void R_BindVBO(VBO_t * vbo) glState.vertexAttribsInterpolation = 0; glState.vertexAttribsOldFrame = 0; glState.vertexAttribsNewFrame = 0; + glState.vertexAttribsTexCoordOffset[0] = 0; + glState.vertexAttribsTexCoordOffset[1] = 1; glState.vertexAnimation = qfalse; glState.skeletalAnimation = qfalse; @@ -316,9 +318,7 @@ void R_InitVBOs(void) tess.vbo->ofs_tangent = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; #endif // these next two are actually interleaved - tess.vbo->ofs_st = offset; - tess.vbo->ofs_lightmap = offset + sizeof(tess.texCoords[0][0]); - offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; + tess.vbo->ofs_st = offset; offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; tess.vbo->ofs_vertexcolor = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES; tess.vbo->ofs_lightdir = offset; @@ -330,7 +330,6 @@ void R_InitVBOs(void) #endif tess.vbo->stride_vertexcolor = sizeof(tess.vertexColors[0]); tess.vbo->stride_st = sizeof(tess.texCoords[0][0]) * 2; - tess.vbo->stride_lightmap = sizeof(tess.texCoords[0][0]) * 2; tess.vbo->stride_lightdir = sizeof(tess.lightdir[0]); dataSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; @@ -471,7 +470,7 @@ void RB_UpdateVBOs(unsigned int attribBits) qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); } - if(attribBits & ATTR_TEXCOORD || attribBits & ATTR_LIGHTCOORD) + if(attribBits & ATTR_TEXCOORD0 || attribBits & ATTR_TEXCOORD1) { // these are interleaved, so we update both if either need it //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); From 75d9d72900b5cf74bad3ab3f1c34f6335792e900 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 May 2014 17:01:49 +0100 Subject: [PATCH 201/708] [MP] Rend2: Add more counters for dynamic VBO size --- codemp/rd-rend2/tr_cmds.cpp | 5 +++-- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_vbo.cpp | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index e9d35d8940..146a606ed2 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -66,8 +66,9 @@ void R_PerformanceCounters( void ) { } else if (r_speeds->integer == 7 ) { - ri->Printf( PRINT_ALL, "VBO draws: static %i dynamic %i\nMultidraws: %i merged %i\n", - backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged ); + ri->Printf( PRINT_ALL, "VBO draws: static %i dynamic %i (%.2fKB)\nMultidraws: %i merged %i\n", + backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_dynamicVboTotalSize / (1024.0f), + backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged ); ri->Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c6c0d810c4..3ef773f373 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1890,6 +1890,7 @@ typedef struct { int c_staticVboDraws; int c_dynamicVboDraws; + int c_dynamicVboTotalSize; int c_multidraws; int c_multidrawsMerged; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 6141238543..af106f8f00 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -457,6 +457,8 @@ void RB_UpdateVBOs(unsigned int attribBits) // update the default VBO if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) { + backEnd.pc.c_dynamicVboTotalSize += tess.numVertexes * (tess.vbo->vertexesSize / SHADER_MAX_VERTEXES); + R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it From 1972ad7c081f837f6ed0ace04eee68a94f526cef Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 May 2014 17:02:55 +0100 Subject: [PATCH 202/708] [MP] Rend2: Use stream, not dynamic, for VBOs --- codemp/rd-rend2/tr_vbo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index af106f8f00..ea45b4ca94 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -99,7 +99,7 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) return GL_STATIC_DRAW_ARB; case VBO_USAGE_DYNAMIC: - return GL_DYNAMIC_DRAW_ARB; + return GL_STREAM_DRAW_ARB; default: ri->Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); @@ -462,7 +462,7 @@ void RB_UpdateVBOs(unsigned int attribBits) R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it - qglBufferDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->vertexesSize, NULL, GL_DYNAMIC_DRAW_ARB); + qglBufferDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->vertexesSize, NULL, GL_STREAM_DRAW_ARB); if(attribBits & ATTR_BITS) { @@ -524,7 +524,7 @@ void RB_UpdateVBOs(unsigned int attribBits) R_BindIBO(tess.ibo); // orphan old buffer so we don't stall on it - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tess.ibo->indexesSize, NULL, GL_DYNAMIC_DRAW_ARB); + qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tess.ibo->indexesSize, NULL, GL_STREAM_DRAW_ARB); qglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); } From a79db581c37668ee2e42d3e193538d3f423b0580 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 May 2014 17:03:29 +0100 Subject: [PATCH 203/708] [MP] Rend2: Uncomment GL log messages --- codemp/rd-rend2/tr_vbo.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index ea45b4ca94..6cc23d302a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -193,11 +193,10 @@ void R_BindVBO(VBO_t * vbo) return; } -/* if(r_logFile->integer) + if(r_logFile->integer) { - // don't just call LogComment, or we will get a call to va() every frame! - GLimp_LogComment(va("--- R_BindVBO( %s ) ---\n", vbo->name)); - } */ // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- R_BindVBO() ---\n"); + } if(glState.currentVBO != vbo) { @@ -225,7 +224,7 @@ R_BindNullVBO */ void R_BindNullVBO(void) { -// GLimp_LogComment("--- R_BindNullVBO ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- R_BindNullVBO ---\n"); if(glState.currentVBO) { @@ -250,11 +249,10 @@ void R_BindIBO(IBO_t * ibo) return; } -/* if(r_logFile->integer) + if(r_logFile->integer) { - // don't just call LogComment, or we will get a call to va() every frame! - GLimp_LogComment(va("--- R_BindIBO( %s ) ---\n", ibo->name)); - } */ // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- R_BindIBO() ---\n"); + } if(glState.currentIBO != ibo) { @@ -273,7 +271,7 @@ R_BindNullIBO */ void R_BindNullIBO(void) { -// GLimp_LogComment("--- R_BindNullIBO ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- R_BindNullIBO ---\n"); if(glState.currentIBO) { From 19566591ed346bb9613169db4fd9f6345c07699e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 26 May 2014 21:09:50 +0100 Subject: [PATCH 204/708] [MP] Rend2: Set draw buffers to use on FBO init --- codemp/rd-rend2/tr_fbo.cpp | 62 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 08495f8098..e55e38716d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -38,9 +38,10 @@ qboolean R_CheckFBO(const FBO_t * fbo) code = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); + if(code == GL_FRAMEBUFFER_COMPLETE_EXT) { - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); return qtrue; } @@ -91,8 +92,6 @@ qboolean R_CheckFBO(const FBO_t * fbo) break; } - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); - return qfalse; } @@ -302,6 +301,35 @@ void FBO_AttachTextureImage(image_t *img, int index) glState.currentFBO->colorImage[index] = img; } +static void FBO_SetupDrawBuffers() +{ + if (!glState.currentFBO) + { + ri->Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); + return; + } + + FBO_t *currentFBO = glState.currentFBO; + int numBuffers = 0; + GLenum bufs[8]; + + while ( currentFBO->colorBuffers[numBuffers++] != 0 ); + + if ( numBuffers == 0 ) + { + qglDrawBuffer (GL_NONE); + } + else + { + for ( int i = 0; i < numBuffers; i++ ) + { + bufs[i] = GL_COLOR_ATTACHMENT0 + i; + } + + qglDrawBuffersARB (numBuffers, bufs); + } +} + /* ============ FBO_Bind @@ -414,6 +442,8 @@ void FBO_Init(void) FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, multisample); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.renderFbo); @@ -426,6 +456,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.msaaResolveFbo); } else if (r_hdr->integer) @@ -439,6 +471,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.renderFbo); } @@ -461,6 +495,8 @@ void FBO_Init(void) R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.sunRaysFbo); } @@ -479,6 +515,8 @@ void FBO_Init(void) FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24_ARB, 0, 0); //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.pshadowFbos[i]); } } @@ -499,6 +537,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.sunShadowFbo[i]); } @@ -507,6 +547,8 @@ void FBO_Init(void) FBO_AttachTextureImage(tr.screenShadowImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.screenShadowFbo); } @@ -518,6 +560,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.textureScratchFbo[i], GL_RGBA8, 0, 0); FBO_AttachTextureImage(tr.textureScratchImage[i], 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.textureScratchFbo[i]); } @@ -528,6 +572,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.calcLevelsFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.calcLevelsImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.calcLevelsFbo); } @@ -538,6 +584,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.targetLevelsFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.targetLevelsImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.targetLevelsFbo); } @@ -549,6 +597,8 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.quarterFbo[i], hdrFormat, 0, 0); FBO_AttachTextureImage(tr.quarterImage[i], 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.quarterFbo[i]); } @@ -559,6 +609,8 @@ void FBO_Init(void) FBO_AttachTextureImage(tr.hdrDepthImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.hdrDepthFbo); tr.screenSsaoFbo = FBO_Create("_screenssao", tr.screenSsaoImage->width, tr.screenSsaoImage->height); @@ -566,6 +618,8 @@ void FBO_Init(void) FBO_AttachTextureImage(tr.screenSsaoImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.screenSsaoFbo); } @@ -580,6 +634,8 @@ void FBO_Init(void) FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.renderCubeFbo); } From 8e6d68aa2fd56191458715f10355c2da2e6d13bc Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 28 May 2014 19:40:05 +0100 Subject: [PATCH 205/708] [MP] Rend2: Render glow stages to a different RT. Glow stages are now rendered using MRT, into color attachment 1. The attachment still needs to be cleared to black before rendering. --- codemp/rd-rend2/glsl/generic_fp.glsl | 7 +++++++ codemp/rd-rend2/glsl/lightall_fp.glsl | 7 +++++++ codemp/rd-rend2/tr_backend.cpp | 9 +++++++++ codemp/rd-rend2/tr_fbo.cpp | 13 ++++++++++--- codemp/rd-rend2/tr_glsl.cpp | 10 ++++++++-- codemp/rd-rend2/tr_image.cpp | 3 +++ codemp/rd-rend2/tr_init.cpp | 26 ++++++++++++++++++-------- codemp/rd-rend2/tr_local.h | 22 +++++++++++++++++----- codemp/rd-rend2/tr_shader.cpp | 8 +++++++- 9 files changed, 86 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index aefa33c3fa..4f7922a02b 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -14,6 +14,7 @@ varying vec2 var_LightTex; varying vec4 var_Color; +layout(location = 1) out vec4 out_Glow; void main() { @@ -42,4 +43,10 @@ void main() #endif gl_FragColor = color * var_Color; + +#if defined(USE_GLOW_BUFFER) + out_Glow = gl_FragColor; +#else + out_Glow = vec4(0.0); +#endif } diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index cdcc96db6e..4687e99bde 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -74,6 +74,7 @@ varying vec4 var_LightDir; varying vec4 var_PrimaryLightDir; #endif +layout(location = 1) out vec4 out_Glow; #define EPSILON 0.00000001 @@ -478,4 +479,10 @@ void main() #endif gl_FragColor.a = diffuse.a * var_Color.a; + +#if defined(USE_GLOW_BUFFER) + out_Glow = gl_FragColor; +#else + out_Glow = vec4(0.0); +#endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 7e6a3e29af..3c3662e94f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -493,6 +493,7 @@ void RB_BeginDrawingView (void) { { clearBits |= GL_STENCIL_BUFFER_BIT; } + if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) { clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used @@ -1933,6 +1934,14 @@ const void *RB_PostProcess(const void *data) } #endif +// Debug output for dynamic glow + if (r_dynamicGlow->integer == 2) + { + vec2_t invert = {1.0f, -1.0f}; + FBO_BlitFromTexture (tr.glowImage, NULL, invert, tr.screenShadowFbo, NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + FBO_FastBlit (tr.screenShadowFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } + backEnd.framePostProcessed = qtrue; return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index e55e38716d..fa38caf851 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -299,6 +299,7 @@ void FBO_AttachTextureImage(image_t *img, int index) R_AttachFBOTexture2D(GL_TEXTURE_2D, img->texnum, index); glState.currentFBO->colorImage[index] = img; + glState.currentFBO->colorBuffers[index] = img->texnum; } static void FBO_SetupDrawBuffers() @@ -313,7 +314,10 @@ static void FBO_SetupDrawBuffers() int numBuffers = 0; GLenum bufs[8]; - while ( currentFBO->colorBuffers[numBuffers++] != 0 ); + while ( currentFBO->colorBuffers[numBuffers] != 0 ) + { + numBuffers++; + } if ( numBuffers == 0 ) { @@ -323,7 +327,7 @@ static void FBO_SetupDrawBuffers() { for ( int i = 0; i < numBuffers; i++ ) { - bufs[i] = GL_COLOR_ATTACHMENT0 + i; + bufs[i] = GL_COLOR_ATTACHMENT0_EXT + i; } qglDrawBuffersARB (numBuffers, bufs); @@ -460,7 +464,7 @@ void FBO_Init(void) R_CheckFBO(tr.msaaResolveFbo); } - else if (r_hdr->integer) + else { tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); FBO_Bind(tr.renderFbo); @@ -468,6 +472,9 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.renderImage, 0); + if (r_dynamicGlow->integer) + FBO_AttachTextureImage(tr.glowImage, 1); + //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c769af3b71..ff93e208c3 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -224,7 +224,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha // HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30)) { - Q_strcat(dest, size, "#version 130\n"); + Q_strcat(dest, size, "#version 330 core\n"); if(shaderType == GL_VERTEX_SHADER_ARB) { @@ -235,7 +235,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha { Q_strcat(dest, size, "#define varying in\n"); - Q_strcat(dest, size, "out vec4 out_Color;\n"); + Q_strcat(dest, size, "layout(location = 0) out vec4 out_Color;\n"); Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); } } @@ -975,6 +975,9 @@ int GLSL_BeginLoadGPUShaders(void) attribs |= ATTR_TEXCOORD1; } + if (i & GENERICDEF_USE_GLOW_BUFFER) + Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); + if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); @@ -1158,6 +1161,9 @@ int GLSL_BeginLoadGPUShaders(void) #endif } + if (i & LIGHTDEF_USE_GLOW_BUFFER) + Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); + if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 0456dc4936..de5d64e209 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2857,6 +2857,9 @@ void R_CreateBuiltinImages( void ) { tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + if (r_dynamicGlow->integer) + tr.glowImage = R_CreateImage("_glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + if (r_drawSunRays->integer) tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 7bd2f4ef25..cd70dfddc1 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -223,9 +223,6 @@ cvar_t *r_debugSort; cvar_t *r_printShaders; cvar_t *r_saveFontData; -/* -Ghoul2 Insert Start -*/ #ifdef _DEBUG cvar_t *r_noPrecacheGLA; #endif @@ -253,10 +250,6 @@ cvar_t *broadsword_effcorr=0; cvar_t *broadsword_ragtobase=0; cvar_t *broadsword_dircap=0; -/* -Ghoul2 Insert End -*/ - cvar_t *r_marksOnTriangleMeshes; cvar_t *r_aviMotionJpegQuality; @@ -267,6 +260,13 @@ int max_polys; cvar_t *r_maxpolyverts; int max_polyverts; +cvar_t *r_dynamicGlow; +cvar_t *r_dynamicGlowPasses; +cvar_t *r_dynamicGlowDelta; +cvar_t *r_dynamicGlowIntensity; +cvar_t *r_dynamicGlowSoft; +cvar_t *r_dynamicGlowWidth; +cvar_t *r_dynamicGlowHeight; extern void RB_SetGL2D (void); void R_Splash() @@ -1056,7 +1056,7 @@ void R_PrintLongString(const char *string) { GfxInfo_f ================ */ -void GfxInfo_f( void ) +static void GfxInfo_f( void ) { const char *enablestrings[] = { @@ -1113,6 +1113,8 @@ void GfxInfo_f( void ) if ( r_finish->integer ) { ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); } + + ri->Printf( PRINT_ALL, "Dynamic Glow: %s\n", enablestrings[r_dynamicGlow->integer != 0] ); } /* @@ -1200,6 +1202,14 @@ void R_Register( void ) r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE ); + r_dynamicGlow = ri->Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE ); + r_dynamicGlowPasses = ri->Cvar_Get( "r_dynamicGlowPasses", "5", CVAR_ARCHIVE ); + r_dynamicGlowDelta = ri->Cvar_Get( "r_dynamicGlowDelta", "0.8f", CVAR_ARCHIVE ); + r_dynamicGlowIntensity = ri->Cvar_Get( "r_dynamicGlowIntensity", "1.13f", CVAR_ARCHIVE ); + r_dynamicGlowSoft = ri->Cvar_Get( "r_dynamicGlowSoft", "1", CVAR_ARCHIVE ); + r_dynamicGlowWidth = ri->Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH ); + r_dynamicGlowHeight = ri->Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH ); + r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3ef773f373..6be77e9407 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -680,6 +680,8 @@ typedef enum typedef struct { qboolean active; + qboolean isDetail; + qboolean glow; textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; @@ -695,7 +697,6 @@ typedef struct { acff_t adjustColorsForFog; - qboolean isDetail; int lightmapStyle; stageType_t type; @@ -956,8 +957,9 @@ enum GENERICDEF_USE_RGBAGEN = 0x0010, GENERICDEF_USE_LIGHTMAP = 0x0020, GENERICDEF_USE_SKELETAL_ANIMATION = 0x0040, - GENERICDEF_ALL = 0x007F, - GENERICDEF_COUNT = 0x0080, + GENERICDEF_USE_GLOW_BUFFER = 0x0080, + GENERICDEF_ALL = 0x00FF, + GENERICDEF_COUNT = 0x0100, }; enum @@ -988,8 +990,9 @@ enum LIGHTDEF_USE_SHADOWMAP = 0x0020, LIGHTDEF_USE_VERTEX_ANIMATION= 0x0040, LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0080, - LIGHTDEF_ALL = 0x00FF, - LIGHTDEF_COUNT = 0x0100 + LIGHTDEF_USE_GLOW_BUFFER = 0x0100, + LIGHTDEF_ALL = 0x01FF, + LIGHTDEF_COUNT = 0x0200 }; enum @@ -1975,6 +1978,7 @@ typedef struct trGlobals_s { image_t *renderImage; + image_t *glowImage; image_t *sunRaysImage; image_t *renderDepthImage; image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; @@ -2304,6 +2308,14 @@ extern cvar_t *r_printShaders; extern cvar_t *r_marksOnTriangleMeshes; +extern cvar_t *r_dynamicGlow; +extern cvar_t *r_dynamicGlowPasses; +extern cvar_t *r_dynamicGlowDelta; +extern cvar_t *r_dynamicGlowIntensity; +extern cvar_t *r_dynamicGlowSoft; +extern cvar_t *r_dynamicGlowWidth; +extern cvar_t *r_dynamicGlowHeight; + //==================================================================== void R_SwapBuffers( int ); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ab8ae5428c..659675d666 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1431,7 +1431,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // If this stage has glow... GLOWXXX else if ( Q_stricmp( token, "glow" ) == 0 ) { - //stage->glow = true; + stage->glow = qtrue; continue; } @@ -2621,6 +2621,9 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; } + if (diffuse->glow) + defs |= LIGHTDEF_USE_GLOW_BUFFER; + //ri->Printf(PRINT_ALL, ".\n"); diffuse->glslShaderGroup = tr.lightallShader; @@ -2793,6 +2796,9 @@ static qboolean CollapseStagesToGLSL(void) if (!pStage2->active) continue; + if (pStage2->glow) + continue; + switch(pStage2->type) { case ST_NORMALMAP: From bf3b9f1cf69f102b9fd96b1a04a9d11b1cd84054 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 28 May 2014 21:43:00 +0100 Subject: [PATCH 206/708] [MP] Rend2: Clear glow buffer to black --- codemp/rd-rend2/qgl.h | 2 ++ codemp/rd-rend2/tr_backend.cpp | 20 +++++++++++++------- codemp/rd-rend2/tr_extensions.cpp | 5 +++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 091e571615..ac8e91707a 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -1304,6 +1304,8 @@ extern PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB; extern PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB; extern PFNGLISPROGRAMARBPROC qglIsProgramARB; +extern PFNGLCLEARBUFFERFVPROC qglClearBufferfv; + /* ** extension constants diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3c3662e94f..13fcdbe5f3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -520,6 +520,13 @@ void RB_BeginDrawingView (void) { qglClear( clearBits ); + if (backEnd.viewParms.targetFbo == NULL) + { + // Clear the glow target + float black[] = {0.0f, 0.0f, 0.0f, 1.0f}; + qglClearBufferfv (GL_COLOR, 1, black); + } + if ( ( backEnd.refdef.rdflags & RDF_HYPERSPACE ) ) { RB_Hyperspace(); @@ -1934,13 +1941,12 @@ const void *RB_PostProcess(const void *data) } #endif -// Debug output for dynamic glow - if (r_dynamicGlow->integer == 2) - { - vec2_t invert = {1.0f, -1.0f}; - FBO_BlitFromTexture (tr.glowImage, NULL, invert, tr.screenShadowFbo, NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - FBO_FastBlit (tr.screenShadowFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } + // Debug output for dynamic glow + if (r_dynamicGlow->integer == 2) + { + FBO_BlitFromTexture (tr.glowImage, NULL, NULL, tr.screenShadowFbo, NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + FBO_FastBlit (tr.screenShadowFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } backEnd.framePostProcessed = qtrue; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 496a3dc23b..d8af171882 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -181,6 +181,9 @@ void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei sa // GL_ARB_draw_buffers void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); +// OpenGL 3.0 +PFNGLCLEARBUFFERFVPROC qglClearBufferfv; + static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); @@ -730,4 +733,6 @@ void GLimp_InitExtraExtensions() // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer && r_hdr->integer); + + qglClearBufferfv = (PFNGLCLEARBUFFERFVPROC)GL_GetProcAddress ("glClearBufferfv"); } From 3dad5197053af49a92069866dfbd9a3ddb787150 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 28 May 2014 21:43:27 +0100 Subject: [PATCH 207/708] [MP] Rend2: Fix render saber to glow buffer bug Sabers and other surfaces which used the generic shader and had glow stages weren't being added to the glow buffer. This commit corrects this issue. --- codemp/rd-rend2/tr_glsl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ff93e208c3..cf2918322d 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2096,5 +2096,10 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; } + if (pStage->glow) + { + shaderAttribs |= GENERICDEF_USE_GLOW_BUFFER; + } + return &tr.genericShader[shaderAttribs]; } From 3618709d602c9e5d787b6d52e3b0c32fcda0c7ab Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 1 Jun 2014 18:54:37 +0100 Subject: [PATCH 208/708] [MP] Rend2: Prelim implementation of dynamic glow --- codemp/rd-rend2/glsl/gaussian_blur_fp.glsl | 48 +++++++++++++++++++ codemp/rd-rend2/glsl/gaussian_blur_vp.glsl | 21 +++++++++ codemp/rd-rend2/tr_backend.cpp | 54 +++++++++++++++++++--- codemp/rd-rend2/tr_fbo.cpp | 21 +++++++-- codemp/rd-rend2/tr_glsl.cpp | 35 ++++++++++++++ codemp/rd-rend2/tr_image.cpp | 7 ++- codemp/rd-rend2/tr_local.h | 4 ++ codemp/rd-rend2/tr_postprocess.cpp | 47 ++++--------------- codemp/rd-rend2/tr_postprocess.h | 4 +- 9 files changed, 190 insertions(+), 51 deletions(-) create mode 100644 codemp/rd-rend2/glsl/gaussian_blur_fp.glsl create mode 100644 codemp/rd-rend2/glsl/gaussian_blur_vp.glsl diff --git a/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl b/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl new file mode 100644 index 0000000000..6916888f34 --- /dev/null +++ b/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl @@ -0,0 +1,48 @@ +uniform sampler2D u_TextureMap; + +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; +varying vec2 var_TexCoords; + +#define NUM_TAPS 3 + +void main() +{ + vec4 color = vec4 (0.0); + +#if NUM_TAPS == 7 + const float weights[] = float[4](1.0 / 64.0, 6.0 / 64.0, 15.0 / 64.0, 20.0 / 64.0); + +#if defined(BLUR_X) + color += texture2D (u_TextureMap, vec2 (-3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture2D (u_TextureMap, vec2 (-2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture2D (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; + color += texture2D (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture2D (u_TextureMap, vec2 ( 2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 ( 3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; +#else + color += texture2D (u_TextureMap, vec2 (0.0, -3.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture2D (u_TextureMap, vec2 (0.0, -2.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture2D (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; + color += texture2D (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture2D (u_TextureMap, vec2 (0.0, 2.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 (0.0, 3.0) * u_InvTexRes + var_TexCoords) * weights[0]; +#endif +#elif NUM_TAPS == 3 + const float weights[] = float[2](0.25, 0.5); + +#if defined(BLUR_X) + color += texture2D (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture2D (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; +#else + color += texture2D (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture2D (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture2D (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[0]; +#endif +#endif + + gl_FragColor = color * u_Color; +} \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl b/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl new file mode 100644 index 0000000000..7b4ff290fa --- /dev/null +++ b/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl @@ -0,0 +1,21 @@ +varying vec2 var_TexCoords; + +void main() +{ + const vec2 positions[4] = vec2[]( + vec2 (-1.0, -1.0), + vec2 (1.0, -1.0), + vec2 (1.0, 1.0), + vec2 (-1.0, 1.0) + ); + + const vec2 texcoords[4] = vec2[]( + vec2 (0.0, 0.0), + vec2 (1.0, 0.0), + vec2 (1.0, 1.0), + vec2 (0.0, 1.0) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 13fcdbe5f3..bbb3c48e0c 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1862,6 +1862,32 @@ const void *RB_PostProcess(const void *data) FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); } + if (r_dynamicGlow->integer) + { + // Downscale 8x + FBO_BlitFromTexture (tr.glowImage, NULL, NULL, tr.glowFboScaled[0], NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + FBO_FastBlit (tr.glowFboScaled[0], NULL, tr.glowFboScaled[1], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_FastBlit (tr.glowFboScaled[1], NULL, tr.glowFboScaled[2], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + // Blur a few times + float spread = 1.0f; + for ( int i = 0, numPasses = r_dynamicGlowPasses->integer; i < numPasses; i++ ) + { + RB_GaussianBlur (tr.glowFboScaled[2], tr.glowFboScaled[3], tr.glowFboScaled[2], spread); + + spread += r_dynamicGlowDelta->value * 0.25f; + } + + // Upscale 4x + qglScissor (0, 0, tr.glowFboScaled[1]->width, tr.glowFboScaled[1]->height); + FBO_FastBlit (tr.glowFboScaled[2], NULL, tr.glowFboScaled[1], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + qglScissor (0, 0, tr.glowFboScaled[0]->width, tr.glowFboScaled[0]->height); + FBO_FastBlit (tr.glowFboScaled[1], NULL, tr.glowFboScaled[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + + // Restore scissor rect + qglScissor (0, 0, glConfig.vidWidth, glConfig.vidHeight); + } srcBox[0] = backEnd.viewParms.viewportX; srcBox[1] = backEnd.viewParms.viewportY; srcBox[2] = backEnd.viewParms.viewportWidth; @@ -1896,8 +1922,6 @@ const void *RB_PostProcess(const void *data) if (1) RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); - else - RB_GaussianBlur(backEnd.refdef.blurFactor); if (0 && r_sunlightMode->integer) { @@ -1941,11 +1965,29 @@ const void *RB_PostProcess(const void *data) } #endif - // Debug output for dynamic glow - if (r_dynamicGlow->integer == 2) + if (r_dynamicGlow->integer != 0) { - FBO_BlitFromTexture (tr.glowImage, NULL, NULL, tr.screenShadowFbo, NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - FBO_FastBlit (tr.screenShadowFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + // Composite the glow/bloom texture + int blendFunc = 0; + vec4_t color = { 1.0f, 1.0f, 1.0f, 1.0f }; + + if ( r_dynamicGlow->integer == 2 ) + { + // Debug output + blendFunc = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO; + } + else if ( r_dynamicGlowSoft->integer ) + { + blendFunc = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE_MINUS_SRC_COLOR; + color[0] = color[1] = color[2] = r_dynamicGlowIntensity->value; + } + else + { + blendFunc = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; + color[0] = color[1] = color[2] = r_dynamicGlowIntensity->value; + } + + FBO_BlitFromTexture (tr.glowFboScaled[0]->colorImage[0], NULL, NULL, NULL, NULL, NULL, color, blendFunc); } backEnd.framePostProcessed = qtrue; diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index fa38caf851..cd37e526f2 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -450,7 +450,6 @@ void FBO_Init(void) R_CheckFBO(tr.renderFbo); - tr.msaaResolveFbo = FBO_Create("_msaaResolve", tr.renderDepthImage->width, tr.renderDepthImage->height); FBO_Bind(tr.msaaResolveFbo); @@ -471,9 +470,7 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.renderImage, 0); - - if (r_dynamicGlow->integer) - FBO_AttachTextureImage(tr.glowImage, 1); + FBO_AttachTextureImage(tr.glowImage, 1); //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); @@ -493,6 +490,22 @@ void FBO_Init(void) FBO_Bind(NULL); } + // glow buffers + { + for ( int i = 0; i < ARRAY_LEN(tr.glowImageScaled); i++ ) + { + tr.glowFboScaled[i] = FBO_Create (va ("*glowScaled%d", i), tr.glowImageScaled[i]->width, tr.glowImageScaled[i]->height); + + FBO_Bind (tr.glowFboScaled[i]); + + FBO_AttachTextureImage (tr.glowImageScaled[i], 0); + + FBO_SetupDrawBuffers(); + + R_CheckFBO (tr.glowFboScaled[i]); + } + } + if (r_drawSunRays->integer) { tr.sunRaysFbo = FBO_Create("_sunRays", tr.renderDepthImage->width, tr.renderDepthImage->height); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index cf2918322d..c3a7e50b67 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -52,6 +52,8 @@ extern const char *fallbackShader_texturecolor_vp; extern const char *fallbackShader_texturecolor_fp; extern const char *fallbackShader_tonemap_vp; extern const char *fallbackShader_tonemap_fp; +extern const char *fallbackShader_gaussian_blur_vp; +extern const char *fallbackShader_gaussian_blur_fp; typedef struct uniformInfo_s { @@ -1299,6 +1301,23 @@ int GLSL_BeginLoadGPUShaders(void) numEtcShaders++; #endif + attribs = 0; + extradefines[0] = '\0'; + Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); + + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, extradefines, qtrue, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + { + ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); + } + + attribs = 0; + extradefines[0] = '\0'; + + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, extradefines, qtrue, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + { + ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); + } + return startTime; } @@ -1584,6 +1603,22 @@ void GLSL_EndLoadGPUShaders ( int startTime ) numEtcShaders++; } + for (i = 0; i < 2; i++) + { + if (!GLSL_EndLoadGPUShader(&tr.gaussianBlurShader[i])) + { + ri->Error(ERR_FATAL, "Could not load gaussian blur shader!"); + } + + GLSL_InitUniforms(&tr.gaussianBlurShader[i]); + +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.gaussianBlurShader[i]); +#endif + + numEtcShaders++; + } + #if 0 attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index de5d64e209..4fa42074b8 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2857,8 +2857,11 @@ void R_CreateBuiltinImages( void ) { tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - if (r_dynamicGlow->integer) - tr.glowImage = R_CreateImage("_glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImage = R_CreateImage("*glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[0] = R_CreateImage("*glowScaled0", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[1] = R_CreateImage("*glowScaled1", NULL, width / 4, height / 4, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[2] = R_CreateImage("*glowScaled2a", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[3] = R_CreateImage("*glowScaled2b", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); if (r_drawSunRays->integer) tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6be77e9407..2fe76117e5 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1979,6 +1979,7 @@ typedef struct trGlobals_s { image_t *renderImage; image_t *glowImage; + image_t *glowImageScaled[4]; image_t *sunRaysImage; image_t *renderDepthImage; image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; @@ -1996,6 +1997,7 @@ typedef struct trGlobals_s { image_t *textureDepthImage; FBO_t *renderFbo; + FBO_t *glowFboScaled[4]; FBO_t *msaaResolveFbo; FBO_t *sunRaysFbo; FBO_t *depthFbo; @@ -2055,6 +2057,8 @@ typedef struct trGlobals_s { shaderProgram_t ssaoShader; shaderProgram_t depthBlurShader[2]; shaderProgram_t testcubeShader; + shaderProgram_t gaussianBlurShader[2]; + shaderProgram_t glowCompositeShader; // ----------------------------------------- diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index f564b0c079..e3eb724863 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -471,53 +471,24 @@ static void RB_BlurAxis(FBO_t *srcFbo, FBO_t *dstFbo, float strength, qboolean h } } -static void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) +void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) { RB_BlurAxis(srcFbo, dstFbo, strength, qtrue); } -static void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) +void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength) { RB_BlurAxis(srcFbo, dstFbo, strength, qfalse); } -void RB_GaussianBlur(float blur) +void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *intermediateFbo, FBO_t *dstFbo, float spread) { - //float mul = 1.f; - float factor = Com_Clamp(0.f, 1.f, blur); + // Blur X + vec2_t scale; + VectorSet2 (scale, spread, spread); - if (factor <= 0.f) - return; - - { - vec4i_t srcBox, dstBox; - vec4_t color; - vec2_t texScale; + FBO_Blit (srcFbo, NULL, scale, intermediateFbo, NULL, &tr.gaussianBlurShader[0], NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - texScale[0] = - texScale[1] = 1.0f; - - VectorSet4(color, 1, 1, 1, 1); - - // first, downsample the framebuffer - FBO_FastBlit(NULL, NULL, tr.quarterFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - // set the alpha channel - VectorSet4(srcBox, 0, 0, tr.whiteImage->width, tr.whiteImage->height); - VectorSet4(dstBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); - qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); - FBO_BlitFromTexture(tr.whiteImage, srcBox, texScale, tr.textureScratchFbo[0], dstBox, &tr.textureColorShader, color, GLS_DEPTHTEST_DISABLE); - qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - - // blur the tiny buffer horizontally and vertically - RB_HBlur(tr.textureScratchFbo[0], tr.textureScratchFbo[1], factor); - RB_VBlur(tr.textureScratchFbo[1], tr.textureScratchFbo[0], factor); - - // finally, merge back to framebuffer - VectorSet4(srcBox, 0, 0, tr.textureScratchFbo[0]->width, tr.textureScratchFbo[0]->height); - VectorSet4(dstBox, 0, 0, glConfig.vidWidth, glConfig.vidHeight); - color[3] = factor; - FBO_Blit(tr.textureScratchFbo[0], srcBox, texScale, NULL, dstBox, &tr.textureColorShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } + // Blur Y + FBO_Blit (intermediateFbo, NULL, scale, dstFbo, NULL, &tr.gaussianBlurShader[1], NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); } diff --git a/codemp/rd-rend2/tr_postprocess.h b/codemp/rd-rend2/tr_postprocess.h index 6c34ecc2f9..9a8cee5bac 100644 --- a/codemp/rd-rend2/tr_postprocess.h +++ b/codemp/rd-rend2/tr_postprocess.h @@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, int autoExposure); void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float blur); void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox); -void RB_GaussianBlur(float blur); +void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *intermediateFbo, FBO_t *dstFbo, float spread); +void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); +void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); #endif From afabccdfbc3af490928086532bfec04c7de78245 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 1 Jun 2014 19:21:12 +0100 Subject: [PATCH 209/708] [MP] Rend2: Increase BSP max VBO size to 16MB On very large maps, 4MB was creating too many vertex buffers. 16MB reduces the number of VBOs to a reasonable number (< 10) without over-shooting for too much memory on smaller maps. --- codemp/rd-rend2/tr_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 97db439a2f..648c9da509 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1900,7 +1900,7 @@ static void R_CreateWorldVBOs(void) VBO_t *vbo; IBO_t *ibo; - int maxVboSize = 4 * 1024 * 1024; + int maxVboSize = 16 * 1024 * 1024; int maxIboSize = 4 * 1024 * 1024; int startTime, endTime; From d7fd97a0b5198bac8a01f53b14e411322b0bc099 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 1 Jun 2014 20:47:12 +0100 Subject: [PATCH 210/708] [MP] Rend2: Port new ioq3 MD3 tangent calculations This fixes some code in the MD3 tangent calculations which looked a bit dodgy, and nobody really understood what it was trying to do. --- codemp/rd-rend2/tr_init.cpp | 2 - codemp/rd-rend2/tr_local.h | 6 +- codemp/rd-rend2/tr_main.cpp | 137 +++++------------------------------ codemp/rd-rend2/tr_model.cpp | 74 ++++++++----------- 4 files changed, 50 insertions(+), 169 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index cd70dfddc1..68b1017d8d 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -138,7 +138,6 @@ cvar_t *r_baseNormalY; cvar_t *r_baseParallax; cvar_t *r_baseSpecular; cvar_t *r_baseGloss; -cvar_t *r_recalcMD3Normals; cvar_t *r_mergeLightmaps; cvar_t *r_dlightMode; cvar_t *r_pshadowDist; @@ -1275,7 +1274,6 @@ void R_Register( void ) r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.1", CVAR_ARCHIVE | CVAR_LATCH ); r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); - r_recalcMD3Normals = ri->Cvar_Get( "r_recalcMD3Normals", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2fe76117e5..bfd4a3ee3f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -167,7 +167,6 @@ extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; extern cvar_t *r_normalAmbient; -extern cvar_t *r_recalcMD3Normals; extern cvar_t *r_mergeLightmaps; extern cvar_t *r_dlightMode; extern cvar_t *r_pshadowDist; @@ -2345,8 +2344,9 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); -void R_CalcTangentSpace(vec3_t tangent, vec3_t bitangent, vec3_t normal, - const vec3_t v0, const vec3_t v1, const vec3_t v2, const vec2_t t0, const vec2_t t1, const vec2_t t2); +void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, + const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3); +void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t normal, vec3_t sdir, vec3_t tdir); qboolean R_CalcTangentVectors(srfVert_t * dv[3]); #define CULL_IN 0 // completely unclipped diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 906865e8f0..4c759f3586 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -296,13 +296,11 @@ void R_CalcTangentSpaceFast(vec3_t tangent, vec3_t bitangent, vec3_t normal, /* http://www.terathon.com/code/tangent.html */ -void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t normal, - const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3) +void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, + const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3) { - vec3_t u, v; float x1, x2, y1, y2, z1, z2; - float s1, s2, t1, t2; - float r, dot; + float s1, s2, t1, t2, r; x1 = v2[0] - v1[0]; x2 = v3[0] - v1[0]; @@ -318,128 +316,29 @@ void R_CalcTBN(vec3_t tangent, vec3_t bitangent, vec3_t normal, r = 1.0f / (s1 * t2 - s2 * t1); - VectorSet(tangent, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); - VectorSet(bitangent, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); - - // compute the face normal based on vertex points - VectorSubtract(v3, v1, u); - VectorSubtract(v2, v1, v); - CrossProduct(u, v, normal); - - VectorNormalize(normal); - - // Gram-Schmidt orthogonalize - //tangent[a] = (t - n * Dot(n, t)).Normalize(); - dot = DotProduct(normal, tangent); - VectorMA(tangent, -dot, normal, tangent); - VectorNormalize(tangent); - - // B=NxT - //CrossProduct(normal, tangent, bitangent); + VectorSet(sdir, (t2 * x1 - t1 * x2) * r, (t2 * y1 - t1 * y2) * r, (t2 * z1 - t1 * z2) * r); + VectorSet(tdir, (s1 * x2 - s2 * x1) * r, (s1 * y2 - s2 * y1) * r, (s1 * z2 - s2 * z1) * r); } -void R_CalcTBN2(vec3_t tangent, vec3_t bitangent, vec3_t normal, - const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t t1, const vec2_t t2, const vec2_t t3) +void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t normal, vec3_t sdir, vec3_t tdir) { - vec3_t v2v1; - vec3_t v3v1; - - float c2c1_T; - float c2c1_B; - - float c3c1_T; - float c3c1_B; - - float denominator; - float scale1, scale2; - - vec3_t T, B, N, C; - - - // Calculate the tangent basis for each vertex of the triangle - // UPDATE: In the 3rd edition of the accompanying article, the for-loop located here has - // been removed as it was redundant (the entire TBN matrix was calculated three times - // instead of just one). - // - // Please note, that this function relies on the fact that the input geometry are triangles - // and the tangent basis for each vertex thus is identical! - // + vec3_t n_cross_t; + float n_dot_t, handedness; - // Calculate the vectors from the current vertex to the two other vertices in the triangle - VectorSubtract(v2, v1, v2v1); - VectorSubtract(v3, v1, v3v1); - - // The equation presented in the article states that: - // c2c1_T = V2.texcoord.x - V1.texcoord.x - // c2c1_B = V2.texcoord.y - V1.texcoord.y - // c3c1_T = V3.texcoord.x - V1.texcoord.x - // c3c1_B = V3.texcoord.y - V1.texcoord.y - - // Calculate c2c1_T and c2c1_B - c2c1_T = t2[0] - t1[0]; - c2c1_B = t2[1] - t2[1]; - - // Calculate c3c1_T and c3c1_B - c3c1_T = t3[0] - t1[0]; - c3c1_B = t3[1] - t1[1]; - - denominator = c2c1_T * c3c1_B - c3c1_T * c2c1_B; - //if(ROUNDOFF(fDenominator) == 0.0f) - if(denominator == 0.0f) - { - // We won't risk a divide by zero, so set the tangent matrix to the identity matrix - VectorSet(tangent, 1, 0, 0); - VectorSet(bitangent, 0, 1, 0); - VectorSet(normal, 0, 0, 1); - } - else - { - // Calculate the reciprocal value once and for all (to achieve speed) - scale1 = 1.0f / denominator; - - // T and B are calculated just as the equation in the article states - VectorSet(T, (c3c1_B * v2v1[0] - c2c1_B * v3v1[0]) * scale1, - (c3c1_B * v2v1[1] - c2c1_B * v3v1[1]) * scale1, - (c3c1_B * v2v1[2] - c2c1_B * v3v1[2]) * scale1); - - VectorSet(B, (-c3c1_T * v2v1[0] + c2c1_T * v3v1[0]) * scale1, - (-c3c1_T * v2v1[1] + c2c1_T * v3v1[1]) * scale1, - (-c3c1_T * v2v1[2] + c2c1_T * v3v1[2]) * scale1); + // Gram-Schmidt orthogonalize + n_dot_t = DotProduct(normal, sdir); + VectorMA(sdir, -n_dot_t, normal, tangent); + VectorNormalize(tangent); - // The normal N is calculated as the cross product between T and B - CrossProduct(T, B, N); + // Calculate handedness + CrossProduct(normal, sdir, n_cross_t); + handedness = (DotProduct(n_cross_t, tdir) < 0.0f) ? -1.0f : 1.0f; -#if 0 - VectorCopy(T, tangent); - VectorCopy(B, bitangent); - VectorCopy(N, normal); -#else - // Calculate the reciprocal value once and for all (to achieve speed) - scale2 = 1.0f / ((T[0] * B[1] * N[2] - T[2] * B[1] * N[0]) + - (B[0] * N[1] * T[2] - B[2] * N[1] * T[0]) + - (N[0] * T[1] * B[2] - N[2] * T[1] * B[0])); - - // Calculate the inverse if the TBN matrix using the formula described in the article. - // We store the basis vectors directly in the provided TBN matrix: pvTBNMatrix - CrossProduct(B, N, C); tangent[0] = C[0] * scale2; - CrossProduct(N, T, C); tangent[1] = -C[0] * scale2; - CrossProduct(T, B, C); tangent[2] = C[0] * scale2; - VectorNormalize(tangent); - - CrossProduct(B, N, C); bitangent[0] = -C[1] * scale2; - CrossProduct(N, T, C); bitangent[1] = C[1] * scale2; - CrossProduct(T, B, C); bitangent[2] = -C[1] * scale2; - VectorNormalize(bitangent); - - CrossProduct(B, N, C); normal[0] = C[2] * scale2; - CrossProduct(N, T, C); normal[1] = -C[2] * scale2; - CrossProduct(T, B, C); normal[2] = C[2] * scale2; - VectorNormalize(normal); -#endif - } + // Calculate bitangent + CrossProduct(normal, tangent, bitangent); + VectorScale(bitangent, handedness, bitangent); } - #ifdef USE_VERT_TANGENT_SPACE qboolean R_CalcTangentVectors(srfVert_t * dv[3]) { diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index b8c77d8607..f49c5c9149 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -799,7 +799,7 @@ R_LoadMD3 */ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modName) { - int f, i, j, k; + int f, i, j; md3Header_t *md3Model; md3Frame_t *md3Frame; @@ -1033,70 +1033,54 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN #ifdef USE_VERT_TANGENT_SPACE // calc tangent spaces { - // Valgrind complaints: Conditional jump or move depends on uninitialised value(s) - // So lets Initialize them. - const float *v0 = NULL, *v1 = NULL, *v2 = NULL; - const float *t0 = NULL, *t1 = NULL, *t2 = NULL; - vec3_t tangent = { 0, 0, 0 }; - vec3_t bitangent = { 0, 0, 0 }; - vec3_t normal = { 0, 0, 0 }; - for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) { VectorClear(v->tangent); VectorClear(v->bitangent); - if (r_recalcMD3Normals->integer) - VectorClear(v->normal); } for(f = 0; f < mdvModel->numFrames; f++) { for(j = 0, tri = surf->indexes; j < surf->numIndexes; j += 3, tri += 3) { - v0 = surf->verts[surf->numVerts * f + tri[0]].xyz; - v1 = surf->verts[surf->numVerts * f + tri[1]].xyz; - v2 = surf->verts[surf->numVerts * f + tri[2]].xyz; + vec3_t sdir, tdir; + const float *v0, *v1, *v2, *t0, *t1, *t2; + glIndex_t index0, index1, index2; + + index0 = surf->numVerts * f + tri[0]; + index1 = surf->numVerts * f + tri[1]; + index2 = surf->numVerts * f + tri[2]; + + v0 = surf->verts[index0].xyz; + v1 = surf->verts[index1].xyz; + v2 = surf->verts[index2].xyz; t0 = surf->st[tri[0]].st; t1 = surf->st[tri[1]].st; t2 = surf->st[tri[2]].st; - if (!r_recalcMD3Normals->integer) - VectorCopy(v->normal, normal); - else - VectorClear(normal); - - #if 1 - R_CalcTangentSpace(tangent, bitangent, normal, v0, v1, v2, t0, t1, t2); - #else - R_CalcNormalForTriangle(normal, v0, v1, v2); - R_CalcTangentsForTriangle(tangent, bitangent, v0, v1, v2, t0, t1, t2); - #endif - - for(k = 0; k < 3; k++) - { - float *v; - - v = surf->verts[surf->numVerts * f + tri[k]].tangent; - VectorAdd(v, tangent, v); - - v = surf->verts[surf->numVerts * f + tri[k]].bitangent; - VectorAdd(v, bitangent, v); - - if (r_recalcMD3Normals->integer) - { - v = surf->verts[surf->numVerts * f + tri[k]].normal; - VectorAdd(v, normal, v); - } - } + R_CalcTexDirs(sdir, tdir, v0, v1, v2, t0, t1, t2); + + VectorAdd(sdir, surf->verts[index0].tangent, surf->verts[index0].tangent); + VectorAdd(sdir, surf->verts[index1].tangent, surf->verts[index1].tangent); + VectorAdd(sdir, surf->verts[index2].tangent, surf->verts[index2].tangent); + VectorAdd(tdir, surf->verts[index0].bitangent, surf->verts[index0].bitangent); + VectorAdd(tdir, surf->verts[index1].bitangent, surf->verts[index1].bitangent); + VectorAdd(tdir, surf->verts[index2].bitangent, surf->verts[index2].bitangent); } } for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) { - VectorNormalize(v->tangent); - VectorNormalize(v->bitangent); - VectorNormalize(v->normal); + vec3_t sdir, tdir; + + VectorCopy(v->tangent, sdir); + VectorCopy(v->bitangent, tdir); + + VectorNormalize(sdir); + VectorNormalize(tdir); + + R_CalcTbnFromNormalAndTexDirs(v->tangent, v->bitangent, v->normal, sdir, tdir); } } #endif From e08c77044fc81a432cd7b578ea93863249c14199 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 1 Jun 2014 21:02:39 +0100 Subject: [PATCH 211/708] [MP] Rend2: Change G2 tangent calcs to match MD3 --- codemp/rd-rend2/tr_ghoul2.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 054b23229c..9ddcf0b617 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4583,6 +4583,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean for ( int k = 0; k < surf->numTriangles; k++ ) { int index[3]; + vec3_t sdir, tdir; float *v0, *v1, *v2; float *uv0, *uv1, *uv2; vec3_t normal = { 0.0f, 0.0f, 0.0f }; @@ -4606,16 +4607,16 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean VectorAdd (normal, v[index[2]].normal, normal); VectorNormalize (normal); - R_CalcTangentSpace (tangent, bitangent, normal, v0, v1, v2, uv0, uv1, uv2); + R_CalcTexDirs (sdir, tdir, v0, v1, v2, uv0, uv1, uv2); for ( int i = 0; i < 3; i++ ) { VectorAdd (tangentsf[baseVertexes[n] + index[i]], - tangent, + sdir, tangentsf[baseVertexes[n] + index[i]]); VectorAdd (bitangentsf[baseVertexes[n] + index[i]], - bitangent, + tdir, bitangentsf[baseVertexes[n] + index[i]]); } } @@ -4623,13 +4624,20 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean // Finally add it to the vertex buffer data for ( int k = 0; k < surf->numVerts; k++ ) { + vec3_t sdir, tdir; + vec3_t& tangent = tangentsf[baseVertexes[n] + k]; vec3_t& bitangent = bitangentsf[baseVertexes[n] + k]; vec3_t NxT; vec4_t T; - VectorNormalize (tangent); - VectorNormalize (bitangent); + VectorCopy (tangent, sdir); + VectorCopy (bitangent, tdir); + + VectorNormalize (sdir); + VectorNormalize (tdir); + + R_CalcTbnFromNormalAndTexDirs(tangent, bitangent, v[k].normal, sdir, tdir); CrossProduct (v[k].normal, tangent, NxT); VectorCopy (tangent, T); From 3030590dd76d86c9f2763431312970e07ea261e0 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 2 Jun 2014 17:21:31 -0500 Subject: [PATCH 212/708] [MP] Rend2: Merge a few fixes from vanilla. Parse and ignore surfacelight/q3map_surfacelight, and lightColor. --- codemp/rd-rend2/tr_shader.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 659675d666..02910571f7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1410,8 +1410,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) break; - strcat( buffer, token ); - strcat( buffer, " " ); + Q_strcat( buffer, sizeof( buffer ), token ); + Q_strcat( buffer, sizeof( buffer ), " " ); } ParseTexMod( buffer, stage ); @@ -1450,8 +1450,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) break; - strcat( buffer, token ); - strcat( buffer, " " ); + Q_strcat( buffer, sizeof( buffer ), token ); + Q_strcat( buffer, sizeof( buffer ), " " ); } ParseSurfaceSprites( buffer, stage );*/ @@ -1483,8 +1483,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) break; - strcat( buffer, token ); - strcat( buffer, " " ); + Q_strcat( buffer, sizeof( buffer ), token ); + Q_strcat( buffer, sizeof( buffer ), " " ); } ParseSurfaceSpritesOptional( param, buffer, stage );*/ @@ -2049,6 +2049,17 @@ static qboolean ParseShader( const char **text ) SkipRestOfLine( text ); continue; } + // q3map_surfacelight deprecated as of 16 Jul 01 + else if ( !Q_stricmp( token, "surfacelight" ) || !Q_stricmp( token, "q3map_surfacelight" ) ) + { + SkipRestOfLine( text ); + continue; + } + else if ( !Q_stricmp( token, "lightColor" ) ) + { + SkipRestOfLine( text ); + continue; + } else if ( !Q_stricmp( token, "deformvertexes" ) || !Q_stricmp( token, "deform" ) ) { ParseDeform( text ); continue; @@ -2587,8 +2598,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, image_t *normalImg; int normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; - COM_StripExtension(diffuseImg->imgName, normalName, MAX_QPATH); - Q_strcat(normalName, MAX_QPATH, "_n"); + COM_StripExtension( diffuseImg->imgName, normalName, sizeof( normalName ) ); + Q_strcat( normalName, sizeof( normalName ), "_n" ); normalImg = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); From 3d86ddec43519b2e9dc29108280ad45ab8737967 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Mon, 2 Jun 2014 18:46:09 -0500 Subject: [PATCH 213/708] [MP] Rend2: Fixed warning issue on x86_64 with escape_string function. --- codemp/rd-rend2/glsl/compact.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 60ff15ad51..06fb01b819 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -20,7 +20,7 @@ bool should_be_escaped ( char c ) std::string& escape_string ( std::string& s ) { - int escapable_characters = std::count_if (s.begin(), s.end(), should_be_escaped); + std::string::difference_type escapable_characters = std::count_if( s.begin(), s.end(), should_be_escaped ); if ( escapable_characters == 0 ) { return s; From 88eb71adfbbd9a1402e1e3791b135bfe842a8974 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 4 Jun 2014 19:09:14 +0100 Subject: [PATCH 214/708] [MP] Rend2: Use immutable textures when available --- codemp/rd-rend2/qgl.h | 8 +++++ codemp/rd-rend2/tr_extensions.cpp | 21 ++++++++++++ codemp/rd-rend2/tr_image.cpp | 56 +++++++++++++++++++++++++------ codemp/rd-rend2/tr_local.h | 2 ++ 4 files changed, 77 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index ac8e91707a..bf33a45ef4 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -1124,6 +1124,14 @@ extern void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); #define GL_DEPTH_CLAMP 0x864F #endif +// GL_ARB_texture_storage +extern PFNGLTEXSTORAGE1DPROC qglTexStorage1D; +extern PFNGLTEXSTORAGE2DPROC qglTexStorage2D; +extern PFNGLTEXSTORAGE3DPROC qglTexStorage3D; +#ifndef GL_ARB_texture_storage +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#endif + #ifndef GL_ARB_seamless_cube_map #define GL_ARB_seamless_cube_map #define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index d8af171882..cd32ecb308 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -181,6 +181,11 @@ void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei sa // GL_ARB_draw_buffers void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); +// GL_ARB_texture_storage +PFNGLTEXSTORAGE1DPROC qglTexStorage1D; +PFNGLTEXSTORAGE2DPROC qglTexStorage2D; +PFNGLTEXSTORAGE3DPROC qglTexStorage3D; + // OpenGL 3.0 PFNGLCLEARBUFFERFVPROC qglClearBufferfv; @@ -731,6 +736,22 @@ void GLimp_InitExtraExtensions() ri->Printf(PRINT_ALL, result[2], extension); } + // GL_ARB_texture_storage + extension = "GL_ARB_texture_storage"; + glRefConfig.immutableTextures = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + qglTexStorage1D = (PFNGLTEXSTORAGE1DPROC)GL_GetProcAddress("glTexStorage1D"); + qglTexStorage2D = (PFNGLTEXSTORAGE2DPROC)GL_GetProcAddress("glTexStorage2D"); + qglTexStorage3D = (PFNGLTEXSTORAGE3DPROC)GL_GetProcAddress("glTexStorage3D"); + + ri->Printf(PRINT_ALL, result[1], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } + // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer && r_hdr->integer); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 4fa42074b8..6ed2210337 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_image.c #include "tr_local.h" +#include "glext.h" static byte s_intensitytable[256]; static unsigned char s_gammatable[256]; @@ -1927,6 +1928,10 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light return internalFormat; } +static int CalcNumMipmapLevels ( int width, int height ) +{ + return static_cast(ceil (log2 (max (width, height))) + 1); +} static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, int flags, qboolean subtexture ) { @@ -1951,10 +1956,27 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei break; } - if ( subtexture ) - qglTexSubImage2D( GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data ); + if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) + { + if ( subtexture ) + { + qglTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data); + } + else + { + int numLevels = (flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; + + qglTexStorage2D (GL_TEXTURE_2D, numLevels, internalFormat, width, height); + qglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, dataFormat, dataType, data); + } + } else - qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, width, height, 0, dataFormat, dataType, data ); + { + if ( subtexture ) + qglTexSubImage2D( GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data ); + else + qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, width, height, 0, dataFormat, dataType, data ); + } if (flags & IMGFLAG_MIPMAP) { @@ -2311,12 +2333,26 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + if (glRefConfig.immutableTextures && !(image->flags & IMGFLAG_MUTABLE)) + { + int numLevels = (image->flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; + + qglTexStorage2D (GL_TEXTURE_CUBE_MAP, numLevels, internalFormat, width, height); + + for ( int i = 0; i < 6; i++ ) + { + qglTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pic); + } + } + else + { + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + } if (image->flags & IMGFLAG_MIPMAP) qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); @@ -2828,7 +2864,7 @@ void R_CreateBuiltinImages( void ) { for(x=0;x<32;x++) { // scratchimage is usually used for cinematic drawing - tr.scratchImage[x] = R_CreateImage("*scratch", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_PICMIP | IMGFLAG_CLAMPTOEDGE, 0); + tr.scratchImage[x] = R_CreateImage("*scratch", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_PICMIP | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MUTABLE, 0); } R_CreateDlightImage(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bfd4a3ee3f..82a15b6728 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -317,6 +317,7 @@ typedef enum IMGFLAG_CLAMPTOEDGE = 0x0040, IMGFLAG_SRGB = 0x0080, IMGFLAG_GENNORMALMAP = 0x0100, + IMGFLAG_MUTABLE = 0x0200, } imgFlags_t; typedef enum @@ -1870,6 +1871,7 @@ typedef struct { qboolean textureSrgb; qboolean framebufferSrgb; qboolean textureSrgbDecode; + qboolean immutableTextures; qboolean depthClamp; qboolean seamlessCubeMap; From 9d760fc2d4b95556edfab41c545a6d46d2aee9e5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 Jun 2014 21:57:07 +0100 Subject: [PATCH 215/708] [MP] Rend2: Fix dynamic glow with MSAA --- codemp/rd-rend2/tr_backend.cpp | 5 +++++ codemp/rd-rend2/tr_fbo.cpp | 27 +++++++++++++++++++++++++++ codemp/rd-rend2/tr_fbo.h | 2 ++ 3 files changed, 34 insertions(+) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index bbb3c48e0c..50046be031 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1841,6 +1841,11 @@ const void *RB_PostProcess(const void *data) // Can't resolve just part of the MSAA FBO, so multiple views will suffer a performance hit here FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); srcFbo = tr.msaaResolveFbo; + + if ( r_dynamicGlow->integer ) + { + FBO_FastBlitIndexed(tr.renderFbo, tr.msaaResolveFbo, 1, 1, GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST); + } } dstBox[0] = backEnd.viewParms.viewportX; diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index cd37e526f2..00a17d4d0d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -444,6 +444,7 @@ void FBO_Init(void) FBO_Bind(tr.renderFbo); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); + FBO_CreateBuffer(tr.renderFbo, hdrFormat, 1, multisample); FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, multisample); FBO_SetupDrawBuffers(); @@ -455,6 +456,7 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.msaaResolveFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.renderImage, 0); + FBO_AttachTextureImage(tr.glowImage, 1); //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); @@ -935,6 +937,7 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu qglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, srcFb); qglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dstFb); + qglBlitFramebufferEXT(srcBoxFinal[0], srcBoxFinal[1], srcBoxFinal[2], srcBoxFinal[3], dstBoxFinal[0], dstBoxFinal[1], dstBoxFinal[2], dstBoxFinal[3], buffers, filter); @@ -942,3 +945,27 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glState.currentFBO = NULL; } + +void FBO_FastBlitIndexed(FBO_t *src, FBO_t *dst, int srcReadBuffer, int dstDrawBuffer, int buffers, int filter) +{ + assert (src != NULL); + assert (dst != NULL); + + qglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, src->frameBuffer); + qglReadBuffer (GL_COLOR_ATTACHMENT0_EXT + srcReadBuffer); + + qglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dst->frameBuffer); + qglDrawBuffer (GL_COLOR_ATTACHMENT0_EXT + dstDrawBuffer); + + qglBlitFramebufferEXT(0, 0, src->width, src->height, + 0, 0, dst->width, dst->height, + buffers, filter); + + qglReadBuffer (GL_COLOR_ATTACHMENT0_EXT); + + glState.currentFBO = dst; + FBO_SetupDrawBuffers(); + + qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glState.currentFBO = NULL; +} diff --git a/codemp/rd-rend2/tr_fbo.h b/codemp/rd-rend2/tr_fbo.h index f036625156..bea9496a18 100644 --- a/codemp/rd-rend2/tr_fbo.h +++ b/codemp/rd-rend2/tr_fbo.h @@ -58,7 +58,9 @@ void FBO_Shutdown(void); void FBO_BlitFromTexture(struct image_s *src, vec4i_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4i_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend); void FBO_Blit(FBO_t *src, vec4i_t srcBox, vec2_t srcTexScale, FBO_t *dst, vec4i_t dstBox, struct shaderProgram_s *shaderProgram, vec4_t color, int blend); + void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int buffers, int filter); +void FBO_FastBlitIndexed(FBO_t *src, FBO_t *dst, int srcReadBuffer, int dstDrawBuffer, int buffers, int filter); #endif From 82d9997027775cb8a1a7ee48f4a7aea97944da05 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 Jun 2014 22:00:55 +0100 Subject: [PATCH 216/708] [MP] Rend2: Removed unneccessary RB_SetGL2D extern --- codemp/rd-rend2/tr_fbo.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 00a17d4d0d..502610a710 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -733,9 +733,6 @@ void R_FBOList_f(void) ri->Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); } -// FIXME -extern void RB_SetGL2D (void); - void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexScale, FBO_t *dst, vec4i_t inDstBox, struct shaderProgram_s *shaderProgram, vec4_t inColor, int blend) { vec4i_t dstBox, srcBox; From debe7b6078a50239ecc71d0ae2833db1c41b49fa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 6 Jun 2014 21:52:17 +0100 Subject: [PATCH 217/708] [MP] Rend2: Removed a load of extension checks This commit removes checking for extensions which are now part of OpenGL 3.2, in preparation for function renaming (removing ARB/EXT suffixes). --- codemp/rd-rend2/tr_backend.cpp | 172 ++++++++------------ codemp/rd-rend2/tr_cmds.cpp | 27 ++-- codemp/rd-rend2/tr_extensions.cpp | 249 ++--------------------------- codemp/rd-rend2/tr_fbo.cpp | 26 +-- codemp/rd-rend2/tr_glsl.cpp | 10 +- codemp/rd-rend2/tr_image.cpp | 170 ++++++++------------ codemp/rd-rend2/tr_init.cpp | 17 +- codemp/rd-rend2/tr_local.h | 21 --- codemp/rd-rend2/tr_main.cpp | 36 +---- codemp/rd-rend2/tr_postprocess.cpp | 166 +++++++++---------- codemp/rd-rend2/tr_scene.cpp | 6 +- codemp/rd-rend2/tr_shade.cpp | 32 +--- codemp/rd-rend2/tr_vbo.cpp | 66 ++------ 13 files changed, 282 insertions(+), 716 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 50046be031..fecb33e36a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -451,31 +451,28 @@ void RB_BeginDrawingView (void) { // 2D images again backEnd.projection2D = qfalse; - if (glRefConfig.framebufferObject) + // FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world + // drawing more world check is in case of double renders, such as skyportals + if (backEnd.viewParms.targetFbo == NULL) { - // FIXME: HUGE HACK: render to the screen fbo if we've already postprocessed the frame and aren't drawing more world - // drawing more world check is in case of double renders, such as skyportals - if (backEnd.viewParms.targetFbo == NULL) + if (!tr.renderFbo || (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) { - if (!tr.renderFbo || (backEnd.framePostProcessed && (backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); } else { - FBO_Bind(backEnd.viewParms.targetFbo); + FBO_Bind(tr.renderFbo); + } + } + else + { + FBO_Bind(backEnd.viewParms.targetFbo); - // FIXME: hack for cubemap testing - if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) - { - //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); - } + // FIXME: hack for cubemap testing + if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + { + //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); + qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); } } @@ -764,8 +761,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { qglEndQueryARB(GL_SAMPLES_PASSED_ARB); } - if (glRefConfig.framebufferObject) - FBO_Bind(fbo); + FBO_Bind(fbo); // go back to the world modelview matrix @@ -884,16 +880,13 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * } // FIXME: HUGE hack - if (glRefConfig.framebufferObject) + if (!tr.renderFbo || backEnd.framePostProcessed) { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); + } + else + { + FBO_Bind(tr.renderFbo); } RB_SetGL2D(); @@ -971,16 +964,13 @@ const void *RB_StretchPic ( const void *data ) { cmd = (const stretchPicCommand_t *)data; // FIXME: HUGE hack - if (glRefConfig.framebufferObject) + if (!tr.renderFbo || backEnd.framePostProcessed) { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); + } + else + { + FBO_Bind(tr.renderFbo); } RB_SetGL2D(); @@ -1069,16 +1059,13 @@ const void *RB_RotatePic ( const void *data ) cmd = (const rotatePicCommand_t *)data; // FIXME: HUGE hack - if (glRefConfig.framebufferObject) + if (!tr.renderFbo || backEnd.framePostProcessed) { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); + } + else + { + FBO_Bind(tr.renderFbo); } RB_SetGL2D(); @@ -1170,16 +1157,13 @@ const void *RB_RotatePic2 ( const void *data ) cmd = (const rotatePicCommand_t *)data; // FIXME: HUGE hack - if (glRefConfig.framebufferObject) + if (!tr.renderFbo || backEnd.framePostProcessed) { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); + } + else + { + FBO_Bind(tr.renderFbo); } RB_SetGL2D(); @@ -1275,12 +1259,12 @@ const void *RB_DrawSurfs( const void *data ) { // clear the z buffer, set the modelview, etc RB_BeginDrawingView (); - if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) { qglEnable(GL_DEPTH_CLAMP); } - if (glRefConfig.framebufferObject && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW))) + if (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW))) { FBO_t *oldFbo = glState.currentFBO; @@ -1478,7 +1462,7 @@ const void *RB_DrawSurfs( const void *data ) { SetViewportAndScissor(); } - if (glRefConfig.framebufferObject && (backEnd.viewParms.flags & VPF_DEPTHCLAMP) && glRefConfig.depthClamp) + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) { qglDisable(GL_DEPTH_CLAMP); } @@ -1500,18 +1484,12 @@ const void *RB_DrawSurfs( const void *data ) { qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); qglClear( GL_COLOR_BUFFER_BIT ); - if (glRefConfig.occlusionQuery) - { - tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; - qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); - } + tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; + qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); RB_DrawSun(0.3, tr.sunFlareShader); - if (glRefConfig.occlusionQuery) - { - qglEndQueryARB(GL_SAMPLES_PASSED_ARB); - } + qglEndQueryARB(GL_SAMPLES_PASSED_ARB); FBO_Bind(oldFbo); } @@ -1523,7 +1501,7 @@ const void *RB_DrawSurfs( const void *data ) { RB_RenderFlares(); } - if (glRefConfig.framebufferObject && tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { FBO_Bind(NULL); GL_SelectTexture(TB_CUBEMAP); @@ -1551,8 +1529,7 @@ const void *RB_DrawBuffer( const void *data ) { if(tess.numIndexes) RB_EndSurface(); - if (glRefConfig.framebufferObject) - FBO_Bind(NULL); + FBO_Bind(NULL); qglDrawBuffer( cmd->buffer ); @@ -1638,14 +1615,11 @@ const void *RB_ColorMask(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (glRefConfig.framebufferObject) - { - // reverse color mask, so 0 0 0 0 is the default - backEnd.colorMask[0] = (qboolean)(!cmd->rgba[0]); - backEnd.colorMask[1] = (qboolean)(!cmd->rgba[1]); - backEnd.colorMask[2] = (qboolean)(!cmd->rgba[2]); - backEnd.colorMask[3] = (qboolean)(!cmd->rgba[3]); - } + // reverse color mask, so 0 0 0 0 is the default + backEnd.colorMask[0] = (qboolean)(!cmd->rgba[0]); + backEnd.colorMask[1] = (qboolean)(!cmd->rgba[1]); + backEnd.colorMask[2] = (qboolean)(!cmd->rgba[2]); + backEnd.colorMask[3] = (qboolean)(!cmd->rgba[3]); qglColorMask(cmd->rgba[0], cmd->rgba[1], cmd->rgba[2], cmd->rgba[3]); @@ -1670,16 +1644,13 @@ const void *RB_ClearDepth(const void *data) if (r_showImages->integer) RB_ShowImages(); - if (glRefConfig.framebufferObject) + if (!tr.renderFbo || backEnd.framePostProcessed) { - if (!tr.renderFbo || backEnd.framePostProcessed) - { - FBO_Bind(NULL); - } - else - { - FBO_Bind(tr.renderFbo); - } + FBO_Bind(NULL); + } + else + { + FBO_Bind(tr.renderFbo); } qglClear(GL_DEPTH_BUFFER_BIT); @@ -1735,20 +1706,17 @@ const void *RB_SwapBuffers( const void *data ) { ri->Hunk_FreeTempMemory( stencilReadback ); } - if (glRefConfig.framebufferObject) + if (!backEnd.framePostProcessed) { - if (!backEnd.framePostProcessed) + if (tr.msaaResolveFbo && r_hdr->integer) { - if (tr.msaaResolveFbo && r_hdr->integer) - { - // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first - FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - else if (tr.renderFbo) - { - FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } + // Resolving an RGB16F MSAA FBO to the screen messes with the brightness, so resolve to an RGB16F FBO first + FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + FBO_FastBlit(tr.msaaResolveFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); + } + else if (tr.renderFbo) + { + FBO_FastBlit(tr.renderFbo, NULL, NULL, NULL, GL_COLOR_BUFFER_BIT, GL_NEAREST); } } @@ -1822,7 +1790,7 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (!glRefConfig.framebufferObject || !r_postProcess->integer || (tr.viewParms.flags & VPF_NOPOSTPROCESS)) + if (!r_postProcess->integer || (tr.viewParms.flags & VPF_NOPOSTPROCESS)) { // do nothing return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 146a606ed2..239d3cf88b 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -480,24 +480,21 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { backEnd.colorMask[3] = qfalse; qglClearColor(0.0f, 0.0f, 0.0f, 1.0f); - if (glRefConfig.framebufferObject) + // clear all framebuffers + if (tr.msaaResolveFbo) { - // clear all framebuffers - if (tr.msaaResolveFbo) - { - FBO_Bind(tr.msaaResolveFbo); - qglClear(GL_COLOR_BUFFER_BIT); - } - - if (tr.renderFbo) - { - FBO_Bind(tr.renderFbo); - qglClear(GL_COLOR_BUFFER_BIT); - } - - FBO_Bind(NULL); + FBO_Bind(tr.msaaResolveFbo); + qglClear(GL_COLOR_BUFFER_BIT); } + if (tr.renderFbo) + { + FBO_Bind(tr.renderFbo); + qglClear(GL_COLOR_BUFFER_BIT); + } + + FBO_Bind(NULL); + qglDrawBuffer(GL_FRONT); qglClear(GL_COLOR_BUFFER_BIT); qglDrawBuffer(GL_BACK); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index cd32ecb308..0589e8c3fd 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -204,43 +204,11 @@ void GLimp_InitExtraExtensions() const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; // GL_EXT_draw_range_elements - extension = "GL_EXT_draw_range_elements"; - glRefConfig.drawRangeElements = qfalse; - qglMultiDrawArraysEXT = NULL; - qglMultiDrawElementsEXT = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglDrawRangeElementsEXT = (void (QCALL *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GL_GetProcAddress("glDrawRangeElementsEXT"); - - if ( r_ext_draw_range_elements->integer) - glRefConfig.drawRangeElements = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } + qglDrawRangeElementsEXT = (void (QCALL *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GL_GetProcAddress("glDrawRangeElementsEXT"); // GL_EXT_multi_draw_arrays - extension = "GL_EXT_multi_draw_arrays"; - glRefConfig.multiDrawArrays = qfalse; - qglMultiDrawArraysEXT = NULL; - qglMultiDrawElementsEXT = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GL_GetProcAddress("glMultiDrawArraysEXT"); - qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GL_GetProcAddress("glMultiDrawElementsEXT"); - - if ( r_ext_multi_draw_arrays->integer ) - glRefConfig.multiDrawArrays = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.multiDrawArrays], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } + qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GL_GetProcAddress("glMultiDrawArraysEXT"); + qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GL_GetProcAddress("glMultiDrawElementsEXT"); // GL_ARB_vertex_program //glRefConfig.vertexProgram = qfalse; @@ -431,7 +399,6 @@ void GLimp_InitExtraExtensions() // GL_ARB_shading_language_100 extension = "GL_ARB_shading_language_100"; - glRefConfig.textureFloat = qfalse; if( GLimp_HaveExtension( extension ) ) { char version[256]; @@ -458,57 +425,8 @@ void GLimp_InitExtraExtensions() glRefConfig.memInfo = MI_ATI; } - extension = "GL_ARB_texture_non_power_of_two"; - glRefConfig.textureNonPowerOfTwo = qfalse; - if( GLimp_HaveExtension( extension ) ) - { - if(1) //(r_ext_texture_non_power_of_two->integer) - { - glRefConfig.textureNonPowerOfTwo = qtrue; - } - - ri->Printf(PRINT_ALL, result[glRefConfig.textureNonPowerOfTwo], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_ARB_texture_float - extension = "GL_ARB_texture_float"; - glRefConfig.textureFloat = qfalse; - if( GLimp_HaveExtension( extension ) ) - { - if( r_ext_texture_float->integer ) - { - glRefConfig.textureFloat = qtrue; - } - - ri->Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_ARB_half_float_pixel - extension = "GL_ARB_half_float_pixel"; - glRefConfig.halfFloatPixel = qfalse; - if( GLimp_HaveExtension( extension ) ) - { - if( r_arb_half_float_pixel->integer ) - glRefConfig.halfFloatPixel = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.halfFloatPixel], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - // GL_EXT_framebuffer_object extension = "GL_EXT_framebuffer_object"; - glRefConfig.framebufferObject = qfalse; if( GLimp_HaveExtension( extension ) ) { qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); @@ -532,23 +450,7 @@ void GLimp_InitExtraExtensions() qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GL_GetProcAddress("glGenerateMipmapEXT"); - if(r_ext_framebuffer_object->value) - glRefConfig.framebufferObject = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_EXT_packed_depth_stencil - extension = "GL_EXT_packed_depth_stencil"; - glRefConfig.packedDepthStencil = qfalse; - if( GLimp_HaveExtension(extension)) - { - glRefConfig.packedDepthStencil = qtrue; - ri->Printf(PRINT_ALL, result[glRefConfig.packedDepthStencil], extension); + ri->Printf(PRINT_ALL, result[1], extension); } else { @@ -556,98 +458,20 @@ void GLimp_InitExtraExtensions() } // GL_ARB_occlusion_query - extension = "GL_ARB_occlusion_query"; - glRefConfig.occlusionQuery = qfalse; - if (GLimp_HaveExtension(extension)) - { - qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GL_GetProcAddress("glGenQueriesARB"); - qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GL_GetProcAddress("glDeleteQueriesARB"); - qglIsQueryARB = (PFNGLISQUERYARBPROC) GL_GetProcAddress("glIsQueryARB"); - qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GL_GetProcAddress("glBeginQueryARB"); - qglEndQueryARB = (PFNGLENDQUERYARBPROC) GL_GetProcAddress("glEndQueryARB"); - qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GL_GetProcAddress("glGetQueryivARB"); - qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GL_GetProcAddress("glGetQueryObjectivARB"); - qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GL_GetProcAddress("glGetQueryObjectuivARB"); - glRefConfig.occlusionQuery = qtrue; - ri->Printf(PRINT_ALL, result[glRefConfig.occlusionQuery], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } + qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GL_GetProcAddress("glGenQueriesARB"); + qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GL_GetProcAddress("glDeleteQueriesARB"); + qglIsQueryARB = (PFNGLISQUERYARBPROC) GL_GetProcAddress("glIsQueryARB"); + qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GL_GetProcAddress("glBeginQueryARB"); + qglEndQueryARB = (PFNGLENDQUERYARBPROC) GL_GetProcAddress("glEndQueryARB"); + qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GL_GetProcAddress("glGetQueryivARB"); + qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GL_GetProcAddress("glGetQueryObjectivARB"); + qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GL_GetProcAddress("glGetQueryObjectuivARB"); // GL_EXT_framebuffer_blit - extension = "GL_EXT_framebuffer_blit"; - glRefConfig.framebufferBlit = qfalse; - if (GLimp_HaveExtension(extension)) - { - qglBlitFramebufferEXT = (void (QCALL *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GL_GetProcAddress("glBlitFramebufferEXT"); - glRefConfig.framebufferBlit = qtrue; - ri->Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } + qglBlitFramebufferEXT = (void (QCALL *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GL_GetProcAddress("glBlitFramebufferEXT"); // GL_EXT_framebuffer_multisample - extension = "GL_EXT_framebuffer_multisample"; - glRefConfig.framebufferMultisample = qfalse; - if (GLimp_HaveExtension(extension)) - { - qglRenderbufferStorageMultisampleEXT = (void (QCALL *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); - glRefConfig.framebufferMultisample = qtrue; - ri->Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_EXT_texture_sRGB - extension = "GL_EXT_texture_sRGB"; - glRefConfig.textureSrgb = qfalse; - if (GLimp_HaveExtension(extension)) - { - if (r_srgb->integer) - glRefConfig.textureSrgb = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.textureSrgb], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_EXT_framebuffer_sRGB - extension = "GL_EXT_framebuffer_sRGB"; - glRefConfig.framebufferSrgb = qfalse; - if (GLimp_HaveExtension(extension)) - { - if (r_srgb->integer) - glRefConfig.framebufferSrgb = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.framebufferSrgb], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_EXT_texture_sRGB_decode - extension = "GL_EXT_texture_sRGB_decode"; - glRefConfig.textureSrgbDecode = qfalse; - if (GLimp_HaveExtension(extension)) - { - if (r_srgb->integer) - glRefConfig.textureSrgbDecode = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.textureSrgbDecode], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } + qglRenderbufferStorageMultisampleEXT = (void (QCALL *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); glRefConfig.textureCompression = TCR_NONE; @@ -693,49 +517,6 @@ void GLimp_InitExtraExtensions() ri->Printf(PRINT_ALL, result[2], extension); } - // GL_ARB_depth_clamp - extension = "GL_ARB_depth_clamp"; - glRefConfig.depthClamp = qfalse; - if( GLimp_HaveExtension( extension ) ) - { - glRefConfig.depthClamp = qtrue; - ri->Printf(PRINT_ALL, result[1], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_ARB_seamless_cube_map - extension = "GL_ARB_seamless_cube_map"; - glRefConfig.seamlessCubeMap = qfalse; - if( GLimp_HaveExtension( extension ) ) - { - if (r_arb_seamless_cube_map->integer) - glRefConfig.seamlessCubeMap = qtrue; - - ri->Printf(PRINT_ALL, result[glRefConfig.seamlessCubeMap], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_ARB_vertex_type_2_10_10_10_rev - extension = "GL_ARB_vertex_type_2_10_10_10_rev"; - glRefConfig.packedNormalDataType = GL_UNSIGNED_BYTE; - if( GLimp_HaveExtension( extension ) ) - { - if (r_arb_vertex_type_2_10_10_10_rev->integer) - glRefConfig.packedNormalDataType = GL_UNSIGNED_INT_2_10_10_10_REV; - - ri->Printf(PRINT_ALL, result[r_arb_vertex_type_2_10_10_10_rev->integer ? 1 : 0], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - // GL_ARB_texture_storage extension = "GL_ARB_texture_storage"; glRefConfig.immutableTextures = qfalse; @@ -753,7 +534,7 @@ void GLimp_InitExtraExtensions() } // use float lightmaps? - glRefConfig.floatLightmap = (qboolean)(glRefConfig.textureFloat && glRefConfig.halfFloatPixel && r_floatLightmap->integer && r_hdr->integer); + glRefConfig.floatLightmap = (qboolean)(r_floatLightmap->integer && r_hdr->integer); qglClearBufferfv = (PFNGLCLEARBUFFERFVPROC)GL_GetProcAddress ("glClearBufferfv"); } diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 502610a710..ecda099f7e 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -192,7 +192,7 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) qglGenRenderbuffersEXT(1, pRenderBuffer); qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, *pRenderBuffer); - if (multisample && glRefConfig.framebufferMultisample) + if (multisample) { qglRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, multisample, format, fbo->width, fbo->height); } @@ -395,9 +395,6 @@ void FBO_Init(void) ri->Printf(PRINT_ALL, "------- FBO_Init -------\n"); - if(!glRefConfig.framebufferObject) - return; - tr.numFBOs = 0; GL_CheckErrors(); @@ -416,7 +413,7 @@ void FBO_Init(void) } */ hdrFormat = GL_RGBA8; - if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat) + if (r_hdr->integer) { hdrFormat = GL_RGB16F_ARB; } @@ -428,7 +425,7 @@ void FBO_Init(void) multisample = r_ext_framebuffer_multisample->integer; } - if (multisample < 2 || !glRefConfig.framebufferBlit) + if (multisample < 2) multisample = 0; if (multisample != r_ext_framebuffer_multisample->integer) @@ -438,7 +435,7 @@ void FBO_Init(void) // only create a render FBO if we need to resolve MSAA or do HDR // otherwise just render straight to the screen (tr.renderFbo = NULL) - if (multisample && glRefConfig.framebufferMultisample) + if (multisample) { tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); FBO_Bind(tr.renderFbo); @@ -678,9 +675,6 @@ void FBO_Shutdown(void) ri->Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); - if(!glRefConfig.framebufferObject) - return; - FBO_Bind(NULL); for(i = 0; i < tr.numFBOs; i++) @@ -714,12 +708,6 @@ void R_FBOList_f(void) int i; FBO_t *fbo; - if(!glRefConfig.framebufferObject) - { - ri->Printf(PRINT_ALL, "GL_EXT_framebuffer_object is not available.\n"); - return; - } - ri->Printf(PRINT_ALL, " size name\n"); ri->Printf(PRINT_ALL, "----------------------------------------------------------\n"); @@ -888,12 +876,6 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu vec4i_t srcBoxFinal, dstBoxFinal; GLuint srcFb, dstFb; - if (!glRefConfig.framebufferBlit) - { - FBO_Blit(src, srcBox, NULL, dst, dstBox, NULL, NULL, 0); - return; - } - // get to a neutral state first //FBO_Bind(NULL); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c3a7e50b67..6066c15d3f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1997,7 +1997,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL; } @@ -2006,7 +2006,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT; } #endif @@ -2023,7 +2023,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); + qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); glState.vertexAttribPointersSet |= ATTR_LIGHTDIRECTION; } @@ -2039,7 +2039,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); + qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL2; } @@ -2048,7 +2048,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 4, glRefConfig.packedNormalDataType, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME + qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT2; } #endif diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 6ed2210337..36d79a3e0c 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1593,7 +1593,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he // // convert to exact power of 2 sizes // - if (glRefConfig.textureNonPowerOfTwo && !mipmap) + if (!mipmap) { scaled_width = width; scaled_height = height; @@ -1869,7 +1869,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } } - if (glRefConfig.textureSrgb && (flags & IMGFLAG_SRGB)) + if (flags & IMGFLAG_SRGB) { switch(internalFormat) { @@ -2089,26 +2089,6 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } } - // Convert to RGB if sRGB textures aren't supported in hardware - if (!glRefConfig.textureSrgb && (flags & IMGFLAG_SRGB)) - { - byte *in = data; - int c = width * height; - while (c--) - { - for (i = 0; i < 3; i++) - { - double x = ByteToFloat(in[i]); - x = sRGBtoRGB(x); - in[i] = FloatToByte(x); - } - in += 4; - } - - // FIXME: Probably should mark the image as non-sRGB as well - flags &= ~IMGFLAG_SRGB; - } - // normals are always swizzled if (type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT) { @@ -2870,107 +2850,93 @@ void R_CreateBuiltinImages( void ) { R_CreateDlightImage(); R_CreateFogImage(); - if (glRefConfig.framebufferObject) - { - int width, height, hdrFormat, rgbFormat; - - if(glRefConfig.textureNonPowerOfTwo) - { - width = glConfig.vidWidth; - height = glConfig.vidHeight; - } - else - { - width = NextPowerOfTwo(glConfig.vidWidth); - height = NextPowerOfTwo(glConfig.vidHeight); - } - - hdrFormat = GL_RGBA8; - if (r_hdr->integer && glRefConfig.framebufferObject && glRefConfig.textureFloat) - hdrFormat = GL_RGBA16F_ARB; + int width, height, hdrFormat, rgbFormat; - rgbFormat = GL_RGBA8; + width = glConfig.vidWidth; + height = glConfig.vidHeight; - tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + hdrFormat = GL_RGBA8; + if (r_hdr->integer) + hdrFormat = GL_RGBA16F_ARB; - tr.glowImage = R_CreateImage("*glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[0] = R_CreateImage("*glowScaled0", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[1] = R_CreateImage("*glowScaled1", NULL, width / 4, height / 4, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[2] = R_CreateImage("*glowScaled2a", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[3] = R_CreateImage("*glowScaled2b", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + rgbFormat = GL_RGBA8; - if (r_drawSunRays->integer) - tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); + tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - if (glRefConfig.framebufferObject) - { - tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); - tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); - } + tr.glowImage = R_CreateImage("*glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[0] = R_CreateImage("*glowScaled0", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[1] = R_CreateImage("*glowScaled1", NULL, width / 4, height / 4, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[2] = R_CreateImage("*glowScaled2a", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[3] = R_CreateImage("*glowScaled2b", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - { - unsigned short sdata[4]; - void *p; + if (r_drawSunRays->integer) + tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - if (hdrFormat == GL_RGBA16F_ARB) - { - sdata[0] = FloatToHalf(0.0f); - sdata[1] = FloatToHalf(0.45f); - sdata[2] = FloatToHalf(1.0f); - sdata[3] = FloatToHalf(1.0f); - p = &sdata[0]; - } - else - { - data[0][0][0] = 0; - data[0][0][1] = 0.45f * 255; - data[0][0][2] = 255; - data[0][0][3] = 255; - p = data; - } + tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); - tr.calcLevelsImage = R_CreateImage("*calcLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.targetLevelsImage = R_CreateImage("*targetLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.fixedLevelsImage = R_CreateImage("*fixedLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - } + { + unsigned short sdata[4]; + void *p; - for (x = 0; x < 2; x++) + if (hdrFormat == GL_RGBA16F_ARB) { - tr.textureScratchImage[x] = R_CreateImage(va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + sdata[0] = FloatToHalf(0.0f); + sdata[1] = FloatToHalf(0.45f); + sdata[2] = FloatToHalf(1.0f); + sdata[3] = FloatToHalf(1.0f); + p = &sdata[0]; } - for (x = 0; x < 2; x++) + else { - tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + data[0][0][0] = 0; + data[0][0][1] = 0.45f * 255; + data[0][0][2] = 255; + data[0][0][3] = 255; + p = data; } - if (r_ssao->integer) - { - tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB); - } + tr.calcLevelsImage = R_CreateImage("*calcLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.targetLevelsImage = R_CreateImage("*targetLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.fixedLevelsImage = R_CreateImage("*fixedLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + } - if (r_shadows->integer == 4) - { - for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) - { - tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - } - } + for (x = 0; x < 2; x++) + { + tr.textureScratchImage[x] = R_CreateImage(va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } + for (x = 0; x < 2; x++) + { + tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } - if (r_sunlightMode->integer) - { - for ( x = 0; x < 3; x++) - { - tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); - } + if (r_ssao->integer) + { + tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB); + } - tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + if (r_shadows->integer == 4) + { + for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) + { + tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } + } - if (r_cubeMapping->integer) + if (r_sunlightMode->integer) + { + for ( x = 0; x < 3; x++) { - tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); + tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); } + + tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + } + + if (r_cubeMapping->integer) + { + tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 68b1017d8d..2acd45e77b 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -94,7 +94,6 @@ cvar_t *r_ext_preferred_tc_method; cvar_t *r_ext_draw_range_elements; cvar_t *r_ext_multi_draw_arrays; -cvar_t *r_ext_framebuffer_object; cvar_t *r_ext_texture_float; cvar_t *r_arb_half_float_pixel; cvar_t *r_ext_framebuffer_multisample; @@ -1024,8 +1023,7 @@ void GL_SetDefaultState( void ) qglDisable( GL_CULL_FACE ); qglDisable( GL_BLEND ); - if (glRefConfig.seamlessCubeMap) - qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } /* @@ -1193,7 +1191,6 @@ void R_Register( void ) r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_framebuffer_object = ri->Cvar_Get( "r_ext_framebuffer_object", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); @@ -1434,18 +1431,12 @@ Ghoul2 Insert End void R_InitQueries(void) { - if (!glRefConfig.occlusionQuery) - return; - if (r_drawSunRays->integer) qglGenQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } void R_ShutDownQueries(void) { - if (!glRefConfig.occlusionQuery) - return; - if (r_drawSunRays->integer) qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } @@ -1531,8 +1522,7 @@ void R_Init( void ) { R_InitImages(); - if (glRefConfig.framebufferObject) - FBO_Init(); + FBO_Init(); int shadersStartTime = GLSL_BeginLoadGPUShaders(); @@ -1590,8 +1580,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { if ( tr.registered ) { R_IssuePendingRenderCommands(); R_ShutDownQueries(); - if (glRefConfig.framebufferObject) - FBO_Shutdown(); + FBO_Shutdown(); R_DeleteTextures(); R_ShutdownVBOs(); GLSL_ShutdownGPUShaders(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 82a15b6728..1c0c687c2b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -132,7 +132,6 @@ extern cvar_t *r_ext_texture_filter_anisotropic; extern cvar_t *r_ext_draw_range_elements; extern cvar_t *r_ext_multi_draw_arrays; -extern cvar_t *r_ext_framebuffer_object; extern cvar_t *r_ext_texture_float; extern cvar_t *r_arb_half_float_pixel; extern cvar_t *r_ext_framebuffer_multisample; @@ -1846,38 +1845,18 @@ typedef enum { // We can't change glConfig_t without breaking DLL/vms compatibility, so // store extensions we have here. typedef struct { - qboolean drawRangeElements; - qboolean multiDrawArrays; - qboolean occlusionQuery; - int glslMajorVersion; int glslMinorVersion; memInfo_t memInfo; - qboolean framebufferObject; int maxRenderbufferSize; int maxColorAttachments; - qboolean textureNonPowerOfTwo; - qboolean textureFloat; - qboolean halfFloatPixel; - qboolean packedDepthStencil; int textureCompression; - - qboolean framebufferMultisample; - qboolean framebufferBlit; - qboolean textureSrgb; - qboolean framebufferSrgb; - qboolean textureSrgbDecode; qboolean immutableTextures; - qboolean depthClamp; - qboolean seamlessCubeMap; - - GLenum packedNormalDataType; - qboolean floatLightmap; } glRefConfig_t; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 4c759f3586..6bba4fdacc 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2324,16 +2324,8 @@ void R_RenderPshadowMaps(const refdef_t *fd) Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - if (glRefConfig.framebufferObject) - { - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - } - else - { - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); - } + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; shadowParms.viewportWidth = PSHADOW_MAP_SIZE; shadowParms.viewportHeight = PSHADOW_MAP_SIZE; shadowParms.isPortal = qfalse; @@ -2342,8 +2334,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - if (glRefConfig.framebufferObject) - shadowParms.targetFbo = tr.pshadowFbos[i]; + shadowParms.targetFbo = tr.pshadowFbos[i]; shadowParms.flags = (viewParmFlags_t)( VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL ); shadowParms.zFar = shadow->lightRadius; @@ -2433,9 +2424,6 @@ void R_RenderPshadowMaps(const refdef_t *fd) } R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); - - if (!glRefConfig.framebufferObject) - R_AddCapShadowmapCmd( i, -1 ); } } } @@ -2631,9 +2619,6 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) Matrix16Transform(lightViewMatrix, point, lightViewPoint); AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - if (!glRefConfig.depthClamp) - lightviewBounds[0][0] = lightviewBounds[1][0] - 8192; - // Moving the Light in Texel-Sized Increments // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx // @@ -2669,16 +2654,8 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - if (glRefConfig.framebufferObject) - { - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - } - else - { - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.sunShadowFbo[level]->height ); - } + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; shadowParms.viewportWidth = tr.sunShadowFbo[level]->width; shadowParms.viewportHeight = tr.sunShadowFbo[level]->height; shadowParms.isPortal = qfalse; @@ -2687,8 +2664,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) shadowParms.fovX = 90; shadowParms.fovY = 90; - if (glRefConfig.framebufferObject) - shadowParms.targetFbo = tr.sunShadowFbo[level]; + shadowParms.targetFbo = tr.sunShadowFbo[level]; shadowParms.flags = (viewParmFlags_t)( VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL ); shadowParms.zFar = lightviewBounds[1][0]; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index e3eb724863..bc90c47f5e 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -71,10 +71,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in color[0] = color[1] = color[2] = 1.0f; - if (glRefConfig.textureFloat) - color[3] = 0.03f; - else - color[3] = 0.1f; + color[3] = 0.03f; FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } @@ -113,114 +110,111 @@ void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float if (blur < 0.004f) return; - if (glRefConfig.framebufferObject) + // bokeh blur + if (blur > 0.0f) { - // bokeh blur - if (blur > 0.0f) - { - vec4i_t quarterBox; + vec4i_t quarterBox; - quarterBox[0] = 0; - quarterBox[1] = tr.quarterFbo[0]->height; - quarterBox[2] = tr.quarterFbo[0]->width; - quarterBox[3] = -tr.quarterFbo[0]->height; + quarterBox[0] = 0; + quarterBox[1] = tr.quarterFbo[0]->height; + quarterBox[2] = tr.quarterFbo[0]->width; + quarterBox[3] = -tr.quarterFbo[0]->height; - // create a quarter texture - //FBO_Blit(NULL, NULL, NULL, tr.quarterFbo[0], NULL, NULL, NULL, 0); - FBO_FastBlit(src, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } + // create a quarter texture + //FBO_Blit(NULL, NULL, NULL, tr.quarterFbo[0], NULL, NULL, NULL, 0); + FBO_FastBlit(src, srcBox, tr.quarterFbo[0], quarterBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } #ifndef HQ_BLUR - if (blur > 1.0f) - { - // create a 1/16th texture - //FBO_Blit(tr.quarterFbo[0], NULL, NULL, tr.textureScratchFbo[0], NULL, NULL, NULL, 0); - FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - } + if (blur > 1.0f) + { + // create a 1/16th texture + //FBO_Blit(tr.quarterFbo[0], NULL, NULL, tr.textureScratchFbo[0], NULL, NULL, NULL, 0); + FBO_FastBlit(tr.quarterFbo[0], NULL, tr.textureScratchFbo[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + } #endif - if (blur > 0.0f && blur <= 1.0f) - { - // Crossfade original with quarter texture - VectorSet4(color, 1, 1, 1, blur); + if (blur > 0.0f && blur <= 1.0f) + { + // Crossfade original with quarter texture + VectorSet4(color, 1, 1, 1, blur); - FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } + FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } #ifndef HQ_BLUR - // ok blur, but can see some pixelization - else if (blur > 1.0f && blur <= 2.0f) - { - // crossfade quarter texture with 1/16th texture - FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, NULL, 0); + // ok blur, but can see some pixelization + else if (blur > 1.0f && blur <= 2.0f) + { + // crossfade quarter texture with 1/16th texture + FBO_Blit(tr.quarterFbo[0], NULL, NULL, dst, dstBox, NULL, NULL, 0); - VectorSet4(color, 1, 1, 1, blur - 1.0f); + VectorSet4(color, 1, 1, 1, blur - 1.0f); - FBO_Blit(tr.textureScratchFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } - else if (blur > 2.0f) - { - // blur 1/16th texture then replace - int i; - - for (i = 0; i < 2; i++) - { - vec2_t blurTexScale; - float subblur; + FBO_Blit(tr.textureScratchFbo[0], NULL, NULL, dst, dstBox, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); + } + else if (blur > 2.0f) + { + // blur 1/16th texture then replace + int i; - subblur = ((blur - 2.0f) / 2.0f) / 3.0f * (float)(i + 1); + for (i = 0; i < 2; i++) + { + vec2_t blurTexScale; + float subblur; - blurTexScale[0] = - blurTexScale[1] = subblur; + subblur = ((blur - 2.0f) / 2.0f) / 3.0f * (float)(i + 1); - color[0] = - color[1] = - color[2] = 0.5f; - color[3] = 1.0f; + blurTexScale[0] = + blurTexScale[1] = subblur; - if (i != 0) - FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); - else - FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, 0); - } + color[0] = + color[1] = + color[2] = 0.5f; + color[3] = 1.0f; - FBO_Blit(tr.textureScratchFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); + if (i != 0) + FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE); + else + FBO_Blit(tr.textureScratchFbo[0], NULL, blurTexScale, tr.textureScratchFbo[1], NULL, &tr.bokehShader, color, 0); } -#else // higher quality blur, but slower - else if (blur > 1.0f) - { - // blur quarter texture then replace - int i; - src = tr.quarterFbo[0]; - dst = tr.quarterFbo[1]; + FBO_Blit(tr.textureScratchFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); + } +#else // higher quality blur, but slower + else if (blur > 1.0f) + { + // blur quarter texture then replace + int i; - VectorSet4(color, 0.5f, 0.5f, 0.5f, 1); + src = tr.quarterFbo[0]; + dst = tr.quarterFbo[1]; - for (i = 0; i < 2; i++) - { - vec2_t blurTexScale; - float subblur; + VectorSet4(color, 0.5f, 0.5f, 0.5f, 1); - subblur = (blur - 1.0f) / 2.0f * (float)(i + 1); + for (i = 0; i < 2; i++) + { + vec2_t blurTexScale; + float subblur; - blurTexScale[0] = - blurTexScale[1] = subblur; + subblur = (blur - 1.0f) / 2.0f * (float)(i + 1); - color[0] = - color[1] = - color[2] = 1.0f; - if (i != 0) - color[3] = 1.0f; - else - color[3] = 0.5f; + blurTexScale[0] = + blurTexScale[1] = subblur; - FBO_Blit(tr.quarterFbo[0], NULL, blurTexScale, tr.quarterFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); - } + color[0] = + color[1] = + color[2] = 1.0f; + if (i != 0) + color[3] = 1.0f; + else + color[3] = 0.5f; - FBO_Blit(tr.quarterFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); + FBO_Blit(tr.quarterFbo[0], NULL, blurTexScale, tr.quarterFbo[1], NULL, &tr.bokehShader, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } -#endif + + FBO_Blit(tr.quarterFbo[1], NULL, NULL, dst, dstBox, &tr.textureColorShader, NULL, 0); } +#endif } @@ -282,8 +276,6 @@ static void RB_RadialBlur(FBO_t *srcFbo, FBO_t *dstFbo, int passes, float stretc static qboolean RB_UpdateSunFlareVis(void) { GLuint sampleCount = 0; - if (!glRefConfig.occlusionQuery) - return qtrue; tr.sunFlareQueryIndex ^= 1; if (!tr.sunFlareQueryActive[tr.sunFlareQueryIndex]) diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 02bf443980..8a78dd5c7a 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -500,13 +500,13 @@ void RE_RenderScene( const refdef_t *fd ) { } /* playing with more shadows */ - if(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) + if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) { R_RenderPshadowMaps(fd); } // playing with even more shadows - if(glRefConfig.framebufferObject && r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) + if(r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) { R_RenderSunShadowMaps(fd, 0); R_RenderSunShadowMaps(fd, 1); @@ -515,7 +515,7 @@ void RE_RenderScene( const refdef_t *fd ) { // playing with cube maps // this is where dynamic cubemaps would be rendered - if (0) //(glRefConfig.framebufferObject && !( fd->rdflags & RDF_NOWORLDMODEL )) + if (0) //(!( fd->rdflags & RDF_NOWORLDMODEL )) { int i, j; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index dd5a694917..55ffbbc9de 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -42,40 +42,14 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { - if (glRefConfig.drawRangeElements) - qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); - else - qglDrawElements(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); - + qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); } static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) { - if (glRefConfig.multiDrawArrays) - { - qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); - } - else - { - int i; - - if (glRefConfig.drawRangeElements) - { - for (i = 0; i < multiDrawPrimitives; i++) - { - qglDrawRangeElementsEXT(GL_TRIANGLES, multiDrawMinIndex[i], multiDrawMaxIndex[i], multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]); - } - } - else - { - for (i = 0; i < multiDrawPrimitives; i++) - { - qglDrawElements(GL_TRIANGLES, multiDrawNumIndexes[i], GL_INDEX_TYPE, multiDrawFirstIndex[i]); - } - } - } + qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); } @@ -1799,7 +1773,7 @@ void RB_StageIteratorGeneric( void ) // // pshadows! // - if (glRefConfig.framebufferObject && r_shadows->integer == 4 && tess.pshadowBits && + if (r_shadows->integer == 4 && tess.pshadowBits && tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) { ProjectPshadowVBOGLSL(); } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 6cc23d302a..9a027e8bcb 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -25,70 +25,32 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA uint32_t R_VboPackTangent(vec4_t v) { - if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) - { - return (((uint32_t)(v[3] * 1.5f + 2.0f )) << 30) - | (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) - | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) - | (((uint32_t)(v[0] * 511.5f + 512.0f))); - } - else - { - return (((uint32_t)(v[3] * 127.5f + 128.0f)) << 24) - | (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16) - | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8) - | (((uint32_t)(v[0] * 127.5f + 128.0f))); - } + return (((uint32_t)(v[3] * 1.5f + 2.0f )) << 30) + | (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(v[0] * 511.5f + 512.0f))); } uint32_t R_VboPackNormal(vec3_t v) { - if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) - { - return (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) - | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) - | (((uint32_t)(v[0] * 511.5f + 512.0f))); - } - else - { - return (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16) - | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8) - | (((uint32_t)(v[0] * 127.5f + 128.0f))); - } + return (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(v[0] * 511.5f + 512.0f))); } void R_VboUnpackTangent(vec4_t v, uint32_t b) { - if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) - { - v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; - v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; - v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; - v[3] = ((b >> 30) & 0x3) * 1.0f/1.5f - 1.0f; - } - else - { - v[0] = ((b) & 0xff) * 1.0f/127.5f - 1.0f; - v[1] = ((b >> 8) & 0xff) * 1.0f/127.5f - 1.0f; - v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f; - v[3] = ((b >> 24) & 0xff) * 1.0f/127.5f - 1.0f; - } + v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[3] = ((b >> 30) & 0x3) * 1.0f/1.5f - 1.0f; } void R_VboUnpackNormal(vec3_t v, uint32_t b) { - if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV) - { - v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; - v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; - v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; - } - else - { - v[0] = ((b) & 0xff) * 1.0f/127.5f - 1.0f; - v[1] = ((b >> 8) & 0xff) * 1.0f/127.5f - 1.0f; - v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f; - } + v[0] = ((b) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f; + v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f; } static GLenum GetGLBufferUsage ( vboUsage_t usage ) From c3a9f065daa0d2a96ca38b6d4ea8da8c88ad2c83 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 09:35:11 +0100 Subject: [PATCH 218/708] [MP] Rend2: Rename extension funcs to core ones This commit renames all extension functions which are part of OpenGL 3.2 with their core names. It also adds a lot of new API functions which are available in 3.2. --- codemp/rd-rend2/qgl.h | 482 +++++++----------- codemp/rd-rend2/tr_backend.cpp | 12 +- codemp/rd-rend2/tr_bsp.cpp | 6 +- codemp/rd-rend2/tr_extensions.cpp | 764 +++++++++++++---------------- codemp/rd-rend2/tr_fbo.cpp | 167 ++++--- codemp/rd-rend2/tr_glsl.cpp | 418 +++++++++------- codemp/rd-rend2/tr_image.cpp | 60 +-- codemp/rd-rend2/tr_init.cpp | 10 +- codemp/rd-rend2/tr_postprocess.cpp | 4 +- codemp/rd-rend2/tr_shade.cpp | 4 +- codemp/rd-rend2/tr_vbo.cpp | 62 +-- 11 files changed, 910 insertions(+), 1079 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index bf33a45ef4..ae7a546041 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -780,102 +780,146 @@ extern void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei #define qglVertexPointer glVertexPointer #define qglViewport glViewport #endif //_WIN32 -// GL_EXT_draw_range_elements -extern void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -// GL_EXT_multi_draw_arrays -extern void (APIENTRY * qglMultiDrawArraysEXT) (GLenum, const GLint *, const GLsizei *, GLsizei); -extern void (APIENTRY * qglMultiDrawElementsEXT) (GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei); - -// GL_ARB_shading_language_100 -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -// GL_ARB_vertex_program -extern void (APIENTRY * qglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -extern void (APIENTRY * qglVertexAttrib4fvARB) (GLuint, const GLfloat *); -extern void (APIENTRY * qglVertexAttribPointerARB) (GLuint index, GLint size, GLenum type, GLboolean normalized, - GLsizei stride, const GLvoid * pointer); -extern void (APIENTRY * qglEnableVertexAttribArrayARB) (GLuint index); -extern void (APIENTRY * qglDisableVertexAttribArrayARB) (GLuint index); - -// GL_ARB_vertex_buffer_object -extern void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer); -extern void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); -extern void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); -extern GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); -extern void (APIENTRY * qglBufferDataARB) (GLenum target, GLint size, const GLvoid * data, GLenum usage); -extern void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLint offset, GLint size, const GLvoid * data); -extern void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); -extern void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); -extern void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params); - -// GL_ARB_shader_objects -extern void (APIENTRY * qglDeleteObjectARB) (GLhandleARB obj); -extern GLhandleARB(APIENTRY * qglGetHandleARB) (GLenum pname); -extern void (APIENTRY * qglDetachObjectARB) (GLhandleARB containerObj, GLhandleARB attachedObj); -extern GLhandleARB(APIENTRY * qglCreateShaderObjectARB) (GLenum shaderType); -extern void (APIENTRY * qglShaderSourceARB) (GLhandleARB shaderObj, GLsizei count, const GLcharARB * *string, - const GLint * length); -extern void (APIENTRY * qglCompileShaderARB) (GLhandleARB shaderObj); -extern GLhandleARB(APIENTRY * qglCreateProgramObjectARB) (void); -extern void (APIENTRY * qglAttachObjectARB) (GLhandleARB containerObj, GLhandleARB obj); -extern void (APIENTRY * qglLinkProgramARB) (GLhandleARB programObj); -extern void (APIENTRY * qglUseProgramObjectARB) (GLhandleARB programObj); -extern void (APIENTRY * qglValidateProgramARB) (GLhandleARB programObj); -extern void (APIENTRY * qglUniform1fARB) (GLint location, GLfloat v0); -extern void (APIENTRY * qglUniform2fARB) (GLint location, GLfloat v0, GLfloat v1); -extern void (APIENTRY * qglUniform3fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -extern void (APIENTRY * qglUniform4fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -extern void (APIENTRY * qglUniform1iARB) (GLint location, GLint v0); -extern void (APIENTRY * qglUniform2iARB) (GLint location, GLint v0, GLint v1); -extern void (APIENTRY * qglUniform3iARB) (GLint location, GLint v0, GLint v1, GLint v2); -extern void (APIENTRY * qglUniform4iARB) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -extern void (APIENTRY * qglUniform1fvARB) (GLint location, GLsizei count, const GLfloat * value); -extern void (APIENTRY * qglUniform2fvARB) (GLint location, GLsizei count, const GLfloat * value); -extern void (APIENTRY * qglUniform3fvARB) (GLint location, GLsizei count, const GLfloat * value); -extern void (APIENTRY * qglUniform4fvARB) (GLint location, GLsizei count, const GLfloat * value); -extern void (APIENTRY * qglUniform2ivARB) (GLint location, GLsizei count, const GLint * value); -extern void (APIENTRY * qglUniform3ivARB) (GLint location, GLsizei count, const GLint * value); -extern void (APIENTRY * qglUniform4ivARB) (GLint location, GLsizei count, const GLint * value); -extern void (APIENTRY * qglUniformMatrix2fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -extern void (APIENTRY * qglUniformMatrix3fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -extern void (APIENTRY * qglUniformMatrix4fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -extern void (APIENTRY * qglGetObjectParameterfvARB) (GLhandleARB obj, GLenum pname, GLfloat * params); -extern void (APIENTRY * qglGetObjectParameterivARB) (GLhandleARB obj, GLenum pname, GLint * params); -extern void (APIENTRY * qglGetInfoLogARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog); -extern void (APIENTRY * qglGetAttachedObjectsARB) (GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, - GLhandleARB * obj); -extern GLint(APIENTRY * qglGetUniformLocationARB) (GLhandleARB programObj, const GLcharARB * name); -extern void (APIENTRY * qglGetActiveUniformARB) (GLhandleARB programObj, GLuint index, GLsizei maxIndex, GLsizei * length, - GLint * size, GLenum * type, GLcharARB * name); -extern void (APIENTRY * qglGetUniformfvARB) (GLhandleARB programObj, GLint location, GLfloat * params); -extern void (APIENTRY * qglGetUniformivARB) (GLhandleARB programObj, GLint location, GLint * params); -extern void (APIENTRY * qglGetShaderSourceARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source); - -// GL_ARB_vertex_shader -extern void (APIENTRY * qglBindAttribLocationARB) (GLhandleARB programObj, GLuint index, const GLcharARB * name); -extern void (APIENTRY * qglGetActiveAttribARB) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, - GLint * size, GLenum * type, GLcharARB * name); -extern GLint(APIENTRY * qglGetAttribLocationARB) (GLhandleARB programObj, const GLcharARB * name); - -// GL_ARB_texture_compression -extern void (APIENTRY * qglCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, - GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, - GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data); -extern void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod, - GLvoid *img); +// Drawing commands +extern PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; +extern PFNGLDRAWARRAYSINSTANCEDPROC qglDrawArraysInstanced; +extern PFNGLDRAWELEMENTSINSTANCEDPROC qglDrawElementsInstanced; +extern PFNGLDRAWELEMENTSBASEVERTEXPROC qglDrawElementsBaseVertex; +extern PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC qglDrawRangeElementsBaseVertex; +extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC qglDrawElementsInstancedBaseVertex; +extern PFNGLMULTIDRAWARRAYSPROC qglMultiDrawArrays; +extern PFNGLMULTIDRAWELEMENTSPROC qglMultiDrawElements; +extern PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC qglMultiDrawElementsBaseVertex; + +// Vertex arrays +extern PFNGLVERTEXATTRIBPOINTERPROC qglVertexAttribPointer; +extern PFNGLVERTEXATTRIBIPOINTERPROC qglVertexAttribIPointer; +extern PFNGLENABLEVERTEXATTRIBARRAYPROC qglEnableVertexAttribArray; +extern PFNGLDISABLEVERTEXATTRIBARRAYPROC qglDisableVertexAttribArray; + +// Vertex array objects +extern PFNGLGENVERTEXARRAYSPROC qglGenVertexArrays; +extern PFNGLDELETEVERTEXARRAYSPROC qglDeleteVertexArrays; +extern PFNGLBINDVERTEXARRAYPROC qglBindVertexArray; +extern PFNGLISVERTEXARRAYPROC qglIsVertexArray; + +// Buffer objects +extern PFNGLBINDBUFFERPROC qglBindBuffer; +extern PFNGLDELETEBUFFERSPROC qglDeleteBuffers; +extern PFNGLGENBUFFERSPROC qglGenBuffers; +extern PFNGLISBUFFERPROC qglIsBuffer; +extern PFNGLBUFFERDATAPROC qglBufferData; +extern PFNGLBUFFERSUBDATAPROC qglBufferSubData; +extern PFNGLGETBUFFERSUBDATAPROC qglGetBufferSubData; +extern PFNGLGETBUFFERPARAMETERIVPROC qglGetBufferParameteriv; +extern PFNGLGETBUFFERPARAMETERI64VPROC qglGetBufferParameteri64v; +extern PFNGLGETBUFFERPOINTERVPROC qglGetBufferPointerv; +extern PFNGLBINDBUFFERRANGEPROC qglBindBufferRange; +extern PFNGLBINDBUFFERBASEPROC qglBindBufferBase; +extern PFNGLMAPBUFFERRANGEPROC qglMapBufferRange; +extern PFNGLMAPBUFFERPROC qglMapBuffer; +extern PFNGLFLUSHMAPPEDBUFFERRANGEPROC qglFlushMappedBufferRange; +extern PFNGLUNMAPBUFFERPROC qglUnmapBuffer; +extern PFNGLCOPYBUFFERSUBDATAPROC qglCopyBufferSubData; +extern PFNGLISBUFFERPROC qglIsBuffer; + +// Shader objects +extern PFNGLCREATESHADERPROC qglCreateShader; +extern PFNGLSHADERSOURCEPROC qglShaderSource; +extern PFNGLCOMPILESHADERPROC qglCompileShader; +extern PFNGLDELETESHADERPROC qglDeleteShader; +extern PFNGLISSHADERPROC qglIsShader; +extern PFNGLGETSHADERIVPROC qglGetShaderiv; +extern PFNGLGETSHADERINFOLOGPROC qglGetShaderInfoLog; +extern PFNGLGETSHADERSOURCEPROC qglGetShaderSource; + +// Program objects +extern PFNGLCREATEPROGRAMPROC qglCreateProgram; +extern PFNGLATTACHSHADERPROC qglAttachShader; +extern PFNGLDETACHSHADERPROC qglDetachShader; +extern PFNGLLINKPROGRAMPROC qglLinkProgram; +extern PFNGLUSEPROGRAMPROC qglUseProgram; +extern PFNGLDELETEPROGRAMPROC qglDeleteProgram; +extern PFNGLVALIDATEPROGRAMPROC qglValidateProgram; +extern PFNGLISPROGRAMPROC qglIsProgram; +extern PFNGLGETPROGRAMIVPROC qglGetProgramiv; +extern PFNGLGETATTACHEDSHADERSPROC qglGetAttachedShaders; +extern PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; + +// Vertex attributes +extern PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; +extern PFNGLGETATTRIBLOCATIONPROC qglGetAttribLocation; +extern PFNGLBINDATTRIBLOCATIONPROC qglBindAttribLocation; +extern PFNGLGETVERTEXATTRIBDVPROC qglGetVertxAttribdv; +extern PFNGLGETVERTEXATTRIBFVPROC qglGetVertxAttribfv; +extern PFNGLGETVERTEXATTRIBIVPROC qglGetVertxAttribiv; +extern PFNGLGETVERTEXATTRIBIIVPROC qglGetVertxAttribIiv; +extern PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertxAttribIuiv; + +// Varying variables +extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC qglTransformFeedbackVaryings; +extern PFNGLGETTRANSFORMFEEDBACKVARYINGPROC qglGetTransformFeedbackVarying; + +// Uniform variables +extern PFNGLGETUNIFORMLOCATIONPROC qglGetUniformLocation; +extern PFNGLGETUNIFORMBLOCKINDEXPROC qglGetUniformBlockIndex; +extern PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC qglGetActiveUniformBlockName; +extern PFNGLGETACTIVEUNIFORMBLOCKIVPROC qglGetActiveUniformBlockiv; +extern PFNGLGETUNIFORMINDICESPROC qglGetUniformIndices; +extern PFNGLGETACTIVEUNIFORMNAMEPROC qglGetActiveUniformName; +extern PFNGLGETACTIVEUNIFORMPROC qglGetActiveUniform; +extern PFNGLGETACTIVEUNIFORMSIVPROC qglGetActiveUniformsiv; +extern PFNGLUNIFORM1IPROC qglUniform1i; +extern PFNGLUNIFORM2IPROC qglUniform2i; +extern PFNGLUNIFORM3IPROC qglUniform3i; +extern PFNGLUNIFORM4IPROC qglUniform4i; +extern PFNGLUNIFORM1FPROC qglUniform1f; +extern PFNGLUNIFORM2FPROC qglUniform2f; +extern PFNGLUNIFORM3FPROC qglUniform3f; +extern PFNGLUNIFORM4FPROC qglUniform4f; +extern PFNGLUNIFORM1IVPROC qglUniform1iv; +extern PFNGLUNIFORM2IVPROC qglUniform2iv; +extern PFNGLUNIFORM3IVPROC qglUniform3iv; +extern PFNGLUNIFORM4IVPROC qglUniform4iv; +extern PFNGLUNIFORM1FVPROC qglUniform1fv; +extern PFNGLUNIFORM2FVPROC qglUniform2fv; +extern PFNGLUNIFORM3FVPROC qglUniform3fv; +extern PFNGLUNIFORM4FVPROC qglUniform4fv; +extern PFNGLUNIFORM1UIPROC qglUniform1ui; +extern PFNGLUNIFORM2UIPROC qglUniform2ui; +extern PFNGLUNIFORM3UIPROC qglUniform3ui; +extern PFNGLUNIFORM4UIPROC qglUniform4ui; +extern PFNGLUNIFORM1UIVPROC qglUniform1uiv; +extern PFNGLUNIFORM2UIVPROC qglUniform2uiv; +extern PFNGLUNIFORM3UIVPROC qglUniform3uiv; +extern PFNGLUNIFORM4UIVPROC qglUniform4uiv; +extern PFNGLUNIFORMMATRIX2FVPROC qglUniformMatrix2fv; +extern PFNGLUNIFORMMATRIX3FVPROC qglUniformMatrix3fv; +extern PFNGLUNIFORMMATRIX4FVPROC qglUniformMatrix4fv; +extern PFNGLUNIFORMMATRIX2X3FVPROC qglUniformMatrix2x3fv; +extern PFNGLUNIFORMMATRIX3X2FVPROC qglUniformMatrix3x2fv; +extern PFNGLUNIFORMMATRIX2X4FVPROC qglUniformMatrix2x4fv; +extern PFNGLUNIFORMMATRIX4X2FVPROC qglUniformMatrix4x2fv; +extern PFNGLUNIFORMMATRIX3X4FVPROC qglUniformMatrix3x4fv; +extern PFNGLUNIFORMMATRIX4X3FVPROC qglUniformMatrix4x3fv; +extern PFNGLUNIFORMBLOCKBINDINGPROC qglUniformBlockBinding; +extern PFNGLGETUNIFORMFVPROC qglGetUniformfv; +extern PFNGLGETUNIFORMIVPROC qglGetUniformiv; +extern PFNGLGETUNIFORMUIVPROC qglGetUniformuiv; + +// Transform feedback +extern PFNGLBEGINTRANSFORMFEEDBACKPROC qglBeginTransformFeedback; +extern PFNGLENDTRANSFORMFEEDBACKPROC qglEndTransformFeedback; + +// Texture compression +extern PFNGLCOMPRESSEDTEXIMAGE3DPROC qglCompressedTexImage3D; +extern PFNGLCOMPRESSEDTEXIMAGE2DPROC qglCompressedTexImage2D; +extern PFNGLCOMPRESSEDTEXIMAGE1DPROC qglCompressedTexImage1D; +extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC qglCompressedTexSubImage3D; +extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC qglCompressedTexSubImage2D; +extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC qglCompressedTexSubImage1D; +extern PFNGLGETCOMPRESSEDTEXIMAGEPROC qglGetCompressedTexImage; // GL_NVX_gpu_memory_info #ifndef GL_NVX_gpu_memory_info @@ -895,190 +939,37 @@ extern void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod, #define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD #endif -// GL_ARB_texture_float -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -// GL_EXT_framebuffer_object -extern GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer); -extern void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); -extern void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers); -extern void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers); -extern void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -extern void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params); -extern GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer); -extern void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer); -extern void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); -extern void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); -extern GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target); -extern void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level); -extern void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level); -extern void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level, GLint zoffset); -extern void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, - GLuint renderbuffer); -extern void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -extern void (APIENTRY * qglGenerateMipmapEXT)(GLenum target); - -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#endif - -// GL_EXT_packed_depth_stencil -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -// GL_ARB_occlusion_query -extern void (APIENTRY * qglGenQueriesARB)(GLsizei n, GLuint *ids); -extern void (APIENTRY * qglDeleteQueriesARB)(GLsizei n, const GLuint *ids); -extern GLboolean (APIENTRY * qglIsQueryARB)(GLuint id); -extern void (APIENTRY * qglBeginQueryARB)(GLenum target, GLuint id); -extern void (APIENTRY * qglEndQueryARB)(GLenum target); -extern void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); -extern void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); -extern void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query -#define GL_SAMPLES_PASSED_ARB 0x8914 -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#endif - -// GL_EXT_framebuffer_blit -extern void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); - -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -// GL_EXT_framebuffer_multisample -extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, - GLenum internalformat, GLsizei width, GLsizei height); - -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#endif +// Framebuffers and renderbuffers +extern PFNGLISRENDERBUFFERPROC qglIsRenderbuffer; +extern PFNGLBINDRENDERBUFFERPROC qglBindRenderbuffer; +extern PFNGLDELETERENDERBUFFERSPROC qglDeleteRenderbuffers; +extern PFNGLGENRENDERBUFFERSPROC qglGenRenderbuffers; +extern PFNGLRENDERBUFFERSTORAGEPROC qglRenderbufferStorage; +extern PFNGLGETRENDERBUFFERPARAMETERIVPROC qglGetRenderbufferParameteriv; +extern PFNGLISFRAMEBUFFERPROC qglIsFramebuffer; +extern PFNGLBINDFRAMEBUFFERPROC qglBindFramebuffer; +extern PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffers; +extern PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffers; +extern PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus; +extern PFNGLFRAMEBUFFERTEXTURE1DPROC qglFramebufferTexture1D; +extern PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D; +extern PFNGLFRAMEBUFFERTEXTURE3DPROC qglFramebufferTexture3D; +extern PFNGLFRAMEBUFFERRENDERBUFFERPROC qglFramebufferRenderbuffer; +extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC qglGetFramebufferAttachmentParameteriv; +extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC qglRenderbufferStorageMultisample; +extern PFNGLBLITFRAMEBUFFERPROC qglBlitFramebuffer; +extern PFNGLGENERATEMIPMAPPROC qglGenerateMipmap; +extern PFNGLDRAWBUFFERSPROC qglDrawBuffers; + +// Query objects +extern PFNGLGENQUERIESPROC qglGenQueries; +extern PFNGLDELETEQUERIESPROC qglDeleteQueries; +extern PFNGLISQUERYPROC qglIsQuery; +extern PFNGLBEGINQUERYPROC qglBeginQuery; +extern PFNGLENDQUERYPROC qglEndQuery; +extern PFNGLGETQUERYIVPROC qglGetQueryiv; +extern PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; +extern PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; #ifndef GL_EXT_texture_compression_latc #define GL_EXT_texture_compression_latc @@ -1096,34 +987,6 @@ extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLs #define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F #endif -// GL_ARB_draw_buffers -extern void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - // GL_ARB_texture_storage extern PFNGLTEXSTORAGE1DPROC qglTexStorage1D; extern PFNGLTEXSTORAGE2DPROC qglTexStorage2D; @@ -1132,11 +995,6 @@ extern PFNGLTEXSTORAGE3DPROC qglTexStorage3D; #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #endif -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - #if defined(WIN32) // WGL_ARB_create_context #ifndef WGL_ARB_create_context diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index fecb33e36a..34b6f7346d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -471,8 +471,8 @@ void RB_BeginDrawingView (void) { // FIXME: hack for cubemap testing if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { - //qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); + //qglFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); } } @@ -758,7 +758,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if (inQuery) { - qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + qglEndQuery(GL_SAMPLES_PASSED); } FBO_Bind(fbo); @@ -1485,11 +1485,11 @@ const void *RB_DrawSurfs( const void *data ) { qglClear( GL_COLOR_BUFFER_BIT ); tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; - qglBeginQueryARB(GL_SAMPLES_PASSED_ARB, tr.sunFlareQuery[tr.sunFlareQueryIndex]); + qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); RB_DrawSun(0.3, tr.sunFlareShader); - qglEndQueryARB(GL_SAMPLES_PASSED_ARB); + qglEndQuery(GL_SAMPLES_PASSED); FBO_Bind(oldFbo); } @@ -1506,7 +1506,7 @@ const void *RB_DrawSurfs( const void *data ) { FBO_Bind(NULL); GL_SelectTexture(TB_CUBEMAP); GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP); - qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); + qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); GL_SelectTexture(0); } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 648c9da509..735e08aff2 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -286,7 +286,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { } if (glRefConfig.floatLightmap) - textureInternalFormat = GL_RGBA16F_ARB; + textureInternalFormat = GL_RGBA16F; else textureInternalFormat = GL_RGBA8; @@ -3317,10 +3317,10 @@ void R_MergeLeafSurfaces(void) mergedSurf->shader = surf1->shader; // finish up the ibo - qglGenBuffersARB(1, &ibo->indexesVBO); + qglGenBuffers(1, &ibo->indexesVBO); R_BindIBO(ibo); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW_ARB); + qglBufferData(GL_ELEMENT_ARRAY_BUFFER, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW); R_BindNullIBO(); GL_CheckErrors(); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 0589e8c3fd..2d17f7ada1 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -32,163 +32,183 @@ extern glwstate_t glw_state; #define GL_GetProcAddress qwglGetProcAddress #endif -// GL_EXT_draw_range_elements -void (APIENTRY * qglDrawRangeElementsEXT) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); - -// GL_EXT_multi_draw_arrays -void (APIENTRY * qglMultiDrawArraysEXT) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -void (APIENTRY * qglMultiDrawElementsEXT) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount); - -// GL_ARB_vertex_shader -void (APIENTRY * qglBindAttribLocationARB) (GLhandleARB programObj, GLuint index, const GLcharARB * name); -void (APIENTRY * qglGetActiveAttribARB) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, - GLint * size, GLenum * type, GLcharARB * name); -GLint(APIENTRY * qglGetAttribLocationARB) (GLhandleARB programObj, const GLcharARB * name); - -// GL_ARB_vertex_program -void (APIENTRY * qglVertexAttrib4fARB) (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -void (APIENTRY * qglVertexAttrib4fvARB) (GLuint, const GLfloat *); -void (APIENTRY * qglVertexAttribPointerARB) (GLuint index, GLint size, GLenum type, GLboolean normalized, - GLsizei stride, const GLvoid * pointer); -void (APIENTRY * qglEnableVertexAttribArrayARB) (GLuint index); -void (APIENTRY * qglDisableVertexAttribArrayARB) (GLuint index); - -// GL_ARB_vertex_buffer_object -void (APIENTRY * qglBindBufferARB) (GLenum target, GLuint buffer); -void (APIENTRY * qglDeleteBuffersARB) (GLsizei n, const GLuint * buffers); -void (APIENTRY * qglGenBuffersARB) (GLsizei n, GLuint * buffers); - -GLboolean(APIENTRY * qglIsBufferARB) (GLuint buffer); -void (APIENTRY * qglBufferDataARB) (GLenum target, GLint size, const GLvoid * data, GLenum usage); -void (APIENTRY * qglBufferSubDataARB) (GLenum target, GLint offset, GLint size, const GLvoid * data); -void (APIENTRY * qglGetBufferSubDataARB) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); - -void (APIENTRY * qglGetBufferParameterivARB) (GLenum target, GLenum pname, GLint * params); -void (APIENTRY * qglGetBufferPointervARB) (GLenum target, GLenum pname, GLvoid * *params); - -// GL_ARB_shader_objects -void (APIENTRY * qglDeleteObjectARB) (GLhandleARB obj); - -GLhandleARB(APIENTRY * qglGetHandleARB) (GLenum pname); -void (APIENTRY * qglDetachObjectARB) (GLhandleARB containerObj, GLhandleARB attachedObj); - -GLhandleARB(APIENTRY * qglCreateShaderObjectARB) (GLenum shaderType); -void (APIENTRY * qglShaderSourceARB) (GLhandleARB shaderObj, GLsizei count, const GLcharARB * *string, - const GLint * length); -void (APIENTRY * qglCompileShaderARB) (GLhandleARB shaderObj); - -GLhandleARB(APIENTRY * qglCreateProgramObjectARB) (void); -void (APIENTRY * qglAttachObjectARB) (GLhandleARB containerObj, GLhandleARB obj); -void (APIENTRY * qglLinkProgramARB) (GLhandleARB programObj); -void (APIENTRY * qglUseProgramObjectARB) (GLhandleARB programObj); -void (APIENTRY * qglValidateProgramARB) (GLhandleARB programObj); -void (APIENTRY * qglUniform1fARB) (GLint location, GLfloat v0); -void (APIENTRY * qglUniform2fARB) (GLint location, GLfloat v0, GLfloat v1); -void (APIENTRY * qglUniform3fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -void (APIENTRY * qglUniform4fARB) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -void (APIENTRY * qglUniform1iARB) (GLint location, GLint v0); -void (APIENTRY * qglUniform2iARB) (GLint location, GLint v0, GLint v1); -void (APIENTRY * qglUniform3iARB) (GLint location, GLint v0, GLint v1, GLint v2); -void (APIENTRY * qglUniform4iARB) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -void (APIENTRY * qglUniform1fvARB) (GLint location, GLsizei count, const GLfloat * value); -void (APIENTRY * qglUniform2fvARB) (GLint location, GLsizei count, const GLfloat * value); -void (APIENTRY * qglUniform3fvARB) (GLint location, GLsizei count, const GLfloat * value); -void (APIENTRY * qglUniform4fvARB) (GLint location, GLsizei count, const GLfloat * value); -void (APIENTRY * qglUniform2ivARB) (GLint location, GLsizei count, const GLint * value); -void (APIENTRY * qglUniform3ivARB) (GLint location, GLsizei count, const GLint * value); -void (APIENTRY * qglUniform4ivARB) (GLint location, GLsizei count, const GLint * value); -void (APIENTRY * qglUniformMatrix2fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -void (APIENTRY * qglUniformMatrix3fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -void (APIENTRY * qglUniformMatrix4fvARB) (GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); -void (APIENTRY * qglGetObjectParameterfvARB) (GLhandleARB obj, GLenum pname, GLfloat * params); -void (APIENTRY * qglGetObjectParameterivARB) (GLhandleARB obj, GLenum pname, GLint * params); -void (APIENTRY * qglGetInfoLogARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog); -void (APIENTRY * qglGetAttachedObjectsARB) (GLhandleARB containerObj, GLsizei maxCount, GLsizei * count, - GLhandleARB * obj); -GLint(APIENTRY * qglGetUniformLocationARB) (GLhandleARB programObj, const GLcharARB * name); -void (APIENTRY * qglGetActiveUniformARB) (GLhandleARB programObj, GLuint index, GLsizei maxIndex, GLsizei * length, - GLint * size, GLenum * type, GLcharARB * name); -void (APIENTRY * qglGetUniformfvARB) (GLhandleARB programObj, GLint location, GLfloat * params); -void (APIENTRY * qglGetUniformivARB) (GLhandleARB programObj, GLint location, GLint * params); -void (APIENTRY * qglGetShaderSourceARB) (GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source); - -// GL_ARB_texture_compression -void (APIENTRY * qglCompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, - GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglCompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglCompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, - GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglCompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, - GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglCompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, - GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglCompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, - GLsizei imageSize, const GLvoid *data); -void (APIENTRY * qglGetCompressedTexImageARB)(GLenum target, GLint lod, - GLvoid *img); - -// GL_EXT_framebuffer_object -GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer); -void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer); -void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers); -void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers); - -void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); - -void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params); - -GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer); -void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer); -void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers); -void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers); - -GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target); - -void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level); -void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level); -void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, - GLint level, GLint zoffset); - -void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, - GLuint renderbuffer); - -void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params); - -void (APIENTRY * qglGenerateMipmapEXT)(GLenum target); - -// GL_ARB_occlusion_query -void (APIENTRY * qglGenQueriesARB)(GLsizei n, GLuint *ids); -void (APIENTRY * qglDeleteQueriesARB)(GLsizei n, const GLuint *ids); -GLboolean (APIENTRY * qglIsQueryARB)(GLuint id); -void (APIENTRY * qglBeginQueryARB)(GLenum target, GLuint id); -void (APIENTRY * qglEndQueryARB)(GLenum target); -void (APIENTRY * qglGetQueryivARB)(GLenum target, GLenum pname, GLint *params); -void (APIENTRY * qglGetQueryObjectivARB)(GLuint id, GLenum pname, GLint *params); -void (APIENTRY * qglGetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint *params); - -// GL_EXT_framebuffer_blit -void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); - -// GL_EXT_framebuffer_multisample -void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples, - GLenum internalformat, GLsizei width, GLsizei height); - -// GL_ARB_draw_buffers -void (APIENTRY * qglDrawBuffersARB)(GLsizei n, const GLenum *bufs); +// Drawing commands +PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; +PFNGLDRAWARRAYSINSTANCEDPROC qglDrawArraysInstanced; +PFNGLDRAWELEMENTSINSTANCEDPROC qglDrawElementsInstanced; +PFNGLDRAWELEMENTSBASEVERTEXPROC qglDrawElementsBaseVertex; +PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC qglDrawRangeElementsBaseVertex; +PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC qglDrawElementsInstancedBaseVertex; +PFNGLMULTIDRAWARRAYSPROC qglMultiDrawArrays; +PFNGLMULTIDRAWELEMENTSPROC qglMultiDrawElements; +PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC qglMultiDrawElementsBaseVertex; + +// Vertex arrays +PFNGLVERTEXATTRIBPOINTERPROC qglVertexAttribPointer; +PFNGLVERTEXATTRIBIPOINTERPROC qglVertexAttribIPointer; +PFNGLENABLEVERTEXATTRIBARRAYPROC qglEnableVertexAttribArray; +PFNGLDISABLEVERTEXATTRIBARRAYPROC qglDisableVertexAttribArray; + +// Vertex array objects +PFNGLGENVERTEXARRAYSPROC qglGenVertexArrays; +PFNGLDELETEVERTEXARRAYSPROC qglDeleteVertexArrays; +PFNGLBINDVERTEXARRAYPROC qglBindVertexArray; +PFNGLISVERTEXARRAYPROC qglIsVertexArray; + +// Buffer objects +PFNGLBINDBUFFERPROC qglBindBuffer; +PFNGLDELETEBUFFERSPROC qglDeleteBuffers; +PFNGLGENBUFFERSPROC qglGenBuffers; +PFNGLBUFFERDATAPROC qglBufferData; +PFNGLBUFFERSUBDATAPROC qglBufferSubData; +PFNGLGETBUFFERSUBDATAPROC qglGetBufferSubData; +PFNGLGETBUFFERPARAMETERIVPROC qglGetBufferParameteriv; +PFNGLGETBUFFERPARAMETERI64VPROC qglGetBufferParameteri64v; +PFNGLGETBUFFERPOINTERVPROC qglGetBufferPointerv; +PFNGLBINDBUFFERRANGEPROC qglBindBufferRange; +PFNGLBINDBUFFERBASEPROC qglBindBufferBase; +PFNGLMAPBUFFERRANGEPROC qglMapBufferRange; +PFNGLMAPBUFFERPROC qglMapBuffer; +PFNGLFLUSHMAPPEDBUFFERRANGEPROC qglFlushMappedBufferRange; +PFNGLUNMAPBUFFERPROC qglUnmapBuffer; +PFNGLCOPYBUFFERSUBDATAPROC qglCopyBufferSubData; +PFNGLISBUFFERPROC qglIsBuffer; + +// Shader objects +PFNGLCREATESHADERPROC qglCreateShader; +PFNGLSHADERSOURCEPROC qglShaderSource; +PFNGLCOMPILESHADERPROC qglCompileShader; +PFNGLDELETESHADERPROC qglDeleteShader; +PFNGLISSHADERPROC qglIsShader; +PFNGLGETSHADERIVPROC qglGetShaderiv; +PFNGLGETSHADERINFOLOGPROC qglGetShaderInfoLog; +PFNGLGETSHADERSOURCEPROC qglGetShaderSource; + +// Program objects +PFNGLCREATEPROGRAMPROC qglCreateProgram; +PFNGLATTACHSHADERPROC qglAttachShader; +PFNGLDETACHSHADERPROC qglDetachShader; +PFNGLLINKPROGRAMPROC qglLinkProgram; +PFNGLUSEPROGRAMPROC qglUseProgram; +PFNGLDELETEPROGRAMPROC qglDeleteProgram; +PFNGLVALIDATEPROGRAMPROC qglValidateProgram; +PFNGLISPROGRAMPROC qglIsProgram; +PFNGLGETPROGRAMIVPROC qglGetProgramiv; +PFNGLGETATTACHEDSHADERSPROC qglGetAttachedShaders; +PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; + +// Vertex attributes +PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; +PFNGLGETATTRIBLOCATIONPROC qglGetAttribLocation; +PFNGLBINDATTRIBLOCATIONPROC qglBindAttribLocation; +PFNGLGETVERTEXATTRIBDVPROC qglGetVertxAttribdv; +PFNGLGETVERTEXATTRIBFVPROC qglGetVertxAttribfv; +PFNGLGETVERTEXATTRIBIVPROC qglGetVertxAttribiv; +PFNGLGETVERTEXATTRIBIIVPROC qglGetVertxAttribIiv; +PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertxAttribIuiv; + +// Varying variables +PFNGLTRANSFORMFEEDBACKVARYINGSPROC qglTransformFeedbackVaryings; +PFNGLGETTRANSFORMFEEDBACKVARYINGPROC qglGetTransformFeedbackVarying; + +// Uniform variables +PFNGLGETUNIFORMLOCATIONPROC qglGetUniformLocation; +PFNGLGETUNIFORMBLOCKINDEXPROC qglGetUniformBlockIndex; +PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC qglGetActiveUniformBlockName; +PFNGLGETACTIVEUNIFORMBLOCKIVPROC qglGetActiveUniformBlockiv; +PFNGLGETUNIFORMINDICESPROC qglGetUniformIndices; +PFNGLGETACTIVEUNIFORMNAMEPROC qglGetActiveUniformName; +PFNGLGETACTIVEUNIFORMPROC qglGetActiveUniform; +PFNGLGETACTIVEUNIFORMSIVPROC qglGetActiveUniformsiv; +PFNGLUNIFORM1IPROC qglUniform1i; +PFNGLUNIFORM2IPROC qglUniform2i; +PFNGLUNIFORM3IPROC qglUniform3i; +PFNGLUNIFORM4IPROC qglUniform4i; +PFNGLUNIFORM1FPROC qglUniform1f; +PFNGLUNIFORM2FPROC qglUniform2f; +PFNGLUNIFORM3FPROC qglUniform3f; +PFNGLUNIFORM4FPROC qglUniform4f; +PFNGLUNIFORM1IVPROC qglUniform1iv; +PFNGLUNIFORM2IVPROC qglUniform2iv; +PFNGLUNIFORM3IVPROC qglUniform3iv; +PFNGLUNIFORM4IVPROC qglUniform4iv; +PFNGLUNIFORM1FVPROC qglUniform1fv; +PFNGLUNIFORM2FVPROC qglUniform2fv; +PFNGLUNIFORM3FVPROC qglUniform3fv; +PFNGLUNIFORM4FVPROC qglUniform4fv; +PFNGLUNIFORM1UIPROC qglUniform1ui; +PFNGLUNIFORM2UIPROC qglUniform2ui; +PFNGLUNIFORM3UIPROC qglUniform3ui; +PFNGLUNIFORM4UIPROC qglUniform4ui; +PFNGLUNIFORM1UIVPROC qglUniform1uiv; +PFNGLUNIFORM2UIVPROC qglUniform2uiv; +PFNGLUNIFORM3UIVPROC qglUniform3uiv; +PFNGLUNIFORM4UIVPROC qglUniform4uiv; +PFNGLUNIFORMMATRIX2FVPROC qglUniformMatrix2fv; +PFNGLUNIFORMMATRIX3FVPROC qglUniformMatrix3fv; +PFNGLUNIFORMMATRIX4FVPROC qglUniformMatrix4fv; +PFNGLUNIFORMMATRIX2X3FVPROC qglUniformMatrix2x3fv; +PFNGLUNIFORMMATRIX3X2FVPROC qglUniformMatrix3x2fv; +PFNGLUNIFORMMATRIX2X4FVPROC qglUniformMatrix2x4fv; +PFNGLUNIFORMMATRIX4X2FVPROC qglUniformMatrix4x2fv; +PFNGLUNIFORMMATRIX3X4FVPROC qglUniformMatrix3x4fv; +PFNGLUNIFORMMATRIX4X3FVPROC qglUniformMatrix4x3fv; +PFNGLUNIFORMBLOCKBINDINGPROC qglUniformBlockBinding; +PFNGLGETUNIFORMFVPROC qglGetUniformfv; +PFNGLGETUNIFORMIVPROC qglGetUniformiv; +PFNGLGETUNIFORMUIVPROC qglGetUniformuiv; + +// Transform feedback +PFNGLBEGINTRANSFORMFEEDBACKPROC qglBeginTransformFeedback; +PFNGLENDTRANSFORMFEEDBACKPROC qglEndTransformFeedback; + +// Texture compression +PFNGLCOMPRESSEDTEXIMAGE3DPROC qglCompressedTexImage3D; +PFNGLCOMPRESSEDTEXIMAGE2DPROC qglCompressedTexImage2D; +PFNGLCOMPRESSEDTEXIMAGE1DPROC qglCompressedTexImage1D; +PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC qglCompressedTexSubImage3D; +PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC qglCompressedTexSubImage2D; +PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC qglCompressedTexSubImage1D; +PFNGLGETCOMPRESSEDTEXIMAGEPROC qglGetCompressedTexImage; + +// Framebuffers +PFNGLISRENDERBUFFERPROC qglIsRenderbuffer; +PFNGLBINDRENDERBUFFERPROC qglBindRenderbuffer; +PFNGLDELETERENDERBUFFERSPROC qglDeleteRenderbuffers; +PFNGLGENRENDERBUFFERSPROC qglGenRenderbuffers; +PFNGLRENDERBUFFERSTORAGEPROC qglRenderbufferStorage; +PFNGLGETRENDERBUFFERPARAMETERIVPROC qglGetRenderbufferParameteriv; +PFNGLISFRAMEBUFFERPROC qglIsFramebuffer; +PFNGLBINDFRAMEBUFFERPROC qglBindFramebuffer; +PFNGLDELETEFRAMEBUFFERSPROC qglDeleteFramebuffers; +PFNGLGENFRAMEBUFFERSPROC qglGenFramebuffers; +PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus; +PFNGLFRAMEBUFFERTEXTURE1DPROC qglFramebufferTexture1D; +PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D; +PFNGLFRAMEBUFFERTEXTURE3DPROC qglFramebufferTexture3D; +PFNGLFRAMEBUFFERRENDERBUFFERPROC qglFramebufferRenderbuffer; +PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC qglGetFramebufferAttachmentParameteriv; +PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC qglRenderbufferStorageMultisample; +PFNGLBLITFRAMEBUFFERPROC qglBlitFramebuffer; +PFNGLGENERATEMIPMAPPROC qglGenerateMipmap; +PFNGLCLEARBUFFERFVPROC qglClearBufferfv; +PFNGLDRAWBUFFERSPROC qglDrawBuffers; + +// Query objects +PFNGLGENQUERIESPROC qglGenQueries; +PFNGLDELETEQUERIESPROC qglDeleteQueries; +PFNGLISQUERYPROC qglIsQuery; +PFNGLBEGINQUERYPROC qglBeginQuery; +PFNGLENDQUERYPROC qglEndQuery; +PFNGLGETQUERYIVPROC qglGetQueryiv; +PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; +PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; // GL_ARB_texture_storage PFNGLTEXSTORAGE1DPROC qglTexStorage1D; PFNGLTEXSTORAGE2DPROC qglTexStorage2D; PFNGLTEXSTORAGE3DPROC qglTexStorage3D; -// OpenGL 3.0 -PFNGLCLEARBUFFERFVPROC qglClearBufferfv; - static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); @@ -203,217 +223,193 @@ void GLimp_InitExtraExtensions() char *extension; const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; - // GL_EXT_draw_range_elements - qglDrawRangeElementsEXT = (void (QCALL *)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *))GL_GetProcAddress("glDrawRangeElementsEXT"); - - // GL_EXT_multi_draw_arrays - qglMultiDrawArraysEXT = (PFNGLMULTIDRAWARRAYSEXTPROC) GL_GetProcAddress("glMultiDrawArraysEXT"); - qglMultiDrawElementsEXT = (PFNGLMULTIDRAWELEMENTSEXTPROC) GL_GetProcAddress("glMultiDrawElementsEXT"); - - // GL_ARB_vertex_program - //glRefConfig.vertexProgram = qfalse; - extension = "GL_ARB_vertex_program"; - qglVertexAttrib4fARB = NULL; - qglVertexAttrib4fvARB = NULL; - qglVertexAttribPointerARB = NULL; - qglEnableVertexAttribArrayARB = NULL; - qglDisableVertexAttribArrayARB = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglVertexAttrib4fARB = (PFNGLVERTEXATTRIB4FARBPROC) GL_GetProcAddress("glVertexAttrib4fARB"); - qglVertexAttrib4fvARB = (PFNGLVERTEXATTRIB4FVARBPROC) GL_GetProcAddress("glVertexAttrib4fvARB"); - qglVertexAttribPointerARB = (PFNGLVERTEXATTRIBPOINTERARBPROC) GL_GetProcAddress("glVertexAttribPointerARB"); - qglEnableVertexAttribArrayARB = - (PFNGLENABLEVERTEXATTRIBARRAYARBPROC) GL_GetProcAddress("glEnableVertexAttribArrayARB"); - qglDisableVertexAttribArrayARB = - (PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) GL_GetProcAddress("glDisableVertexAttribArrayARB"); - - ri->Printf(PRINT_ALL, result[1], extension); - //glRefConfig.vertexProgram = qtrue; - } - else - { - ri->Error(ERR_FATAL, result[2], extension); - } + // Drawing commands + qglDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GL_GetProcAddress("glDrawRangeElements"); + qglDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)GL_GetProcAddress("glDrawArraysInstanced"); + qglDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)GL_GetProcAddress("glDrawElementsInstanced"); + qglDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glDrawElementsBaseVertex"); + qglDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glDrawRangeElementsBaseVertex"); + qglDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)GL_GetProcAddress("glDrawElementsInstancedBaseVertex"); + qglMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)GL_GetProcAddress("glMultiDrawArrays"); + qglMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)GL_GetProcAddress("glMultiDrawElements"); + qglMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glMultiDrawElementsBaseVertex"); + + // Vertex arrays + qglVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)GL_GetProcAddress("glVertexAttribPointer"); + qglVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)GL_GetProcAddress("glVertexAttribIPointer"); + qglEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)GL_GetProcAddress("glEnableVertexAttribArray"); + qglDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)GL_GetProcAddress("glDisableVertexAttribArray"); + + // Vertex array objects + qglGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)GL_GetProcAddress("glGenVertexArrays"); + qglDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)GL_GetProcAddress("glDeleteVertexArrays"); + qglBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)GL_GetProcAddress("glBindVertexArray"); + qglIsVertexArray = (PFNGLISVERTEXARRAYPROC)GL_GetProcAddress("glIsVertexArray"); - // GL_ARB_vertex_buffer_object - //glRefConfig.vertexBufferObject = qfalse; - extension = "GL_ARB_vertex_buffer_object"; - qglBindBufferARB = NULL; - qglDeleteBuffersARB = NULL; - qglGenBuffersARB = NULL; - qglIsBufferARB = NULL; - qglBufferDataARB = NULL; - qglBufferSubDataARB = NULL; - qglGetBufferSubDataARB = NULL; - qglGetBufferParameterivARB = NULL; - qglGetBufferPointervARB = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglBindBufferARB = (PFNGLBINDBUFFERARBPROC) GL_GetProcAddress("glBindBufferARB"); - qglDeleteBuffersARB = (PFNGLDELETEBUFFERSARBPROC) GL_GetProcAddress("glDeleteBuffersARB"); - qglGenBuffersARB = (PFNGLGENBUFFERSARBPROC) GL_GetProcAddress("glGenBuffersARB"); - qglIsBufferARB = (PFNGLISBUFFERARBPROC) GL_GetProcAddress("glIsBufferARB"); - qglBufferDataARB = (void (QCALL *)(GLenum,GLint,const GLvoid *,GLenum)) GL_GetProcAddress("glBufferDataARB"); - qglBufferSubDataARB = (void (QCALL *)(GLenum,GLint,GLint,const GLvoid *)) GL_GetProcAddress("glBufferSubDataARB"); - qglGetBufferSubDataARB = (void (QCALL *)(GLenum,GLintptrARB,GLsizeiptrARB,GLvoid*)) GL_GetProcAddress("glGetBufferSubDataARB"); - qglGetBufferParameterivARB = (PFNGLGETBUFFERPARAMETERIVARBPROC) GL_GetProcAddress("glGetBufferParameterivARB"); - qglGetBufferPointervARB = (PFNGLGETBUFFERPOINTERVARBPROC) GL_GetProcAddress("glGetBufferPointervARB"); - ri->Printf(PRINT_ALL, result[1], extension); - //glRefConfig.vertexBufferObject = qtrue; - } - else - { - ri->Error(ERR_FATAL, result[2], extension); - } - - // GL_ARB_shader_objects - extension = "GL_ARB_shader_objects"; - //glRefConfig.shaderObjects = qfalse; - qglDeleteObjectARB = NULL; - qglGetHandleARB = NULL; - qglDetachObjectARB = NULL; - qglCreateShaderObjectARB = NULL; - qglShaderSourceARB = NULL; - qglCompileShaderARB = NULL; - qglCreateProgramObjectARB = NULL; - qglAttachObjectARB = NULL; - qglLinkProgramARB = NULL; - qglUseProgramObjectARB = NULL; - qglValidateProgramARB = NULL; - qglUniform1fARB = NULL; - qglUniform2fARB = NULL; - qglUniform3fARB = NULL; - qglUniform4fARB = NULL; - qglUniform1iARB = NULL; - qglUniform2iARB = NULL; - qglUniform3iARB = NULL; - qglUniform4iARB = NULL; - qglUniform1fvARB = NULL; - qglUniform2fvARB = NULL; - qglUniform3fvARB = NULL; - qglUniform4fvARB = NULL; - qglUniform2ivARB = NULL; - qglUniform3ivARB = NULL; - qglUniform4ivARB = NULL; - qglUniformMatrix2fvARB = NULL; - qglUniformMatrix3fvARB = NULL; - qglUniformMatrix4fvARB = NULL; - qglGetObjectParameterfvARB = NULL; - qglGetObjectParameterivARB = NULL; - qglGetInfoLogARB = NULL; - qglGetAttachedObjectsARB = NULL; - qglGetUniformLocationARB = NULL; - qglGetActiveUniformARB = NULL; - qglGetUniformfvARB = NULL; - qglGetUniformivARB = NULL; - qglGetShaderSourceARB = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) GL_GetProcAddress("glDeleteObjectARB"); - qglGetHandleARB = (PFNGLGETHANDLEARBPROC) GL_GetProcAddress("glGetHandleARB"); - qglDetachObjectARB = (PFNGLDETACHOBJECTARBPROC) GL_GetProcAddress("glDetachObjectARB"); - qglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) GL_GetProcAddress("glCreateShaderObjectARB"); - qglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) GL_GetProcAddress("glShaderSourceARB"); - qglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) GL_GetProcAddress("glCompileShaderARB"); - qglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) GL_GetProcAddress("glCreateProgramObjectARB"); - qglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) GL_GetProcAddress("glAttachObjectARB"); - qglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GL_GetProcAddress("glLinkProgramARB"); - qglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GL_GetProcAddress("glUseProgramObjectARB"); - qglValidateProgramARB = (PFNGLVALIDATEPROGRAMARBPROC) GL_GetProcAddress("glValidateProgramARB"); - qglUniform1fARB = (PFNGLUNIFORM1FARBPROC) GL_GetProcAddress("glUniform1fARB"); - qglUniform2fARB = (PFNGLUNIFORM2FARBPROC) GL_GetProcAddress("glUniform2fARB"); - qglUniform3fARB = (PFNGLUNIFORM3FARBPROC) GL_GetProcAddress("glUniform3fARB"); - qglUniform4fARB = (PFNGLUNIFORM4FARBPROC) GL_GetProcAddress("glUniform4fARB"); - qglUniform1iARB = (PFNGLUNIFORM1IARBPROC) GL_GetProcAddress("glUniform1iARB"); - qglUniform2iARB = (PFNGLUNIFORM2IARBPROC) GL_GetProcAddress("glUniform2iARB"); - qglUniform3iARB = (PFNGLUNIFORM3IARBPROC) GL_GetProcAddress("glUniform3iARB"); - qglUniform4iARB = (PFNGLUNIFORM4IARBPROC) GL_GetProcAddress("glUniform4iARB"); - qglUniform1fvARB = (PFNGLUNIFORM1FVARBPROC) GL_GetProcAddress("glUniform1fvARB"); - qglUniform2fvARB = (PFNGLUNIFORM2FVARBPROC) GL_GetProcAddress("glUniform2fvARB"); - qglUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) GL_GetProcAddress("glUniform3fvARB"); - qglUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GL_GetProcAddress("glUniform4fvARB"); - qglUniform2ivARB = (PFNGLUNIFORM2IVARBPROC) GL_GetProcAddress("glUniform2ivARB"); - qglUniform3ivARB = (PFNGLUNIFORM3IVARBPROC) GL_GetProcAddress("glUniform3ivARB"); - qglUniform4ivARB = (PFNGLUNIFORM4IVARBPROC) GL_GetProcAddress("glUniform4ivARB"); - qglUniformMatrix2fvARB = (PFNGLUNIFORMMATRIX2FVARBPROC) GL_GetProcAddress("glUniformMatrix2fvARB"); - qglUniformMatrix3fvARB = (PFNGLUNIFORMMATRIX3FVARBPROC) GL_GetProcAddress("glUniformMatrix3fvARB"); - qglUniformMatrix4fvARB = (PFNGLUNIFORMMATRIX4FVARBPROC) GL_GetProcAddress("glUniformMatrix4fvARB"); - qglGetObjectParameterfvARB = (PFNGLGETOBJECTPARAMETERFVARBPROC) GL_GetProcAddress("glGetObjectParameterfvARB"); - qglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) GL_GetProcAddress("glGetObjectParameterivARB"); - qglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) GL_GetProcAddress("glGetInfoLogARB"); - qglGetAttachedObjectsARB = (PFNGLGETATTACHEDOBJECTSARBPROC) GL_GetProcAddress("glGetAttachedObjectsARB"); - qglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GL_GetProcAddress("glGetUniformLocationARB"); - qglGetActiveUniformARB = (PFNGLGETACTIVEUNIFORMARBPROC) GL_GetProcAddress("glGetActiveUniformARB"); - qglGetUniformfvARB = (PFNGLGETUNIFORMFVARBPROC) GL_GetProcAddress("glGetUniformfvARB"); - qglGetUniformivARB = (PFNGLGETUNIFORMIVARBPROC) GL_GetProcAddress("glGetUniformivARB"); - qglGetShaderSourceARB = (PFNGLGETSHADERSOURCEARBPROC) GL_GetProcAddress("glGetShaderSourceARB"); - ri->Printf(PRINT_ALL, result[1], extension); - //glRefConfig.shaderObjects = qtrue; - } - else - { - ri->Error(ERR_FATAL, result[2], extension); - } - - // GL_ARB_vertex_shader - //glRefConfig.vertexShader = qfalse; - extension = "GL_ARB_vertex_shader"; - qglBindAttribLocationARB = NULL; - qglGetActiveAttribARB = NULL; - qglGetAttribLocationARB = NULL; - if( GLimp_HaveExtension( extension ) ) - { - //int reservedComponents; - - //qglGetIntegerv(GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.maxVertexUniforms); - //qglGetIntegerv(GL_MAX_VARYING_FLOATS_ARB, &glConfig.maxVaryingFloats); - //qglGetIntegerv(GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.maxVertexAttribs); - - //reservedComponents = 16 * 10; // approximation how many uniforms we have besides the bone matrices - -#if 0 - if(glConfig.driverType == GLDRV_MESA) - { - // HACK - // restrict to number of vertex uniforms to 512 because of: - // xreal.x86_64: nv50_program.c:4181: nv50_program_validate_data: Assertion `p->param_nr <= 512' failed - - glConfig.maxVertexUniforms = Q_bound(0, glConfig.maxVertexUniforms, 512); - } -#endif - - //glConfig.maxVertexSkinningBones = (int) Q_bound(0.0, (Q_max(glConfig.maxVertexUniforms - reservedComponents, 0) / 16), MAX_BONES); - //glConfig.vboVertexSkinningAvailable = r_vboVertexSkinning->integer && ((glConfig.maxVertexSkinningBones >= 12) ? qtrue : qfalse); - - qglBindAttribLocationARB = (PFNGLBINDATTRIBLOCATIONARBPROC) GL_GetProcAddress("glBindAttribLocationARB"); - qglGetActiveAttribARB = (PFNGLGETACTIVEATTRIBARBPROC) GL_GetProcAddress("glGetActiveAttribARB"); - qglGetAttribLocationARB = (PFNGLGETATTRIBLOCATIONARBPROC) GL_GetProcAddress("glGetAttribLocationARB"); - ri->Printf(PRINT_ALL, result[1], extension); - //glRefConfig.vertexShader = qtrue; - } - else - { - ri->Error(ERR_FATAL, result[2], extension); - } - - // GL_ARB_shading_language_100 - extension = "GL_ARB_shading_language_100"; - if( GLimp_HaveExtension( extension ) ) + // Buffer objects + qglBindBuffer = (PFNGLBINDBUFFERPROC)GL_GetProcAddress("glBindBuffer"); + qglDeleteBuffers = (PFNGLDELETEBUFFERSPROC)GL_GetProcAddress("glDeleteBuffers"); + qglGenBuffers = (PFNGLGENBUFFERSPROC)GL_GetProcAddress("glGenBuffers"); + qglBufferData = (PFNGLBUFFERDATAPROC)GL_GetProcAddress("glBufferData"); + qglBufferSubData = (PFNGLBUFFERSUBDATAPROC)GL_GetProcAddress("glBufferSubData"); + qglGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)GL_GetProcAddress("glGetBufferSubData"); + qglGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)GL_GetProcAddress("glGetBufferParameteriv"); + qglGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)GL_GetProcAddress("glGetBufferParameteri64v"); + qglGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)GL_GetProcAddress("glGetBufferPointerv"); + qglBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)GL_GetProcAddress("glBindBufferRange"); + qglBindBufferBase = (PFNGLBINDBUFFERBASEPROC)GL_GetProcAddress("glBindBufferBase"); + qglMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)GL_GetProcAddress("glMapBufferRange"); + qglMapBuffer = (PFNGLMAPBUFFERPROC)GL_GetProcAddress("glMapBuffer"); + qglFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)GL_GetProcAddress("glFlushMappedBufferRange"); + qglUnmapBuffer = (PFNGLUNMAPBUFFERPROC)GL_GetProcAddress("glUnmapBuffer"); + qglCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)GL_GetProcAddress("glCopyBufferSubData"); + qglIsBuffer = (PFNGLISBUFFERPROC)GL_GetProcAddress("glIsBuffer"); + + // Shader objects + qglCreateShader = (PFNGLCREATESHADERPROC)GL_GetProcAddress("glCreateShader"); + qglShaderSource = (PFNGLSHADERSOURCEPROC)GL_GetProcAddress("glShaderSource"); + qglCompileShader = (PFNGLCOMPILESHADERPROC)GL_GetProcAddress("glCompileShader"); + qglDeleteShader = (PFNGLDELETESHADERPROC)GL_GetProcAddress("glDeleteShader"); + qglIsShader = (PFNGLISSHADERPROC)GL_GetProcAddress("glIsShader"); + qglGetShaderiv = (PFNGLGETSHADERIVPROC)GL_GetProcAddress("glGetShaderiv"); + qglGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)GL_GetProcAddress("glGetShaderInfoLog"); + qglGetShaderSource = (PFNGLGETSHADERSOURCEPROC)GL_GetProcAddress("glGetShaderSource"); + + // Program objects + qglCreateProgram = (PFNGLCREATEPROGRAMPROC)GL_GetProcAddress("glCreateProgram"); + qglAttachShader = (PFNGLATTACHSHADERPROC)GL_GetProcAddress("glAttachShader"); + qglDetachShader = (PFNGLDETACHSHADERPROC)GL_GetProcAddress("glDetachShader"); + qglLinkProgram = (PFNGLLINKPROGRAMPROC)GL_GetProcAddress("glLinkProgram"); + qglUseProgram = (PFNGLUSEPROGRAMPROC)GL_GetProcAddress("glUseProgram"); + qglDeleteProgram = (PFNGLDELETEPROGRAMPROC)GL_GetProcAddress("glDeleteProgram"); + qglValidateProgram = (PFNGLVALIDATEPROGRAMPROC)GL_GetProcAddress("glValidateProgram"); + qglIsProgram = (PFNGLISPROGRAMPROC)GL_GetProcAddress("glIsProgram"); + qglGetProgramiv = (PFNGLGETPROGRAMIVPROC)GL_GetProcAddress("glGetProgramiv"); + qglGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)GL_GetProcAddress("glGetAttachedShaders"); + qglGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)GL_GetProcAddress("glGetProgramInfoLog"); + + // Vertex attributes + qglGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)GL_GetProcAddress("glGetActiveAttrib"); + qglGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)GL_GetProcAddress("glGetAttribLocation"); + qglBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)GL_GetProcAddress("glBindAttribLocation"); + qglGetVertxAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)GL_GetProcAddress("glGetVertxAttribdv"); + qglGetVertxAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)GL_GetProcAddress("glGetVertxAttribfv"); + qglGetVertxAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)GL_GetProcAddress("glGetVertxAttribiv"); + qglGetVertxAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)GL_GetProcAddress("glGetVertxAttribIiv"); + qglGetVertxAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)GL_GetProcAddress("glGetVertxAttribIuiv"); + + // Varying variables + qglTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)GL_GetProcAddress("glTransformFeedbackVaryings"); + qglGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)GL_GetProcAddress("glGetTransformFeedbackVarying"); + + // Uniform variables + qglGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)GL_GetProcAddress("glGetUniformLocation"); + qglGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GL_GetProcAddress("glGetUniformBlockIndex"); + qglGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)GL_GetProcAddress("glGetActiveUniformBlockName"); + qglGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)GL_GetProcAddress("glGetActiveUniformBlockiv"); + qglGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)GL_GetProcAddress("glGetUniformIndices"); + qglGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)GL_GetProcAddress("glGetActiveUniformName"); + qglGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)GL_GetProcAddress("glGetActiveUniform"); + qglGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)GL_GetProcAddress("glGetActiveUniformsiv"); + qglUniform1i = (PFNGLUNIFORM1IPROC)GL_GetProcAddress("glUniform1i"); + qglUniform2i = (PFNGLUNIFORM2IPROC)GL_GetProcAddress("glUniform2i"); + qglUniform3i = (PFNGLUNIFORM3IPROC)GL_GetProcAddress("glUniform3i"); + qglUniform4i = (PFNGLUNIFORM4IPROC)GL_GetProcAddress("glUniform4i"); + qglUniform1f = (PFNGLUNIFORM1FPROC)GL_GetProcAddress("glUniform1f"); + qglUniform2f = (PFNGLUNIFORM2FPROC)GL_GetProcAddress("glUniform2f"); + qglUniform3f = (PFNGLUNIFORM3FPROC)GL_GetProcAddress("glUniform3f"); + qglUniform4f = (PFNGLUNIFORM4FPROC)GL_GetProcAddress("glUniform4f"); + qglUniform1iv = (PFNGLUNIFORM1IVPROC)GL_GetProcAddress("glUniform1iv"); + qglUniform2iv = (PFNGLUNIFORM2IVPROC)GL_GetProcAddress("glUniform2iv"); + qglUniform3iv = (PFNGLUNIFORM3IVPROC)GL_GetProcAddress("glUniform3iv"); + qglUniform4iv = (PFNGLUNIFORM4IVPROC)GL_GetProcAddress("glUniform4iv"); + qglUniform1fv = (PFNGLUNIFORM1FVPROC)GL_GetProcAddress("glUniform1fv"); + qglUniform2fv = (PFNGLUNIFORM2FVPROC)GL_GetProcAddress("glUniform2fv"); + qglUniform3fv = (PFNGLUNIFORM3FVPROC)GL_GetProcAddress("glUniform3fv"); + qglUniform4fv = (PFNGLUNIFORM4FVPROC)GL_GetProcAddress("glUniform4fv"); + qglUniform1ui = (PFNGLUNIFORM1UIPROC)GL_GetProcAddress("glUniform1ui"); + qglUniform2ui = (PFNGLUNIFORM2UIPROC)GL_GetProcAddress("glUniform2ui"); + qglUniform3ui = (PFNGLUNIFORM3UIPROC)GL_GetProcAddress("glUniform3ui"); + qglUniform4ui = (PFNGLUNIFORM4UIPROC)GL_GetProcAddress("glUniform4ui"); + qglUniform1uiv = (PFNGLUNIFORM1UIVPROC)GL_GetProcAddress("glUniform1uiv"); + qglUniform2uiv = (PFNGLUNIFORM2UIVPROC)GL_GetProcAddress("glUniform2uiv"); + qglUniform3uiv = (PFNGLUNIFORM3UIVPROC)GL_GetProcAddress("glUniform3uiv"); + qglUniform4uiv = (PFNGLUNIFORM4UIVPROC)GL_GetProcAddress("glUniform4uiv"); + qglUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)GL_GetProcAddress("glUniformMatrix2fv"); + qglUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)GL_GetProcAddress("glUniformMatrix3fv"); + qglUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)GL_GetProcAddress("glUniformMatrix4fv"); + qglUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)GL_GetProcAddress("glUniformMatrix2x3fv"); + qglUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)GL_GetProcAddress("glUniformMatrix3x2fv"); + qglUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)GL_GetProcAddress("glUniformMatrix2x4fv"); + qglUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)GL_GetProcAddress("glUniformMatrix4x2fv"); + qglUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)GL_GetProcAddress("glUniformMatrix3x4fv"); + qglUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)GL_GetProcAddress("glUniformMatrix4x3fv"); + qglUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GL_GetProcAddress("glUniformBlockBinding"); + qglGetUniformfv = (PFNGLGETUNIFORMFVPROC)GL_GetProcAddress("glGetUniformfv"); + qglGetUniformiv = (PFNGLGETUNIFORMIVPROC)GL_GetProcAddress("glGetUniformiv"); + qglGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)GL_GetProcAddress("glGetUniformuiv"); + + // Transform feedback + qglBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)GL_GetProcAddress("glBeginTransformFeedback"); + qglEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)GL_GetProcAddress("glEndTransformFeedback"); + + // Texture compression + qglCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)GL_GetProcAddress("glCompressedTexImage3D"); + qglCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)GL_GetProcAddress("glCompressedTexImage2D"); + qglCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)GL_GetProcAddress("glCompressedTexImage1D"); + qglCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)GL_GetProcAddress("glCompressedTexSubImage3D"); + qglCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)GL_GetProcAddress("glCompressedTexSubImage2D"); + qglCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)GL_GetProcAddress("glCompressedTexSubImage1D"); + qglGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)GL_GetProcAddress("glGetCompressedTexImage"); + + // GLSL { char version[256]; - Q_strncpyz( version, (char *) qglGetString (GL_SHADING_LANGUAGE_VERSION_ARB), sizeof( version ) ); + Q_strncpyz( version, (const char *) qglGetString (GL_SHADING_LANGUAGE_VERSION), sizeof( version ) ); sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); ri->Printf(PRINT_ALL, "...using GLSL version %s\n", version); } - else - { - ri->Error(ERR_FATAL, result[2], extension); - } + // Framebuffer and renderbuffers + qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glRefConfig.maxRenderbufferSize); + qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glRefConfig.maxColorAttachments); + + qglIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) GL_GetProcAddress("glIsRenderbuffer"); + qglBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) GL_GetProcAddress("glBindRenderbuffer"); + qglDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) GL_GetProcAddress("glDeleteRenderbuffers"); + qglGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) GL_GetProcAddress("glGenRenderbuffers"); + qglRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) GL_GetProcAddress("glRenderbufferStorage"); + qglGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) GL_GetProcAddress("glGetRenderbufferParameteriv"); + qglIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) GL_GetProcAddress("glIsFramebuffer"); + qglBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) GL_GetProcAddress("glBindFramebuffer"); + qglDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) GL_GetProcAddress("glDeleteFramebuffers"); + qglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) GL_GetProcAddress("glGenFramebuffers"); + qglCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) GL_GetProcAddress("glCheckFramebufferStatus"); + qglFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) GL_GetProcAddress("glFramebufferTexture1D"); + qglFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) GL_GetProcAddress("glFramebufferTexture2D"); + qglFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) GL_GetProcAddress("glFramebufferTexture3D"); + qglFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) GL_GetProcAddress("glFramebufferRenderbuffer"); + qglGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) GL_GetProcAddress("glGetFramebufferAttachmentParameteriv"); + qglRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)GL_GetProcAddress("glRenderbufferStorageMultisample"); + qglBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)GL_GetProcAddress("glBlitFramebuffer"); + qglGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) GL_GetProcAddress("glGenerateMipmap"); + qglDrawBuffers = (PFNGLDRAWBUFFERSPROC) GL_GetProcAddress("glDrawBuffers"); + qglClearBufferfv = (PFNGLCLEARBUFFERFVPROC)GL_GetProcAddress ("glClearBufferfv"); + + // Queries + qglGenQueries = (PFNGLGENQUERIESPROC) GL_GetProcAddress("glGenQueries"); + qglDeleteQueries = (PFNGLDELETEQUERIESPROC) GL_GetProcAddress("glDeleteQueries"); + qglIsQuery = (PFNGLISQUERYPROC) GL_GetProcAddress("glIsQuery"); + qglBeginQuery = (PFNGLBEGINQUERYPROC) GL_GetProcAddress("glBeginQuery"); + qglEndQuery = (PFNGLENDQUERYPROC) GL_GetProcAddress("glEndQuery"); + qglGetQueryiv = (PFNGLGETQUERYIVPROC) GL_GetProcAddress("glGetQueryiv"); + qglGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) GL_GetProcAddress("glGetQueryObjectiv"); + qglGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) GL_GetProcAddress("glGetQueryObjectuiv"); + + // Memory info glRefConfig.memInfo = MI_NONE; if( GLimp_HaveExtension( "GL_NVX_gpu_memory_info" ) ) @@ -425,54 +421,6 @@ void GLimp_InitExtraExtensions() glRefConfig.memInfo = MI_ATI; } - // GL_EXT_framebuffer_object - extension = "GL_EXT_framebuffer_object"; - if( GLimp_HaveExtension( extension ) ) - { - qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize); - qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments); - - qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) GL_GetProcAddress("glIsRenderbufferEXT"); - qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) GL_GetProcAddress("glBindRenderbufferEXT"); - qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) GL_GetProcAddress("glDeleteRenderbuffersEXT"); - qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) GL_GetProcAddress("glGenRenderbuffersEXT"); - qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) GL_GetProcAddress("glRenderbufferStorageEXT"); - qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) GL_GetProcAddress("glGetRenderbufferParameterivEXT"); - qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) GL_GetProcAddress("glIsFramebufferEXT"); - qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) GL_GetProcAddress("glBindFramebufferEXT"); - qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glDeleteFramebuffersEXT"); - qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) GL_GetProcAddress("glGenFramebuffersEXT"); - qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) GL_GetProcAddress("glCheckFramebufferStatusEXT"); - qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) GL_GetProcAddress("glFramebufferTexture1DEXT"); - qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) GL_GetProcAddress("glFramebufferTexture2DEXT"); - qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) GL_GetProcAddress("glFramebufferTexture3DEXT"); - qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) GL_GetProcAddress("glFramebufferRenderbufferEXT"); - qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT"); - qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) GL_GetProcAddress("glGenerateMipmapEXT"); - - ri->Printf(PRINT_ALL, result[1], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - - // GL_ARB_occlusion_query - qglGenQueriesARB = (PFNGLGENQUERIESARBPROC) GL_GetProcAddress("glGenQueriesARB"); - qglDeleteQueriesARB = (PFNGLDELETEQUERIESARBPROC) GL_GetProcAddress("glDeleteQueriesARB"); - qglIsQueryARB = (PFNGLISQUERYARBPROC) GL_GetProcAddress("glIsQueryARB"); - qglBeginQueryARB = (PFNGLBEGINQUERYARBPROC) GL_GetProcAddress("glBeginQueryARB"); - qglEndQueryARB = (PFNGLENDQUERYARBPROC) GL_GetProcAddress("glEndQueryARB"); - qglGetQueryivARB = (PFNGLGETQUERYIVARBPROC) GL_GetProcAddress("glGetQueryivARB"); - qglGetQueryObjectivARB = (PFNGLGETQUERYOBJECTIVARBPROC) GL_GetProcAddress("glGetQueryObjectivARB"); - qglGetQueryObjectuivARB = (PFNGLGETQUERYOBJECTUIVARBPROC) GL_GetProcAddress("glGetQueryObjectuivARB"); - - // GL_EXT_framebuffer_blit - qglBlitFramebufferEXT = (void (QCALL *)(GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLint,GLbitfield,GLenum))GL_GetProcAddress("glBlitFramebufferEXT"); - - // GL_EXT_framebuffer_multisample - qglRenderbufferStorageMultisampleEXT = (void (QCALL *)(GLenum, GLsizei, GLenum, GLsizei, GLsizei))GL_GetProcAddress("glRenderbufferStorageMultisampleEXT"); - glRefConfig.textureCompression = TCR_NONE; // GL_EXT_texture_compression_latc @@ -503,20 +451,6 @@ void GLimp_InitExtraExtensions() ri->Printf(PRINT_ALL, result[2], extension); } - // GL_ARB_draw_buffers - extension = "GL_ARB_draw_buffers"; - qglDrawBuffersARB = NULL; - if( GLimp_HaveExtension( extension ) ) - { - qglDrawBuffersARB = (void (QCALL *)(GLsizei,const GLenum *)) GL_GetProcAddress("glDrawBuffersARB"); - - ri->Printf(PRINT_ALL, result[1], extension); - } - else - { - ri->Printf(PRINT_ALL, result[2], extension); - } - // GL_ARB_texture_storage extension = "GL_ARB_texture_storage"; glRefConfig.immutableTextures = qfalse; @@ -535,6 +469,4 @@ void GLimp_InitExtraExtensions() // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(r_floatLightmap->integer && r_hdr->integer); - - qglClearBufferfv = (PFNGLCLEARBUFFERFVPROC)GL_GetProcAddress ("glClearBufferfv"); } diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index ecda099f7e..c63d6e2823 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -33,14 +33,14 @@ qboolean R_CheckFBO(const FBO_t * fbo) int code; int id; - qglGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &id); - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->frameBuffer); + qglGetIntegerv(GL_FRAMEBUFFER_BINDING, &id); + qglBindFramebuffer(GL_FRAMEBUFFER, fbo->frameBuffer); - code = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + code = qglCheckFramebufferStatus(GL_FRAMEBUFFER); - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, id); + qglBindFramebuffer(GL_FRAMEBUFFER, id); - if(code == GL_FRAMEBUFFER_COMPLETE_EXT) + if(code == GL_FRAMEBUFFER_COMPLETE) { return qtrue; } @@ -48,40 +48,39 @@ qboolean R_CheckFBO(const FBO_t * fbo) // an error occured switch (code) { - case GL_FRAMEBUFFER_COMPLETE_EXT: + case GL_FRAMEBUFFER_COMPLETE: break; - case GL_FRAMEBUFFER_UNSUPPORTED_EXT: + case GL_FRAMEBUFFER_UNSUPPORTED: ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); break; - case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); + case GL_FRAMEBUFFER_UNDEFINED: + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Default framebuffer was checked, but does not exist\n", fbo->name); break; - case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing attachment\n", fbo->name); + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); break; - //case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: - // ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, duplicate attachment\n", fbo->name); - // break; + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, no attachments attached\n", fbo->name); + break; - case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same dimensions\n", - fbo->name); + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched multisampling values\n", fbo->name); break; - case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, attached images must have same format\n", + case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: + ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched layer targets\n", fbo->name); break; - case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); break; - case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); break; @@ -130,7 +129,7 @@ FBO_t *FBO_Create(const char *name, int width, int height) fbo->width = width; fbo->height = height; - qglGenFramebuffersEXT(1, &fbo->frameBuffer); + qglGenFramebuffers(1, &fbo->frameBuffer); return fbo; } @@ -147,36 +146,36 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) case GL_RGBA: case GL_RGB8: case GL_RGBA8: - case GL_RGB16F_ARB: - case GL_RGBA16F_ARB: - case GL_RGB32F_ARB: - case GL_RGBA32F_ARB: + case GL_RGB16F: + case GL_RGBA16F: + case GL_RGB32F: + case GL_RGBA32F: fbo->colorFormat = format; pRenderBuffer = &fbo->colorBuffers[index]; - attachment = GL_COLOR_ATTACHMENT0_EXT + index; + attachment = GL_COLOR_ATTACHMENT0 + index; break; case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: fbo->depthFormat = format; pRenderBuffer = &fbo->depthBuffer; - attachment = GL_DEPTH_ATTACHMENT_EXT; + attachment = GL_DEPTH_ATTACHMENT; break; case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: + case GL_STENCIL_INDEX1: + case GL_STENCIL_INDEX4: + case GL_STENCIL_INDEX8: + case GL_STENCIL_INDEX16: fbo->stencilFormat = format; pRenderBuffer = &fbo->stencilBuffer; - attachment = GL_STENCIL_ATTACHMENT_EXT; + attachment = GL_STENCIL_ATTACHMENT; break; - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: + case GL_DEPTH_STENCIL: + case GL_DEPTH24_STENCIL8: fbo->packedDepthStencilFormat = format; pRenderBuffer = &fbo->packedDepthStencilBuffer; attachment = 0; // special for stencil and depth @@ -189,27 +188,27 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) absent = (qboolean)(*pRenderBuffer == 0); if (absent) - qglGenRenderbuffersEXT(1, pRenderBuffer); + qglGenRenderbuffers(1, pRenderBuffer); - qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, *pRenderBuffer); + qglBindRenderbuffer(GL_RENDERBUFFER, *pRenderBuffer); if (multisample) { - qglRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, multisample, format, fbo->width, fbo->height); + qglRenderbufferStorageMultisample(GL_RENDERBUFFER, multisample, format, fbo->width, fbo->height); } else { - qglRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, format, fbo->width, fbo->height); + qglRenderbufferStorage(GL_RENDERBUFFER, format, fbo->width, fbo->height); } if(absent) { if (attachment == 0) { - qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, *pRenderBuffer); - qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, *pRenderBuffer); + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, *pRenderBuffer); + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, *pRenderBuffer); } else - qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment, GL_RENDERBUFFER_EXT, *pRenderBuffer); + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, attachment, GL_RENDERBUFFER, *pRenderBuffer); } } @@ -227,7 +226,7 @@ void R_AttachFBOTexture1D(int texId, int index) return; } - qglFramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_1D, texId, 0); + qglFramebufferTexture1D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_1D, texId, 0); } /* @@ -237,7 +236,7 @@ R_AttachFBOTexture2D */ void R_AttachFBOTexture2D(int target, int texId, int index) { - if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) + if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)) { ri->Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); return; @@ -249,7 +248,7 @@ void R_AttachFBOTexture2D(int target, int texId, int index) return; } - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, target, texId, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, target, texId, 0); } /* @@ -265,7 +264,7 @@ void R_AttachFBOTexture3D(int texId, int index, int zOffset) return; } - qglFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + index, GL_TEXTURE_3D_EXT, texId, 0, zOffset); + qglFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + index, GL_TEXTURE_3D, texId, 0, zOffset); } /* @@ -275,7 +274,7 @@ R_AttachFBOTextureDepth */ void R_AttachFBOTextureDepth(int texId) { - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, 0); } /* @@ -285,8 +284,8 @@ R_AttachFBOTexturePackedDepthStencil */ void R_AttachFBOTexturePackedDepthStencil(int texId) { - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); - qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, 0); } void FBO_AttachTextureImage(image_t *img, int index) @@ -327,10 +326,10 @@ static void FBO_SetupDrawBuffers() { for ( int i = 0; i < numBuffers; i++ ) { - bufs[i] = GL_COLOR_ATTACHMENT0_EXT + i; + bufs[i] = GL_COLOR_ATTACHMENT0 + i; } - qglDrawBuffersARB (numBuffers, bufs); + qglDrawBuffers (numBuffers, bufs); } } @@ -355,27 +354,27 @@ void FBO_Bind(FBO_t * fbo) if (!fbo) { - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); - //qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); + qglBindFramebuffer(GL_FRAMEBUFFER, 0); + //qglBindRenderbuffer(GL_RENDERBUFFER, 0); glState.currentFBO = NULL; return; } - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->frameBuffer); + qglBindFramebuffer(GL_FRAMEBUFFER, fbo->frameBuffer); /* if(fbo->colorBuffers[0]) { - qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo->colorBuffers[0]); + qglBindRenderbuffer(GL_RENDERBUFFER, fbo->colorBuffers[0]); } */ /* if(fbo->depthBuffer) { - qglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, fbo->depthBuffer); - qglFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, fbo->depthBuffer); + qglBindRenderbuffer(GL_RENDERBUFFER, fbo->depthBuffer); + qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->depthBuffer); } */ @@ -415,10 +414,10 @@ void FBO_Init(void) hdrFormat = GL_RGBA8; if (r_hdr->integer) { - hdrFormat = GL_RGB16F_ARB; + hdrFormat = GL_RGB16F; } - qglGetIntegerv(GL_MAX_SAMPLES_EXT, &multisample); + qglGetIntegerv(GL_MAX_SAMPLES, &multisample); if (r_ext_framebuffer_multisample->integer < multisample) { @@ -442,7 +441,7 @@ void FBO_Init(void) FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 1, multisample); - FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, multisample); + FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, multisample); FBO_SetupDrawBuffers(); @@ -455,7 +454,7 @@ void FBO_Init(void) FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); @@ -471,7 +470,7 @@ void FBO_Init(void) FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); @@ -531,7 +530,7 @@ void FBO_Init(void) //FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); FBO_AttachTextureImage(tr.pshadowMaps[i], 0); - FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24_ARB, 0, 0); + FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24, 0, 0); //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); FBO_SetupDrawBuffers(); @@ -553,7 +552,7 @@ void FBO_Init(void) qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); - //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); FBO_SetupDrawBuffers(); @@ -648,10 +647,10 @@ void FBO_Init(void) FBO_Bind(tr.renderCubeFbo); //FBO_AttachTextureImage(tr.renderCubeImage, 0); - R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, tr.renderCubeImage->texnum, 0); + R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); glState.currentFBO->colorImage[0] = tr.renderCubeImage; - FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24_ARB, 0, 0); + FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); FBO_SetupDrawBuffers(); @@ -684,17 +683,17 @@ void FBO_Shutdown(void) for(j = 0; j < glRefConfig.maxColorAttachments; j++) { if(fbo->colorBuffers[j]) - qglDeleteRenderbuffersEXT(1, &fbo->colorBuffers[j]); + qglDeleteRenderbuffers(1, &fbo->colorBuffers[j]); } if(fbo->depthBuffer) - qglDeleteRenderbuffersEXT(1, &fbo->depthBuffer); + qglDeleteRenderbuffers(1, &fbo->depthBuffer); if(fbo->stencilBuffer) - qglDeleteRenderbuffersEXT(1, &fbo->stencilBuffer); + qglDeleteRenderbuffers(1, &fbo->stencilBuffer); if(fbo->frameBuffer) - qglDeleteFramebuffersEXT(1, &fbo->frameBuffer); + qglDeleteFramebuffers(1, &fbo->frameBuffer); } } @@ -914,14 +913,14 @@ void FBO_FastBlit(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, int bu VectorSet4(dstBoxFinal, dstBox[0], dstBox[1], dstBox[0] + dstBox[2], dstBox[1] + dstBox[3]); } - qglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, srcFb); - qglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dstFb); + qglBindFramebuffer(GL_READ_FRAMEBUFFER, srcFb); + qglBindFramebuffer(GL_DRAW_FRAMEBUFFER, dstFb); - qglBlitFramebufferEXT(srcBoxFinal[0], srcBoxFinal[1], srcBoxFinal[2], srcBoxFinal[3], + qglBlitFramebuffer(srcBoxFinal[0], srcBoxFinal[1], srcBoxFinal[2], srcBoxFinal[3], dstBoxFinal[0], dstBoxFinal[1], dstBoxFinal[2], dstBoxFinal[3], buffers, filter); - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + qglBindFramebuffer(GL_FRAMEBUFFER, 0); glState.currentFBO = NULL; } @@ -930,21 +929,21 @@ void FBO_FastBlitIndexed(FBO_t *src, FBO_t *dst, int srcReadBuffer, int dstDrawB assert (src != NULL); assert (dst != NULL); - qglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, src->frameBuffer); - qglReadBuffer (GL_COLOR_ATTACHMENT0_EXT + srcReadBuffer); + qglBindFramebuffer(GL_READ_FRAMEBUFFER, src->frameBuffer); + qglReadBuffer (GL_COLOR_ATTACHMENT0 + srcReadBuffer); - qglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, dst->frameBuffer); - qglDrawBuffer (GL_COLOR_ATTACHMENT0_EXT + dstDrawBuffer); + qglBindFramebuffer(GL_DRAW_FRAMEBUFFER, dst->frameBuffer); + qglDrawBuffer (GL_COLOR_ATTACHMENT0 + dstDrawBuffer); - qglBlitFramebufferEXT(0, 0, src->width, src->height, + qglBlitFramebuffer(0, 0, src->width, src->height, 0, 0, dst->width, dst->height, buffers, filter); - qglReadBuffer (GL_COLOR_ATTACHMENT0_EXT); + qglReadBuffer (GL_COLOR_ATTACHMENT0); glState.currentFBO = dst; FBO_SetupDrawBuffers(); - qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + qglBindFramebuffer(GL_FRAMEBUFFER, 0); glState.currentFBO = NULL; } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6066c15d3f..e97f50071a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -151,8 +151,50 @@ static uniformInfo_t uniformsInfo[] = { "u_BoneMatrices", GLSL_MAT16, 80 }, }; +static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) +{ + char *msg; + static char msgPart[1024]; + int maxLength = 0; + int i; + int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; + + qglGetProgramiv(object, GL_INFO_LOG_LENGTH, &maxLength); + + if (maxLength <= 0) + { + ri->Printf(printLevel, "No compile log.\n"); + return; + } + + ri->Printf(printLevel, "compile log:\n"); + + if (maxLength < 1023) + { + qglGetProgramInfoLog(object, maxLength, &maxLength, msgPart); + + msgPart[maxLength + 1] = '\0'; + + ri->Printf(printLevel, "%s\n", msgPart); + } + else + { + msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); + + qglGetProgramInfoLog(object, maxLength, &maxLength, msg); + + for(i = 0; i < maxLength; i += 1024) + { + Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); + + ri->Printf(printLevel, "%s\n", msgPart); + } + + Z_Free(msg); + } +} -static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) +static void GLSL_PrintShaderInfoLog(GLuint object, qboolean developerOnly) { char *msg; static char msgPart[1024]; @@ -160,7 +202,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) int i; int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; - qglGetObjectParameterivARB(object, GL_OBJECT_INFO_LOG_LENGTH_ARB, &maxLength); + qglGetShaderiv(object, GL_INFO_LOG_LENGTH, &maxLength); if (maxLength <= 0) { @@ -172,7 +214,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) if (maxLength < 1023) { - qglGetInfoLogARB(object, maxLength, &maxLength, msgPart); + qglGetShaderInfoLog(object, maxLength, &maxLength, msgPart); msgPart[maxLength + 1] = '\0'; @@ -182,7 +224,7 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) { msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); - qglGetInfoLogARB(object, maxLength, &maxLength, msg); + qglGetShaderInfoLog(object, maxLength, &maxLength, msg); for(i = 0; i < maxLength; i += 1024) { @@ -195,18 +237,18 @@ static void GLSL_PrintInfoLog(GLhandleARB object, qboolean developerOnly) } } -static void GLSL_PrintShaderSource(GLhandleARB object) +static void GLSL_PrintShaderSource(GLuint shader) { char *msg; static char msgPart[1024]; int maxLength = 0; int i; - qglGetObjectParameterivARB(object, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &maxLength); + qglGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &maxLength); msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); - qglGetShaderSourceARB(object, maxLength, &maxLength, msg); + qglGetShaderSource(shader, maxLength, &maxLength, msg); for(i = 0; i < maxLength; i += 1024) { @@ -228,7 +270,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha { Q_strcat(dest, size, "#version 330 core\n"); - if(shaderType == GL_VERTEX_SHADER_ARB) + if(shaderType == GL_VERTEX_SHADER) { Q_strcat(dest, size, "#define attribute in\n"); Q_strcat(dest, size, "#define varying out\n"); @@ -341,16 +383,16 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha Q_strcat(dest, size, "#line 0\n"); } -static int GLSL_EnqueueCompileGPUShader(GLhandleARB program, GLhandleARB *prevShader, const GLcharARB *buffer, int size, GLenum shaderType) +static int GLSL_EnqueueCompileGPUShader(GLuint program, GLuint *prevShader, const GLchar *buffer, int size, GLenum shaderType) { - GLhandleARB shader; + GLuint shader; - shader = qglCreateShaderObjectARB(shaderType); + shader = qglCreateShader(shaderType); - qglShaderSourceARB(shader, 1, &buffer, &size); + qglShaderSource(shader, 1, &buffer, &size); // compile shader - qglCompileShaderARB(shader); + qglCompileShader(shader); *prevShader = shader; @@ -366,7 +408,7 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, int size; int result; - if(shaderType == GL_VERTEX_SHADER_ARB) + if(shaderType == GL_VERTEX_SHADER) { Com_sprintf(filename, sizeof(filename), "glsl/%s_vp.glsl", name); } @@ -414,59 +456,59 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, return result; } -static void GLSL_LinkProgram(GLhandleARB program) +static void GLSL_LinkProgram(GLuint program) { GLint linked; - qglLinkProgramARB(program); + qglLinkProgram(program); - qglGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &linked); + qglGetProgramiv(program, GL_LINK_STATUS, &linked); if(!linked) { - GLSL_PrintInfoLog(program, qfalse); + GLSL_PrintProgramInfoLog(program, qfalse); ri->Printf(PRINT_ALL, "\n"); ri->Error(ERR_DROP, "shaders failed to link"); } } -static void GLSL_ValidateProgram(GLhandleARB program) +static void GLSL_ValidateProgram(GLuint program) { GLint validated; - qglValidateProgramARB(program); + qglValidateProgram(program); - qglGetObjectParameterivARB(program, GL_OBJECT_VALIDATE_STATUS_ARB, &validated); + qglGetProgramiv(program, GL_VALIDATE_STATUS, &validated); if(!validated) { - GLSL_PrintInfoLog(program, qfalse); + GLSL_PrintProgramInfoLog(program, qfalse); ri->Printf(PRINT_ALL, "\n"); ri->Error(ERR_DROP, "shaders failed to validate"); } } -static void GLSL_ShowProgramUniforms(GLhandleARB program) +static void GLSL_ShowProgramUniforms(GLuint program) { int i, count, size; GLenum type; char uniformName[1000]; // install the executables in the program object as part of current state. - qglUseProgramObjectARB(program); + qglUseProgram(program); // check for GL Errors // query the number of active uniforms - qglGetObjectParameterivARB(program, GL_OBJECT_ACTIVE_UNIFORMS_ARB, &count); + qglGetProgramiv(program, GL_ACTIVE_UNIFORMS, &count); // Loop over each of the active uniforms, and set their value for(i = 0; i < count; i++) { - qglGetActiveUniformARB(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); + qglGetActiveUniform(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); ri->Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); } - qglUseProgramObjectARB(0); + qglUseProgram(0); } static int GLSL_BeginLoadGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) @@ -478,22 +520,22 @@ static int GLSL_BeginLoadGPUShader2(shaderProgram_t * program, const char *name, program->name = (char *)Z_Malloc (nameBufSize, TAG_GENERAL); Q_strncpyz(program->name, name, nameBufSize); - program->program = qglCreateProgramObjectARB(); + program->program = qglCreateProgram(); program->attribs = attribs; - if (!(GLSL_EnqueueCompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER_ARB))) + if (!(GLSL_EnqueueCompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER))) { - ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER_ARB\n", name); - qglDeleteObjectARB(program->program); + ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER\n", name); + qglDeleteProgram(program->program); return 0; } if(fpCode) { - if(!(GLSL_EnqueueCompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER_ARB))) + if(!(GLSL_EnqueueCompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER))) { - ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER_ARB\n", name); - qglDeleteObjectARB(program->program); + ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER\n", name); + qglDeleteProgram(program->program); return 0; } } @@ -501,15 +543,15 @@ static int GLSL_BeginLoadGPUShader2(shaderProgram_t * program, const char *name, return 1; } -static bool GLSL_IsGPUShaderCompiled (GLhandleARB shader) +static bool GLSL_IsGPUShaderCompiled (GLuint shader) { GLint compiled; - qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled); + qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); if(!compiled) { GLSL_PrintShaderSource(shader); - GLSL_PrintInfoLog(shader, qfalse); + GLSL_PrintShaderInfoLog(shader, qfalse); ri->Error(ERR_DROP, "Couldn't compile shader"); return qfalse; } @@ -531,60 +573,60 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) return false; } - qglAttachObjectARB(program->program, program->vertexShader); - qglAttachObjectARB(program->program, program->fragmentShader); + qglAttachShader(program->program, program->vertexShader); + qglAttachShader(program->program, program->fragmentShader); if(attribs & ATTR_POSITION) - qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION, "attr_Position"); + qglBindAttribLocation(program->program, ATTR_INDEX_POSITION, "attr_Position"); if(attribs & ATTR_TEXCOORD0) - qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD0, "attr_TexCoord0"); + qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD0, "attr_TexCoord0"); if(attribs & ATTR_TEXCOORD1) - qglBindAttribLocationARB(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); + qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); #ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT) - qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); + qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); #endif if(attribs & ATTR_NORMAL) - qglBindAttribLocationARB(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); + qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); if(attribs & ATTR_COLOR) - qglBindAttribLocationARB(program->program, ATTR_INDEX_COLOR, "attr_Color"); + qglBindAttribLocation(program->program, ATTR_INDEX_COLOR, "attr_Color"); if(attribs & ATTR_PAINTCOLOR) - qglBindAttribLocationARB(program->program, ATTR_INDEX_PAINTCOLOR, "attr_PaintColor"); + qglBindAttribLocation(program->program, ATTR_INDEX_PAINTCOLOR, "attr_PaintColor"); if(attribs & ATTR_LIGHTDIRECTION) - qglBindAttribLocationARB(program->program, ATTR_INDEX_LIGHTDIRECTION, "attr_LightDirection"); + qglBindAttribLocation(program->program, ATTR_INDEX_LIGHTDIRECTION, "attr_LightDirection"); if(attribs & ATTR_POSITION2) - qglBindAttribLocationARB(program->program, ATTR_INDEX_POSITION2, "attr_Position2"); + qglBindAttribLocation(program->program, ATTR_INDEX_POSITION2, "attr_Position2"); if(attribs & ATTR_NORMAL2) - qglBindAttribLocationARB(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); + qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); #ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT2) - qglBindAttribLocationARB(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); + qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); #endif if(attribs & ATTR_BONE_INDEXES) - qglBindAttribLocationARB(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); + qglBindAttribLocation(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); if(attribs & ATTR_BONE_WEIGHTS) - qglBindAttribLocationARB(program->program, ATTR_INDEX_BONE_WEIGHTS, "attr_BoneWeights"); + qglBindAttribLocation(program->program, ATTR_INDEX_BONE_WEIGHTS, "attr_BoneWeights"); GLSL_LinkProgram(program->program); // Won't be needing these anymore... - qglDetachObjectARB (program->program, program->vertexShader); - qglDetachObjectARB (program->program, program->fragmentShader); + qglDetachShader (program->program, program->vertexShader); + qglDetachShader (program->program, program->fragmentShader); - qglDeleteObjectARB (program->vertexShader); - qglDeleteObjectARB (program->fragmentShader); + qglDeleteShader (program->vertexShader); + qglDeleteShader (program->fragmentShader); program->vertexShader = program->fragmentShader = 0; @@ -603,7 +645,7 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, size = sizeof(vpCode); if (addHeader) { - GLSL_GetShaderHeader(GL_VERTEX_SHADER_ARB, extra, vpCode, size); + GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, vpCode, size); postHeader = &vpCode[strlen(vpCode)]; size -= strlen(vpCode); } @@ -612,7 +654,7 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, postHeader = &vpCode[0]; } - if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER_ARB, postHeader, size)) + if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER, postHeader, size)) { return 0; } @@ -622,7 +664,7 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, size = sizeof(fpCode); if (addHeader) { - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER_ARB, extra, fpCode, size); + GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, fpCode, size); postHeader = &fpCode[strlen(fpCode)]; size -= strlen(fpCode); } @@ -631,7 +673,7 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, postHeader = &fpCode[0]; } - if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER_ARB, postHeader, size)) + if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER, postHeader, size)) { return 0; } @@ -654,7 +696,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) size = 0; for (i = 0; i < UNIFORM_COUNT; i++) { - uniforms[i] = qglGetUniformLocationARB(program->program, uniformsInfo[i].name); + uniforms[i] = qglGetUniformLocation(program->program, uniformsInfo[i].name); if (uniforms[i] == -1) continue; @@ -720,7 +762,7 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) *compare = value; - qglUniform1iARB(uniforms[uniformNum], value); + qglUniform1i(uniforms[uniformNum], value); } void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value) @@ -744,7 +786,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu *compare = value; - qglUniform1fARB(uniforms[uniformNum], value); + qglUniform1f(uniforms[uniformNum], value); } void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v) @@ -769,7 +811,7 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t compare[0] = v[0]; compare[1] = v[1]; - qglUniform2fARB(uniforms[uniformNum], v[0], v[1]); + qglUniform2f(uniforms[uniformNum], v[0], v[1]); } void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v) @@ -793,7 +835,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t VectorCopy(v, compare); - qglUniform3fARB(uniforms[uniformNum], v[0], v[1], v[2]); + qglUniform3f(uniforms[uniformNum], v[0], v[1], v[2]); } void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v) @@ -817,7 +859,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t VectorCopy4(v, compare); - qglUniform4fARB(uniforms[uniformNum], v[0], v[1], v[2], v[3]); + qglUniform4f(uniforms[uniformNum], v[0], v[1], v[2], v[3]); } void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v) @@ -841,7 +883,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ VectorCopy5(v, compare); - qglUniform1fvARB(uniforms[uniformNum], 5, v); + qglUniform1fv(uniforms[uniformNum], 5, v); } void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) @@ -869,14 +911,14 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const flo Com_Memcpy (compare, matrix, sizeof (float) * 16 * numElements); - qglUniformMatrix4fvARB(uniforms[uniformNum], numElements, GL_FALSE, matrix); + qglUniformMatrix4fv(uniforms[uniformNum], numElements, GL_FALSE, matrix); } void GLSL_DeleteGPUShader(shaderProgram_t *program) { if(program->program) { - qglDeleteObjectARB(program->program); + qglDeleteProgram(program->program); Z_Free (program->name); Z_Free (program->uniformBuffer); @@ -1292,9 +1334,9 @@ int GLSL_BeginLoadGPUShaders(void) GLSL_InitUniforms(&tr.testcubeShader); - qglUseProgramObjectARB(tr.testcubeShader.program); + qglUseProgram(tr.testcubeShader.program); GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); GLSL_FinishGPUShader(&tr.testcubeShader); @@ -1340,10 +1382,10 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.genericShader[i]); - qglUseProgramObjectARB(tr.genericShader[i].program); + qglUseProgram(tr.genericShader[i].program); GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.genericShader[i]); @@ -1359,9 +1401,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.textureColorShader); - qglUseProgramObjectARB(tr.textureColorShader.program); + qglUseProgram(tr.textureColorShader.program); GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); GLSL_FinishGPUShader(&tr.textureColorShader); @@ -1397,9 +1439,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.dlightShader[i]); - qglUseProgramObjectARB(tr.dlightShader[i].program); + qglUseProgram(tr.dlightShader[i].program); GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.dlightShader[i]); @@ -1427,7 +1469,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.lightallShader[i]); - qglUseProgramObjectARB(tr.lightallShader[i].program); + qglUseProgram(tr.lightallShader[i].program); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_NORMALMAP, TB_NORMALMAP); @@ -1435,7 +1477,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.lightallShader[i]); @@ -1463,9 +1505,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.pshadowShader); - qglUseProgramObjectARB(tr.pshadowShader.program); + qglUseProgram(tr.pshadowShader.program); GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.pshadowShader); @@ -1480,9 +1522,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.down4xShader); - qglUseProgramObjectARB(tr.down4xShader.program); + qglUseProgram(tr.down4xShader.program); GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.down4xShader); @@ -1497,9 +1539,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.bokehShader); - qglUseProgramObjectARB(tr.bokehShader.program); + qglUseProgram(tr.bokehShader.program); GLSL_SetUniformInt(&tr.bokehShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.bokehShader); @@ -1514,10 +1556,10 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.tonemapShader); - qglUseProgramObjectARB(tr.tonemapShader.program); + qglUseProgram(tr.tonemapShader.program); GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.tonemapShader); @@ -1534,9 +1576,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.calclevels4xShader[i]); - qglUseProgramObjectARB(tr.calclevels4xShader[i].program); + qglUseProgram(tr.calclevels4xShader[i].program); GLSL_SetUniformInt(&tr.calclevels4xShader[i], UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); @@ -1552,12 +1594,12 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.shadowmaskShader); - qglUseProgramObjectARB(tr.shadowmaskShader.program); + qglUseProgram(tr.shadowmaskShader.program); GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP); GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.shadowmaskShader); @@ -1572,9 +1614,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.ssaoShader); - qglUseProgramObjectARB(tr.ssaoShader.program); + qglUseProgram(tr.ssaoShader.program); GLSL_SetUniformInt(&tr.ssaoShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.ssaoShader); @@ -1591,10 +1633,10 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.depthBlurShader[i]); - qglUseProgramObjectARB(tr.depthBlurShader[i].program); + qglUseProgram(tr.depthBlurShader[i].program); GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENIMAGEMAP, TB_COLORMAP); GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENDEPTHMAP, TB_LIGHTMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); #if defined(_DEBUG) GLSL_FinishGPUShader(&tr.depthBlurShader[i]); @@ -1630,9 +1672,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.testcubeShader); - qglUseProgramObjectARB(tr.testcubeShader.program); + qglUseProgram(tr.testcubeShader.program); GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - qglUseProgramObjectARB(0); + qglUseProgram(0); GLSL_FinishGPUShader(&tr.testcubeShader); @@ -1650,22 +1692,22 @@ void GLSL_ShutdownGPUShaders(void) ri->Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); - qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION); - qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION2); - qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL); + qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD0); + qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD1); + qglDisableVertexAttribArray(ATTR_INDEX_POSITION); + qglDisableVertexAttribArray(ATTR_INDEX_POSITION2); + qglDisableVertexAttribArray(ATTR_INDEX_NORMAL); #ifdef USE_VERT_TANGENT_SPACE - qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + qglDisableVertexAttribArray(ATTR_INDEX_TANGENT); #endif - qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); + qglDisableVertexAttribArray(ATTR_INDEX_NORMAL2); #ifdef USE_VERT_TANGENT_SPACE - qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + qglDisableVertexAttribArray(ATTR_INDEX_TANGENT2); #endif - qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); - qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); + qglDisableVertexAttribArray(ATTR_INDEX_COLOR); + qglDisableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); + qglDisableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); + qglDisableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); GLSL_BindNullProgram(); for ( i = 0; i < GENERICDEF_COUNT; i++) @@ -1698,7 +1740,7 @@ void GLSL_ShutdownGPUShaders(void) GLSL_DeleteGPUShader(&tr.depthBlurShader[i]); glState.currentProgram = 0; - qglUseProgramObjectARB(0); + qglUseProgram(0); } @@ -1718,7 +1760,7 @@ void GLSL_BindProgram(shaderProgram_t * program) if(glState.currentProgram != program) { - qglUseProgramObjectARB(program->program); + qglUseProgram(program->program); glState.currentProgram = program; backEnd.pc.c_glslShaderBinds++; } @@ -1734,7 +1776,7 @@ void GLSL_BindNullProgram(void) if(glState.currentProgram) { - qglUseProgramObjectARB(0); + qglUseProgram(0); glState.currentProgram = NULL; } } @@ -1756,13 +1798,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_POSITION) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_POSITION )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_POSITION); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_POSITION )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_POSITION); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_POSITION )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_POSITION )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_POSITION); } } @@ -1770,13 +1812,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_TEXCOORD0) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TEXCOORD )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TEXCOORD )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_TEXCOORD0); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TEXCOORD )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD0); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TEXCOORD )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD0); } } @@ -1784,13 +1826,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_TEXCOORD1) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_LIGHTCOORD )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_LIGHTCOORD )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_TEXCOORD1); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_LIGHTCOORD )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TEXCOORD1); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_LIGHTCOORD )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD1); } } @@ -1798,13 +1840,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_NORMAL) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_NORMAL )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_NORMAL); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_NORMAL )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_NORMAL); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_NORMAL )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_NORMAL )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_NORMAL); } } @@ -1813,13 +1855,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_TANGENT) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TANGENT )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TANGENT )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_TANGENT); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TANGENT )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TANGENT )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_TANGENT); } } #endif @@ -1828,13 +1870,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_COLOR) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_COLOR )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_COLOR); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_COLOR )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_COLOR); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_COLOR )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_COLOR); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_COLOR )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_COLOR); } } @@ -1842,13 +1884,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_LIGHTDIRECTION) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_LIGHTDIRECTION )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_LIGHTDIRECTION); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_LIGHTDIRECTION )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); } } @@ -1856,13 +1898,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_POSITION2) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_POSITION2 )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_POSITION2); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_POSITION2 )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_POSITION2); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_POSITION2 )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_POSITION2); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_POSITION2 )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_POSITION2); } } @@ -1870,13 +1912,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_NORMAL2) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_NORMAL2 )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_NORMAL2 )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_NORMAL2); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_NORMAL2 )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_NORMAL2); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_NORMAL2 )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_NORMAL2); } } @@ -1885,13 +1927,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_TANGENT2) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_TANGENT2 )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TANGENT2 )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_TANGENT2); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_TANGENT2 )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_TANGENT2); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TANGENT2 )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_TANGENT2); } } #endif @@ -1900,13 +1942,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_BONE_INDEXES) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BONE_INDEXES )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_BONE_INDEXES )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BONE_INDEXES )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_INDEXES); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_BONE_INDEXES )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); } } @@ -1914,13 +1956,13 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { if(stateBits & ATTR_BONE_WEIGHTS) { - GLimp_LogComment("qglEnableVertexAttribArrayARB( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglEnableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); + GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_BONE_WEIGHTS )\n"); + qglEnableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); } else { - GLimp_LogComment("qglDisableVertexAttribArrayARB( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglDisableVertexAttribArrayARB(ATTR_INDEX_BONE_WEIGHTS); + GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_BONE_WEIGHTS )\n"); + qglDisableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); } } @@ -1933,16 +1975,16 @@ void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) if ( attribBits & ATTR_TEXCOORD0 ) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); } if ( attribBits & ATTR_TEXCOORD1 ) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); } } @@ -1971,101 +2013,101 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) if((attribBits & ATTR_POSITION) && (!(glState.vertexAttribPointersSet & ATTR_POSITION) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_POSITION )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + newFrame * vbo->size_xyz)); + qglVertexAttribPointer(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + newFrame * vbo->size_xyz)); glState.vertexAttribPointersSet |= ATTR_POSITION; } if((attribBits & ATTR_TEXCOORD0) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD0)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TEXCOORD )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); glState.vertexAttribPointersSet |= ATTR_TEXCOORD0; } if((attribBits & ATTR_TEXCOORD1) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD1)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTCOORD )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); glState.vertexAttribPointersSet |= ATTR_TEXCOORD1; } if((attribBits & ATTR_NORMAL) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_NORMAL )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); + qglVertexAttribPointer(ATTR_INDEX_NORMAL, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL; } #ifdef USE_VERT_TANGENT_SPACE if((attribBits & ATTR_TANGENT) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TANGENT )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME + qglVertexAttribPointer(ATTR_INDEX_TANGENT, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT; } #endif if((attribBits & ATTR_COLOR) && !(glState.vertexAttribPointersSet & ATTR_COLOR)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_COLOR )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_COLOR )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, vbo->stride_vertexcolor, BUFFER_OFFSET(vbo->ofs_vertexcolor)); + qglVertexAttribPointer(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, vbo->stride_vertexcolor, BUFFER_OFFSET(vbo->ofs_vertexcolor)); glState.vertexAttribPointersSet |= ATTR_COLOR; } if((attribBits & ATTR_LIGHTDIRECTION) && !(glState.vertexAttribPointersSet & ATTR_LIGHTDIRECTION)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_LIGHTDIRECTION )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_LIGHTDIRECTION, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); + qglVertexAttribPointer(ATTR_INDEX_LIGHTDIRECTION, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); glState.vertexAttribPointersSet |= ATTR_LIGHTDIRECTION; } if((attribBits & ATTR_POSITION2) && (!(glState.vertexAttribPointersSet & ATTR_POSITION2) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_POSITION2 )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_POSITION2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + oldFrame * vbo->size_xyz)); + qglVertexAttribPointer(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + oldFrame * vbo->size_xyz)); glState.vertexAttribPointersSet |= ATTR_POSITION2; } if((attribBits & ATTR_NORMAL2) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL2) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_NORMAL2 )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_NORMAL2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_NORMAL2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); + qglVertexAttribPointer(ATTR_INDEX_NORMAL2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); glState.vertexAttribPointersSet |= ATTR_NORMAL2; } #ifdef USE_VERT_TANGENT_SPACE if((attribBits & ATTR_TANGENT2) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT2) || animated)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_TANGENT2 )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TANGENT2 )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_TANGENT2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME + qglVertexAttribPointer(ATTR_INDEX_TANGENT2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME glState.vertexAttribPointersSet |= ATTR_TANGENT2; } #endif if((attribBits & ATTR_BONE_INDEXES) && !(glState.vertexAttribPointersSet & ATTR_BONE_INDEXES)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_INDEXES )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_BONE_INDEXES )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, vbo->stride_boneindexes, BUFFER_OFFSET(vbo->ofs_boneindexes)); + qglVertexAttribPointer(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, vbo->stride_boneindexes, BUFFER_OFFSET(vbo->ofs_boneindexes)); glState.vertexAttribPointersSet |= ATTR_BONE_INDEXES; } if((attribBits & ATTR_BONE_WEIGHTS) && !(glState.vertexAttribPointersSet & ATTR_BONE_WEIGHTS)) { - GLimp_LogComment("qglVertexAttribPointerARB( ATTR_INDEX_BONE_WEIGHTS )\n"); + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglVertexAttribPointerARB(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, vbo->stride_boneweights, BUFFER_OFFSET(vbo->ofs_boneweights)); + qglVertexAttribPointer(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, vbo->stride_boneweights, BUFFER_OFFSET(vbo->ofs_boneweights)); glState.vertexAttribPointersSet |= ATTR_BONE_WEIGHTS; } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 36d79a3e0c..54078d4a78 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -236,25 +236,25 @@ void R_ImageList_f( void ) { // 2 bytes per pixel? estSize *= 2; break; - case GL_SRGB_EXT: - case GL_SRGB8_EXT: + case GL_SRGB: + case GL_SRGB8: format = "sRGB "; // 3 bytes per pixel? estSize *= 3; break; - case GL_SRGB_ALPHA_EXT: - case GL_SRGB8_ALPHA8_EXT: + case GL_SRGB_ALPHA: + case GL_SRGB8_ALPHA8: format = "sRGBA"; // 4 bytes per pixel? estSize *= 4; break; - case GL_SLUMINANCE_EXT: - case GL_SLUMINANCE8_EXT: + case GL_SLUMINANCE: + case GL_SLUMINANCE8: format = "sL "; // 1 byte per pixel? break; - case GL_SLUMINANCE_ALPHA_EXT: - case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_SLUMINANCE_ALPHA: + case GL_SLUMINANCE8_ALPHA8: format = "sLA "; // 2 byte per pixel? estSize *= 2; @@ -1874,40 +1874,40 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light switch(internalFormat) { case GL_RGB: - internalFormat = GL_SRGB_EXT; + internalFormat = GL_SRGB; break; case GL_RGB4: case GL_RGB5: case GL_RGB8: - internalFormat = GL_SRGB8_EXT; + internalFormat = GL_SRGB8; break; case GL_RGBA: - internalFormat = GL_SRGB_ALPHA_EXT; + internalFormat = GL_SRGB_ALPHA; break; case GL_RGBA4: case GL_RGBA8: - internalFormat = GL_SRGB8_ALPHA8_EXT; + internalFormat = GL_SRGB8_ALPHA8; break; case GL_LUMINANCE: - internalFormat = GL_SLUMINANCE_EXT; + internalFormat = GL_SLUMINANCE; break; case GL_LUMINANCE8: case GL_LUMINANCE16: - internalFormat = GL_SLUMINANCE8_EXT; + internalFormat = GL_SLUMINANCE8; break; case GL_LUMINANCE_ALPHA: - internalFormat = GL_SLUMINANCE_ALPHA_EXT; + internalFormat = GL_SLUMINANCE_ALPHA; break; case GL_LUMINANCE8_ALPHA8: case GL_LUMINANCE16_ALPHA16: - internalFormat = GL_SLUMINANCE8_ALPHA8_EXT; + internalFormat = GL_SLUMINANCE8_ALPHA8; break; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: @@ -1940,15 +1940,15 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei switch(internalFormat) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: dataFormat = GL_DEPTH_COMPONENT; dataType = GL_UNSIGNED_BYTE; break; - case GL_RGBA16F_ARB: + case GL_RGBA16F: dataFormat = GL_RGBA; - dataType = GL_HALF_FLOAT_ARB; + dataType = GL_HALF_FLOAT; break; default: dataFormat = GL_RGBA; @@ -2218,9 +2218,9 @@ static void EmptyTexture( int width, int height, imgType_t type, int flags, switch(internalFormat) { case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16_ARB: - case GL_DEPTH_COMPONENT24_ARB: - case GL_DEPTH_COMPONENT32_ARB: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: qglTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); @@ -2335,7 +2335,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT } if (image->flags & IMGFLAG_MIPMAP) - qglGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP); + qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); image->uploadWidth = width; image->uploadHeight = height; @@ -2857,7 +2857,7 @@ void R_CreateBuiltinImages( void ) { hdrFormat = GL_RGBA8; if (r_hdr->integer) - hdrFormat = GL_RGBA16F_ARB; + hdrFormat = GL_RGBA16F; rgbFormat = GL_RGBA8; @@ -2872,14 +2872,14 @@ void R_CreateBuiltinImages( void ) { if (r_drawSunRays->integer) tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); - tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); { unsigned short sdata[4]; void *p; - if (hdrFormat == GL_RGBA16F_ARB) + if (hdrFormat == GL_RGBA16F) { sdata[0] = FloatToHalf(0.0f); sdata[1] = FloatToHalf(0.45f); @@ -2928,7 +2928,7 @@ void R_CreateBuiltinImages( void ) { { for ( x = 0; x < 3; x++) { - tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB); + tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); } tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 2acd45e77b..b2ff5466d4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1009,10 +1009,10 @@ void GL_SetDefaultState( void ) glState.vertexAttribsState = 0; glState.vertexAttribPointersSet = 0; glState.currentProgram = 0; - qglUseProgramObjectARB(0); + qglUseProgram(0); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBuffer(GL_ARRAY_BUFFER, 0); + qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glState.currentVBO = NULL; glState.currentIBO = NULL; @@ -1432,13 +1432,13 @@ Ghoul2 Insert End void R_InitQueries(void) { if (r_drawSunRays->integer) - qglGenQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); + qglGenQueries(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } void R_ShutDownQueries(void) { if (r_drawSunRays->integer) - qglDeleteQueriesARB(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); + qglDeleteQueries(ARRAY_LEN(tr.sunFlareQuery), tr.sunFlareQuery); } void RE_SetLightStyle (int style, int color); diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index bc90c47f5e..1b54c181bd 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -288,7 +288,7 @@ static qboolean RB_UpdateSunFlareVis(void) for (iter=0 ; ; ++iter) { GLint available = 0; - qglGetQueryObjectivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_AVAILABLE_ARB, &available); + qglGetQueryObjectiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_AVAILABLE, &available); if (available) break; } @@ -296,7 +296,7 @@ static qboolean RB_UpdateSunFlareVis(void) ri->Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); } - qglGetQueryObjectuivARB(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT_ARB, &sampleCount); + qglGetQueryObjectuiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT, &sampleCount); return (qboolean)(sampleCount > 0); } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 55ffbbc9de..bc56190d00 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -42,14 +42,14 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { - qglDrawRangeElementsEXT(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); + qglDrawRangeElements(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); } static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) { - qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); + qglMultiDrawElements(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 9a027e8bcb..bab0d0d595 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -58,10 +58,10 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) switch (usage) { case VBO_USAGE_STATIC: - return GL_STATIC_DRAW_ARB; + return GL_STATIC_DRAW; case VBO_USAGE_DYNAMIC: - return GL_STREAM_DRAW_ARB; + return GL_STREAM_DRAW; default: ri->Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); @@ -92,12 +92,12 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) vbo->vertexesSize = vertexesSize; - qglGenBuffersARB(1, &vbo->vertexesVBO); + qglGenBuffers(1, &vbo->vertexesVBO); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); - qglBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexesSize, vertexes, glUsage); + qglBindBuffer(GL_ARRAY_BUFFER, vbo->vertexesVBO); + qglBufferData(GL_ARRAY_BUFFER, vertexesSize, vertexes, glUsage); - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + qglBindBuffer(GL_ARRAY_BUFFER, 0); glState.currentVBO = NULL; @@ -127,12 +127,12 @@ IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) ibo->indexesSize = indexesSize; - qglGenBuffersARB(1, &ibo->indexesVBO); + qglGenBuffers(1, &ibo->indexesVBO); - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexesSize, indexes, glUsage); + qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO); + qglBufferData(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, glUsage); - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glState.currentIBO = NULL; @@ -173,7 +173,7 @@ void R_BindVBO(VBO_t * vbo) glState.vertexAnimation = qfalse; glState.skeletalAnimation = qfalse; - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo->vertexesVBO); + qglBindBuffer(GL_ARRAY_BUFFER, vbo->vertexesVBO); backEnd.pc.c_vboVertexBuffers++; } @@ -190,7 +190,7 @@ void R_BindNullVBO(void) if(glState.currentVBO) { - qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); + qglBindBuffer(GL_ARRAY_BUFFER, 0); glState.currentVBO = NULL; } @@ -218,7 +218,7 @@ void R_BindIBO(IBO_t * ibo) if(glState.currentIBO != ibo) { - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, ibo->indexesVBO); + qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO); glState.currentIBO = ibo; @@ -237,7 +237,7 @@ void R_BindNullIBO(void) if(glState.currentIBO) { - qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); + qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glState.currentIBO = NULL; glState.vertexAttribPointersSet = 0; } @@ -325,7 +325,7 @@ void R_ShutdownVBOs(void) if(vbo->vertexesVBO) { - qglDeleteBuffersARB(1, &vbo->vertexesVBO); + qglDeleteBuffers(1, &vbo->vertexesVBO); } //ri->Free(vbo); @@ -337,7 +337,7 @@ void R_ShutdownVBOs(void) if(ibo->indexesVBO) { - qglDeleteBuffersARB(1, &ibo->indexesVBO); + qglDeleteBuffers(1, &ibo->indexesVBO); } //ri->Free(ibo); @@ -422,59 +422,59 @@ void RB_UpdateVBOs(unsigned int attribBits) R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it - qglBufferDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->vertexesSize, NULL, GL_STREAM_DRAW_ARB); + qglBufferData(GL_ARRAY_BUFFER, tess.vbo->vertexesSize, NULL, GL_STREAM_DRAW); if(attribBits & ATTR_BITS) { if(attribBits & ATTR_POSITION) { //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); } if(attribBits & ATTR_TEXCOORD0 || attribBits & ATTR_TEXCOORD1) { // these are interleaved, so we update both if either need it //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); } if(attribBits & ATTR_NORMAL) { //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); } #ifdef USE_VERT_TANGENT_SPACE if(attribBits & ATTR_TANGENT) { //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); } #endif if(attribBits & ATTR_COLOR) { //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); } if(attribBits & ATTR_LIGHTDIRECTION) { //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0])); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); } } else { - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); #ifdef USE_VERT_TANGENT_SPACE - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); #endif - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); - qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); + qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); } } @@ -484,8 +484,8 @@ void RB_UpdateVBOs(unsigned int attribBits) R_BindIBO(tess.ibo); // orphan old buffer so we don't stall on it - qglBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, tess.ibo->indexesSize, NULL, GL_STREAM_DRAW_ARB); + qglBufferData(GL_ELEMENT_ARRAY_BUFFER, tess.ibo->indexesSize, NULL, GL_STREAM_DRAW); - qglBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); + qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); } } From 94ddd6c7e3cfd608c940aaae5156b51fafb68744 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 17:16:43 +0100 Subject: [PATCH 219/708] [MP] Rend2: Check for NULL GL function pointers All GL function pointers are checked for nullness - ERR_FATAL is generated if a function pointer is null. --- codemp/rd-rend2/tr_extensions.cpp | 305 ++++++++++++++++-------------- 1 file changed, 159 insertions(+), 146 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 2d17f7ada1..23f16f688b 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -218,149 +218,162 @@ static qboolean GLimp_HaveExtension(const char *ext) return (qboolean)((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. } +template +static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionString ) +{ + glFunction = (GLFuncType)GL_GetProcAddress (glFunctionString); + if ( glFunction == NULL ) + { + Com_Error (ERR_FATAL, "ERROR: OpenGL function '%s' could not be found.\n", glFunctionString); + return qfalse; + } + + return qtrue; +} + void GLimp_InitExtraExtensions() { char *extension; const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; // Drawing commands - qglDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)GL_GetProcAddress("glDrawRangeElements"); - qglDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)GL_GetProcAddress("glDrawArraysInstanced"); - qglDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)GL_GetProcAddress("glDrawElementsInstanced"); - qglDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glDrawElementsBaseVertex"); - qglDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glDrawRangeElementsBaseVertex"); - qglDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)GL_GetProcAddress("glDrawElementsInstancedBaseVertex"); - qglMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)GL_GetProcAddress("glMultiDrawArrays"); - qglMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)GL_GetProcAddress("glMultiDrawElements"); - qglMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)GL_GetProcAddress("glMultiDrawElementsBaseVertex"); + GetGLFunction (qglDrawRangeElements, "glDrawRangeElements"); + GetGLFunction (qglDrawArraysInstanced, "glDrawArraysInstanced"); + GetGLFunction (qglDrawElementsInstanced, "glDrawElementsInstanced"); + GetGLFunction (qglDrawElementsBaseVertex, "glDrawElementsBaseVertex"); + GetGLFunction (qglDrawRangeElementsBaseVertex, "glDrawRangeElementsBaseVertex"); + GetGLFunction (qglDrawElementsInstancedBaseVertex, "glDrawElementsInstancedBaseVertex"); + GetGLFunction (qglMultiDrawArrays, "glMultiDrawArrays"); + GetGLFunction (qglMultiDrawElements, "glMultiDrawElements"); + GetGLFunction (qglMultiDrawElementsBaseVertex, "glMultiDrawElementsBaseVertex"); // Vertex arrays - qglVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)GL_GetProcAddress("glVertexAttribPointer"); - qglVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)GL_GetProcAddress("glVertexAttribIPointer"); - qglEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)GL_GetProcAddress("glEnableVertexAttribArray"); - qglDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)GL_GetProcAddress("glDisableVertexAttribArray"); + GetGLFunction (qglVertexAttribPointer, "glVertexAttribPointer"); + GetGLFunction (qglVertexAttribIPointer, "glVertexAttribIPointer"); + GetGLFunction (qglEnableVertexAttribArray, "glEnableVertexAttribArray"); + GetGLFunction (qglDisableVertexAttribArray, "glDisableVertexAttribArray"); // Vertex array objects - qglGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)GL_GetProcAddress("glGenVertexArrays"); - qglDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)GL_GetProcAddress("glDeleteVertexArrays"); - qglBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)GL_GetProcAddress("glBindVertexArray"); - qglIsVertexArray = (PFNGLISVERTEXARRAYPROC)GL_GetProcAddress("glIsVertexArray"); + GetGLFunction (qglGenVertexArrays, "glGenVertexArrays"); + GetGLFunction (qglDeleteVertexArrays, "glDeleteVertexArrays"); + GetGLFunction (qglBindVertexArray, "glBindVertexArray"); + GetGLFunction (qglIsVertexArray, "glIsVertexArray"); // Buffer objects - qglBindBuffer = (PFNGLBINDBUFFERPROC)GL_GetProcAddress("glBindBuffer"); - qglDeleteBuffers = (PFNGLDELETEBUFFERSPROC)GL_GetProcAddress("glDeleteBuffers"); - qglGenBuffers = (PFNGLGENBUFFERSPROC)GL_GetProcAddress("glGenBuffers"); - qglBufferData = (PFNGLBUFFERDATAPROC)GL_GetProcAddress("glBufferData"); - qglBufferSubData = (PFNGLBUFFERSUBDATAPROC)GL_GetProcAddress("glBufferSubData"); - qglGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)GL_GetProcAddress("glGetBufferSubData"); - qglGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)GL_GetProcAddress("glGetBufferParameteriv"); - qglGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)GL_GetProcAddress("glGetBufferParameteri64v"); - qglGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)GL_GetProcAddress("glGetBufferPointerv"); - qglBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)GL_GetProcAddress("glBindBufferRange"); - qglBindBufferBase = (PFNGLBINDBUFFERBASEPROC)GL_GetProcAddress("glBindBufferBase"); - qglMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)GL_GetProcAddress("glMapBufferRange"); - qglMapBuffer = (PFNGLMAPBUFFERPROC)GL_GetProcAddress("glMapBuffer"); - qglFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)GL_GetProcAddress("glFlushMappedBufferRange"); - qglUnmapBuffer = (PFNGLUNMAPBUFFERPROC)GL_GetProcAddress("glUnmapBuffer"); - qglCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)GL_GetProcAddress("glCopyBufferSubData"); - qglIsBuffer = (PFNGLISBUFFERPROC)GL_GetProcAddress("glIsBuffer"); + GetGLFunction (qglBindBuffer, "glBindBuffer"); + GetGLFunction (qglDeleteBuffers, "glDeleteBuffers"); + GetGLFunction (qglGenBuffers, "glGenBuffers"); + GetGLFunction (qglBufferData, "glBufferData"); + GetGLFunction (qglBufferSubData, "glBufferSubData"); + GetGLFunction (qglGetBufferSubData, "glGetBufferSubData"); + GetGLFunction (qglGetBufferParameteriv, "glGetBufferParameteriv"); + GetGLFunction (qglGetBufferParameteri64v, "glGetBufferParameteri64v"); + GetGLFunction (qglGetBufferPointerv, "glGetBufferPointerv"); + GetGLFunction (qglBindBufferRange, "glBindBufferRange"); + GetGLFunction (qglBindBufferBase, "glBindBufferBase"); + GetGLFunction (qglMapBufferRange, "glMapBufferRange"); + GetGLFunction (qglMapBuffer, "glMapBuffer"); + GetGLFunction (qglFlushMappedBufferRange, "glFlushMappedBufferRange"); + GetGLFunction (qglUnmapBuffer, "glUnmapBuffer"); + GetGLFunction (qglCopyBufferSubData, "glCopyBufferSubData"); + GetGLFunction (qglIsBuffer, "glIsBuffer"); // Shader objects - qglCreateShader = (PFNGLCREATESHADERPROC)GL_GetProcAddress("glCreateShader"); - qglShaderSource = (PFNGLSHADERSOURCEPROC)GL_GetProcAddress("glShaderSource"); - qglCompileShader = (PFNGLCOMPILESHADERPROC)GL_GetProcAddress("glCompileShader"); - qglDeleteShader = (PFNGLDELETESHADERPROC)GL_GetProcAddress("glDeleteShader"); - qglIsShader = (PFNGLISSHADERPROC)GL_GetProcAddress("glIsShader"); - qglGetShaderiv = (PFNGLGETSHADERIVPROC)GL_GetProcAddress("glGetShaderiv"); - qglGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)GL_GetProcAddress("glGetShaderInfoLog"); - qglGetShaderSource = (PFNGLGETSHADERSOURCEPROC)GL_GetProcAddress("glGetShaderSource"); + GetGLFunction (qglCreateShader, "glCreateShader"); + GetGLFunction (qglShaderSource, "glShaderSource"); + GetGLFunction (qglCompileShader, "glCompileShader"); + GetGLFunction (qglDeleteShader, "glDeleteShader"); + GetGLFunction (qglIsShader, "glIsShader"); + GetGLFunction (qglGetShaderiv, "glGetShaderiv"); + GetGLFunction (qglGetShaderInfoLog, "glGetShaderInfoLog"); + GetGLFunction (qglGetShaderSource, "glGetShaderSource"); // Program objects - qglCreateProgram = (PFNGLCREATEPROGRAMPROC)GL_GetProcAddress("glCreateProgram"); - qglAttachShader = (PFNGLATTACHSHADERPROC)GL_GetProcAddress("glAttachShader"); - qglDetachShader = (PFNGLDETACHSHADERPROC)GL_GetProcAddress("glDetachShader"); - qglLinkProgram = (PFNGLLINKPROGRAMPROC)GL_GetProcAddress("glLinkProgram"); - qglUseProgram = (PFNGLUSEPROGRAMPROC)GL_GetProcAddress("glUseProgram"); - qglDeleteProgram = (PFNGLDELETEPROGRAMPROC)GL_GetProcAddress("glDeleteProgram"); - qglValidateProgram = (PFNGLVALIDATEPROGRAMPROC)GL_GetProcAddress("glValidateProgram"); - qglIsProgram = (PFNGLISPROGRAMPROC)GL_GetProcAddress("glIsProgram"); - qglGetProgramiv = (PFNGLGETPROGRAMIVPROC)GL_GetProcAddress("glGetProgramiv"); - qglGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)GL_GetProcAddress("glGetAttachedShaders"); - qglGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)GL_GetProcAddress("glGetProgramInfoLog"); + GetGLFunction (qglCreateProgram, "glCreateProgram"); + GetGLFunction (qglAttachShader, "glAttachShader"); + GetGLFunction (qglDetachShader, "glDetachShader"); + GetGLFunction (qglLinkProgram, "glLinkProgram"); + GetGLFunction (qglUseProgram, "glUseProgram"); + GetGLFunction (qglDeleteProgram, "glDeleteProgram"); + GetGLFunction (qglValidateProgram, "glValidateProgram"); + GetGLFunction (qglIsProgram, "glIsProgram"); + GetGLFunction (qglGetProgramiv, "glGetProgramiv"); + GetGLFunction (qglGetAttachedShaders, "glGetAttachedShaders"); + GetGLFunction (qglGetProgramInfoLog, "glGetProgramInfoLog"); // Vertex attributes - qglGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)GL_GetProcAddress("glGetActiveAttrib"); - qglGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)GL_GetProcAddress("glGetAttribLocation"); - qglBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)GL_GetProcAddress("glBindAttribLocation"); - qglGetVertxAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)GL_GetProcAddress("glGetVertxAttribdv"); - qglGetVertxAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)GL_GetProcAddress("glGetVertxAttribfv"); - qglGetVertxAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)GL_GetProcAddress("glGetVertxAttribiv"); - qglGetVertxAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)GL_GetProcAddress("glGetVertxAttribIiv"); - qglGetVertxAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)GL_GetProcAddress("glGetVertxAttribIuiv"); + GetGLFunction (qglGetActiveAttrib, "glGetActiveAttrib"); + GetGLFunction (qglGetAttribLocation, "glGetAttribLocation"); + GetGLFunction (qglBindAttribLocation, "glBindAttribLocation"); + GetGLFunction (qglGetVertxAttribdv, "glGetVertxAttribdv"); + GetGLFunction (qglGetVertxAttribfv, "glGetVertxAttribfv"); + GetGLFunction (qglGetVertxAttribiv, "glGetVertxAttribiv"); + GetGLFunction (qglGetVertxAttribIiv, "glGetVertxAttribIiv"); + GetGLFunction (qglGetVertxAttribIuiv, "glGetVertxAttribIuiv"); // Varying variables - qglTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)GL_GetProcAddress("glTransformFeedbackVaryings"); - qglGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)GL_GetProcAddress("glGetTransformFeedbackVarying"); + GetGLFunction (qglTransformFeedbackVaryings, "glTransformFeedbackVaryings"); + GetGLFunction (qglGetTransformFeedbackVarying, "glGetTransformFeedbackVarying"); // Uniform variables - qglGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)GL_GetProcAddress("glGetUniformLocation"); - qglGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)GL_GetProcAddress("glGetUniformBlockIndex"); - qglGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)GL_GetProcAddress("glGetActiveUniformBlockName"); - qglGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)GL_GetProcAddress("glGetActiveUniformBlockiv"); - qglGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)GL_GetProcAddress("glGetUniformIndices"); - qglGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)GL_GetProcAddress("glGetActiveUniformName"); - qglGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)GL_GetProcAddress("glGetActiveUniform"); - qglGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)GL_GetProcAddress("glGetActiveUniformsiv"); - qglUniform1i = (PFNGLUNIFORM1IPROC)GL_GetProcAddress("glUniform1i"); - qglUniform2i = (PFNGLUNIFORM2IPROC)GL_GetProcAddress("glUniform2i"); - qglUniform3i = (PFNGLUNIFORM3IPROC)GL_GetProcAddress("glUniform3i"); - qglUniform4i = (PFNGLUNIFORM4IPROC)GL_GetProcAddress("glUniform4i"); - qglUniform1f = (PFNGLUNIFORM1FPROC)GL_GetProcAddress("glUniform1f"); - qglUniform2f = (PFNGLUNIFORM2FPROC)GL_GetProcAddress("glUniform2f"); - qglUniform3f = (PFNGLUNIFORM3FPROC)GL_GetProcAddress("glUniform3f"); - qglUniform4f = (PFNGLUNIFORM4FPROC)GL_GetProcAddress("glUniform4f"); - qglUniform1iv = (PFNGLUNIFORM1IVPROC)GL_GetProcAddress("glUniform1iv"); - qglUniform2iv = (PFNGLUNIFORM2IVPROC)GL_GetProcAddress("glUniform2iv"); - qglUniform3iv = (PFNGLUNIFORM3IVPROC)GL_GetProcAddress("glUniform3iv"); - qglUniform4iv = (PFNGLUNIFORM4IVPROC)GL_GetProcAddress("glUniform4iv"); - qglUniform1fv = (PFNGLUNIFORM1FVPROC)GL_GetProcAddress("glUniform1fv"); - qglUniform2fv = (PFNGLUNIFORM2FVPROC)GL_GetProcAddress("glUniform2fv"); - qglUniform3fv = (PFNGLUNIFORM3FVPROC)GL_GetProcAddress("glUniform3fv"); - qglUniform4fv = (PFNGLUNIFORM4FVPROC)GL_GetProcAddress("glUniform4fv"); - qglUniform1ui = (PFNGLUNIFORM1UIPROC)GL_GetProcAddress("glUniform1ui"); - qglUniform2ui = (PFNGLUNIFORM2UIPROC)GL_GetProcAddress("glUniform2ui"); - qglUniform3ui = (PFNGLUNIFORM3UIPROC)GL_GetProcAddress("glUniform3ui"); - qglUniform4ui = (PFNGLUNIFORM4UIPROC)GL_GetProcAddress("glUniform4ui"); - qglUniform1uiv = (PFNGLUNIFORM1UIVPROC)GL_GetProcAddress("glUniform1uiv"); - qglUniform2uiv = (PFNGLUNIFORM2UIVPROC)GL_GetProcAddress("glUniform2uiv"); - qglUniform3uiv = (PFNGLUNIFORM3UIVPROC)GL_GetProcAddress("glUniform3uiv"); - qglUniform4uiv = (PFNGLUNIFORM4UIVPROC)GL_GetProcAddress("glUniform4uiv"); - qglUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)GL_GetProcAddress("glUniformMatrix2fv"); - qglUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)GL_GetProcAddress("glUniformMatrix3fv"); - qglUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)GL_GetProcAddress("glUniformMatrix4fv"); - qglUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)GL_GetProcAddress("glUniformMatrix2x3fv"); - qglUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)GL_GetProcAddress("glUniformMatrix3x2fv"); - qglUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)GL_GetProcAddress("glUniformMatrix2x4fv"); - qglUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)GL_GetProcAddress("glUniformMatrix4x2fv"); - qglUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)GL_GetProcAddress("glUniformMatrix3x4fv"); - qglUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)GL_GetProcAddress("glUniformMatrix4x3fv"); - qglUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)GL_GetProcAddress("glUniformBlockBinding"); - qglGetUniformfv = (PFNGLGETUNIFORMFVPROC)GL_GetProcAddress("glGetUniformfv"); - qglGetUniformiv = (PFNGLGETUNIFORMIVPROC)GL_GetProcAddress("glGetUniformiv"); - qglGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)GL_GetProcAddress("glGetUniformuiv"); + GetGLFunction (qglGetUniformLocation, "glGetUniformLocation"); + GetGLFunction (qglGetUniformBlockIndex, "glGetUniformBlockIndex"); + GetGLFunction (qglGetActiveUniformBlockName, "glGetActiveUniformBlockName"); + GetGLFunction (qglGetActiveUniformBlockiv, "glGetActiveUniformBlockiv"); + GetGLFunction (qglGetUniformIndices, "glGetUniformIndices"); + GetGLFunction (qglGetActiveUniformName, "glGetActiveUniformName"); + GetGLFunction (qglGetActiveUniform, "glGetActiveUniform"); + GetGLFunction (qglGetActiveUniformsiv, "glGetActiveUniformsiv"); + GetGLFunction (qglUniform1i, "glUniform1i"); + GetGLFunction (qglUniform2i, "glUniform2i"); + GetGLFunction (qglUniform3i, "glUniform3i"); + GetGLFunction (qglUniform4i, "glUniform4i"); + GetGLFunction (qglUniform1f, "glUniform1f"); + GetGLFunction (qglUniform2f, "glUniform2f"); + GetGLFunction (qglUniform3f, "glUniform3f"); + GetGLFunction (qglUniform4f, "glUniform4f"); + GetGLFunction (qglUniform1iv, "glUniform1iv"); + GetGLFunction (qglUniform2iv, "glUniform2iv"); + GetGLFunction (qglUniform3iv, "glUniform3iv"); + GetGLFunction (qglUniform4iv, "glUniform4iv"); + GetGLFunction (qglUniform1fv, "glUniform1fv"); + GetGLFunction (qglUniform2fv, "glUniform2fv"); + GetGLFunction (qglUniform3fv, "glUniform3fv"); + GetGLFunction (qglUniform4fv, "glUniform4fv"); + GetGLFunction (qglUniform1ui, "glUniform1ui"); + GetGLFunction (qglUniform2ui, "glUniform2ui"); + GetGLFunction (qglUniform3ui, "glUniform3ui"); + GetGLFunction (qglUniform4ui, "glUniform4ui"); + GetGLFunction (qglUniform1uiv, "glUniform1uiv"); + GetGLFunction (qglUniform2uiv, "glUniform2uiv"); + GetGLFunction (qglUniform3uiv, "glUniform3uiv"); + GetGLFunction (qglUniform4uiv, "glUniform4uiv"); + GetGLFunction (qglUniformMatrix2fv, "glUniformMatrix2fv"); + GetGLFunction (qglUniformMatrix3fv, "glUniformMatrix3fv"); + GetGLFunction (qglUniformMatrix4fv, "glUniformMatrix4fv"); + GetGLFunction (qglUniformMatrix2x3fv, "glUniformMatrix2x3fv"); + GetGLFunction (qglUniformMatrix3x2fv, "glUniformMatrix3x2fv"); + GetGLFunction (qglUniformMatrix2x4fv, "glUniformMatrix2x4fv"); + GetGLFunction (qglUniformMatrix4x2fv, "glUniformMatrix4x2fv"); + GetGLFunction (qglUniformMatrix3x4fv, "glUniformMatrix3x4fv"); + GetGLFunction (qglUniformMatrix4x3fv, "glUniformMatrix4x3fv"); + GetGLFunction (qglUniformBlockBinding, "glUniformBlockBinding"); + GetGLFunction (qglGetUniformfv, "glGetUniformfv"); + GetGLFunction (qglGetUniformiv, "glGetUniformiv"); + GetGLFunction (qglGetUniformuiv, "glGetUniformuiv"); // Transform feedback - qglBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)GL_GetProcAddress("glBeginTransformFeedback"); - qglEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)GL_GetProcAddress("glEndTransformFeedback"); + GetGLFunction (qglBeginTransformFeedback, "glBeginTransformFeedback"); + GetGLFunction (qglEndTransformFeedback, "glEndTransformFeedback"); // Texture compression - qglCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)GL_GetProcAddress("glCompressedTexImage3D"); - qglCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)GL_GetProcAddress("glCompressedTexImage2D"); - qglCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)GL_GetProcAddress("glCompressedTexImage1D"); - qglCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)GL_GetProcAddress("glCompressedTexSubImage3D"); - qglCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)GL_GetProcAddress("glCompressedTexSubImage2D"); - qglCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)GL_GetProcAddress("glCompressedTexSubImage1D"); - qglGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)GL_GetProcAddress("glGetCompressedTexImage"); + GetGLFunction (qglCompressedTexImage3D, "glCompressedTexImage3D"); + GetGLFunction (qglCompressedTexImage2D, "glCompressedTexImage2D"); + GetGLFunction (qglCompressedTexImage1D, "glCompressedTexImage1D"); + GetGLFunction (qglCompressedTexSubImage3D, "glCompressedTexSubImage3D"); + GetGLFunction (qglCompressedTexSubImage2D, "glCompressedTexSubImage2D"); + GetGLFunction (qglCompressedTexSubImage1D, "glCompressedTexSubImage1D"); + GetGLFunction (qglGetCompressedTexImage, "glGetCompressedTexImage"); // GLSL { @@ -377,37 +390,37 @@ void GLimp_InitExtraExtensions() qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glRefConfig.maxRenderbufferSize); qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glRefConfig.maxColorAttachments); - qglIsRenderbuffer = (PFNGLISRENDERBUFFERPROC) GL_GetProcAddress("glIsRenderbuffer"); - qglBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC) GL_GetProcAddress("glBindRenderbuffer"); - qglDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC) GL_GetProcAddress("glDeleteRenderbuffers"); - qglGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC) GL_GetProcAddress("glGenRenderbuffers"); - qglRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC) GL_GetProcAddress("glRenderbufferStorage"); - qglGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC) GL_GetProcAddress("glGetRenderbufferParameteriv"); - qglIsFramebuffer = (PFNGLISFRAMEBUFFERPROC) GL_GetProcAddress("glIsFramebuffer"); - qglBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) GL_GetProcAddress("glBindFramebuffer"); - qglDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC) GL_GetProcAddress("glDeleteFramebuffers"); - qglGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC) GL_GetProcAddress("glGenFramebuffers"); - qglCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC) GL_GetProcAddress("glCheckFramebufferStatus"); - qglFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC) GL_GetProcAddress("glFramebufferTexture1D"); - qglFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC) GL_GetProcAddress("glFramebufferTexture2D"); - qglFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC) GL_GetProcAddress("glFramebufferTexture3D"); - qglFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC) GL_GetProcAddress("glFramebufferRenderbuffer"); - qglGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) GL_GetProcAddress("glGetFramebufferAttachmentParameteriv"); - qglRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)GL_GetProcAddress("glRenderbufferStorageMultisample"); - qglBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)GL_GetProcAddress("glBlitFramebuffer"); - qglGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) GL_GetProcAddress("glGenerateMipmap"); - qglDrawBuffers = (PFNGLDRAWBUFFERSPROC) GL_GetProcAddress("glDrawBuffers"); - qglClearBufferfv = (PFNGLCLEARBUFFERFVPROC)GL_GetProcAddress ("glClearBufferfv"); + GetGLFunction (qglIsRenderbuffer, "glIsRenderbuffer"); + GetGLFunction (qglBindRenderbuffer, "glBindRenderbuffer"); + GetGLFunction (qglDeleteRenderbuffers, "glDeleteRenderbuffers"); + GetGLFunction (qglGenRenderbuffers, "glGenRenderbuffers"); + GetGLFunction (qglRenderbufferStorage, "glRenderbufferStorage"); + GetGLFunction (qglGetRenderbufferParameteriv, "glGetRenderbufferParameteriv"); + GetGLFunction (qglIsFramebuffer, "glIsFramebuffer"); + GetGLFunction (qglBindFramebuffer, "glBindFramebuffer"); + GetGLFunction (qglDeleteFramebuffers, "glDeleteFramebuffers"); + GetGLFunction (qglGenFramebuffers, "glGenFramebuffers"); + GetGLFunction (qglCheckFramebufferStatus, "glCheckFramebufferStatus"); + GetGLFunction (qglFramebufferTexture1D, "glFramebufferTexture1D"); + GetGLFunction (qglFramebufferTexture2D, "glFramebufferTexture2D"); + GetGLFunction (qglFramebufferTexture3D, "glFramebufferTexture3D"); + GetGLFunction (qglFramebufferRenderbuffer, "glFramebufferRenderbuffer"); + GetGLFunction (qglGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv"); + GetGLFunction (qglRenderbufferStorageMultisample, "glRenderbufferStorageMultisample"); + GetGLFunction (qglBlitFramebuffer, "glBlitFramebuffer"); + GetGLFunction (qglGenerateMipmap, "glGenerateMipmap"); + GetGLFunction (qglDrawBuffers, "glDrawBuffers"); + GetGLFunction (qglClearBufferfv, "glClearBufferfv"); // Queries - qglGenQueries = (PFNGLGENQUERIESPROC) GL_GetProcAddress("glGenQueries"); - qglDeleteQueries = (PFNGLDELETEQUERIESPROC) GL_GetProcAddress("glDeleteQueries"); - qglIsQuery = (PFNGLISQUERYPROC) GL_GetProcAddress("glIsQuery"); - qglBeginQuery = (PFNGLBEGINQUERYPROC) GL_GetProcAddress("glBeginQuery"); - qglEndQuery = (PFNGLENDQUERYPROC) GL_GetProcAddress("glEndQuery"); - qglGetQueryiv = (PFNGLGETQUERYIVPROC) GL_GetProcAddress("glGetQueryiv"); - qglGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC) GL_GetProcAddress("glGetQueryObjectiv"); - qglGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC) GL_GetProcAddress("glGetQueryObjectuiv"); + GetGLFunction (qglGenQueries, "glGenQueries"); + GetGLFunction (qglDeleteQueries, "glDeleteQueries"); + GetGLFunction (qglIsQuery, "glIsQuery"); + GetGLFunction (qglBeginQuery, "glBeginQuery"); + GetGLFunction (qglEndQuery, "glEndQuery"); + GetGLFunction (qglGetQueryiv, "glGetQueryiv"); + GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv"); + GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv"); // Memory info glRefConfig.memInfo = MI_NONE; From 8aa449c7325c27ff206f0be7fa15f3215d519c66 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 17:22:46 +0100 Subject: [PATCH 220/708] [MP] Rend2: Fixed GL function name typo --- codemp/rd-rend2/qgl.h | 10 +++++----- codemp/rd-rend2/tr_extensions.cpp | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index ae7a546041..97d16b1ad4 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -851,11 +851,11 @@ extern PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; extern PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; extern PFNGLGETATTRIBLOCATIONPROC qglGetAttribLocation; extern PFNGLBINDATTRIBLOCATIONPROC qglBindAttribLocation; -extern PFNGLGETVERTEXATTRIBDVPROC qglGetVertxAttribdv; -extern PFNGLGETVERTEXATTRIBFVPROC qglGetVertxAttribfv; -extern PFNGLGETVERTEXATTRIBIVPROC qglGetVertxAttribiv; -extern PFNGLGETVERTEXATTRIBIIVPROC qglGetVertxAttribIiv; -extern PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertxAttribIuiv; +extern PFNGLGETVERTEXATTRIBDVPROC qglGetVertexAttribdv; +extern PFNGLGETVERTEXATTRIBFVPROC qglGetVertexAttribfv; +extern PFNGLGETVERTEXATTRIBIVPROC qglGetVertexAttribiv; +extern PFNGLGETVERTEXATTRIBIIVPROC qglGetVertexAttribIiv; +extern PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertexAttribIuiv; // Varying variables extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC qglTransformFeedbackVaryings; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 23f16f688b..6694ae68a2 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -101,11 +101,11 @@ PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; PFNGLGETATTRIBLOCATIONPROC qglGetAttribLocation; PFNGLBINDATTRIBLOCATIONPROC qglBindAttribLocation; -PFNGLGETVERTEXATTRIBDVPROC qglGetVertxAttribdv; -PFNGLGETVERTEXATTRIBFVPROC qglGetVertxAttribfv; -PFNGLGETVERTEXATTRIBIVPROC qglGetVertxAttribiv; -PFNGLGETVERTEXATTRIBIIVPROC qglGetVertxAttribIiv; -PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertxAttribIuiv; +PFNGLGETVERTEXATTRIBDVPROC qglGetVertexAttribdv; +PFNGLGETVERTEXATTRIBFVPROC qglGetVertexAttribfv; +PFNGLGETVERTEXATTRIBIVPROC qglGetVertexAttribiv; +PFNGLGETVERTEXATTRIBIIVPROC qglGetVertexAttribIiv; +PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertexAttribIuiv; // Varying variables PFNGLTRANSFORMFEEDBACKVARYINGSPROC qglTransformFeedbackVaryings; @@ -305,11 +305,11 @@ void GLimp_InitExtraExtensions() GetGLFunction (qglGetActiveAttrib, "glGetActiveAttrib"); GetGLFunction (qglGetAttribLocation, "glGetAttribLocation"); GetGLFunction (qglBindAttribLocation, "glBindAttribLocation"); - GetGLFunction (qglGetVertxAttribdv, "glGetVertxAttribdv"); - GetGLFunction (qglGetVertxAttribfv, "glGetVertxAttribfv"); - GetGLFunction (qglGetVertxAttribiv, "glGetVertxAttribiv"); - GetGLFunction (qglGetVertxAttribIiv, "glGetVertxAttribIiv"); - GetGLFunction (qglGetVertxAttribIuiv, "glGetVertxAttribIuiv"); + GetGLFunction (qglGetVertexAttribdv, "glGetVertexAttribdv"); + GetGLFunction (qglGetVertexAttribfv, "glGetVertexAttribfv"); + GetGLFunction (qglGetVertexAttribiv, "glGetVertexAttribiv"); + GetGLFunction (qglGetVertexAttribIiv, "glGetVertexAttribIiv"); + GetGLFunction (qglGetVertexAttribIuiv, "glGetVertexAttribIuiv"); // Varying variables GetGLFunction (qglTransformFeedbackVaryings, "glTransformFeedbackVaryings"); From 2f8ced7d73635c812de90f73f815fdad3d47a3db Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 18:07:56 +0100 Subject: [PATCH 221/708] [MP] Rend2: Use GetGLFunction for extensions too --- codemp/rd-rend2/tr_extensions.cpp | 313 +++++++++++++++--------------- 1 file changed, 160 insertions(+), 153 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 6694ae68a2..179b3ee8ba 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -219,12 +219,16 @@ static qboolean GLimp_HaveExtension(const char *ext) } template -static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionString ) +static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionString, qboolean errorOnFailure ) { glFunction = (GLFuncType)GL_GetProcAddress (glFunctionString); if ( glFunction == NULL ) { - Com_Error (ERR_FATAL, "ERROR: OpenGL function '%s' could not be found.\n", glFunctionString); + if ( errorOnFailure ) + { + Com_Error (ERR_FATAL, "ERROR: OpenGL function '%s' could not be found.\n", glFunctionString); + } + return qfalse; } @@ -237,143 +241,143 @@ void GLimp_InitExtraExtensions() const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; // Drawing commands - GetGLFunction (qglDrawRangeElements, "glDrawRangeElements"); - GetGLFunction (qglDrawArraysInstanced, "glDrawArraysInstanced"); - GetGLFunction (qglDrawElementsInstanced, "glDrawElementsInstanced"); - GetGLFunction (qglDrawElementsBaseVertex, "glDrawElementsBaseVertex"); - GetGLFunction (qglDrawRangeElementsBaseVertex, "glDrawRangeElementsBaseVertex"); - GetGLFunction (qglDrawElementsInstancedBaseVertex, "glDrawElementsInstancedBaseVertex"); - GetGLFunction (qglMultiDrawArrays, "glMultiDrawArrays"); - GetGLFunction (qglMultiDrawElements, "glMultiDrawElements"); - GetGLFunction (qglMultiDrawElementsBaseVertex, "glMultiDrawElementsBaseVertex"); + GetGLFunction (qglDrawRangeElements, "glDrawRangeElements", qtrue); + GetGLFunction (qglDrawArraysInstanced, "glDrawArraysInstanced", qtrue); + GetGLFunction (qglDrawElementsInstanced, "glDrawElementsInstanced", qtrue); + GetGLFunction (qglDrawElementsBaseVertex, "glDrawElementsBaseVertex", qtrue); + GetGLFunction (qglDrawRangeElementsBaseVertex, "glDrawRangeElementsBaseVertex", qtrue); + GetGLFunction (qglDrawElementsInstancedBaseVertex, "glDrawElementsInstancedBaseVertex", qtrue); + GetGLFunction (qglMultiDrawArrays, "glMultiDrawArrays", qtrue); + GetGLFunction (qglMultiDrawElements, "glMultiDrawElements", qtrue); + GetGLFunction (qglMultiDrawElementsBaseVertex, "glMultiDrawElementsBaseVertex", qtrue); // Vertex arrays - GetGLFunction (qglVertexAttribPointer, "glVertexAttribPointer"); - GetGLFunction (qglVertexAttribIPointer, "glVertexAttribIPointer"); - GetGLFunction (qglEnableVertexAttribArray, "glEnableVertexAttribArray"); - GetGLFunction (qglDisableVertexAttribArray, "glDisableVertexAttribArray"); + GetGLFunction (qglVertexAttribPointer, "glVertexAttribPointer", qtrue); + GetGLFunction (qglVertexAttribIPointer, "glVertexAttribIPointer", qtrue); + GetGLFunction (qglEnableVertexAttribArray, "glEnableVertexAttribArray", qtrue); + GetGLFunction (qglDisableVertexAttribArray, "glDisableVertexAttribArray", qtrue); // Vertex array objects - GetGLFunction (qglGenVertexArrays, "glGenVertexArrays"); - GetGLFunction (qglDeleteVertexArrays, "glDeleteVertexArrays"); - GetGLFunction (qglBindVertexArray, "glBindVertexArray"); - GetGLFunction (qglIsVertexArray, "glIsVertexArray"); + GetGLFunction (qglGenVertexArrays, "glGenVertexArrays", qtrue); + GetGLFunction (qglDeleteVertexArrays, "glDeleteVertexArrays", qtrue); + GetGLFunction (qglBindVertexArray, "glBindVertexArray", qtrue); + GetGLFunction (qglIsVertexArray, "glIsVertexArray", qtrue); // Buffer objects - GetGLFunction (qglBindBuffer, "glBindBuffer"); - GetGLFunction (qglDeleteBuffers, "glDeleteBuffers"); - GetGLFunction (qglGenBuffers, "glGenBuffers"); - GetGLFunction (qglBufferData, "glBufferData"); - GetGLFunction (qglBufferSubData, "glBufferSubData"); - GetGLFunction (qglGetBufferSubData, "glGetBufferSubData"); - GetGLFunction (qglGetBufferParameteriv, "glGetBufferParameteriv"); - GetGLFunction (qglGetBufferParameteri64v, "glGetBufferParameteri64v"); - GetGLFunction (qglGetBufferPointerv, "glGetBufferPointerv"); - GetGLFunction (qglBindBufferRange, "glBindBufferRange"); - GetGLFunction (qglBindBufferBase, "glBindBufferBase"); - GetGLFunction (qglMapBufferRange, "glMapBufferRange"); - GetGLFunction (qglMapBuffer, "glMapBuffer"); - GetGLFunction (qglFlushMappedBufferRange, "glFlushMappedBufferRange"); - GetGLFunction (qglUnmapBuffer, "glUnmapBuffer"); - GetGLFunction (qglCopyBufferSubData, "glCopyBufferSubData"); - GetGLFunction (qglIsBuffer, "glIsBuffer"); + GetGLFunction (qglBindBuffer, "glBindBuffer", qtrue); + GetGLFunction (qglDeleteBuffers, "glDeleteBuffers", qtrue); + GetGLFunction (qglGenBuffers, "glGenBuffers", qtrue); + GetGLFunction (qglBufferData, "glBufferData", qtrue); + GetGLFunction (qglBufferSubData, "glBufferSubData", qtrue); + GetGLFunction (qglGetBufferSubData, "glGetBufferSubData", qtrue); + GetGLFunction (qglGetBufferParameteriv, "glGetBufferParameteriv", qtrue); + GetGLFunction (qglGetBufferParameteri64v, "glGetBufferParameteri64v", qtrue); + GetGLFunction (qglGetBufferPointerv, "glGetBufferPointerv", qtrue); + GetGLFunction (qglBindBufferRange, "glBindBufferRange", qtrue); + GetGLFunction (qglBindBufferBase, "glBindBufferBase", qtrue); + GetGLFunction (qglMapBufferRange, "glMapBufferRange", qtrue); + GetGLFunction (qglMapBuffer, "glMapBuffer", qtrue); + GetGLFunction (qglFlushMappedBufferRange, "glFlushMappedBufferRange", qtrue); + GetGLFunction (qglUnmapBuffer, "glUnmapBuffer", qtrue); + GetGLFunction (qglCopyBufferSubData, "glCopyBufferSubData", qtrue); + GetGLFunction (qglIsBuffer, "glIsBuffer", qtrue); // Shader objects - GetGLFunction (qglCreateShader, "glCreateShader"); - GetGLFunction (qglShaderSource, "glShaderSource"); - GetGLFunction (qglCompileShader, "glCompileShader"); - GetGLFunction (qglDeleteShader, "glDeleteShader"); - GetGLFunction (qglIsShader, "glIsShader"); - GetGLFunction (qglGetShaderiv, "glGetShaderiv"); - GetGLFunction (qglGetShaderInfoLog, "glGetShaderInfoLog"); - GetGLFunction (qglGetShaderSource, "glGetShaderSource"); + GetGLFunction (qglCreateShader, "glCreateShader", qtrue); + GetGLFunction (qglShaderSource, "glShaderSource", qtrue); + GetGLFunction (qglCompileShader, "glCompileShader", qtrue); + GetGLFunction (qglDeleteShader, "glDeleteShader", qtrue); + GetGLFunction (qglIsShader, "glIsShader", qtrue); + GetGLFunction (qglGetShaderiv, "glGetShaderiv", qtrue); + GetGLFunction (qglGetShaderInfoLog, "glGetShaderInfoLog", qtrue); + GetGLFunction (qglGetShaderSource, "glGetShaderSource", qtrue); // Program objects - GetGLFunction (qglCreateProgram, "glCreateProgram"); - GetGLFunction (qglAttachShader, "glAttachShader"); - GetGLFunction (qglDetachShader, "glDetachShader"); - GetGLFunction (qglLinkProgram, "glLinkProgram"); - GetGLFunction (qglUseProgram, "glUseProgram"); - GetGLFunction (qglDeleteProgram, "glDeleteProgram"); - GetGLFunction (qglValidateProgram, "glValidateProgram"); - GetGLFunction (qglIsProgram, "glIsProgram"); - GetGLFunction (qglGetProgramiv, "glGetProgramiv"); - GetGLFunction (qglGetAttachedShaders, "glGetAttachedShaders"); - GetGLFunction (qglGetProgramInfoLog, "glGetProgramInfoLog"); + GetGLFunction (qglCreateProgram, "glCreateProgram", qtrue); + GetGLFunction (qglAttachShader, "glAttachShader", qtrue); + GetGLFunction (qglDetachShader, "glDetachShader", qtrue); + GetGLFunction (qglLinkProgram, "glLinkProgram", qtrue); + GetGLFunction (qglUseProgram, "glUseProgram", qtrue); + GetGLFunction (qglDeleteProgram, "glDeleteProgram", qtrue); + GetGLFunction (qglValidateProgram, "glValidateProgram", qtrue); + GetGLFunction (qglIsProgram, "glIsProgram", qtrue); + GetGLFunction (qglGetProgramiv, "glGetProgramiv", qtrue); + GetGLFunction (qglGetAttachedShaders, "glGetAttachedShaders", qtrue); + GetGLFunction (qglGetProgramInfoLog, "glGetProgramInfoLog", qtrue); // Vertex attributes - GetGLFunction (qglGetActiveAttrib, "glGetActiveAttrib"); - GetGLFunction (qglGetAttribLocation, "glGetAttribLocation"); - GetGLFunction (qglBindAttribLocation, "glBindAttribLocation"); - GetGLFunction (qglGetVertexAttribdv, "glGetVertexAttribdv"); - GetGLFunction (qglGetVertexAttribfv, "glGetVertexAttribfv"); - GetGLFunction (qglGetVertexAttribiv, "glGetVertexAttribiv"); - GetGLFunction (qglGetVertexAttribIiv, "glGetVertexAttribIiv"); - GetGLFunction (qglGetVertexAttribIuiv, "glGetVertexAttribIuiv"); + GetGLFunction (qglGetActiveAttrib, "glGetActiveAttrib", qtrue); + GetGLFunction (qglGetAttribLocation, "glGetAttribLocation", qtrue); + GetGLFunction (qglBindAttribLocation, "glBindAttribLocation", qtrue); + GetGLFunction (qglGetVertexAttribdv, "glGetVertexAttribdv", qtrue); + GetGLFunction (qglGetVertexAttribfv, "glGetVertexAttribfv", qtrue); + GetGLFunction (qglGetVertexAttribiv, "glGetVertexAttribiv", qtrue); + GetGLFunction (qglGetVertexAttribIiv, "glGetVertexAttribIiv", qtrue); + GetGLFunction (qglGetVertexAttribIuiv, "glGetVertexAttribIuiv", qtrue); // Varying variables - GetGLFunction (qglTransformFeedbackVaryings, "glTransformFeedbackVaryings"); - GetGLFunction (qglGetTransformFeedbackVarying, "glGetTransformFeedbackVarying"); + GetGLFunction (qglTransformFeedbackVaryings, "glTransformFeedbackVaryings", qtrue); + GetGLFunction (qglGetTransformFeedbackVarying, "glGetTransformFeedbackVarying", qtrue); // Uniform variables - GetGLFunction (qglGetUniformLocation, "glGetUniformLocation"); - GetGLFunction (qglGetUniformBlockIndex, "glGetUniformBlockIndex"); - GetGLFunction (qglGetActiveUniformBlockName, "glGetActiveUniformBlockName"); - GetGLFunction (qglGetActiveUniformBlockiv, "glGetActiveUniformBlockiv"); - GetGLFunction (qglGetUniformIndices, "glGetUniformIndices"); - GetGLFunction (qglGetActiveUniformName, "glGetActiveUniformName"); - GetGLFunction (qglGetActiveUniform, "glGetActiveUniform"); - GetGLFunction (qglGetActiveUniformsiv, "glGetActiveUniformsiv"); - GetGLFunction (qglUniform1i, "glUniform1i"); - GetGLFunction (qglUniform2i, "glUniform2i"); - GetGLFunction (qglUniform3i, "glUniform3i"); - GetGLFunction (qglUniform4i, "glUniform4i"); - GetGLFunction (qglUniform1f, "glUniform1f"); - GetGLFunction (qglUniform2f, "glUniform2f"); - GetGLFunction (qglUniform3f, "glUniform3f"); - GetGLFunction (qglUniform4f, "glUniform4f"); - GetGLFunction (qglUniform1iv, "glUniform1iv"); - GetGLFunction (qglUniform2iv, "glUniform2iv"); - GetGLFunction (qglUniform3iv, "glUniform3iv"); - GetGLFunction (qglUniform4iv, "glUniform4iv"); - GetGLFunction (qglUniform1fv, "glUniform1fv"); - GetGLFunction (qglUniform2fv, "glUniform2fv"); - GetGLFunction (qglUniform3fv, "glUniform3fv"); - GetGLFunction (qglUniform4fv, "glUniform4fv"); - GetGLFunction (qglUniform1ui, "glUniform1ui"); - GetGLFunction (qglUniform2ui, "glUniform2ui"); - GetGLFunction (qglUniform3ui, "glUniform3ui"); - GetGLFunction (qglUniform4ui, "glUniform4ui"); - GetGLFunction (qglUniform1uiv, "glUniform1uiv"); - GetGLFunction (qglUniform2uiv, "glUniform2uiv"); - GetGLFunction (qglUniform3uiv, "glUniform3uiv"); - GetGLFunction (qglUniform4uiv, "glUniform4uiv"); - GetGLFunction (qglUniformMatrix2fv, "glUniformMatrix2fv"); - GetGLFunction (qglUniformMatrix3fv, "glUniformMatrix3fv"); - GetGLFunction (qglUniformMatrix4fv, "glUniformMatrix4fv"); - GetGLFunction (qglUniformMatrix2x3fv, "glUniformMatrix2x3fv"); - GetGLFunction (qglUniformMatrix3x2fv, "glUniformMatrix3x2fv"); - GetGLFunction (qglUniformMatrix2x4fv, "glUniformMatrix2x4fv"); - GetGLFunction (qglUniformMatrix4x2fv, "glUniformMatrix4x2fv"); - GetGLFunction (qglUniformMatrix3x4fv, "glUniformMatrix3x4fv"); - GetGLFunction (qglUniformMatrix4x3fv, "glUniformMatrix4x3fv"); - GetGLFunction (qglUniformBlockBinding, "glUniformBlockBinding"); - GetGLFunction (qglGetUniformfv, "glGetUniformfv"); - GetGLFunction (qglGetUniformiv, "glGetUniformiv"); - GetGLFunction (qglGetUniformuiv, "glGetUniformuiv"); + GetGLFunction (qglGetUniformLocation, "glGetUniformLocation", qtrue); + GetGLFunction (qglGetUniformBlockIndex, "glGetUniformBlockIndex", qtrue); + GetGLFunction (qglGetActiveUniformBlockName, "glGetActiveUniformBlockName", qtrue); + GetGLFunction (qglGetActiveUniformBlockiv, "glGetActiveUniformBlockiv", qtrue); + GetGLFunction (qglGetUniformIndices, "glGetUniformIndices", qtrue); + GetGLFunction (qglGetActiveUniformName, "glGetActiveUniformName", qtrue); + GetGLFunction (qglGetActiveUniform, "glGetActiveUniform", qtrue); + GetGLFunction (qglGetActiveUniformsiv, "glGetActiveUniformsiv", qtrue); + GetGLFunction (qglUniform1i, "glUniform1i", qtrue); + GetGLFunction (qglUniform2i, "glUniform2i", qtrue); + GetGLFunction (qglUniform3i, "glUniform3i", qtrue); + GetGLFunction (qglUniform4i, "glUniform4i", qtrue); + GetGLFunction (qglUniform1f, "glUniform1f", qtrue); + GetGLFunction (qglUniform2f, "glUniform2f", qtrue); + GetGLFunction (qglUniform3f, "glUniform3f", qtrue); + GetGLFunction (qglUniform4f, "glUniform4f", qtrue); + GetGLFunction (qglUniform1iv, "glUniform1iv", qtrue); + GetGLFunction (qglUniform2iv, "glUniform2iv", qtrue); + GetGLFunction (qglUniform3iv, "glUniform3iv", qtrue); + GetGLFunction (qglUniform4iv, "glUniform4iv", qtrue); + GetGLFunction (qglUniform1fv, "glUniform1fv", qtrue); + GetGLFunction (qglUniform2fv, "glUniform2fv", qtrue); + GetGLFunction (qglUniform3fv, "glUniform3fv", qtrue); + GetGLFunction (qglUniform4fv, "glUniform4fv", qtrue); + GetGLFunction (qglUniform1ui, "glUniform1ui", qtrue); + GetGLFunction (qglUniform2ui, "glUniform2ui", qtrue); + GetGLFunction (qglUniform3ui, "glUniform3ui", qtrue); + GetGLFunction (qglUniform4ui, "glUniform4ui", qtrue); + GetGLFunction (qglUniform1uiv, "glUniform1uiv", qtrue); + GetGLFunction (qglUniform2uiv, "glUniform2uiv", qtrue); + GetGLFunction (qglUniform3uiv, "glUniform3uiv", qtrue); + GetGLFunction (qglUniform4uiv, "glUniform4uiv", qtrue); + GetGLFunction (qglUniformMatrix2fv, "glUniformMatrix2fv", qtrue); + GetGLFunction (qglUniformMatrix3fv, "glUniformMatrix3fv", qtrue); + GetGLFunction (qglUniformMatrix4fv, "glUniformMatrix4fv", qtrue); + GetGLFunction (qglUniformMatrix2x3fv, "glUniformMatrix2x3fv", qtrue); + GetGLFunction (qglUniformMatrix3x2fv, "glUniformMatrix3x2fv", qtrue); + GetGLFunction (qglUniformMatrix2x4fv, "glUniformMatrix2x4fv", qtrue); + GetGLFunction (qglUniformMatrix4x2fv, "glUniformMatrix4x2fv", qtrue); + GetGLFunction (qglUniformMatrix3x4fv, "glUniformMatrix3x4fv", qtrue); + GetGLFunction (qglUniformMatrix4x3fv, "glUniformMatrix4x3fv", qtrue); + GetGLFunction (qglUniformBlockBinding, "glUniformBlockBinding", qtrue); + GetGLFunction (qglGetUniformfv, "glGetUniformfv", qtrue); + GetGLFunction (qglGetUniformiv, "glGetUniformiv", qtrue); + GetGLFunction (qglGetUniformuiv, "glGetUniformuiv", qtrue); // Transform feedback - GetGLFunction (qglBeginTransformFeedback, "glBeginTransformFeedback"); - GetGLFunction (qglEndTransformFeedback, "glEndTransformFeedback"); + GetGLFunction (qglBeginTransformFeedback, "glBeginTransformFeedback", qtrue); + GetGLFunction (qglEndTransformFeedback, "glEndTransformFeedback", qtrue); // Texture compression - GetGLFunction (qglCompressedTexImage3D, "glCompressedTexImage3D"); - GetGLFunction (qglCompressedTexImage2D, "glCompressedTexImage2D"); - GetGLFunction (qglCompressedTexImage1D, "glCompressedTexImage1D"); - GetGLFunction (qglCompressedTexSubImage3D, "glCompressedTexSubImage3D"); - GetGLFunction (qglCompressedTexSubImage2D, "glCompressedTexSubImage2D"); - GetGLFunction (qglCompressedTexSubImage1D, "glCompressedTexSubImage1D"); - GetGLFunction (qglGetCompressedTexImage, "glGetCompressedTexImage"); + GetGLFunction (qglCompressedTexImage3D, "glCompressedTexImage3D", qtrue); + GetGLFunction (qglCompressedTexImage2D, "glCompressedTexImage2D", qtrue); + GetGLFunction (qglCompressedTexImage1D, "glCompressedTexImage1D", qtrue); + GetGLFunction (qglCompressedTexSubImage3D, "glCompressedTexSubImage3D", qtrue); + GetGLFunction (qglCompressedTexSubImage2D, "glCompressedTexSubImage2D", qtrue); + GetGLFunction (qglCompressedTexSubImage1D, "glCompressedTexSubImage1D", qtrue); + GetGLFunction (qglGetCompressedTexImage, "glGetCompressedTexImage", qtrue); // GLSL { @@ -390,37 +394,37 @@ void GLimp_InitExtraExtensions() qglGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glRefConfig.maxRenderbufferSize); qglGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glRefConfig.maxColorAttachments); - GetGLFunction (qglIsRenderbuffer, "glIsRenderbuffer"); - GetGLFunction (qglBindRenderbuffer, "glBindRenderbuffer"); - GetGLFunction (qglDeleteRenderbuffers, "glDeleteRenderbuffers"); - GetGLFunction (qglGenRenderbuffers, "glGenRenderbuffers"); - GetGLFunction (qglRenderbufferStorage, "glRenderbufferStorage"); - GetGLFunction (qglGetRenderbufferParameteriv, "glGetRenderbufferParameteriv"); - GetGLFunction (qglIsFramebuffer, "glIsFramebuffer"); - GetGLFunction (qglBindFramebuffer, "glBindFramebuffer"); - GetGLFunction (qglDeleteFramebuffers, "glDeleteFramebuffers"); - GetGLFunction (qglGenFramebuffers, "glGenFramebuffers"); - GetGLFunction (qglCheckFramebufferStatus, "glCheckFramebufferStatus"); - GetGLFunction (qglFramebufferTexture1D, "glFramebufferTexture1D"); - GetGLFunction (qglFramebufferTexture2D, "glFramebufferTexture2D"); - GetGLFunction (qglFramebufferTexture3D, "glFramebufferTexture3D"); - GetGLFunction (qglFramebufferRenderbuffer, "glFramebufferRenderbuffer"); - GetGLFunction (qglGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv"); - GetGLFunction (qglRenderbufferStorageMultisample, "glRenderbufferStorageMultisample"); - GetGLFunction (qglBlitFramebuffer, "glBlitFramebuffer"); - GetGLFunction (qglGenerateMipmap, "glGenerateMipmap"); - GetGLFunction (qglDrawBuffers, "glDrawBuffers"); - GetGLFunction (qglClearBufferfv, "glClearBufferfv"); + GetGLFunction (qglIsRenderbuffer, "glIsRenderbuffer", qtrue); + GetGLFunction (qglBindRenderbuffer, "glBindRenderbuffer", qtrue); + GetGLFunction (qglDeleteRenderbuffers, "glDeleteRenderbuffers", qtrue); + GetGLFunction (qglGenRenderbuffers, "glGenRenderbuffers", qtrue); + GetGLFunction (qglRenderbufferStorage, "glRenderbufferStorage", qtrue); + GetGLFunction (qglGetRenderbufferParameteriv, "glGetRenderbufferParameteriv", qtrue); + GetGLFunction (qglIsFramebuffer, "glIsFramebuffer", qtrue); + GetGLFunction (qglBindFramebuffer, "glBindFramebuffer", qtrue); + GetGLFunction (qglDeleteFramebuffers, "glDeleteFramebuffers", qtrue); + GetGLFunction (qglGenFramebuffers, "glGenFramebuffers", qtrue); + GetGLFunction (qglCheckFramebufferStatus, "glCheckFramebufferStatus", qtrue); + GetGLFunction (qglFramebufferTexture1D, "glFramebufferTexture1D", qtrue); + GetGLFunction (qglFramebufferTexture2D, "glFramebufferTexture2D", qtrue); + GetGLFunction (qglFramebufferTexture3D, "glFramebufferTexture3D", qtrue); + GetGLFunction (qglFramebufferRenderbuffer, "glFramebufferRenderbuffer", qtrue); + GetGLFunction (qglGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", qtrue); + GetGLFunction (qglRenderbufferStorageMultisample, "glRenderbufferStorageMultisample", qtrue); + GetGLFunction (qglBlitFramebuffer, "glBlitFramebuffer", qtrue); + GetGLFunction (qglGenerateMipmap, "glGenerateMipmap", qtrue); + GetGLFunction (qglDrawBuffers, "glDrawBuffers", qtrue); + GetGLFunction (qglClearBufferfv, "glClearBufferfv", qtrue); // Queries - GetGLFunction (qglGenQueries, "glGenQueries"); - GetGLFunction (qglDeleteQueries, "glDeleteQueries"); - GetGLFunction (qglIsQuery, "glIsQuery"); - GetGLFunction (qglBeginQuery, "glBeginQuery"); - GetGLFunction (qglEndQuery, "glEndQuery"); - GetGLFunction (qglGetQueryiv, "glGetQueryiv"); - GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv"); - GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv"); + GetGLFunction (qglGenQueries, "glGenQueries", qtrue); + GetGLFunction (qglDeleteQueries, "glDeleteQueries", qtrue); + GetGLFunction (qglIsQuery, "glIsQuery", qtrue); + GetGLFunction (qglBeginQuery, "glBeginQuery", qtrue); + GetGLFunction (qglEndQuery, "glEndQuery", qtrue); + GetGLFunction (qglGetQueryiv, "glGetQueryiv", qtrue); + GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv", qtrue); + GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv", qtrue); // Memory info glRefConfig.memInfo = MI_NONE; @@ -469,11 +473,14 @@ void GLimp_InitExtraExtensions() glRefConfig.immutableTextures = qfalse; if( GLimp_HaveExtension( extension ) ) { - qglTexStorage1D = (PFNGLTEXSTORAGE1DPROC)GL_GetProcAddress("glTexStorage1D"); - qglTexStorage2D = (PFNGLTEXSTORAGE2DPROC)GL_GetProcAddress("glTexStorage2D"); - qglTexStorage3D = (PFNGLTEXSTORAGE3DPROC)GL_GetProcAddress("glTexStorage3D"); - - ri->Printf(PRINT_ALL, result[1], extension); + qboolean loaded = qtrue; + + loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage3D, "glTexStorage3D", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage1D, "glTexStorage1D", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage2D, "glTexStorage2D", qfalse)); + + glRefConfig.immutableTextures = loaded; + ri->Printf(PRINT_ALL, result[loaded], extension); } else { From f0ad18ae5c028c17f40fa04120630ceb89aeb23c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 18:08:20 +0100 Subject: [PATCH 222/708] [MP] Rend2: Fix immutable textures --- codemp/rd-rend2/tr_image.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 54078d4a78..78115c8a71 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2018,15 +2018,31 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei if ( data && r_colorMipLevels->integer ) R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] ); - if ( subtexture ) + if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) { - x >>= 1; - y >>= 1; - qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); + if ( subtexture ) + { + x >>= 1; + y >>= 1; + qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); + } + else + { + qglTexSubImage2D (GL_TEXTURE_2D, miplevel, 0, 0, width, height, dataFormat, dataType, data ); + } } else { - qglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, width, height, 0, dataFormat, dataType, data ); + if ( subtexture ) + { + x >>= 1; + y >>= 1; + qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); + } + else + { + qglTexImage2D (GL_TEXTURE_2D, miplevel, internalFormat, width, height, 0, dataFormat, dataType, data ); + } } } } From 9f887d7d091edcc889c2cf0b3c0930ce34e475aa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 18:14:55 +0100 Subject: [PATCH 223/708] [MP] Rend2: Refactor immutable texture loading --- codemp/rd-rend2/tr_image.cpp | 40 +++++++++++++----------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 78115c8a71..d47b21f1f6 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1956,26 +1956,23 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei break; } - if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) + if ( subtexture ) { - if ( subtexture ) - { - qglTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data); - } - else + qglTexSubImage2D (GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data); + } + else + { + if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) { int numLevels = (flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; qglTexStorage2D (GL_TEXTURE_2D, numLevels, internalFormat, width, height); qglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, dataFormat, dataType, data); } - } - else - { - if ( subtexture ) - qglTexSubImage2D( GL_TEXTURE_2D, 0, x, y, width, height, dataFormat, dataType, data ); else + { qglTexImage2D (GL_TEXTURE_2D, 0, internalFormat, width, height, 0, dataFormat, dataType, data ); + } } if (flags & IMGFLAG_MIPMAP) @@ -2018,26 +2015,17 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei if ( data && r_colorMipLevels->integer ) R_BlendOverTexture( (byte *)data, width * height, mipBlendColors[miplevel] ); - if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) + if ( subtexture ) { - if ( subtexture ) - { - x >>= 1; - y >>= 1; - qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); - } - else - { - qglTexSubImage2D (GL_TEXTURE_2D, miplevel, 0, 0, width, height, dataFormat, dataType, data ); - } + x >>= 1; + y >>= 1; + qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); } else { - if ( subtexture ) + if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) { - x >>= 1; - y >>= 1; - qglTexSubImage2D( GL_TEXTURE_2D, miplevel, x, y, width, height, dataFormat, dataType, data ); + qglTexSubImage2D (GL_TEXTURE_2D, miplevel, 0, 0, width, height, dataFormat, dataType, data ); } else { From 8626d495ca4fac5cf1ae0cf4d7c6030c0165d8f5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 19:49:53 +0100 Subject: [PATCH 224/708] [MP] Rend2: Remove explicit fragment out locations This commit removes the explicit layout location qualifiers from some fragment shaders as these are not available in OpenGL 3.2. They are replaced with API calls to glBindFragDataLocation to set their locations. --- codemp/rd-rend2/glsl/generic_fp.glsl | 2 +- codemp/rd-rend2/glsl/lightall_fp.glsl | 2 +- codemp/rd-rend2/qgl.h | 1 + codemp/rd-rend2/tr_extensions.cpp | 2 ++ codemp/rd-rend2/tr_glsl.cpp | 29 +++++++++++---------------- codemp/rd-rend2/tr_local.h | 6 +++--- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index 4f7922a02b..e518cdbd89 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -14,7 +14,7 @@ varying vec2 var_LightTex; varying vec4 var_Color; -layout(location = 1) out vec4 out_Glow; +out vec4 out_Glow; void main() { diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 4687e99bde..bdee3a40fe 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -74,7 +74,7 @@ varying vec4 var_LightDir; varying vec4 var_PrimaryLightDir; #endif -layout(location = 1) out vec4 out_Glow; +out vec4 out_Glow; #define EPSILON 0.00000001 diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 97d16b1ad4..33853d933e 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -846,6 +846,7 @@ extern PFNGLISPROGRAMPROC qglIsProgram; extern PFNGLGETPROGRAMIVPROC qglGetProgramiv; extern PFNGLGETATTACHEDSHADERSPROC qglGetAttachedShaders; extern PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; +extern PFNGLBINDFRAGDATALOCATIONPROC qglBindFragDataLocation; // Vertex attributes extern PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 179b3ee8ba..df6ddc59d5 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -96,6 +96,7 @@ PFNGLISPROGRAMPROC qglIsProgram; PFNGLGETPROGRAMIVPROC qglGetProgramiv; PFNGLGETATTACHEDSHADERSPROC qglGetAttachedShaders; PFNGLGETPROGRAMINFOLOGPROC qglGetProgramInfoLog; +PFNGLBINDFRAGDATALOCATIONPROC qglBindFragDataLocation; // Vertex attributes PFNGLGETACTIVEATTRIBPROC qglGetActiveAttrib; @@ -304,6 +305,7 @@ void GLimp_InitExtraExtensions() GetGLFunction (qglGetProgramiv, "glGetProgramiv", qtrue); GetGLFunction (qglGetAttachedShaders, "glGetAttachedShaders", qtrue); GetGLFunction (qglGetProgramInfoLog, "glGetProgramInfoLog", qtrue); + GetGLFunction (qglBindFragDataLocation, "glBindFragDataLocation", qtrue); // Vertex attributes GetGLFunction (qglGetActiveAttrib, "glGetActiveAttrib", qtrue); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e97f50071a..dac908ef39 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -265,27 +265,19 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha dest[0] = '\0'; - // HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones - if(glRefConfig.glslMajorVersion > 1 || (glRefConfig.glslMajorVersion == 1 && glRefConfig.glslMinorVersion >= 30)) - { - Q_strcat(dest, size, "#version 330 core\n"); - - if(shaderType == GL_VERTEX_SHADER) - { - Q_strcat(dest, size, "#define attribute in\n"); - Q_strcat(dest, size, "#define varying out\n"); - } - else - { - Q_strcat(dest, size, "#define varying in\n"); + Q_strcat(dest, size, "#version 150 core\n"); - Q_strcat(dest, size, "layout(location = 0) out vec4 out_Color;\n"); - Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); - } + if(shaderType == GL_VERTEX_SHADER) + { + Q_strcat(dest, size, "#define attribute in\n"); + Q_strcat(dest, size, "#define varying out\n"); } else { - Q_strcat(dest, size, "#version 120\n"); + Q_strcat(dest, size, "#define varying in\n"); + + Q_strcat(dest, size, "out vec4 out_Color;\n"); + Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); } // HACK: add some macros to avoid extra uniforms and save speed and code maintenance @@ -576,6 +568,9 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) qglAttachShader(program->program, program->vertexShader); qglAttachShader(program->program, program->fragmentShader); + qglBindFragDataLocation (program->program, 0, "out_Color"); + qglBindFragDataLocation (program->program, 1, "out_Glow"); + if(attribs & ATTR_POSITION) qglBindAttribLocation(program->program, ATTR_INDEX_POSITION, "attr_Position"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 1c0c687c2b..986c178fb9 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1101,9 +1101,9 @@ typedef struct shaderProgram_s { char *name; - GLhandleARB program; - GLhandleARB vertexShader; - GLhandleARB fragmentShader; + GLuint program; + GLuint vertexShader; + GLuint fragmentShader; uint32_t attribs; // vertex array attributes // uniform parameters From 791b090b923af82ee7c508e439373e0e94f1c3bb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 Jun 2014 19:56:31 +0100 Subject: [PATCH 225/708] [MP] Rend2: Remove #version directive The #version directive is added programmatically by the renderer. They shouldn't be placed in the GLSL files. --- codemp/rd-rend2/glsl/texturecolor_fp.glsl | 2 -- codemp/rd-rend2/glsl/texturecolor_vp.glsl | 2 -- 2 files changed, 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/texturecolor_fp.glsl b/codemp/rd-rend2/glsl/texturecolor_fp.glsl index e077e7daf2..7c9046e18e 100644 --- a/codemp/rd-rend2/glsl/texturecolor_fp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_fp.glsl @@ -1,5 +1,3 @@ -#version 120 - uniform sampler2D u_DiffuseMap; uniform vec4 u_Color; diff --git a/codemp/rd-rend2/glsl/texturecolor_vp.glsl b/codemp/rd-rend2/glsl/texturecolor_vp.glsl index 7a5750a564..552cd93837 100644 --- a/codemp/rd-rend2/glsl/texturecolor_vp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_vp.glsl @@ -1,5 +1,3 @@ -#version 120 - attribute vec3 attr_Position; attribute vec4 attr_TexCoord0; From cd4861eea3ee31d9aed677feec4d31fc13663469 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 14 Jun 2014 12:20:33 +0100 Subject: [PATCH 226/708] [MP] Rend2: Fix for crash when using NV drivers. Passing NULL to glTexSubImage2D on Nvidia drivers generates a segfault. Adding a guard prevents this. This commit also adds some extra checks so that mipmaps aren't generated when creating an immutable texture with NULL data. --- codemp/rd-rend2/tr_image.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d47b21f1f6..e92c397672 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1967,7 +1967,11 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei int numLevels = (flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; qglTexStorage2D (GL_TEXTURE_2D, numLevels, internalFormat, width, height); - qglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, dataFormat, dataType, data); + + if ( data != NULL ) + { + qglTexSubImage2D (GL_TEXTURE_2D, 0, 0, 0, width, height, dataFormat, dataType, data); + } } else { @@ -1975,8 +1979,12 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } } - if (flags & IMGFLAG_MIPMAP) + if ((flags & IMGFLAG_MIPMAP) && + (data != NULL || !glRefConfig.immutableTextures || (flags & IMGFLAG_MUTABLE))) { + // Don't need to generate mipmaps if we are generating an immutable texture and + // the data is NULL. All levels have already been allocated by glTexStorage2D. + int miplevel = 0; while (width > 1 || height > 1) From c245c3f20c4af354d3ec246444557ce7f0850ce8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 14 Jun 2014 20:30:14 +0100 Subject: [PATCH 227/708] [MP] Rend2: Remove usage of C++11 constructor The GLSL compactor was using a constructor for std::ofstream which was introduced in C++11. --- codemp/rd-rend2/glsl/compact.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 06fb01b819..c6882c1c66 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -114,7 +114,7 @@ int main ( int argc, char *argv[] ) output += "\";\n\n"; } - std::ofstream ofs (outFile, std::ios::out); + std::ofstream ofs (outFile.c_str(), std::ios::out); if ( !ofs ) { std::cerr << "Could not create file " << outFile << '\n'; From f26638b172210195cad05ed1595737cf357446c4 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 15 Jun 2014 15:03:57 +0100 Subject: [PATCH 228/708] [MP] Rend2: Fixed another case of NV driver crash Similar to before with NULL data and glTexSubImage2D, this time for cubemapped textures. Thanks to UQ1 for finding this. --- codemp/rd-rend2/tr_image.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index e92c397672..8203bd862b 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2331,9 +2331,12 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexStorage2D (GL_TEXTURE_CUBE_MAP, numLevels, internalFormat, width, height); - for ( int i = 0; i < 6; i++ ) + if ( pic != NULL ) { - qglTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pic); + for ( int i = 0; i < 6; i++ ) + { + qglTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pic); + } } } else From b5d4dd50ede450a760181bb9547dc22dd1661a83 Mon Sep 17 00:00:00 2001 From: Razish Date: Fri, 20 Jun 2014 10:14:21 +1000 Subject: [PATCH 229/708] [MP] Rend2: Fix fog shader for dynamic glow. Patch by UniqueOne --- codemp/rd-rend2/glsl/fogpass_fp.glsl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl index e2ad465ba3..652387319c 100644 --- a/codemp/rd-rend2/glsl/fogpass_fp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_fp.glsl @@ -2,8 +2,16 @@ uniform vec4 u_Color; varying float var_Scale; +out vec4 out_Glow; + void main() { gl_FragColor = u_Color; gl_FragColor.a = sqrt(clamp(var_Scale, 0.0, 1.0)); + +#if defined(USE_GLOW_BUFFER) + out_Glow = gl_FragColor; +#else + out_Glow = vec4(0.0); +#endif } From 4d620915811bf8f8cb7986c4c5954313ab88a870 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 21 Jun 2014 20:22:59 +0100 Subject: [PATCH 230/708] [MP] Rend2: Fix normal/tangent calculations --- codemp/rd-rend2/glsl/lightall_vp.glsl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 9e6b500c2b..b4161b4021 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -189,7 +189,7 @@ void main() vec3 position = position4.xyz; vec3 normal = normalize (normal4.xyz); #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = tangent4.xyz; + vec3 tangent = normalize (tangent4.xyz); #endif #else vec3 position = attr_Position; @@ -199,9 +199,11 @@ void main() #endif #endif +#if !defined(USE_SKELETAL_ANIMATION) normal = normal * 2.0 - vec3(1.0); -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) tangent = tangent * 2.0 - vec3(1.0); + #endif #endif #if defined(USE_TCGEN) From 4942b94b808284cbfc591ac28bbe8f5c411610f9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 21 Jun 2014 21:18:41 +0100 Subject: [PATCH 231/708] [MP] Rend2: Removed FIXME --- codemp/rd-rend2/tr_ghoul2.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 9ddcf0b617..1d18d38e25 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -8,8 +8,6 @@ #include "ghoul2/G2_gore.h" #endif -// FIXME: ghoul2 doesn't use cubemaps :( - #ifdef _MSC_VER #pragma warning (disable: 4512) //default assignment operator could not be gened #endif From 14196fa554a695a2731e5021ad0df490b032df00 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 22 Jun 2014 12:26:20 +0100 Subject: [PATCH 232/708] [MP] Rend2: Fix cubemapping Removing a tiny left over from the debugging code I added a while ago. --- codemp/rd-rend2/glsl/lightall_fp.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index bdee3a40fe..d9a53f1c8f 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -432,7 +432,7 @@ void main() vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; - gl_FragColor.rgb = cubeLightColor * reflectance; + gl_FragColor.rgb += cubeLightColor * reflectance; #endif #if defined(USE_PRIMARY_LIGHT) From a2851fb752e8bc58ee551364869a59540fda473a Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sun, 22 Jun 2014 19:45:28 -0500 Subject: [PATCH 233/708] [MP] Rend2: Fix spacing in RE_StretchPic --- codemp/rd-rend2/tr_cmds.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 239d3cf88b..7f46597a50 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -301,9 +301,9 @@ void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { stretchPicCommand_t *cmd; - if (!tr.registered) { - return; - } + if ( !tr.registered ) { + return; + } cmd = (stretchPicCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; From a5fcba1f6d3975d6ad3cac64b40f1e0743370fa7 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 28 Jun 2014 10:21:14 -0500 Subject: [PATCH 234/708] [MP] Rend2: Moved console commands in the renderer to an array to avoid forgetting to remove commands at shutdowns. Also refactored maxpolys/maxpolyverts initialization. --- codemp/rd-rend2/tr_init.cpp | 78 +++++++++++++++++++------------------ codemp/rd-rend2/tr_local.h | 6 --- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b2ff5466d4..f9df406120 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #include "ghoul2/g2_local.h" +#include bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez @@ -253,9 +254,13 @@ cvar_t *r_marksOnTriangleMeshes; cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +// the limits apply to the sum of all scenes in a frame -- +// the main view, all the 3D icons, etc +#define DEFAULT_MAX_POLYS 600 +#define DEFAULT_MAX_POLYVERTS 3000 cvar_t *r_maxpolys; -int max_polys; cvar_t *r_maxpolyverts; +int max_polys; int max_polyverts; cvar_t *r_dynamicGlow; @@ -1166,6 +1171,32 @@ void GfxMemInfo_f( void ) } } +typedef struct consoleCommand_s { + const char *cmd; + xcommand_t func; +} consoleCommand_t; + +static consoleCommand_t commands[] = { + { "imagelist", R_ImageList_f }, + { "shaderlist", R_ShaderList_f }, + { "skinlist", R_SkinList_f }, + { "fontlist", R_FontList_f }, + { "screenshot", R_ScreenShotTGA_f }, + { "screenshot_png", R_ScreenShotPNG_f }, + { "screenshot_tga", R_ScreenShotTGA_f }, + { "gfxinfo", GfxInfo_f }, + { "gfxmeminfo", GfxMemInfo_f }, + //{ "r_we", R_WorldEffect_f }, + //{ "imagecacheinfo", RE_RegisterImages_Info_f }, + { "modellist", R_Modellist_f }, + { "modelist", R_ModeList_f }, + //{ "modelcacheinfo", RE_RegisterModels_Info_f }, + { "minimize", GLimp_Minimize }, +}; + +static const size_t numCommands = ARRAY_LEN( commands ); + + #ifdef _WIN32 #define SWAPINTERVAL_FLAGS CVAR_ARCHIVE #else @@ -1383,8 +1414,8 @@ void R_Register( void ) r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); - r_maxpolys = ri->Cvar_Get( "r_maxpolys", va("%d", MAX_POLYS), 0); - r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", va("%d", MAX_POLYVERTS), 0); + r_maxpolys = ri->Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0); + r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0 ); /* Ghoul2 Insert Start @@ -1413,20 +1444,8 @@ Ghoul2 Insert End se_language = ri->Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART ); - // make sure all the commands added here are also - // removed in R_Shutdown - ri->Cmd_AddCommand( "imagelist", R_ImageList_f ); - ri->Cmd_AddCommand( "shaderlist", R_ShaderList_f ); - ri->Cmd_AddCommand( "skinlist", R_SkinList_f ); - ri->Cmd_AddCommand( "fontlist", R_FontList_f ); - ri->Cmd_AddCommand( "modellist", R_Modellist_f ); - ri->Cmd_AddCommand( "modelist", R_ModeList_f ); - ri->Cmd_AddCommand( "screenshot", R_ScreenShotJPEG_f ); - ri->Cmd_AddCommand( "screenshot_png", R_ScreenShotPNG_f ); - ri->Cmd_AddCommand( "screenshot_tga", R_ScreenShotTGA_f ); - ri->Cmd_AddCommand( "gfxinfo", GfxInfo_f ); - ri->Cmd_AddCommand( "minimize", GLimp_Minimize ); - ri->Cmd_AddCommand( "gfxmeminfo", GfxMemInfo_f ); + for ( size_t i = 0; i < numCommands; i++ ) + ri->Cmd_AddCommand( commands[i].cmd, commands[i].func ); } void R_InitQueries(void) @@ -1499,13 +1518,8 @@ void R_Init( void ) { R_ImageLoader_Init(); R_Register(); - max_polys = r_maxpolys->integer; - if (max_polys < MAX_POLYS) - max_polys = MAX_POLYS; - - max_polyverts = r_maxpolyverts->integer; - if (max_polyverts < MAX_POLYVERTS) - max_polyverts = MAX_POLYVERTS; + max_polys = (std::min)( r_maxpolys->integer, DEFAULT_MAX_POLYS ); + max_polyverts = (std::min)( r_maxpolyverts->integer, DEFAULT_MAX_POLYVERTS ); ptr = (byte*)ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData = (backEndData_t *) ptr; @@ -1562,20 +1576,8 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); - ri->Cmd_RemoveCommand ("modellist"); - ri->Cmd_RemoveCommand ("screenshot"); - ri->Cmd_RemoveCommand ("screenshot_png"); - ri->Cmd_RemoveCommand ("screenshot_tga"); - ri->Cmd_RemoveCommand ("imagelist"); - ri->Cmd_RemoveCommand ("shaderlist"); - ri->Cmd_RemoveCommand ("skinlist"); - ri->Cmd_RemoveCommand ("fontlist"); - ri->Cmd_RemoveCommand ("gfxinfo"); - ri->Cmd_RemoveCommand("minimize"); - ri->Cmd_RemoveCommand( "modelist" ); - ri->Cmd_RemoveCommand( "shaderstate" ); - ri->Cmd_RemoveCommand( "gfxmeminfo" ); - + for ( size_t i = 0; i < numCommands; i++ ) + ri->Cmd_RemoveCommand( commands[i].cmd ); if ( tr.registered ) { R_IssuePendingRenderCommands(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 986c178fb9..e365352850 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2990,12 +2990,6 @@ typedef enum { } renderCommand_t; -// these are sort of arbitrary limits. -// the limits apply to the sum of all scenes in a frame -- -// the main view, all the 3D icons, etc -#define MAX_POLYS 600 -#define MAX_POLYVERTS 3000 - // all of the information needed by the back end must be // contained in a backEndData_t. typedef struct backEndData_s { From 305de7f69a781dc3c46ee3d7c7fbb3c9f7001b82 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 25 Jul 2014 10:15:39 -0500 Subject: [PATCH 235/708] [MP] Rend2: Enable forcesight surfaces in rend2 as well. --- codemp/rd-rend2/tr_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 6bba4fdacc..d7156b582b 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1688,7 +1688,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, fogIndex = 0; } - if ( (shader->surfaceFlags & SURF_FORCESIGHT) /*&& !(tr.refdef.rdflags & RDF_ForceSightOn)*/ ) + if ( (shader->surfaceFlags & SURF_FORCESIGHT) && !(tr.refdef.rdflags & RDF_ForceSightOn) ) { //if shader is only seen with ForceSight and we don't have ForceSight on, then don't draw return; } From b25262f058e0022d08d770874331ff6a0d16e9c6 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sat, 26 Jul 2014 23:29:56 -0500 Subject: [PATCH 236/708] [MP] Rend2: Don't load external GLSL files by default External GLSL should probably only be used for development testing, not released products. The GLSL files are tied to the code, and the code changes some what often. Fixes using OpenArena 0.8.8 which has incompatible GLSL files in a pk3. --- codemp/rd-rend2/tr_glsl.cpp | 15 +++++++++++---- codemp/rd-rend2/tr_init.cpp | 4 ++++ codemp/rd-rend2/tr_local.h | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index dac908ef39..993e579cb5 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -409,24 +409,31 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name); } - ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); - size = ri->FS_ReadFile(filename, (void **)&buffer); + if ( r_externalGLSL->integer ) { + size = ri->FS_ReadFile( filename, (void **)&buffer ); + } + else { + size = 0; + buffer = NULL; + } + if(!buffer) { if (fallback) { - ri->Printf(PRINT_DEVELOPER, "couldn't load, using fallback\n"); + ri->Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename); shaderText = fallback; size = strlen(shaderText); } else { - ri->Printf(PRINT_DEVELOPER, "couldn't load!\n"); + ri->Printf(PRINT_DEVELOPER, "couldn't load '%s'\n", filename); return 0; } } else { + ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); shaderText = buffer; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f9df406120..144f4c18c0 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -106,6 +106,8 @@ cvar_t *r_mergeLeafSurfaces; cvar_t *r_cameraExposure; +cvar_t *r_externalGLSL; + cvar_t *r_hdr; cvar_t *r_floatLightmap; cvar_t *r_postProcess; @@ -1266,6 +1268,8 @@ void R_Register( void ) r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); + r_externalGLSL = ri->Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH ); + r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e365352850..28732430cf 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2220,6 +2220,8 @@ extern cvar_t *r_anaglyphMode; extern cvar_t *r_mergeMultidraws; extern cvar_t *r_mergeLeafSurfaces; +extern cvar_t *r_externalGLSL; + extern cvar_t *r_hdr; extern cvar_t *r_floatLightmap; extern cvar_t *r_postProcess; From f4085f4c9b495bb1e8146cab4972de4b86da9b1c Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 8 Aug 2014 10:18:39 -0500 Subject: [PATCH 237/708] [MP] Rend2: Fix SkipBracedSection after a previous master branch merge. --- codemp/rd-rend2/tr_shader.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 02910571f7..debd3fcedc 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3645,8 +3645,6 @@ static shader_t *FinishShader( void ) { //======================================================================================== -qboolean SkipBracedSection_Depth (const char **program, int depth); - /* ==================== FindShaderInShaderText @@ -3698,7 +3696,7 @@ static const char *FindShaderInShaderText( const char *shadername ) { } else { // skip the definition - SkipBracedSection_Depth( &p, 0 ); + SkipBracedSection( &p, 0 ); } } @@ -4351,7 +4349,7 @@ static void ScanAndLoadShaderFiles( void ) break; } - if(!SkipBracedSection_Depth(&p, 1)) + if(!SkipBracedSection(&p, 1)) { ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); @@ -4402,7 +4400,7 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTableSizes[hash]++; size++; - SkipBracedSection(&p); + SkipBracedSection(&p, 0); } size += MAX_SHADERTEXT_HASH; @@ -4428,7 +4426,7 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp; - SkipBracedSection(&p); + SkipBracedSection(&p, 0); } return; From 327e2cc61ca4eb745da5143bb1cd550d6548230d Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 9 Aug 2014 09:00:15 -0500 Subject: [PATCH 238/708] [MP] Rend2: Support normalmaps with animmap. All images in the animmap should be normalmap if you set the stage for it. --- codemp/rd-rend2/tr_shader.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index debd3fcedc..4beba8e02a 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -884,6 +884,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } num = stage->bundle[0].numImageAnimations; if ( num < MAX_IMAGE_ANIMATIONS ) { + imgType_t imgtype = IMGTYPE_COLORALPHA; int flags = type == ANIMMAP_CLAMP ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; if (!shader.noMipMaps) @@ -898,7 +899,24 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - stage->bundle[0].image[num] = R_FindImageFile( token, IMGTYPE_COLORALPHA, flags ); + if ( stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP ) + { + imgtype = IMGTYPE_NORMAL; + flags |= IMGFLAG_NOLIGHTSCALE; + + if ( stage->type == ST_NORMALPARALLAXMAP ) + imgtype = IMGTYPE_NORMALHEIGHT; + } + else + { + if ( r_genNormalMaps->integer ) + flags |= IMGFLAG_GENNORMALMAP; + + if ( r_srgb->integer ) + flags |= IMGFLAG_SRGB; + } + + stage->bundle[0].image[num] = R_FindImageFile( token, imgtype, flags ); if ( !stage->bundle[0].image[num] ) { ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); From 90f268680a98e52ecc0712365aaa4e7dffbb0ea1 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Sat, 9 Aug 2014 15:00:26 -0500 Subject: [PATCH 239/708] [MP] Rend2: Add missing tr_types.h header to rd-common files. --- codemp/rd-rend2/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index ef87b8cc19..e9fac34363 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -79,7 +79,8 @@ set(MPRend2RdCommonFiles "${MPDir}/rd-common/tr_image_tga.cpp" "${MPDir}/rd-common/tr_image_png.cpp" "${MPDir}/rd-common/tr_noise.cpp" - "${MPDir}/rd-common/tr_public.h") + "${MPDir}/rd-common/tr_public.h" + "${MPDir}/rd-common/tr_types.h") source_group("rd-common" FILES ${MPRend2RdCommonFiles}) set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) From 97010f64b41f6d19241d518b45a7caf04ab29204 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 27 Sep 2014 21:57:24 +0100 Subject: [PATCH 240/708] [Rend2] Fix compile errors after merge with master --- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 02910571f7..a0638750de 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4402,7 +4402,7 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTableSizes[hash]++; size++; - SkipBracedSection(&p); + SkipBracedSection(&p, 0); } size += MAX_SHADERTEXT_HASH; @@ -4428,7 +4428,7 @@ static void ScanAndLoadShaderFiles( void ) hash = generateHashValue(token, MAX_SHADERTEXT_HASH); shaderTextHashTable[hash][shaderTextHashTableSizes[hash]++] = oldp; - SkipBracedSection(&p); + SkipBracedSection(&p, 0); } return; From 4ffcbfd6b0d9a20c52bb3ed0aa3ebe1d34d4320f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 27 Sep 2014 21:58:11 +0100 Subject: [PATCH 241/708] [Rend2] Pre-create names for buffer objects --- codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_vbo.cpp | 45 ++++++++++---------------------------- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 986c178fb9..5890a6475f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2079,9 +2079,11 @@ typedef struct trGlobals_s { FBO_t *fbos[MAX_FBOS]; int numVBOs; + unsigned int vboNames[MAX_VBOS]; VBO_t *vbos[MAX_VBOS]; int numIBOs; + unsigned int iboNames[MAX_IBOS]; IBO_t *ibos[MAX_IBOS]; // shader indexes from other modules will be looked up in tr.shaders[] diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index bab0d0d595..e8e2c6e496 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -86,13 +86,12 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) R_IssuePendingRenderCommands(); vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri->Hunk_Alloc(sizeof(*vbo), h_low); - tr.numVBOs++; memset(vbo, 0, sizeof(*vbo)); vbo->vertexesSize = vertexesSize; - - qglGenBuffers(1, &vbo->vertexesVBO); + vbo->vertexesVBO = tr.vboNames[tr.numVBOs]; + tr.numVBOs++; qglBindBuffer(GL_ARRAY_BUFFER, vbo->vertexesVBO); qglBufferData(GL_ARRAY_BUFFER, vertexesSize, vertexes, glUsage); @@ -123,11 +122,10 @@ IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) R_IssuePendingRenderCommands(); ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); - tr.numIBOs++; ibo->indexesSize = indexesSize; - - qglGenBuffers(1, &ibo->indexesVBO); + ibo->indexesVBO = tr.iboNames[tr.numIBOs]; + tr.numIBOs++; qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO); qglBufferData(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, glUsage); @@ -255,6 +253,11 @@ void R_InitVBOs(void) ri->Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); + // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is + // actually created on first bind. + qglGenBuffers(MAX_IBOS, tr.iboNames); + qglGenBuffers(MAX_VBOS, tr.vboNames); + tr.numVBOs = 0; tr.numIBOs = 0; @@ -309,39 +312,13 @@ R_ShutdownVBOs */ void R_ShutdownVBOs(void) { - int i; - VBO_t *vbo; - IBO_t *ibo; - ri->Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); R_BindNullVBO(); R_BindNullIBO(); - - for(i = 0; i < tr.numVBOs; i++) - { - vbo = tr.vbos[i]; - - if(vbo->vertexesVBO) - { - qglDeleteBuffers(1, &vbo->vertexesVBO); - } - - //ri->Free(vbo); - } - - for(i = 0; i < tr.numIBOs; i++) - { - ibo = tr.ibos[i]; - - if(ibo->indexesVBO) - { - qglDeleteBuffers(1, &ibo->indexesVBO); - } - - //ri->Free(ibo); - } + qglDeleteBuffers(MAX_IBOS, tr.iboNames); + qglDeleteBuffers(MAX_VBOS, tr.vboNames); tr.numVBOs = 0; tr.numIBOs = 0; From 65d85cbb99f56bc6869c1a696babf1e3d667d90b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 18 Oct 2014 18:12:21 +0100 Subject: [PATCH 242/708] [Rend2] Allow more vertex deforms in vertex shader --- codemp/rd-rend2/glsl/dlight_vp.glsl | 145 ++++++++++++++++------- codemp/rd-rend2/glsl/fogpass_vp.glsl | 147 +++++++++++++++++------- codemp/rd-rend2/glsl/generic_vp.glsl | 144 +++++++++++++++++------ codemp/rd-rend2/glsl/shadowfill_vp.glsl | 145 ++++++++++++++++------- codemp/rd-rend2/tr_glsl.cpp | 65 +++++++---- codemp/rd-rend2/tr_local.h | 26 +++-- codemp/rd-rend2/tr_shade.cpp | 118 ++++++++++++------- 7 files changed, 553 insertions(+), 237 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index c8a961d3ec..6fdeb3b89d 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -5,8 +5,9 @@ attribute vec3 attr_Normal; uniform vec4 u_DlightInfo; #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; uniform float u_Time; #endif @@ -17,57 +18,118 @@ varying vec2 var_Tex1; varying vec4 var_Color; #if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +float GetNoiseValue( float x, float y, float z, float t ) { - if (u_DeformGen == 0) - { - return pos; - } + // Variation on the 'one-liner random function'. + // Not sure if this is still 'correctly' random + return fract( sin( dot( + vec4( x, y, z, t ), + vec4( 12.9898, 78.233, 12.9898, 78.233 ) + )) * 43758.5453 ); +} - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; +float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) +{ + float value = phase + time * frequency; - if (u_DeformGen == DGEN_BULGE) + switch ( func ) { - phase *= st.x; + case WF_SIN: + return sin(value * 2.0 * M_PI); + case WF_SQUARE: + return sign(0.5 - fract(value)); + case WF_TRIANGLE: + return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SAWTOOTH: + return fract(value); + case WF_INVERSE_SAWTOOTH: + return 1.0 - fract(value); + default: + return 0.0; } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) +} + +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + switch ( u_DeformType ) { - phase += dot(pos.xyz, vec3(spread)); - } + default: + { + return pos; + } - float value = phase + (u_Time * frequency); - float func; + case DEFORM_BULGE: + { + float bulgeHeight = u_DeformParams[1]; // amplitude + float bulgeWidth = u_DeformParams[2]; // phase + float bulgeSpeed = u_DeformParams[3]; // frequency - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); + float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + + return pos + normal * scale * bulgeHeight; + } + + case DEFORM_WAVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + float offset = dot( pos.xyz, vec3( spread ) ); + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + + return pos + normal * (base + scale * amplitude); + } + + case DEFORM_MOVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + + return pos + direction * (base + scale * amplitude); + } } - else // if (u_DeformGen == DGEN_BULGE) +} + +vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +{ + if ( u_DeformType != DEFORM_NORMALS ) { - func = sin(value); + return normal; } - return pos + normal * (base + func * amplitude); + float amplitude = u_DeformParams[1]; + float frequency = u_DeformParams[3]; + + vec3 outNormal = normal; + const float scale = 0.98; + + outNormal.x += amplitude * GetNoiseValue( + position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.y += amplitude * GetNoiseValue( + 100.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.z += amplitude * GetNoiseValue( + 200.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + return outNormal; } #endif @@ -78,6 +140,7 @@ void main() #if defined(USE_DEFORM_VERTEXES) position = DeformPosition(position, normal, attr_TexCoord0.st); + normal = DeformNormal( position, normal ); #endif gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index e3aaf2dae7..b79c9890fc 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -16,8 +16,9 @@ uniform vec4 u_FogDepth; uniform float u_FogEyeT; #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; #endif uniform float u_Time; @@ -34,57 +35,118 @@ uniform vec4 u_Color; varying float var_Scale; #if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +float GetNoiseValue( float x, float y, float z, float t ) { - if (u_DeformGen == 0) - { - return pos; - } + // Variation on the 'one-liner random function'. + // Not sure if this is still 'correctly' random + return fract( sin( dot( + vec4( x, y, z, t ), + vec4( 12.9898, 78.233, 12.9898, 78.233 ) + )) * 43758.5453 ); +} - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; +float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) +{ + float value = phase + time * frequency; - if (u_DeformGen == DGEN_BULGE) + switch ( func ) { - phase *= st.x; + case WF_SIN: + return sin(value * 2.0 * M_PI); + case WF_SQUARE: + return sign(0.5 - fract(value)); + case WF_TRIANGLE: + return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SAWTOOTH: + return fract(value); + case WF_INVERSE_SAWTOOTH: + return 1.0 - fract(value); + default: + return 0.0; } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } - - float value = phase + (u_Time * frequency); - float func; +} - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + switch ( u_DeformType ) { - func = (1.0 - fract(value)); + default: + { + return pos; + } + + case DEFORM_BULGE: + { + float bulgeHeight = u_DeformParams[1]; // amplitude + float bulgeWidth = u_DeformParams[2]; // phase + float bulgeSpeed = u_DeformParams[3]; // frequency + + float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + + return pos + normal * scale * bulgeHeight; + } + + case DEFORM_WAVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + float offset = dot( pos.xyz, vec3( spread ) ); + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + + return pos + normal * (base + scale * amplitude); + } + + case DEFORM_MOVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + + return pos + direction * (base + scale * amplitude); + } } - else // if (u_DeformGen == DGEN_BULGE) +} + +vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +{ + if ( u_DeformType != DEFORM_NORMALS ) { - func = sin(value); + return normal; } - return pos + normal * (base + func * amplitude); + float amplitude = u_DeformParams[1]; + float frequency = u_DeformParams[3]; + + vec3 outNormal = normal; + const float scale = 0.98; + + outNormal.x += amplitude * GetNoiseValue( + position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.y += amplitude * GetNoiseValue( + 100.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.z += amplitude * GetNoiseValue( + 200.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + return outNormal; } #endif @@ -131,6 +193,7 @@ void main() #if defined(USE_DEFORM_VERTEXES) position = DeformPosition(position, normal, attr_TexCoord0.st); + normal = DeformNormal( position, normal ); #endif gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index d80b0d3653..ec7cf9ae3a 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -37,8 +37,9 @@ uniform vec4 u_FogColorMask; #endif #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; uniform float u_Time; #endif @@ -68,52 +69,118 @@ varying vec2 var_LightTex; varying vec4 var_Color; #if defined(USE_DEFORM_VERTEXES) -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +float GetNoiseValue( float x, float y, float z, float t ) { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; - - if (u_DeformGen == DGEN_BULGE) - { - phase *= st.x; - } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) - { - phase += dot(pos.xyz, vec3(spread)); - } + // Variation on the 'one-liner random function'. + // Not sure if this is still 'correctly' random + return fract( sin( dot( + vec4( x, y, z, t ), + vec4( 12.9898, 78.233, 12.9898, 78.233 ) + )) * 43758.5453 ); +} - float value = phase + (u_Time * frequency); - float func; +float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) +{ + float value = phase + time * frequency; - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(fract(0.5 - value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) + switch ( func ) { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SIN: + return sin(value * 2.0 * M_PI); + case WF_SQUARE: + return sign(0.5 - fract(value)); + case WF_TRIANGLE: + return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SAWTOOTH: + return fract(value); + case WF_INVERSE_SAWTOOTH: + return 1.0 - fract(value); + default: + return 0.0; } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) +} + +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + switch ( u_DeformType ) { - func = (1.0 - fract(value)); + default: + { + return pos; + } + + case DEFORM_BULGE: + { + float bulgeHeight = u_DeformParams[1]; // amplitude + float bulgeWidth = u_DeformParams[2]; // phase + float bulgeSpeed = u_DeformParams[3]; // frequency + + float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + + return pos + normal * scale * bulgeHeight; + } + + case DEFORM_WAVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + float offset = dot( pos.xyz, vec3( spread ) ); + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + + return pos + normal * (base + scale * amplitude); + } + + case DEFORM_MOVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + + return pos + direction * (base + scale * amplitude); + } } - else // if (u_DeformGen == DGEN_BULGE) +} + +vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +{ + if ( u_DeformType != DEFORM_NORMALS ) { - func = sin(value); + return normal; } - return pos + normal * (base + func * amplitude); + float amplitude = u_DeformParams[1]; + float frequency = u_DeformParams[3]; + + vec3 outNormal = normal; + const float scale = 0.98; + + outNormal.x += amplitude * GetNoiseValue( + position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.y += amplitude * GetNoiseValue( + 100.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.z += amplitude * GetNoiseValue( + 200.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + return outNormal; } #endif @@ -236,6 +303,7 @@ void main() #if defined(USE_DEFORM_VERTEXES) position = DeformPosition(position, normal, attr_TexCoord0.st); + normal = DeformNormal( position, normal ); #endif gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl index 7a5cc571a1..e140637ea8 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -8,8 +8,9 @@ attribute vec3 attr_Normal2; //#endif //#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformGen; -uniform float u_DeformParams[5]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; //#endif uniform float u_Time; @@ -23,57 +24,118 @@ uniform float u_VertexLerp; varying vec3 var_Position; -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +float GetNoiseValue( float x, float y, float z, float t ) { - if (u_DeformGen == 0) - { - return pos; - } + // Variation on the 'one-liner random function'. + // Not sure if this is still 'correctly' random + return fract( sin( dot( + vec4( x, y, z, t ), + vec4( 12.9898, 78.233, 12.9898, 78.233 ) + )) * 43758.5453 ); +} - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; +float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) +{ + float value = phase + time * frequency; - if (u_DeformGen == DGEN_BULGE) + switch ( func ) { - phase *= st.x; + case WF_SIN: + return sin(value * 2.0 * M_PI); + case WF_SQUARE: + return sign(0.5 - fract(value)); + case WF_TRIANGLE: + return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SAWTOOTH: + return fract(value); + case WF_INVERSE_SAWTOOTH: + return 1.0 - fract(value); + default: + return 0.0; } - else // if (u_DeformGen <= DGEN_WAVE_INVERSE_SAWTOOTH) +} + +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + switch ( u_DeformType ) { - phase += dot(pos.xyz, vec3(spread)); - } + default: + { + return pos; + } - float value = phase + (u_Time * frequency); - float func; + case DEFORM_BULGE: + { + float bulgeHeight = u_DeformParams[1]; // amplitude + float bulgeWidth = u_DeformParams[2]; // phase + float bulgeSpeed = u_DeformParams[3]; // frequency - if (u_DeformGen == DGEN_WAVE_SIN) - { - func = sin(value * 2.0 * M_PI); - } - else if (u_DeformGen == DGEN_WAVE_SQUARE) - { - func = sign(0.5 - fract(value)); - } - else if (u_DeformGen == DGEN_WAVE_TRIANGLE) - { - func = abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - } - else if (u_DeformGen == DGEN_WAVE_SAWTOOTH) - { - func = fract(value); - } - else if (u_DeformGen == DGEN_WAVE_INVERSE_SAWTOOTH) - { - func = (1.0 - fract(value)); + float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + + return pos + normal * scale * bulgeHeight; + } + + case DEFORM_WAVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + float spread = u_DeformParams[4]; + + float offset = dot( pos.xyz, vec3( spread ) ); + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + + return pos + normal * (base + scale * amplitude); + } + + case DEFORM_MOVE: + { + float base = u_DeformParams[0]; + float amplitude = u_DeformParams[1]; + float phase = u_DeformParams[2]; + float frequency = u_DeformParams[3]; + vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + + return pos + direction * (base + scale * amplitude); + } } - else // if (u_DeformGen == DGEN_BULGE) +} + +vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +{ + if ( u_DeformType != DEFORM_NORMALS ) { - func = sin(value); + return normal; } - return pos + normal * (base + func * amplitude); + float amplitude = u_DeformParams[1]; + float frequency = u_DeformParams[3]; + + vec3 outNormal = normal; + const float scale = 0.98; + + outNormal.x += amplitude * GetNoiseValue( + position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.y += amplitude * GetNoiseValue( + 100.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.z += amplitude * GetNoiseValue( + 200.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + return outNormal; } void main() @@ -83,6 +145,7 @@ void main() normal = normalize(normal - vec3(0.5)); position = DeformPosition(position, normal, attr_TexCoord0.st); + normal = DeformNormal( position, normal ); gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index dac908ef39..ded853243e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -96,8 +96,9 @@ static uniformInfo_t uniformsInfo[] = { "u_TCGen0Vector0", GLSL_VEC3, 1 }, { "u_TCGen0Vector1", GLSL_VEC3, 1 }, - { "u_DeformGen", GLSL_INT, 1 }, - { "u_DeformParams", GLSL_FLOAT5, 1 }, + { "u_DeformType", GLSL_INT, 1 }, + { "u_DeformFunc", GLSL_INT, 1 }, + { "u_DeformParams", GLSL_FLOAT, 7 }, { "u_ColorGen", GLSL_INT, 1 }, { "u_AlphaGen", GLSL_INT, 1 }, @@ -296,21 +297,29 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha Q_strcat(dest, size, va("#ifndef deformGen_t\n" "#define deformGen_t\n" - "#define DGEN_WAVE_SIN %i\n" - "#define DGEN_WAVE_SQUARE %i\n" - "#define DGEN_WAVE_TRIANGLE %i\n" - "#define DGEN_WAVE_SAWTOOTH %i\n" - "#define DGEN_WAVE_INVERSE_SAWTOOTH %i\n" - "#define DGEN_BULGE %i\n" - "#define DGEN_MOVE %i\n" + "#define DEFORM_NONE %i\n" + "#define DEFORM_WAVE %i\n" + "#define DEFORM_NORMALS %i\n" + "#define DEFORM_BULGE %i\n" + "#define DEFORM_MOVE %i\n" + "#define WF_NONE %i\n" + "#define WF_SIN %i\n" + "#define WF_SQUARE %i\n" + "#define WF_TRIANGLE %i\n" + "#define WF_SAWTOOTH %i\n" + "#define WF_INVERSE_SAWTOOTH %i\n" "#endif\n", - DGEN_WAVE_SIN, - DGEN_WAVE_SQUARE, - DGEN_WAVE_TRIANGLE, - DGEN_WAVE_SAWTOOTH, - DGEN_WAVE_INVERSE_SAWTOOTH, - DGEN_BULGE, - DGEN_MOVE)); + DEFORM_NONE, + DEFORM_WAVE, + DEFORM_NORMALS, + DEFORM_BULGE, + DEFORM_MOVE, + GF_NONE, + GF_SIN, + GF_SQUARE, + GF_TRIANGLE, + GF_SAWTOOTH, + GF_INVERSE_SAWTOOTH)); Q_strcat(dest, size, va("#ifndef tcGen_t\n" @@ -706,9 +715,6 @@ void GLSL_InitUniforms(shaderProgram_t *program) case GLSL_FLOAT: size += sizeof(GLfloat) * uniformsInfo[i].size; break; - case GLSL_FLOAT5: - size += sizeof(float) * 5 * uniformsInfo[i].size; - break; case GLSL_VEC2: size += sizeof(float) * 2 * uniformsInfo[i].size; break; @@ -857,7 +863,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t qglUniform4f(uniforms[uniformNum], v[0], v[1], v[2], v[3]); } -void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v) +void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float *v, int numFloats) { GLint *uniforms = program->uniforms; float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); @@ -865,20 +871,29 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_ if (uniforms[uniformNum] == -1) return; - if (uniformsInfo[uniformNum].type != GLSL_FLOAT5) + if (uniformsInfo[uniformNum].type != GLSL_FLOAT) + { + ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (uniformsInfo[uniformNum].size < numFloats) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloat5: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: uniform %i only has %d elements! Tried to set %d\n", + uniformNum, + uniformsInfo[uniformNum].size, + numFloats ); return; } - if (VectorCompare5(v, compare)) + if ( memcmp( compare, v, sizeof( float ) * numFloats ) == 0 ) { return; } - VectorCopy5(v, compare); + memcpy( compare, v, sizeof( float ) * numFloats ); - qglUniform1fv(uniforms[uniformNum], 5, v); + qglUniform1fv(uniforms[uniformNum], numFloats, v); } void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5890a6475f..8937452c26 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -509,7 +509,8 @@ typedef enum // do not edit until this line DGEN_BULGE, - DGEN_MOVE + DGEN_NORMALS, + DGEN_MOVE, } deformGen_t; typedef enum { @@ -794,17 +795,20 @@ typedef struct shader_s { static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) { - if(shader->numDeforms) + if ( shader->numDeforms > 1 ) { - const deformStage_t *ds = &shader->deforms[0]; - - if (shader->numDeforms > 1) - return qtrue; + return qtrue; + } - switch (ds->deformation) + if ( shader->numDeforms > 0 ) + { + switch (shader->deforms[0].deformation) { + case DEFORM_NONE: + case DEFORM_NORMALS: case DEFORM_WAVE: case DEFORM_BULGE: + case DEFORM_MOVE: return qfalse; default: @@ -812,6 +816,8 @@ static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) } } + assert( shader->numDeforms == 0 ); + return qfalse; } @@ -998,7 +1004,6 @@ enum { GLSL_INT, GLSL_FLOAT, - GLSL_FLOAT5, GLSL_VEC2, GLSL_VEC3, GLSL_VEC4, @@ -1038,7 +1043,8 @@ typedef enum UNIFORM_TCGEN0VECTOR0, UNIFORM_TCGEN0VECTOR1, - UNIFORM_DEFORMGEN, + UNIFORM_DEFORMTYPE, + UNIFORM_DEFORMFUNC, UNIFORM_DEFORMPARAMS, UNIFORM_COLORGEN, @@ -2690,7 +2696,7 @@ void GLSL_BindNullProgram(void); void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value); void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value); -void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_t v); +void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float *v, int numFloats); void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index bc56190d00..42317183c4 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -311,10 +311,12 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr } -static void ComputeDeformValues(int *deformGen, vec5_t deformParams) +static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float deformParams[7]) { // u_DeformGen - *deformGen = DGEN_NONE; + *type = DEFORM_NONE; + *waveFunc = GF_NONE; + if(!ShaderRequiresCPUDeforms(tess.shader)) { deformStage_t *ds; @@ -325,23 +327,54 @@ static void ComputeDeformValues(int *deformGen, vec5_t deformParams) switch (ds->deformation) { case DEFORM_WAVE: - *deformGen = ds->deformationWave.func; + *type = DEFORM_WAVE; + *waveFunc = ds->deformationWave.func; deformParams[0] = ds->deformationWave.base; deformParams[1] = ds->deformationWave.amplitude; deformParams[2] = ds->deformationWave.phase; deformParams[3] = ds->deformationWave.frequency; deformParams[4] = ds->deformationSpread; + deformParams[5] = 0.0f; + deformParams[6] = 0.0f; break; case DEFORM_BULGE: - *deformGen = DGEN_BULGE; + *type = DEFORM_BULGE; - deformParams[0] = 0; + deformParams[0] = 0.0f; deformParams[1] = ds->bulgeHeight; // amplitude deformParams[2] = ds->bulgeWidth; // phase deformParams[3] = ds->bulgeSpeed; // frequency - deformParams[4] = 0; + deformParams[4] = 0.0f; + deformParams[5] = 0.0f; + deformParams[6] = 0.0f; + break; + + case DEFORM_MOVE: + *type = DEFORM_MOVE; + *waveFunc = ds->deformationWave.func; + + deformParams[0] = ds->deformationWave.base; + deformParams[1] = ds->deformationWave.amplitude; + deformParams[2] = ds->deformationWave.phase; + deformParams[3] = ds->deformationWave.frequency; + deformParams[4] = ds->moveVector[0]; + deformParams[5] = ds->moveVector[1]; + deformParams[6] = ds->moveVector[2]; + + break; + + case DEFORM_NORMALS: + *type = DEFORM_NORMALS; + + deformParams[0] = 0.0f; + deformParams[1] = ds->deformationWave.amplitude; // amplitude + deformParams[2] = 0.0f; // phase + deformParams[3] = ds->deformationWave.frequency; // frequency + deformParams[4] = 0.0f; + deformParams[5] = 0.0f; + deformParams[6] = 0.0f; break; default: @@ -356,14 +389,15 @@ static void ProjectDlightTexture( void ) { vec3_t origin; float scale; float radius; - int deformGen; - vec5_t deformParams; + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; if ( !backEnd.refdef.num_dlights ) { return; } - ComputeDeformValues(&deformGen, deformParams); + ComputeDeformValues(&deformType, &deformGen, deformParams); for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { dlight_t *dl; @@ -389,10 +423,11 @@ static void ProjectDlightTexture( void ) { GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } @@ -737,8 +772,9 @@ static void ForwardDlight( void ) { //float scale; float radius; - int deformGen; - vec5_t deformParams; + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; float eyeT = 0; @@ -750,7 +786,7 @@ static void ForwardDlight( void ) { return; } - ComputeDeformValues(&deformGen, deformParams); + ComputeDeformValues(&deformType, &deformGen, deformParams); ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); @@ -790,10 +826,11 @@ static void ForwardDlight( void ) { GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } @@ -915,16 +952,11 @@ static void ProjectPshadowVBOGLSL( void ) { vec3_t origin; float radius; - int deformGen; - vec5_t deformParams; - shaderCommands_t *input = &tess; if ( !backEnd.refdef.num_pshadows ) { return; } - - ComputeDeformValues(&deformGen, deformParams); for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { pshadow_t *ps; @@ -1000,10 +1032,11 @@ static void RB_FogPass( void ) { float eyeT = 0; shaderProgram_t *sp; - int deformGen; + deform_t deformType; + genFunc_t deformGen; vec5_t deformParams; - ComputeDeformValues(&deformGen, deformParams); + ComputeDeformValues(&deformType, &deformGen, deformParams); { int index = 0; @@ -1030,10 +1063,11 @@ static void RB_FogPass( void ) { GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } @@ -1173,10 +1207,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; float eyeT = 0; - int deformGen; - vec5_t deformParams; + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; - ComputeDeformValues(&deformGen, deformParams); + ComputeDeformValues(&deformType, &deformGen, deformParams); ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); @@ -1308,10 +1343,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } @@ -1600,10 +1636,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) static void RB_RenderShadowmap( shaderCommands_t *input ) { - int deformGen; - vec5_t deformParams; + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; - ComputeDeformValues(&deformGen, deformParams); + ComputeDeformValues(&deformType, &deformGen, deformParams); { shaderProgram_t *sp = &tr.shadowmapShader; @@ -1618,10 +1655,11 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMGEN, deformGen); - if (deformGen != DGEN_NONE) + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - GLSL_SetUniformFloat5(sp, UNIFORM_DEFORMPARAMS, deformParams); + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } From 6187235978ce76d9251975dc302822bc9d2bd915 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 18 Oct 2014 18:51:16 +0100 Subject: [PATCH 243/708] [Rend2] Calc DEFORM_PROJECTION_SHADOW on GPU Projection shadow type vertex deformations are now calculated on the GPU. --- codemp/rd-rend2/glsl/dlight_vp.glsl | 22 ++++++++++++++++++++++ codemp/rd-rend2/glsl/fogpass_vp.glsl | 22 ++++++++++++++++++++++ codemp/rd-rend2/glsl/generic_vp.glsl | 22 ++++++++++++++++++++++ codemp/rd-rend2/glsl/shadowfill_vp.glsl | 22 ++++++++++++++++++++++ codemp/rd-rend2/tr_glsl.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 12 ++++++++++++ 7 files changed, 103 insertions(+) diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index 6fdeb3b89d..4d1ba43d6f 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -95,6 +95,28 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + direction * (base + scale * amplitude); } + + case DEFORM_PROJECTION_SHADOW: + { + vec3 ground = vec3( + u_DeformParams[0], + u_DeformParams[1], + u_DeformParams[2]); + float groundDist = u_DeformParams[3]; + vec3 lightDir = vec3( + u_DeformParams[4], + u_DeformParams[5], + u_DeformParams[6]); + + float d = dot( lightDir, ground ); + + lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; + d = 1.0 / dot( lightDir, ground ); + + vec3 lightPos = lightDir * d; + + return pos - lightPos * dot( pos, ground ) + groundDist; + } } } diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index b79c9890fc..cc21980a8d 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -112,6 +112,28 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + direction * (base + scale * amplitude); } + + case DEFORM_PROJECTION_SHADOW: + { + vec3 ground = vec3( + u_DeformParams[0], + u_DeformParams[1], + u_DeformParams[2]); + float groundDist = u_DeformParams[3]; + vec3 lightDir = vec3( + u_DeformParams[4], + u_DeformParams[5], + u_DeformParams[6]); + + float d = dot( lightDir, ground ); + + lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; + d = 1.0 / dot( lightDir, ground ); + + vec3 lightPos = lightDir * d; + + return pos - lightPos * dot( pos, ground ) + groundDist; + } } } diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index ec7cf9ae3a..b9ac074f7f 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -146,6 +146,28 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + direction * (base + scale * amplitude); } + + case DEFORM_PROJECTION_SHADOW: + { + vec3 ground = vec3( + u_DeformParams[0], + u_DeformParams[1], + u_DeformParams[2]); + float groundDist = u_DeformParams[3]; + vec3 lightDir = vec3( + u_DeformParams[4], + u_DeformParams[5], + u_DeformParams[6]); + + float d = dot( lightDir, ground ); + + lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; + d = 1.0 / dot( lightDir, ground ); + + vec3 lightPos = lightDir * d; + + return pos - lightPos * dot( pos, ground ) + groundDist; + } } } diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl index e140637ea8..2e016114c7 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -101,6 +101,28 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + direction * (base + scale * amplitude); } + + case DEFORM_PROJECTION_SHADOW: + { + vec3 ground = vec3( + u_DeformParams[0], + u_DeformParams[1], + u_DeformParams[2]); + float groundDist = u_DeformParams[3]; + vec3 lightDir = vec3( + u_DeformParams[4], + u_DeformParams[5], + u_DeformParams[6]); + + float d = dot( lightDir, ground ); + + lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; + d = 1.0 / dot( lightDir, ground ); + + vec3 lightPos = lightDir * d; + + return pos - lightPos * dot( pos, ground ) + groundDist; + } } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a2f4b1b89e..b04e31a454 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -302,6 +302,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha "#define DEFORM_NORMALS %i\n" "#define DEFORM_BULGE %i\n" "#define DEFORM_MOVE %i\n" + "#define DEFORM_PROJECTION_SHADOW %i\n" "#define WF_NONE %i\n" "#define WF_SIN %i\n" "#define WF_SQUARE %i\n" @@ -314,6 +315,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha DEFORM_NORMALS, DEFORM_BULGE, DEFORM_MOVE, + DEFORM_PROJECTION_SHADOW, GF_NONE, GF_SIN, GF_SQUARE, diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2a62010116..28b7b33477 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -809,6 +809,7 @@ static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) case DEFORM_WAVE: case DEFORM_BULGE: case DEFORM_MOVE: + case DEFORM_PROJECTION_SHADOW: return qfalse; default: diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 42317183c4..efb8390959 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -377,6 +377,18 @@ static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float defor deformParams[6] = 0.0f; break; + case DEFORM_PROJECTION_SHADOW: + *type = DEFORM_PROJECTION_SHADOW; + + deformParams[0] = backEnd.ori.axis[0][2]; + deformParams[1] = backEnd.ori.axis[1][2]; + deformParams[2] = backEnd.ori.axis[2][2]; + deformParams[3] = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; + deformParams[4] = backEnd.currentEntity->lightDir[0]; + deformParams[5] = backEnd.currentEntity->lightDir[1]; + deformParams[6] = backEnd.currentEntity->lightDir[2]; + break; + default: break; } From 3325924bbe15f115f741f0d96c002fa7315e1d02 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Oct 2014 07:53:15 +0100 Subject: [PATCH 244/708] [Rend2] Fix GLSL shader bugs const-qualifier should come before the inout-qualifier in GLSL150. --- codemp/rd-rend2/glsl/dlight_vp.glsl | 2 +- codemp/rd-rend2/glsl/fogpass_vp.glsl | 2 +- codemp/rd-rend2/glsl/generic_vp.glsl | 2 +- codemp/rd-rend2/glsl/shadowfill_vp.glsl | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index 4d1ba43d6f..3291c29730 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -120,7 +120,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } } -vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +vec3 DeformNormal( const in vec3 position, const in vec3 normal ) { if ( u_DeformType != DEFORM_NORMALS ) { diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index cc21980a8d..708f6e0a6b 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -137,7 +137,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } } -vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +vec3 DeformNormal( const in vec3 position, const in vec3 normal ) { if ( u_DeformType != DEFORM_NORMALS ) { diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index b9ac074f7f..3fbd7791f7 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -171,7 +171,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } } -vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +vec3 DeformNormal( const in vec3 position, const in vec3 normal ) { if ( u_DeformType != DEFORM_NORMALS ) { diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl index 2e016114c7..dab0902548 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -126,7 +126,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) } } -vec3 DeformNormal( in const vec3 position, in const vec3 normal ) +vec3 DeformNormal( const in vec3 position, const in vec3 normal ) { if ( u_DeformType != DEFORM_NORMALS ) { From 557a8c45d9b5d0a97f3fb9370c6dc628e1967357 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 22 Oct 2014 21:24:19 +0100 Subject: [PATCH 245/708] [Rend2] Fix memory leak in Ghoul2 code. --- codemp/rd-rend2/tr_backend.cpp | 2 ++ codemp/rd-rend2/tr_ghoul2.cpp | 47 +++++++++++++++++++++------------- codemp/rd-rend2/tr_local.h | 1 + 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 34b6f7346d..d5892e3c52 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1681,6 +1681,8 @@ const void *RB_SwapBuffers( const void *data ) { RB_EndSurface(); } + ResetGhoul2RenderableSurfaceHeap(); + // texture swapping test if ( r_showImages->integer ) { RB_ShowImages(); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 1d18d38e25..cec63c862a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -80,6 +80,30 @@ void G2Time_ReportTimers(void) //rww - RAGDOLL_END +static const int MAX_RENDERABLE_SURFACES = 2048; +static CRenderableSurface renderSurfHeap[MAX_RENDERABLE_SURFACES]; +static int currentRenderSurfIndex = 0; + +static CRenderableSurface *AllocGhoul2RenderableSurface() +{ + if ( currentRenderSurfIndex >= MAX_RENDERABLE_SURFACES ) + { + ri->Error( ERR_DROP, "AllocRenderableSurface: Reached maximum number of Ghoul2 renderable surfaces (%d)", MAX_RENDERABLE_SURFACES ); + return NULL; + } + + CRenderableSurface *rs = &renderSurfHeap[currentRenderSurfIndex++]; + + rs->Init(); + + return rs; +} + +void ResetGhoul2RenderableSurfaceHeap() +{ + currentRenderSurfIndex = 0; +} + bool HackadelicOnClient=false; // means this is a render traversal qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); @@ -763,21 +787,6 @@ class CRenderSurface {} }; -#ifdef _G2_GORE -#define MAX_RENDER_SURFACES (2048) -static CRenderableSurface RSStorage[MAX_RENDER_SURFACES]; -static unsigned int NextRS=0; - -CRenderableSurface *AllocRS() -{ - CRenderableSurface *ret=&RSStorage[NextRS]; - ret->Init(); - NextRS++; - NextRS%=MAX_RENDER_SURFACES; - return ret; -} -#endif - /* All bones should be an identity orientation to display the mesh exactly @@ -2437,7 +2446,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out - CRenderableSurface *newSurf = new CRenderableSurface; + CRenderableSurface *newSurf = AllocGhoul2RenderableSurface(); newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; assert (newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); newSurf->surfaceData = surface; @@ -2472,7 +2481,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from } else if (tex->tex[RS.lod]) { - CRenderableSurface *newSurf2 = AllocRS(); + CRenderableSurface *newSurf2 = AllocGhoul2RenderableSurface(); *newSurf2=*newSurf; newSurf2->goreChain=0; newSurf2->alternateTex=tex->tex[RS.lod]; @@ -3461,8 +3470,10 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) mdxmSurface_t *surfData = surf->surfaceData; mdxmVBOMesh_t *surface = surf->vboMesh; - if(!surface->vbo || !surface->ibo) + if ( surface->vbo == NULL || surface->ibo == NULL ) + { return; + } RB_EndSurface(); RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 28b7b33477..36d1fd1f0c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3046,6 +3046,7 @@ extern qboolean R_LoadMDXM (model_t *mod, void *buffer, const char *name, qboole extern qboolean R_LoadMDXA (model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); bool LoadTGAPalletteImage ( const char *name, byte **pic, int *width, int *height); void RE_InsertModelIntoHash(const char *name, model_t *mod); +void ResetGhoul2RenderableSurfaceHeap(); /* Ghoul2 Insert End */ From d20a05a508c34bee36df53a36c9da647d12befe1 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 24 Oct 2014 20:14:18 +0100 Subject: [PATCH 246/708] [Rend2] Remove use of deprecated GLSL features --- codemp/rd-rend2/glsl/bokeh_fp.glsl | 91 +++++++++++----------- codemp/rd-rend2/glsl/bokeh_vp.glsl | 9 +-- codemp/rd-rend2/glsl/calclevels4x_fp.glsl | 20 +++-- codemp/rd-rend2/glsl/calclevels4x_vp.glsl | 9 +-- codemp/rd-rend2/glsl/depthblur_fp.glsl | 14 ++-- codemp/rd-rend2/glsl/depthblur_vp.glsl | 6 +- codemp/rd-rend2/glsl/dlight_fp.glsl | 9 ++- codemp/rd-rend2/glsl/dlight_vp.glsl | 24 +++--- codemp/rd-rend2/glsl/down4x_fp.glsl | 40 +++++----- codemp/rd-rend2/glsl/down4x_vp.glsl | 8 +- codemp/rd-rend2/glsl/fogpass_fp.glsl | 11 +-- codemp/rd-rend2/glsl/fogpass_vp.glsl | 38 ++++----- codemp/rd-rend2/glsl/gaussian_blur_fp.glsl | 50 ++++++------ codemp/rd-rend2/glsl/gaussian_blur_vp.glsl | 2 +- codemp/rd-rend2/glsl/generic_fp.glsl | 18 ++--- codemp/rd-rend2/glsl/generic_vp.glsl | 74 +++++++++--------- codemp/rd-rend2/glsl/lightall_fp.glsl | 74 +++++++++--------- codemp/rd-rend2/glsl/lightall_vp.glsl | 85 ++++++++++---------- codemp/rd-rend2/glsl/pshadow_fp.glsl | 22 +++--- codemp/rd-rend2/glsl/pshadow_vp.glsl | 11 +-- codemp/rd-rend2/glsl/shadowfill_fp.glsl | 12 +-- codemp/rd-rend2/glsl/shadowfill_vp.glsl | 26 +++---- codemp/rd-rend2/glsl/shadowmask_fp.glsl | 44 ++++++----- codemp/rd-rend2/glsl/shadowmask_vp.glsl | 16 ++-- codemp/rd-rend2/glsl/ssao_fp.glsl | 9 ++- codemp/rd-rend2/glsl/ssao_vp.glsl | 6 +- codemp/rd-rend2/glsl/texturecolor_fp.glsl | 8 +- codemp/rd-rend2/glsl/texturecolor_vp.glsl | 8 +- codemp/rd-rend2/glsl/tonemap_fp.glsl | 16 ++-- codemp/rd-rend2/glsl/tonemap_vp.glsl | 8 +- codemp/rd-rend2/tr_glsl.cpp | 82 ++++++++----------- 31 files changed, 425 insertions(+), 425 deletions(-) diff --git a/codemp/rd-rend2/glsl/bokeh_fp.glsl b/codemp/rd-rend2/glsl/bokeh_fp.glsl index d08816aeff..2404cecffe 100644 --- a/codemp/rd-rend2/glsl/bokeh_fp.glsl +++ b/codemp/rd-rend2/glsl/bokeh_fp.glsl @@ -1,9 +1,10 @@ uniform sampler2D u_TextureMap; +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; -uniform vec4 u_Color; +in vec2 var_TexCoords; -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; +out vec4 out_Color; void main() { @@ -13,58 +14,58 @@ void main() #if 0 float c[7] = float[7](1.0, 0.9659258263, 0.8660254038, 0.7071067812, 0.5, 0.2588190451, 0.0); - tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[6]); color = texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[5]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[4]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[5], c[1]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[6], c[0]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[5]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[4]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[5], -c[1]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[6], -c[0]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[6]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[5]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[4]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[4], c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[5], c[1]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[5]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[4]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[4], -c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[5], -c[1]); color += texture(u_TextureMap, tc); - gl_FragColor = color * 0.04166667 * u_Color; + out_Color = color * 0.04166667 * u_Color; #endif float c[5] = float[5](1.0, 0.9238795325, 0.7071067812, 0.3826834324, 0.0); - tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[0], c[4]); color = texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], c[1]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], c[0]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[1], -c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[2], -c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[3], -c[1]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( c[4], -c[0]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[0], c[4]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], c[1]); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[1], -c[3]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[2], -c[2]); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( -c[3], -c[1]); color += texture(u_TextureMap, tc); - gl_FragColor = color * 0.0625 * u_Color; + out_Color = color * 0.0625 * u_Color; } diff --git a/codemp/rd-rend2/glsl/bokeh_vp.glsl b/codemp/rd-rend2/glsl/bokeh_vp.glsl index bdaa74af8e..8a5f1940bb 100644 --- a/codemp/rd-rend2/glsl/bokeh_vp.glsl +++ b/codemp/rd-rend2/glsl/bokeh_vp.glsl @@ -1,10 +1,9 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec4 attr_TexCoord0; -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_TexCoords; +uniform mat4 u_ModelViewProjectionMatrix; +out vec2 var_TexCoords; void main() { diff --git a/codemp/rd-rend2/glsl/calclevels4x_fp.glsl b/codemp/rd-rend2/glsl/calclevels4x_fp.glsl index c8cf06c710..8f5189647c 100644 --- a/codemp/rd-rend2/glsl/calclevels4x_fp.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x_fp.glsl @@ -1,16 +1,17 @@ uniform sampler2D u_TextureMap; +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; -uniform vec4 u_Color; +in vec2 var_TexCoords; -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; +out vec4 out_Color; -const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); +const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); vec3 GetValues(vec2 offset, vec3 current) { - vec3 minAvgMax; - vec2 tc = var_TexCoords + u_InvTexRes * offset; minAvgMax = texture2D(u_TextureMap, tc).rgb; + vec2 tc = var_TexCoords + u_InvTexRes * offset; + vec3 minAvgMax = texture(u_TextureMap, tc).rgb; #ifdef FIRST_PASS float lumi = max(dot(LUMINANCE_VECTOR, minAvgMax), 0.000001); @@ -18,7 +19,10 @@ vec3 GetValues(vec2 offset, vec3 current) minAvgMax = vec3(loglumi * 0.05 + 0.5); #endif - return vec3(min(current.x, minAvgMax.x), current.y + minAvgMax.y, max(current.z, minAvgMax.z)); + return vec3( + min(current.x, minAvgMax.x), + current.y + minAvgMax.y, + max(current.z, minAvgMax.z)); } void main() @@ -51,5 +55,5 @@ void main() current.y *= 0.0625; #endif - gl_FragColor = vec4(current, 1.0f); + out_Color = vec4(current, 1.0f); } diff --git a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl index bdaa74af8e..8a5f1940bb 100644 --- a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl @@ -1,10 +1,9 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec4 attr_TexCoord0; -uniform mat4 u_ModelViewProjectionMatrix; - -varying vec2 var_TexCoords; +uniform mat4 u_ModelViewProjectionMatrix; +out vec2 var_TexCoords; void main() { diff --git a/codemp/rd-rend2/glsl/depthblur_fp.glsl b/codemp/rd-rend2/glsl/depthblur_fp.glsl index 93895b4e17..102a9def8f 100644 --- a/codemp/rd-rend2/glsl/depthblur_fp.glsl +++ b/codemp/rd-rend2/glsl/depthblur_fp.glsl @@ -1,8 +1,10 @@ uniform sampler2D u_ScreenImageMap; uniform sampler2D u_ScreenDepthMap; +uniform vec4 u_ViewInfo; // zfar / znear, zfar -uniform vec4 u_ViewInfo; // zfar / znear, zfar -varying vec2 var_ScreenTex; +in vec2 var_ScreenTex; + +out vec4 out_Color; //float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033); float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); @@ -11,7 +13,7 @@ float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) { - float sampleZDivW = texture2D(depthMap, tex).r; + float sampleZDivW = texture(depthMap, tex).r; return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } @@ -28,7 +30,7 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa float depthCenter = zFar * getLinearDepth(depthMap, tex, zFarDivZNear); vec2 centerSlope = vec2(dFdx(depthCenter), dFdy(depthCenter)) / vec2(dFdx(tex.x), dFdy(tex.y)); - vec4 result = texture2D(imageMap, tex) * gauss[0]; + vec4 result = texture(imageMap, tex) * gauss[0]; float total = gauss[0]; int i, j; @@ -41,7 +43,7 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa float depthExpected = depthCenter + dot(centerSlope, offset); if(abs(depthSample - depthExpected) < 5.0) { - result += texture2D(imageMap, tex + offset) * gauss[j]; + result += texture(imageMap, tex + offset) * gauss[j]; total += gauss[j]; } } @@ -54,5 +56,5 @@ vec4 depthGaussian1D(sampler2D imageMap, sampler2D depthMap, vec2 tex, float zFa void main() { - gl_FragColor = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); + out_Color = depthGaussian1D(u_ScreenImageMap, u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); } diff --git a/codemp/rd-rend2/glsl/depthblur_vp.glsl b/codemp/rd-rend2/glsl/depthblur_vp.glsl index 9c46a79f26..22c12b3e9b 100644 --- a/codemp/rd-rend2/glsl/depthblur_vp.glsl +++ b/codemp/rd-rend2/glsl/depthblur_vp.glsl @@ -1,7 +1,7 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; +in vec4 attr_Position; +in vec4 attr_TexCoord0; -varying vec2 var_ScreenTex; +out vec2 var_ScreenTex; void main() { diff --git a/codemp/rd-rend2/glsl/dlight_fp.glsl b/codemp/rd-rend2/glsl/dlight_fp.glsl index 8ffca5b98d..de5be02f22 100644 --- a/codemp/rd-rend2/glsl/dlight_fp.glsl +++ b/codemp/rd-rend2/glsl/dlight_fp.glsl @@ -1,12 +1,13 @@ uniform sampler2D u_DiffuseMap; -varying vec2 var_Tex1; -varying vec4 var_Color; +in vec2 var_Tex1; +in vec4 var_Color; +out vec4 out_Color; void main() { - vec4 color = texture2D(u_DiffuseMap, var_Tex1); + vec4 color = texture(u_DiffuseMap, var_Tex1); - gl_FragColor = color * var_Color; + out_Color = color * var_Color; } diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight_vp.glsl index 3291c29730..243333bc06 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight_vp.glsl @@ -1,21 +1,21 @@ -attribute vec3 attr_Position; -attribute vec2 attr_TexCoord0; -attribute vec3 attr_Normal; +in vec3 attr_Position; +in vec2 attr_TexCoord0; +in vec3 attr_Normal; -uniform vec4 u_DlightInfo; +uniform vec4 u_DlightInfo; #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; -uniform float u_Time; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; +uniform float u_Time; #endif -uniform vec4 u_Color; -uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_Color; +uniform mat4 u_ModelViewProjectionMatrix; -varying vec2 var_Tex1; -varying vec4 var_Color; +out vec2 var_Tex1; +out vec4 var_Color; #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) diff --git a/codemp/rd-rend2/glsl/down4x_fp.glsl b/codemp/rd-rend2/glsl/down4x_fp.glsl index 0f88fb2e34..9940996069 100644 --- a/codemp/rd-rend2/glsl/down4x_fp.glsl +++ b/codemp/rd-rend2/glsl/down4x_fp.glsl @@ -1,34 +1,36 @@ uniform sampler2D u_TextureMap; +uniform vec2 u_InvTexRes; -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; +in vec2 var_TexCoords; + +out vec4 out_Color; void main() { vec4 color; vec2 tc; - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -1.5); color = texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -1.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -1.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -1.5); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, -0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, -0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, -0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, -0.5); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 0.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 0.5); color += texture(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture2D(u_TextureMap, tc); - tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture2D(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-1.5, 1.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2(-0.5, 1.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 0.5, 1.5); color += texture(u_TextureMap, tc); + tc = var_TexCoords + u_InvTexRes * vec2( 1.5, 1.5); color += texture(u_TextureMap, tc); color *= 0.0625; - gl_FragColor = color; + out_Color = color; } diff --git a/codemp/rd-rend2/glsl/down4x_vp.glsl b/codemp/rd-rend2/glsl/down4x_vp.glsl index bdaa74af8e..984c70f104 100644 --- a/codemp/rd-rend2/glsl/down4x_vp.glsl +++ b/codemp/rd-rend2/glsl/down4x_vp.glsl @@ -1,9 +1,9 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec4 attr_TexCoord0; -uniform mat4 u_ModelViewProjectionMatrix; +uniform mat4 u_ModelViewProjectionMatrix; -varying vec2 var_TexCoords; +out vec2 var_TexCoords; void main() diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl index 652387319c..1defd59dc5 100644 --- a/codemp/rd-rend2/glsl/fogpass_fp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_fp.glsl @@ -1,16 +1,17 @@ -uniform vec4 u_Color; +uniform vec4 u_Color; -varying float var_Scale; +in float var_Scale; +out vec4 out_Color; out vec4 out_Glow; void main() { - gl_FragColor = u_Color; - gl_FragColor.a = sqrt(clamp(var_Scale, 0.0, 1.0)); + out_Color.rgb = u_Color.rgb; + out_Color.a = sqrt(clamp(var_Scale, 0.0, 1.0)); #if defined(USE_GLOW_BUFFER) - out_Glow = gl_FragColor; + out_Glow = out_Color; #else out_Glow = vec4(0.0); #endif diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index 708f6e0a6b..f045931a14 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -1,38 +1,38 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; +in vec3 attr_Position; +in vec3 attr_Normal; -attribute vec2 attr_TexCoord0; +in vec2 attr_TexCoord0; #if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; +in vec3 attr_Position2; +in vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; +in vec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; #endif -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; +uniform vec4 u_FogDistance; +uniform vec4 u_FogDepth; +uniform float u_FogEyeT; #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; #endif -uniform float u_Time; -uniform mat4 u_ModelViewProjectionMatrix; +uniform float u_Time; +uniform mat4 u_ModelViewProjectionMatrix; #if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; +uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4 u_BoneMatrices[20]; #endif -uniform vec4 u_Color; +uniform vec4 u_Color; -varying float var_Scale; +out float var_Scale; #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) diff --git a/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl b/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl index 6916888f34..b76fed2f59 100644 --- a/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl +++ b/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl @@ -1,8 +1,10 @@ uniform sampler2D u_TextureMap; +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; -uniform vec4 u_Color; -uniform vec2 u_InvTexRes; -varying vec2 var_TexCoords; +in vec2 var_TexCoords; + +out vec4 out_Color; #define NUM_TAPS 3 @@ -14,35 +16,35 @@ void main() const float weights[] = float[4](1.0 / 64.0, 6.0 / 64.0, 15.0 / 64.0, 20.0 / 64.0); #if defined(BLUR_X) - color += texture2D (u_TextureMap, vec2 (-3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; - color += texture2D (u_TextureMap, vec2 (-2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; - color += texture2D (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; - color += texture2D (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; - color += texture2D (u_TextureMap, vec2 ( 2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 ( 3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (-3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (-2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; + color += texture (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture (u_TextureMap, vec2 ( 2.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 ( 3.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; #else - color += texture2D (u_TextureMap, vec2 (0.0, -3.0) * u_InvTexRes + var_TexCoords) * weights[0]; - color += texture2D (u_TextureMap, vec2 (0.0, -2.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[2]; - color += texture2D (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; - color += texture2D (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[2]; - color += texture2D (u_TextureMap, vec2 (0.0, 2.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 (0.0, 3.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (0.0, -3.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (0.0, -2.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[3]; + color += texture (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[2]; + color += texture (u_TextureMap, vec2 (0.0, 2.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 (0.0, 3.0) * u_InvTexRes + var_TexCoords) * weights[0]; #endif #elif NUM_TAPS == 3 const float weights[] = float[2](0.25, 0.5); #if defined(BLUR_X) - color += texture2D (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; - color += texture2D (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (-1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 ( 0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 ( 1.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[0]; #else - color += texture2D (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[0]; - color += texture2D (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; - color += texture2D (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (0.0, -1.0) * u_InvTexRes + var_TexCoords) * weights[0]; + color += texture (u_TextureMap, vec2 (0.0, 0.0) * u_InvTexRes + var_TexCoords) * weights[1]; + color += texture (u_TextureMap, vec2 (0.0, 1.0) * u_InvTexRes + var_TexCoords) * weights[0]; #endif #endif - gl_FragColor = color * u_Color; + out_Color = color * u_Color; } \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl b/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl index 7b4ff290fa..d3965cfabb 100644 --- a/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl +++ b/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl @@ -1,4 +1,4 @@ -varying vec2 var_TexCoords; +out vec2 var_TexCoords; void main() { diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index e518cdbd89..a2141fbee1 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -2,25 +2,25 @@ uniform sampler2D u_DiffuseMap; #if defined(USE_LIGHTMAP) uniform sampler2D u_LightMap; - -uniform int u_Texture1Env; +uniform int u_Texture1Env; #endif -varying vec2 var_DiffuseTex; +in vec2 var_DiffuseTex; #if defined(USE_LIGHTMAP) -varying vec2 var_LightTex; +in vec2 var_LightTex; #endif -varying vec4 var_Color; +in vec4 var_Color; +out vec4 out_Color; out vec4 out_Glow; void main() { - vec4 color = texture2D(u_DiffuseMap, var_DiffuseTex); + vec4 color = texture(u_DiffuseMap, var_DiffuseTex); #if defined(USE_LIGHTMAP) - vec4 color2 = texture2D(u_LightMap, var_LightTex); + vec4 color2 = texture(u_LightMap, var_LightTex); #if defined(RGBM_LIGHTMAP) color2.rgb *= color2.a; color2.a = 1.0; @@ -42,10 +42,10 @@ void main() //color = color * (u_Texture1Env.xxxx + color2 * u_Texture1Env.z) + color2 * u_Texture1Env.y; #endif - gl_FragColor = color * var_Color; + out_Color = color * var_Color; #if defined(USE_GLOW_BUFFER) - out_Glow = gl_FragColor; + out_Glow = out_Color; #else out_Glow = vec4(0.0); #endif diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 3fbd7791f7..1fea4baadd 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -1,72 +1,72 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; +in vec3 attr_Position; +in vec3 attr_Normal; #if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; +in vec3 attr_Position2; +in vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; +in vec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; #endif -attribute vec4 attr_Color; -attribute vec2 attr_TexCoord0; +in vec4 attr_Color; +in vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -attribute vec2 attr_TexCoord1; +in vec2 attr_TexCoord1; #endif -uniform vec4 u_DiffuseTexMatrix; -uniform vec4 u_DiffuseTexOffTurb; +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; #if defined(USE_TCGEN) || defined(USE_RGBAGEN) -uniform vec3 u_LocalViewOrigin; +uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCGEN) -uniform int u_TCGen0; -uniform vec3 u_TCGen0Vector0; -uniform vec3 u_TCGen0Vector1; +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; #endif #if defined(USE_FOG) -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; -uniform vec4 u_FogColorMask; +uniform vec4 u_FogDistance; +uniform vec4 u_FogDepth; +uniform float u_FogEyeT; +uniform vec4 u_FogColorMask; #endif #if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; -uniform float u_Time; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; +uniform float u_Time; #endif -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_BaseColor; -uniform vec4 u_VertColor; +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; #if defined(USE_RGBAGEN) -uniform int u_ColorGen; -uniform int u_AlphaGen; -uniform vec3 u_AmbientLight; -uniform vec3 u_DirectedLight; -uniform vec3 u_ModelLightDir; -uniform float u_PortalRange; +uniform int u_ColorGen; +uniform int u_AlphaGen; +uniform vec3 u_AmbientLight; +uniform vec3 u_DirectedLight; +uniform vec3 u_ModelLightDir; +uniform float u_PortalRange; #endif #if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; +uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4 u_BoneMatrices[20]; #endif -varying vec2 var_DiffuseTex; +out vec2 var_DiffuseTex; #if defined(USE_LIGHTMAP) -varying vec2 var_LightTex; +out vec2 var_LightTex; #endif -varying vec4 var_Color; +out vec4 var_Color; #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index d9a53f1c8f..8552c4cd70 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -26,54 +26,54 @@ uniform samplerCube u_CubeMap; #if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) // y = deluxe, w = cube -uniform vec4 u_EnableTextures; +uniform vec4 u_EnableTextures; #endif #if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; +uniform vec3 u_DirectedLight; +uniform vec3 u_AmbientLight; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec3 u_PrimaryLightColor; -uniform vec3 u_PrimaryLightAmbient; +uniform vec3 u_PrimaryLightColor; +uniform vec3 u_PrimaryLightAmbient; #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec4 u_NormalScale; -uniform vec4 u_SpecularScale; +uniform vec4 u_NormalScale; +uniform vec4 u_SpecularScale; #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_CUBEMAP) -uniform vec4 u_CubeMapInfo; +uniform vec4 u_CubeMapInfo; #endif #endif -varying vec4 var_TexCoords; - -varying vec4 var_Color; +in vec4 var_TexCoords; +in vec4 var_Color; #if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) #if defined(USE_VERT_TANGENT_SPACE) -varying vec4 var_Normal; -varying vec4 var_Tangent; -varying vec4 var_Bitangent; +in vec4 var_Normal; +in vec4 var_Tangent; +in vec4 var_Bitangent; #else -varying vec3 var_Normal; -varying vec3 var_ViewDir; +in vec3 var_Normal; +in vec3 var_ViewDir; #endif #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -varying vec4 var_LightDir; +in vec4 var_LightDir; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec4 var_PrimaryLightDir; +in vec4 var_PrimaryLightDir; #endif +out vec4 out_Color; out vec4 out_Glow; #define EPSILON 0.00000001 @@ -82,9 +82,9 @@ out vec4 out_Glow; float SampleDepth(sampler2D normalMap, vec2 t) { #if defined(SWIZZLE_NORMALMAP) - return 1.0 - texture2D(normalMap, t).r; + return 1.0 - texture(normalMap, t).r; #else - return 1.0 - texture2D(normalMap, t).a; + return 1.0 - texture(normalMap, t).a; #endif } @@ -267,13 +267,13 @@ void main() L = var_LightDir.xyz; #if defined(USE_DELUXEMAP) - L += (texture2D(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; + L += (texture(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; #endif float sqrLightDist = dot(L, L); #endif #if defined(USE_LIGHTMAP) - vec4 lightmapColor = texture2D(u_LightMap, var_TexCoords.zw); + vec4 lightmapColor = texture(u_LightMap, var_TexCoords.zw); #if defined(RGBM_LIGHTMAP) lightmapColor.rgb *= lightmapColor.a; #endif @@ -289,7 +289,7 @@ void main() texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); #endif - vec4 diffuse = texture2D(u_DiffuseMap, texCoords); + vec4 diffuse = texture(u_DiffuseMap, texCoords); #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_LIGHTMAP) @@ -308,9 +308,9 @@ void main() #if defined(USE_NORMALMAP) #if defined(SWIZZLE_NORMALMAP) - N.xy = texture2D(u_NormalMap, texCoords).ag - vec2(0.5); + N.xy = texture(u_NormalMap, texCoords).ag - vec2(0.5); #else - N.xy = texture2D(u_NormalMap, texCoords).rg - vec2(0.5); + N.xy = texture(u_NormalMap, texCoords).rg - vec2(0.5); #endif N.xy *= u_NormalScale.xy; N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); @@ -324,7 +324,7 @@ void main() #if defined(USE_SHADOWMAP) vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; - float shadowValue = texture2D(u_ShadowMap, shadowTex).r; + float shadowValue = texture(u_ShadowMap, shadowTex).r; // surfaces not facing the light are always shadowed shadowValue *= float(dot(var_Normal.xyz, var_PrimaryLightDir.xyz) > 0.0); @@ -360,7 +360,7 @@ void main() NE = clamp(dot(N, E), 0.0, 1.0); #if defined(USE_SPECULARMAP) - vec4 specular = texture2D(u_SpecularMap, texCoords); + vec4 specular = texture(u_SpecularMap, texCoords); #else vec4 specular = vec4(1.0); #endif @@ -404,7 +404,7 @@ void main() #endif #endif - gl_FragColor.rgb = lightColor * reflectance * (attenuation * NL); + out_Color.rgb = lightColor * reflectance * (attenuation * NL); #if 0 vec3 aSpecular = EnvironmentBRDF(gloss, NE, specular.rgb); @@ -415,10 +415,10 @@ void main() float hemiSpecularUp = mix(hemiDiffuseUp, float(N.z >= 0.0), gloss); float hemiSpecularDown = 1.0 - hemiSpecularUp; - gl_FragColor.rgb += ambientColor * 0.75 * (diffuse.rgb * hemiDiffuseUp + aSpecular * hemiSpecularUp); - gl_FragColor.rgb += ambientColor * 0.25 * (diffuse.rgb * hemiDiffuseDown + aSpecular * hemiSpecularDown); + out_Color.rgb += ambientColor * 0.75 * (diffuse.rgb * hemiDiffuseUp + aSpecular * hemiSpecularUp); + out_Color.rgb += ambientColor * 0.25 * (diffuse.rgb * hemiDiffuseDown + aSpecular * hemiSpecularDown); #else - gl_FragColor.rgb += ambientColor * (diffuse.rgb + specular.rgb); + out_Color.rgb += ambientColor * (diffuse.rgb + specular.rgb); #endif #if defined(USE_CUBEMAP) @@ -430,9 +430,9 @@ void main() // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - vec3 cubeLightColor = textureCubeLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; + vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; - gl_FragColor.rgb += cubeLightColor * reflectance; + out_Color.rgb += cubeLightColor * reflectance; #endif #if defined(USE_PRIMARY_LIGHT) @@ -466,7 +466,7 @@ void main() // enable when point lights are supported as primary lights //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); - gl_FragColor.rgb += lightColor * reflectance * NL2; + out_Color.rgb += lightColor * reflectance * NL2; #endif #else @@ -475,13 +475,13 @@ void main() lightColor *= lightmapColor.rgb; #endif - gl_FragColor.rgb = diffuse.rgb * lightColor; + out_Color.rgb = diffuse.rgb * lightColor; #endif - gl_FragColor.a = diffuse.a * var_Color.a; + out_Color.a = diffuse.a * var_Color.a; #if defined(USE_GLOW_BUFFER) - out_Glow = gl_FragColor; + out_Glow = out_Color; #else out_Glow = vec4(0.0); #endif diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index b4161b4021..6e49528f73 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -1,28 +1,28 @@ -attribute vec2 attr_TexCoord0; +in vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -attribute vec2 attr_TexCoord1; +in vec2 attr_TexCoord1; #endif -attribute vec4 attr_Color; +in vec4 attr_Color; -attribute vec3 attr_Position; -attribute vec3 attr_Normal; +in vec3 attr_Position; +in vec3 attr_Normal; #if defined(USE_VERT_TANGENT_SPACE) -attribute vec4 attr_Tangent; +in vec4 attr_Tangent; #endif #if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; +in vec3 attr_Position2; +in vec3 attr_Normal2; #if defined(USE_VERT_TANGENT_SPACE) -attribute vec4 attr_Tangent2; +in vec4 attr_Tangent2; #endif #elif defined(USE_SKELETAL_ANIMATION) -attribute vec4 attr_BoneIndexes; -attribute vec4 attr_BoneWeights; +in vec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; #endif #if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) -attribute vec3 attr_LightDirection; +in vec3 attr_LightDirection; #endif #if defined(USE_DELUXEMAP) @@ -30,71 +30,70 @@ uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cu #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec3 u_ViewOrigin; +uniform vec3 u_ViewOrigin; #endif #if defined(USE_TCGEN) -uniform int u_TCGen0; -uniform vec3 u_TCGen0Vector0; -uniform vec3 u_TCGen0Vector1; -uniform vec3 u_LocalViewOrigin; +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; +uniform vec3 u_LocalViewOrigin; #endif #if defined(USE_TCMOD) -uniform vec4 u_DiffuseTexMatrix; -uniform vec4 u_DiffuseTexOffTurb; +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; #endif -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_BaseColor; -uniform vec4 u_VertColor; +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; #if defined(USE_MODELMATRIX) -uniform mat4 u_ModelMatrix; +uniform mat4 u_ModelMatrix; #endif #if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; +uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4 u_BoneMatrices[20]; #endif #if defined(USE_LIGHT_VECTOR) -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; #if defined(USE_FAST_LIGHT) -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; +uniform vec3 u_DirectedLight; +uniform vec3 u_AmbientLight; #endif #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec4 u_PrimaryLightOrigin; +uniform vec4 u_PrimaryLightOrigin; uniform float u_PrimaryLightRadius; #endif -varying vec4 var_TexCoords; +out vec4 var_TexCoords; +out vec4 var_Color; +out vec3 var_N; -varying vec4 var_Color; - -varying vec3 var_N; #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_VERT_TANGENT_SPACE) -varying vec4 var_Normal; -varying vec4 var_Tangent; -varying vec4 var_Bitangent; - #else -varying vec3 var_Normal; -varying vec3 var_ViewDir; +out vec4 var_Normal; +out vec4 var_Tangent; +out vec4 var_Bitangent; + #else +out vec3 var_Normal; +out vec3 var_ViewDir; #endif #endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -varying vec4 var_LightDir; +out vec4 var_LightDir; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -varying vec4 var_PrimaryLightDir; +out vec4 var_PrimaryLightDir; #endif #if defined(USE_TCGEN) @@ -274,7 +273,7 @@ void main() #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) vec3 viewDir = u_ViewOrigin - position; #if defined(USE_VERT_TANGENT_SPACE) - // store view direction in tangent space to save on varyings + // store view direction in tangent space to save on outs var_Normal = vec4(normal, viewDir.x); var_Tangent = vec4(tangent, viewDir.y); var_Bitangent = vec4(bitangent, viewDir.z); diff --git a/codemp/rd-rend2/glsl/pshadow_fp.glsl b/codemp/rd-rend2/glsl/pshadow_fp.glsl index b152971af6..f2dd219be8 100644 --- a/codemp/rd-rend2/glsl/pshadow_fp.glsl +++ b/codemp/rd-rend2/glsl/pshadow_fp.glsl @@ -1,16 +1,18 @@ uniform sampler2D u_ShadowMap; +uniform vec3 u_LightForward; +uniform vec3 u_LightUp; +uniform vec3 u_LightRight; +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; -uniform vec3 u_LightForward; -uniform vec3 u_LightUp; -uniform vec3 u_LightRight; -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; -varying vec3 var_Position; -varying vec3 var_Normal; +in vec3 var_Position; +in vec3 var_Normal; + +out vec4 out_Color; float sampleDistMap(sampler2D texMap, vec2 uv, float scale) { - vec3 distv = texture2D(texMap, uv).xyz; + vec3 distv = texture(texMap, uv).xyz; return dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0)) * scale; } @@ -93,6 +95,6 @@ void main() intensity *= max(sign(lightDist - dist), 0.0); #endif - gl_FragColor.rgb = vec3(0); - gl_FragColor.a = clamp(intensity, 0.0, 0.75); + out_Color.rgb = vec3(0.0); + out_Color.a = clamp(intensity, 0.0, 0.75); } diff --git a/codemp/rd-rend2/glsl/pshadow_vp.glsl b/codemp/rd-rend2/glsl/pshadow_vp.glsl index 0f9940cd4e..a6699c15da 100644 --- a/codemp/rd-rend2/glsl/pshadow_vp.glsl +++ b/codemp/rd-rend2/glsl/pshadow_vp.glsl @@ -1,9 +1,10 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; +in vec3 attr_Position; +in vec3 attr_Normal; -uniform mat4 u_ModelViewProjectionMatrix; -varying vec3 var_Position; -varying vec3 var_Normal; +uniform mat4 u_ModelViewProjectionMatrix; + +out vec3 var_Position; +out vec3 var_Normal; void main() diff --git a/codemp/rd-rend2/glsl/shadowfill_fp.glsl b/codemp/rd-rend2/glsl/shadowfill_fp.glsl index 150f3d1229..97ae43fce7 100644 --- a/codemp/rd-rend2/glsl/shadowfill_fp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_fp.glsl @@ -1,7 +1,9 @@ uniform vec4 u_LightOrigin; uniform float u_LightRadius; -varying vec3 var_Position; +in vec3 var_Position; + +out vec4 out_Color; void main() { @@ -16,7 +18,7 @@ void main() comp = depth * bitSh; comp.xyz = fract(comp.xyz); comp -= comp.xxyz * bitMsk; - gl_FragColor = comp; + out_Color = comp; #endif #if 1 @@ -28,14 +30,14 @@ void main() comp = depth * bitSh; comp.xy = fract(comp.xy); comp -= comp.xxy * bitMsk; - gl_FragColor = vec4(comp, 1.0); + out_Color = vec4(comp, 1.0); #endif #if 0 // 8 bit precision - gl_FragColor = vec4(depth, depth, depth, 1); + out_Color = vec4(depth, depth, depth, 1); #endif #else - gl_FragColor = vec4(0, 0, 0, 1); + out_Color = vec4(0, 0, 0, 1); #endif } diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill_vp.glsl index dab0902548..746b75e7fe 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill_vp.glsl @@ -1,28 +1,28 @@ -attribute vec3 attr_Position; -attribute vec3 attr_Normal; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec3 attr_Normal; +in vec4 attr_TexCoord0; //#if defined(USE_VERTEX_ANIMATION) -attribute vec3 attr_Position2; -attribute vec3 attr_Normal2; +in vec3 attr_Position2; +in vec3 attr_Normal2; //#endif //#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; +uniform int u_DeformType; +uniform int u_DeformFunc; +uniform float u_DeformParams[7]; //#endif -uniform float u_Time; -uniform mat4 u_ModelViewProjectionMatrix; +uniform float u_Time; +uniform mat4 u_ModelViewProjectionMatrix; -uniform mat4 u_ModelMatrix; +uniform mat4 u_ModelMatrix; //#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; +uniform float u_VertexLerp; //#endif -varying vec3 var_Position; +out vec3 var_Position; float GetNoiseValue( float x, float y, float z, float t ) { diff --git a/codemp/rd-rend2/glsl/shadowmask_fp.glsl b/codemp/rd-rend2/glsl/shadowmask_fp.glsl index b489fef549..17f13b96db 100644 --- a/codemp/rd-rend2/glsl/shadowmask_fp.glsl +++ b/codemp/rd-rend2/glsl/shadowmask_fp.glsl @@ -6,17 +6,19 @@ uniform sampler2D u_ShadowMap2; uniform sampler2D u_ShadowMap3; #endif -uniform mat4 u_ShadowMvp; +uniform mat4 u_ShadowMvp; #if defined(USE_SHADOW_CASCADE) -uniform mat4 u_ShadowMvp2; -uniform mat4 u_ShadowMvp3; +uniform mat4 u_ShadowMvp2; +uniform mat4 u_ShadowMvp3; #endif -uniform vec3 u_ViewOrigin; -uniform vec4 u_ViewInfo; // zfar / znear, zfar +uniform vec3 u_ViewOrigin; +uniform vec4 u_ViewInfo; // zfar / znear, zfar -varying vec2 var_DepthTex; -varying vec3 var_ViewDir; +in vec2 var_DepthTex; +in vec3 var_ViewDir; + +out vec4 out_Color; // depth is GL_DEPTH_COMPONENT24 // so the maximum error is 1.0 / 2^24 @@ -50,23 +52,23 @@ float PCF(const sampler2D shadowmap, const vec2 st, const float dist) float cosr = cos(r) * scale; mat2 rmat = mat2(cosr, sinr, -sinr, cosr); - mult = step(dist, texture2D(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r); + mult = step(dist, texture(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r); #if defined(USE_SHADOW_FILTER2) - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r); - mult += step(dist, texture2D(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r); + mult += step(dist, texture(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r); mult *= 0.11111; #else mult *= 0.33333; #endif #else - mult = step(dist, texture2D(shadowmap, st).r); + mult = step(dist, texture(shadowmap, st).r); #endif return mult; @@ -74,9 +76,9 @@ float PCF(const sampler2D shadowmap, const vec2 st, const float dist) float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear) { - float sampleZDivW = texture2D(depthMap, tex).r; - sampleZDivW -= DEPTH_MAX_ERROR; - return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); + float sampleZDivW = texture(depthMap, tex).r; + sampleZDivW -= DEPTH_MAX_ERROR; + return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } void main() @@ -128,5 +130,5 @@ void main() } #endif - gl_FragColor = vec4(vec3(result), 1.0); + out_Color = vec4(vec3(result), 1.0); } diff --git a/codemp/rd-rend2/glsl/shadowmask_vp.glsl b/codemp/rd-rend2/glsl/shadowmask_vp.glsl index 13166a2400..5dc7c929d9 100644 --- a/codemp/rd-rend2/glsl/shadowmask_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowmask_vp.glsl @@ -1,13 +1,13 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; +in vec4 attr_Position; +in vec4 attr_TexCoord0; -uniform vec3 u_ViewForward; -uniform vec3 u_ViewLeft; -uniform vec3 u_ViewUp; -uniform vec4 u_ViewInfo; // zfar / znear +uniform vec3 u_ViewForward; +uniform vec3 u_ViewLeft; +uniform vec3 u_ViewUp; +uniform vec4 u_ViewInfo; // zfar / znear -varying vec2 var_DepthTex; -varying vec3 var_ViewDir; +out vec2 var_DepthTex; +out vec3 var_ViewDir; void main() { diff --git a/codemp/rd-rend2/glsl/ssao_fp.glsl b/codemp/rd-rend2/glsl/ssao_fp.glsl index 6263284c56..679fbc4d7a 100644 --- a/codemp/rd-rend2/glsl/ssao_fp.glsl +++ b/codemp/rd-rend2/glsl/ssao_fp.glsl @@ -1,8 +1,9 @@ uniform sampler2D u_ScreenDepthMap; +uniform vec4 u_ViewInfo; // zfar / znear, zfar -uniform vec4 u_ViewInfo; // zfar / znear, zfar +in vec2 var_ScreenTex; -varying vec2 var_ScreenTex; +out vec4 out_Color; vec2 poissonDisc[9] = vec2[9]( vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386), @@ -39,7 +40,7 @@ mat2 randomRotation( const vec2 p ) float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) { - float sampleZDivW = texture2D(depthMap, tex).r; + float sampleZDivW = texture(depthMap, tex).r; return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } @@ -82,5 +83,5 @@ void main() { float result = ambientOcclusion(u_ScreenDepthMap, var_ScreenTex, u_ViewInfo.x, u_ViewInfo.y); - gl_FragColor = vec4(vec3(result), 1.0); + out_Color = vec4(vec3(result), 1.0); } diff --git a/codemp/rd-rend2/glsl/ssao_vp.glsl b/codemp/rd-rend2/glsl/ssao_vp.glsl index 9c46a79f26..22c12b3e9b 100644 --- a/codemp/rd-rend2/glsl/ssao_vp.glsl +++ b/codemp/rd-rend2/glsl/ssao_vp.glsl @@ -1,7 +1,7 @@ -attribute vec4 attr_Position; -attribute vec4 attr_TexCoord0; +in vec4 attr_Position; +in vec4 attr_TexCoord0; -varying vec2 var_ScreenTex; +out vec2 var_ScreenTex; void main() { diff --git a/codemp/rd-rend2/glsl/texturecolor_fp.glsl b/codemp/rd-rend2/glsl/texturecolor_fp.glsl index 7c9046e18e..29bb5c3c4f 100644 --- a/codemp/rd-rend2/glsl/texturecolor_fp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_fp.glsl @@ -1,10 +1,12 @@ uniform sampler2D u_DiffuseMap; -uniform vec4 u_Color; +uniform vec4 u_Color; -varying vec2 var_Tex1; +in vec2 var_Tex1; + +out vec4 out_Color; void main() { - gl_FragColor = texture2D(u_DiffuseMap, var_Tex1) * u_Color; + out_Color = texture(u_DiffuseMap, var_Tex1) * u_Color; } diff --git a/codemp/rd-rend2/glsl/texturecolor_vp.glsl b/codemp/rd-rend2/glsl/texturecolor_vp.glsl index 552cd93837..e1f2061cc0 100644 --- a/codemp/rd-rend2/glsl/texturecolor_vp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor_vp.glsl @@ -1,9 +1,9 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec4 attr_TexCoord0; -uniform mat4 u_ModelViewProjectionMatrix; +uniform mat4 u_ModelViewProjectionMatrix; -varying vec2 var_Tex1; +out vec2 var_Tex1; void main() diff --git a/codemp/rd-rend2/glsl/tonemap_fp.glsl b/codemp/rd-rend2/glsl/tonemap_fp.glsl index 9b18de8a1c..1d84c1866d 100644 --- a/codemp/rd-rend2/glsl/tonemap_fp.glsl +++ b/codemp/rd-rend2/glsl/tonemap_fp.glsl @@ -1,12 +1,12 @@ uniform sampler2D u_TextureMap; uniform sampler2D u_LevelsMap; +uniform vec4 u_Color; +uniform vec2 u_AutoExposureMinMax; +uniform vec3 u_ToneMinAvgMaxLinear; -uniform vec4 u_Color; +in vec2 var_TexCoords; -uniform vec2 u_AutoExposureMinMax; -uniform vec3 u_ToneMinAvgMaxLinear; - -varying vec2 var_TexCoords; +out vec4 out_Color; const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); @@ -31,8 +31,8 @@ vec3 FilmicTonemap(vec3 x) void main() { - vec4 color = texture2D(u_TextureMap, var_TexCoords) * u_Color; - vec3 minAvgMax = texture2D(u_LevelsMap, var_TexCoords).rgb; + vec4 color = texture(u_TextureMap, var_TexCoords) * u_Color; + vec3 minAvgMax = texture(u_LevelsMap, var_TexCoords).rgb; vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); float avgLum = exp2(logMinAvgMaxLum.y); @@ -44,5 +44,5 @@ void main() vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x)); color.rgb = FilmicTonemap(color.rgb) * fWhite; - gl_FragColor = clamp(color, 0.0, 1.0); + out_Color = clamp(color, 0.0, 1.0); } diff --git a/codemp/rd-rend2/glsl/tonemap_vp.glsl b/codemp/rd-rend2/glsl/tonemap_vp.glsl index bdaa74af8e..984c70f104 100644 --- a/codemp/rd-rend2/glsl/tonemap_vp.glsl +++ b/codemp/rd-rend2/glsl/tonemap_vp.glsl @@ -1,9 +1,9 @@ -attribute vec3 attr_Position; -attribute vec4 attr_TexCoord0; +in vec3 attr_Position; +in vec4 attr_TexCoord0; -uniform mat4 u_ModelViewProjectionMatrix; +uniform mat4 u_ModelViewProjectionMatrix; -varying vec2 var_TexCoords; +out vec2 var_TexCoords; void main() diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index b04e31a454..7f2a3bfa51 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -268,19 +268,6 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha Q_strcat(dest, size, "#version 150 core\n"); - if(shaderType == GL_VERTEX_SHADER) - { - Q_strcat(dest, size, "#define attribute in\n"); - Q_strcat(dest, size, "#define varying out\n"); - } - else - { - Q_strcat(dest, size, "#define varying in\n"); - - Q_strcat(dest, size, "out vec4 out_Color;\n"); - Q_strcat(dest, size, "#define gl_FragColor out_Color\n"); - } - // HACK: add some macros to avoid extra uniforms and save speed and code maintenance //Q_strcat(dest, size, // va("#ifndef r_SpecularExponent\n#define r_SpecularExponent %f\n#endif\n", r_specularExponent->value)); @@ -647,25 +634,21 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) } static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, - int attribs, qboolean fragmentShader, const GLcharARB *extra, qboolean addHeader, + int attribs, qboolean fragmentShader, const GLcharARB *extra, const char *fallback_vp, const char *fallback_fp) { char vpCode[32000]; char fpCode[32000]; char *postHeader; int size; + size_t vertexShaderCodeLen; size = sizeof(vpCode); - if (addHeader) - { - GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, vpCode, size); - postHeader = &vpCode[strlen(vpCode)]; - size -= strlen(vpCode); - } - else - { - postHeader = &vpCode[0]; - } + + GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, vpCode, size); + vertexShaderCodeLen = strlen(vpCode); + postHeader = &vpCode[vertexShaderCodeLen]; + size -= vertexShaderCodeLen; if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER, postHeader, size)) { @@ -674,17 +657,14 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, if (fragmentShader) { + size_t fragmentShaderCodeLen; + size = sizeof(fpCode); - if (addHeader) - { - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, fpCode, size); - postHeader = &fpCode[strlen(fpCode)]; - size -= strlen(fpCode); - } - else - { - postHeader = &fpCode[0]; - } + + GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, fpCode, size); + fragmentShaderCodeLen = strlen(fpCode); + postHeader = &fpCode[fragmentShaderCodeLen]; + size -= fragmentShaderCodeLen; if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER, postHeader, size)) { @@ -1044,7 +1024,7 @@ int GLSL_BeginLoadGPUShaders(void) if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); - if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, qtrue, fallbackShader_generic_vp, fallbackShader_generic_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, fallbackShader_generic_vp, fallbackShader_generic_fp)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); } @@ -1053,7 +1033,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, qfalse, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) { ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); } @@ -1077,7 +1057,7 @@ int GLSL_BeginLoadGPUShaders(void) if (i & FOGDEF_USE_SKELETAL_ANIMATION) Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); - if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, qtrue, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } @@ -1094,7 +1074,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); } - if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, qtrue, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); } @@ -1227,7 +1207,7 @@ int GLSL_BeginLoadGPUShaders(void) if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); - if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, qtrue, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); } @@ -1237,7 +1217,7 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) { ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } @@ -1247,7 +1227,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, qtrue, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } @@ -1256,7 +1236,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, qtrue, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) { ri->Error(ERR_FATAL, "Could not load down4x shader!"); } @@ -1265,7 +1245,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, qtrue, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) { ri->Error(ERR_FATAL, "Could not load bokeh shader!"); } @@ -1274,7 +1254,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, qtrue, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) { ri->Error(ERR_FATAL, "Could not load tonemap shader!"); } @@ -1288,7 +1268,7 @@ int GLSL_BeginLoadGPUShaders(void) if (!i) Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); - if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, qtrue, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); } @@ -1310,7 +1290,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, qtrue, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } @@ -1319,7 +1299,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, qtrue, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) { ri->Error(ERR_FATAL, "Could not load ssao shader!"); } @@ -1336,7 +1316,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); - if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, qtrue, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } @@ -1346,7 +1326,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) + if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, NULL, NULL)) { ri->Error(ERR_FATAL, "Could not load testcube shader!"); } @@ -1366,7 +1346,7 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, extradefines, qtrue, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, extradefines, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } @@ -1374,7 +1354,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, extradefines, qtrue, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, extradefines, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } From 004017fd40e79ebf652764d54606dbe1e8682d42 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 12 Feb 2015 11:29:51 -0600 Subject: [PATCH 247/708] Rend2: Merge master changes into rd-rend2 folder to make it work again. --- codemp/rd-common/tr_types.h | 3 - codemp/rd-rend2/CMakeLists.txt | 55 +- codemp/rd-rend2/G2_API.cpp | 8 +- codemp/rd-rend2/G2_bones.cpp | 2 +- codemp/rd-rend2/G2_misc.cpp | 22 +- codemp/rd-rend2/glext.h | 22924 +++++++++++++--------------- codemp/rd-rend2/qgl.h | 472 +- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_extensions.cpp | 9 +- codemp/rd-rend2/tr_ghoul2.cpp | 10 +- codemp/rd-rend2/tr_image.cpp | 4 +- codemp/rd-rend2/tr_init.cpp | 692 +- codemp/rd-rend2/tr_local.h | 21 +- codemp/rd-rend2/tr_world.cpp | 4 +- 15 files changed, 11388 insertions(+), 12842 deletions(-) diff --git a/codemp/rd-common/tr_types.h b/codemp/rd-common/tr_types.h index 7469867327..4e6ead91c8 100644 --- a/codemp/rd-common/tr_types.h +++ b/codemp/rd-common/tr_types.h @@ -351,7 +351,4 @@ typedef struct glconfig_s { // used CDS. qboolean isFullscreen; qboolean stereoEnabled; - - // specific to rend2 - int numTextureUnits; } glconfig_t; diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index e9fac34363..9a7f64d72c 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -6,10 +6,15 @@ if(NOT InOpenJK) endif(NOT InOpenJK) set(MPRend2IncludeDirectories ${MPDir}) -set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} "${MPDir}/rd-rend2") +set(MPRend2IncludeDirectories + ${MPRend2IncludeDirectories} + ${SharedDir} + "${MPDir}/rd-rend2" + ) set(MPRend2Files "${MPDir}/rd-rend2/iqm.h" + "${MPDir}/rd-rend2/glext.h" "${MPDir}/rd-rend2/qgl.h" "${MPDir}/rd-rend2/G2_API.cpp" "${MPDir}/rd-rend2/G2_bolts.cpp" @@ -84,17 +89,22 @@ set(MPRend2RdCommonFiles source_group("rd-common" FILES ${MPRend2RdCommonFiles}) set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) -set(MPRend2QcommonFiles - "${MPDir}/qcommon/GenericParser2.cpp" +set(MPRend2CommonFiles "${MPDir}/qcommon/matcomp.cpp" "${MPDir}/qcommon/q_math.cpp" "${MPDir}/qcommon/q_shared.cpp") -source_group("qcommon" FILES ${MPRend2QcommonFiles}) -set(MPRend2Files ${MPRend2Files} ${MPRend2QcommonFiles}) - -file(GLOB_RECURSE MPRend2JpegFiles "${OpenJKLibDir}/jpeg-8c/*.c" "${OpenJKLibDir}/jpeg-8c/*.h") -source_group("jpeg-8c" FILES ${MPRend2JpegFiles}) -set(MPRend2Files ${MPRend2Files} ${MPRend2JpegFiles}) +source_group("common" FILES ${MPRend2CommonFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2CommonFiles}) + +if(UseInternalJPEG) + file(GLOB_RECURSE MPRend2JpegFiles "${OpenJKLibDir}/jpeg-8c/*.c" "${OpenJKLibDir}/jpeg-8c/*.h") + source_group("jpeg-8c" FILES ${MPRend2JpegFiles}) + set(MPRend2Files ${MPRend2Files} ${MPRend2JpegFiles}) +else() + find_package(JPEG REQUIRED) + set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${JPEG_INCLUDE_DIR}) + set(MPRend2Libraries ${MPRend2Libraries} ${JPEG_LIBRARIES}) +endif() if(UseInternalPNG) set(MPRend2LibPngFiles @@ -160,30 +170,9 @@ else(UseInternalZlib) set(MPRend2Libraries ${MPRend2Libraries} ${ZLIB_LIBRARY}) endif(UseInternalZlib) -if(NOT WIN32) - find_package(OpenGL REQUIRED) - set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OPENGL_INCLUDE_DIR}) - set(MPRend2Libraries ${MPRend2Libraries} ${OPENGL_LIBRARIES}) - - find_package(SDL2 REQUIRED) - set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${SDL2_INCLUDE_DIR}) - set(MPRend2Libraries ${MPRend2Libraries} ${SDL2_LIBRARY}) -endif(NOT WIN32) - - -if(WIN32) - set(MPRend2Win32Files - "${MPDir}/win32/win_gamma.cpp" - "${MPDir}/win32/win_glimp.cpp" - "${MPDir}/win32/win_qgl.cpp") - source_group("win32" FILES ${MPRend2Win32Files}) - set(MPRend2Files ${MPRend2Files} ${MPRend2Win32Files}) -else(WIN32) - set(MPRend2SysFiles - "${MPDir}/sdl/sdl_glimp.cpp") - source_group("sys" FILES ${MPRend2SysFiles}) - set(MPRend2Files ${MPRend2Files} ${MPRend2SysFiles}) -endif(WIN32) +find_package(OpenGL REQUIRED) +set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OPENGL_INCLUDE_DIR}) +set(MPRend2Libraries ${MPRend2Libraries} ${OPENGL_LIBRARIES}) source_group("renderer" FILES ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) set(MPRend2Files ${MPRend2Files} ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 9fb0a3904c..8d2d142ecd 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -380,9 +380,9 @@ static size_t DeserializeGhoul2Info ( const char *buffer, CGhoul2Info& g2Info ) class Ghoul2InfoArray : public IGhoul2InfoArray { - vector mInfos[MAX_G2_MODELS]; + std::vector mInfos[MAX_G2_MODELS]; int mIds[MAX_G2_MODELS]; - list mFreeIndecies; + std::list mFreeIndecies; void DeleteLow(int idx) { for (size_t model=0; model< mInfos[idx].size(); model++) @@ -579,7 +579,7 @@ class Ghoul2InfoArray : public IGhoul2InfoArray DeleteLow(handle&G2_INDEX_MASK); } } - vector &Get(int handle) + std::vector &Get(int handle) { assert(handle>0); //null handle assert((handle&G2_INDEX_MASK)>=0&&(handle&G2_INDEX_MASK) &Get(int handle) const + const std::vector &Get(int handle) const { assert(handle>0); assert(mIds[handle&G2_INDEX_MASK]==handle); // not a valid handle, could be old or garbage diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 383832c945..d70c9f18e1 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -1234,7 +1234,7 @@ enum ERagState }; static int ragState; -static vector rag; // once we get the dependents precomputed this can be local +static std::vector rag; // once we get the dependents precomputed this can be local static void G2_Generate_MatrixRag( diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 530c5a5fc0..6654f3384e 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -14,8 +14,8 @@ static int CurrentTag=GORE_TAG_UPPER+1; static int CurrentTagUpper=GORE_TAG_UPPER; -static map GoreRecords; -static map,int> GoreTagsTemp; // this is a surface index to gore tag map used only +static std::map GoreRecords; +static std::map,int> GoreTagsTemp; // this is a surface index to gore tag map used only // temporarily during the generation phase so we reuse gore tags per LOD int goreModelIndex; @@ -42,7 +42,7 @@ int AllocGoreRecord() while (GoreRecords.size()>MAX_GORE_RECORDS) { int tagHigh=(*GoreRecords.begin()).first&GORE_TAG_MASK; - map::iterator it; + std::map::iterator it; GoreTextureCoordinates *gTC; it = GoreRecords.begin(); @@ -84,7 +84,7 @@ void ResetGoreTag() GoreTextureCoordinates *FindGoreRecord(int tag) { - map::iterator i=GoreRecords.find(tag); + std::map::iterator i=GoreRecords.find(tag); if (i!=GoreRecords.end()) { return &(*i).second; @@ -104,11 +104,11 @@ void DeleteGoreRecord(int tag) } static int CurrentGoreSet=1; // this is a UUID for gore sets -static map GoreSets; // map from uuid to goreset +static std::map GoreSets; // map from uuid to goreset CGoreSet *FindGoreSet(int goreSetTag) { - map::iterator f=GoreSets.find(goreSetTag); + std::map::iterator f=GoreSets.find(goreSetTag); if (f!=GoreSets.end()) { return (*f).second; @@ -126,7 +126,7 @@ CGoreSet *NewGoreSet() void DeleteGoreSet(int goreSetTag) { - map::iterator f=GoreSets.find(goreSetTag); + std::map::iterator f=GoreSets.find(goreSetTag); if (f!=GoreSets.end()) { if ( (*f).second->mRefCount == 0 || (*f).second->mRefCount - 1 == 0 ) @@ -144,7 +144,7 @@ void DeleteGoreSet(int goreSetTag) CGoreSet::~CGoreSet() { - multimap::iterator i; + std::multimap::iterator i; for (i=mGoreRecords.begin();i!=mGoreRecords.end();i++) { DeleteGoreRecord((*i).second.mGoreTag); @@ -932,7 +932,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu } int newTag; - map,int>::iterator f=GoreTagsTemp.find(pair(goreModelIndex,TS.surfaceNum)); + std::map,int>::iterator f=GoreTagsTemp.find(std::pair(goreModelIndex,TS.surfaceNum)); if (f==GoreTagsTemp.end()) // need to generate a record { newTag=AllocGoreRecord(); @@ -972,8 +972,8 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu add.mGoreGrowFactor = ( 1.0f - TS.gore->goreScaleStartFraction) / (float)(TS.gore->growDuration); //curscale = (curtime-mGoreGrowStartTime)*mGoreGrowFactor; add.mGoreGrowOffset = TS.gore->goreScaleStartFraction; - goreSet->mGoreRecords.insert(pair(TS.surfaceNum,add)); - GoreTagsTemp[pair(goreModelIndex,TS.surfaceNum)]=newTag; + goreSet->mGoreRecords.insert(std::pair(TS.surfaceNum,add)); + GoreTagsTemp[std::pair(goreModelIndex,TS.surfaceNum)]=newTag; } else { diff --git a/codemp/rd-rend2/glext.h b/codemp/rd-rend2/glext.h index d3c64c19f6..63ea7f2465 100644 --- a/codemp/rd-rend2/glext.h +++ b/codemp/rd-rend2/glext.h @@ -1,20 +1,13 @@ #ifndef __glext_h_ -#define __glext_h_ +#define __glext_h_ 1 #ifdef __cplusplus extern "C" { #endif /* -** THIS FILE IS OBSOLETE. Please migrate away from using the -** ".spec" files and the headers generated from them to the -** XML Registry and headers generated from that. See -** http://www.opengl.org/registry/api/README.txt -** for more information. -** -** -** Copyright (c) 2007-2013 The Khronos Group Inc. -** +** Copyright (c) 2013-2014 The Khronos Group Inc. +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -22,10 +15,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -34,15 +27,19 @@ extern "C" { ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. */ - -/* Header file version number, required by OpenGL ABI for Linux */ -/* glext.h last updated $Date: 2013-06-13 02:52:31 -0700 (Thu, 13 Jun 2013) $ */ -/* Current version at http://www.opengl.org/registry/ */ -#define GL_GLEXT_VERSION 87 -/* Function declaration macros - to move into glplatform.h */ +/* +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.opengl.org/registry/ +** +** Khronos $Revision: 28986 $ on $Date: 2014-11-18 18:43:15 -0800 (Tue, 18 Nov 2014) $ +*/ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif @@ -56,9 +53,20 @@ extern "C" { #define GLAPI extern #endif -/*************************************************************/ +#define GL_GLEXT_VERSION 20141118 + +/* Generated C header for: + * API: gl + * Profile: compatibility + * Versions considered: .* + * Versions emitted: 1\.[2-9]|[234]\.[0-9] + * Default extensions included: gl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ #ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 #define GL_UNSIGNED_BYTE_3_3_2 0x8032 #define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 #define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 @@ -100,87 +108,20 @@ extern "C" { #define GL_SINGLE_COLOR 0x81F9 #define GL_SEPARATE_SPECULAR_COLOR 0x81FA #define GL_ALIASED_POINT_SIZE_RANGE 0x846D +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); #endif - -#ifndef GL_ARB_imaging -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 -#define GL_FUNC_ADD 0x8006 -#define GL_MIN 0x8007 -#define GL_MAX 0x8008 -#define GL_BLEND_EQUATION 0x8009 -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B -#define GL_CONVOLUTION_1D 0x8010 -#define GL_CONVOLUTION_2D 0x8011 -#define GL_SEPARABLE_2D 0x8012 -#define GL_CONVOLUTION_BORDER_MODE 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS 0x8015 -#define GL_REDUCE 0x8016 -#define GL_CONVOLUTION_FORMAT 0x8017 -#define GL_CONVOLUTION_WIDTH 0x8018 -#define GL_CONVOLUTION_HEIGHT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 -#define GL_HISTOGRAM 0x8024 -#define GL_PROXY_HISTOGRAM 0x8025 -#define GL_HISTOGRAM_WIDTH 0x8026 -#define GL_HISTOGRAM_FORMAT 0x8027 -#define GL_HISTOGRAM_RED_SIZE 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C -#define GL_HISTOGRAM_SINK 0x802D -#define GL_MINMAX 0x802E -#define GL_MINMAX_FORMAT 0x802F -#define GL_MINMAX_SINK 0x8030 -#define GL_TABLE_TOO_LARGE 0x8031 -#define GL_COLOR_MATRIX 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB -#define GL_COLOR_TABLE 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 -#define GL_PROXY_COLOR_TABLE 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 -#define GL_COLOR_TABLE_SCALE 0x80D6 -#define GL_COLOR_TABLE_BIAS 0x80D7 -#define GL_COLOR_TABLE_FORMAT 0x80D8 -#define GL_COLOR_TABLE_WIDTH 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF -#define GL_CONSTANT_BORDER 0x8151 -#define GL_REPLICATE_BORDER 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR 0x8154 -#endif +#endif /* GL_VERSION_1_2 */ #ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 #define GL_TEXTURE0 0x84C0 #define GL_TEXTURE1 0x84C1 #define GL_TEXTURE2 0x84C2 @@ -277,9 +218,104 @@ extern "C" { #define GL_PREVIOUS 0x8578 #define GL_DOT3_RGB 0x86AE #define GL_DOT3_RGBA 0x86AF +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum texture); +GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, void *img); +GLAPI void APIENTRY glClientActiveTexture (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); #endif +#endif /* GL_VERSION_1_3 */ #ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 #define GL_BLEND_DST_RGB 0x80C8 #define GL_BLEND_SRC_RGB 0x80C9 #define GL_BLEND_DST_ALPHA 0x80CA @@ -319,93 +355,244 @@ extern "C" { #define GL_TEXTURE_FILTER_CONTROL 0x8500 #define GL_DEPTH_TEXTURE_MODE 0x884B #define GL_COMPARE_R_TO_TEXTURE 0x884E -#endif - -#ifndef GL_VERSION_1_5 -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 -#define GL_QUERY_COUNTER_BITS 0x8864 -#define GL_CURRENT_QUERY 0x8865 -#define GL_QUERY_RESULT 0x8866 -#define GL_QUERY_RESULT_AVAILABLE 0x8867 -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F -#define GL_READ_ONLY 0x88B8 -#define GL_WRITE_ONLY 0x88B9 -#define GL_READ_WRITE 0x88BA -#define GL_BUFFER_ACCESS 0x88BB -#define GL_BUFFER_MAPPED 0x88BC -#define GL_BUFFER_MAP_POINTER 0x88BD -#define GL_STREAM_DRAW 0x88E0 -#define GL_STREAM_READ 0x88E1 -#define GL_STREAM_COPY 0x88E2 -#define GL_STATIC_DRAW 0x88E4 -#define GL_STATIC_READ 0x88E5 -#define GL_STATIC_COPY 0x88E6 -#define GL_DYNAMIC_DRAW 0x88E8 -#define GL_DYNAMIC_READ 0x88E9 -#define GL_DYNAMIC_COPY 0x88EA -#define GL_SAMPLES_PASSED 0x8914 -#define GL_SRC1_ALPHA 0x8589 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E -#define GL_FOG_COORD_SRC 0x8450 -#define GL_FOG_COORD 0x8451 -#define GL_CURRENT_FOG_COORD 0x8453 -#define GL_FOG_COORD_ARRAY_TYPE 0x8454 -#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 -#define GL_FOG_COORD_ARRAY_POINTER 0x8456 -#define GL_FOG_COORD_ARRAY 0x8457 -#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC2_ALPHA 0x858A -#endif - -#ifndef GL_VERSION_2_0 -#define GL_BLEND_EQUATION_RGB 0x8009 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 -#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_MAX_DRAW_BUFFERS 0x8824 -#define GL_DRAW_BUFFER0 0x8825 -#define GL_DRAW_BUFFER1 0x8826 -#define GL_DRAW_BUFFER2 0x8827 -#define GL_DRAW_BUFFER3 0x8828 -#define GL_DRAW_BUFFER4 0x8829 -#define GL_DRAW_BUFFER5 0x882A -#define GL_DRAW_BUFFER6 0x882B -#define GL_DRAW_BUFFER7 0x882C -#define GL_DRAW_BUFFER8 0x882D -#define GL_DRAW_BUFFER9 0x882E -#define GL_DRAW_BUFFER10 0x882F -#define GL_DRAW_BUFFER11 0x8830 -#define GL_DRAW_BUFFER12 0x8831 -#define GL_DRAW_BUFFER13 0x8832 -#define GL_DRAW_BUFFER14 0x8833 -#define GL_DRAW_BUFFER15 0x8834 -#define GL_BLEND_EQUATION_ALPHA 0x883D -#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_FUNC_ADD 0x8006 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); +GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount); +GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFogCoordf (GLfloat coord); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); +GLAPI void APIENTRY glFogCoordd (GLdouble coord); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2iv (const GLint *v); +GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); +GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3iv (const GLint *v); +GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); +GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glBlendEquation (GLenum mode); +#endif +#endif /* GL_VERSION_1_4 */ + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#include +typedef ptrdiff_t GLsizeiptr; +typedef ptrdiff_t GLintptr; +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_SRC1_ALPHA 0x8589 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_FOG_COORD_SRC 0x8450 +#define GL_FOG_COORD 0x8451 +#define GL_CURRENT_FOG_COORD 0x8453 +#define GL_FOG_COORD_ARRAY_TYPE 0x8454 +#define GL_FOG_COORD_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORD_ARRAY_POINTER 0x8456 +#define GL_FOG_COORD_ARRAY 0x8457 +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING 0x889D +#define GL_SRC0_RGB 0x8580 +#define GL_SRC1_RGB 0x8581 +#define GL_SRC2_RGB 0x8582 +#define GL_SRC0_ALPHA 0x8588 +#define GL_SRC2_ALPHA 0x858A +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQuery (GLuint id); +GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQuery (GLenum target); +GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); +GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void *APIENTRY glMapBuffer (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_VERSION_1_5 */ + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +typedef char GLchar; +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_MAX_VERTEX_ATTRIBS 0x8869 #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A #define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 #define GL_FRAGMENT_SHADER 0x8B30 @@ -459,42 +646,247 @@ extern "C" { #define GL_POINT_SPRITE 0x8861 #define GL_COORD_REPLACE 0x8862 #define GL_MAX_TEXTURE_COORDS 0x8871 -#endif - -#ifndef GL_VERSION_2_1 -#define GL_PIXEL_PACK_BUFFER 0x88EB -#define GL_PIXEL_UNPACK_BUFFER 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF -#define GL_FLOAT_MAT2x3 0x8B65 -#define GL_FLOAT_MAT2x4 0x8B66 -#define GL_FLOAT_MAT3x2 0x8B67 -#define GL_FLOAT_MAT3x4 0x8B68 -#define GL_FLOAT_MAT4x2 0x8B69 -#define GL_FLOAT_MAT4x3 0x8B6A -#define GL_SRGB 0x8C40 -#define GL_SRGB8 0x8C41 -#define GL_SRGB_ALPHA 0x8C42 -#define GL_SRGB8_ALPHA8 0x8C43 -#define GL_COMPRESSED_SRGB 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 -#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F -#define GL_SLUMINANCE_ALPHA 0x8C44 -#define GL_SLUMINANCE8_ALPHA8 0x8C45 -#define GL_SLUMINANCE 0x8C46 -#define GL_SLUMINANCE8 0x8C47 -#define GL_COMPRESSED_SLUMINANCE 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B -#endif - -#ifndef GL_VERSION_3_0 -#define GL_COMPARE_REF_TO_TEXTURE 0x884E -#define GL_CLIP_DISTANCE0 0x3000 -#define GL_CLIP_DISTANCE1 0x3001 -#define GL_CLIP_DISTANCE2 0x3002 -#define GL_CLIP_DISTANCE3 0x3003 -#define GL_CLIP_DISTANCE4 0x3004 -#define GL_CLIP_DISTANCE5 0x3005 +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GLAPI void APIENTRY glCompileShader (GLuint shader); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum type); +GLAPI void APIENTRY glDeleteProgram (GLuint program); +GLAPI void APIENTRY glDeleteShader (GLuint shader); +GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); +GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgram (GLuint program); +GLAPI GLboolean APIENTRY glIsShader (GLuint shader); +GLAPI void APIENTRY glLinkProgram (GLuint program); +GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GLAPI void APIENTRY glUseProgram (GLuint program); +GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glValidateProgram (GLuint program); +GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +#endif +#endif /* GL_VERSION_2_0 */ + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_VERSION_2_1 */ + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +typedef unsigned short GLhalf; +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_CLIP_DISTANCE0 0x3000 +#define GL_CLIP_DISTANCE1 0x3001 +#define GL_CLIP_DISTANCE2 0x3002 +#define GL_CLIP_DISTANCE3 0x3003 +#define GL_CLIP_DISTANCE4 0x3004 +#define GL_CLIP_DISTANCE5 0x3005 #define GL_CLIP_DISTANCE6 0x3006 #define GL_CLIP_DISTANCE7 0x3007 #define GL_MAX_CLIP_DISTANCES 0x0D32 @@ -588,10500 +980,3848 @@ extern "C" { #define GL_BUFFER_ACCESS_FLAGS 0x911F #define GL_BUFFER_MAP_LENGTH 0x9120 #define GL_BUFFER_MAP_OFFSET 0x9121 -/* Reuse tokens from ARB_depth_buffer_float */ -/* reuse GL_DEPTH_COMPONENT32F */ -/* reuse GL_DEPTH32F_STENCIL8 */ -/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */ -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_DEFAULT */ -/* reuse GL_FRAMEBUFFER_UNDEFINED */ -/* reuse GL_DEPTH_STENCIL_ATTACHMENT */ -/* reuse GL_INDEX */ -/* reuse GL_MAX_RENDERBUFFER_SIZE */ -/* reuse GL_DEPTH_STENCIL */ -/* reuse GL_UNSIGNED_INT_24_8 */ -/* reuse GL_DEPTH24_STENCIL8 */ -/* reuse GL_TEXTURE_STENCIL_SIZE */ -/* reuse GL_TEXTURE_RED_TYPE */ -/* reuse GL_TEXTURE_GREEN_TYPE */ -/* reuse GL_TEXTURE_BLUE_TYPE */ -/* reuse GL_TEXTURE_ALPHA_TYPE */ -/* reuse GL_TEXTURE_DEPTH_TYPE */ -/* reuse GL_UNSIGNED_NORMALIZED */ -/* reuse GL_FRAMEBUFFER_BINDING */ -/* reuse GL_DRAW_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_BINDING */ -/* reuse GL_READ_FRAMEBUFFER */ -/* reuse GL_DRAW_FRAMEBUFFER */ -/* reuse GL_READ_FRAMEBUFFER_BINDING */ -/* reuse GL_RENDERBUFFER_SAMPLES */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* reuse GL_FRAMEBUFFER_COMPLETE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */ -/* reuse GL_FRAMEBUFFER_UNSUPPORTED */ -/* reuse GL_MAX_COLOR_ATTACHMENTS */ -/* reuse GL_COLOR_ATTACHMENT0 */ -/* reuse GL_COLOR_ATTACHMENT1 */ -/* reuse GL_COLOR_ATTACHMENT2 */ -/* reuse GL_COLOR_ATTACHMENT3 */ -/* reuse GL_COLOR_ATTACHMENT4 */ -/* reuse GL_COLOR_ATTACHMENT5 */ -/* reuse GL_COLOR_ATTACHMENT6 */ -/* reuse GL_COLOR_ATTACHMENT7 */ -/* reuse GL_COLOR_ATTACHMENT8 */ -/* reuse GL_COLOR_ATTACHMENT9 */ -/* reuse GL_COLOR_ATTACHMENT10 */ -/* reuse GL_COLOR_ATTACHMENT11 */ -/* reuse GL_COLOR_ATTACHMENT12 */ -/* reuse GL_COLOR_ATTACHMENT13 */ -/* reuse GL_COLOR_ATTACHMENT14 */ -/* reuse GL_COLOR_ATTACHMENT15 */ -/* reuse GL_DEPTH_ATTACHMENT */ -/* reuse GL_STENCIL_ATTACHMENT */ -/* reuse GL_FRAMEBUFFER */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_RENDERBUFFER_WIDTH */ -/* reuse GL_RENDERBUFFER_HEIGHT */ -/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */ -/* reuse GL_STENCIL_INDEX1 */ -/* reuse GL_STENCIL_INDEX4 */ -/* reuse GL_STENCIL_INDEX8 */ -/* reuse GL_STENCIL_INDEX16 */ -/* reuse GL_RENDERBUFFER_RED_SIZE */ -/* reuse GL_RENDERBUFFER_GREEN_SIZE */ -/* reuse GL_RENDERBUFFER_BLUE_SIZE */ -/* reuse GL_RENDERBUFFER_ALPHA_SIZE */ -/* reuse GL_RENDERBUFFER_DEPTH_SIZE */ -/* reuse GL_RENDERBUFFER_STENCIL_SIZE */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */ -/* reuse GL_MAX_SAMPLES */ -/* Reuse tokens from ARB_framebuffer_sRGB */ -/* reuse GL_FRAMEBUFFER_SRGB */ -/* Reuse tokens from ARB_half_float_vertex */ -/* reuse GL_HALF_FLOAT */ -/* Reuse tokens from ARB_map_buffer_range */ -/* reuse GL_MAP_READ_BIT */ -/* reuse GL_MAP_WRITE_BIT */ -/* reuse GL_MAP_INVALIDATE_RANGE_BIT */ -/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */ -/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */ -/* reuse GL_MAP_UNSYNCHRONIZED_BIT */ -/* Reuse tokens from ARB_texture_compression_rgtc */ -/* reuse GL_COMPRESSED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */ -/* reuse GL_COMPRESSED_RG_RGTC2 */ -/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */ -/* Reuse tokens from ARB_texture_rg */ -/* reuse GL_RG */ -/* reuse GL_RG_INTEGER */ -/* reuse GL_R8 */ -/* reuse GL_R16 */ -/* reuse GL_RG8 */ -/* reuse GL_RG16 */ -/* reuse GL_R16F */ -/* reuse GL_R32F */ -/* reuse GL_RG16F */ -/* reuse GL_RG32F */ -/* reuse GL_R8I */ -/* reuse GL_R8UI */ -/* reuse GL_R16I */ -/* reuse GL_R16UI */ -/* reuse GL_R32I */ -/* reuse GL_R32UI */ -/* reuse GL_RG8I */ -/* reuse GL_RG8UI */ -/* reuse GL_RG16I */ -/* reuse GL_RG16UI */ -/* reuse GL_RG32I */ -/* reuse GL_RG32UI */ -/* Reuse tokens from ARB_vertex_array_object */ -/* reuse GL_VERTEX_ARRAY_BINDING */ -#define GL_CLAMP_VERTEX_COLOR 0x891A -#define GL_CLAMP_FRAGMENT_COLOR 0x891B -#define GL_ALPHA_INTEGER 0x8D97 -/* Reuse tokens from ARB_framebuffer_object */ -/* reuse GL_TEXTURE_LUMINANCE_TYPE */ -/* reuse GL_TEXTURE_INTENSITY_TYPE */ -#endif - -#ifndef GL_VERSION_3_1 -#define GL_SAMPLER_2D_RECT 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 -#define GL_SAMPLER_BUFFER 0x8DC2 -#define GL_INT_SAMPLER_2D_RECT 0x8DCD -#define GL_INT_SAMPLER_BUFFER 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 -#define GL_TEXTURE_BUFFER 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D -#define GL_TEXTURE_RECTANGLE 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 -#define GL_RED_SNORM 0x8F90 -#define GL_RG_SNORM 0x8F91 -#define GL_RGB_SNORM 0x8F92 -#define GL_RGBA_SNORM 0x8F93 -#define GL_R8_SNORM 0x8F94 -#define GL_RG8_SNORM 0x8F95 -#define GL_RGB8_SNORM 0x8F96 -#define GL_RGBA8_SNORM 0x8F97 -#define GL_R16_SNORM 0x8F98 -#define GL_RG16_SNORM 0x8F99 -#define GL_RGB16_SNORM 0x8F9A -#define GL_RGBA16_SNORM 0x8F9B -#define GL_SIGNED_NORMALIZED 0x8F9C -#define GL_PRIMITIVE_RESTART 0x8F9D -#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E -/* Reuse tokens from ARB_copy_buffer */ -/* reuse GL_COPY_READ_BUFFER */ -/* reuse GL_COPY_WRITE_BUFFER */ -/* Reuse tokens from ARB_draw_instanced (none) */ -/* Reuse tokens from ARB_uniform_buffer_object */ -/* reuse GL_UNIFORM_BUFFER */ -/* reuse GL_UNIFORM_BUFFER_BINDING */ -/* reuse GL_UNIFORM_BUFFER_START */ -/* reuse GL_UNIFORM_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_UNIFORM_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMBINED_UNIFORM_BLOCKS */ -/* reuse GL_MAX_UNIFORM_BUFFER_BINDINGS */ -/* reuse GL_MAX_UNIFORM_BLOCK_SIZE */ -/* reuse GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH */ -/* reuse GL_ACTIVE_UNIFORM_BLOCKS */ -/* reuse GL_UNIFORM_TYPE */ -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_INDEX */ -/* reuse GL_UNIFORM_OFFSET */ -/* reuse GL_UNIFORM_ARRAY_STRIDE */ -/* reuse GL_UNIFORM_MATRIX_STRIDE */ -/* reuse GL_UNIFORM_IS_ROW_MAJOR */ -/* reuse GL_UNIFORM_BLOCK_BINDING */ -/* reuse GL_UNIFORM_BLOCK_DATA_SIZE */ -/* reuse GL_UNIFORM_BLOCK_NAME_LENGTH */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS */ -/* reuse GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_INVALID_INDEX */ -#endif - -#ifndef GL_VERSION_3_2 -#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 -#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 -#define GL_LINES_ADJACENCY 0x000A -#define GL_LINE_STRIP_ADJACENCY 0x000B -#define GL_TRIANGLES_ADJACENCY 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D -#define GL_PROGRAM_POINT_SIZE 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 -#define GL_GEOMETRY_SHADER 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT 0x8916 -#define GL_GEOMETRY_INPUT_TYPE 0x8917 -#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 -#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 -#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 -#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 -#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 -#define GL_CONTEXT_PROFILE_MASK 0x9126 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -/* Reuse tokens from ARB_depth_clamp */ -/* reuse GL_DEPTH_CLAMP */ -/* Reuse tokens from ARB_draw_elements_base_vertex (none) */ -/* Reuse tokens from ARB_fragment_coord_conventions (none) */ -/* Reuse tokens from ARB_provoking_vertex */ -/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */ -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -/* Reuse tokens from ARB_seamless_cube_map */ -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -/* Reuse tokens from ARB_sync */ -/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */ -/* reuse GL_OBJECT_TYPE */ -/* reuse GL_SYNC_CONDITION */ -/* reuse GL_SYNC_STATUS */ -/* reuse GL_SYNC_FLAGS */ -/* reuse GL_SYNC_FENCE */ -/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */ -/* reuse GL_UNSIGNALED */ -/* reuse GL_SIGNALED */ -/* reuse GL_ALREADY_SIGNALED */ -/* reuse GL_TIMEOUT_EXPIRED */ -/* reuse GL_CONDITION_SATISFIED */ -/* reuse GL_WAIT_FAILED */ -/* reuse GL_TIMEOUT_IGNORED */ -/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */ -/* reuse GL_TIMEOUT_IGNORED */ -/* Reuse tokens from ARB_texture_multisample */ -/* reuse GL_SAMPLE_POSITION */ -/* reuse GL_SAMPLE_MASK */ -/* reuse GL_SAMPLE_MASK_VALUE */ -/* reuse GL_MAX_SAMPLE_MASK_WORDS */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_SAMPLES */ -/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */ -/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */ -/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */ -/* reuse GL_MAX_INTEGER_SAMPLES */ -/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */ -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE -/* Reuse tokens from ARB_blend_func_extended */ -/* reuse GL_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_COLOR */ -/* reuse GL_ONE_MINUS_SRC1_ALPHA */ -/* reuse GL_MAX_DUAL_SOURCE_DRAW_BUFFERS */ -/* Reuse tokens from ARB_explicit_attrib_location (none) */ -/* Reuse tokens from ARB_occlusion_query2 */ -/* reuse GL_ANY_SAMPLES_PASSED */ -/* Reuse tokens from ARB_sampler_objects */ -/* reuse GL_SAMPLER_BINDING */ -/* Reuse tokens from ARB_shader_bit_encoding (none) */ -/* Reuse tokens from ARB_texture_rgb10_a2ui */ -/* reuse GL_RGB10_A2UI */ -/* Reuse tokens from ARB_texture_swizzle */ -/* reuse GL_TEXTURE_SWIZZLE_R */ -/* reuse GL_TEXTURE_SWIZZLE_G */ -/* reuse GL_TEXTURE_SWIZZLE_B */ -/* reuse GL_TEXTURE_SWIZZLE_A */ -/* reuse GL_TEXTURE_SWIZZLE_RGBA */ -/* Reuse tokens from ARB_timer_query */ -/* reuse GL_TIME_ELAPSED */ -/* reuse GL_TIMESTAMP */ -/* Reuse tokens from ARB_vertex_type_2_10_10_10_rev */ -/* reuse GL_INT_2_10_10_10_REV */ -#endif - -#ifndef GL_VERSION_4_0 -#define GL_SAMPLE_SHADING 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F -#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F -/* Reuse tokens from ARB_texture_query_lod (none) */ -/* Reuse tokens from ARB_draw_buffers_blend (none) */ -/* Reuse tokens from ARB_draw_indirect */ -/* reuse GL_DRAW_INDIRECT_BUFFER */ -/* reuse GL_DRAW_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_gpu_shader5 */ -/* reuse GL_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MAX_GEOMETRY_SHADER_INVOCATIONS */ -/* reuse GL_MIN_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_MAX_FRAGMENT_INTERPOLATION_OFFSET */ -/* reuse GL_FRAGMENT_INTERPOLATION_OFFSET_BITS */ -/* Reuse tokens from ARB_gpu_shader_fp64 */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -/* Reuse tokens from ARB_shader_subroutine */ -/* reuse GL_ACTIVE_SUBROUTINES */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORMS */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_ACTIVE_SUBROUTINE_MAX_LENGTH */ -/* reuse GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH */ -/* reuse GL_MAX_SUBROUTINES */ -/* reuse GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS */ -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -/* Reuse tokens from ARB_tessellation_shader */ -/* reuse GL_PATCHES */ -/* reuse GL_PATCH_VERTICES */ -/* reuse GL_PATCH_DEFAULT_INNER_LEVEL */ -/* reuse GL_PATCH_DEFAULT_OUTER_LEVEL */ -/* reuse GL_TESS_CONTROL_OUTPUT_VERTICES */ -/* reuse GL_TESS_GEN_MODE */ -/* reuse GL_TESS_GEN_SPACING */ -/* reuse GL_TESS_GEN_VERTEX_ORDER */ -/* reuse GL_TESS_GEN_POINT_MODE */ -/* reuse GL_ISOLINES */ -/* reuse GL_FRACTIONAL_ODD */ -/* reuse GL_FRACTIONAL_EVEN */ -/* reuse GL_MAX_PATCH_VERTICES */ -/* reuse GL_MAX_TESS_GEN_LEVEL */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_PATCH_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_INPUT_COMPONENTS */ -/* reuse GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_EVALUATION_SHADER */ -/* reuse GL_TESS_CONTROL_SHADER */ -/* Reuse tokens from ARB_texture_buffer_object_rgb32 (none) */ -/* Reuse tokens from ARB_transform_feedback2 */ -/* reuse GL_TRANSFORM_FEEDBACK */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED */ -/* reuse GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE */ -/* reuse GL_TRANSFORM_FEEDBACK_BINDING */ -/* Reuse tokens from ARB_transform_feedback3 */ -/* reuse GL_MAX_TRANSFORM_FEEDBACK_BUFFERS */ -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_VERSION_4_1 -/* Reuse tokens from ARB_ES2_compatibility */ -/* reuse GL_FIXED */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_TYPE */ -/* reuse GL_IMPLEMENTATION_COLOR_READ_FORMAT */ -/* reuse GL_LOW_FLOAT */ -/* reuse GL_MEDIUM_FLOAT */ -/* reuse GL_HIGH_FLOAT */ -/* reuse GL_LOW_INT */ -/* reuse GL_MEDIUM_INT */ -/* reuse GL_HIGH_INT */ -/* reuse GL_SHADER_COMPILER */ -/* reuse GL_SHADER_BINARY_FORMATS */ -/* reuse GL_NUM_SHADER_BINARY_FORMATS */ -/* reuse GL_MAX_VERTEX_UNIFORM_VECTORS */ -/* reuse GL_MAX_VARYING_VECTORS */ -/* reuse GL_MAX_FRAGMENT_UNIFORM_VECTORS */ -/* reuse GL_RGB565 */ -/* Reuse tokens from ARB_get_program_binary */ -/* reuse GL_PROGRAM_BINARY_RETRIEVABLE_HINT */ -/* reuse GL_PROGRAM_BINARY_LENGTH */ -/* reuse GL_NUM_PROGRAM_BINARY_FORMATS */ -/* reuse GL_PROGRAM_BINARY_FORMATS */ -/* Reuse tokens from ARB_separate_shader_objects */ -/* reuse GL_VERTEX_SHADER_BIT */ -/* reuse GL_FRAGMENT_SHADER_BIT */ -/* reuse GL_GEOMETRY_SHADER_BIT */ -/* reuse GL_TESS_CONTROL_SHADER_BIT */ -/* reuse GL_TESS_EVALUATION_SHADER_BIT */ -/* reuse GL_ALL_SHADER_BITS */ -/* reuse GL_PROGRAM_SEPARABLE */ -/* reuse GL_ACTIVE_PROGRAM */ -/* reuse GL_PROGRAM_PIPELINE_BINDING */ -/* Reuse tokens from ARB_shader_precision (none) */ -/* Reuse tokens from ARB_vertex_attrib_64bit - all are in GL 3.0 and 4.0 already */ -/* Reuse tokens from ARB_viewport_array - some are in GL 1.1 and ARB_provoking_vertex already */ -/* reuse GL_MAX_VIEWPORTS */ -/* reuse GL_VIEWPORT_SUBPIXEL_BITS */ -/* reuse GL_VIEWPORT_BOUNDS_RANGE */ -/* reuse GL_LAYER_PROVOKING_VERTEX */ -/* reuse GL_VIEWPORT_INDEX_PROVOKING_VERTEX */ -/* reuse GL_UNDEFINED_VERTEX */ -#endif - -#ifndef GL_VERSION_4_2 -/* Reuse tokens from ARB_base_instance (none) */ -/* Reuse tokens from ARB_shading_language_420pack (none) */ -/* Reuse tokens from ARB_transform_feedback_instanced (none) */ -/* Reuse tokens from ARB_compressed_texture_pixel_storage */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */ -/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */ -/* Reuse tokens from ARB_conservative_depth (none) */ -/* Reuse tokens from ARB_internalformat_query */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* Reuse tokens from ARB_map_buffer_alignment */ -/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */ -/* Reuse tokens from ARB_shader_atomic_counters */ -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_START */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */ -/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */ -/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */ -/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */ -/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */ -/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */ -/* Reuse tokens from ARB_shader_image_load_store */ -/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */ -/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */ -/* reuse GL_UNIFORM_BARRIER_BIT */ -/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */ -/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */ -/* reuse GL_COMMAND_BARRIER_BIT */ -/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */ -/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */ -/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */ -/* reuse GL_FRAMEBUFFER_BARRIER_BIT */ -/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */ -/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */ -/* reuse GL_ALL_BARRIER_BITS */ -/* reuse GL_MAX_IMAGE_UNITS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -/* reuse GL_IMAGE_BINDING_NAME */ -/* reuse GL_IMAGE_BINDING_LEVEL */ -/* reuse GL_IMAGE_BINDING_LAYERED */ -/* reuse GL_IMAGE_BINDING_LAYER */ -/* reuse GL_IMAGE_BINDING_ACCESS */ -/* reuse GL_IMAGE_1D */ -/* reuse GL_IMAGE_2D */ -/* reuse GL_IMAGE_3D */ -/* reuse GL_IMAGE_2D_RECT */ -/* reuse GL_IMAGE_CUBE */ -/* reuse GL_IMAGE_BUFFER */ -/* reuse GL_IMAGE_1D_ARRAY */ -/* reuse GL_IMAGE_2D_ARRAY */ -/* reuse GL_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_INT_IMAGE_1D */ -/* reuse GL_INT_IMAGE_2D */ -/* reuse GL_INT_IMAGE_3D */ -/* reuse GL_INT_IMAGE_2D_RECT */ -/* reuse GL_INT_IMAGE_CUBE */ -/* reuse GL_INT_IMAGE_BUFFER */ -/* reuse GL_INT_IMAGE_1D_ARRAY */ -/* reuse GL_INT_IMAGE_2D_ARRAY */ -/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D */ -/* reuse GL_UNSIGNED_INT_IMAGE_3D */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */ -/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */ -/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */ -/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_MAX_IMAGE_SAMPLES */ -/* reuse GL_IMAGE_BINDING_FORMAT */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */ -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */ -/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */ -/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */ -/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */ -/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */ -/* Reuse tokens from ARB_shading_language_packing (none) */ -/* Reuse tokens from ARB_texture_storage */ -/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */ -#endif - -#ifndef GL_VERSION_4_3 -#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 -#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E -/* Reuse tokens from ARB_arrays_of_arrays (none, GLSL only) */ -/* Reuse tokens from ARB_fragment_layer_viewport (none, GLSL only) */ -/* Reuse tokens from ARB_shader_image_size (none, GLSL only) */ -/* Reuse tokens from ARB_ES3_compatibility */ -/* reuse GL_COMPRESSED_RGB8_ETC2 */ -/* reuse GL_COMPRESSED_SRGB8_ETC2 */ -/* reuse GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ -/* reuse GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 */ -/* reuse GL_COMPRESSED_RGBA8_ETC2_EAC */ -/* reuse GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC */ -/* reuse GL_COMPRESSED_R11_EAC */ -/* reuse GL_COMPRESSED_SIGNED_R11_EAC */ -/* reuse GL_COMPRESSED_RG11_EAC */ -/* reuse GL_COMPRESSED_SIGNED_RG11_EAC */ -/* reuse GL_PRIMITIVE_RESTART_FIXED_INDEX */ -/* reuse GL_ANY_SAMPLES_PASSED_CONSERVATIVE */ -/* reuse GL_MAX_ELEMENT_INDEX */ -/* Reuse tokens from ARB_clear_buffer_object (none) */ -/* Reuse tokens from ARB_compute_shader */ -/* reuse GL_COMPUTE_SHADER */ -/* reuse GL_MAX_COMPUTE_UNIFORM_BLOCKS */ -/* reuse GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS */ -/* reuse GL_MAX_COMPUTE_IMAGE_UNIFORMS */ -/* reuse GL_MAX_COMPUTE_SHARED_MEMORY_SIZE */ -/* reuse GL_MAX_COMPUTE_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS */ -/* reuse GL_MAX_COMPUTE_ATOMIC_COUNTERS */ -/* reuse GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS */ -/* reuse GL_MAX_COMPUTE_LOCAL_INVOCATIONS */ -/* reuse GL_MAX_COMPUTE_WORK_GROUP_COUNT */ -/* reuse GL_MAX_COMPUTE_WORK_GROUP_SIZE */ -/* reuse GL_COMPUTE_LOCAL_WORK_SIZE */ -/* reuse GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER */ -/* reuse GL_DISPATCH_INDIRECT_BUFFER */ -/* reuse GL_DISPATCH_INDIRECT_BUFFER_BINDING */ -/* Reuse tokens from ARB_copy_image (none) */ -/* Reuse tokens from KHR_debug */ -/* reuse GL_DEBUG_OUTPUT_SYNCHRONOUS */ -/* reuse GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH */ -/* reuse GL_DEBUG_CALLBACK_FUNCTION */ -/* reuse GL_DEBUG_CALLBACK_USER_PARAM */ -/* reuse GL_DEBUG_SOURCE_API */ -/* reuse GL_DEBUG_SOURCE_WINDOW_SYSTEM */ -/* reuse GL_DEBUG_SOURCE_SHADER_COMPILER */ -/* reuse GL_DEBUG_SOURCE_THIRD_PARTY */ -/* reuse GL_DEBUG_SOURCE_APPLICATION */ -/* reuse GL_DEBUG_SOURCE_OTHER */ -/* reuse GL_DEBUG_TYPE_ERROR */ -/* reuse GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR */ -/* reuse GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR */ -/* reuse GL_DEBUG_TYPE_PORTABILITY */ -/* reuse GL_DEBUG_TYPE_PERFORMANCE */ -/* reuse GL_DEBUG_TYPE_OTHER */ -/* reuse GL_MAX_DEBUG_MESSAGE_LENGTH */ -/* reuse GL_MAX_DEBUG_LOGGED_MESSAGES */ -/* reuse GL_DEBUG_LOGGED_MESSAGES */ -/* reuse GL_DEBUG_SEVERITY_HIGH */ -/* reuse GL_DEBUG_SEVERITY_MEDIUM */ -/* reuse GL_DEBUG_SEVERITY_LOW */ -/* reuse GL_DEBUG_TYPE_MARKER */ -/* reuse GL_DEBUG_TYPE_PUSH_GROUP */ -/* reuse GL_DEBUG_TYPE_POP_GROUP */ -/* reuse GL_DEBUG_SEVERITY_NOTIFICATION */ -/* reuse GL_MAX_DEBUG_GROUP_STACK_DEPTH */ -/* reuse GL_DEBUG_GROUP_STACK_DEPTH */ -/* reuse GL_BUFFER */ -/* reuse GL_SHADER */ -/* reuse GL_PROGRAM */ -/* reuse GL_QUERY */ -/* reuse GL_PROGRAM_PIPELINE */ -/* reuse GL_SAMPLER */ -/* reuse GL_DISPLAY_LIST */ -/* reuse GL_MAX_LABEL_LENGTH */ -/* reuse GL_DEBUG_OUTPUT */ -/* reuse GL_CONTEXT_FLAG_DEBUG_BIT */ -/* reuse GL_STACK_UNDERFLOW */ -/* reuse GL_STACK_OVERFLOW */ -/* Reuse tokens from ARB_explicit_uniform_location */ -/* reuse GL_MAX_UNIFORM_LOCATIONS */ -/* Reuse tokens from ARB_framebuffer_no_attachments */ -/* reuse GL_FRAMEBUFFER_DEFAULT_WIDTH */ -/* reuse GL_FRAMEBUFFER_DEFAULT_HEIGHT */ -/* reuse GL_FRAMEBUFFER_DEFAULT_LAYERS */ -/* reuse GL_FRAMEBUFFER_DEFAULT_SAMPLES */ -/* reuse GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS */ -/* reuse GL_MAX_FRAMEBUFFER_WIDTH */ -/* reuse GL_MAX_FRAMEBUFFER_HEIGHT */ -/* reuse GL_MAX_FRAMEBUFFER_LAYERS */ -/* reuse GL_MAX_FRAMEBUFFER_SAMPLES */ -/* Reuse tokens from ARB_internalformat_query2 */ -/* reuse GL_INTERNALFORMAT_SUPPORTED */ -/* reuse GL_INTERNALFORMAT_PREFERRED */ -/* reuse GL_INTERNALFORMAT_RED_SIZE */ -/* reuse GL_INTERNALFORMAT_GREEN_SIZE */ -/* reuse GL_INTERNALFORMAT_BLUE_SIZE */ -/* reuse GL_INTERNALFORMAT_ALPHA_SIZE */ -/* reuse GL_INTERNALFORMAT_DEPTH_SIZE */ -/* reuse GL_INTERNALFORMAT_STENCIL_SIZE */ -/* reuse GL_INTERNALFORMAT_SHARED_SIZE */ -/* reuse GL_INTERNALFORMAT_RED_TYPE */ -/* reuse GL_INTERNALFORMAT_GREEN_TYPE */ -/* reuse GL_INTERNALFORMAT_BLUE_TYPE */ -/* reuse GL_INTERNALFORMAT_ALPHA_TYPE */ -/* reuse GL_INTERNALFORMAT_DEPTH_TYPE */ -/* reuse GL_INTERNALFORMAT_STENCIL_TYPE */ -/* reuse GL_MAX_WIDTH */ -/* reuse GL_MAX_HEIGHT */ -/* reuse GL_MAX_DEPTH */ -/* reuse GL_MAX_LAYERS */ -/* reuse GL_MAX_COMBINED_DIMENSIONS */ -/* reuse GL_COLOR_COMPONENTS */ -/* reuse GL_DEPTH_COMPONENTS */ -/* reuse GL_STENCIL_COMPONENTS */ -/* reuse GL_COLOR_RENDERABLE */ -/* reuse GL_DEPTH_RENDERABLE */ -/* reuse GL_STENCIL_RENDERABLE */ -/* reuse GL_FRAMEBUFFER_RENDERABLE */ -/* reuse GL_FRAMEBUFFER_RENDERABLE_LAYERED */ -/* reuse GL_FRAMEBUFFER_BLEND */ -/* reuse GL_READ_PIXELS */ -/* reuse GL_READ_PIXELS_FORMAT */ -/* reuse GL_READ_PIXELS_TYPE */ -/* reuse GL_TEXTURE_IMAGE_FORMAT */ -/* reuse GL_TEXTURE_IMAGE_TYPE */ -/* reuse GL_GET_TEXTURE_IMAGE_FORMAT */ -/* reuse GL_GET_TEXTURE_IMAGE_TYPE */ -/* reuse GL_MIPMAP */ -/* reuse GL_MANUAL_GENERATE_MIPMAP */ -/* reuse GL_AUTO_GENERATE_MIPMAP */ -/* reuse GL_COLOR_ENCODING */ -/* reuse GL_SRGB_READ */ -/* reuse GL_SRGB_WRITE */ -/* reuse GL_FILTER */ -/* reuse GL_VERTEX_TEXTURE */ -/* reuse GL_TESS_CONTROL_TEXTURE */ -/* reuse GL_TESS_EVALUATION_TEXTURE */ -/* reuse GL_GEOMETRY_TEXTURE */ -/* reuse GL_FRAGMENT_TEXTURE */ -/* reuse GL_COMPUTE_TEXTURE */ -/* reuse GL_TEXTURE_SHADOW */ -/* reuse GL_TEXTURE_GATHER */ -/* reuse GL_TEXTURE_GATHER_SHADOW */ -/* reuse GL_SHADER_IMAGE_LOAD */ -/* reuse GL_SHADER_IMAGE_STORE */ -/* reuse GL_SHADER_IMAGE_ATOMIC */ -/* reuse GL_IMAGE_TEXEL_SIZE */ -/* reuse GL_IMAGE_COMPATIBILITY_CLASS */ -/* reuse GL_IMAGE_PIXEL_FORMAT */ -/* reuse GL_IMAGE_PIXEL_TYPE */ -/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST */ -/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST */ -/* reuse GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE */ -/* reuse GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE */ -/* reuse GL_TEXTURE_COMPRESSED_BLOCK_WIDTH */ -/* reuse GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT */ -/* reuse GL_TEXTURE_COMPRESSED_BLOCK_SIZE */ -/* reuse GL_CLEAR_BUFFER */ -/* reuse GL_TEXTURE_VIEW */ -/* reuse GL_VIEW_COMPATIBILITY_CLASS */ -/* reuse GL_FULL_SUPPORT */ -/* reuse GL_CAVEAT_SUPPORT */ -/* reuse GL_IMAGE_CLASS_4_X_32 */ -/* reuse GL_IMAGE_CLASS_2_X_32 */ -/* reuse GL_IMAGE_CLASS_1_X_32 */ -/* reuse GL_IMAGE_CLASS_4_X_16 */ -/* reuse GL_IMAGE_CLASS_2_X_16 */ -/* reuse GL_IMAGE_CLASS_1_X_16 */ -/* reuse GL_IMAGE_CLASS_4_X_8 */ -/* reuse GL_IMAGE_CLASS_2_X_8 */ -/* reuse GL_IMAGE_CLASS_1_X_8 */ -/* reuse GL_IMAGE_CLASS_11_11_10 */ -/* reuse GL_IMAGE_CLASS_10_10_10_2 */ -/* reuse GL_VIEW_CLASS_128_BITS */ -/* reuse GL_VIEW_CLASS_96_BITS */ -/* reuse GL_VIEW_CLASS_64_BITS */ -/* reuse GL_VIEW_CLASS_48_BITS */ -/* reuse GL_VIEW_CLASS_32_BITS */ -/* reuse GL_VIEW_CLASS_24_BITS */ -/* reuse GL_VIEW_CLASS_16_BITS */ -/* reuse GL_VIEW_CLASS_8_BITS */ -/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGB */ -/* reuse GL_VIEW_CLASS_S3TC_DXT1_RGBA */ -/* reuse GL_VIEW_CLASS_S3TC_DXT3_RGBA */ -/* reuse GL_VIEW_CLASS_S3TC_DXT5_RGBA */ -/* reuse GL_VIEW_CLASS_RGTC1_RED */ -/* reuse GL_VIEW_CLASS_RGTC2_RG */ -/* reuse GL_VIEW_CLASS_BPTC_UNORM */ -/* reuse GL_VIEW_CLASS_BPTC_FLOAT */ -/* Reuse tokens from ARB_invalidate_subdata (none) */ -/* Reuse tokens from ARB_multi_draw_indirect (none) */ -/* Reuse tokens from ARB_program_interface_query */ -/* reuse GL_UNIFORM */ -/* reuse GL_UNIFORM_BLOCK */ -/* reuse GL_PROGRAM_INPUT */ -/* reuse GL_PROGRAM_OUTPUT */ -/* reuse GL_BUFFER_VARIABLE */ -/* reuse GL_SHADER_STORAGE_BLOCK */ -/* reuse GL_VERTEX_SUBROUTINE */ -/* reuse GL_TESS_CONTROL_SUBROUTINE */ -/* reuse GL_TESS_EVALUATION_SUBROUTINE */ -/* reuse GL_GEOMETRY_SUBROUTINE */ -/* reuse GL_FRAGMENT_SUBROUTINE */ -/* reuse GL_COMPUTE_SUBROUTINE */ -/* reuse GL_VERTEX_SUBROUTINE_UNIFORM */ -/* reuse GL_TESS_CONTROL_SUBROUTINE_UNIFORM */ -/* reuse GL_TESS_EVALUATION_SUBROUTINE_UNIFORM */ -/* reuse GL_GEOMETRY_SUBROUTINE_UNIFORM */ -/* reuse GL_FRAGMENT_SUBROUTINE_UNIFORM */ -/* reuse GL_COMPUTE_SUBROUTINE_UNIFORM */ -/* reuse GL_TRANSFORM_FEEDBACK_VARYING */ -/* reuse GL_ACTIVE_RESOURCES */ -/* reuse GL_MAX_NAME_LENGTH */ -/* reuse GL_MAX_NUM_ACTIVE_VARIABLES */ -/* reuse GL_MAX_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_NAME_LENGTH */ -/* reuse GL_TYPE */ -/* reuse GL_ARRAY_SIZE */ -/* reuse GL_OFFSET */ -/* reuse GL_BLOCK_INDEX */ -/* reuse GL_ARRAY_STRIDE */ -/* reuse GL_MATRIX_STRIDE */ -/* reuse GL_IS_ROW_MAJOR */ -/* reuse GL_ATOMIC_COUNTER_BUFFER_INDEX */ -/* reuse GL_BUFFER_BINDING */ -/* reuse GL_BUFFER_DATA_SIZE */ -/* reuse GL_NUM_ACTIVE_VARIABLES */ -/* reuse GL_ACTIVE_VARIABLES */ -/* reuse GL_REFERENCED_BY_VERTEX_SHADER */ -/* reuse GL_REFERENCED_BY_TESS_CONTROL_SHADER */ -/* reuse GL_REFERENCED_BY_TESS_EVALUATION_SHADER */ -/* reuse GL_REFERENCED_BY_GEOMETRY_SHADER */ -/* reuse GL_REFERENCED_BY_FRAGMENT_SHADER */ -/* reuse GL_REFERENCED_BY_COMPUTE_SHADER */ -/* reuse GL_TOP_LEVEL_ARRAY_SIZE */ -/* reuse GL_TOP_LEVEL_ARRAY_STRIDE */ -/* reuse GL_LOCATION */ -/* reuse GL_LOCATION_INDEX */ -/* reuse GL_IS_PER_PATCH */ -/* Reuse tokens from ARB_robust_buffer_access_behavior (none) */ -/* Reuse tokens from ARB_shader_storage_buffer_object */ -/* reuse GL_SHADER_STORAGE_BUFFER */ -/* reuse GL_SHADER_STORAGE_BUFFER_BINDING */ -/* reuse GL_SHADER_STORAGE_BUFFER_START */ -/* reuse GL_SHADER_STORAGE_BUFFER_SIZE */ -/* reuse GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS */ -/* reuse GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS */ -/* reuse GL_MAX_SHADER_STORAGE_BLOCK_SIZE */ -/* reuse GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT */ -/* reuse GL_SHADER_STORAGE_BARRIER_BIT */ -/* reuse GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES */ -/* Reuse tokens from ARB_stencil_texturing */ -/* reuse GL_DEPTH_STENCIL_TEXTURE_MODE */ -/* Reuse tokens from ARB_texture_buffer_range */ -/* reuse GL_TEXTURE_BUFFER_OFFSET */ -/* reuse GL_TEXTURE_BUFFER_SIZE */ -/* reuse GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT */ -/* Reuse tokens from ARB_texture_query_levels (none) */ -/* Reuse tokens from ARB_texture_storage_multisample (none) */ -/* Reuse tokens from ARB_texture_view */ -/* reuse GL_TEXTURE_VIEW_MIN_LEVEL */ -/* reuse GL_TEXTURE_VIEW_NUM_LEVELS */ -/* reuse GL_TEXTURE_VIEW_MIN_LAYER */ -/* reuse GL_TEXTURE_VIEW_NUM_LAYERS */ -/* reuse GL_TEXTURE_IMMUTABLE_LEVELS */ -/* Reuse tokens from ARB_vertex_attrib_binding */ -/* reuse GL_VERTEX_ATTRIB_BINDING */ -/* reuse GL_VERTEX_ATTRIB_RELATIVE_OFFSET */ -/* reuse GL_VERTEX_BINDING_DIVISOR */ -/* reuse GL_VERTEX_BINDING_OFFSET */ -/* reuse GL_VERTEX_BINDING_STRIDE */ -/* reuse GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET */ -/* reuse GL_MAX_VERTEX_ATTRIB_BINDINGS */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -#endif - -#ifndef GL_ARB_multisample -#define GL_MULTISAMPLE_ARB 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F -#define GL_SAMPLE_COVERAGE_ARB 0x80A0 -#define GL_SAMPLE_BUFFERS_ARB 0x80A8 -#define GL_SAMPLES_ARB 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB -#define GL_MULTISAMPLE_BIT_ARB 0x20000000 -#endif - -#ifndef GL_ARB_texture_env_add -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_NORMAL_MAP_ARB 0x8511 -#define GL_REFLECTION_MAP_ARB 0x8512 -#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C -#endif - -#ifndef GL_ARB_texture_compression -#define GL_COMPRESSED_ALPHA_ARB 0x84E9 -#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA -#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB -#define GL_COMPRESSED_INTENSITY_ARB 0x84EC -#define GL_COMPRESSED_RGB_ARB 0x84ED -#define GL_COMPRESSED_RGBA_ARB 0x84EE -#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF -#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 -#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_CLAMP_TO_BORDER_ARB 0x812D -#endif - -#ifndef GL_ARB_point_parameters -#define GL_POINT_SIZE_MIN_ARB 0x8126 -#define GL_POINT_SIZE_MAX_ARB 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 -#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 -#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 -#define GL_VERTEX_BLEND_ARB 0x86A7 -#define GL_CURRENT_WEIGHT_ARB 0x86A8 -#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 -#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA -#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB -#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC -#define GL_WEIGHT_ARRAY_ARB 0x86AD -#define GL_MODELVIEW0_ARB 0x1700 -#define GL_MODELVIEW1_ARB 0x850A -#define GL_MODELVIEW2_ARB 0x8722 -#define GL_MODELVIEW3_ARB 0x8723 -#define GL_MODELVIEW4_ARB 0x8724 -#define GL_MODELVIEW5_ARB 0x8725 -#define GL_MODELVIEW6_ARB 0x8726 -#define GL_MODELVIEW7_ARB 0x8727 -#define GL_MODELVIEW8_ARB 0x8728 -#define GL_MODELVIEW9_ARB 0x8729 -#define GL_MODELVIEW10_ARB 0x872A -#define GL_MODELVIEW11_ARB 0x872B -#define GL_MODELVIEW12_ARB 0x872C -#define GL_MODELVIEW13_ARB 0x872D -#define GL_MODELVIEW14_ARB 0x872E -#define GL_MODELVIEW15_ARB 0x872F -#define GL_MODELVIEW16_ARB 0x8730 -#define GL_MODELVIEW17_ARB 0x8731 -#define GL_MODELVIEW18_ARB 0x8732 -#define GL_MODELVIEW19_ARB 0x8733 -#define GL_MODELVIEW20_ARB 0x8734 -#define GL_MODELVIEW21_ARB 0x8735 -#define GL_MODELVIEW22_ARB 0x8736 -#define GL_MODELVIEW23_ARB 0x8737 -#define GL_MODELVIEW24_ARB 0x8738 -#define GL_MODELVIEW25_ARB 0x8739 -#define GL_MODELVIEW26_ARB 0x873A -#define GL_MODELVIEW27_ARB 0x873B -#define GL_MODELVIEW28_ARB 0x873C -#define GL_MODELVIEW29_ARB 0x873D -#define GL_MODELVIEW30_ARB 0x873E -#define GL_MODELVIEW31_ARB 0x873F -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_MATRIX_PALETTE_ARB 0x8840 -#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 -#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 -#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 -#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 -#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 -#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 -#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 -#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 -#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_COMBINE_ARB 0x8570 -#define GL_COMBINE_RGB_ARB 0x8571 -#define GL_COMBINE_ALPHA_ARB 0x8572 -#define GL_SOURCE0_RGB_ARB 0x8580 -#define GL_SOURCE1_RGB_ARB 0x8581 -#define GL_SOURCE2_RGB_ARB 0x8582 -#define GL_SOURCE0_ALPHA_ARB 0x8588 -#define GL_SOURCE1_ALPHA_ARB 0x8589 -#define GL_SOURCE2_ALPHA_ARB 0x858A -#define GL_OPERAND0_RGB_ARB 0x8590 -#define GL_OPERAND1_RGB_ARB 0x8591 -#define GL_OPERAND2_RGB_ARB 0x8592 -#define GL_OPERAND0_ALPHA_ARB 0x8598 -#define GL_OPERAND1_ALPHA_ARB 0x8599 -#define GL_OPERAND2_ALPHA_ARB 0x859A -#define GL_RGB_SCALE_ARB 0x8573 -#define GL_ADD_SIGNED_ARB 0x8574 -#define GL_INTERPOLATE_ARB 0x8575 -#define GL_SUBTRACT_ARB 0x84E7 -#define GL_CONSTANT_ARB 0x8576 -#define GL_PRIMARY_COLOR_ARB 0x8577 -#define GL_PREVIOUS_ARB 0x8578 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_DOT3_RGB_ARB 0x86AE -#define GL_DOT3_RGBA_ARB 0x86AF -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_ARB 0x8370 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_DEPTH_COMPONENT16_ARB 0x81A5 -#define GL_DEPTH_COMPONENT24_ARB 0x81A6 -#define GL_DEPTH_COMPONENT32_ARB 0x81A7 -#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A -#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B -#endif - -#ifndef GL_ARB_shadow -#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C -#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D -#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF -#endif - -#ifndef GL_ARB_window_pos -#endif - -#ifndef GL_ARB_vertex_program -#define GL_COLOR_SUM_ARB 0x8458 -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 -#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 -#define GL_PROGRAM_LENGTH_ARB 0x8627 -#define GL_PROGRAM_STRING_ARB 0x8628 -#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E -#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F -#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 -#define GL_CURRENT_MATRIX_ARB 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 -#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 -#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B -#define GL_PROGRAM_BINDING_ARB 0x8677 -#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A -#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 -#define GL_PROGRAM_FORMAT_ARB 0x8876 -#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 -#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 -#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 -#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 -#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 -#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 -#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 -#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 -#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 -#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 -#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA -#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB -#define GL_PROGRAM_ATTRIBS_ARB 0x88AC -#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD -#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE -#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF -#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 -#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 -#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 -#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 -#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 -#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 -#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 -#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 -#define GL_MATRIX0_ARB 0x88C0 -#define GL_MATRIX1_ARB 0x88C1 -#define GL_MATRIX2_ARB 0x88C2 -#define GL_MATRIX3_ARB 0x88C3 -#define GL_MATRIX4_ARB 0x88C4 -#define GL_MATRIX5_ARB 0x88C5 -#define GL_MATRIX6_ARB 0x88C6 -#define GL_MATRIX7_ARB 0x88C7 -#define GL_MATRIX8_ARB 0x88C8 -#define GL_MATRIX9_ARB 0x88C9 -#define GL_MATRIX10_ARB 0x88CA -#define GL_MATRIX11_ARB 0x88CB -#define GL_MATRIX12_ARB 0x88CC -#define GL_MATRIX13_ARB 0x88CD -#define GL_MATRIX14_ARB 0x88CE -#define GL_MATRIX15_ARB 0x88CF -#define GL_MATRIX16_ARB 0x88D0 -#define GL_MATRIX17_ARB 0x88D1 -#define GL_MATRIX18_ARB 0x88D2 -#define GL_MATRIX19_ARB 0x88D3 -#define GL_MATRIX20_ARB 0x88D4 -#define GL_MATRIX21_ARB 0x88D5 -#define GL_MATRIX22_ARB 0x88D6 -#define GL_MATRIX23_ARB 0x88D7 -#define GL_MATRIX24_ARB 0x88D8 -#define GL_MATRIX25_ARB 0x88D9 -#define GL_MATRIX26_ARB 0x88DA -#define GL_MATRIX27_ARB 0x88DB -#define GL_MATRIX28_ARB 0x88DC -#define GL_MATRIX29_ARB 0x88DD -#define GL_MATRIX30_ARB 0x88DE -#define GL_MATRIX31_ARB 0x88DF -#endif - -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_BUFFER_SIZE_ARB 0x8764 -#define GL_BUFFER_USAGE_ARB 0x8765 -#define GL_ARRAY_BUFFER_ARB 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 -#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 -#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A -#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B -#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C -#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D -#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F -#define GL_READ_ONLY_ARB 0x88B8 -#define GL_WRITE_ONLY_ARB 0x88B9 -#define GL_READ_WRITE_ARB 0x88BA -#define GL_BUFFER_ACCESS_ARB 0x88BB -#define GL_BUFFER_MAPPED_ARB 0x88BC -#define GL_BUFFER_MAP_POINTER_ARB 0x88BD -#define GL_STREAM_DRAW_ARB 0x88E0 -#define GL_STREAM_READ_ARB 0x88E1 -#define GL_STREAM_COPY_ARB 0x88E2 -#define GL_STATIC_DRAW_ARB 0x88E4 -#define GL_STATIC_READ_ARB 0x88E5 -#define GL_STATIC_COPY_ARB 0x88E6 -#define GL_DYNAMIC_DRAW_ARB 0x88E8 -#define GL_DYNAMIC_READ_ARB 0x88E9 -#define GL_DYNAMIC_COPY_ARB 0x88EA -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_QUERY_COUNTER_BITS_ARB 0x8864 -#define GL_CURRENT_QUERY_ARB 0x8865 -#define GL_QUERY_RESULT_ARB 0x8866 -#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 -#define GL_SAMPLES_PASSED_ARB 0x8914 -#endif - -#ifndef GL_ARB_shader_objects -#define GL_PROGRAM_OBJECT_ARB 0x8B40 -#define GL_SHADER_OBJECT_ARB 0x8B48 -#define GL_OBJECT_TYPE_ARB 0x8B4E -#define GL_OBJECT_SUBTYPE_ARB 0x8B4F -#define GL_FLOAT_VEC2_ARB 0x8B50 -#define GL_FLOAT_VEC3_ARB 0x8B51 -#define GL_FLOAT_VEC4_ARB 0x8B52 -#define GL_INT_VEC2_ARB 0x8B53 -#define GL_INT_VEC3_ARB 0x8B54 -#define GL_INT_VEC4_ARB 0x8B55 -#define GL_BOOL_ARB 0x8B56 -#define GL_BOOL_VEC2_ARB 0x8B57 -#define GL_BOOL_VEC3_ARB 0x8B58 -#define GL_BOOL_VEC4_ARB 0x8B59 -#define GL_FLOAT_MAT2_ARB 0x8B5A -#define GL_FLOAT_MAT3_ARB 0x8B5B -#define GL_FLOAT_MAT4_ARB 0x8B5C -#define GL_SAMPLER_1D_ARB 0x8B5D -#define GL_SAMPLER_2D_ARB 0x8B5E -#define GL_SAMPLER_3D_ARB 0x8B5F -#define GL_SAMPLER_CUBE_ARB 0x8B60 -#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 -#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 -#define GL_SAMPLER_2D_RECT_ARB 0x8B63 -#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 -#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 -#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 -#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 -#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 -#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 -#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 -#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 -#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 -#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_VERTEX_SHADER_ARB 0x8B31 -#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A -#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D -#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 -#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_FRAGMENT_SHADER_ARB 0x8B30 -#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#endif - -#ifndef GL_ARB_point_sprite -#define GL_POINT_SPRITE_ARB 0x8861 -#define GL_COORD_REPLACE_ARB 0x8862 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 -#define GL_DRAW_BUFFER0_ARB 0x8825 -#define GL_DRAW_BUFFER1_ARB 0x8826 -#define GL_DRAW_BUFFER2_ARB 0x8827 -#define GL_DRAW_BUFFER3_ARB 0x8828 -#define GL_DRAW_BUFFER4_ARB 0x8829 -#define GL_DRAW_BUFFER5_ARB 0x882A -#define GL_DRAW_BUFFER6_ARB 0x882B -#define GL_DRAW_BUFFER7_ARB 0x882C -#define GL_DRAW_BUFFER8_ARB 0x882D -#define GL_DRAW_BUFFER9_ARB 0x882E -#define GL_DRAW_BUFFER10_ARB 0x882F -#define GL_DRAW_BUFFER11_ARB 0x8830 -#define GL_DRAW_BUFFER12_ARB 0x8831 -#define GL_DRAW_BUFFER13_ARB 0x8832 -#define GL_DRAW_BUFFER14_ARB 0x8833 -#define GL_DRAW_BUFFER15_ARB 0x8834 -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_RGBA_FLOAT_MODE_ARB 0x8820 -#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A -#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B -#define GL_CLAMP_READ_COLOR_ARB 0x891C -#define GL_FIXED_ONLY_ARB 0x891D -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_HALF_FLOAT_ARB 0x140B -#endif - -#ifndef GL_ARB_texture_float -#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 -#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 -#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 -#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 -#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 -#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 -#define GL_RGBA32F_ARB 0x8814 -#define GL_RGB32F_ARB 0x8815 -#define GL_ALPHA32F_ARB 0x8816 -#define GL_INTENSITY32F_ARB 0x8817 -#define GL_LUMINANCE32F_ARB 0x8818 -#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 -#define GL_RGBA16F_ARB 0x881A -#define GL_RGB16F_ARB 0x881B -#define GL_ALPHA16F_ARB 0x881C -#define GL_INTENSITY16F_ARB 0x881D -#define GL_LUMINANCE16F_ARB 0x881E -#define GL_LUMINANCE_ALPHA16F_ARB 0x881F -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_DEPTH_COMPONENT32F 0x8CAC -#define GL_DEPTH32F_STENCIL8 0x8CAD -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD -#endif - -#ifndef GL_ARB_draw_instanced -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 -#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 -#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 -#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 -#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 -#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 -#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 -#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 -#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 -#define GL_FRAMEBUFFER_DEFAULT 0x8218 -#define GL_FRAMEBUFFER_UNDEFINED 0x8219 -#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 -#define GL_DEPTH_STENCIL 0x84F9 -#define GL_UNSIGNED_INT_24_8 0x84FA -#define GL_DEPTH24_STENCIL8 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE 0x88F1 -#define GL_TEXTURE_RED_TYPE 0x8C10 -#define GL_TEXTURE_GREEN_TYPE 0x8C11 -#define GL_TEXTURE_BLUE_TYPE 0x8C12 -#define GL_TEXTURE_ALPHA_TYPE 0x8C13 -#define GL_TEXTURE_DEPTH_TYPE 0x8C16 -#define GL_UNSIGNED_NORMALIZED 0x8C17 -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_READ_FRAMEBUFFER 0x8CA8 -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA -#define GL_RENDERBUFFER_SAMPLES 0x8CAB -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_COLOR_ATTACHMENT1 0x8CE1 -#define GL_COLOR_ATTACHMENT2 0x8CE2 -#define GL_COLOR_ATTACHMENT3 0x8CE3 -#define GL_COLOR_ATTACHMENT4 0x8CE4 -#define GL_COLOR_ATTACHMENT5 0x8CE5 -#define GL_COLOR_ATTACHMENT6 0x8CE6 -#define GL_COLOR_ATTACHMENT7 0x8CE7 -#define GL_COLOR_ATTACHMENT8 0x8CE8 -#define GL_COLOR_ATTACHMENT9 0x8CE9 -#define GL_COLOR_ATTACHMENT10 0x8CEA -#define GL_COLOR_ATTACHMENT11 0x8CEB -#define GL_COLOR_ATTACHMENT12 0x8CEC -#define GL_COLOR_ATTACHMENT13 0x8CED -#define GL_COLOR_ATTACHMENT14 0x8CEE -#define GL_COLOR_ATTACHMENT15 0x8CEF -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_STENCIL_INDEX1 0x8D46 -#define GL_STENCIL_INDEX4 0x8D47 -#define GL_STENCIL_INDEX8 0x8D48 -#define GL_STENCIL_INDEX16 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 -#define GL_MAX_SAMPLES 0x8D57 -#define GL_INDEX 0x8222 -#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 -#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB 0x8DB9 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_LINES_ADJACENCY_ARB 0x000A -#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B -#define GL_TRIANGLES_ADJACENCY_ARB 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D -#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 -#define GL_GEOMETRY_SHADER_ARB 0x8DD9 -#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 -/* reuse GL_MAX_VARYING_COMPONENTS */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */ -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_HALF_FLOAT 0x140B -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_TEXTURE_BUFFER_ARB 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC -#define GL_COMPRESSED_RG_RGTC2 0x8DBD -#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE -#endif - -#ifndef GL_ARB_texture_rg -#define GL_RG 0x8227 -#define GL_RG_INTEGER 0x8228 -#define GL_R8 0x8229 -#define GL_R16 0x822A -#define GL_RG8 0x822B -#define GL_RG16 0x822C -#define GL_R16F 0x822D -#define GL_R32F 0x822E -#define GL_RG16F 0x822F -#define GL_RG32F 0x8230 -#define GL_R8I 0x8231 -#define GL_R8UI 0x8232 -#define GL_R16I 0x8233 -#define GL_R16UI 0x8234 -#define GL_R32I 0x8235 -#define GL_R32UI 0x8236 -#define GL_RG8I 0x8237 -#define GL_RG8UI 0x8238 -#define GL_RG16I 0x8239 -#define GL_RG16UI 0x823A -#define GL_RG32I 0x823B -#define GL_RG32UI 0x823C -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING 0x85B5 -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_UNIFORM_BUFFER 0x8A11 -#define GL_UNIFORM_BUFFER_BINDING 0x8A28 -#define GL_UNIFORM_BUFFER_START 0x8A29 -#define GL_UNIFORM_BUFFER_SIZE 0x8A2A -#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B -#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C -#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D -#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E -#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F -#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 -#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 -#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 -#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 -#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 -#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 -#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 -#define GL_UNIFORM_TYPE 0x8A37 -#define GL_UNIFORM_SIZE 0x8A38 -#define GL_UNIFORM_NAME_LENGTH 0x8A39 -#define GL_UNIFORM_BLOCK_INDEX 0x8A3A -#define GL_UNIFORM_OFFSET 0x8A3B -#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C -#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D -#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E -#define GL_UNIFORM_BLOCK_BINDING 0x8A3F -#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 -#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 -#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 -#define GL_INVALID_INDEX 0xFFFFFFFFu -#endif - -#ifndef GL_ARB_compatibility -/* ARB_compatibility just defines tokens from core 3.0 */ -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_COPY_READ_BUFFER_BINDING 0x8F36 -#define GL_COPY_READ_BUFFER 0x8F36 -#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 -#define GL_COPY_WRITE_BUFFER 0x8F37 -#endif - -#ifndef GL_ARB_shader_texture_lod -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_DEPTH_CLAMP 0x864F -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION 0x8E4D -#define GL_LAST_VERTEX_CONVENTION 0x8E4E -#define GL_PROVOKING_VERTEX 0x8E4F -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F -#endif - -#ifndef GL_ARB_sync -#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 -#define GL_OBJECT_TYPE 0x9112 -#define GL_SYNC_CONDITION 0x9113 -#define GL_SYNC_STATUS 0x9114 -#define GL_SYNC_FLAGS 0x9115 -#define GL_SYNC_FENCE 0x9116 -#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 -#define GL_UNSIGNALED 0x9118 -#define GL_SIGNALED 0x9119 -#define GL_ALREADY_SIGNALED 0x911A -#define GL_TIMEOUT_EXPIRED 0x911B -#define GL_CONDITION_SATISFIED 0x911C -#define GL_WAIT_FAILED 0x911D -#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 -#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_SAMPLE_POSITION 0x8E50 -#define GL_SAMPLE_MASK 0x8E51 -#define GL_SAMPLE_MASK_VALUE 0x8E52 -#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 -#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 -#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 -#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 -#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 -#define GL_TEXTURE_SAMPLES 0x9106 -#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 -#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 -#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A -#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B -#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C -#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D -#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E -#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F -#define GL_MAX_INTEGER_SAMPLES 0x9110 -#endif - -#ifndef GL_ARB_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_ARB_draw_buffers_blend -#endif - -#ifndef GL_ARB_sample_shading -#define GL_SAMPLE_SHADING_ARB 0x8C36 -#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 -#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A -#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B -#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C -#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D -#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E -#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F -#endif - -#ifndef GL_ARB_texture_gather -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F -#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F -#endif - -#ifndef GL_ARB_texture_query_lod -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_SHADER_INCLUDE_ARB 0x8DAE -#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 -#define GL_NAMED_STRING_TYPE_ARB 0x8DEA -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C -#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D -#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E -#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_SRC1_COLOR 0x88F9 -/* reuse GL_SRC1_ALPHA */ -#define GL_ONE_MINUS_SRC1_COLOR 0x88FA -#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB -#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC -#endif - -#ifndef GL_ARB_explicit_attrib_location -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ANY_SAMPLES_PASSED 0x8C2F -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_SAMPLER_BINDING 0x8919 -#endif - -#ifndef GL_ARB_shader_bit_encoding -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_RGB10_A2UI 0x906F -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R 0x8E42 -#define GL_TEXTURE_SWIZZLE_G 0x8E43 -#define GL_TEXTURE_SWIZZLE_B 0x8E44 -#define GL_TEXTURE_SWIZZLE_A 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 -#endif - -#ifndef GL_ARB_timer_query -#define GL_TIME_ELAPSED 0x88BF -#define GL_TIMESTAMP 0x8E28 -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -/* reuse GL_UNSIGNED_INT_2_10_10_10_REV */ -#define GL_INT_2_10_10_10_REV 0x8D9F -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_DRAW_INDIRECT_BUFFER 0x8F3F -#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F -#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C -#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D -/* reuse GL_MAX_VERTEX_STREAMS */ -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2 0x8FFC -#define GL_DOUBLE_VEC3 0x8FFD -#define GL_DOUBLE_VEC4 0x8FFE -#define GL_DOUBLE_MAT2 0x8F46 -#define GL_DOUBLE_MAT3 0x8F47 -#define GL_DOUBLE_MAT4 0x8F48 -#define GL_DOUBLE_MAT2x3 0x8F49 -#define GL_DOUBLE_MAT2x4 0x8F4A -#define GL_DOUBLE_MAT3x2 0x8F4B -#define GL_DOUBLE_MAT3x4 0x8F4C -#define GL_DOUBLE_MAT4x2 0x8F4D -#define GL_DOUBLE_MAT4x3 0x8F4E -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ACTIVE_SUBROUTINES 0x8DE5 -#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 -#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 -#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 -#define GL_MAX_SUBROUTINES 0x8DE7 -#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 -#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A -#define GL_COMPATIBLE_SUBROUTINES 0x8E4B -/* reuse GL_UNIFORM_SIZE */ -/* reuse GL_UNIFORM_NAME_LENGTH */ -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_PATCHES 0x000E -#define GL_PATCH_VERTICES 0x8E72 -#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 -#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 -#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 -#define GL_TESS_GEN_MODE 0x8E76 -#define GL_TESS_GEN_SPACING 0x8E77 -#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 -#define GL_TESS_GEN_POINT_MODE 0x8E79 -/* reuse GL_TRIANGLES */ -/* reuse GL_QUADS */ -#define GL_ISOLINES 0x8E7A -/* reuse GL_EQUAL */ -#define GL_FRACTIONAL_ODD 0x8E7B -#define GL_FRACTIONAL_EVEN 0x8E7C -/* reuse GL_CCW */ -/* reuse GL_CW */ -#define GL_MAX_PATCH_VERTICES 0x8E7D -#define GL_MAX_TESS_GEN_LEVEL 0x8E7E -#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F -#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 -#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 -#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 -#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 -#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 -#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 -#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 -#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 -#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A -#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C -#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D -#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E -#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 -#define GL_TESS_EVALUATION_SHADER 0x8E87 -#define GL_TESS_CONTROL_SHADER 0x8E88 -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -/* reuse GL_RGB32F */ -/* reuse GL_RGB32UI */ -/* reuse GL_RGB32I */ -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK 0x8E22 -#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 -#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 -#define GL_MAX_VERTEX_STREAMS 0x8E71 -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_FIXED 0x140C -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 -#define GL_SHADER_COMPILER 0x8DFA -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_RGB565 0x8D62 -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 -#define GL_PROGRAM_BINARY_LENGTH 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE -#define GL_PROGRAM_BINARY_FORMATS 0x87FF -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_VERTEX_SHADER_BIT 0x00000001 -#define GL_FRAGMENT_SHADER_BIT 0x00000002 -#define GL_GEOMETRY_SHADER_BIT 0x00000004 -#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 -#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 -#define GL_ALL_SHADER_BITS 0xFFFFFFFF -#define GL_PROGRAM_SEPARABLE 0x8258 -#define GL_ACTIVE_PROGRAM 0x8259 -#define GL_PROGRAM_PIPELINE_BINDING 0x825A -#endif - -#ifndef GL_ARB_shader_precision -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -/* reuse GL_RGB32I */ -/* reuse GL_DOUBLE_VEC2 */ -/* reuse GL_DOUBLE_VEC3 */ -/* reuse GL_DOUBLE_VEC4 */ -/* reuse GL_DOUBLE_MAT2 */ -/* reuse GL_DOUBLE_MAT3 */ -/* reuse GL_DOUBLE_MAT4 */ -/* reuse GL_DOUBLE_MAT2x3 */ -/* reuse GL_DOUBLE_MAT2x4 */ -/* reuse GL_DOUBLE_MAT3x2 */ -/* reuse GL_DOUBLE_MAT3x4 */ -/* reuse GL_DOUBLE_MAT4x2 */ -/* reuse GL_DOUBLE_MAT4x3 */ -#endif - -#ifndef GL_ARB_viewport_array -/* reuse GL_SCISSOR_BOX */ -/* reuse GL_VIEWPORT */ -/* reuse GL_DEPTH_RANGE */ -/* reuse GL_SCISSOR_TEST */ -#define GL_MAX_VIEWPORTS 0x825B -#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C -#define GL_VIEWPORT_BOUNDS_RANGE 0x825D -#define GL_LAYER_PROVOKING_VERTEX 0x825E -#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F -#define GL_UNDEFINED_VERTEX 0x8260 -/* reuse GL_FIRST_VERTEX_CONVENTION */ -/* reuse GL_LAST_VERTEX_CONVENTION */ -/* reuse GL_PROVOKING_VERTEX */ -#endif - -#ifndef GL_ARB_cl_event -#define GL_SYNC_CL_EVENT_ARB 0x8240 -#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 -#endif - -#ifndef GL_ARB_debug_output -#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 -#define GL_DEBUG_SOURCE_API_ARB 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A -#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B -#define GL_DEBUG_TYPE_ERROR_ARB 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E -#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 -#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 -#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 -#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 -#endif - -#ifndef GL_ARB_robustness -/* reuse GL_NO_ERROR */ -#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 -#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 -#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 -#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 -#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 -#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 -#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 -#endif - -#ifndef GL_ARB_shader_stencil_export -#endif - -#ifndef GL_ARB_base_instance -#endif - -#ifndef GL_ARB_shading_language_420pack -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 -#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 -#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 -#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A -#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B -#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C -#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D -#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E -#endif - -#ifndef GL_ARB_conservative_depth -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_NUM_SAMPLE_COUNTS 0x9380 -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 -#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 -#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 -#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 -#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 -#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB -#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE -#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF -#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 -#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 -#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 -#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 -#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 -#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 -#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 -#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 -#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC -#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 -#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA -#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 -#define GL_COMMAND_BARRIER_BIT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 -#define GL_ALL_BARRIER_BITS 0xFFFFFFFF -#define GL_MAX_IMAGE_UNITS 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 -#define GL_IMAGE_BINDING_NAME 0x8F3A -#define GL_IMAGE_BINDING_LEVEL 0x8F3B -#define GL_IMAGE_BINDING_LAYERED 0x8F3C -#define GL_IMAGE_BINDING_LAYER 0x8F3D -#define GL_IMAGE_BINDING_ACCESS 0x8F3E -#define GL_IMAGE_1D 0x904C -#define GL_IMAGE_2D 0x904D -#define GL_IMAGE_3D 0x904E -#define GL_IMAGE_2D_RECT 0x904F -#define GL_IMAGE_CUBE 0x9050 -#define GL_IMAGE_BUFFER 0x9051 -#define GL_IMAGE_1D_ARRAY 0x9052 -#define GL_IMAGE_2D_ARRAY 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 -#define GL_INT_IMAGE_1D 0x9057 -#define GL_INT_IMAGE_2D 0x9058 -#define GL_INT_IMAGE_3D 0x9059 -#define GL_INT_IMAGE_2D_RECT 0x905A -#define GL_INT_IMAGE_CUBE 0x905B -#define GL_INT_IMAGE_BUFFER 0x905C -#define GL_INT_IMAGE_1D_ARRAY 0x905D -#define GL_INT_IMAGE_2D_ARRAY 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C -#define GL_MAX_IMAGE_SAMPLES 0x906D -#define GL_IMAGE_BINDING_FORMAT 0x906E -#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 -#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 -#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA -#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB -#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC -#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD -#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE -#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF -#endif - -#ifndef GL_ARB_shading_language_packing -#endif - -#ifndef GL_ARB_texture_storage -#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F -#endif - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 -#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 -#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 -#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 -#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 -#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 -#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 -#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 -#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 -#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 -#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA -#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB -#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC -#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC -#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD -#endif - -#ifndef GL_KHR_debug -#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 -#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 -#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 -#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 -#define GL_DEBUG_SOURCE_API 0x8246 -#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 -#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 -#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 -#define GL_DEBUG_SOURCE_APPLICATION 0x824A -#define GL_DEBUG_SOURCE_OTHER 0x824B -#define GL_DEBUG_TYPE_ERROR 0x824C -#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D -#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E -#define GL_DEBUG_TYPE_PORTABILITY 0x824F -#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 -#define GL_DEBUG_TYPE_OTHER 0x8251 -#define GL_DEBUG_TYPE_MARKER 0x8268 -#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 -#define GL_DEBUG_TYPE_POP_GROUP 0x826A -#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B -#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C -#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D -#define GL_BUFFER 0x82E0 -#define GL_SHADER 0x82E1 -#define GL_PROGRAM 0x82E2 -#define GL_QUERY 0x82E3 -#define GL_PROGRAM_PIPELINE 0x82E4 -#define GL_SAMPLER 0x82E6 -#define GL_DISPLAY_LIST 0x82E7 -/* DISPLAY_LIST used in compatibility profile only */ -#define GL_MAX_LABEL_LENGTH 0x82E8 -#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES 0x9145 -#define GL_DEBUG_SEVERITY_HIGH 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 -#define GL_DEBUG_SEVERITY_LOW 0x9148 -#define GL_DEBUG_OUTPUT 0x92E0 -#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 -/* reuse GL_STACK_UNDERFLOW */ -/* reuse GL_STACK_OVERFLOW */ -#endif - -#ifndef GL_ARB_arrays_of_arrays -#endif - -#ifndef GL_ARB_clear_buffer_object -#endif - -#ifndef GL_ARB_compute_shader -#define GL_COMPUTE_SHADER 0x91B9 -#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB -#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC -#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD -#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 -#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 -#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 -#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 -#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 -#define GL_MAX_COMPUTE_LOCAL_INVOCATIONS 0x90EB -#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE -#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF -#define GL_COMPUTE_LOCAL_WORK_SIZE 0x8267 -#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC -#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED -#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE -#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF -#define GL_COMPUTE_SHADER_BIT 0x00000020 -#endif - -#ifndef GL_ARB_copy_image -#endif - -#ifndef GL_ARB_texture_view -#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB -#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC -#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD -#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE -#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF -#endif - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_VERTEX_ATTRIB_BINDING 0x82D4 -#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 -#define GL_VERTEX_BINDING_DIVISOR 0x82D6 -#define GL_VERTEX_BINDING_OFFSET 0x82D7 -#define GL_VERTEX_BINDING_STRIDE 0x82D8 -#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 -#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA -#endif - -#ifndef GL_ARB_robustness_isolation -#endif - -#ifndef GL_ARB_ES3_compatibility -#define GL_COMPRESSED_RGB8_ETC2 0x9274 -#define GL_COMPRESSED_SRGB8_ETC2 0x9275 -#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 -#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 -#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 -#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 -#define GL_COMPRESSED_R11_EAC 0x9270 -#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 -#define GL_COMPRESSED_RG11_EAC 0x9272 -#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 -#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 -#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A -#define GL_MAX_ELEMENT_INDEX 0x8D6B -#endif - -#ifndef GL_ARB_explicit_uniform_location -#define GL_MAX_UNIFORM_LOCATIONS 0x826E -#endif - -#ifndef GL_ARB_fragment_layer_viewport -#endif - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 -#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 -#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 -#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 -#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 -#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 -#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 -#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 -#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 -#endif - -#ifndef GL_ARB_internalformat_query2 -/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */ -/* reuse GL_NUM_SAMPLE_COUNTS */ -/* reuse GL_RENDERBUFFER */ -/* reuse GL_SAMPLES */ -/* reuse GL_TEXTURE_1D */ -/* reuse GL_TEXTURE_1D_ARRAY */ -/* reuse GL_TEXTURE_2D */ -/* reuse GL_TEXTURE_2D_ARRAY */ -/* reuse GL_TEXTURE_3D */ -/* reuse GL_TEXTURE_CUBE_MAP */ -/* reuse GL_TEXTURE_CUBE_MAP_ARRAY */ -/* reuse GL_TEXTURE_RECTANGLE */ -/* reuse GL_TEXTURE_BUFFER */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE */ -/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */ -/* reuse GL_TEXTURE_COMPRESSED */ -#define GL_INTERNALFORMAT_SUPPORTED 0x826F -#define GL_INTERNALFORMAT_PREFERRED 0x8270 -#define GL_INTERNALFORMAT_RED_SIZE 0x8271 -#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 -#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 -#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 -#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 -#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 -#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 -#define GL_INTERNALFORMAT_RED_TYPE 0x8278 -#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 -#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A -#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B -#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C -#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D -#define GL_MAX_WIDTH 0x827E -#define GL_MAX_HEIGHT 0x827F -#define GL_MAX_DEPTH 0x8280 -#define GL_MAX_LAYERS 0x8281 -#define GL_MAX_COMBINED_DIMENSIONS 0x8282 -#define GL_COLOR_COMPONENTS 0x8283 -#define GL_DEPTH_COMPONENTS 0x8284 -#define GL_STENCIL_COMPONENTS 0x8285 -#define GL_COLOR_RENDERABLE 0x8286 -#define GL_DEPTH_RENDERABLE 0x8287 -#define GL_STENCIL_RENDERABLE 0x8288 -#define GL_FRAMEBUFFER_RENDERABLE 0x8289 -#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A -#define GL_FRAMEBUFFER_BLEND 0x828B -#define GL_READ_PIXELS 0x828C -#define GL_READ_PIXELS_FORMAT 0x828D -#define GL_READ_PIXELS_TYPE 0x828E -#define GL_TEXTURE_IMAGE_FORMAT 0x828F -#define GL_TEXTURE_IMAGE_TYPE 0x8290 -#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 -#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 -#define GL_MIPMAP 0x8293 -#define GL_MANUAL_GENERATE_MIPMAP 0x8294 -#define GL_AUTO_GENERATE_MIPMAP 0x8295 -#define GL_COLOR_ENCODING 0x8296 -#define GL_SRGB_READ 0x8297 -#define GL_SRGB_WRITE 0x8298 -#define GL_SRGB_DECODE_ARB 0x8299 -#define GL_FILTER 0x829A -#define GL_VERTEX_TEXTURE 0x829B -#define GL_TESS_CONTROL_TEXTURE 0x829C -#define GL_TESS_EVALUATION_TEXTURE 0x829D -#define GL_GEOMETRY_TEXTURE 0x829E -#define GL_FRAGMENT_TEXTURE 0x829F -#define GL_COMPUTE_TEXTURE 0x82A0 -#define GL_TEXTURE_SHADOW 0x82A1 -#define GL_TEXTURE_GATHER 0x82A2 -#define GL_TEXTURE_GATHER_SHADOW 0x82A3 -#define GL_SHADER_IMAGE_LOAD 0x82A4 -#define GL_SHADER_IMAGE_STORE 0x82A5 -#define GL_SHADER_IMAGE_ATOMIC 0x82A6 -#define GL_IMAGE_TEXEL_SIZE 0x82A7 -#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 -#define GL_IMAGE_PIXEL_FORMAT 0x82A9 -#define GL_IMAGE_PIXEL_TYPE 0x82AA -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD -#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE -#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF -#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 -#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 -#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 -#define GL_CLEAR_BUFFER 0x82B4 -#define GL_TEXTURE_VIEW 0x82B5 -#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 -#define GL_FULL_SUPPORT 0x82B7 -#define GL_CAVEAT_SUPPORT 0x82B8 -#define GL_IMAGE_CLASS_4_X_32 0x82B9 -#define GL_IMAGE_CLASS_2_X_32 0x82BA -#define GL_IMAGE_CLASS_1_X_32 0x82BB -#define GL_IMAGE_CLASS_4_X_16 0x82BC -#define GL_IMAGE_CLASS_2_X_16 0x82BD -#define GL_IMAGE_CLASS_1_X_16 0x82BE -#define GL_IMAGE_CLASS_4_X_8 0x82BF -#define GL_IMAGE_CLASS_2_X_8 0x82C0 -#define GL_IMAGE_CLASS_1_X_8 0x82C1 -#define GL_IMAGE_CLASS_11_11_10 0x82C2 -#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 -#define GL_VIEW_CLASS_128_BITS 0x82C4 -#define GL_VIEW_CLASS_96_BITS 0x82C5 -#define GL_VIEW_CLASS_64_BITS 0x82C6 -#define GL_VIEW_CLASS_48_BITS 0x82C7 -#define GL_VIEW_CLASS_32_BITS 0x82C8 -#define GL_VIEW_CLASS_24_BITS 0x82C9 -#define GL_VIEW_CLASS_16_BITS 0x82CA -#define GL_VIEW_CLASS_8_BITS 0x82CB -#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC -#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD -#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE -#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF -#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 -#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 -#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 -#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 -#endif - -#ifndef GL_ARB_invalidate_subdata -#endif - -#ifndef GL_ARB_multi_draw_indirect -#endif - -#ifndef GL_ARB_program_interface_query -#define GL_UNIFORM 0x92E1 -#define GL_UNIFORM_BLOCK 0x92E2 -#define GL_PROGRAM_INPUT 0x92E3 -#define GL_PROGRAM_OUTPUT 0x92E4 -#define GL_BUFFER_VARIABLE 0x92E5 -#define GL_SHADER_STORAGE_BLOCK 0x92E6 -/* reuse GL_ATOMIC_COUNTER_BUFFER */ -#define GL_VERTEX_SUBROUTINE 0x92E8 -#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 -#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA -#define GL_GEOMETRY_SUBROUTINE 0x92EB -#define GL_FRAGMENT_SUBROUTINE 0x92EC -#define GL_COMPUTE_SUBROUTINE 0x92ED -#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE -#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF -#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 -#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 -#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 -#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 -#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 -#define GL_ACTIVE_RESOURCES 0x92F5 -#define GL_MAX_NAME_LENGTH 0x92F6 -#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 -#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 -#define GL_NAME_LENGTH 0x92F9 -#define GL_TYPE 0x92FA -#define GL_ARRAY_SIZE 0x92FB -#define GL_OFFSET 0x92FC -#define GL_BLOCK_INDEX 0x92FD -#define GL_ARRAY_STRIDE 0x92FE -#define GL_MATRIX_STRIDE 0x92FF -#define GL_IS_ROW_MAJOR 0x9300 -#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 -#define GL_BUFFER_BINDING 0x9302 -#define GL_BUFFER_DATA_SIZE 0x9303 -#define GL_NUM_ACTIVE_VARIABLES 0x9304 -#define GL_ACTIVE_VARIABLES 0x9305 -#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 -#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 -#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 -#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 -#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A -#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B -#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C -#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D -#define GL_LOCATION 0x930E -#define GL_LOCATION_INDEX 0x930F -#define GL_IS_PER_PATCH 0x92E7 -/* reuse GL_NUM_COMPATIBLE_SUBROUTINES */ -/* reuse GL_COMPATIBLE_SUBROUTINES */ -#endif - -#ifndef GL_ARB_robust_buffer_access_behavior -#endif - -#ifndef GL_ARB_shader_image_size -#endif - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_SHADER_STORAGE_BUFFER 0x90D2 -#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 -#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 -#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 -#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 -#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 -#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 -#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 -#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA -#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB -#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC -#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD -#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE -#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF -#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 -#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 -/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */ -#endif - -#ifndef GL_ARB_stencil_texturing -#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA -#endif - -#ifndef GL_ARB_texture_buffer_range -#define GL_TEXTURE_BUFFER_OFFSET 0x919D -#define GL_TEXTURE_BUFFER_SIZE 0x919E -#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F -#endif - -#ifndef GL_ARB_texture_query_levels -#endif - -#ifndef GL_ARB_texture_storage_multisample -#endif - -#ifndef GL_EXT_abgr -#define GL_ABGR_EXT 0x8000 -#endif - -#ifndef GL_EXT_blend_color -#define GL_CONSTANT_COLOR_EXT 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 -#define GL_CONSTANT_ALPHA_EXT 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 -#define GL_BLEND_COLOR_EXT 0x8005 -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_POLYGON_OFFSET_EXT 0x8037 -#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 -#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 -#endif - -#ifndef GL_EXT_texture -#define GL_ALPHA4_EXT 0x803B -#define GL_ALPHA8_EXT 0x803C -#define GL_ALPHA12_EXT 0x803D -#define GL_ALPHA16_EXT 0x803E -#define GL_LUMINANCE4_EXT 0x803F -#define GL_LUMINANCE8_EXT 0x8040 -#define GL_LUMINANCE12_EXT 0x8041 -#define GL_LUMINANCE16_EXT 0x8042 -#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 -#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 -#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 -#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 -#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 -#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 -#define GL_INTENSITY_EXT 0x8049 -#define GL_INTENSITY4_EXT 0x804A -#define GL_INTENSITY8_EXT 0x804B -#define GL_INTENSITY12_EXT 0x804C -#define GL_INTENSITY16_EXT 0x804D -#define GL_RGB2_EXT 0x804E -#define GL_RGB4_EXT 0x804F -#define GL_RGB5_EXT 0x8050 -#define GL_RGB8_EXT 0x8051 -#define GL_RGB10_EXT 0x8052 -#define GL_RGB12_EXT 0x8053 -#define GL_RGB16_EXT 0x8054 -#define GL_RGBA2_EXT 0x8055 -#define GL_RGBA4_EXT 0x8056 -#define GL_RGB5_A1_EXT 0x8057 -#define GL_RGBA8_EXT 0x8058 -#define GL_RGB10_A2_EXT 0x8059 -#define GL_RGBA12_EXT 0x805A -#define GL_RGBA16_EXT 0x805B -#define GL_TEXTURE_RED_SIZE_EXT 0x805C -#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D -#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E -#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F -#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 -#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 -#define GL_REPLACE_EXT 0x8062 -#define GL_PROXY_TEXTURE_1D_EXT 0x8063 -#define GL_PROXY_TEXTURE_2D_EXT 0x8064 -#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 -#endif - -#ifndef GL_EXT_texture3D -#define GL_PACK_SKIP_IMAGES_EXT 0x806B -#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C -#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D -#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E -#define GL_TEXTURE_3D_EXT 0x806F -#define GL_PROXY_TEXTURE_3D_EXT 0x8070 -#define GL_TEXTURE_DEPTH_EXT 0x8071 -#define GL_TEXTURE_WRAP_R_EXT 0x8072 -#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_FILTER4_SGIS 0x8146 -#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 -#endif - -#ifndef GL_EXT_subtexture -#endif - -#ifndef GL_EXT_copy_texture -#endif - -#ifndef GL_EXT_histogram -#define GL_HISTOGRAM_EXT 0x8024 -#define GL_PROXY_HISTOGRAM_EXT 0x8025 -#define GL_HISTOGRAM_WIDTH_EXT 0x8026 -#define GL_HISTOGRAM_FORMAT_EXT 0x8027 -#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 -#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 -#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A -#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B -#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C -#define GL_HISTOGRAM_SINK_EXT 0x802D -#define GL_MINMAX_EXT 0x802E -#define GL_MINMAX_FORMAT_EXT 0x802F -#define GL_MINMAX_SINK_EXT 0x8030 -#define GL_TABLE_TOO_LARGE_EXT 0x8031 -#endif - -#ifndef GL_EXT_convolution -#define GL_CONVOLUTION_1D_EXT 0x8010 -#define GL_CONVOLUTION_2D_EXT 0x8011 -#define GL_SEPARABLE_2D_EXT 0x8012 -#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 -#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 -#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 -#define GL_REDUCE_EXT 0x8016 -#define GL_CONVOLUTION_FORMAT_EXT 0x8017 -#define GL_CONVOLUTION_WIDTH_EXT 0x8018 -#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 -#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A -#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B -#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C -#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D -#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E -#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F -#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 -#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 -#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 -#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 -#endif - -#ifndef GL_SGI_color_matrix -#define GL_COLOR_MATRIX_SGI 0x80B1 -#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 -#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 -#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 -#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 -#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 -#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 -#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 -#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 -#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA -#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB -#endif - -#ifndef GL_SGI_color_table -#define GL_COLOR_TABLE_SGI 0x80D0 -#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 -#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 -#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 -#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 -#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 -#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_PIXEL_TEXTURE_SGIS 0x8353 -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 -#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_PIXEL_TEX_GEN_SGIX 0x8139 -#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B -#endif - -#ifndef GL_SGIS_texture4D -#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 -#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 -#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 -#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 -#define GL_TEXTURE_4D_SGIS 0x8134 -#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 -#define GL_TEXTURE_4DSIZE_SGIS 0x8136 -#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 -#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 -#define GL_TEXTURE_4D_BINDING_SGIS 0x814F -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC -#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD -#endif - -#ifndef GL_EXT_cmyka -#define GL_CMYK_EXT 0x800C -#define GL_CMYKA_EXT 0x800D -#define GL_PACK_CMYK_HINT_EXT 0x800E -#define GL_UNPACK_CMYK_HINT_EXT 0x800F -#endif - -#ifndef GL_EXT_texture_object -#define GL_TEXTURE_PRIORITY_EXT 0x8066 -#define GL_TEXTURE_RESIDENT_EXT 0x8067 -#define GL_TEXTURE_1D_BINDING_EXT 0x8068 -#define GL_TEXTURE_2D_BINDING_EXT 0x8069 -#define GL_TEXTURE_3D_BINDING_EXT 0x806A -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 -#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 -#define GL_LINEAR_DETAIL_SGIS 0x8097 -#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 -#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 -#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A -#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B -#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_LINEAR_SHARPEN_SGIS 0x80AD -#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE -#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF -#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 -#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 -#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 -#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_TEXTURE_MIN_LOD_SGIS 0x813A -#define GL_TEXTURE_MAX_LOD_SGIS 0x813B -#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C -#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D -#endif - -#ifndef GL_SGIS_multisample -#define GL_MULTISAMPLE_SGIS 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F -#define GL_SAMPLE_MASK_SGIS 0x80A0 -#define GL_1PASS_SGIS 0x80A1 -#define GL_2PASS_0_SGIS 0x80A2 -#define GL_2PASS_1_SGIS 0x80A3 -#define GL_4PASS_0_SGIS 0x80A4 -#define GL_4PASS_1_SGIS 0x80A5 -#define GL_4PASS_2_SGIS 0x80A6 -#define GL_4PASS_3_SGIS 0x80A7 -#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 -#define GL_SAMPLES_SGIS 0x80A9 -#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA -#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB -#define GL_SAMPLE_PATTERN_SGIS 0x80AC -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_RESCALE_NORMAL_EXT 0x803A -#endif - -#ifndef GL_EXT_vertex_array -#define GL_VERTEX_ARRAY_EXT 0x8074 -#define GL_NORMAL_ARRAY_EXT 0x8075 -#define GL_COLOR_ARRAY_EXT 0x8076 -#define GL_INDEX_ARRAY_EXT 0x8077 -#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 -#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 -#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A -#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B -#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C -#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D -#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E -#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F -#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 -#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 -#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 -#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 -#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 -#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 -#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 -#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 -#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A -#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B -#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C -#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D -#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E -#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F -#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 -#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 -#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 -#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 -#endif - -#ifndef GL_EXT_misc_attribute -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_GENERATE_MIPMAP_SGIS 0x8191 -#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 -#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 -#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 -#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 -#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 -#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 -#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 -#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 -#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 -#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D -#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E -#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F -#endif - -#ifndef GL_SGIX_shadow -#define GL_TEXTURE_COMPARE_SGIX 0x819A -#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B -#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C -#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_CLAMP_TO_EDGE_SGIS 0x812F -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_CLAMP_TO_BORDER_SGIS 0x812D -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_FUNC_ADD_EXT 0x8006 -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#define GL_BLEND_EQUATION_EXT 0x8009 -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_FUNC_SUBTRACT_EXT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B -#endif - -#ifndef GL_EXT_blend_logic_op -#endif - -#ifndef GL_SGIX_interlace -#define GL_INTERLACE_SGIX 0x8094 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E -#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F -#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 -#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 -#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 -#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 -#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 -#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_DUAL_ALPHA4_SGIS 0x8110 -#define GL_DUAL_ALPHA8_SGIS 0x8111 -#define GL_DUAL_ALPHA12_SGIS 0x8112 -#define GL_DUAL_ALPHA16_SGIS 0x8113 -#define GL_DUAL_LUMINANCE4_SGIS 0x8114 -#define GL_DUAL_LUMINANCE8_SGIS 0x8115 -#define GL_DUAL_LUMINANCE12_SGIS 0x8116 -#define GL_DUAL_LUMINANCE16_SGIS 0x8117 -#define GL_DUAL_INTENSITY4_SGIS 0x8118 -#define GL_DUAL_INTENSITY8_SGIS 0x8119 -#define GL_DUAL_INTENSITY12_SGIS 0x811A -#define GL_DUAL_INTENSITY16_SGIS 0x811B -#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C -#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D -#define GL_QUAD_ALPHA4_SGIS 0x811E -#define GL_QUAD_ALPHA8_SGIS 0x811F -#define GL_QUAD_LUMINANCE4_SGIS 0x8120 -#define GL_QUAD_LUMINANCE8_SGIS 0x8121 -#define GL_QUAD_INTENSITY4_SGIS 0x8122 -#define GL_QUAD_INTENSITY8_SGIS 0x8123 -#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 -#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 -#endif - -#ifndef GL_SGIX_sprite -#define GL_SPRITE_SGIX 0x8148 -#define GL_SPRITE_MODE_SGIX 0x8149 -#define GL_SPRITE_AXIS_SGIX 0x814A -#define GL_SPRITE_TRANSLATION_SGIX 0x814B -#define GL_SPRITE_AXIAL_SGIX 0x814C -#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D -#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E -#endif - -#ifndef GL_EXT_point_parameters -#define GL_POINT_SIZE_MIN_EXT 0x8126 -#define GL_POINT_SIZE_MAX_EXT 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 -#define GL_DISTANCE_ATTENUATION_EXT 0x8129 -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_POINT_SIZE_MIN_SGIS 0x8126 -#define GL_POINT_SIZE_MAX_SGIS 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 -#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 -#endif - -#ifndef GL_SGIX_instruments -#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 -#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 -#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A -#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B -#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C -#endif - -#ifndef GL_SGIX_framezoom -#define GL_FRAMEZOOM_SGIX 0x818B -#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C -#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 -#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 -#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 -#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 -#define GL_DEFORMATIONS_MASK_SGIX 0x8196 -#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_REFERENCE_PLANE_SGIX 0x817D -#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E -#endif - -#ifndef GL_SGIX_flush_raster -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 -#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 -#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_FOG_FUNC_SGIS 0x812A -#define GL_FOG_FUNC_POINTS_SGIS 0x812B -#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_FOG_OFFSET_SGIX 0x8198 -#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 -#endif - -#ifndef GL_HP_image_transform -#define GL_IMAGE_SCALE_X_HP 0x8155 -#define GL_IMAGE_SCALE_Y_HP 0x8156 -#define GL_IMAGE_TRANSLATE_X_HP 0x8157 -#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 -#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 -#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A -#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B -#define GL_IMAGE_MAG_FILTER_HP 0x815C -#define GL_IMAGE_MIN_FILTER_HP 0x815D -#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E -#define GL_CUBIC_HP 0x815F -#define GL_AVERAGE_HP 0x8160 -#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 -#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 -#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_IGNORE_BORDER_HP 0x8150 -#define GL_CONSTANT_BORDER_HP 0x8151 -#define GL_REPLICATE_BORDER_HP 0x8153 -#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 -#endif - -#ifndef GL_INGR_palette_buffer -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE -#endif - -#ifndef GL_EXT_color_subtable -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_VERTEX_DATA_HINT_PGI 0x1A22A -#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B -#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C -#define GL_MAX_VERTEX_HINT_PGI 0x1A22D -#define GL_VERTEX23_BIT_PGI 0x00000004 -#define GL_VERTEX4_BIT_PGI 0x00000008 -#define GL_COLOR3_BIT_PGI 0x00010000 -#define GL_COLOR4_BIT_PGI 0x00020000 -#define GL_EDGEFLAG_BIT_PGI 0x00040000 -#define GL_INDEX_BIT_PGI 0x00080000 -#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 -#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 -#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 -#define GL_MAT_EMISSION_BIT_PGI 0x00800000 -#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 -#define GL_MAT_SHININESS_BIT_PGI 0x02000000 -#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 -#define GL_NORMAL_BIT_PGI 0x08000000 -#define GL_TEXCOORD1_BIT_PGI 0x10000000 -#define GL_TEXCOORD2_BIT_PGI 0x20000000 -#define GL_TEXCOORD3_BIT_PGI 0x40000000 -#define GL_TEXCOORD4_BIT_PGI 0x80000000 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 -#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD -#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 -#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C -#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E -#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F -#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 -#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 -#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 -#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 -#define GL_CLIP_NEAR_HINT_PGI 0x1A220 -#define GL_CLIP_FAR_HINT_PGI 0x1A221 -#define GL_WIDE_LINE_HINT_PGI 0x1A222 -#define GL_BACK_NORMALS_HINT_PGI 0x1A223 -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_COLOR_INDEX1_EXT 0x80E2 -#define GL_COLOR_INDEX2_EXT 0x80E3 -#define GL_COLOR_INDEX4_EXT 0x80E4 -#define GL_COLOR_INDEX8_EXT 0x80E5 -#define GL_COLOR_INDEX12_EXT 0x80E6 -#define GL_COLOR_INDEX16_EXT 0x80E7 -#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_LIST_PRIORITY_SGIX 0x8182 -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_IR_INSTRUMENT1_SGIX 0x817F -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E -#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F -#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SHADOW_AMBIENT_SGIX 0x80BF -#endif - -#ifndef GL_EXT_index_texture -#endif - -#ifndef GL_EXT_index_material -#define GL_INDEX_MATERIAL_EXT 0x81B8 -#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 -#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA -#endif - -#ifndef GL_EXT_index_func -#define GL_INDEX_TEST_EXT 0x81B5 -#define GL_INDEX_TEST_FUNC_EXT 0x81B6 -#define GL_INDEX_TEST_REF_EXT 0x81B7 -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_IUI_V2F_EXT 0x81AD -#define GL_IUI_V3F_EXT 0x81AE -#define GL_IUI_N3F_V2F_EXT 0x81AF -#define GL_IUI_N3F_V3F_EXT 0x81B0 -#define GL_T2F_IUI_V2F_EXT 0x81B1 -#define GL_T2F_IUI_V3F_EXT 0x81B2 -#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 -#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 -#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_CULL_VERTEX_EXT 0x81AA -#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB -#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_YCRCB_422_SGIX 0x81BB -#define GL_YCRCB_444_SGIX 0x81BC -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 -#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 -#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 -#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 -#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 -#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 -#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 -#define GL_LIGHT_ENV_MODE_SGIX 0x8407 -#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 -#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 -#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A -#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B -#define GL_FRAGMENT_LIGHT0_SGIX 0x840C -#define GL_FRAGMENT_LIGHT1_SGIX 0x840D -#define GL_FRAGMENT_LIGHT2_SGIX 0x840E -#define GL_FRAGMENT_LIGHT3_SGIX 0x840F -#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 -#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 -#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 -#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 -#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 -#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 -#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 -#endif - -#ifndef GL_WIN_phong_shading -#define GL_PHONG_WIN 0x80EA -#define GL_PHONG_HINT_WIN 0x80EB -#endif - -#ifndef GL_WIN_specular_fog -#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC -#endif - -#ifndef GL_EXT_light_texture -#define GL_FRAGMENT_MATERIAL_EXT 0x8349 -#define GL_FRAGMENT_NORMAL_EXT 0x834A -#define GL_FRAGMENT_COLOR_EXT 0x834C -#define GL_ATTENUATION_EXT 0x834D -#define GL_SHADOW_ATTENUATION_EXT 0x834E -#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F -#define GL_TEXTURE_LIGHT_EXT 0x8350 -#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 -#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 -/* reuse GL_FRAGMENT_DEPTH_EXT */ -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_ALPHA_MIN_SGIX 0x8320 -#define GL_ALPHA_MAX_SGIX 0x8321 -#endif - -#ifndef GL_EXT_bgra -#define GL_BGR_EXT 0x80E0 -#define GL_BGRA_EXT 0x80E1 -#endif - -#ifndef GL_SGIX_async -#define GL_ASYNC_MARKER_SGIX 0x8329 -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C -#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D -#define GL_ASYNC_READ_PIXELS_SGIX 0x835E -#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F -#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 -#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_ASYNC_HISTOGRAM_SGIX 0x832C -#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D -#endif - -#ifndef GL_INTEL_texture_scissor -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 -#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 -#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 -#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 -#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 -#endif - -#ifndef GL_HP_occlusion_test -#define GL_OCCLUSION_TEST_HP 0x8165 -#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 -#define GL_PIXEL_MAG_FILTER_EXT 0x8331 -#define GL_PIXEL_MIN_FILTER_EXT 0x8332 -#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 -#define GL_CUBIC_EXT 0x8334 -#define GL_AVERAGE_EXT 0x8335 -#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 -#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 -#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 -#define GL_SINGLE_COLOR_EXT 0x81F9 -#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA -#endif - -#ifndef GL_EXT_secondary_color -#define GL_COLOR_SUM_EXT 0x8458 -#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 -#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A -#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B -#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C -#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D -#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_PERTURB_EXT 0x85AE -#define GL_TEXTURE_NORMAL_EXT 0x85AF -#endif - -#ifndef GL_EXT_multi_draw_arrays -#endif - -#ifndef GL_EXT_fog_coord -#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 -#define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 -#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 -#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 -#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 -#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 -#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 -#endif - -#ifndef GL_REND_screen_coordinates -#define GL_SCREEN_COORDINATES_REND 0x8490 -#define GL_INVERTED_SCREEN_W_REND 0x8491 -#endif - -#ifndef GL_EXT_coordinate_frame -#define GL_TANGENT_ARRAY_EXT 0x8439 -#define GL_BINORMAL_ARRAY_EXT 0x843A -#define GL_CURRENT_TANGENT_EXT 0x843B -#define GL_CURRENT_BINORMAL_EXT 0x843C -#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E -#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F -#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 -#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 -#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 -#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 -#define GL_MAP1_TANGENT_EXT 0x8444 -#define GL_MAP2_TANGENT_EXT 0x8445 -#define GL_MAP1_BINORMAL_EXT 0x8446 -#define GL_MAP2_BINORMAL_EXT 0x8447 -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_COMBINE_EXT 0x8570 -#define GL_COMBINE_RGB_EXT 0x8571 -#define GL_COMBINE_ALPHA_EXT 0x8572 -#define GL_RGB_SCALE_EXT 0x8573 -#define GL_ADD_SIGNED_EXT 0x8574 -#define GL_INTERPOLATE_EXT 0x8575 -#define GL_CONSTANT_EXT 0x8576 -#define GL_PRIMARY_COLOR_EXT 0x8577 -#define GL_PREVIOUS_EXT 0x8578 -#define GL_SOURCE0_RGB_EXT 0x8580 -#define GL_SOURCE1_RGB_EXT 0x8581 -#define GL_SOURCE2_RGB_EXT 0x8582 -#define GL_SOURCE0_ALPHA_EXT 0x8588 -#define GL_SOURCE1_ALPHA_EXT 0x8589 -#define GL_SOURCE2_ALPHA_EXT 0x858A -#define GL_OPERAND0_RGB_EXT 0x8590 -#define GL_OPERAND1_RGB_EXT 0x8591 -#define GL_OPERAND2_RGB_EXT 0x8592 -#define GL_OPERAND0_ALPHA_EXT 0x8598 -#define GL_OPERAND1_ALPHA_EXT 0x8599 -#define GL_OPERAND2_ALPHA_EXT 0x859A -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_TRANSFORM_HINT_APPLE 0x85B1 -#endif - -#ifndef GL_SUNX_constant_data -#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 -#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 -#endif - -#ifndef GL_SUN_global_alpha -#define GL_GLOBAL_ALPHA_SUN 0x81D9 -#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA -#endif - -#ifndef GL_SUN_triangle_list -#define GL_RESTART_SUN 0x0001 -#define GL_REPLACE_MIDDLE_SUN 0x0002 -#define GL_REPLACE_OLDEST_SUN 0x0003 -#define GL_TRIANGLE_LIST_SUN 0x81D7 -#define GL_REPLACEMENT_CODE_SUN 0x81D8 -#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 -#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 -#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 -#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 -#define GL_R1UI_V3F_SUN 0x85C4 -#define GL_R1UI_C4UB_V3F_SUN 0x85C5 -#define GL_R1UI_C3F_V3F_SUN 0x85C6 -#define GL_R1UI_N3F_V3F_SUN 0x85C7 -#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 -#define GL_R1UI_T2F_V3F_SUN 0x85C9 -#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA -#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB -#endif - -#ifndef GL_SUN_vertex -#endif - -#ifndef GL_EXT_blend_func_separate -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB -#endif - -#ifndef GL_INGR_color_clamp -#define GL_RED_MIN_CLAMP_INGR 0x8560 -#define GL_GREEN_MIN_CLAMP_INGR 0x8561 -#define GL_BLUE_MIN_CLAMP_INGR 0x8562 -#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 -#define GL_RED_MAX_CLAMP_INGR 0x8564 -#define GL_GREEN_MAX_CLAMP_INGR 0x8565 -#define GL_BLUE_MAX_CLAMP_INGR 0x8566 -#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 -#endif - -#ifndef GL_INGR_interlace_read -#define GL_INTERLACE_READ_INGR 0x8568 -#endif - -#ifndef GL_EXT_stencil_wrap -#define GL_INCR_WRAP_EXT 0x8507 -#define GL_DECR_WRAP_EXT 0x8508 -#endif - -#ifndef GL_EXT_422_pixels -#define GL_422_EXT 0x80CC -#define GL_422_REV_EXT 0x80CD -#define GL_422_AVERAGE_EXT 0x80CE -#define GL_422_REV_AVERAGE_EXT 0x80CF -#endif - -#ifndef GL_NV_texgen_reflection -#define GL_NORMAL_MAP_NV 0x8511 -#define GL_REFLECTION_MAP_NV 0x8512 -#endif - -#ifndef GL_EXT_texture_cube_map -#define GL_NORMAL_MAP_EXT 0x8511 -#define GL_REFLECTION_MAP_EXT 0x8512 -#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A -#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C -#endif - -#ifndef GL_SUN_convolution_border_modes -#define GL_WRAP_BORDER_SUN 0x81D4 -#endif - -#ifndef GL_EXT_texture_env_add -#endif - -#ifndef GL_EXT_texture_lod_bias -#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD -#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 -#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -#endif - -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -#ifndef GL_EXT_vertex_weighting -#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 -#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 -#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 -#define GL_MODELVIEW1_MATRIX_EXT 0x8506 -#define GL_VERTEX_WEIGHTING_EXT 0x8509 -#define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_EXT 0x850A -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F -#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 -#endif - -#ifndef GL_NV_light_max_exponent -#define GL_MAX_SHININESS_NV 0x8504 -#define GL_MAX_SPOT_EXPONENT_NV 0x8505 -#endif - -#ifndef GL_NV_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_NV 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E -#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F -#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 -#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 -#endif - -#ifndef GL_NV_register_combiners -#define GL_REGISTER_COMBINERS_NV 0x8522 -#define GL_VARIABLE_A_NV 0x8523 -#define GL_VARIABLE_B_NV 0x8524 -#define GL_VARIABLE_C_NV 0x8525 -#define GL_VARIABLE_D_NV 0x8526 -#define GL_VARIABLE_E_NV 0x8527 -#define GL_VARIABLE_F_NV 0x8528 -#define GL_VARIABLE_G_NV 0x8529 -#define GL_CONSTANT_COLOR0_NV 0x852A -#define GL_CONSTANT_COLOR1_NV 0x852B -#define GL_PRIMARY_COLOR_NV 0x852C -#define GL_SECONDARY_COLOR_NV 0x852D -#define GL_SPARE0_NV 0x852E -#define GL_SPARE1_NV 0x852F -#define GL_DISCARD_NV 0x8530 -#define GL_E_TIMES_F_NV 0x8531 -#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 -#define GL_UNSIGNED_IDENTITY_NV 0x8536 -#define GL_UNSIGNED_INVERT_NV 0x8537 -#define GL_EXPAND_NORMAL_NV 0x8538 -#define GL_EXPAND_NEGATE_NV 0x8539 -#define GL_HALF_BIAS_NORMAL_NV 0x853A -#define GL_HALF_BIAS_NEGATE_NV 0x853B -#define GL_SIGNED_IDENTITY_NV 0x853C -#define GL_SIGNED_NEGATE_NV 0x853D -#define GL_SCALE_BY_TWO_NV 0x853E -#define GL_SCALE_BY_FOUR_NV 0x853F -#define GL_SCALE_BY_ONE_HALF_NV 0x8540 -#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 -#define GL_COMBINER_INPUT_NV 0x8542 -#define GL_COMBINER_MAPPING_NV 0x8543 -#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 -#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 -#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 -#define GL_COMBINER_MUX_SUM_NV 0x8547 -#define GL_COMBINER_SCALE_NV 0x8548 -#define GL_COMBINER_BIAS_NV 0x8549 -#define GL_COMBINER_AB_OUTPUT_NV 0x854A -#define GL_COMBINER_CD_OUTPUT_NV 0x854B -#define GL_COMBINER_SUM_OUTPUT_NV 0x854C -#define GL_MAX_GENERAL_COMBINERS_NV 0x854D -#define GL_NUM_GENERAL_COMBINERS_NV 0x854E -#define GL_COLOR_SUM_CLAMP_NV 0x854F -#define GL_COMBINER0_NV 0x8550 -#define GL_COMBINER1_NV 0x8551 -#define GL_COMBINER2_NV 0x8552 -#define GL_COMBINER3_NV 0x8553 -#define GL_COMBINER4_NV 0x8554 -#define GL_COMBINER5_NV 0x8555 -#define GL_COMBINER6_NV 0x8556 -#define GL_COMBINER7_NV 0x8557 -/* reuse GL_TEXTURE0_ARB */ -/* reuse GL_TEXTURE1_ARB */ -/* reuse GL_ZERO */ -/* reuse GL_NONE */ -/* reuse GL_FOG */ -#endif - -#ifndef GL_NV_fog_distance -#define GL_FOG_DISTANCE_MODE_NV 0x855A -#define GL_EYE_RADIAL_NV 0x855B -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C -/* reuse GL_EYE_PLANE */ -#endif - -#ifndef GL_NV_texgen_emboss -#define GL_EMBOSS_LIGHT_NV 0x855D -#define GL_EMBOSS_CONSTANT_NV 0x855E -#define GL_EMBOSS_MAP_NV 0x855F -#endif - -#ifndef GL_NV_blend_square -#endif - -#ifndef GL_NV_texture_env_combine4 -#define GL_COMBINE4_NV 0x8503 -#define GL_SOURCE3_RGB_NV 0x8583 -#define GL_SOURCE3_ALPHA_NV 0x858B -#define GL_OPERAND3_RGB_NV 0x8593 -#define GL_OPERAND3_ALPHA_NV 0x859B -#endif - -#ifndef GL_MESA_resize_buffers -#endif - -#ifndef GL_MESA_window_pos -#endif - -#ifndef GL_EXT_texture_compression_s3tc -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 -#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 -#endif - -#ifndef GL_IBM_cull_vertex -#define GL_CULL_VERTEX_IBM 103050 -#endif - -#ifndef GL_IBM_multimode_draw_arrays -#endif - -#ifndef GL_IBM_vertex_array_lists -#define GL_VERTEX_ARRAY_LIST_IBM 103070 -#define GL_NORMAL_ARRAY_LIST_IBM 103071 -#define GL_COLOR_ARRAY_LIST_IBM 103072 -#define GL_INDEX_ARRAY_LIST_IBM 103073 -#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 -#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 -#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 -#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 -#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 -#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 -#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 -#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 -#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 -#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 -#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 -#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 -#endif - -#ifndef GL_SGIX_subsample -#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 -#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 -#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 -#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 -#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 -#endif - -#ifndef GL_SGIX_ycrcb_subsample -#endif - -#ifndef GL_SGIX_ycrcba -#define GL_YCRCB_SGIX 0x8318 -#define GL_YCRCBA_SGIX 0x8319 -#endif - -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 -#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 -#endif - -#ifndef GL_3DFX_multisample -#define GL_MULTISAMPLE_3DFX 0x86B2 -#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 -#define GL_SAMPLES_3DFX 0x86B4 -#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 -#endif - -#ifndef GL_3DFX_tbuffer -#endif - -#ifndef GL_EXT_multisample -#define GL_MULTISAMPLE_EXT 0x809D -#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F -#define GL_SAMPLE_MASK_EXT 0x80A0 -#define GL_1PASS_EXT 0x80A1 -#define GL_2PASS_0_EXT 0x80A2 -#define GL_2PASS_1_EXT 0x80A3 -#define GL_4PASS_0_EXT 0x80A4 -#define GL_4PASS_1_EXT 0x80A5 -#define GL_4PASS_2_EXT 0x80A6 -#define GL_4PASS_3_EXT 0x80A7 -#define GL_SAMPLE_BUFFERS_EXT 0x80A8 -#define GL_SAMPLES_EXT 0x80A9 -#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA -#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB -#define GL_SAMPLE_PATTERN_EXT 0x80AC -#define GL_MULTISAMPLE_BIT_EXT 0x20000000 -#endif - -#ifndef GL_SGIX_vertex_preclip -#define GL_VERTEX_PRECLIP_SGIX 0x83EE -#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF -#endif - -#ifndef GL_SGIX_convolution_accuracy -#define GL_CONVOLUTION_HINT_SGIX 0x8316 -#endif - -#ifndef GL_SGIX_resample -#define GL_PACK_RESAMPLE_SGIX 0x842C -#define GL_UNPACK_RESAMPLE_SGIX 0x842D -#define GL_RESAMPLE_REPLICATE_SGIX 0x842E -#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F -#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 -#endif - -#ifndef GL_SGIS_point_line_texgen -#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 -#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 -#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 -#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 -#define GL_EYE_POINT_SGIS 0x81F4 -#define GL_OBJECT_POINT_SGIS 0x81F5 -#define GL_EYE_LINE_SGIS 0x81F6 -#define GL_OBJECT_LINE_SGIS 0x81F7 -#endif - -#ifndef GL_SGIS_texture_color_mask -#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF -#endif - -#ifndef GL_EXT_texture_env_dot3 -#define GL_DOT3_RGB_EXT 0x8740 -#define GL_DOT3_RGBA_EXT 0x8741 -#endif - -#ifndef GL_ATI_texture_mirror_once -#define GL_MIRROR_CLAMP_ATI 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 -#endif - -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -#ifndef GL_IBM_static_data -#define GL_ALL_STATIC_DATA_IBM 103060 -#define GL_STATIC_VERTEX_ARRAY_IBM 103061 -#endif - -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_MIRRORED_REPEAT_IBM 0x8370 -#endif - -#ifndef GL_NV_evaluators -#define GL_EVAL_2D_NV 0x86C0 -#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 -#define GL_MAP_TESSELLATION_NV 0x86C2 -#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 -#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 -#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 -#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 -#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 -#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 -#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 -#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA -#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB -#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC -#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD -#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE -#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF -#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 -#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 -#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 -#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 -#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 -#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 -#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 -#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 -#endif - -#ifndef GL_NV_packed_depth_stencil -#define GL_DEPTH_STENCIL_NV 0x84F9 -#define GL_UNSIGNED_INT_24_8_NV 0x84FA -#endif - -#ifndef GL_NV_register_combiners2 -#define GL_PER_STAGE_CONSTANTS_NV 0x8535 -#endif - -#ifndef GL_NV_texture_compression_vtc -#endif - -#ifndef GL_NV_texture_rectangle -#define GL_TEXTURE_RECTANGLE_NV 0x84F5 -#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 -#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 -#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 -#endif - -#ifndef GL_NV_texture_shader -#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C -#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D -#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E -#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 -#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA -#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB -#define GL_DSDT_MAG_INTENSITY_NV 0x86DC -#define GL_SHADER_CONSISTENT_NV 0x86DD -#define GL_TEXTURE_SHADER_NV 0x86DE -#define GL_SHADER_OPERATION_NV 0x86DF -#define GL_CULL_MODES_NV 0x86E0 -#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 -#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 -#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 -#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 -#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 -#define GL_CONST_EYE_NV 0x86E5 -#define GL_PASS_THROUGH_NV 0x86E6 -#define GL_CULL_FRAGMENT_NV 0x86E7 -#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 -#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 -#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA -#define GL_DOT_PRODUCT_NV 0x86EC -#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED -#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE -#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 -#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 -#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 -#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 -#define GL_HILO_NV 0x86F4 -#define GL_DSDT_NV 0x86F5 -#define GL_DSDT_MAG_NV 0x86F6 -#define GL_DSDT_MAG_VIB_NV 0x86F7 -#define GL_HILO16_NV 0x86F8 -#define GL_SIGNED_HILO_NV 0x86F9 -#define GL_SIGNED_HILO16_NV 0x86FA -#define GL_SIGNED_RGBA_NV 0x86FB -#define GL_SIGNED_RGBA8_NV 0x86FC -#define GL_SIGNED_RGB_NV 0x86FE -#define GL_SIGNED_RGB8_NV 0x86FF -#define GL_SIGNED_LUMINANCE_NV 0x8701 -#define GL_SIGNED_LUMINANCE8_NV 0x8702 -#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 -#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 -#define GL_SIGNED_ALPHA_NV 0x8705 -#define GL_SIGNED_ALPHA8_NV 0x8706 -#define GL_SIGNED_INTENSITY_NV 0x8707 -#define GL_SIGNED_INTENSITY8_NV 0x8708 -#define GL_DSDT8_NV 0x8709 -#define GL_DSDT8_MAG8_NV 0x870A -#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B -#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C -#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D -#define GL_HI_SCALE_NV 0x870E -#define GL_LO_SCALE_NV 0x870F -#define GL_DS_SCALE_NV 0x8710 -#define GL_DT_SCALE_NV 0x8711 -#define GL_MAGNITUDE_SCALE_NV 0x8712 -#define GL_VIBRANCE_SCALE_NV 0x8713 -#define GL_HI_BIAS_NV 0x8714 -#define GL_LO_BIAS_NV 0x8715 -#define GL_DS_BIAS_NV 0x8716 -#define GL_DT_BIAS_NV 0x8717 -#define GL_MAGNITUDE_BIAS_NV 0x8718 -#define GL_VIBRANCE_BIAS_NV 0x8719 -#define GL_TEXTURE_BORDER_VALUES_NV 0x871A -#define GL_TEXTURE_HI_SIZE_NV 0x871B -#define GL_TEXTURE_LO_SIZE_NV 0x871C -#define GL_TEXTURE_DS_SIZE_NV 0x871D -#define GL_TEXTURE_DT_SIZE_NV 0x871E -#define GL_TEXTURE_MAG_SIZE_NV 0x871F -#endif - -#ifndef GL_NV_texture_shader2 -#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF -#endif - -#ifndef GL_NV_vertex_array_range2 -#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 -#endif - -#ifndef GL_NV_vertex_program -#define GL_VERTEX_PROGRAM_NV 0x8620 -#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 -#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 -#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 -#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 -#define GL_CURRENT_ATTRIB_NV 0x8626 -#define GL_PROGRAM_LENGTH_NV 0x8627 -#define GL_PROGRAM_STRING_NV 0x8628 -#define GL_MODELVIEW_PROJECTION_NV 0x8629 -#define GL_IDENTITY_NV 0x862A -#define GL_INVERSE_NV 0x862B -#define GL_TRANSPOSE_NV 0x862C -#define GL_INVERSE_TRANSPOSE_NV 0x862D -#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E -#define GL_MAX_TRACK_MATRICES_NV 0x862F -#define GL_MATRIX0_NV 0x8630 -#define GL_MATRIX1_NV 0x8631 -#define GL_MATRIX2_NV 0x8632 -#define GL_MATRIX3_NV 0x8633 -#define GL_MATRIX4_NV 0x8634 -#define GL_MATRIX5_NV 0x8635 -#define GL_MATRIX6_NV 0x8636 -#define GL_MATRIX7_NV 0x8637 -#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 -#define GL_CURRENT_MATRIX_NV 0x8641 -#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 -#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 -#define GL_PROGRAM_PARAMETER_NV 0x8644 -#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 -#define GL_PROGRAM_TARGET_NV 0x8646 -#define GL_PROGRAM_RESIDENT_NV 0x8647 -#define GL_TRACK_MATRIX_NV 0x8648 -#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 -#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A -#define GL_PROGRAM_ERROR_POSITION_NV 0x864B -#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 -#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 -#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 -#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 -#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 -#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 -#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 -#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 -#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 -#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 -#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A -#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B -#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C -#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D -#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E -#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F -#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 -#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 -#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 -#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 -#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 -#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 -#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 -#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 -#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 -#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 -#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A -#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B -#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C -#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D -#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E -#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F -#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 -#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 -#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 -#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 -#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 -#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 -#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 -#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 -#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 -#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 -#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A -#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B -#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C -#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D -#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E -#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F -#endif - -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 -#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A -#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B -#endif - -#ifndef GL_SGIX_scalebias_hint -#define GL_SCALEBIAS_HINT_SGIX 0x8322 -#endif - -#ifndef GL_OML_interlace -#define GL_INTERLACE_OML 0x8980 -#define GL_INTERLACE_READ_OML 0x8981 -#endif - -#ifndef GL_OML_subsample -#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 -#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 -#endif - -#ifndef GL_OML_resample -#define GL_PACK_RESAMPLE_OML 0x8984 -#define GL_UNPACK_RESAMPLE_OML 0x8985 -#define GL_RESAMPLE_REPLICATE_OML 0x8986 -#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 -#define GL_RESAMPLE_AVERAGE_OML 0x8988 -#define GL_RESAMPLE_DECIMATE_OML 0x8989 -#endif - -#ifndef GL_NV_copy_depth_to_color -#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E -#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F -#endif - -#ifndef GL_ATI_envmap_bumpmap -#define GL_BUMP_ROT_MATRIX_ATI 0x8775 -#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 -#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 -#define GL_BUMP_TEX_UNITS_ATI 0x8778 -#define GL_DUDV_ATI 0x8779 -#define GL_DU8DV8_ATI 0x877A -#define GL_BUMP_ENVMAP_ATI 0x877B -#define GL_BUMP_TARGET_ATI 0x877C -#endif - -#ifndef GL_ATI_fragment_shader -#define GL_FRAGMENT_SHADER_ATI 0x8920 -#define GL_REG_0_ATI 0x8921 -#define GL_REG_1_ATI 0x8922 -#define GL_REG_2_ATI 0x8923 -#define GL_REG_3_ATI 0x8924 -#define GL_REG_4_ATI 0x8925 -#define GL_REG_5_ATI 0x8926 -#define GL_REG_6_ATI 0x8927 -#define GL_REG_7_ATI 0x8928 -#define GL_REG_8_ATI 0x8929 -#define GL_REG_9_ATI 0x892A -#define GL_REG_10_ATI 0x892B -#define GL_REG_11_ATI 0x892C -#define GL_REG_12_ATI 0x892D -#define GL_REG_13_ATI 0x892E -#define GL_REG_14_ATI 0x892F -#define GL_REG_15_ATI 0x8930 -#define GL_REG_16_ATI 0x8931 -#define GL_REG_17_ATI 0x8932 -#define GL_REG_18_ATI 0x8933 -#define GL_REG_19_ATI 0x8934 -#define GL_REG_20_ATI 0x8935 -#define GL_REG_21_ATI 0x8936 -#define GL_REG_22_ATI 0x8937 -#define GL_REG_23_ATI 0x8938 -#define GL_REG_24_ATI 0x8939 -#define GL_REG_25_ATI 0x893A -#define GL_REG_26_ATI 0x893B -#define GL_REG_27_ATI 0x893C -#define GL_REG_28_ATI 0x893D -#define GL_REG_29_ATI 0x893E -#define GL_REG_30_ATI 0x893F -#define GL_REG_31_ATI 0x8940 -#define GL_CON_0_ATI 0x8941 -#define GL_CON_1_ATI 0x8942 -#define GL_CON_2_ATI 0x8943 -#define GL_CON_3_ATI 0x8944 -#define GL_CON_4_ATI 0x8945 -#define GL_CON_5_ATI 0x8946 -#define GL_CON_6_ATI 0x8947 -#define GL_CON_7_ATI 0x8948 -#define GL_CON_8_ATI 0x8949 -#define GL_CON_9_ATI 0x894A -#define GL_CON_10_ATI 0x894B -#define GL_CON_11_ATI 0x894C -#define GL_CON_12_ATI 0x894D -#define GL_CON_13_ATI 0x894E -#define GL_CON_14_ATI 0x894F -#define GL_CON_15_ATI 0x8950 -#define GL_CON_16_ATI 0x8951 -#define GL_CON_17_ATI 0x8952 -#define GL_CON_18_ATI 0x8953 -#define GL_CON_19_ATI 0x8954 -#define GL_CON_20_ATI 0x8955 -#define GL_CON_21_ATI 0x8956 -#define GL_CON_22_ATI 0x8957 -#define GL_CON_23_ATI 0x8958 -#define GL_CON_24_ATI 0x8959 -#define GL_CON_25_ATI 0x895A -#define GL_CON_26_ATI 0x895B -#define GL_CON_27_ATI 0x895C -#define GL_CON_28_ATI 0x895D -#define GL_CON_29_ATI 0x895E -#define GL_CON_30_ATI 0x895F -#define GL_CON_31_ATI 0x8960 -#define GL_MOV_ATI 0x8961 -#define GL_ADD_ATI 0x8963 -#define GL_MUL_ATI 0x8964 -#define GL_SUB_ATI 0x8965 -#define GL_DOT3_ATI 0x8966 -#define GL_DOT4_ATI 0x8967 -#define GL_MAD_ATI 0x8968 -#define GL_LERP_ATI 0x8969 -#define GL_CND_ATI 0x896A -#define GL_CND0_ATI 0x896B -#define GL_DOT2_ADD_ATI 0x896C -#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D -#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E -#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F -#define GL_NUM_PASSES_ATI 0x8970 -#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 -#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 -#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 -#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 -#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 -#define GL_SWIZZLE_STR_ATI 0x8976 -#define GL_SWIZZLE_STQ_ATI 0x8977 -#define GL_SWIZZLE_STR_DR_ATI 0x8978 -#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 -#define GL_SWIZZLE_STRQ_ATI 0x897A -#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B -#define GL_RED_BIT_ATI 0x00000001 -#define GL_GREEN_BIT_ATI 0x00000002 -#define GL_BLUE_BIT_ATI 0x00000004 -#define GL_2X_BIT_ATI 0x00000001 -#define GL_4X_BIT_ATI 0x00000002 -#define GL_8X_BIT_ATI 0x00000004 -#define GL_HALF_BIT_ATI 0x00000008 -#define GL_QUARTER_BIT_ATI 0x00000010 -#define GL_EIGHTH_BIT_ATI 0x00000020 -#define GL_SATURATE_BIT_ATI 0x00000040 -#define GL_COMP_BIT_ATI 0x00000002 -#define GL_NEGATE_BIT_ATI 0x00000004 -#define GL_BIAS_BIT_ATI 0x00000008 -#endif - -#ifndef GL_ATI_pn_triangles -#define GL_PN_TRIANGLES_ATI 0x87F0 -#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 -#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 -#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 -#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 -#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 -#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 -#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 -#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 -#endif - -#ifndef GL_ATI_vertex_array_object -#define GL_STATIC_ATI 0x8760 -#define GL_DYNAMIC_ATI 0x8761 -#define GL_PRESERVE_ATI 0x8762 -#define GL_DISCARD_ATI 0x8763 -#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 -#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 -#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 -#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 -#endif - -#ifndef GL_EXT_vertex_shader -#define GL_VERTEX_SHADER_EXT 0x8780 -#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 -#define GL_OP_INDEX_EXT 0x8782 -#define GL_OP_NEGATE_EXT 0x8783 -#define GL_OP_DOT3_EXT 0x8784 -#define GL_OP_DOT4_EXT 0x8785 -#define GL_OP_MUL_EXT 0x8786 -#define GL_OP_ADD_EXT 0x8787 -#define GL_OP_MADD_EXT 0x8788 -#define GL_OP_FRAC_EXT 0x8789 -#define GL_OP_MAX_EXT 0x878A -#define GL_OP_MIN_EXT 0x878B -#define GL_OP_SET_GE_EXT 0x878C -#define GL_OP_SET_LT_EXT 0x878D -#define GL_OP_CLAMP_EXT 0x878E -#define GL_OP_FLOOR_EXT 0x878F -#define GL_OP_ROUND_EXT 0x8790 -#define GL_OP_EXP_BASE_2_EXT 0x8791 -#define GL_OP_LOG_BASE_2_EXT 0x8792 -#define GL_OP_POWER_EXT 0x8793 -#define GL_OP_RECIP_EXT 0x8794 -#define GL_OP_RECIP_SQRT_EXT 0x8795 -#define GL_OP_SUB_EXT 0x8796 -#define GL_OP_CROSS_PRODUCT_EXT 0x8797 -#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 -#define GL_OP_MOV_EXT 0x8799 -#define GL_OUTPUT_VERTEX_EXT 0x879A -#define GL_OUTPUT_COLOR0_EXT 0x879B -#define GL_OUTPUT_COLOR1_EXT 0x879C -#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D -#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E -#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F -#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 -#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 -#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 -#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 -#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 -#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 -#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 -#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 -#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 -#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 -#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA -#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB -#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC -#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD -#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE -#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF -#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 -#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 -#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 -#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 -#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 -#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 -#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 -#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 -#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 -#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 -#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA -#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB -#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC -#define GL_OUTPUT_FOG_EXT 0x87BD -#define GL_SCALAR_EXT 0x87BE -#define GL_VECTOR_EXT 0x87BF -#define GL_MATRIX_EXT 0x87C0 -#define GL_VARIANT_EXT 0x87C1 -#define GL_INVARIANT_EXT 0x87C2 -#define GL_LOCAL_CONSTANT_EXT 0x87C3 -#define GL_LOCAL_EXT 0x87C4 -#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 -#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 -#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 -#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 -#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD -#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE -#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF -#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 -#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 -#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 -#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 -#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 -#define GL_X_EXT 0x87D5 -#define GL_Y_EXT 0x87D6 -#define GL_Z_EXT 0x87D7 -#define GL_W_EXT 0x87D8 -#define GL_NEGATIVE_X_EXT 0x87D9 -#define GL_NEGATIVE_Y_EXT 0x87DA -#define GL_NEGATIVE_Z_EXT 0x87DB -#define GL_NEGATIVE_W_EXT 0x87DC -#define GL_ZERO_EXT 0x87DD -#define GL_ONE_EXT 0x87DE -#define GL_NEGATIVE_ONE_EXT 0x87DF -#define GL_NORMALIZED_RANGE_EXT 0x87E0 -#define GL_FULL_RANGE_EXT 0x87E1 -#define GL_CURRENT_VERTEX_EXT 0x87E2 -#define GL_MVP_MATRIX_EXT 0x87E3 -#define GL_VARIANT_VALUE_EXT 0x87E4 -#define GL_VARIANT_DATATYPE_EXT 0x87E5 -#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 -#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 -#define GL_VARIANT_ARRAY_EXT 0x87E8 -#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 -#define GL_INVARIANT_VALUE_EXT 0x87EA -#define GL_INVARIANT_DATATYPE_EXT 0x87EB -#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC -#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED -#endif - -#ifndef GL_ATI_vertex_streams -#define GL_MAX_VERTEX_STREAMS_ATI 0x876B -#define GL_VERTEX_STREAM0_ATI 0x876C -#define GL_VERTEX_STREAM1_ATI 0x876D -#define GL_VERTEX_STREAM2_ATI 0x876E -#define GL_VERTEX_STREAM3_ATI 0x876F -#define GL_VERTEX_STREAM4_ATI 0x8770 -#define GL_VERTEX_STREAM5_ATI 0x8771 -#define GL_VERTEX_STREAM6_ATI 0x8772 -#define GL_VERTEX_STREAM7_ATI 0x8773 -#define GL_VERTEX_SOURCE_ATI 0x8774 -#endif - -#ifndef GL_ATI_element_array -#define GL_ELEMENT_ARRAY_ATI 0x8768 -#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 -#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A -#endif - -#ifndef GL_SUN_mesh_array -#define GL_QUAD_MESH_SUN 0x8614 -#define GL_TRIANGLE_MESH_SUN 0x8615 -#endif - -#ifndef GL_SUN_slice_accum -#define GL_SLICE_ACCUM_SUN 0x85CC -#endif - -#ifndef GL_NV_multisample_filter_hint -#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 -#endif - -#ifndef GL_NV_depth_clamp -#define GL_DEPTH_CLAMP_NV 0x864F -#endif - -#ifndef GL_NV_occlusion_query -#define GL_PIXEL_COUNTER_BITS_NV 0x8864 -#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 -#define GL_PIXEL_COUNT_NV 0x8866 -#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 -#endif - -#ifndef GL_NV_point_sprite -#define GL_POINT_SPRITE_NV 0x8861 -#define GL_COORD_REPLACE_NV 0x8862 -#define GL_POINT_SPRITE_R_MODE_NV 0x8863 -#endif - -#ifndef GL_NV_texture_shader3 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 -#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 -#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 -#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 -#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 -#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 -#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 -#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 -#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A -#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B -#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C -#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D -#define GL_HILO8_NV 0x885E -#define GL_SIGNED_HILO8_NV 0x885F -#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 -#endif - -#ifndef GL_NV_vertex_program1_1 -#endif - -#ifndef GL_EXT_shadow_funcs -#endif - -#ifndef GL_EXT_stencil_two_side -#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 -#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 -#endif - -#ifndef GL_ATI_text_fragment_shader -#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 -#endif - -#ifndef GL_APPLE_client_storage -#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 -#endif - -#ifndef GL_APPLE_element_array -#define GL_ELEMENT_ARRAY_APPLE 0x8A0C -#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D -#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E -#endif - -#ifndef GL_APPLE_fence -#define GL_DRAW_PIXELS_APPLE 0x8A0A -#define GL_FENCE_APPLE 0x8A0B -#endif - -#ifndef GL_APPLE_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 -#endif - -#ifndef GL_APPLE_vertex_array_range -#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D -#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E -#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F -#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 -#define GL_STORAGE_CLIENT_APPLE 0x85B4 -#define GL_STORAGE_CACHED_APPLE 0x85BE -#define GL_STORAGE_SHARED_APPLE 0x85BF -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_YCBCR_422_APPLE 0x85B9 -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -#ifndef GL_S3_s3tc -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 -#define GL_RGBA_S3TC 0x83A2 -#define GL_RGBA4_S3TC 0x83A3 -#define GL_RGBA_DXT5_S3TC 0x83A4 -#define GL_RGBA4_DXT5_S3TC 0x83A5 -#endif - -#ifndef GL_ATI_draw_buffers -#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 -#define GL_DRAW_BUFFER0_ATI 0x8825 -#define GL_DRAW_BUFFER1_ATI 0x8826 -#define GL_DRAW_BUFFER2_ATI 0x8827 -#define GL_DRAW_BUFFER3_ATI 0x8828 -#define GL_DRAW_BUFFER4_ATI 0x8829 -#define GL_DRAW_BUFFER5_ATI 0x882A -#define GL_DRAW_BUFFER6_ATI 0x882B -#define GL_DRAW_BUFFER7_ATI 0x882C -#define GL_DRAW_BUFFER8_ATI 0x882D -#define GL_DRAW_BUFFER9_ATI 0x882E -#define GL_DRAW_BUFFER10_ATI 0x882F -#define GL_DRAW_BUFFER11_ATI 0x8830 -#define GL_DRAW_BUFFER12_ATI 0x8831 -#define GL_DRAW_BUFFER13_ATI 0x8832 -#define GL_DRAW_BUFFER14_ATI 0x8833 -#define GL_DRAW_BUFFER15_ATI 0x8834 -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_RGBA_FLOAT_MODE_ATI 0x8820 -#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_MODULATE_ADD_ATI 0x8744 -#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 -#define GL_MODULATE_SUBTRACT_ATI 0x8746 -#endif - -#ifndef GL_ATI_texture_float -#define GL_RGBA_FLOAT32_ATI 0x8814 -#define GL_RGB_FLOAT32_ATI 0x8815 -#define GL_ALPHA_FLOAT32_ATI 0x8816 -#define GL_INTENSITY_FLOAT32_ATI 0x8817 -#define GL_LUMINANCE_FLOAT32_ATI 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 -#define GL_RGBA_FLOAT16_ATI 0x881A -#define GL_RGB_FLOAT16_ATI 0x881B -#define GL_ALPHA_FLOAT16_ATI 0x881C -#define GL_INTENSITY_FLOAT16_ATI 0x881D -#define GL_LUMINANCE_FLOAT16_ATI 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F -#endif - -#ifndef GL_NV_float_buffer -#define GL_FLOAT_R_NV 0x8880 -#define GL_FLOAT_RG_NV 0x8881 -#define GL_FLOAT_RGB_NV 0x8882 -#define GL_FLOAT_RGBA_NV 0x8883 -#define GL_FLOAT_R16_NV 0x8884 -#define GL_FLOAT_R32_NV 0x8885 -#define GL_FLOAT_RG16_NV 0x8886 -#define GL_FLOAT_RG32_NV 0x8887 -#define GL_FLOAT_RGB16_NV 0x8888 -#define GL_FLOAT_RGB32_NV 0x8889 -#define GL_FLOAT_RGBA16_NV 0x888A -#define GL_FLOAT_RGBA32_NV 0x888B -#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C -#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D -#define GL_FLOAT_RGBA_MODE_NV 0x888E -#endif - -#ifndef GL_NV_fragment_program -#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 -#define GL_FRAGMENT_PROGRAM_NV 0x8870 -#define GL_MAX_TEXTURE_COORDS_NV 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 -#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 -#define GL_PROGRAM_ERROR_STRING_NV 0x8874 -#endif - -#ifndef GL_NV_half_float -#define GL_HALF_FLOAT_NV 0x140B -#endif - -#ifndef GL_NV_pixel_data_range -#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 -#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 -#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A -#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B -#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C -#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D -#endif - -#ifndef GL_NV_primitive_restart -#define GL_PRIMITIVE_RESTART_NV 0x8558 -#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 -#endif - -#ifndef GL_NV_texture_expand_normal -#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F -#endif - -#ifndef GL_NV_vertex_program2 -#endif - -#ifndef GL_ATI_map_object_buffer -#endif - -#ifndef GL_ATI_separate_stencil -#define GL_STENCIL_BACK_FUNC_ATI 0x8800 -#define GL_STENCIL_BACK_FAIL_ATI 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 -#endif - -#ifndef GL_ATI_vertex_attrib_array_object -#endif - -#ifndef GL_OES_byte_coordinates -#endif - -#ifndef GL_OES_fixed_point -#define GL_FIXED_OES 0x140C -#endif - -#ifndef GL_OES_single_precision -#endif - -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -#ifndef GL_OES_query_matrix -#endif - -#ifndef GL_EXT_depth_bounds_test -#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 -#define GL_DEPTH_BOUNDS_EXT 0x8891 -#endif - -#ifndef GL_EXT_texture_mirror_clamp -#define GL_MIRROR_CLAMP_EXT 0x8742 -#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 -#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 -#endif - -#ifndef GL_EXT_blend_equation_separate -#define GL_BLEND_EQUATION_RGB_EXT 0x8009 -#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D -#endif - -#ifndef GL_MESA_pack_invert -#define GL_PACK_INVERT_MESA 0x8758 -#endif - -#ifndef GL_MESA_ycbcr_texture -#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB -#define GL_YCBCR_MESA 0x8757 -#endif - -#ifndef GL_EXT_pixel_buffer_object -#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB -#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC -#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED -#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF -#endif - -#ifndef GL_NV_fragment_program_option -#endif - -#ifndef GL_NV_fragment_program2 -#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 -#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 -#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 -#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 -#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 -#endif - -#ifndef GL_NV_vertex_program2_option -/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ -/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ -#endif - -#ifndef GL_NV_vertex_program3 -/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ -#endif - -#ifndef GL_EXT_framebuffer_object -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#endif - -#ifndef GL_GREMEDY_string_marker -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_DEPTH_STENCIL_EXT 0x84F9 -#define GL_UNSIGNED_INT_24_8_EXT 0x84FA -#define GL_DEPTH24_STENCIL8_EXT 0x88F0 -#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 -#endif - -#ifndef GL_EXT_stencil_clear_tag -#define GL_STENCIL_TAG_BITS_EXT 0x88F2 -#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 -#endif - -#ifndef GL_EXT_texture_sRGB -#define GL_SRGB_EXT 0x8C40 -#define GL_SRGB8_EXT 0x8C41 -#define GL_SRGB_ALPHA_EXT 0x8C42 -#define GL_SRGB8_ALPHA8_EXT 0x8C43 -#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 -#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 -#define GL_SLUMINANCE_EXT 0x8C46 -#define GL_SLUMINANCE8_EXT 0x8C47 -#define GL_COMPRESSED_SRGB_EXT 0x8C48 -#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 -#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A -#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B -#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E -#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F -#endif - -#ifndef GL_EXT_framebuffer_blit -#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA -#endif - -#ifndef GL_EXT_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#define GL_MAX_SAMPLES_EXT 0x8D57 -#endif - -#ifndef GL_MESAX_texture_stack -#define GL_TEXTURE_1D_STACK_MESAX 0x8759 -#define GL_TEXTURE_2D_STACK_MESAX 0x875A -#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B -#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C -#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D -#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E -#endif - -#ifndef GL_EXT_timer_query -#define GL_TIME_ELAPSED_EXT 0x88BF -#endif - -#ifndef GL_EXT_gpu_program_parameters -#endif - -#ifndef GL_APPLE_flush_buffer_range -#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 -#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 -#endif - -#ifndef GL_NV_gpu_program4 -#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 -#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 -#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 -#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 -#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 -#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 -#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 -#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 -#endif - -#ifndef GL_NV_geometry_program4 -#define GL_LINES_ADJACENCY_EXT 0x000A -#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B -#define GL_TRIANGLES_ADJACENCY_EXT 0x000C -#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D -#define GL_GEOMETRY_PROGRAM_NV 0x8C26 -#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 -#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 -#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA -#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB -#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC -#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 -#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 -#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 -#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 -#endif - -#ifndef GL_EXT_geometry_shader4 -#define GL_GEOMETRY_SHADER_EXT 0x8DD9 -/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ -/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ -/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ -/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ -#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD -#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE -#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B -#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF -#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 -#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 -/* reuse GL_LINES_ADJACENCY_EXT */ -/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ -/* reuse GL_TRIANGLES_ADJACENCY_EXT */ -/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ -/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -/* reuse GL_PROGRAM_POINT_SIZE_EXT */ -#endif - -#ifndef GL_NV_vertex_program4 -#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD -#endif - -#ifndef GL_EXT_gpu_shader4 -#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 -#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 -#define GL_SAMPLER_BUFFER_EXT 0x8DC2 -#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 -#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 -#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 -#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 -#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 -#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 -#define GL_INT_SAMPLER_1D_EXT 0x8DC9 -#define GL_INT_SAMPLER_2D_EXT 0x8DCA -#define GL_INT_SAMPLER_3D_EXT 0x8DCB -#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC -#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD -#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE -#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF -#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 -#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 -#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 -#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 -#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 -#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 -#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 -#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 -#endif - -#ifndef GL_EXT_draw_instanced -#endif - -#ifndef GL_EXT_packed_float -#define GL_R11F_G11F_B10F_EXT 0x8C3A -#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B -#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C -#endif - -#ifndef GL_EXT_texture_array -#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 -#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A -#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B -#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C -#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D -#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF -#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E -/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ -#endif - -#ifndef GL_EXT_texture_buffer_object -#define GL_TEXTURE_BUFFER_EXT 0x8C2A -#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B -#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C -#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D -#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E -#endif - -#ifndef GL_EXT_texture_compression_latc -#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 -#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 -#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 -#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 -#endif - -#ifndef GL_EXT_texture_compression_rgtc -#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB -#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC -#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD -#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE -#endif - -#ifndef GL_EXT_texture_shared_exponent -#define GL_RGB9_E5_EXT 0x8C3D -#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E -#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F -#endif - -#ifndef GL_NV_depth_buffer_float -#define GL_DEPTH_COMPONENT32F_NV 0x8DAB -#define GL_DEPTH32F_STENCIL8_NV 0x8DAC -#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD -#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF -#endif - -#ifndef GL_NV_fragment_program4 -#endif - -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB -#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 -#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 -#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 -#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA -#endif - -#ifndef GL_NV_geometry_shader4 -#endif - -#ifndef GL_NV_parameter_buffer_object -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 -#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 -#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 -#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 -#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 -#endif - -#ifndef GL_EXT_draw_buffers2 -#endif - -#ifndef GL_NV_transform_feedback -#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 -#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 -#define GL_TEXTURE_COORD_NV 0x8C79 -#define GL_CLIP_DISTANCE_NV 0x8C7A -#define GL_VERTEX_ID_NV 0x8C7B -#define GL_PRIMITIVE_ID_NV 0x8C7C -#define GL_GENERIC_ATTRIB_NV 0x8C7D -#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 -#define GL_ACTIVE_VARYINGS_NV 0x8C81 -#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 -#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 -#define GL_PRIMITIVES_GENERATED_NV 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 -#define GL_RASTERIZER_DISCARD_NV 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B -#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C -#define GL_SEPARATE_ATTRIBS_NV 0x8C8D -#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F -#define GL_LAYER_NV 0x8DAA -#define GL_NEXT_BUFFER_NV -2 -#define GL_SKIP_COMPONENTS4_NV -3 -#define GL_SKIP_COMPONENTS3_NV -4 -#define GL_SKIP_COMPONENTS2_NV -5 -#define GL_SKIP_COMPONENTS1_NV -6 -#endif - -#ifndef GL_EXT_bindable_uniform -#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 -#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 -#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 -#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED -#define GL_UNIFORM_BUFFER_EXT 0x8DEE -#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF -#endif - -#ifndef GL_EXT_texture_integer -#define GL_RGBA32UI_EXT 0x8D70 -#define GL_RGB32UI_EXT 0x8D71 -#define GL_ALPHA32UI_EXT 0x8D72 -#define GL_INTENSITY32UI_EXT 0x8D73 -#define GL_LUMINANCE32UI_EXT 0x8D74 -#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 -#define GL_RGBA16UI_EXT 0x8D76 -#define GL_RGB16UI_EXT 0x8D77 -#define GL_ALPHA16UI_EXT 0x8D78 -#define GL_INTENSITY16UI_EXT 0x8D79 -#define GL_LUMINANCE16UI_EXT 0x8D7A -#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B -#define GL_RGBA8UI_EXT 0x8D7C -#define GL_RGB8UI_EXT 0x8D7D -#define GL_ALPHA8UI_EXT 0x8D7E -#define GL_INTENSITY8UI_EXT 0x8D7F -#define GL_LUMINANCE8UI_EXT 0x8D80 -#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 -#define GL_RGBA32I_EXT 0x8D82 -#define GL_RGB32I_EXT 0x8D83 -#define GL_ALPHA32I_EXT 0x8D84 -#define GL_INTENSITY32I_EXT 0x8D85 -#define GL_LUMINANCE32I_EXT 0x8D86 -#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 -#define GL_RGBA16I_EXT 0x8D88 -#define GL_RGB16I_EXT 0x8D89 -#define GL_ALPHA16I_EXT 0x8D8A -#define GL_INTENSITY16I_EXT 0x8D8B -#define GL_LUMINANCE16I_EXT 0x8D8C -#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D -#define GL_RGBA8I_EXT 0x8D8E -#define GL_RGB8I_EXT 0x8D8F -#define GL_ALPHA8I_EXT 0x8D90 -#define GL_INTENSITY8I_EXT 0x8D91 -#define GL_LUMINANCE8I_EXT 0x8D92 -#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 -#define GL_RED_INTEGER_EXT 0x8D94 -#define GL_GREEN_INTEGER_EXT 0x8D95 -#define GL_BLUE_INTEGER_EXT 0x8D96 -#define GL_ALPHA_INTEGER_EXT 0x8D97 -#define GL_RGB_INTEGER_EXT 0x8D98 -#define GL_RGBA_INTEGER_EXT 0x8D99 -#define GL_BGR_INTEGER_EXT 0x8D9A -#define GL_BGRA_INTEGER_EXT 0x8D9B -#define GL_LUMINANCE_INTEGER_EXT 0x8D9C -#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D -#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E -#endif - -#ifndef GL_GREMEDY_frame_terminator -#endif - -#ifndef GL_NV_conditional_render -#define GL_QUERY_WAIT_NV 0x8E13 -#define GL_QUERY_NO_WAIT_NV 0x8E14 -#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 -#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 -#endif - -#ifndef GL_NV_present_video -#define GL_FRAME_NV 0x8E26 -#define GL_FIELDS_NV 0x8E27 -#define GL_CURRENT_TIME_NV 0x8E28 -#define GL_NUM_FILL_STREAMS_NV 0x8E29 -#define GL_PRESENT_TIME_NV 0x8E2A -#define GL_PRESENT_DURATION_NV 0x8E2B -#endif - -#ifndef GL_EXT_transform_feedback -#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E -#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 -#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 -#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F -#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C -#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D -#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 -#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 -#define GL_RASTERIZER_DISCARD_EXT 0x8C89 -#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B -#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 -#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 -#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F -#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 -#endif - -#ifndef GL_EXT_direct_state_access -#define GL_PROGRAM_MATRIX_EXT 0x8E2D -#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E -#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F -#endif - -#ifndef GL_EXT_vertex_array_bgra -/* reuse GL_BGRA */ -#endif - -#ifndef GL_EXT_texture_swizzle -#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 -#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 -#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 -#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 -#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 -#endif - -#ifndef GL_NV_explicit_multisample -#define GL_SAMPLE_POSITION_NV 0x8E50 -#define GL_SAMPLE_MASK_NV 0x8E51 -#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 -#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 -#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 -#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 -#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 -#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 -#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 -#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 -#endif - -#ifndef GL_NV_transform_feedback2 -#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 -#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 -#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 -#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 -#endif - -#ifndef GL_ATI_meminfo -#define GL_VBO_FREE_MEMORY_ATI 0x87FB -#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC -#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD -#endif - -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -#ifndef GL_AMD_texture_texture4 -#endif - -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_SAMPLER_BUFFER_AMD 0x9001 -#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 -#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 -#define GL_TESSELLATION_MODE_AMD 0x9004 -#define GL_TESSELLATION_FACTOR_AMD 0x9005 -#define GL_DISCRETE_AMD 0x9006 -#define GL_CONTINUOUS_AMD 0x9007 -#endif - -#ifndef GL_EXT_provoking_vertex -#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C -#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D -#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E -#define GL_PROVOKING_VERTEX_EXT 0x8E4F -#endif - -#ifndef GL_EXT_texture_snorm -#define GL_ALPHA_SNORM 0x9010 -#define GL_LUMINANCE_SNORM 0x9011 -#define GL_LUMINANCE_ALPHA_SNORM 0x9012 -#define GL_INTENSITY_SNORM 0x9013 -#define GL_ALPHA8_SNORM 0x9014 -#define GL_LUMINANCE8_SNORM 0x9015 -#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 -#define GL_INTENSITY8_SNORM 0x9017 -#define GL_ALPHA16_SNORM 0x9018 -#define GL_LUMINANCE16_SNORM 0x9019 -#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A -#define GL_INTENSITY16_SNORM 0x901B -/* reuse GL_RED_SNORM */ -/* reuse GL_RG_SNORM */ -/* reuse GL_RGB_SNORM */ -/* reuse GL_RGBA_SNORM */ -/* reuse GL_R8_SNORM */ -/* reuse GL_RG8_SNORM */ -/* reuse GL_RGB8_SNORM */ -/* reuse GL_RGBA8_SNORM */ -/* reuse GL_R16_SNORM */ -/* reuse GL_RG16_SNORM */ -/* reuse GL_RGB16_SNORM */ -/* reuse GL_RGBA16_SNORM */ -/* reuse GL_SIGNED_NORMALIZED */ -#endif - -#ifndef GL_AMD_draw_buffers_blend -#endif - -#ifndef GL_APPLE_texture_range -#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 -#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#define GL_STORAGE_PRIVATE_APPLE 0x85BD -/* reuse GL_STORAGE_CACHED_APPLE */ -/* reuse GL_STORAGE_SHARED_APPLE */ -#endif - -#ifndef GL_APPLE_float_pixels -#define GL_HALF_APPLE 0x140B -#define GL_RGBA_FLOAT32_APPLE 0x8814 -#define GL_RGB_FLOAT32_APPLE 0x8815 -#define GL_ALPHA_FLOAT32_APPLE 0x8816 -#define GL_INTENSITY_FLOAT32_APPLE 0x8817 -#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 -#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 -#define GL_RGBA_FLOAT16_APPLE 0x881A -#define GL_RGB_FLOAT16_APPLE 0x881B -#define GL_ALPHA_FLOAT16_APPLE 0x881C -#define GL_INTENSITY_FLOAT16_APPLE 0x881D -#define GL_LUMINANCE_FLOAT16_APPLE 0x881E -#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F -#define GL_COLOR_FLOAT_APPLE 0x8A0F -#endif - -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 -#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 -#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 -#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 -#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 -#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 -#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 -#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 -#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 -#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 -#endif - -#ifndef GL_APPLE_aux_depth_stencil -#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 -#endif - -#ifndef GL_APPLE_object_purgeable -#define GL_BUFFER_OBJECT_APPLE 0x85B3 -#define GL_RELEASED_APPLE 0x8A19 -#define GL_VOLATILE_APPLE 0x8A1A -#define GL_RETAINED_APPLE 0x8A1B -#define GL_UNDEFINED_APPLE 0x8A1C -#define GL_PURGEABLE_APPLE 0x8A1D -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_PACK_ROW_BYTES_APPLE 0x8A15 -#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -/* reuse GL_UNSIGNED_SHORT_8_8_APPLE */ -/* reuse GL_UNSIGNED_SHORT_8_8_REV_APPLE */ -#endif - -#ifndef GL_NV_video_capture -#define GL_VIDEO_BUFFER_NV 0x9020 -#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 -#define GL_FIELD_UPPER_NV 0x9022 -#define GL_FIELD_LOWER_NV 0x9023 -#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 -#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 -#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 -#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 -#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 -#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 -#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A -#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B -#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C -#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D -#define GL_PARTIAL_SUCCESS_NV 0x902E -#define GL_SUCCESS_NV 0x902F -#define GL_FAILURE_NV 0x9030 -#define GL_YCBYCR8_422_NV 0x9031 -#define GL_YCBAYCR8A_4224_NV 0x9032 -#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 -#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 -#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 -#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 -#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 -#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 -#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 -#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A -#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B -#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C -#endif - -#ifndef GL_NV_copy_image -#endif - -#ifndef GL_EXT_separate_shader_objects -#define GL_ACTIVE_PROGRAM_EXT 0x8B8D -#endif - -#ifndef GL_NV_parameter_buffer_object2 -#endif - -#ifndef GL_NV_shader_buffer_load -#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D -#define GL_GPU_ADDRESS_NV 0x8F34 -#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 -#endif - -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E -#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F -#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 -#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 -#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 -#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 -#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 -#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 -#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 -#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 -#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 -#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 -#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A -#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B -#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C -#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D -#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E -#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F -#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 -#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 -#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 -#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 -#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 -#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 -#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 -#endif - -#ifndef GL_NV_texture_barrier -#endif - -#ifndef GL_AMD_shader_stencil_export -#endif - -#ifndef GL_AMD_seamless_cubemap_per_texture -/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */ -#endif - -#ifndef GL_AMD_conservative_depth -#endif - -#ifndef GL_EXT_shader_image_load_store -#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 -#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 -#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A -#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B -#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C -#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D -#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E -#define GL_IMAGE_1D_EXT 0x904C -#define GL_IMAGE_2D_EXT 0x904D -#define GL_IMAGE_3D_EXT 0x904E -#define GL_IMAGE_2D_RECT_EXT 0x904F -#define GL_IMAGE_CUBE_EXT 0x9050 -#define GL_IMAGE_BUFFER_EXT 0x9051 -#define GL_IMAGE_1D_ARRAY_EXT 0x9052 -#define GL_IMAGE_2D_ARRAY_EXT 0x9053 -#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 -#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 -#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 -#define GL_INT_IMAGE_1D_EXT 0x9057 -#define GL_INT_IMAGE_2D_EXT 0x9058 -#define GL_INT_IMAGE_3D_EXT 0x9059 -#define GL_INT_IMAGE_2D_RECT_EXT 0x905A -#define GL_INT_IMAGE_CUBE_EXT 0x905B -#define GL_INT_IMAGE_BUFFER_EXT 0x905C -#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D -#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E -#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F -#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 -#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 -#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 -#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 -#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 -#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 -#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 -#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 -#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 -#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 -#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B -#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C -#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D -#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E -#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 -#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 -#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 -#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 -#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 -#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 -#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 -#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 -#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 -#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 -#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 -#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 -#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF -#endif - -#ifndef GL_EXT_vertex_attrib_64bit -/* reuse GL_DOUBLE */ -#define GL_DOUBLE_VEC2_EXT 0x8FFC -#define GL_DOUBLE_VEC3_EXT 0x8FFD -#define GL_DOUBLE_VEC4_EXT 0x8FFE -#define GL_DOUBLE_MAT2_EXT 0x8F46 -#define GL_DOUBLE_MAT3_EXT 0x8F47 -#define GL_DOUBLE_MAT4_EXT 0x8F48 -#define GL_DOUBLE_MAT2x3_EXT 0x8F49 -#define GL_DOUBLE_MAT2x4_EXT 0x8F4A -#define GL_DOUBLE_MAT3x2_EXT 0x8F4B -#define GL_DOUBLE_MAT3x4_EXT 0x8F4C -#define GL_DOUBLE_MAT4x2_EXT 0x8F4D -#define GL_DOUBLE_MAT4x3_EXT 0x8F4E -#endif - -#ifndef GL_NV_gpu_program5 -#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A -#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B -#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C -#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D -#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E -#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F -#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 -#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 -#endif - -#ifndef GL_NV_gpu_shader5 -#define GL_INT64_NV 0x140E -#define GL_UNSIGNED_INT64_NV 0x140F -#define GL_INT8_NV 0x8FE0 -#define GL_INT8_VEC2_NV 0x8FE1 -#define GL_INT8_VEC3_NV 0x8FE2 -#define GL_INT8_VEC4_NV 0x8FE3 -#define GL_INT16_NV 0x8FE4 -#define GL_INT16_VEC2_NV 0x8FE5 -#define GL_INT16_VEC3_NV 0x8FE6 -#define GL_INT16_VEC4_NV 0x8FE7 -#define GL_INT64_VEC2_NV 0x8FE9 -#define GL_INT64_VEC3_NV 0x8FEA -#define GL_INT64_VEC4_NV 0x8FEB -#define GL_UNSIGNED_INT8_NV 0x8FEC -#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED -#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE -#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF -#define GL_UNSIGNED_INT16_NV 0x8FF0 -#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 -#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 -#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 -#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 -#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 -#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 -#define GL_FLOAT16_NV 0x8FF8 -#define GL_FLOAT16_VEC2_NV 0x8FF9 -#define GL_FLOAT16_VEC3_NV 0x8FFA -#define GL_FLOAT16_VEC4_NV 0x8FFB -/* reuse GL_PATCHES */ -#endif - -#ifndef GL_NV_shader_buffer_store -#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 -/* reuse GL_READ_WRITE */ -/* reuse GL_WRITE_ONLY */ -#endif - -#ifndef GL_NV_tessellation_program5 -#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 -#define GL_TESS_CONTROL_PROGRAM_NV 0x891E -#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F -#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 -#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 -#endif - -#ifndef GL_NV_vertex_attrib_integer_64bit -/* reuse GL_INT64_NV */ -/* reuse GL_UNSIGNED_INT64_NV */ -#endif - -#ifndef GL_NV_multisample_coverage -#define GL_COLOR_SAMPLES_NV 0x8E20 -/* reuse GL_SAMPLES_ARB */ -#endif - -#ifndef GL_AMD_name_gen_delete -#define GL_DATA_BUFFER_AMD 0x9151 -#define GL_PERFORMANCE_MONITOR_AMD 0x9152 -#define GL_QUERY_OBJECT_AMD 0x9153 -#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 -#define GL_SAMPLER_OBJECT_AMD 0x9155 -#endif - -#ifndef GL_AMD_debug_output -#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 -#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 -#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 -#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 -#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 -#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 -#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 -#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A -#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B -#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C -#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D -#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E -#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F -#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 -#endif - -#ifndef GL_NV_vdpau_interop -#define GL_SURFACE_STATE_NV 0x86EB -#define GL_SURFACE_REGISTERED_NV 0x86FD -#define GL_SURFACE_MAPPED_NV 0x8700 -#define GL_WRITE_DISCARD_NV 0x88BE -#endif - -#ifndef GL_AMD_transform_feedback3_lines_triangles -#endif - -#ifndef GL_AMD_depth_clamp_separate -#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E -#define GL_DEPTH_CLAMP_FAR_AMD 0x901F -#endif - -#ifndef GL_EXT_texture_sRGB_decode -#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 -#define GL_DECODE_EXT 0x8A49 -#define GL_SKIP_DECODE_EXT 0x8A4A -#endif - -#ifndef GL_NV_texture_multisample -#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 -#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_FACTOR_MIN_AMD 0x901C -#define GL_FACTOR_MAX_AMD 0x901D -#endif - -#ifndef GL_AMD_sample_positions -#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F -#endif - -#ifndef GL_EXT_x11_sync_object -#define GL_SYNC_X11_FENCE_EXT 0x90E1 -#endif - -#ifndef GL_AMD_multi_draw_indirect -#endif - -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA -#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB -#endif - -#ifndef GL_NV_path_rendering -#define GL_PATH_FORMAT_SVG_NV 0x9070 -#define GL_PATH_FORMAT_PS_NV 0x9071 -#define GL_STANDARD_FONT_NAME_NV 0x9072 -#define GL_SYSTEM_FONT_NAME_NV 0x9073 -#define GL_FILE_NAME_NV 0x9074 -#define GL_PATH_STROKE_WIDTH_NV 0x9075 -#define GL_PATH_END_CAPS_NV 0x9076 -#define GL_PATH_INITIAL_END_CAP_NV 0x9077 -#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 -#define GL_PATH_JOIN_STYLE_NV 0x9079 -#define GL_PATH_MITER_LIMIT_NV 0x907A -#define GL_PATH_DASH_CAPS_NV 0x907B -#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C -#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D -#define GL_PATH_DASH_OFFSET_NV 0x907E -#define GL_PATH_CLIENT_LENGTH_NV 0x907F -#define GL_PATH_FILL_MODE_NV 0x9080 -#define GL_PATH_FILL_MASK_NV 0x9081 -#define GL_PATH_FILL_COVER_MODE_NV 0x9082 -#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 -#define GL_PATH_STROKE_MASK_NV 0x9084 -#define GL_COUNT_UP_NV 0x9088 -#define GL_COUNT_DOWN_NV 0x9089 -#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A -#define GL_CONVEX_HULL_NV 0x908B -#define GL_BOUNDING_BOX_NV 0x908D -#define GL_TRANSLATE_X_NV 0x908E -#define GL_TRANSLATE_Y_NV 0x908F -#define GL_TRANSLATE_2D_NV 0x9090 -#define GL_TRANSLATE_3D_NV 0x9091 -#define GL_AFFINE_2D_NV 0x9092 -#define GL_AFFINE_3D_NV 0x9094 -#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 -#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 -#define GL_UTF8_NV 0x909A -#define GL_UTF16_NV 0x909B -#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C -#define GL_PATH_COMMAND_COUNT_NV 0x909D -#define GL_PATH_COORD_COUNT_NV 0x909E -#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F -#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 -#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 -#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 -#define GL_SQUARE_NV 0x90A3 -#define GL_ROUND_NV 0x90A4 -#define GL_TRIANGULAR_NV 0x90A5 -#define GL_BEVEL_NV 0x90A6 -#define GL_MITER_REVERT_NV 0x90A7 -#define GL_MITER_TRUNCATE_NV 0x90A8 -#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 -#define GL_USE_MISSING_GLYPH_NV 0x90AA -#define GL_PATH_ERROR_POSITION_NV 0x90AB -#define GL_PATH_FOG_GEN_MODE_NV 0x90AC -#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD -#define GL_ADJACENT_PAIRS_NV 0x90AE -#define GL_FIRST_TO_REST_NV 0x90AF -#define GL_PATH_GEN_MODE_NV 0x90B0 -#define GL_PATH_GEN_COEFF_NV 0x90B1 -#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 -#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 -#define GL_PATH_STENCIL_FUNC_NV 0x90B7 -#define GL_PATH_STENCIL_REF_NV 0x90B8 -#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 -#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD -#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE -#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF -#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 -#define GL_MOVE_TO_RESETS_NV 0x90B5 -#define GL_MOVE_TO_CONTINUES_NV 0x90B6 -#define GL_CLOSE_PATH_NV 0x00 -#define GL_MOVE_TO_NV 0x02 -#define GL_RELATIVE_MOVE_TO_NV 0x03 -#define GL_LINE_TO_NV 0x04 -#define GL_RELATIVE_LINE_TO_NV 0x05 -#define GL_HORIZONTAL_LINE_TO_NV 0x06 -#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 -#define GL_VERTICAL_LINE_TO_NV 0x08 -#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 -#define GL_QUADRATIC_CURVE_TO_NV 0x0A -#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B -#define GL_CUBIC_CURVE_TO_NV 0x0C -#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D -#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E -#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F -#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 -#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 -#define GL_SMALL_CCW_ARC_TO_NV 0x12 -#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 -#define GL_SMALL_CW_ARC_TO_NV 0x14 -#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 -#define GL_LARGE_CCW_ARC_TO_NV 0x16 -#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 -#define GL_LARGE_CW_ARC_TO_NV 0x18 -#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 -#define GL_RESTART_PATH_NV 0xF0 -#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 -#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 -#define GL_RECT_NV 0xF6 -#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 -#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA -#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC -#define GL_ARC_TO_NV 0xFE -#define GL_RELATIVE_ARC_TO_NV 0xFF -#define GL_BOLD_BIT_NV 0x01 -#define GL_ITALIC_BIT_NV 0x02 -#define GL_GLYPH_WIDTH_BIT_NV 0x01 -#define GL_GLYPH_HEIGHT_BIT_NV 0x02 -#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 -#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 -#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 -#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 -#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 -#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 -#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 -#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 -#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 -#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 -#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 -#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 -#define GL_FONT_ASCENDER_BIT_NV 0x00200000 -#define GL_FONT_DESCENDER_BIT_NV 0x00400000 -#define GL_FONT_HEIGHT_BIT_NV 0x00800000 -#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 -#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 -#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 -#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 -#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 -/* reuse GL_PRIMARY_COLOR */ -/* reuse GL_PRIMARY_COLOR_NV */ -/* reuse GL_SECONDARY_COLOR_NV */ -#endif - -#ifndef GL_AMD_pinned_memory -#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 -#endif - -#ifndef GL_AMD_stencil_operation_extended -#define GL_SET_AMD 0x874A -#define GL_REPLACE_VALUE_AMD 0x874B -#define GL_STENCIL_OP_VALUE_AMD 0x874C -#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D -#endif - -#ifndef GL_AMD_vertex_shader_viewport_index -#endif - -#ifndef GL_AMD_vertex_shader_layer -#endif - -#ifndef GL_NV_bindless_texture -#endif - -#ifndef GL_NV_shader_atomic_float -#endif - -#ifndef GL_AMD_query_buffer_object -#define GL_QUERY_BUFFER_AMD 0x9192 -#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 -#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 -#endif - -#ifndef GL_NV_compute_program5 -#define GL_COMPUTE_PROGRAM_NV 0x90FB -#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC -#endif - -#ifndef GL_NV_shader_storage_buffer_object -#endif - -#ifndef GL_NV_shader_atomic_counters -#endif - -#ifndef GL_NV_deep_texture3D -#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 -#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 -#endif - -#ifndef GL_NVX_conditional_render -#endif - -#ifndef GL_AMD_sparse_texture -#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 -#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 -#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 -#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 -#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 -#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A -#define GL_MIN_SPARSE_LEVEL_AMD 0x919B -#define GL_MIN_LOD_WARNING_AMD 0x919C -#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 -#endif - -#ifndef GL_AMD_shader_trinary_minmax -#endif - -#ifndef GL_INTEL_map_texture -#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF -#define GL_LAYOUT_DEFAULT_INTEL 0 -#define GL_LAYOUT_LINEAR_INTEL 1 -#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 -#endif - -#ifndef GL_NV_draw_texture -#endif - - -/*************************************************************/ - -#include -#ifndef GL_VERSION_2_0 -/* GL type for program/shader text */ -typedef char GLchar; -#endif - -#ifndef GL_VERSION_1_5 -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptr; -typedef ptrdiff_t GLsizeiptr; -#endif - -#ifndef GL_ARB_vertex_buffer_object -/* GL types for handling large vertex buffer objects */ -typedef ptrdiff_t GLintptrARB; -typedef ptrdiff_t GLsizeiptrARB; -#endif - -#ifndef GL_ARB_shader_objects -/* GL types for program/shader text and shader object handles */ -typedef char GLcharARB; -typedef unsigned int GLhandleARB; -#endif - -/* GL type for "half" precision (s10e5) float data in host memory */ -#ifndef GL_ARB_half_float_pixel -typedef unsigned short GLhalfARB; -#endif - -#ifndef GL_NV_half_float -typedef unsigned short GLhalfNV; -#endif - -#ifndef GLEXT_64_TYPES_DEFINED -/* This code block is duplicated in glxext.h, so must be protected */ -#define GLEXT_64_TYPES_DEFINED -/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ -/* (as used in the GL_EXT_timer_query extension). */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#include -#elif defined(__sun__) || defined(__digital__) -#include -#if defined(__STDC__) -#if defined(__arch64__) || defined(_LP64) -typedef long int int64_t; -typedef unsigned long int uint64_t; -#else -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#endif /* __arch64__ */ -#endif /* __STDC__ */ -#elif defined( __VMS ) || defined(__sgi) -#include -#elif defined(__SCO__) || defined(__USLC__) -#include -#elif defined(__UNIXOS2__) || defined(__SOL64__) -typedef long int int32_t; -typedef long long int int64_t; -typedef unsigned long long int uint64_t; -#elif defined(_WIN32) && defined(__GNUC__) -#include -#elif defined(_WIN32) -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -#else -/* Fallback if nothing above works */ -#include -#endif -#endif - -#ifndef GL_EXT_timer_query -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; -#endif - -#ifndef GL_ARB_sync -typedef int64_t GLint64; -typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; -#endif - -#ifndef GL_ARB_cl_event -/* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ -struct _cl_context; -struct _cl_event; -#endif - -#ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_KHR_debug -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); -#endif - -#ifndef GL_NV_vdpau_interop -typedef GLintptr GLvdpauSurfaceNV; -#endif - -#ifndef GL_OES_fixed_point -/* GLint must be 32 bits, a relatively safe assumption on modern CPUs */ -typedef GLint GLfixed; -#endif - -#ifndef GL_VERSION_1_2 -#define GL_VERSION_1_2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -GLAPI void APIENTRY glBlendEquation (GLenum mode); -GLAPI void APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -GLAPI void APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogram (GLenum target); -GLAPI void APIENTRY glResetMinmax (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); -#endif - -#ifndef GL_VERSION_1_3 -#define GL_VERSION_1_3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTexture (GLenum texture); -GLAPI void APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); -GLAPI void APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid *img); -GLAPI void APIENTRY glClientActiveTexture (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1d (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1f (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1i (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1s (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2d (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2f (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2i (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2s (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3d (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3f (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3i (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3s (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4d (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dv (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4f (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fv (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4i (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4iv (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4s (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4sv (GLenum target, const GLshort *v); -GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); -#endif - -#ifndef GL_VERSION_1_4 -#define GL_VERSION_1_4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -GLAPI void APIENTRY glMultiDrawArrays (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -GLAPI void APIENTRY glMultiDrawElements (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); -GLAPI void APIENTRY glPointParameterf (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfv (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glPointParameteri (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameteriv (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFogCoordf (GLfloat coord); -GLAPI void APIENTRY glFogCoordfv (const GLfloat *coord); -GLAPI void APIENTRY glFogCoordd (GLdouble coord); -GLAPI void APIENTRY glFogCoorddv (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointer (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glSecondaryColor3b (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3d (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3f (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3i (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3iv (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3s (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ub (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3ui (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3us (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glWindowPos2d (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2f (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2i (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2iv (const GLint *v); -GLAPI void APIENTRY glWindowPos2s (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2sv (const GLshort *v); -GLAPI void APIENTRY glWindowPos3d (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dv (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3f (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fv (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3i (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3iv (const GLint *v); -GLAPI void APIENTRY glWindowPos3s (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3sv (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); -#endif - -#ifndef GL_VERSION_1_5 -#define GL_VERSION_1_5 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueries (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQuery (GLuint id); -GLAPI void APIENTRY glBeginQuery (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQuery (GLenum target); -GLAPI void APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectiv (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); -GLAPI void APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBuffer (GLuint buffer); -GLAPI void APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBuffer (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum target); -GLAPI void APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_VERSION_2_0 -#define GL_VERSION_2_0 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GLAPI void APIENTRY glAttachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); -GLAPI void APIENTRY glCompileShader (GLuint shader); -GLAPI GLuint APIENTRY glCreateProgram (void); -GLAPI GLuint APIENTRY glCreateShader (GLenum type); -GLAPI void APIENTRY glDeleteProgram (GLuint program); -GLAPI void APIENTRY glDeleteShader (GLuint shader); -GLAPI void APIENTRY glDetachShader (GLuint program, GLuint shader); -GLAPI void APIENTRY glDisableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glEnableVertexAttribArray (GLuint index); -GLAPI void APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -GLAPI GLint APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -GLAPI void APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -GLAPI GLint APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdv (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgram (GLuint program); -GLAPI GLboolean APIENTRY glIsShader (GLuint shader); -GLAPI void APIENTRY glLinkProgram (GLuint program); -GLAPI void APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); -GLAPI void APIENTRY glUseProgram (GLuint program); -GLAPI void APIENTRY glUniform1f (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1i (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glValidateProgram (GLuint program); -GLAPI void APIENTRY glVertexAttrib1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1s (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2s (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3s (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4Niv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4Nub (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4s (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); -typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); -typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); -typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); -typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length); -typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_VERSION_2_1 -#define GL_VERSION_2_1 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -#endif - -#ifndef GL_VERSION_3_0 -#define GL_VERSION_3_0 1 -/* OpenGL 3.0 also reuses entry points from these extensions: */ -/* ARB_framebuffer_object */ -/* ARB_map_buffer_range */ -/* ARB_vertex_array_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); -GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); -GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedback (void); -GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); -GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRender (void); -GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); -GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); -GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); -GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); -GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); -GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -GLAPI const GLubyte * APIENTRY glGetStringi (GLenum name, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* const *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); -typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); -typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); -#endif - -#ifndef GL_VERSION_3_1 -#define GL_VERSION_3_1 1 -/* OpenGL 3.1 also reuses entry points from these extensions: */ -/* ARB_copy_buffer */ -/* ARB_uniform_buffer_object */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); -GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount); -typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); -#endif - -#ifndef GL_VERSION_3_2 -#define GL_VERSION_3_2 1 -/* OpenGL 3.2 also reuses entry points from these extensions: */ -/* ARB_draw_elements_base_vertex */ -/* ARB_provoking_vertex */ -/* ARB_sync */ -/* ARB_texture_multisample */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); -GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -#endif - -#ifndef GL_VERSION_3_3 -#define GL_VERSION_3_3 1 -/* OpenGL 3.3 also reuses entry points from these extensions: */ -/* ARB_blend_func_extended */ -/* ARB_sampler_objects */ -/* ARB_explicit_attrib_location, but it has none */ -/* ARB_occlusion_query2 (no entry points) */ -/* ARB_shader_bit_encoding (no entry points) */ -/* ARB_texture_rgb10_a2ui (no entry points) */ -/* ARB_texture_swizzle (no entry points) */ -/* ARB_timer_query */ -/* ARB_vertex_type_2_10_10_10_rev */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_VERSION_4_0 -#define GL_VERSION_4_0 1 -/* OpenGL 4.0 also reuses entry points from these extensions: */ -/* ARB_texture_query_lod (no entry points) */ -/* ARB_draw_indirect */ -/* ARB_gpu_shader5 (no entry points) */ -/* ARB_gpu_shader_fp64 */ -/* ARB_shader_subroutine */ -/* ARB_tessellation_shader */ -/* ARB_texture_buffer_object_rgb32 (no entry points) */ -/* ARB_texture_cube_map_array (no entry points) */ -/* ARB_texture_gather (no entry points) */ -/* ARB_transform_feedback2 */ -/* ARB_transform_feedback3 */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShading (GLfloat value); -GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); -typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_VERSION_4_1 -#define GL_VERSION_4_1 1 -/* OpenGL 4.1 reuses entry points from these extensions: */ -/* ARB_ES2_compatibility */ -/* ARB_get_program_binary */ -/* ARB_separate_shader_objects */ -/* ARB_shader_precision (no entry points) */ -/* ARB_vertex_attrib_64bit */ -/* ARB_viewport_array */ -#endif - -#ifndef GL_VERSION_4_2 -#define GL_VERSION_4_2 1 -/* OpenGL 4.2 reuses entry points from these extensions: */ -/* ARB_base_instance */ -/* ARB_shading_language_420pack (no entry points) */ -/* ARB_transform_feedback_instanced */ -/* ARB_compressed_texture_pixel_storage (no entry points) */ -/* ARB_conservative_depth (no entry points) */ -/* ARB_internalformat_query */ -/* ARB_map_buffer_alignment (no entry points) */ -/* ARB_shader_atomic_counters */ -/* ARB_shader_image_load_store */ -/* ARB_shading_language_packing (no entry points) */ -/* ARB_texture_storage */ -#endif - -#ifndef GL_VERSION_4_3 -#define GL_VERSION_4_3 1 -/* OpenGL 4.3 reuses entry points from these extensions: */ -/* ARB_arrays_of_arrays (no entry points, GLSL only) */ -/* ARB_fragment_layer_viewport (no entry points, GLSL only) */ -/* ARB_shader_image_size (no entry points, GLSL only) */ -/* ARB_ES3_compatibility (no entry points) */ -/* ARB_clear_buffer_object */ -/* ARB_compute_shader */ -/* ARB_copy_image */ -/* KHR_debug (includes ARB_debug_output commands promoted to KHR without suffixes) */ -/* ARB_explicit_uniform_location (no entry points) */ -/* ARB_framebuffer_no_attachments */ -/* ARB_internalformat_query2 */ -/* ARB_invalidate_subdata */ -/* ARB_multi_draw_indirect */ -/* ARB_program_interface_query */ -/* ARB_robust_buffer_access_behavior (no entry points) */ -/* ARB_shader_storage_buffer_object */ -/* ARB_stencil_texturing (no entry points) */ -/* ARB_texture_buffer_range */ -/* ARB_texture_query_levels (no entry points) */ -/* ARB_texture_storage_multisample */ -/* ARB_texture_view */ -/* ARB_vertex_attrib_binding */ -#endif - -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); -GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); -GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); -GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); -GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); -GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); -GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); -GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); -GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); -GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); -GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); -GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); -GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); -GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); -GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); -#endif - -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); -GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); -GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); -#endif - -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); -#endif - -#ifndef GL_ARB_texture_env_add -#define GL_ARB_texture_env_add 1 -#endif - -#ifndef GL_ARB_texture_cube_map -#define GL_ARB_texture_cube_map 1 -#endif - -#ifndef GL_ARB_texture_compression -#define GL_ARB_texture_compression 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, GLvoid *img); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); -#endif - -#ifndef GL_ARB_texture_border_clamp -#define GL_ARB_texture_border_clamp 1 -#endif - -#ifndef GL_ARB_point_parameters -#define GL_ARB_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_ARB_vertex_blend -#define GL_ARB_vertex_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); -GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); -GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); -GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); -GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); -GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); -GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); -GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); -GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexBlendARB (GLint count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); -typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); -typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); -typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); -typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); -typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); -typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); -typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); -#endif - -#ifndef GL_ARB_matrix_palette -#define GL_ARB_matrix_palette 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); -GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); -GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); -GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); -GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); -typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); -typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_ARB_texture_env_combine -#define GL_ARB_texture_env_combine 1 -#endif - -#ifndef GL_ARB_texture_env_crossbar -#define GL_ARB_texture_env_crossbar 1 -#endif - -#ifndef GL_ARB_texture_env_dot3 -#define GL_ARB_texture_env_dot3 1 -#endif - -#ifndef GL_ARB_texture_mirrored_repeat -#define GL_ARB_texture_mirrored_repeat 1 -#endif - -#ifndef GL_ARB_depth_texture -#define GL_ARB_depth_texture 1 -#endif - -#ifndef GL_ARB_shadow -#define GL_ARB_shadow 1 -#endif - -#ifndef GL_ARB_shadow_ambient -#define GL_ARB_shadow_ambient 1 -#endif - -#ifndef GL_ARB_window_pos -#define GL_ARB_window_pos 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); -GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); -#endif - -#ifndef GL_ARB_vertex_program -#define GL_ARB_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); -GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); -GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); -typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); -#endif - -#ifndef GL_ARB_fragment_program -#define GL_ARB_fragment_program 1 -/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ -#endif - -#ifndef GL_ARB_vertex_buffer_object -#define GL_ARB_vertex_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); -GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); -GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); -GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); -GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum target, GLenum access); -GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); -GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); -typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); -typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); -typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); -typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif - -#ifndef GL_ARB_occlusion_query -#define GL_ARB_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); -GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); -GLAPI void APIENTRY glEndQueryARB (GLenum target); -GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_objects -#define GL_ARB_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); -GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); -GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); -GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); -GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); -GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); -GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); -GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); -GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); -GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); -GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); -GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); -GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); -GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); -typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); -typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); -typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); -typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); -typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); -typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); -typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); -typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); -typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); -typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); -typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); -typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); -#endif - -#ifndef GL_ARB_vertex_shader -#define GL_ARB_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); -GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); -typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); -typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); -#endif - -#ifndef GL_ARB_fragment_shader -#define GL_ARB_fragment_shader 1 -#endif - -#ifndef GL_ARB_shading_language_100 -#define GL_ARB_shading_language_100 1 -#endif - -#ifndef GL_ARB_texture_non_power_of_two -#define GL_ARB_texture_non_power_of_two 1 -#endif - -#ifndef GL_ARB_point_sprite -#define GL_ARB_point_sprite 1 -#endif - -#ifndef GL_ARB_fragment_program_shadow -#define GL_ARB_fragment_program_shadow 1 -#endif - -#ifndef GL_ARB_draw_buffers -#define GL_ARB_draw_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ARB_texture_rectangle -#define GL_ARB_texture_rectangle 1 -#endif - -#ifndef GL_ARB_color_buffer_float -#define GL_ARB_color_buffer_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); -#endif - -#ifndef GL_ARB_half_float_pixel -#define GL_ARB_half_float_pixel 1 -#endif - -#ifndef GL_ARB_texture_float -#define GL_ARB_texture_float 1 -#endif - -#ifndef GL_ARB_pixel_buffer_object -#define GL_ARB_pixel_buffer_object 1 -#endif - -#ifndef GL_ARB_depth_buffer_float -#define GL_ARB_depth_buffer_float 1 -#endif - -#ifndef GL_ARB_draw_instanced -#define GL_ARB_draw_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif - -#ifndef GL_ARB_framebuffer_object -#define GL_ARB_framebuffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmap (GLenum target); -GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -#endif - -#ifndef GL_ARB_framebuffer_sRGB -#define GL_ARB_framebuffer_sRGB 1 -#endif - -#ifndef GL_ARB_geometry_shader4 -#define GL_ARB_geometry_shader4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); -GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif - -#ifndef GL_ARB_half_float_vertex -#define GL_ARB_half_float_vertex 1 -#endif - -#ifndef GL_ARB_instanced_arrays -#define GL_ARB_instanced_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); -#endif - -#ifndef GL_ARB_map_buffer_range -#define GL_ARB_map_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); -#endif - -#ifndef GL_ARB_texture_buffer_object -#define GL_ARB_texture_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); -#endif - -#ifndef GL_ARB_texture_compression_rgtc -#define GL_ARB_texture_compression_rgtc 1 -#endif - -#ifndef GL_ARB_texture_rg -#define GL_ARB_texture_rg 1 -#endif - -#ifndef GL_ARB_vertex_array_object -#define GL_ARB_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArray (GLuint array); -GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); -#endif - -#ifndef GL_ARB_uniform_buffer_object -#define GL_ARB_uniform_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); -GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); -GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar* const *uniformNames, GLuint *uniformIndices); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); -typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); -typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); -#endif - -#ifndef GL_ARB_compatibility -#define GL_ARB_compatibility 1 -#endif - -#ifndef GL_ARB_copy_buffer -#define GL_ARB_copy_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_shader_texture_lod -#define GL_ARB_shader_texture_lod 1 -#endif - -#ifndef GL_ARB_depth_clamp -#define GL_ARB_depth_clamp 1 -#endif - -#ifndef GL_ARB_draw_elements_base_vertex -#define GL_ARB_draw_elements_base_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); -GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei drawcount, const GLint *basevertex); -#endif - -#ifndef GL_ARB_fragment_coord_conventions -#define GL_ARB_fragment_coord_conventions 1 -#endif - -#ifndef GL_ARB_provoking_vertex -#define GL_ARB_provoking_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertex (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); -#endif - -#ifndef GL_ARB_seamless_cube_map -#define GL_ARB_seamless_cube_map 1 -#endif - -#ifndef GL_ARB_sync -#define GL_ARB_sync 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); -GLAPI GLboolean APIENTRY glIsSync (GLsync sync); -GLAPI void APIENTRY glDeleteSync (GLsync sync); -GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); -GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); -typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); -typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); -typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); -typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -#endif - -#ifndef GL_ARB_texture_multisample -#define GL_ARB_texture_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask); -#endif - -#ifndef GL_ARB_vertex_array_bgra -#define GL_ARB_vertex_array_bgra 1 -#endif - -#ifndef GL_ARB_draw_buffers_blend -#define GL_ARB_draw_buffers_blend 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -#endif - -#ifndef GL_ARB_sample_shading -#define GL_ARB_sample_shading 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); -#endif - -#ifndef GL_ARB_texture_cube_map_array -#define GL_ARB_texture_cube_map_array 1 -#endif - -#ifndef GL_ARB_texture_gather -#define GL_ARB_texture_gather 1 -#endif - -#ifndef GL_ARB_texture_query_lod -#define GL_ARB_texture_query_lod 1 -#endif - -#ifndef GL_ARB_shading_language_include -#define GL_ARB_shading_language_include 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); -typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar* *path, const GLint *length); -typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); -typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_texture_compression_bptc -#define GL_ARB_texture_compression_bptc 1 -#endif - -#ifndef GL_ARB_blend_func_extended -#define GL_ARB_blend_func_extended 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); -#endif - -#ifndef GL_ARB_explicit_attrib_location -#define GL_ARB_explicit_attrib_location 1 -#endif - -#ifndef GL_ARB_occlusion_query2 -#define GL_ARB_occlusion_query2 1 -#endif - -#ifndef GL_ARB_sampler_objects -#define GL_ARB_sampler_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); -GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); -GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); -GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); -GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); -GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); -GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); -GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); -GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); -typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); -typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); -typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); -#endif - -#ifndef GL_ARB_shader_bit_encoding -#define GL_ARB_shader_bit_encoding 1 -#endif - -#ifndef GL_ARB_texture_rgb10_a2ui -#define GL_ARB_texture_rgb10_a2ui 1 -#endif - -#ifndef GL_ARB_texture_swizzle -#define GL_ARB_texture_swizzle 1 -#endif - -#ifndef GL_ARB_timer_query -#define GL_ARB_timer_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); -GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); -GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); -#endif - -#ifndef GL_ARB_vertex_type_2_10_10_10_rev -#define GL_ARB_vertex_type_2_10_10_10_rev 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); -GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); -GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); -GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); -GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); -GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); -GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); -GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); -GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); -GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); -GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); -typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); -typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); -typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); -typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); -#endif - -#ifndef GL_ARB_draw_indirect -#define GL_ARB_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const GLvoid *indirect); -GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const GLvoid *indirect); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const GLvoid *indirect); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const GLvoid *indirect); -#endif - -#ifndef GL_ARB_gpu_shader5 -#define GL_ARB_gpu_shader5 1 -#endif - -#ifndef GL_ARB_gpu_shader_fp64 -#define GL_ARB_gpu_shader_fp64 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); -GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); -typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_subroutine -#define GL_ARB_shader_subroutine 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); -GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); -GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); -typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); -#endif - -#ifndef GL_ARB_tessellation_shader -#define GL_ARB_tessellation_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); -GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); -#endif - -#ifndef GL_ARB_texture_buffer_object_rgb32 -#define GL_ARB_texture_buffer_object_rgb32 1 -#endif - -#ifndef GL_ARB_transform_feedback2 -#define GL_ARB_transform_feedback2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); -GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); -GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); -GLAPI void APIENTRY glPauseTransformFeedback (void); -GLAPI void APIENTRY glResumeTransformFeedback (void); -GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); -#endif - -#ifndef GL_ARB_transform_feedback3 -#define GL_ARB_transform_feedback3 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); -GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); -GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); -GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); -typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); -typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_ES2_compatibility -#define GL_ARB_ES2_compatibility 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReleaseShaderCompiler (void); -GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); -GLAPI void APIENTRY glClearDepthf (GLfloat d); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); -typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); -typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); -#endif - -#ifndef GL_ARB_get_program_binary -#define GL_ARB_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLsizei length); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); -#endif - -#ifndef GL_ARB_separate_shader_objects -#define GL_ARB_separate_shader_objects 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); -GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar* const *strings); -GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); -GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); -GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); -GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); -GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); -GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); -GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); -typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar* const *strings); -typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); -typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); -typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); -#endif - -#ifndef GL_ARB_vertex_attrib_64bit -#define GL_ARB_vertex_attrib_64bit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); -#endif - -#ifndef GL_ARB_viewport_array -#define GL_ARB_viewport_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); -GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); -GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); -GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); -typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); -typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); -typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); -#endif - -#ifndef GL_ARB_cl_event -#define GL_ARB_cl_event 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context * context, struct _cl_event * event, GLbitfield flags); -#endif - -#ifndef GL_ARB_debug_output -#define GL_ARB_debug_output 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -#endif - -#ifndef GL_ARB_robustness -#define GL_ARB_robustness 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); -GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); -GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); -GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); -GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); -GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); -GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); -typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); -typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); -typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); -typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); -typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); -typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); -typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *table); -typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, GLvoid *image); -typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, GLvoid *row, GLsizei columnBufSize, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, GLvoid *values); -typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img); -typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); -typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); -#endif - -#ifndef GL_ARB_shader_stencil_export -#define GL_ARB_shader_stencil_export 1 -#endif - -#ifndef GL_ARB_base_instance -#define GL_ARB_base_instance 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); -#endif - -#ifndef GL_ARB_shading_language_420pack -#define GL_ARB_shading_language_420pack 1 -#endif - -#ifndef GL_ARB_transform_feedback_instanced -#define GL_ARB_transform_feedback_instanced 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); -GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); -#endif - -#ifndef GL_ARB_compressed_texture_pixel_storage -#define GL_ARB_compressed_texture_pixel_storage 1 -#endif - -#ifndef GL_ARB_conservative_depth -#define GL_ARB_conservative_depth 1 -#endif - -#ifndef GL_ARB_internalformat_query -#define GL_ARB_internalformat_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); -#endif - -#ifndef GL_ARB_map_buffer_alignment -#define GL_ARB_map_buffer_alignment 1 -#endif - -#ifndef GL_ARB_shader_atomic_counters -#define GL_ARB_shader_atomic_counters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_shader_image_load_store -#define GL_ARB_shader_image_load_store 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); -typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); -#endif - -#ifndef GL_ARB_shading_language_packing -#define GL_ARB_shading_language_packing 1 -#endif - -#ifndef GL_ARB_texture_storage -#define GL_ARB_texture_storage 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); -#endif - -#ifndef GL_KHR_texture_compression_astc_ldr -#define GL_KHR_texture_compression_astc_ldr 1 -#endif - -#ifndef GL_KHR_debug -#define GL_KHR_debug 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); -GLAPI void APIENTRY glPopDebugGroup (void); -GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); -GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); -typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); -typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); -typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); -typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); -typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); -#endif - -#ifndef GL_ARB_arrays_of_arrays -#define GL_ARB_arrays_of_arrays 1 -#endif - -#ifndef GL_ARB_clear_buffer_object -#define GL_ARB_clear_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); -typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, GLsizeiptr offset, GLsizeiptr size, const void *data); -#endif - -#ifndef GL_ARB_compute_shader -#define GL_ARB_compute_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); -typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); -#endif - -#ifndef GL_ARB_copy_image -#define GL_ARB_copy_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); -#endif - -#ifndef GL_ARB_texture_view -#define GL_ARB_texture_view 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); -#endif - -#ifndef GL_ARB_vertex_attrib_binding -#define GL_ARB_vertex_attrib_binding 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); -GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); -typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); -#endif - -#ifndef GL_ARB_robustness_isolation -#define GL_ARB_robustness_isolation 1 -#endif - -#ifndef GL_ARB_ES3_compatibility -#define GL_ARB_ES3_compatibility 1 -#endif - -#ifndef GL_ARB_explicit_uniform_location -#define GL_ARB_explicit_uniform_location 1 -#endif - -#ifndef GL_ARB_fragment_layer_viewport -#define GL_ARB_fragment_layer_viewport 1 -#endif - -#ifndef GL_ARB_framebuffer_no_attachments -#define GL_ARB_framebuffer_no_attachments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); -GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -#endif - -#ifndef GL_ARB_internalformat_query2 -#define GL_ARB_internalformat_query2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); -#endif - -#ifndef GL_ARB_invalidate_subdata -#define GL_ARB_invalidate_subdata 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); -GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); -GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); -GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); -typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_ARB_multi_draw_indirect -#define GL_ARB_multi_draw_indirect 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); -#endif - -#ifndef GL_ARB_program_interface_query -#define GL_ARB_program_interface_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); -GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); -typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); -typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); -#endif - -#ifndef GL_ARB_robust_buffer_access_behavior -#define GL_ARB_robust_buffer_access_behavior 1 -#endif - -#ifndef GL_ARB_shader_image_size -#define GL_ARB_shader_image_size 1 -#endif - -#ifndef GL_ARB_shader_storage_buffer_object -#define GL_ARB_shader_storage_buffer_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); -#endif - -#ifndef GL_ARB_stencil_texturing -#define GL_ARB_stencil_texturing 1 -#endif - -#ifndef GL_ARB_texture_buffer_range -#define GL_ARB_texture_buffer_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); -#endif - -#ifndef GL_ARB_texture_query_levels -#define GL_ARB_texture_query_levels 1 -#endif - -#ifndef GL_ARB_texture_storage_multisample -#define GL_ARB_texture_storage_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); -typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); -#endif - -#ifndef GL_EXT_abgr -#define GL_EXT_abgr 1 -#endif - -#ifndef GL_EXT_blend_color -#define GL_EXT_blend_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -#endif - -#ifndef GL_EXT_polygon_offset -#define GL_EXT_polygon_offset 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); -#endif - -#ifndef GL_EXT_texture -#define GL_EXT_texture 1 -#endif - -#ifndef GL_EXT_texture3D -#define GL_EXT_texture3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGIS_texture_filter4 -#define GL_SGIS_texture_filter4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); -GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); -typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); -#endif - -#ifndef GL_EXT_subtexture -#define GL_EXT_subtexture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_EXT_copy_texture -#define GL_EXT_copy_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_histogram -#define GL_EXT_histogram 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); -GLAPI void APIENTRY glResetHistogramEXT (GLenum target); -GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); -typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); -#endif - -#ifndef GL_EXT_convolution -#define GL_EXT_convolution 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); -GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); -GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *image); -GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); -typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); -#endif - -#ifndef GL_SGI_color_matrix -#define GL_SGI_color_matrix 1 -#endif - -#ifndef GL_SGI_color_table -#define GL_SGI_color_table 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, GLvoid *table); -GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); -#endif - -#ifndef GL_SGIX_pixel_texture -#define GL_SGIX_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); -#endif - -#ifndef GL_SGIS_pixel_texture -#define GL_SGIS_pixel_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIS_texture4D -#define GL_SGIS_texture4D 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); -#endif - -#ifndef GL_SGI_texture_color_table -#define GL_SGI_texture_color_table 1 -#endif - -#ifndef GL_EXT_cmyka -#define GL_EXT_cmyka 1 -#endif - -#ifndef GL_EXT_texture_object -#define GL_EXT_texture_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); -GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); -GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); -GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); -GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); -GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); -typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); -#endif - -#ifndef GL_SGIS_detail_texture -#define GL_SGIS_detail_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_SGIS_sharpen_texture -#define GL_SGIS_sharpen_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); -#endif - -#ifndef GL_EXT_packed_pixels -#define GL_EXT_packed_pixels 1 -#endif - -#ifndef GL_SGIS_texture_lod -#define GL_SGIS_texture_lod 1 -#endif - -#ifndef GL_SGIS_multisample -#define GL_SGIS_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); -#endif - -#ifndef GL_EXT_rescale_normal -#define GL_EXT_rescale_normal 1 -#endif - -#ifndef GL_EXT_vertex_array -#define GL_EXT_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glArrayElementEXT (GLint i); -GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); -GLAPI void APIENTRY glGetPointervEXT (GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); -typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); -typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_misc_attribute -#define GL_EXT_misc_attribute 1 -#endif - -#ifndef GL_SGIS_generate_mipmap -#define GL_SGIS_generate_mipmap 1 -#endif - -#ifndef GL_SGIX_clipmap -#define GL_SGIX_clipmap 1 -#endif - -#ifndef GL_SGIX_shadow -#define GL_SGIX_shadow 1 -#endif - -#ifndef GL_SGIS_texture_edge_clamp -#define GL_SGIS_texture_edge_clamp 1 -#endif - -#ifndef GL_SGIS_texture_border_clamp -#define GL_SGIS_texture_border_clamp 1 -#endif - -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); -#endif - -#ifndef GL_EXT_blend_subtract -#define GL_EXT_blend_subtract 1 -#endif - -#ifndef GL_EXT_blend_logic_op -#define GL_EXT_blend_logic_op 1 -#endif - -#ifndef GL_SGIX_interlace -#define GL_SGIX_interlace 1 -#endif - -#ifndef GL_SGIX_pixel_tiles -#define GL_SGIX_pixel_tiles 1 -#endif - -#ifndef GL_SGIS_texture_select -#define GL_SGIS_texture_select 1 -/* This used to be SGIX prefix, which was an error in the header */ -#endif - -#ifndef GL_SGIX_sprite -#define GL_SGIX_sprite 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_texture_multi_buffer -#define GL_SGIX_texture_multi_buffer 1 -#endif - -#ifndef GL_EXT_point_parameters -#define GL_EXT_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIS_point_parameters -#define GL_SGIS_point_parameters 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); -GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); -#endif - -#ifndef GL_SGIX_instruments -#define GL_SGIX_instruments 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); -GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); -GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); -GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); -GLAPI void APIENTRY glStartInstrumentsSGIX (void); -GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); -typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); -typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); -typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); -typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif - -#ifndef GL_SGIX_texture_scale_bias -#define GL_SGIX_texture_scale_bias 1 -#endif - -#ifndef GL_SGIX_framezoom -#define GL_SGIX_framezoom 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); -#endif - -#ifndef GL_SGIX_tag_sample_buffer -#define GL_SGIX_tag_sample_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTagSampleBufferSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_polynomial_ffd -#define GL_SGIX_polynomial_ffd 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); -GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); -typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); -typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); -#endif - -#ifndef GL_SGIX_reference_plane -#define GL_SGIX_reference_plane 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); -#endif - -#ifndef GL_SGIX_flush_raster -#define GL_SGIX_flush_raster 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushRasterSGIX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); -#endif - -#ifndef GL_SGIX_depth_texture -#define GL_SGIX_depth_texture 1 -#endif - -#ifndef GL_SGIS_fog_function -#define GL_SGIS_fog_function 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); -GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); -typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); -#endif - -#ifndef GL_SGIX_fog_offset -#define GL_SGIX_fog_offset 1 -#endif - -#ifndef GL_HP_image_transform -#define GL_HP_image_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_HP_convolution_border_modes -#define GL_HP_convolution_border_modes 1 -#endif - -#ifndef GL_SGIX_texture_add_env -#define GL_SGIX_texture_add_env 1 -#endif - -#ifndef GL_EXT_color_subtable -#define GL_EXT_color_subtable 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); -typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif - -#ifndef GL_PGI_vertex_hints -#define GL_PGI_vertex_hints 1 -#endif - -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); -#endif - -#ifndef GL_EXT_paletted_texture -#define GL_EXT_paletted_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, GLvoid *data); -GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_clip_volume_hint -#define GL_EXT_clip_volume_hint 1 -#endif - -#ifndef GL_SGIX_list_priority -#define GL_SGIX_list_priority 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); -GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); -GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); -GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); -#endif - -#ifndef GL_SGIX_ir_instrument1 -#define GL_SGIX_ir_instrument1 1 -#endif - -#ifndef GL_SGIX_calligraphic_fragment -#define GL_SGIX_calligraphic_fragment 1 -#endif - -#ifndef GL_SGIX_texture_lod_bias -#define GL_SGIX_texture_lod_bias 1 -#endif - -#ifndef GL_SGIX_shadow_ambient -#define GL_SGIX_shadow_ambient 1 -#endif - -#ifndef GL_EXT_index_texture -#define GL_EXT_index_texture 1 -#endif - -#ifndef GL_EXT_index_material -#define GL_EXT_index_material 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_EXT_index_func -#define GL_EXT_index_func 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); -#endif - -#ifndef GL_EXT_index_array_formats -#define GL_EXT_index_array_formats 1 -#endif - -#ifndef GL_EXT_compiled_vertex_array -#define GL_EXT_compiled_vertex_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); -GLAPI void APIENTRY glUnlockArraysEXT (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); -#endif - -#ifndef GL_EXT_cull_vertex -#define GL_EXT_cull_vertex 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); -GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); -#endif - -#ifndef GL_SGIX_ycrcb -#define GL_SGIX_ycrcb 1 -#endif - -#ifndef GL_SGIX_fragment_lighting -#define GL_SGIX_fragment_lighting 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); -GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); -GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); -GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); -GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); -GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_IBM_rasterpos_clip -#define GL_IBM_rasterpos_clip 1 -#endif - -#ifndef GL_HP_texture_lighting -#define GL_HP_texture_lighting 1 -#endif - -#ifndef GL_EXT_draw_range_elements -#define GL_EXT_draw_range_elements 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); -#endif - -#ifndef GL_WIN_phong_shading -#define GL_WIN_phong_shading 1 -#endif - -#ifndef GL_WIN_specular_fog -#define GL_WIN_specular_fog 1 -#endif - -#ifndef GL_EXT_light_texture -#define GL_EXT_light_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); -GLAPI void APIENTRY glTextureLightEXT (GLenum pname); -GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); -typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); -#endif - -#ifndef GL_SGIX_blend_alpha_minmax -#define GL_SGIX_blend_alpha_minmax 1 -#endif - -#ifndef GL_EXT_bgra -#define GL_EXT_bgra 1 -#endif - -#ifndef GL_SGIX_async -#define GL_SGIX_async 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); -GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); -GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); -GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); -GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); -GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); -typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); -typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); -typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); -#endif - -#ifndef GL_SGIX_async_pixel -#define GL_SGIX_async_pixel 1 -#endif - -#ifndef GL_SGIX_async_histogram -#define GL_SGIX_async_histogram 1 -#endif - -#ifndef GL_INTEL_parallel_arrays -#define GL_INTEL_parallel_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); -#endif - -#ifndef GL_HP_occlusion_test -#define GL_HP_occlusion_test 1 -#endif - -#ifndef GL_EXT_pixel_transform -#define GL_EXT_pixel_transform 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); -#endif - -#ifndef GL_EXT_pixel_transform_color_table -#define GL_EXT_pixel_transform_color_table 1 -#endif - -#ifndef GL_EXT_shared_texture_palette -#define GL_EXT_shared_texture_palette 1 -#endif - -#ifndef GL_EXT_separate_specular_color -#define GL_EXT_separate_specular_color 1 -#endif - -#ifndef GL_EXT_secondary_color -#define GL_EXT_secondary_color 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); -GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); -GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); -GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); -GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); -GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); -GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); -GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); -GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); -GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); -GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); -GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); -GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); -GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_perturb_normal -#define GL_EXT_texture_perturb_normal 1 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_INDEX 0x8222 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_ALPHA_INTEGER 0x8D97 +typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp); +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +GLAPI void APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GLAPI void APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glEnablei (GLenum target, GLuint index); +GLAPI void APIENTRY glDisablei (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledi (GLenum target, GLuint index); +GLAPI void APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedback (void); +GLAPI void APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glClampColor (GLenum target, GLenum clamp); +GLAPI void APIENTRY glBeginConditionalRender (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRender (void); +GLAPI void APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GLAPI void APIENTRY glVertexAttribI1i (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2i (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3i (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1ui (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2ui (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3ui (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bv (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4sv (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubv (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usv (GLuint index, const GLushort *v); +GLAPI void APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocation (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1ui (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GLAPI const GLubyte *APIENTRY glGetStringi (GLenum name, GLuint index); +GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmap (GLenum target); +GLAPI void APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void *APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glBindVertexArray (GLuint array); +GLAPI void APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArray (GLuint array); #endif +#endif /* GL_VERSION_3_0 */ -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 +#ifndef GL_VERSION_3_1 +#define GL_VERSION_3_1 1 +#define GL_SAMPLER_2D_RECT 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64 +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_2D_RECT 0x8DCD +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_RECTANGLE 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM 0x8F98 +#define GL_RG16_SNORM 0x8F99 +#define GL_RGB16_SNORM 0x8F9A +#define GL_RGBA16_SNORM 0x8F9B +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART 0x8F9D +#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index); +typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC) (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLsizei *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +GLAPI void APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GLAPI void APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GLAPI void APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glPrimitiveRestartIndex (GLuint index); +GLAPI void APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GLAPI void APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformName (GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName); +GLAPI GLuint APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GLAPI void APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GLAPI void APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); #endif +#endif /* GL_VERSION_3_1 */ -#ifndef GL_EXT_fog_coord -#define GL_EXT_fog_coord 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); -GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); -GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); -GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); -GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); -typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); -typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); -typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#ifndef GL_VERSION_3_2 +#define GL_VERSION_3_2 1 +typedef struct __GLsync *GLsync; +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +/* Fallback if nothing above works */ +#include #endif - -#ifndef GL_REND_screen_coordinates -#define GL_REND_screen_coordinates 1 #endif - -#ifndef GL_EXT_coordinate_frame -#define GL_EXT_coordinate_frame 1 +typedef uint64_t GLuint64; +typedef int64_t GLint64; +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_PROGRAM_POINT_SIZE 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#define GL_DEPTH_CLAMP 0x864F +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_PROVOKING_VERTEX 0x8E4F +#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode); +typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); -GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); -GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); -GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); -GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); -GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); -GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); -GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); -GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); -GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); -GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); -GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); -GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); -GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); -GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); -GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); -GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); -GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); -typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); -typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); -typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); -typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); -typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); -typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); -typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); -typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); -typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); -typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); -typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); -#endif - -#ifndef GL_EXT_texture_env_combine -#define GL_EXT_texture_env_combine 1 -#endif - -#ifndef GL_APPLE_specular_vector -#define GL_APPLE_specular_vector 1 -#endif - -#ifndef GL_APPLE_transform_hint -#define GL_APPLE_transform_hint 1 +GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +GLAPI void APIENTRY glProvokingVertex (GLenum mode); +GLAPI GLsync APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GLAPI GLboolean APIENTRY glIsSync (GLsync sync); +GLAPI void APIENTRY glDeleteSync (GLsync sync); +GLAPI GLenum APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GLAPI void APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GLAPI void APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GLAPI void APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glTexImage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); #endif +#endif /* GL_VERSION_3_2 */ -#ifndef GL_SGIX_fog_scale -#define GL_SGIX_fog_scale 1 +#ifndef GL_VERSION_3_3 +#define GL_VERSION_3_3 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_SRC1_COLOR 0x88F9 +#define GL_ONE_MINUS_SRC1_COLOR 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46 +#define GL_TIME_ELAPSED 0x88BF +#define GL_TIMESTAMP 0x8E28 +#define GL_INT_2_10_10_10_REV 0x8D9F +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC) (GLuint id, GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC) (GLuint index, GLenum type, GLboolean normalized, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC) (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP2UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP3UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLVERTEXP4UIPROC) (GLenum type, GLuint value); +typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC) (GLenum type, const GLuint *value); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC) (GLenum texture, GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC) (GLenum texture, GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLNORMALP3UIPROC) (GLenum type, GLuint coords); +typedef void (APIENTRYP PFNGLNORMALP3UIVPROC) (GLenum type, const GLuint *coords); +typedef void (APIENTRYP PFNGLCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP3UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLCOLORP4UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLCOLORP4UIVPROC) (GLenum type, const GLuint *color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC) (GLenum type, GLuint color); +typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC) (GLenum type, const GLuint *color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindFragDataLocationIndexed (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataIndex (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GLAPI void APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GLAPI GLboolean APIENTRY glIsSampler (GLuint sampler); +GLAPI void APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GLAPI void APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GLAPI void APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GLAPI void APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GLAPI void APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GLAPI void APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GLAPI void APIENTRY glQueryCounter (GLuint id, GLenum target); +GLAPI void APIENTRY glGetQueryObjecti64v (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64v (GLuint id, GLenum pname, GLuint64 *params); +GLAPI void APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GLAPI void APIENTRY glVertexAttribP1ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP1uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP2ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP2uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP3ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP3uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexAttribP4ui (GLuint index, GLenum type, GLboolean normalized, GLuint value); +GLAPI void APIENTRY glVertexAttribP4uiv (GLuint index, GLenum type, GLboolean normalized, const GLuint *value); +GLAPI void APIENTRY glVertexP2ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP2uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP3ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP3uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glVertexP4ui (GLenum type, GLuint value); +GLAPI void APIENTRY glVertexP4uiv (GLenum type, const GLuint *value); +GLAPI void APIENTRY glTexCoordP1ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP1uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP2ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP2uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glTexCoordP4ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glTexCoordP4uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP1ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP1uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP2ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP2uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP3ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP3uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glMultiTexCoordP4ui (GLenum texture, GLenum type, GLuint coords); +GLAPI void APIENTRY glMultiTexCoordP4uiv (GLenum texture, GLenum type, const GLuint *coords); +GLAPI void APIENTRY glNormalP3ui (GLenum type, GLuint coords); +GLAPI void APIENTRY glNormalP3uiv (GLenum type, const GLuint *coords); +GLAPI void APIENTRY glColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP3uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glColorP4ui (GLenum type, GLuint color); +GLAPI void APIENTRY glColorP4uiv (GLenum type, const GLuint *color); +GLAPI void APIENTRY glSecondaryColorP3ui (GLenum type, GLuint color); +GLAPI void APIENTRY glSecondaryColorP3uiv (GLenum type, const GLuint *color); #endif +#endif /* GL_VERSION_3_3 */ -#ifndef GL_SUNX_constant_data -#define GL_SUNX_constant_data 1 +#ifndef GL_VERSION_4_0 +#define GL_VERSION_4_0 1 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_MAX_VERTEX_STREAMS 0x8E71 +#define GL_DOUBLE_VEC2 0x8FFC +#define GL_DOUBLE_VEC3 0x8FFD +#define GL_DOUBLE_VEC4 0x8FFE +#define GL_DOUBLE_MAT2 0x8F46 +#define GL_DOUBLE_MAT3 0x8F47 +#define GL_DOUBLE_MAT4 0x8F48 +#define GL_DOUBLE_MAT2x3 0x8F49 +#define GL_DOUBLE_MAT2x4 0x8F4A +#define GL_DOUBLE_MAT3x2 0x8F4B +#define GL_DOUBLE_MAT3x4 0x8F4C +#define GL_DOUBLE_MAT4x2 0x8F4D +#define GL_DOUBLE_MAT4x3 0x8F4E +#define GL_ACTIVE_SUBROUTINES 0x8DE5 +#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47 +#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48 +#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49 +#define GL_MAX_SUBROUTINES 0x8DE7 +#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8 +#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A +#define GL_COMPATIBLE_SUBROUTINES 0x8E4B +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73 +#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (APIENTRYP PFNGLUNIFORM1DPROC) (GLint location, GLdouble x); +typedef void (APIENTRYP PFNGLUNIFORM2DPROC) (GLint location, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLUNIFORM3DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLUNIFORM4DPROC) (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLUNIFORM1DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM2DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM3DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORM4DVPROC) (GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC) (GLuint program, GLint location, GLdouble *params); +typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC) (GLuint program, GLenum shadertype, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC) (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC) (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC) (GLenum shadertype, GLsizei count, const GLuint *indices); +typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC) (GLenum shadertype, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC) (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC) (GLenum pname, const GLfloat *values); +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC) (GLenum mode, GLuint id); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC) (GLenum mode, GLuint id, GLuint stream); +typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC) (GLenum target, GLuint index, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFinishTextureSUNX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +GLAPI void APIENTRY glMinSampleShading (GLfloat value); +GLAPI void APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GLAPI void APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GLAPI void APIENTRY glUniform1d (GLint location, GLdouble x); +GLAPI void APIENTRY glUniform2d (GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glUniform3d (GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glUniform4d (GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glUniform1dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform2dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform3dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniform4dv (GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix2x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix3x4dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x2dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glUniformMatrix4x3dv (GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glGetUniformdv (GLuint program, GLint location, GLdouble *params); +GLAPI GLint APIENTRY glGetSubroutineUniformLocation (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI GLuint APIENTRY glGetSubroutineIndex (GLuint program, GLenum shadertype, const GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineUniformiv (GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values); +GLAPI void APIENTRY glGetActiveSubroutineUniformName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetActiveSubroutineName (GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glUniformSubroutinesuiv (GLenum shadertype, GLsizei count, const GLuint *indices); +GLAPI void APIENTRY glGetUniformSubroutineuiv (GLenum shadertype, GLint location, GLuint *params); +GLAPI void APIENTRY glGetProgramStageiv (GLuint program, GLenum shadertype, GLenum pname, GLint *values); +GLAPI void APIENTRY glPatchParameteri (GLenum pname, GLint value); +GLAPI void APIENTRY glPatchParameterfv (GLenum pname, const GLfloat *values); +GLAPI void APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GLAPI void APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI GLboolean APIENTRY glIsTransformFeedback (GLuint id); +GLAPI void APIENTRY glPauseTransformFeedback (void); +GLAPI void APIENTRY glResumeTransformFeedback (void); +GLAPI void APIENTRY glDrawTransformFeedback (GLenum mode, GLuint id); +GLAPI void APIENTRY glDrawTransformFeedbackStream (GLenum mode, GLuint id, GLuint stream); +GLAPI void APIENTRY glBeginQueryIndexed (GLenum target, GLuint index, GLuint id); +GLAPI void APIENTRY glEndQueryIndexed (GLenum target, GLuint index); +GLAPI void APIENTRY glGetQueryIndexediv (GLenum target, GLuint index, GLenum pname, GLint *params); #endif +#endif /* GL_VERSION_4_0 */ -#ifndef GL_SUN_global_alpha -#define GL_SUN_global_alpha 1 +#ifndef GL_VERSION_4_1 +#define GL_VERSION_4_1 1 +#define GL_FIXED 0x140C +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_RGB565 0x8D62 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_MAX_VIEWPORTS 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE 0x825D +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F +#define GL_UNDEFINED_VERTEX 0x8260 +typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC) (GLuint program, GLint location, GLdouble v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC) (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC) (GLuint program, GLint location, GLsizei count, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f); +typedef void (APIENTRYP PFNGLGETFLOATI_VPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC) (GLenum target, GLuint index, GLdouble *data); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); -GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); -GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); -GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); -GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); -GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); -GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); -typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +GLAPI void APIENTRY glReleaseShaderCompiler (void); +GLAPI void APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GLAPI void APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GLAPI void APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GLAPI void APIENTRY glClearDepthf (GLfloat d); +GLAPI void APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GLAPI void APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GLAPI void APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GLAPI void APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GLAPI void APIENTRY glBindProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GLAPI void APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI GLboolean APIENTRY glIsProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1d (GLuint program, GLint location, GLdouble v0); +GLAPI void APIENTRY glProgramUniform1dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2d (GLuint program, GLint location, GLdouble v0, GLdouble v1); +GLAPI void APIENTRY glProgramUniform2dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2); +GLAPI void APIENTRY glProgramUniform3dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4d (GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3); +GLAPI void APIENTRY glProgramUniform4dv (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glValidateProgramPipeline (GLuint pipeline); +GLAPI void APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GLAPI void APIENTRY glVertexAttribL1d (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2d (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3d (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4d (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dv (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdv (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glViewportArrayv (GLuint first, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glViewportIndexedf (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GLAPI void APIENTRY glViewportIndexedfv (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glScissorArrayv (GLuint first, GLsizei count, const GLint *v); +GLAPI void APIENTRY glScissorIndexed (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GLAPI void APIENTRY glScissorIndexedv (GLuint index, const GLint *v); +GLAPI void APIENTRY glDepthRangeArrayv (GLuint first, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glDepthRangeIndexed (GLuint index, GLdouble n, GLdouble f); +GLAPI void APIENTRY glGetFloati_v (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoublei_v (GLenum target, GLuint index, GLdouble *data); #endif +#endif /* GL_VERSION_4_1 */ -#ifndef GL_SUN_triangle_list -#define GL_SUN_triangle_list 1 +#ifndef GL_VERSION_4_2 +#define GL_VERSION_4_2 1 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127 +#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128 +#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129 +#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A +#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B +#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C +#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D +#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5 +#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9 +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39 +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_1D 0x904C +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_2D_RECT 0x904F +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_IMAGE_1D_ARRAY 0x9052 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056 +#define GL_INT_IMAGE_1D 0x9057 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_2D_RECT 0x905A +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_INT_IMAGE_1D_ARRAY 0x905D +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C +#define GL_MAX_IMAGE_SAMPLES 0x906D +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei instancecount); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); -GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); -GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); -GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); -GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); -GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); -GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const GLvoid* *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params); +GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers); +GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei instancecount); +GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei instancecount); #endif +#endif /* GL_VERSION_4_2 */ -#ifndef GL_SUN_vertex -#define GL_SUN_vertex 1 +#ifndef GL_VERSION_4_3 +#define GL_VERSION_4_3 1 +typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9 +#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_INTERNALFORMAT_SUPPORTED 0x826F +#define GL_INTERNALFORMAT_PREFERRED 0x8270 +#define GL_INTERNALFORMAT_RED_SIZE 0x8271 +#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272 +#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273 +#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274 +#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275 +#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276 +#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277 +#define GL_INTERNALFORMAT_RED_TYPE 0x8278 +#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279 +#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A +#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B +#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C +#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D +#define GL_MAX_WIDTH 0x827E +#define GL_MAX_HEIGHT 0x827F +#define GL_MAX_DEPTH 0x8280 +#define GL_MAX_LAYERS 0x8281 +#define GL_MAX_COMBINED_DIMENSIONS 0x8282 +#define GL_COLOR_COMPONENTS 0x8283 +#define GL_DEPTH_COMPONENTS 0x8284 +#define GL_STENCIL_COMPONENTS 0x8285 +#define GL_COLOR_RENDERABLE 0x8286 +#define GL_DEPTH_RENDERABLE 0x8287 +#define GL_STENCIL_RENDERABLE 0x8288 +#define GL_FRAMEBUFFER_RENDERABLE 0x8289 +#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A +#define GL_FRAMEBUFFER_BLEND 0x828B +#define GL_READ_PIXELS 0x828C +#define GL_READ_PIXELS_FORMAT 0x828D +#define GL_READ_PIXELS_TYPE 0x828E +#define GL_TEXTURE_IMAGE_FORMAT 0x828F +#define GL_TEXTURE_IMAGE_TYPE 0x8290 +#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291 +#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292 +#define GL_MIPMAP 0x8293 +#define GL_MANUAL_GENERATE_MIPMAP 0x8294 +#define GL_AUTO_GENERATE_MIPMAP 0x8295 +#define GL_COLOR_ENCODING 0x8296 +#define GL_SRGB_READ 0x8297 +#define GL_SRGB_WRITE 0x8298 +#define GL_FILTER 0x829A +#define GL_VERTEX_TEXTURE 0x829B +#define GL_TESS_CONTROL_TEXTURE 0x829C +#define GL_TESS_EVALUATION_TEXTURE 0x829D +#define GL_GEOMETRY_TEXTURE 0x829E +#define GL_FRAGMENT_TEXTURE 0x829F +#define GL_COMPUTE_TEXTURE 0x82A0 +#define GL_TEXTURE_SHADOW 0x82A1 +#define GL_TEXTURE_GATHER 0x82A2 +#define GL_TEXTURE_GATHER_SHADOW 0x82A3 +#define GL_SHADER_IMAGE_LOAD 0x82A4 +#define GL_SHADER_IMAGE_STORE 0x82A5 +#define GL_SHADER_IMAGE_ATOMIC 0x82A6 +#define GL_IMAGE_TEXEL_SIZE 0x82A7 +#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8 +#define GL_IMAGE_PIXEL_FORMAT 0x82A9 +#define GL_IMAGE_PIXEL_TYPE 0x82AA +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD +#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE +#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF +#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1 +#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2 +#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3 +#define GL_CLEAR_BUFFER 0x82B4 +#define GL_TEXTURE_VIEW 0x82B5 +#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6 +#define GL_FULL_SUPPORT 0x82B7 +#define GL_CAVEAT_SUPPORT 0x82B8 +#define GL_IMAGE_CLASS_4_X_32 0x82B9 +#define GL_IMAGE_CLASS_2_X_32 0x82BA +#define GL_IMAGE_CLASS_1_X_32 0x82BB +#define GL_IMAGE_CLASS_4_X_16 0x82BC +#define GL_IMAGE_CLASS_2_X_16 0x82BD +#define GL_IMAGE_CLASS_1_X_16 0x82BE +#define GL_IMAGE_CLASS_4_X_8 0x82BF +#define GL_IMAGE_CLASS_2_X_8 0x82C0 +#define GL_IMAGE_CLASS_1_X_8 0x82C1 +#define GL_IMAGE_CLASS_11_11_10 0x82C2 +#define GL_IMAGE_CLASS_10_10_10_2 0x82C3 +#define GL_VIEW_CLASS_128_BITS 0x82C4 +#define GL_VIEW_CLASS_96_BITS 0x82C5 +#define GL_VIEW_CLASS_64_BITS 0x82C6 +#define GL_VIEW_CLASS_48_BITS 0x82C7 +#define GL_VIEW_CLASS_32_BITS 0x82C8 +#define GL_VIEW_CLASS_24_BITS 0x82C9 +#define GL_VIEW_CLASS_16_BITS 0x82CA +#define GL_VIEW_CLASS_8_BITS 0x82CB +#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC +#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD +#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE +#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF +#define GL_VIEW_CLASS_RGTC1_RED 0x82D0 +#define GL_VIEW_CLASS_RGTC2_RG 0x82D1 +#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2 +#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_VERTEX_SUBROUTINE 0x92E8 +#define GL_TESS_CONTROL_SUBROUTINE 0x92E9 +#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA +#define GL_GEOMETRY_SUBROUTINE 0x92EB +#define GL_FRAGMENT_SUBROUTINE 0x92EC +#define GL_COMPUTE_SUBROUTINE 0x92ED +#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE +#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF +#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0 +#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1 +#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2 +#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_LOCATION_INDEX 0x930F +#define GL_IS_PER_PATCH 0x92E7 +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_DISPLAY_LIST 0x82E7 +typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC) (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC) (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC) (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glClearBufferData (GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearBufferSubData (GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GLAPI void APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GLAPI void APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GLAPI void APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInternalformati64v (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params); +GLAPI void APIENTRY glInvalidateTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glInvalidateTexImage (GLuint texture, GLint level); +GLAPI void APIENTRY glInvalidateBufferSubData (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer); +GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glMultiDrawArraysIndirect (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +GLAPI void APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GLAPI GLuint APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GLAPI void APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GLAPI GLint APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI GLint APIENTRY glGetProgramResourceLocationIndex (GLuint program, GLenum programInterface, const GLchar *name); +GLAPI void APIENTRY glShaderStorageBlockBinding (GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding); +GLAPI void APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureView (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +GLAPI void APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribLFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GLAPI void APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GLAPI void APIENTRY glPopDebugGroup (void); +GLAPI void APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GLAPI void APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); #endif +#endif /* GL_VERSION_4_3 */ + +#ifndef GL_VERSION_4_4 +#define GL_VERSION_4_4 1 +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAP_PERSISTENT_BIT 0x0040 +#define GL_MAP_COHERENT_BIT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT 0x0100 +#define GL_CLIENT_STORAGE_BIT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F +#define GL_BUFFER_STORAGE_FLAGS 0x8220 +#define GL_CLEAR_TEXTURE 0x9365 +#define GL_LOCATION_COMPONENT 0x934A +#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B +#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C +#define GL_QUERY_BUFFER 0x9192 +#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000 +#define GL_QUERY_BUFFER_BINDING 0x9193 +#define GL_QUERY_RESULT_NO_WAIT 0x9194 +#define GL_MIRROR_CLAMP_TO_EDGE 0x8743 +typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC) (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +typedef void (APIENTRYP PFNGLBINDTEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC) (GLuint first, GLsizei count, const GLuint *samplers); +typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC) (GLuint first, GLsizei count, const GLuint *textures); +typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC) (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferStorage (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearTexImage (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearTexSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glBindBuffersBase (GLenum target, GLuint first, GLsizei count, const GLuint *buffers); +GLAPI void APIENTRY glBindBuffersRange (GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes); +GLAPI void APIENTRY glBindTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindSamplers (GLuint first, GLsizei count, const GLuint *samplers); +GLAPI void APIENTRY glBindImageTextures (GLuint first, GLsizei count, const GLuint *textures); +GLAPI void APIENTRY glBindVertexBuffers (GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +#endif +#endif /* GL_VERSION_4_4 */ + +#ifndef GL_VERSION_4_5 +#define GL_VERSION_4_5 1 +#define GL_CONTEXT_LOST 0x0507 +#define GL_NEGATIVE_ONE_TO_ONE 0x935E +#define GL_ZERO_TO_ONE 0x935F +#define GL_CLIP_ORIGIN 0x935C +#define GL_CLIP_DEPTH_MODE 0x935D +#define GL_QUERY_WAIT_INVERTED 0x8E17 +#define GL_QUERY_NO_WAIT_INVERTED 0x8E18 +#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19 +#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A +#define GL_MAX_CULL_DISTANCES 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA +#define GL_TEXTURE_TARGET 0x1006 +#define GL_QUERY_TARGET 0x82EA +#define GL_TEXTURE_BINDING 0x82EB +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +typedef void (APIENTRYP PFNGLCLIPCONTROLPROC) (GLenum origin, GLenum depth); +typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC) (GLuint xfb, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC) (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC) (GLuint xfb, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint *param); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC) (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC) (GLuint buffer, GLsizei size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC) (GLuint buffer, GLsizei size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizei size, const void *data); +typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERPROC) (GLuint buffer, GLenum access); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC) (GLuint buffer, GLintptr offset, GLsizei length); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC) (GLuint buffer, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizei size, void *data); +typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC) (GLuint framebuffer, GLenum buf); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC) (GLuint framebuffer, GLenum src); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC) (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC) (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC) (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC) (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC) (GLuint framebuffer, GLenum target); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC) (GLuint framebuffer, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATETEXTURESPROC) (GLenum target, GLsizei n, GLuint *textures); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC) (GLuint texture, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC) (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC) (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC) (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC) (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC) (GLuint texture, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC) (GLuint texture, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC) (GLuint unit, GLuint texture); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC) (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC) (GLuint texture, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC) (GLuint texture, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC) (GLuint texture, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC) (GLuint texture, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC) (GLuint texture, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC) (GLuint vaobj, GLuint buffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC) (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC) (GLsizei n, GLuint *samplers); +typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef void (APIENTRYP PFNGLCREATEQUERIESPROC) (GLenum target, GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC) (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNMAPDVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClipControl (GLenum origin, GLenum depth); +GLAPI void APIENTRY glCreateTransformFeedbacks (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glTransformFeedbackBufferBase (GLuint xfb, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackBufferRange (GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizei size); +GLAPI void APIENTRY glGetTransformFeedbackiv (GLuint xfb, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki_v (GLuint xfb, GLenum pname, GLuint index, GLint *param); +GLAPI void APIENTRY glGetTransformFeedbacki64_v (GLuint xfb, GLenum pname, GLuint index, GLint64 *param); +GLAPI void APIENTRY glCreateBuffers (GLsizei n, GLuint *buffers); +GLAPI void APIENTRY glNamedBufferStorage (GLuint buffer, GLsizei size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glNamedBufferData (GLuint buffer, GLsizei size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, const void *data); +GLAPI void APIENTRY glCopyNamedBufferSubData (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizei size); +GLAPI void APIENTRY glClearNamedBufferData (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubData (GLuint buffer, GLenum internalformat, GLintptr offset, GLsizei size, GLenum format, GLenum type, const void *data); +GLAPI void *APIENTRY glMapNamedBuffer (GLuint buffer, GLenum access); +GLAPI void *APIENTRY glMapNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length, GLbitfield access); +GLAPI GLboolean APIENTRY glUnmapNamedBuffer (GLuint buffer); +GLAPI void APIENTRY glFlushMappedNamedBufferRange (GLuint buffer, GLintptr offset, GLsizei length); +GLAPI void APIENTRY glGetNamedBufferParameteriv (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferParameteri64v (GLuint buffer, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetNamedBufferPointerv (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubData (GLuint buffer, GLintptr offset, GLsizei size, void *data); +GLAPI void APIENTRY glCreateFramebuffers (GLsizei n, GLuint *framebuffers); +GLAPI void APIENTRY glNamedFramebufferRenderbuffer (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glNamedFramebufferParameteri (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glNamedFramebufferTexture (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayer (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferDrawBuffer (GLuint framebuffer, GLenum buf); +GLAPI void APIENTRY glNamedFramebufferDrawBuffers (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glNamedFramebufferReadBuffer (GLuint framebuffer, GLenum src); +GLAPI void APIENTRY glInvalidateNamedFramebufferData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments); +GLAPI void APIENTRY glInvalidateNamedFramebufferSubData (GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glClearNamedFramebufferiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value); +GLAPI void APIENTRY glClearNamedFramebufferuiv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value); +GLAPI void APIENTRY glClearNamedFramebufferfv (GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value); +GLAPI void APIENTRY glClearNamedFramebufferfi (GLuint framebuffer, GLenum buffer, const GLfloat depth, GLint stencil); +GLAPI void APIENTRY glBlitNamedFramebuffer (GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatus (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glGetNamedFramebufferParameteriv (GLuint framebuffer, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameteriv (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateRenderbuffers (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glNamedRenderbufferStorage (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisample (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameteriv (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateTextures (GLenum target, GLsizei n, GLuint *textures); +GLAPI void APIENTRY glTextureBuffer (GLuint texture, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureBufferRange (GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizei size); +GLAPI void APIENTRY glTextureStorage1D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3D (GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisample (GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCompressedTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCopyTextureSubImage1D (GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTextureSubImage3D (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureParameterf (GLuint texture, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfv (GLuint texture, GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glTextureParameteri (GLuint texture, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterIiv (GLuint texture, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuiv (GLuint texture, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glTextureParameteriv (GLuint texture, GLenum pname, const GLint *param); +GLAPI void APIENTRY glGenerateTextureMipmap (GLuint texture); +GLAPI void APIENTRY glBindTextureUnit (GLuint unit, GLuint texture); +GLAPI void APIENTRY glGetTextureImage (GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureImage (GLuint texture, GLint level, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetTextureLevelParameterfv (GLuint texture, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameteriv (GLuint texture, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterfv (GLuint texture, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterIiv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuiv (GLuint texture, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetTextureParameteriv (GLuint texture, GLenum pname, GLint *params); +GLAPI void APIENTRY glCreateVertexArrays (GLsizei n, GLuint *arrays); +GLAPI void APIENTRY glDisableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glEnableVertexArrayAttrib (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glVertexArrayElementBuffer (GLuint vaobj, GLuint buffer); +GLAPI void APIENTRY glVertexArrayVertexBuffer (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexBuffers (GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides); +GLAPI void APIENTRY glVertexArrayAttribBinding (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayAttribFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribIFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayAttribLFormat (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayBindingDivisor (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glGetVertexArrayiv (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexediv (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayIndexed64iv (GLuint vaobj, GLuint index, GLenum pname, GLint64 *param); +GLAPI void APIENTRY glCreateSamplers (GLsizei n, GLuint *samplers); +GLAPI void APIENTRY glCreateProgramPipelines (GLsizei n, GLuint *pipelines); +GLAPI void APIENTRY glCreateQueries (GLenum target, GLsizei n, GLuint *ids); +GLAPI void APIENTRY glGetQueryBufferObjecti64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectui64v (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glGetQueryBufferObjectuiv (GLuint id, GLuint buffer, GLenum pname, GLintptr offset); +GLAPI void APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GLAPI void APIENTRY glGetTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetCompressedTextureSubImage (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels); +GLAPI GLenum APIENTRY glGetGraphicsResetStatus (void); +GLAPI void APIENTRY glGetnCompressedTexImage (GLenum target, GLint lod, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnTexImage (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels); +GLAPI void APIENTRY glGetnUniformdv (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnMapdv (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfv (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapiv (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfv (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuiv (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusv (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStipple (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTable (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilter (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilter (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glTextureBarrier (void); +#endif +#endif /* GL_VERSION_4_5 */ -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif +#ifndef GL_ARB_ES2_compatibility +#define GL_ARB_ES2_compatibility 1 +#endif /* GL_ARB_ES2_compatibility */ -#ifndef GL_INGR_blend_func_separate -#define GL_INGR_blend_func_separate 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); -#endif +#ifndef GL_ARB_ES3_1_compatibility +#define GL_ARB_ES3_1_compatibility 1 +#endif /* GL_ARB_ES3_1_compatibility */ -#ifndef GL_INGR_color_clamp -#define GL_INGR_color_clamp 1 -#endif +#ifndef GL_ARB_ES3_compatibility +#define GL_ARB_ES3_compatibility 1 +#endif /* GL_ARB_ES3_compatibility */ -#ifndef GL_INGR_interlace_read -#define GL_INGR_interlace_read 1 -#endif +#ifndef GL_ARB_arrays_of_arrays +#define GL_ARB_arrays_of_arrays 1 +#endif /* GL_ARB_arrays_of_arrays */ -#ifndef GL_EXT_stencil_wrap -#define GL_EXT_stencil_wrap 1 -#endif +#ifndef GL_ARB_base_instance +#define GL_ARB_base_instance 1 +#endif /* GL_ARB_base_instance */ -#ifndef GL_EXT_422_pixels -#define GL_EXT_422_pixels 1 -#endif +#ifndef GL_ARB_bindless_texture +#define GL_ARB_bindless_texture 1 +typedef uint64_t GLuint64EXT; +#define GL_UNSIGNED_INT64_ARB 0x140F +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLEARBPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEARBPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLEARBPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64ARBPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VARBPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64ARBPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VARBPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTARBPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64ARBPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VARBPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VARBPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleARB (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleARB (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentARB (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleARB (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentARB (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentARB (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64ARB (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vARB (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64ARB (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vARB (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentARB (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentARB (GLuint64 handle); +GLAPI void APIENTRY glVertexAttribL1ui64ARB (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL1ui64vARB (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLui64vARB (GLuint index, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_ARB_bindless_texture */ -#ifndef GL_NV_texgen_reflection -#define GL_NV_texgen_reflection 1 -#endif +#ifndef GL_ARB_blend_func_extended +#define GL_ARB_blend_func_extended 1 +#endif /* GL_ARB_blend_func_extended */ -#ifndef GL_SUN_convolution_border_modes -#define GL_SUN_convolution_border_modes 1 -#endif +#ifndef GL_ARB_buffer_storage +#define GL_ARB_buffer_storage 1 +#endif /* GL_ARB_buffer_storage */ -#ifndef GL_EXT_texture_env_add -#define GL_EXT_texture_env_add 1 +#ifndef GL_ARB_cl_event +#define GL_ARB_cl_event 1 +struct _cl_context; +struct _cl_event; +#define GL_SYNC_CL_EVENT_ARB 0x8240 +#define GL_SYNC_CL_EVENT_COMPLETE_ARB 0x8241 +typedef GLsync (APIENTRYP PFNGLCREATESYNCFROMCLEVENTARBPROC) (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glCreateSyncFromCLeventARB (struct _cl_context *context, struct _cl_event *event, GLbitfield flags); #endif +#endif /* GL_ARB_cl_event */ -#ifndef GL_EXT_texture_lod_bias -#define GL_EXT_texture_lod_bias 1 -#endif +#ifndef GL_ARB_clear_buffer_object +#define GL_ARB_clear_buffer_object 1 +#endif /* GL_ARB_clear_buffer_object */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif +#ifndef GL_ARB_clear_texture +#define GL_ARB_clear_texture 1 +#endif /* GL_ARB_clear_texture */ -#ifndef GL_EXT_vertex_weighting -#define GL_EXT_vertex_weighting 1 +#ifndef GL_ARB_clip_control +#define GL_ARB_clip_control 1 +#endif /* GL_ARB_clip_control */ + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); -GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); -GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #endif +#endif /* GL_ARB_color_buffer_float */ -#ifndef GL_NV_light_max_exponent -#define GL_NV_light_max_exponent 1 -#endif +#ifndef GL_ARB_compatibility +#define GL_ARB_compatibility 1 +#endif /* GL_ARB_compatibility */ -#ifndef GL_NV_vertex_array_range -#define GL_NV_vertex_array_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); -GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const GLvoid *pointer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); -#endif +#ifndef GL_ARB_compressed_texture_pixel_storage +#define GL_ARB_compressed_texture_pixel_storage 1 +#endif /* GL_ARB_compressed_texture_pixel_storage */ -#ifndef GL_NV_register_combiners -#define GL_NV_register_combiners 1 +#ifndef GL_ARB_compute_shader +#define GL_ARB_compute_shader 1 +#endif /* GL_ARB_compute_shader */ + +#ifndef GL_ARB_compute_variable_group_size +#define GL_ARB_compute_variable_group_size 1 +#define GL_MAX_COMPUTE_VARIABLE_GROUP_INVOCATIONS_ARB 0x9344 +#define GL_MAX_COMPUTE_FIXED_GROUP_INVOCATIONS_ARB 0x90EB +#define GL_MAX_COMPUTE_VARIABLE_GROUP_SIZE_ARB 0x9345 +#define GL_MAX_COMPUTE_FIXED_GROUP_SIZE_ARB 0x91BF +typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEGROUPSIZEARBPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); -GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); -GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); -typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glDispatchComputeGroupSizeARB (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z, GLuint group_size_x, GLuint group_size_y, GLuint group_size_z); #endif +#endif /* GL_ARB_compute_variable_group_size */ -#ifndef GL_NV_fog_distance -#define GL_NV_fog_distance 1 -#endif +#ifndef GL_ARB_conditional_render_inverted +#define GL_ARB_conditional_render_inverted 1 +#endif /* GL_ARB_conditional_render_inverted */ -#ifndef GL_NV_texgen_emboss -#define GL_NV_texgen_emboss 1 -#endif +#ifndef GL_ARB_conservative_depth +#define GL_ARB_conservative_depth 1 +#endif /* GL_ARB_conservative_depth */ -#ifndef GL_NV_blend_square -#define GL_NV_blend_square 1 -#endif +#ifndef GL_ARB_copy_buffer +#define GL_ARB_copy_buffer 1 +#endif /* GL_ARB_copy_buffer */ -#ifndef GL_NV_texture_env_combine4 -#define GL_NV_texture_env_combine4 1 -#endif +#ifndef GL_ARB_copy_image +#define GL_ARB_copy_image 1 +#endif /* GL_ARB_copy_image */ -#ifndef GL_MESA_resize_buffers -#define GL_MESA_resize_buffers 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glResizeBuffersMESA (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); -#endif +#ifndef GL_ARB_cull_distance +#define GL_ARB_cull_distance 1 +#endif /* GL_ARB_cull_distance */ -#ifndef GL_MESA_window_pos -#define GL_MESA_window_pos 1 +#ifndef GL_ARB_debug_output +#define GL_ARB_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_ARB 0x8245 +#define GL_DEBUG_SOURCE_API_ARB 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_ARB 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_ARB 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_ARB 0x824A +#define GL_DEBUG_SOURCE_OTHER_ARB 0x824B +#define GL_DEBUG_TYPE_ERROR_ARB 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_ARB 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_ARB 0x8250 +#define GL_DEBUG_TYPE_OTHER_ARB 0x8251 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_ARB 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_ARB 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_ARB 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_ARB 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_ARB 0x9147 +#define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 +typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); -GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); -GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); -GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); -GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); -GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); -GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); -GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); -GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); -GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); -typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); -typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif +#endif /* GL_ARB_debug_output */ + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif /* GL_ARB_depth_buffer_float */ + +#ifndef GL_ARB_depth_clamp +#define GL_ARB_depth_clamp 1 +#endif /* GL_ARB_depth_clamp */ + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif /* GL_ARB_depth_texture */ -#ifndef GL_EXT_texture_compression_s3tc -#define GL_EXT_texture_compression_s3tc 1 -#endif +#ifndef GL_ARB_derivative_control +#define GL_ARB_derivative_control 1 +#endif /* GL_ARB_derivative_control */ -#ifndef GL_IBM_cull_vertex -#define GL_IBM_cull_vertex 1 -#endif +#ifndef GL_ARB_direct_state_access +#define GL_ARB_direct_state_access 1 +#endif /* GL_ARB_direct_state_access */ -#ifndef GL_IBM_multimode_draw_arrays -#define GL_IBM_multimode_draw_arrays 1 +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); -typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glDrawBuffersARB (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ARB_draw_buffers */ -#ifndef GL_IBM_vertex_array_lists -#define GL_IBM_vertex_array_lists 1 +#ifndef GL_ARB_draw_buffers_blend +#define GL_ARB_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDEQUATIONIARBPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIARBPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLBLENDFUNCIARBPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIARBPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean* *pointer, GLint ptrstride); -GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); -typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +GLAPI void APIENTRY glBlendEquationiARB (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateiARB (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI void APIENTRY glBlendFunciARB (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateiARB (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); #endif +#endif /* GL_ARB_draw_buffers_blend */ -#ifndef GL_SGIX_subsample -#define GL_SGIX_subsample 1 -#endif +#ifndef GL_ARB_draw_elements_base_vertex +#define GL_ARB_draw_elements_base_vertex 1 +#endif /* GL_ARB_draw_elements_base_vertex */ -#ifndef GL_SGIX_ycrcba -#define GL_SGIX_ycrcba 1 -#endif +#ifndef GL_ARB_draw_indirect +#define GL_ARB_draw_indirect 1 +#endif /* GL_ARB_draw_indirect */ -#ifndef GL_SGIX_ycrcb_subsample -#define GL_SGIX_ycrcb_subsample 1 +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); #endif +#endif /* GL_ARB_draw_instanced */ -#ifndef GL_SGIX_depth_pass_instrument -#define GL_SGIX_depth_pass_instrument 1 -#endif +#ifndef GL_ARB_enhanced_layouts +#define GL_ARB_enhanced_layouts 1 +#endif /* GL_ARB_enhanced_layouts */ -#ifndef GL_3DFX_texture_compression_FXT1 -#define GL_3DFX_texture_compression_FXT1 1 -#endif +#ifndef GL_ARB_explicit_attrib_location +#define GL_ARB_explicit_attrib_location 1 +#endif /* GL_ARB_explicit_attrib_location */ -#ifndef GL_3DFX_multisample -#define GL_3DFX_multisample 1 -#endif +#ifndef GL_ARB_explicit_uniform_location +#define GL_ARB_explicit_uniform_location 1 +#endif /* GL_ARB_explicit_uniform_location */ -#ifndef GL_3DFX_tbuffer -#define GL_3DFX_tbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); -#endif +#ifndef GL_ARB_fragment_coord_conventions +#define GL_ARB_fragment_coord_conventions 1 +#endif /* GL_ARB_fragment_coord_conventions */ -#ifndef GL_EXT_multisample -#define GL_EXT_multisample 1 +#ifndef GL_ARB_fragment_layer_viewport +#define GL_ARB_fragment_layer_viewport 1 +#endif /* GL_ARB_fragment_layer_viewport */ + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, void *string); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); -GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); -typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +GLAPI void APIENTRY glProgramStringARB (GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glBindProgramARB (GLenum target, GLuint program); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glGenProgramsARB (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetProgramivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringARB (GLenum target, GLenum pname, void *string); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint program); #endif +#endif /* GL_ARB_fragment_program */ -#ifndef GL_SGIX_vertex_preclip -#define GL_SGIX_vertex_preclip 1 +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif /* GL_ARB_fragment_program_shadow */ + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif /* GL_ARB_fragment_shader */ + +#ifndef GL_ARB_framebuffer_no_attachments +#define GL_ARB_framebuffer_no_attachments 1 +#endif /* GL_ARB_framebuffer_no_attachments */ + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif /* GL_ARB_framebuffer_object */ + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif /* GL_ARB_framebuffer_sRGB */ + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriARB (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glFramebufferTextureARB (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); #endif +#endif /* GL_ARB_geometry_shader4 */ -#ifndef GL_SGIX_convolution_accuracy -#define GL_SGIX_convolution_accuracy 1 -#endif +#ifndef GL_ARB_get_program_binary +#define GL_ARB_get_program_binary 1 +#endif /* GL_ARB_get_program_binary */ -#ifndef GL_SGIX_resample -#define GL_SGIX_resample 1 -#endif +#ifndef GL_ARB_get_texture_sub_image +#define GL_ARB_get_texture_sub_image 1 +#endif /* GL_ARB_get_texture_sub_image */ -#ifndef GL_SGIS_point_line_texgen -#define GL_SGIS_point_line_texgen 1 -#endif +#ifndef GL_ARB_gpu_shader5 +#define GL_ARB_gpu_shader5 1 +#endif /* GL_ARB_gpu_shader5 */ -#ifndef GL_SGIS_texture_color_mask -#define GL_SGIS_texture_color_mask 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -#endif +#ifndef GL_ARB_gpu_shader_fp64 +#define GL_ARB_gpu_shader_fp64 1 +#endif /* GL_ARB_gpu_shader_fp64 */ -#ifndef GL_SGIX_igloo_interface -#define GL_SGIX_igloo_interface 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const GLvoid *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); -#endif +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +typedef unsigned short GLhalfARB; +#define GL_HALF_FLOAT_ARB 0x140B +#endif /* GL_ARB_half_float_pixel */ -#ifndef GL_EXT_texture_env_dot3 -#define GL_EXT_texture_env_dot3 1 -#endif +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif /* GL_ARB_half_float_vertex */ -#ifndef GL_ATI_texture_mirror_once -#define GL_ATI_texture_mirror_once 1 +#ifndef GL_ARB_imaging +#define GL_ARB_imaging 1 +#define GL_BLEND_COLOR 0x8005 +#define GL_BLEND_EQUATION 0x8009 +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTable (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTable (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTable (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glColorSubTable (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTable (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterf (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteri (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilter (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2D (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); +GLAPI void APIENTRY glGetHistogram (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmax (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogram (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmax (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogram (GLenum target); +GLAPI void APIENTRY glResetMinmax (GLenum target); #endif +#endif /* GL_ARB_imaging */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 +#ifndef GL_ARB_indirect_parameters +#define GL_ARB_indirect_parameters 1 +#define GL_PARAMETER_BUFFER_ARB 0x80EE +#define GL_PARAMETER_BUFFER_BINDING_ARB 0x80EF +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTCOUNTARBPROC) (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTARBPROC) (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); -GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); -GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); -GLAPI void APIENTRY glFinishFenceNV (GLuint fence); -GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +GLAPI void APIENTRY glMultiDrawArraysIndirectCountARB (GLenum mode, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectCountARB (GLenum mode, GLenum type, GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); #endif +#endif /* GL_ARB_indirect_parameters */ -#ifndef GL_IBM_static_data -#define GL_IBM_static_data 1 +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB 0x88FE +typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +GLAPI void APIENTRY glVertexAttribDivisorARB (GLuint index, GLuint divisor); #endif +#endif /* GL_ARB_instanced_arrays */ -#ifndef GL_IBM_texture_mirrored_repeat -#define GL_IBM_texture_mirrored_repeat 1 -#endif +#ifndef GL_ARB_internalformat_query +#define GL_ARB_internalformat_query 1 +#endif /* GL_ARB_internalformat_query */ -#ifndef GL_NV_evaluators -#define GL_NV_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); -typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); -#endif +#ifndef GL_ARB_internalformat_query2 +#define GL_ARB_internalformat_query2 1 +#define GL_SRGB_DECODE_ARB 0x8299 +#endif /* GL_ARB_internalformat_query2 */ -#ifndef GL_NV_packed_depth_stencil -#define GL_NV_packed_depth_stencil 1 -#endif +#ifndef GL_ARB_invalidate_subdata +#define GL_ARB_invalidate_subdata 1 +#endif /* GL_ARB_invalidate_subdata */ -#ifndef GL_NV_register_combiners2 -#define GL_NV_register_combiners2 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); -#endif +#ifndef GL_ARB_map_buffer_alignment +#define GL_ARB_map_buffer_alignment 1 +#endif /* GL_ARB_map_buffer_alignment */ -#ifndef GL_NV_texture_compression_vtc -#define GL_NV_texture_compression_vtc 1 -#endif +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif /* GL_ARB_map_buffer_range */ -#ifndef GL_NV_texture_rectangle -#define GL_NV_texture_rectangle 1 +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint index); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint size, const GLubyte *indices); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint size, const GLushort *indices); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint size, const GLuint *indices); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); #endif +#endif /* GL_ARB_matrix_palette */ -#ifndef GL_NV_texture_shader -#define GL_NV_texture_shader 1 -#endif +#ifndef GL_ARB_multi_bind +#define GL_ARB_multi_bind 1 +#endif /* GL_ARB_multi_bind */ -#ifndef GL_NV_texture_shader2 -#define GL_NV_texture_shader2 1 +#ifndef GL_ARB_multi_draw_indirect +#define GL_ARB_multi_draw_indirect 1 +#endif /* GL_ARB_multi_draw_indirect */ + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLfloat value, GLboolean invert); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLfloat value, GLboolean invert); #endif +#endif /* GL_ARB_multisample */ -#ifndef GL_NV_vertex_array_range2 -#define GL_NV_vertex_array_range2 1 +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum texture); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum target, GLdouble s); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum target, GLfloat s); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum target, GLint s); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum target, GLshort s); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum target, GLdouble s, GLdouble t); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum target, GLfloat s, GLfloat t); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum target, GLint s, GLint t); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum target, GLshort s, GLshort t); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum target, GLint s, GLint t, GLint r); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum target, const GLshort *v); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum target, const GLdouble *v); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum target, const GLfloat *v); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum target, const GLint *v); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum target, const GLshort *v); #endif +#endif /* GL_ARB_multitexture */ -#ifndef GL_NV_vertex_program -#define GL_NV_vertex_program 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); -GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); -GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); -GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); -GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); -GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, GLvoid* *pointer); -GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); -GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); -GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); -GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); -GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); -GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); -GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); -GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); -GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); -GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); -GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); -typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); -typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); -typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); -typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); -typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint id); +GLAPI void APIENTRY glBeginQueryARB (GLenum target, GLuint id); +GLAPI void APIENTRY glEndQueryARB (GLenum target); +GLAPI void APIENTRY glGetQueryivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint id, GLenum pname, GLuint *params); #endif +#endif /* GL_ARB_occlusion_query */ -#ifndef GL_SGIX_texture_coordinate_clamp -#define GL_SGIX_texture_coordinate_clamp 1 -#endif +#ifndef GL_ARB_occlusion_query2 +#define GL_ARB_occlusion_query2 1 +#endif /* GL_ARB_occlusion_query2 */ + +#ifndef GL_ARB_pipeline_statistics_query +#define GL_ARB_pipeline_statistics_query 1 +#define GL_VERTICES_SUBMITTED_ARB 0x82EE +#define GL_PRIMITIVES_SUBMITTED_ARB 0x82EF +#define GL_VERTEX_SHADER_INVOCATIONS_ARB 0x82F0 +#define GL_TESS_CONTROL_SHADER_PATCHES_ARB 0x82F1 +#define GL_TESS_EVALUATION_SHADER_INVOCATIONS_ARB 0x82F2 +#define GL_GEOMETRY_SHADER_PRIMITIVES_EMITTED_ARB 0x82F3 +#define GL_FRAGMENT_SHADER_INVOCATIONS_ARB 0x82F4 +#define GL_COMPUTE_SHADER_INVOCATIONS_ARB 0x82F5 +#define GL_CLIPPING_INPUT_PRIMITIVES_ARB 0x82F6 +#define GL_CLIPPING_OUTPUT_PRIMITIVES_ARB 0x82F7 +#endif /* GL_ARB_pipeline_statistics_query */ -#ifndef GL_SGIX_scalebias_hint -#define GL_SGIX_scalebias_hint 1 -#endif +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif /* GL_ARB_pixel_buffer_object */ -#ifndef GL_OML_interlace -#define GL_OML_interlace 1 +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvARB (GLenum pname, const GLfloat *params); #endif +#endif /* GL_ARB_point_parameters */ -#ifndef GL_OML_subsample -#define GL_OML_subsample 1 -#endif +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif /* GL_ARB_point_sprite */ -#ifndef GL_OML_resample -#define GL_OML_resample 1 +#ifndef GL_ARB_program_interface_query +#define GL_ARB_program_interface_query 1 +#endif /* GL_ARB_program_interface_query */ + +#ifndef GL_ARB_provoking_vertex +#define GL_ARB_provoking_vertex 1 +#endif /* GL_ARB_provoking_vertex */ + +#ifndef GL_ARB_query_buffer_object +#define GL_ARB_query_buffer_object 1 +#endif /* GL_ARB_query_buffer_object */ + +#ifndef GL_ARB_robust_buffer_access_behavior +#define GL_ARB_robust_buffer_access_behavior 1 +#endif /* GL_ARB_robust_buffer_access_behavior */ + +#ifndef GL_ARB_robustness +#define GL_ARB_robustness 1 +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GL_GUILTY_CONTEXT_RESET_ARB 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_ARB 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_ARB 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GL_NO_RESET_NOTIFICATION_ARB 0x8261 +typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void); +typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, void *img); +typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMUIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNMAPDVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +typedef void (APIENTRYP PFNGLGETNMAPFVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +typedef void (APIENTRYP PFNGLGETNMAPIVARBPROC) (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +typedef void (APIENTRYP PFNGLGETNPIXELMAPFVARBPROC) (GLenum map, GLsizei bufSize, GLfloat *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVARBPROC) (GLenum map, GLsizei bufSize, GLuint *values); +typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVARBPROC) (GLenum map, GLsizei bufSize, GLushort *values); +typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEARBPROC) (GLsizei bufSize, GLubyte *pattern); +typedef void (APIENTRYP PFNGLGETNCOLORTABLEARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERARBPROC) (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +typedef void (APIENTRYP PFNGLGETNHISTOGRAMARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +typedef void (APIENTRYP PFNGLGETNMINMAXARBPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLenum APIENTRY glGetGraphicsResetStatusARB (void); +GLAPI void APIENTRY glGetnTexImageARB (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *img); +GLAPI void APIENTRY glReadnPixelsARB (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GLAPI void APIENTRY glGetnCompressedTexImageARB (GLenum target, GLint lod, GLsizei bufSize, void *img); +GLAPI void APIENTRY glGetnUniformfvARB (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GLAPI void APIENTRY glGetnUniformivARB (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GLAPI void APIENTRY glGetnUniformuivARB (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei bufSize, GLdouble *params); +GLAPI void APIENTRY glGetnMapdvARB (GLenum target, GLenum query, GLsizei bufSize, GLdouble *v); +GLAPI void APIENTRY glGetnMapfvARB (GLenum target, GLenum query, GLsizei bufSize, GLfloat *v); +GLAPI void APIENTRY glGetnMapivARB (GLenum target, GLenum query, GLsizei bufSize, GLint *v); +GLAPI void APIENTRY glGetnPixelMapfvARB (GLenum map, GLsizei bufSize, GLfloat *values); +GLAPI void APIENTRY glGetnPixelMapuivARB (GLenum map, GLsizei bufSize, GLuint *values); +GLAPI void APIENTRY glGetnPixelMapusvARB (GLenum map, GLsizei bufSize, GLushort *values); +GLAPI void APIENTRY glGetnPolygonStippleARB (GLsizei bufSize, GLubyte *pattern); +GLAPI void APIENTRY glGetnColorTableARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table); +GLAPI void APIENTRY glGetnConvolutionFilterARB (GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image); +GLAPI void APIENTRY glGetnSeparableFilterARB (GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span); +GLAPI void APIENTRY glGetnHistogramARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); +GLAPI void APIENTRY glGetnMinmaxARB (GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values); #endif +#endif /* GL_ARB_robustness */ -#ifndef GL_NV_copy_depth_to_color -#define GL_NV_copy_depth_to_color 1 +#ifndef GL_ARB_robustness_isolation +#define GL_ARB_robustness_isolation 1 +#endif /* GL_ARB_robustness_isolation */ + +#ifndef GL_ARB_sample_shading +#define GL_ARB_sample_shading 1 +#define GL_SAMPLE_SHADING_ARB 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_ARB 0x8C37 +typedef void (APIENTRYP PFNGLMINSAMPLESHADINGARBPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value); #endif +#endif /* GL_ARB_sample_shading */ -#ifndef GL_ATI_envmap_bumpmap -#define GL_ATI_envmap_bumpmap 1 +#ifndef GL_ARB_sampler_objects +#define GL_ARB_sampler_objects 1 +#endif /* GL_ARB_sampler_objects */ + +#ifndef GL_ARB_seamless_cube_map +#define GL_ARB_seamless_cube_map 1 +#endif /* GL_ARB_seamless_cube_map */ + +#ifndef GL_ARB_seamless_cubemap_per_texture +#define GL_ARB_seamless_cubemap_per_texture 1 +#endif /* GL_ARB_seamless_cubemap_per_texture */ + +#ifndef GL_ARB_separate_shader_objects +#define GL_ARB_separate_shader_objects 1 +#endif /* GL_ARB_separate_shader_objects */ + +#ifndef GL_ARB_shader_atomic_counters +#define GL_ARB_shader_atomic_counters 1 +#endif /* GL_ARB_shader_atomic_counters */ + +#ifndef GL_ARB_shader_bit_encoding +#define GL_ARB_shader_bit_encoding 1 +#endif /* GL_ARB_shader_bit_encoding */ + +#ifndef GL_ARB_shader_draw_parameters +#define GL_ARB_shader_draw_parameters 1 +#endif /* GL_ARB_shader_draw_parameters */ + +#ifndef GL_ARB_shader_group_vote +#define GL_ARB_shader_group_vote 1 +#endif /* GL_ARB_shader_group_vote */ + +#ifndef GL_ARB_shader_image_load_store +#define GL_ARB_shader_image_load_store 1 +#endif /* GL_ARB_shader_image_load_store */ + +#ifndef GL_ARB_shader_image_size +#define GL_ARB_shader_image_size 1 +#endif /* GL_ARB_shader_image_size */ + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef __APPLE__ +typedef void *GLhandleARB; +#else +typedef unsigned int GLhandleARB; +#endif +typedef char GLcharARB; +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj); +typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj); +typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); -GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); -GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); -GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); -typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); -typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB obj); +GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum pname); +GLAPI void APIENTRY glDetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj); +GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum shaderType); +GLAPI void APIENTRY glShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string, const GLint *length); +GLAPI void APIENTRY glCompileShaderARB (GLhandleARB shaderObj); +GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (GLhandleARB containerObj, GLhandleARB obj); +GLAPI void APIENTRY glLinkProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB programObj); +GLAPI void APIENTRY glValidateProgramARB (GLhandleARB programObj); +GLAPI void APIENTRY glUniform1fARB (GLint location, GLfloat v0); +GLAPI void APIENTRY glUniform2fARB (GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glUniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glUniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glUniform1iARB (GLint location, GLint v0); +GLAPI void APIENTRY glUniform2iARB (GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glUniform3iARB (GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glUniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glUniform1fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform2fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform3fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform4fvARB (GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glUniform1ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform2ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform3ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniform4ivARB (GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj); +GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params); +GLAPI void APIENTRY glGetUniformivARB (GLhandleARB programObj, GLint location, GLint *params); +GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); #endif +#endif /* GL_ARB_shader_objects */ -#ifndef GL_ATI_fragment_shader -#define GL_ATI_fragment_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); -GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); -GLAPI void APIENTRY glBeginFragmentShaderATI (void); -GLAPI void APIENTRY glEndFragmentShaderATI (void); -GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); -GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); -GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); -typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); -typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); -typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); -typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); -typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); -#endif +#ifndef GL_ARB_shader_precision +#define GL_ARB_shader_precision 1 +#endif /* GL_ARB_shader_precision */ -#ifndef GL_ATI_pn_triangles -#define GL_ATI_pn_triangles 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); -GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_shader_stencil_export +#define GL_ARB_shader_stencil_export 1 +#endif /* GL_ARB_shader_stencil_export */ -#ifndef GL_ATI_vertex_array_object -#define GL_ATI_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const GLvoid *pointer, GLenum usage); -GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); -GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); -typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); -#endif +#ifndef GL_ARB_shader_storage_buffer_object +#define GL_ARB_shader_storage_buffer_object 1 +#endif /* GL_ARB_shader_storage_buffer_object */ -#ifndef GL_EXT_vertex_shader -#define GL_EXT_vertex_shader 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginVertexShaderEXT (void); -GLAPI void APIENTRY glEndVertexShaderEXT (void); -GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); -GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); -GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); -GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); -GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); -GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const GLvoid *addr); -GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); -GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); -GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); -GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); -GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); -GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); -GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); -GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); -GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); -GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); -GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); -GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); -GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); -GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); -GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); -GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); -GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, GLvoid* *data); -GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); -GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); -GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); -typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); -typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); -typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); -typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); -typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); -typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); -typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); -typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); -typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); -typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); -typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); -typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); -typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); -typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); -typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); -typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); -typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); -typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); -typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); -typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); -typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); -typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); -typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); -#endif +#ifndef GL_ARB_shader_subroutine +#define GL_ARB_shader_subroutine 1 +#endif /* GL_ARB_shader_subroutine */ -#ifndef GL_ATI_vertex_streams -#define GL_ATI_vertex_streams 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); -GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); -GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); -GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); -GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); -GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); -GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); -GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); -GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); -GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); -GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); -GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); -GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); -GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); -GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); -GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); -GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); -typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); -typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); -#endif +#ifndef GL_ARB_shader_texture_image_samples +#define GL_ARB_shader_texture_image_samples 1 +#endif /* GL_ARB_shader_texture_image_samples */ + +#ifndef GL_ARB_shader_texture_lod +#define GL_ARB_shader_texture_lod 1 +#endif /* GL_ARB_shader_texture_lod */ + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif /* GL_ARB_shading_language_100 */ + +#ifndef GL_ARB_shading_language_420pack +#define GL_ARB_shading_language_420pack 1 +#endif /* GL_ARB_shading_language_420pack */ -#ifndef GL_ATI_element_array -#define GL_ATI_element_array 1 +#ifndef GL_ARB_shading_language_include +#define GL_ARB_shading_language_include 1 +#define GL_SHADER_INCLUDE_ARB 0x8DAE +#define GL_NAMED_STRING_LENGTH_ARB 0x8DE9 +#define GL_NAMED_STRING_TYPE_ARB 0x8DEA +typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerATI (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); +GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); +GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); +GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); +GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #endif +#endif /* GL_ARB_shading_language_include */ -#ifndef GL_SUN_mesh_array -#define GL_SUN_mesh_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); -#endif +#ifndef GL_ARB_shading_language_packing +#define GL_ARB_shading_language_packing 1 +#endif /* GL_ARB_shading_language_packing */ -#ifndef GL_SUN_slice_accum -#define GL_SUN_slice_accum 1 -#endif +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif /* GL_ARB_shadow */ -#ifndef GL_NV_multisample_filter_hint -#define GL_NV_multisample_filter_hint 1 -#endif +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif /* GL_ARB_shadow_ambient */ + +#ifndef GL_ARB_sparse_buffer +#define GL_ARB_sparse_buffer 1 +#define GL_SPARSE_STORAGE_BIT_ARB 0x0400 +#define GL_SPARSE_BUFFER_PAGE_SIZE_ARB 0x82F8 +typedef void (APIENTRYP PFNGLBUFFERPAGECOMMITMENTARBPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +typedef void (APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTARBPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferPageCommitmentARB (GLenum target, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +GLAPI void APIENTRY glNamedBufferPageCommitmentARB (GLuint buffer, GLintptr offset, GLsizeiptr size, GLboolean commit); +#endif +#endif /* GL_ARB_sparse_buffer */ + +#ifndef GL_ARB_sparse_texture +#define GL_ARB_sparse_texture 1 +#define GL_TEXTURE_SPARSE_ARB 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_ARB 0x91A7 +#define GL_NUM_SPARSE_LEVELS_ARB 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_ARB 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_ARB 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_ARB 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_ARB 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_ARB 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_ARB 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_ARB 0x91A9 +typedef void (APIENTRYP PFNGLTEXPAGECOMMITMENTARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexPageCommitmentARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +#endif +#endif /* GL_ARB_sparse_texture */ -#ifndef GL_NV_depth_clamp -#define GL_NV_depth_clamp 1 -#endif +#ifndef GL_ARB_stencil_texturing +#define GL_ARB_stencil_texturing 1 +#endif /* GL_ARB_stencil_texturing */ -#ifndef GL_NV_occlusion_query -#define GL_NV_occlusion_query 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); -GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); -GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); -GLAPI void APIENTRY glEndOcclusionQueryNV (void); -GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); -typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); -#endif +#ifndef GL_ARB_sync +#define GL_ARB_sync 1 +#endif /* GL_ARB_sync */ -#ifndef GL_NV_point_sprite -#define GL_NV_point_sprite 1 +#ifndef GL_ARB_tessellation_shader +#define GL_ARB_tessellation_shader 1 +#endif /* GL_ARB_tessellation_shader */ + +#ifndef GL_ARB_texture_barrier +#define GL_ARB_texture_barrier 1 +#endif /* GL_ARB_texture_barrier */ + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif /* GL_ARB_texture_border_clamp */ + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); -GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexBufferARB (GLenum target, GLenum internalformat, GLuint buffer); #endif +#endif /* GL_ARB_texture_buffer_object */ + +#ifndef GL_ARB_texture_buffer_object_rgb32 +#define GL_ARB_texture_buffer_object_rgb32 1 +#endif /* GL_ARB_texture_buffer_object_rgb32 */ + +#ifndef GL_ARB_texture_buffer_range +#define GL_ARB_texture_buffer_range 1 +#endif /* GL_ARB_texture_buffer_range */ + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, void *img); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum target, GLint level, void *img); +#endif +#endif /* GL_ARB_texture_compression */ + +#ifndef GL_ARB_texture_compression_bptc +#define GL_ARB_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_ARB 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB 0x8E8F +#endif /* GL_ARB_texture_compression_bptc */ + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif /* GL_ARB_texture_compression_rgtc */ + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif /* GL_ARB_texture_cube_map */ + +#ifndef GL_ARB_texture_cube_map_array +#define GL_ARB_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_ARB 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_ARB 0x900A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY_ARB 0x900B +#define GL_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_ARB 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_ARB 0x900F +#endif /* GL_ARB_texture_cube_map_array */ + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif /* GL_ARB_texture_env_add */ + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif /* GL_ARB_texture_env_combine */ + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif /* GL_ARB_texture_env_crossbar */ + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif /* GL_ARB_texture_env_dot3 */ + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif /* GL_ARB_texture_float */ + +#ifndef GL_ARB_texture_gather +#define GL_ARB_texture_gather 1 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB 0x8E5F +#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS_ARB 0x8F9F +#endif /* GL_ARB_texture_gather */ + +#ifndef GL_ARB_texture_mirror_clamp_to_edge +#define GL_ARB_texture_mirror_clamp_to_edge 1 +#endif /* GL_ARB_texture_mirror_clamp_to_edge */ + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif /* GL_ARB_texture_mirrored_repeat */ + +#ifndef GL_ARB_texture_multisample +#define GL_ARB_texture_multisample 1 +#endif /* GL_ARB_texture_multisample */ + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif /* GL_ARB_texture_non_power_of_two */ + +#ifndef GL_ARB_texture_query_levels +#define GL_ARB_texture_query_levels 1 +#endif /* GL_ARB_texture_query_levels */ + +#ifndef GL_ARB_texture_query_lod +#define GL_ARB_texture_query_lod 1 +#endif /* GL_ARB_texture_query_lod */ + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif /* GL_ARB_texture_rectangle */ + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif /* GL_ARB_texture_rg */ + +#ifndef GL_ARB_texture_rgb10_a2ui +#define GL_ARB_texture_rgb10_a2ui 1 +#endif /* GL_ARB_texture_rgb10_a2ui */ + +#ifndef GL_ARB_texture_stencil8 +#define GL_ARB_texture_stencil8 1 +#endif /* GL_ARB_texture_stencil8 */ + +#ifndef GL_ARB_texture_storage +#define GL_ARB_texture_storage 1 +#endif /* GL_ARB_texture_storage */ + +#ifndef GL_ARB_texture_storage_multisample +#define GL_ARB_texture_storage_multisample 1 +#endif /* GL_ARB_texture_storage_multisample */ + +#ifndef GL_ARB_texture_swizzle +#define GL_ARB_texture_swizzle 1 +#endif /* GL_ARB_texture_swizzle */ + +#ifndef GL_ARB_texture_view +#define GL_ARB_texture_view 1 +#endif /* GL_ARB_texture_view */ + +#ifndef GL_ARB_timer_query +#define GL_ARB_timer_query 1 +#endif /* GL_ARB_timer_query */ -#ifndef GL_NV_texture_shader3 -#define GL_NV_texture_shader3 1 -#endif +#ifndef GL_ARB_transform_feedback2 +#define GL_ARB_transform_feedback2 1 +#endif /* GL_ARB_transform_feedback2 */ -#ifndef GL_NV_vertex_program1_1 -#define GL_NV_vertex_program1_1 1 -#endif +#ifndef GL_ARB_transform_feedback3 +#define GL_ARB_transform_feedback3 1 +#endif /* GL_ARB_transform_feedback3 */ -#ifndef GL_EXT_shadow_funcs -#define GL_EXT_shadow_funcs 1 -#endif +#ifndef GL_ARB_transform_feedback_instanced +#define GL_ARB_transform_feedback_instanced 1 +#endif /* GL_ARB_transform_feedback_instanced */ -#ifndef GL_EXT_stencil_two_side -#define GL_EXT_stencil_two_side 1 +#ifndef GL_ARB_transform_feedback_overflow_query +#define GL_ARB_transform_feedback_overflow_query 1 +#define GL_TRANSFORM_FEEDBACK_OVERFLOW_ARB 0x82EC +#define GL_TRANSFORM_FEEDBACK_STREAM_OVERFLOW_ARB 0x82ED +#endif /* GL_ARB_transform_feedback_overflow_query */ + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *m); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *m); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *m); #endif +#endif /* GL_ARB_transpose_matrix */ -#ifndef GL_ATI_text_fragment_shader -#define GL_ATI_text_fragment_shader 1 -#endif +#ifndef GL_ARB_uniform_buffer_object +#define GL_ARB_uniform_buffer_object 1 +#endif /* GL_ARB_uniform_buffer_object */ -#ifndef GL_APPLE_client_storage -#define GL_APPLE_client_storage 1 -#endif +#ifndef GL_ARB_vertex_array_bgra +#define GL_ARB_vertex_array_bgra 1 +#endif /* GL_ARB_vertex_array_bgra */ -#ifndef GL_APPLE_element_array -#define GL_APPLE_element_array 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const GLvoid *pointer); -GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); -GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); -typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); -#endif +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif /* GL_ARB_vertex_array_object */ -#ifndef GL_APPLE_fence -#define GL_APPLE_fence 1 +#ifndef GL_ARB_vertex_attrib_64bit +#define GL_ARB_vertex_attrib_64bit 1 +#endif /* GL_ARB_vertex_attrib_64bit */ + +#ifndef GL_ARB_vertex_attrib_binding +#define GL_ARB_vertex_attrib_binding 1 +#endif /* GL_ARB_vertex_attrib_binding */ + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); -GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); -GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); -GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); -GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); -GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); -typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); -typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); -typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); -typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); -typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +GLAPI void APIENTRY glWeightbvARB (GLint size, const GLbyte *weights); +GLAPI void APIENTRY glWeightsvARB (GLint size, const GLshort *weights); +GLAPI void APIENTRY glWeightivARB (GLint size, const GLint *weights); +GLAPI void APIENTRY glWeightfvARB (GLint size, const GLfloat *weights); +GLAPI void APIENTRY glWeightdvARB (GLint size, const GLdouble *weights); +GLAPI void APIENTRY glWeightubvARB (GLint size, const GLubyte *weights); +GLAPI void APIENTRY glWeightusvARB (GLint size, const GLushort *weights); +GLAPI void APIENTRY glWeightuivARB (GLint size, const GLuint *weights); +GLAPI void APIENTRY glWeightPointerARB (GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexBlendARB (GLint count); #endif +#endif /* GL_ARB_vertex_blend */ -#ifndef GL_APPLE_vertex_array_object -#define GL_APPLE_vertex_array_object 1 +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +// Unfortunate problem with the OS X SDK which defines these types incorrectly +#if !defined(MACOS_X) +typedef ptrdiff_t GLsizeiptrARB; +typedef ptrdiff_t GLintptrARB; +#endif +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +typedef void *(APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); -GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); -GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); -GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); -typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); -typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +GLAPI void APIENTRY glBindBufferARB (GLenum target, GLuint buffer); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei n, const GLuint *buffers); +GLAPI void APIENTRY glGenBuffersARB (GLsizei n, GLuint *buffers); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint buffer); +GLAPI void APIENTRY glBufferDataARB (GLenum target, GLsizeiptrARB size, const void *data, GLenum usage); +GLAPI void APIENTRY glBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const void *data); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum target, GLintptrARB offset, GLsizeiptrARB size, void *data); +GLAPI void *APIENTRY glMapBufferARB (GLenum target, GLenum access); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum target); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum target, GLenum pname, void **params); #endif +#endif /* GL_ARB_vertex_buffer_object */ -#ifndef GL_APPLE_vertex_array_range -#define GL_APPLE_vertex_array_range 1 +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, void **pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, GLvoid *pointer); -GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); -typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); -#endif - -#ifndef GL_APPLE_ycbcr_422 -#define GL_APPLE_ycbcr_422 1 -#endif - -#ifndef GL_S3_s3tc -#define GL_S3_s3tc 1 +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint index); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint index, GLenum pname, void **pointer); #endif +#endif /* GL_ARB_vertex_program */ -#ifndef GL_ATI_draw_buffers -#define GL_ATI_draw_buffers 1 +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); -#endif - -#ifndef GL_ATI_pixel_format_float -#define GL_ATI_pixel_format_float 1 -/* This is really a WGL extension, but defines some associated GL enums. - * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. - */ -#endif - -#ifndef GL_ATI_texture_env_combine3 -#define GL_ATI_texture_env_combine3 1 -#endif - -#ifndef GL_ATI_texture_float -#define GL_ATI_texture_float 1 -#endif - -#ifndef GL_NV_float_buffer -#define GL_NV_float_buffer 1 +GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name); +GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name); #endif +#endif /* GL_ARB_vertex_shader */ -#ifndef GL_NV_fragment_program -#define GL_NV_fragment_program 1 -/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); -typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); -#endif +#ifndef GL_ARB_vertex_type_10f_11f_11f_rev +#define GL_ARB_vertex_type_10f_11f_11f_rev 1 +#endif /* GL_ARB_vertex_type_10f_11f_11f_rev */ -#ifndef GL_NV_half_float -#define GL_NV_half_float 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); -GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); -GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); -GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); -GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); -GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); -GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); -GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); -GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); -GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); -GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); -GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); -typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); -typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); -typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); -typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); -typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); -typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); -typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); -typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); -typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); -typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); -#endif +#ifndef GL_ARB_vertex_type_2_10_10_10_rev +#define GL_ARB_vertex_type_2_10_10_10_rev 1 +#endif /* GL_ARB_vertex_type_2_10_10_10_rev */ -#ifndef GL_NV_pixel_data_range -#define GL_NV_pixel_data_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const GLvoid *pointer); -GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); -#endif +#ifndef GL_ARB_viewport_array +#define GL_ARB_viewport_array 1 +#endif /* GL_ARB_viewport_array */ -#ifndef GL_NV_primitive_restart -#define GL_NV_primitive_restart 1 +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPrimitiveRestartNV (void); -GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); -typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +GLAPI void APIENTRY glWindowPos2dARB (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iARB (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos2sARB (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iARB (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *v); +GLAPI void APIENTRY glWindowPos3sARB (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *v); #endif +#endif /* GL_ARB_window_pos */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#endif /* GL_KHR_context_flush_control */ -#ifndef GL_NV_texture_expand_normal -#define GL_NV_texture_expand_normal 1 -#endif +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +#endif /* GL_KHR_debug */ -#ifndef GL_NV_vertex_program2 -#define GL_NV_vertex_program2 1 -#endif +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ -#ifndef GL_ATI_map_object_buffer -#define GL_ATI_map_object_buffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint buffer); -GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); -#endif +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS 0x90F3 +#endif /* GL_KHR_robustness */ -#ifndef GL_ATI_separate_stencil -#define GL_ATI_separate_stencil 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); -typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); -#endif +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ -#ifndef GL_ATI_vertex_attrib_array_object -#define GL_ATI_vertex_attrib_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); -#endif +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ #ifndef GL_OES_byte_coordinates #define GL_OES_byte_coordinates 1 +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); +typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); +typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); +typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); +typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x, GLbyte y); +typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); +typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z, GLbyte w); +typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glMultiTexCoord1bOES (GLenum texture, GLbyte s); GLAPI void APIENTRY glMultiTexCoord1bvOES (GLenum texture, const GLbyte *coords); @@ -11099,1015 +4839,1628 @@ GLAPI void APIENTRY glTexCoord3bOES (GLbyte s, GLbyte t, GLbyte r); GLAPI void APIENTRY glTexCoord3bvOES (const GLbyte *coords); GLAPI void APIENTRY glTexCoord4bOES (GLbyte s, GLbyte t, GLbyte r, GLbyte q); GLAPI void APIENTRY glTexCoord4bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex2bOES (GLbyte x); +GLAPI void APIENTRY glVertex2bOES (GLbyte x, GLbyte y); GLAPI void APIENTRY glVertex2bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y); +GLAPI void APIENTRY glVertex3bOES (GLbyte x, GLbyte y, GLbyte z); GLAPI void APIENTRY glVertex3bvOES (const GLbyte *coords); -GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glVertex4bOES (GLbyte x, GLbyte y, GLbyte z, GLbyte w); GLAPI void APIENTRY glVertex4bvOES (const GLbyte *coords); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BOESPROC) (GLenum texture, GLbyte s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BOESPROC) (GLenum texture, GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BOESPROC) (GLenum texture, GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4BVOESPROC) (GLenum texture, const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD1BOESPROC) (GLbyte s); -typedef void (APIENTRYP PFNGLTEXCOORD1BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2BOESPROC) (GLbyte s, GLbyte t); -typedef void (APIENTRYP PFNGLTEXCOORD2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3BOESPROC) (GLbyte s, GLbyte t, GLbyte r); -typedef void (APIENTRYP PFNGLTEXCOORD3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4BOESPROC) (GLbyte s, GLbyte t, GLbyte r, GLbyte q); -typedef void (APIENTRYP PFNGLTEXCOORD4BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX2BOESPROC) (GLbyte x); -typedef void (APIENTRYP PFNGLVERTEX2BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX3BOESPROC) (GLbyte x, GLbyte y); -typedef void (APIENTRYP PFNGLVERTEX3BVOESPROC) (const GLbyte *coords); -typedef void (APIENTRYP PFNGLVERTEX4BOESPROC) (GLbyte x, GLbyte y, GLbyte z); -typedef void (APIENTRYP PFNGLVERTEX4BVOESPROC) (const GLbyte *coords); #endif +#endif /* GL_OES_byte_coordinates */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ #ifndef GL_OES_fixed_point #define GL_OES_fixed_point 1 +typedef GLint GLfixed; +#define GL_FIXED_OES 0x140C +typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); +typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); +typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); +typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); +typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); +typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); +typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); +typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); +typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); +typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); +typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); +typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); +typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); +typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); +typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); +typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); +typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); +typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); +typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); +typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); +typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); +typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); +typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); +typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); +typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); +typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); +typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); +typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); +typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); +typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); +typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); +typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); +typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); +typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); +typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); +typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); +typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); +typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); +typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); +typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); #ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); +GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); +GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); +GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); +GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); +GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); +GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); +GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); +GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glLineWidthxOES (GLfixed width); +GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); +GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); +GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); +GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); +GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); +GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); +GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glPointSizexOES (GLfixed size); +GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); +GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); +GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); +GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); +GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); +GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glAccumxOES (GLenum op, GLfixed value); -GLAPI void APIENTRY glAlphaFuncxOES (GLenum func, GLfixed ref); GLAPI void APIENTRY glBitmapxOES (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); GLAPI void APIENTRY glBlendColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glClearAccumxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearColorxOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -GLAPI void APIENTRY glClearDepthxOES (GLfixed depth); -GLAPI void APIENTRY glClipPlanexOES (GLenum plane, const GLfixed *equation); GLAPI void APIENTRY glColor3xOES (GLfixed red, GLfixed green, GLfixed blue); -GLAPI void APIENTRY glColor4xOES (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); GLAPI void APIENTRY glColor3xvOES (const GLfixed *components); GLAPI void APIENTRY glColor4xvOES (const GLfixed *components); GLAPI void APIENTRY glConvolutionParameterxOES (GLenum target, GLenum pname, GLfixed param); GLAPI void APIENTRY glConvolutionParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glDepthRangexOES (GLfixed n, GLfixed f); GLAPI void APIENTRY glEvalCoord1xOES (GLfixed u); -GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); GLAPI void APIENTRY glEvalCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glEvalCoord2xOES (GLfixed u, GLfixed v); GLAPI void APIENTRY glEvalCoord2xvOES (const GLfixed *coords); GLAPI void APIENTRY glFeedbackBufferxOES (GLsizei n, GLenum type, const GLfixed *buffer); -GLAPI void APIENTRY glFogxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glFogxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glFrustumxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -GLAPI void APIENTRY glGetClipPlanexOES (GLenum plane, GLfixed *equation); GLAPI void APIENTRY glGetConvolutionParameterxvOES (GLenum target, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetFixedvOES (GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetHistogramParameterxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetLightxOES (GLenum light, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetMapxvOES (GLenum target, GLenum query, GLfixed *v); GLAPI void APIENTRY glGetMaterialxOES (GLenum face, GLenum pname, GLfixed param); GLAPI void APIENTRY glGetPixelMapxv (GLenum map, GLint size, GLfixed *values); -GLAPI void APIENTRY glGetTexEnvxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetTexGenxvOES (GLenum coord, GLenum pname, GLfixed *params); GLAPI void APIENTRY glGetTexLevelParameterxvOES (GLenum target, GLint level, GLenum pname, GLfixed *params); -GLAPI void APIENTRY glGetTexParameterxvOES (GLenum target, GLenum pname, GLfixed *params); GLAPI void APIENTRY glIndexxOES (GLfixed component); GLAPI void APIENTRY glIndexxvOES (const GLfixed *component); -GLAPI void APIENTRY glLightModelxOES (GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightModelxvOES (GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glLightxOES (GLenum light, GLenum pname, GLfixed param); -GLAPI void APIENTRY glLightxvOES (GLenum light, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glLineWidthxOES (GLfixed width); -GLAPI void APIENTRY glLoadMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glLoadTransposeMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMap1xOES (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); GLAPI void APIENTRY glMap2xOES (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); GLAPI void APIENTRY glMapGrid1xOES (GLint n, GLfixed u1, GLfixed u2); GLAPI void APIENTRY glMapGrid2xOES (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -GLAPI void APIENTRY glMaterialxOES (GLenum face, GLenum pname, GLfixed param); -GLAPI void APIENTRY glMaterialxvOES (GLenum face, GLenum pname, const GLfixed *param); -GLAPI void APIENTRY glMultMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMultTransposeMatrixxOES (const GLfixed *m); GLAPI void APIENTRY glMultiTexCoord1xOES (GLenum texture, GLfixed s); -GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); -GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glMultiTexCoord4xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); GLAPI void APIENTRY glMultiTexCoord1xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord2xOES (GLenum texture, GLfixed s, GLfixed t); GLAPI void APIENTRY glMultiTexCoord2xvOES (GLenum texture, const GLfixed *coords); +GLAPI void APIENTRY glMultiTexCoord3xOES (GLenum texture, GLfixed s, GLfixed t, GLfixed r); GLAPI void APIENTRY glMultiTexCoord3xvOES (GLenum texture, const GLfixed *coords); GLAPI void APIENTRY glMultiTexCoord4xvOES (GLenum texture, const GLfixed *coords); -GLAPI void APIENTRY glNormal3xOES (GLfixed nx, GLfixed ny, GLfixed nz); GLAPI void APIENTRY glNormal3xvOES (const GLfixed *coords); -GLAPI void APIENTRY glOrthoxOES (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); GLAPI void APIENTRY glPassThroughxOES (GLfixed token); GLAPI void APIENTRY glPixelMapx (GLenum map, GLint size, const GLfixed *values); GLAPI void APIENTRY glPixelStorex (GLenum pname, GLfixed param); GLAPI void APIENTRY glPixelTransferxOES (GLenum pname, GLfixed param); GLAPI void APIENTRY glPixelZoomxOES (GLfixed xfactor, GLfixed yfactor); -GLAPI void APIENTRY glPointParameterxvOES (GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glPointSizexOES (GLfixed size); -GLAPI void APIENTRY glPolygonOffsetxOES (GLfixed factor, GLfixed units); GLAPI void APIENTRY glPrioritizeTexturesxOES (GLsizei n, const GLuint *textures, const GLfixed *priorities); GLAPI void APIENTRY glRasterPos2xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); GLAPI void APIENTRY glRasterPos2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos3xOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glRasterPos3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glRasterPos4xOES (GLfixed x, GLfixed y, GLfixed z, GLfixed w); GLAPI void APIENTRY glRasterPos4xvOES (const GLfixed *coords); GLAPI void APIENTRY glRectxOES (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); GLAPI void APIENTRY glRectxvOES (const GLfixed *v1, const GLfixed *v2); -GLAPI void APIENTRY glRotatexOES (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -GLAPI void APIENTRY glSampleCoverageOES (GLfixed value, GLboolean invert); -GLAPI void APIENTRY glScalexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glTexCoord1xOES (GLfixed s); -GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); -GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); -GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); GLAPI void APIENTRY glTexCoord1xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord2xOES (GLfixed s, GLfixed t); GLAPI void APIENTRY glTexCoord2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord3xOES (GLfixed s, GLfixed t, GLfixed r); GLAPI void APIENTRY glTexCoord3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glTexCoord4xOES (GLfixed s, GLfixed t, GLfixed r, GLfixed q); GLAPI void APIENTRY glTexCoord4xvOES (const GLfixed *coords); -GLAPI void APIENTRY glTexEnvxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexEnvxvOES (GLenum target, GLenum pname, const GLfixed *params); GLAPI void APIENTRY glTexGenxOES (GLenum coord, GLenum pname, GLfixed param); GLAPI void APIENTRY glTexGenxvOES (GLenum coord, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTexParameterxOES (GLenum target, GLenum pname, GLfixed param); -GLAPI void APIENTRY glTexParameterxvOES (GLenum target, GLenum pname, const GLfixed *params); -GLAPI void APIENTRY glTranslatexOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glVertex2xOES (GLfixed x); -GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); -GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glVertex2xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex3xOES (GLfixed x, GLfixed y); GLAPI void APIENTRY glVertex3xvOES (const GLfixed *coords); +GLAPI void APIENTRY glVertex4xOES (GLfixed x, GLfixed y, GLfixed z); GLAPI void APIENTRY glVertex4xvOES (const GLfixed *coords); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLACCUMXOESPROC) (GLenum op, GLfixed value); -typedef void (APIENTRYP PFNGLALPHAFUNCXOESPROC) (GLenum func, GLfixed ref); -typedef void (APIENTRYP PFNGLBITMAPXOESPROC) (GLsizei width, GLsizei height, GLfixed xorig, GLfixed yorig, GLfixed xmove, GLfixed ymove, const GLubyte *bitmap); -typedef void (APIENTRYP PFNGLBLENDCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARACCUMXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORXOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCLEARDEPTHXOESPROC) (GLfixed depth); -typedef void (APIENTRYP PFNGLCLIPPLANEXOESPROC) (GLenum plane, const GLfixed *equation); -typedef void (APIENTRYP PFNGLCOLOR3XOESPROC) (GLfixed red, GLfixed green, GLfixed blue); -typedef void (APIENTRYP PFNGLCOLOR4XOESPROC) (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha); -typedef void (APIENTRYP PFNGLCOLOR3XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCOLOR4XVOESPROC) (const GLfixed *components); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLDEPTHRANGEXOESPROC) (GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLEVALCOORD1XOESPROC) (GLfixed u); -typedef void (APIENTRYP PFNGLEVALCOORD2XOESPROC) (GLfixed u, GLfixed v); -typedef void (APIENTRYP PFNGLEVALCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLEVALCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLFEEDBACKBUFFERXOESPROC) (GLsizei n, GLenum type, const GLfixed *buffer); -typedef void (APIENTRYP PFNGLFOGXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLFOGXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLFRUSTUMXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLGETCLIPPLANEXOESPROC) (GLenum plane, GLfixed *equation); -typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETFIXEDVOESPROC) (GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETMAPXVOESPROC) (GLenum target, GLenum query, GLfixed *v); -typedef void (APIENTRYP PFNGLGETMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLGETPIXELMAPXVPROC) (GLenum map, GLint size, GLfixed *values); -typedef void (APIENTRYP PFNGLGETTEXENVXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXGENXVOESPROC) (GLenum coord, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERXVOESPROC) (GLenum target, GLint level, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, GLfixed *params); -typedef void (APIENTRYP PFNGLINDEXXOESPROC) (GLfixed component); -typedef void (APIENTRYP PFNGLINDEXXVOESPROC) (const GLfixed *component); -typedef void (APIENTRYP PFNGLLIGHTMODELXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTMODELXVOESPROC) (GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLLIGHTXOESPROC) (GLenum light, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLLIGHTXVOESPROC) (GLenum light, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLLINEWIDTHXOESPROC) (GLfixed width); -typedef void (APIENTRYP PFNGLLOADMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMAP1XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint stride, GLint order, GLfixed points); -typedef void (APIENTRYP PFNGLMAP2XOESPROC) (GLenum target, GLfixed u1, GLfixed u2, GLint ustride, GLint uorder, GLfixed v1, GLfixed v2, GLint vstride, GLint vorder, GLfixed points); -typedef void (APIENTRYP PFNGLMAPGRID1XOESPROC) (GLint n, GLfixed u1, GLfixed u2); -typedef void (APIENTRYP PFNGLMAPGRID2XOESPROC) (GLint n, GLfixed u1, GLfixed u2, GLfixed v1, GLfixed v2); -typedef void (APIENTRYP PFNGLMATERIALXOESPROC) (GLenum face, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLMATERIALXVOESPROC) (GLenum face, GLenum pname, const GLfixed *param); -typedef void (APIENTRYP PFNGLMULTMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXXOESPROC) (const GLfixed *m); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XOESPROC) (GLenum texture, GLfixed s); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XOESPROC) (GLenum texture, GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XOESPROC) (GLenum texture, GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLMULTITEXCOORD1XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD2XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD3XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLMULTITEXCOORD4XVOESPROC) (GLenum texture, const GLfixed *coords); -typedef void (APIENTRYP PFNGLNORMAL3XOESPROC) (GLfixed nx, GLfixed ny, GLfixed nz); -typedef void (APIENTRYP PFNGLNORMAL3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLORTHOXOESPROC) (GLfixed l, GLfixed r, GLfixed b, GLfixed t, GLfixed n, GLfixed f); -typedef void (APIENTRYP PFNGLPASSTHROUGHXOESPROC) (GLfixed token); -typedef void (APIENTRYP PFNGLPIXELMAPXPROC) (GLenum map, GLint size, const GLfixed *values); -typedef void (APIENTRYP PFNGLPIXELSTOREXPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELTRANSFERXOESPROC) (GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLPIXELZOOMXOESPROC) (GLfixed xfactor, GLfixed yfactor); -typedef void (APIENTRYP PFNGLPOINTPARAMETERXVOESPROC) (GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLPOINTSIZEXOESPROC) (GLfixed size); -typedef void (APIENTRYP PFNGLPOLYGONOFFSETXOESPROC) (GLfixed factor, GLfixed units); -typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESXOESPROC) (GLsizei n, const GLuint *textures, const GLfixed *priorities); -typedef void (APIENTRYP PFNGLRASTERPOS2XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLRASTERPOS3XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLRASTERPOS4XOESPROC) (GLfixed x, GLfixed y, GLfixed z, GLfixed w); -typedef void (APIENTRYP PFNGLRASTERPOS2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRASTERPOS4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLRECTXOESPROC) (GLfixed x1, GLfixed y1, GLfixed x2, GLfixed y2); -typedef void (APIENTRYP PFNGLRECTXVOESPROC) (const GLfixed *v1, const GLfixed *v2); -typedef void (APIENTRYP PFNGLROTATEXOESPROC) (GLfixed angle, GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLSAMPLECOVERAGEOESPROC) (GLfixed value, GLboolean invert); -typedef void (APIENTRYP PFNGLSCALEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLTEXCOORD1XOESPROC) (GLfixed s); -typedef void (APIENTRYP PFNGLTEXCOORD2XOESPROC) (GLfixed s, GLfixed t); -typedef void (APIENTRYP PFNGLTEXCOORD3XOESPROC) (GLfixed s, GLfixed t, GLfixed r); -typedef void (APIENTRYP PFNGLTEXCOORD4XOESPROC) (GLfixed s, GLfixed t, GLfixed r, GLfixed q); -typedef void (APIENTRYP PFNGLTEXCOORD1XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXCOORD4XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLTEXENVXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXENVXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTEXGENXOESPROC) (GLenum coord, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXGENXVOESPROC) (GLenum coord, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERXOESPROC) (GLenum target, GLenum pname, GLfixed param); -typedef void (APIENTRYP PFNGLTEXPARAMETERXVOESPROC) (GLenum target, GLenum pname, const GLfixed *params); -typedef void (APIENTRYP PFNGLTRANSLATEXOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLVERTEX2XOESPROC) (GLfixed x); -typedef void (APIENTRYP PFNGLVERTEX3XOESPROC) (GLfixed x, GLfixed y); -typedef void (APIENTRYP PFNGLVERTEX4XOESPROC) (GLfixed x, GLfixed y, GLfixed z); -typedef void (APIENTRYP PFNGLVERTEX2XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX3XVOESPROC) (const GLfixed *coords); -typedef void (APIENTRYP PFNGLVERTEX4XVOESPROC) (const GLfixed *coords); #endif +#endif /* GL_OES_fixed_point */ + +#ifndef GL_OES_query_matrix +#define GL_OES_query_matrix 1 +typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); +#endif +#endif /* GL_OES_query_matrix */ + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif /* GL_OES_read_format */ + +#ifndef GL_OES_single_precision +#define GL_OES_single_precision 1 +typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); +typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); +typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); +typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); +GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); +GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); +GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); +#endif +#endif /* GL_OES_single_precision */ + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif /* GL_3DFX_multisample */ + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint mask); +#endif +#endif /* GL_3DFX_tbuffer */ + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif /* GL_3DFX_texture_compression_FXT1 */ + +#ifndef GL_AMD_blend_minmax_factor +#define GL_AMD_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_AMD_blend_minmax_factor */ + +#ifndef GL_AMD_conservative_depth +#define GL_AMD_conservative_depth 1 +#endif /* GL_AMD_conservative_depth */ + +#ifndef GL_AMD_debug_output +#define GL_AMD_debug_output 1 +typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +#define GL_MAX_DEBUG_MESSAGE_LENGTH_AMD 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_AMD 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_AMD 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_AMD 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_AMD 0x9147 +#define GL_DEBUG_SEVERITY_LOW_AMD 0x9148 +#define GL_DEBUG_CATEGORY_API_ERROR_AMD 0x9149 +#define GL_DEBUG_CATEGORY_WINDOW_SYSTEM_AMD 0x914A +#define GL_DEBUG_CATEGORY_DEPRECATION_AMD 0x914B +#define GL_DEBUG_CATEGORY_UNDEFINED_BEHAVIOR_AMD 0x914C +#define GL_DEBUG_CATEGORY_PERFORMANCE_AMD 0x914D +#define GL_DEBUG_CATEGORY_SHADER_COMPILER_AMD 0x914E +#define GL_DEBUG_CATEGORY_APPLICATION_AMD 0x914F +#define GL_DEBUG_CATEGORY_OTHER_AMD 0x9150 +typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, void *userParam); +typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); +GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, void *userParam); +GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +#endif +#endif /* GL_AMD_debug_output */ + +#ifndef GL_AMD_depth_clamp_separate +#define GL_AMD_depth_clamp_separate 1 +#define GL_DEPTH_CLAMP_NEAR_AMD 0x901E +#define GL_DEPTH_CLAMP_FAR_AMD 0x901F +#endif /* GL_AMD_depth_clamp_separate */ + +#ifndef GL_AMD_draw_buffers_blend +#define GL_AMD_draw_buffers_blend 1 +typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); +GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); +GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +#endif +#endif /* GL_AMD_draw_buffers_blend */ -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 +#ifndef GL_AMD_gcn_shader +#define GL_AMD_gcn_shader 1 +#endif /* GL_AMD_gcn_shader */ + +#ifndef GL_AMD_gpu_shader_int64 +#define GL_AMD_gpu_shader_int64 1 +typedef int64_t GLint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangefOES (GLclampf n, GLclampf f); -GLAPI void APIENTRY glFrustumfOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -GLAPI void APIENTRY glOrthofOES (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -GLAPI void APIENTRY glClipPlanefOES (GLenum plane, const GLfloat *equation); -GLAPI void APIENTRY glClearDepthfOES (GLclampf depth); -GLAPI void APIENTRY glGetClipPlanefOES (GLenum plane, GLfloat *equation); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEFOESPROC) (GLclampf n, GLclampf f); -typedef void (APIENTRYP PFNGLFRUSTUMFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLORTHOFOESPROC) (GLfloat l, GLfloat r, GLfloat b, GLfloat t, GLfloat n, GLfloat f); -typedef void (APIENTRYP PFNGLCLIPPLANEFOESPROC) (GLenum plane, const GLfloat *equation); -typedef void (APIENTRYP PFNGLCLEARDEPTHFOESPROC) (GLclampf depth); -typedef void (APIENTRYP PFNGLGETCLIPPLANEFOESPROC) (GLenum plane, GLfloat *equation); +GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); +GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #endif +#endif /* GL_AMD_gpu_shader_int64 */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 +#ifndef GL_AMD_interleaved_elements +#define GL_AMD_interleaved_elements 1 +#define GL_VERTEX_ELEMENT_SWIZZLE_AMD 0x91A4 +#define GL_VERTEX_ID_SWIZZLE_AMD 0x91A5 +typedef void (APIENTRYP PFNGLVERTEXATTRIBPARAMETERIAMDPROC) (GLuint index, GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribParameteriAMD (GLuint index, GLenum pname, GLint param); #endif +#endif /* GL_AMD_interleaved_elements */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 +#ifndef GL_AMD_multi_draw_indirect +#define GL_AMD_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const void *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const void *indirect, GLsizei primcount, GLsizei stride); #endif +#endif /* GL_AMD_multi_draw_indirect */ -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 +#ifndef GL_AMD_name_gen_delete +#define GL_AMD_name_gen_delete 1 +#define GL_DATA_BUFFER_AMD 0x9151 +#define GL_PERFORMANCE_MONITOR_AMD 0x9152 +#define GL_QUERY_OBJECT_AMD 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_AMD 0x9154 +#define GL_SAMPLER_OBJECT_AMD 0x9155 +typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); +typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); +typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLbitfield APIENTRY glQueryMatrixxOES (GLfixed *mantissa, GLint *exponent); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLbitfield (APIENTRYP PFNGLQUERYMATRIXXOESPROC) (GLfixed *mantissa, GLint *exponent); +GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); +GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); +GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); #endif +#endif /* GL_AMD_name_gen_delete */ -#ifndef GL_EXT_depth_bounds_test -#define GL_EXT_depth_bounds_test 1 +#ifndef GL_AMD_occlusion_query_event +#define GL_AMD_occlusion_query_event 1 +#define GL_OCCLUSION_QUERY_EVENT_MASK_AMD 0x874F +#define GL_QUERY_DEPTH_PASS_EVENT_BIT_AMD 0x00000001 +#define GL_QUERY_DEPTH_FAIL_EVENT_BIT_AMD 0x00000002 +#define GL_QUERY_STENCIL_FAIL_EVENT_BIT_AMD 0x00000004 +#define GL_QUERY_DEPTH_BOUNDS_FAIL_EVENT_BIT_AMD 0x00000008 +#define GL_QUERY_ALL_EVENT_BITS_AMD 0xFFFFFFFF +typedef void (APIENTRYP PFNGLQUERYOBJECTPARAMETERUIAMDPROC) (GLenum target, GLuint id, GLenum pname, GLuint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +GLAPI void APIENTRY glQueryObjectParameteruiAMD (GLenum target, GLuint id, GLenum pname, GLuint param); #endif +#endif /* GL_AMD_occlusion_query_event */ -#ifndef GL_EXT_texture_mirror_clamp -#define GL_EXT_texture_mirror_clamp 1 +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); #endif +#endif /* GL_AMD_performance_monitor */ -#ifndef GL_EXT_blend_equation_separate -#define GL_EXT_blend_equation_separate 1 +#ifndef GL_AMD_pinned_memory +#define GL_AMD_pinned_memory 1 +#define GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD 0x9160 +#endif /* GL_AMD_pinned_memory */ + +#ifndef GL_AMD_query_buffer_object +#define GL_AMD_query_buffer_object 1 +#define GL_QUERY_BUFFER_AMD 0x9192 +#define GL_QUERY_BUFFER_BINDING_AMD 0x9193 +#define GL_QUERY_RESULT_NO_WAIT_AMD 0x9194 +#endif /* GL_AMD_query_buffer_object */ + +#ifndef GL_AMD_sample_positions +#define GL_AMD_sample_positions 1 +#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F +typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); +#endif +#endif /* GL_AMD_sample_positions */ + +#ifndef GL_AMD_seamless_cubemap_per_texture +#define GL_AMD_seamless_cubemap_per_texture 1 +#endif /* GL_AMD_seamless_cubemap_per_texture */ + +#ifndef GL_AMD_shader_atomic_counter_ops +#define GL_AMD_shader_atomic_counter_ops 1 +#endif /* GL_AMD_shader_atomic_counter_ops */ + +#ifndef GL_AMD_shader_stencil_export +#define GL_AMD_shader_stencil_export 1 +#endif /* GL_AMD_shader_stencil_export */ + +#ifndef GL_AMD_shader_trinary_minmax +#define GL_AMD_shader_trinary_minmax 1 +#endif /* GL_AMD_shader_trinary_minmax */ + +#ifndef GL_AMD_sparse_texture +#define GL_AMD_sparse_texture 1 +#define GL_VIRTUAL_PAGE_SIZE_X_AMD 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_AMD 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_AMD 0x9197 +#define GL_MAX_SPARSE_TEXTURE_SIZE_AMD 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_AMD 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS 0x919A +#define GL_MIN_SPARSE_LEVEL_AMD 0x919B +#define GL_MIN_LOD_WARNING_AMD 0x919C +#define GL_TEXTURE_STORAGE_SPARSE_BIT_AMD 0x00000001 +typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +#endif +#endif /* GL_AMD_sparse_texture */ + +#ifndef GL_AMD_stencil_operation_extended +#define GL_AMD_stencil_operation_extended 1 +#define GL_SET_AMD 0x874A +#define GL_REPLACE_VALUE_AMD 0x874B +#define GL_STENCIL_OP_VALUE_AMD 0x874C +#define GL_STENCIL_BACK_OP_VALUE_AMD 0x874D +typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); +#endif +#endif /* GL_AMD_stencil_operation_extended */ + +#ifndef GL_AMD_texture_texture4 +#define GL_AMD_texture_texture4 1 +#endif /* GL_AMD_texture_texture4 */ + +#ifndef GL_AMD_transform_feedback3_lines_triangles +#define GL_AMD_transform_feedback3_lines_triangles 1 +#endif /* GL_AMD_transform_feedback3_lines_triangles */ + +#ifndef GL_AMD_transform_feedback4 +#define GL_AMD_transform_feedback4 1 +#define GL_STREAM_RASTERIZATION_AMD 0x91A0 +#endif /* GL_AMD_transform_feedback4 */ + +#ifndef GL_AMD_vertex_shader_layer +#define GL_AMD_vertex_shader_layer 1 +#endif /* GL_AMD_vertex_shader_layer */ + +#ifndef GL_AMD_vertex_shader_tessellator +#define GL_AMD_vertex_shader_tessellator 1 +#define GL_SAMPLER_BUFFER_AMD 0x9001 +#define GL_INT_SAMPLER_BUFFER_AMD 0x9002 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003 +#define GL_TESSELLATION_MODE_AMD 0x9004 +#define GL_TESSELLATION_FACTOR_AMD 0x9005 +#define GL_DISCRETE_AMD 0x9006 +#define GL_CONTINUOUS_AMD 0x9007 +typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); -#endif - -#ifndef GL_MESA_pack_invert -#define GL_MESA_pack_invert 1 +GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); +GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); #endif +#endif /* GL_AMD_vertex_shader_tessellator */ -#ifndef GL_MESA_ycbcr_texture -#define GL_MESA_ycbcr_texture 1 -#endif +#ifndef GL_AMD_vertex_shader_viewport_index +#define GL_AMD_vertex_shader_viewport_index 1 +#endif /* GL_AMD_vertex_shader_viewport_index */ -#ifndef GL_EXT_pixel_buffer_object -#define GL_EXT_pixel_buffer_object 1 -#endif +#ifndef GL_APPLE_aux_depth_stencil +#define GL_APPLE_aux_depth_stencil 1 +#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14 +#endif /* GL_APPLE_aux_depth_stencil */ -#ifndef GL_NV_fragment_program_option -#define GL_NV_fragment_program_option 1 -#endif +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif /* GL_APPLE_client_storage */ -#ifndef GL_NV_fragment_program2 -#define GL_NV_fragment_program2 1 +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#define GL_ELEMENT_ARRAY_APPLE 0x8A0C +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8A0D +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x8A0E +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); #endif +#endif /* GL_APPLE_element_array */ -#ifndef GL_NV_vertex_program2_option -#define GL_NV_vertex_program2_option 1 +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei n, GLuint *fences); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint fence); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint fence); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum object, GLuint name); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum object, GLint name); #endif +#endif /* GL_APPLE_fence */ -#ifndef GL_NV_vertex_program3 -#define GL_NV_vertex_program3 1 -#endif +#ifndef GL_APPLE_float_pixels +#define GL_APPLE_float_pixels 1 +#define GL_HALF_APPLE 0x140B +#define GL_RGBA_FLOAT32_APPLE 0x8814 +#define GL_RGB_FLOAT32_APPLE 0x8815 +#define GL_ALPHA_FLOAT32_APPLE 0x8816 +#define GL_INTENSITY_FLOAT32_APPLE 0x8817 +#define GL_LUMINANCE_FLOAT32_APPLE 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819 +#define GL_RGBA_FLOAT16_APPLE 0x881A +#define GL_RGB_FLOAT16_APPLE 0x881B +#define GL_ALPHA_FLOAT16_APPLE 0x881C +#define GL_INTENSITY_FLOAT16_APPLE 0x881D +#define GL_LUMINANCE_FLOAT16_APPLE 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F +#define GL_COLOR_FLOAT_APPLE 0x8A0F +#endif /* GL_APPLE_float_pixels */ -#ifndef GL_EXT_framebuffer_object -#define GL_EXT_framebuffer_object 1 +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); -GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); -GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); -GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); -GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); -GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); -GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); -GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); -GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); -typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); -typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); -typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); -typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); -typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); #endif +#endif /* GL_APPLE_flush_buffer_range */ -#ifndef GL_GREMEDY_string_marker -#define GL_GREMEDY_string_marker 1 +#ifndef GL_APPLE_object_purgeable +#define GL_APPLE_object_purgeable 1 +#define GL_BUFFER_OBJECT_APPLE 0x85B3 +#define GL_RELEASED_APPLE 0x8A19 +#define GL_VOLATILE_APPLE 0x8A1A +#define GL_RETAINED_APPLE 0x8A1B +#define GL_UNDEFINED_APPLE 0x8A1C +#define GL_PURGEABLE_APPLE 0x8A1D +typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const GLvoid *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); -#endif - -#ifndef GL_EXT_packed_depth_stencil -#define GL_EXT_packed_depth_stencil 1 +GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); +GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); #endif +#endif /* GL_APPLE_object_purgeable */ -#ifndef GL_EXT_stencil_clear_tag -#define GL_EXT_stencil_clear_tag 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); -#endif +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ -#ifndef GL_EXT_texture_sRGB -#define GL_EXT_texture_sRGB 1 -#endif +#ifndef GL_APPLE_row_bytes +#define GL_APPLE_row_bytes 1 +#define GL_PACK_ROW_BYTES_APPLE 0x8A15 +#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16 +#endif /* GL_APPLE_row_bytes */ -#ifndef GL_EXT_framebuffer_blit -#define GL_EXT_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif /* GL_APPLE_specular_vector */ -#ifndef GL_EXT_framebuffer_multisample -#define GL_EXT_framebuffer_multisample 1 +#ifndef GL_APPLE_texture_range +#define GL_APPLE_texture_range 1 +#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7 +#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8 +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#define GL_STORAGE_PRIVATE_APPLE 0x85BD +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, void **params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, void **params); #endif +#endif /* GL_APPLE_texture_range */ -#ifndef GL_MESAX_texture_stack -#define GL_MESAX_texture_stack 1 -#endif +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif /* GL_APPLE_transform_hint */ -#ifndef GL_EXT_timer_query -#define GL_EXT_timer_query 1 +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint array); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei n, const GLuint *arrays); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei n, GLuint *arrays); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint array); #endif +#endif /* GL_APPLE_vertex_array_object */ -#ifndef GL_EXT_gpu_program_parameters -#define GL_EXT_gpu_program_parameters 1 +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CLIENT_APPLE 0x85B4 +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, void *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei length, void *pointer); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum pname, GLint param); #endif +#endif /* GL_APPLE_vertex_array_range */ -#ifndef GL_APPLE_flush_buffer_range -#define GL_APPLE_flush_buffer_range 1 +#ifndef GL_APPLE_vertex_program_evaluators +#define GL_APPLE_vertex_program_evaluators 1 +#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00 +#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01 +#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02 +#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03 +#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04 +#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05 +#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06 +#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07 +#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08 +#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09 +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); +typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum target, GLintptr offset, GLsizeiptr size); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); +GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); +GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); +GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); +GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); #endif +#endif /* GL_APPLE_vertex_program_evaluators */ + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#define GL_YCBCR_422_APPLE 0x85B9 +#endif /* GL_APPLE_ycbcr_422 */ -#ifndef GL_NV_gpu_program4 -#define GL_NV_gpu_program4 1 +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glDrawBuffersATI (GLsizei n, const GLenum *bufs); #endif +#endif /* GL_ATI_draw_buffers */ -#ifndef GL_NV_geometry_program4 -#define GL_NV_geometry_program4 1 +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); -GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); -typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glElementPointerATI (GLenum type, const void *pointer); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum mode, GLsizei count); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum mode, GLuint start, GLuint end, GLsizei count); #endif +#endif /* GL_ATI_element_array */ -#ifndef GL_EXT_geometry_shader4 -#define GL_EXT_geometry_shader4 1 +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum pname, const GLint *param); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum pname, const GLfloat *param); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum pname, GLint *param); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum pname, GLfloat *param); #endif +#endif /* GL_ATI_envmap_bumpmap */ -#ifndef GL_NV_vertex_program4 -#define GL_NV_vertex_program4 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); -GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); -GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); -GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); -GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); -GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); -GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); -GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); -GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); -GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); -GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); -GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); -GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint range); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint id); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint dst, GLuint coord, GLenum swizzle); +GLAPI void APIENTRY glSampleMapATI (GLuint dst, GLuint interp, GLenum swizzle); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint dst, const GLfloat *value); #endif +#endif /* GL_ATI_fragment_shader */ -#ifndef GL_EXT_gpu_shader4 -#define GL_EXT_gpu_shader4 1 +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +typedef void *(APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); -GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); -GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); -GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); -GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); -typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); -typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); -typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +GLAPI void *APIENTRY glMapObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint buffer); #endif +#endif /* GL_ATI_map_object_buffer */ -#ifndef GL_EXT_draw_instanced -#define GL_EXT_draw_instanced 1 +#ifndef GL_ATI_meminfo +#define GL_ATI_meminfo 1 +#define GL_VBO_FREE_MEMORY_ATI 0x87FB +#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC +#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD +#endif /* GL_ATI_meminfo */ + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif /* GL_ATI_pixel_format_float */ + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); -typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +GLAPI void APIENTRY glPNTrianglesiATI (GLenum pname, GLint param); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_pn_triangles */ -#ifndef GL_EXT_packed_float -#define GL_EXT_packed_float 1 +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); #endif +#endif /* GL_ATI_separate_stencil */ -#ifndef GL_EXT_texture_array -#define GL_EXT_texture_array 1 +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif /* GL_ATI_text_fragment_shader */ + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif /* GL_ATI_texture_env_combine3 */ + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif /* GL_ATI_texture_float */ + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif /* GL_ATI_texture_mirror_once */ + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const void *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei size, const void *pointer, GLenum usage); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint buffer, GLuint offset, GLsizei size, const void *pointer, GLenum preserve); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint buffer, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint buffer); +GLAPI void APIENTRY glArrayObjectATI (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum array, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum array, GLenum pname, GLint *params); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint id, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint id, GLenum pname, GLint *params); #endif +#endif /* GL_ATI_vertex_array_object */ -#ifndef GL_EXT_texture_buffer_object -#define GL_EXT_texture_buffer_object 1 +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint index, GLenum pname, GLint *params); +#endif +#endif /* GL_ATI_vertex_attrib_array_object */ + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum stream, GLshort x); +GLAPI void APIENTRY glVertexStream1svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream1iATI (GLenum stream, GLint x); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream1fATI (GLenum stream, GLfloat x); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream1dATI (GLenum stream, GLdouble x); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream2sATI (GLenum stream, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexStream2svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream2iATI (GLenum stream, GLint x, GLint y); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream2fATI (GLenum stream, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream2dATI (GLenum stream, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream3sATI (GLenum stream, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream3iATI (GLenum stream, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream3fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream3dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glVertexStream4sATI (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexStream4svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glVertexStream4iATI (GLenum stream, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glVertexStream4fATI (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glVertexStream4dATI (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glNormalStream3bATI (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum stream, const GLbyte *coords); +GLAPI void APIENTRY glNormalStream3sATI (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +GLAPI void APIENTRY glNormalStream3svATI (GLenum stream, const GLshort *coords); +GLAPI void APIENTRY glNormalStream3iATI (GLenum stream, GLint nx, GLint ny, GLint nz); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum stream, const GLint *coords); +GLAPI void APIENTRY glNormalStream3fATI (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum stream, const GLfloat *coords); +GLAPI void APIENTRY glNormalStream3dATI (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum stream, const GLdouble *coords); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum stream); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum pname, GLint param); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum pname, GLfloat param); #endif +#endif /* GL_ATI_vertex_streams */ -#ifndef GL_EXT_texture_compression_latc -#define GL_EXT_texture_compression_latc 1 -#endif +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif /* GL_EXT_422_pixels */ -#ifndef GL_EXT_texture_compression_rgtc -#define GL_EXT_texture_compression_rgtc 1 -#endif +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#define GL_ABGR_EXT 0x8000 +#endif /* GL_EXT_abgr */ -#ifndef GL_EXT_texture_shared_exponent -#define GL_EXT_texture_shared_exponent 1 -#endif +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif /* GL_EXT_bgra */ -#ifndef GL_NV_depth_buffer_float -#define GL_NV_depth_buffer_float 1 +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); -GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); -typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); -typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); -#endif - -#ifndef GL_NV_fragment_program4 -#define GL_NV_fragment_program4 1 +GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); #endif +#endif /* GL_EXT_bindable_uniform */ -#ifndef GL_NV_framebuffer_multisample_coverage -#define GL_NV_framebuffer_multisample_coverage 1 +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -#ifndef GL_EXT_framebuffer_sRGB -#define GL_EXT_framebuffer_sRGB 1 -#endif - -#ifndef GL_NV_geometry_shader4 -#define GL_NV_geometry_shader4 1 +GLAPI void APIENTRY glBlendColorEXT (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); #endif +#endif /* GL_EXT_blend_color */ -#ifndef GL_NV_parameter_buffer_object -#define GL_NV_parameter_buffer_object 1 +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#define GL_BLEND_EQUATION_RGB_EXT 0x8009 +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum modeRGB, GLenum modeAlpha); #endif +#endif /* GL_EXT_blend_equation_separate */ -#ifndef GL_EXT_draw_buffers2 -#define GL_EXT_draw_buffers2 1 +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); -GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); -GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); -GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); -GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); -typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); -typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); -typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); -typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); #endif +#endif /* GL_EXT_blend_func_separate */ -#ifndef GL_NV_transform_feedback -#define GL_NV_transform_feedback 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackNV (void); -GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint count, const GLint *attribs, GLenum bufferMode); -GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); -GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); -GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); -GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); -typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); -typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); -typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); -#endif +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif /* GL_EXT_blend_logic_op */ -#ifndef GL_EXT_bindable_uniform -#define GL_EXT_bindable_uniform 1 +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_BLEND_EQUATION_EXT 0x8009 +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniformBufferEXT (GLuint program, GLint location, GLuint buffer); -GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint program, GLint location); -GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint program, GLint location); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); -typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); -typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +GLAPI void APIENTRY glBlendEquationEXT (GLenum mode); #endif +#endif /* GL_EXT_blend_minmax */ -#ifndef GL_EXT_texture_integer -#define GL_EXT_texture_integer 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); -GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); -typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); -#endif +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif /* GL_EXT_blend_subtract */ -#ifndef GL_GREMEDY_frame_terminator -#define GL_GREMEDY_frame_terminator 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); -#endif +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif /* GL_EXT_clip_volume_hint */ -#ifndef GL_NV_conditional_render -#define GL_NV_conditional_render 1 +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif /* GL_EXT_cmyka */ + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); -GLAPI void APIENTRY glEndConditionalRenderNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +GLAPI void APIENTRY glColorSubTableEXT (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); #endif +#endif /* GL_EXT_color_subtable */ -#ifndef GL_NV_present_video -#define GL_NV_present_video 1 +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); -GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); -typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); -typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glLockArraysEXT (GLint first, GLsizei count); +GLAPI void APIENTRY glUnlockArraysEXT (void); #endif +#endif /* GL_EXT_compiled_vertex_array */ -#ifndef GL_EXT_transform_feedback -#define GL_EXT_transform_feedback 1 +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); -GLAPI void APIENTRY glEndTransformFeedbackEXT (void); -GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); -typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); -typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); -typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode); -typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *image); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum target, GLenum pname, GLfloat params); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum target, GLenum pname, GLint params); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum target, GLenum format, GLenum type, void *image); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum target, GLenum format, GLenum type, void *row, void *column, void *span); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *row, const void *column); #endif +#endif /* GL_EXT_convolution */ -#ifndef GL_EXT_direct_state_access -#define GL_EXT_direct_state_access 1 +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); -GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); -GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); -GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); -GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); -GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); -GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); -GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); -GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); -GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); -GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); -GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); -GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); -GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); -GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); -GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); -GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); -GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); -GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, GLvoid* *data); -GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); -GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); -GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, GLvoid *string); -GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); -GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); -GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); -GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); -GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); -GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); -GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); -GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); -GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); -GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); -GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); -GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); -GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); -GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); -GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); -GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); -GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); -GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); -GLAPI GLvoid* APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); -GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, GLvoid* *params); -GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); -GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); -GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); -GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); -GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); -GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); -GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); -GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); -GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); -GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); -GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); -GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); -GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); -GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); -GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); -GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); -typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +GLAPI void APIENTRY glTangent3bEXT (GLbyte tx, GLbyte ty, GLbyte tz); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glTangent3dEXT (GLdouble tx, GLdouble ty, GLdouble tz); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glTangent3fEXT (GLfloat tx, GLfloat ty, GLfloat tz); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glTangent3iEXT (GLint tx, GLint ty, GLint tz); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *v); +GLAPI void APIENTRY glTangent3sEXT (GLshort tx, GLshort ty, GLshort tz); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte bx, GLbyte by, GLbyte bz); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble bx, GLdouble by, GLdouble bz); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat bx, GLfloat by, GLfloat bz); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glBinormal3iEXT (GLint bx, GLint by, GLint bz); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *v); +GLAPI void APIENTRY glBinormal3sEXT (GLshort bx, GLshort by, GLshort bz); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT (GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_coordinate_frame */ + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_copy_texture */ + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum pname, GLdouble *params); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_cull_vertex */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +typedef void (APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GLAPI void APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GLAPI void APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd zmin, GLclampd zmax); +#endif +#endif /* GL_EXT_depth_bounds_test */ + +#ifndef GL_EXT_direct_state_access +#define GL_EXT_direct_state_access 1 +#define GL_PROGRAM_MATRIX_EXT 0x8E2D +#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E +#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); @@ -12123,54 +6476,30 @@ typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); -typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param); typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); +typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); -typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); -typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); @@ -12186,49 +6515,61 @@ typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum ta typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index); typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data); typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data); -typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits); -typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); -typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, void **data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, void *img); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, void **params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); @@ -12254,6 +6595,16 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); @@ -12262,20 +6613,33 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint l typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); -typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage); -typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access); -typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer); -typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); -typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data); -typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); -typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLENABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEIEXTPROC) (GLenum array, GLuint index); +typedef void (APIENTRYP PFNGLGETFLOATI_VEXTPROC) (GLenum pname, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETDOUBLEI_VEXTPROC) (GLenum pname, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPOINTERI_VEXTPROC) (GLenum pname, GLuint index, void **params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, void *string); typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); @@ -12288,13 +6652,38 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs); typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode); typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLNAMEDCOPYBUFFERSUBDATAEXTPROC) (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer); typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYEDGEFLAGOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYINDEXOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYNORMALOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYTEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYMULTITEXCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYFOGCOORDOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYSECONDARYCOLOROFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYEXTPROC) (GLuint vaobj, GLenum array); +typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBEXTPROC) (GLuint vaobj, GLuint index); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERVEXTPROC) (GLuint vaobj, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERVEXTPROC) (GLuint vaobj, GLenum pname, void **param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYINTEGERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETVERTEXARRAYPOINTERI_VEXTPROC) (GLuint vaobj, GLuint index, GLenum pname, void **param); +typedef void *(APIENTRYP PFNGLMAPNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length); +typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTPROC) (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIEXTPROC) (GLuint framebuffer, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DEXTPROC) (GLuint program, GLint location, GLdouble x); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y); typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DEXTPROC) (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); @@ -12312,30 +6701,3615 @@ typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVEXTPROC) (GLuint program, typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEEXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +typedef void (APIENTRYP PFNGLVERTEXARRAYBINDVERTEXBUFFEREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBIFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLFORMATEXTPROC) (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBBINDINGEXTPROC) (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBINDINGDIVISOREXTPROC) (GLuint vaobj, GLuint bindingindex, GLuint divisor); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +typedef void (APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBDIVISOREXTPROC) (GLuint vaobj, GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GLAPI void APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glMatrixPopEXT (GLenum mode); +GLAPI void APIENTRY glMatrixPushEXT (GLenum mode); +GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield mask); +GLAPI void APIENTRY glTextureParameterfEXT (GLuint texture, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glTextureParameteriEXT (GLuint texture, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetTextureImageEXT (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint texture, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glBindMultiTextureEXT (GLenum texunit, GLenum target, GLuint texture); +GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum texunit, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexEnviEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexGendEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble param); +GLAPI void APIENTRY glMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params); +GLAPI void APIENTRY glMultiTexGenfEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexGeniEXT (GLenum texunit, GLenum coord, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum texunit, GLenum coord, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum texunit, GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, void *pixels); +GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum texunit, GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params); +GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum target, GLuint index, GLfloat *data); +GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum target, GLuint index, GLdouble *data); +GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum target, GLuint index, void **data); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum target, GLuint index); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum target, GLuint index); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum target, GLuint index, GLint *data); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum target, GLuint index, GLboolean *data); +GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint texture, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *bits); +GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum texunit, GLenum target, GLint lod, void *img); +GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GLAPI void APIENTRY glNamedBufferDataEXT (GLuint buffer, GLsizeiptr size, const void *data, GLenum usage); +GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data); +GLAPI void *APIENTRY glMapNamedBufferEXT (GLuint buffer, GLenum access); +GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint buffer); +GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint buffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint buffer, GLenum pname, void **params); +GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, void *data); +GLAPI void APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GLAPI void APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GLAPI void APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GLAPI void APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GLAPI void APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GLAPI void APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GLAPI void APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GLAPI void APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GLAPI void APIENTRY glTextureBufferEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glMultiTexBufferEXT (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer); +GLAPI void APIENTRY glTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint texture, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint texture, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum texunit, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum texunit, GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint program, GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint program, GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint program, GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint program, GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glEnableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glDisableClientStateiEXT (GLenum array, GLuint index); +GLAPI void APIENTRY glGetFloati_vEXT (GLenum pname, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetDoublei_vEXT (GLenum pname, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetPointeri_vEXT (GLenum pname, GLuint index, void **params); +GLAPI void APIENTRY glNamedProgramStringEXT (GLuint program, GLenum target, GLenum format, GLsizei len, const void *string); +GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint program, GLenum target, GLuint index, const GLdouble *params); +GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint program, GLenum target, GLuint index, const GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint program, GLenum target, GLuint index, GLdouble *params); +GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint program, GLenum target, GLuint index, GLfloat *params); +GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint program, GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint program, GLenum target, GLenum pname, void *string); +GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint renderbuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint framebuffer, GLenum target); +GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint texture, GLenum target); +GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum texunit, GLenum target); +GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint framebuffer, GLsizei n, const GLenum *bufs); +GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint framebuffer, GLenum mode); +GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glNamedCopyBufferSubDataEXT (GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer); +GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face); +GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint texture, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum texunit, GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glVertexArrayVertexOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayEdgeFlagOffsetEXT (GLuint vaobj, GLuint buffer, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayIndexOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayNormalOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayMultiTexCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum texunit, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayFogCoordOffsetEXT (GLuint vaobj, GLuint buffer, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArraySecondaryColorOffsetEXT (GLuint vaobj, GLuint buffer, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glVertexArrayVertexAttribIOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glEnableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glDisableVertexArrayEXT (GLuint vaobj, GLenum array); +GLAPI void APIENTRY glEnableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glDisableVertexArrayAttribEXT (GLuint vaobj, GLuint index); +GLAPI void APIENTRY glGetVertexArrayIntegervEXT (GLuint vaobj, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointervEXT (GLuint vaobj, GLenum pname, void **param); +GLAPI void APIENTRY glGetVertexArrayIntegeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, GLint *param); +GLAPI void APIENTRY glGetVertexArrayPointeri_vEXT (GLuint vaobj, GLuint index, GLenum pname, void **param); +GLAPI void *APIENTRY glMapNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access); +GLAPI void APIENTRY glFlushMappedNamedBufferRangeEXT (GLuint buffer, GLintptr offset, GLsizeiptr length); +GLAPI void APIENTRY glNamedBufferStorageEXT (GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags); +GLAPI void APIENTRY glClearNamedBufferDataEXT (GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glClearNamedBufferSubDataEXT (GLuint buffer, GLenum internalformat, GLsizeiptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data); +GLAPI void APIENTRY glNamedFramebufferParameteriEXT (GLuint framebuffer, GLenum pname, GLint param); +GLAPI void APIENTRY glGetNamedFramebufferParameterivEXT (GLuint framebuffer, GLenum pname, GLint *params); +GLAPI void APIENTRY glProgramUniform1dEXT (GLuint program, GLint location, GLdouble x); +GLAPI void APIENTRY glProgramUniform2dEXT (GLuint program, GLint location, GLdouble x, GLdouble y); +GLAPI void APIENTRY glProgramUniform3dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glProgramUniform4dEXT (GLuint program, GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramUniform1dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform2dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform3dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniform4dvEXT (GLuint program, GLint location, GLsizei count, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix2x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix3x4dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x2dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glProgramUniformMatrix4x3dvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value); +GLAPI void APIENTRY glTextureBufferRangeEXT (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +GLAPI void APIENTRY glVertexArrayBindVertexBufferEXT (GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GLAPI void APIENTRY glVertexArrayVertexAttribFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribIFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribLFormatEXT (GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GLAPI void APIENTRY glVertexArrayVertexAttribBindingEXT (GLuint vaobj, GLuint attribindex, GLuint bindingindex); +GLAPI void APIENTRY glVertexArrayVertexBindingDivisorEXT (GLuint vaobj, GLuint bindingindex, GLuint divisor); +GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTexturePageCommitmentEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean resident); +GLAPI void APIENTRY glVertexArrayVertexAttribDivisorEXT (GLuint vaobj, GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_direct_state_access */ + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +#endif +#endif /* GL_EXT_draw_buffers2 */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +#endif +#endif /* GL_EXT_draw_range_elements */ + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat coord); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *coord); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble coord); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *coord); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_fog_coord */ + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit */ + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_EXT_framebuffer_multisample */ + +#ifndef GL_EXT_framebuffer_multisample_blit_scaled +#define GL_EXT_framebuffer_multisample_blit_scaled 1 +#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA +#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB +#endif /* GL_EXT_framebuffer_multisample_blit_scaled */ + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint renderbuffer); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei n, const GLuint *renderbuffers); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei n, GLuint *renderbuffers); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint framebuffer); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum target, GLuint framebuffer); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei n, const GLuint *framebuffers); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei n, GLuint *framebuffers); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum target); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum target); +#endif +#endif /* GL_EXT_framebuffer_object */ + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif /* GL_EXT_framebuffer_sRGB */ + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +#endif +#endif /* GL_EXT_geometry_shader4 */ + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif +#endif /* GL_EXT_gpu_program_parameters */ + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_EXT 0x88FD +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_EXT 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_EXT 0x8905 +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint program, GLint location, GLuint *params); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint program, const GLchar *name); +GLAPI void APIENTRY glUniform1uiEXT (GLint location, GLuint v0); +GLAPI void APIENTRY glUniform2uiEXT (GLint location, GLuint v0, GLuint v1); +GLAPI void APIENTRY glUniform3uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2); +GLAPI void APIENTRY glUniform4uiEXT (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GLAPI void APIENTRY glUniform1uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform2uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform3uivEXT (GLint location, GLsizei count, const GLuint *value); +GLAPI void APIENTRY glUniform4uivEXT (GLint location, GLsizei count, const GLuint *value); +#endif +#endif /* GL_EXT_gpu_shader4 */ + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum target, GLboolean reset, GLenum format, GLenum type, void *values); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glHistogramEXT (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glMinmaxEXT (GLenum target, GLenum internalformat, GLboolean sink); +GLAPI void APIENTRY glResetHistogramEXT (GLenum target); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum target); +#endif +#endif /* GL_EXT_histogram */ + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif /* GL_EXT_index_array_formats */ + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum func, GLclampf ref); +#endif +#endif /* GL_EXT_index_func */ + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_index_material */ + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif /* GL_EXT_index_texture */ + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum mode); +GLAPI void APIENTRY glTextureLightEXT (GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum face, GLenum mode); +#endif +#endif /* GL_EXT_light_texture */ + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif /* GL_EXT_misc_attribute */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT (GLenum pattern); +#endif +#endif /* GL_EXT_multisample */ + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif /* GL_EXT_packed_depth_stencil */ + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif /* GL_EXT_packed_float */ + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif /* GL_EXT_packed_pixels */ + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, void *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glGetColorTableEXT (GLenum target, GLenum format, GLenum type, void *data); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_paletted_texture */ + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif /* GL_EXT_pixel_buffer_object */ + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_EXT_pixel_transform */ + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif /* GL_EXT_pixel_transform_color_table */ + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum pname, const GLfloat *params); +#endif +#endif /* GL_EXT_point_parameters */ + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat factor, GLfloat bias); +#endif +#endif /* GL_EXT_polygon_offset */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_provoking_vertex +#define GL_EXT_provoking_vertex 1 +#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_PROVOKING_VERTEX_EXT 0x8E4F +typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); +#endif +#endif /* GL_EXT_provoking_vertex */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif /* GL_EXT_rescale_normal */ + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *v); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_secondary_color */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8B8D +typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); +typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); +GLAPI void APIENTRY glActiveProgramEXT (GLuint program); +GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif /* GL_EXT_separate_specular_color */ + +#ifndef GL_EXT_shader_image_load_formatted +#define GL_EXT_shader_image_load_formatted 1 +#endif /* GL_EXT_shader_image_load_formatted */ + +#ifndef GL_EXT_shader_image_load_store +#define GL_EXT_shader_image_load_store 1 +#define GL_MAX_IMAGE_UNITS_EXT 0x8F38 +#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS_EXT 0x8F39 +#define GL_IMAGE_BINDING_NAME_EXT 0x8F3A +#define GL_IMAGE_BINDING_LEVEL_EXT 0x8F3B +#define GL_IMAGE_BINDING_LAYERED_EXT 0x8F3C +#define GL_IMAGE_BINDING_LAYER_EXT 0x8F3D +#define GL_IMAGE_BINDING_ACCESS_EXT 0x8F3E +#define GL_IMAGE_1D_EXT 0x904C +#define GL_IMAGE_2D_EXT 0x904D +#define GL_IMAGE_3D_EXT 0x904E +#define GL_IMAGE_2D_RECT_EXT 0x904F +#define GL_IMAGE_CUBE_EXT 0x9050 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_IMAGE_1D_ARRAY_EXT 0x9052 +#define GL_IMAGE_2D_ARRAY_EXT 0x9053 +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_IMAGE_2D_MULTISAMPLE_EXT 0x9055 +#define GL_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9056 +#define GL_INT_IMAGE_1D_EXT 0x9057 +#define GL_INT_IMAGE_2D_EXT 0x9058 +#define GL_INT_IMAGE_3D_EXT 0x9059 +#define GL_INT_IMAGE_2D_RECT_EXT 0x905A +#define GL_INT_IMAGE_CUBE_EXT 0x905B +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_INT_IMAGE_1D_ARRAY_EXT 0x905D +#define GL_INT_IMAGE_2D_ARRAY_EXT 0x905E +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_INT_IMAGE_2D_MULTISAMPLE_EXT 0x9060 +#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x9061 +#define GL_UNSIGNED_INT_IMAGE_1D_EXT 0x9062 +#define GL_UNSIGNED_INT_IMAGE_2D_EXT 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D_EXT 0x9064 +#define GL_UNSIGNED_INT_IMAGE_2D_RECT_EXT 0x9065 +#define GL_UNSIGNED_INT_IMAGE_CUBE_EXT 0x9066 +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY_EXT 0x9068 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY_EXT 0x9069 +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_EXT 0x906B +#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY_EXT 0x906C +#define GL_MAX_IMAGE_SAMPLES_EXT 0x906D +#define GL_IMAGE_BINDING_FORMAT_EXT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT_EXT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT_EXT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT_EXT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT_EXT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT_EXT 0x00000020 +#define GL_COMMAND_BARRIER_BIT_EXT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT_EXT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT_EXT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT_EXT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT_EXT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT_EXT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT_EXT 0x00001000 +#define GL_ALL_BARRIER_BITS_EXT 0xFFFFFFFF +typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); +GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); +#endif +#endif /* GL_EXT_shader_image_load_store */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif /* GL_EXT_shadow_funcs */ + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif /* GL_EXT_shared_texture_palette */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif +#endif /* GL_EXT_stencil_clear_tag */ + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum face); +#endif +#endif /* GL_EXT_stencil_two_side */ + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif /* GL_EXT_stencil_wrap */ + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_subtexture */ + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif /* GL_EXT_texture */ + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +#endif +#endif /* GL_EXT_texture3D */ + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif +#endif /* GL_EXT_texture_array */ + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +#endif +#endif /* GL_EXT_texture_buffer_object */ + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif /* GL_EXT_texture_compression_latc */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_cube_map +#define GL_EXT_texture_cube_map 1 +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif /* GL_EXT_texture_cube_map */ + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif /* GL_EXT_texture_env_add */ + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif /* GL_EXT_texture_env_combine */ + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif /* GL_EXT_texture_env_dot3 */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GLAPI void APIENTRY glClearColorIiEXT (GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif +#endif /* GL_EXT_texture_integer */ + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif /* GL_EXT_texture_lod_bias */ + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif /* GL_EXT_texture_mirror_clamp */ + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei n, const GLuint *textures, GLboolean *residences); +GLAPI void APIENTRY glBindTextureEXT (GLenum target, GLuint texture); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei n, const GLuint *textures); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei n, GLuint *textures); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint texture); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif +#endif /* GL_EXT_texture_object */ + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); +#endif +#endif /* GL_EXT_texture_perturb_normal */ + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_sRGB */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif /* GL_EXT_texture_shared_exponent */ + +#ifndef GL_EXT_texture_snorm +#define GL_EXT_texture_snorm 1 +#define GL_ALPHA_SNORM 0x9010 +#define GL_LUMINANCE_SNORM 0x9011 +#define GL_LUMINANCE_ALPHA_SNORM 0x9012 +#define GL_INTENSITY_SNORM 0x9013 +#define GL_ALPHA8_SNORM 0x9014 +#define GL_LUMINANCE8_SNORM 0x9015 +#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016 +#define GL_INTENSITY8_SNORM 0x9017 +#define GL_ALPHA16_SNORM 0x9018 +#define GL_LUMINANCE16_SNORM 0x9019 +#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A +#define GL_INTENSITY16_SNORM 0x901B +#define GL_RED_SNORM 0x8F90 +#define GL_RG_SNORM 0x8F91 +#define GL_RGB_SNORM 0x8F92 +#define GL_RGBA_SNORM 0x8F93 +#endif /* GL_EXT_texture_snorm */ + +#ifndef GL_EXT_texture_swizzle +#define GL_EXT_texture_swizzle 1 +#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42 +#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43 +#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44 +#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45 +#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46 +#endif /* GL_EXT_texture_swizzle */ + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#define GL_TIME_ELAPSED_EXT 0x88BF +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +#endif +#endif /* GL_EXT_timer_query */ + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackEXT (void); +GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +#endif +#endif /* GL_EXT_transform_feedback */ + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, void **params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint i); +GLAPI void APIENTRY glColorPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glDrawArraysEXT (GLenum mode, GLint first, GLsizei count); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei stride, GLsizei count, const GLboolean *pointer); +GLAPI void APIENTRY glGetPointervEXT (GLenum pname, void **params); +GLAPI void APIENTRY glIndexPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glNormalPointerEXT (GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +GLAPI void APIENTRY glVertexPointerEXT (GLint size, GLenum type, GLsizei stride, GLsizei count, const void *pointer); +#endif +#endif /* GL_EXT_vertex_array */ + +#ifndef GL_EXT_vertex_array_bgra +#define GL_EXT_vertex_array_bgra 1 +#endif /* GL_EXT_vertex_array_bgra */ + +#ifndef GL_EXT_vertex_attrib_64bit +#define GL_EXT_vertex_attrib_64bit 1 +#define GL_DOUBLE_VEC2_EXT 0x8FFC +#define GL_DOUBLE_VEC3_EXT 0x8FFD +#define GL_DOUBLE_VEC4_EXT 0x8FFE +#define GL_DOUBLE_MAT2_EXT 0x8F46 +#define GL_DOUBLE_MAT3_EXT 0x8F47 +#define GL_DOUBLE_MAT4_EXT 0x8F48 +#define GL_DOUBLE_MAT2x3_EXT 0x8F49 +#define GL_DOUBLE_MAT2x4_EXT 0x8F4A +#define GL_DOUBLE_MAT3x2_EXT 0x8F4B +#define GL_DOUBLE_MAT3x4_EXT 0x8F4C +#define GL_DOUBLE_MAT4x2_EXT 0x8F4D +#define GL_DOUBLE_MAT4x3_EXT 0x8F4E +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); +#endif +#endif /* GL_EXT_vertex_attrib_64bit */ + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const void *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const void *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, void **data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint id); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint range); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint id); +GLAPI void APIENTRY glShaderOp1EXT (GLenum op, GLuint res, GLuint arg1); +GLAPI void APIENTRY glShaderOp2EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +GLAPI void APIENTRY glShaderOp3EXT (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +GLAPI void APIENTRY glSwizzleEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glWriteMaskEXT (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +GLAPI void APIENTRY glInsertComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI void APIENTRY glExtractComponentEXT (GLuint res, GLuint src, GLuint num); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +GLAPI void APIENTRY glSetInvariantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint id, GLenum type, const void *addr); +GLAPI void APIENTRY glVariantbvEXT (GLuint id, const GLbyte *addr); +GLAPI void APIENTRY glVariantsvEXT (GLuint id, const GLshort *addr); +GLAPI void APIENTRY glVariantivEXT (GLuint id, const GLint *addr); +GLAPI void APIENTRY glVariantfvEXT (GLuint id, const GLfloat *addr); +GLAPI void APIENTRY glVariantdvEXT (GLuint id, const GLdouble *addr); +GLAPI void APIENTRY glVariantubvEXT (GLuint id, const GLubyte *addr); +GLAPI void APIENTRY glVariantusvEXT (GLuint id, const GLushort *addr); +GLAPI void APIENTRY glVariantuivEXT (GLuint id, const GLuint *addr); +GLAPI void APIENTRY glVariantPointerEXT (GLuint id, GLenum type, GLuint stride, const void *addr); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint id); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint id); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum light, GLenum value); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum face, GLenum value); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum unit, GLenum coord, GLenum value); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum unit, GLenum value); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum value); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint id, GLenum cap); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint id, GLenum value, void **data); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint id, GLenum value, GLboolean *data); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint id, GLenum value, GLint *data); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint id, GLenum value, GLfloat *data); +#endif +#endif /* GL_EXT_vertex_shader */ + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT 0x0BA6 +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT 0x1700 +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const void *pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat weight); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *weight); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLint size, GLenum type, GLsizei stride, const void *pointer); +#endif +#endif /* GL_EXT_vertex_weighting */ + +#ifndef GL_EXT_x11_sync_object +#define GL_EXT_x11_sync_object 1 +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +#endif +#endif /* GL_EXT_x11_sync_object */ + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif +#endif /* GL_GREMEDY_frame_terminator */ + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const void *string); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei len, const void *string); +#endif +#endif /* GL_GREMEDY_string_marker */ + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif /* GL_HP_convolution_border_modes */ + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum target, GLenum pname, GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum target, GLenum pname, GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum target, GLenum pname, GLfloat *params); +#endif +#endif /* GL_HP_image_transform */ + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif /* GL_HP_occlusion_test */ + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif /* GL_HP_texture_lighting */ + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#define GL_CULL_VERTEX_IBM 103050 +#endif /* GL_IBM_cull_vertex */ + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount, GLint modestride); +#endif +#endif /* GL_IBM_multimode_draw_arrays */ + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif /* GL_IBM_rasterpos_clip */ + +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 +#define GL_ALL_STATIC_DATA_IBM 103060 +#define GL_STATIC_VERTEX_ARRAY_IBM 103061 +typedef void (APIENTRYP PFNGLFLUSHSTATICDATAIBMPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushStaticDataIBM (GLenum target); +#endif +#endif /* GL_IBM_static_data */ + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif /* GL_IBM_texture_mirrored_repeat */ + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM (GLint size, GLenum type, GLint stride, const void **pointer, GLint ptrstride); +#endif +#endif /* GL_IBM_vertex_array_lists */ + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif +#endif /* GL_INGR_blend_func_separate */ + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif /* GL_INGR_color_clamp */ + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#define GL_INTERLACE_READ_INGR 0x8568 +#endif /* GL_INGR_interlace_read */ + +#ifndef GL_INTEL_fragment_shader_ordering +#define GL_INTEL_fragment_shader_ordering 1 +#endif /* GL_INTEL_fragment_shader_ordering */ + +#ifndef GL_INTEL_map_texture +#define GL_INTEL_map_texture 1 +#define GL_TEXTURE_MEMORY_LAYOUT_INTEL 0x83FF +#define GL_LAYOUT_DEFAULT_INTEL 0 +#define GL_LAYOUT_LINEAR_INTEL 1 +#define GL_LAYOUT_LINEAR_CPU_CACHED_INTEL 2 +typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); +typedef void *(APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); +GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); +GLAPI void *APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, GLint *stride, GLenum *layout); +#endif +#endif /* GL_INTEL_map_texture */ + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void **pointer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum type, const void **pointer); +GLAPI void APIENTRY glColorPointervINTEL (GLint size, GLenum type, const void **pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint size, GLenum type, const void **pointer); +#endif +#endif /* GL_INTEL_parallel_arrays */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +typedef void (APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GLAPI void APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GLAPI void APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GLAPI void APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GLAPI void APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GLAPI void APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, GLvoid *data, GLuint *bytesWritten); +GLAPI void APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GLAPI void APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif /* GL_MESAX_texture_stack */ + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#define GL_PACK_INVERT_MESA 0x8758 +#endif /* GL_MESA_pack_invert */ + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif +#endif /* GL_MESA_resize_buffers */ + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble x, GLdouble y); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat x, GLfloat y); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos2iMESA (GLint x, GLint y); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort x, GLshort y); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos3iMESA (GLint x, GLint y, GLint z); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *v); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *v); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *v); +GLAPI void APIENTRY glWindowPos4iMESA (GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *v); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *v); +#endif +#endif /* GL_MESA_window_pos */ + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif /* GL_MESA_ycbcr_texture */ + +#ifndef GL_NVX_conditional_render +#define GL_NVX_conditional_render 1 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); +GLAPI void APIENTRY glEndConditionalRenderNVX (void); +#endif +#endif /* GL_NVX_conditional_render */ + +#ifndef GL_NVX_gpu_memory_info +#define GL_NVX_gpu_memory_info 1 +#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047 +#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048 +#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049 +#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A +#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B +#endif /* GL_NVX_gpu_memory_info */ + +#ifndef GL_NV_bindless_multi_draw_indirect +#define GL_NV_bindless_multi_draw_indirect 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect */ + +#ifndef GL_NV_bindless_multi_draw_indirect_count +#define GL_NV_bindless_multi_draw_indirect_count 1 +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTBINDLESSCOUNTNVPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysIndirectBindlessCountNV (GLenum mode, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +GLAPI void APIENTRY glMultiDrawElementsIndirectBindlessCountNV (GLenum mode, GLenum type, const void *indirect, GLsizei drawCount, GLsizei maxDrawCount, GLsizei stride, GLint vertexBufferCount); +#endif +#endif /* GL_NV_bindless_multi_draw_indirect_count */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); +GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GLAPI void APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif /* GL_NV_blend_square */ + +#ifndef GL_NV_compute_program5 +#define GL_NV_compute_program5 1 +#define GL_COMPUTE_PROGRAM_NV 0x90FB +#define GL_COMPUTE_PROGRAM_PARAMETER_BUFFER_NV 0x90FC +#endif /* GL_NV_compute_program5 */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GLAPI void APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif /* GL_NV_copy_depth_to_color */ + +#ifndef GL_NV_copy_image +#define GL_NV_copy_image 1 +typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_NV_copy_image */ + +#ifndef GL_NV_deep_texture3D +#define GL_NV_deep_texture3D 1 +#define GL_MAX_DEEP_3D_TEXTURE_WIDTH_HEIGHT_NV 0x90D0 +#define GL_MAX_DEEP_3D_TEXTURE_DEPTH_NV 0x90D1 +#endif /* GL_NV_deep_texture3D */ + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble zNear, GLdouble zFar); +GLAPI void APIENTRY glClearDepthdNV (GLdouble depth); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble zmin, GLdouble zmax); +#endif +#endif /* GL_NV_depth_buffer_float */ + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#define GL_DEPTH_CLAMP_NV 0x864F +#endif /* GL_NV_depth_clamp */ + +#ifndef GL_NV_draw_texture +#define GL_NV_draw_texture 1 +typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +#endif +#endif /* GL_NV_draw_texture */ + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const void *points); +GLAPI void APIENTRY glMapParameterivNV (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glMapParameterfvNV (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, void *points); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum target, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum target, GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glEvalMapsNV (GLenum target, GLenum mode); +#endif +#endif /* GL_NV_evaluators */ + +#ifndef GL_NV_explicit_multisample +#define GL_NV_explicit_multisample 1 +#define GL_SAMPLE_POSITION_NV 0x8E50 +#define GL_SAMPLE_MASK_NV 0x8E51 +#define GL_SAMPLE_MASK_VALUE_NV 0x8E52 +#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53 +#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54 +#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55 +#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56 +#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57 +#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58 +#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59 +typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); +typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); +GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); +GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); +#endif +#endif /* GL_NV_explicit_multisample */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GLAPI void APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint fence); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint fence); +GLAPI void APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GLAPI void APIENTRY glFinishFenceNV (GLuint fence); +GLAPI void APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif /* GL_NV_float_buffer */ + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +#endif /* GL_NV_fog_distance */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif +#endif /* GL_NV_fragment_program */ + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif /* GL_NV_fragment_program2 */ + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif /* GL_NV_fragment_program4 */ + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif /* GL_NV_fragment_program_option */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufsize, GLfloat *v); +typedef void (APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GLAPI void APIENTRY glGetCoverageModulationTableNV (GLsizei bufsize, GLfloat *v); +GLAPI void APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample_coverage */ + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum target, GLint limit); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif +#endif /* GL_NV_geometry_program4 */ + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif /* GL_NV_geometry_shader4 */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum target, GLuint index, const GLint *params); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum target, GLuint index, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum target, GLuint index, const GLuint *params); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum target, GLuint index, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum target, GLuint index, GLuint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum target, GLuint index, GLint *params); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum target, GLuint index, GLuint *params); +#endif +#endif /* GL_NV_gpu_program4 */ + +#ifndef GL_NV_gpu_program5 +#define GL_NV_gpu_program5 1 +#define GL_MAX_GEOMETRY_PROGRAM_INVOCATIONS_NV 0x8E5A +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_NV 0x8E5C +#define GL_FRAGMENT_PROGRAM_INTERPOLATION_OFFSET_BITS_NV 0x8E5D +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_NV 0x8E5F +#define GL_MAX_PROGRAM_SUBROUTINE_PARAMETERS_NV 0x8F44 +#define GL_MAX_PROGRAM_SUBROUTINE_NUM_NV 0x8F45 +typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); +GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); +#endif +#endif /* GL_NV_gpu_program5 */ + +#ifndef GL_NV_gpu_program5_mem_extended +#define GL_NV_gpu_program5_mem_extended 1 +#endif /* GL_NV_gpu_program5_mem_extended */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +typedef unsigned short GLhalfNV; +#define GL_HALF_FLOAT_NV 0x140B +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glColor4hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV s); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum target, GLhalfNV s); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum target, GLhalfNV s, GLhalfNV t); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum target, const GLhalfNV *v); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV fog); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *fog); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *v); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV weight); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *weight); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint index, GLhalfNV x); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint index, GLhalfNV x, GLhalfNV y); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint index, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint index, GLsizei n, const GLhalfNV *v); +#endif +#endif /* GL_NV_half_float */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif /* GL_NV_light_max_exponent */ + +#ifndef GL_NV_multisample_coverage +#define GL_NV_multisample_coverage 1 +#endif /* GL_NV_multisample_coverage */ + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif /* GL_NV_multisample_filter_hint */ + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei n, GLuint *ids); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei n, const GLuint *ids); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint id); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint id, GLenum pname, GLuint *params); +#endif +#endif /* GL_NV_occlusion_query */ + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif /* GL_NV_packed_depth_stencil */ + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLfloat *params); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLint *params); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum target, GLuint bindingIndex, GLuint wordIndex, GLsizei count, const GLuint *params); +#endif +#endif /* GL_NV_parameter_buffer_object */ + +#ifndef GL_NV_parameter_buffer_object2 +#define GL_NV_parameter_buffer_object2 1 +#endif /* GL_NV_parameter_buffer_object2 */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_2_BYTES_NV 0x1407 +#define GL_3_BYTES_NV 0x1408 +#define GL_4_BYTES_NV 0x1409 +#define GL_EYE_LINEAR_NV 0x2400 +#define GL_OBJECT_LINEAR_NV 0x2401 +#define GL_CONSTANT_NV 0x8576 +#define GL_PATH_FOG_GEN_MODE_NV 0x90AC +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_PATH_GEN_COLOR_FORMAT_NV 0x90B2 +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +typedef GLenum (APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); +typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); +GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); +GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); +GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GLAPI void APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GLAPI void APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI void APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GLAPI GLenum APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint baseAndCount[2]); +GLAPI GLenum APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI GLenum APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GLAPI void APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLfloat *params); +GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); +GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); +GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); +GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); +GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); +GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, const void *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum target, GLsizei length, const void *pointer); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum target); +#endif +#endif /* GL_NV_pixel_data_range */ + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glPointParameterivNV (GLenum pname, const GLint *params); +#endif +#endif /* GL_NV_point_sprite */ + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1); +GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3); +GLAPI void APIENTRY glGetVideoivNV (GLuint video_slot, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVideouivNV (GLuint video_slot, GLenum pname, GLuint *params); +GLAPI void APIENTRY glGetVideoi64vNV (GLuint video_slot, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVideoui64vNV (GLuint video_slot, GLenum pname, GLuint64EXT *params); +#endif +#endif /* GL_NV_present_video */ + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint index); +#endif +#endif /* GL_NV_primitive_restart */ + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum pname, GLfloat param); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum pname, const GLint *params); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum pname, GLint param); +GLAPI void APIENTRY glCombinerInputNV (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glCombinerOutputNV (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum stage, GLenum portion, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum variable, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum variable, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_register_combiners */ + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum stage, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum stage, GLenum pname, GLfloat *params); +#endif +#endif /* GL_NV_register_combiners2 */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_shader_atomic_counters +#define GL_NV_shader_atomic_counters 1 +#endif /* GL_NV_shader_atomic_counters */ + +#ifndef GL_NV_shader_atomic_float +#define GL_NV_shader_atomic_float 1 +#endif /* GL_NV_shader_atomic_float */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_atomic_int64 +#define GL_NV_shader_atomic_int64 1 +#endif /* GL_NV_shader_atomic_int64 */ + +#ifndef GL_NV_shader_buffer_load +#define GL_NV_shader_buffer_load 1 +#define GL_BUFFER_GPU_ADDRESS_NV 0x8F1D +#define GL_GPU_ADDRESS_NV 0x8F34 +#define GL_MAX_SHADER_BUFFER_ADDRESS_NV 0x8F35 +typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); +typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); +typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); +typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); +typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); +typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); +typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); +GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); +GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); +GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); +GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); +GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); +GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); +GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); +GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); +GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); #endif +#endif /* GL_NV_shader_buffer_load */ -#ifndef GL_EXT_vertex_array_bgra -#define GL_EXT_vertex_array_bgra 1 -#endif +#ifndef GL_NV_shader_buffer_store +#define GL_NV_shader_buffer_store 1 +#define GL_SHADER_GLOBAL_ACCESS_BARRIER_BIT_NV 0x00000010 +#endif /* GL_NV_shader_buffer_store */ -#ifndef GL_EXT_texture_swizzle -#define GL_EXT_texture_swizzle 1 +#ifndef GL_NV_shader_storage_buffer_object +#define GL_NV_shader_storage_buffer_object 1 +#endif /* GL_NV_shader_storage_buffer_object */ + +#ifndef GL_NV_shader_thread_group +#define GL_NV_shader_thread_group 1 +#define GL_WARP_SIZE_NV 0x9339 +#define GL_WARPS_PER_SM_NV 0x933A +#define GL_SM_COUNT_NV 0x933B +#endif /* GL_NV_shader_thread_group */ + +#ifndef GL_NV_shader_thread_shuffle +#define GL_NV_shader_thread_shuffle 1 +#endif /* GL_NV_shader_thread_shuffle */ + +#ifndef GL_NV_tessellation_program5 +#define GL_NV_tessellation_program5 1 +#define GL_MAX_PROGRAM_PATCH_ATTRIBS_NV 0x86D8 +#define GL_TESS_CONTROL_PROGRAM_NV 0x891E +#define GL_TESS_EVALUATION_PROGRAM_NV 0x891F +#define GL_TESS_CONTROL_PROGRAM_PARAMETER_BUFFER_NV 0x8C74 +#define GL_TESS_EVALUATION_PROGRAM_PARAMETER_BUFFER_NV 0x8C75 +#endif /* GL_NV_tessellation_program5 */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif /* GL_NV_texgen_emboss */ + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif /* GL_NV_texgen_reflection */ + +#ifndef GL_NV_texture_barrier +#define GL_NV_texture_barrier 1 +typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureBarrierNV (void); #endif +#endif /* GL_NV_texture_barrier */ -#ifndef GL_NV_explicit_multisample -#define GL_NV_explicit_multisample 1 +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif /* GL_NV_texture_compression_vtc */ + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif /* GL_NV_texture_env_combine4 */ + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif /* GL_NV_texture_expand_normal */ + +#ifndef GL_NV_texture_multisample +#define GL_NV_texture_multisample 1 +#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045 +#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046 +typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetMultisamplefvNV (GLenum pname, GLuint index, GLfloat *val); -GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint index, GLbitfield mask); -GLAPI void APIENTRY glTexRenderbufferNV (GLenum target, GLuint renderbuffer); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val); -typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask); -typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer); +GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); +GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); +#endif +#endif /* GL_NV_texture_multisample */ + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif /* GL_NV_texture_rectangle */ + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_2D_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_2D_BIAS_NV 0x86E3 +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif /* GL_NV_texture_shader */ + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif /* GL_NV_texture_shader2 */ + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif /* GL_NV_texture_shader3 */ + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#define GL_LAYER_NV 0x8DAA +#define GL_NEXT_BUFFER_NV -2 +#define GL_SKIP_COMPONENTS4_NV -3 +#define GL_SKIP_COMPONENTS3_NV -4 +#define GL_SKIP_COMPONENTS2_NV -5 +#define GL_SKIP_COMPONENTS1_NV -6 +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKSTREAMATTRIBSNVPROC) (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum primitiveMode); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLsizei count, const GLint *attribs, GLenum bufferMode); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum target, GLuint index, GLuint buffer); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +GLAPI void APIENTRY glActiveVaryingNV (GLuint program, const GLchar *name); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint program, const GLchar *name); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint program, GLuint index, GLint *location); +GLAPI void APIENTRY glTransformFeedbackStreamAttribsNV (GLsizei count, const GLint *attribs, GLsizei nbuffers, const GLint *bufstreams, GLenum bufferMode); #endif +#endif /* GL_NV_transform_feedback */ #ifndef GL_NV_transform_feedback2 #define GL_NV_transform_feedback2 1 +#define GL_TRANSFORM_FEEDBACK_NV 0x8E22 +#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23 +#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25 +typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); +typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum target, GLuint id); GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei n, const GLuint *ids); @@ -12344,148 +10318,495 @@ GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint id); GLAPI void APIENTRY glPauseTransformFeedbackNV (void); GLAPI void APIENTRY glResumeTransformFeedbackNV (void); GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum mode, GLuint id); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id); -typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids); -typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids); -typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id); -typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void); -typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id); #endif +#endif /* GL_NV_transform_feedback2 */ -#ifndef GL_ATI_meminfo -#define GL_ATI_meminfo 1 -#endif +#ifndef GL_NV_uniform_buffer_unified_memory +#define GL_NV_uniform_buffer_unified_memory 1 +#define GL_UNIFORM_BUFFER_UNIFIED_NV 0x936E +#define GL_UNIFORM_BUFFER_ADDRESS_NV 0x936F +#define GL_UNIFORM_BUFFER_LENGTH_NV 0x9370 +#endif /* GL_NV_uniform_buffer_unified_memory */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 +#ifndef GL_NV_vdpau_interop +#define GL_NV_vdpau_interop 1 +typedef GLintptr GLvdpauSurfaceNV; +#define GL_SURFACE_STATE_NV 0x86EB +#define GL_SURFACE_REGISTERED_NV 0x86FD +#define GL_SURFACE_MAPPED_NV 0x8700 +#define GL_WRITE_DISCARD_NV 0x88BE +typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const void *vdpDevice, const void *getProcAddress); +typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +typedef GLboolean (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); +typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); +typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); -typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -#ifndef GL_AMD_texture_texture4 -#define GL_AMD_texture_texture4 1 +GLAPI void APIENTRY glVDPAUInitNV (const void *vdpDevice, const void *getProcAddress); +GLAPI void APIENTRY glVDPAUFiniNV (void); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (const void *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); +GLAPI GLboolean APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); +GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); +GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); #endif +#endif /* GL_NV_vdpau_interop */ -#ifndef GL_AMD_vertex_shader_tessellator -#define GL_AMD_vertex_shader_tessellator 1 +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const void *pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTessellationFactorAMD (GLfloat factor); -GLAPI void APIENTRY glTessellationModeAMD (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor); -typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode); +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei length, const void *pointer); #endif +#endif /* GL_NV_vertex_array_range */ -#ifndef GL_EXT_provoking_vertex -#define GL_EXT_provoking_vertex 1 +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif /* GL_NV_vertex_array_range2 */ + +#ifndef GL_NV_vertex_attrib_integer_64bit +#define GL_NV_vertex_attrib_integer_64bit 1 +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProvokingVertexEXT (GLenum mode); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode); +GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); +GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); +GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); +GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); +GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); +GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); +GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); +GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); #endif +#endif /* GL_NV_vertex_attrib_integer_64bit */ -#ifndef GL_EXT_texture_snorm -#define GL_EXT_texture_snorm 1 +#ifndef GL_NV_vertex_buffer_unified_memory +#define GL_NV_vertex_buffer_unified_memory 1 +#define GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV 0x8F1E +#define GL_ELEMENT_ARRAY_UNIFIED_NV 0x8F1F +#define GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV 0x8F20 +#define GL_VERTEX_ARRAY_ADDRESS_NV 0x8F21 +#define GL_NORMAL_ARRAY_ADDRESS_NV 0x8F22 +#define GL_COLOR_ARRAY_ADDRESS_NV 0x8F23 +#define GL_INDEX_ARRAY_ADDRESS_NV 0x8F24 +#define GL_TEXTURE_COORD_ARRAY_ADDRESS_NV 0x8F25 +#define GL_EDGE_FLAG_ARRAY_ADDRESS_NV 0x8F26 +#define GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV 0x8F27 +#define GL_FOG_COORD_ARRAY_ADDRESS_NV 0x8F28 +#define GL_ELEMENT_ARRAY_ADDRESS_NV 0x8F29 +#define GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV 0x8F2A +#define GL_VERTEX_ARRAY_LENGTH_NV 0x8F2B +#define GL_NORMAL_ARRAY_LENGTH_NV 0x8F2C +#define GL_COLOR_ARRAY_LENGTH_NV 0x8F2D +#define GL_INDEX_ARRAY_LENGTH_NV 0x8F2E +#define GL_TEXTURE_COORD_ARRAY_LENGTH_NV 0x8F2F +#define GL_EDGE_FLAG_ARRAY_LENGTH_NV 0x8F30 +#define GL_SECONDARY_COLOR_ARRAY_LENGTH_NV 0x8F31 +#define GL_FOG_COORD_ARRAY_LENGTH_NV 0x8F32 +#define GL_ELEMENT_ARRAY_LENGTH_NV 0x8F33 +#define GL_DRAW_INDIRECT_UNIFIED_NV 0x8F40 +#define GL_DRAW_INDIRECT_ADDRESS_NV 0x8F41 +#define GL_DRAW_INDIRECT_LENGTH_NV 0x8F42 +typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); +GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); +GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); +GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); +GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); #endif +#endif /* GL_NV_vertex_buffer_unified_memory */ -#ifndef GL_AMD_draw_buffers_blend -#define GL_AMD_draw_buffers_blend 1 +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, void **pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint buf, GLenum src, GLenum dst); -GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint buf, GLenum mode); -GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint buf, GLenum modeRGB, GLenum modeAlpha); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst); -typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode); -typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei n, const GLuint *programs, GLboolean *residences); +GLAPI void APIENTRY glBindProgramNV (GLenum target, GLuint id); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glExecuteProgramNV (GLenum target, GLuint id, const GLfloat *params); +GLAPI void APIENTRY glGenProgramsNV (GLsizei n, GLuint *programs); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum target, GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum target, GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetProgramivNV (GLuint id, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetProgramStringNV (GLuint id, GLenum pname, GLubyte *program); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum target, GLuint address, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint index, GLenum pname, GLdouble *params); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint index, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint index, GLenum pname, void **pointer); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint id); +GLAPI void APIENTRY glLoadProgramNV (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum target, GLuint index, const GLdouble *v); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum target, GLuint index, const GLfloat *v); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum target, GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum target, GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei n, const GLuint *programs); +GLAPI void APIENTRY glTrackMatrixNV (GLenum target, GLuint address, GLenum matrix, GLenum transform); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint index, GLint fsize, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint index, GLdouble x); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint index, GLfloat x); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint index, GLshort x); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint index, GLdouble x, GLdouble y); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint index, GLfloat x, GLfloat y); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint index, GLshort x, GLshort y); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint index, GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint index, const GLdouble *v); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint index, const GLfloat *v); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint index, GLsizei count, const GLdouble *v); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint index, GLsizei count, const GLfloat *v); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint index, GLsizei count, const GLshort *v); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint index, GLsizei count, const GLubyte *v); #endif +#endif /* GL_NV_vertex_program */ -#ifndef GL_APPLE_texture_range -#define GL_APPLE_texture_range 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureRangeAPPLE (GLenum target, GLsizei length, const GLvoid *pointer); -GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum target, GLenum pname, GLvoid* *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params); -#endif +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif /* GL_NV_vertex_program1_1 */ -#ifndef GL_APPLE_float_pixels -#define GL_APPLE_float_pixels 1 -#endif +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif /* GL_NV_vertex_program2 */ -#ifndef GL_APPLE_vertex_program_evaluators -#define GL_APPLE_vertex_program_evaluators 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint index, GLenum pname); -GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint index, GLenum pname); -GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname); -typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -#endif +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif /* GL_NV_vertex_program2_option */ -#ifndef GL_APPLE_aux_depth_stencil -#define GL_APPLE_aux_depth_stencil 1 -#endif +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif /* GL_NV_vertex_program3 */ -#ifndef GL_APPLE_object_purgeable -#define GL_APPLE_object_purgeable 1 +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum objectType, GLuint name, GLenum option); -GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option); -typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params); -#endif - -#ifndef GL_APPLE_row_bytes -#define GL_APPLE_row_bytes 1 -#endif - -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint index, GLint x); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint index, GLint x, GLint y); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint index, GLint x, GLint y, GLint z); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint index, GLint x, GLint y, GLint z, GLint w); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint index, GLuint x); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint index, GLuint x, GLuint y); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint index, GLuint x, GLuint y, GLuint z); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint index, const GLint *v); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint index, const GLuint *v); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint index, const GLbyte *v); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint index, const GLshort *v); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint index, const GLubyte *v); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint index, const GLushort *v); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint index, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint index, GLenum pname, GLuint *params); #endif +#endif /* GL_NV_vertex_program4 */ #ifndef GL_NV_video_capture #define GL_NV_video_capture 1 +#define GL_VIDEO_BUFFER_NV 0x9020 +#define GL_VIDEO_BUFFER_BINDING_NV 0x9021 +#define GL_FIELD_UPPER_NV 0x9022 +#define GL_FIELD_LOWER_NV 0x9023 +#define GL_NUM_VIDEO_CAPTURE_STREAMS_NV 0x9024 +#define GL_NEXT_VIDEO_CAPTURE_BUFFER_STATUS_NV 0x9025 +#define GL_VIDEO_CAPTURE_TO_422_SUPPORTED_NV 0x9026 +#define GL_LAST_VIDEO_CAPTURE_STATUS_NV 0x9027 +#define GL_VIDEO_BUFFER_PITCH_NV 0x9028 +#define GL_VIDEO_COLOR_CONVERSION_MATRIX_NV 0x9029 +#define GL_VIDEO_COLOR_CONVERSION_MAX_NV 0x902A +#define GL_VIDEO_COLOR_CONVERSION_MIN_NV 0x902B +#define GL_VIDEO_COLOR_CONVERSION_OFFSET_NV 0x902C +#define GL_VIDEO_BUFFER_INTERNAL_FORMAT_NV 0x902D +#define GL_PARTIAL_SUCCESS_NV 0x902E +#define GL_SUCCESS_NV 0x902F +#define GL_FAILURE_NV 0x9030 +#define GL_YCBYCR8_422_NV 0x9031 +#define GL_YCBAYCR8A_4224_NV 0x9032 +#define GL_Z6Y10Z6CB10Z6Y10Z6CR10_422_NV 0x9033 +#define GL_Z6Y10Z6CB10Z6A10Z6Y10Z6CR10Z6A10_4224_NV 0x9034 +#define GL_Z4Y12Z4CB12Z4Y12Z4CR12_422_NV 0x9035 +#define GL_Z4Y12Z4CB12Z4A12Z4Y12Z4CR12Z4A12_4224_NV 0x9036 +#define GL_Z4Y12Z4CB12Z4CR12_444_NV 0x9037 +#define GL_VIDEO_CAPTURE_FRAME_WIDTH_NV 0x9038 +#define GL_VIDEO_CAPTURE_FRAME_HEIGHT_NV 0x9039 +#define GL_VIDEO_CAPTURE_FIELD_UPPER_HEIGHT_NV 0x903A +#define GL_VIDEO_CAPTURE_FIELD_LOWER_HEIGHT_NV 0x903B +#define GL_VIDEO_CAPTURE_SURFACE_ORIGIN_NV 0x903C +typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); +typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); +typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginVideoCaptureNV (GLuint video_capture_slot); GLAPI void APIENTRY glBindVideoCaptureStreamBufferNV (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); @@ -12499,645 +10820,948 @@ GLAPI GLenum APIENTRY glVideoCaptureNV (GLuint video_capture_slot, GLuint *seque GLAPI void APIENTRY glVideoCaptureStreamParameterivNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); GLAPI void APIENTRY glVideoCaptureStreamParameterfvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glVideoCaptureStreamParameterdvNV (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMBUFFERNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLintptrARB offset); -typedef void (APIENTRYP PFNGLBINDVIDEOCAPTURESTREAMTEXTURENVPROC) (GLuint video_capture_slot, GLuint stream, GLenum frame_region, GLenum target, GLuint texture); -typedef void (APIENTRYP PFNGLENDVIDEOCAPTURENVPROC) (GLuint video_capture_slot); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTUREIVNVPROC) (GLuint video_capture_slot, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLint *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLfloat *params); -typedef void (APIENTRYP PFNGLGETVIDEOCAPTURESTREAMDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, GLdouble *params); -typedef GLenum (APIENTRYP PFNGLVIDEOCAPTURENVPROC) (GLuint video_capture_slot, GLuint *sequence_num, GLuint64EXT *capture_time); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERIVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLint *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERFVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLfloat *params); -typedef void (APIENTRYP PFNGLVIDEOCAPTURESTREAMPARAMETERDVNVPROC) (GLuint video_capture_slot, GLuint stream, GLenum pname, const GLdouble *params); #endif +#endif /* GL_NV_video_capture */ -#ifndef GL_NV_copy_image -#define GL_NV_copy_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glCopyImageSubDataNV (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATANVPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); -#endif +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif /* GL_OML_interlace */ -#ifndef GL_EXT_separate_shader_objects -#define GL_EXT_separate_shader_objects 1 +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif /* GL_OML_resample */ + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif /* GL_OML_subsample */ + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUseShaderProgramEXT (GLenum type, GLuint program); -GLAPI void APIENTRY glActiveProgramEXT (GLuint program); -GLAPI GLuint APIENTRY glCreateShaderProgramEXT (GLenum type, const GLchar *string); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUSESHADERPROGRAMEXTPROC) (GLenum type, GLuint program); -typedef void (APIENTRYP PFNGLACTIVEPROGRAMEXTPROC) (GLuint program); -typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMEXTPROC) (GLenum type, const GLchar *string); +GLAPI void APIENTRY glHintPGI (GLenum target, GLint mode); #endif +#endif /* GL_PGI_misc_hints */ -#ifndef GL_NV_parameter_buffer_object2 -#define GL_NV_parameter_buffer_object2 1 -#endif +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif /* GL_PGI_vertex_hints */ -#ifndef GL_NV_shader_buffer_load -#define GL_NV_shader_buffer_load 1 +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif /* GL_REND_screen_coordinates */ + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#define GL_RGBA_DXT5_S3TC 0x83A4 +#define GL_RGBA4_DXT5_S3TC 0x83A5 +#endif /* GL_S3_s3tc */ + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMakeBufferResidentNV (GLenum target, GLenum access); -GLAPI void APIENTRY glMakeBufferNonResidentNV (GLenum target); -GLAPI GLboolean APIENTRY glIsBufferResidentNV (GLenum target); -GLAPI void APIENTRY glMakeNamedBufferResidentNV (GLuint buffer, GLenum access); -GLAPI void APIENTRY glMakeNamedBufferNonResidentNV (GLuint buffer); -GLAPI GLboolean APIENTRY glIsNamedBufferResidentNV (GLuint buffer); -GLAPI void APIENTRY glGetBufferParameterui64vNV (GLenum target, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetNamedBufferParameterui64vNV (GLuint buffer, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glGetIntegerui64vNV (GLenum value, GLuint64EXT *result); -GLAPI void APIENTRY glUniformui64NV (GLint location, GLuint64EXT value); -GLAPI void APIENTRY glUniformui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformui64vNV (GLuint program, GLint location, GLuint64EXT *params); -GLAPI void APIENTRY glProgramUniformui64NV (GLuint program, GLint location, GLuint64EXT value); -GLAPI void APIENTRY glProgramUniformui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMAKEBUFFERRESIDENTNVPROC) (GLenum target, GLenum access); -typedef void (APIENTRYP PFNGLMAKEBUFFERNONRESIDENTNVPROC) (GLenum target); -typedef GLboolean (APIENTRYP PFNGLISBUFFERRESIDENTNVPROC) (GLenum target); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERRESIDENTNVPROC) (GLuint buffer, GLenum access); -typedef void (APIENTRYP PFNGLMAKENAMEDBUFFERNONRESIDENTNVPROC) (GLuint buffer); -typedef GLboolean (APIENTRYP PFNGLISNAMEDBUFFERRESIDENTNVPROC) (GLuint buffer); -typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERUI64VNVPROC) (GLenum target, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERUI64VNVPROC) (GLuint buffer, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLGETINTEGERUI64VNVPROC) (GLenum value, GLuint64EXT *result); -typedef void (APIENTRYP PFNGLUNIFORMUI64NVPROC) (GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLUNIFORMUI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64NVPROC) (GLuint program, GLint location, GLuint64EXT value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_detail_texture */ -#ifndef GL_NV_vertex_buffer_unified_memory -#define GL_NV_vertex_buffer_unified_memory 1 +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBufferAddressRangeNV (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -GLAPI void APIENTRY glVertexFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glNormalFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glIndexFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glTexCoordFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glEdgeFlagFormatNV (GLsizei stride); -GLAPI void APIENTRY glSecondaryColorFormatNV (GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glFogCoordFormatNV (GLenum type, GLsizei stride); -GLAPI void APIENTRY glVertexAttribFormatNV (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -GLAPI void APIENTRY glVertexAttribIFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -GLAPI void APIENTRY glGetIntegerui64i_vNV (GLenum value, GLuint index, GLuint64EXT *result); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBUFFERADDRESSRANGENVPROC) (GLenum pname, GLuint index, GLuint64EXT address, GLsizeiptr length); -typedef void (APIENTRYP PFNGLVERTEXFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLNORMALFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLINDEXFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLTEXCOORDFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLEDGEFLAGFORMATNVPROC) (GLsizei stride); -typedef void (APIENTRYP PFNGLSECONDARYCOLORFORMATNVPROC) (GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLFOGCOORDFORMATNVPROC) (GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride); -typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); -typedef void (APIENTRYP PFNGLGETINTEGERUI64I_VNVPROC) (GLenum value, GLuint index, GLuint64EXT *result); +GLAPI void APIENTRY glFogFuncSGIS (GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *points); +#endif +#endif /* GL_SGIS_fog_function */ + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif /* GL_SGIS_generate_mipmap */ + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum pattern); #endif +#endif /* GL_SGIS_multisample */ -#ifndef GL_NV_texture_barrier -#define GL_NV_texture_barrier 1 +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTextureBarrierNV (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXTUREBARRIERNVPROC) (void); +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum pname, GLint param); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum pname, GLint *params); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum pname, GLfloat *params); #endif +#endif /* GL_SGIS_pixel_texture */ -#ifndef GL_AMD_shader_stencil_export -#define GL_AMD_shader_stencil_export 1 -#endif +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif /* GL_SGIS_point_line_texgen */ -#ifndef GL_AMD_seamless_cubemap_per_texture -#define GL_AMD_seamless_cubemap_per_texture 1 +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum pname, const GLfloat *params); #endif +#endif /* GL_SGIS_point_parameters */ -#ifndef GL_AMD_conservative_depth -#define GL_AMD_conservative_depth 1 +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum target, GLsizei n, const GLfloat *points); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum target, GLfloat *points); #endif +#endif /* GL_SGIS_sharpen_texture */ -#ifndef GL_EXT_shader_image_load_store -#define GL_EXT_shader_image_load_store 1 +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBindImageTextureEXT (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -GLAPI void APIENTRY glMemoryBarrierEXT (GLbitfield barriers); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREEXTPROC) (GLuint index, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLint format); -typedef void (APIENTRYP PFNGLMEMORYBARRIEREXTPROC) (GLbitfield barriers); +GLAPI void APIENTRY glTexImage4DSGIS (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const void *pixels); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const void *pixels); #endif +#endif /* GL_SGIS_texture4D */ -#ifndef GL_EXT_vertex_attrib_64bit -#define GL_EXT_vertex_attrib_64bit 1 +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif /* GL_SGIS_texture_border_clamp */ + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1dEXT (GLuint index, GLdouble x); -GLAPI void APIENTRY glVertexAttribL2dEXT (GLuint index, GLdouble x, GLdouble y); -GLAPI void APIENTRY glVertexAttribL3dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z); -GLAPI void APIENTRY glVertexAttribL4dEXT (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -GLAPI void APIENTRY glVertexAttribL1dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL2dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL3dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribL4dvEXT (GLuint index, const GLdouble *v); -GLAPI void APIENTRY glVertexAttribLPointerEXT (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -GLAPI void APIENTRY glGetVertexAttribLdvEXT (GLuint index, GLenum pname, GLdouble *params); -GLAPI void APIENTRY glVertexArrayVertexAttribLOffsetEXT (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DEXTPROC) (GLuint index, GLdouble x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DEXTPROC) (GLuint index, GLdouble x, GLdouble y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DEXTPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVEXTPROC) (GLuint index, const GLdouble *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVEXTPROC) (GLuint index, GLenum pname, GLdouble *params); -typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXATTRIBLOFFSETEXTPROC) (GLuint vaobj, GLuint buffer, GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); #endif +#endif /* GL_SGIS_texture_color_mask */ -#ifndef GL_NV_gpu_program5 -#define GL_NV_gpu_program5 1 +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif /* GL_SGIS_texture_edge_clamp */ + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glProgramSubroutineParametersuivNV (GLenum target, GLsizei count, const GLuint *params); -GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint index, GLuint *param); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLPROGRAMSUBROUTINEPARAMETERSUIVNVPROC) (GLenum target, GLsizei count, const GLuint *params); -typedef void (APIENTRYP PFNGLGETPROGRAMSUBROUTINEPARAMETERUIVNVPROC) (GLenum target, GLuint index, GLuint *param); +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum target, GLenum filter, GLfloat *weights); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); #endif +#endif /* GL_SGIS_texture_filter4 */ -#ifndef GL_NV_gpu_shader5 -#define GL_NV_gpu_shader5 1 +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif /* GL_SGIS_texture_lod */ + +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif /* GL_SGIS_texture_select */ + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#define GL_ASYNC_MARKER_SGIX 0x8329 +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); -GLAPI void APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); -GLAPI void APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); -GLAPI void APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); -GLAPI void APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -GLAPI void APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); -GLAPI void APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -GLAPI void APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint marker); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *markerp); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *markerp); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei range); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint marker, GLsizei range); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint marker); #endif +#endif /* GL_SGIX_async */ + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif /* GL_SGIX_async_histogram */ + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif /* GL_SGIX_async_pixel */ -#ifndef GL_NV_shader_buffer_store -#define GL_NV_shader_buffer_store 1 -#endif +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif /* GL_SGIX_blend_alpha_minmax */ -#ifndef GL_NV_tessellation_program5 -#define GL_NV_tessellation_program5 1 -#endif +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif /* GL_SGIX_calligraphic_fragment */ -#ifndef GL_NV_vertex_attrib_integer_64bit -#define GL_NV_vertex_attrib_integer_64bit 1 +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif /* GL_SGIX_clipmap */ + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif /* GL_SGIX_convolution_accuracy */ + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif /* GL_SGIX_depth_pass_instrument */ + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif /* GL_SGIX_depth_texture */ + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVertexAttribL1i64NV (GLuint index, GLint64EXT x); -GLAPI void APIENTRY glVertexAttribL2i64NV (GLuint index, GLint64EXT x, GLint64EXT y); -GLAPI void APIENTRY glVertexAttribL3i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -GLAPI void APIENTRY glVertexAttribL4i64NV (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -GLAPI void APIENTRY glVertexAttribL1i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4i64vNV (GLuint index, const GLint64EXT *v); -GLAPI void APIENTRY glVertexAttribL1ui64NV (GLuint index, GLuint64EXT x); -GLAPI void APIENTRY glVertexAttribL2ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y); -GLAPI void APIENTRY glVertexAttribL3ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -GLAPI void APIENTRY glVertexAttribL4ui64NV (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -GLAPI void APIENTRY glVertexAttribL1ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL2ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL3ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glVertexAttribL4ui64vNV (GLuint index, const GLuint64EXT *v); -GLAPI void APIENTRY glGetVertexAttribLi64vNV (GLuint index, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetVertexAttribLui64vNV (GLuint index, GLenum pname, GLuint64EXT *params); -GLAPI void APIENTRY glVertexAttribLFormatNV (GLuint index, GLint size, GLenum type, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64NVPROC) (GLuint index, GLint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64NVPROC) (GLuint index, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4I64VNVPROC) (GLuint index, const GLint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64NVPROC) (GLuint index, GLuint64EXT x); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64NVPROC) (GLuint index, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL1UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL2UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL3UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLVERTEXATTRIBL4UI64VNVPROC) (GLuint index, const GLuint64EXT *v); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLI64VNVPROC) (GLuint index, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLUI64VNVPROC) (GLuint index, GLenum pname, GLuint64EXT *params); -typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATNVPROC) (GLuint index, GLint size, GLenum type, GLsizei stride); +GLAPI void APIENTRY glFlushRasterSGIX (void); #endif +#endif /* GL_SGIX_flush_raster */ -#ifndef GL_NV_multisample_coverage -#define GL_NV_multisample_coverage 1 -#endif +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif /* GL_SGIX_fog_offset */ -#ifndef GL_AMD_name_gen_delete -#define GL_AMD_name_gen_delete 1 +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGenNamesAMD (GLenum identifier, GLuint num, GLuint *names); -GLAPI void APIENTRY glDeleteNamesAMD (GLenum identifier, GLuint num, const GLuint *names); -GLAPI GLboolean APIENTRY glIsNameAMD (GLenum identifier, GLuint name); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLGENNAMESAMDPROC) (GLenum identifier, GLuint num, GLuint *names); -typedef void (APIENTRYP PFNGLDELETENAMESAMDPROC) (GLenum identifier, GLuint num, const GLuint *names); -typedef GLboolean (APIENTRYP PFNGLISNAMEAMDPROC) (GLenum identifier, GLuint name); +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum face, GLenum mode); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum light, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum light, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum light, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum light, GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum pname, const GLint *params); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum face, GLenum pname, GLfloat param); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum face, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum face, GLenum pname, GLint param); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum face, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum light, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum light, GLenum pname, GLint *params); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum face, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum face, GLenum pname, GLint *params); +GLAPI void APIENTRY glLightEnviSGIX (GLenum pname, GLint param); #endif +#endif /* GL_SGIX_fragment_lighting */ -#ifndef GL_AMD_debug_output -#define GL_AMD_debug_output 1 +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDebugMessageEnableAMD (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -GLAPI void APIENTRY glDebugMessageInsertAMD (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackAMD (GLDEBUGPROCAMD callback, GLvoid *userParam); -GLAPI GLuint APIENTRY glGetDebugMessageLogAMD (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDEBUGMESSAGEENABLEAMDPROC) (GLenum category, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); -typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTAMDPROC) (GLenum category, GLenum severity, GLuint id, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKAMDPROC) (GLDEBUGPROCAMD callback, GLvoid *userParam); -typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGAMDPROC) (GLuint count, GLsizei bufsize, GLenum *categories, GLuint *severities, GLuint *ids, GLsizei *lengths, GLchar *message); +GLAPI void APIENTRY glFrameZoomSGIX (GLint factor); #endif +#endif /* GL_SGIX_framezoom */ -#ifndef GL_NV_vdpau_interop -#define GL_NV_vdpau_interop 1 +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const void *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glVDPAUInitNV (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -GLAPI void APIENTRY glVDPAUFiniNV (void); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterVideoSurfaceNV (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI GLvdpauSurfaceNV APIENTRY glVDPAURegisterOutputSurfaceNV (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -GLAPI void APIENTRY glVDPAUIsSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUUnregisterSurfaceNV (GLvdpauSurfaceNV surface); -GLAPI void APIENTRY glVDPAUGetSurfaceivNV (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -GLAPI void APIENTRY glVDPAUSurfaceAccessNV (GLvdpauSurfaceNV surface, GLenum access); -GLAPI void APIENTRY glVDPAUMapSurfacesNV (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -GLAPI void APIENTRY glVDPAUUnmapSurfacesNV (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLVDPAUINITNVPROC) (const GLvoid *vdpDevice, const GLvoid *getProcAddress); -typedef void (APIENTRYP PFNGLVDPAUFININVPROC) (void); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTERVIDEOSURFACENVPROC) (const GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef GLvdpauSurfaceNV (APIENTRYP PFNGLVDPAUREGISTEROUTPUTSURFACENVPROC) (GLvoid *vdpSurface, GLenum target, GLsizei numTextureNames, const GLuint *textureNames); -typedef void (APIENTRYP PFNGLVDPAUISSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUUNREGISTERSURFACENVPROC) (GLvdpauSurfaceNV surface); -typedef void (APIENTRYP PFNGLVDPAUGETSURFACEIVNVPROC) (GLvdpauSurfaceNV surface, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); -typedef void (APIENTRYP PFNGLVDPAUSURFACEACCESSNVPROC) (GLvdpauSurfaceNV surface, GLenum access); -typedef void (APIENTRYP PFNGLVDPAUMAPSURFACESNVPROC) (GLsizei numSurfaces, const GLvdpauSurfaceNV *surfaces); -typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, const GLvdpauSurfaceNV *surfaces); +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum pname, const void *params); #endif +#endif /* GL_SGIX_igloo_interface */ -#ifndef GL_AMD_transform_feedback3_lines_triangles -#define GL_AMD_transform_feedback3_lines_triangles 1 +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei size, GLint *buffer); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *marker_p); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint marker); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint marker); #endif +#endif /* GL_SGIX_instruments */ -#ifndef GL_AMD_depth_clamp_separate -#define GL_AMD_depth_clamp_separate 1 -#endif +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#define GL_INTERLACE_SGIX 0x8094 +#endif /* GL_SGIX_interlace */ -#ifndef GL_EXT_texture_sRGB_decode -#define GL_EXT_texture_sRGB_decode 1 -#endif +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif /* GL_SGIX_ir_instrument1 */ -#ifndef GL_NV_texture_multisample -#define GL_NV_texture_multisample 1 +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#define GL_LIST_PRIORITY_SGIX 0x8182 +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations); -typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations); -#endif - -#ifndef GL_AMD_blend_minmax_factor -#define GL_AMD_blend_minmax_factor 1 +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint list, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint list, GLenum pname, GLint *params); +GLAPI void APIENTRY glListParameterfSGIX (GLuint list, GLenum pname, GLfloat param); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint list, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glListParameteriSGIX (GLuint list, GLenum pname, GLint param); +GLAPI void APIENTRY glListParameterivSGIX (GLuint list, GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_list_priority */ -#ifndef GL_AMD_sample_positions -#define GL_AMD_sample_positions 1 +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val); +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum mode); #endif +#endif /* GL_SGIX_pixel_texture */ -#ifndef GL_EXT_x11_sync_object -#define GL_EXT_x11_sync_object 1 +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif /* GL_SGIX_pixel_tiles */ + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags); +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +GLAPI void APIENTRY glDeformSGIX (GLbitfield mask); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield mask); #endif +#endif /* GL_SGIX_polynomial_ffd */ -#ifndef GL_AMD_multi_draw_indirect -#define GL_AMD_multi_draw_indirect 1 +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride); -typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride); +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *equation); #endif +#endif /* GL_SGIX_reference_plane */ -#ifndef GL_EXT_framebuffer_multisample_blit_scaled -#define GL_EXT_framebuffer_multisample_blit_scaled 1 -#endif +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif /* GL_SGIX_resample */ -#ifndef GL_NV_path_rendering -#define GL_NV_path_rendering 1 +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif /* GL_SGIX_scalebias_hint */ + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif /* GL_SGIX_shadow */ + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif /* GL_SGIX_shadow_ambient */ + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint APIENTRY glGenPathsNV (GLsizei range); -GLAPI void APIENTRY glDeletePathsNV (GLuint path, GLsizei range); -GLAPI GLboolean APIENTRY glIsPathNV (GLuint path); -GLAPI void APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -GLAPI void APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); -GLAPI void APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -GLAPI void APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -GLAPI void APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); -GLAPI void APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -GLAPI void APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); -GLAPI void APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); -GLAPI void APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); -GLAPI void APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); -GLAPI void APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -GLAPI void APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); -GLAPI void APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); -GLAPI void APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); -GLAPI void APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); -GLAPI void APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glPathCoverDepthFuncNV (GLenum func); -GLAPI void APIENTRY glPathColorGenNV (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -GLAPI void APIENTRY glPathTexGenNV (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -GLAPI void APIENTRY glPathFogGenNV (GLenum genMode); -GLAPI void APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); -GLAPI void APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -GLAPI void APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); -GLAPI void APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); -GLAPI void APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); -GLAPI void APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -GLAPI void APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -GLAPI void APIENTRY glGetPathColorGenivNV (GLenum color, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathColorGenfvNV (GLenum color, GLenum pname, GLfloat *value); -GLAPI void APIENTRY glGetPathTexGenivNV (GLenum texCoordSet, GLenum pname, GLint *value); -GLAPI void APIENTRY glGetPathTexGenfvNV (GLenum texCoordSet, GLenum pname, GLfloat *value); -GLAPI GLboolean APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); -GLAPI GLboolean APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); -GLAPI GLfloat APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); -GLAPI GLboolean APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint (APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); -typedef void (APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); -typedef GLboolean (APIENTRYP PFNGLISPATHNVPROC) (GLuint path); -typedef void (APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const GLvoid *coords); -typedef void (APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const GLvoid *pathString); -typedef void (APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const GLvoid *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const GLvoid *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); -typedef void (APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); -typedef void (APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); -typedef void (APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); -typedef void (APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); -typedef void (APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); -typedef void (APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); -typedef void (APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); -typedef void (APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); -typedef void (APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); -typedef void (APIENTRYP PFNGLPATHCOLORGENNVPROC) (GLenum color, GLenum genMode, GLenum colorFormat, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHTEXGENNVPROC) (GLenum texCoordSet, GLenum genMode, GLint components, const GLfloat *coeffs); -typedef void (APIENTRYP PFNGLPATHFOGGENNVPROC) (GLenum genMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); -typedef void (APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); -typedef void (APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); -typedef void (APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); -typedef void (APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); -typedef void (APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const GLvoid *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENIVNVPROC) (GLenum color, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHCOLORGENFVNVPROC) (GLenum color, GLenum pname, GLfloat *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENIVNVPROC) (GLenum texCoordSet, GLenum pname, GLint *value); -typedef void (APIENTRYP PFNGLGETPATHTEXGENFVNVPROC) (GLenum texCoordSet, GLenum pname, GLfloat *value); -typedef GLboolean (APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); -typedef GLboolean (APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); -typedef GLfloat (APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); -typedef GLboolean (APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum pname, GLfloat param); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum pname, GLint param); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum pname, const GLint *params); #endif +#endif /* GL_SGIX_sprite */ -#ifndef GL_AMD_pinned_memory -#define GL_AMD_pinned_memory 1 -#endif +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif /* GL_SGIX_subsample */ -#ifndef GL_AMD_stencil_operation_extended -#define GL_AMD_stencil_operation_extended 1 +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glStencilOpValueAMD (GLenum face, GLuint value); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSTENCILOPVALUEAMDPROC) (GLenum face, GLuint value); +GLAPI void APIENTRY glTagSampleBufferSGIX (void); #endif +#endif /* GL_SGIX_tag_sample_buffer */ -#ifndef GL_AMD_vertex_shader_viewport_index -#define GL_AMD_vertex_shader_viewport_index 1 -#endif +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif /* GL_SGIX_texture_add_env */ -#ifndef GL_AMD_vertex_shader_layer -#define GL_AMD_vertex_shader_layer 1 -#endif +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif /* GL_SGIX_texture_coordinate_clamp */ -#ifndef GL_NV_bindless_texture -#define GL_NV_bindless_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GLAPI GLuint64 APIENTRY glGetTextureHandleNV (GLuint texture); -GLAPI GLuint64 APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); -GLAPI void APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); -GLAPI void APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); -GLAPI GLuint64 APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -GLAPI void APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); -GLAPI void APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); -GLAPI void APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); -GLAPI void APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); -GLAPI void APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); -GLAPI void APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -GLAPI GLboolean APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); -GLAPI GLboolean APIENTRY glIsImageHandleResidentNV (GLuint64 handle); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef GLuint64 (APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); -typedef GLuint64 (APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef GLuint64 (APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); -typedef void (APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); -typedef void (APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); -typedef GLboolean (APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); -typedef GLboolean (APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); -#endif +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif /* GL_SGIX_texture_lod_bias */ + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif /* GL_SGIX_texture_multi_buffer */ + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif /* GL_SGIX_texture_scale_bias */ + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif /* GL_SGIX_vertex_preclip */ + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif /* GL_SGIX_ycrcb */ -#ifndef GL_NV_shader_atomic_float -#define GL_NV_shader_atomic_float 1 -#endif +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif /* GL_SGIX_ycrcb_subsample */ -#ifndef GL_AMD_query_buffer_object -#define GL_AMD_query_buffer_object 1 -#endif +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif /* GL_SGIX_ycrcba */ -#ifndef GL_NV_compute_program5 -#define GL_NV_compute_program5 1 -#endif +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif /* GL_SGI_color_matrix */ -#ifndef GL_NV_shader_storage_buffer_object -#define GL_NV_shader_storage_buffer_object 1 +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, void *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const void *table); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +GLAPI void APIENTRY glGetColorTableSGI (GLenum target, GLenum format, GLenum type, void *table); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum target, GLenum pname, GLfloat *params); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum target, GLenum pname, GLint *params); #endif +#endif /* GL_SGI_color_table */ -#ifndef GL_NV_shader_atomic_counters -#define GL_NV_shader_atomic_counters 1 -#endif +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif /* GL_SGI_texture_color_table */ -#ifndef GL_NV_deep_texture3D -#define GL_NV_deep_texture3D 1 +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); #endif +#endif /* GL_SUNX_constant_data */ -#ifndef GL_NVX_conditional_render -#define GL_NVX_conditional_render 1 +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif /* GL_SUN_convolution_border_modes */ + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glBeginConditionalRenderNVX (GLuint id); -GLAPI void APIENTRY glEndConditionalRenderNVX (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVXPROC) (GLuint id); -typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVXPROC) (void); +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint factor); #endif +#endif /* GL_SUN_global_alpha */ -#ifndef GL_AMD_sparse_texture -#define GL_AMD_sparse_texture 1 +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glTexStorageSparseAMD (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -GLAPI void APIENTRY glTextureStorageSparseAMD (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLTEXSTORAGESPARSEAMDPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); -typedef void (APIENTRYP PFNGLTEXTURESTORAGESPARSEAMDPROC) (GLuint texture, GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei layers, GLbitfield flags); +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum mode, GLint first, GLsizei count, GLsizei width); #endif +#endif /* GL_SUN_mesh_array */ -#ifndef GL_AMD_shader_trinary_minmax -#define GL_AMD_shader_trinary_minmax 1 -#endif +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif /* GL_SUN_slice_accum */ -#ifndef GL_INTEL_map_texture -#define GL_INTEL_map_texture 1 +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const void **pointer); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glSyncTextureINTEL (GLuint texture); -GLAPI void APIENTRY glUnmapTexture2DINTEL (GLuint texture, GLint level); -GLAPI GLvoid* APIENTRY glMapTexture2DINTEL (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLSYNCTEXTUREINTELPROC) (GLuint texture); -typedef void (APIENTRYP PFNGLUNMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level); -typedef GLvoid* (APIENTRYP PFNGLMAPTEXTURE2DINTELPROC) (GLuint texture, GLint level, GLbitfield access, const GLint *stride, const GLenum *layout); +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum type, GLsizei stride, const void **pointer); #endif +#endif /* GL_SUN_triangle_list */ -#ifndef GL_NV_draw_texture -#define GL_NV_draw_texture 1 +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glDrawTextureNV (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (APIENTRYP PFNGLDRAWTEXTURENVPROC) (GLuint texture, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); #endif +#endif /* GL_SUN_vertex */ +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif /* GL_WIN_phong_shading */ + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif /* GL_WIN_specular_fog */ #ifdef __cplusplus } diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 33853d933e..6a6894d0d3 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -1,450 +1,33 @@ -/* -=========================================================================== -Copyright (C) 1999-2005 Id Software, Inc. - -This file is part of Quake III Arena source code. - -Quake III Arena source code is free software; you can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation; either version 2 of the License, -or (at your option) any later version. - -Quake III Arena source code is distributed in the hope that it will be -useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with Quake III Arena source code; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================== -*/ -/* -** QGL.H -*/ - -#ifndef __QGL_H__ -#define __QGL_H__ - -#ifndef _WIN32 -#include +#pragma once + +#if defined( __LINT__ ) +# include +#elif defined( _WIN32 ) +# include +# include +#elif defined(MACOS_X) +// Prevent OS X from including its own out-of-date glext.h +# define GL_GLEXT_LEGACY +# include +#elif defined( __linux__ ) +# include +# include +// bk001129 - from cvs1.17 (mkv) +# if defined(__FX__) +# include +# endif +#elif defined( __FreeBSD__ ) // rb010123 +# include +# include +# if defined(__FX__) +# include +# endif #else -#include -#include -#include "glext.h" - -#define GLsizeiptrARB size_t * -#define GLintptrARB int * -#define GLhandleARB unsigned int -#define GLcharARB char +# include #endif -typedef void (APIENTRY *PFNGLCOMBINERPARAMETERFVNV) (GLenum pname,const GLfloat *params); -typedef void (APIENTRY *PFNGLCOMBINERPARAMETERIVNV) (GLenum pname,const GLint *params); -typedef void (APIENTRY *PFNGLCOMBINERPARAMETERFNV) (GLenum pname,GLfloat param); -typedef void (APIENTRY *PFNGLCOMBINERPARAMETERINV) (GLenum pname,GLint param); -typedef void (APIENTRY *PFNGLCOMBINERINPUTNV) (GLenum stage,GLenum portion,GLenum variable,GLenum input,GLenum mapping, - GLenum componentUsage); -typedef void (APIENTRY *PFNGLCOMBINEROUTPUTNV) (GLenum stage,GLenum portion,GLenum abOutput,GLenum cdOutput,GLenum sumOutput, - GLenum scale, GLenum bias,GLboolean abDotProduct,GLboolean cdDotProduct, - GLboolean muxSum); -typedef void (APIENTRY *PFNGLFINALCOMBINERINPUTNV) (GLenum variable,GLenum input,GLenum mapping,GLenum componentUsage); - -typedef void (APIENTRY *PFNGLGETCOMBINERINPUTPARAMETERFVNV) (GLenum stage,GLenum portion,GLenum variable,GLenum pname,GLfloat *params); -typedef void (APIENTRY *PFNGLGETCOMBINERINPUTPARAMETERIVNV) (GLenum stage,GLenum portion,GLenum variable,GLenum pname,GLint *params); -typedef void (APIENTRY *PFNGLGETCOMBINEROUTPUTPARAMETERFVNV) (GLenum stage,GLenum portion,GLenum pname,GLfloat *params); -typedef void (APIENTRY *PFNGLGETCOMBINEROUTPUTPARAMETERIVNV) (GLenum stage,GLenum portion,GLenum pname,GLint *params); -typedef void (APIENTRY *PFNGLGETFINALCOMBINERINPUTPARAMETERFVNV) (GLenum variable,GLenum pname,GLfloat *params); -typedef void (APIENTRY *PFNGLGETFINALCOMBINERINPUTPARAMETERIVNV) (GLenum variable,GLenum pname,GLfloat *params); -/***********************************************************************************************************/ - -// Declare Register Combiners function pointers. -extern PFNGLCOMBINERPARAMETERFVNV qglCombinerParameterfvNV; -extern PFNGLCOMBINERPARAMETERIVNV qglCombinerParameterivNV; -extern PFNGLCOMBINERPARAMETERFNV qglCombinerParameterfNV; -extern PFNGLCOMBINERPARAMETERINV qglCombinerParameteriNV; -extern PFNGLCOMBINERINPUTNV qglCombinerInputNV; -extern PFNGLCOMBINEROUTPUTNV qglCombinerOutputNV; -extern PFNGLFINALCOMBINERINPUTNV qglFinalCombinerInputNV; -extern PFNGLGETCOMBINERINPUTPARAMETERFVNV qglGetCombinerInputParameterfvNV; -extern PFNGLGETCOMBINERINPUTPARAMETERIVNV qglGetCombinerInputParameterivNV; -extern PFNGLGETCOMBINEROUTPUTPARAMETERFVNV qglGetCombinerOutputParameterfvNV; -extern PFNGLGETCOMBINEROUTPUTPARAMETERIVNV qglGetCombinerOutputParameterivNV; -extern PFNGLGETFINALCOMBINERINPUTPARAMETERFVNV qglGetFinalCombinerInputParameterfvNV; -extern PFNGLGETFINALCOMBINERINPUTPARAMETERIVNV qglGetFinalCombinerInputParameterivNV; - -extern void (APIENTRYP qglActiveTextureARB) (GLenum texture); -extern void (APIENTRYP qglClientActiveTextureARB) (GLenum texture); -extern void (APIENTRYP qglMultiTexCoord2fARB) (GLenum target, GLfloat s, GLfloat t); - -extern void (APIENTRYP qglLockArraysEXT) (GLint first, GLsizei count); -extern void (APIENTRYP qglUnlockArraysEXT) (void); - - -//=========================================================================== -#ifdef _WIN32 -extern int ( WINAPI * qwglSwapIntervalEXT)( int interval ); - -extern BOOL ( WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT); -extern HGLRC ( WINAPI * qwglCreateContext)(HDC); -extern HGLRC ( WINAPI * qwglCreateLayerContext)(HDC, int); -extern BOOL ( WINAPI * qwglDeleteContext)(HGLRC); -extern HGLRC ( WINAPI * qwglGetCurrentContext)(VOID); -extern HDC ( WINAPI * qwglGetCurrentDC)(VOID); -extern PROC ( WINAPI * qwglGetProcAddress)(LPCSTR); -extern BOOL ( WINAPI * qwglMakeCurrent)(HDC, HGLRC); -extern BOOL ( WINAPI * qwglShareLists)(HGLRC, HGLRC); -extern BOOL ( WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD); - -extern BOOL ( WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT, - FLOAT, int, LPGLYPHMETRICSFLOAT); - -extern BOOL ( WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT, - LPLAYERPLANEDESCRIPTOR); -extern int ( WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int, - CONST COLORREF *); -extern int ( WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int, - COLORREF *); -extern BOOL ( WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL); -extern BOOL ( WINAPI * qwglSwapLayerBuffers)(HDC, UINT); +#include "glext.h" -extern void ( APIENTRY * qglAccum )(GLenum op, GLfloat value); -extern void ( APIENTRY * qglAlphaFunc )(GLenum func, GLclampf ref); -extern GLboolean ( APIENTRY * qglAreTexturesResident )(GLsizei n, const GLuint *textures, GLboolean *residences); -extern void ( APIENTRY * qglArrayElement )(GLint i); -extern void ( APIENTRY * qglBegin )(GLenum mode); -extern void ( APIENTRY * qglBindTexture )(GLenum target, GLuint texture); -extern void ( APIENTRY * qglBitmap )(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap); -extern void ( APIENTRY * qglBlendFunc )(GLenum sfactor, GLenum dfactor); -extern void ( APIENTRY * qglCallList )(GLuint list); -extern void ( APIENTRY * qglCallLists )(GLsizei n, GLenum type, const GLvoid *lists); -extern void ( APIENTRY * qglClear )(GLbitfield mask); -extern void ( APIENTRY * qglClearAccum )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -extern void ( APIENTRY * qglClearColor )(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -extern void ( APIENTRY * qglClearDepth )(GLclampd depth); -extern void ( APIENTRY * qglClearIndex )(GLfloat c); -extern void ( APIENTRY * qglClearStencil )(GLint s); -extern void ( APIENTRY * qglClipPlane )(GLenum plane, const GLdouble *equation); -extern void ( APIENTRY * qglColor3b )(GLbyte red, GLbyte green, GLbyte blue); -extern void ( APIENTRY * qglColor3bv )(const GLbyte *v); -extern void ( APIENTRY * qglColor3d )(GLdouble red, GLdouble green, GLdouble blue); -extern void ( APIENTRY * qglColor3dv )(const GLdouble *v); -extern void ( APIENTRY * qglColor3f )(GLfloat red, GLfloat green, GLfloat blue); -extern void ( APIENTRY * qglColor3fv )(const GLfloat *v); -extern void ( APIENTRY * qglColor3i )(GLint red, GLint green, GLint blue); -extern void ( APIENTRY * qglColor3iv )(const GLint *v); -extern void ( APIENTRY * qglColor3s )(GLshort red, GLshort green, GLshort blue); -extern void ( APIENTRY * qglColor3sv )(const GLshort *v); -extern void ( APIENTRY * qglColor3ub )(GLubyte red, GLubyte green, GLubyte blue); -extern void ( APIENTRY * qglColor3ubv )(const GLubyte *v); -extern void ( APIENTRY * qglColor3ui )(GLuint red, GLuint green, GLuint blue); -extern void ( APIENTRY * qglColor3uiv )(const GLuint *v); -extern void ( APIENTRY * qglColor3us )(GLushort red, GLushort green, GLushort blue); -extern void ( APIENTRY * qglColor3usv )(const GLushort *v); -extern void ( APIENTRY * qglColor4b )(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); -extern void ( APIENTRY * qglColor4bv )(const GLbyte *v); -extern void ( APIENTRY * qglColor4d )(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); -extern void ( APIENTRY * qglColor4dv )(const GLdouble *v); -extern void ( APIENTRY * qglColor4f )(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -extern void ( APIENTRY * qglColor4fv )(const GLfloat *v); -extern void ( APIENTRY * qglColor4i )(GLint red, GLint green, GLint blue, GLint alpha); -extern void ( APIENTRY * qglColor4iv )(const GLint *v); -extern void ( APIENTRY * qglColor4s )(GLshort red, GLshort green, GLshort blue, GLshort alpha); -extern void ( APIENTRY * qglColor4sv )(const GLshort *v); -extern void ( APIENTRY * qglColor4ub )(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); -extern void ( APIENTRY * qglColor4ubv )(const GLubyte *v); -extern void ( APIENTRY * qglColor4ui )(GLuint red, GLuint green, GLuint blue, GLuint alpha); -extern void ( APIENTRY * qglColor4uiv )(const GLuint *v); -extern void ( APIENTRY * qglColor4us )(GLushort red, GLushort green, GLushort blue, GLushort alpha); -extern void ( APIENTRY * qglColor4usv )(const GLushort *v); -extern void ( APIENTRY * qglColorMask )(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -extern void ( APIENTRY * qglColorMaterial )(GLenum face, GLenum mode); -extern void ( APIENTRY * qglColorPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglCopyPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); -extern void ( APIENTRY * qglCopyTexImage1D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border); -extern void ( APIENTRY * qglCopyTexImage2D )(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -extern void ( APIENTRY * qglCopyTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); -extern void ( APIENTRY * qglCopyTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -extern void ( APIENTRY * qglCullFace )(GLenum mode); -extern void ( APIENTRY * qglDeleteLists )(GLuint list, GLsizei range); -extern void ( APIENTRY * qglDeleteTextures )(GLsizei n, const GLuint *textures); -extern void ( APIENTRY * qglDepthFunc )(GLenum func); -extern void ( APIENTRY * qglDepthMask )(GLboolean flag); -extern void ( APIENTRY * qglDepthRange )(GLclampd zNear, GLclampd zFar); -extern void ( APIENTRY * qglDisable )(GLenum cap); -extern void ( APIENTRY * qglDisableClientState )(GLenum array); -extern void ( APIENTRY * qglDrawArrays )(GLenum mode, GLint first, GLsizei count); -extern void ( APIENTRY * qglDrawBuffer )(GLenum mode); -extern void ( APIENTRY * qglDrawElements )(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices); -extern void ( APIENTRY * qglDrawPixels )(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -extern void ( APIENTRY * qglEdgeFlag )(GLboolean flag); -extern void ( APIENTRY * qglEdgeFlagPointer )(GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglEdgeFlagv )(const GLboolean *flag); -extern void ( APIENTRY * qglEnable )(GLenum cap); -extern void ( APIENTRY * qglEnableClientState )(GLenum array); -extern void ( APIENTRY * qglEnd )(void); -extern void ( APIENTRY * qglEndList )(void); -extern void ( APIENTRY * qglEvalCoord1d )(GLdouble u); -extern void ( APIENTRY * qglEvalCoord1dv )(const GLdouble *u); -extern void ( APIENTRY * qglEvalCoord1f )(GLfloat u); -extern void ( APIENTRY * qglEvalCoord1fv )(const GLfloat *u); -extern void ( APIENTRY * qglEvalCoord2d )(GLdouble u, GLdouble v); -extern void ( APIENTRY * qglEvalCoord2dv )(const GLdouble *u); -extern void ( APIENTRY * qglEvalCoord2f )(GLfloat u, GLfloat v); -extern void ( APIENTRY * qglEvalCoord2fv )(const GLfloat *u); -extern void ( APIENTRY * qglEvalMesh1 )(GLenum mode, GLint i1, GLint i2); -extern void ( APIENTRY * qglEvalMesh2 )(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); -extern void ( APIENTRY * qglEvalPoint1 )(GLint i); -extern void ( APIENTRY * qglEvalPoint2 )(GLint i, GLint j); -extern void ( APIENTRY * qglFeedbackBuffer )(GLsizei size, GLenum type, GLfloat *buffer); -extern void ( APIENTRY * qglFinish )(void); -extern void ( APIENTRY * qglFlush )(void); -extern void ( APIENTRY * qglFogf )(GLenum pname, GLfloat param); -extern void ( APIENTRY * qglFogfv )(GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglFogi )(GLenum pname, GLint param); -extern void ( APIENTRY * qglFogiv )(GLenum pname, const GLint *params); -extern void ( APIENTRY * qglFrontFace )(GLenum mode); -extern void ( APIENTRY * qglFrustum )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -extern GLuint ( APIENTRY * qglGenLists )(GLsizei range); -extern void ( APIENTRY * qglGenTextures )(GLsizei n, GLuint *textures); -extern void ( APIENTRY * qglGetBooleanv )(GLenum pname, GLboolean *params); -extern void ( APIENTRY * qglGetClipPlane )(GLenum plane, GLdouble *equation); -extern void ( APIENTRY * qglGetDoublev )(GLenum pname, GLdouble *params); -extern GLenum ( APIENTRY * qglGetError )(void); -extern void ( APIENTRY * qglGetFloatv )(GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetIntegerv )(GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetLightfv )(GLenum light, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetLightiv )(GLenum light, GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetMapdv )(GLenum target, GLenum query, GLdouble *v); -extern void ( APIENTRY * qglGetMapfv )(GLenum target, GLenum query, GLfloat *v); -extern void ( APIENTRY * qglGetMapiv )(GLenum target, GLenum query, GLint *v); -extern void ( APIENTRY * qglGetMaterialfv )(GLenum face, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetMaterialiv )(GLenum face, GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetPixelMapfv )(GLenum m, GLfloat *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglGetPixelMapuiv )(GLenum m, GLuint *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglGetPixelMapusv )(GLenum m, GLushort *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglGetPointerv )(GLenum pname, GLvoid* *params); -extern void ( APIENTRY * qglGetPolygonStipple )(GLubyte *mask); -extern const GLubyte * ( APIENTRY * qglGetString )(GLenum name); -extern void ( APIENTRY * qglGetTexEnvfv )(GLenum target, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetTexEnviv )(GLenum target, GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetTexGendv )(GLenum coord, GLenum pname, GLdouble *params); -extern void ( APIENTRY * qglGetTexGenfv )(GLenum coord, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetTexGeniv )(GLenum coord, GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetTexImage )(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); -extern void ( APIENTRY * qglGetTexLevelParameterfv )(GLenum target, GLint level, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetTexLevelParameteriv )(GLenum target, GLint level, GLenum pname, GLint *params); -extern void ( APIENTRY * qglGetTexParameterfv )(GLenum target, GLenum pname, GLfloat *params); -extern void ( APIENTRY * qglGetTexParameteriv )(GLenum target, GLenum pname, GLint *params); -extern void ( APIENTRY * qglHint )(GLenum target, GLenum mode); -extern void ( APIENTRY * qglIndexMask )(GLuint mask); -extern void ( APIENTRY * qglIndexPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglIndexd )(GLdouble c); -extern void ( APIENTRY * qglIndexdv )(const GLdouble *c); -extern void ( APIENTRY * qglIndexf )(GLfloat c); -extern void ( APIENTRY * qglIndexfv )(const GLfloat *c); -extern void ( APIENTRY * qglIndexi )(GLint c); -extern void ( APIENTRY * qglIndexiv )(const GLint *c); -extern void ( APIENTRY * qglIndexs )(GLshort c); -extern void ( APIENTRY * qglIndexsv )(const GLshort *c); -extern void ( APIENTRY * qglIndexub )(GLubyte c); -extern void ( APIENTRY * qglIndexubv )(const GLubyte *c); -extern void ( APIENTRY * qglInitNames )(void); -extern void ( APIENTRY * qglInterleavedArrays )(GLenum format, GLsizei stride, const GLvoid *pointer); -extern GLboolean ( APIENTRY * qglIsEnabled )(GLenum cap); -extern GLboolean ( APIENTRY * qglIsList )(GLuint list); -extern GLboolean ( APIENTRY * qglIsTexture )(GLuint texture); -extern void ( APIENTRY * qglLightModelf )(GLenum pname, GLfloat param); -extern void ( APIENTRY * qglLightModelfv )(GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglLightModeli )(GLenum pname, GLint param); -extern void ( APIENTRY * qglLightModeliv )(GLenum pname, const GLint *params); -extern void ( APIENTRY * qglLightf )(GLenum light, GLenum pname, GLfloat param); -extern void ( APIENTRY * qglLightfv )(GLenum light, GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglLighti )(GLenum light, GLenum pname, GLint param); -extern void ( APIENTRY * qglLightiv )(GLenum light, GLenum pname, const GLint *params); -extern void ( APIENTRY * qglLineStipple )(GLint factor, GLushort pattern); -extern void ( APIENTRY * qglLineWidth )(GLfloat width); -extern void ( APIENTRY * qglListBase )(GLuint base); -extern void ( APIENTRY * qglLoadIdentity )(void); -extern void ( APIENTRY * qglLoadMatrixd )(const GLdouble *m); -extern void ( APIENTRY * qglLoadMatrixf )(const GLfloat *m); -extern void ( APIENTRY * qglLoadName )(GLuint name); -extern void ( APIENTRY * qglLogicOp )(GLenum opcode); -extern void ( APIENTRY * qglMap1d )(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points); -extern void ( APIENTRY * qglMap1f )(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points); -extern void ( APIENTRY * qglMap2d )(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points); -extern void ( APIENTRY * qglMap2f )(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points); -extern void ( APIENTRY * qglMapGrid1d )(GLint un, GLdouble u1, GLdouble u2); -extern void ( APIENTRY * qglMapGrid1f )(GLint un, GLfloat u1, GLfloat u2); -extern void ( APIENTRY * qglMapGrid2d )(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); -extern void ( APIENTRY * qglMapGrid2f )(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); -extern void ( APIENTRY * qglMaterialf )(GLenum face, GLenum pname, GLfloat param); -extern void ( APIENTRY * qglMaterialfv )(GLenum face, GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglMateriali )(GLenum face, GLenum pname, GLint param); -extern void ( APIENTRY * qglMaterialiv )(GLenum face, GLenum pname, const GLint *params); -extern void ( APIENTRY * qglMatrixMode )(GLenum mode); -extern void ( APIENTRY * qglMultMatrixd )(const GLdouble *m); -extern void ( APIENTRY * qglMultMatrixf )(const GLfloat *m); -extern void ( APIENTRY * qglNewList )(GLuint list, GLenum mode); -extern void ( APIENTRY * qglNormal3b )(GLbyte nx, GLbyte ny, GLbyte nz); -extern void ( APIENTRY * qglNormal3bv )(const GLbyte *v); -extern void ( APIENTRY * qglNormal3d )(GLdouble nx, GLdouble ny, GLdouble nz); -extern void ( APIENTRY * qglNormal3dv )(const GLdouble *v); -extern void ( APIENTRY * qglNormal3f )(GLfloat nx, GLfloat ny, GLfloat nz); -extern void ( APIENTRY * qglNormal3fv )(const GLfloat *v); -extern void ( APIENTRY * qglNormal3i )(GLint nx, GLint ny, GLint nz); -extern void ( APIENTRY * qglNormal3iv )(const GLint *v); -extern void ( APIENTRY * qglNormal3s )(GLshort nx, GLshort ny, GLshort nz); -extern void ( APIENTRY * qglNormal3sv )(const GLshort *v); -extern void ( APIENTRY * qglNormalPointer )(GLenum type, GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglOrtho )(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); -extern void ( APIENTRY * qglPassThrough )(GLfloat token); -extern void ( APIENTRY * qglPixelMapfv )(GLenum m, GLsizei mapsize, const GLfloat *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglPixelMapuiv )(GLenum m, GLsizei mapsize, const GLuint *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglPixelMapusv )(GLenum m, GLsizei mapsize, const GLushort *values); //rwwRMG - map->m (avoid map type conflict) -extern void ( APIENTRY * qglPixelStoref )(GLenum pname, GLfloat param); -extern void ( APIENTRY * qglPixelStorei )(GLenum pname, GLint param); -extern void ( APIENTRY * qglPixelTransferf )(GLenum pname, GLfloat param); -extern void ( APIENTRY * qglPixelTransferi )(GLenum pname, GLint param); -extern void ( APIENTRY * qglPixelZoom )(GLfloat xfactor, GLfloat yfactor); -extern void ( APIENTRY * qglPointSize )(GLfloat size); -extern void ( APIENTRY * qglPolygonMode )(GLenum face, GLenum mode); -extern void ( APIENTRY * qglPolygonOffset )(GLfloat factor, GLfloat units); -extern void ( APIENTRY * qglPolygonStipple )(const GLubyte *mask); -extern void ( APIENTRY * qglPopAttrib )(void); -extern void ( APIENTRY * qglPopClientAttrib )(void); -extern void ( APIENTRY * qglPopMatrix )(void); -extern void ( APIENTRY * qglPopName )(void); -extern void ( APIENTRY * qglPrioritizeTextures )(GLsizei n, const GLuint *textures, const GLclampf *priorities); -extern void ( APIENTRY * qglPushAttrib )(GLbitfield mask); -extern void ( APIENTRY * qglPushClientAttrib )(GLbitfield mask); -extern void ( APIENTRY * qglPushMatrix )(void); -extern void ( APIENTRY * qglPushName )(GLuint name); -extern void ( APIENTRY * qglRasterPos2d )(GLdouble x, GLdouble y); -extern void ( APIENTRY * qglRasterPos2dv )(const GLdouble *v); -extern void ( APIENTRY * qglRasterPos2f )(GLfloat x, GLfloat y); -extern void ( APIENTRY * qglRasterPos2fv )(const GLfloat *v); -extern void ( APIENTRY * qglRasterPos2i )(GLint x, GLint y); -extern void ( APIENTRY * qglRasterPos2iv )(const GLint *v); -extern void ( APIENTRY * qglRasterPos2s )(GLshort x, GLshort y); -extern void ( APIENTRY * qglRasterPos2sv )(const GLshort *v); -extern void ( APIENTRY * qglRasterPos3d )(GLdouble x, GLdouble y, GLdouble z); -extern void ( APIENTRY * qglRasterPos3dv )(const GLdouble *v); -extern void ( APIENTRY * qglRasterPos3f )(GLfloat x, GLfloat y, GLfloat z); -extern void ( APIENTRY * qglRasterPos3fv )(const GLfloat *v); -extern void ( APIENTRY * qglRasterPos3i )(GLint x, GLint y, GLint z); -extern void ( APIENTRY * qglRasterPos3iv )(const GLint *v); -extern void ( APIENTRY * qglRasterPos3s )(GLshort x, GLshort y, GLshort z); -extern void ( APIENTRY * qglRasterPos3sv )(const GLshort *v); -extern void ( APIENTRY * qglRasterPos4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern void ( APIENTRY * qglRasterPos4dv )(const GLdouble *v); -extern void ( APIENTRY * qglRasterPos4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern void ( APIENTRY * qglRasterPos4fv )(const GLfloat *v); -extern void ( APIENTRY * qglRasterPos4i )(GLint x, GLint y, GLint z, GLint w); -extern void ( APIENTRY * qglRasterPos4iv )(const GLint *v); -extern void ( APIENTRY * qglRasterPos4s )(GLshort x, GLshort y, GLshort z, GLshort w); -extern void ( APIENTRY * qglRasterPos4sv )(const GLshort *v); -extern void ( APIENTRY * qglReadBuffer )(GLenum mode); -extern void ( APIENTRY * qglReadPixels )(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); -extern void ( APIENTRY * qglRectd )(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); -extern void ( APIENTRY * qglRectdv )(const GLdouble *v1, const GLdouble *v2); -extern void ( APIENTRY * qglRectf )(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); -extern void ( APIENTRY * qglRectfv )(const GLfloat *v1, const GLfloat *v2); -extern void ( APIENTRY * qglRecti )(GLint x1, GLint y1, GLint x2, GLint y2); -extern void ( APIENTRY * qglRectiv )(const GLint *v1, const GLint *v2); -extern void ( APIENTRY * qglRects )(GLshort x1, GLshort y1, GLshort x2, GLshort y2); -extern void ( APIENTRY * qglRectsv )(const GLshort *v1, const GLshort *v2); -extern GLint ( APIENTRY * qglRenderMode )(GLenum mode); -extern void ( APIENTRY * qglRotated )(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); -extern void ( APIENTRY * qglRotatef )(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); -extern void ( APIENTRY * qglScaled )(GLdouble x, GLdouble y, GLdouble z); -extern void ( APIENTRY * qglScalef )(GLfloat x, GLfloat y, GLfloat z); -extern void ( APIENTRY * qglScissor )(GLint x, GLint y, GLsizei width, GLsizei height); -extern void ( APIENTRY * qglSelectBuffer )(GLsizei size, GLuint *buffer); -extern void ( APIENTRY * qglShadeModel )(GLenum mode); -extern void ( APIENTRY * qglStencilFunc )(GLenum func, GLint ref, GLuint mask); -extern void ( APIENTRY * qglStencilMask )(GLuint mask); -extern void ( APIENTRY * qglStencilOp )(GLenum fail, GLenum zfail, GLenum zpass); -extern void ( APIENTRY * qglTexCoord1d )(GLdouble s); -extern void ( APIENTRY * qglTexCoord1dv )(const GLdouble *v); -extern void ( APIENTRY * qglTexCoord1f )(GLfloat s); -extern void ( APIENTRY * qglTexCoord1fv )(const GLfloat *v); -extern void ( APIENTRY * qglTexCoord1i )(GLint s); -extern void ( APIENTRY * qglTexCoord1iv )(const GLint *v); -extern void ( APIENTRY * qglTexCoord1s )(GLshort s); -extern void ( APIENTRY * qglTexCoord1sv )(const GLshort *v); -extern void ( APIENTRY * qglTexCoord2d )(GLdouble s, GLdouble t); -extern void ( APIENTRY * qglTexCoord2dv )(const GLdouble *v); -extern void ( APIENTRY * qglTexCoord2f )(GLfloat s, GLfloat t); -extern void ( APIENTRY * qglTexCoord2fv )(const GLfloat *v); -extern void ( APIENTRY * qglTexCoord2i )(GLint s, GLint t); -extern void ( APIENTRY * qglTexCoord2iv )(const GLint *v); -extern void ( APIENTRY * qglTexCoord2s )(GLshort s, GLshort t); -extern void ( APIENTRY * qglTexCoord2sv )(const GLshort *v); -extern void ( APIENTRY * qglTexCoord3d )(GLdouble s, GLdouble t, GLdouble r); -extern void ( APIENTRY * qglTexCoord3dv )(const GLdouble *v); -extern void ( APIENTRY * qglTexCoord3f )(GLfloat s, GLfloat t, GLfloat r); -extern void ( APIENTRY * qglTexCoord3fv )(const GLfloat *v); -extern void ( APIENTRY * qglTexCoord3i )(GLint s, GLint t, GLint r); -extern void ( APIENTRY * qglTexCoord3iv )(const GLint *v); -extern void ( APIENTRY * qglTexCoord3s )(GLshort s, GLshort t, GLshort r); -extern void ( APIENTRY * qglTexCoord3sv )(const GLshort *v); -extern void ( APIENTRY * qglTexCoord4d )(GLdouble s, GLdouble t, GLdouble r, GLdouble q); -extern void ( APIENTRY * qglTexCoord4dv )(const GLdouble *v); -extern void ( APIENTRY * qglTexCoord4f )(GLfloat s, GLfloat t, GLfloat r, GLfloat q); -extern void ( APIENTRY * qglTexCoord4fv )(const GLfloat *v); -extern void ( APIENTRY * qglTexCoord4i )(GLint s, GLint t, GLint r, GLint q); -extern void ( APIENTRY * qglTexCoord4iv )(const GLint *v); -extern void ( APIENTRY * qglTexCoord4s )(GLshort s, GLshort t, GLshort r, GLshort q); -extern void ( APIENTRY * qglTexCoord4sv )(const GLshort *v); -extern void ( APIENTRY * qglTexCoordPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglTexEnvf )(GLenum target, GLenum pname, GLfloat param); -extern void ( APIENTRY * qglTexEnvfv )(GLenum target, GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglTexEnvi )(GLenum target, GLenum pname, GLint param); -extern void ( APIENTRY * qglTexEnviv )(GLenum target, GLenum pname, const GLint *params); -extern void ( APIENTRY * qglTexGend )(GLenum coord, GLenum pname, GLdouble param); -extern void ( APIENTRY * qglTexGendv )(GLenum coord, GLenum pname, const GLdouble *params); -extern void ( APIENTRY * qglTexGenf )(GLenum coord, GLenum pname, GLfloat param); -extern void ( APIENTRY * qglTexGenfv )(GLenum coord, GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglTexGeni )(GLenum coord, GLenum pname, GLint param); -extern void ( APIENTRY * qglTexGeniv )(GLenum coord, GLenum pname, const GLint *params); -extern void ( APIENTRY * qglTexImage1D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -extern void ( APIENTRY * qglTexImage2D )(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); -extern void ( APIENTRY * qglTexParameterf )(GLenum target, GLenum pname, GLfloat param); -extern void ( APIENTRY * qglTexParameterfv )(GLenum target, GLenum pname, const GLfloat *params); -extern void ( APIENTRY * qglTexParameteri )(GLenum target, GLenum pname, GLint param); -extern void ( APIENTRY * qglTexParameteriv )(GLenum target, GLenum pname, const GLint *params); -extern void ( APIENTRY * qglTexSubImage1D )(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); -extern void ( APIENTRY * qglTexSubImage2D )(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); -extern void ( APIENTRY * qglTranslated )(GLdouble x, GLdouble y, GLdouble z); -extern void ( APIENTRY * qglTranslatef )(GLfloat x, GLfloat y, GLfloat z); -extern void ( APIENTRY * qglVertex2d )(GLdouble x, GLdouble y); -extern void ( APIENTRY * qglVertex2dv )(const GLdouble *v); -extern void ( APIENTRY * qglVertex2f )(GLfloat x, GLfloat y); -extern void ( APIENTRY * qglVertex2fv )(const GLfloat *v); -extern void ( APIENTRY * qglVertex2i )(GLint x, GLint y); -extern void ( APIENTRY * qglVertex2iv )(const GLint *v); -extern void ( APIENTRY * qglVertex2s )(GLshort x, GLshort y); -extern void ( APIENTRY * qglVertex2sv )(const GLshort *v); -extern void ( APIENTRY * qglVertex3d )(GLdouble x, GLdouble y, GLdouble z); -extern void ( APIENTRY * qglVertex3dv )(const GLdouble *v); -extern void ( APIENTRY * qglVertex3f )(GLfloat x, GLfloat y, GLfloat z); -extern void ( APIENTRY * qglVertex3fv )(const GLfloat *v); -extern void ( APIENTRY * qglVertex3i )(GLint x, GLint y, GLint z); -extern void ( APIENTRY * qglVertex3iv )(const GLint *v); -extern void ( APIENTRY * qglVertex3s )(GLshort x, GLshort y, GLshort z); -extern void ( APIENTRY * qglVertex3sv )(const GLshort *v); -extern void ( APIENTRY * qglVertex4d )(GLdouble x, GLdouble y, GLdouble z, GLdouble w); -extern void ( APIENTRY * qglVertex4dv )(const GLdouble *v); -extern void ( APIENTRY * qglVertex4f )(GLfloat x, GLfloat y, GLfloat z, GLfloat w); -extern void ( APIENTRY * qglVertex4fv )(const GLfloat *v); -extern void ( APIENTRY * qglVertex4i )(GLint x, GLint y, GLint z, GLint w); -extern void ( APIENTRY * qglVertex4iv )(const GLint *v); -extern void ( APIENTRY * qglVertex4s )(GLshort x, GLshort y, GLshort z, GLshort w); -extern void ( APIENTRY * qglVertex4sv )(const GLshort *v); -extern void ( APIENTRY * qglVertexPointer )(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -extern void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei height); -#else #define qglAccum glAccum #define qglAlphaFunc glAlphaFunc #define qglAreTexturesResident glAreTexturesResident @@ -779,7 +362,6 @@ extern void ( APIENTRY * qglViewport )(GLint x, GLint y, GLsizei width, GLsizei #define qglVertex4sv glVertex4sv #define qglVertexPointer glVertexPointer #define qglViewport glViewport -#endif //_WIN32 // Drawing commands extern PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; @@ -1028,8 +610,6 @@ extern HGLRC(APIENTRY * qwglCreateContextAttribsARB) (HDC hdC, HGLRC hS extern GLXContext (APIENTRY * qglXCreateContextAttribsARB) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); #endif -#endif - #ifdef _WIN32 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index d5892e3c52..a8b1cb96c5 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1728,7 +1728,7 @@ const void *RB_SwapBuffers( const void *data ) { GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); - GLimp_EndFrame(); + ri->WIN_Present( &window ); backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 735e08aff2..5127b2a099 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -144,7 +144,7 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) if ( r > 1.0f || g > 1.0f || b > 1.0f ) { - float high = max (max (r, g), b); + float high = Q_max (Q_max (r, g), b); r /= high; g /= high; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index df6ddc59d5..28affed984 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -23,14 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -#ifndef _WIN32 -#include -#define GL_GetProcAddress SDL_GL_GetProcAddress -#else -#include "../win32/glw_win.h" -extern glwstate_t glw_state; -#define GL_GetProcAddress qwglGetProcAddress -#endif +#define GL_GetProcAddress ri->GL_GetProcAddress // Drawing commands PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index cec63c862a..741fe574f7 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -319,10 +319,10 @@ class CBoneCache const model_t *mod; // these are split for better cpu cache behavior - vector mBones; - vector mFinalBones; + std::vector mBones; + std::vector mFinalBones; - vector mSmoothBones; // for render smoothing + std::vector mSmoothBones; // for render smoothing //vector mSkels; boneInfo_v *rootBoneList; @@ -2458,9 +2458,9 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from if (RS.gore_set && drawGore) { int curTime = G2API_GetTime(tr.refdef.time); - pair::iterator,multimap::iterator> range= + std::pair::iterator,std::multimap::iterator> range= RS.gore_set->mGoreRecords.equal_range(RS.surfaceNum); - multimap::iterator k,kcur; + std::multimap::iterator k,kcur; CRenderableSurface *last=newSurf; for (k=range.first;k!=range.second;) { diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 8203bd862b..e4f63eac8f 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1930,7 +1930,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light static int CalcNumMipmapLevels ( int width, int height ) { - return static_cast(ceil (log2 (max (width, height))) + 1); + return static_cast(ceil (log2 (Q_max (width, height))) + 1); } static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, int flags, qboolean subtexture ) @@ -3028,7 +3028,7 @@ void R_SetColorMappings( void ) { if ( glConfig.deviceSupportsGamma ) { - GLimp_SetGamma( s_gammatable, s_gammatable, s_gammatable ); + ri->WIN_SetGamma( &glConfig, s_gammatable, s_gammatable, s_gammatable ); } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 144f4c18c0..5e6b3e6b41 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -26,16 +26,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez +bool g_bTextureRectangleHack = false; glconfig_t glConfig; glconfigExt_t glConfigExt; glRefConfig_t glRefConfig; -float displayAspect = 0.0f; - glstate_t glState; - -static void GfxInfo_f( void ); -static void GfxMemInfo_f( void ); +window_t window; cvar_t *se_language; @@ -43,8 +40,6 @@ cvar_t *r_flareSize; cvar_t *r_flareFade; cvar_t *r_flareCoeff; -cvar_t *r_displayRefresh; - cvar_t *r_verbose; cvar_t *r_ignore; @@ -61,7 +56,6 @@ cvar_t *r_anaglyphMode; cvar_t *r_greyscale; -cvar_t *r_ignorehwgamma; cvar_t *r_measureOverdraw; cvar_t *r_inGameVideo; @@ -164,11 +158,7 @@ cvar_t *r_ignoreDstAlpha; cvar_t *r_ignoreGLErrors; cvar_t *r_logFile; -cvar_t *r_stencilbits; -cvar_t *r_depthbits; -cvar_t *r_colorbits; cvar_t *r_texturebits; -cvar_t *r_ext_multisample; cvar_t *r_drawBuffer; cvar_t *r_lightmap; @@ -176,7 +166,6 @@ cvar_t *r_vertexLight; cvar_t *r_uiFullScreen; cvar_t *r_shadows; cvar_t *r_flares; -cvar_t *r_mode; cvar_t *r_nobind; cvar_t *r_singleShader; cvar_t *r_roundImagesDown; @@ -187,7 +176,6 @@ cvar_t *r_showsky; cvar_t *r_shownormals; cvar_t *r_finish; cvar_t *r_clear; -cvar_t *r_swapInterval; cvar_t *r_markcount; cvar_t *r_textureMode; cvar_t *r_offsetFactor; @@ -201,13 +189,7 @@ cvar_t *r_portalOnly; cvar_t *r_subdivisions; cvar_t *r_lodCurveError; -cvar_t *r_fullscreen; -cvar_t *r_noborder; -cvar_t *r_centerWindow; -cvar_t *r_customwidth; -cvar_t *r_customheight; -cvar_t *r_customPixelAspect; cvar_t *r_overBrightBits; cvar_t *r_mapOverBrightBits; @@ -273,6 +255,47 @@ cvar_t *r_dynamicGlowSoft; cvar_t *r_dynamicGlowWidth; cvar_t *r_dynamicGlowHeight; +PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB; +PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB; +PFNGLMULTITEXCOORD2FARBPROC qglMultiTexCoord2fARB; + +PFNGLCOMBINERPARAMETERFVNVPROC qglCombinerParameterfvNV; +PFNGLCOMBINERPARAMETERIVNVPROC qglCombinerParameterivNV; +PFNGLCOMBINERPARAMETERFNVPROC qglCombinerParameterfNV; +PFNGLCOMBINERPARAMETERINVPROC qglCombinerParameteriNV; +PFNGLCOMBINERINPUTNVPROC qglCombinerInputNV; +PFNGLCOMBINEROUTPUTNVPROC qglCombinerOutputNV; + +PFNGLFINALCOMBINERINPUTNVPROC qglFinalCombinerInputNV; +PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC qglGetCombinerInputParameterfvNV; +PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC qglGetCombinerInputParameterivNV; +PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC qglGetCombinerOutputParameterfvNV; +PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC qglGetCombinerOutputParameterivNV; +PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC qglGetFinalCombinerInputParameterfvNV; +PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC qglGetFinalCombinerInputParameterivNV; + +PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB; +PFNGLBINDPROGRAMARBPROC qglBindProgramARB; +PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB; +PFNGLGENPROGRAMSARBPROC qglGenProgramsARB; +PFNGLPROGRAMENVPARAMETER4DARBPROC qglProgramEnvParameter4dARB; +PFNGLPROGRAMENVPARAMETER4DVARBPROC qglProgramEnvParameter4dvARB; +PFNGLPROGRAMENVPARAMETER4FARBPROC qglProgramEnvParameter4fARB; +PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB; +PFNGLPROGRAMLOCALPARAMETER4DARBPROC qglProgramLocalParameter4dARB; +PFNGLPROGRAMLOCALPARAMETER4DVARBPROC qglProgramLocalParameter4dvARB; +PFNGLPROGRAMLOCALPARAMETER4FARBPROC qglProgramLocalParameter4fARB; +PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB; +PFNGLGETPROGRAMENVPARAMETERDVARBPROC qglGetProgramEnvParameterdvARB; +PFNGLGETPROGRAMENVPARAMETERFVARBPROC qglGetProgramEnvParameterfvARB; +PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC qglGetProgramLocalParameterdvARB; +PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC qglGetProgramLocalParameterfvARB; +PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB; +PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB; +PFNGLISPROGRAMARBPROC qglIsProgramARB; + +PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT; +PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT; extern void RB_SetGL2D (void); void R_Splash() { @@ -316,7 +339,445 @@ void R_Splash() qglVertex2f(x2, y2); qglEnd(); - GLimp_EndFrame(); + ri->WIN_Present(&window); +} + +/* +** GLW_CheckForExtension + + Cannot use strstr directly to differentiate between (for eg) reg_combiners and reg_combiners2 +*/ +bool GL_CheckForExtension(const char *ext) +{ + const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); + if (ptr == NULL) + return false; + ptr += strlen(ext); + return ((*ptr == ' ') || (*ptr == '\0')); // verify it's complete string. +} + + +static void GLW_InitTextureCompression( void ) +{ + bool newer_tc, old_tc; + + // Check for available tc methods. + newer_tc = GL_CheckForExtension("ARB_texture_compression") && GL_CheckForExtension("EXT_texture_compression_s3tc"); + old_tc = GL_CheckForExtension("GL_S3_s3tc"); + + if ( old_tc ) + { + Com_Printf ("...GL_S3_s3tc available\n" ); + } + + if ( newer_tc ) + { + Com_Printf ("...GL_EXT_texture_compression_s3tc available\n" ); + } + + if ( !r_ext_compressed_textures->value ) + { + // Compressed textures are off + glConfig.textureCompression = TC_NONE; + Com_Printf ("...ignoring texture compression\n" ); + } + else if ( !old_tc && !newer_tc ) + { + // Requesting texture compression, but no method found + glConfig.textureCompression = TC_NONE; + Com_Printf ("...no supported texture compression method found\n" ); + Com_Printf (".....ignoring texture compression\n" ); + } + else + { + // some form of supported texture compression is avaiable, so see if the user has a preference + if ( r_ext_preferred_tc_method->integer == TC_NONE ) + { + // No preference, so pick the best + if ( newer_tc ) + { + Com_Printf ("...no tc preference specified\n" ); + Com_Printf (".....using GL_EXT_texture_compression_s3tc\n" ); + glConfig.textureCompression = TC_S3TC_DXT; + } + else + { + Com_Printf ("...no tc preference specified\n" ); + Com_Printf (".....using GL_S3_s3tc\n" ); + glConfig.textureCompression = TC_S3TC; + } + } + else + { + // User has specified a preference, now see if this request can be honored + if ( old_tc && newer_tc ) + { + // both are avaiable, so we can use the desired tc method + if ( r_ext_preferred_tc_method->integer == TC_S3TC ) + { + Com_Printf ("...using preferred tc method, GL_S3_s3tc\n" ); + glConfig.textureCompression = TC_S3TC; + } + else + { + Com_Printf ("...using preferred tc method, GL_EXT_texture_compression_s3tc\n" ); + glConfig.textureCompression = TC_S3TC_DXT; + } + } + else + { + // Both methods are not available, so this gets trickier + if ( r_ext_preferred_tc_method->integer == TC_S3TC ) + { + // Preferring to user older compression + if ( old_tc ) + { + Com_Printf ("...using GL_S3_s3tc\n" ); + glConfig.textureCompression = TC_S3TC; + } + else + { + // Drat, preference can't be honored + Com_Printf ("...preferred tc method, GL_S3_s3tc not available\n" ); + Com_Printf (".....falling back to GL_EXT_texture_compression_s3tc\n" ); + glConfig.textureCompression = TC_S3TC_DXT; + } + } + else + { + // Preferring to user newer compression + if ( newer_tc ) + { + Com_Printf ("...using GL_EXT_texture_compression_s3tc\n" ); + glConfig.textureCompression = TC_S3TC_DXT; + } + else + { + // Drat, preference can't be honored + Com_Printf ("...preferred tc method, GL_EXT_texture_compression_s3tc not available\n" ); + Com_Printf (".....falling back to GL_S3_s3tc\n" ); + glConfig.textureCompression = TC_S3TC; + } + } + } + } + } +} + +/* +=============== +GLimp_InitExtensions +=============== +*/ +extern bool g_bDynamicGlowSupported; +static void GLimp_InitExtensions( void ) +{ + if ( !r_allowExtensions->integer ) + { + Com_Printf ("*** IGNORING OPENGL EXTENSIONS ***\n" ); + g_bDynamicGlowSupported = false; + ri->Cvar_Set( "r_DynamicGlow","0" ); + return; + } + + Com_Printf ("Initializing OpenGL extensions\n" ); + + // Select our tc scheme + GLW_InitTextureCompression(); + + // GL_EXT_texture_env_add + glConfig.textureEnvAddAvailable = qfalse; + if ( GL_CheckForExtension( "EXT_texture_env_add" ) ) + { + if ( r_ext_texture_env_add->integer ) + { + glConfig.textureEnvAddAvailable = qtrue; + Com_Printf ("...using GL_EXT_texture_env_add\n" ); + } + else + { + glConfig.textureEnvAddAvailable = qfalse; + Com_Printf ("...ignoring GL_EXT_texture_env_add\n" ); + } + } + else + { + Com_Printf ("...GL_EXT_texture_env_add not found\n" ); + } + + // GL_EXT_texture_filter_anisotropic + glConfig.maxTextureFilterAnisotropy = 0; + if ( GL_CheckForExtension( "EXT_texture_filter_anisotropic" ) ) + { + qglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.maxTextureFilterAnisotropy ); + Com_Printf ("...GL_EXT_texture_filter_anisotropic available\n" ); + + if ( r_ext_texture_filter_anisotropic->integer > 1 ) + { + Com_Printf ("...using GL_EXT_texture_filter_anisotropic\n" ); + } + else + { + Com_Printf ("...ignoring GL_EXT_texture_filter_anisotropic\n" ); + } + ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) + { + ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + } + } + else + { + Com_Printf ("...GL_EXT_texture_filter_anisotropic not found\n" ); + ri->Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); + } + + // GL_EXT_clamp_to_edge + glConfig.clampToEdgeAvailable = qtrue; + Com_Printf ("...using GL_EXT_texture_edge_clamp\n" ); + + // GL_ARB_multitexture + qglMultiTexCoord2fARB = NULL; + qglActiveTextureARB = NULL; + qglClientActiveTextureARB = NULL; + if ( GL_CheckForExtension( "GL_ARB_multitexture" ) ) + { + if ( r_ext_multitexture->integer ) + { + qglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) ri->GL_GetProcAddress( "glMultiTexCoord2fARB" ); + qglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) ri->GL_GetProcAddress( "glActiveTextureARB" ); + qglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) ri->GL_GetProcAddress( "glClientActiveTextureARB" ); + + if ( qglActiveTextureARB ) + { + qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.maxActiveTextures ); + + if ( glConfig.maxActiveTextures > 1 ) + { + Com_Printf ("...using GL_ARB_multitexture\n" ); + } + else + { + qglMultiTexCoord2fARB = NULL; + qglActiveTextureARB = NULL; + qglClientActiveTextureARB = NULL; + Com_Printf ("...not using GL_ARB_multitexture, < 2 texture units\n" ); + } + } + } + else + { + Com_Printf ("...ignoring GL_ARB_multitexture\n" ); + } + } + else + { + Com_Printf ("...GL_ARB_multitexture not found\n" ); + } + + // GL_EXT_compiled_vertex_array + qglLockArraysEXT = NULL; + qglUnlockArraysEXT = NULL; + if ( GL_CheckForExtension( "GL_EXT_compiled_vertex_array" ) ) + { + if ( r_ext_compiled_vertex_array->integer ) + { + Com_Printf ("...using GL_EXT_compiled_vertex_array\n" ); + qglLockArraysEXT = ( PFNGLLOCKARRAYSEXTPROC ) ri->GL_GetProcAddress( "glLockArraysEXT" ); + qglUnlockArraysEXT = ( PFNGLUNLOCKARRAYSEXTPROC ) ri->GL_GetProcAddress( "glUnlockArraysEXT" ); + if (!qglLockArraysEXT || !qglUnlockArraysEXT) { + Com_Error (ERR_FATAL, "bad getprocaddress"); + } + } + else + { + Com_Printf ("...ignoring GL_EXT_compiled_vertex_array\n" ); + } + } + else + { + Com_Printf ("...GL_EXT_compiled_vertex_array not found\n" ); + } + + bool bNVRegisterCombiners = false; + // Register Combiners. + if ( GL_CheckForExtension( "GL_NV_register_combiners" ) ) + { + // NOTE: This extension requires multitexture support (over 2 units). + if ( glConfig.maxActiveTextures >= 2 ) + { + bNVRegisterCombiners = true; + // Register Combiners function pointer address load. - AReis + // NOTE: VV guys will _definetly_ not be able to use regcoms. Pixel Shaders are just as good though :-) + // NOTE: Also, this is an nVidia specific extension (of course), so fragment shaders would serve the same purpose + // if we needed some kind of fragment/pixel manipulation support. + qglCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glCombinerParameterfvNV" ); + qglCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glCombinerParameterivNV" ); + qglCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)ri->GL_GetProcAddress( "glCombinerParameterfNV" ); + qglCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)ri->GL_GetProcAddress( "glCombinerParameteriNV" ); + qglCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)ri->GL_GetProcAddress( "glCombinerInputNV" ); + qglCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)ri->GL_GetProcAddress( "glCombinerOutputNV" ); + qglFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)ri->GL_GetProcAddress( "glFinalCombinerInputNV" ); + qglGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetCombinerInputParameterfvNV" ); + qglGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetCombinerInputParameterivNV" ); + qglGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetCombinerOutputParameterfvNV" ); + qglGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetCombinerOutputParameterivNV" ); + qglGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetFinalCombinerInputParameterfvNV" ); + qglGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetFinalCombinerInputParameterivNV" ); + + // Validate the functions we need. + if ( !qglCombinerParameterfvNV || !qglCombinerParameterivNV || !qglCombinerParameterfNV || !qglCombinerParameteriNV || !qglCombinerInputNV || + !qglCombinerOutputNV || !qglFinalCombinerInputNV || !qglGetCombinerInputParameterfvNV || !qglGetCombinerInputParameterivNV || + !qglGetCombinerOutputParameterfvNV || !qglGetCombinerOutputParameterivNV || !qglGetFinalCombinerInputParameterfvNV || !qglGetFinalCombinerInputParameterivNV ) + { + bNVRegisterCombiners = false; + qglCombinerParameterfvNV = NULL; + qglCombinerParameteriNV = NULL; + Com_Printf ("...GL_NV_register_combiners failed\n" ); + } + } + else + { + bNVRegisterCombiners = false; + Com_Printf ("...ignoring GL_NV_register_combiners\n" ); + } + } + else + { + bNVRegisterCombiners = false; + Com_Printf ("...GL_NV_register_combiners not found\n" ); + } + + // NOTE: Vertex and Fragment Programs are very dependant on each other - this is actually a + // good thing! So, just check to see which we support (one or the other) and load the shared + // function pointers. ARB rocks! + + // Vertex Programs. + bool bARBVertexProgram = false; + if ( GL_CheckForExtension( "GL_ARB_vertex_program" ) ) + { + bARBVertexProgram = true; + } + else + { + bARBVertexProgram = false; + Com_Printf ("...GL_ARB_vertex_program not found\n" ); + } + + // Fragment Programs. + bool bARBFragmentProgram = false; + if ( GL_CheckForExtension( "GL_ARB_fragment_program" ) ) + { + bARBFragmentProgram = true; + } + else + { + bARBFragmentProgram = false; + Com_Printf ("...GL_ARB_fragment_program not found\n" ); + } + + // If we support one or the other, load the shared function pointers. + if ( bARBVertexProgram || bARBFragmentProgram ) + { + qglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) ri->GL_GetProcAddress("glProgramStringARB"); + qglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) ri->GL_GetProcAddress("glBindProgramARB"); + qglDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) ri->GL_GetProcAddress("glDeleteProgramsARB"); + qglGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) ri->GL_GetProcAddress("glGenProgramsARB"); + qglProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4dARB"); + qglProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4dvARB"); + qglProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4fARB"); + qglProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4fvARB"); + qglProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4dARB"); + qglProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4dvARB"); + qglProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4fARB"); + qglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4fvARB"); + qglGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC) ri->GL_GetProcAddress("glGetProgramEnvParameterdvARB"); + qglGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) ri->GL_GetProcAddress("glGetProgramEnvParameterfvARB"); + qglGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) ri->GL_GetProcAddress("glGetProgramLocalParameterdvARB"); + qglGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) ri->GL_GetProcAddress("glGetProgramLocalParameterfvARB"); + qglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) ri->GL_GetProcAddress("glGetProgramivARB"); + qglGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC) ri->GL_GetProcAddress("glGetProgramStringARB"); + qglIsProgramARB = (PFNGLISPROGRAMARBPROC) ri->GL_GetProcAddress("glIsProgramARB"); + + // Validate the functions we need. + if ( !qglProgramStringARB || !qglBindProgramARB || !qglDeleteProgramsARB || !qglGenProgramsARB || + !qglProgramEnvParameter4dARB || !qglProgramEnvParameter4dvARB || !qglProgramEnvParameter4fARB || + !qglProgramEnvParameter4fvARB || !qglProgramLocalParameter4dARB || !qglProgramLocalParameter4dvARB || + !qglProgramLocalParameter4fARB || !qglProgramLocalParameter4fvARB || !qglGetProgramEnvParameterdvARB || + !qglGetProgramEnvParameterfvARB || !qglGetProgramLocalParameterdvARB || !qglGetProgramLocalParameterfvARB || + !qglGetProgramivARB || !qglGetProgramStringARB || !qglIsProgramARB ) + { + bARBVertexProgram = false; + bARBFragmentProgram = false; + qglGenProgramsARB = NULL; //clear ptrs that get checked + qglProgramEnvParameter4fARB = NULL; + Com_Printf ("...ignoring GL_ARB_vertex_program\n" ); + Com_Printf ("...ignoring GL_ARB_fragment_program\n" ); + } + } + + // Figure out which texture rectangle extension to use. + bool bTexRectSupported = false; + if ( Q_stricmpn( glConfig.vendor_string, "ATI Technologies",16 )==0 + && Q_stricmpn( glConfig.version_string, "1.3.3",5 )==0 + && glConfig.version_string[5] < '9' ) //1.3.34 and 1.3.37 and 1.3.38 are broken for sure, 1.3.39 is not + { + g_bTextureRectangleHack = true; + } + + if ( GL_CheckForExtension( "GL_NV_texture_rectangle" ) || GL_CheckForExtension( "GL_EXT_texture_rectangle" ) ) + { + bTexRectSupported = true; + } + + // Find out how many general combiners they have. + #define GL_MAX_GENERAL_COMBINERS_NV 0x854D + GLint iNumGeneralCombiners = 0; + if(bNVRegisterCombiners) + qglGetIntegerv( GL_MAX_GENERAL_COMBINERS_NV, &iNumGeneralCombiners ); + + // Only allow dynamic glows/flares if they have the hardware + if ( bTexRectSupported && bARBVertexProgram && qglActiveTextureARB && glConfig.maxActiveTextures >= 4 && + ( ( bNVRegisterCombiners && iNumGeneralCombiners >= 2 ) || bARBFragmentProgram ) ) + { + g_bDynamicGlowSupported = true; + // this would overwrite any achived setting gwg + // ri->Cvar_Set( "r_DynamicGlow", "1" ); + } + else + { + g_bDynamicGlowSupported = false; + ri->Cvar_Set( "r_DynamicGlow","0" ); + } +} + +// Truncates the GL extensions string by only allowing up to 'maxExtensions' extensions in the string. +static const char *TruncateGLExtensionsString (const char *extensionsString, int maxExtensions) +{ + const char *p = extensionsString; + const char *q; + int numExtensions = 0; + size_t extensionsLen = strlen (extensionsString); + + char *truncatedExtensions; + + while ( (q = strchr (p, ' ')) != NULL && numExtensions <= maxExtensions ) + { + p = q + 1; + numExtensions++; + } + + if ( q != NULL ) + { + // We still have more extensions. We'll call this the end + + extensionsLen = p - extensionsString - 1; + } + + truncatedExtensions = (char *)Hunk_Alloc(extensionsLen + 1, h_low); + Q_strncpyz (truncatedExtensions, extensionsString, extensionsLen + 1); + + return truncatedExtensions; } /* @@ -329,8 +790,6 @@ void R_Splash() */ static void InitOpenGL( void ) { - char renderer_buffer[1024]; - // // initialize OS specific portions of the renderer // @@ -341,26 +800,33 @@ static void InitOpenGL( void ) // - r_ignorehwgamma // - r_gamma // - + if ( glConfig.vidWidth == 0 ) { - GLint temp; - - GLimp_Init(); - GLimp_InitExtraExtensions(); + memset(&glConfig, 0, sizeof(glConfig)); + + window = ri->WIN_Init(GRAPHICS_API_OPENGL, &glConfig); - strcpy( renderer_buffer, glConfig.renderer_string ); - Q_strlwr( renderer_buffer ); + Com_Printf( "GL_RENDERER: %s\n", (char *)qglGetString (GL_RENDERER) ); + + // get our config strings + glConfig.vendor_string = (const char *)qglGetString (GL_VENDOR); + glConfig.renderer_string = (const char *)qglGetString (GL_RENDERER); + glConfig.version_string = (const char *)qglGetString (GL_VERSION); + glConfig.extensions_string = (const char *)qglGetString (GL_EXTENSIONS); + + glConfigExt.originalExtensionString = glConfig.extensions_string; + glConfig.extensions_string = TruncateGLExtensionsString(glConfigExt.originalExtensionString, 128); // OpenGL driver constants - qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &temp ); - glConfig.maxTextureSize = temp; + qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.maxTextureSize ); // stubbed or broken drivers may have reported 0... - if ( glConfig.maxTextureSize <= 0 ) - { - glConfig.maxTextureSize = 0; - } + glConfig.maxTextureSize = Q_max(0, glConfig.maxTextureSize); + + // initialize extensions + GLimp_InitExtensions( ); + GLimp_InitExtraExtensions( ); // set default state GL_SetDefaultState(); @@ -416,80 +882,10 @@ void GL_CheckErrs( char *file, int line ) { ri->Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); } - -/* -** R_GetModeInfo -*/ -typedef struct vidmode_s -{ - const char *description; - int width, height; - float pixelAspect; // pixel width / height -} vidmode_t; - -vidmode_t r_vidModes[] = -{ - { "Mode 0: 320x240", 320, 240, 1 }, - { "Mode 1: 400x300", 400, 300, 1 }, - { "Mode 2: 512x384", 512, 384, 1 }, - { "Mode 3: 640x480", 640, 480, 1 }, - { "Mode 4: 800x600", 800, 600, 1 }, - { "Mode 5: 960x720", 960, 720, 1 }, - { "Mode 6: 1024x768", 1024, 768, 1 }, - { "Mode 7: 1152x864", 1152, 864, 1 }, - { "Mode 8: 1280x1024", 1280, 1024, 1 }, - { "Mode 9: 1600x1200", 1600, 1200, 1 }, - { "Mode 10: 2048x1536", 2048, 1536, 1 }, - { "Mode 11: 856x480 (wide)",856, 480, 1 } -}; -static int s_numVidModes = ARRAY_LEN( r_vidModes ); - -qboolean R_GetModeInfo( int *width, int *height, int mode ) { - vidmode_t *vm; - float pixelAspect; - - if ( mode < -1 ) { - return qfalse; - } - if ( mode >= s_numVidModes ) { - return qfalse; - } - - if ( mode == -1 ) { - *width = r_customwidth->integer; - *height = r_customheight->integer; - pixelAspect = r_customPixelAspect->value; - } else { - vm = &r_vidModes[mode]; - - *width = vm->width; - *height = vm->height; - pixelAspect = vm->pixelAspect; - } - - return qtrue; -} - /* -** R_ModeList_f -*/ -static void R_ModeList_f( void ) -{ - int i; - - ri->Printf( PRINT_ALL, "\n" ); - for ( i = 0; i < s_numVidModes; i++ ) - { - ri->Printf( PRINT_ALL, "%s\n", r_vidModes[i].description ); - } - ri->Printf( PRINT_ALL, "\n" ); -} +============================================================================== - -/* -============================================================================== - - SCREEN SHOTS + SCREEN SHOTS NOTE TTimo some thoughts about the screenshots system: @@ -1072,6 +1468,14 @@ static void GfxInfo_f( void ) "windowed", "fullscreen" }; + const char *noborderstrings[] = + { + "", + "noborder " + }; + + int fullscreen = ri->Cvar_VariableIntegerValue("r_fullscreen"); + int noborder = ri->Cvar_VariableIntegerValue("r_noborder"); ri->Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); ri->Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); @@ -1080,9 +1484,12 @@ static void GfxInfo_f( void ) R_PrintLongString( glConfigExt.originalExtensionString ); ri->Printf( PRINT_ALL, "\n" ); ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); - ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_UNITS_ARB: %d\n", glConfig.numTextureUnits ); ri->Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); - ri->Printf( PRINT_ALL, "MODE: %d, %d x %d %s hz:", r_mode->integer, glConfig.vidWidth, glConfig.vidHeight, fsstrings[r_fullscreen->integer == 1] ); + ri->Printf( PRINT_ALL, "MODE: %d, %d x %d %s%s hz:", + ri->Cvar_VariableIntegerValue("r_mode"), + glConfig.vidWidth, glConfig.vidHeight, + fullscreen == 0 ? noborderstrings[noborder == 1] : noborderstrings[0], + fsstrings[fullscreen == 1] ); if ( glConfig.displayFrequency ) { ri->Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); @@ -1111,8 +1518,9 @@ static void GfxInfo_f( void ) { ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } - if ( r_displayRefresh ->integer ) { - ri->Printf( PRINT_ALL, "Display refresh set to %d\n", r_displayRefresh->integer ); + int displayRefresh = ri->Cvar_VariableIntegerValue("r_displayRefresh"); + if ( displayRefresh ) { + ri->Printf( PRINT_ALL, "Display refresh set to %d\n", displayRefresh ); } if ( r_finish->integer ) { ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); @@ -1191,20 +1599,12 @@ static consoleCommand_t commands[] = { //{ "r_we", R_WorldEffect_f }, //{ "imagecacheinfo", RE_RegisterImages_Info_f }, { "modellist", R_Modellist_f }, - { "modelist", R_ModeList_f }, //{ "modelcacheinfo", RE_RegisterModels_Info_f }, - { "minimize", GLimp_Minimize }, }; static const size_t numCommands = ARRAY_LEN( commands ); -#ifdef _WIN32 -#define SWAPINTERVAL_FLAGS CVAR_ARCHIVE -#else -#define SWAPINTERVAL_FLAGS CVAR_ARCHIVE | CVAR_LATCH -#endif - /* =============== R_Register @@ -1245,20 +1645,7 @@ void R_Register( void ) r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_colorbits = ri->Cvar_Get( "r_colorbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_stencilbits = ri->Cvar_Get( "r_stencilbits", "8", CVAR_ARCHIVE | CVAR_LATCH ); - r_depthbits = ri->Cvar_Get( "r_depthbits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_multisample = ri->Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - ri->Cvar_CheckRange( r_ext_multisample, 0, 4, qtrue ); r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ignorehwgamma = ri->Cvar_Get( "r_ignorehwgamma", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_mode = ri->Cvar_Get( "r_mode", "4", CVAR_ARCHIVE | CVAR_LATCH ); - r_fullscreen = ri->Cvar_Get( "r_fullscreen", "0", CVAR_ARCHIVE|CVAR_LATCH ); - r_noborder = ri->Cvar_Get("r_noborder", "0", CVAR_ARCHIVE|CVAR_LATCH); - r_centerWindow = ri->Cvar_Get( "r_centerWindow", "0", CVAR_ARCHIVE|CVAR_LATCH ); - r_customwidth = ri->Cvar_Get( "r_customwidth", "1600", CVAR_ARCHIVE | CVAR_LATCH ); - r_customheight = ri->Cvar_Get( "r_customheight", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_customPixelAspect = ri->Cvar_Get( "r_customPixelAspect", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_simpleMipMaps = ri->Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0); @@ -1334,8 +1721,6 @@ void R_Register( void ) r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH ); r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); - r_displayRefresh = ri->Cvar_Get( "r_displayRefresh", "0", CVAR_LATCH ); - ri->Cvar_CheckRange( r_displayRefresh, 0, 240, qtrue ); // // archived variables that can change at any time @@ -1355,8 +1740,6 @@ void R_Register( void ) r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); - r_swapInterval = ri->Cvar_Get( "r_swapInterval", "0", - SWAPINTERVAL_FLAGS ); r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE ); r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); @@ -1430,7 +1813,7 @@ Ghoul2 Insert Start r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT ); r_Ghoul2AnimSmooth = ri->Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE ); r_Ghoul2UnSqashAfterSmooth = ri->Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE ); - broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_NONE ); + broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_ARCHIVE ); broadsword_kickbones = ri->Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE ); broadsword_kickorigin = ri->Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE ); broadsword_dontstopanim = ri->Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE ); @@ -1483,11 +1866,6 @@ void R_Init( void ) { Com_Memset( &backEnd, 0, sizeof( backEnd ) ); Com_Memset( &tess, 0, sizeof( tess ) ); -#ifdef _WIN32 - tr.wv = (WinVars_t *)ri->GetWinVars(); -#endif - -// Swap_Init(); // // init function tables @@ -1518,12 +1896,12 @@ void R_Init( void ) { R_InitFogTable(); - R_NoiseInit(); R_ImageLoader_Init(); + R_NoiseInit(); R_Register(); - max_polys = (std::min)( r_maxpolys->integer, DEFAULT_MAX_POLYS ); - max_polyverts = (std::min)( r_maxpolyverts->integer, DEFAULT_MAX_POLYVERTS ); + max_polys = Q_min( r_maxpolys->integer, DEFAULT_MAX_POLYS ); + max_polyverts = Q_min( r_maxpolyverts->integer, DEFAULT_MAX_POLYVERTS ); ptr = (byte*)ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); backEndData = (backEndData_t *) ptr; @@ -1531,7 +1909,7 @@ void R_Init( void ) { backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); R_InitNextFrame(); - for ( int i = 0; i < MAXLIGHTMAPS; i++ ) + for ( int i = 0; i < MAX_LIGHT_STYLES; i++ ) { RE_SetLightStyle (i, -1); } @@ -1583,6 +1961,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { for ( size_t i = 0; i < numCommands; i++ ) ri->Cmd_RemoveCommand( commands[i].cmd ); + R_ShutdownFonts(); if ( tr.registered ) { R_IssuePendingRenderCommands(); R_ShutDownQueries(); @@ -1591,26 +1970,20 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { R_ShutdownVBOs(); GLSL_ShutdownGPUShaders(); - if ( restarting ) + if ( destroyWindow && restarting ) { SaveGhoul2InfoArray(); } } - R_ShutdownFonts(); - // shut down platform specific OpenGL stuff if ( destroyWindow ) { - GLimp_Shutdown(); - - Com_Memset( &glConfig, 0, sizeof( glConfig ) ); - Com_Memset( &glState, 0, sizeof( glState ) ); + ri->WIN_Shutdown(); } tr.registered = qfalse; } - /* ============= RE_EndRegistration @@ -1651,7 +2024,8 @@ void RE_GetLightStyle(int style, color4ub_t color) return; } - *(int *)color = *(int *)styleColors[style]; + byteAlias_t *baDest = (byteAlias_t *)&color, *baSource = (byteAlias_t *)&styleColors[style]; + baDest->i = baSource->i; } void RE_SetLightStyle(int style, int color) @@ -1662,9 +2036,9 @@ void RE_SetLightStyle(int style, int color) return; } - if (*(int*)styleColors[style] != color) - { - *(int *)styleColors[style] = color; + byteAlias_t *ba = (byteAlias_t *)&styleColors[style]; + if ( ba->i != color) { + ba->i = color; } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 36d1fd1f0c..48eed17fd3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -40,11 +40,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 -#include "win32\win_local.h" -#include "qcommon\sstring.h" -#endif - #define GL_INDEX_TYPE GL_UNSIGNED_INT typedef unsigned int glIndex_t; @@ -1934,6 +1929,8 @@ typedef struct { typedef struct trGlobals_s { qboolean registered; // cleared at shutdown, set at beginRegistration + window_t window; + int visIndex; int visClusters[MAX_VISCOUNTS]; int visCounts[MAX_VISCOUNTS]; // incremented every time a new vis cluster is entered @@ -2117,10 +2114,6 @@ typedef struct trGlobals_s { float rangedFog; float distanceCull, distanceCullSquared; //rwwRMG - added -#ifdef _WIN32 - WinVars_t *wv; -#endif - // Specific to Jedi Academy int numBSPModels; int currentLevel; @@ -2137,6 +2130,7 @@ extern backEndState_t backEnd; extern trGlobals_t tr; extern glstate_t glState; // outside of TR since it shouldn't be cleared during ref re-init extern glRefConfig_t glRefConfig; +extern window_t window; // // cvars @@ -2450,13 +2444,8 @@ IMPLEMENTATION SPECIFIC FUNCTIONS ==================================================================== */ -void GLimp_Init( void ); -void GLimp_Shutdown( void ); -void GLimp_EndFrame( void ); -void GLimp_LogComment( char *comment ); -void GLimp_InitExtraExtensions( void ); -void GLimp_Minimize( void ); -void GLimp_SetGamma( unsigned char red[256], unsigned char green[256], unsigned char blue[256] ); +static QINLINE void GLimp_LogComment( char *comment ) {} +void GLimp_InitExtraExtensions(); /* ==================================================================== diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index e9cd391bc7..669f37b997 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -791,8 +791,8 @@ void R_AddWorldSurfaces (void) { ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); // perform frustum culling and flag all the potentially visible surfaces - tr.refdef.num_dlights = min (tr.refdef.num_dlights, 32) ; - tr.refdef.num_pshadows = min (tr.refdef.num_pshadows, 32) ; + tr.refdef.num_dlights = Q_min (tr.refdef.num_dlights, 32) ; + tr.refdef.num_pshadows = Q_min (tr.refdef.num_pshadows, 32) ; planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; From 9792d176249b62aeb898376b6f01f8265d64100d Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 12 Feb 2015 11:30:42 -0600 Subject: [PATCH 248/708] Rend2: Fixed dlight image not using the nocompression flag. --- codemp/rd-rend2/tr_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index e4f63eac8f..97931e7ff9 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2657,7 +2657,7 @@ static void R_CreateDlightImage( void ) { R_LoadImage("gfx/2d/dlight", &pic, &width, &height); if (pic) { - tr.dlightImage = R_CreateImage("*dlight", pic, width, height, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); + tr.dlightImage = R_CreateImage("*dlight", pic, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); Z_Free(pic); } else @@ -2685,7 +2685,7 @@ static void R_CreateDlightImage( void ) { data[y][x][3] = 255; } } - tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE, 0 ); + tr.dlightImage = R_CreateImage("*dlight", (byte *)data, DLIGHT_SIZE, DLIGHT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); } } From 0540484e6e0e6b174da7bf00f41ab1525a39a15d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 22 Mar 2015 00:24:25 +0000 Subject: [PATCH 249/708] [Rend2] Get rend2 working with WIN_Init changes Rend2 now attempts to create an OpenGL 3.2 context. --- codemp/rd-rend2/tr_init.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5e6b3e6b41..f86f129f91 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -803,9 +803,14 @@ static void InitOpenGL( void ) if ( glConfig.vidWidth == 0 ) { + windowDesc_t windowDesc = {}; memset(&glConfig, 0, sizeof(glConfig)); - window = ri->WIN_Init(GRAPHICS_API_OPENGL, &glConfig); + windowDesc.api = GRAPHICS_API_OPENGL; + windowDesc.gl.majorVersion = 3; + windowDesc.gl.minorVersion = 2; + + window = ri->WIN_Init(&windowDesc, &glConfig); Com_Printf( "GL_RENDERER: %s\n", (char *)qglGetString (GL_RENDERER) ); From 9a0f989558b29130dfa3778e7d500446d16b2e96 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 23 May 2015 16:28:28 +0100 Subject: [PATCH 250/708] Rend2: Dynamic vertex data and attributes Dynamic vertex data is now interleaved. Attributes handling has been refactored so there's less loops. Maps with multiple lightmaps are broken again for now, and performance might be slightly worse than before. --- codemp/rd-rend2/tr_bsp.cpp | 57 +++-- codemp/rd-rend2/tr_curve.cpp | 5 - codemp/rd-rend2/tr_ghoul2.cpp | 51 ++--- codemp/rd-rend2/tr_glsl.cpp | 346 +++++-------------------------- codemp/rd-rend2/tr_local.h | 89 ++++---- codemp/rd-rend2/tr_main.cpp | 3 - codemp/rd-rend2/tr_model.cpp | 38 ++-- codemp/rd-rend2/tr_model_iqm.cpp | 6 - codemp/rd-rend2/tr_shade.cpp | 2 - codemp/rd-rend2/tr_shader.cpp | 2 - codemp/rd-rend2/tr_surface.cpp | 10 - codemp/rd-rend2/tr_vbo.cpp | 155 ++++++++------ 12 files changed, 239 insertions(+), 525 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5127b2a099..b3d5d029d5 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -801,7 +801,6 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, surf->data = (surfaceType_t *)cv; -#ifdef USE_VERT_TANGENT_SPACE // Calculate tangent spaces { srfVert_t *dv[3]; @@ -815,7 +814,6 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, R_CalcTangentVectors(dv); } } -#endif } @@ -1045,7 +1043,6 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor cv->numIndexes -= badTriangles * 3; } -#ifdef USE_VERT_TANGENT_SPACE // Calculate tangent spaces { srfVert_t *dv[3]; @@ -1059,7 +1056,6 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor R_CalcTangentVectors(dv); } } -#endif } /* @@ -1844,10 +1840,7 @@ static void CopyVert(const srfVert_t * in, srfVert_t * out) for(j = 0; j < 3; j++) { out->xyz[j] = in->xyz[j]; -#ifdef USE_VERT_TANGENT_SPACE out->tangent[j] = in->tangent[j]; - //out->bitangent[j] = in->bitangent[j]; -#endif out->normal[j] = in->normal[j]; out->lightdir[j] = in->lightdir[j]; } @@ -1870,9 +1863,7 @@ struct packedVertex_t { vec3_t position; uint32_t normal; -#ifdef USE_VERT_TANGENT_SPACE uint32_t tangent; -#endif vec2_t texcoords[1 + MAXLIGHTMAPS]; vec4_t colors[MAXLIGHTMAPS]; uint32_t lightDirection; @@ -1900,8 +1891,8 @@ static void R_CreateWorldVBOs(void) VBO_t *vbo; IBO_t *ibo; - int maxVboSize = 16 * 1024 * 1024; - int maxIboSize = 4 * 1024 * 1024; + int maxVboSize = 64 * 1024 * 1024; + int maxIboSize = 16 * 1024 * 1024; int startTime, endTime; @@ -2047,9 +2038,7 @@ static void R_CreateWorldVBOs(void) VectorCopy (bspSurf->verts[i].xyz, vert.position); vert.normal = R_VboPackNormal (bspSurf->verts[i].normal); -#ifdef USE_VERT_TANGENT_SPACE vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); -#endif VectorCopy2 (bspSurf->verts[i].st, vert.texcoords[0]); for (int j = 0; j < MAXLIGHTMAPS; j++) @@ -2070,24 +2059,30 @@ static void R_CreateWorldVBOs(void) ibo = R_CreateIBO((byte *)indexes, numIndexes * sizeof (glIndex_t), VBO_USAGE_STATIC); // Setup the offsets and strides - vbo->ofs_xyz = offsetof (packedVertex_t, position); - vbo->ofs_normal = offsetof (packedVertex_t, normal); -#ifdef USE_VERT_TANGENT_SPACE - vbo->ofs_tangent = offsetof (packedVertex_t, tangent); -#endif - vbo->ofs_st = offsetof (packedVertex_t, texcoords); - vbo->ofs_vertexcolor = offsetof (packedVertex_t, colors); - vbo->ofs_lightdir = offsetof (packedVertex_t, lightDirection); - - const size_t packedVertexSize = sizeof (packedVertex_t); - vbo->stride_xyz = packedVertexSize; - vbo->stride_normal = packedVertexSize; -#ifdef USE_VERT_TANGENT_SPACE - vbo->stride_tangent = packedVertexSize; -#endif - vbo->stride_st = packedVertexSize; - vbo->stride_vertexcolor = packedVertexSize; - vbo->stride_lightdir = packedVertexSize; + vbo->offsets[ATTR_INDEX_POSITION] = offsetof(packedVertex_t, position); + vbo->offsets[ATTR_INDEX_NORMAL] = offsetof(packedVertex_t, normal); + vbo->offsets[ATTR_INDEX_TANGENT] = offsetof(packedVertex_t, tangent); + vbo->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(packedVertex_t, texcoords[0]); + vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[1]); + vbo->offsets[ATTR_INDEX_COLOR] = offsetof(packedVertex_t, colors); + vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offsetof(packedVertex_t, lightDirection); + + const size_t packedVertexSize = sizeof(packedVertex_t); + vbo->strides[ATTR_INDEX_POSITION] = packedVertexSize; + vbo->strides[ATTR_INDEX_NORMAL] = packedVertexSize; + vbo->strides[ATTR_INDEX_TANGENT] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD0] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD1] = packedVertexSize; + vbo->strides[ATTR_INDEX_COLOR] = packedVertexSize; + vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = packedVertexSize; + + vbo->sizes[ATTR_INDEX_POSITION] = sizeof(verts->position); + vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(verts->normal); + vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD1] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(verts->tangent); + vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(verts->lightDirection); + vbo->sizes[ATTR_INDEX_COLOR] = sizeof(verts->colors); // point bsp surfaces to VBO for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 9741c9d510..9ce6ce0d39 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -215,7 +215,6 @@ static int neighbors[8][2] = { } } -#ifdef USE_VERT_TANGENT_SPACE static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], int numIndexes, glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) { @@ -254,8 +253,6 @@ static void MakeMeshTangentVectors(int width, int height, srfVert_t ctrl[MAX_GRI } } } -#endif - static int MakeMeshIndexes(int width, int height, srfVert_t ctrl[MAX_GRID_SIZE][MAX_GRID_SIZE], glIndex_t indexes[(MAX_GRID_SIZE-1)*(MAX_GRID_SIZE-1)*2*3]) @@ -640,9 +637,7 @@ srfBspSurface_t *R_SubdividePatchToGrid( int width, int height, // calculate normals MakeMeshNormals( width, height, ctrl ); -#ifdef USE_VERT_TANGENT_SPACE MakeMeshTangentVectors(width, height, ctrl, numIndexes, indexes); -#endif return R_CreateSurfaceGridMesh(width, height, ctrl, errorTable, numIndexes, indexes); } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 741fe574f7..2987275121 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4454,24 +4454,18 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vec2_t *texcoords; vec4_t *bonerefs; vec4_t *weights; -#ifdef USE_VERT_TANGENT_SPACE uint32_t *tangents; -#endif byte *data; int dataSize = 0; int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights; -#ifdef USE_VERT_TANGENT_SPACE int ofs_tangent; -#endif int stride = 0; int numVerts = 0; int numTriangles = 0; -#ifdef USE_VERT_TANGENT_SPACE vec3_t *tangentsf; vec3_t *bitangentsf; -#endif // +1 to add total vertex count int *baseVertexes = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); @@ -4497,19 +4491,15 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean baseVertexes[mdxm->numSurfaces] = numVerts; -#ifdef USE_VERT_TANGENT_SPACE tangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts); bitangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts);; -#endif dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); dataSize += numVerts * sizeof (*weights); dataSize += numVerts * sizeof (*bonerefs); -#ifdef USE_VERT_TANGENT_SPACE dataSize += numVerts * sizeof (*tangents); -#endif // Allocate and write to memory data = (byte *)ri->Hunk_AllocateTempMemory (dataSize); @@ -4534,11 +4524,9 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean ofsWeights = stride; stride += sizeof (*weights); -#ifdef USE_VERT_TANGENT_SPACE tangents = (uint32_t *)(data + stride); ofs_tangent = stride; stride += sizeof (*tangents); -#endif surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4587,7 +4575,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean texcoords = (vec2_t *)((byte *)texcoords + stride); } -#ifdef USE_VERT_TANGENT_SPACE mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); for ( int k = 0; k < surf->numTriangles; k++ ) { @@ -4655,7 +4642,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean *tangents = R_VboPackTangent (T); tangents = (uint32_t *)((byte *)tangents + stride); } -#endif surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); } @@ -4674,23 +4660,26 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean ri->Hunk_FreeTempMemory (tangentsf); ri->Hunk_FreeTempMemory (bitangentsf); - vbo->ofs_xyz = ofsPosition; - vbo->ofs_normal = ofsNormals; - vbo->ofs_st = ofsTexcoords; - vbo->ofs_boneindexes = ofsBoneRefs; - vbo->ofs_boneweights = ofsWeights; -#ifdef USE_VERT_TANGENT_SPACE - vbo->ofs_tangent = ofs_tangent; -#endif - - vbo->stride_xyz = stride; - vbo->stride_normal = stride; - vbo->stride_st = stride; - vbo->stride_boneindexes = stride; - vbo->stride_boneweights = stride; -#ifdef USE_VERT_TANGENT_SPACE - vbo->stride_tangent = stride; -#endif + vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; + vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; + vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofsTexcoords; + vbo->offsets[ATTR_INDEX_BONE_INDEXES] = ofsBoneRefs; + vbo->offsets[ATTR_INDEX_BONE_WEIGHTS] = ofsWeights; + vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; + + vbo->strides[ATTR_INDEX_POSITION] = stride; + vbo->strides[ATTR_INDEX_NORMAL] = stride; + vbo->strides[ATTR_INDEX_TEXCOORD0] = stride; + vbo->strides[ATTR_INDEX_BONE_INDEXES] = stride; + vbo->strides[ATTR_INDEX_BONE_WEIGHTS] = stride; + vbo->strides[ATTR_INDEX_TANGENT] = stride; + + vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); + vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); + vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); + vbo->sizes[ATTR_INDEX_BONE_WEIGHTS] = sizeof(*weights); + vbo->sizes[ATTR_INDEX_BONE_INDEXES] = sizeof(*bonerefs); + vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); // Fill in the index buffer glIndex_t *indices = (glIndex_t *)ri->Hunk_AllocateTempMemory (sizeof (glIndex_t) * numTriangles * 3); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 7f2a3bfa51..24717196dc 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -585,10 +585,8 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) if(attribs & ATTR_TEXCOORD1) qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); -#ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT) qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); -#endif if(attribs & ATTR_NORMAL) qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); @@ -608,10 +606,8 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) if(attribs & ATTR_NORMAL2) qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); -#ifdef USE_VERT_TANGENT_SPACE if(attribs & ATTR_TANGENT2) qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); -#endif if(attribs & ATTR_BONE_INDEXES) qglBindAttribLocation(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); @@ -1147,10 +1143,8 @@ int GLSL_BeginLoadGPUShaders(void) if (r_normalMapping->integer == 3) Q_strcat(extradefines, 1024, "#define USE_TRIACE_OREN_NAYAR\n"); -#ifdef USE_VERT_TANGENT_SPACE Q_strcat(extradefines, 1024, "#define USE_VERT_TANGENT_SPACE\n"); attribs |= ATTR_TANGENT; -#endif if ((i & LIGHTDEF_USE_PARALLAXMAP) && r_parallaxMapping->integer) Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); @@ -1196,12 +1190,10 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; -#ifdef USE_VERT_TANGENT_SPACE if (r_normalMapping->integer) { attribs |= ATTR_TANGENT2; } -#endif } if (i & LIGHTDEF_USE_GLOW_BUFFER) @@ -1691,22 +1683,9 @@ void GLSL_ShutdownGPUShaders(void) ri->Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); - qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD0); - qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD1); - qglDisableVertexAttribArray(ATTR_INDEX_POSITION); - qglDisableVertexAttribArray(ATTR_INDEX_POSITION2); - qglDisableVertexAttribArray(ATTR_INDEX_NORMAL); -#ifdef USE_VERT_TANGENT_SPACE - qglDisableVertexAttribArray(ATTR_INDEX_TANGENT); -#endif - qglDisableVertexAttribArray(ATTR_INDEX_NORMAL2); -#ifdef USE_VERT_TANGENT_SPACE - qglDisableVertexAttribArray(ATTR_INDEX_TANGENT2); -#endif - qglDisableVertexAttribArray(ATTR_INDEX_COLOR); - qglDisableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); - qglDisableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); - qglDisableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); + for ( int i = 0; i < ATTR_INDEX_MAX; i++ ) + qglDisableVertexAttribArray(i); + GLSL_BindNullProgram(); for ( i = 0; i < GENERICDEF_COUNT; i++) @@ -1788,180 +1767,18 @@ void GLSL_VertexAttribsState(uint32_t stateBits) GLSL_VertexAttribPointers(stateBits); diff = stateBits ^ glState.vertexAttribsState; - if(!diff) - { + if (!diff) return; - } - - if(diff & ATTR_POSITION) - { - if(stateBits & ATTR_POSITION) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_POSITION )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_POSITION); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_POSITION )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_POSITION); - } - } - if(diff & ATTR_TEXCOORD0) + for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j << 1 ) { - if(stateBits & ATTR_TEXCOORD0) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TEXCOORD )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_TEXCOORD0); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TEXCOORD )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD0); - } - } - - if(diff & ATTR_TEXCOORD1) - { - if(stateBits & ATTR_TEXCOORD1) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_LIGHTCOORD )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_TEXCOORD1); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_LIGHTCOORD )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_TEXCOORD1); - } - } - - if(diff & ATTR_NORMAL) - { - if(stateBits & ATTR_NORMAL) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_NORMAL )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_NORMAL); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_NORMAL )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_NORMAL); - } - } - -#ifdef USE_VERT_TANGENT_SPACE - if(diff & ATTR_TANGENT) - { - if(stateBits & ATTR_TANGENT) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TANGENT )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_TANGENT); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TANGENT )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_TANGENT); - } - } -#endif - - if(diff & ATTR_COLOR) - { - if(stateBits & ATTR_COLOR) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_COLOR )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_COLOR); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_COLOR )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_COLOR); - } - } - - if(diff & ATTR_LIGHTDIRECTION) - { - if(stateBits & ATTR_LIGHTDIRECTION) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_LIGHTDIRECTION )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_LIGHTDIRECTION); - } - } - - if(diff & ATTR_POSITION2) - { - if(stateBits & ATTR_POSITION2) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_POSITION2 )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_POSITION2); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_POSITION2 )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_POSITION2); - } - } - - if(diff & ATTR_NORMAL2) - { - if(stateBits & ATTR_NORMAL2) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_NORMAL2 )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_NORMAL2); - } - else + // FIXME: Use BitScanForward? + if (diff & j) { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_NORMAL2 )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_NORMAL2); - } - } - -#ifdef USE_VERT_TANGENT_SPACE - if(diff & ATTR_TANGENT2) - { - if(stateBits & ATTR_TANGENT2) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_TANGENT2 )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_TANGENT2); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_TANGENT2 )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_TANGENT2); - } - } -#endif - - if(diff & ATTR_BONE_INDEXES) - { - if(stateBits & ATTR_BONE_INDEXES) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_BONE_INDEXES )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_BONE_INDEXES )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_BONE_INDEXES); - } - } - - if(diff & ATTR_BONE_WEIGHTS) - { - if(stateBits & ATTR_BONE_WEIGHTS) - { - GLimp_LogComment("qglEnableVertexAttribArray( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglEnableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); - } - else - { - GLimp_LogComment("qglDisableVertexAttribArray( ATTR_INDEX_BONE_WEIGHTS )\n"); - qglDisableVertexAttribArray(ATTR_INDEX_BONE_WEIGHTS); + if(stateBits & j) + qglEnableVertexAttribArray(i); + else + qglDisableVertexAttribArray(i); } } @@ -1970,20 +1787,21 @@ void GLSL_VertexAttribsState(uint32_t stateBits) void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) { + return; VBO_t *vbo = glState.currentVBO; if ( attribBits & ATTR_TEXCOORD0 ) { GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->strides[ATTR_INDEX_TEXCOORD0], BUFFER_OFFSET(vbo->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); } if ( attribBits & ATTR_TEXCOORD1 ) { GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->strides[ATTR_INDEX_TEXCOORD1], BUFFER_OFFSET(vbo->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); } } @@ -2009,107 +1827,53 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) oldFrame = glState.vertexAttribsOldFrame; newFrame = glState.vertexAttribsNewFrame; animated = glState.vertexAnimation; - - if((attribBits & ATTR_POSITION) && (!(glState.vertexAttribPointersSet & ATTR_POSITION) || animated)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_POSITION )\n"); - - qglVertexAttribPointer(ATTR_INDEX_POSITION, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + newFrame * vbo->size_xyz)); - glState.vertexAttribPointersSet |= ATTR_POSITION; - } - - if((attribBits & ATTR_TEXCOORD0) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD0)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); - glState.vertexAttribPointersSet |= ATTR_TEXCOORD0; - } - - if((attribBits & ATTR_TEXCOORD1) && !(glState.vertexAttribPointersSet & ATTR_TEXCOORD1)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->stride_st, BUFFER_OFFSET(vbo->ofs_st + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); - glState.vertexAttribPointersSet |= ATTR_TEXCOORD1; - } - - if((attribBits & ATTR_NORMAL) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL) || animated)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_NORMAL )\n"); - - qglVertexAttribPointer(ATTR_INDEX_NORMAL, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + newFrame * vbo->size_normal)); - glState.vertexAttribPointersSet |= ATTR_NORMAL; - } - -#ifdef USE_VERT_TANGENT_SPACE - if((attribBits & ATTR_TANGENT) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT) || animated)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TANGENT )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TANGENT, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + newFrame * vbo->size_normal)); // FIXME - glState.vertexAttribPointersSet |= ATTR_TANGENT; - } -#endif - - if((attribBits & ATTR_COLOR) && !(glState.vertexAttribPointersSet & ATTR_COLOR)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_COLOR )\n"); - - qglVertexAttribPointer(ATTR_INDEX_COLOR, 4, GL_FLOAT, 0, vbo->stride_vertexcolor, BUFFER_OFFSET(vbo->ofs_vertexcolor)); - glState.vertexAttribPointersSet |= ATTR_COLOR; - } - - if((attribBits & ATTR_LIGHTDIRECTION) && !(glState.vertexAttribPointersSet & ATTR_LIGHTDIRECTION)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTDIRECTION )\n"); - - qglVertexAttribPointer(ATTR_INDEX_LIGHTDIRECTION, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_lightdir, BUFFER_OFFSET(vbo->ofs_lightdir)); - glState.vertexAttribPointersSet |= ATTR_LIGHTDIRECTION; - } - - if((attribBits & ATTR_POSITION2) && (!(glState.vertexAttribPointersSet & ATTR_POSITION2) || animated)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_POSITION2 )\n"); - - qglVertexAttribPointer(ATTR_INDEX_POSITION2, 3, GL_FLOAT, 0, vbo->stride_xyz, BUFFER_OFFSET(vbo->ofs_xyz + oldFrame * vbo->size_xyz)); - glState.vertexAttribPointersSet |= ATTR_POSITION2; - } - - if((attribBits & ATTR_NORMAL2) && (!(glState.vertexAttribPointersSet & ATTR_NORMAL2) || animated)) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_NORMAL2 )\n"); - qglVertexAttribPointer(ATTR_INDEX_NORMAL2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_normal, BUFFER_OFFSET(vbo->ofs_normal + oldFrame * vbo->size_normal)); - glState.vertexAttribPointersSet |= ATTR_NORMAL2; - } - -#ifdef USE_VERT_TANGENT_SPACE - if((attribBits & ATTR_TANGENT2) && (!(glState.vertexAttribPointersSet & ATTR_TANGENT2) || animated)) + VertexArraysProperties vertexArrays; + if ( tess.useInternalVBO ) { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TANGENT2 )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TANGENT2, 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, vbo->stride_tangent, BUFFER_OFFSET(vbo->ofs_tangent + oldFrame * vbo->size_normal)); // FIXME - glState.vertexAttribPointersSet |= ATTR_TANGENT2; + CalculateVertexArraysProperties(attribBits, &vertexArrays); } -#endif - - if((attribBits & ATTR_BONE_INDEXES) && !(glState.vertexAttribPointersSet & ATTR_BONE_INDEXES)) + else { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_BONE_INDEXES )\n"); - - qglVertexAttribPointer(ATTR_INDEX_BONE_INDEXES, 4, GL_FLOAT, 0, vbo->stride_boneindexes, BUFFER_OFFSET(vbo->ofs_boneindexes)); - glState.vertexAttribPointersSet |= ATTR_BONE_INDEXES; - } - - if((attribBits & ATTR_BONE_WEIGHTS) && !(glState.vertexAttribPointersSet & ATTR_BONE_WEIGHTS)) + CalculateVertexArraysFromVBO(attribBits, vbo, &vertexArrays); + } + + const struct + { + int numComponents; + GLenum type; + GLboolean normalize; + int offset; + } attributes[ATTR_INDEX_MAX] = { + { 3, GL_FLOAT, GL_FALSE, 0 }, // position + { 2, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0] }, + { 2, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1] }, + { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // tangent + { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // normal + { 4, GL_FLOAT, GL_FALSE, 0 }, // color + { 0, GL_NONE, GL_FALSE, 0 }, // paint color + { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // light direction + { 4, GL_FLOAT, GL_FALSE, 0 }, // bon indices + { 4, GL_FLOAT, GL_FALSE, 0 }, // bone weights + { 3, GL_FLOAT, GL_FALSE, 0 }, // pos2 + { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, + { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, + }; + + for ( int i = 0, j = 1 ; i < ATTR_INDEX_MAX; i++, j <<= 1 ) { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_BONE_WEIGHTS )\n"); - - qglVertexAttribPointer(ATTR_INDEX_BONE_WEIGHTS, 4, GL_FLOAT, 0, vbo->stride_boneweights, BUFFER_OFFSET(vbo->ofs_boneweights)); - glState.vertexAttribPointersSet |= ATTR_BONE_WEIGHTS; + if ( attribBits & j ) + { + qglVertexAttribPointer(i, + attributes[i].numComponents, + attributes[i].type, + attributes[i].normalize, + vertexArrays.strides[i], + BUFFER_OFFSET(vertexArrays.offsets[i] + attributes[i].offset)); + + glState.vertexAttribPointersSet |= j; + } } - } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 48eed17fd3..88f538702a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -62,8 +62,6 @@ typedef unsigned int glIndex_t; #define CUBE_MAP_MIPS 7 #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) -#define USE_VERT_TANGENT_SPACE - /* ===================================================== @@ -321,6 +319,27 @@ typedef enum ANIMMAP_ONESHOT } animMapType_t; +enum +{ + ATTR_INDEX_POSITION, + ATTR_INDEX_TEXCOORD0, + ATTR_INDEX_TEXCOORD1, + ATTR_INDEX_TANGENT, + ATTR_INDEX_NORMAL, + ATTR_INDEX_COLOR, + ATTR_INDEX_PAINTCOLOR, + ATTR_INDEX_LIGHTDIRECTION, + ATTR_INDEX_BONE_INDEXES, + ATTR_INDEX_BONE_WEIGHTS, + + // GPU vertex animations + ATTR_INDEX_POSITION2, + ATTR_INDEX_TANGENT2, + ATTR_INDEX_NORMAL2, + + ATTR_INDEX_MAX +}; + typedef struct image_s { char imgName[MAX_QPATH]; // game path, including extension int width, height; // source image @@ -383,30 +402,10 @@ typedef struct VBO_s { uint32_t vertexesVBO; int vertexesSize; // amount of memory data allocated for all vertices in bytes - uint32_t ofs_xyz; - uint32_t ofs_normal; - uint32_t ofs_st; - uint32_t ofs_vertexcolor; - uint32_t ofs_lightdir; -#ifdef USE_VERT_TANGENT_SPACE - uint32_t ofs_tangent; -#endif - uint32_t ofs_boneweights; - uint32_t ofs_boneindexes; - - uint32_t stride_xyz; - uint32_t stride_normal; - uint32_t stride_st; - uint32_t stride_vertexcolor; - uint32_t stride_lightdir; -#ifdef USE_VERT_TANGENT_SPACE - uint32_t stride_tangent; -#endif - uint32_t stride_boneweights; - uint32_t stride_boneindexes; - uint32_t size_xyz; - uint32_t size_normal; + uint32_t offsets[ATTR_INDEX_MAX]; + uint32_t strides[ATTR_INDEX_MAX]; + uint32_t sizes[ATTR_INDEX_MAX]; } VBO_t; typedef struct IBO_s @@ -817,25 +816,6 @@ static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) return qfalse; } -enum -{ - ATTR_INDEX_POSITION, - ATTR_INDEX_TEXCOORD0, - ATTR_INDEX_TEXCOORD1, - ATTR_INDEX_TANGENT, - ATTR_INDEX_NORMAL, - ATTR_INDEX_COLOR, - ATTR_INDEX_PAINTCOLOR, - ATTR_INDEX_LIGHTDIRECTION, - ATTR_INDEX_BONE_INDEXES, - ATTR_INDEX_BONE_WEIGHTS, - - // GPU vertex animations - ATTR_INDEX_POSITION2, - ATTR_INDEX_TANGENT2, - ATTR_INDEX_NORMAL2 -}; - enum { GLS_SRCBLEND_ZERO = (1 << 0), @@ -1290,9 +1270,7 @@ typedef struct vec2_t st; vec2_t lightmap[MAXLIGHTMAPS]; vec3_t normal; -#ifdef USE_VERT_TANGENT_SPACE vec4_t tangent; -#endif vec3_t lightdir; vec4_t vertexColors[MAXLIGHTMAPS]; @@ -1608,10 +1586,8 @@ typedef struct { vec3_t xyz; vec3_t normal; -#ifdef USE_VERT_TANGENT_SPACE vec3_t tangent; vec3_t bitangent; -#endif } mdvVertex_t; typedef struct @@ -2468,9 +2444,7 @@ struct shaderCommands_s glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); uint32_t normal[SHADER_MAX_VERTEXES] QALIGN(16); -#ifdef USE_VERT_TANGENT_SPACE uint32_t tangent[SHADER_MAX_VERTEXES] QALIGN(16); -#endif vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); vec4_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16); uint32_t lightdir[SHADER_MAX_VERTEXES] QALIGN(16); @@ -2647,13 +2621,24 @@ VERTEX BUFFER OBJECTS ============================================================ */ +struct VertexArraysProperties +{ + size_t vertexDataSize; + int numVertexArrays; + + int enabledAttributes[ATTR_INDEX_MAX]; + int offsets[ATTR_INDEX_MAX]; + int sizes[ATTR_INDEX_MAX]; + int strides[ATTR_INDEX_MAX]; + void *streams[ATTR_INDEX_MAX]; +}; + uint32_t R_VboPackTangent(vec4_t v); uint32_t R_VboPackNormal(vec3_t v); void R_VboUnpackTangent(vec4_t v, uint32_t b); void R_VboUnpackNormal(vec3_t v, uint32_t b); VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage); - IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage); void R_BindVBO(VBO_t * vbo); @@ -2667,6 +2652,8 @@ void R_ShutdownVBOs(void); void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); +void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); +void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); /* diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index d7156b582b..16f60ce9e9 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -339,7 +339,6 @@ void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t norm VectorScale(bitangent, handedness, bitangent); } -#ifdef USE_VERT_TANGENT_SPACE qboolean R_CalcTangentVectors(srfVert_t * dv[3]) { int i; @@ -396,8 +395,6 @@ qboolean R_CalcTangentVectors(srfVert_t * dv[3]) return qtrue; } -#endif - /* ================= diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index f49c5c9149..c5cfc82c4e 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1030,7 +1030,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN st->st[1] = LittleFloat(md3st->st[1]); } -#ifdef USE_VERT_TANGENT_SPACE // calc tangent spaces { for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) @@ -1083,7 +1082,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN R_CalcTbnFromNormalAndTexDirs(v->tangent, v->bitangent, v->normal, sdir, tdir); } } -#endif // find the next surface md3Surf = (md3Surface_t *) ((byte *) md3Surf + md3Surf->ofsEnd); @@ -1103,17 +1101,13 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vec3_t *verts; vec2_t *texcoords; uint32_t *normals; -#ifdef USE_VERT_TANGENT_SPACE uint32_t *tangents; -#endif byte *data; int dataSize; int ofs_xyz, ofs_normal, ofs_st; -#ifdef USE_VERT_TANGENT_SPACE int ofs_tangent; -#endif dataSize = 0; @@ -1123,10 +1117,8 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN ofs_normal = dataSize; dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*normals); -#ifdef USE_VERT_TANGENT_SPACE ofs_tangent = dataSize; dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents); -#endif ofs_st = dataSize; dataSize += surf->numVerts * sizeof(*texcoords); @@ -1135,9 +1127,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN verts = (vec3_t *)(data + ofs_xyz); normals = (uint32_t *)(data + ofs_normal); -#ifdef USE_VERT_TANGENT_SPACE tangents = (uint32_t *)(data + ofs_tangent); -#endif texcoords = (vec2_t *)(data + ofs_st); v = surf->verts; @@ -1149,13 +1139,11 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN VectorCopy(v->xyz, verts[j]); normals[j] = R_VboPackNormal(v->normal); -#ifdef USE_VERT_TANGENT_SPACE CrossProduct(v->normal, v->tangent, nxt); VectorCopy(v->tangent, tangent); tangent[3] = (DotProduct(nxt, v->bitangent) < 0.0f) ? -1.0f : 1.0f; tangents[j] = R_VboPackTangent(tangent); -#endif } st = surf->st; @@ -1175,22 +1163,20 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); - vboSurf->vbo->ofs_xyz = ofs_xyz; - vboSurf->vbo->ofs_normal = ofs_normal; -#ifdef USE_VERT_TANGENT_SPACE - vboSurf->vbo->ofs_tangent = ofs_tangent; -#endif - vboSurf->vbo->ofs_st = ofs_st; + vboSurf->vbo->offsets[ATTR_INDEX_POSITION] = ofs_xyz; + vboSurf->vbo->offsets[ATTR_INDEX_NORMAL] = ofs_normal; + vboSurf->vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofs_st; + vboSurf->vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; - vboSurf->vbo->stride_xyz = sizeof(*verts); - vboSurf->vbo->stride_normal = sizeof(*normals); -#ifdef USE_VERT_TANGENT_SPACE - vboSurf->vbo->stride_tangent = sizeof(*tangents); -#endif - vboSurf->vbo->stride_st = sizeof(*st); + vboSurf->vbo->strides[ATTR_INDEX_POSITION] = sizeof(*verts); + vboSurf->vbo->strides[ATTR_INDEX_NORMAL] = sizeof(*normals); + vboSurf->vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(*st); + vboSurf->vbo->strides[ATTR_INDEX_TANGENT] = sizeof(*tangents); - vboSurf->vbo->size_xyz = sizeof(*verts) * surf->numVerts; - vboSurf->vbo->size_normal = sizeof(*normals) * surf->numVerts; + vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); + vboSurf->vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); + vboSurf->vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); + vboSurf->vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); Z_Free(data); diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index dc68142497..10a9d85f72 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -1025,9 +1025,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vec4_t *outXYZ; uint32_t *outNormal; -#ifdef USE_VERT_TANGENT_SPACE uint32_t *outTangent; -#endif vec2_t (*outTexCoord)[2]; vec4_t *outColor; @@ -1043,9 +1041,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { outXYZ = &tess.xyz[tess.numVertexes]; outNormal = &tess.normal[tess.numVertexes]; -#ifdef USE_VERT_TANGENT_SPACE outTangent = &tess.tangent[tess.numVertexes]; -#endif outTexCoord = &tess.texCoords[tess.numVertexes]; outColor = &tess.vertexColors[tess.numVertexes]; @@ -1132,14 +1128,12 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { *outNormal = R_VboPackNormal(normal); -#ifdef USE_VERT_TANGENT_SPACE tangent[0] = DotProduct(&nrmMat[0], &data->tangents[4*vtx]); tangent[1] = DotProduct(&nrmMat[3], &data->tangents[4*vtx]); tangent[2] = DotProduct(&nrmMat[6], &data->tangents[4*vtx]); tangent[3] = data->tangents[4*vtx+3]; *outTangent++ = R_VboPackTangent(tangent); -#endif } (*outColor)[0] = data->colors[4*vtx+0] / 255.0f; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index efb8390959..ebd023e255 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1124,9 +1124,7 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) if (vertexAttribs & ATTR_NORMAL) { vertexAttribs |= ATTR_NORMAL2; -#ifdef USE_VERT_TANGENT_SPACE vertexAttribs |= ATTR_TANGENT2; -#endif } } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4beba8e02a..4a4324b9b7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2336,12 +2336,10 @@ static void ComputeVertexAttribs(void) { shader.vertexAttribs |= ATTR_NORMAL; -#ifdef USE_VERT_TANGENT_SPACE if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && !(r_normalMapping->integer == 0 && r_specularMapping->integer == 0)) { shader.vertexAttribs |= ATTR_TANGENT; } -#endif switch (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) { diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 3aee826b5f..1061a02fce 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -368,9 +368,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn float *xyz, *texCoords, *lightCoords; uint32_t *lightdir; uint32_t *normal; -#ifdef USE_VERT_TANGENT_SPACE uint32_t *tangent; -#endif glIndex_t *outIndex; float *color; @@ -401,7 +399,6 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn *normal = R_VboPackNormal(dv->normal); } -#ifdef USE_VERT_TANGENT_SPACE if ( tess.shader->vertexAttribs & ATTR_TANGENT ) { dv = verts; @@ -409,7 +406,6 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn for ( i = 0 ; i < numVerts ; i++, dv++, tangent++ ) *tangent = R_VboPackTangent(dv->tangent); } -#endif if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { @@ -1744,9 +1740,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { float *xyz; float *texCoords, *lightCoords; uint32_t *normal; -#ifdef USE_VERT_TANGENT_SPACE uint32_t *tangent; -#endif float *color; uint32_t *lightdir; srfVert_t *dv; @@ -1832,9 +1826,7 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { xyz = tess.xyz[numVertexes]; normal = &tess.normal[numVertexes]; -#ifdef USE_VERT_TANGENT_SPACE tangent = &tess.tangent[numVertexes]; -#endif texCoords = tess.texCoords[numVertexes][0]; lightCoords = tess.texCoords[numVertexes][1]; color = tess.vertexColors[numVertexes]; @@ -1857,12 +1849,10 @@ static void RB_SurfaceGrid( srfBspSurface_t *srf ) { *normal++ = R_VboPackNormal(dv->normal); } -#ifdef USE_VERT_TANGENT_SPACE if ( tess.shader->vertexAttribs & ATTR_TANGENT ) { *tangent++ = R_VboPackTangent(dv->tangent); } -#endif if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { VectorCopy2(dv->st, texCoords); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index e8e2c6e496..d527ba730b 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -263,9 +263,7 @@ void R_InitVBOs(void) dataSize = sizeof(tess.xyz[0]); dataSize += sizeof(tess.normal[0]); -#ifdef USE_VERT_TANGENT_SPACE dataSize += sizeof(tess.tangent[0]); -#endif dataSize += sizeof(tess.vertexColors[0]); dataSize += sizeof(tess.texCoords[0][0]) * 2; dataSize += sizeof(tess.lightdir[0]); @@ -275,25 +273,21 @@ void R_InitVBOs(void) offset = 0; - tess.vbo->ofs_xyz = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; - tess.vbo->ofs_normal = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; -#ifdef USE_VERT_TANGENT_SPACE - tess.vbo->ofs_tangent = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; -#endif + tess.vbo->offsets[ATTR_INDEX_POSITION] = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; + tess.vbo->offsets[ATTR_INDEX_NORMAL] = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; // these next two are actually interleaved - tess.vbo->ofs_st = offset; offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; + tess.vbo->offsets[ATTR_INDEX_TEXCOORD0] = offset; offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; + tess.vbo->offsets[ATTR_INDEX_TANGENT] = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; - tess.vbo->ofs_vertexcolor = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES; - tess.vbo->ofs_lightdir = offset; + tess.vbo->offsets[ATTR_INDEX_COLOR] = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES; + tess.vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offset; - tess.vbo->stride_xyz = sizeof(tess.xyz[0]); - tess.vbo->stride_normal = sizeof(tess.normal[0]); -#ifdef USE_VERT_TANGENT_SPACE - tess.vbo->stride_tangent = sizeof(tess.tangent[0]); -#endif - tess.vbo->stride_vertexcolor = sizeof(tess.vertexColors[0]); - tess.vbo->stride_st = sizeof(tess.texCoords[0][0]) * 2; - tess.vbo->stride_lightdir = sizeof(tess.lightdir[0]); + tess.vbo->strides[ATTR_INDEX_POSITION] = sizeof(tess.xyz[0]); + tess.vbo->strides[ATTR_INDEX_NORMAL] = sizeof(tess.normal[0]); + tess.vbo->strides[ATTR_INDEX_TANGENT] = sizeof(tess.tangent[0]); + tess.vbo->strides[ATTR_INDEX_COLOR] = sizeof(tess.vertexColors[0]); + tess.vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; + tess.vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); dataSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; @@ -375,6 +369,68 @@ void R_VBOList_f(void) ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", indexesSize / (1024.0f * 1024.0f)); } +void AddVertexArray(VertexArraysProperties *properties, int attributeIndex, size_t size, int stride, int offset, void *stream ) +{ + properties->enabledAttributes[properties->numVertexArrays] = attributeIndex; + properties->offsets[attributeIndex] = offset; + properties->vertexDataSize += size; + properties->sizes[attributeIndex] = size; + properties->strides[attributeIndex] = stride; + properties->streams[attributeIndex] = stream; + + properties->numVertexArrays++; +} + +void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties) +{ + properties->vertexDataSize = 0; + properties->numVertexArrays = 0; + + if(attributes & ATTR_BITS) + { + if (attributes & ATTR_POSITION) + AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); + + if (attributes & (ATTR_TEXCOORD0 | ATTR_TEXCOORD1)) + AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0]); + + if (attributes & ATTR_NORMAL) + AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); + + if (attributes & ATTR_TANGENT) + AddVertexArray(properties, ATTR_INDEX_TANGENT, sizeof(tess.tangent[0]), 0, properties->vertexDataSize, tess.tangent); + + if (attributes & ATTR_COLOR) + AddVertexArray(properties, ATTR_INDEX_COLOR, sizeof(tess.vertexColors[0]), 0, properties->vertexDataSize, tess.vertexColors); + + if (attributes & ATTR_LIGHTDIRECTION) + AddVertexArray(properties, ATTR_INDEX_LIGHTDIRECTION, sizeof(tess.lightdir[0]), 0, properties->vertexDataSize, tess.lightdir); + } + else + { + AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); + AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0]); + AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); + AddVertexArray(properties, ATTR_INDEX_TANGENT, sizeof(tess.tangent[0]), 0, properties->vertexDataSize, tess.tangent); + AddVertexArray(properties, ATTR_INDEX_COLOR, sizeof(tess.vertexColors[0]), 0, properties->vertexDataSize, tess.vertexColors); + AddVertexArray(properties, ATTR_INDEX_LIGHTDIRECTION, sizeof(tess.lightdir[0]), 0, properties->vertexDataSize, tess.lightdir); + } + + for ( int i = 0; i < properties->numVertexArrays; i++ ) + properties->strides[properties->enabledAttributes[i]] = properties->vertexDataSize; +} + +void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties) +{ + properties->vertexDataSize = 0; + properties->numVertexArrays = 0; + + for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + { + if ( attributes & j ) + AddVertexArray(properties, i, vbo->sizes[i], vbo->strides[i], vbo->offsets[i], NULL); + } +} /* ============== @@ -394,65 +450,30 @@ void RB_UpdateVBOs(unsigned int attribBits) // update the default VBO if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) { - backEnd.pc.c_dynamicVboTotalSize += tess.numVertexes * (tess.vbo->vertexesSize / SHADER_MAX_VERTEXES); + VertexArraysProperties vertexArrays = {}; + CalculateVertexArraysProperties(attribBits, &vertexArrays); + + backEnd.pc.c_dynamicVboTotalSize += tess.numVertexes * vertexArrays.vertexDataSize; R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it - qglBufferData(GL_ARRAY_BUFFER, tess.vbo->vertexesSize, NULL, GL_STREAM_DRAW); + void *dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, 0, tess.numVertexes * vertexArrays.vertexDataSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + void *writePtr = dstPtr; - if(attribBits & ATTR_BITS) + // Interleave the data + for ( int i = 0; i < tess.numVertexes; i++ ) { - if(attribBits & ATTR_POSITION) - { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0])); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); - } - - if(attribBits & ATTR_TEXCOORD0 || attribBits & ATTR_TEXCOORD1) - { - // these are interleaved, so we update both if either need it - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); - } - - if(attribBits & ATTR_NORMAL) - { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0])); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); - } - -#ifdef USE_VERT_TANGENT_SPACE - if(attribBits & ATTR_TANGENT) - { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0])); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); - } -#endif - - if(attribBits & ATTR_COLOR) + for ( int j = 0; j < vertexArrays.numVertexArrays; j++ ) { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0])); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); - } + int attributeIndex = vertexArrays.enabledAttributes[j]; - if(attribBits & ATTR_LIGHTDIRECTION) - { - //ri->Printf(PRINT_ALL, "offset %d, size %d\n", tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0])); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); + memcpy(writePtr, (byte *)vertexArrays.streams[attributeIndex] + i * vertexArrays.sizes[attributeIndex], vertexArrays.sizes[attributeIndex]); + writePtr = (byte *)writePtr + vertexArrays.sizes[attributeIndex]; } } - else - { - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_xyz, tess.numVertexes * sizeof(tess.xyz[0]), tess.xyz); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_st, tess.numVertexes * sizeof(tess.texCoords[0][0]) * 2, tess.texCoords); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_normal, tess.numVertexes * sizeof(tess.normal[0]), tess.normal); -#ifdef USE_VERT_TANGENT_SPACE - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_tangent, tess.numVertexes * sizeof(tess.tangent[0]), tess.tangent); -#endif - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_vertexcolor, tess.numVertexes * sizeof(tess.vertexColors[0]), tess.vertexColors); - qglBufferSubData(GL_ARRAY_BUFFER, tess.vbo->ofs_lightdir, tess.numVertexes * sizeof(tess.lightdir[0]), tess.lightdir); - } + + qglUnmapBuffer(GL_ARRAY_BUFFER); } // update the default IBO From acc6020ad7fc44e3e05cfb0bc8d88e315148df8d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 23 May 2015 17:41:59 +0100 Subject: [PATCH 251/708] Rend2: Improve dynamic vertex data streaming Instead of orphaning the same buffer over and over for every dynamic object, create a large buffers for vertex and index data and then append to this buffer until it runs out. At this point, orphan the buffer and then start over. --- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_glsl.cpp | 9 +++++++ codemp/rd-rend2/tr_local.h | 5 ++++ codemp/rd-rend2/tr_shade.cpp | 4 +++- codemp/rd-rend2/tr_sky.cpp | 2 ++ codemp/rd-rend2/tr_surface.cpp | 4 ++++ codemp/rd-rend2/tr_vbo.cpp | 44 ++++++++++++++++++++++------------ 7 files changed, 53 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b3d5d029d5..7a7b1d94dc 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2063,7 +2063,7 @@ static void R_CreateWorldVBOs(void) vbo->offsets[ATTR_INDEX_NORMAL] = offsetof(packedVertex_t, normal); vbo->offsets[ATTR_INDEX_TANGENT] = offsetof(packedVertex_t, tangent); vbo->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(packedVertex_t, texcoords[0]); - vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[1]); + vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[0]); vbo->offsets[ATTR_INDEX_COLOR] = offsetof(packedVertex_t, colors); vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offsetof(packedVertex_t, lightDirection); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 24717196dc..fa541a746b 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1860,6 +1860,15 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, }; + if ( tess.useInternalVBO ) + { + for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) + { + int attributeIndex = vertexArrays.enabledAttributes[i]; + vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; + } + } + for ( int i = 0, j = 1 ; i < ATTR_INDEX_MAX; i++, j <<= 1 ) { if ( attribBits & j ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 88f538702a..fde20c344a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2453,6 +2453,10 @@ struct shaderCommands_s VBO_t *vbo; IBO_t *ibo; qboolean useInternalVBO; + int internalVBOWriteOffset; + int internalVBOCommitOffset; + int internalIBOWriteOffset; + int internalIBOCommitOffset; stageVars_t svars QALIGN(16); @@ -2652,6 +2656,7 @@ void R_ShutdownVBOs(void); void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); +void RB_CommitInternalBufferData(); void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ebd023e255..82f98e32cc 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -42,7 +42,7 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { - qglDrawRangeElements(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t))); + qglDrawRangeElements(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)) + (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0)); } @@ -1850,6 +1850,8 @@ void RB_StageIteratorGeneric( void ) RB_FogPass(); } + RB_CommitInternalBufferData(); + // // reset polygon offset // diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 8488e8bdbf..f5ae628740 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -472,6 +472,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max //R_BindNullVBO(); //R_BindNullIBO(); + RB_CommitInternalBufferData(); + tess.numIndexes = tess.firstIndex; tess.numVertexes = firstVertex; tess.firstIndex = 0; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 1061a02fce..40053b0f0c 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -206,6 +206,8 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + RB_CommitInternalBufferData(); + tess.numIndexes = 0; tess.numVertexes = 0; tess.firstIndex = 0; @@ -657,6 +659,8 @@ static void RB_SurfaceBeam( void ) R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + RB_CommitInternalBufferData(); + tess.numIndexes = 0; tess.numVertexes = 0; tess.firstIndex = 0; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index d527ba730b..2d67937222 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -261,14 +261,7 @@ void R_InitVBOs(void) tr.numVBOs = 0; tr.numIBOs = 0; - dataSize = sizeof(tess.xyz[0]); - dataSize += sizeof(tess.normal[0]); - dataSize += sizeof(tess.tangent[0]); - dataSize += sizeof(tess.vertexColors[0]); - dataSize += sizeof(tess.texCoords[0][0]) * 2; - dataSize += sizeof(tess.lightdir[0]); - dataSize *= SHADER_MAX_VERTEXES; - + dataSize = 12 * 1024 * 1024; tess.vbo = R_CreateVBO(NULL, dataSize, VBO_USAGE_DYNAMIC); offset = 0; @@ -289,8 +282,7 @@ void R_InitVBOs(void) tess.vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; tess.vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); - dataSize = sizeof(tess.indexes[0]) * SHADER_MAX_INDEXES; - + dataSize = 4 * 1024 * 1024; tess.ibo = R_CreateIBO(NULL, dataSize, VBO_USAGE_DYNAMIC); R_BindNullVBO(); @@ -450,15 +442,24 @@ void RB_UpdateVBOs(unsigned int attribBits) // update the default VBO if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) { + GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; VertexArraysProperties vertexArrays = {}; CalculateVertexArraysProperties(attribBits, &vertexArrays); - backEnd.pc.c_dynamicVboTotalSize += tess.numVertexes * vertexArrays.vertexDataSize; + int totalVertexDataSize = tess.numVertexes * vertexArrays.vertexDataSize; + backEnd.pc.c_dynamicVboTotalSize += totalVertexDataSize; + + if ( (tess.internalVBOWriteOffset + totalVertexDataSize) > tess.vbo->vertexesSize ) + { + tess.internalVBOCommitOffset = 0; + tess.internalVBOWriteOffset = 0; + mapFlags |= GL_MAP_INVALIDATE_BUFFER_BIT; + } R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it - void *dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, 0, tess.numVertexes * vertexArrays.vertexDataSize, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT); + void *dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, tess.internalVBOWriteOffset, totalVertexDataSize, mapFlags); void *writePtr = dstPtr; // Interleave the data @@ -474,16 +475,29 @@ void RB_UpdateVBOs(unsigned int attribBits) } qglUnmapBuffer(GL_ARRAY_BUFFER); + tess.internalVBOWriteOffset += totalVertexDataSize; } // update the default IBO if(tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES) { + int totalIndexDataSize = tess.numIndexes * sizeof(tess.indexes[0]); + R_BindIBO(tess.ibo); - // orphan old buffer so we don't stall on it - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, tess.ibo->indexesSize, NULL, GL_STREAM_DRAW); + if ( (tess.internalIBOWriteOffset + totalIndexDataSize) > tess.ibo->indexesSize ) + { + tess.internalIBOCommitOffset = 0; + tess.internalIBOWriteOffset = 0; + } - qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, tess.numIndexes * sizeof(tess.indexes[0]), tess.indexes); + qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOWriteOffset, totalIndexDataSize, tess.indexes); + tess.internalIBOWriteOffset += totalIndexDataSize; } } + +void RB_CommitInternalBufferData() +{ + tess.internalIBOCommitOffset = tess.internalIBOWriteOffset; + tess.internalVBOCommitOffset = tess.internalVBOWriteOffset; +} \ No newline at end of file From 0d2f61ae2bd6f9ac11782be6c2744693b8bbe025 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 23 May 2015 18:22:58 +0100 Subject: [PATCH 252/708] Rend2: Upload indices using mapped buffer --- codemp/rd-rend2/tr_glsl.cpp | 14 +++++--------- codemp/rd-rend2/tr_vbo.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index fa541a746b..5d577771fc 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1832,6 +1832,11 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) if ( tess.useInternalVBO ) { CalculateVertexArraysProperties(attribBits, &vertexArrays); + for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) + { + int attributeIndex = vertexArrays.enabledAttributes[i]; + vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; + } } else { @@ -1859,15 +1864,6 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, }; - - if ( tess.useInternalVBO ) - { - for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) - { - int attributeIndex = vertexArrays.enabledAttributes[i]; - vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; - } - } for ( int i = 0, j = 1 ; i < ATTR_INDEX_MAX; i++, j <<= 1 ) { diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 2d67937222..239879dc05 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -481,6 +481,7 @@ void RB_UpdateVBOs(unsigned int attribBits) // update the default IBO if(tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES) { + GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; int totalIndexDataSize = tess.numIndexes * sizeof(tess.indexes[0]); R_BindIBO(tess.ibo); @@ -489,9 +490,13 @@ void RB_UpdateVBOs(unsigned int attribBits) { tess.internalIBOCommitOffset = 0; tess.internalIBOWriteOffset = 0; + mapFlags |= GL_MAP_INVALIDATE_BUFFER_BIT; } - qglBufferSubData(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOWriteOffset, totalIndexDataSize, tess.indexes); + void *dst = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOCommitOffset, totalIndexDataSize, mapFlags); + memcpy(dst, tess.indexes, totalIndexDataSize); + qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + tess.internalIBOWriteOffset += totalIndexDataSize; } } From 1f383ec8ecb8a2cc6ced0e49b46fd8154e758817 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 23 May 2015 18:32:42 +0100 Subject: [PATCH 253/708] Rend2: Add back the texcoord fixup code --- codemp/rd-rend2/tr_glsl.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5d577771fc..21fa5ea5aa 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1787,7 +1787,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits) void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) { - return; VBO_t *vbo = glState.currentVBO; if ( attribBits & ATTR_TEXCOORD0 ) From b6818697e81c1c4d1bb6825130e1dc0e1669ff6c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 24 May 2015 22:34:46 +0100 Subject: [PATCH 254/708] Rend2: Code cleanup and shader sorting In addition to shaders being sorted by their 'sort' field, they're also sorted by number of stages. --- codemp/rd-rend2/tr_backend.cpp | 24 +-- codemp/rd-rend2/tr_ghoul2.cpp | 352 --------------------------------- codemp/rd-rend2/tr_glsl.cpp | 7 - codemp/rd-rend2/tr_local.h | 3 - codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 16 +- 6 files changed, 28 insertions(+), 376 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a8b1cb96c5..1ea6df962f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -567,7 +567,7 @@ void RB_BeginDrawingView (void) { RB_RenderDrawSurfList ================== */ -void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { +static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { shader_t *shader, *oldShader; int fogNum, oldFogNum; int entityNum, oldEntityNum; @@ -938,7 +938,7 @@ RB_SetColor ============= */ -const void *RB_SetColor( const void *data ) { +static const void *RB_SetColor( const void *data ) { const setColorCommand_t *cmd; cmd = (const setColorCommand_t *)data; @@ -956,7 +956,7 @@ const void *RB_SetColor( const void *data ) { RB_StretchPic ============= */ -const void *RB_StretchPic ( const void *data ) { +static const void *RB_StretchPic ( const void *data ) { const stretchPicCommand_t *cmd; shader_t *shader; int numVerts, numIndexes; @@ -1045,7 +1045,7 @@ const void *RB_StretchPic ( const void *data ) { RB_DrawRotatePic ============= */ -const void *RB_RotatePic ( const void *data ) +static const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; image_t *image; @@ -1143,7 +1143,7 @@ const void *RB_RotatePic ( const void *data ) RB_DrawRotatePic2 ============= */ -const void *RB_RotatePic2 ( const void *data ) +static const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; image_t *image; @@ -1243,7 +1243,7 @@ RB_DrawSurfs ============= */ -const void *RB_DrawSurfs( const void *data ) { +static const void *RB_DrawSurfs( const void *data ) { const drawSurfsCommand_t *cmd; // finish any 2D drawing if needed @@ -1520,7 +1520,7 @@ RB_DrawBuffer ============= */ -const void *RB_DrawBuffer( const void *data ) { +static const void *RB_DrawBuffer( const void *data ) { const drawBufferCommand_t *cmd; cmd = (const drawBufferCommand_t *)data; @@ -1607,7 +1607,7 @@ RB_ColorMask ============= */ -const void *RB_ColorMask(const void *data) +static const void *RB_ColorMask(const void *data) { const colorMaskCommand_t *cmd = (colorMaskCommand_t *)data; @@ -1632,7 +1632,7 @@ RB_ClearDepth ============= */ -const void *RB_ClearDepth(const void *data) +static const void *RB_ClearDepth(const void *data) { const clearDepthCommand_t *cmd = (clearDepthCommand_t *)data; @@ -1673,7 +1673,7 @@ RB_SwapBuffers ============= */ -const void *RB_SwapBuffers( const void *data ) { +static const void *RB_SwapBuffers( const void *data ) { const swapBuffersCommand_t *cmd; // finish any 2D drawing if needed @@ -1742,7 +1742,7 @@ RB_CapShadowMap ============= */ -const void *RB_CapShadowMap(const void *data) +static const void *RB_CaptureShadowMap(const void *data) { const capShadowmapCommand_t *cmd = (const capShadowmapCommand_t *)data; @@ -2019,7 +2019,7 @@ void RB_ExecuteRenderCommands( const void *data ) { data = RB_ClearDepth(data); break; case RC_CAPSHADOWMAP: - data = RB_CapShadowMap(data); + data = RB_CaptureShadowMap(data); break; case RC_POSTPROCESS: data = RB_PostProcess(data); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 2987275121..17e55e1448 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3460,11 +3460,8 @@ static void MDXABoneToMatrix ( const mdxaBone_t& bone, matrix_t& matrix ) matrix[15] = 1.0f; } -//This is a slightly mangled version of the same function from the sof2sp base. -//It provides a pretty significant performance increase over the existing one. void RB_SurfaceGhoul( CRenderableSurface *surf ) { -#if 1 static matrix_t boneMatrices[80] = {}; mdxmSurface_t *surfData = surf->surfaceData; @@ -3504,355 +3501,6 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) // So we don't lerp surfaces that shouldn't be lerped glState.skeletalAnimation = qfalse; -#else -#ifdef G2_PERFORMANCE_ANALYSIS - G2PerformanceTimer_RB_SurfaceGhoul.Start(); -#endif - - static int j, k; - static int baseIndex, baseVertex; - static int numVerts; - static mdxmVertex_t *v; - static int *triangles; - static int indexes; - static glIndex_t *tessIndexes; - static mdxmVertexTexCoord_t *pTexCoords; - static int *piBoneReferences; - -#ifdef _G2_GORE - if (surf->alternateTex) - { - // a gore surface ready to go. - - /* - sizeof(int)+ // num verts - sizeof(int)+ // num tris - sizeof(int)*newNumVerts+ // which verts to copy from original surface - sizeof(float)*4*newNumVerts+ // storgage for deformed verts - sizeof(float)*4*newNumVerts+ // storgage for deformed normal - sizeof(float)*2*newNumVerts+ // texture coordinates - sizeof(int)*newNumTris*3; // new indecies - */ - - int *data=(int *)surf->alternateTex; - numVerts=*data++; - indexes=(*data++); - // first up, sanity check our numbers - RB_CheckOverflow(numVerts,indexes); - indexes*=3; - - data+=numVerts; - - baseIndex = tess.numIndexes; - baseVertex = tess.numVertexes; - - memcpy(&tess.xyz[baseVertex][0],data,sizeof(float)*4*numVerts); - data+=4*numVerts; - memcpy(&tess.normal[baseVertex][0],data,sizeof(float)*4*numVerts); - data+=4*numVerts; - assert(numVerts>0); - - //float *texCoords = tess.texCoords[0][baseVertex]; - float *texCoords = tess.texCoords[baseVertex][0]; - int hack = baseVertex; - //rww - since the array is arranged as such we cannot increment - //the relative memory position to get where we want. Maybe this - //is why sof2 has the texCoords array reversed. In any case, I - //am currently too lazy to get around it. - //Or can you += array[.][x]+2? - if (surf->scale>1.0f) - { - for ( j = 0; j < numVerts; j++) - { - texCoords[0]=((*(float *)data)-0.5f)*surf->scale+0.5f; - data++; - texCoords[1]=((*(float *)data)-0.5f)*surf->scale+0.5f; - data++; - //texCoords+=2;// Size of gore (s,t). - hack++; - texCoords = tess.texCoords[hack][0]; - } - } - else - { - for (j=0;jfade) - { - static int lFade; - static int j; - - if (surf->fade<1.0) - { - tess.fading = true; - lFade = Q_ftol(254.4f*surf->fade); - - for (j=0;jfade > 2.0f && surf->fade < 3.0f) - { //hack to fade out on RGB if desired (don't want to add more to CRenderableSurface) -rww - tess.fading = true; - lFade = Q_ftol(254.4f*(surf->fade-2.0f)); - - for (j=0;jsurfaceData; - - CBoneCache *bones = surf->boneCache; - -#ifndef _G2_GORE //we use this later, for gore - delete surf; -#endif - - // first up, sanity check our numbers - RB_CheckOverflow( surface->numVerts, surface->numTriangles ); - - // - // deform the vertexes by the lerped bones - // - - // first up, sanity check our numbers - baseVertex = tess.numVertexes; - triangles = (int *) ((byte *)surface + surface->ofsTriangles); - baseIndex = tess.numIndexes; -#if 0 - indexes = surface->numTriangles * 3; - for (j = 0 ; j < indexes ; j++) { - tess.indexes[baseIndex + j] = baseVertex + triangles[j]; - } - tess.numIndexes += indexes; -#else - indexes = surface->numTriangles; //*3; //unrolled 3 times, don't multiply - tessIndexes = &tess.indexes[baseIndex]; - for (j = 0 ; j < indexes ; j++) { - *tessIndexes++ = baseVertex + *triangles++; - *tessIndexes++ = baseVertex + *triangles++; - *tessIndexes++ = baseVertex + *triangles++; - } - tess.numIndexes += indexes*3; -#endif - - numVerts = surface->numVerts; - - piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); - baseVertex = tess.numVertexes; - v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); - pTexCoords = (mdxmVertexTexCoord_t *) &v[numVerts]; - -// if (r_ghoul2fastnormals&&r_ghoul2fastnormals->integer==0) -#if 0 - if (0) - { - for ( j = 0; j < numVerts; j++, baseVertex++,v++ ) - { - const int iNumWeights = G2_GetVertWeights( v ); - - float fTotalWeight = 0.0f; - - k=0; - int iBoneIndex = G2_GetVertBoneIndex( v, k ); - float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); - const mdxaBone_t *bone = &bones->EvalRender(piBoneReferences[iBoneIndex]); - - tess.xyz[baseVertex][0] = fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] = fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] = fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - - tess.normal[baseVertex][0] = fBoneWeight * DotProduct( bone->matrix[0], v->normal ); - tess.normal[baseVertex][1] = fBoneWeight * DotProduct( bone->matrix[1], v->normal ); - tess.normal[baseVertex][2] = fBoneWeight * DotProduct( bone->matrix[2], v->normal ); - - for ( k++ ; k < iNumWeights ; k++) - { - iBoneIndex = G2_GetVertBoneIndex( v, k ); - fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); - - bone = &bones->EvalRender(piBoneReferences[iBoneIndex]); - - tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - - tess.normal[baseVertex][0] += fBoneWeight * DotProduct( bone->matrix[0], v->normal ); - tess.normal[baseVertex][1] += fBoneWeight * DotProduct( bone->matrix[1], v->normal ); - tess.normal[baseVertex][2] += fBoneWeight * DotProduct( bone->matrix[2], v->normal ); - } - - tess.texCoords[baseVertex][0][0] = pTexCoords[j].texCoords[0]; - tess.texCoords[baseVertex][0][1] = pTexCoords[j].texCoords[1]; - } - } - else - { -#endif - float fTotalWeight; - float fBoneWeight; - float t1; - float t2; - const mdxaBone_t *bone; - const mdxaBone_t *bone2; - for ( j = 0; j < numVerts; j++, baseVertex++,v++ ) - { - - bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, 0 )]); - int iNumWeights = G2_GetVertWeights( v ); - tess.normal[baseVertex][0] = DotProduct( bone->matrix[0], v->normal ); - tess.normal[baseVertex][1] = DotProduct( bone->matrix[1], v->normal ); - tess.normal[baseVertex][2] = DotProduct( bone->matrix[2], v->normal ); - - if (iNumWeights==1) - { - tess.xyz[baseVertex][0] = ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] = ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] = ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - } - else - { - fBoneWeight = G2_GetVertBoneWeightNotSlow( v, 0); - if (iNumWeights==2) - { - bone2 = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, 1 )]); - /* - useless transposition - tess.xyz[baseVertex][0] = - v[0]*(w*(bone->matrix[0][0]-bone2->matrix[0][0])+bone2->matrix[0][0])+ - v[1]*(w*(bone->matrix[0][1]-bone2->matrix[0][1])+bone2->matrix[0][1])+ - v[2]*(w*(bone->matrix[0][2]-bone2->matrix[0][2])+bone2->matrix[0][2])+ - w*(bone->matrix[0][3]-bone2->matrix[0][3]) + bone2->matrix[0][3]; - */ - t1 = ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - t2 = ( DotProduct( bone2->matrix[0], v->vertCoords ) + bone2->matrix[0][3] ); - tess.xyz[baseVertex][0] = fBoneWeight * (t1-t2) + t2; - t1 = ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - t2 = ( DotProduct( bone2->matrix[1], v->vertCoords ) + bone2->matrix[1][3] ); - tess.xyz[baseVertex][1] = fBoneWeight * (t1-t2) + t2; - t1 = ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - t2 = ( DotProduct( bone2->matrix[2], v->vertCoords ) + bone2->matrix[2][3] ); - tess.xyz[baseVertex][2] = fBoneWeight * (t1-t2) + t2; - } - else - { - - tess.xyz[baseVertex][0] = fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] = fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] = fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - - fTotalWeight=fBoneWeight; - for (k=1; k < iNumWeights-1 ; k++) - { - bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, k )]); - fBoneWeight = G2_GetVertBoneWeightNotSlow( v, k); - fTotalWeight += fBoneWeight; - - tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - } - bone = &bones->EvalRender(piBoneReferences[G2_GetVertBoneIndex( v, k )]); - fBoneWeight = 1.0f-fTotalWeight; - - tess.xyz[baseVertex][0] += fBoneWeight * ( DotProduct( bone->matrix[0], v->vertCoords ) + bone->matrix[0][3] ); - tess.xyz[baseVertex][1] += fBoneWeight * ( DotProduct( bone->matrix[1], v->vertCoords ) + bone->matrix[1][3] ); - tess.xyz[baseVertex][2] += fBoneWeight * ( DotProduct( bone->matrix[2], v->vertCoords ) + bone->matrix[2][3] ); - } - } - - tess.texCoords[baseVertex][0][0] = pTexCoords[j].texCoords[0]; - tess.texCoords[baseVertex][0][1] = pTexCoords[j].texCoords[1]; - } -#if 0 - } -#endif - -#ifdef _G2_GORE - CRenderableSurface *storeSurf = surf; - - while (surf->goreChain) - { - surf=(CRenderableSurface *)surf->goreChain; - if (surf->alternateTex) - { - // get a gore surface ready to go. - - /* - sizeof(int)+ // num verts - sizeof(int)+ // num tris - sizeof(int)*newNumVerts+ // which verts to copy from original surface - sizeof(float)*4*newNumVerts+ // storgage for deformed verts - sizeof(float)*4*newNumVerts+ // storgage for deformed normal - sizeof(float)*2*newNumVerts+ // texture coordinates - sizeof(int)*newNumTris*3; // new indecies - */ - - int *data=(int *)surf->alternateTex; - int gnumVerts=*data++; - data++; - - float *fdata=(float *)data; - fdata+=gnumVerts; - for (j=0;j=0&&data[j]=0&&data[j]numVerts; - -#ifdef G2_PERFORMANCE_ANALYSIS - G2Time_RB_SurfaceGhoul += G2PerformanceTimer_RB_SurfaceGhoul.End(); -#endif -#endif } /* diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 21fa5ea5aa..186ec7581c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1806,8 +1806,6 @@ void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) void GLSL_VertexAttribPointers(uint32_t attribBits) { - qboolean animated; - int newFrame, oldFrame; VBO_t *vbo = glState.currentVBO; if(!vbo) @@ -1822,11 +1820,6 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); } - // position/normal/tangent are always set in case of animation - oldFrame = glState.vertexAttribsOldFrame; - newFrame = glState.vertexAttribsNewFrame; - animated = glState.vertexAnimation; - VertexArraysProperties vertexArrays; if ( tess.useInternalVBO ) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fde20c344a..429b10c7e8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2487,9 +2487,6 @@ struct shaderCommands_s int numPasses; void (*currentStageIteratorFunc)( void ); shaderStage_t **xstages; - - // JA specific - bool fading; }; #ifdef _WIN32 diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 82f98e32cc..c460066868 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1709,7 +1709,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) void RB_StageIteratorGeneric( void ) { shaderCommands_t *input; - unsigned int vertexAttribs = 0; + uint32_t vertexAttribs = 0; input = &tess; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4a4324b9b7..5113594665 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3133,10 +3133,24 @@ static void SortNewShader( void ) { newShader = tr.shaders[ tr.numShaders - 1 ]; sort = newShader->sort; + int numStagesInNewShader = 0; + while ( newShader->stages[numStagesInNewShader] ) + numStagesInNewShader++; + for ( i = tr.numShaders - 2 ; i >= 0 ; i-- ) { - if ( tr.sortedShaders[ i ]->sort <= sort ) { + int numStages = 0; + while ( tr.sortedShaders[numStages] ) + numStages++; + + if ( tr.sortedShaders[ i ]->sort < sort ) { + break; + } + + if ( tr.sortedShaders[ i ]->sort == sort && numStages <= numStagesInNewShader ) + { break; } + tr.sortedShaders[i+1] = tr.sortedShaders[i]; tr.sortedShaders[i+1]->sortedIndex++; } From d39c6a7e0c6b8db6745f1ebed420bb55563a9a64 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 25 May 2015 13:37:05 +0100 Subject: [PATCH 255/708] Rend2: Fix cinematics not rendering correctly Some code paths which call R_DrawElementsVBO directly do not set tess.useInternalVBO so vertex attribute pointers were not being set correctly. --- codemp/rd-rend2/tr_sky.cpp | 4 +++- codemp/rd-rend2/tr_surface.cpp | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index f5ae628740..754711c011 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -418,6 +418,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max tess.minIndex = firstVertex; tess.maxIndex = tess.numVertexes; + tess.useInternalVBO = qtrue; // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); @@ -473,7 +474,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max //R_BindNullIBO(); RB_CommitInternalBufferData(); - + + tess.useInternalVBO = qfalse; tess.numIndexes = tess.firstIndex; tess.numVertexes = firstVertex; tess.firstIndex = 0; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 40053b0f0c..0fafecbf4b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -199,6 +199,7 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) tess.indexes[tess.numIndexes++] = 3; tess.minIndex = 0; tess.maxIndex = 3; + tess.useInternalVBO = qtrue; RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); @@ -213,6 +214,7 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) tess.firstIndex = 0; tess.minIndex = 0; tess.maxIndex = 0; + tess.useInternalVBO = qfalse; } @@ -646,6 +648,7 @@ static void RB_SurfaceBeam( void ) tess.minIndex = 0; tess.maxIndex = tess.numVertexes; + tess.useInternalVBO = qtrue; // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function RB_UpdateVBOs(ATTR_POSITION); @@ -666,6 +669,7 @@ static void RB_SurfaceBeam( void ) tess.firstIndex = 0; tess.minIndex = 0; tess.maxIndex = 0; + tess.useInternalVBO = qfalse; } //------------------ From 899a2aac3e05d47b13af4126d66bb4175521f680 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 27 May 2015 23:10:29 +0100 Subject: [PATCH 256/708] Rend2: Fix random crashes It helps if you assign the result of an operation to something instead of throwing it away :) --- codemp/rd-rend2/tr_glsl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 186ec7581c..03590d07f8 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1764,13 +1764,14 @@ void GLSL_VertexAttribsState(uint32_t stateBits) { uint32_t diff; + //Com_Printf("%d\n", stateBits); GLSL_VertexAttribPointers(stateBits); diff = stateBits ^ glState.vertexAttribsState; if (!diff) return; - for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j << 1 ) + for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) { // FIXME: Use BitScanForward? if (diff & j) From e8cbb99a290278f1ce3fbfe877ce4dc0b406e764 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 28 May 2015 21:03:57 +0100 Subject: [PATCH 257/708] Rend2: Support for persistently mapped buffers Only used when immutable buffers are enabled (r_arb_buffer_storage). --- codemp/rd-rend2/qgl.h | 205 +----------------------------- codemp/rd-rend2/tr_extensions.cpp | 27 ++++ codemp/rd-rend2/tr_init.cpp | 3 + codemp/rd-rend2/tr_local.h | 4 + codemp/rd-rend2/tr_vbo.cpp | 101 +++++++++++++-- 5 files changed, 128 insertions(+), 212 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 6a6894d0d3..8cfa06ebdd 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -578,206 +578,5 @@ extern PFNGLTEXSTORAGE3DPROC qglTexStorage3D; #define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F #endif -#if defined(WIN32) -// WGL_ARB_create_context -#ifndef WGL_ARB_create_context -#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 -#define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 -#define ERROR_INVALID_VERSION_ARB 0x2095 -#define ERROR_INVALID_PROFILE_ARB 0x2096 -#endif - -extern HGLRC(APIENTRY * qwglCreateContextAttribsARB) (HDC hdC, HGLRC hShareContext, const int *attribList); -#endif - -#if 0 //defined(__linux__) -// GLX_ARB_create_context -#ifndef GLX_ARB_create_context -#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 -#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 -#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 -#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 -#define GLX_CONTEXT_FLAGS_ARB 0x2094 -#endif - -extern GLXContext (APIENTRY * qglXCreateContextAttribsARB) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); -#endif - -#ifdef _WIN32 - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pixel Format extension definitions. - AReis -/***********************************************************************************************************/ -#define WGL_COLOR_BITS_ARB 0x2014 -#define WGL_ALPHA_BITS_ARB 0x201B -#define WGL_DEPTH_BITS_ARB 0x2022 -#define WGL_STENCIL_BITS_ARB 0x2023 - -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); -typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); -typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); -/***********************************************************************************************************/ - -// Declare Pixel Format function pointers. -extern PFNWGLGETPIXELFORMATATTRIBIVARBPROC qwglGetPixelFormatAttribivARB; -extern PFNWGLGETPIXELFORMATATTRIBFVARBPROC qwglGetPixelFormatAttribfvARB; -extern PFNWGLCHOOSEPIXELFORMATARBPROC qwglChoosePixelFormatARB; - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Pixel Buffer extension definitions. - AReis -/***********************************************************************************************************/ -DECLARE_HANDLE(HPBUFFERARB); - -#define WGL_SUPPORT_OPENGL_ARB 0x2010 -#define WGL_DOUBLE_BUFFER_ARB 0x2011 -#define WGL_DRAW_TO_PBUFFER_ARB 0x202D -#define WGL_PBUFFER_WIDTH_ARB 0x2034 -#define WGL_PBUFFER_HEIGHT_ARB 0x2035 -#define WGL_RED_BITS_ARB 0x2015 -#define WGL_GREEN_BITS_ARB 0x2017 -#define WGL_BLUE_BITS_ARB 0x2019 - -typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); -typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); -typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); -typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); -typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); -/***********************************************************************************************************/ - -// Declare Pixel Buffer function pointers. -extern PFNWGLCREATEPBUFFERARBPROC qwglCreatePbufferARB; -extern PFNWGLGETPBUFFERDCARBPROC qwglGetPbufferDCARB; -extern PFNWGLRELEASEPBUFFERDCARBPROC qwglReleasePbufferDCARB; -extern PFNWGLDESTROYPBUFFERARBPROC qwglDestroyPbufferARB; -extern PFNWGLQUERYPBUFFERARBPROC qwglQueryPbufferARB; - - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Render-Texture extension definitions. - AReis -/***********************************************************************************************************/ -#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 -#define WGL_TEXTURE_FORMAT_ARB 0x2072 -#define WGL_TEXTURE_TARGET_ARB 0x2073 -#define WGL_TEXTURE_RGB_ARB 0x2075 -#define WGL_TEXTURE_RGBA_ARB 0x2076 -#define WGL_TEXTURE_2D_ARB 0x207A -#define WGL_FRONT_LEFT_ARB 0x2083 - -typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); -typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int * piAttribList); -/***********************************************************************************************************/ - -// Declare Render-Texture function pointers. -extern PFNWGLBINDTEXIMAGEARBPROC qwglBindTexImageARB; -extern PFNWGLRELEASETEXIMAGEARBPROC qwglReleaseTexImageARB; -extern PFNWGLSETPBUFFERATTRIBARBPROC qwglSetPbufferAttribARB; - -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Vertex and Fragment Program extension definitions. - AReis -/***********************************************************************************************************/ -#ifndef GL_ARB_fragment_program -#define GL_FRAGMENT_PROGRAM_ARB 0x8804 -#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 -#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 -#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 -#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 -#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 -#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A -#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B -#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C -#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D -#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E -#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F -#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 -#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 -#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 -#endif - -// NOTE: These are obviously not all the vertex program flags (have you seen how many there actually are!). I'm -// only including the ones I use (to reduce code clutter), so if you need any of the other flags, just add them. -#define GL_VERTEX_PROGRAM_ARB 0x8620 -#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 - -typedef void (APIENTRY * PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); -typedef void (APIENTRY * PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); -typedef void (APIENTRY * PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); -typedef void (APIENTRY * PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); -typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRY * PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); -typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); -typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -typedef void (APIENTRY * PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); -typedef void (APIENTRY * PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRY * PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRY * PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); -typedef void (APIENTRY * PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); -typedef void (APIENTRY * PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -typedef void (APIENTRY * PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); -typedef GLboolean (APIENTRY * PFNGLISPROGRAMARBPROC) (GLuint program); -/***********************************************************************************************************/ - -// Declare Vertex and Fragment Program function pointers. -extern PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB; -extern PFNGLBINDPROGRAMARBPROC qglBindProgramARB; -extern PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB; -extern PFNGLGENPROGRAMSARBPROC qglGenProgramsARB; -extern PFNGLPROGRAMENVPARAMETER4DARBPROC qglProgramEnvParameter4dARB; -extern PFNGLPROGRAMENVPARAMETER4DVARBPROC qglProgramEnvParameter4dvARB; -extern PFNGLPROGRAMENVPARAMETER4FARBPROC qglProgramEnvParameter4fARB; -extern PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB; -extern PFNGLPROGRAMLOCALPARAMETER4DARBPROC qglProgramLocalParameter4dARB; -extern PFNGLPROGRAMLOCALPARAMETER4DVARBPROC qglProgramLocalParameter4dvARB; -extern PFNGLPROGRAMLOCALPARAMETER4FARBPROC qglProgramLocalParameter4fARB; -extern PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB; -extern PFNGLGETPROGRAMENVPARAMETERDVARBPROC qglGetProgramEnvParameterdvARB; -extern PFNGLGETPROGRAMENVPARAMETERFVARBPROC qglGetProgramEnvParameterfvARB; -extern PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC qglGetProgramLocalParameterdvARB; -extern PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC qglGetProgramLocalParameterfvARB; -extern PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB; -extern PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB; -extern PFNGLISPROGRAMARBPROC qglIsProgramARB; - -extern PFNGLCLEARBUFFERFVPROC qglClearBufferfv; - - -/* -** extension constants -*/ - - -// S3TC compression constants -#define GL_RGB_S3TC 0x83A0 -#define GL_RGB4_S3TC 0x83A1 - - -// extensions will be function pointers on all platforms - -extern void ( APIENTRY * qglMultiTexCoord2fARB )( GLenum texture, GLfloat s, GLfloat t ); -extern void ( APIENTRY * qglActiveTextureARB )( GLenum texture ); -extern void ( APIENTRY * qglClientActiveTextureARB )( GLenum texture ); - -extern void ( APIENTRY * qglLockArraysEXT) (GLint, GLint); -extern void ( APIENTRY * qglUnlockArraysEXT) (void); - -extern void ( APIENTRY * qglPointParameterfEXT)( GLenum, GLfloat); -extern void ( APIENTRY * qglPointParameterfvEXT)( GLenum, GLfloat *); - -//3d textures -rww -extern void ( APIENTRY * qglTexImage3DEXT) (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); -extern void ( APIENTRY * qglTexSubImage3DEXT) (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); - -#define GL_MAX_ACTIVE_TEXTURES_ARB 0x84E2 \ No newline at end of file +// GL_ARB_buffer_storage +extern PFNGLBUFFERSTORAGEPROC qglBufferStorage; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 28affed984..05bd188390 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -203,6 +203,9 @@ PFNGLTEXSTORAGE1DPROC qglTexStorage1D; PFNGLTEXSTORAGE2DPROC qglTexStorage2D; PFNGLTEXSTORAGE3DPROC qglTexStorage3D; +// GL_ARB_buffer_storage +PFNGLBUFFERSTORAGEPROC qglBufferStorage; + static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); @@ -482,6 +485,30 @@ void GLimp_InitExtraExtensions() ri->Printf(PRINT_ALL, result[2], extension); } + // GL_ARB_buffer_storage + extension = "GL_ARB_buffer_storage"; + glRefConfig.immutableBuffers = qfalse; + if( GLimp_HaveExtension( extension ) ) + { + qboolean loaded = qtrue; + + if ( r_arb_buffer_storage->integer ) + { + loaded = (qboolean)(loaded && GetGLFunction (qglBufferStorage, "glBufferStorage", qfalse)); + } + else + { + loaded = qfalse; + } + + glRefConfig.immutableBuffers = loaded; + ri->Printf(PRINT_ALL, result[loaded], extension); + } + else + { + ri->Printf(PRINT_ALL, result[2], extension); + } + // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(r_floatLightmap->integer && r_hdr->integer); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f86f129f91..b8eb53002a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -94,6 +94,7 @@ cvar_t *r_arb_half_float_pixel; cvar_t *r_ext_framebuffer_multisample; cvar_t *r_arb_seamless_cube_map; cvar_t *r_arb_vertex_type_2_10_10_10_rev; +cvar_t *r_arb_buffer_storage; cvar_t *r_mergeMultidraws; cvar_t *r_mergeLeafSurfaces; @@ -1527,6 +1528,7 @@ static void GfxInfo_f( void ) if ( displayRefresh ) { ri->Printf( PRINT_ALL, "Display refresh set to %d\n", displayRefresh ); } + if ( r_finish->integer ) { ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); } @@ -1634,6 +1636,7 @@ void R_Register( void ) r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); + r_arb_buffer_storage = ri->Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH); r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE ); r_dynamicGlow = ri->Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 429b10c7e8..97f6680016 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1834,6 +1834,7 @@ typedef struct { int textureCompression; qboolean immutableTextures; + qboolean immutableBuffers; qboolean floatLightmap; } glRefConfig_t; @@ -2159,6 +2160,7 @@ extern cvar_t *r_arb_half_float_pixel; extern cvar_t *r_ext_framebuffer_multisample; extern cvar_t *r_arb_seamless_cube_map; extern cvar_t *r_arb_vertex_type_2_10_10_10_rev; +extern cvar_t *r_arb_buffer_storage; extern cvar_t *r_nobind; // turns off binding to appropriate textures extern cvar_t *r_singleShader; // make most world faces use default shader @@ -2452,6 +2454,8 @@ struct shaderCommands_s VBO_t *vbo; IBO_t *ibo; + void *vboData; // If immutable buffers + void *iboData; // are available qboolean useInternalVBO; int internalVBOWriteOffset; int internalVBOCommitOffset; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 239879dc05..20aa3396c3 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -77,7 +77,6 @@ R_CreateVBO VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) { VBO_t *vbo; - int glUsage = GetGLBufferUsage (usage); if ( tr.numVBOs == MAX_VBOS ) { ri->Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); @@ -94,7 +93,21 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) tr.numVBOs++; qglBindBuffer(GL_ARRAY_BUFFER, vbo->vertexesVBO); - qglBufferData(GL_ARRAY_BUFFER, vertexesSize, vertexes, glUsage); + if ( glRefConfig.immutableBuffers ) + { + GLbitfield creationFlags = 0; + if ( usage == VBO_USAGE_DYNAMIC ) + { + creationFlags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; + } + + qglBufferStorage(GL_ARRAY_BUFFER, vertexesSize, vertexes, creationFlags); + } + else + { + int glUsage = GetGLBufferUsage (usage); + qglBufferData(GL_ARRAY_BUFFER, vertexesSize, vertexes, glUsage); + } qglBindBuffer(GL_ARRAY_BUFFER, 0); @@ -113,7 +126,6 @@ R_CreateIBO IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) { IBO_t *ibo; - int glUsage = GetGLBufferUsage (usage); if ( tr.numIBOs == MAX_IBOS ) { ri->Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); @@ -128,7 +140,22 @@ IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) tr.numIBOs++; qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO); - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, glUsage); + if ( glRefConfig.immutableBuffers ) + { + GLbitfield creationFlags = 0; + if ( usage == VBO_USAGE_DYNAMIC ) + { + creationFlags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; + } + + qglBufferStorage(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, creationFlags); + GL_CheckErrors(); + } + else + { + int glUsage = GetGLBufferUsage (usage); + qglBufferData(GL_ELEMENT_ARRAY_BUFFER, indexesSize, indexes, glUsage); + } qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); @@ -282,9 +309,32 @@ void R_InitVBOs(void) tess.vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; tess.vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); + tess.vbo->sizes[ATTR_INDEX_POSITION] = sizeof(tess.xyz[0]); + tess.vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(tess.normal[0]); + tess.vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(tess.tangent[0]); + tess.vbo->sizes[ATTR_INDEX_COLOR] = sizeof(tess.vertexColors[0]); + tess.vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; + tess.vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); + dataSize = 4 * 1024 * 1024; tess.ibo = R_CreateIBO(NULL, dataSize, VBO_USAGE_DYNAMIC); + if ( glRefConfig.immutableBuffers ) + { + R_BindVBO(tess.vbo); + GL_CheckErrors(); + + R_BindIBO(tess.ibo); + GL_CheckErrors(); + + tess.vboData = qglMapBufferRange(GL_ARRAY_BUFFER, 0, tess.vbo->vertexesSize, GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT); + GL_CheckErrors(); + + tess.iboData = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, tess.ibo->indexesSize, GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT); + GL_CheckErrors(); + + } + R_BindNullVBO(); R_BindNullIBO(); @@ -300,6 +350,14 @@ void R_ShutdownVBOs(void) { ri->Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); + if ( glRefConfig.immutableBuffers ) + { + R_BindVBO(tess.vbo); + R_BindIBO(tess.ibo); + qglUnmapBuffer(GL_ARRAY_BUFFER); + qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + } + R_BindNullVBO(); R_BindNullIBO(); @@ -459,10 +517,18 @@ void RB_UpdateVBOs(unsigned int attribBits) R_BindVBO(tess.vbo); // orphan old buffer so we don't stall on it - void *dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, tess.internalVBOWriteOffset, totalVertexDataSize, mapFlags); - void *writePtr = dstPtr; + void *dstPtr; + if ( glRefConfig.immutableBuffers ) + { + dstPtr = (byte *)tess.vboData + tess.internalVBOWriteOffset; + } + else + { + dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, tess.internalVBOWriteOffset, totalVertexDataSize, mapFlags); + } // Interleave the data + void *writePtr = dstPtr; for ( int i = 0; i < tess.numVertexes; i++ ) { for ( int j = 0; j < vertexArrays.numVertexArrays; j++ ) @@ -474,7 +540,11 @@ void RB_UpdateVBOs(unsigned int attribBits) } } - qglUnmapBuffer(GL_ARRAY_BUFFER); + if ( !glRefConfig.immutableBuffers ) + { + qglUnmapBuffer(GL_ARRAY_BUFFER); + } + tess.internalVBOWriteOffset += totalVertexDataSize; } @@ -493,9 +563,22 @@ void RB_UpdateVBOs(unsigned int attribBits) mapFlags |= GL_MAP_INVALIDATE_BUFFER_BIT; } - void *dst = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOCommitOffset, totalIndexDataSize, mapFlags); + void *dst; + if ( glRefConfig.immutableBuffers ) + { + dst = (byte *)tess.iboData + tess.internalIBOWriteOffset; + } + else + { + dst = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOCommitOffset, totalIndexDataSize, mapFlags); + } + memcpy(dst, tess.indexes, totalIndexDataSize); - qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + + if ( !glRefConfig.immutableBuffers ) + { + qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + } tess.internalIBOWriteOffset += totalIndexDataSize; } From 63031b6fcf4cedfe94c0463cad9d53b4712b4412 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 28 May 2015 21:05:46 +0100 Subject: [PATCH 258/708] Rend2: Tidy up code cruft --- codemp/rd-rend2/qgl.h | 4 + codemp/rd-rend2/tr_backend.cpp | 15 +- codemp/rd-rend2/tr_cmds.cpp | 1 - codemp/rd-rend2/tr_extensions.cpp | 45 ++++- codemp/rd-rend2/tr_flares.cpp | 4 - codemp/rd-rend2/tr_image.cpp | 23 +-- codemp/rd-rend2/tr_init.cpp | 300 +----------------------------- codemp/rd-rend2/tr_local.h | 3 +- codemp/rd-rend2/tr_shade.cpp | 20 +- codemp/rd-rend2/tr_shader.cpp | 4 - codemp/rd-rend2/tr_surface.cpp | 2 +- codemp/rd-rend2/tr_vbo.cpp | 2 +- 12 files changed, 69 insertions(+), 354 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 8cfa06ebdd..62dbb5dbfe 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -406,6 +406,9 @@ extern PFNGLUNMAPBUFFERPROC qglUnmapBuffer; extern PFNGLCOPYBUFFERSUBDATAPROC qglCopyBufferSubData; extern PFNGLISBUFFERPROC qglIsBuffer; +// Texturing +extern PFNGLACTIVETEXTUREPROC qglActiveTexture; + // Shader objects extern PFNGLCREATESHADERPROC qglCreateShader; extern PFNGLSHADERSOURCEPROC qglShaderSource; @@ -543,6 +546,7 @@ extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC qglRenderbufferStorageMultisample extern PFNGLBLITFRAMEBUFFERPROC qglBlitFramebuffer; extern PFNGLGENERATEMIPMAPPROC qglGenerateMipmap; extern PFNGLDRAWBUFFERSPROC qglDrawBuffers; +extern PFNGLCLEARBUFFERFVPROC qglClearBufferfv; // Query objects extern PFNGLGENQUERIESPROC qglGenQueries; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1ea6df962f..3923d0b4e8 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -78,7 +78,7 @@ void GL_SelectTexture( int unit ) if (!(unit >= 0 && unit <= 31)) ri->Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); - qglActiveTextureARB( GL_TEXTURE0_ARB + unit ); + qglActiveTexture( GL_TEXTURE0 + unit ); glState.currenttmu = unit; } @@ -438,15 +438,6 @@ to actually render the visible surfaces for this view void RB_BeginDrawingView (void) { int clearBits = 0; - // sync with gl if needed - if ( r_finish->integer == 1 && !glState.finishCalled ) { - qglFinish (); - glState.finishCalled = qtrue; - } - if ( r_finish->integer == 0 ) { - glState.finishCalled = qtrue; - } - // we will need to change the projection matrix before drawing // 2D images again backEnd.projection2D = qfalse; @@ -1722,10 +1713,6 @@ static const void *RB_SwapBuffers( const void *data ) { } } - if ( !glState.finishCalled ) { - qglFinish(); - } - GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); ri->WIN_Present( &window ); diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 7f46597a50..f8931595c1 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -379,7 +379,6 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { if ( !tr.registered ) { return; } - glState.finishCalled = qfalse; tr.frameCount++; tr.frameSceneNum = 0; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 05bd188390..e1d0f2574e 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -67,6 +67,9 @@ PFNGLUNMAPBUFFERPROC qglUnmapBuffer; PFNGLCOPYBUFFERSUBDATAPROC qglCopyBufferSubData; PFNGLISBUFFERPROC qglIsBuffer; +// Texturing +PFNGLACTIVETEXTUREPROC qglActiveTexture; + // Shader objects PFNGLCREATESHADERPROC qglCreateShader; PFNGLSHADERSOURCEPROC qglShaderSource; @@ -232,11 +235,14 @@ static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionSt return qtrue; } -void GLimp_InitExtraExtensions() +void GLW_InitTextureCompression( void ); +void GLimp_InitExtensions() { char *extension; const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; + Com_Printf("Initializing OpenGL 3.2 functions\n"); + // Drawing commands GetGLFunction (qglDrawRangeElements, "glDrawRangeElements", qtrue); GetGLFunction (qglDrawArraysInstanced, "glDrawArraysInstanced", qtrue); @@ -279,6 +285,10 @@ void GLimp_InitExtraExtensions() GetGLFunction (qglCopyBufferSubData, "glCopyBufferSubData", qtrue); GetGLFunction (qglIsBuffer, "glIsBuffer", qtrue); + // Texturing + GetGLFunction (qglActiveTexture, "glActiveTexture", qtrue); + + // Shader objects GetGLFunction (qglCreateShader, "glCreateShader", qtrue); GetGLFunction (qglShaderSource, "glShaderSource", qtrue); @@ -424,9 +434,40 @@ void GLimp_InitExtraExtensions() GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv", qtrue); GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv", qtrue); + Com_Printf ("Initializing OpenGL extensions\n" ); + + // Select our tc scheme + GLW_InitTextureCompression(); + + // GL_EXT_texture_filter_anisotropic + glConfig.maxTextureFilterAnisotropy = 0; + if ( GLimp_HaveExtension( "EXT_texture_filter_anisotropic" ) ) + { + qglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.maxTextureFilterAnisotropy ); + Com_Printf ("...GL_EXT_texture_filter_anisotropic available\n" ); + + if ( r_ext_texture_filter_anisotropic->integer > 1 ) + { + Com_Printf ("...using GL_EXT_texture_filter_anisotropic\n" ); + } + else + { + Com_Printf ("...ignoring GL_EXT_texture_filter_anisotropic\n" ); + } + ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) + { + ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + } + } + else + { + Com_Printf ("...GL_EXT_texture_filter_anisotropic not found\n" ); + ri->Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); + } + // Memory info glRefConfig.memInfo = MI_NONE; - if( GLimp_HaveExtension( "GL_NVX_gpu_memory_info" ) ) { glRefConfig.memInfo = MI_NVX; diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index a609f97fa6..5f975e4bc7 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -281,10 +281,6 @@ void RB_TestFlare( flare_t *f ) { backEnd.pc.c_flareTests++; - // doing a readpixels is as good as doing a glFinish(), so - // don't bother with another sync - glState.finishCalled = qfalse; - // if we're doing multisample rendering, read from the correct FBO oldFbo = glState.currentFBO; if (tr.msaaResolveFbo) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 97931e7ff9..1534a76523 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2297,15 +2297,13 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT // lightmaps are always allocated on TMU 1 - if ( qglActiveTextureARB && isLightmap ) { + if ( isLightmap ) { image->TMU = 1; } else { image->TMU = 0; } - if ( qglActiveTextureARB ) { - GL_SelectTexture( image->TMU ); - } + GL_SelectTexture( image->TMU ); if (image->flags & IMGFLAG_CUBEMAP) { @@ -2416,10 +2414,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); - if ( qglActiveTextureARB ) { - GL_SelectTexture( image->TMU ); - } - + GL_SelectTexture( image->TMU ); GL_Bind(image); // copy or resample data as appropriate for first MIP level @@ -3062,12 +3057,8 @@ void R_DeleteTextures( void ) { tr.numImages = 0; Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) ); - if ( qglActiveTextureARB ) { - GL_SelectTexture( 1 ); - qglBindTexture( GL_TEXTURE_2D, 0 ); - GL_SelectTexture( 0 ); - qglBindTexture( GL_TEXTURE_2D, 0 ); - } else { - qglBindTexture( GL_TEXTURE_2D, 0 ); - } + GL_SelectTexture( 1 ); + qglBindTexture( GL_TEXTURE_2D, 0 ); + GL_SelectTexture( 0 ); + qglBindTexture( GL_TEXTURE_2D, 0 ); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index b8eb53002a..da30218a9c 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -25,9 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "ghoul2/g2_local.h" #include -bool g_bDynamicGlowSupported = false; // Not used. Put here to keep *_glimp from whining at us. --eez -bool g_bTextureRectangleHack = false; - glconfig_t glConfig; glconfigExt_t glConfigExt; glRefConfig_t glRefConfig; @@ -358,7 +355,7 @@ bool GL_CheckForExtension(const char *ext) } -static void GLW_InitTextureCompression( void ) +void GLW_InitTextureCompression( void ) { bool newer_tc, old_tc; @@ -465,293 +462,6 @@ static void GLW_InitTextureCompression( void ) } } -/* -=============== -GLimp_InitExtensions -=============== -*/ -extern bool g_bDynamicGlowSupported; -static void GLimp_InitExtensions( void ) -{ - if ( !r_allowExtensions->integer ) - { - Com_Printf ("*** IGNORING OPENGL EXTENSIONS ***\n" ); - g_bDynamicGlowSupported = false; - ri->Cvar_Set( "r_DynamicGlow","0" ); - return; - } - - Com_Printf ("Initializing OpenGL extensions\n" ); - - // Select our tc scheme - GLW_InitTextureCompression(); - - // GL_EXT_texture_env_add - glConfig.textureEnvAddAvailable = qfalse; - if ( GL_CheckForExtension( "EXT_texture_env_add" ) ) - { - if ( r_ext_texture_env_add->integer ) - { - glConfig.textureEnvAddAvailable = qtrue; - Com_Printf ("...using GL_EXT_texture_env_add\n" ); - } - else - { - glConfig.textureEnvAddAvailable = qfalse; - Com_Printf ("...ignoring GL_EXT_texture_env_add\n" ); - } - } - else - { - Com_Printf ("...GL_EXT_texture_env_add not found\n" ); - } - - // GL_EXT_texture_filter_anisotropic - glConfig.maxTextureFilterAnisotropy = 0; - if ( GL_CheckForExtension( "EXT_texture_filter_anisotropic" ) ) - { - qglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.maxTextureFilterAnisotropy ); - Com_Printf ("...GL_EXT_texture_filter_anisotropic available\n" ); - - if ( r_ext_texture_filter_anisotropic->integer > 1 ) - { - Com_Printf ("...using GL_EXT_texture_filter_anisotropic\n" ); - } - else - { - Com_Printf ("...ignoring GL_EXT_texture_filter_anisotropic\n" ); - } - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); - if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) - { - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); - } - } - else - { - Com_Printf ("...GL_EXT_texture_filter_anisotropic not found\n" ); - ri->Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); - } - - // GL_EXT_clamp_to_edge - glConfig.clampToEdgeAvailable = qtrue; - Com_Printf ("...using GL_EXT_texture_edge_clamp\n" ); - - // GL_ARB_multitexture - qglMultiTexCoord2fARB = NULL; - qglActiveTextureARB = NULL; - qglClientActiveTextureARB = NULL; - if ( GL_CheckForExtension( "GL_ARB_multitexture" ) ) - { - if ( r_ext_multitexture->integer ) - { - qglMultiTexCoord2fARB = ( PFNGLMULTITEXCOORD2FARBPROC ) ri->GL_GetProcAddress( "glMultiTexCoord2fARB" ); - qglActiveTextureARB = ( PFNGLACTIVETEXTUREARBPROC ) ri->GL_GetProcAddress( "glActiveTextureARB" ); - qglClientActiveTextureARB = ( PFNGLCLIENTACTIVETEXTUREARBPROC ) ri->GL_GetProcAddress( "glClientActiveTextureARB" ); - - if ( qglActiveTextureARB ) - { - qglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.maxActiveTextures ); - - if ( glConfig.maxActiveTextures > 1 ) - { - Com_Printf ("...using GL_ARB_multitexture\n" ); - } - else - { - qglMultiTexCoord2fARB = NULL; - qglActiveTextureARB = NULL; - qglClientActiveTextureARB = NULL; - Com_Printf ("...not using GL_ARB_multitexture, < 2 texture units\n" ); - } - } - } - else - { - Com_Printf ("...ignoring GL_ARB_multitexture\n" ); - } - } - else - { - Com_Printf ("...GL_ARB_multitexture not found\n" ); - } - - // GL_EXT_compiled_vertex_array - qglLockArraysEXT = NULL; - qglUnlockArraysEXT = NULL; - if ( GL_CheckForExtension( "GL_EXT_compiled_vertex_array" ) ) - { - if ( r_ext_compiled_vertex_array->integer ) - { - Com_Printf ("...using GL_EXT_compiled_vertex_array\n" ); - qglLockArraysEXT = ( PFNGLLOCKARRAYSEXTPROC ) ri->GL_GetProcAddress( "glLockArraysEXT" ); - qglUnlockArraysEXT = ( PFNGLUNLOCKARRAYSEXTPROC ) ri->GL_GetProcAddress( "glUnlockArraysEXT" ); - if (!qglLockArraysEXT || !qglUnlockArraysEXT) { - Com_Error (ERR_FATAL, "bad getprocaddress"); - } - } - else - { - Com_Printf ("...ignoring GL_EXT_compiled_vertex_array\n" ); - } - } - else - { - Com_Printf ("...GL_EXT_compiled_vertex_array not found\n" ); - } - - bool bNVRegisterCombiners = false; - // Register Combiners. - if ( GL_CheckForExtension( "GL_NV_register_combiners" ) ) - { - // NOTE: This extension requires multitexture support (over 2 units). - if ( glConfig.maxActiveTextures >= 2 ) - { - bNVRegisterCombiners = true; - // Register Combiners function pointer address load. - AReis - // NOTE: VV guys will _definetly_ not be able to use regcoms. Pixel Shaders are just as good though :-) - // NOTE: Also, this is an nVidia specific extension (of course), so fragment shaders would serve the same purpose - // if we needed some kind of fragment/pixel manipulation support. - qglCombinerParameterfvNV = (PFNGLCOMBINERPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glCombinerParameterfvNV" ); - qglCombinerParameterivNV = (PFNGLCOMBINERPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glCombinerParameterivNV" ); - qglCombinerParameterfNV = (PFNGLCOMBINERPARAMETERFNVPROC)ri->GL_GetProcAddress( "glCombinerParameterfNV" ); - qglCombinerParameteriNV = (PFNGLCOMBINERPARAMETERINVPROC)ri->GL_GetProcAddress( "glCombinerParameteriNV" ); - qglCombinerInputNV = (PFNGLCOMBINERINPUTNVPROC)ri->GL_GetProcAddress( "glCombinerInputNV" ); - qglCombinerOutputNV = (PFNGLCOMBINEROUTPUTNVPROC)ri->GL_GetProcAddress( "glCombinerOutputNV" ); - qglFinalCombinerInputNV = (PFNGLFINALCOMBINERINPUTNVPROC)ri->GL_GetProcAddress( "glFinalCombinerInputNV" ); - qglGetCombinerInputParameterfvNV = (PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetCombinerInputParameterfvNV" ); - qglGetCombinerInputParameterivNV = (PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetCombinerInputParameterivNV" ); - qglGetCombinerOutputParameterfvNV = (PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetCombinerOutputParameterfvNV" ); - qglGetCombinerOutputParameterivNV = (PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetCombinerOutputParameterivNV" ); - qglGetFinalCombinerInputParameterfvNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC)ri->GL_GetProcAddress( "glGetFinalCombinerInputParameterfvNV" ); - qglGetFinalCombinerInputParameterivNV = (PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC)ri->GL_GetProcAddress( "glGetFinalCombinerInputParameterivNV" ); - - // Validate the functions we need. - if ( !qglCombinerParameterfvNV || !qglCombinerParameterivNV || !qglCombinerParameterfNV || !qglCombinerParameteriNV || !qglCombinerInputNV || - !qglCombinerOutputNV || !qglFinalCombinerInputNV || !qglGetCombinerInputParameterfvNV || !qglGetCombinerInputParameterivNV || - !qglGetCombinerOutputParameterfvNV || !qglGetCombinerOutputParameterivNV || !qglGetFinalCombinerInputParameterfvNV || !qglGetFinalCombinerInputParameterivNV ) - { - bNVRegisterCombiners = false; - qglCombinerParameterfvNV = NULL; - qglCombinerParameteriNV = NULL; - Com_Printf ("...GL_NV_register_combiners failed\n" ); - } - } - else - { - bNVRegisterCombiners = false; - Com_Printf ("...ignoring GL_NV_register_combiners\n" ); - } - } - else - { - bNVRegisterCombiners = false; - Com_Printf ("...GL_NV_register_combiners not found\n" ); - } - - // NOTE: Vertex and Fragment Programs are very dependant on each other - this is actually a - // good thing! So, just check to see which we support (one or the other) and load the shared - // function pointers. ARB rocks! - - // Vertex Programs. - bool bARBVertexProgram = false; - if ( GL_CheckForExtension( "GL_ARB_vertex_program" ) ) - { - bARBVertexProgram = true; - } - else - { - bARBVertexProgram = false; - Com_Printf ("...GL_ARB_vertex_program not found\n" ); - } - - // Fragment Programs. - bool bARBFragmentProgram = false; - if ( GL_CheckForExtension( "GL_ARB_fragment_program" ) ) - { - bARBFragmentProgram = true; - } - else - { - bARBFragmentProgram = false; - Com_Printf ("...GL_ARB_fragment_program not found\n" ); - } - - // If we support one or the other, load the shared function pointers. - if ( bARBVertexProgram || bARBFragmentProgram ) - { - qglProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) ri->GL_GetProcAddress("glProgramStringARB"); - qglBindProgramARB = (PFNGLBINDPROGRAMARBPROC) ri->GL_GetProcAddress("glBindProgramARB"); - qglDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) ri->GL_GetProcAddress("glDeleteProgramsARB"); - qglGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) ri->GL_GetProcAddress("glGenProgramsARB"); - qglProgramEnvParameter4dARB = (PFNGLPROGRAMENVPARAMETER4DARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4dARB"); - qglProgramEnvParameter4dvARB = (PFNGLPROGRAMENVPARAMETER4DVARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4dvARB"); - qglProgramEnvParameter4fARB = (PFNGLPROGRAMENVPARAMETER4FARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4fARB"); - qglProgramEnvParameter4fvARB = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) ri->GL_GetProcAddress("glProgramEnvParameter4fvARB"); - qglProgramLocalParameter4dARB = (PFNGLPROGRAMLOCALPARAMETER4DARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4dARB"); - qglProgramLocalParameter4dvARB = (PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4dvARB"); - qglProgramLocalParameter4fARB = (PFNGLPROGRAMLOCALPARAMETER4FARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4fARB"); - qglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) ri->GL_GetProcAddress("glProgramLocalParameter4fvARB"); - qglGetProgramEnvParameterdvARB = (PFNGLGETPROGRAMENVPARAMETERDVARBPROC) ri->GL_GetProcAddress("glGetProgramEnvParameterdvARB"); - qglGetProgramEnvParameterfvARB = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) ri->GL_GetProcAddress("glGetProgramEnvParameterfvARB"); - qglGetProgramLocalParameterdvARB = (PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) ri->GL_GetProcAddress("glGetProgramLocalParameterdvARB"); - qglGetProgramLocalParameterfvARB = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) ri->GL_GetProcAddress("glGetProgramLocalParameterfvARB"); - qglGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) ri->GL_GetProcAddress("glGetProgramivARB"); - qglGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC) ri->GL_GetProcAddress("glGetProgramStringARB"); - qglIsProgramARB = (PFNGLISPROGRAMARBPROC) ri->GL_GetProcAddress("glIsProgramARB"); - - // Validate the functions we need. - if ( !qglProgramStringARB || !qglBindProgramARB || !qglDeleteProgramsARB || !qglGenProgramsARB || - !qglProgramEnvParameter4dARB || !qglProgramEnvParameter4dvARB || !qglProgramEnvParameter4fARB || - !qglProgramEnvParameter4fvARB || !qglProgramLocalParameter4dARB || !qglProgramLocalParameter4dvARB || - !qglProgramLocalParameter4fARB || !qglProgramLocalParameter4fvARB || !qglGetProgramEnvParameterdvARB || - !qglGetProgramEnvParameterfvARB || !qglGetProgramLocalParameterdvARB || !qglGetProgramLocalParameterfvARB || - !qglGetProgramivARB || !qglGetProgramStringARB || !qglIsProgramARB ) - { - bARBVertexProgram = false; - bARBFragmentProgram = false; - qglGenProgramsARB = NULL; //clear ptrs that get checked - qglProgramEnvParameter4fARB = NULL; - Com_Printf ("...ignoring GL_ARB_vertex_program\n" ); - Com_Printf ("...ignoring GL_ARB_fragment_program\n" ); - } - } - - // Figure out which texture rectangle extension to use. - bool bTexRectSupported = false; - if ( Q_stricmpn( glConfig.vendor_string, "ATI Technologies",16 )==0 - && Q_stricmpn( glConfig.version_string, "1.3.3",5 )==0 - && glConfig.version_string[5] < '9' ) //1.3.34 and 1.3.37 and 1.3.38 are broken for sure, 1.3.39 is not - { - g_bTextureRectangleHack = true; - } - - if ( GL_CheckForExtension( "GL_NV_texture_rectangle" ) || GL_CheckForExtension( "GL_EXT_texture_rectangle" ) ) - { - bTexRectSupported = true; - } - - // Find out how many general combiners they have. - #define GL_MAX_GENERAL_COMBINERS_NV 0x854D - GLint iNumGeneralCombiners = 0; - if(bNVRegisterCombiners) - qglGetIntegerv( GL_MAX_GENERAL_COMBINERS_NV, &iNumGeneralCombiners ); - - // Only allow dynamic glows/flares if they have the hardware - if ( bTexRectSupported && bARBVertexProgram && qglActiveTextureARB && glConfig.maxActiveTextures >= 4 && - ( ( bNVRegisterCombiners && iNumGeneralCombiners >= 2 ) || bARBFragmentProgram ) ) - { - g_bDynamicGlowSupported = true; - // this would overwrite any achived setting gwg - // ri->Cvar_Set( "r_DynamicGlow", "1" ); - } - else - { - g_bDynamicGlowSupported = false; - ri->Cvar_Set( "r_DynamicGlow","0" ); - } -} - // Truncates the GL extensions string by only allowing up to 'maxExtensions' extensions in the string. static const char *TruncateGLExtensionsString (const char *extensionsString, int maxExtensions) { @@ -831,8 +541,7 @@ static void InitOpenGL( void ) glConfig.maxTextureSize = Q_max(0, glConfig.maxTextureSize); // initialize extensions - GLimp_InitExtensions( ); - GLimp_InitExtraExtensions( ); + GLimp_InitExtensions(); // set default state GL_SetDefaultState(); @@ -1516,10 +1225,7 @@ static void GfxInfo_f( void ) ri->Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); ri->Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); ri->Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); - ri->Printf( PRINT_ALL, "multitexture: %s\n", enablestrings[qglActiveTextureARB != 0] ); - ri->Printf( PRINT_ALL, "compiled vertex arrays: %s\n", enablestrings[qglLockArraysEXT != 0 ] ); - ri->Printf( PRINT_ALL, "texenv add: %s\n", enablestrings[glConfig.textureEnvAddAvailable != 0] ); - ri->Printf( PRINT_ALL, "compressed textures: %s\n", enablestrings[glConfig.textureCompression!=TC_NONE] ); + if ( r_vertexLight->integer ) { ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 97f6680016..44f1cb7224 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1785,7 +1785,6 @@ typedef struct { typedef struct glstate_s { int currenttextures[NUM_TEXTURE_BUNDLES]; int currenttmu; - qboolean finishCalled; int texEnv[2]; int faceCulling; uint32_t glStateBits; @@ -2423,7 +2422,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS */ static QINLINE void GLimp_LogComment( char *comment ) {} -void GLimp_InitExtraExtensions(); +void GLimp_InitExtensions(); /* ==================================================================== diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c460066868..356ac8831a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1718,15 +1718,21 @@ void RB_StageIteratorGeneric( void ) return; } - if (tess.useInternalVBO) + // + // log this call + // + if ( r_logFile->integer ) { - RB_DeformTessGeometry(); + // don't just call LogComment, or we will get + // a call to va() every frame! + GLimp_LogComment( va("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) ); } vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); if (tess.useInternalVBO) { + RB_DeformTessGeometry(); RB_UpdateVBOs(vertexAttribs); } else @@ -1734,16 +1740,6 @@ void RB_StageIteratorGeneric( void ) backEnd.pc.c_staticVboDraws++; } - // - // log this call - // - if ( r_logFile->integer ) - { - // don't just call LogComment, or we will get - // a call to va() every frame! - GLimp_LogComment( va("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) ); - } - // // set face culling appropriately // diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 5113594665..fbc5af9bff 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2467,10 +2467,6 @@ static qboolean CollapseMultitexture( void ) { int i; textureBundle_t tmpBundle; - if ( !qglActiveTextureARB ) { - return qfalse; - } - // make sure both stages are active if ( !stages[0].active || !stages[1].active ) { return qfalse; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 0fafecbf4b..1e935e0c97 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2052,7 +2052,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) //mdvSurface_t *mdvSurface; refEntity_t *refEnt; -// GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); // FIXME: REIMPLEMENT (wasn't implemented in ioq3 to begin with) --eez + GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); if(!surface->vbo || !surface->ibo) return; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 20aa3396c3..0daf2b63d6 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -441,7 +441,7 @@ void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties if (attributes & ATTR_POSITION) AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); - if (attributes & (ATTR_TEXCOORD0 | ATTR_TEXCOORD1)) + if (attributes & ATTR_TEXCOORD0) AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0]); if (attributes & ATTR_NORMAL) From b2cb9bd9a57fcf68a00c4c791c5ce17a6b9e785c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 3 Jun 2015 21:20:54 +0100 Subject: [PATCH 259/708] Rend2: Add missing vbolist command --- codemp/rd-rend2/tr_init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index da30218a9c..1c57aa5357 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1313,6 +1313,7 @@ static consoleCommand_t commands[] = { //{ "imagecacheinfo", RE_RegisterImages_Info_f }, { "modellist", R_Modellist_f }, //{ "modelcacheinfo", RE_RegisterModels_Info_f }, + { "vbolist", R_VBOList_f }, }; static const size_t numCommands = ARRAY_LEN( commands ); From 10a3f3c571730fee8591a02615cfa8240db4f034 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 9 Jul 2015 09:10:05 -0500 Subject: [PATCH 260/708] Rend2: Applied some fixes from vanilla renderer --- codemp/rd-rend2/CMakeLists.txt | 2 - codemp/rd-rend2/G2_API.cpp | 2 +- codemp/rd-rend2/G2_bones.cpp | 5 +- codemp/rd-rend2/tr_backend.cpp | 144 ++++++++---------- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_cmds.cpp | 8 +- codemp/rd-rend2/tr_init.cpp | 13 +- codemp/rd-rend2/tr_shader.cpp | 42 ++++- codemp/rd-vanilla/tr_backend.cpp | 254 ++++++++++++++----------------- 9 files changed, 234 insertions(+), 238 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 9a7f64d72c..617a344405 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 2.8.8) - # Make sure the user is not executing this script directly if(NOT InOpenJK) message(FATAL_ERROR "Use the top-level cmake script!") diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 8d2d142ecd..8e5128f8ba 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -834,7 +834,7 @@ int G2API_InitGhoul2Model(CGhoul2Info_v **ghoul2Ptr, const char *fileName, int m } else { - G2_Init_Bone_List(ghoul2[model].mBlist); + G2_Init_Bone_List(ghoul2[model].mBlist, ghoul2[model].aHeader->numBones); G2_Init_Bolt_List(ghoul2[model].mBltlist); ghoul2[model].mCustomShader = customShader; ghoul2[model].mCustomSkin = customSkin; diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index d70c9f18e1..75762f6a2e 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -1594,7 +1594,7 @@ void G2_ResetRagDoll(CGhoul2Info_v &ghoul2V) boneInfo_v &blist = ghoul2.mBlist; #if 1 //Eh, screw it. Ragdoll does a lot of terrible things to the bones that probably aren't directly reversible, so just reset it all. - G2_Init_Bone_List(blist); + G2_Init_Bone_List(blist, ghoul2.aHeader->numBones); #else //The anims on every bone are messed up too, as are the angles. There's not really any way to get back to a normal state, so just clear the list //and let them re-set their anims/angles gameside. int i = 0; @@ -4839,9 +4839,10 @@ qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params } // set the bone list to all unused so the bone transformation routine ignores it. -void G2_Init_Bone_List(boneInfo_v &blist) +void G2_Init_Bone_List(boneInfo_v &blist, int numBones) { blist.clear(); + blist.reserve(numBones); } void G2_RemoveRedundantBoneOverrides(boneInfo_v &blist, int *activeBones) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1ea6df962f..4bd806f446 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -959,7 +959,6 @@ RB_StretchPic static const void *RB_StretchPic ( const void *data ) { const stretchPicCommand_t *cmd; shader_t *shader; - int numVerts, numIndexes; cmd = (const stretchPicCommand_t *)data; @@ -985,8 +984,8 @@ static const void *RB_StretchPic ( const void *data ) { } RB_CHECKOVERFLOW( 4, 6 ); - numVerts = tess.numVertexes; - numIndexes = tess.numIndexes; + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; tess.numVertexes += 4; tess.numIndexes += 6; @@ -998,16 +997,11 @@ static const void *RB_StretchPic ( const void *data ) { tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; - - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; tess.xyz[ numVerts ][0] = cmd->x; tess.xyz[ numVerts ][1] = cmd->y; @@ -1048,13 +1042,7 @@ RB_DrawRotatePic static const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; - image_t *image; shader_t *shader; - int numVerts; - int numIndexes; - vec3_t point, rotatedPoint; - vec3_t axis = { 0.0f, 0.0f, 1.0f }; - vec3_t xlat; cmd = (const rotatePicCommand_t *)data; @@ -1071,7 +1059,6 @@ static const void *RB_RotatePic ( const void *data ) RB_SetGL2D(); shader = cmd->shader; - image = shader->stages[0]->bundle[0].image[0]; if ( shader != tess.shader ) { if ( tess.numIndexes ) { RB_EndSurface(); @@ -1081,8 +1068,18 @@ static const void *RB_RotatePic ( const void *data ) } RB_CHECKOVERFLOW( 4, 6 ); - numVerts = tess.numVertexes; - numIndexes = tess.numIndexes; + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; + + float angle = DEG2RAD( cmd->a ); + float s = sinf( angle ); + float c = cosf( angle ); + + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x + cmd->w, cmd->y, 1.0f } + }; tess.numVertexes += 4; tess.numIndexes += 6; @@ -1094,43 +1091,36 @@ static const void *RB_RotatePic ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } - - VectorSet (xlat, cmd->x, cmd->y, 0.0f); - - VectorSet (point, -cmd->w, 0.0f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts]); + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; tess.texCoords[ numVerts ][0][0] = cmd->s1; tess.texCoords[ numVerts ][0][1] = cmd->t1; - VectorSet (point, 0.0f, 0.0f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 1]); + tess.xyz[ numVerts + 1 ][0] = m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; - VectorSet (point, 0.0f, cmd->h, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 2]); + tess.xyz[ numVerts + 2 ][0] = m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; - VectorSet (point, -cmd->w, cmd->h, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 3]); + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w) + m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w) + m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; @@ -1146,13 +1136,7 @@ RB_DrawRotatePic2 static const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; - image_t *image; shader_t *shader; - int numVerts; - int numIndexes; - vec3_t point, rotatedPoint; - vec3_t axis = { 0.0f, 0.0f, 1.0f }; - vec3_t xlat; cmd = (const rotatePicCommand_t *)data; @@ -1169,7 +1153,6 @@ static const void *RB_RotatePic2 ( const void *data ) RB_SetGL2D(); shader = cmd->shader; - image = shader->stages[0]->bundle[0].image[0]; if ( shader != tess.shader ) { if ( tess.numIndexes ) { RB_EndSurface(); @@ -1179,8 +1162,18 @@ static const void *RB_RotatePic2 ( const void *data ) } RB_CHECKOVERFLOW( 4, 6 ); - numVerts = tess.numVertexes; - numIndexes = tess.numIndexes; + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; + + float angle = DEG2RAD( cmd->a ); + float s = sinf( angle ); + float c = cosf( angle ); + + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x, cmd->y, 1.0f } + }; tess.numVertexes += 4; tess.numIndexes += 6; @@ -1192,43 +1185,36 @@ static const void *RB_RotatePic2 ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; - - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } - - VectorSet (xlat, cmd->x, cmd->y, 0.0f); - - VectorSet (point, -cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts]); + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; tess.texCoords[ numVerts ][0][0] = cmd->s1; tess.texCoords[ numVerts ][0][1] = cmd->t1; - VectorSet (point, cmd->w * 0.5f, -cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 1]); + tess.xyz[ numVerts + 1 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; - VectorSet (point, cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 2]); + tess.xyz[ numVerts + 2 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; - VectorSet (point, -cmd->w * 0.5f, cmd->h * 0.5f, 0.0f); - RotatePointAroundVector (rotatedPoint, axis, point, -cmd->a); - VectorAdd (rotatedPoint, xlat, tess.xyz[numVerts + 3]); + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 7a7b1d94dc..0155026148 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -101,7 +101,7 @@ static void R_ColorShiftLightingBytes( byte in[4], byte out[4] ) { int shift, r, g, b; // shift the color data based on overbright range - shift = r_mapOverBrightBits->integer - tr.overbrightBits; + shift = Q_max( 0, r_mapOverBrightBits->integer - tr.overbrightBits ); // shift the data based on overbright range r = in[0] << shift; diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 7f46597a50..3aa154e3fe 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -445,11 +445,11 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // check for errors if ( !r_ignoreGLErrors->integer ) { - int err; - R_IssuePendingRenderCommands(); - if ((err = qglGetError()) != GL_NO_ERROR) - ri->Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err); + + GLenum err = qglGetError(); + if ( err != GL_NO_ERROR ) + Com_Error( ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!\n", err ); } if (glConfig.stereoEnabled) { diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f86f129f91..614ea73c90 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -850,7 +850,8 @@ GL_CheckErrors ================== */ void GL_CheckErrs( char *file, int line ) { - int err; +#if defined(_DEBUG) + GLenum err; char s[64]; err = qglGetError(); @@ -885,6 +886,7 @@ void GL_CheckErrs( char *file, int line ) { } ri->Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); +#endif } /* @@ -1859,8 +1861,7 @@ void RE_SetLightStyle (int style, int color); R_Init =============== */ -void R_Init( void ) { - int err; +void R_Init( void ) { int i; byte *ptr; @@ -1943,9 +1944,11 @@ void R_Init( void ) { GLSL_EndLoadGPUShaders (shadersStartTime); - err = qglGetError(); +#if defined(_DEBUG) + GLenum err = qglGetError(); if ( err != GL_NO_ERROR ) - ri->Printf (PRINT_ALL, "glGetError() = 0x%x\n", err); + ri->Printf( PRINT_ALL, "glGetError() = 0x%x\n", err ); +#endif RestoreGhoul2InfoArray(); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 5113594665..86c26a7227 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -31,11 +31,15 @@ static shaderStage_t stages[MAX_SHADER_STAGES]; static shader_t shader; static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS]; +// Hash value (generated using the generateHashValueForText function) for the original +// retail JKA shader for gfx/2d/wedge. +#define RETAIL_ROCKET_WEDGE_SHADER_HASH (1217042) + #define FILE_HASH_SIZE 1024 static shader_t* hashTable[FILE_HASH_SIZE]; #define MAX_SHADERTEXT_HASH 2048 -static char **shaderTextHashTable[MAX_SHADERTEXT_HASH]; +static char **shaderTextHashTable[MAX_SHADERTEXT_HASH] = { 0 }; const int lightmapsNone[MAXLIGHTMAPS] = { @@ -114,14 +118,25 @@ static void ClearGlobalShader(void) shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; } +static uint32_t generateHashValueForText( const char *string, size_t length ) +{ + int i = 0; + uint32_t hash = 0; + + while ( length-- ) + { + hash += string[i] * (i + 119); + i++; + } + + return (hash ^ (hash >> 10) ^ (hash >> 20)); +} + /* ================ return a hash value for the filename ================ */ -#ifdef __GNUCC__ - #warning TODO: check if long is ok here -#endif static long generateHashValue( const char *fname, const int size ) { int i; long hash; @@ -130,7 +145,7 @@ static long generateHashValue( const char *fname, const int size ) { hash = 0; i = 0; while (fname[i] != '\0') { - letter = tolower(fname[i]); + letter = tolower((unsigned char)fname[i]); if (letter =='.') break; // don't include extension if (letter =='\\') letter = '/'; // damn path names if (letter == PATH_SEP) letter = '/'; // damn path names @@ -1938,6 +1953,7 @@ will optimize it. static qboolean ParseShader( const char **text ) { char *token; + const char *begin = *text; int s; s = 0; @@ -2224,6 +2240,22 @@ static qboolean ParseShader( const char **text ) shader.explicitlyDefined = qtrue; + // The basejka rocket lock wedge shader uses the incorrect blending mode. + // It only worked because the shader state was not being set, and relied + // on previous state to be multiplied by alpha. Since fixing RB_RotatePic, + // the shader needs to be fixed here to render correctly. + // + // We match against the retail version of gfx/2d/wedge by calculating the + // hash value of the shader text, and comparing it against a precalculated + // value. + uint32_t shaderHash = generateHashValueForText( begin, *text - begin ); + if ( shaderHash == RETAIL_ROCKET_WEDGE_SHADER_HASH && + Q_stricmp( shader.name, "gfx/2d/wedge" ) == 0 ) + { + stages[0].stateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS); + stages[0].stateBits |= GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + } + return qtrue; } diff --git a/codemp/rd-vanilla/tr_backend.cpp b/codemp/rd-vanilla/tr_backend.cpp index eb6ee3f80a..6b9430bd6d 100644 --- a/codemp/rd-vanilla/tr_backend.cpp +++ b/codemp/rd-vanilla/tr_backend.cpp @@ -1335,7 +1335,6 @@ RB_StretchPic const void *RB_StretchPic ( const void *data ) { const stretchPicCommand_t *cmd; shader_t *shader; - int numVerts, numIndexes; cmd = (const stretchPicCommand_t *)data; @@ -1353,8 +1352,8 @@ const void *RB_StretchPic ( const void *data ) { } RB_CHECKOVERFLOW( 4, 6 ); - numVerts = tess.numVertexes; - numIndexes = tess.numIndexes; + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; tess.numVertexes += 4; tess.numIndexes += 6; @@ -1412,89 +1411,80 @@ RB_DrawRotatePic const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; - image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; - shader = cmd->shader; - image = &shader->stages[0].bundle[0].image[0]; - - if ( image ) { - if ( !backEnd.projection2D ) { - RB_SetGL2D(); - } + if ( !backEnd.projection2D ) { + RB_SetGL2D(); + } - shader = cmd->shader; - if ( shader != tess.shader ) { - if ( tess.numIndexes ) { - RB_EndSurface(); - } - backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0 ); + shader = cmd->shader; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0 ); + } - RB_CHECKOVERFLOW( 4, 6 ); - int numVerts = tess.numVertexes; - int numIndexes = tess.numIndexes; - - float angle = DEG2RAD( cmd-> a ); - float s = sinf( angle ); - float c = cosf( angle ); - - matrix3_t m = { - { c, s, 0.0f }, - { -s, c, 0.0f }, - { cmd->x + cmd->w, cmd->y, 1.0f } - }; + RB_CHECKOVERFLOW( 4, 6 ); + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; - tess.numVertexes += 4; - tess.numIndexes += 6; + float angle = DEG2RAD( cmd->a ); + float s = sinf( angle ); + float c = cosf( angle ); - tess.indexes[ numIndexes ] = numVerts + 3; - tess.indexes[ numIndexes + 1 ] = numVerts + 0; - tess.indexes[ numIndexes + 2 ] = numVerts + 2; - tess.indexes[ numIndexes + 3 ] = numVerts + 2; - tess.indexes[ numIndexes + 4 ] = numVerts + 0; - tess.indexes[ numIndexes + 5 ] = numVerts + 1; + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x + cmd->w, cmd->y, 1.0f } + }; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + tess.numVertexes += 4; + tess.numIndexes += 6; - tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; - tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; - tess.xyz[ numVerts ][2] = 0; + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; - tess.texCoords[ numVerts ][0][0] = cmd->s1; - tess.texCoords[ numVerts ][0][1] = cmd->t1; + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - tess.xyz[ numVerts + 1 ][0] = m[2][0]; - tess.xyz[ numVerts + 1 ][1] = m[2][1]; - tess.xyz[ numVerts + 1 ][2] = 0; + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; - tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; - tess.xyz[ numVerts + 2 ][0] = m[1][0] * (cmd->h) + m[2][0]; - tess.xyz[ numVerts + 2 ][1] = m[1][1] * (cmd->h) + m[2][1]; - tess.xyz[ numVerts + 2 ][2] = 0; + tess.xyz[ numVerts + 1 ][0] = m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; - tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; - tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w) + m[1][0] * (cmd->h) + m[2][0]; - tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w) + m[1][1] * (cmd->h) + m[2][1]; - tess.xyz[ numVerts + 3 ][2] = 0; + tess.xyz[ numVerts + 2 ][0] = m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; - tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; - return (const void *)(cmd + 1); + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w) + m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w) + m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; - } + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; return (const void *)(cmd + 1); } @@ -1507,101 +1497,87 @@ RB_DrawRotatePic2 const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; - image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; - shader = cmd->shader; - - if ( shader->numUnfoggedPasses ) - { - image = &shader->stages[0].bundle[0].image[0]; - - if ( image ) - { - if ( !backEnd.projection2D ) { - RB_SetGL2D(); - } - - shader = cmd->shader; - if ( shader != tess.shader ) { - if ( tess.numIndexes ) { - RB_EndSurface(); - } - backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0 ); - } - - RB_CHECKOVERFLOW( 4, 6 ); - int numVerts = tess.numVertexes; - int numIndexes = tess.numIndexes; + if ( !backEnd.projection2D ) { + RB_SetGL2D(); + } - float angle = DEG2RAD( cmd-> a ); - float s = sinf( angle ); - float c = cosf( angle ); + shader = cmd->shader; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); + } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0 ); + } - matrix3_t m = { - { c, s, 0.0f }, - { -s, c, 0.0f }, - { cmd->x, cmd->y, 1.0f } - }; + RB_CHECKOVERFLOW( 4, 6 ); + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; - tess.numVertexes += 4; - tess.numIndexes += 6; + float angle = DEG2RAD( cmd->a ); + float s = sinf( angle ); + float c = cosf( angle ); - tess.indexes[ numIndexes ] = numVerts + 3; - tess.indexes[ numIndexes + 1 ] = numVerts + 0; - tess.indexes[ numIndexes + 2 ] = numVerts + 2; - tess.indexes[ numIndexes + 3 ] = numVerts + 2; - tess.indexes[ numIndexes + 4 ] = numVerts + 0; - tess.indexes[ numIndexes + 5 ] = numVerts + 1; + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x, cmd->y, 1.0f } + }; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + tess.numVertexes += 4; + tess.numIndexes += 6; - tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts ][2] = 0; + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; - tess.texCoords[ numVerts ][0][0] = cmd->s1; - tess.texCoords[ numVerts ][0][1] = cmd->t1; + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - tess.xyz[ numVerts + 1 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 1 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 1 ][2] = 0; + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; - tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; - tess.xyz[ numVerts + 2 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 2 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 2 ][2] = 0; + tess.xyz[ numVerts + 1 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; - tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; - tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 3 ][2] = 0; + tess.xyz[ numVerts + 2 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; - tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; - return (const void *)(cmd + 1); + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; #if 0 - // Hmmm, this is not too cool - GL_State( GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + // Hmmm, this is not too cool + GL_State( GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); #endif - } - } return (const void *)(cmd + 1); } From 8104a5b73937d37422e4d2a2650f650e40195ae1 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 9 Jul 2015 09:32:00 -0500 Subject: [PATCH 261/708] Rend2: Don't use "using namespace std" in tr_cache.cpp --- codemp/rd-rend2/tr_cache.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index e2cca45269..6a0a08eae6 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -4,7 +4,6 @@ // This differs significantly from Raven's own caching code. // For starters, we are allowed to use ri-> whatever because we don't care about running on dedicated (use rd-vanilla!) -using namespace std; CImageCacheManager *CImgCache = new CImageCacheManager(); CModelCacheManager *CModelCache = new CModelCacheManager(); @@ -30,7 +29,7 @@ void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) FileHash_t fh; fh.handle = handle; Q_strncpyz( fh.fileName, fileName, sizeof(fh.fileName) ); - loaded.insert(make_pair(fileName, fh)); + loaded.insert(std::make_pair(fileName, fh)); } static const byte FakeGLAFile[] = @@ -330,7 +329,7 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const int iNameOffset = psShaderName - (char *)rFile.pDiskImage; int iPokeOffset = (char*) piShaderIndexPoke - (char *)rFile.pDiskImage; - rFile.shaderCache.push_back( make_pair( iNameOffset, iPokeOffset ) ); + rFile.shaderCache.push_back( std::make_pair( iNameOffset, iPokeOffset ) ); } void CModelCacheManager::AllocateShaders( const char *psFileName ) From 53a3fb9dd9a044a270996586405edaacd8594e96 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Thu, 9 Jul 2015 09:33:18 -0500 Subject: [PATCH 262/708] Rend2: Accidentally put changes to vanilla renderer in rend2 branch. --- codemp/rd-vanilla/tr_backend.cpp | 254 +++++++++++++++++-------------- 1 file changed, 139 insertions(+), 115 deletions(-) diff --git a/codemp/rd-vanilla/tr_backend.cpp b/codemp/rd-vanilla/tr_backend.cpp index 6b9430bd6d..eb6ee3f80a 100644 --- a/codemp/rd-vanilla/tr_backend.cpp +++ b/codemp/rd-vanilla/tr_backend.cpp @@ -1335,6 +1335,7 @@ RB_StretchPic const void *RB_StretchPic ( const void *data ) { const stretchPicCommand_t *cmd; shader_t *shader; + int numVerts, numIndexes; cmd = (const stretchPicCommand_t *)data; @@ -1352,8 +1353,8 @@ const void *RB_StretchPic ( const void *data ) { } RB_CHECKOVERFLOW( 4, 6 ); - int numVerts = tess.numVertexes; - int numIndexes = tess.numIndexes; + numVerts = tess.numVertexes; + numIndexes = tess.numIndexes; tess.numVertexes += 4; tess.numIndexes += 6; @@ -1411,80 +1412,89 @@ RB_DrawRotatePic const void *RB_RotatePic ( const void *data ) { const rotatePicCommand_t *cmd; + image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; - if ( !backEnd.projection2D ) { - RB_SetGL2D(); - } - shader = cmd->shader; - if ( shader != tess.shader ) { - if ( tess.numIndexes ) { - RB_EndSurface(); + image = &shader->stages[0].bundle[0].image[0]; + + if ( image ) { + if ( !backEnd.projection2D ) { + RB_SetGL2D(); } - backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0 ); - } - RB_CHECKOVERFLOW( 4, 6 ); - int numVerts = tess.numVertexes; - int numIndexes = tess.numIndexes; + shader = cmd->shader; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); + } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0 ); + } - float angle = DEG2RAD( cmd->a ); - float s = sinf( angle ); - float c = cosf( angle ); + RB_CHECKOVERFLOW( 4, 6 ); + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; - matrix3_t m = { - { c, s, 0.0f }, - { -s, c, 0.0f }, - { cmd->x + cmd->w, cmd->y, 1.0f } - }; + float angle = DEG2RAD( cmd-> a ); + float s = sinf( angle ); + float c = cosf( angle ); - tess.numVertexes += 4; - tess.numIndexes += 6; + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x + cmd->w, cmd->y, 1.0f } + }; - tess.indexes[ numIndexes ] = numVerts + 3; - tess.indexes[ numIndexes + 1 ] = numVerts + 0; - tess.indexes[ numIndexes + 2 ] = numVerts + 2; - tess.indexes[ numIndexes + 3 ] = numVerts + 2; - tess.indexes[ numIndexes + 4 ] = numVerts + 0; - tess.indexes[ numIndexes + 5 ] = numVerts + 1; + tess.numVertexes += 4; + tess.numIndexes += 6; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; - tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; - tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; - tess.xyz[ numVerts ][2] = 0; + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - tess.texCoords[ numVerts ][0][0] = cmd->s1; - tess.texCoords[ numVerts ][0][1] = cmd->t1; + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; - tess.xyz[ numVerts + 1 ][0] = m[2][0]; - tess.xyz[ numVerts + 1 ][1] = m[2][1]; - tess.xyz[ numVerts + 1 ][2] = 0; + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; - tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + tess.xyz[ numVerts + 1 ][0] = m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; - tess.xyz[ numVerts + 2 ][0] = m[1][0] * (cmd->h) + m[2][0]; - tess.xyz[ numVerts + 2 ][1] = m[1][1] * (cmd->h) + m[2][1]; - tess.xyz[ numVerts + 2 ][2] = 0; + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; - tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + tess.xyz[ numVerts + 2 ][0] = m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; - tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w) + m[1][0] * (cmd->h) + m[2][0]; - tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w) + m[1][1] * (cmd->h) + m[2][1]; - tess.xyz[ numVerts + 3 ][2] = 0; + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; - tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w) + m[1][0] * (cmd->h) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w) + m[1][1] * (cmd->h) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; + + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + + return (const void *)(cmd + 1); + + } return (const void *)(cmd + 1); } @@ -1497,87 +1507,101 @@ RB_DrawRotatePic2 const void *RB_RotatePic2 ( const void *data ) { const rotatePicCommand_t *cmd; + image_t *image; shader_t *shader; cmd = (const rotatePicCommand_t *)data; - if ( !backEnd.projection2D ) { - RB_SetGL2D(); - } - shader = cmd->shader; - if ( shader != tess.shader ) { - if ( tess.numIndexes ) { - RB_EndSurface(); - } - backEnd.currentEntity = &backEnd.entity2D; - RB_BeginSurface( shader, 0 ); - } - RB_CHECKOVERFLOW( 4, 6 ); - int numVerts = tess.numVertexes; - int numIndexes = tess.numIndexes; + if ( shader->numUnfoggedPasses ) + { + image = &shader->stages[0].bundle[0].image[0]; - float angle = DEG2RAD( cmd->a ); - float s = sinf( angle ); - float c = cosf( angle ); + if ( image ) + { + if ( !backEnd.projection2D ) { + RB_SetGL2D(); + } - matrix3_t m = { - { c, s, 0.0f }, - { -s, c, 0.0f }, - { cmd->x, cmd->y, 1.0f } - }; + shader = cmd->shader; + if ( shader != tess.shader ) { + if ( tess.numIndexes ) { + RB_EndSurface(); + } + backEnd.currentEntity = &backEnd.entity2D; + RB_BeginSurface( shader, 0 ); + } - tess.numVertexes += 4; - tess.numIndexes += 6; + RB_CHECKOVERFLOW( 4, 6 ); + int numVerts = tess.numVertexes; + int numIndexes = tess.numIndexes; - tess.indexes[ numIndexes ] = numVerts + 3; - tess.indexes[ numIndexes + 1 ] = numVerts + 0; - tess.indexes[ numIndexes + 2 ] = numVerts + 2; - tess.indexes[ numIndexes + 3 ] = numVerts + 2; - tess.indexes[ numIndexes + 4 ] = numVerts + 0; - tess.indexes[ numIndexes + 5 ] = numVerts + 1; + float angle = DEG2RAD( cmd-> a ); + float s = sinf( angle ); + float c = cosf( angle ); - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + matrix3_t m = { + { c, s, 0.0f }, + { -s, c, 0.0f }, + { cmd->x, cmd->y, 1.0f } + }; - tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts ][2] = 0; + tess.numVertexes += 4; + tess.numIndexes += 6; - tess.texCoords[ numVerts ][0][0] = cmd->s1; - tess.texCoords[ numVerts ][0][1] = cmd->t1; + tess.indexes[ numIndexes ] = numVerts + 3; + tess.indexes[ numIndexes + 1 ] = numVerts + 0; + tess.indexes[ numIndexes + 2 ] = numVerts + 2; + tess.indexes[ numIndexes + 3 ] = numVerts + 2; + tess.indexes[ numIndexes + 4 ] = numVerts + 0; + tess.indexes[ numIndexes + 5 ] = numVerts + 1; - tess.xyz[ numVerts + 1 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 1 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 1 ][2] = 0; + byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; + baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; - tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts ][2] = 0; - tess.xyz[ numVerts + 2 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 2 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 2 ][2] = 0; + tess.texCoords[ numVerts ][0][0] = cmd->s1; + tess.texCoords[ numVerts ][0][1] = cmd->t1; - tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; - tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + tess.xyz[ numVerts + 1 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 1 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 1 ][2] = 0; - tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; - tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; - tess.xyz[ numVerts + 3 ][2] = 0; + tess.texCoords[ numVerts + 1 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 1 ][0][1] = cmd->t1; + + tess.xyz[ numVerts + 2 ][0] = m[0][0] * (cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 2 ][1] = m[0][1] * (cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 2 ][2] = 0; + + tess.texCoords[ numVerts + 2 ][0][0] = cmd->s2; + tess.texCoords[ numVerts + 2 ][0][1] = cmd->t2; + + tess.xyz[ numVerts + 3 ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (cmd->h * 0.5f) + m[2][0]; + tess.xyz[ numVerts + 3 ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (cmd->h * 0.5f) + m[2][1]; + tess.xyz[ numVerts + 3 ][2] = 0; + + tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; + tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; + + return (const void *)(cmd + 1); - tess.texCoords[ numVerts + 3 ][0][0] = cmd->s1; - tess.texCoords[ numVerts + 3 ][0][1] = cmd->t2; #if 0 - // Hmmm, this is not too cool - GL_State( GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + // Hmmm, this is not too cool + GL_State( GLS_DEPTHTEST_DISABLE | + GLS_SRCBLEND_SRC_ALPHA | + GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); #endif + } + } return (const void *)(cmd + 1); } From 8fec706fa6eefbc84992e42c9c42fca23bf495f6 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 10 Jul 2015 14:57:41 -0500 Subject: [PATCH 263/708] Rend2: Fixed incorrect merge issue from vanilla related to RB_StretchPic etc. --- codemp/rd-rend2/tr_backend.cpp | 45 ++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 4bd806f446..cbabbf28e3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -997,11 +997,16 @@ static const void *RB_StretchPic ( const void *data ) { tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + { + vec4_t color; + + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); + } tess.xyz[ numVerts ][0] = cmd->x; tess.xyz[ numVerts ][1] = cmd->y; @@ -1091,11 +1096,16 @@ static const void *RB_RotatePic ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + { + vec4_t color; + + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); + } tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; @@ -1185,11 +1195,16 @@ static const void *RB_RotatePic2 ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - byteAlias_t *baDest = NULL, *baSource = (byteAlias_t *)&backEnd.color2D; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 0]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 1]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 2]; baDest->ui = baSource->ui; - baDest = (byteAlias_t *)&tess.vertexColors[numVerts + 3]; baDest->ui = baSource->ui; + { + vec4_t color; + + VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); + + VectorCopy4(color, tess.vertexColors[ numVerts ]); + VectorCopy4(color, tess.vertexColors[ numVerts + 1]); + VectorCopy4(color, tess.vertexColors[ numVerts + 2]); + VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); + } tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; From bb65c0824d05036ef14aeb09a90c9e4c10d0d211 Mon Sep 17 00:00:00 2001 From: Ensiform Date: Fri, 10 Jul 2015 15:22:30 -0500 Subject: [PATCH 264/708] Rend2: Fixed screenshot cmd also pointing to tga output. --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 614ea73c90..3ff89e9396 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1598,7 +1598,7 @@ static consoleCommand_t commands[] = { { "shaderlist", R_ShaderList_f }, { "skinlist", R_SkinList_f }, { "fontlist", R_FontList_f }, - { "screenshot", R_ScreenShotTGA_f }, + { "screenshot", R_ScreenShotJPEG_f }, { "screenshot_png", R_ScreenShotPNG_f }, { "screenshot_tga", R_ScreenShotTGA_f }, { "gfxinfo", GfxInfo_f }, From 58b6b41383735fb69d9d75874385f7e9374ea8fa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 18 Jul 2015 13:37:34 +0100 Subject: [PATCH 265/708] Rend2: Don't use app-generated names for textures --- codemp/rd-rend2/tr_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 1534a76523..7f96f37e5e 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2270,7 +2270,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT } image = tr.images[tr.numImages] = (image_t *)ri->Hunk_Alloc( sizeof( image_t ), h_low ); - image->texnum = 1024 + tr.numImages; + qglGenTextures(1, &image->texnum); tr.numImages++; image->type = type; From d2b392dd8a167212a8691aa87858e0e0ff700460 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 18 Jul 2015 16:00:51 +0100 Subject: [PATCH 266/708] Rend2: Fix stretched triangles in G2 rendering Due to the way bone weights are stored in the .glm file, some precision is lost when expanding them back out to full floats. As a result, the sum of all the weights will not always up to 1.0. To rectify this, the influence of the last bone is now calculated as whatever is remaining after the other weightings have been subtracted from 1.0. This commit also fixes a minor issue with a one-off issue with the max index passed to glDrawRangeElements. This makes no difference to the rendering and is more for correctness. --- codemp/rd-rend2/tr_ghoul2.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 17e55e1448..84c50b6218 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4196,12 +4196,21 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean for ( int k = 0; k < surf->numVerts; k++ ) { int numWeights = G2_GetVertWeights (&v[k]); - for ( int w = 0; w < numWeights; w++ ) + float lastWeight = 1.0f; + int lastInfluence = numWeights - 1; + for ( int w = 0; w < lastInfluence; w++ ) { - (*weights)[w] = G2_GetVertBoneWeightNotSlow (&v[k], w); + float weight = G2_GetVertBoneWeightNotSlow (&v[k], w); + (*weights)[w] = weight; (*bonerefs)[w] = (float)G2_GetVertBoneIndex (&v[k], w); + + lastWeight -= weight; } + // Ensure that all the weights add up to 1.0 + (*weights)[lastInfluence] = lastWeight; + (*bonerefs)[lastInfluence] = (float)G2_GetVertBoneIndex (&v[k], lastInfluence); + // Fill in the rest of the info with zeroes. for ( int w = numWeights; w < 4; w++ ) { @@ -4369,7 +4378,7 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vboMeshes[n].indexOffset = indexOffsets[n]; vboMeshes[n].minIndex = baseVertexes[n]; - vboMeshes[n].maxIndex = baseVertexes[n + 1]; + vboMeshes[n].maxIndex = baseVertexes[n + 1] - 1; vboMeshes[n].numVertexes = surf->numVerts; vboMeshes[n].numIndexes = surf->numTriangles * 3; From e8dcfdfded9350f36c005afbc404e5bcae493199 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 19 Jul 2015 12:21:30 +0100 Subject: [PATCH 267/708] Rend2: Fix ordering of GLSL function declaration --- codemp/rd-rend2/glsl/lightall_fp.glsl | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 8552c4cd70..0c1f903bbf 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -136,6 +136,26 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) } #endif +float CalcFresnel(float EH) +{ +#if 1 + // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + // not accurate, but fast + return exp2(-10.0 * EH); +#elif 0 + // From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ + return exp2((-5.55473 * EH - 6.98316) * EH); +#elif 0 + float blend = 1.0 - EH; + float blend2 = blend * blend; + blend *= blend2 * blend2; + + return blend; +#else + return pow(1.0 - EH, 5.0); +#endif +} + vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) { #if 1 @@ -162,26 +182,6 @@ float CalcGGX(float NH, float gloss) return a_sq / (d * d); } -float CalcFresnel(float EH) -{ -#if 1 - // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - // not accurate, but fast - return exp2(-10.0 * EH); -#elif 0 - // From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ - return exp2((-5.55473 * EH - 6.98316) * EH); -#elif 0 - float blend = 1.0 - EH; - float blend2 = blend * blend; - blend *= blend2 * blend2; - - return blend; -#else - return pow(1.0 - EH, 5.0); -#endif -} - float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) { float roughness = exp2(gloss * -6.5); From c2f5df609b703cb8dcf18b5b697b2cde37c2b213 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 19 Jul 2015 12:21:54 +0100 Subject: [PATCH 268/708] Rend2: Fix misc_cubemaps not rendering This fixes use of cubemaps for image based lighting --- codemp/rd-rend2/tr_fbo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index c63d6e2823..73003dc685 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -646,9 +646,9 @@ void FBO_Init(void) tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); FBO_Bind(tr.renderCubeFbo); - //FBO_AttachTextureImage(tr.renderCubeImage, 0); R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); glState.currentFBO->colorImage[0] = tr.renderCubeImage; + glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); From c56c1d350de013c1d6cab14f48d07a5cae0b1f6b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 19 Jul 2015 17:45:30 +0100 Subject: [PATCH 269/708] Rend2: Various tidying up with glClear --- codemp/rd-rend2/tr_backend.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 4d3b421544..3ef4600a82 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -474,8 +474,11 @@ void RB_BeginDrawingView (void) { // ensures that depth writes are enabled for the depth clear GL_State( GLS_DEFAULT ); + // clear relevant buffers - clearBits = GL_DEPTH_BUFFER_BIT; + clearBits = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT; + + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); if ( r_measureOverdraw->integer || r_shadows->integer == 2 ) { @@ -484,7 +487,6 @@ void RB_BeginDrawingView (void) { if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) { - clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used #ifdef _DEBUG qglClearColor( 0.8f, 0.7f, 0.4f, 1.0f ); // FIXME: get color of sky #else @@ -495,14 +497,12 @@ void RB_BeginDrawingView (void) { // clear to white for shadow maps if (backEnd.viewParms.flags & VPF_SHADOWMAP) { - clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } // clear to black for cube maps if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { - clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); } @@ -1300,6 +1300,9 @@ static const void *RB_DrawSurfs( const void *data ) { qglViewport(box[0], box[1], box[2], box[3]); qglScissor(box[0], box[1], box[2], box[3]); + GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + qglClearBufferfv(GL_COLOR, 0, black); + box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; @@ -1473,8 +1476,8 @@ static const void *RB_DrawSurfs( const void *data ) { FBO_t *oldFbo = glState.currentFBO; FBO_Bind(tr.sunRaysFbo); - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - qglClear( GL_COLOR_BUFFER_BIT ); + GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + qglClearBufferfv( GL_COLOR, 0, black ); tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); @@ -1487,7 +1490,7 @@ static const void *RB_DrawSurfs( const void *data ) { } // darken down any stencil shadows - RB_ShadowFinish(); + RB_ShadowFinish(); // add light flares on lights that aren't obscured RB_RenderFlares(); From e59814fba27090d2e13f05e440e649fbae7b4955 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 19 Jul 2015 19:58:02 +0100 Subject: [PATCH 270/708] Rend2: Don't scale the specular texture by default --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4a457b8852..83e33bd0fb 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1080,7 +1080,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if(!Q_stricmp(token, "specularMap")) { stage->type = ST_SPECULARMAP; - VectorSet4(stage->specularScale, r_baseSpecular->integer, r_baseSpecular->integer, r_baseSpecular->integer, 1.0f); + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); } else { From d094ec627d1d88f818ff9f59f81da2bb154e678b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 20 Jul 2015 19:44:25 +0100 Subject: [PATCH 271/708] Rend2: Clamp gloss and reflectance to 0-1. --- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 83e33bd0fb..c639cd4bad 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1101,7 +1101,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } stage->specularScale[0] = stage->specularScale[1] = - stage->specularScale[2] = atof( token ); + stage->specularScale[2] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); } // // specularExponent @@ -1135,7 +1135,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = atof( token ); + stage->specularScale[3] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); } // // parallaxDepth From c59e705013003dcd2f182cf5316a853a3729f176 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 23 Jul 2015 22:15:37 +0100 Subject: [PATCH 272/708] Rend2: Fix objects rendering as pure black This turned out to be a bug I introduced back in 8325f6c when I was fixing a lot of the initial rendering bugs. There was some issues with the depth range not being restored after they had been changed by the RenderDrawSurfLists function, which would affect subsequent renders. --- codemp/rd-rend2/tr_backend.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3ef4600a82..cf0504fc60 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -687,11 +687,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); } - if (!sunflare) - qglDepthRange (0, 1); + if( !sunflare ) + qglDepthRange( 0.0f, 1.0f ); - depth[0] = 0; - depth[1] = 1; break; case 1: @@ -704,12 +702,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix( temp.projectionMatrix ); } - if(!oldDepthRange) - { - depth[0] = 0; - depth[1] = 0.3f; - qglDepthRange (depth[0], depth[1]); - } + if ( !oldDepthRange ) + qglDepthRange( 0.0f, 0.3f ); + break; case 2: @@ -722,12 +717,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix( temp.projectionMatrix ); } - if(!oldDepthRange) - { - depth[0] = 0.0f; - depth[1] = 0.0f; - qglDepthRange (depth[0], depth[1]); - } + if ( !oldDepthRange ) + qglDepthRange( 0.0f, 0.0f ); + break; } @@ -758,7 +750,8 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); - //qglDepthRange (0, 1); + // Restore depth range for subsequent rendering + qglDepthRange( 0.0f, 1.0f ); } From 7289d015ca1cdb22c0660fcb6eb52c21271be23a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Jul 2015 13:04:29 +0100 Subject: [PATCH 273/708] Rend2: Fix sporadic black triangles on G2 models Forgot to shift tangent vector into [-0.5, 0.5] range after reading from vertex input! --- codemp/rd-rend2/glsl/lightall_vp.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index 6e49528f73..c93fcccfae 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -171,7 +171,7 @@ void main() vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) vec4 tangent4 = vec4(0.0); - vec4 originalTangent = vec4(attr_Tangent.xyz, 0.0); + vec4 originalTangent = vec4(attr_Tangent.xyz - vec3(0.5), 0.0); #endif for (int i = 0; i < 4; i++) From 9f5637b291c58b43ded2961e303819068ccabd3f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Jul 2015 17:44:26 +0100 Subject: [PATCH 274/708] Rend2: Use scissor for mirror views When a mirror view is being rendered, a scissor rectangle is now specified to prevent unneeded pixels from being drawn. --- codemp/rd-rend2/tr_backend.cpp | 24 +++++----- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_main.cpp | 84 +++++++++++++++++++++++++++++++--- 3 files changed, 91 insertions(+), 18 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index cf0504fc60..0d7e93f0a5 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -423,8 +423,18 @@ static void SetViewportAndScissor( void ) { // set the window clipping qglViewport( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); - qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, - backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); + + if ( !backEnd.viewParms.scissorX && !backEnd.viewParms.scissorY && + !backEnd.viewParms.scissorWidth && !backEnd.viewParms.scissorHeight ) + { + qglScissor( backEnd.viewParms.viewportX, backEnd.viewParms.viewportY, + backEnd.viewParms.viewportWidth, backEnd.viewParms.viewportHeight ); + } + else + { + qglScissor( backEnd.viewParms.scissorX, backEnd.viewParms.scissorY, + backEnd.viewParms.scissorWidth, backEnd.viewParms.scissorHeight ); + } } /* @@ -1517,16 +1527,6 @@ static const void *RB_DrawBuffer( const void *data ) { if(tess.numIndexes) RB_EndSurface(); - FBO_Bind(NULL); - - qglDrawBuffer( cmd->buffer ); - - // clear screen for debugging - if ( r_clear->integer ) { - qglClearColor( 1, 0, 0.5, 1 ); - qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - } - return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 44f1cb7224..24e3d14e9e 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1186,6 +1186,7 @@ typedef struct { int frameCount; // copied from tr.frameCount cplane_t portalPlane; // clip anything behind this if mirroring int viewportX, viewportY, viewportWidth, viewportHeight; + int scissorX, scissorY, scissorWidth, scissorHeight; FBO_t *targetFbo; int targetFboLayer; int targetFboCubemapIndex; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 16f60ce9e9..869e018ba6 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1210,7 +1210,7 @@ void R_PlaneForSurface (surfaceType_t *surfType, cplane_t *plane) { return; default: Com_Memset (plane, 0, sizeof(*plane)); - plane->normal[0] = 1; + plane->normal[0] = 1; return; } } @@ -1405,7 +1405,7 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) ** ** Determines if a surface is completely offscreen. */ -static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128] ) { +static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128], int *numVertices ) { float shortest = 100000000; int entityNum; int numTriangles; @@ -1424,7 +1424,14 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - assert( tess.numVertexes < 128 ); + if ( tess.numVertexes > 128 ) + { + // Don't bother trying, just assume it's off-screen and make it look bad. Besides, artists + // shouldn't be using this many vertices on a mirror surface anyway :) + return qtrue; + } + + *numVertices = tess.numVertexes; for ( i = 0; i < tess.numVertexes; i++ ) { @@ -1432,6 +1439,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 unsigned int pointFlags = 0; R_TransformModelToClip( tess.xyz[i], tr.ori.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); + VectorCopy4(clip, clipDest[i]); for ( j = 0; j < 3; j++ ) { @@ -1511,6 +1519,7 @@ Returns qtrue if another view has been rendered */ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { vec4_t clipDest[128]; + int numVertices; viewParms_t newParms; viewParms_t oldParms; orientation_t surface, camera; @@ -1526,7 +1535,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { } // trivially reject portal/mirror - if ( SurfIsOffscreen( drawSurf, clipDest ) ) { + if ( SurfIsOffscreen( drawSurf, clipDest, &numVertices ) ) { return qfalse; } @@ -1545,6 +1554,67 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { if (newParms.isMirror) newParms.flags |= VPF_NOVIEWMODEL; + // Calculate window coordinates of this surface to get tight fitting scissor rectangle + int minRectX = INT_MAX; + int minRectY = INT_MAX; + int maxRectX = 0; + int maxRectY = 0; + + int viewportWidth = oldParms.viewportWidth; + int viewportHeight = oldParms.viewportHeight; + float viewportCenterX = oldParms.viewportX + 0.5f * viewportWidth; + float viewportCenterY = oldParms.viewportY + 0.5f * viewportHeight; + + for ( int i = 0; i < numVertices; i++ ) + { + float ndcX; + float ndcY; + float wdcX; + float wdcY; + int floorX; + int floorY; + int ceilX; + int ceilY; + + if ( clipDest[i][0] <= -clipDest[i][3] ) + ndcX = -1.0f; + else if ( clipDest[i][0] >= clipDest[i][3] ) + ndcX = 1.0f; + else + ndcX = clipDest[i][0] / clipDest[i][3]; + + if ( clipDest[i][1] <= -clipDest[i][3] ) + ndcY = -1.0f; + else if ( clipDest[i][1] >= clipDest[i][3] ) + ndcY = 1.0f; + else + ndcY = clipDest[i][1] / clipDest[i][3]; + + wdcX = 0.5f * viewportWidth * ndcX + viewportCenterX; + wdcY = 0.5f * viewportHeight * ndcY + viewportCenterY; + + floorX = (int)wdcX; + floorY = (int)wdcY; + + ceilX = (int)(wdcX + 0.5f); + ceilY = (int)(wdcY + 0.5f); + + minRectX = Q_min(minRectX, floorX); + minRectY = Q_min(minRectY, floorY); + maxRectX = Q_max(maxRectX, ceilX); + maxRectY = Q_max(maxRectY, ceilY); + } + + minRectX = Q_max(minRectX, 0); + minRectY = Q_max(minRectY, 0); + maxRectX = Q_min(maxRectX, oldParms.viewportX + viewportWidth); + maxRectY = Q_min(maxRectY, oldParms.viewportY + viewportHeight); + + newParms.scissorX = minRectX; + newParms.scissorY = minRectY; + newParms.scissorWidth = maxRectX - minRectX; + newParms.scissorHeight = maxRectY - minRectY; + R_MirrorPoint (oldParms.ori.origin, &surface, &camera, newParms.ori.origin ); VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); @@ -1554,7 +1624,9 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { R_MirrorVector (oldParms.ori.axis[1], &surface, &camera, newParms.ori.axis[1]); R_MirrorVector (oldParms.ori.axis[2], &surface, &camera, newParms.ori.axis[2]); - // OPTIMIZE: restrict the viewport on the mirrored view + // OPTIMIZE further: restrict the viewport and set up the view and projection + // matrices so they only draw into the tightest screen-space aligned box required + // to fill the restricted viewport. // render the mirror view R_RenderView (&newParms); @@ -2433,7 +2505,7 @@ static float CalcSplit(float n, float f, float i, float m) void R_RenderSunShadowMaps(const refdef_t *fd, int level) { - viewParms_t shadowParms; + viewParms_t shadowParms; vec4_t lightDir, lightCol; vec3_t lightViewAxis[3]; vec3_t lightOrigin; From 6b76f8fb179b135ab5260997bcf0a480460bff25 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Jul 2015 17:46:08 +0100 Subject: [PATCH 275/708] Revert "Rend2: Various tidying up with glClear" This reverts commit c56c1d350de013c1d6cab14f48d07a5cae0b1f6b. The commit causes problems with mirrors because the mirror view is drawn before the main render. However, if the screen is cleared to black, then the results of the mirror view are lost. This can be improved by rendering the mirror view to an FBO instead. --- codemp/rd-rend2/tr_backend.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 0d7e93f0a5..bd689bbb50 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -484,11 +484,8 @@ void RB_BeginDrawingView (void) { // ensures that depth writes are enabled for the depth clear GL_State( GLS_DEFAULT ); - // clear relevant buffers - clearBits = GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT; - - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + clearBits = GL_DEPTH_BUFFER_BIT; if ( r_measureOverdraw->integer || r_shadows->integer == 2 ) { @@ -497,6 +494,7 @@ void RB_BeginDrawingView (void) { if ( r_fastsky->integer && !( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) ) { + clearBits |= GL_COLOR_BUFFER_BIT; // FIXME: only if sky shaders have been used #ifdef _DEBUG qglClearColor( 0.8f, 0.7f, 0.4f, 1.0f ); // FIXME: get color of sky #else @@ -507,12 +505,14 @@ void RB_BeginDrawingView (void) { // clear to white for shadow maps if (backEnd.viewParms.flags & VPF_SHADOWMAP) { + clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } // clear to black for cube maps if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { + clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); } @@ -1303,9 +1303,6 @@ static const void *RB_DrawSurfs( const void *data ) { qglViewport(box[0], box[1], box[2], box[3]); qglScissor(box[0], box[1], box[2], box[3]); - GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; - qglClearBufferfv(GL_COLOR, 0, black); - box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; @@ -1479,8 +1476,8 @@ static const void *RB_DrawSurfs( const void *data ) { FBO_t *oldFbo = glState.currentFBO; FBO_Bind(tr.sunRaysFbo); - GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; - qglClearBufferfv( GL_COLOR, 0, black ); + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClear( GL_COLOR_BUFFER_BIT ); tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); @@ -1493,7 +1490,7 @@ static const void *RB_DrawSurfs( const void *data ) { } // darken down any stencil shadows - RB_ShadowFinish(); + RB_ShadowFinish(); // add light flares on lights that aren't obscured RB_RenderFlares(); From 365c97fba45c24e1b2798f329f710fd45d4add79 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Jul 2015 21:30:49 +0100 Subject: [PATCH 276/708] Rend2: Split GLSL shader text into substrings Instead of a single continuous string for each GLSL shader, split it into substrings based on line. This avoids an internal string limit in MSVC which throws a compile-time error. Thanks to UniqueOne for this fix :) --- codemp/rd-rend2/glsl/compact.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index c6882c1c66..31fb212b0b 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -109,7 +109,7 @@ int main ( int argc, char *argv[] ) continue; } - output += escape_string (line) + "\\n\\\n"; + output += escape_string (line) + "\\n\"\n\""; } output += "\";\n\n"; } From cc7f290a27ed428e76b64f2418baafe926464567 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Jul 2015 21:36:01 +0100 Subject: [PATCH 277/708] Rend2: Remove debug text from the GLSL compactor Not sure how that got left in there unnoticed... --- codemp/rd-rend2/glsl/compact.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 31fb212b0b..9b615054b5 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -38,7 +38,6 @@ std::string& escape_string ( std::string& s ) char c = *it; if ( should_be_escaped (c) ) { - std::cout << "escaped something\n"; it = s.insert (it, '\\'); it += 2; } From e10d9c58d19fffb9bbfc45ff5526547852b26bae Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 26 Jul 2015 12:19:44 +0100 Subject: [PATCH 278/708] Rend2: Fix size of bone matrix array in CPU buffer Changed size of the bone matrices array for GLSL shaders on the CPU side to match the uniform in the GLSL shaders. --- codemp/rd-rend2/tr_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 03590d07f8..1cab1c5e74 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -149,7 +149,7 @@ static uniformInfo_t uniformsInfo[] = { "u_CubeMapInfo", GLSL_VEC4, 1 }, - { "u_BoneMatrices", GLSL_MAT16, 80 }, + { "u_BoneMatrices", GLSL_MAT16, 20 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) From 25b28cb023ddfbe763ef4b7dcf15f967476e81cb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 1 Aug 2015 10:55:43 +0100 Subject: [PATCH 279/708] Rend2: Make images use pool allocator --- codemp/rd-rend2/tr_backend.cpp | 5 +- codemp/rd-rend2/tr_image.cpp | 140 +++++++++++++++++++++++++++------ 2 files changed, 120 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index bd689bbb50..711467558a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1551,9 +1551,8 @@ void RB_ShowImages( void ) { start = ri->Milliseconds(); - for ( i=0 ; ipoolNext ) { w = glConfig.vidWidth / 20; h = glConfig.vidHeight / 15; x = i % 20 * w; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 7f96f37e5e..fcc9d82b0e 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -29,8 +29,37 @@ static unsigned char s_gammatable[256]; int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; int gl_filter_max = GL_LINEAR; -#define FILE_HASH_SIZE 1024 -static image_t* hashTable[FILE_HASH_SIZE]; +#define FILE_HASH_SIZE 1553 // Prime numbers are a good size for hash tables :) +#define NUM_IMAGES_PER_POOL_ALLOC 512 + +static struct ImagesPool +{ + image_t *pPool; + ImagesPool *pNext; +} *imagesPool; + +static image_t *hashTable[FILE_HASH_SIZE]; + +/* +Extends the size of the images pool allocator +*/ +static void R_ExtendImagesPool() +{ + ImagesPool *pool = (ImagesPool *)Z_Malloc(sizeof(*pool), TAG_GENERAL); + image_t *freeImages = (image_t *)Z_Malloc(sizeof(*freeImages) * NUM_IMAGES_PER_POOL_ALLOC, TAG_IMAGE_T); + + for ( int i = 0; i < (NUM_IMAGES_PER_POOL_ALLOC - 1); i++ ) + { + freeImages[i].poolNext = &freeImages[i + 1]; + } + freeImages[NUM_IMAGES_PER_POOL_ALLOC - 1].poolNext = tr.imagesFreeList; + + pool->pPool = freeImages; + pool->pNext = imagesPool; + imagesPool = pool; + + tr.imagesFreeList = freeImages; +} /* ** R_GammaCorrect @@ -76,8 +105,8 @@ static long generateHashValue( const char *fname ) { hash+=(long)(letter)*(i+119); i++; } - hash &= (FILE_HASH_SIZE-1); - return hash; + + return hash % FILE_HASH_SIZE; } /* @@ -110,8 +139,8 @@ void GL_TextureMode( const char *string ) { } // change all the existing mipmap texture objects - for ( i = 0 ; i < tr.numImages ; i++ ) { - glt = tr.images[ i ]; + glt = tr.images; + for ( i = 0 ; i < tr.numImages ; i++, glt = glt->poolNext ) { if ( glt->flags & IMGFLAG_MIPMAP ) { GL_Bind (glt); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); @@ -159,12 +188,12 @@ R_ImageList_f void R_ImageList_f( void ) { int i; int estTotalSize = 0; + image_t *image = tr.images; ri->Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); - for ( i = 0 ; i < tr.numImages ; i++ ) + for ( i = 0 ; i < tr.numImages ; i++, image = image->poolNext ) { - image_t *image = tr.images[i]; char *format = "???? "; char *sizeSuffix; int estSize; @@ -2244,6 +2273,58 @@ static void EmptyTexture( int width, int height, imgType_t type, int flags, GL_CheckErrors(); } +static image_t *R_AllocImage() +{ + image_t *result; + + if ( !tr.imagesFreeList ) + { + R_ExtendImagesPool(); + } + + // Remove from free list + result = tr.imagesFreeList; + tr.imagesFreeList = tr.imagesFreeList->poolNext; + + // Add to list of used images + result->poolNext = tr.images; + tr.images = result; + + tr.numImages++; + + return result; +} + +static void R_FreeImage( image_t *imageToFree ) +{ + if ( imageToFree ) + { + // Images aren't deleted individually very often. Not a + // problem to do this really... + if ( imageToFree == tr.images ) + { + tr.images = imageToFree->poolNext; + imageToFree->poolNext = tr.imagesFreeList; + tr.imagesFreeList = imageToFree; + } + else + { + image_t *image = tr.images; + while ( image ) + { + if ( image->poolNext == imageToFree ) + { + image->poolNext = imageToFree->poolNext; + imageToFree->poolNext = tr.imagesFreeList; + tr.imagesFreeList = imageToFree; + break; + } + + image = image->poolNext; + } + } + } +} /* ================ @@ -2265,13 +2346,8 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT isLightmap = qtrue; } - if ( tr.numImages == MAX_DRAWIMAGES ) { - ri->Error( ERR_DROP, "R_CreateImage: MAX_DRAWIMAGES hit"); - } - - image = tr.images[tr.numImages] = (image_t *)ri->Hunk_Alloc( sizeof( image_t ), h_low ); + image = R_AllocImage(); qglGenTextures(1, &image->texnum); - tr.numImages++; image->type = type; image->flags = flags; @@ -2294,7 +2370,6 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT } image->internalFormat = internalFormat; - // lightmaps are always allocated on TMU 1 if ( isLightmap ) { @@ -3027,13 +3102,24 @@ void R_SetColorMappings( void ) { } } +/* +Initialise the images pool allocator +*/ +void R_InitImagesPool() +{ + Com_Memset(hashTable, 0, sizeof(hashTable)); + + imagesPool = NULL; + tr.imagesFreeList = NULL; + R_ExtendImagesPool(); +} + /* =============== R_InitImages =============== */ -void R_InitImages( void ) { - Com_Memset(hashTable, 0, sizeof(hashTable)); +void R_InitImages( void ) { // build brightness translation tables R_SetColorMappings(); @@ -3047,15 +3133,25 @@ R_DeleteTextures =============== */ void R_DeleteTextures( void ) { - int i; - - for ( i=0; itexnum ); + image_t *image = tr.images; + while ( image ) + { + qglDeleteTextures(1, &image->texnum); + image = image->poolNext; } - Com_Memset( tr.images, 0, sizeof( tr.images ) ); tr.numImages = 0; + // Free pool and allocated images + while ( imagesPool ) + { + ImagesPool *pNext = imagesPool->pNext; + Z_Free(imagesPool->pPool); + Z_Free(imagesPool); + + imagesPool = pNext; + } + Com_Memset( glState.currenttextures, 0, sizeof( glState.currenttextures ) ); GL_SelectTexture( 1 ); qglBindTexture( GL_TEXTURE_2D, 0 ); From 438e0e26db1a84870beb8f0ae2fa18fc3d6bc246 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 1 Aug 2015 11:15:36 +0100 Subject: [PATCH 280/708] Rend2: Missing change from last commit --- codemp/rd-rend2/tr_local.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 24e3d14e9e..da5985cc09 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -354,7 +354,8 @@ typedef struct image_s { imgType_t type; int flags; - struct image_s* next; + struct image_s *next; + struct image_s *poolNext; } image_t; typedef struct dlight_s { @@ -2054,7 +2055,8 @@ typedef struct trGlobals_s { int numModels; int numImages; - image_t *images[MAX_DRAWIMAGES]; + image_t *images; + image_t *imagesFreeList; int numFBOs; FBO_t *fbos[MAX_FBOS]; @@ -2386,6 +2388,7 @@ void R_ScreenShotJPEG_f( void ); void R_InitFogTable( void ); float R_FogFactor( float s, float t ); +void R_InitImagesPool(); void R_InitImages( void ); void R_DeleteTextures( void ); int R_SumOfUsedImages( void ); From 0ce3c7568e25975a6ad7be299876cf57a9ccdd18 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 1 Aug 2015 11:17:00 +0100 Subject: [PATCH 281/708] Rend2: Last missing change from previous commit... --- codemp/rd-rend2/tr_init.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index abb8946b58..5f4c4cf0c1 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1630,6 +1630,8 @@ void R_Init( void ) { RE_SetLightStyle (i, -1); } + R_InitImagesPool(); + InitOpenGL(); R_InitImages(); From 9dab74cf32640e138119189b609f59cb7f6f67b4 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 1 Aug 2015 11:42:12 +0100 Subject: [PATCH 282/708] Rend2: Last missing piece of the puzzle --- codemp/rd-rend2/tr_image.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index fcc9d82b0e..9e4d88bdf9 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -169,11 +169,12 @@ R_SumOfUsedImages int R_SumOfUsedImages( void ) { int total; int i; + image_t *image = tr.images; total = 0; - for ( i = 0; i < tr.numImages; i++ ) { - if ( tr.images[i]->frameUsed == tr.frameCount ) { - total += tr.images[i]->uploadWidth * tr.images[i]->uploadHeight; + for ( i = 0; i < tr.numImages; i++, image = image->poolNext ) { + if ( image->frameUsed == tr.frameCount ) { + total += image->uploadWidth * image->uploadHeight; } } From 6055dead56ad12c4f3d04be040e426dcf2b0dbc5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 00:30:03 +0100 Subject: [PATCH 283/708] Rend2: Add support for GL_ARB_debug_output Setting r_debugContext 1, and then running vid_restart will cause the window system to create an OpenGL 'debug' context. This allows the renderer to give a callback function to the GL driver, which will be called any time an OpenGL error happens. Majorly useful for finding errors in the GL code without calling glGetError() everywhere. As it is a debug context, performance is degraded but this is not usually an issue when debugging. This commit also removes some unnecessary GL function pointers. --- codemp/rd-rend2/qgl.h | 6 +++ codemp/rd-rend2/tr_extensions.cpp | 71 +++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_init.cpp | 59 +++++-------------------- codemp/rd-rend2/tr_local.h | 4 ++ 4 files changed, 92 insertions(+), 48 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 62dbb5dbfe..9e590d87ba 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -584,3 +584,9 @@ extern PFNGLTEXSTORAGE3DPROC qglTexStorage3D; // GL_ARB_buffer_storage extern PFNGLBUFFERSTORAGEPROC qglBufferStorage; + +// GL_ARB_debug_output +extern PFNGLDEBUGMESSAGECONTROLARBPROC qglDebugMessageControlARB; +extern PFNGLDEBUGMESSAGEINSERTARBPROC qglDebugMessageInsertARB; +extern PFNGLDEBUGMESSAGECALLBACKARBPROC qglDebugMessageCallbackARB; +extern PFNGLGETDEBUGMESSAGELOGARBPROC qglGetDebugMessageLogARB; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index e1d0f2574e..e7a220381f 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -209,6 +209,12 @@ PFNGLTEXSTORAGE3DPROC qglTexStorage3D; // GL_ARB_buffer_storage PFNGLBUFFERSTORAGEPROC qglBufferStorage; +// GL_ARB_debug_output +PFNGLDEBUGMESSAGECONTROLARBPROC qglDebugMessageControlARB; +PFNGLDEBUGMESSAGEINSERTARBPROC qglDebugMessageInsertARB; +PFNGLDEBUGMESSAGECALLBACKARBPROC qglDebugMessageCallbackARB; +PFNGLGETDEBUGMESSAGELOGARBPROC qglGetDebugMessageLogARB; + static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); @@ -235,6 +241,43 @@ static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionSt return qtrue; } +static void __stdcall GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenum severity, + GLsizei length, const GLchar *message, const void *userParam) +{ + const char *severityText = ""; + const char *typeText = ""; + const char *sourceText = ""; + + switch ( source ) + { + case GL_DEBUG_SOURCE_API_ARB: sourceText = "API"; break; + case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB: sourceText = "WS"; break; + case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB: sourceText = "SC"; break; + case GL_DEBUG_SOURCE_THIRD_PARTY_ARB: sourceText = "3rd"; break; + case GL_DEBUG_SOURCE_APPLICATION_ARB: sourceText = "App"; break; + case GL_DEBUG_SOURCE_OTHER_ARB: sourceText = "Oth"; break; + } + + switch ( severity ) + { + case GL_DEBUG_SEVERITY_HIGH_ARB: severityText = "High"; break; + case GL_DEBUG_SEVERITY_MEDIUM_ARB: severityText = "Medium"; break; + case GL_DEBUG_SEVERITY_LOW_ARB: severityText = "Low"; break; + } + + switch ( type ) + { + case GL_DEBUG_TYPE_ERROR_ARB: typeText = "Error"; break; + case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB: typeText = "Deprecated"; break; + case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB: typeText = "Undefined"; break; + case GL_DEBUG_TYPE_PORTABILITY_ARB: typeText = "Portability"; break; + case GL_DEBUG_TYPE_PERFORMANCE_ARB: typeText = "Performance"; break; + case GL_DEBUG_TYPE_OTHER_ARB: typeText = "Other"; break; + } + + Com_Printf( S_COLOR_YELLOW "OpenGL -> [%s][%s][%s] %s\n", sourceText, severityText, typeText, message ); +} + void GLW_InitTextureCompression( void ); void GLimp_InitExtensions() { @@ -550,6 +593,34 @@ void GLimp_InitExtensions() ri->Printf(PRINT_ALL, result[2], extension); } + // GL_ARB_debug_output + extension = "GL_ARB_debug_output"; + if ( GLimp_HaveExtension( extension ) ) + { + qboolean loaded = qtrue; + + if ( r_debugContext->integer ) + { + loaded = (qboolean)(loaded && GetGLFunction (qglDebugMessageControlARB, "glDebugMessageControlARB", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction (qglDebugMessageInsertARB, "glDebugMessageInsertARB", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction (qglDebugMessageCallbackARB, "glDebugMessageCallbackARB", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction (qglGetDebugMessageLogARB, "glGetDebugMessageLogARB", qfalse)); + } + else + { + loaded = qfalse; + } + + glRefConfig.debugContext = loaded; + ri->Printf(PRINT_ALL, result[loaded], extension); + } + // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(r_floatLightmap->integer && r_hdr->integer); + + if ( glRefConfig.debugContext ) + { + qglEnable( GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB ); + qglDebugMessageCallbackARB(GLimp_OnError, NULL); + } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5f4c4cf0c1..c3d1301c15 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -253,47 +253,8 @@ cvar_t *r_dynamicGlowSoft; cvar_t *r_dynamicGlowWidth; cvar_t *r_dynamicGlowHeight; -PFNGLACTIVETEXTUREARBPROC qglActiveTextureARB; -PFNGLCLIENTACTIVETEXTUREARBPROC qglClientActiveTextureARB; -PFNGLMULTITEXCOORD2FARBPROC qglMultiTexCoord2fARB; - -PFNGLCOMBINERPARAMETERFVNVPROC qglCombinerParameterfvNV; -PFNGLCOMBINERPARAMETERIVNVPROC qglCombinerParameterivNV; -PFNGLCOMBINERPARAMETERFNVPROC qglCombinerParameterfNV; -PFNGLCOMBINERPARAMETERINVPROC qglCombinerParameteriNV; -PFNGLCOMBINERINPUTNVPROC qglCombinerInputNV; -PFNGLCOMBINEROUTPUTNVPROC qglCombinerOutputNV; - -PFNGLFINALCOMBINERINPUTNVPROC qglFinalCombinerInputNV; -PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC qglGetCombinerInputParameterfvNV; -PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC qglGetCombinerInputParameterivNV; -PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC qglGetCombinerOutputParameterfvNV; -PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC qglGetCombinerOutputParameterivNV; -PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC qglGetFinalCombinerInputParameterfvNV; -PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC qglGetFinalCombinerInputParameterivNV; - -PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB; -PFNGLBINDPROGRAMARBPROC qglBindProgramARB; -PFNGLDELETEPROGRAMSARBPROC qglDeleteProgramsARB; -PFNGLGENPROGRAMSARBPROC qglGenProgramsARB; -PFNGLPROGRAMENVPARAMETER4DARBPROC qglProgramEnvParameter4dARB; -PFNGLPROGRAMENVPARAMETER4DVARBPROC qglProgramEnvParameter4dvARB; -PFNGLPROGRAMENVPARAMETER4FARBPROC qglProgramEnvParameter4fARB; -PFNGLPROGRAMENVPARAMETER4FVARBPROC qglProgramEnvParameter4fvARB; -PFNGLPROGRAMLOCALPARAMETER4DARBPROC qglProgramLocalParameter4dARB; -PFNGLPROGRAMLOCALPARAMETER4DVARBPROC qglProgramLocalParameter4dvARB; -PFNGLPROGRAMLOCALPARAMETER4FARBPROC qglProgramLocalParameter4fARB; -PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB; -PFNGLGETPROGRAMENVPARAMETERDVARBPROC qglGetProgramEnvParameterdvARB; -PFNGLGETPROGRAMENVPARAMETERFVARBPROC qglGetProgramEnvParameterfvARB; -PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC qglGetProgramLocalParameterdvARB; -PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC qglGetProgramLocalParameterfvARB; -PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB; -PFNGLGETPROGRAMSTRINGARBPROC qglGetProgramStringARB; -PFNGLISPROGRAMARBPROC qglIsProgramARB; - -PFNGLLOCKARRAYSEXTPROC qglLockArraysEXT; -PFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT; +cvar_t *r_debugContext; + extern void RB_SetGL2D (void); void R_Splash() { @@ -520,6 +481,8 @@ static void InitOpenGL( void ) windowDesc.api = GRAPHICS_API_OPENGL; windowDesc.gl.majorVersion = 3; windowDesc.gl.minorVersion = 2; + if ( r_debugContext->integer ) + windowDesc.gl.contextFlags = GLCONTEXT_DEBUG; window = ri->WIN_Init(&windowDesc, &glConfig); @@ -1106,13 +1069,11 @@ void GL_SetDefaultState( void ) // initialize downstream texture unit if we're running // in a multitexture environment - if ( qglActiveTextureARB ) { - GL_SelectTexture( 1 ); - GL_TextureMode( r_textureMode->string ); - GL_TexEnv( GL_MODULATE ); - qglDisable( GL_TEXTURE_2D ); - GL_SelectTexture( 0 ); - } + GL_SelectTexture( 1 ); + GL_TextureMode( r_textureMode->string ); + GL_TexEnv( GL_MODULATE ); + qglDisable( GL_TEXTURE_2D ); + GL_SelectTexture( 0 ); qglEnable(GL_TEXTURE_2D); GL_TextureMode( r_textureMode->string ); @@ -1356,6 +1317,8 @@ void R_Register( void ) r_dynamicGlowWidth = ri->Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH ); r_dynamicGlowHeight = ri->Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH ); + r_debugContext = ri->Cvar_Get( "r_debugContext", "0", CVAR_LATCH ); + r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index da5985cc09..3670a5f851 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1837,6 +1837,8 @@ typedef struct { qboolean immutableTextures; qboolean immutableBuffers; + qboolean debugContext; + qboolean floatLightmap; } glRefConfig_t; @@ -2285,6 +2287,8 @@ extern cvar_t *r_dynamicGlowSoft; extern cvar_t *r_dynamicGlowWidth; extern cvar_t *r_dynamicGlowHeight; +extern cvar_t *r_debugContext; + //==================================================================== void R_SwapBuffers( int ); From e80fa28884b13608685f790643ff7bc6eb2a1d8d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 00:34:28 +0100 Subject: [PATCH 284/708] Rend2: Make r_clear actually do something. This is useful for debugging purposes. Set to 1 to clear the active framebuffer before every render. --- codemp/rd-rend2/tr_backend.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 711467558a..557b32209e 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -487,6 +487,11 @@ void RB_BeginDrawingView (void) { // clear relevant buffers clearBits = GL_DEPTH_BUFFER_BIT; + if ( r_clear->integer ) + { + clearBits |= GL_COLOR_BUFFER_BIT; + } + if ( r_measureOverdraw->integer || r_shadows->integer == 2 ) { clearBits |= GL_STENCIL_BUFFER_BIT; From 6469fa33d74b9595d62b093d846f81337bb844fa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 00:35:27 +0100 Subject: [PATCH 285/708] Rend2: Fix texture filtering modes set on cubemaps It is invalid to set a texture's magnification filter to GL_LINEAR_MIPMAP_LINEAR. It should be set to GL_LINEAR. --- codemp/rd-rend2/tr_image.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 9e4d88bdf9..eef267842a 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2390,14 +2390,13 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT if (image->flags & IMGFLAG_MIPMAP) { - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); } else { - qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); } + qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); if (glRefConfig.immutableTextures && !(image->flags & IMGFLAG_MUTABLE)) { From a05b6761e13642df78d40e4cdea7cb739a2c50a1 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 01:02:30 +0100 Subject: [PATCH 286/708] Rend2: Fix multiple lightmaps...again Changes in 9a0f9895 didn't quite cover all the nuances of using multiple texture coordinates for multiple lightmaps. Now it does :) --- codemp/rd-rend2/tr_glsl.cpp | 109 ++++++++++++++++++--------------- codemp/rd-rend2/tr_local.h | 6 +- codemp/rd-rend2/tr_shade.cpp | 18 +++--- codemp/rd-rend2/tr_sky.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 4 +- codemp/rd-rend2/tr_vbo.cpp | 8 ++- 6 files changed, 83 insertions(+), 66 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 1cab1c5e74..0cf9b3ce0a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1760,52 +1760,80 @@ void GLSL_BindNullProgram(void) } -void GLSL_VertexAttribsState(uint32_t stateBits) +void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArraysOut) { - uint32_t diff; + VertexArraysProperties vertexArraysLocal; + VertexArraysProperties *vertexArrays = vertexArraysOut; - //Com_Printf("%d\n", stateBits); - GLSL_VertexAttribPointers(stateBits); - - diff = stateBits ^ glState.vertexAttribsState; - if (!diff) - return; + if ( !vertexArrays ) + { + vertexArrays = &vertexArraysLocal; + } - for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + if ( tess.useInternalVBO ) { - // FIXME: Use BitScanForward? - if (diff & j) + CalculateVertexArraysProperties(stateBits, vertexArrays); + for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { - if(stateBits & j) - qglEnableVertexAttribArray(i); - else - qglDisableVertexAttribArray(i); + int attributeIndex = vertexArrays->enabledAttributes[i]; + vertexArrays->offsets[attributeIndex] += tess.internalVBOCommitOffset; } + + // Slight hack to make tc0 and tc1 offset from the same position. + vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] = vertexArrays->offsets[ATTR_INDEX_TEXCOORD0]; + } + else + { + CalculateVertexArraysFromVBO(stateBits, glState.currentVBO, vertexArrays); } - glState.vertexAttribsState = stateBits; + GLSL_VertexAttribPointers(stateBits, vertexArrays); + + uint32_t diff = stateBits ^ glState.vertexAttribsState; + if ( diff ) + { + for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + { + // FIXME: Use BitScanForward? + if (diff & j) + { + if(stateBits & j) + qglEnableVertexAttribArray(i); + else + qglDisableVertexAttribArray(i); + } + } + + glState.vertexAttribsState = stateBits; + } } -void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ) +void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits, const VertexArraysProperties *vertexArrays ) { - VBO_t *vbo = glState.currentVBO; - if ( attribBits & ATTR_TEXCOORD0 ) { GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, vbo->strides[ATTR_INDEX_TEXCOORD0], BUFFER_OFFSET(vbo->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + qglVertexAttribPointer( + ATTR_INDEX_TEXCOORD0, + 2, GL_FLOAT, + 0, vertexArrays->strides[ATTR_INDEX_TEXCOORD0], + BUFFER_OFFSET(vertexArrays->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); } if ( attribBits & ATTR_TEXCOORD1 ) { GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, vbo->strides[ATTR_INDEX_TEXCOORD1], BUFFER_OFFSET(vbo->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + qglVertexAttribPointer( + ATTR_INDEX_TEXCOORD1, + 2, GL_FLOAT, + 0, vertexArrays->strides[ATTR_INDEX_TEXCOORD1], + BUFFER_OFFSET(vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); } } -void GLSL_VertexAttribPointers(uint32_t attribBits) +void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays) { VBO_t *vbo = glState.currentVBO; @@ -1821,21 +1849,6 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); } - VertexArraysProperties vertexArrays; - if ( tess.useInternalVBO ) - { - CalculateVertexArraysProperties(attribBits, &vertexArrays); - for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) - { - int attributeIndex = vertexArrays.enabledAttributes[i]; - vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; - } - } - else - { - CalculateVertexArraysFromVBO(attribBits, vbo, &vertexArrays); - } - const struct { int numComponents; @@ -1858,19 +1871,17 @@ void GLSL_VertexAttribPointers(uint32_t attribBits) { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, }; - for ( int i = 0, j = 1 ; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { - if ( attribBits & j ) - { - qglVertexAttribPointer(i, - attributes[i].numComponents, - attributes[i].type, - attributes[i].normalize, - vertexArrays.strides[i], - BUFFER_OFFSET(vertexArrays.offsets[i] + attributes[i].offset)); - - glState.vertexAttribPointersSet |= j; - } + int attributeIndex = vertexArrays->enabledAttributes[i]; + qglVertexAttribPointer(attributeIndex, + attributes[attributeIndex].numComponents, + attributes[attributeIndex].type, + attributes[attributeIndex].normalize, + vertexArrays->strides[attributeIndex], + BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + + glState.vertexAttribPointersSet |= (1 << attributeIndex); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3670a5f851..2da2ea0fe5 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2680,9 +2680,9 @@ GLSL int GLSL_BeginLoadGPUShaders(void); void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); -void GLSL_VertexAttribsState(uint32_t stateBits); -void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits ); -void GLSL_VertexAttribPointers(uint32_t attribBits); +void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArrays); +void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits, const VertexArraysProperties *vertexArrays ); +void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays); void GLSL_BindProgram(shaderProgram_t * program); void GLSL_BindNullProgram(void); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 356ac8831a..a752ad0d97 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -138,7 +138,7 @@ static void DrawTris (shaderCommands_t *input) { shaderProgram_t *sp = &tr.textureColorShader; vec4_t color; - GLSL_VertexAttribsState(ATTR_POSITION); + GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); @@ -1137,7 +1137,7 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -static void UpdateTexCoords ( const shaderStage_t *stage ) +static void UpdateTexCoords ( const shaderStage_t *stage, const VertexArraysProperties *vertexArrays ) { uint32_t updateAttribs = 0; if ( stage->bundle[0].image[0] != NULL ) @@ -1206,11 +1206,11 @@ static void UpdateTexCoords ( const shaderStage_t *stage ) if ( updateAttribs != 0 ) { - GLSL_UpdateTexCoordVertexAttribPointers (updateAttribs); + GLSL_UpdateTexCoordVertexAttribPointers( updateAttribs, vertexArrays ); } } -static void RB_IterateStagesGeneric( shaderCommands_t *input ) +static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int stage; @@ -1395,7 +1395,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input ) } } - UpdateTexCoords (pStage); + UpdateTexCoords (pStage, vertexArrays); GL_State( stateBits ); @@ -1768,14 +1768,16 @@ void RB_StageIteratorGeneric( void ) // // Set vertex attribs and pointers // - GLSL_VertexAttribsState(vertexAttribs); + + VertexArraysProperties vertexArrays; + GLSL_VertexAttribsState(vertexAttribs, &vertexArrays); // // render depth if in depthfill mode // if (backEnd.depthFill) { - RB_IterateStagesGeneric( input ); + RB_IterateStagesGeneric( input, &vertexArrays ); // // reset polygon offset @@ -1812,7 +1814,7 @@ void RB_StageIteratorGeneric( void ) // // call shader function // - RB_IterateStagesGeneric( input ); + RB_IterateStagesGeneric( input, &vertexArrays ); // // pshadows! diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 754711c011..d6f58d88ea 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -426,7 +426,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max { shaderProgram_t *sp = &tr.textureColorShader; - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); @@ -442,7 +442,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max shaderProgram_t *sp = &tr.lightallShader[0]; vec4_t vector; - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 1e935e0c97..e5cd5d0ed7 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -203,7 +203,7 @@ void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]) RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0); + GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); @@ -653,7 +653,7 @@ static void RB_SurfaceBeam( void ) // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function RB_UpdateVBOs(ATTR_POSITION); - GLSL_VertexAttribsState(ATTR_POSITION); + GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(sp); GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 0daf2b63d6..ee6dd9bcfd 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -442,7 +442,10 @@ void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); if (attributes & ATTR_TEXCOORD0) - AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0]); + AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][0]); + + if (attributes & ATTR_TEXCOORD1) + AddVertexArray(properties, ATTR_INDEX_TEXCOORD1, sizeof(tess.texCoords[0][1]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][1]); if (attributes & ATTR_NORMAL) AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); @@ -459,7 +462,8 @@ void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties else { AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); - AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0]); + AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][0]); + AddVertexArray(properties, ATTR_INDEX_TEXCOORD1, sizeof(tess.texCoords[0][1]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][1]); AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); AddVertexArray(properties, ATTR_INDEX_TANGENT, sizeof(tess.tangent[0]), 0, properties->vertexDataSize, tess.tangent); AddVertexArray(properties, ATTR_INDEX_COLOR, sizeof(tess.vertexColors[0]), 0, properties->vertexDataSize, tess.vertexColors); From 34b0cab31a9d1982f86206540494f9d89b745a36 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 10:30:28 +0100 Subject: [PATCH 287/708] Rend2: Decrement numImages when deleting an image --- codemp/rd-rend2/tr_image.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index eef267842a..21e8e765c4 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2307,6 +2307,8 @@ static void R_FreeImage( image_t *imageToFree ) tr.images = imageToFree->poolNext; imageToFree->poolNext = tr.imagesFreeList; tr.imagesFreeList = imageToFree; + + tr.numImages--; } else { @@ -2318,6 +2320,8 @@ static void R_FreeImage( image_t *imageToFree ) image->poolNext = imageToFree->poolNext; imageToFree->poolNext = tr.imagesFreeList; tr.imagesFreeList = imageToFree; + + tr.numImages--; break; } From 38714cc464d9e74652c47f0194c348e05b84cc8d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 11:42:41 +0100 Subject: [PATCH 288/708] Rend2: Fix sizes of shadowCubemaps textures. Also fix some GL errors associated with using them. --- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_image.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 557b32209e..375c173e25 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1743,7 +1743,7 @@ static const void *RB_CaptureShadowMap(const void *data) if (tr.shadowCubemaps[cmd->map] != NULL) { GL_Bind(tr.shadowCubemaps[cmd->map]); - qglCopyTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + qglCopyTexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE ); } } else @@ -1751,7 +1751,7 @@ static const void *RB_CaptureShadowMap(const void *data) if (tr.pshadowMaps[cmd->map] != NULL) { GL_Bind(tr.pshadowMaps[cmd->map]); - qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, 0); + qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE ); } } } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 21e8e765c4..b309563066 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2913,7 +2913,7 @@ void R_CreateBuiltinImages( void ) { { for( x = 0; x < MAX_DLIGHTS; x++) { - tr.shadowCubemaps[x] = R_CreateImage(va("*shadowcubemap%i", x), (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); + tr.shadowCubemaps[x] = R_CreateImage(va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); } } From 1c8514ed74f969fbcf7d2528177bbdcbeba04b10 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 12:01:04 +0100 Subject: [PATCH 289/708] Rend2: Renamed modelMatrix -> modelViewMatrix ..cause that's what it actually is. Also renamed transformMatrix -> modelMatrix. --- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_flares.cpp | 2 +- codemp/rd-rend2/tr_local.h | 4 ++-- codemp/rd-rend2/tr_main.cpp | 20 ++++++++++---------- codemp/rd-rend2/tr_postprocess.cpp | 4 ++-- codemp/rd-rend2/tr_shade.cpp | 12 ++++++------ codemp/rd-rend2/tr_shade_calc.cpp | 6 +++--- codemp/rd-rend2/tr_sky.cpp | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 375c173e25..f8564767aa 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -686,7 +686,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); } - GL_SetModelviewMatrix( backEnd.ori.modelMatrix ); + GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); // // change depthrange. Also change projection matrix so first person weapon does not look like coming @@ -763,7 +763,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // go back to the world modelview matrix - GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix ); + GL_SetModelviewMatrix( backEnd.viewParms.world.modelViewMatrix ); // Restore depth range for subsequent rendering qglDepthRange( 0.0f, 1.0f ); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 5f975e4bc7..b1184550e3 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -149,7 +149,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t // if the point is off the screen, don't bother adding it // calculate screen coordinates and depth - R_TransformModelToClip( point, backEnd.ori.modelMatrix, + R_TransformModelToClip( point, backEnd.ori.modelViewMatrix, backEnd.viewParms.projectionMatrix, eye, clip ); // check to see if the point is completely off screen diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2da2ea0fe5..bce0b2efe9 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -389,8 +389,8 @@ typedef struct { vec3_t origin; // in world coordinates vec3_t axis[3]; // orientation in world vec3_t viewOrigin; // viewParms->or.origin in local coordinates + float modelViewMatrix[16]; float modelMatrix[16]; - float transformMatrix[16]; } orientationr_t; typedef enum @@ -2827,7 +2827,7 @@ Ghoul2 Insert End ============================================================= ============================================================= */ -void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, +void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, const float *projectionMatrix, vec4_t eye, vec4_t dst ); void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 869e018ba6..6f01060b80 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -631,16 +631,16 @@ R_TransformModelToClip ========================== */ -void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix, +void R_TransformModelToClip( const vec3_t src, const float *modelViewMatrix, const float *projectionMatrix, vec4_t eye, vec4_t dst ) { int i; for ( i = 0 ; i < 4 ; i++ ) { eye[i] = - src[0] * modelMatrix[ i + 0 * 4 ] + - src[1] * modelMatrix[ i + 1 * 4 ] + - src[2] * modelMatrix[ i + 2 * 4 ] + - 1 * modelMatrix[ i + 3 * 4 ]; + src[0] * modelViewMatrix[ i + 0 * 4 ] + + src[1] * modelViewMatrix[ i + 1 * 4 ] + + src[2] * modelViewMatrix[ i + 2 * 4 ] + + 1 * modelViewMatrix[ i + 3 * 4 ]; } for ( i = 0 ; i < 4 ; i++ ) { @@ -738,8 +738,8 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, glMatrix[11] = 0; glMatrix[15] = 1; - Matrix16Copy(glMatrix, ori->transformMatrix); - myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, ori->modelMatrix ); + Matrix16Copy(glMatrix, ori->modelMatrix); + myGlMultMatrix( glMatrix, viewParms->world.modelViewMatrix, ori->modelViewMatrix ); // calculate the viewer origin in the model's space // needed for fog, specular, and environment mapping @@ -805,7 +805,7 @@ void R_RotateForViewer (void) // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) - myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelMatrix ); + myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelViewMatrix ); tr.viewParms.world = tr.ori; @@ -1438,7 +1438,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 int j; unsigned int pointFlags = 0; - R_TransformModelToClip( tess.xyz[i], tr.ori.modelMatrix, tr.viewParms.projectionMatrix, eye, clip ); + R_TransformModelToClip( tess.xyz[i], tr.ori.modelViewMatrix, tr.viewParms.projectionMatrix, eye, clip ); VectorCopy4(clip, clipDest[i]); for ( j = 0; j < 3; j++ ) @@ -2771,7 +2771,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); } - Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]); + Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelViewMatrix, tr.refdef.sunShadowMvp[level]); } } diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 1b54c181bd..6cbaf82f0b 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -324,7 +324,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) matrix_t trans, model, mvp; Matrix16Translation( backEnd.viewParms.ori.origin, trans ); - Matrix16Multiply( backEnd.viewParms.world.modelMatrix, trans, model ); + Matrix16Multiply( backEnd.viewParms.world.modelViewMatrix, trans, model ); Matrix16Multiply(backEnd.viewParms.projectionMatrix, model, mvp); dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) @@ -333,7 +333,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) } // project sun point - //Matrix16Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp); + //Matrix16Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelViewMatrix, mvp); Matrix16Transform(mvp, pos, hpos); // transform to UV coords diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index a752ad0d97..a8d1963cf9 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -721,9 +721,9 @@ static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, fl fog = tr.world->fogs + tess.fogNum; VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local ); - fogDistanceVector[0] = -backEnd.ori.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.ori.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.ori.modelMatrix[10]; + fogDistanceVector[0] = -backEnd.ori.modelViewMatrix[2]; + fogDistanceVector[1] = -backEnd.ori.modelViewMatrix[6]; + fogDistanceVector[2] = -backEnd.ori.modelViewMatrix[10]; fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] ); // scale the fog vectors based on the fog's thickness @@ -894,7 +894,7 @@ static void ForwardDlight( void ) { // where they aren't rendered GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); if (pStage->bundle[TB_DIFFUSEMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); @@ -1473,7 +1473,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); } - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); @@ -1661,7 +1661,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.transformMatrix); + GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 6b9025d186..309fe7057d 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -693,9 +693,9 @@ void RB_CalcFogTexCoords( float *st ) { // all fogging distance is based on world Z units VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local ); - fogDistanceVector[0] = -backEnd.ori.modelMatrix[2]; - fogDistanceVector[1] = -backEnd.ori.modelMatrix[6]; - fogDistanceVector[2] = -backEnd.ori.modelMatrix[10]; + fogDistanceVector[0] = -backEnd.ori.modelViewMatrix[2]; + fogDistanceVector[1] = -backEnd.ori.modelViewMatrix[6]; + fogDistanceVector[2] = -backEnd.ori.modelViewMatrix[10]; fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] ); // scale the fog vectors based on the fog's thickness diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index d6f58d88ea..9587ab231a 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -805,14 +805,14 @@ void RB_DrawSun( float scale, shader_t *shader ) { return; } - //qglLoadMatrixf( backEnd.viewParms.world.modelMatrix ); + //qglLoadMatrixf( backEnd.viewParms.world.modelViewMatrix ); //qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]); { // FIXME: this could be a lot cleaner matrix_t translation, modelview; Matrix16Translation( backEnd.viewParms.ori.origin, translation ); - Matrix16Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview ); + Matrix16Multiply( backEnd.viewParms.world.modelViewMatrix, translation, modelview ); GL_SetModelviewMatrix( modelview ); } From aadc750ee05ce5543109ceae22a32e5e4e49e61d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 12:03:11 +0100 Subject: [PATCH 290/708] Rend2: R_SortDrawSurfs -> R_SortAndSubmitDrawSurfs --- codemp/rd-rend2/tr_main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 6f01060b80..a040e68b5c 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1791,10 +1791,10 @@ void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, /* ================= -R_SortDrawSurfs +R_SortAndSubmitDrawSurfs ================= */ -void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { +void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { shader_t *shader; int fogNum; int entityNum; @@ -2084,7 +2084,7 @@ void R_RenderView (viewParms_t *parms) { R_GenerateDrawSurfs(); - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); // draw main system development information (surface outlines, etc) R_DebugGraphics(); @@ -2492,7 +2492,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) R_AddEntitySurface(shadow->entityNums[j]); } - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); } } } @@ -2768,7 +2768,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) R_AddEntitySurfaces (); - R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); } Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelViewMatrix, tr.refdef.sunShadowMvp[level]); From d265810ba8495aa80cdce6611f1ae008e5948e40 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 12:04:39 +0100 Subject: [PATCH 291/708] Rend2: Remove commented out code from FBO code --- codemp/rd-rend2/tr_fbo.cpp | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 73003dc685..64eeaa822e 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -355,30 +355,13 @@ void FBO_Bind(FBO_t * fbo) if (!fbo) { qglBindFramebuffer(GL_FRAMEBUFFER, 0); - //qglBindRenderbuffer(GL_RENDERBUFFER, 0); glState.currentFBO = NULL; - - return; } - - qglBindFramebuffer(GL_FRAMEBUFFER, fbo->frameBuffer); - - /* - if(fbo->colorBuffers[0]) - { - qglBindRenderbuffer(GL_RENDERBUFFER, fbo->colorBuffers[0]); - } - */ - - /* - if(fbo->depthBuffer) - { - qglBindRenderbuffer(GL_RENDERBUFFER, fbo->depthBuffer); - qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, fbo->depthBuffer); - } - */ - - glState.currentFBO = fbo; + else + { + qglBindFramebuffer(GL_FRAMEBUFFER, fbo->frameBuffer); + glState.currentFBO = fbo; + } } /* @@ -450,11 +433,9 @@ void FBO_Init(void) tr.msaaResolveFbo = FBO_Create("_msaaResolve", tr.renderDepthImage->width, tr.renderDepthImage->height); FBO_Bind(tr.msaaResolveFbo); - //FBO_CreateBuffer(tr.msaaResolveFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - //FBO_CreateBuffer(tr.msaaResolveFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); @@ -466,11 +447,9 @@ void FBO_Init(void) tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); FBO_Bind(tr.renderFbo); - //FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, 0); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - //FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); From 5069a7a4ea80b21487b42c30329b3335036cfdd6 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 12:05:54 +0100 Subject: [PATCH 292/708] Rend2: Improve /imagelist command The /imagelist command now displays more readable sizes for each image, and for the total amount used. It also recognises 24-bit depth texture formats as well. --- codemp/rd-rend2/tr_image.cpp | 60 +++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b309563066..2c153a0e03 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -181,6 +181,32 @@ int R_SumOfUsedImages( void ) { return total; } +static float GetReadableSize( int bytes, char **units ) +{ + float result = bytes; + *units = "b "; + + if (result >= 1024.0f) + { + result /= 1024.0f; + *units = "kb"; + } + + if (result >= 1024.0f) + { + result /= 1024.0f; + *units = "Mb"; + } + + if (result >= 1024.0f) + { + result /= 1024.0f; + *units = "Gb"; + } + + return result; +} + /* =============== R_ImageList_f @@ -189,6 +215,7 @@ R_ImageList_f void R_ImageList_f( void ) { int i; int estTotalSize = 0; + char *sizeSuffix; image_t *image = tr.images; ri->Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); @@ -196,9 +223,7 @@ void R_ImageList_f( void ) { for ( i = 0 ; i < tr.numImages ; i++, image = image->poolNext ) { char *format = "???? "; - char *sizeSuffix; int estSize; - int displaySize; estSize = image->uploadHeight * image->uploadWidth; @@ -289,39 +314,26 @@ void R_ImageList_f( void ) { // 2 byte per pixel? estSize *= 2; break; + + case GL_DEPTH_COMPONENT24: + format = "D24 "; + break; } // mipmap adds about 50% if (image->flags & IMGFLAG_MIPMAP) estSize += estSize / 2; - sizeSuffix = "b "; - displaySize = estSize; + float printSize = GetReadableSize(estSize, &sizeSuffix); - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "kb"; - } - - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "Mb"; - } - - if (displaySize > 1024) - { - displaySize /= 1024; - sizeSuffix = "Gb"; - } - - ri->Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName); + ri->Printf(PRINT_ALL, "%4i: %4ix%4i %s %7.2f%s %s\n", i, image->uploadWidth, image->uploadHeight, format, printSize, sizeSuffix, image->imgName); estTotalSize += estSize; } + float printSize = GetReadableSize(estTotalSize, &sizeSuffix); + ri->Printf (PRINT_ALL, " ---------\n"); - ri->Printf (PRINT_ALL, " approx %i bytes\n", estTotalSize); + ri->Printf (PRINT_ALL, " approx %i bytes (%.2f%s)\n", estTotalSize, printSize, sizeSuffix); ri->Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); } From 72170d690db8e671a37f78f9cfacd366c70342eb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 2 Aug 2015 13:27:52 +0100 Subject: [PATCH 293/708] Rend2: Enable tex compression for regular textures Prior to this commit, texture compression was not being used on artist-specific textures. Compression is now used, and massive memory savings can be seen in some maps (e.g. on Atlantica, 1.8GB -> 500MB). As part of this change, a workaround is put in place for AMD drivers which don't seem to implement immutable textures + BPTC compression properly. When loading a BPTC compressed texture, mutable textures are used instead. This needs double checking on other cards though.. --- codemp/rd-rend2/tr_extensions.cpp | 1 + codemp/rd-rend2/tr_image.cpp | 44 +++++++++++++++++++++++++++---- codemp/rd-rend2/tr_init.cpp | 18 +++++++++++++ codemp/rd-rend2/tr_local.h | 10 +++++++ 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index e7a220381f..514ce7a812 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -562,6 +562,7 @@ void GLimp_InitExtensions() loaded = (qboolean)(loaded && GetGLFunction (qglTexStorage2D, "glTexStorage2D", qfalse)); glRefConfig.immutableTextures = loaded; + ri->Printf(PRINT_ALL, result[loaded], extension); } else diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 2c153a0e03..81b9307698 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1975,6 +1975,40 @@ static int CalcNumMipmapLevels ( int width, int height ) return static_cast(ceil (log2 (Q_max (width, height))) + 1); } +static qboolean IsBPTCTextureFormat( GLenum internalformat ) +{ + switch ( internalformat ) + { + case GL_COMPRESSED_RGBA_BPTC_UNORM_ARB: + case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB: + case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB: + case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB: + return qtrue; + + default: + return qfalse; + } +} + +static qboolean ShouldUseImmutableTextures(int imageFlags, GLenum internalformat) +{ + if ( glRefConfig.hardwareVendor == IHV_AMD ) + { + // Corrupted texture data is seen when using BPTC + immutable textures + if ( IsBPTCTextureFormat( internalformat ) ) + { + return qfalse; + } + } + + if ( imageFlags & IMGFLAG_MUTABLE ) + { + return qfalse; + } + + return glRefConfig.immutableTextures; +} + static void RawImage_UploadTexture( byte *data, int x, int y, int width, int height, GLenum internalFormat, imgType_t type, int flags, qboolean subtexture ) { int dataFormat, dataType; @@ -2004,7 +2038,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } else { - if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) + if ( ShouldUseImmutableTextures( flags, internalFormat ) ) { int numLevels = (flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; @@ -2022,7 +2056,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } if ((flags & IMGFLAG_MIPMAP) && - (data != NULL || !glRefConfig.immutableTextures || (flags & IMGFLAG_MUTABLE))) + (data != NULL || !ShouldUseImmutableTextures(flags, internalFormat) )) { // Don't need to generate mipmaps if we are generating an immutable texture and // the data is NULL. All levels have already been allocated by glTexStorage2D. @@ -2073,7 +2107,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } else { - if ( glRefConfig.immutableTextures && !(flags & IMGFLAG_MUTABLE) ) + if ( ShouldUseImmutableTextures(flags, internalFormat) ) { qglTexSubImage2D (GL_TEXTURE_2D, miplevel, 0, 0, width, height, dataFormat, dataType, data ); } @@ -2414,7 +2448,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT } qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - if (glRefConfig.immutableTextures && !(image->flags & IMGFLAG_MUTABLE)) + if ( ShouldUseImmutableTextures( image->flags, internalFormat ) ) { int numLevels = (image->flags & IMGFLAG_MIPMAP) ? CalcNumMipmapLevels (width, height) : 1; @@ -2723,7 +2757,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) R_CreateNormalMap( name, pic, width, height, flags ); } - image = R_CreateImage( name, pic, width, height, type, flags, GL_RGBA8 ); + image = R_CreateImage( name, pic, width, height, type, flags, 0 ); Z_Free( pic ); return image; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c3d1301c15..bb84fa3f3b 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -500,6 +500,24 @@ static void InitOpenGL( void ) // OpenGL driver constants qglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.maxTextureSize ); + // Determine GPU IHV + if ( Q_stristr( glConfig.vendor_string, "ATI Technologies Inc." ) ) + { + glRefConfig.hardwareVendor = IHV_AMD; + } + else if ( Q_stristr( glConfig.vendor_string, "NVIDIA" ) ) + { + glRefConfig.hardwareVendor = IHV_NVIDIA; + } + else if ( Q_stristr( glConfig.vendor_string, "INTEL") ) + { + glRefConfig.hardwareVendor = IHV_INTEL; + } + else + { + glRefConfig.hardwareVendor = IHV_UNKNOWN; + } + // stubbed or broken drivers may have reported 0... glConfig.maxTextureSize = Q_max(0, glConfig.maxTextureSize); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bce0b2efe9..ceff69939d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1821,12 +1821,22 @@ typedef enum { TCR_BPTC = 0x0002, } textureCompressionRef_t; +typedef enum { + IHV_UNKNOWN, + + IHV_NVIDIA, + IHV_AMD, + IHV_INTEL +} gpuIhv_t; + // We can't change glConfig_t without breaking DLL/vms compatibility, so // store extensions we have here. typedef struct { int glslMajorVersion; int glslMinorVersion; + gpuIhv_t hardwareVendor; + memInfo_t memInfo; int maxRenderbufferSize; From 185086c33a89c9fc8908024d35a138914993f0ca Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Aug 2015 11:08:35 +0100 Subject: [PATCH 294/708] Rend2: Improved dynamic glow Based on algorithm described in "Next Generation Post Processing in Call of Duty: Advanced Warfare": http://advances.realtimerendering.com/s2014/index.html --- codemp/rd-rend2/glsl/dglow_downsample_fp.glsl | 29 ++++++++++++ codemp/rd-rend2/glsl/dglow_downsample_vp.glsl | 19 ++++++++ codemp/rd-rend2/glsl/dglow_upsample_fp.glsl | 25 +++++++++++ codemp/rd-rend2/glsl/dglow_upsample_vp.glsl | 19 ++++++++ codemp/rd-rend2/tr_backend.cpp | 27 +++-------- codemp/rd-rend2/tr_glsl.cpp | 44 ++++++++++++++++++ codemp/rd-rend2/tr_image.cpp | 13 ++++-- codemp/rd-rend2/tr_local.h | 7 ++- codemp/rd-rend2/tr_postprocess.cpp | 45 +++++++++++++++++++ codemp/rd-rend2/tr_postprocess.h | 6 ++- 10 files changed, 205 insertions(+), 29 deletions(-) create mode 100644 codemp/rd-rend2/glsl/dglow_downsample_fp.glsl create mode 100644 codemp/rd-rend2/glsl/dglow_downsample_vp.glsl create mode 100644 codemp/rd-rend2/glsl/dglow_upsample_fp.glsl create mode 100644 codemp/rd-rend2/glsl/dglow_upsample_vp.glsl diff --git a/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl new file mode 100644 index 0000000000..f474c3f962 --- /dev/null +++ b/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl @@ -0,0 +1,29 @@ +uniform sampler2D u_TextureMap; +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; + +in vec2 var_TexCoords; + +out vec4 out_Color; + +void main() +{ + // Based on "Next Generation Post Processing in Call of Duty: Advanced Warfare": + // http://advances.realtimerendering.com/s2014/index.html + vec4 color = vec4(0.0); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2(-2.0, -2.0))); + color += 0.5 * 0.25 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 0.0, -2.0))); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 2.0, -2.0))); + color += 0.25 * 0.5 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2(-1.0, -1.0))); + color += 0.25 * 0.5 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 1.0, -1.0))); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2(-2.0, 0.0))); + color += 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 0.0, 0.0))); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 2.0, -2.0))); + color += 0.25 * 0.5 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2(-1.0, 1.0))); + color += 0.25 * 0.5 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 1.0, 1.0))); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2(-2.0, 2.0))); + color += 0.5 * 0.25 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 0.0, 2.0))); + color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 2.0, 2.0))); + + out_Color = color * u_Color; +} \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl b/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl new file mode 100644 index 0000000000..3dc80a8bbe --- /dev/null +++ b/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl @@ -0,0 +1,19 @@ +out vec2 var_TexCoords; + +void main() +{ + const vec2 positions[] = vec2[3]( + vec2(-1.0f, -1.0f), + vec2(-1.0f, 3.0f), + vec2( 3.0f, -1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} diff --git a/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl new file mode 100644 index 0000000000..d33e9d88f4 --- /dev/null +++ b/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl @@ -0,0 +1,25 @@ +uniform sampler2D u_TextureMap; +uniform vec4 u_Color; +uniform vec2 u_InvTexRes; + +in vec2 var_TexCoords; + +out vec4 out_Color; + +void main() +{ + // Based on "Next Generation Post Processing in Call of Duty: Advanced Warfare": + // http://advances.realtimerendering.com/s2014/index.html + vec4 color = vec4(0.0); + color += 0.0625 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2(-1.0, -1.0)); + color += 0.125 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 0.0, -1.0)); + color += 0.0625 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 1.0, -1.0)); + color += 0.125 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2(-1.0, 0.0)); + color += 0.25 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 0.0, 0.0)); + color += 0.125 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 1.0, 0.0)); + color += 0.0625 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2(-1.0, 1.0)); + color += 0.125 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 0.0, 1.0)); + color += 0.0625 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 1.0, 1.0)); + + out_Color = color * u_Color; +} \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl b/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl new file mode 100644 index 0000000000..3dc80a8bbe --- /dev/null +++ b/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl @@ -0,0 +1,19 @@ +out vec2 var_TexCoords; + +void main() +{ + const vec2 positions[] = vec2[3]( + vec2(-1.0f, -1.0f), + vec2(-1.0f, 3.0f), + vec2( 3.0f, -1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f8564767aa..893ec0b985 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1824,29 +1824,12 @@ const void *RB_PostProcess(const void *data) if (r_dynamicGlow->integer) { - // Downscale 8x - FBO_BlitFromTexture (tr.glowImage, NULL, NULL, tr.glowFboScaled[0], NULL, &tr.textureColorShader, NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - FBO_FastBlit (tr.glowFboScaled[0], NULL, tr.glowFboScaled[1], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - FBO_FastBlit (tr.glowFboScaled[1], NULL, tr.glowFboScaled[2], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - // Blur a few times - float spread = 1.0f; - for ( int i = 0, numPasses = r_dynamicGlowPasses->integer; i < numPasses; i++ ) - { - RB_GaussianBlur (tr.glowFboScaled[2], tr.glowFboScaled[3], tr.glowFboScaled[2], spread); - - spread += r_dynamicGlowDelta->value * 0.25f; - } - - // Upscale 4x - qglScissor (0, 0, tr.glowFboScaled[1]->width, tr.glowFboScaled[1]->height); - FBO_FastBlit (tr.glowFboScaled[2], NULL, tr.glowFboScaled[1], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); - - qglScissor (0, 0, tr.glowFboScaled[0]->width, tr.glowFboScaled[0]->height); - FBO_FastBlit (tr.glowFboScaled[1], NULL, tr.glowFboScaled[0], NULL, GL_COLOR_BUFFER_BIT, GL_LINEAR); + RB_BloomDownscale(tr.glowImage, tr.glowFboScaled[0]); + for ( int i = 1; i < ARRAY_LEN(tr.glowFboScaled); i++ ) + RB_BloomDownscale(tr.glowFboScaled[i - 1], tr.glowFboScaled[i]); - // Restore scissor rect - qglScissor (0, 0, glConfig.vidWidth, glConfig.vidHeight); + for ( int i = ARRAY_LEN(tr.glowFboScaled) - 2; i >= 0; i-- ) + RB_BloomUpscale(tr.glowFboScaled[i + 1], tr.glowFboScaled[i], r_dynamicGlowIntensity->value); } srcBox[0] = backEnd.viewParms.viewportX; srcBox[1] = backEnd.viewParms.viewportY; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 0cf9b3ce0a..3d2e3a90be 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -54,6 +54,10 @@ extern const char *fallbackShader_tonemap_vp; extern const char *fallbackShader_tonemap_fp; extern const char *fallbackShader_gaussian_blur_vp; extern const char *fallbackShader_gaussian_blur_fp; +extern const char *fallbackShader_dglow_downsample_vp; +extern const char *fallbackShader_dglow_downsample_fp; +extern const char *fallbackShader_dglow_upsample_vp; +extern const char *fallbackShader_dglow_upsample_fp; typedef struct uniformInfo_s { @@ -1351,6 +1355,20 @@ int GLSL_BeginLoadGPUShaders(void) ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } + attribs = 0; + extradefines[0] = '\0'; + if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, qtrue, extradefines, fallbackShader_dglow_downsample_vp, fallbackShader_dglow_downsample_fp)) + { + ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); + } + + attribs = 0; + extradefines[0] = '\0'; + if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, extradefines, fallbackShader_dglow_upsample_vp, fallbackShader_dglow_upsample_fp)) + { + ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); + } + return startTime; } @@ -1652,6 +1670,32 @@ void GLSL_EndLoadGPUShaders ( int startTime ) numEtcShaders++; } + if (!GLSL_EndLoadGPUShader(&tr.dglowDownsample)) + { + ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); + } + + GLSL_InitUniforms(&tr.dglowDownsample); + +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.dglowDownsample); +#endif + + numEtcShaders++; + + if (!GLSL_EndLoadGPUShader(&tr.dglowUpsample)) + { + ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); + } + + GLSL_InitUniforms(&tr.dglowUpsample); + +#if defined(_DEBUG) + GLSL_FinishGPUShader(&tr.dglowUpsample); +#endif + + numEtcShaders++; + #if 0 attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 81b9307698..7443bb3b69 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2999,10 +2999,15 @@ void R_CreateBuiltinImages( void ) { tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); tr.glowImage = R_CreateImage("*glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[0] = R_CreateImage("*glowScaled0", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[1] = R_CreateImage("*glowScaled1", NULL, width / 4, height / 4, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[2] = R_CreateImage("*glowScaled2a", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImageScaled[3] = R_CreateImage("*glowScaled2b", NULL, width / 8, height / 8, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + + int glowImageWidth = width; + int glowImageHeight = height; + for ( int i = 0; i < ARRAY_LEN(tr.glowImageScaled); i++ ) + { + tr.glowImageScaled[i] = R_CreateImage(va("*glowScaled%d", i), NULL, glowImageWidth, glowImageHeight, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + glowImageWidth = Q_max(1, glowImageWidth >> 1); + glowImageHeight = Q_max(1, glowImageHeight >> 1); + } if (r_drawSunRays->integer) tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ceff69939d..8bc02a275b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -646,6 +646,7 @@ enum TB_LIGHTMAP = 1, TB_LEVELSMAP = 1, TB_SHADOWMAP3 = 1, + TB_COLORMAP2 = 1, TB_NORMALMAP = 2, TB_DELUXEMAP = 3, TB_SHADOWMAP2 = 3, @@ -1953,7 +1954,7 @@ typedef struct trGlobals_s { image_t *renderImage; image_t *glowImage; - image_t *glowImageScaled[4]; + image_t *glowImageScaled[6]; image_t *sunRaysImage; image_t *renderDepthImage; image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; @@ -1971,7 +1972,7 @@ typedef struct trGlobals_s { image_t *textureDepthImage; FBO_t *renderFbo; - FBO_t *glowFboScaled[4]; + FBO_t *glowFboScaled[6]; FBO_t *msaaResolveFbo; FBO_t *sunRaysFbo; FBO_t *depthFbo; @@ -2033,6 +2034,8 @@ typedef struct trGlobals_s { shaderProgram_t testcubeShader; shaderProgram_t gaussianBlurShader[2]; shaderProgram_t glowCompositeShader; + shaderProgram_t dglowDownsample; + shaderProgram_t dglowUpsample; // ----------------------------------------- diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 6cbaf82f0b..37ac9bebe1 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -484,3 +484,48 @@ void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *intermediateFbo, FBO_t *dstFbo, float // Blur Y FBO_Blit (intermediateFbo, NULL, scale, dstFbo, NULL, &tr.gaussianBlurShader[1], NULL, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); } + +void RB_BloomDownscale(image_t *sourceImage, FBO_t *destFBO) +{ + vec2_t invTexRes = { 1.0f / sourceImage->width, 1.0f / sourceImage->height }; + + FBO_Bind(destFBO); + GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + + qglClearBufferfv(GL_COLOR, 0, colorBlack); + qglViewport(0, 0, destFBO->width, destFBO->height); + + GLSL_BindProgram(&tr.dglowDownsample); + GLSL_SetUniformVec2(&tr.dglowDownsample, UNIFORM_INVTEXRES, invTexRes); + GLSL_SetUniformVec4(&tr.dglowDownsample, UNIFORM_COLOR, colorWhite); + GL_BindToTMU(sourceImage, 0); + + // Draw fullscreen triangle + qglDrawArrays(GL_TRIANGLES, 0, 3); +} + +void RB_BloomDownscale(FBO_t *sourceFBO, FBO_t *destFBO) +{ + RB_BloomDownscale(sourceFBO->colorImage[0], destFBO); +} + +void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO, float intensity) +{ + image_t *sourceImage = sourceFBO->colorImage[0]; + vec2_t invTexRes = { 1.0f / sourceImage->width, 1.0f / sourceImage->height }; + float color[] = { intensity, intensity, intensity, 1.0f }; + + FBO_Bind(destFBO); + GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + + qglClearBufferfv(GL_COLOR, 0, colorBlack); + glViewport(0, 0, destFBO->width, destFBO->height); + + GLSL_BindProgram(&tr.dglowUpsample); + GLSL_SetUniformVec2(&tr.dglowUpsample, UNIFORM_INVTEXRES, invTexRes); + GLSL_SetUniformVec4(&tr.dglowUpsample, UNIFORM_COLOR, color); + GL_BindToTMU(sourceImage, 0); + + // Draw fullscreen triangle + qglDrawArrays(GL_TRIANGLES, 0, 3); +} diff --git a/codemp/rd-rend2/tr_postprocess.h b/codemp/rd-rend2/tr_postprocess.h index 9a8cee5bac..500beea251 100644 --- a/codemp/rd-rend2/tr_postprocess.h +++ b/codemp/rd-rend2/tr_postprocess.h @@ -23,7 +23,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef TR_POSTPROCESS_H #define TR_POSTPROCESS_H -#include "tr_fbo.h" +typedef struct FBO_s FBO_t; +typedef struct image_s image_t; void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, int autoExposure); void RB_BokehBlur(FBO_t *src, vec4i_t srcBox, FBO_t *dst, vec4i_t dstBox, float blur); @@ -31,5 +32,8 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox); void RB_GaussianBlur(FBO_t *srcFbo, FBO_t *intermediateFbo, FBO_t *dstFbo, float spread); void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); +void RB_BloomDownscale(image_t *sourceImage, FBO_t *destFBO); +void RB_BloomDownscale(FBO_t *sourceFBO, FBO_t *destFBO); +void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO, float intensity); #endif From 714ab85c96d9aa8921fd026d027f0b18e0028d93 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Aug 2015 22:57:33 +0100 Subject: [PATCH 295/708] Rend2: Make use of r_dynamicGlowPasses --- codemp/rd-rend2/tr_backend.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 893ec0b985..568cd39584 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1825,10 +1825,11 @@ const void *RB_PostProcess(const void *data) if (r_dynamicGlow->integer) { RB_BloomDownscale(tr.glowImage, tr.glowFboScaled[0]); - for ( int i = 1; i < ARRAY_LEN(tr.glowFboScaled); i++ ) + int numPasses = Com_Clampi(1, ARRAY_LEN(tr.glowFboScaled), r_dynamicGlowPasses->integer); + for ( int i = 1; i < numPasses; i++ ) RB_BloomDownscale(tr.glowFboScaled[i - 1], tr.glowFboScaled[i]); - for ( int i = ARRAY_LEN(tr.glowFboScaled) - 2; i >= 0; i-- ) + for ( int i = numPasses - 2; i >= 0; i-- ) RB_BloomUpscale(tr.glowFboScaled[i + 1], tr.glowFboScaled[i], r_dynamicGlowIntensity->value); } srcBox[0] = backEnd.viewParms.viewportX; From 44654f8f09ccf0c7ba791a55a824fca8898b792b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 15 Aug 2015 23:11:54 +0100 Subject: [PATCH 296/708] Rend2: Don't use r_dynamicGlowIntensity It looks bad in some cases. This commit also tidies up the fragment shaders for downsampling and upsampling of glow textures. --- codemp/rd-rend2/glsl/dglow_downsample_fp.glsl | 5 ++--- codemp/rd-rend2/glsl/dglow_upsample_fp.glsl | 5 ++--- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_postprocess.cpp | 9 +++------ codemp/rd-rend2/tr_postprocess.h | 2 +- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl index f474c3f962..684bc21970 100644 --- a/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl +++ b/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl @@ -1,6 +1,5 @@ uniform sampler2D u_TextureMap; -uniform vec4 u_Color; -uniform vec2 u_InvTexRes; +uniform vec2 u_InvTexRes; in vec2 var_TexCoords; @@ -25,5 +24,5 @@ void main() color += 0.5 * 0.25 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 0.0, 2.0))); color += 0.25 * 0.125 * texture(u_TextureMap, var_TexCoords + (u_InvTexRes * vec2( 2.0, 2.0))); - out_Color = color * u_Color; + out_Color = color; } \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl index d33e9d88f4..1085dbe608 100644 --- a/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl +++ b/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl @@ -1,6 +1,5 @@ uniform sampler2D u_TextureMap; -uniform vec4 u_Color; -uniform vec2 u_InvTexRes; +uniform vec2 u_InvTexRes; in vec2 var_TexCoords; @@ -21,5 +20,5 @@ void main() color += 0.125 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 0.0, 1.0)); color += 0.0625 * texture(u_TextureMap, var_TexCoords + u_InvTexRes * vec2( 1.0, 1.0)); - out_Color = color * u_Color; + out_Color = color; } \ No newline at end of file diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 568cd39584..c6f05343eb 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1830,7 +1830,7 @@ const void *RB_PostProcess(const void *data) RB_BloomDownscale(tr.glowFboScaled[i - 1], tr.glowFboScaled[i]); for ( int i = numPasses - 2; i >= 0; i-- ) - RB_BloomUpscale(tr.glowFboScaled[i + 1], tr.glowFboScaled[i], r_dynamicGlowIntensity->value); + RB_BloomUpscale(tr.glowFboScaled[i + 1], tr.glowFboScaled[i]); } srcBox[0] = backEnd.viewParms.viewportX; srcBox[1] = backEnd.viewParms.viewportY; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 37ac9bebe1..76727b226a 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -492,12 +492,11 @@ void RB_BloomDownscale(image_t *sourceImage, FBO_t *destFBO) FBO_Bind(destFBO); GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - qglClearBufferfv(GL_COLOR, 0, colorBlack); qglViewport(0, 0, destFBO->width, destFBO->height); + qglClearBufferfv(GL_COLOR, 0, colorBlack); GLSL_BindProgram(&tr.dglowDownsample); GLSL_SetUniformVec2(&tr.dglowDownsample, UNIFORM_INVTEXRES, invTexRes); - GLSL_SetUniformVec4(&tr.dglowDownsample, UNIFORM_COLOR, colorWhite); GL_BindToTMU(sourceImage, 0); // Draw fullscreen triangle @@ -509,21 +508,19 @@ void RB_BloomDownscale(FBO_t *sourceFBO, FBO_t *destFBO) RB_BloomDownscale(sourceFBO->colorImage[0], destFBO); } -void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO, float intensity) +void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO) { image_t *sourceImage = sourceFBO->colorImage[0]; vec2_t invTexRes = { 1.0f / sourceImage->width, 1.0f / sourceImage->height }; - float color[] = { intensity, intensity, intensity, 1.0f }; FBO_Bind(destFBO); GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - qglClearBufferfv(GL_COLOR, 0, colorBlack); glViewport(0, 0, destFBO->width, destFBO->height); + qglClearBufferfv(GL_COLOR, 0, colorBlack); GLSL_BindProgram(&tr.dglowUpsample); GLSL_SetUniformVec2(&tr.dglowUpsample, UNIFORM_INVTEXRES, invTexRes); - GLSL_SetUniformVec4(&tr.dglowUpsample, UNIFORM_COLOR, color); GL_BindToTMU(sourceImage, 0); // Draw fullscreen triangle diff --git a/codemp/rd-rend2/tr_postprocess.h b/codemp/rd-rend2/tr_postprocess.h index 500beea251..0aba4b564a 100644 --- a/codemp/rd-rend2/tr_postprocess.h +++ b/codemp/rd-rend2/tr_postprocess.h @@ -34,6 +34,6 @@ void RB_HBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); void RB_VBlur(FBO_t *srcFbo, FBO_t *dstFbo, float strength); void RB_BloomDownscale(image_t *sourceImage, FBO_t *destFBO); void RB_BloomDownscale(FBO_t *sourceFBO, FBO_t *destFBO); -void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO, float intensity); +void RB_BloomUpscale(FBO_t *sourceFBO, FBO_t *destFBO); #endif From 91c9282088cf2be43a4cd930d3400d9e04192985 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Aug 2015 13:53:32 +0100 Subject: [PATCH 297/708] Rend2: Don't put everything into drawSurf_t::sort It doesn't make sense to sort on most of the data that used to be in the sort key. This may potentially make sorting slower but this is in preparation for bigger changes in the coming weeks. --- codemp/rd-rend2/tr_backend.cpp | 27 +++++++++--- codemp/rd-rend2/tr_local.h | 73 ++++++++++++------------------ codemp/rd-rend2/tr_main.cpp | 81 +++++++++++++++++++--------------- codemp/rd-rend2/tr_scene.cpp | 1 - codemp/rd-rend2/tr_shader.cpp | 6 +-- codemp/rd-rend2/tr_world.cpp | 1 - 6 files changed, 97 insertions(+), 92 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c6f05343eb..b4e8ee4817 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -613,7 +613,18 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.pc.c_surfaces += numDrawSurfs; for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - if ( drawSurf->sort == oldSort && drawSurf->cubemapIndex == oldCubemapIndex) { + R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); + entityNum = drawSurf->entityNum; + dlighted = drawSurf->lit; + cubemapIndex = drawSurf->cubemapIndex; + + if ( shader == oldShader && + fogNum == oldFogNum && + postRender == oldPostRender && + cubemapIndex == oldCubemapIndex && + entityNum == oldEntityNum && + dlighted == oldDlighted ) + { if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) continue; @@ -621,19 +632,25 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); continue; } + oldSort = drawSurf->sort; - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); - cubemapIndex = drawSurf->cubemapIndex; // // change the tess parameters if needed // a "entityMergable" shader is a shader that can have surfaces from seperate // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && ( shader != oldShader || fogNum != oldFogNum || dlighted != oldDlighted || postRender != oldPostRender || cubemapIndex != oldCubemapIndex - || ( entityNum != oldEntityNum && !shader->entityMergable ) ) ) { + if ( shader != NULL && + ( shader != oldShader || + fogNum != oldFogNum || + dlighted != oldDlighted || + postRender != oldPostRender || + cubemapIndex != oldCubemapIndex || + (entityNum != oldEntityNum && !shader->entityMergable))) + { if (oldShader != NULL) { RB_EndSurface(); } + RB_BeginSurface( shader, fogNum, cubemapIndex ); backEnd.pc.c_surfBatches++; oldShader = shader; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8bc02a275b..5413399315 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1233,10 +1233,32 @@ typedef enum { SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) } surfaceType_t; +/* +the drawsurf sort data is packed into a single 32 bit value so it can be +compared quickly during the qsorting process +*/ +#define QSORT_FOGNUM_SHIFT 0 +#define QSORT_FOGNUM_BITS 5 +#define QSORT_FOGNUM_MASK ((1 << QSORT_FOGNUM_BITS) - 1) + +#define QSORT_SHADERNUM_SHIFT (QSORT_FOGNUM_SHIFT + QSORT_FOGNUM_BITS) +#define QSORT_SHADERNUM_BITS SHADERNUM_BITS +#define QSORT_SHADERNUM_MASK ((1 << QSORT_SHADERNUM_BITS) - 1) + +#define QSORT_POSTRENDER_SHIFT (QSORT_SHADERNUM_SHIFT + QSORT_SHADERNUM_BITS) +#define QSORT_POSTRENDER_BITS 1 +#define QSORT_POSTRENDER_MASK ((1 << QSORT_POSTRENDER_BITS) - 1) + +#if QSORT_POSTRENDER_SHIFT >= 32 + #error "Sort field needs to be expanded" +#endif + typedef struct drawSurf_s { - unsigned int sort; // bit combination for fast compares - int cubemapIndex; - surfaceType_t *surface; // any of surface*_t + uint32_t sort; // bit combination for fast compares + int cubemapIndex; + int entityNum; + qboolean lit; + surfaceType_t *surface; // any of surface*_t } drawSurf_t; #define MAX_FACE_POINTS 64 @@ -1725,44 +1747,7 @@ void R_Modellist_f (void); #define MAX_DRAWSURFS 0x10000 #define DRAWSURF_MASK (MAX_DRAWSURFS-1) -/* - -the drawsurf sort data is packed into a single 32 bit value so it can be -compared quickly during the qsorting process - -the bits are allocated as follows: - -0 - 1 : dlightmap index -//2 : used to be clipped flag REMOVED - 03.21.00 rad -2 - 6 : fog index -11 - 20 : entity index -21 - 31 : sorted shader index - - TTimo - 1.32 -0-1 : dlightmap index -2-6 : fog index -7-16 : entity index -17-30 : sorted shader index - - SmileTheory - for pshadows -17-31 : sorted shader index -7-16 : entity index -2-6 : fog index -1 : pshadow flag -0 : dlight flag -*/ -#define QSORT_FOGNUM_SHIFT 1 -#define QSORT_REFENTITYNUM_SHIFT 6 -#define QSORT_SHADERNUM_SHIFT (QSORT_REFENTITYNUM_SHIFT+REFENTITYNUM_BITS) -#if (QSORT_SHADERNUM_SHIFT+SHADERNUM_BITS) > 32 - #error "Need to update sorting, too many bits." -#endif -#define QSORT_POSTRENDER_SHIFT (QSORT_SHADERNUM_SHIFT + SHADERNUM_BITS) -#if QSORT_POSTRENDER_SHIFT >= 32 - #error "Sort field needs to be expanded" -#endif - -extern int gl_filter_min, gl_filter_max; +extern int gl_filter_min, gl_filter_max; /* ** performanceCounters_t @@ -2011,7 +1996,6 @@ typedef struct trGlobals_s { trRefEntity_t *currentEntity; trRefEntity_t worldEntity; // point currentEntity at this when rendering world int currentEntityNum; - int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT model_t *currentModel; // @@ -2320,9 +2304,8 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e ); void R_AddPolygonSurfaces( void ); -void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *postRender ); - +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *fogNum, int *postRender ); +uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender); void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index a040e68b5c..24339cac71 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1411,7 +1411,6 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 int numTriangles; shader_t *shader; int fogNum; - int dlighted; int postRender; vec4_t clip, eye; int i; @@ -1420,7 +1419,9 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(); - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); + entityNum = drawSurf->entityNum; + RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); @@ -1742,15 +1743,38 @@ bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ) (refEntity->e.renderfx & RF_FORCE_ENT_ALPHA); } +/* +================= +R_DecomposeSort +================= +*/ +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *fogNum, int *postRender ) +{ + *fogNum = (sort >> QSORT_FOGNUM_SHIFT) & QSORT_FOGNUM_MASK; + *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & QSORT_SHADERNUM_MASK ]; + *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & QSORT_POSTRENDER_MASK; +} + +uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender) +{ + uint32_t key = 0; + + key |= (sortedShaderIndex & QSORT_SHADERNUM_MASK) << QSORT_SHADERNUM_SHIFT; + key |= (fogIndex & QSORT_FOGNUM_MASK) << QSORT_FOGNUM_SHIFT; + key |= (postRender & QSORT_POSTRENDER_MASK) << QSORT_POSTRENDER_SHIFT; + + return key; +} + /* ================= R_AddDrawSurf ================= */ -void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, - int fogIndex, int dlightMap, int postRender, - int cubemap) { - int index; +void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, + int dlightMap, int postRender, int cubemap) { + int index; + drawSurf_t *surf; if (tr.refdef.rdflags & RDF_NOFOG) { @@ -1765,28 +1789,15 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, // instead of checking for overflow, we just mask the index // so it wraps around index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; - // the sort data is packed into a single 32 bit value so it can be - // compared quickly during the qsorting process - tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT) - | tr.shiftedEntityNum | ( fogIndex << QSORT_FOGNUM_SHIFT ) - | ((int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; - tr.refdef.drawSurfs[index].cubemapIndex = cubemap; - tr.refdef.drawSurfs[index].surface = surface; - tr.refdef.numDrawSurfs++; -} + surf = tr.refdef.drawSurfs + index; -/* -================= -R_DecomposeSort -================= -*/ -void R_DecomposeSort( unsigned sort, int *entityNum, shader_t **shader, - int *fogNum, int *dlightMap, int *postRender ) { - *fogNum = ( sort >> QSORT_FOGNUM_SHIFT ) & 31; - *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1) ]; - *entityNum = ( sort >> QSORT_REFENTITYNUM_SHIFT ) & REFENTITYNUM_MASK; - *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & 1; - *dlightMap = sort & 1; + surf->sort = R_CreateSortKey(shader->sortedIndex, fogIndex, postRender); + surf->entityNum = tr.currentEntityNum; + surf->lit = (qboolean)dlightMap; + surf->cubemapIndex = cubemap; + surf->surface = surface; + + tr.refdef.numDrawSurfs++; } /* @@ -1795,11 +1806,6 @@ R_SortAndSubmitDrawSurfs ================= */ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader; - int fogNum; - int entityNum; - int dlighted; - int postRender; int i; //ri->Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); @@ -1831,7 +1837,13 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { // check for any pass through drawing, which // may cause another view to be rendered first for ( i = 0 ; i < numDrawSurfs ; i++ ) { - R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &fogNum, &dlighted, &postRender ); + int entityNum; + shader_t *shader; + int fogNum; + int postRender; + + R_DecomposeSort( (drawSurfs+i)->sort, &shader, &fogNum, &postRender ); + entityNum = drawSurfs[i].entityNum; if ( shader->sort > SS_PORTAL ) { break; @@ -1866,9 +1878,6 @@ static void R_AddEntitySurface (int entityNum) ent->needDlights = qfalse; - // preshift the value we are going to OR into the drawsurf sort - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; - // // the weapon model must be handled special -- // we don't want the hacked weapon position showing in diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 8a78dd5c7a..2bb38528f9 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -94,7 +94,6 @@ void R_AddPolygonSurfaces( void ) { int fogMask; tr.currentEntityNum = REFENTITYNUM_WORLD; - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0); for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c639cd4bad..5821e0cfa6 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3104,18 +3104,16 @@ static void FixRenderCommandList( int newShader ) { drawSurf_t *drawSurf; shader_t *shader; int fogNum; - int entityNum; - int dlightMap; int postRender; int sortedIndex; const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &fogNum, &dlightMap, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = (sortedIndex << QSORT_SHADERNUM_SHIFT) | (entityNum << QSORT_REFENTITYNUM_SHIFT) | ( fogNum << QSORT_FOGNUM_SHIFT ) | ( (int)postRender << QSORT_POSTRENDER_SHIFT) | (int)dlightMap; + drawSurf->sort = R_CreateSortKey(sortedIndex, fogNum, postRender); } } curCmd = (const void *)(ds_cmd + 1); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 669f37b997..7ecb3c8c66 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -781,7 +781,6 @@ void R_AddWorldSurfaces (void) { } tr.currentEntityNum = REFENTITYNUM_WORLD; - tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT; // determine which leaves are in the PVS / areamask if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) From 510459c9e7abe3d844d1e63148ea64dbca44eef9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Aug 2015 14:05:49 +0100 Subject: [PATCH 298/708] Rend2: Refactor R_SortAndSubmitDrawSurfs --- codemp/rd-rend2/tr_main.cpp | 84 +++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 24339cac71..b42ab9f970 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1806,61 +1806,53 @@ R_SortAndSubmitDrawSurfs ================= */ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { - int i; - - //ri->Printf(PRINT_ALL, "firstDrawSurf %d numDrawSurfs %d\n", (int)(drawSurfs - tr.refdef.drawSurfs), numDrawSurfs); - // it is possible for some views to not have any surfaces - if ( numDrawSurfs < 1 ) { - // we still need to add it for hyperspace cases - R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); - return; - } - - // if we overflowed MAX_DRAWSURFS, the drawsurfs - // wrapped around in the buffer and we will be missing - // the first surfaces, not the last ones - if ( numDrawSurfs > MAX_DRAWSURFS ) { - numDrawSurfs = MAX_DRAWSURFS; - } + if ( numDrawSurfs >= 1 ) + { + // if we overflowed MAX_DRAWSURFS, the drawsurfs + // wrapped around in the buffer and we will be missing + // the first surfaces, not the last ones + if ( numDrawSurfs > MAX_DRAWSURFS ) { + numDrawSurfs = MAX_DRAWSURFS; + } - // sort the drawsurfs by sort type, then orientation, then shader - R_RadixSort( drawSurfs, numDrawSurfs ); + R_RadixSort( drawSurfs, numDrawSurfs ); - // skip pass through drawing if rendering a shadow map - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) - { - R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); - return; - } + // skip pass through drawing if rendering a shadow map + if (!(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) + { + // FIXME: Don't do this at submit time. Determine what surfaces are mirrors + // at RE_RenderScene or earlier. - // check for any pass through drawing, which - // may cause another view to be rendered first - for ( i = 0 ; i < numDrawSurfs ; i++ ) { - int entityNum; - shader_t *shader; - int fogNum; - int postRender; + // check for any pass through drawing, which + // may cause another view to be rendered first + for ( int i = 0 ; i < numDrawSurfs ; i++ ) { + int entityNum; + shader_t *shader; + int fogNum; + int postRender; - R_DecomposeSort( (drawSurfs+i)->sort, &shader, &fogNum, &postRender ); - entityNum = drawSurfs[i].entityNum; + R_DecomposeSort( (drawSurfs+i)->sort, &shader, &fogNum, &postRender ); + entityNum = drawSurfs[i].entityNum; - if ( shader->sort > SS_PORTAL ) { - break; - } + if ( shader->sort > SS_PORTAL ) { + break; + } - // no shader should ever have this sort type - if ( shader->sort == SS_BAD ) { - ri->Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); - } + // no shader should ever have this sort type + if ( shader->sort == SS_BAD ) { + ri->Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); + } - // if the mirror was completely clipped away, we may need to check another surface - if ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) { - // this is a debug option to see exactly what is being mirrored - if ( r_portalOnly->integer ) { - return; + // if the mirror was completely clipped away, we may need to check another surface + if ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) { + // this is a debug option to see exactly what is being mirrored + if ( r_portalOnly->integer ) { + return; + } + break; // only one mirror view at a time + } } - break; // only one mirror view at a time } } From 33767da82de15d0838e6cf7b7eb9b5c3c0f96f17 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 16 Aug 2015 15:42:45 +0100 Subject: [PATCH 299/708] Rend2: Tidy up some globals --- codemp/rd-rend2/tr_animation.cpp | 8 ++-- codemp/rd-rend2/tr_backend.cpp | 57 ++++++++------------------- codemp/rd-rend2/tr_ghoul2.cpp | 12 +++--- codemp/rd-rend2/tr_local.h | 21 +++++----- codemp/rd-rend2/tr_main.cpp | 66 +++++++++++++++----------------- codemp/rd-rend2/tr_mesh.cpp | 4 +- codemp/rd-rend2/tr_model_iqm.cpp | 8 ++-- codemp/rd-rend2/tr_scene.cpp | 3 +- codemp/rd-rend2/tr_world.cpp | 22 +++++------ 9 files changed, 83 insertions(+), 118 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 1840f279b6..2ececac36a 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -178,7 +178,7 @@ R_MDRAddAnimSurfaces // much stuff in there is just copied from R_AddMd3Surfaces in tr_mesh.c -void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { +void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { mdrHeader_t *header; mdrSurface_t *surface; mdrLOD_t *lod; @@ -288,7 +288,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, qfalse, R_IsPostRenderEntity (entityNum, ent), 0 ); } // projection shadows work fine with personal models @@ -297,11 +297,11 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent ) { && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, qfalse, R_IsPostRenderEntity (entityNum, ent), 0 ); } if (!personalModel) - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index b4e8ee4817..2840a016ff 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -403,17 +403,9 @@ A player has predicted a teleport, but hasn't arrived yet ================ */ static void RB_Hyperspace( void ) { - float c; - - if ( !backEnd.isHyperspace ) { - // do initialization shit - } - - c = ( backEnd.refdef.time & 255 ) / 255.0f; - qglClearColor( c, c, c, 1 ); - qglClear( GL_COLOR_BUFFER_BIT ); - - backEnd.isHyperspace = qtrue; + float c = ( backEnd.refdef.time & 255 ) / 255.0f; + vec4_t v = { c, c, c, 1.0f }; + qglClearBufferfv( GL_COLOR, 0, v ); } @@ -535,10 +527,6 @@ void RB_BeginDrawingView (void) { RB_Hyperspace(); return; } - else - { - backEnd.isHyperspace = qfalse; - } glState.faceCulling = -1; // force face culling to set next time @@ -959,10 +947,10 @@ static const void *RB_SetColor( const void *data ) { cmd = (const setColorCommand_t *)data; - backEnd.color2D[0] = cmd->color[0] * 255; - backEnd.color2D[1] = cmd->color[1] * 255; - backEnd.color2D[2] = cmd->color[2] * 255; - backEnd.color2D[3] = cmd->color[3] * 255; + backEnd.color2D[0] = cmd->color[0]; + backEnd.color2D[1] = cmd->color[1]; + backEnd.color2D[2] = cmd->color[2]; + backEnd.color2D[3] = cmd->color[3]; return (const void *)(cmd + 1); } @@ -1013,16 +1001,10 @@ static const void *RB_StretchPic ( const void *data ) { tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; - - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts ]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 1 ]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 2 ]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 3 ]); tess.xyz[ numVerts ][0] = cmd->x; tess.xyz[ numVerts ][1] = cmd->y; @@ -1112,16 +1094,10 @@ static const void *RB_RotatePic ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; - - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts ]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 1]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 2]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 3 ]); tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w) + m[2][0]; tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w) + m[2][1]; @@ -1618,8 +1594,7 @@ static const void *RB_ColorMask(const void *data) const colorMaskCommand_t *cmd = (colorMaskCommand_t *)data; // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); + RB_EndSurface(); // reverse color mask, so 0 0 0 0 is the default backEnd.colorMask[0] = (qboolean)(!cmd->rgba[0]); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 84c50b6218..a6131d31bd 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2382,7 +2382,7 @@ void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, m #endif } -void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from SP. +void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripping right from SP. { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_RenderSurfaces.Start(); @@ -2452,7 +2452,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf ((surfaceType_t *)newSurf, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), cubemapIndex); + R_AddDrawSurf ((surfaceType_t *)newSurf, entityNum, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (entityNum, tr.currentEntity), cubemapIndex); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2532,7 +2532,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf ((surfaceType_t *)newSurf2, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), cubemapIndex); + R_AddDrawSurf ((surfaceType_t *)newSurf2, entityNum, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (entityNum, tr.currentEntity), cubemapIndex); } } } @@ -2550,7 +2550,7 @@ void RenderSurfaces(CRenderSurface &RS) //also ended up just ripping right from for (i=0; i< surfInfo->numChildren; i++) { RS.surfaceNum = surfInfo->childIndexes[i]; - RenderSurfaces(RS); + RenderSurfaces(RS, entityNum); } #ifdef G2_PERFORMANCE_ANALYSIS @@ -3164,7 +3164,7 @@ R_AddGHOULSurfaces ============== */ -void R_AddGhoulSurfaces( trRefEntity_t *ent ) { +void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_R_AddGHOULSurfaces.Start(); #endif @@ -3328,7 +3328,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent ) { RS.renderfx |= RF_NOSHADOW; } - RenderSurfaces(RS); + RenderSurfaces(RS, entityNum); } } HackadelicOnClient=false; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5413399315..d9f6c1efea 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1879,13 +1879,11 @@ typedef struct { viewParms_t viewParms; orientationr_t ori; backEndCounters_t pc; - qboolean isHyperspace; trRefEntity_t *currentEntity; qboolean skyRenderedThisView; // flag for drawing sun qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes - byte color2D[4]; - qboolean vertexes2D; // shader needs to be finished + float color2D[4]; trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering FBO_t *last2DFBO; @@ -1995,7 +1993,6 @@ typedef struct trGlobals_s { trRefEntity_t *currentEntity; trRefEntity_t worldEntity; // point currentEntity at this when rendering world - int currentEntityNum; model_t *currentModel; // @@ -2296,9 +2293,9 @@ void R_RenderPshadowMaps(const refdef_t *fd); void R_RenderSunShadowMaps(const refdef_t *fd, int level); void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ); -void R_AddMD3Surfaces( trRefEntity_t *e ); -void R_AddNullModelSurfaces( trRefEntity_t *e ); -void R_AddBeamSurfaces( trRefEntity_t *e ); +void R_AddMD3Surfaces( trRefEntity_t *e, int entityNum ); +void R_AddNullModelSurfaces( trRefEntity_t *e, int entityNum ); +void R_AddBeamSurfaces( trRefEntity_t *e, int entityNum ); void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); void R_AddLightningBoltSurfaces( trRefEntity_t *e ); @@ -2306,7 +2303,7 @@ void R_AddPolygonSurfaces( void ); void R_DecomposeSort( uint32_t sort, shader_t **shader, int *fogNum, int *postRender ); uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender); -void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, +void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); @@ -2532,7 +2529,7 @@ WORLD MAP ============================================================ */ -void R_AddBrushModelSurfaces( trRefEntity_t *e ); +void R_AddBrushModelSurfaces( trRefEntity_t *e, int entityNum ); void R_AddWorldSurfaces( void ); qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ); @@ -2739,10 +2736,10 @@ ANIMATED MODELS ============================================================= */ -void R_MDRAddAnimSurfaces( trRefEntity_t *ent ); +void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ); void RB_MDRSurfaceAnim( mdrSurface_t *surface ); qboolean R_LoadIQM (model_t *mod, void *buffer, int filesize, const char *name ); -void R_AddIQMSurfaces( trRefEntity_t *ent ); +void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ); void RB_IQMSurfaceAnim( surfaceType_t *surface ); int R_IQMLerpTag( orientation_t *tag, iqmData_t *data, int startFrame, int endFrame, @@ -2813,7 +2810,7 @@ CRenderableSurface(): #endif }; -void R_AddGhoulSurfaces( trRefEntity_t *ent ); +void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); void RB_SurfaceGhoul( CRenderableSurface *surface ); /* Ghoul2 Insert End diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index b42ab9f970..12c782098f 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -769,7 +769,7 @@ R_RotateForViewer Sets up the modelview matrix for a given viewParm ================= */ -void R_RotateForViewer (void) +static void R_RotateForViewer(viewParms_t *viewParms) { float viewerMatrix[16]; vec3_t origin; @@ -778,24 +778,24 @@ void R_RotateForViewer (void) tr.ori.axis[0][0] = 1; tr.ori.axis[1][1] = 1; tr.ori.axis[2][2] = 1; - VectorCopy (tr.viewParms.ori.origin, tr.ori.viewOrigin); + VectorCopy (viewParms->ori.origin, tr.ori.viewOrigin); // transform by the camera placement - VectorCopy( tr.viewParms.ori.origin, origin ); + VectorCopy( viewParms->ori.origin, origin ); - viewerMatrix[0] = tr.viewParms.ori.axis[0][0]; - viewerMatrix[4] = tr.viewParms.ori.axis[0][1]; - viewerMatrix[8] = tr.viewParms.ori.axis[0][2]; + viewerMatrix[0] = viewParms->ori.axis[0][0]; + viewerMatrix[4] = viewParms->ori.axis[0][1]; + viewerMatrix[8] = viewParms->ori.axis[0][2]; viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8]; - viewerMatrix[1] = tr.viewParms.ori.axis[1][0]; - viewerMatrix[5] = tr.viewParms.ori.axis[1][1]; - viewerMatrix[9] = tr.viewParms.ori.axis[1][2]; + viewerMatrix[1] = viewParms->ori.axis[1][0]; + viewerMatrix[5] = viewParms->ori.axis[1][1]; + viewerMatrix[9] = viewParms->ori.axis[1][2]; viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9]; - viewerMatrix[2] = tr.viewParms.ori.axis[2][0]; - viewerMatrix[6] = tr.viewParms.ori.axis[2][1]; - viewerMatrix[10] = tr.viewParms.ori.axis[2][2]; + viewerMatrix[2] = viewParms->ori.axis[2][0]; + viewerMatrix[6] = viewParms->ori.axis[2][1]; + viewerMatrix[10] = viewParms->ori.axis[2][2]; viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10]; viewerMatrix[3] = 0; @@ -807,7 +807,7 @@ void R_RotateForViewer (void) // to OpenGL's coordinate system (looking down -Z) myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelViewMatrix ); - tr.viewParms.world = tr.ori; + viewParms->world = tr.ori; } @@ -1239,7 +1239,6 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) { - tr.currentEntityNum = entityNum; tr.currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity @@ -1357,7 +1356,6 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) { - tr.currentEntityNum = entityNum; tr.currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity @@ -1417,7 +1415,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 unsigned int pointOr = 0; unsigned int pointAnd = (unsigned int)~0; - R_RotateForViewer(); + R_RotateForViewer(&tr.viewParms); R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); entityNum = drawSurf->entityNum; @@ -1771,8 +1769,8 @@ uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender) R_AddDrawSurf ================= */ -void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, - int dlightMap, int postRender, int cubemap) { +void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, + int dlightMap, int postRender, int cubemap ) { int index; drawSurf_t *surf; @@ -1792,7 +1790,7 @@ void R_AddDrawSurf( surfaceType_t *surface, shader_t *shader, int fogIndex, surf = tr.refdef.drawSurfs + index; surf->sort = R_CreateSortKey(shader->sortedIndex, fogIndex, postRender); - surf->entityNum = tr.currentEntityNum; + surf->entityNum = entityNum; surf->lit = (qboolean)dlightMap; surf->cubemapIndex = cubemap; surf->surface = surface; @@ -1864,9 +1862,7 @@ static void R_AddEntitySurface (int entityNum) trRefEntity_t *ent; shader_t *shader; - tr.currentEntityNum = entityNum; - - ent = tr.currentEntity = &tr.refdef.entities[tr.currentEntityNum]; + ent = tr.currentEntity = &tr.refdef.entities[entityNum]; ent->needDlights = qfalse; @@ -1898,7 +1894,7 @@ static void R_AddEntitySurface (int entityNum) return; } shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), 0, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); break; case RT_MODEL: @@ -1907,24 +1903,24 @@ static void R_AddEntitySurface (int entityNum) tr.currentModel = R_GetModelByHandle( ent->e.hModel ); if (!tr.currentModel) { - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0/* cubeMap */ ); + R_AddDrawSurf( &entitySurface, entityNum, tr.defaultShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0/* cubeMap */ ); } else { switch ( tr.currentModel->type ) { case MOD_MESH: - R_AddMD3Surfaces( ent ); + R_AddMD3Surfaces( ent, entityNum ); break; case MOD_MDR: - R_MDRAddAnimSurfaces( ent ); + R_MDRAddAnimSurfaces( ent, entityNum ); break; case MOD_IQM: - R_AddIQMSurfaces( ent ); + R_AddIQMSurfaces( ent, entityNum ); break; case MOD_BRUSH: - R_AddBrushModelSurfaces( ent ); + R_AddBrushModelSurfaces( ent, entityNum ); break; case MOD_MDXM: if (ent->e.ghoul2) - R_AddGhoulSurfaces(ent); + R_AddGhoulSurfaces(ent, entityNum); break; case MOD_BAD: // null model axis if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { @@ -1933,11 +1929,11 @@ static void R_AddEntitySurface (int entityNum) if( ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2)) ) { - R_AddGhoulSurfaces( ent ); + R_AddGhoulSurfaces( ent, entityNum ); break; } - R_AddDrawSurf( &entitySurface, tr.defaultShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, entityNum, tr.defaultShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); @@ -1947,7 +1943,7 @@ static void R_AddEntitySurface (int entityNum) break; case RT_ENT_CHAIN: shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); @@ -2079,7 +2075,7 @@ void R_RenderView (viewParms_t *parms) { tr.viewCount++; // set viewParms.world - R_RotateForViewer (); + R_RotateForViewer(&tr.viewParms); R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); @@ -2427,7 +2423,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) tr.viewCount++; // set viewParms.world - R_RotateForViewer (); + R_RotateForViewer(&tr.viewParms); { float xmin, xmax, ymin, ymax, znear, zfar; @@ -2759,7 +2755,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) tr.viewCount++; // set viewParms.world - R_RotateForViewer (); + R_RotateForViewer(&tr.viewParms); R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 60deca0f5a..21d3ed93b0 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -280,7 +280,7 @@ R_AddMD3Surfaces ================= */ -void R_AddMD3Surfaces( trRefEntity_t *ent ) { +void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { int i; mdvModel_t *model = NULL; mdvSurface_t *surface = NULL; @@ -390,7 +390,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((surfaceType_t *)vboSurface, shader, fogNum, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); + R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 10a9d85f72..4325b0e9c0 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -834,7 +834,7 @@ R_AddIQMSurfaces Add all surfaces of this model ================= */ -void R_AddIQMSurfaces( trRefEntity_t *ent ) { +void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { iqmData_t *data; srfIQModel_t *surface; int i, j; @@ -924,7 +924,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.shadowShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 ); } // projection shadows work fine with personal models @@ -932,11 +932,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) { && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, tr.projectionShadowShader, 0, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 ); } if( !personalModel ) { - R_AddDrawSurf( (surfaceType_t *)surface, shader, fogNum, 0, R_IsPostRenderEntity (tr.currentEntityNum, ent), cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, 0, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 2bb38528f9..6714020325 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -93,12 +93,11 @@ void R_AddPolygonSurfaces( void ) { srfPoly_t *poly; int fogMask; - tr.currentEntityNum = REFENTITYNUM_WORLD; fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0); for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex & fogMask, qfalse, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), 0 /* cubemapIndex */ ); + R_AddDrawSurf( ( surfaceType_t * )poly, REFENTITYNUM_WORLD, sh, poly->fogIndex & fogMask, qfalse, R_IsPostRenderEntity (REFENTITYNUM_WORLD, tr.currentEntity), 0 /* cubemapIndex */ ); } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 7ecb3c8c66..96d79fcb59 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -31,7 +31,7 @@ Tries to cull surfaces before they are lighted or added to the sorting list. ================ */ -static qboolean R_CullSurface( msurface_t *surf ) { +static qboolean R_CullSurface( msurface_t *surf, int entityNum ) { if ( r_nocull->integer || surf->cullinfo.type == CULLINFO_NONE) { return qfalse; } @@ -113,7 +113,7 @@ static qboolean R_CullSurface( msurface_t *surf ) { { int sphereCull; - if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { + if ( entityNum != REFENTITYNUM_WORLD ) { sphereCull = R_CullLocalPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); } else { sphereCull = R_CullPointAndRadius( surf->cullinfo.localOrigin, surf->cullinfo.radius ); @@ -129,7 +129,7 @@ static qboolean R_CullSurface( msurface_t *surf ) { { int boxCull; - if ( tr.currentEntityNum != REFENTITYNUM_WORLD ) { + if ( entityNum != REFENTITYNUM_WORLD ) { boxCull = R_CullLocalBox( surf->cullinfo.bounds ); } else { boxCull = R_CullBox( surf->cullinfo.bounds ); @@ -321,11 +321,11 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { R_AddWorldSurface ====================== */ -static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits ) { +static void R_AddWorldSurface( msurface_t *surf, int entityNum, int dlightBits, int pshadowBits ) { // FIXME: bmodel fog? // try to cull before dlighting or adding - if ( R_CullSurface( surf ) ) { + if ( R_CullSurface( surf, entityNum ) ) { return; } @@ -341,7 +341,7 @@ static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits pshadowBits = ( pshadowBits != 0 ); }*/ - R_AddDrawSurf( surf->data, surf->shader, surf->fogIndex, dlightBits, R_IsPostRenderEntity (tr.currentEntityNum, tr.currentEntity), surf->cubemapIndex ); + R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, R_IsPostRenderEntity (entityNum, tr.currentEntity), surf->cubemapIndex ); } /* @@ -357,7 +357,7 @@ static void R_AddWorldSurface( msurface_t *surf, int dlightBits, int pshadowBits R_AddBrushModelSurfaces ================= */ -void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { +void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { bmodel_t *bmodel; int clip; model_t *pModel; @@ -381,7 +381,7 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent ) { if (tr.world->surfacesViewCount[surf] != tr.viewCount) { tr.world->surfacesViewCount[surf] = tr.viewCount; - R_AddWorldSurface( tr.world->surfaces + surf, tr.currentEntity->needDlights, 0 ); + R_AddWorldSurface( tr.world->surfaces + surf, entityNum, tr.currentEntity->needDlights, 0 ); } } } @@ -780,8 +780,6 @@ void R_AddWorldSurfaces (void) { return; } - tr.currentEntityNum = REFENTITYNUM_WORLD; - // determine which leaves are in the PVS / areamask if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) R_MarkLeaves (); @@ -825,7 +823,7 @@ void R_AddWorldSurfaces (void) { if (tr.world->surfacesViewCount[i] != tr.viewCount) continue; - R_AddWorldSurface( tr.world->surfaces + i, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i] ); + R_AddWorldSurface( tr.world->surfaces + i, REFENTITYNUM_WORLD, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i] ); tr.refdef.dlightMask |= tr.world->surfacesDlightBits[i]; } for (i = 0; i < tr.world->numMergedSurfaces; i++) @@ -833,7 +831,7 @@ void R_AddWorldSurfaces (void) { if (tr.world->mergedSurfacesViewCount[i] != tr.viewCount) continue; - R_AddWorldSurface( tr.world->mergedSurfaces + i, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i] ); + R_AddWorldSurface( tr.world->mergedSurfaces + i, REFENTITYNUM_WORLD, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i] ); tr.refdef.dlightMask |= tr.world->mergedSurfacesDlightBits[i]; } From 6283354b54347f5f318b5332067f5b4c3d56b56b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 20 Aug 2015 21:09:14 +0100 Subject: [PATCH 300/708] Rend2: Fix color in RotatePic2 --- codemp/rd-rend2/tr_backend.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 2840a016ff..f6ac9d5bdb 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1187,16 +1187,10 @@ static const void *RB_RotatePic2 ( const void *data ) tess.indexes[ numIndexes + 4 ] = numVerts + 0; tess.indexes[ numIndexes + 5 ] = numVerts + 1; - { - vec4_t color; - - VectorScale4(backEnd.color2D, 1.0f / 255.0f, color); - - VectorCopy4(color, tess.vertexColors[ numVerts ]); - VectorCopy4(color, tess.vertexColors[ numVerts + 1]); - VectorCopy4(color, tess.vertexColors[ numVerts + 2]); - VectorCopy4(color, tess.vertexColors[ numVerts + 3 ]); - } + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts ]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 1]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 2]); + VectorCopy4(backEnd.color2D, tess.vertexColors[ numVerts + 3 ]); tess.xyz[ numVerts ][0] = m[0][0] * (-cmd->w * 0.5f) + m[1][0] * (-cmd->h * 0.5f) + m[2][0]; tess.xyz[ numVerts ][1] = m[0][1] * (-cmd->w * 0.5f) + m[1][1] * (-cmd->h * 0.5f) + m[2][1]; From 0944ca2d1328af19ed40904fda37e1c8c582ff74 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 22 Aug 2015 12:07:27 +0100 Subject: [PATCH 301/708] Rend2: Change bone matrices uniform to use mat4x3. This gives a 25% memory reduction for matrices --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 13 +++++-- codemp/rd-rend2/glsl/generic_vp.glsl | 13 +++++-- codemp/rd-rend2/glsl/lightall_vp.glsl | 15 +++++--- codemp/rd-rend2/tr_backend.cpp | 8 ++--- codemp/rd-rend2/tr_extramath.h | 1 + codemp/rd-rend2/tr_fbo.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 32 ++++++++--------- codemp/rd-rend2/tr_glsl.cpp | 51 +++++++++++++++++++++------ codemp/rd-rend2/tr_local.h | 8 +++-- codemp/rd-rend2/tr_shade.cpp | 22 ++++++------ codemp/rd-rend2/tr_sky.cpp | 2 +- codemp/rd-rend2/tr_surface.cpp | 4 +-- 12 files changed, 111 insertions(+), 60 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index f045931a14..0db7fc4165 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -27,7 +27,7 @@ uniform mat4 u_ModelViewProjectionMatrix; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4x3 u_BoneMatrices[20]; #endif uniform vec4 u_Color; @@ -202,8 +202,15 @@ void main() { int boneIndex = int(attr_BoneIndexes[i]); - position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; - normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + mat4 boneMatrix = mat4( + vec4(u_BoneMatrices[boneIndex][0], 0.0), + vec4(u_BoneMatrices[boneIndex][1], 0.0), + vec4(u_BoneMatrices[boneIndex][2], 0.0), + vec4(u_BoneMatrices[boneIndex][3], 1.0) + ); + + position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; + normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; } vec3 position = position4.xyz; diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index 1fea4baadd..ad5b0b065d 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -59,7 +59,7 @@ uniform float u_PortalRange; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4x3 u_BoneMatrices[20]; #endif out vec2 var_DiffuseTex; @@ -312,8 +312,15 @@ void main() { int boneIndex = int(attr_BoneIndexes[i]); - position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; - normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + mat4 boneMatrix = mat4( + vec4(u_BoneMatrices[boneIndex][0], 0.0), + vec4(u_BoneMatrices[boneIndex][1], 0.0), + vec4(u_BoneMatrices[boneIndex][2], 0.0), + vec4(u_BoneMatrices[boneIndex][3], 1.0) + ); + + position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; + normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; } vec3 position = position4.xyz; diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index c93fcccfae..e19c3afc2f 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -56,7 +56,7 @@ uniform mat4 u_ModelMatrix; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) -uniform mat4 u_BoneMatrices[20]; +uniform mat4x3 u_BoneMatrices[20]; #endif #if defined(USE_LIGHT_VECTOR) @@ -178,10 +178,17 @@ void main() { int boneIndex = int(attr_BoneIndexes[i]); - position4 += (u_BoneMatrices[boneIndex] * originalPosition) * attr_BoneWeights[i]; - normal4 += (u_BoneMatrices[boneIndex] * originalNormal) * attr_BoneWeights[i]; + mat4 boneMatrix = mat4( + vec4(u_BoneMatrices[boneIndex][0], 0.0), + vec4(u_BoneMatrices[boneIndex][1], 0.0), + vec4(u_BoneMatrices[boneIndex][2], 0.0), + vec4(u_BoneMatrices[boneIndex][3], 1.0) + ); + + position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; + normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - tangent4 += (u_BoneMatrices[boneIndex] * originalTangent) * attr_BoneWeights[i]; + tangent4 += (boneMatrix * originalTangent) * attr_BoneWeights[i]; #endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f6ac9d5bdb..c3ffee6c5b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -907,7 +907,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * GLSL_BindProgram(&tr.textureColorShader); - GLSL_SetUniformMatrix16(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); RB_InstantQuad2(quadVerts, texCoords); @@ -1324,9 +1324,9 @@ static const void *RB_DrawSurfs( const void *data ) { GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); - GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]); - GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]); - GLSL_SetUniformMatrix16(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]); + GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]); + GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]); + GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]); GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); { diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index 079de8d506..e5c480d5b8 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define __TR_EXTRAMATH_H__ typedef float matrix_t[16]; +typedef float mat4x3_t[12]; typedef int vec2i_t[2]; typedef int vec3i_t[3]; typedef int vec4i_t[4]; diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 64eeaa822e..b6b9f7dc47 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -812,7 +812,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS GLSL_BindProgram(shaderProgram); - GLSL_SetUniformMatrix16(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); + GLSL_SetUniformMatrix4x4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color); GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes); GLSL_SetUniformVec2(shaderProgram, UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a6131d31bd..ee1bc55862 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3437,32 +3437,28 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } -static void MDXABoneToMatrix ( const mdxaBone_t& bone, matrix_t& matrix ) +static void MDXABoneToMatrix ( const mdxaBone_t& bone, mat4x3_t& matrix ) { matrix[0] = bone.matrix[0][0]; matrix[1] = bone.matrix[1][0]; matrix[2] = bone.matrix[2][0]; - matrix[3] = 0.0f; - - matrix[4] = bone.matrix[0][1]; - matrix[5] = bone.matrix[1][1]; - matrix[6] = bone.matrix[2][1]; - matrix[7] = 0.0f; - - matrix[8] = bone.matrix[0][2]; - matrix[9] = bone.matrix[1][2]; - matrix[10] = bone.matrix[2][2]; - matrix[11] = 0.0f; - - matrix[12] = bone.matrix[0][3]; - matrix[13] = bone.matrix[1][3]; - matrix[14] = bone.matrix[2][3]; - matrix[15] = 1.0f; + + matrix[3] = bone.matrix[0][1]; + matrix[4] = bone.matrix[1][1]; + matrix[5] = bone.matrix[2][1]; + + matrix[6] = bone.matrix[0][2]; + matrix[7] = bone.matrix[1][2]; + matrix[8] = bone.matrix[2][2]; + + matrix[9] = bone.matrix[0][3]; + matrix[10] = bone.matrix[1][3]; + matrix[11] = bone.matrix[2][3]; } void RB_SurfaceGhoul( CRenderableSurface *surf ) { - static matrix_t boneMatrices[80] = {}; + static mat4x3_t boneMatrices[20] = {}; mdxmSurface_t *surfData = surf->surfaceData; mdxmVBOMesh_t *surface = surf->vboMesh; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3d2e3a90be..ea0da2bc2c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -87,9 +87,9 @@ static uniformInfo_t uniformsInfo[] = { "u_ShadowMap2", GLSL_INT, 1 }, { "u_ShadowMap3", GLSL_INT, 1 }, - { "u_ShadowMvp", GLSL_MAT16, 1 }, - { "u_ShadowMvp2", GLSL_MAT16, 1 }, - { "u_ShadowMvp3", GLSL_MAT16, 1 }, + { "u_ShadowMvp", GLSL_MAT4x4, 1 }, + { "u_ShadowMvp2", GLSL_MAT4x4, 1 }, + { "u_ShadowMvp3", GLSL_MAT4x4, 1 }, { "u_EnableTextures", GLSL_VEC4, 1 }, { "u_DiffuseTexMatrix", GLSL_VEC4, 1 }, @@ -127,8 +127,8 @@ static uniformInfo_t uniformsInfo[] = { "u_FogEyeT", GLSL_FLOAT, 1 }, { "u_FogColorMask", GLSL_VEC4, 1 }, - { "u_ModelMatrix", GLSL_MAT16, 1 }, - { "u_ModelViewProjectionMatrix", GLSL_MAT16, 1 }, + { "u_ModelMatrix", GLSL_MAT4x4, 1 }, + { "u_ModelViewProjectionMatrix", GLSL_MAT4x4, 1 }, { "u_Time", GLSL_FLOAT, 1 }, { "u_VertexLerp" , GLSL_FLOAT, 1 }, @@ -153,7 +153,7 @@ static uniformInfo_t uniformsInfo[] = { "u_CubeMapInfo", GLSL_VEC4, 1 }, - { "u_BoneMatrices", GLSL_MAT16, 20 }, + { "u_BoneMatrices", GLSL_MAT4x3, 20 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) @@ -713,7 +713,10 @@ void GLSL_InitUniforms(shaderProgram_t *program) case GLSL_VEC4: size += sizeof(float) * 4 * uniformsInfo[i].size; break; - case GLSL_MAT16: + case GLSL_MAT4x3: + size += sizeof(float) * 12 * uniformsInfo[i].size; + break; + case GLSL_MAT4x4: size += sizeof(float) * 16 * uniformsInfo[i].size; break; default: @@ -885,7 +888,35 @@ void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float qglUniform1fv(uniforms[uniformNum], numFloats, v); } -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) +void GLSL_SetUniformMatrix4x3(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) +{ + GLint *uniforms = program->uniforms; + float *compare; + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_MAT4x3) + { + ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x3: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (uniformsInfo[uniformNum].size < numElements) + return; + + compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + if (memcmp (matrix, compare, sizeof (float) * 12 * numElements) == 0) + { + return; + } + + Com_Memcpy (compare, matrix, sizeof (float) * 12 * numElements); + + qglUniformMatrix4x3fv(uniforms[uniformNum], numElements, GL_FALSE, matrix); +} + +void GLSL_SetUniformMatrix4x4(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements) { GLint *uniforms = program->uniforms; float *compare; @@ -893,9 +924,9 @@ void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const flo if (uniforms[uniformNum] == -1) return; - if (uniformsInfo[uniformNum].type != GLSL_MAT16) + if (uniformsInfo[uniformNum].type != GLSL_MAT4x4) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix16: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x4: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d9f6c1efea..a5c64a54cc 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -985,7 +985,8 @@ enum GLSL_VEC2, GLSL_VEC3, GLSL_VEC4, - GLSL_MAT16 + GLSL_MAT4x3, + GLSL_MAT4x4, }; typedef enum @@ -1784,7 +1785,7 @@ typedef struct glstate_s { int vertexAttribsTexCoordOffset[2]; qboolean vertexAnimation; qboolean skeletalAnimation; - matrix_t *boneMatrices; + mat4x3_t *boneMatrices; int numBones; shaderProgram_t *currentProgram; FBO_t *currentFBO; @@ -2685,7 +2686,8 @@ void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); -void GLSL_SetUniformMatrix16(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); +void GLSL_SetUniformMatrix4x3(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); +void GLSL_SetUniformMatrix4x4(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index a8d1963cf9..563f5e69ed 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -141,7 +141,7 @@ static void DrawTris (shaderCommands_t *input) { GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); VectorSet4(color, 1, 1, 1, 1); GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); @@ -431,7 +431,7 @@ static void ProjectDlightTexture( void ) { GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -832,7 +832,7 @@ static void ForwardDlight( void ) { GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); @@ -894,7 +894,7 @@ static void ForwardDlight( void ) { // where they aren't rendered GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); if (pStage->bundle[TB_DIFFUSEMAP].image[0]) R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); @@ -987,7 +987,7 @@ static void ProjectPshadowVBOGLSL( void ) { GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); VectorCopy(origin, vector); vector[3] = 1.0f; @@ -1071,7 +1071,7 @@ static void RB_FogPass( void ) { fog = tr.world->fogs + tess.fogNum; - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -1342,13 +1342,13 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); if (glState.skeletalAnimation) { - GLSL_SetUniformMatrix16 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); + GLSL_SetUniformMatrix4x3 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); } GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -1473,7 +1473,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); } - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); @@ -1659,9 +1659,9 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 9587ab231a..8c370d197c 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -445,7 +445,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); color[0] = color[1] = diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index e5cd5d0ed7..e8ddb524e8 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -229,7 +229,7 @@ void RB_InstantQuad(vec4_t quadVerts[4]) GLSL_BindProgram(&tr.textureColorShader); - GLSL_SetUniformMatrix16(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite); RB_InstantQuad2(quadVerts, texCoords); @@ -656,7 +656,7 @@ static void RB_SurfaceBeam( void ) GLSL_VertexAttribsState(ATTR_POSITION, NULL); GLSL_BindProgram(sp); - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed); From 23d47e4ca87821395637070ad2c4fa0ea860203d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 22 Aug 2015 12:38:02 +0100 Subject: [PATCH 302/708] Rend2: Reduce vertex data size for g2 models Bone indices and bone weights are now stored in uint8 x 4 instead of float x 4. Vertex data size before this commit was: position = 12 bytes (3 x f32) normals = 4 bytes (1 x uint1010102) texcoords = 8 bytes (2 x f32) weights = 16 bytes (4 x f32) bone indices = 16 bytes (4 x f32) tangents = 4 bytes (1 x uint1010102) TOTAL = 60 bytes After this commit: weights = 4 bytes indices = 4 bytes TOTAL = 36 bytes 60 bytes -> 36 bytes = 40% vertex data size reduction --- codemp/rd-rend2/glsl/fogpass_vp.glsl | 4 +-- codemp/rd-rend2/glsl/generic_vp.glsl | 4 +-- codemp/rd-rend2/glsl/lightall_vp.glsl | 4 +-- codemp/rd-rend2/tr_ghoul2.cpp | 40 +++++++++++---------- codemp/rd-rend2/tr_glsl.cpp | 50 +++++++++++++++++---------- 5 files changed, 58 insertions(+), 44 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass_vp.glsl index 0db7fc4165..db0e68ae7f 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_vp.glsl @@ -7,7 +7,7 @@ in vec2 attr_TexCoord0; in vec3 attr_Position2; in vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) -in vec4 attr_BoneIndexes; +in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif @@ -200,7 +200,7 @@ void main() for (int i = 0; i < 4; i++) { - int boneIndex = int(attr_BoneIndexes[i]); + uint boneIndex = attr_BoneIndexes[i]; mat4 boneMatrix = mat4( vec4(u_BoneMatrices[boneIndex][0], 0.0), diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index ad5b0b065d..c025c7d4f2 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -5,7 +5,7 @@ in vec3 attr_Normal; in vec3 attr_Position2; in vec3 attr_Normal2; #elif defined(USE_SKELETAL_ANIMATION) -in vec4 attr_BoneIndexes; +in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif @@ -310,7 +310,7 @@ void main() for (int i = 0; i < 4; i++) { - int boneIndex = int(attr_BoneIndexes[i]); + uint boneIndex = attr_BoneIndexes[i]; mat4 boneMatrix = mat4( vec4(u_BoneMatrices[boneIndex][0], 0.0), diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index e19c3afc2f..c330e5694b 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -17,7 +17,7 @@ in vec3 attr_Normal2; in vec4 attr_Tangent2; #endif #elif defined(USE_SKELETAL_ANIMATION) -in vec4 attr_BoneIndexes; +in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif @@ -176,7 +176,7 @@ void main() for (int i = 0; i < 4; i++) { - int boneIndex = int(attr_BoneIndexes[i]); + uint boneIndex = attr_BoneIndexes[i]; mat4 boneMatrix = mat4( vec4(u_BoneMatrices[boneIndex][0], 0.0), diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index ee1bc55862..638b013dec 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4096,8 +4096,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean vec3_t *verts; uint32_t *normals; vec2_t *texcoords; - vec4_t *bonerefs; - vec4_t *weights; + byte *bonerefs; + byte *weights; uint32_t *tangents; byte *data; @@ -4141,8 +4141,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); - dataSize += numVerts * sizeof (*weights); - dataSize += numVerts * sizeof (*bonerefs); + dataSize += numVerts * sizeof (*weights) * 4; + dataSize += numVerts * sizeof (*bonerefs) * 4; dataSize += numVerts * sizeof (*tangents); // Allocate and write to memory @@ -4160,13 +4160,13 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean ofsTexcoords = stride; stride += sizeof (*texcoords); - bonerefs = (vec4_t *)(data + stride); + bonerefs = data + stride; ofsBoneRefs = stride; - stride += sizeof (*bonerefs); + stride += sizeof (*bonerefs) * 4; - weights = (vec4_t *)(data + stride); + weights = data + stride; ofsWeights = stride; - stride += sizeof (*weights); + stride += sizeof (*weights) * 4; tangents = (uint32_t *)(data + stride); ofs_tangent = stride; @@ -4192,30 +4192,32 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean for ( int k = 0; k < surf->numVerts; k++ ) { int numWeights = G2_GetVertWeights (&v[k]); - float lastWeight = 1.0f; + int lastWeight = 255; int lastInfluence = numWeights - 1; for ( int w = 0; w < lastInfluence; w++ ) { - float weight = G2_GetVertBoneWeightNotSlow (&v[k], w); - (*weights)[w] = weight; - (*bonerefs)[w] = (float)G2_GetVertBoneIndex (&v[k], w); + float weight = G2_GetVertBoneWeightNotSlow(&v[k], w); + weights[w] = (byte)(weight * 255.0f); + bonerefs[w] = G2_GetVertBoneIndex(&v[k], w); - lastWeight -= weight; + lastWeight -= weights[w]; } + assert(lastWeight > 0); + // Ensure that all the weights add up to 1.0 - (*weights)[lastInfluence] = lastWeight; - (*bonerefs)[lastInfluence] = (float)G2_GetVertBoneIndex (&v[k], lastInfluence); + weights[lastInfluence] = lastWeight; + bonerefs[lastInfluence] = G2_GetVertBoneIndex(&v[k], lastInfluence); // Fill in the rest of the info with zeroes. for ( int w = numWeights; w < 4; w++ ) { - (*weights)[w] = 0.0f; - (*bonerefs)[w] = 0.0f; + weights[w] = 0; + bonerefs[w] = 0; } - weights = (vec4_t *)((byte *)weights + stride); - bonerefs = (vec4_t *)((byte *)bonerefs + stride); + weights += stride; + bonerefs += stride; } // Texture coordinates diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ea0da2bc2c..e9019cba0b 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1927,34 +1927,46 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties const struct { int numComponents; + GLboolean integerAttribute; GLenum type; GLboolean normalize; int offset; } attributes[ATTR_INDEX_MAX] = { - { 3, GL_FLOAT, GL_FALSE, 0 }, // position - { 2, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0] }, - { 2, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1] }, - { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // tangent - { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // normal - { 4, GL_FLOAT, GL_FALSE, 0 }, // color - { 0, GL_NONE, GL_FALSE, 0 }, // paint color - { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // light direction - { 4, GL_FLOAT, GL_FALSE, 0 }, // bon indices - { 4, GL_FLOAT, GL_FALSE, 0 }, // bone weights - { 3, GL_FLOAT, GL_FALSE, 0 }, // pos2 - { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, - { 4, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, + { 3, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // position + { 2, GL_FALSE, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0] }, + { 2, GL_FALSE, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1] }, + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // tangent + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // normal + { 4, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // color + { 0, GL_FALSE, GL_NONE, GL_FALSE, 0 }, // paint color + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // light direction + { 4, GL_TRUE, GL_UNSIGNED_BYTE, GL_FALSE, 0 }, // bone indices + { 4, GL_FALSE, GL_UNSIGNED_BYTE, GL_TRUE, 0 }, // bone weights + { 3, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // pos2 + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, }; for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { int attributeIndex = vertexArrays->enabledAttributes[i]; - qglVertexAttribPointer(attributeIndex, - attributes[attributeIndex].numComponents, - attributes[attributeIndex].type, - attributes[attributeIndex].normalize, - vertexArrays->strides[attributeIndex], - BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + if ( attributes[attributeIndex].integerAttribute ) + { + qglVertexAttribIPointer(attributeIndex, + attributes[attributeIndex].numComponents, + attributes[attributeIndex].type, + vertexArrays->strides[attributeIndex], + BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + } + else + { + qglVertexAttribPointer(attributeIndex, + attributes[attributeIndex].numComponents, + attributes[attributeIndex].type, + attributes[attributeIndex].normalize, + vertexArrays->strides[attributeIndex], + BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + } glState.vertexAttribPointersSet |= (1 << attributeIndex); } From 4184ca19b03234ccb6b05e5356e7411f07356eb4 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 23 Aug 2015 17:57:57 +0100 Subject: [PATCH 303/708] Rend2: Draw splash screen with shaders --- codemp/rd-rend2/tr_glsl.cpp | 41 +++++++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_init.cpp | 40 +++++++----------------------------- codemp/rd-rend2/tr_local.h | 2 ++ 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e9019cba0b..3a7a8b1259 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -993,6 +993,45 @@ static bool GLSL_IsValidPermutationForLight (int lightType, int shaderCaps) return true; } +void GLSL_InitSplashScreenShader() +{ + const char *vs = + "#version 150 core\n" + "out vec2 var_TexCoords;\n" + "void main() {\n" + " vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0);\n" + " gl_Position = vec4(position, 0.0, 1.0);\n" + " var_TexCoords = vec2(position.x * 0.5 + 0.5, 2.0 - (position.y * 0.5 + 0.5));\n" + "}"; + + const char *fs = + "#version 150 core\n" + "uniform sampler2D u_SplashTexture;\n" + "in vec2 var_TexCoords;\n" + "out vec4 out_Color;\n" + "void main() {\n" + " out_Color = texture(u_SplashTexture, var_TexCoords);\n" + "}"; + + GLuint vshader = qglCreateShader(GL_VERTEX_SHADER); + qglShaderSource(vshader, 1, &vs, NULL); + qglCompileShader(vshader); + + GLuint fshader = qglCreateShader(GL_FRAGMENT_SHADER); + qglShaderSource(fshader, 1, &fs, NULL); + qglCompileShader(fshader); + + GLuint program = qglCreateProgram(); + qglAttachShader(program, vshader); + qglAttachShader(program, fshader); + qglLinkProgram(program); + + size_t splashLen = strlen("splash"); + tr.splashScreenShader.program = program; + tr.splashScreenShader.name = (char *)Z_Malloc(splashLen + 1, TAG_GENERAL); + Q_strncpyz(tr.splashScreenShader.name, "splash", splashLen + 1); +} + int GLSL_BeginLoadGPUShaders(void) { int startTime; @@ -1763,6 +1802,8 @@ void GLSL_ShutdownGPUShaders(void) GLSL_BindNullProgram(); + GLSL_DeleteGPUShader(&tr.splashScreenShader); + for ( i = 0; i < GENERICDEF_COUNT; i++) GLSL_DeleteGPUShader(&tr.genericShader[i]); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index bb84fa3f3b..d6125d7621 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -258,45 +258,19 @@ cvar_t *r_debugContext; extern void RB_SetGL2D (void); void R_Splash() { - image_t *pImage = R_FindImageFile( "menu/splash", IMGTYPE_COLORALPHA, IMGFLAG_NONE); - qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); - qglScissor( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); - qglMatrixMode(GL_PROJECTION); - qglLoadIdentity (); - qglOrtho (0, 640, 480, 0, 0, 1); - qglMatrixMode(GL_MODELVIEW); - qglLoadIdentity (); - - GL_State( GLS_DEPTHTEST_DISABLE | - GLS_SRCBLEND_SRC_ALPHA | - GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + GLSL_InitSplashScreenShader(); + qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglDisable( GL_CULL_FACE ); qglDisable( GL_CLIP_PLANE0 ); + + image_t *pImage = R_FindImageFile( "menu/splash", IMGTYPE_COLORALPHA, IMGFLAG_NONE); if (pImage ) - {//invalid paths? GL_Bind( pImage ); - } - GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); - const int width = 640; - const int height = 480; - const float x1 = 320 - width / 2; - const float x2 = 320 + width / 2; - const float y1 = 240 - height / 2; - const float y2 = 240 + height / 2; - - - qglBegin (GL_TRIANGLE_STRIP); - qglTexCoord2f( 0, 0 ); - qglVertex2f(x1, y1); - qglTexCoord2f( 1 , 0 ); - qglVertex2f(x2, y1); - qglTexCoord2f( 0, 1 ); - qglVertex2f(x1, y2); - qglTexCoord2f( 1, 1 ); - qglVertex2f(x2, y2); - qglEnd(); + GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + GLSL_BindProgram(&tr.splashScreenShader); + qglDrawArrays(GL_TRIANGLES, 0, 3); ri->WIN_Present(&window); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a5c64a54cc..5b2f345869 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1999,6 +1999,7 @@ typedef struct trGlobals_s { // // GPU shader programs // + shaderProgram_t splashScreenShader; shaderProgram_t genericShader[GENERICDEF_COUNT]; shaderProgram_t textureColorShader; shaderProgram_t fogShader[FOGDEF_COUNT]; @@ -2671,6 +2672,7 @@ GLSL ============================================================ */ +void GLSL_InitSplashScreenShader(); int GLSL_BeginLoadGPUShaders(void); void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); From 353143beaa1cf61148e858f494b4eea6ddc22e4a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 23 Aug 2015 18:52:19 +0100 Subject: [PATCH 304/708] Rend2: Remove redundant vertex attrib calls --- codemp/rd-rend2/tr_glsl.cpp | 50 ++++++++++++++++++++++++++++--------- codemp/rd-rend2/tr_local.h | 3 +++ 2 files changed, 41 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3a7a8b1259..d7c0a11e3c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1928,24 +1928,38 @@ void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits, const Vertex { if ( attribBits & ATTR_TEXCOORD0 ) { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); + int newOffset = vertexArrays->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0]; + if ( glState.currentVaoVbo[ATTR_INDEX_TEXCOORD0] != glState.currentVBO->vertexesVBO || + glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD0] != newOffset || + glState.currentVaoStrides[ATTR_INDEX_TEXCOORD0] != vertexArrays->strides[ATTR_INDEX_TEXCOORD0] ) + { + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); + + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, + vertexArrays->strides[ATTR_INDEX_TEXCOORD0], BUFFER_OFFSET(newOffset)); - qglVertexAttribPointer( - ATTR_INDEX_TEXCOORD0, - 2, GL_FLOAT, - 0, vertexArrays->strides[ATTR_INDEX_TEXCOORD0], - BUFFER_OFFSET(vertexArrays->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0])); + glState.currentVaoVbo[ATTR_INDEX_TEXCOORD0] = glState.currentVBO->vertexesVBO; + glState.currentVaoStrides[ATTR_INDEX_TEXCOORD0] = vertexArrays->strides[ATTR_INDEX_TEXCOORD0]; + glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD0] = newOffset; + } } if ( attribBits & ATTR_TEXCOORD1 ) { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_LIGHTCOORD )\n"); + int newOffset = vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1]; + if ( glState.currentVaoVbo[ATTR_INDEX_TEXCOORD1] != glState.currentVBO->vertexesVBO || + glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD1] != newOffset || + glState.currentVaoStrides[ATTR_INDEX_TEXCOORD1] != vertexArrays->strides[ATTR_INDEX_TEXCOORD1] ) + { + GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD1 )\n"); + + qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, + vertexArrays->strides[ATTR_INDEX_TEXCOORD1], BUFFER_OFFSET(newOffset)); - qglVertexAttribPointer( - ATTR_INDEX_TEXCOORD1, - 2, GL_FLOAT, - 0, vertexArrays->strides[ATTR_INDEX_TEXCOORD1], - BUFFER_OFFSET(vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1])); + glState.currentVaoVbo[ATTR_INDEX_TEXCOORD1] = glState.currentVBO->vertexesVBO; + glState.currentVaoStrides[ATTR_INDEX_TEXCOORD1] = vertexArrays->strides[ATTR_INDEX_TEXCOORD1]; + glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD1] = newOffset; + } } } @@ -1991,6 +2005,15 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { int attributeIndex = vertexArrays->enabledAttributes[i]; + + if ( glState.currentVaoVbo[attributeIndex] == glState.currentVBO->vertexesVBO && + glState.currentVaoOffsets[attributeIndex] == vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset && + glState.currentVaoStrides[attributeIndex] == vertexArrays->strides[attributeIndex] ) + { + // No change + continue; + } + if ( attributes[attributeIndex].integerAttribute ) { qglVertexAttribIPointer(attributeIndex, @@ -2009,6 +2032,9 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); } + glState.currentVaoVbo[attributeIndex] = glState.currentVBO->vertexesVBO; + glState.currentVaoStrides[attributeIndex] = vertexArrays->strides[attributeIndex]; + glState.currentVaoOffsets[attributeIndex] = vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset; glState.vertexAttribPointersSet |= (1 << attributeIndex); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5b2f345869..aabae2b73e 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1794,6 +1794,9 @@ typedef struct glstate_s { matrix_t modelview; matrix_t projection; matrix_t modelviewProjection; + int currentVaoVbo[ATTR_INDEX_MAX]; + int currentVaoStrides[ATTR_INDEX_MAX]; + int currentVaoOffsets[ATTR_INDEX_MAX]; } glstate_t; typedef enum { From 9661c72b63fe63cba33b4120339512311fbe4a2d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 24 Aug 2015 20:53:39 +0100 Subject: [PATCH 305/708] Rend2: Add binned triangle counts (r_speed 8) --- codemp/rd-rend2/tr_cmds.cpp | 17 +++++++++++++++++ codemp/rd-rend2/tr_local.h | 17 +++++++++++++++++ codemp/rd-rend2/tr_shade.cpp | 31 +++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index ce49c4b5f9..cadc75885c 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -72,6 +72,23 @@ void R_PerformanceCounters( void ) { ri->Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); } + else if (r_speeds->integer == 8) + { + ri->Printf( PRINT_ALL, "0-19: %d 20-49: %d 50-99: %d 100-299: %d\n", + backEnd.pc.c_triangleCountBins[TRI_BIN_0_19], + backEnd.pc.c_triangleCountBins[TRI_BIN_20_49], + backEnd.pc.c_triangleCountBins[TRI_BIN_50_99], + backEnd.pc.c_triangleCountBins[TRI_BIN_100_299]); + + ri->Printf( PRINT_ALL, "300-599: %d 600-999: %d 1000-1499: %d 1500-1999: %d\n", + backEnd.pc.c_triangleCountBins[TRI_BIN_300_599], + backEnd.pc.c_triangleCountBins[TRI_BIN_600_999], + backEnd.pc.c_triangleCountBins[TRI_BIN_1000_1499], + backEnd.pc.c_triangleCountBins[TRI_BIN_1500_1999]); + ri->Printf( PRINT_ALL, "2000-2999: %d 3000+: %d\n", + backEnd.pc.c_triangleCountBins[TRI_BIN_2000_2999], + backEnd.pc.c_triangleCountBins[TRI_BIN_3000_PLUS]); + } Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index aabae2b73e..304aa40ad3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1842,6 +1842,21 @@ typedef struct { qboolean floatLightmap; } glRefConfig_t; +enum +{ + TRI_BIN_0_19, + TRI_BIN_20_49, + TRI_BIN_50_99, + TRI_BIN_100_299, + TRI_BIN_300_599, + TRI_BIN_600_999, + TRI_BIN_1000_1499, + TRI_BIN_1500_1999, + TRI_BIN_2000_2999, + TRI_BIN_3000_PLUS, + + NUM_TRI_BINS, +}; typedef struct { int c_surfaces, c_shaders, c_vertexes, c_indexes, c_totalIndexes; @@ -1873,6 +1888,8 @@ typedef struct { int c_fogDraws; int c_dlightDraws; + int c_triangleCountBins[NUM_TRI_BINS]; + int msec; // total msec for backend run } backEndCounters_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 563f5e69ed..dafc80e965 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA color4ub_t styleColors[MAX_LIGHT_STYLES]; +void RB_BinTriangleCounts( void ); + /* ================== @@ -479,6 +481,8 @@ static void ProjectDlightTexture( void ) { backEnd.pc.c_totalIndexes += tess.numIndexes; backEnd.pc.c_dlightIndexes += tess.numIndexes; backEnd.pc.c_dlightVertexes += tess.numVertexes; + + RB_BinTriangleCounts(); } } @@ -955,6 +959,8 @@ static void ForwardDlight( void ) { backEnd.pc.c_totalIndexes += tess.numIndexes; backEnd.pc.c_dlightIndexes += tess.numIndexes; backEnd.pc.c_dlightVertexes += tess.numVertexes; + + RB_BinTriangleCounts(); } } @@ -1025,6 +1031,7 @@ static void ProjectPshadowVBOGLSL( void ) { backEnd.pc.c_totalIndexes += tess.numIndexes; //backEnd.pc.c_dlightIndexes += tess.numIndexes; + RB_BinTriangleCounts(); } } @@ -1859,6 +1866,28 @@ void RB_StageIteratorGeneric( void ) } } +void RB_BinTriangleCounts( void ) +{ + int numTriangles = tess.numIndexes / 3; + if ( numTriangles < 20 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_0_19]++; + else if ( numTriangles < 50 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_20_49]++; + else if ( numTriangles < 100 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_50_99]++; + else if ( numTriangles < 300 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_100_299]++; + else if ( numTriangles < 600 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_300_599]++; + else if ( numTriangles < 1000 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_1000_1499]++; + else if ( numTriangles < 1500 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_1500_1999]++; + else if ( numTriangles < 2000 ) + backEnd.pc.c_triangleCountBins[TRI_BIN_2000_2999]++; + else + backEnd.pc.c_triangleCountBins[TRI_BIN_3000_PLUS]++; +} /* ** RB_EndSurface @@ -1897,6 +1926,8 @@ void RB_EndSurface( void ) { backEnd.pc.c_indexes += tess.numIndexes; backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses; + RB_BinTriangleCounts(); + // // call off to shader specific tess end function // From 56efe405dfaaa253435341d9464dca5eb33e37be Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 29 Aug 2015 18:22:39 +0100 Subject: [PATCH 306/708] Rend2: Add cubemap index to sort key for now... Reduces the number of state changes by a tiny bit --- codemp/rd-rend2/tr_backend.cpp | 3 +-- codemp/rd-rend2/tr_local.h | 11 +++++++---- codemp/rd-rend2/tr_main.cpp | 17 ++++++++++------- codemp/rd-rend2/tr_shader.cpp | 5 +++-- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c3ffee6c5b..860d0a8450 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -601,10 +601,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.pc.c_surfaces += numDrawSurfs; for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &fogNum, &postRender ); entityNum = drawSurf->entityNum; dlighted = drawSurf->lit; - cubemapIndex = drawSurf->cubemapIndex; if ( shader == oldShader && fogNum == oldFogNum && diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 304aa40ad3..19a1a96b34 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1242,7 +1242,11 @@ compared quickly during the qsorting process #define QSORT_FOGNUM_BITS 5 #define QSORT_FOGNUM_MASK ((1 << QSORT_FOGNUM_BITS) - 1) -#define QSORT_SHADERNUM_SHIFT (QSORT_FOGNUM_SHIFT + QSORT_FOGNUM_BITS) +#define QSORT_CUBEMAP_SHIFT (QSORT_FOGNUM_SHIFT + QSORT_FOGNUM_BITS) +#define QSORT_CUBEMAP_BITS 6 +#define QSORT_CUBEMAP_MASK ((1 << QSORT_CUBEMAP_BITS) - 1) + +#define QSORT_SHADERNUM_SHIFT (QSORT_CUBEMAP_SHIFT + QSORT_CUBEMAP_BITS) #define QSORT_SHADERNUM_BITS SHADERNUM_BITS #define QSORT_SHADERNUM_MASK ((1 << QSORT_SHADERNUM_BITS) - 1) @@ -1256,7 +1260,6 @@ compared quickly during the qsorting process typedef struct drawSurf_s { uint32_t sort; // bit combination for fast compares - int cubemapIndex; int entityNum; qboolean lit; surfaceType_t *surface; // any of surface*_t @@ -2323,8 +2326,8 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e ); void R_AddPolygonSurfaces( void ); -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *fogNum, int *postRender ); -uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender); +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *fogNum, int *postRender ); +uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int fogIndex, int postRender); void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 12c782098f..cc73652617 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1409,6 +1409,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 int numTriangles; shader_t *shader; int fogNum; + int cubemap; int postRender; vec4_t clip, eye; int i; @@ -1417,10 +1418,10 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(&tr.viewParms); - R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &fogNum, &postRender ); entityNum = drawSurf->entityNum; - RB_BeginSurface( shader, fogNum, drawSurf->cubemapIndex ); + RB_BeginSurface( shader, fogNum, cubemap ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); if ( tess.numVertexes > 128 ) @@ -1746,18 +1747,20 @@ bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ) R_DecomposeSort ================= */ -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *fogNum, int *postRender ) +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *fogNum, int *postRender ) { *fogNum = (sort >> QSORT_FOGNUM_SHIFT) & QSORT_FOGNUM_MASK; *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & QSORT_SHADERNUM_MASK ]; *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & QSORT_POSTRENDER_MASK; + *cubemap = (sort >> QSORT_CUBEMAP_SHIFT ) & QSORT_CUBEMAP_MASK; } -uint32_t R_CreateSortKey(int sortedShaderIndex, int fogIndex, int postRender) +uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int fogIndex, int postRender) { uint32_t key = 0; key |= (sortedShaderIndex & QSORT_SHADERNUM_MASK) << QSORT_SHADERNUM_SHIFT; + key |= (cubemapIndex & QSORT_CUBEMAP_MASK) << QSORT_CUBEMAP_SHIFT; key |= (fogIndex & QSORT_FOGNUM_MASK) << QSORT_FOGNUM_SHIFT; key |= (postRender & QSORT_POSTRENDER_MASK) << QSORT_POSTRENDER_SHIFT; @@ -1789,10 +1792,9 @@ void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, in index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; surf = tr.refdef.drawSurfs + index; - surf->sort = R_CreateSortKey(shader->sortedIndex, fogIndex, postRender); + surf->sort = R_CreateSortKey(shader->sortedIndex, cubemap, fogIndex, postRender); surf->entityNum = entityNum; surf->lit = (qboolean)dlightMap; - surf->cubemapIndex = cubemap; surf->surface = surface; tr.refdef.numDrawSurfs++; @@ -1829,8 +1831,9 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { shader_t *shader; int fogNum; int postRender; + int cubemap; - R_DecomposeSort( (drawSurfs+i)->sort, &shader, &fogNum, &postRender ); + R_DecomposeSort( (drawSurfs+i)->sort, &shader, &cubemap, &fogNum, &postRender ); entityNum = drawSurfs[i].entityNum; if ( shader->sort > SS_PORTAL ) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 5821e0cfa6..588db8ac30 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3106,14 +3106,15 @@ static void FixRenderCommandList( int newShader ) { int fogNum; int postRender; int sortedIndex; + int cubemap; const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &shader, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &fogNum, &postRender ); sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = R_CreateSortKey(sortedIndex, fogNum, postRender); + drawSurf->sort = R_CreateSortKey(sortedIndex, cubemap, fogNum, postRender); } } curCmd = (const void *)(ds_cmd + 1); From 8d681f8513442ae8fc0a484fb2e95861c446b371 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 29 Aug 2015 18:24:17 +0100 Subject: [PATCH 307/708] Rend2: Add /capframe command for debugging. /capframe will record one or more frames worth of draw data into a csv-formatted file. This is useful for determining what state changes are happening and if any optimizations can be done. --- codemp/rd-rend2/tr_backend.cpp | 11 ++++++ codemp/rd-rend2/tr_init.cpp | 25 ++++++++++++++ codemp/rd-rend2/tr_local.h | 3 ++ codemp/rd-rend2/tr_shade.cpp | 61 +++++++++++++++++++++++++++++----- 4 files changed, 92 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 860d0a8450..36423950ca 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1696,6 +1696,17 @@ static const void *RB_SwapBuffers( const void *data ) { } } + if ( tr.numFramesToCapture > 0 ) + { + tr.numFramesToCapture--; + if ( !tr.numFramesToCapture ) + { + ri->Printf( PRINT_ALL, "Frames captured\n" ); + ri->FS_FCloseFile(tr.debugFile); + tr.debugFile = 0; + } + } + GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); ri->WIN_Present( &window ); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index d6125d7621..6af2a13c7e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1249,6 +1249,30 @@ void GfxMemInfo_f( void ) } } +static void R_CaptureFrameData_f() +{ + int argc = ri->Cmd_Argc(); + if ( argc <= 1 ) + { + ri->Printf( PRINT_ALL, "Usage: %s \n", ri->Cmd_Argv(0)); + return; + } + + + const char *cmd = ri->Cmd_Argv(1); + if ( Q_stricmp(cmd, "single") == 0 ) + tr.numFramesToCapture = 1; + else if ( Q_stricmp(cmd, "multi") == 0 ) + tr.numFramesToCapture = atoi(ri->Cmd_Argv(1)); + + int len = ri->FS_FOpenFileByMode("rend2.log", &tr.debugFile, FS_APPEND); + if ( len == -1 || !tr.debugFile ) + { + ri->Printf( PRINT_ERROR, "Failed to open rend2 log file\n" ); + tr.numFramesToCapture = 0; + } +} + typedef struct consoleCommand_s { const char *cmd; xcommand_t func; @@ -1269,6 +1293,7 @@ static consoleCommand_t commands[] = { { "modellist", R_Modellist_f }, //{ "modelcacheinfo", RE_RegisterModels_Info_f }, { "vbolist", R_VBOList_f }, + { "capframes", R_CaptureFrameData_f }, }; static const size_t numCommands = ARRAY_LEN( commands ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 19a1a96b34..72b808b718 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1929,6 +1929,9 @@ typedef struct trGlobals_s { window_t window; + fileHandle_t debugFile; + int numFramesToCapture; + int visIndex; int visClusters[MAX_VISCOUNTS]; int visCounts[MAX_VISCOUNTS]; // incremented every time a new vis cluster is entered diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index dafc80e965..888852b1f3 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -781,6 +781,46 @@ static void ComputeFogColorMask( shaderStage_t *pStage, vec4_t fogColorMask ) } } +static void CaptureDrawData(shaderCommands_t *input) +{ + if ( !tr.numFramesToCapture ) + return; + + if ( input->multiDrawPrimitives ) + { + int numIndexes = 0; + for ( int i = 0; i < input->multiDrawPrimitives; i++ ) + numIndexes += input->multiDrawNumIndexes[i]; + + const char *data = va("%d,%d,dlight,0,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,Y\n", + tr.frameCount, + backEnd.currentEntity == &tr.worldEntity ? -1 : (backEnd.currentEntity - tr.refdef.entities), + input->shader->name, 0, input->shader->sortedIndex, (int)input->shader->sort, + input->fogNum, + input->cubemapIndex, + glState.vertexAttribsState, + glState.glStateBits, + glState.currentVBO->vertexesVBO, + glState.currentIBO->indexesVBO, + numIndexes / 3); + ri->FS_Write(data, strlen(data), tr.debugFile); + } + else + { + const char *data = va("%d,%d,dlight,0,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,N\n", + tr.frameCount, + backEnd.currentEntity == &tr.worldEntity ? -1 : (backEnd.currentEntity - tr.refdef.entities), + input->shader->name, 0, input->shader->sortedIndex, (int)input->shader->sort, + input->fogNum, + input->cubemapIndex, + glState.vertexAttribsState, + glState.glStateBits, + input->vbo->vertexesVBO, + input->ibo->indexesVBO, + input->numIndexes / 3); + ri->FS_Write(data, strlen(data), tr.debugFile); + } +} static void ForwardDlight( void ) { int l; @@ -947,6 +987,8 @@ static void ForwardDlight( void ) { // draw // + CaptureDrawData(input); + if (input->multiDrawPrimitives) { R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); @@ -1241,6 +1283,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays int stateBits; colorGen_t forceRGBGen = CGEN_BAD; alphaGen_t forceAlphaGen = AGEN_IDENTITY; + int index = 0; if ( !pStage ) { @@ -1256,7 +1299,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { if (pStage->glslShaderGroup == tr.lightallShader) { - int index = 0; + index = 0; if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { @@ -1282,34 +1325,34 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } else { - int shaderAttribs = 0; + index = 0; if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) { - shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; + index |= GENERICDEF_USE_DEFORM_VERTEXES; } if (glState.vertexAnimation) { - shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; + index |= GENERICDEF_USE_VERTEX_ANIMATION; } if (glState.skeletalAnimation) { - shaderAttribs |= GENERICDEF_USE_SKELETAL_ANIMATION; + index |= GENERICDEF_USE_SKELETAL_ANIMATION; } if (pStage->stateBits & GLS_ATEST_BITS) { - shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; + index |= GENERICDEF_USE_TCGEN_AND_TCMOD; } - sp = &tr.genericShader[shaderAttribs]; + sp = &tr.genericShader[index]; } } else if (pStage->glslShaderGroup == tr.lightallShader) { - int index = pStage->glslShaderIndex; + index = pStage->glslShaderIndex; if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { @@ -1627,6 +1670,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); } + CaptureDrawData(input); + // // draw // From 1a55bd0a5741a3ff3bf287a301ab749de5fd43ca Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 29 Aug 2015 18:27:33 +0100 Subject: [PATCH 308/708] Rend2: Lightmap bundle cannot use texcoord0 --- codemp/rd-rend2/tr_shade.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 888852b1f3..d04935537b 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1241,11 +1241,7 @@ static void UpdateTexCoords ( const shaderStage_t *stage, const VertexArraysProp } case TCGEN_TEXTURE: - if (glState.vertexAttribsTexCoordOffset[1] != 0) - { - glState.vertexAttribsTexCoordOffset[1] = 0; - updateAttribs |= ATTR_TEXCOORD1; - } + assert(!"Invalid tcgen (TCGEN_TEXTURE) on lightmap bundle"); break; default: From 268268c5734998788dbfda7d04d0d531dfff1976 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 29 Aug 2015 18:28:22 +0100 Subject: [PATCH 309/708] Rend2: Detect non-animated MD3 models when drawing Animating MD3 models require extra vertex data to be sent. If the old frame and current frame are set to the same, then assume that it's not animating. --- codemp/rd-rend2/tr_surface.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index e8ddb524e8..766dcf1d3b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2076,18 +2076,21 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) refEnt = &backEnd.currentEntity->e; - if(refEnt->oldframe == refEnt->frame) + if ( refEnt->oldframe || refEnt->frame ) { - glState.vertexAttribsInterpolation = 0; - } - else - { - glState.vertexAttribsInterpolation = refEnt->backlerp; - } + if(refEnt->oldframe == refEnt->frame) + { + glState.vertexAttribsInterpolation = 0; + } + else + { + glState.vertexAttribsInterpolation = refEnt->backlerp; + } - glState.vertexAttribsOldFrame = refEnt->oldframe; - glState.vertexAttribsNewFrame = refEnt->frame; - glState.vertexAnimation = qtrue; + glState.vertexAttribsOldFrame = refEnt->oldframe; + glState.vertexAttribsNewFrame = refEnt->frame; + glState.vertexAnimation = qtrue; + } RB_EndSurface(); From 58a2f6a372a1f4169cee1a0dce4852ac12eb1a3d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 29 Aug 2015 18:36:06 +0100 Subject: [PATCH 310/708] Rend2: Fix bad copy/paste of CaptureDrawData code --- codemp/rd-rend2/tr_shade.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index d04935537b..25882650f1 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -781,7 +781,7 @@ static void ComputeFogColorMask( shaderStage_t *pStage, vec4_t fogColorMask ) } } -static void CaptureDrawData(shaderCommands_t *input) +static void CaptureDrawData(shaderCommands_t *input, shaderStage_t *stage, int glslShaderIndex, int stageIndex ) { if ( !tr.numFramesToCapture ) return; @@ -792,10 +792,11 @@ static void CaptureDrawData(shaderCommands_t *input) for ( int i = 0; i < input->multiDrawPrimitives; i++ ) numIndexes += input->multiDrawNumIndexes[i]; - const char *data = va("%d,%d,dlight,0,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,Y\n", + const char *data = va("%d,%d,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,Y\n", tr.frameCount, backEnd.currentEntity == &tr.worldEntity ? -1 : (backEnd.currentEntity - tr.refdef.entities), - input->shader->name, 0, input->shader->sortedIndex, (int)input->shader->sort, + stage->glslShaderGroup ? "lightall" : "generic", glslShaderIndex, + input->shader->name, stageIndex, input->shader->sortedIndex, (int)input->shader->sort, input->fogNum, input->cubemapIndex, glState.vertexAttribsState, @@ -807,16 +808,17 @@ static void CaptureDrawData(shaderCommands_t *input) } else { - const char *data = va("%d,%d,dlight,0,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,N\n", + const char *data = va("%d,%d,%s,%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,N\n", tr.frameCount, backEnd.currentEntity == &tr.worldEntity ? -1 : (backEnd.currentEntity - tr.refdef.entities), - input->shader->name, 0, input->shader->sortedIndex, (int)input->shader->sort, + stage->glslShaderGroup ? "lightall" : "generic", glslShaderIndex, + input->shader->name, stageIndex, input->shader->sortedIndex, (int)input->shader->sort, input->fogNum, input->cubemapIndex, glState.vertexAttribsState, glState.glStateBits, - input->vbo->vertexesVBO, - input->ibo->indexesVBO, + glState.currentVBO->vertexesVBO, + glState.currentIBO->indexesVBO, input->numIndexes / 3); ri->FS_Write(data, strlen(data), tr.debugFile); } @@ -987,7 +989,7 @@ static void ForwardDlight( void ) { // draw // - CaptureDrawData(input); + CaptureDrawData(input, pStage, 0, 0); if (input->multiDrawPrimitives) { @@ -1415,7 +1417,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays stateBits = pStage->stateBits; - if ( backEnd.currentEntity ) + if (backEnd.currentEntity) { assert(backEnd.currentEntity->e.renderfx >= 0); @@ -1666,7 +1668,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); } - CaptureDrawData(input); + CaptureDrawData(input, pStage, index, stage); // // draw From afc5dc4b1507368d8c4871d95c2320cda118f1d5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 30 Aug 2015 00:28:59 +0100 Subject: [PATCH 311/708] Rend2: Remove lightmap support from generic glsl Port of ioquake/ioq3@b1821e303 --- codemp/rd-rend2/glsl/generic_fp.glsl | 32 ------ codemp/rd-rend2/glsl/generic_vp.glsl | 9 +- codemp/rd-rend2/tr_glsl.cpp | 15 --- codemp/rd-rend2/tr_local.h | 12 +- codemp/rd-rend2/tr_shade.cpp | 12 -- codemp/rd-rend2/tr_shader.cpp | 157 +-------------------------- 6 files changed, 6 insertions(+), 231 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index a2141fbee1..b5dfa99cb8 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -1,16 +1,7 @@ uniform sampler2D u_DiffuseMap; -#if defined(USE_LIGHTMAP) -uniform sampler2D u_LightMap; -uniform int u_Texture1Env; -#endif - in vec2 var_DiffuseTex; -#if defined(USE_LIGHTMAP) -in vec2 var_LightTex; -#endif - in vec4 var_Color; out vec4 out_Color; @@ -19,29 +10,6 @@ out vec4 out_Glow; void main() { vec4 color = texture(u_DiffuseMap, var_DiffuseTex); -#if defined(USE_LIGHTMAP) - vec4 color2 = texture(u_LightMap, var_LightTex); - #if defined(RGBM_LIGHTMAP) - color2.rgb *= color2.a; - color2.a = 1.0; - #endif - - if (u_Texture1Env == TEXENV_MODULATE) - { - color *= color2; - } - else if (u_Texture1Env == TEXENV_ADD) - { - color += color2; - } - else if (u_Texture1Env == TEXENV_REPLACE) - { - color = color2; - } - - //color = color * (u_Texture1Env.xxxx + color2 * u_Texture1Env.z) + color2 * u_Texture1Env.y; -#endif - out_Color = color * var_Color; #if defined(USE_GLOW_BUFFER) diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic_vp.glsl index c025c7d4f2..481e3bfc35 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic_vp.glsl @@ -12,7 +12,7 @@ in vec4 attr_BoneWeights; in vec4 attr_Color; in vec2 attr_TexCoord0; -#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) +#if defined(USE_TCGEN) in vec2 attr_TexCoord1; #endif @@ -63,9 +63,6 @@ uniform mat4x3 u_BoneMatrices[20]; #endif out vec2 var_DiffuseTex; -#if defined(USE_LIGHTMAP) -out vec2 var_LightTex; -#endif out vec4 var_Color; #if defined(USE_DEFORM_VERTEXES) @@ -349,10 +346,6 @@ void main() var_DiffuseTex = tex; #endif -#if defined(USE_LIGHTMAP) - var_LightTex = attr_TexCoord1.st; -#endif - #if defined(USE_RGBAGEN) var_Color = CalcColor(position, normal); #else diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d7c0a11e3c..aa6a9a6c88 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -94,7 +94,6 @@ static uniformInfo_t uniformsInfo[] = { "u_EnableTextures", GLSL_VEC4, 1 }, { "u_DiffuseTexMatrix", GLSL_VEC4, 1 }, { "u_DiffuseTexOffTurb", GLSL_VEC4, 1 }, - { "u_Texture1Env", GLSL_INT, 1 }, { "u_TCGen0", GLSL_INT, 1 }, { "u_TCGen0Vector0", GLSL_VEC3, 1 }, @@ -1082,18 +1081,9 @@ int GLSL_BeginLoadGPUShaders(void) if (i & GENERICDEF_USE_RGBAGEN) Q_strcat(extradefines, 1024, "#define USE_RGBAGEN\n"); - if (i & GENERICDEF_USE_LIGHTMAP) - { - Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); - attribs |= ATTR_TEXCOORD1; - } - if (i & GENERICDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); - if (r_hdr->integer && !glRefConfig.floatLightmap) - Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); - if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, fallbackShader_generic_vp, fallbackShader_generic_fp)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); @@ -2050,11 +2040,6 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderAttribs |= GENERICDEF_USE_FOG; } - if (pStage->bundle[1].image[0] && tess.shader->multitextureEnv) - { - shaderAttribs |= GENERICDEF_USE_LIGHTMAP; - } - switch (pStage->rgbGen) { case CGEN_LIGHTING_DIFFUSE: diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 72b808b718..021aea15c8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -761,8 +761,6 @@ typedef struct shader_s { float portalRange; // distance to fog out at qboolean isPortal; - int multitextureEnv; // 0, GL_MODULATE, GL_ADD (FIXME: put in stage) - cullType_t cullType; // CT_FRONT_SIDED, CT_BACK_SIDED, or CT_TWO_SIDED qboolean polygonOffset; // set for decals and other items that must be offset qboolean noMipMaps; // for console fonts, 2D elements, etc. @@ -938,11 +936,10 @@ enum GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, GENERICDEF_USE_FOG = 0x0008, GENERICDEF_USE_RGBAGEN = 0x0010, - GENERICDEF_USE_LIGHTMAP = 0x0020, - GENERICDEF_USE_SKELETAL_ANIMATION = 0x0040, - GENERICDEF_USE_GLOW_BUFFER = 0x0080, - GENERICDEF_ALL = 0x00FF, - GENERICDEF_COUNT = 0x0100, + GENERICDEF_USE_SKELETAL_ANIMATION = 0x0020, + GENERICDEF_USE_GLOW_BUFFER = 0x0040, + GENERICDEF_ALL = 0x007F, + GENERICDEF_COUNT = 0x0080, }; enum @@ -1016,7 +1013,6 @@ typedef enum UNIFORM_DIFFUSETEXMATRIX, UNIFORM_DIFFUSETEXOFFTURB, - UNIFORM_TEXTURE1ENV, UNIFORM_TCGEN0, UNIFORM_TCGEN0VECTOR0, diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 25882650f1..ce4e26d689 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1627,16 +1627,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays else if ( pStage->bundle[1].image[0] != 0 ) { R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); - - // - // lightmap/secondary pass - // - if ( r_lightmap->integer ) { - GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, GL_REPLACE); - } else { - GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, tess.shader->multitextureEnv); - } - R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 ); } else @@ -1645,8 +1635,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // set state // R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); - - GLSL_SetUniformInt(sp, UNIFORM_TEXTURE1ENV, 0); } // diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 588db8ac30..af8a4b0dc9 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2447,150 +2447,6 @@ static void ComputeVertexAttribs(void) } } -typedef struct { - int blendA; - int blendB; - - int multitextureEnv; - int multitextureBlend; -} collapse_t; - -static collapse_t collapse[] = { - { 0, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, - GL_MODULATE, 0 }, - - { 0, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, - GL_MODULATE, 0 }, - - { GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, - GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, - - { GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, - GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, - - { GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, - GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, - - { GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO, - GL_MODULATE, GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR }, - - { 0, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, - GL_ADD, 0 }, - - { GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE, - GL_ADD, GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE }, -#if 0 - { 0, GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_SRCBLEND_SRC_ALPHA, - GL_DECAL, 0 }, -#endif - { -1 } -}; - -/* -================ -CollapseMultitexture - -Attempt to combine two stages into a single multitexture stage -FIXME: I think modulated add + modulated add collapses incorrectly -================= -*/ -static qboolean CollapseMultitexture( void ) { - int abits, bbits; - int i; - textureBundle_t tmpBundle; - - // make sure both stages are active - if ( !stages[0].active || !stages[1].active ) { - return qfalse; - } - - abits = stages[0].stateBits; - bbits = stages[1].stateBits; - - // make sure that both stages have identical state other than blend modes - if ( ( abits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) != - ( bbits & ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS | GLS_DEPTHMASK_TRUE ) ) ) { - return qfalse; - } - - abits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - bbits &= ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - - // search for a valid multitexture blend function - for ( i = 0; collapse[i].blendA != -1 ; i++ ) { - if ( abits == collapse[i].blendA - && bbits == collapse[i].blendB ) { - break; - } - } - - // nothing found - if ( collapse[i].blendA == -1 ) { - return qfalse; - } - - // GL_ADD is a separate extension - if ( collapse[i].multitextureEnv == GL_ADD && !glConfig.textureEnvAddAvailable ) { - return qfalse; - } - - // make sure waveforms have identical parameters - if ( ( stages[0].rgbGen != stages[1].rgbGen ) || - ( stages[0].alphaGen != stages[1].alphaGen ) ) { - return qfalse; - } - - // an add collapse can only have identity colors - if ( collapse[i].multitextureEnv == GL_ADD && stages[0].rgbGen != CGEN_IDENTITY ) { - return qfalse; - } - - if ( stages[0].rgbGen == CGEN_WAVEFORM ) - { - if ( memcmp( &stages[0].rgbWave, - &stages[1].rgbWave, - sizeof( stages[0].rgbWave ) ) ) - { - return qfalse; - } - } - if ( stages[0].alphaGen == AGEN_WAVEFORM ) - { - if ( memcmp( &stages[0].alphaWave, - &stages[1].alphaWave, - sizeof( stages[0].alphaWave ) ) ) - { - return qfalse; - } - } - - - // make sure that lightmaps are in bundle 1 for 3dfx - if ( stages[0].bundle[0].isLightmap ) - { - tmpBundle = stages[0].bundle[0]; - stages[0].bundle[0] = stages[1].bundle[0]; - stages[0].bundle[1] = tmpBundle; - } - else - { - stages[0].bundle[1] = stages[1].bundle[0]; - } - - // set the new blend state bits - shader.multitextureEnv = collapse[i].multitextureEnv; - stages[0].stateBits &= ~( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - stages[0].stateBits |= collapse[i].multitextureBlend; - - // - // move down subsequent shaders - // - memmove( &stages[1], &stages[2], sizeof( stages[0] ) * ( MAX_SHADER_STAGES - 2 ) ); - Com_Memset( &stages[MAX_SHADER_STAGES-1], 0, sizeof( stages[0] ) ); - - return qtrue; -} - static void CollapseStagesToLightall(shaderStage_t *diffuse, shaderStage_t *normal, shaderStage_t *specular, shaderStage_t *lightmap, qboolean useLightVector, qboolean useLightVertex, qboolean parallax, qboolean tcgen) @@ -2977,9 +2833,6 @@ static qboolean CollapseStagesToGLSL(void) numStages++; } - if (numStages == i && i >= 2 && CollapseMultitexture()) - numStages--; - // convert any remaining lightmap stages to a lighting pass with a white texture // only do this with r_sunlightMode non-zero, as it's only for correct shadows. if (r_sunlightMode->integer && shader.numDeforms == 0) @@ -4283,15 +4136,7 @@ void R_ShaderList_f (void) { } else { ri->Printf (PRINT_ALL, " "); } - if ( shader->multitextureEnv == GL_ADD ) { - ri->Printf( PRINT_ALL, "MT(a) " ); - } else if ( shader->multitextureEnv == GL_MODULATE ) { - ri->Printf( PRINT_ALL, "MT(m) " ); - } else if ( shader->multitextureEnv == GL_DECAL ) { - ri->Printf( PRINT_ALL, "MT(d) " ); - } else { - ri->Printf( PRINT_ALL, " " ); - } + if ( shader->explicitlyDefined ) { ri->Printf( PRINT_ALL, "E " ); } else { From 9467e75dd194b680930c9a7005a60e59200eb932 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 30 Aug 2015 12:30:06 +0100 Subject: [PATCH 312/708] Rend2: Remove display list code --- codemp/rd-rend2/tr_local.h | 7 ------- codemp/rd-rend2/tr_surface.cpp | 7 ------- 2 files changed, 14 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 021aea15c8..132682eb03 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1222,7 +1222,6 @@ typedef enum { SF_MDX, SF_FLARE, SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity - SF_DISPLAY_LIST, SF_VBO_MESH, SF_VBO_MDVMESH, @@ -1276,12 +1275,6 @@ typedef struct srfPoly_s { polyVert_t *verts; } srfPoly_t; -typedef struct srfDisplayList_s { - surfaceType_t surfaceType; - int listNum; -} srfDisplayList_t; - - typedef struct srfFlare_s { surfaceType_t surfaceType; vec3_t origin; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 766dcf1d3b..b8c1b3e9a5 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2098,12 +2098,6 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) glState.vertexAnimation = qfalse; } -static void RB_SurfaceDisplayList( srfDisplayList_t *surf ) { - // all apropriate state must be set in RB_BeginSurface - // this isn't implemented yet... - qglCallList( surf->listNum ); -} - static void RB_SurfaceSkip( void *surf ) { } @@ -2121,7 +2115,6 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceGhoul, // SF_MDX, (void(*)(void*))RB_SurfaceFlare, // SF_FLARE, (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY - (void(*)(void*))RB_SurfaceDisplayList, // SF_DISPLAY_LIST (void(*)(void*))RB_SurfaceVBOMesh, // SF_VBO_MESH, (void(*)(void*))RB_SurfaceVBOMDVMesh, // SF_VBO_MDVMESH }; From ab4a01d2a9f40e2df514a1e8ccb6874c9c751bff Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Sep 2015 17:02:17 +0100 Subject: [PATCH 313/708] Rend2: Add GPU timers. This commit also adds support sync objects and timer queries. --- codemp/rd-rend2/qgl.h | 11 +++ codemp/rd-rend2/tr_backend.cpp | 57 ++++++++++++++++ codemp/rd-rend2/tr_cmds.cpp | 107 ++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_extensions.cpp | 32 +++++++++ codemp/rd-rend2/tr_init.cpp | 46 ++++++++++++- codemp/rd-rend2/tr_local.h | 49 +++++++++++++- codemp/rd-rend2/tr_scene.cpp | 14 ++++ 7 files changed, 312 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 9e590d87ba..5a66259a76 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -558,6 +558,12 @@ extern PFNGLGETQUERYIVPROC qglGetQueryiv; extern PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; extern PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; +// Sync objects and fences +extern PFNGLFENCESYNCPROC qglFenceSync; +extern PFNGLDELETESYNCPROC qglDeleteSync; +extern PFNGLCLIENTWAITSYNCPROC qglClientWaitSync; +extern PFNGLWAITSYNCPROC qglWaitSync; + #ifndef GL_EXT_texture_compression_latc #define GL_EXT_texture_compression_latc #define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 @@ -590,3 +596,8 @@ extern PFNGLDEBUGMESSAGECONTROLARBPROC qglDebugMessageControlARB; extern PFNGLDEBUGMESSAGEINSERTARBPROC qglDebugMessageInsertARB; extern PFNGLDEBUGMESSAGECALLBACKARBPROC qglDebugMessageCallbackARB; extern PFNGLGETDEBUGMESSAGELOGARBPROC qglGetDebugMessageLogARB; + +// GL_ARB_timer_query +extern PFNGLQUERYCOUNTERPROC qglQueryCounter; +extern PFNGLGETQUERYOBJECTI64VPROC qglGetQueryObjecti64v; +extern PFNGLGETQUERYOBJECTUI64VPROC qglGetQueryObjectui64v; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 36423950ca..57ada04d30 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1707,6 +1707,14 @@ static const void *RB_SwapBuffers( const void *data ) { } } + int frameNumber = backEndData->realFrameNumber; + gpuFrame_t *currentFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; + + assert( !currentFrame->sync ); + currentFrame->sync = qglFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 ); + + backEndData->realFrameNumber = frameNumber + 1; + GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); ri->WIN_Present( &window ); @@ -1935,6 +1943,49 @@ const void *RB_PostProcess(const void *data) return (const void *)(cmd + 1); } +static const void *RB_BeginTimedBlock( const void *data ) +{ + const beginTimedBlockCommand_t *cmd = (const beginTimedBlockCommand_t *)data; + if ( glRefConfig.timerQuery ) + { + gpuFrame_t *currentFrame = &backEndData->frames[backEndData->realFrameNumber % MAX_FRAMES]; + gpuTimer_t *timer = currentFrame->timers + currentFrame->numTimers++; + + if ( cmd->timerHandle >= 0 && currentFrame->numTimers <= MAX_GPU_TIMERS ) + { + gpuTimedBlock_t *timedBlock = currentFrame->timedBlocks + cmd->timerHandle; + timedBlock->beginTimer = timer->queryName; + timedBlock->name = cmd->name; + + currentFrame->numTimedBlocks++; + + qglQueryCounter( timer->queryName, GL_TIMESTAMP ); + } + } + + return (const void *)(cmd + 1); +} + +static const void *RB_EndTimedBlock( const void *data ) +{ + const endTimedBlockCommand_t *cmd = (const endTimedBlockCommand_t *)data; + if ( glRefConfig.timerQuery ) + { + gpuFrame_t *currentFrame = &backEndData->frames[backEndData->realFrameNumber % MAX_FRAMES]; + gpuTimer_t *timer = currentFrame->timers + currentFrame->numTimers++; + + if ( cmd->timerHandle >= 0 && currentFrame->numTimers <= MAX_GPU_TIMERS ) + { + gpuTimedBlock_t *timedBlock = currentFrame->timedBlocks + cmd->timerHandle; + timedBlock->endTimer = timer->queryName; + + qglQueryCounter( timer->queryName, GL_TIMESTAMP ); + } + } + + return (const void *)(cmd + 1); +} + /* ==================== @@ -1989,6 +2040,12 @@ void RB_ExecuteRenderCommands( const void *data ) { case RC_POSTPROCESS: data = RB_PostProcess(data); break; + case RC_BEGIN_TIMED_BLOCK: + data = RB_BeginTimedBlock(data); + break; + case RC_END_TIMED_BLOCK: + data = RB_EndTimedBlock(data); + break; case RC_END_OF_LIST: default: // finish any 2D drawing if needed diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index cadc75885c..e29c96ce0b 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -27,10 +27,14 @@ R_PerformanceCounters ===================== */ void R_PerformanceCounters( void ) { + gpuFrame_t *currentFrame = backEndData->frames + (backEndData->realFrameNumber % MAX_FRAMES); + if ( !r_speeds->integer ) { // clear the counters even if we aren't printing Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); + currentFrame->numTimedBlocks = 0; + currentFrame->numTimers = 0; return; } @@ -89,9 +93,41 @@ void R_PerformanceCounters( void ) { backEnd.pc.c_triangleCountBins[TRI_BIN_2000_2999], backEnd.pc.c_triangleCountBins[TRI_BIN_3000_PLUS]); } + else if ( r_speeds->integer == 100 ) + { + gpuFrame_t *frame = backEndData->frames + (backEndData->realFrameNumber % MAX_FRAMES); + + // TODO: We want to draw this as text on the screen... + // Print to console for now + + int numTimedBlocks = frame->numTimedBlocks; + for ( int i = 0; i < numTimedBlocks; i++ ) + { + gpuTimedBlock_t *timedBlock = frame->timedBlocks + i; + GLuint64 startTime, endTime, diffInNs; + float diffInMs; + + qglGetQueryObjectui64v( timedBlock->beginTimer, GL_QUERY_RESULT, &startTime); + qglGetQueryObjectui64v( timedBlock->endTimer, GL_QUERY_RESULT, &endTime); + + diffInNs = endTime - startTime; + diffInMs = diffInNs / 1e6f; + + ri->Printf( PRINT_ALL, "%s: %.3fms ", timedBlock->name, diffInMs ); + + if ( (i % 7) == 6 ) + { + ri->Printf( PRINT_ALL, "\n" ); + } + } + + ri->Printf( PRINT_ALL, "\n" ); + } Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); Com_Memset( &backEnd.pc, 0, sizeof( backEnd.pc ) ); + currentFrame->numTimedBlocks = 0; + currentFrame->numTimers = 0; } @@ -227,6 +263,47 @@ void R_AddPostProcessCmd( ) { cmd->viewParms = tr.viewParms; } +qhandle_t R_BeginTimedBlockCmd( const char *name ) +{ + beginTimedBlockCommand_t *cmd; + + cmd = (beginTimedBlockCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) + { + return (qhandle_t)-1; + } + + if ( tr.numTimedBlocks >= (MAX_GPU_TIMERS / 2) ) + { + return (qhandle_t)-1; + } + + cmd->commandId = RC_BEGIN_TIMED_BLOCK; + cmd->name = name; + cmd->timerHandle = tr.numTimedBlocks++; + + return (qhandle_t)cmd->timerHandle; +} + +void R_EndTimedBlockCmd( qhandle_t timerHandle ) +{ + endTimedBlockCommand_t *cmd; + + cmd = (endTimedBlockCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); + if ( !cmd ) + { + return; + } + + if ( cmd->timerHandle == -1 ) + { + return; + } + + cmd->commandId = RC_END_TIMED_BLOCK; + cmd->timerHandle = timerHandle; +} + /* ============= RE_SetColor @@ -397,6 +474,36 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { return; } + int frameNumber = backEndData->realFrameNumber; + gpuFrame_t *thisFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; + if ( thisFrame->sync ) + { + GLsync sync = thisFrame->sync; + GLenum result = qglClientWaitSync( sync, 0, 0 ); + if ( result != GL_ALREADY_SIGNALED ) + { + ri->Printf( PRINT_DEVELOPER, "OpenGL: GPU is more than %d frames behind! Waiting for this frame to finish...\n", MAX_FRAMES ); + + static const GLuint64 HALF_SECOND = 500 * 1000 * 1000; + do + { + result = qglClientWaitSync( sync, GL_SYNC_FLUSH_COMMANDS_BIT, HALF_SECOND); + if ( result == GL_WAIT_FAILED ) + { + // FIXME: Doesn't this mean the frame will never render? + qglDeleteSync( sync ); + thisFrame->sync = NULL; + + ri->Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); + return; + } + } + while ( result != GL_ALREADY_SIGNALED && result != GL_CONDITION_SATISFIED ); + } + qglDeleteSync( sync ); + thisFrame->sync = NULL; + } + tr.frameCount++; tr.frameSceneNum = 0; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 514ce7a812..b211510478 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -201,6 +201,12 @@ PFNGLGETQUERYIVPROC qglGetQueryiv; PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; +// Sync objects and fences +PFNGLFENCESYNCPROC qglFenceSync; +PFNGLDELETESYNCPROC qglDeleteSync; +PFNGLCLIENTWAITSYNCPROC qglClientWaitSync; +PFNGLWAITSYNCPROC qglWaitSync; + // GL_ARB_texture_storage PFNGLTEXSTORAGE1DPROC qglTexStorage1D; PFNGLTEXSTORAGE2DPROC qglTexStorage2D; @@ -215,6 +221,11 @@ PFNGLDEBUGMESSAGEINSERTARBPROC qglDebugMessageInsertARB; PFNGLDEBUGMESSAGECALLBACKARBPROC qglDebugMessageCallbackARB; PFNGLGETDEBUGMESSAGELOGARBPROC qglGetDebugMessageLogARB; +// GL_ARB_timer_query +PFNGLQUERYCOUNTERPROC qglQueryCounter; +PFNGLGETQUERYOBJECTI64VPROC qglGetQueryObjecti64v; +PFNGLGETQUERYOBJECTUI64VPROC qglGetQueryObjectui64v; + static qboolean GLimp_HaveExtension(const char *ext) { const char *ptr = Q_stristr( glConfigExt.originalExtensionString, ext ); @@ -477,6 +488,12 @@ void GLimp_InitExtensions() GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv", qtrue); GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv", qtrue); + // Sync objects and fences + GetGLFunction (qglFenceSync, "glFenceSync", qtrue); + GetGLFunction (qglDeleteSync, "glDeleteSync", qtrue); + GetGLFunction (qglClientWaitSync, "glClientWaitSync", qtrue); + GetGLFunction (qglWaitSync, "glWaitSync", qtrue); + Com_Printf ("Initializing OpenGL extensions\n" ); // Select our tc scheme @@ -616,6 +633,21 @@ void GLimp_InitExtensions() ri->Printf(PRINT_ALL, result[loaded], extension); } + // GL_ARB_timer_query + extension = "GL_ARB_timer_query"; + if ( GLimp_HaveExtension( extension ) ) + { + qboolean loaded = qtrue; + + loaded = (qboolean)(loaded && GetGLFunction(qglQueryCounter, "glQueryCounter", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction(qglGetQueryObjecti64v, "glGetQueryObjecti64v", qfalse)); + loaded = (qboolean)(loaded && GetGLFunction(qglGetQueryObjectui64v, "glGetQueryObjectui64v", qfalse)); + + glRefConfig.timerQuery = loaded; + + ri->Printf(PRINT_ALL, result[loaded], extension); + } + // use float lightmaps? glRefConfig.floatLightmap = (qboolean)(r_floatLightmap->integer && r_hdr->integer); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 6af2a13c7e..9d1658d876 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1546,15 +1546,50 @@ void R_ShutDownQueries(void) void RE_SetLightStyle (int style, int color); +static void R_InitBackEndFrameData() +{ + GLuint timerQueries[MAX_GPU_TIMERS*MAX_FRAMES]; + qglGenQueries(MAX_GPU_TIMERS*MAX_FRAMES, timerQueries); + + for ( int i = 0; i < MAX_FRAMES; i++ ) + { + gpuFrame_t *frame = backEndData->frames + i; + + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) + { + gpuTimer_t *timer = frame->timers + j; + timer->queryName = timerQueries[i*MAX_GPU_TIMERS + j]; + } + } +} + +static void R_ShutdownBackEndFrameData() +{ + if ( !backEndData ) + return; + + for ( int i = 0; i < MAX_FRAMES; i++ ) + { + gpuFrame_t *frame = backEndData->frames + i; + + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) + { + gpuTimer_t *timer = frame->timers + j; + Com_Printf( "Deleting query %d\n", timer->queryName ); + qglDeleteQueries(1, &timer->queryName); + } + } +} + /* =============== R_Init =============== */ void R_Init( void ) { - int i; byte *ptr; - + int i; + ri->Printf( PRINT_ALL, "----- R_Init -----\n" ); // clear all our internal state @@ -1603,6 +1638,7 @@ void R_Init( void ) { backEndData = (backEndData_t *) ptr; backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); + R_InitNextFrame(); for ( int i = 0; i < MAX_LIGHT_STYLES; i++ ) @@ -1614,6 +1650,7 @@ void R_Init( void ) { InitOpenGL(); + R_InitBackEndFrameData(); R_InitImages(); FBO_Init(); @@ -1654,13 +1691,15 @@ void R_Init( void ) { RE_Shutdown =============== */ -void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { +void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); for ( size_t i = 0; i < numCommands; i++ ) ri->Cmd_RemoveCommand( commands[i].cmd ); + R_ShutdownBackEndFrameData(); + R_ShutdownFonts(); if ( tr.registered ) { R_IssuePendingRenderCommands(); @@ -1682,6 +1721,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { } tr.registered = qfalse; + backEndData = NULL; } /* diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 132682eb03..406004ed78 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1830,6 +1830,7 @@ typedef struct { qboolean immutableBuffers; qboolean debugContext; + qboolean timerQuery; qboolean floatLightmap; } glRefConfig_t; @@ -2060,6 +2061,8 @@ typedef struct trGlobals_s { frontEndCounters_t pc; int frontEndMsec; // not in pc due to clearing issue + int numTimedBlocks; + // // put large tables at the end, so most elements will be // within the +/32K indexed range on risc processors @@ -2984,6 +2987,17 @@ typedef struct postProcessCommand_s { viewParms_t viewParms; } postProcessCommand_t; +typedef struct beginTimedBlockCommand_s { + int commandId; + qhandle_t timerHandle; + const char *name; +} beginTimedBlockCommand_t; + +typedef struct endTimedBlockCommand_s { + int commandId; + qhandle_t timerHandle; +} endTimedBlockCommand_t; + typedef enum { RC_END_OF_LIST, RC_SET_COLOR, @@ -2998,13 +3012,43 @@ typedef enum { RC_COLORMASK, RC_CLEARDEPTH, RC_CAPSHADOWMAP, - RC_POSTPROCESS + RC_POSTPROCESS, + RC_BEGIN_TIMED_BLOCK, + RC_END_TIMED_BLOCK } renderCommand_t; +struct gpuTimer_t +{ + const char *name; + GLuint queryName; +}; + +struct gpuTimedBlock_t +{ + const char *name; + GLuint beginTimer; + GLuint endTimer; +}; + +#define MAX_GPU_TIMERS (512) +struct gpuFrame_t +{ + GLsync sync; + + int numTimers; + int numTimedBlocks; + + gpuTimer_t timers[MAX_GPU_TIMERS]; + gpuTimedBlock_t timedBlocks[MAX_GPU_TIMERS / 2]; // Each block will need 2 timer queries. +}; // all of the information needed by the back end must be // contained in a backEndData_t. +#define MAX_FRAMES (2) typedef struct backEndData_s { + unsigned realFrameNumber; + gpuFrame_t frames[MAX_FRAMES]; + drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; trRefEntity_t entities[MAX_REFENTITIES]; @@ -3028,6 +3072,9 @@ void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); void R_AddCapShadowmapCmd( int dlight, int cubeSide ); void R_AddPostProcessCmd (void); +qhandle_t R_BeginTimedBlockCmd( const char *name ); +void R_EndTimedBlockCmd( qhandle_t timerHandle ); + void RE_SetColor( const float *rgba ); void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 6714020325..09a5bb03a3 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -45,6 +45,8 @@ R_InitNextFrame void R_InitNextFrame( void ) { backEndData->commands.used = 0; + tr.numTimedBlocks = 0; + r_firstSceneDrawSurf = 0; r_numdlights = 0; @@ -494,21 +496,27 @@ void RE_RenderScene( const refdef_t *fd ) { // SmileTheory: playing with shadow mapping if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2) { + qhandle_t timer = R_BeginTimedBlockCmd( "Dlight cubemaps" ); R_RenderDlightCubemaps(fd); + R_EndTimedBlockCmd( timer ); } /* playing with more shadows */ if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) { + qhandle_t timer = R_BeginTimedBlockCmd( "PShadow Maps" ); R_RenderPshadowMaps(fd); + R_EndTimedBlockCmd( timer ); } // playing with even more shadows if(r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) { + qhandle_t timer = R_BeginTimedBlockCmd( "Shadow cascades" ); R_RenderSunShadowMaps(fd, 0); R_RenderSunShadowMaps(fd, 1); R_RenderSunShadowMaps(fd, 2); + R_EndTimedBlockCmd( timer ); } // playing with cube maps @@ -556,10 +564,16 @@ void RE_RenderScene( const refdef_t *fd ) { parms.flags = VPF_USESUNLIGHT; } + qhandle_t timer = R_BeginTimedBlockCmd( "Main Render" ); R_RenderView( &parms ); + R_EndTimedBlockCmd( timer ); if(!( fd->rdflags & RDF_NOWORLDMODEL )) + { + qhandle_t timer = R_BeginTimedBlockCmd( "Post processing" ); R_AddPostProcessCmd(); + R_EndTimedBlockCmd( timer ); + } RE_EndScene(); From 4eb702dac4c3faa8e1a7f3f9f9ad32a01831a1a8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 15 Sep 2015 21:10:13 +0100 Subject: [PATCH 314/708] Rend2: Fix segfault on map change Problem first occurred in 353143bea. On map change, the renderer is restarted but some contents in the glState variable are not cleared so they retain the values from before the restart. This can cause some state not to be set. --- codemp/rd-rend2/tr_init.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 9d1658d876..cffb34823a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1074,20 +1074,17 @@ void GL_SetDefaultState( void ) //qglShadeModel( GL_SMOOTH ); qglDepthFunc( GL_LEQUAL ); + Com_Memset(&glState, 0, sizeof(glState)); + // // make sure our GL state vector is set correctly // glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE; - glState.vertexAttribsState = 0; - glState.vertexAttribPointersSet = 0; - glState.currentProgram = 0; qglUseProgram(0); qglBindBuffer(GL_ARRAY_BUFFER, 0); qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glState.currentVBO = NULL; - glState.currentIBO = NULL; qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL); qglDepthMask( GL_TRUE ); From 7d5aa600fc4eb707d381ea6fd2c418e2c42c7866 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 15 Sep 2015 23:24:22 +0100 Subject: [PATCH 315/708] Rend2: Correctly sort shaders by number of stages --- codemp/rd-rend2/tr_shader.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index af8a4b0dc9..e683f9fb33 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3018,20 +3018,21 @@ static void SortNewShader( void ) { numStagesInNewShader++; for ( i = tr.numShaders - 2 ; i >= 0 ; i-- ) { + shader_t *shader = tr.sortedShaders[i]; int numStages = 0; - while ( tr.sortedShaders[numStages] ) + while ( shader->stages[numStages] ) numStages++; - if ( tr.sortedShaders[ i ]->sort < sort ) { + if ( shader->sort < sort ) { break; } - if ( tr.sortedShaders[ i ]->sort == sort && numStages <= numStagesInNewShader ) + if ( shader->sort == sort && numStages <= numStagesInNewShader ) { break; } - tr.sortedShaders[i+1] = tr.sortedShaders[i]; + tr.sortedShaders[i+1] = shader; tr.sortedShaders[i+1]->sortedIndex++; } From d0638bb3131f613b78edbbfa5b17fae50fff7915 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 18 Sep 2015 19:13:10 +0100 Subject: [PATCH 316/708] Rend2: Start on surface sprites --- codemp/rd-rend2/tr_local.h | 57 +++++- codemp/rd-rend2/tr_shade.cpp | 12 +- codemp/rd-rend2/tr_shader.cpp | 338 ++++++++++++++++++++++++++++++++- codemp/rd-rend2/tr_surface.cpp | 5 + 4 files changed, 403 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 406004ed78..6250838409 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -667,6 +667,49 @@ typedef enum ST_GLSL } stageType_t; +enum surfaceSpriteType_t +{ + SS_TYPE_VERTICAL, + SS_TYPE_BILLBOARD, + SS_TYPE_EFFECT, + SS_TYPE_FLATTENED, + SS_TYPE_WEATHER, +}; + +enum surfaceSpriteOrientation_t +{ + SS_ORIENTATION_NORMAL, + SS_ORIENTATION_UP, + SS_ORIENTATION_DOWN, + SS_ORIENTATION_ANY, +}; + +struct surfaceSprite_t +{ + surfaceSpriteType_t type; + surfaceSpriteOrientation_t orientation; + + float width; + float height; + float density; + float fadeDistance; + + float maxFadeDistance; + float fadeScale; + float widthVariance; + float heightVariance; + + float windStrength; + float idleWindStrength; + float verticalSkew; + + float fxDuration; + float fxGrowWidth; + float fxGrowHeight; + float fxStartAlpha; + float fxEndAlpha; +}; + // any change in the LIGHTMAP_* defines here MUST be reflected in // R_FindShader() in tr_bsp.c #define LIGHTMAP_2D -4 // shader is for 2D rendering @@ -702,7 +745,7 @@ typedef struct { vec4_t normalScale; vec4_t specularScale; - qboolean isSurfaceSprite; + surfaceSprite_t *surfaceSprite; } shaderStage_t; @@ -1224,6 +1267,7 @@ typedef enum { SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity SF_VBO_MESH, SF_VBO_MDVMESH, + SF_SURFACE_SPRITES, SF_NUM_SURFACE_TYPES, SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) @@ -1408,6 +1452,17 @@ typedef struct srfVBOMDVMesh_s IBO_t *ibo; } srfVBOMDVMesh_t; +struct srfSprites_t +{ + surfaceType_t surfaceType; + + surfaceSprite_t *spriteData; + + int numSprites; + + // ubo containing positions +}; + extern void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])(void *); /* diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ce4e26d689..4869eef6a2 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1288,7 +1288,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays break; } - if ( pStage->isSurfaceSprite ) + if ( pStage->surfaceSprite ) { continue; } @@ -1895,6 +1895,16 @@ void RB_StageIteratorGeneric( void ) { qglDisable( GL_POLYGON_OFFSET_FILL ); } + + // Draw surface sprites + for ( int i = 0; i < input->shader->numUnfoggedPasses; i++ ) + { + shaderStage_t *stage = input->shader->stages[i]; + if ( stage->surfaceSprite ) + { + // Draw surface sprites + } + } } void RB_BinTriangleCounts( void ) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e683f9fb33..a4696ae2d1 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -700,6 +700,333 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) } } +static void InitSurfaceSprite( surfaceSprite_t *surfaceSprite ) +{ + *surfaceSprite = {}; + + surfaceSprite->fadeDistance = 1.33f; + surfaceSprite->fxDuration = 1000.0f; +} + +// surfaceSprites +static void ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) +{ + const char *token; + const char **text = &buffer; + surfaceSprite_t surfaceSprite; + + InitSurfaceSprite( &surfaceSprite ); + + // + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites 'type' param in shader '%s'\n", shader.name ); + return; + } + + if ( !Q_stricmp( token, "vertical" ) ) + surfaceSprite.type = SS_TYPE_VERTICAL; + else if ( !Q_stricmp( token, "oriented" ) ) + surfaceSprite.type = SS_TYPE_BILLBOARD; + else if ( !Q_stricmp( token, "effect" ) ) + surfaceSprite.type = SS_TYPE_EFFECT; + else if ( !Q_stricmp( token, "flattened" ) ) + surfaceSprite.type = SS_TYPE_FLATTENED; + else + { + surfaceSprite.type = SS_TYPE_VERTICAL; + ri->Printf( PRINT_ALL, S_COLOR_YELLOW, "WARNING: unknown surfaceSprites 'type' given (%s). Defaulting to 'vertical'.\n", token ); + } + + // + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites 'width' param in shader '%s'\n", shader.name ); + return; + } + surfaceSprite.width = atof( token ); + + // + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites 'height' param in shader '%s'\n", shader.name ); + return; + } + surfaceSprite.height = atof( token ); + + // + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites 'density' param in shader '%s'\n", shader.name ); + return; + } + surfaceSprite.density = atof( token ); + + // + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites 'fade distance' param in shader '%s'\n", shader.name ); + return; + } + surfaceSprite.fadeDistance = atof( token ); + + if ( !stage->surfaceSprite ) + { + stage->surfaceSprite = (surfaceSprite_t *)Hunk_Alloc( sizeof(*stage->surfaceSprite), h_low ); + } + + *stage->surfaceSprite = surfaceSprite; +} + +// +// ssFadeMax +// ssFadeScale +// ssVariance +// ssHangdown +// ssFaceup +// ssAnyAngle +// ssWind +// ssWindIdle +// ssVertSkew +// ssFXDuration +// ssFXGrow +// ssFXAlphaRange +// ssWeather +// +static void ParseSurfaceSpriteOptions( const char *keyword, const char *buffer, shaderStage_t *stage ) +{ + const char *token; + const char **text = &keyword; + float value; + surfaceSprite_t *surfaceSprite = stage->surfaceSprite; + + if ( !surfaceSprite ) + { + stage->surfaceSprite = (surfaceSprite_t *)Hunk_Alloc( sizeof(*stage->surfaceSprite), h_low ); + InitSurfaceSprite( stage->surfaceSprite ); + surfaceSprite = stage->surfaceSprite; + } + + if ( !Q_stricmp( keyword, "ssFadeMax" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFadeMax missing value in shader '%s'\n", shader.name ); + return; + } + value = atof( token ); + + if ( value <= surfaceSprite->fadeDistance ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFadeMax value (%.2f) less than or equal to fade distance (%.2f) in shader '%s'.\n", value, stage->surfaceSprite->fadeDistance, shader.name ); + return; + } + + surfaceSprite->maxFadeDistance = value; + } + else if ( !Q_stricmp( keyword, "ssFadeScale" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFadeScale missing value in shader '%s'\n", shader.name ); + return; + } + surfaceSprite->fadeScale = atof( token ); + } + else if ( !Q_stricmp( keyword, "ssVariance" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssVariance missing 'width variance' in shader '%s'\n", shader.name ); + return; + } + surfaceSprite->widthVariance = atof( token ); + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssVariance missing 'height variance' in shader '%s'\n", shader.name ); + return; + } + surfaceSprite->heightVariance = atof( token ); + } + else if ( !Q_stricmp( keyword, "ssHangdown" ) ) + { + surfaceSprite->orientation = SS_ORIENTATION_DOWN; + } + else if ( !Q_stricmp( keyword, "ssFaceup" ) ) + { + surfaceSprite->orientation = SS_ORIENTATION_UP; + } + else if ( !Q_stricmp( keyword, "ssAnyAngle" ) ) + { + surfaceSprite->orientation = SS_ORIENTATION_ANY; + } + else if ( !Q_stricmp( keyword, "ssWind" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssWind missing value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssWind value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->windStrength = value; + + if ( surfaceSprite->idleWindStrength <= 0.0f ) + { + surfaceSprite->idleWindStrength = value; + } + } + else if ( !Q_stricmp( keyword, "ssWindIdle" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssWindIdle missing value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssWindIdle value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->idleWindStrength = value; + } + else if ( !Q_stricmp( keyword, "ssVertSkew" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssVertSkew missing value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssVertSkew value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->verticalSkew = value; + } + else if ( !Q_stricmp( keyword, "ssFXDuration" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXDuration missing value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXDuration value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->fxDuration = value; + } + else if ( !Q_stricmp( keyword, "ssFXGrow" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXGrow missing 'grow width' value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXGrow 'grow width' value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->fxGrowWidth = value; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXGrow missing 'grow height' value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXGrow 'grow height' value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + surfaceSprite->fxGrowHeight = value; + } + else if ( !Q_stricmp( keyword, "ssFXAlphaRange" ) ) + { + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange missing 'start alpha' value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange 'start alpha' value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + else if ( value > 1.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange 'start alpha' value is greater than 1 in shader '%s'. Clamping to 1.\n", shader.name ); + value = 1.0f; + } + surfaceSprite->fxStartAlpha = value; + + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange missing 'end alpha' value in shader '%s'\n", shader.name ); + return; + } + + value = atof( token ); + if ( value < 0.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange 'end alpha' value is less than 0 in shader '%s'. Clamping to 0.\n", shader.name ); + value = 0.0f; + } + else if ( value > 1.0f ) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: ssFXAlphaRange 'end alpha' value is greater than 1 in shader '%s'. Clamping to 1.\n", shader.name ); + value = 1.0f; + } + surfaceSprite->fxEndAlpha = value; + } + else if ( !Q_stricmp( keyword, "ssWeather" ) ) + { + surfaceSprite->type = SS_TYPE_WEATHER; + } + else + { + ri->Printf( PRINT_ALL, "WARNING: invalid shader keyword '%s' in shader '%s'.\n", keyword, shader.name ); + } +} + static animMapType_t AnimMapType( const char *token ) { if ( !Q_stricmp( token, "clampanimMap" ) ) { return ANIMMAP_CLAMP; } @@ -1474,9 +1801,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "surfaceSprites" ) ) { // Mark this stage as a surface sprite so we can skip it for now - stage->isSurfaceSprite = qtrue; - SkipRestOfLine( text ); - /*char buffer[1024] = ""; + char buffer[1024] = {}; while ( 1 ) { @@ -1487,7 +1812,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strcat( buffer, sizeof( buffer ), " " ); } - ParseSurfaceSprites( buffer, stage );*/ + ParseSurfaceSprites( buffer, stage ); continue; } @@ -1506,8 +1831,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if (!Q_stricmpn(token, "ss", 2)) // <--- NOTE ONLY COMPARING FIRST TWO LETTERS { - SkipRestOfLine( text ); - /*char buffer[1024] = ""; + char buffer[1024] = ""; char param[128]; strcpy(param,token); @@ -1520,7 +1844,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strcat( buffer, sizeof( buffer ), " " ); } - ParseSurfaceSpritesOptional( param, buffer, stage );*/ + ParseSurfaceSpriteOptions( param, buffer, stage ); continue; } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b8c1b3e9a5..df88153ab0 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2098,6 +2098,10 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) glState.vertexAnimation = qfalse; } +static void RB_SurfaceSprites( void *surfaceSprites ) +{ +} + static void RB_SurfaceSkip( void *surf ) { } @@ -2117,4 +2121,5 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY (void(*)(void*))RB_SurfaceVBOMesh, // SF_VBO_MESH, (void(*)(void*))RB_SurfaceVBOMDVMesh, // SF_VBO_MDVMESH + (void(*)(void*))RB_SurfaceSprites, // SF_SURFACE_SPRITES }; From 8c8784c6c46b1fa8433ca09410ba4a69bed7015b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 7 Feb 2016 13:55:29 +0000 Subject: [PATCH 317/708] Fix rend2 on OSX. Disabled alpha testing for now --- codemp/rd-rend2/qgl.h | 6 ++-- codemp/rd-rend2/tr_backend.cpp | 36 ++------------------ codemp/rd-rend2/tr_flares.cpp | 6 ++-- codemp/rd-rend2/tr_glsl.cpp | 20 ++--------- codemp/rd-rend2/tr_image.cpp | 61 +++++++--------------------------- codemp/rd-rend2/tr_init.cpp | 61 ++++++++++++++++++++++++---------- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shadows.cpp | 6 ++-- codemp/rd-rend2/tr_vbo.cpp | 37 ++++++++++++++++++++- 9 files changed, 105 insertions(+), 130 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 5a66259a76..4af9d5217e 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -6,9 +6,7 @@ # include # include #elif defined(MACOS_X) -// Prevent OS X from including its own out-of-date glext.h -# define GL_GLEXT_LEGACY -# include +# include #elif defined( __linux__ ) # include # include @@ -29,7 +27,7 @@ #include "glext.h" #define qglAccum glAccum -#define qglAlphaFunc glAlphaFunc +//#define qglAlphaFunc glAlphaFunc #define qglAreTexturesResident glAreTexturesResident #define qglArrayElement glArrayElement #define qglBegin glBegin diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 57ada04d30..96df490964 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -150,39 +150,6 @@ void GL_Cull( int cullType ) { } } -/* -** GL_TexEnv -*/ -void GL_TexEnv( int env ) -{ - if ( env == glState.texEnv[glState.currenttmu] ) - { - return; - } - - glState.texEnv[glState.currenttmu] = env; - - - switch ( env ) - { - case GL_MODULATE: - qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); - break; - case GL_REPLACE: - qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); - break; - case GL_DECAL: - qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); - break; - case GL_ADD: - qglTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); - break; - default: - ri->Error( ERR_DROP, "GL_TexEnv: invalid env '%d' passed", env ); - break; - } -} - /* ** GL_State ** @@ -348,6 +315,7 @@ void GL_State( uint32_t stateBits ) // // alpha test // +#if 0 if ( diff & GLS_ATEST_BITS ) { switch ( stateBits & GLS_ATEST_BITS ) @@ -376,6 +344,7 @@ void GL_State( uint32_t stateBits ) break; } } +#endif glState.glStateBits = stateBits; } @@ -823,7 +792,6 @@ void RB_SetGL2D (void) { GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); qglDisable( GL_CULL_FACE ); - qglDisable( GL_CLIP_PLANE0 ); // set time for 2D shaders backEnd.refdef.time = ri->Milliseconds(); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index b1184550e3..e78b5790f9 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -465,6 +465,7 @@ extend past the portal edge will be overwritten. ================== */ void RB_RenderFlares (void) { +#if 0 flare_t *f; flare_t **prev; qboolean draw; @@ -522,10 +523,6 @@ void RB_RenderFlares (void) { return; // none visible } - if ( backEnd.viewParms.isPortal ) { - qglDisable (GL_CLIP_PLANE0); - } - Matrix16Copy(glState.projection, oldprojection); Matrix16Copy(glState.modelview, oldmodelview); Matrix16Identity(matrix); @@ -545,6 +542,7 @@ void RB_RenderFlares (void) { GL_SetProjectionMatrix(oldprojection); GL_SetModelviewMatrix(oldmodelview); +#endif } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index aa6a9a6c88..9198d7b3bb 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -357,8 +357,8 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha "#define TEXENV_ADD %i\n" "#define TEXENV_REPLACE %i\n" "#endif\n", - GL_MODULATE, - GL_ADD, + 0x2100/* GL_MODULATE */, + 0x0104/* GL_ADD */, GL_REPLACE)); fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); @@ -471,21 +471,6 @@ static void GLSL_LinkProgram(GLuint program) } } -static void GLSL_ValidateProgram(GLuint program) -{ - GLint validated; - - qglValidateProgram(program); - - qglGetProgramiv(program, GL_VALIDATE_STATUS, &validated); - if(!validated) - { - GLSL_PrintProgramInfoLog(program, qfalse); - ri->Printf(PRINT_ALL, "\n"); - ri->Error(ERR_DROP, "shaders failed to validate"); - } -} - static void GLSL_ShowProgramUniforms(GLuint program) { int i, count, size; @@ -728,7 +713,6 @@ void GLSL_InitUniforms(shaderProgram_t *program) void GLSL_FinishGPUShader(shaderProgram_t *program) { - GLSL_ValidateProgram(program->program); GLSL_ShowProgramUniforms(program->program); GL_CheckErrors(); } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 7443bb3b69..265758d665 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -271,12 +271,6 @@ void R_ImageList_f( void ) { // 4 bytes per pixel estSize *= 4; break; - case GL_LUMINANCE8: - case GL_LUMINANCE16: - case GL_LUMINANCE: - format = "L "; - // 1 byte per pixel? - break; case GL_RGB5: case GL_RGB8: case GL_RGB: @@ -284,13 +278,6 @@ void R_ImageList_f( void ) { // 3 bytes per pixel? estSize *= 3; break; - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE16_ALPHA16: - case GL_LUMINANCE_ALPHA: - format = "LA "; - // 2 bytes per pixel? - estSize *= 2; - break; case GL_SRGB: case GL_SRGB8: format = "sRGB "; @@ -303,18 +290,6 @@ void R_ImageList_f( void ) { // 4 bytes per pixel? estSize *= 4; break; - case GL_SLUMINANCE: - case GL_SLUMINANCE8: - format = "sL "; - // 1 byte per pixel? - break; - case GL_SLUMINANCE_ALPHA: - case GL_SLUMINANCE8_ALPHA8: - format = "sLA "; - // 2 byte per pixel? - estSize *= 2; - break; - case GL_DEPTH_COMPONENT24: format = "D24 "; break; @@ -1791,7 +1766,7 @@ static qboolean RawImage_HasAlpha(const byte *scan, int numPixels) static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean lightMap, imgType_t type, int flags) { int samples = 3; - GLenum internalFormat = GL_RGB; + GLenum internalFormat = GL_RGB8; qboolean forceNoCompression = (qboolean)(flags & IMGFLAG_NO_COMPRESSION); qboolean normalmap = (qboolean)(type == IMGTYPE_NORMAL || type == IMGTYPE_NORMALHEIGHT); @@ -1817,15 +1792,17 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } else { - internalFormat = GL_RGBA; + internalFormat = GL_RGBA8; } } } else if(lightMap) { +#if 0 if(r_greyscale->integer) internalFormat = GL_LUMINANCE; else +#endif internalFormat = GL_RGBA; } else @@ -1838,6 +1815,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light // select proper internal format if ( samples == 3 ) { +#if 0 if(r_greyscale->integer) { if(r_texturebits->integer == 16) @@ -1848,6 +1826,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light internalFormat = GL_LUMINANCE; } else +#endif { if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) { @@ -1871,12 +1850,13 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } else { - internalFormat = GL_RGB; + internalFormat = GL_RGB8; } } } else if ( samples == 4 ) { +#if 0 if(r_greyscale->integer) { if(r_texturebits->integer == 16) @@ -1887,6 +1867,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light internalFormat = GL_LUMINANCE_ALPHA; } else +#endif { if ( !forceNoCompression && (glRefConfig.textureCompression & TCR_BPTC) ) { @@ -1906,7 +1887,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light } else { - internalFormat = GL_RGBA; + internalFormat = GL_RGBA8; } } } @@ -1916,7 +1897,7 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light switch(internalFormat) { case GL_RGB: - internalFormat = GL_SRGB; + internalFormat = GL_SRGB8; break; case GL_RGB4: @@ -1934,24 +1915,6 @@ static GLenum RawImage_GetFormat(const byte *data, int numPixels, qboolean light internalFormat = GL_SRGB8_ALPHA8; break; - case GL_LUMINANCE: - internalFormat = GL_SLUMINANCE; - break; - - case GL_LUMINANCE8: - case GL_LUMINANCE16: - internalFormat = GL_SLUMINANCE8; - break; - - case GL_LUMINANCE_ALPHA: - internalFormat = GL_SLUMINANCE_ALPHA; - break; - - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE16_ALPHA16: - internalFormat = GL_SLUMINANCE8_ALPHA8; - break; - case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: internalFormat = GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT; break; @@ -2309,7 +2272,7 @@ static void EmptyTexture( int width, int height, imgType_t type, int flags, case GL_DEPTH_COMPONENT16: case GL_DEPTH_COMPONENT24: case GL_DEPTH_COMPONENT32: - qglTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); + //qglTexParameterf(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); break; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index cffb34823a..585ca88277 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -258,11 +258,14 @@ cvar_t *r_debugContext; extern void RB_SetGL2D (void); void R_Splash() { - GLSL_InitSplashScreenShader(); + const GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); + qglClearBufferfv(GL_COLOR, 0, black); + + GLSL_InitSplashScreenShader(); + qglDisable( GL_CULL_FACE ); - qglDisable( GL_CLIP_PLANE0 ); image_t *pImage = R_FindImageFile( "menu/splash", IMGTYPE_COLORALPHA, IMGFLAG_NONE); if (pImage ) @@ -426,6 +429,34 @@ static const char *TruncateGLExtensionsString (const char *extensionsString, int return truncatedExtensions; } +static const char *GetGLExtensionsString() +{ + GLint numExtensions; + glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + size_t extensionStringLen = 0; + + for ( int i = 0; i < numExtensions; i++ ) + { + extensionStringLen += strlen((const char *)glGetStringi(GL_EXTENSIONS, i)) + 1; + } + + char *extensionString = (char *)Hunk_Alloc(extensionStringLen + 1, h_low); + char *p = extensionString; + for ( int i = 0; i < numExtensions; i++ ) + { + const char *extension = (const char *)glGetStringi(GL_EXTENSIONS, i); + while ( *extension != '\0' ) + *p++ = *extension++; + + *p++ = ' '; + } + + *p = '\0'; + assert((p - extensionString) == extensionStringLen); + + return extensionString; +} + /* ** InitOpenGL ** @@ -455,6 +486,7 @@ static void InitOpenGL( void ) windowDesc.api = GRAPHICS_API_OPENGL; windowDesc.gl.majorVersion = 3; windowDesc.gl.minorVersion = 2; + windowDesc.gl.profile = GLPROFILE_CORE; if ( r_debugContext->integer ) windowDesc.gl.contextFlags = GLCONTEXT_DEBUG; @@ -466,7 +498,7 @@ static void InitOpenGL( void ) glConfig.vendor_string = (const char *)qglGetString (GL_VENDOR); glConfig.renderer_string = (const char *)qglGetString (GL_RENDERER); glConfig.version_string = (const char *)qglGetString (GL_VERSION); - glConfig.extensions_string = (const char *)qglGetString (GL_EXTENSIONS); + glConfig.extensions_string = GetGLExtensionsString(); glConfigExt.originalExtensionString = glConfig.extensions_string; glConfig.extensions_string = TruncateGLExtensionsString(glConfigExt.originalExtensionString, 128); @@ -500,11 +532,17 @@ static void InitOpenGL( void ) // set default state GL_SetDefaultState(); + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); R_Splash(); //get something on screen asap } else { // set default state + GLuint vao; + glGenVertexArrays(1, &vao); + glBindVertexArray(vao); GL_SetDefaultState(); } } @@ -536,12 +574,6 @@ void GL_CheckErrs( char *file, int line ) { case GL_INVALID_OPERATION: strcpy( s, "GL_INVALID_OPERATION" ); break; - case GL_STACK_OVERFLOW: - strcpy( s, "GL_STACK_OVERFLOW" ); - break; - case GL_STACK_UNDERFLOW: - strcpy( s, "GL_STACK_UNDERFLOW" ); - break; case GL_OUT_OF_MEMORY: strcpy( s, "GL_OUT_OF_MEMORY" ); break; @@ -1057,19 +1089,15 @@ void GL_SetDefaultState( void ) qglCullFace(GL_FRONT); - qglColor4f (1,1,1,1); - // initialize downstream texture unit if we're running // in a multitexture environment GL_SelectTexture( 1 ); GL_TextureMode( r_textureMode->string ); - GL_TexEnv( GL_MODULATE ); - qglDisable( GL_TEXTURE_2D ); + //GL_TexEnv( GL_MODULATE ); GL_SelectTexture( 0 ); - qglEnable(GL_TEXTURE_2D); GL_TextureMode( r_textureMode->string ); - GL_TexEnv( GL_MODULATE ); + //GL_TexEnv( GL_MODULATE ); //qglShadeModel( GL_SMOOTH ); qglDepthFunc( GL_LEQUAL ); @@ -1572,7 +1600,6 @@ static void R_ShutdownBackEndFrameData() for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) { gpuTimer_t *timer = frame->timers + j; - Com_Printf( "Deleting query %d\n", timer->queryName ); qglDeleteQueries(1, &timer->queryName); } } @@ -1984,4 +2011,4 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { return &re; } -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 406004ed78..c5904551c1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2359,7 +2359,7 @@ void GL_CheckErrs( char *file, int line ); void GL_State( uint32_t stateVector ); void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); -void GL_TexEnv( int env ); +//void GL_TexEnv( int env ); void GL_Cull( int cullType ); #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index e735d37674..025a858af6 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -90,6 +90,7 @@ void R_RenderShadowEdges( void ) { qglEnd(); } #else +#if 0 int c, c2; int j, k; int i2; @@ -137,6 +138,7 @@ void R_RenderShadowEdges( void ) { } } #endif +#endif } /* @@ -213,7 +215,6 @@ void RB_ShadowTessEnd( void ) { GL_Bind( tr.whiteImage ); qglEnable( GL_CULL_FACE ); GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); - qglColor3f( 0.2f, 0.2f, 0.2f ); // don't write to the color buffer qglGetBooleanv(GL_COLOR_WRITEMASK, rgba); @@ -262,6 +263,7 @@ overlap and double darken. ================= */ void RB_ShadowFinish( void ) { +#if 0 if ( r_shadows->integer != 2 ) { return; } @@ -271,7 +273,6 @@ void RB_ShadowFinish( void ) { qglEnable( GL_STENCIL_TEST ); qglStencilFunc( GL_NOTEQUAL, 0, 255 ); - qglDisable (GL_CLIP_PLANE0); qglDisable (GL_CULL_FACE); GL_Bind( tr.whiteImage ); @@ -293,6 +294,7 @@ void RB_ShadowFinish( void ) { qglColor4f(1,1,1,1); qglDisable( GL_STENCIL_TEST ); +#endif } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index ee6dd9bcfd..e361993ce8 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -69,6 +69,41 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) } } +#if 0 +struct Attribute +{ + int index; + GLenum type; + int numElements; + qboolean normalised; + int offset; + int stride; + int stream; +}; + +const int MAX_ATTRIBUTES = 8; +struct VertexFormat +{ + Attribute attributes[MAX_ATTRIBUTES]; + int numAttributes; +}; + +const int MAX_VERTEX_STREAMS = 2; +struct VertexArrayObject +{ + GLuint vao; + IBO_t *ibo; + VBO_t *vbos[MAX_VERTEX_STREAMS]; + int numStreams; + VertexFormat format; +}; + +VertexArrayObject *R_GetVertexArrayObject( const VertexFormat& format ) +{ + return nullptr; +} +#endif + /* ============ R_CreateVBO @@ -592,4 +627,4 @@ void RB_CommitInternalBufferData() { tess.internalIBOCommitOffset = tess.internalIBOWriteOffset; tess.internalVBOCommitOffset = tess.internalVBOWriteOffset; -} \ No newline at end of file +} From ff866e7f01f5e060577932d0b66607a832cbda0a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 10 Feb 2016 20:40:58 +0000 Subject: [PATCH 318/708] Improve texcoord swapping situation Get the shader to pick the correct texcoord instead. --- codemp/rd-rend2/glsl/lightall_vp.glsl | 56 ++++--- codemp/rd-rend2/tr_bsp.cpp | 201 ++------------------------ codemp/rd-rend2/tr_glsl.cpp | 139 ++++++++++-------- codemp/rd-rend2/tr_local.h | 82 +++++++---- codemp/rd-rend2/tr_shade.cpp | 73 +--------- 5 files changed, 186 insertions(+), 365 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl index c330e5694b..b11927bcbc 100644 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ b/codemp/rd-rend2/glsl/lightall_vp.glsl @@ -1,6 +1,9 @@ in vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) in vec2 attr_TexCoord1; +in vec2 attr_TexCoord2; +in vec2 attr_TexCoord3; +in vec2 attr_TexCoord4; #endif in vec4 attr_Color; @@ -33,11 +36,12 @@ uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cu uniform vec3 u_ViewOrigin; #endif -#if defined(USE_TCGEN) +#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) uniform int u_TCGen0; uniform vec3 u_TCGen0Vector0; uniform vec3 u_TCGen0Vector1; uniform vec3 u_LocalViewOrigin; +uniform int u_TCGen1; #endif #if defined(USE_TCMOD) @@ -96,25 +100,43 @@ out vec4 var_LightDir; out vec4 var_PrimaryLightDir; #endif -#if defined(USE_TCGEN) +#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) { - vec2 tex = attr_TexCoord0.st; + vec2 tex = attr_TexCoord0; - if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3) - { - tex = attr_TexCoord1.st; - } - else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) - { - vec3 viewer = normalize(u_LocalViewOrigin - position); - vec2 ref = reflect(viewer, normal).yz; - tex.s = ref.x * -0.5 + 0.5; - tex.t = ref.y * 0.5 + 0.5; - } - else if (TCGen == TCGEN_VECTOR) + switch (TCGen) { - tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + case TCGEN_LIGHTMAP: + tex = attr_TexCoord1; + break; + + case TCGEN_LIGHTMAP1: + tex = attr_TexCoord2; + break; + + case TCGEN_LIGHTMAP2: + tex = attr_TexCoord3; + break; + + case TCGEN_LIGHTMAP3: + tex = attr_TexCoord4; + break; + + case TCGEN_ENVIRONMENT_MAPPED: + { + vec3 viewer = normalize(u_LocalViewOrigin - position); + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; + } + break; + + case TCGEN_VECTOR: + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + break; } return tex; @@ -248,7 +270,7 @@ void main() #endif #if defined(USE_LIGHTMAP) - var_TexCoords.zw = attr_TexCoord1.st; + var_TexCoords.zw = GenTexCoords(u_TCGen1, vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); #endif var_Color = u_VertColor * attr_Color + u_BaseColor; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 0155026148..99952d25f4 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2063,7 +2063,10 @@ static void R_CreateWorldVBOs(void) vbo->offsets[ATTR_INDEX_NORMAL] = offsetof(packedVertex_t, normal); vbo->offsets[ATTR_INDEX_TANGENT] = offsetof(packedVertex_t, tangent); vbo->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(packedVertex_t, texcoords[0]); - vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[0]); + vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[1]); + vbo->offsets[ATTR_INDEX_TEXCOORD2] = offsetof(packedVertex_t, texcoords[2]); + vbo->offsets[ATTR_INDEX_TEXCOORD3] = offsetof(packedVertex_t, texcoords[3]); + vbo->offsets[ATTR_INDEX_TEXCOORD4] = offsetof(packedVertex_t, texcoords[4]); vbo->offsets[ATTR_INDEX_COLOR] = offsetof(packedVertex_t, colors); vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offsetof(packedVertex_t, lightDirection); @@ -2073,6 +2076,9 @@ static void R_CreateWorldVBOs(void) vbo->strides[ATTR_INDEX_TANGENT] = packedVertexSize; vbo->strides[ATTR_INDEX_TEXCOORD0] = packedVertexSize; vbo->strides[ATTR_INDEX_TEXCOORD1] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD2] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD3] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD4] = packedVertexSize; vbo->strides[ATTR_INDEX_COLOR] = packedVertexSize; vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = packedVertexSize; @@ -2080,6 +2086,9 @@ static void R_CreateWorldVBOs(void) vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(verts->normal); vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(verts->texcoords[0]); vbo->sizes[ATTR_INDEX_TEXCOORD1] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD2] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD3] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD4] = sizeof(verts->texcoords[0]); vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(verts->tangent); vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(verts->lightDirection); vbo->sizes[ATTR_INDEX_COLOR] = sizeof(verts->colors); @@ -3474,196 +3483,6 @@ void RE_LoadWorldMap( const char *name ) { // determine vertex light directions R_CalcVertexLightDirs(); - // determine which parts of the map are in sunlight -#if 0 - if (0) - { - world_t *w; - - uint8_t *primaryLightGrid, *data; - int lightGridSize; - int i; - - w = &s_worldData; - - lightGridSize = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; - primaryLightGrid = (uint8_t *)Z_Malloc(lightGridSize * sizeof(*primaryLightGrid), TAG_GENERAL); - - memset(primaryLightGrid, 0, lightGridSize * sizeof(*primaryLightGrid)); - - data = w->lightGridData; - for (i = 0; i < lightGridSize; i++, data += 8) - { - int lat, lng; - vec3_t gridLightDir, gridLightCol; - - // skip samples in wall - if (!(data[0]+data[1]+data[2]+data[3]+data[4]+data[5]) ) - continue; - - gridLightCol[0] = ByteToFloat(data[3]); - gridLightCol[1] = ByteToFloat(data[4]); - gridLightCol[2] = ByteToFloat(data[5]); - (void)gridLightCol; // Suppress unused-but-set-variable warning - - lat = data[7]; - lng = data[6]; - lat *= (FUNCTABLE_SIZE/256); - lng *= (FUNCTABLE_SIZE/256); - - // decode X as cos( lat ) * sin( long ) - // decode Y as sin( lat ) * sin( long ) - // decode Z as cos( long ) - - gridLightDir[0] = tr.sinTable[(lat+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK] * tr.sinTable[lng]; - gridLightDir[1] = tr.sinTable[lat] * tr.sinTable[lng]; - gridLightDir[2] = tr.sinTable[(lng+(FUNCTABLE_SIZE/4))&FUNCTABLE_MASK]; - - // FIXME: magic number for determining if light direction is close enough to sunlight - if (DotProduct(gridLightDir, tr.sunDirection) > 0.75f) - { - primaryLightGrid[i] = 1; - } - else - { - primaryLightGrid[i] = 255; - } - } - - if (0) - { - int i; - byte *buffer = (byte *)Z_Malloc(w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18, TAG_GENERAL); - byte *out; - uint8_t *in; - char fileName[MAX_QPATH]; - - Com_Memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = w->lightGridBounds[0] & 255; - buffer[13] = w->lightGridBounds[0] >> 8; - buffer[14] = w->lightGridBounds[1] & 255; - buffer[15] = w->lightGridBounds[1] >> 8; - buffer[16] = 24; // pixel size - - in = primaryLightGrid; - for (i = 0; i < w->lightGridBounds[2]; i++) - { - int j; - - sprintf(fileName, "primarylg%d.tga", i); - - out = buffer + 18; - for (j = 0; j < w->lightGridBounds[0] * w->lightGridBounds[1]; j++) - { - if (*in == 1) - { - *out++ = 255; - *out++ = 255; - *out++ = 255; - } - else if (*in == 255) - { - *out++ = 64; - *out++ = 64; - *out++ = 64; - } - else - { - *out++ = 0; - *out++ = 0; - *out++ = 0; - } - in++; - } - - ri->FS_WriteFile(fileName, buffer, w->lightGridBounds[0] * w->lightGridBounds[1] * 3 + 18); - } - - Z_Free(buffer); - } - - for (i = 0; i < w->numWorldSurfaces; i++) - { - msurface_t *surf = w->surfaces + i; - cullinfo_t *ci = &surf->cullinfo; - - if(ci->type & CULLINFO_PLANE) - { - if (DotProduct(ci->plane.normal, tr.sunDirection) <= 0.0f) - { - //ri->Printf(PRINT_ALL, "surface %d is not oriented towards sunlight\n", i); - continue; - } - } - - if(ci->type & CULLINFO_BOX) - { - int ibounds[2][3], x, y, z, goodSamples, numSamples; - vec3_t lightOrigin; - - VectorSubtract( ci->bounds[0], w->lightGridOrigin, lightOrigin ); - - ibounds[0][0] = floor(lightOrigin[0] * w->lightGridInverseSize[0]); - ibounds[0][1] = floor(lightOrigin[1] * w->lightGridInverseSize[1]); - ibounds[0][2] = floor(lightOrigin[2] * w->lightGridInverseSize[2]); - - VectorSubtract( ci->bounds[1], w->lightGridOrigin, lightOrigin ); - - ibounds[1][0] = ceil(lightOrigin[0] * w->lightGridInverseSize[0]); - ibounds[1][1] = ceil(lightOrigin[1] * w->lightGridInverseSize[1]); - ibounds[1][2] = ceil(lightOrigin[2] * w->lightGridInverseSize[2]); - - ibounds[0][0] = CLAMP(ibounds[0][0], 0, w->lightGridSize[0]); - ibounds[0][1] = CLAMP(ibounds[0][1], 0, w->lightGridSize[1]); - ibounds[0][2] = CLAMP(ibounds[0][2], 0, w->lightGridSize[2]); - - ibounds[1][0] = CLAMP(ibounds[1][0], 0, w->lightGridSize[0]); - ibounds[1][1] = CLAMP(ibounds[1][1], 0, w->lightGridSize[1]); - ibounds[1][2] = CLAMP(ibounds[1][2], 0, w->lightGridSize[2]); - - /* - ri->Printf(PRINT_ALL, "surf %d bounds (%f %f %f)-(%f %f %f) ibounds (%d %d %d)-(%d %d %d)\n", i, - ci->bounds[0][0], ci->bounds[0][1], ci->bounds[0][2], - ci->bounds[1][0], ci->bounds[1][1], ci->bounds[1][2], - ibounds[0][0], ibounds[0][1], ibounds[0][2], - ibounds[1][0], ibounds[1][1], ibounds[1][2]); - */ - - goodSamples = 0; - numSamples = 0; - for (x = ibounds[0][0]; x <= ibounds[1][0]; x++) - { - for (y = ibounds[0][1]; y <= ibounds[1][1]; y++) - { - for (z = ibounds[0][2]; z <= ibounds[1][2]; z++) - { - uint8_t primaryLight = primaryLightGrid[x * 8 + y * 8 * w->lightGridBounds[0] + z * 8 * w->lightGridBounds[0] * w->lightGridBounds[2]]; - - if (primaryLight == 0) - continue; - - numSamples++; - - if (primaryLight == 1) - goodSamples++; - } - } - } - - // FIXME: magic number for determining whether object is mostly in sunlight - if (goodSamples > numSamples * 0.75f) - { - //ri->Printf(PRINT_ALL, "surface %d is in sunlight\n", i); - //surf->primaryLight = 1; - } - } - } - - Z_Free(primaryLightGrid); - } -#endif - // load cubemaps if (r_cubeMapping->integer) { diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 9198d7b3bb..b8cee80818 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -98,6 +98,7 @@ static uniformInfo_t uniformsInfo[] = { "u_TCGen0", GLSL_INT, 1 }, { "u_TCGen0Vector0", GLSL_VEC3, 1 }, { "u_TCGen0Vector1", GLSL_VEC3, 1 }, + { "u_TCGen1", GLSL_INT, 1 }, { "u_DeformType", GLSL_INT, 1 }, { "u_DeformFunc", GLSL_INT, 1 }, @@ -573,6 +574,15 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) if(attribs & ATTR_TEXCOORD1) qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); + if(attribs & ATTR_TEXCOORD2) + qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD2, "attr_TexCoord2"); + + if(attribs & ATTR_TEXCOORD3) + qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD3, "attr_TexCoord3"); + + if(attribs & ATTR_TEXCOORD4) + qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD4, "attr_TexCoord4"); + if(attribs & ATTR_TANGENT) qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); @@ -1022,6 +1032,58 @@ int GLSL_BeginLoadGPUShaders(void) char extradefines[1024]; int attribs; +#if 0 + // vertex size = 48 bytes + VertexFormat bspVertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 2, false, GL_HALF_FLOAT, false, 16 }, // tc1 + { 2, false, GL_HALF_FLOAT, false, 20 }, // tc2 + { 2, false, GL_HALF_FLOAT, false, 24 }, // tc3 + { 2, false, GL_HALF_FLOAT, false, 28 }, // tc4 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 32 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // normal + { 4, false, GL_FLOAT, false, 40 }, // color + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 44 }, // light dir + } + }; + + // vertex size = 32 bytes + VertexFormat rectVertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_FLOAT, false, 16 } // color + } + }; + + // vertex size = 32 bytes + VertexFormat g2VertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal + { 4, true, GL_UNSIGNED_BYTE, false, 24 }, // bone indices + { 4, false, GL_UNSIGNED_BYTE, true, 28 }, // bone weights + } + }; + + // vertex size = 44 bytes + VertexFormat md3VertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal + { 3, false, GL_FLOAT, false, 24 }, // pos2 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 40 }, // normal + } + }; +#endif + ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); R_IssuePendingRenderCommands(); @@ -1898,45 +1960,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA } } -void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits, const VertexArraysProperties *vertexArrays ) -{ - if ( attribBits & ATTR_TEXCOORD0 ) - { - int newOffset = vertexArrays->offsets[ATTR_INDEX_TEXCOORD0] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0]; - if ( glState.currentVaoVbo[ATTR_INDEX_TEXCOORD0] != glState.currentVBO->vertexesVBO || - glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD0] != newOffset || - glState.currentVaoStrides[ATTR_INDEX_TEXCOORD0] != vertexArrays->strides[ATTR_INDEX_TEXCOORD0] ) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD0, 2, GL_FLOAT, 0, - vertexArrays->strides[ATTR_INDEX_TEXCOORD0], BUFFER_OFFSET(newOffset)); - - glState.currentVaoVbo[ATTR_INDEX_TEXCOORD0] = glState.currentVBO->vertexesVBO; - glState.currentVaoStrides[ATTR_INDEX_TEXCOORD0] = vertexArrays->strides[ATTR_INDEX_TEXCOORD0]; - glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD0] = newOffset; - } - } - - if ( attribBits & ATTR_TEXCOORD1 ) - { - int newOffset = vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] + sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1]; - if ( glState.currentVaoVbo[ATTR_INDEX_TEXCOORD1] != glState.currentVBO->vertexesVBO || - glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD1] != newOffset || - glState.currentVaoStrides[ATTR_INDEX_TEXCOORD1] != vertexArrays->strides[ATTR_INDEX_TEXCOORD1] ) - { - GLimp_LogComment("qglVertexAttribPointer( ATTR_INDEX_TEXCOORD1 )\n"); - - qglVertexAttribPointer(ATTR_INDEX_TEXCOORD1, 2, GL_FLOAT, 0, - vertexArrays->strides[ATTR_INDEX_TEXCOORD1], BUFFER_OFFSET(newOffset)); - - glState.currentVaoVbo[ATTR_INDEX_TEXCOORD1] = glState.currentVBO->vertexesVBO; - glState.currentVaoStrides[ATTR_INDEX_TEXCOORD1] = vertexArrays->strides[ATTR_INDEX_TEXCOORD1]; - glState.currentVaoOffsets[ATTR_INDEX_TEXCOORD1] = newOffset; - } - } -} - void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays) { VBO_t *vbo = glState.currentVBO; @@ -1959,21 +1982,23 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties GLboolean integerAttribute; GLenum type; GLboolean normalize; - int offset; } attributes[ATTR_INDEX_MAX] = { - { 3, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // position - { 2, GL_FALSE, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[0] }, - { 2, GL_FALSE, GL_FLOAT, GL_FALSE, sizeof (vec2_t) * glState.vertexAttribsTexCoordOffset[1] }, - { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // tangent - { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // normal - { 4, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // color - { 0, GL_FALSE, GL_NONE, GL_FALSE, 0 }, // paint color - { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, // light direction - { 4, GL_TRUE, GL_UNSIGNED_BYTE, GL_FALSE, 0 }, // bone indices - { 4, GL_FALSE, GL_UNSIGNED_BYTE, GL_TRUE, 0 }, // bone weights - { 3, GL_FALSE, GL_FLOAT, GL_FALSE, 0 }, // pos2 - { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, - { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE, 0 }, + { 3, GL_FALSE, GL_FLOAT, GL_FALSE }, // position + { 2, GL_FALSE, GL_FLOAT, GL_FALSE }, // tc0 + { 2, GL_FALSE, GL_FLOAT, GL_FALSE }, // tc1 + { 2, GL_FALSE, GL_FLOAT, GL_FALSE }, // tc2 + { 2, GL_FALSE, GL_FLOAT, GL_FALSE }, // tc3 + { 2, GL_FALSE, GL_FLOAT, GL_FALSE }, // tc4 + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // tangent + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal + { 4, GL_FALSE, GL_FLOAT, GL_FALSE }, // color + { 0, GL_FALSE, GL_NONE, GL_FALSE }, // paint color + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // light direction + { 4, GL_TRUE, GL_UNSIGNED_BYTE, GL_FALSE }, // bone indices + { 4, GL_FALSE, GL_UNSIGNED_BYTE, GL_TRUE }, // bone weights + { 3, GL_FALSE, GL_FLOAT, GL_FALSE }, // pos2 + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // tangent2 + { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal2 }; for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) @@ -1981,7 +2006,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties int attributeIndex = vertexArrays->enabledAttributes[i]; if ( glState.currentVaoVbo[attributeIndex] == glState.currentVBO->vertexesVBO && - glState.currentVaoOffsets[attributeIndex] == vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset && + glState.currentVaoOffsets[attributeIndex] == vertexArrays->offsets[attributeIndex] && glState.currentVaoStrides[attributeIndex] == vertexArrays->strides[attributeIndex] ) { // No change @@ -1994,7 +2019,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties attributes[attributeIndex].numComponents, attributes[attributeIndex].type, vertexArrays->strides[attributeIndex], - BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + BUFFER_OFFSET(vertexArrays->offsets[attributeIndex])); } else { @@ -2003,12 +2028,12 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties attributes[attributeIndex].type, attributes[attributeIndex].normalize, vertexArrays->strides[attributeIndex], - BUFFER_OFFSET(vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset)); + BUFFER_OFFSET(vertexArrays->offsets[attributeIndex])); } glState.currentVaoVbo[attributeIndex] = glState.currentVBO->vertexesVBO; glState.currentVaoStrides[attributeIndex] = vertexArrays->strides[attributeIndex]; - glState.currentVaoOffsets[attributeIndex] = vertexArrays->offsets[attributeIndex] + attributes[attributeIndex].offset; + glState.currentVaoOffsets[attributeIndex] = vertexArrays->offsets[attributeIndex]; glState.vertexAttribPointersSet |= (1 << attributeIndex); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c5904551c1..92e923a1db 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -324,6 +324,9 @@ enum ATTR_INDEX_POSITION, ATTR_INDEX_TEXCOORD0, ATTR_INDEX_TEXCOORD1, + ATTR_INDEX_TEXCOORD2, + ATTR_INDEX_TEXCOORD3, + ATTR_INDEX_TEXCOORD4, ATTR_INDEX_TANGENT, ATTR_INDEX_NORMAL, ATTR_INDEX_COLOR, @@ -895,38 +898,59 @@ enum GLS_DEFAULT = GLS_DEPTHMASK_TRUE }; +struct Attribute +{ + int numComponents; + bool integerAttribute; + GLenum type; + bool normalize; + int offset; +}; + +const int MAX_ATTRIBUTES = 8; +struct VertexFormat +{ + Attribute attributes[MAX_ATTRIBUTES]; +}; + enum { - ATTR_POSITION = 0x0001, - ATTR_TEXCOORD0 = 0x0002, - ATTR_TEXCOORD1 = 0x0004, - ATTR_TANGENT = 0x0008, - ATTR_NORMAL = 0x0010, - ATTR_COLOR = 0x0020, - ATTR_PAINTCOLOR = 0x0040, - ATTR_LIGHTDIRECTION = 0x0080, - ATTR_BONE_INDEXES = 0x0100, - ATTR_BONE_WEIGHTS = 0x0200, + ATTR_POSITION = 0x0001, + ATTR_TEXCOORD0 = 0x0002, + ATTR_TEXCOORD1 = 0x0004, + ATTR_TEXCOORD2 = 0x0008, + ATTR_TEXCOORD3 = 0x0010, + ATTR_TEXCOORD4 = 0x0020, + ATTR_TANGENT = 0x0040, + ATTR_NORMAL = 0x0080, + ATTR_COLOR = 0x0100, + ATTR_PAINTCOLOR = 0x0200, + ATTR_LIGHTDIRECTION = 0x0400, + ATTR_BONE_INDEXES = 0x0800, + ATTR_BONE_WEIGHTS = 0x1000, // for .md3 interpolation - ATTR_POSITION2 = 0x0400, - ATTR_TANGENT2 = 0x0800, - ATTR_NORMAL2 = 0x1000, - - ATTR_DEFAULT = ATTR_POSITION, - ATTR_BITS = ATTR_POSITION | - ATTR_TEXCOORD0 | - ATTR_TEXCOORD1 | - ATTR_TANGENT | - ATTR_NORMAL | - ATTR_COLOR | - ATTR_PAINTCOLOR | - ATTR_LIGHTDIRECTION | - ATTR_BONE_INDEXES | - ATTR_BONE_WEIGHTS | - ATTR_POSITION2 | - ATTR_TANGENT2 | - ATTR_NORMAL2 + ATTR_POSITION2 = 0x2000, + ATTR_TANGENT2 = 0x4000, + ATTR_NORMAL2 = 0x8000, + + ATTR_DEFAULT = ATTR_POSITION, + ATTR_BITS = ATTR_POSITION | + ATTR_TEXCOORD0 | + ATTR_TEXCOORD1 | + ATTR_TEXCOORD2 | + ATTR_TEXCOORD3 | + ATTR_TEXCOORD4 | + ATTR_TANGENT | + ATTR_NORMAL | + ATTR_COLOR | + ATTR_PAINTCOLOR | + ATTR_LIGHTDIRECTION | + ATTR_BONE_INDEXES | + ATTR_BONE_WEIGHTS | + ATTR_POSITION2 | + ATTR_TANGENT2 | + ATTR_NORMAL2 }; enum @@ -1017,6 +1041,7 @@ typedef enum UNIFORM_TCGEN0, UNIFORM_TCGEN0VECTOR0, UNIFORM_TCGEN0VECTOR1, + UNIFORM_TCGEN1, UNIFORM_DEFORMTYPE, UNIFORM_DEFORMFUNC, @@ -2695,7 +2720,6 @@ int GLSL_BeginLoadGPUShaders(void); void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArrays); -void GLSL_UpdateTexCoordVertexAttribPointers ( uint32_t attribBits, const VertexArraysProperties *vertexArrays ); void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays); void GLSL_BindProgram(shaderProgram_t * program); void GLSL_BindNullProgram(void); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ce4e26d689..914be40ff8 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -984,6 +984,7 @@ static void ForwardDlight( void ) { GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + GLSL_SetUniformInt(sp, UNIFORM_TCGEN1, pStage->bundle[1].tcGen); // // draw @@ -1188,75 +1189,6 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -static void UpdateTexCoords ( const shaderStage_t *stage, const VertexArraysProperties *vertexArrays ) -{ - uint32_t updateAttribs = 0; - if ( stage->bundle[0].image[0] != NULL ) - { - switch (stage->bundle[0].tcGen) - { - case TCGEN_LIGHTMAP: - case TCGEN_LIGHTMAP1: - case TCGEN_LIGHTMAP2: - case TCGEN_LIGHTMAP3: - { - int newLightmapIndex = stage->bundle[0].tcGen - TCGEN_LIGHTMAP + 1; - if (newLightmapIndex != glState.vertexAttribsTexCoordOffset[0]) - { - glState.vertexAttribsTexCoordOffset[0] = newLightmapIndex; - updateAttribs |= ATTR_TEXCOORD0; - } - - break; - } - - case TCGEN_TEXTURE: - if (glState.vertexAttribsTexCoordOffset[0] != 0) - { - glState.vertexAttribsTexCoordOffset[0] = 0; - updateAttribs |= ATTR_TEXCOORD0; - } - break; - - default: - break; - } - } - - if ( stage->bundle[TB_LIGHTMAP].image[0] != NULL ) - { - switch (stage->bundle[TB_LIGHTMAP].tcGen) - { - case TCGEN_LIGHTMAP: - case TCGEN_LIGHTMAP1: - case TCGEN_LIGHTMAP2: - case TCGEN_LIGHTMAP3: - { - int newLightmapIndex = stage->bundle[TB_LIGHTMAP].tcGen - TCGEN_LIGHTMAP + 1; - if (newLightmapIndex != glState.vertexAttribsTexCoordOffset[1]) - { - glState.vertexAttribsTexCoordOffset[1] = newLightmapIndex; - updateAttribs |= ATTR_TEXCOORD1; - } - - break; - } - - case TCGEN_TEXTURE: - assert(!"Invalid tcgen (TCGEN_TEXTURE) on lightmap bundle"); - break; - - default: - break; - } - } - - if ( updateAttribs != 0 ) - { - GLSL_UpdateTexCoordVertexAttribPointers( updateAttribs, vertexArrays ); - } -} - static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int stage; @@ -1443,8 +1375,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } } - UpdateTexCoords (pStage, vertexArrays); - GL_State( stateBits ); { @@ -1511,6 +1441,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + GLSL_SetUniformInt(sp, UNIFORM_TCGEN1, pStage->bundle[1].tcGen); if (pStage->bundle[0].tcGen == TCGEN_VECTOR) { vec3_t vec; From 5cd4b3d0261ee3f97dbe96b00b5f2d546099cbbe Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 10 Feb 2016 20:46:13 +0000 Subject: [PATCH 319/708] Remove last remainders of weird texcoord handling --- codemp/rd-rend2/tr_glsl.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index b8cee80818..c610d31d67 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1930,9 +1930,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA int attributeIndex = vertexArrays->enabledAttributes[i]; vertexArrays->offsets[attributeIndex] += tess.internalVBOCommitOffset; } - - // Slight hack to make tc0 and tc1 offset from the same position. - vertexArrays->offsets[ATTR_INDEX_TEXCOORD1] = vertexArrays->offsets[ATTR_INDEX_TEXCOORD0]; } else { From b58429aa906746f2a123b164355c85ccbf172363 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 12 Feb 2016 22:32:51 +0000 Subject: [PATCH 320/708] Move alpha testing into shaders for core GL ctx Also tidied up the code a bit in some places and fixed some minor bugs (to do with printing out source code). --- codemp/rd-rend2/glsl/dlight_fp.glsl | 14 ++ codemp/rd-rend2/glsl/fogpass_fp.glsl | 14 ++ codemp/rd-rend2/glsl/generic_fp.glsl | 15 ++ codemp/rd-rend2/glsl/lightall_fp.glsl | 14 ++ codemp/rd-rend2/tr_glsl.cpp | 291 +++++++++++++++++--------- codemp/rd-rend2/tr_local.h | 116 ++++++---- codemp/rd-rend2/tr_shade.cpp | 231 +++++++++++++------- codemp/rd-rend2/tr_shader.cpp | 45 ++-- 8 files changed, 507 insertions(+), 233 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight_fp.glsl b/codemp/rd-rend2/glsl/dlight_fp.glsl index de5be02f22..2b763e2c33 100644 --- a/codemp/rd-rend2/glsl/dlight_fp.glsl +++ b/codemp/rd-rend2/glsl/dlight_fp.glsl @@ -1,4 +1,7 @@ uniform sampler2D u_DiffuseMap; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif in vec2 var_Tex1; in vec4 var_Color; @@ -9,5 +12,16 @@ void main() { vec4 color = texture(u_DiffuseMap, var_Tex1); +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (color.a < u_AlphaTestValue) +# endif + discard; +#endif + out_Color = color * var_Color; } diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl index 1defd59dc5..4530cbceef 100644 --- a/codemp/rd-rend2/glsl/fogpass_fp.glsl +++ b/codemp/rd-rend2/glsl/fogpass_fp.glsl @@ -1,4 +1,7 @@ uniform vec4 u_Color; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif in float var_Scale; @@ -10,6 +13,17 @@ void main() out_Color.rgb = u_Color.rgb; out_Color.a = sqrt(clamp(var_Scale, 0.0, 1.0)); +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (out_Color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (out_Color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (out_Color.a < u_AlphaTestValue) +# endif + discard; +#endif + #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; #else diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl index b5dfa99cb8..a95f890be9 100644 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ b/codemp/rd-rend2/glsl/generic_fp.glsl @@ -1,4 +1,7 @@ uniform sampler2D u_DiffuseMap; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif in vec2 var_DiffuseTex; @@ -10,6 +13,18 @@ out vec4 out_Glow; void main() { vec4 color = texture(u_DiffuseMap, var_DiffuseTex); + +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (color.a < u_AlphaTestValue) +# endif + discard; +#endif + out_Color = color * var_Color; #if defined(USE_GLOW_BUFFER) diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall_fp.glsl index 0c1f903bbf..49a247f708 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall_fp.glsl @@ -50,6 +50,10 @@ uniform vec4 u_CubeMapInfo; #endif #endif +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif + in vec4 var_TexCoords; in vec4 var_Color; @@ -290,6 +294,16 @@ void main() #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (diffuse.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (diffuse.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (diffuse.a < u_AlphaTestValue) +# endif + discard; +#endif #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #if defined(USE_LIGHTMAP) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c610d31d67..1dbe2cf5cd 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -154,15 +154,14 @@ static uniformInfo_t uniformsInfo[] = { "u_CubeMapInfo", GLSL_VEC4, 1 }, { "u_BoneMatrices", GLSL_MAT4x3, 20 }, + { "u_AlphaTestValue", GLSL_FLOAT, 1 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) { - char *msg; - static char msgPart[1024]; - int maxLength = 0; - int i; - int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; + char msgPart[1024]; + int maxLength = 0; + int printLevel = developerOnly ? PRINT_DEVELOPER : PRINT_ALL; qglGetProgramiv(object, GL_INFO_LOG_LENGTH, &maxLength); @@ -184,11 +183,11 @@ static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) } else { - msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); + char *msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); qglGetProgramInfoLog(object, maxLength, &maxLength, msg); - for(i = 0; i < maxLength; i += 1024) + for(int i = 0; i < maxLength; i += 1023) { Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); @@ -244,19 +243,21 @@ static void GLSL_PrintShaderInfoLog(GLuint object, qboolean developerOnly) static void GLSL_PrintShaderSource(GLuint shader) { - char *msg; - static char msgPart[1024]; - int maxLength = 0; - int i; - + int maxLength = 0; qglGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &maxLength); - msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); + if ( maxLength == 0 ) + { + Com_Printf("No shader source available to output\n"); + return; + } - qglGetShaderSource(shader, maxLength, &maxLength, msg); + char *msg = (char *)Z_Malloc(maxLength, TAG_SHADERTEXT); + qglGetShaderSource(shader, maxLength, nullptr, msg); - for(i = 0; i < maxLength; i += 1024) + for (int i = 0; i < maxLength; i += 1023) { + char msgPart[1024]; Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); ri->Printf(PRINT_ALL, "%s\n", msgPart); } @@ -362,6 +363,14 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha 0x0104/* GL_ADD */, GL_REPLACE)); + Q_strcat(dest, size, + va("#define ATEST_CMP_LT %d\n" + "#define ATEST_CMP_GT %d\n" + "#define ATEST_CMP_GE %d\n", + ATEST_CMP_LT, + ATEST_CMP_GT, + ATEST_CMP_GE)); + fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); Q_strcat(dest, size, @@ -534,7 +543,7 @@ static bool GLSL_IsGPUShaderCompiled (GLuint shader) GLint compiled; qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - if(!compiled) + if (!compiled) { GLSL_PrintShaderSource(shader); GLSL_PrintShaderInfoLog(shader, qfalse); @@ -723,8 +732,10 @@ void GLSL_InitUniforms(shaderProgram_t *program) void GLSL_FinishGPUShader(shaderProgram_t *program) { +#if defined(_DEBUG) GLSL_ShowProgramUniforms(program->program); GL_CheckErrors(); +#endif } void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) @@ -1029,7 +1040,7 @@ int GLSL_BeginLoadGPUShaders(void) { int startTime; int i; - char extradefines[1024]; + char extradefines[1200]; int attribs; #if 0 @@ -1101,34 +1112,61 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (i & GENERICDEF_USE_DEFORM_VERTEXES) - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); if (i & GENERICDEF_USE_TCGEN_AND_TCMOD) { - Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); - Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCGEN\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } if (i & GENERICDEF_USE_VERTEX_ANIMATION) { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; } if (i & GENERICDEF_USE_SKELETAL_ANIMATION) { - Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } if (i & GENERICDEF_USE_FOG) - Q_strcat(extradefines, 1024, "#define USE_FOG\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_FOG\n"); if (i & GENERICDEF_USE_RGBAGEN) - Q_strcat(extradefines, 1024, "#define USE_RGBAGEN\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_RGBAGEN\n"); if (i & GENERICDEF_USE_GLOW_BUFFER) - Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); + + switch ( i & GENERICDEF_USE_ATEST_MASK ) + { + case GENERICDEF_USE_ATEST_LT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_LT\n"); + break; + } + + case GENERICDEF_USE_ATEST_GT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GT\n"); + break; + } + + case GENERICDEF_USE_ATEST_GE: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GE\n"); + break; + } + + default: + break; + } if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, fallbackShader_generic_vp, fallbackShader_generic_fp)) { @@ -1155,13 +1193,40 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (i & FOGDEF_USE_DEFORM_VERTEXES) - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); if (i & FOGDEF_USE_VERTEX_ANIMATION) - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); if (i & FOGDEF_USE_SKELETAL_ANIMATION) - Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); + + switch ( i & FOGDEF_USE_ATEST_MASK ) + { + case FOGDEF_USE_ATEST_LT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_LT\n"); + break; + } + + case FOGDEF_USE_ATEST_GT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GT\n"); + break; + } + + case FOGDEF_USE_ATEST_GE: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GE\n"); + break; + } + + default: + break; + } if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) { @@ -1177,7 +1242,34 @@ int GLSL_BeginLoadGPUShaders(void) if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) { - Q_strcat(extradefines, 1024, "#define USE_DEFORM_VERTEXES\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); + } + + switch ( i & DLIGHTDEF_USE_ATEST_MASK ) + { + case DLIGHTDEF_USE_ATEST_LT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_LT\n"); + break; + } + + case DLIGHTDEF_USE_ATEST_GT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GT\n"); + break; + } + + case DLIGHTDEF_USE_ATEST_GE: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GE\n"); + break; + } + + default: + break; } if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) @@ -1203,40 +1295,40 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (r_deluxeSpecular->value > 0.000001f) - Q_strcat(extradefines, 1024, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); + Q_strcat(extradefines, sizeof(extradefines), va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); if (r_specularIsMetallic->value) - Q_strcat(extradefines, 1024, "#define SPECULAR_IS_METALLIC\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define SPECULAR_IS_METALLIC\n"); if (r_dlightMode->integer >= 2) - Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); if (1) - Q_strcat(extradefines, 1024, "#define SWIZZLE_NORMALMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define SWIZZLE_NORMALMAP\n"); if (r_hdr->integer && !glRefConfig.floatLightmap) - Q_strcat(extradefines, 1024, "#define RGBM_LIGHTMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define RGBM_LIGHTMAP\n"); if (lightType) { - Q_strcat(extradefines, 1024, "#define USE_LIGHT\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT\n"); if (fastLight) - Q_strcat(extradefines, 1024, "#define USE_FAST_LIGHT\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_FAST_LIGHT\n"); switch (lightType) { case LIGHTDEF_USE_LIGHTMAP: - Q_strcat(extradefines, 1024, "#define USE_LIGHTMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHTMAP\n"); if (r_deluxeMapping->integer && !fastLight) - Q_strcat(extradefines, 1024, "#define USE_DELUXEMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DELUXEMAP\n"); attribs |= ATTR_TEXCOORD1 | ATTR_LIGHTDIRECTION; break; case LIGHTDEF_USE_LIGHT_VECTOR: - Q_strcat(extradefines, 1024, "#define USE_LIGHT_VECTOR\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VECTOR\n"); break; case LIGHTDEF_USE_LIGHT_VERTEX: - Q_strcat(extradefines, 1024, "#define USE_LIGHT_VERTEX\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VERTEX\n"); attribs |= ATTR_LIGHTDIRECTION; break; default: @@ -1245,59 +1337,59 @@ int GLSL_BeginLoadGPUShaders(void) if (r_normalMapping->integer) { - Q_strcat(extradefines, 1024, "#define USE_NORMALMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_NORMALMAP\n"); if (r_normalMapping->integer == 2) - Q_strcat(extradefines, 1024, "#define USE_OREN_NAYAR\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_OREN_NAYAR\n"); if (r_normalMapping->integer == 3) - Q_strcat(extradefines, 1024, "#define USE_TRIACE_OREN_NAYAR\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TRIACE_OREN_NAYAR\n"); - Q_strcat(extradefines, 1024, "#define USE_VERT_TANGENT_SPACE\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERT_TANGENT_SPACE\n"); attribs |= ATTR_TANGENT; if ((i & LIGHTDEF_USE_PARALLAXMAP) && r_parallaxMapping->integer) - Q_strcat(extradefines, 1024, "#define USE_PARALLAXMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_PARALLAXMAP\n"); } if (r_specularMapping->integer) { - Q_strcat(extradefines, 1024, "#define USE_SPECULARMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SPECULARMAP\n"); } if (r_cubeMapping->integer) - Q_strcat(extradefines, 1024, "#define USE_CUBEMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_CUBEMAP\n"); } if (i & LIGHTDEF_USE_SHADOWMAP) { - Q_strcat(extradefines, 1024, "#define USE_SHADOWMAP\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); if (r_sunlightMode->integer == 1) - Q_strcat(extradefines, 1024, "#define SHADOWMAP_MODULATE\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define SHADOWMAP_MODULATE\n"); else if (r_sunlightMode->integer == 2) - Q_strcat(extradefines, 1024, "#define USE_PRIMARY_LIGHT\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_PRIMARY_LIGHT\n"); } if (i & LIGHTDEF_USE_TCGEN_AND_TCMOD) { - Q_strcat(extradefines, 1024, "#define USE_TCGEN\n"); - Q_strcat(extradefines, 1024, "#define USE_TCMOD\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCGEN\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } if (i & LIGHTDEF_ENTITY) { if (i & LIGHTDEF_USE_VERTEX_ANIMATION) { - Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); } else if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) { - Q_strcat(extradefines, 1024, "#define USE_SKELETAL_ANIMATION\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } - Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_MODELMATRIX\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; if (r_normalMapping->integer) @@ -1306,8 +1398,35 @@ int GLSL_BeginLoadGPUShaders(void) } } + switch (i & LIGHTDEF_USE_ATEST_MASK) + { + case LIGHTDEF_USE_ATEST_LT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_LT\n"); + break; + } + + case LIGHTDEF_USE_ATEST_GT: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GT\n"); + break; + } + + case LIGHTDEF_USE_ATEST_GE: + { + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_ATEST ATEST_CMP_GE\n"); + break; + } + + default: + break; + } + if (i & LIGHTDEF_USE_GLOW_BUFFER) - Q_strcat(extradefines, 1024, "#define USE_GLOW_BUFFER\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) { @@ -1327,7 +1446,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_NORMAL; extradefines[0] = '\0'; - Q_strcat(extradefines, 1024, "#define USE_PCF\n#define USE_DISCARD\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) { @@ -1368,7 +1487,7 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (!i) - Q_strcat(extradefines, 1024, "#define FIRST_PASS\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) { @@ -1381,15 +1500,15 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (r_shadowFilter->integer >= 1) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER\n"); if (r_shadowFilter->integer >= 2) - Q_strcat(extradefines, 1024, "#define USE_SHADOW_FILTER2\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); - Q_strcat(extradefines, 1024, "#define USE_SHADOW_CASCADE\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_CASCADE\n"); - Q_strcat(extradefines, 1024, va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); - Q_strcat(extradefines, 1024, va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); + Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); + Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) @@ -1413,9 +1532,9 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; if (i & 1) - Q_strcat(extradefines, 1024, "#define USE_VERTICAL_BLUR\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTICAL_BLUR\n"); else - Q_strcat(extradefines, 1024, "#define USE_HORIZONTAL_BLUR\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) @@ -1502,9 +1621,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.genericShader[i]); -#endif numGenShaders++; } @@ -1537,9 +1654,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) } GLSL_InitUniforms(&tr.fogShader[i]); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.fogShader[i]); -#endif numEtcShaders++; } @@ -1558,9 +1673,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.dlightShader[i]); -#endif numEtcShaders++; } @@ -1594,9 +1707,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.lightallShader[i]); -#endif numLightShaders++; } @@ -1607,9 +1718,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) } GLSL_InitUniforms(&tr.shadowmapShader); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.shadowmapShader); -#endif numEtcShaders++; @@ -1624,9 +1733,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.pshadowShader); -#endif numEtcShaders++; @@ -1641,9 +1748,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.down4xShader); -#endif numEtcShaders++; @@ -1658,9 +1763,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.bokehShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.bokehShader); -#endif numEtcShaders++; @@ -1676,9 +1779,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.tonemapShader); -#endif numEtcShaders++; @@ -1695,9 +1796,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.calclevels4xShader[i], UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); -#endif numEtcShaders++; } @@ -1716,9 +1815,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.shadowmaskShader); -#endif numEtcShaders++; @@ -1733,9 +1830,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.ssaoShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.ssaoShader); -#endif numEtcShaders++; @@ -1753,9 +1848,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENDEPTHMAP, TB_LIGHTMAP); qglUseProgram(0); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.depthBlurShader[i]); -#endif numEtcShaders++; } @@ -1769,9 +1862,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.gaussianBlurShader[i]); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.gaussianBlurShader[i]); -#endif numEtcShaders++; } @@ -1783,9 +1874,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.dglowDownsample); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.dglowDownsample); -#endif numEtcShaders++; @@ -1796,9 +1885,7 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_InitUniforms(&tr.dglowUpsample); -#if defined(_DEBUG) GLSL_FinishGPUShader(&tr.dglowUpsample); -#endif numEtcShaders++; @@ -2046,6 +2133,16 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderAttribs |= GENERICDEF_USE_FOG; } + if ( pStage->alphaTestCmp != ATEST_CMP_NONE ) + { + switch ( pStage->alphaTestCmp ) + { + case ATEST_CMP_LT: shaderAttribs |= GENERICDEF_USE_ATEST_LT; break; + case ATEST_CMP_GT: shaderAttribs |= GENERICDEF_USE_ATEST_GT; break; + case ATEST_CMP_GE: shaderAttribs |= GENERICDEF_USE_ATEST_GE; break; + } + } + switch (pStage->rgbGen) { case CGEN_LIGHTING_DIFFUSE: diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 92e923a1db..a61cb4c805 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -670,6 +670,14 @@ typedef enum ST_GLSL } stageType_t; +enum AlphaTestCmp +{ + ATEST_CMP_NONE, + ATEST_CMP_LT, + ATEST_CMP_GT, + ATEST_CMP_GE, +}; + // any change in the LIGHTMAP_* defines here MUST be reflected in // R_FindShader() in tr_bsp.c #define LIGHTMAP_2D -4 // shader is for 2D rendering @@ -681,6 +689,9 @@ typedef struct { qboolean active; qboolean isDetail; qboolean glow; + + AlphaTestCmp alphaTestCmp; + float alphaTestValue; textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; @@ -873,27 +884,17 @@ enum | GLS_DEPTHFUNC_EQUAL | GLS_DEPTHFUNC_GREATER, - GLS_ATEST_GT_0 = (1 << 23), - GLS_ATEST_LT_128 = (1 << 24), - GLS_ATEST_GE_128 = (1 << 25), - GLS_ATEST_GE_192 = (1 << 26), - - GLS_ATEST_BITS = GLS_ATEST_GT_0 - | GLS_ATEST_LT_128 - | GLS_ATEST_GE_128 - | GLS_ATEST_GE_192, - - GLS_REDMASK_FALSE = (1 << 27), - GLS_GREENMASK_FALSE = (1 << 28), - GLS_BLUEMASK_FALSE = (1 << 29), - GLS_ALPHAMASK_FALSE = (1 << 30), + GLS_REDMASK_FALSE = (1 << 23), + GLS_GREENMASK_FALSE = (1 << 24), + GLS_BLUEMASK_FALSE = (1 << 25), + GLS_ALPHAMASK_FALSE = (1 << 26), GLS_COLORMASK_BITS = GLS_REDMASK_FALSE | GLS_GREENMASK_FALSE | GLS_BLUEMASK_FALSE | GLS_ALPHAMASK_FALSE, - GLS_STENCILTEST_ENABLE = (1 << 31), + GLS_STENCILTEST_ENABLE = (1 << 27), GLS_DEFAULT = GLS_DEPTHMASK_TRUE }; @@ -955,48 +956,72 @@ enum enum { - GENERICDEF_USE_DEFORM_VERTEXES = 0x0001, - GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002, - GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, - GENERICDEF_USE_FOG = 0x0008, - GENERICDEF_USE_RGBAGEN = 0x0010, - GENERICDEF_USE_SKELETAL_ANIMATION = 0x0020, - GENERICDEF_USE_GLOW_BUFFER = 0x0040, - GENERICDEF_ALL = 0x007F, - GENERICDEF_COUNT = 0x0080, + GENERICDEF_USE_DEFORM_VERTEXES = 0x0001, + GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002, + GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, + GENERICDEF_USE_FOG = 0x0008, + GENERICDEF_USE_RGBAGEN = 0x0010, + GENERICDEF_USE_SKELETAL_ANIMATION = 0x0020, + GENERICDEF_USE_GLOW_BUFFER = 0x0040, + GENERICDEF_USE_ATEST_LT = 0x0080, + GENERICDEF_USE_ATEST_GT = 0x0100, + GENERICDEF_USE_ATEST_GE = 0x0180, + GENERICDEF_USE_ATEST_MASK = GENERICDEF_USE_ATEST_LT | + GENERICDEF_USE_ATEST_GT | + GENERICDEF_USE_ATEST_GE, + GENERICDEF_ALL = 0x01FF, + GENERICDEF_COUNT = 0x0200, }; enum { - FOGDEF_USE_DEFORM_VERTEXES = 0x0001, - FOGDEF_USE_VERTEX_ANIMATION = 0x0002, - FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, - FOGDEF_ALL = 0x0007, - FOGDEF_COUNT = 0x0008, + FOGDEF_USE_DEFORM_VERTEXES = 0x0001, + FOGDEF_USE_VERTEX_ANIMATION = 0x0002, + FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, + FOGDEF_USE_ATEST_LT = 0x0008, + FOGDEF_USE_ATEST_GT = 0x0010, + FOGDEF_USE_ATEST_GE = 0x0018, + FOGDEF_USE_ATEST_MASK = FOGDEF_USE_ATEST_LT | + FOGDEF_USE_ATEST_GT | + FOGDEF_USE_ATEST_GE, + FOGDEF_ALL = 0x001F, + FOGDEF_COUNT = 0x0020, }; enum { - DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, - DLIGHTDEF_ALL = 0x0001, - DLIGHTDEF_COUNT = 0x0002, + DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, + DLIGHTDEF_USE_ATEST_LT = 0x0002, + DLIGHTDEF_USE_ATEST_GT = 0x0004, + DLIGHTDEF_USE_ATEST_GE = 0x0006, + DLIGHTDEF_USE_ATEST_MASK = DLIGHTDEF_USE_ATEST_LT | + DLIGHTDEF_USE_ATEST_GT | + DLIGHTDEF_USE_ATEST_GE, + DLIGHTDEF_ALL = 0x0007, + DLIGHTDEF_COUNT = 0x0008, }; enum { - LIGHTDEF_USE_LIGHTMAP = 0x0001, - LIGHTDEF_USE_LIGHT_VECTOR = 0x0002, - LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, - LIGHTDEF_LIGHTTYPE_MASK = 0x0003, - LIGHTDEF_ENTITY = 0x0004, - LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, - LIGHTDEF_USE_PARALLAXMAP = 0x0010, - LIGHTDEF_USE_SHADOWMAP = 0x0020, - LIGHTDEF_USE_VERTEX_ANIMATION= 0x0040, - LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0080, - LIGHTDEF_USE_GLOW_BUFFER = 0x0100, - LIGHTDEF_ALL = 0x01FF, - LIGHTDEF_COUNT = 0x0200 + LIGHTDEF_USE_LIGHTMAP = 0x0001, + LIGHTDEF_USE_LIGHT_VECTOR = 0x0002, + LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, + LIGHTDEF_LIGHTTYPE_MASK = 0x0003, + LIGHTDEF_ENTITY = 0x0004, + LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, + LIGHTDEF_USE_PARALLAXMAP = 0x0010, + LIGHTDEF_USE_SHADOWMAP = 0x0020, + LIGHTDEF_USE_VERTEX_ANIMATION = 0x0040, + LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0080, + LIGHTDEF_USE_GLOW_BUFFER = 0x0100, + LIGHTDEF_USE_ATEST_LT = 0x0200, + LIGHTDEF_USE_ATEST_GT = 0x0400, + LIGHTDEF_USE_ATEST_GE = 0x0600, + LIGHTDEF_USE_ATEST_MASK = LIGHTDEF_USE_ATEST_LT | + LIGHTDEF_USE_ATEST_GT | + LIGHTDEF_USE_ATEST_GE, + LIGHTDEF_ALL = 0x07FF, + LIGHTDEF_COUNT = 0x0800 }; enum @@ -1097,6 +1122,7 @@ typedef enum UNIFORM_CUBEMAPINFO, UNIFORM_BONE_MATRICES, + UNIFORM_ALPHA_TEST_VALUE, UNIFORM_COUNT } uniform_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 914be40ff8..9ebfc7261a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -423,20 +423,40 @@ static void ProjectDlightTexture( void ) { } dl = &backEnd.refdef.dlights[l]; - VectorCopy( dl->transformed, origin ); - radius = dl->radius; - scale = 1.0f / radius; - sp = &tr.dlightShader[deformGen == DGEN_NONE ? 0 : 1]; + GL_Bind( tr.dlightImage ); + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + uint32_t shaderCaps = 0; + if ( dl->additive ) { + GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + shaderCaps |= DLIGHTDEF_USE_ATEST_GT; + } + else { + GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + shaderCaps |= DLIGHTDEF_USE_ATEST_GT; + } + + if ( deformGen != DGEN_NONE ) + { + shaderCaps |= DLIGHTDEF_USE_DEFORM_VERTEXES; + } backEnd.pc.c_dlightDraws++; + sp = &tr.dlightShader[shaderCaps]; GLSL_BindProgram(sp); - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + VectorCopy( dl->transformed, origin ); + radius = dl->radius; + scale = 1.0f / radius; + + vec4_t color = {dl->color[0], dl->color[1], dl->color[2], 1.0f}; + vec4_t dlightInfo = {origin[0], origin[1], origin[2], scale}; + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); if (deformType != DEFORM_NONE) { @@ -445,28 +465,8 @@ static void ProjectDlightTexture( void ) { GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); } - vector[0] = dl->color[0]; - vector[1] = dl->color[1]; - vector[2] = dl->color[2]; - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, vector); - - vector[0] = origin[0]; - vector[1] = origin[1]; - vector[2] = origin[2]; - vector[3] = scale; - GLSL_SetUniformVec4(sp, UNIFORM_DLIGHTINFO, vector); - - GL_Bind( tr.dlightImage ); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - if ( dl->additive ) { - GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - } - else { - GL_State( GLS_ATEST_GT_0 | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - } + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + GLSL_SetUniformVec4(sp, UNIFORM_DLIGHTINFO, dlightInfo); if (tess.multiDrawPrimitives) { @@ -1214,6 +1214,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays colorGen_t forceRGBGen = CGEN_BAD; alphaGen_t forceAlphaGen = AGEN_IDENTITY; int index = 0; + bool useAlphaTestGE192 = false; if ( !pStage ) { @@ -1225,6 +1226,37 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays continue; } + stateBits = pStage->stateBits; + + if (backEnd.currentEntity) + { + assert(backEnd.currentEntity->e.renderfx >= 0); + + if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) + { + // we want to be able to rip a hole in the thing being disintegrated, and by doing the depth-testing it avoids some kinds of artefacts, but will probably introduce others? + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; + useAlphaTestGE192 = true; + } + + if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) + {//want to use RGBGen from ent + forceRGBGen = CGEN_ENTITY; + } + + if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) + { + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) + { //depth write, so faces through the model will be stomped over by nearer ones. this works because + //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. + stateBits |= GLS_DEPTHMASK_TRUE; + } + } + } + + GL_State( stateBits ); + if (backEnd.depthFill) { if (pStage->glslShaderGroup == tr.lightallShader) @@ -1246,9 +1278,28 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } } - if (pStage->stateBits & GLS_ATEST_BITS) + if ( !useAlphaTestGE192 ) { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + if (pStage->alphaTestCmp != ATEST_CMP_NONE) + { + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + switch ( pStage->alphaTestCmp ) + { + case ATEST_CMP_LT: + index |= LIGHTDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= LIGHTDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= LIGHTDEF_USE_ATEST_GE; + break; + } + } + } + else + { + index |= LIGHTDEF_USE_ATEST_GE; } sp = &pStage->glslShaderGroup[index]; @@ -1272,9 +1323,28 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays index |= GENERICDEF_USE_SKELETAL_ANIMATION; } - if (pStage->stateBits & GLS_ATEST_BITS) + if ( !useAlphaTestGE192 ) + { + if (pStage->alphaTestCmp != ATEST_CMP_NONE) + { + index |= GENERICDEF_USE_TCGEN_AND_TCMOD; + switch ( pStage->alphaTestCmp ) + { + case ATEST_CMP_LT: + index |= GENERICDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= GENERICDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= GENERICDEF_USE_ATEST_GE; + break; + } + } + } + else { - index |= GENERICDEF_USE_TCGEN_AND_TCMOD; + index |= GENERICDEF_USE_ATEST_GE; } sp = &tr.genericShader[index]; @@ -1284,29 +1354,58 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { index = pStage->glslShaderIndex; - if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + if (r_lightmap->integer && (index & LIGHTDEF_USE_LIGHTMAP)) { - index |= LIGHTDEF_ENTITY; - - if (glState.vertexAnimation) + index = LIGHTDEF_USE_LIGHTMAP; + } + else + { + if (backEnd.currentEntity && + backEnd.currentEntity != &tr.worldEntity) { - index |= LIGHTDEF_USE_VERTEX_ANIMATION; + index |= LIGHTDEF_ENTITY; + + if (glState.vertexAnimation) + { + index |= LIGHTDEF_USE_VERTEX_ANIMATION; + } + + if (glState.skeletalAnimation) + { + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + } } - if (glState.skeletalAnimation) + if (r_sunlightMode->integer && + (backEnd.viewParms.flags & VPF_USESUNLIGHT) && + (index & LIGHTDEF_LIGHTTYPE_MASK)) { - index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } - } - - if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (index & LIGHTDEF_LIGHTTYPE_MASK)) - { - index |= LIGHTDEF_USE_SHADOWMAP; - } + index |= LIGHTDEF_USE_SHADOWMAP; + } - if (r_lightmap->integer && index & LIGHTDEF_USE_LIGHTMAP) - { - index = LIGHTDEF_USE_LIGHTMAP; + if ( !useAlphaTestGE192 ) + { + if (pStage->alphaTestCmp != ATEST_CMP_NONE) + { + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + switch ( pStage->alphaTestCmp ) + { + case ATEST_CMP_LT: + index |= LIGHTDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= LIGHTDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= LIGHTDEF_USE_ATEST_GE; + break; + } + } + } + else + { + index |= LIGHTDEF_USE_ATEST_GE; + } } sp = &pStage->glslShaderGroup[index]; @@ -1347,35 +1446,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); } - stateBits = pStage->stateBits; - - if (backEnd.currentEntity) - { - assert(backEnd.currentEntity->e.renderfx >= 0); - - if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) - { - // we want to be able to rip a hole in the thing being disintegrated, and by doing the depth-testing it avoids some kinds of artefacts, but will probably introduce others? - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE | GLS_ATEST_GE_192; - } - - if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) - {//want to use RGBGen from ent - forceRGBGen = CGEN_ENTITY; - } - - if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) - { - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) - { //depth write, so faces through the model will be stomped over by nearer ones. this works because - //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. - stateBits |= GLS_DEPTHMASK_TRUE; - } - } - } - - GL_State( stateBits ); { vec4_t baseColor; @@ -1457,6 +1527,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); + float alphaTestValue = useAlphaTestGE192 ? 0.75f : pStage->alphaTestValue; + GLSL_SetUniformFloat(sp, UNIFORM_ALPHA_TEST_VALUE, alphaTestValue); + //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); // @@ -1464,7 +1537,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // if ( backEnd.depthFill ) { - if (!(pStage->stateBits & GLS_ATEST_BITS)) + if (pStage->alphaTestCmp == ATEST_CMP_NONE) GL_BindToTMU( tr.whiteImage, 0 ); else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) R_BindAnimatedImageToTMU( &pStage->bundle[TB_COLORMAP], TB_COLORMAP ); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e683f9fb33..09c3fc78ad 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -239,30 +239,39 @@ static qboolean ParseVector( const char **text, int count, float *v ) { /* =============== -NameToAFunc +ParseAlphaTestFunc =============== */ -static unsigned NameToAFunc( const char *funcname ) +static void ParseAlphaTestFunc( shaderStage_t *stage, const char *funcname ) { + stage->alphaTestCmp = ATEST_CMP_NONE; + if ( !Q_stricmp( funcname, "GT0" ) ) { - return GLS_ATEST_GT_0; + stage->alphaTestCmp = ATEST_CMP_GT; + stage->alphaTestValue = 0.0f; } else if ( !Q_stricmp( funcname, "LT128" ) ) { - return GLS_ATEST_LT_128; + stage->alphaTestCmp = ATEST_CMP_LT; + stage->alphaTestValue = 0.5f; } else if ( !Q_stricmp( funcname, "GE128" ) ) { - return GLS_ATEST_GE_128; + stage->alphaTestCmp = ATEST_CMP_GE; + stage->alphaTestValue = 0.5f; } else if ( !Q_stricmp( funcname, "GE192" ) ) { - return GLS_ATEST_GE_192; + stage->alphaTestCmp = ATEST_CMP_GE; + stage->alphaTestValue = 0.75f; + } + else + { + ri->Printf( PRINT_WARNING, + "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", + funcname, shader.name ); } - - ri->Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); - return 0; } @@ -721,7 +730,7 @@ ParseStage static qboolean ParseStage( shaderStage_t *stage, const char **text ) { char *token; - unsigned depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, atestBits = 0, depthFuncBits = 0; + unsigned depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, depthFuncBits = 0; qboolean depthMaskExplicit = qfalse; stage->active = qtrue; @@ -967,7 +976,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } - atestBits = NameToAFunc( token ); + ParseAlphaTestFunc( stage, token ); } // // depthFunc @@ -1568,7 +1577,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // stage->stateBits = depthMaskBits | blendSrcBits | blendDstBits | - atestBits | depthFuncBits; return qtrue; @@ -2535,6 +2543,19 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (diffuse->glow) defs |= LIGHTDEF_USE_GLOW_BUFFER; + switch ( diffuse->alphaTestCmp ) + { + case ATEST_CMP_LT: + defs |= LIGHTDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + defs |= LIGHTDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + defs |= LIGHTDEF_USE_ATEST_GE; + break; + } + //ri->Printf(PRINT_ALL, ".\n"); diffuse->glslShaderGroup = tr.lightallShader; From e0e7ff6e9a72a2b4d80730dca5904fed98117279 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 13 Feb 2016 18:47:41 +0000 Subject: [PATCH 321/708] Tidy up VAO handling --- codemp/rd-rend2/tr_init.cpp | 12 +++++++----- codemp/rd-rend2/tr_local.h | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 585ca88277..0bf62bace6 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -530,19 +530,20 @@ static void InitOpenGL( void ) // initialize extensions GLimp_InitExtensions(); - // set default state - GL_SetDefaultState(); + // Create the default VAO GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); + tr.globalVao = vao; + + // set default state + GL_SetDefaultState(); + R_Splash(); //get something on screen asap } else { // set default state - GLuint vao; - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); GL_SetDefaultState(); } } @@ -1735,6 +1736,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { if ( destroyWindow && restarting ) { + glDeleteVertexArrays(1, &tr.globalVao); SaveGhoul2InfoArray(); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a61cb4c805..051bba70ea 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1984,6 +1984,8 @@ typedef struct trGlobals_s { int frameSceneNum; // zeroed at RE_BeginFrame + GLuint globalVao; + qboolean worldMapLoaded; qboolean worldDeluxeMapping; vec2_t autoExposureMinMax; From 5741f04bd65958d9bde83ea9f9d83f14e77c157e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 13 Feb 2016 18:51:14 +0000 Subject: [PATCH 322/708] Tidying up code/renaming functions --- codemp/rd-rend2/tr_shade.cpp | 22 ++++++++++++++++------ codemp/rd-rend2/tr_surface.cpp | 31 ++++++++++++++++++------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9ebfc7261a..2c154e80b5 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1234,7 +1234,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) { - // we want to be able to rip a hole in the thing being disintegrated, and by doing the depth-testing it avoids some kinds of artefacts, but will probably introduce others? + // we want to be able to rip a hole in the thing being + // disintegrated, and by doing the depth-testing it avoids some + // kinds of artefacts, but will probably introduce others? stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; useAlphaTestGE192 = true; } @@ -1248,8 +1250,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) - { //depth write, so faces through the model will be stomped over by nearer ones. this works because - //we draw RF_FORCE_ENT_ALPHA stuff after everything else, including standard alpha surfs. + { + // depth write, so faces through the model will be stomped + // over by nearer ones. this works because we draw + // RF_FORCE_ENT_ALPHA stuff after everything else, including + // standard alpha surfs. stateBits |= GLS_DEPTHMASK_TRUE; } } @@ -1547,7 +1552,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays int i; vec4_t enableTextures; - if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) + if (r_sunlightMode->integer && + (backEnd.viewParms.flags & VPF_USESUNLIGHT) && + (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP); GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); @@ -1556,7 +1563,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } VectorSet4(enableTextures, 0, 0, 0, 0); - if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && pStage->bundle[TB_LIGHTMAP].image[0]) + if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && + pStage->bundle[TB_LIGHTMAP].image[0]) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { @@ -1644,7 +1652,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // // testing cube map // - if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex && r_cubeMapping->integer) + if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && + input->cubemapIndex && + r_cubeMapping->integer) { vec4_t vec; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b8c1b3e9a5..9164aaa29c 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -46,8 +46,9 @@ RB_CheckOverflow ============== */ void RB_CheckOverflow( int verts, int indexes ) { - if (tess.numVertexes + verts < SHADER_MAX_VERTEXES - && tess.numIndexes + indexes < SHADER_MAX_INDEXES) { + if ((tess.numVertexes + verts) < SHADER_MAX_VERTEXES && + (tess.numIndexes + indexes) < SHADER_MAX_INDEXES) + { return; } @@ -65,7 +66,9 @@ void RB_CheckOverflow( int verts, int indexes ) { void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) { - if (!(vbo == glState.currentVBO && ibo == glState.currentIBO) || tess.multiDrawPrimitives >= MAX_MULTIDRAW_PRIMITIVES) + if (vbo != glState.currentVBO || + ibo != glState.currentIBO || + tess.multiDrawPrimitives >= MAX_MULTIDRAW_PRIMITIVES) { RB_EndSurface(); RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); @@ -455,7 +458,9 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn tess.numVertexes += numVerts; } -static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck) +static qboolean RB_SurfaceVbo( + VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, + int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck) { int i, mergeForward, mergeBack; GLvoid *firstIndexOffset, *lastIndexOffset; @@ -465,7 +470,7 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex return qfalse; } - if (shaderCheck && !(!ShaderRequiresCPUDeforms(tess.shader) && !tess.shader->isSky && !tess.shader->isPortal)) + if (shaderCheck && (ShaderRequiresCPUDeforms(tess.shader) || tess.shader->isSky || tess.shader->isPortal)) { return qfalse; } @@ -560,10 +565,10 @@ static qboolean RB_SurfaceVbo(VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndex /* ============= -RB_SurfaceTriangles +RB_SurfaceBSPTriangles ============= */ -static void RB_SurfaceTriangles( srfBspSurface_t *srf ) { +static void RB_SurfaceBSPTriangles( srfBspSurface_t *srf ) { if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { @@ -1694,8 +1699,8 @@ static void RB_SurfaceMesh(mdvSurface_t *surface) { RB_SurfaceFace ============== */ -static void RB_SurfaceFace( srfBspSurface_t *srf ) { - if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, +static void RB_SurfaceBSPFace( srfBspSurface_t *srf ) { + if( RB_SurfaceVbo(srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; @@ -1743,7 +1748,7 @@ RB_SurfaceGrid Just copy the grid of points and triangulate ============= */ -static void RB_SurfaceGrid( srfBspSurface_t *srf ) { +static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { int i, j; float *xyz; float *texCoords, *lightCoords; @@ -2105,9 +2110,9 @@ static void RB_SurfaceSkip( void *surf ) { void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceBad, // SF_BAD, (void(*)(void*))RB_SurfaceSkip, // SF_SKIP, - (void(*)(void*))RB_SurfaceFace, // SF_FACE, - (void(*)(void*))RB_SurfaceGrid, // SF_GRID, - (void(*)(void*))RB_SurfaceTriangles, // SF_TRIANGLES, + (void(*)(void*))RB_SurfaceBSPFace, // SF_FACE, + (void(*)(void*))RB_SurfaceBSPGrid, // SF_GRID, + (void(*)(void*))RB_SurfaceBSPTriangles, // SF_TRIANGLES, (void(*)(void*))RB_SurfacePolychain, // SF_POLY, (void(*)(void*))RB_SurfaceMesh, // SF_MDV, (void(*)(void*))RB_MDRSurfaceAnim, // SF_MDR, From 949494f54df2ff50fdbcd22ec8bc8b358548930e Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 13 Feb 2016 21:00:29 +0000 Subject: [PATCH 323/708] Minor code tidying --- codemp/rd-rend2/tr_shade.cpp | 12 ++++++++---- codemp/rd-rend2/tr_shader.cpp | 7 +++++-- codemp/rd-rend2/tr_surface.cpp | 5 ++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 2c154e80b5..762ceedf7b 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1880,10 +1880,14 @@ void RB_StageIteratorGeneric( void ) // // now do any dynamic lighting needed // - if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE - && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - if (tess.shader->numUnfoggedPasses == 1 && tess.xstages[0]->glslShaderGroup == tr.lightallShader - && (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && r_dlightMode->integer) + if ( tess.dlightBits && + tess.shader->sort <= SS_OPAQUE && + !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) + { + if (tess.shader->numUnfoggedPasses == 1 && + tess.xstages[0]->glslShaderGroup == tr.lightallShader && + (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && + r_dlightMode->integer) { ForwardDlight(); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 09c3fc78ad..2e9e589ec5 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2376,7 +2376,9 @@ static void ComputeVertexAttribs(void) { shader.vertexAttribs |= ATTR_NORMAL; - if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && !(r_normalMapping->integer == 0 && r_specularMapping->integer == 0)) + if ((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && + (r_normalMapping->integer != 0 || + r_specularMapping->integer != 0)) { shader.vertexAttribs |= ATTR_TANGENT; } @@ -2408,7 +2410,8 @@ static void ComputeVertexAttribs(void) case TCGEN_LIGHTMAP1: case TCGEN_LIGHTMAP2: case TCGEN_LIGHTMAP3: - shader.vertexAttribs |= ATTR_TEXCOORD1; + shader.vertexAttribs |= (ATTR_TEXCOORD1 | ATTR_TEXCOORD2 | + ATTR_TEXCOORD3 | ATTR_TEXCOORD4); break; case TCGEN_ENVIRONMENT_MAPPED: shader.vertexAttribs |= ATTR_NORMAL; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 9164aaa29c..e9c996f936 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -470,7 +470,10 @@ static qboolean RB_SurfaceVbo( return qfalse; } - if (shaderCheck && (ShaderRequiresCPUDeforms(tess.shader) || tess.shader->isSky || tess.shader->isPortal)) + if (shaderCheck && + (ShaderRequiresCPUDeforms(tess.shader) || + tess.shader->isSky || + tess.shader->isPortal)) { return qfalse; } From 722a7c3dd355c0086e4f14dc10fa6013e4776938 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 14 Feb 2016 21:24:57 +0000 Subject: [PATCH 324/708] Fix some compiler warnings --- codemp/game/NPC_move.c | 4 +- codemp/game/bg_pmove.c | 2 +- codemp/game/w_saber.c | 2 +- codemp/qcommon/q_platform.h | 8 +--- codemp/rd-rend2/G2_API.cpp | 87 +++++++++++++++------------------- codemp/rd-rend2/tr_extramath.h | 4 +- codemp/rd-rend2/tr_local.h | 4 +- 7 files changed, 47 insertions(+), 64 deletions(-) diff --git a/codemp/game/NPC_move.c b/codemp/game/NPC_move.c index 7fe0842767..b232b99032 100644 --- a/codemp/game/NPC_move.c +++ b/codemp/game/NPC_move.c @@ -95,7 +95,7 @@ NPC_CheckCombatMove ------------------------- */ -QINLINE qboolean NPC_CheckCombatMove( void ) +static qboolean NPC_CheckCombatMove( void ) { //return NPCInfo->combatMove; if ( ( NPCS.NPCInfo->goalEntity && NPCS.NPC->enemy && NPCS.NPCInfo->goalEntity == NPCS.NPC->enemy ) || ( NPCS.NPCInfo->combatMove ) ) @@ -143,7 +143,7 @@ NPC_GetMoveInformation ------------------------- */ -QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) +static qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) { //NOTENOTE: Use path stacks! diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c index c4180d8e28..d480ab1567 100644 --- a/codemp/game/bg_pmove.c +++ b/codemp/game/bg_pmove.c @@ -259,7 +259,7 @@ qboolean BG_KnockDownable(playerState_t *ps) } //hacky assumption check, assume any client non-humanoid is a rocket trooper -qboolean QINLINE PM_IsRocketTrooper(void) +static qboolean PM_IsRocketTrooper(void) { /* if (pm->ps->clientNum < MAX_CLIENTS && diff --git a/codemp/game/w_saber.c b/codemp/game/w_saber.c index aa283ed4d7..3d9076dfdf 100644 --- a/codemp/game/w_saber.c +++ b/codemp/game/w_saber.c @@ -5238,7 +5238,7 @@ static QINLINE qboolean CheckSaberDamage(gentity_t *self, int rSaberNum, int rBl return didHit; } -QINLINE int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { +static int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { if ( v1[0] > v2[0]+0.0001f || v1[0] < v2[0]-0.0001f || v1[1] > v2[1]+0.0001f || v1[1] < v2[1]-0.0001f || v1[2] > v2[2]+0.0001f || v1[2] < v2[2]-0.0001f ) { diff --git a/codemp/qcommon/q_platform.h b/codemp/qcommon/q_platform.h index 93632340be..f61fbf89b4 100644 --- a/codemp/qcommon/q_platform.h +++ b/codemp/qcommon/q_platform.h @@ -95,7 +95,7 @@ along with this program; if not, see . #endif #define OS_STRING "macosx" - #define QINLINE /*inline*/ + #define QINLINE inline #define PATH_SEP '/' #if defined(__ppc__) @@ -123,11 +123,7 @@ along with this program; if not, see . #define OS_STRING "kFreeBSD" #endif - #ifdef __clang__ - #define QINLINE static inline - #else - #define QINLINE inline - #endif + #define QINLINE inline #define PATH_SEP '/' diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 8e5128f8ba..cc82662dd8 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -889,7 +889,7 @@ qboolean G2API_SetSurfaceOnOff(CGhoul2Info_v &ghoul2, const char *surfaceName, c { CGhoul2Info *ghlInfo = NULL; - if (&ghoul2 && ghoul2.size()>0) + if (ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -1286,7 +1286,7 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch { setFrame=0.0f; } - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1488,7 +1488,7 @@ qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ) { - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1825,7 +1825,7 @@ int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneN { // assert(ghoul2.size()>modelIndex); - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; if (G2_SetupModelPointers(ghlInfo)) @@ -1856,9 +1856,7 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In if (G2_SetupModelPointers(ghoul2From)&&G2_SetupModelPointers(ghoul2To)) { // make sure we have a model to attach, a model to attach to, and a bolt on that model - if (&ghoul2From && - &ghoul2To && - (ghoul2From.size() > modelFrom) && + if ((ghoul2From.size() > modelFrom) && (ghoul2To.size() > toModel) && ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) { @@ -1874,12 +1872,9 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo) { - if (&ghoul2) + if (ghoul2.size() > modelIndex) { - if (ghoul2.size() > modelIndex) - { - ghoul2[modelIndex].mModelBoltLink = boltInfo; - } + ghoul2[modelIndex].mModelBoltLink = boltInfo; } } @@ -1922,7 +1917,7 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde { assert(ghoul2.size() > modelIndex); - if (&ghoul2 && (ghoul2.size() > modelIndex)) + if (ghoul2.size() > modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; @@ -2114,15 +2109,11 @@ void G2API_ListBones(CGhoul2Info *ghlInfo, int frame) // decide if we have Ghoul2 models associated with this ghoul list or not qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2) { - int i; - if (&ghoul2 && ghoul2.size()) + for (int i=0; i modelFrom) { - // assume we actually have a model to copy from - if (ghoul2From.size() > modelFrom) + // if we don't have enough models on the to side, resize us so we do + if (ghoul2To.size() <= modelTo) { - // if we don't have enough models on the to side, resize us so we do - if (ghoul2To.size() <= modelTo) - { - assert (modelTo < 5); - ghoul2To.resize(modelTo + 1); + assert (modelTo < 5); + ghoul2To.resize(modelTo + 1); #if 0 - forceReconstruct = qtrue; + forceReconstruct = qtrue; #endif - } - // do the copy + } + // do the copy - if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) - { //remove the bonecache before we stomp over this instance. - if (ghoul2To[modelTo].mBoneCache) - { - RemoveBoneCache(ghoul2To[modelTo].mBoneCache); - ghoul2To[modelTo].mBoneCache = 0; - } + if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) + { //remove the bonecache before we stomp over this instance. + if (ghoul2To[modelTo].mBoneCache) + { + RemoveBoneCache(ghoul2To[modelTo].mBoneCache); + ghoul2To[modelTo].mBoneCache = 0; } - ghoul2To[modelTo] = ghoul2From[modelFrom]; + } + ghoul2To[modelTo] = ghoul2From[modelFrom]; #if 0 - if (forceReconstruct) - { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, - //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns - //a completely invalid matrix - ghoul2To[0].mSkelFrameNum = 0; - } -#endif + if (forceReconstruct) + { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, + //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns + //a completely invalid matrix + ghoul2To[0].mSkelFrameNum = 0; } +#endif } } @@ -2615,7 +2602,7 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) { if (G2_SetupModelPointers(ghoul2)) { - if (&ghoul2 && (ghoul2.size() > modelIndex)) + if (ghoul2.size() > modelIndex) { //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); //return mod->mdxm->animName; @@ -2631,7 +2618,7 @@ qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex) { CGhoul2Info *ghlInfo = NULL; - if (&ghoul2 && ghoul2.size()>0) + if (ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -2718,7 +2705,7 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) for (i = 0; i < mdxm->numSurfaces; i++) { - if (surf->shader && surf->shader[0]) + if (surf->shader[0]) { //found a surface with a shader name, ok. return qfalse; } diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index e5c480d5b8..bb77b4eeb0 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -60,7 +60,7 @@ void Matrix16SimpleInverse( const matrix_t in, matrix_t out); #define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f)) #define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) ) -static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) +QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) { @@ -69,7 +69,7 @@ static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) return 1; } -static QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) +QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 051bba70ea..feca5a9990 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -801,7 +801,7 @@ typedef struct shader_s { struct shader_s *next; } shader_t; -static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) +QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) { if ( shader->numDeforms > 1 ) { @@ -2495,7 +2495,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS ==================================================================== */ -static QINLINE void GLimp_LogComment( char *comment ) {} +QINLINE void GLimp_LogComment( char *comment ) {} void GLimp_InitExtensions(); /* From 00a6d4323b91ad3be42c014a77dc8538f77e8c90 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 14 Feb 2016 21:42:18 +0000 Subject: [PATCH 325/708] More code tidying --- codemp/rd-rend2/tr_backend.cpp | 38 ++-------- codemp/rd-rend2/tr_local.h | 8 ++ codemp/rd-rend2/tr_shade.cpp | 135 ++++++++++++--------------------- codemp/rd-rend2/tr_shader.cpp | 96 ++++------------------- 4 files changed, 79 insertions(+), 198 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 96df490964..20264fa644 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -110,7 +110,6 @@ void GL_BindToTMU( image_t *image, int tmu ) } } - /* ** GL_Cull */ @@ -312,39 +311,18 @@ void GL_State( uint32_t stateBits ) } } - // - // alpha test - // -#if 0 - if ( diff & GLS_ATEST_BITS ) + if ( diff & GLS_POLYGON_OFFSET_FILL ) { - switch ( stateBits & GLS_ATEST_BITS ) + if ( stateBits & GLS_POLYGON_OFFSET_FILL ) { - case 0: - qglDisable( GL_ALPHA_TEST ); - break; - case GLS_ATEST_GT_0: - qglEnable( GL_ALPHA_TEST ); - qglAlphaFunc( GL_GREATER, 0.0f ); - break; - case GLS_ATEST_LT_128: - qglEnable( GL_ALPHA_TEST ); - qglAlphaFunc( GL_LESS, 0.5f ); - break; - case GLS_ATEST_GE_128: - qglEnable( GL_ALPHA_TEST ); - qglAlphaFunc( GL_GEQUAL, 0.5f ); - break; - case GLS_ATEST_GE_192: - qglEnable( GL_ALPHA_TEST ); - qglAlphaFunc( GL_GEQUAL, 0.75f ); - break; - default: - assert( 0 ); - break; + qglEnable( GL_POLYGON_OFFSET_FILL ); + qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value ); + } + else + { + qglDisable( GL_POLYGON_OFFSET_FILL ); } } -#endif glState.glStateBits = stateBits; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index feca5a9990..1c3ce13b30 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -896,6 +896,8 @@ enum GLS_STENCILTEST_ENABLE = (1 << 27), + GLS_POLYGON_OFFSET_FILL = (1 << 28), + GLS_DEFAULT = GLS_DEPTHMASK_TRUE }; @@ -2414,6 +2416,7 @@ void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); //void GL_TexEnv( int env ); void GL_Cull( int cullType ); +void GL_PolygonOffset( qboolean enabled ); #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) @@ -2566,6 +2569,11 @@ struct shaderCommands_s shaderStage_t **xstages; }; +struct drawState_t +{ + uint32_t stateBits; +}; + #ifdef _WIN32 typedef __declspec(align(16)) shaderCommands_s shaderCommands_t; #else diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 762ceedf7b..70c51e6d2a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1760,11 +1760,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) */ void RB_StageIteratorGeneric( void ) { - shaderCommands_t *input; - uint32_t vertexAttribs = 0; - - input = &tess; - + shaderCommands_t *input = &tess; if (!input->numVertexes || !input->numIndexes) { return; @@ -1780,8 +1776,10 @@ void RB_StageIteratorGeneric( void ) GLimp_LogComment( va("--- RB_StageIteratorGeneric( %s ) ---\n", tess.shader->name) ); } - vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); - + // + // update vertex buffer data + // + uint32_t vertexAttribs = RB_CalcShaderVertexAttribs( input->shader ); if (tess.useInternalVBO) { RB_DeformTessGeometry(); @@ -1797,8 +1795,6 @@ void RB_StageIteratorGeneric( void ) // if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) { - //GL_Cull( CT_TWO_SIDED ); - if (input->shader->cullType == CT_TWO_SIDED) GL_Cull( CT_TWO_SIDED ); else if (input->shader->cullType == CT_FRONT_SIDED) @@ -1810,109 +1806,76 @@ void RB_StageIteratorGeneric( void ) else GL_Cull( input->shader->cullType ); - // set polygon offset if necessary - if ( input->shader->polygonOffset ) - { - qglEnable( GL_POLYGON_OFFSET_FILL ); - qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value ); - } - // - // Set vertex attribs and pointers + // set vertex attribs and pointers // - VertexArraysProperties vertexArrays; GLSL_VertexAttribsState(vertexAttribs, &vertexArrays); - // - // render depth if in depthfill mode - // if (backEnd.depthFill) { - RB_IterateStagesGeneric( input, &vertexArrays ); - // - // reset polygon offset + // render depth if in depthfill mode // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } - - return; + RB_IterateStagesGeneric( input, &vertexArrays ); } - - // - // render shadowmap if in shadowmap mode - // - if (backEnd.viewParms.flags & VPF_SHADOWMAP) + else if (backEnd.viewParms.flags & VPF_SHADOWMAP) { + // + // render shadowmap if in shadowmap mode + // if ( input->shader->sort == SS_OPAQUE ) { RB_RenderShadowmap( input ); } + } + else + { // - // reset polygon offset + // call shader function // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } - - return; - } - - // - // - // call shader function - // - RB_IterateStagesGeneric( input, &vertexArrays ); - - // - // pshadows! - // - if (r_shadows->integer == 4 && tess.pshadowBits && - tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) { - ProjectPshadowVBOGLSL(); - } - + RB_IterateStagesGeneric( input, &vertexArrays ); - // - // now do any dynamic lighting needed - // - if ( tess.dlightBits && - tess.shader->sort <= SS_OPAQUE && - !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) - { - if (tess.shader->numUnfoggedPasses == 1 && - tess.xstages[0]->glslShaderGroup == tr.lightallShader && - (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && - r_dlightMode->integer) + // + // pshadows! + // + if (r_shadows->integer == 4 && + tess.pshadowBits && + tess.shader->sort <= SS_OPAQUE && + !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) { - ForwardDlight(); + ProjectPshadowVBOGLSL(); } - else + + // + // now do any dynamic lighting needed + // + if ( tess.dlightBits && + tess.shader->sort <= SS_OPAQUE && + !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - ProjectDlightTexture(); + if (tess.shader->numUnfoggedPasses == 1 && + tess.xstages[0]->glslShaderGroup == tr.lightallShader && + (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && + r_dlightMode->integer) + { + ForwardDlight(); + } + else + { + ProjectDlightTexture(); + } } - } - // - // now do fog - // - if ( tess.fogNum && tess.shader->fogPass ) { - RB_FogPass(); + // + // now do fog + // + if ( tess.fogNum && tess.shader->fogPass ) { + RB_FogPass(); + } } RB_CommitInternalBufferData(); - - // - // reset polygon offset - // - if ( input->shader->polygonOffset ) - { - qglDisable( GL_POLYGON_OFFSET_FILL ); - } } void RB_BinTriangleCounts( void ) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 2e9e589ec5..73c161078d 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -730,7 +730,10 @@ ParseStage static qboolean ParseStage( shaderStage_t *stage, const char **text ) { char *token; - unsigned depthMaskBits = GLS_DEPTHMASK_TRUE, blendSrcBits = 0, blendDstBits = 0, depthFuncBits = 0; + unsigned depthMaskBits = GLS_DEPTHMASK_TRUE; + unsigned blendSrcBits = 0; + unsigned blendDstBits = 0; + unsigned depthFuncBits = 0; qboolean depthMaskExplicit = qfalse; stage->active = qtrue; @@ -3267,84 +3270,6 @@ static shader_t *FinishShader( void ) { shader.sort = SS_DECAL; } -#if 0 - int firstLightmapStage; - shaderStage_t *lmStage; - - firstLightmapStage = FindFirstLightmapStage (stages, MAX_SHADER_STAGES); - lmStage = &stages[firstLightmapStage]; - - if ( firstLightmapStage != MAX_SHADER_STAGES ) - { - if ( shader.lightmapIndex[0] == LIGHTMAP_BY_VERTEX ) - { - if ( firstLightmapStage == 0 ) - { - /*// Shift all stages above it down 1. - memmove (lmStage, - lmStage + 1, - sizeof (shaderStage_t) * (MAX_SHADER_STAGES - firstLightmapStage - 1)); - memset (stages + MAX_SHADER_STAGES - 1, 0, sizeof (shaderStage_t)); - - // Set state bits back to default on the over-written stage. - lmStage->stateBits = GLS_DEFAULT;*/ - ri->Printf (PRINT_ALL, "Shader '%s' has first stage as lightmap by vertex.\n", shader.name); - } - - /*lmStage->rgbGen = CGEN_EXACT_VERTEX_LIT; - lmStage->alphaGen = AGEN_SKIP; - - firstLightmapStage = MAX_SHADER_STAGES;*/ - } - } - - if ( firstLightmapStage != MAX_SHADER_STAGES ) - { - int numStyles = GetNumStylesInShader (&shader); - - ri->Printf (PRINT_ALL, "Shader '%s' has %d stages with light styles.\n", shader.name, numStyles); - /*if ( numStyles > 0 ) - { - // Move back all stages, after the first lightmap stage, by 'numStyles' elements. - memmove (lmStage + numStyles, - lmStage + 1, - sizeof (shaderStage_t) * (MAX_SHADER_STAGES - firstLightmapStage - numStyles - 1)); - - // Insert new shader stages after first lightmap stage - for ( int i = 1; i <= numStyles; i++ ) - { - shaderStage_t *stage = lmStage + i; - - // Duplicate first lightmap stage into this stage. - *stage = *lmStage; - - if ( shader.lightmapIndex[i] == LIGHTMAP_BY_VERTEX ) - { - stage->bundle[0].image[0] = tr.whiteImage; - } - else if ( shader.lightmapIndex[i] < 0 ) - { - Com_Error (ERR_DROP, "FinishShader: light style with no lightmap or vertex style in shader %s.\n", shader.name); - } - else - { - stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[i]]; - stage->bundle[0].tcGen = (texCoordGen_t)(TCGEN_LIGHTMAP + i); - } - - stage->rgbGen = CGEN_LIGHTMAPSTYLE; - stage->stateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS); - stage->stateBits |= GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; - } - } - - // Set all the light styles for the lightmap stages. - for ( int i = 0; i <= numStyles; i++ ) - { - lmStage[i].lightmapStyle = shader.styles[i]; - }*/ - } -#else int lmStage; for(lmStage = 0; lmStage < MAX_SHADER_STAGES; lmStage++) { @@ -3420,7 +3345,6 @@ static shader_t *FinishShader( void ) { stages[lmStage+i].lightmapStyle = shader.styles[i]; } } -#endif // // set appropriate stage information @@ -3432,14 +3356,22 @@ static shader_t *FinishShader( void ) { break; } - // check for a missing texture + // check for a missing texture if ( !pStage->bundle[0].image[0] ) { - ri->Printf( PRINT_WARNING, "Shader %s has a stage with no image\n", shader.name ); + ri->Printf( PRINT_WARNING, "Shader %s, stage %d has no image. This stage will be ignored\n", shader.name, stage + 1 ); pStage->active = qfalse; stage++; continue; } + // + // add additional state bits + // + if ( shader.polygonOffset ) + { + pStage->stateBits |= GLS_POLYGON_OFFSET_FILL; + } + // // ditch this stage if it's detail and detail textures are disabled // From 3a7a0d7fe2ae8e22d509f6627b34ff44354804ae Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 14 Feb 2016 21:42:36 +0000 Subject: [PATCH 326/708] Revert "Fix some compiler warnings" This reverts commit 722a7c3dd355c0086e4f14dc10fa6013e4776938. --- codemp/game/NPC_move.c | 4 +- codemp/game/bg_pmove.c | 2 +- codemp/game/w_saber.c | 2 +- codemp/qcommon/q_platform.h | 8 +++- codemp/rd-rend2/G2_API.cpp | 87 +++++++++++++++++++--------------- codemp/rd-rend2/tr_extramath.h | 4 +- codemp/rd-rend2/tr_local.h | 4 +- 7 files changed, 64 insertions(+), 47 deletions(-) diff --git a/codemp/game/NPC_move.c b/codemp/game/NPC_move.c index b232b99032..7fe0842767 100644 --- a/codemp/game/NPC_move.c +++ b/codemp/game/NPC_move.c @@ -95,7 +95,7 @@ NPC_CheckCombatMove ------------------------- */ -static qboolean NPC_CheckCombatMove( void ) +QINLINE qboolean NPC_CheckCombatMove( void ) { //return NPCInfo->combatMove; if ( ( NPCS.NPCInfo->goalEntity && NPCS.NPC->enemy && NPCS.NPCInfo->goalEntity == NPCS.NPC->enemy ) || ( NPCS.NPCInfo->combatMove ) ) @@ -143,7 +143,7 @@ NPC_GetMoveInformation ------------------------- */ -static qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) +QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) { //NOTENOTE: Use path stacks! diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c index d480ab1567..c4180d8e28 100644 --- a/codemp/game/bg_pmove.c +++ b/codemp/game/bg_pmove.c @@ -259,7 +259,7 @@ qboolean BG_KnockDownable(playerState_t *ps) } //hacky assumption check, assume any client non-humanoid is a rocket trooper -static qboolean PM_IsRocketTrooper(void) +qboolean QINLINE PM_IsRocketTrooper(void) { /* if (pm->ps->clientNum < MAX_CLIENTS && diff --git a/codemp/game/w_saber.c b/codemp/game/w_saber.c index 3d9076dfdf..aa283ed4d7 100644 --- a/codemp/game/w_saber.c +++ b/codemp/game/w_saber.c @@ -5238,7 +5238,7 @@ static QINLINE qboolean CheckSaberDamage(gentity_t *self, int rSaberNum, int rBl return didHit; } -static int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { +QINLINE int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { if ( v1[0] > v2[0]+0.0001f || v1[0] < v2[0]-0.0001f || v1[1] > v2[1]+0.0001f || v1[1] < v2[1]-0.0001f || v1[2] > v2[2]+0.0001f || v1[2] < v2[2]-0.0001f ) { diff --git a/codemp/qcommon/q_platform.h b/codemp/qcommon/q_platform.h index f61fbf89b4..93632340be 100644 --- a/codemp/qcommon/q_platform.h +++ b/codemp/qcommon/q_platform.h @@ -95,7 +95,7 @@ along with this program; if not, see . #endif #define OS_STRING "macosx" - #define QINLINE inline + #define QINLINE /*inline*/ #define PATH_SEP '/' #if defined(__ppc__) @@ -123,7 +123,11 @@ along with this program; if not, see . #define OS_STRING "kFreeBSD" #endif - #define QINLINE inline + #ifdef __clang__ + #define QINLINE static inline + #else + #define QINLINE inline + #endif #define PATH_SEP '/' diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index cc82662dd8..8e5128f8ba 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -889,7 +889,7 @@ qboolean G2API_SetSurfaceOnOff(CGhoul2Info_v &ghoul2, const char *surfaceName, c { CGhoul2Info *ghlInfo = NULL; - if (ghoul2.size()>0) + if (&ghoul2 && ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -1286,7 +1286,7 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch { setFrame=0.0f; } - if (ghoul2.size()>modelIndex) + if (&ghoul2 && ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1488,7 +1488,7 @@ qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ) { - if (ghoul2.size()>modelIndex) + if (&ghoul2 && ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1825,7 +1825,7 @@ int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneN { // assert(ghoul2.size()>modelIndex); - if (ghoul2.size()>modelIndex) + if (&ghoul2 && ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; if (G2_SetupModelPointers(ghlInfo)) @@ -1856,7 +1856,9 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In if (G2_SetupModelPointers(ghoul2From)&&G2_SetupModelPointers(ghoul2To)) { // make sure we have a model to attach, a model to attach to, and a bolt on that model - if ((ghoul2From.size() > modelFrom) && + if (&ghoul2From && + &ghoul2To && + (ghoul2From.size() > modelFrom) && (ghoul2To.size() > toModel) && ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) { @@ -1872,9 +1874,12 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo) { - if (ghoul2.size() > modelIndex) + if (&ghoul2) { - ghoul2[modelIndex].mModelBoltLink = boltInfo; + if (ghoul2.size() > modelIndex) + { + ghoul2[modelIndex].mModelBoltLink = boltInfo; + } } } @@ -1917,7 +1922,7 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde { assert(ghoul2.size() > modelIndex); - if (ghoul2.size() > modelIndex) + if (&ghoul2 && (ghoul2.size() > modelIndex)) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; @@ -2109,11 +2114,15 @@ void G2API_ListBones(CGhoul2Info *ghlInfo, int frame) // decide if we have Ghoul2 models associated with this ghoul list or not qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2) { - for (int i=0; i modelFrom) + // have we real ghoul2 models yet? + if (&ghoul2From && &ghoul2To) { - // if we don't have enough models on the to side, resize us so we do - if (ghoul2To.size() <= modelTo) + // assume we actually have a model to copy from + if (ghoul2From.size() > modelFrom) { - assert (modelTo < 5); - ghoul2To.resize(modelTo + 1); + // if we don't have enough models on the to side, resize us so we do + if (ghoul2To.size() <= modelTo) + { + assert (modelTo < 5); + ghoul2To.resize(modelTo + 1); #if 0 - forceReconstruct = qtrue; + forceReconstruct = qtrue; #endif - } - // do the copy + } + // do the copy - if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) - { //remove the bonecache before we stomp over this instance. - if (ghoul2To[modelTo].mBoneCache) - { - RemoveBoneCache(ghoul2To[modelTo].mBoneCache); - ghoul2To[modelTo].mBoneCache = 0; + if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) + { //remove the bonecache before we stomp over this instance. + if (ghoul2To[modelTo].mBoneCache) + { + RemoveBoneCache(ghoul2To[modelTo].mBoneCache); + ghoul2To[modelTo].mBoneCache = 0; + } } - } - ghoul2To[modelTo] = ghoul2From[modelFrom]; + ghoul2To[modelTo] = ghoul2From[modelFrom]; #if 0 - if (forceReconstruct) - { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, - //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns - //a completely invalid matrix - ghoul2To[0].mSkelFrameNum = 0; - } + if (forceReconstruct) + { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, + //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns + //a completely invalid matrix + ghoul2To[0].mSkelFrameNum = 0; + } #endif + } } } @@ -2602,7 +2615,7 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) { if (G2_SetupModelPointers(ghoul2)) { - if (ghoul2.size() > modelIndex) + if (&ghoul2 && (ghoul2.size() > modelIndex)) { //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); //return mod->mdxm->animName; @@ -2618,7 +2631,7 @@ qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex) { CGhoul2Info *ghlInfo = NULL; - if (ghoul2.size()>0) + if (&ghoul2 && ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -2705,7 +2718,7 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) for (i = 0; i < mdxm->numSurfaces; i++) { - if (surf->shader[0]) + if (surf->shader && surf->shader[0]) { //found a surface with a shader name, ok. return qfalse; } diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index bb77b4eeb0..e5c480d5b8 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -60,7 +60,7 @@ void Matrix16SimpleInverse( const matrix_t in, matrix_t out); #define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f)) #define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) ) -QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) +static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) { @@ -69,7 +69,7 @@ QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) return 1; } -QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) +static QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 1c3ce13b30..712235df4f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -801,7 +801,7 @@ typedef struct shader_s { struct shader_s *next; } shader_t; -QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) +static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) { if ( shader->numDeforms > 1 ) { @@ -2498,7 +2498,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS ==================================================================== */ -QINLINE void GLimp_LogComment( char *comment ) {} +static QINLINE void GLimp_LogComment( char *comment ) {} void GLimp_InitExtensions(); /* From 4aa48f862123d12522096213e35dccc5a25e4153 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 14 Feb 2016 21:50:47 +0000 Subject: [PATCH 327/708] Fix QINLINE warnings on OSX --- codemp/game/NPC_move.c | 5 ++--- codemp/game/bg_pmove.c | 2 +- codemp/game/w_saber.c | 2 +- codemp/qcommon/q_platform.h | 2 +- codemp/rd-rend2/tr_extramath.h | 4 ++-- codemp/rd-rend2/tr_local.h | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/codemp/game/NPC_move.c b/codemp/game/NPC_move.c index 7fe0842767..baddac0f3d 100644 --- a/codemp/game/NPC_move.c +++ b/codemp/game/NPC_move.c @@ -95,7 +95,7 @@ NPC_CheckCombatMove ------------------------- */ -QINLINE qboolean NPC_CheckCombatMove( void ) +static QINLINE qboolean NPC_CheckCombatMove( void ) { //return NPCInfo->combatMove; if ( ( NPCS.NPCInfo->goalEntity && NPCS.NPC->enemy && NPCS.NPCInfo->goalEntity == NPCS.NPC->enemy ) || ( NPCS.NPCInfo->combatMove ) ) @@ -142,8 +142,7 @@ static void NPC_LadderMove( vec3_t dir ) NPC_GetMoveInformation ------------------------- */ - -QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) +static QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) { //NOTENOTE: Use path stacks! diff --git a/codemp/game/bg_pmove.c b/codemp/game/bg_pmove.c index c4180d8e28..e8a0a97177 100644 --- a/codemp/game/bg_pmove.c +++ b/codemp/game/bg_pmove.c @@ -259,7 +259,7 @@ qboolean BG_KnockDownable(playerState_t *ps) } //hacky assumption check, assume any client non-humanoid is a rocket trooper -qboolean QINLINE PM_IsRocketTrooper(void) +static qboolean QINLINE PM_IsRocketTrooper(void) { /* if (pm->ps->clientNum < MAX_CLIENTS && diff --git a/codemp/game/w_saber.c b/codemp/game/w_saber.c index aa283ed4d7..7e4f361028 100644 --- a/codemp/game/w_saber.c +++ b/codemp/game/w_saber.c @@ -5238,7 +5238,7 @@ static QINLINE qboolean CheckSaberDamage(gentity_t *self, int rSaberNum, int rBl return didHit; } -QINLINE int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { +static QINLINE int VectorCompare2( const vec3_t v1, const vec3_t v2 ) { if ( v1[0] > v2[0]+0.0001f || v1[0] < v2[0]-0.0001f || v1[1] > v2[1]+0.0001f || v1[1] < v2[1]-0.0001f || v1[2] > v2[2]+0.0001f || v1[2] < v2[2]-0.0001f ) { diff --git a/codemp/qcommon/q_platform.h b/codemp/qcommon/q_platform.h index 93632340be..68a1b5d299 100644 --- a/codemp/qcommon/q_platform.h +++ b/codemp/qcommon/q_platform.h @@ -95,7 +95,7 @@ along with this program; if not, see . #endif #define OS_STRING "macosx" - #define QINLINE /*inline*/ + #define QINLINE inline #define PATH_SEP '/' #if defined(__ppc__) diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index e5c480d5b8..bb77b4eeb0 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -60,7 +60,7 @@ void Matrix16SimpleInverse( const matrix_t in, matrix_t out); #define RGBtosRGB(a) (((a) < 0.0031308f) ? (12.92f * (a)) : (1.055f * pow((a), 0.41666f) - 0.055f)) #define sRGBtoRGB(a) (((a) <= 0.04045f) ? ((a) / 12.92f) : (pow((((a) + 0.055f) / 1.055f), 2.4)) ) -static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) +QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3]) { @@ -69,7 +69,7 @@ static QINLINE int VectorCompare4(const vec4_t v1, const vec4_t v2) return 1; } -static QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) +QINLINE int VectorCompare5(const vec5_t v1, const vec5_t v2) { if(v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2] || v1[3] != v2[3] || v1[4] != v2[4]) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 712235df4f..a0e5a810cb 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -801,7 +801,7 @@ typedef struct shader_s { struct shader_s *next; } shader_t; -static QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) +QINLINE qboolean ShaderRequiresCPUDeforms(const shader_t * shader) { if ( shader->numDeforms > 1 ) { @@ -2498,7 +2498,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS ==================================================================== */ -static QINLINE void GLimp_LogComment( char *comment ) {} +QINLINE void GLimp_LogComment( char *comment ) {} void GLimp_InitExtensions(); /* From 1c0b26837bc896eb1c9533a03566aeb8283eeec0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 21 Feb 2016 19:57:47 +0000 Subject: [PATCH 328/708] Prelim implementation for surface sprites. Currently the billboards are fixed-size, and don't rotate to face the camera. Also only vertical sprites work atm. --- codemp/rd-rend2/glsl/compact.cpp | 2 +- codemp/rd-rend2/glsl/surface_sprites_fp.glsl | 15 + codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 32 ++ codemp/rd-rend2/qgl.h | 1 + codemp/rd-rend2/tr_backend.cpp | 92 ++++ codemp/rd-rend2/tr_bsp.cpp | 234 ++++++++- codemp/rd-rend2/tr_extensions.cpp | 2 + codemp/rd-rend2/tr_glsl.cpp | 80 ++- codemp/rd-rend2/tr_init.cpp | 4 +- codemp/rd-rend2/tr_local.h | 100 +++- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 17 +- codemp/rd-rend2/tr_shader.cpp | 526 ++++++++++++++++++- codemp/rd-rend2/tr_surface.cpp | 24 + codemp/rd-rend2/tr_vbo.cpp | 2 - codemp/rd-rend2/tr_world.cpp | 16 +- 16 files changed, 1040 insertions(+), 109 deletions(-) create mode 100644 codemp/rd-rend2/glsl/surface_sprites_fp.glsl create mode 100644 codemp/rd-rend2/glsl/surface_sprites_vp.glsl diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 9b615054b5..72a4cb6f63 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -120,4 +120,4 @@ int main ( int argc, char *argv[] ) } ofs << output; -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl new file mode 100644 index 0000000000..57e927f759 --- /dev/null +++ b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl @@ -0,0 +1,15 @@ +uniform sampler2D u_DiffuseMap; + +in vec2 var_TexCoords; + +out vec4 out_Color; +out vec4 out_Glow; + +void main() +{ + out_Color = texture(u_DiffuseMap, var_TexCoords); + if ( out_Color.a < 0.5 ) + discard; + + out_Glow = vec4(0.0); +} diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl new file mode 100644 index 0000000000..d656409ca3 --- /dev/null +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -0,0 +1,32 @@ +in vec3 attr_Position; +in vec3 attr_Normal; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec2 var_TexCoords; + +void main() +{ + int vertexID = gl_VertexID; + const vec3 offsets[] = vec3[]( + vec3(-10.0, 0.0, 0.0), + vec3( 10.0, 0.0, 0.0), + vec3(-10.0, 0.0, 40.0), + vec3( 10.0, 0.0, 0.0), + vec3( 10.0, 0.0, 40.0), + vec3(-10.0, 0.0, 40.0) + ); + + const vec2 texcoords[] = vec2[]( + vec2(0.0, 1.0), + vec2(1.0, 1.0), + vec2(0.0, 0.0), + vec2(1.0, 1.0), + vec2(1.0, 0.0), + vec2(0.0, 0.0) + ); + + vec4 worldPos = vec4(attr_Position + offsets[gl_VertexID], 1.0); + gl_Position = u_ModelViewProjectionMatrix * worldPos; + var_TexCoords = texcoords[gl_VertexID]; +} diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 4af9d5217e..45a65f4bb6 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -375,6 +375,7 @@ extern PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC qglMultiDrawElementsBaseVertex; // Vertex arrays extern PFNGLVERTEXATTRIBPOINTERPROC qglVertexAttribPointer; extern PFNGLVERTEXATTRIBIPOINTERPROC qglVertexAttribIPointer; +extern PFNGLVERTEXATTRIBDIVISORPROC qglVertexAttribDivisor; extern PFNGLENABLEVERTEXATTRIBARRAYPROC qglEnableVertexAttribArray; extern PFNGLDISABLEVERTEXATTRIBARRAYPROC qglDisableVertexAttribArray; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 20264fa644..e9b4a237a0 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -327,6 +327,98 @@ void GL_State( uint32_t stateBits ) glState.glStateBits = stateBits; } +void GL_VertexAttribPointers( + size_t numAttributes, + vertexAttribute_t *attributes ) +{ + assert(attributes != nullptr || numAttributes == 0); + + uint32_t newAttribs = 0; + for ( int i = 0; i < numAttributes; i++ ) + { + vertexAttribute_t& attrib = attributes[i]; + + newAttribs |= (1 << attrib.index); + if ( memcmp(&glState.currentVaoAttribs[attrib.index], &attrib, + sizeof(glState.currentVaoAttribs[attrib.index])) == 0 ) + { + // No change + continue; + } + + R_BindVBO(attrib.vbo); + if ( attrib.integerAttribute ) + { + qglVertexAttribIPointer(attrib.index, + attrib.numComponents, + attrib.type, + attrib.stride, + BUFFER_OFFSET(attrib.offset)); + } + else + { + qglVertexAttribPointer(attrib.index, + attrib.numComponents, + attrib.type, + attrib.normalize, + attrib.stride, + BUFFER_OFFSET(attrib.offset)); + } + qglVertexAttribDivisor(attrib.index, attrib.stepRate); + + glState.currentVaoAttribs[attrib.index] = attrib; + } + + uint32_t diff = newAttribs ^ glState.vertexAttribsState; + if ( diff ) + { + for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + { + // FIXME: Use BitScanForward? + if (diff & j) + { + if(newAttribs & j) + qglEnableVertexAttribArray(i); + else + qglDisableVertexAttribArray(i); + } + } + + glState.vertexAttribsState = newAttribs; + } +} + +void GL_DrawIndexed( + GLenum primitiveType, + int numIndices, + int offset, + int numInstances, + int baseVertex) +{ + assert(numInstances > 0); + qglDrawElementsInstancedBaseVertex( + primitiveType, + numIndices, + GL_INDEX_TYPE, + BUFFER_OFFSET(offset), + numInstances, + baseVertex); +} + +void GL_MultiDrawIndexed( + GLenum primitiveType, + int *numIndices, + glIndex_t **offsets, + int numDraws) +{ + assert(numDraws > 0); + qglMultiDrawElements( + primitiveType, + numIndices, + GL_INDEX_TYPE, + (const GLvoid **)offsets, + numDraws); +} void GL_SetProjectionMatrix(matrix_t matrix) { diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 99952d25f4..a233befc2f 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_map.c #include "tr_local.h" +#include /* @@ -679,6 +680,9 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, realLightmapNum[j] = FatLightmap (LittleLong (ds->lightmapNum[j])); } + surf->numSurfaceSprites = 0; + surf->surfaceSprites = nullptr; + // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -837,6 +841,9 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, realLightmapNum[j] = FatLightmap (LittleLong (ds->lightmapNum[j])); } + surf->numSurfaceSprites = 0; + surf->surfaceSprites = nullptr; + // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -937,6 +944,9 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor int i, j; int numVerts, numIndexes, badTriangles; + surf->numSurfaceSprites = 0; + surf->surfaceSprites = nullptr; + // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -1067,6 +1077,9 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int srfFlare_t *flare; int i; + surf->numSurfaceSprites = 0; + surf->surfaceSprites = nullptr; + // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; @@ -1832,33 +1845,6 @@ static int BSPSurfaceCompare(const void *a, const void *b) return 0; } - -static void CopyVert(const srfVert_t * in, srfVert_t * out) -{ - int j; - - for(j = 0; j < 3; j++) - { - out->xyz[j] = in->xyz[j]; - out->tangent[j] = in->tangent[j]; - out->normal[j] = in->normal[j]; - out->lightdir[j] = in->lightdir[j]; - } - - out->tangent[3] = in->tangent[3]; - - for(j = 0; j < 2; j++) - { - out->st[j] = in->st[j]; - Com_Memcpy (out->lightmap[j], in->lightmap[j], sizeof (out->lightmap[0])); - } - - for(j = 0; j < 4; j++) - { - Com_Memcpy (out->vertexColors[j], in->vertexColors[j], sizeof (out->vertexColors[0])); - } -} - struct packedVertex_t { vec3_t position; @@ -3042,7 +3028,7 @@ R_MergeLeafSurfaces Merges surfaces that share a common leaf ================= */ -void R_MergeLeafSurfaces(void) +static void R_MergeLeafSurfaces(void) { int i, j, k; int numWorldSurfaces; @@ -3379,7 +3365,11 @@ static void R_CalcVertexLightDirs( void ) case SF_GRID: case SF_TRIANGLES: for(i = 0; i < bspSurf->numVerts; i++) - R_LightDirForPoint( bspSurf->verts[i].xyz, bspSurf->verts[i].lightdir, bspSurf->verts[i].normal, &s_worldData ); + R_LightDirForPoint( + bspSurf->verts[i].xyz, + bspSurf->verts[i].lightdir, + bspSurf->verts[i].normal, + &s_worldData ); break; @@ -3389,6 +3379,190 @@ static void R_CalcVertexLightDirs( void ) } } +struct sprite_t +{ + vec3_t position; + vec3_t normal; +}; + +static uint32_t UpdateHash( const char *text, uint32_t hash ) +{ + for ( int i = 0; text[i]; ++i ) + { + char letter = tolower((unsigned char)text[i]); + if (letter == '.') break; // don't include extension + if (letter == '\\') letter = '/'; // damn path names + if (letter == PATH_SEP) letter = '/'; // damn path names + + hash += (uint32_t)(letter)*(i+119); + } + + return (hash ^ (hash >> 10) ^ (hash >> 20)); +} + +static void R_GenerateSurfaceSprites( + const srfBspSurface_t *bspSurf, + const shaderStage_t *stage, + srfSprites_t *out) +{ + const surfaceSprite_t *surfaceSprite = stage->ss; + const textureBundle_t *bundle = &stage->bundle[0]; + + const float density = surfaceSprite->density; + const srfVert_t *verts = bspSurf->verts; + const glIndex_t *indexes = bspSurf->indexes; + + std::vector sprites; + sprites.reserve(10000); + for ( int i = 0, numIndexes = bspSurf->numIndexes; i < numIndexes; i += 3 ) + { + const srfVert_t *v0 = verts + indexes[i + 0]; + const srfVert_t *v1 = verts + indexes[i + 1]; + const srfVert_t *v2 = verts + indexes[i + 2]; + + vec3_t p0, p1, p2; + VectorCopy(v0->xyz, p0); + VectorCopy(v1->xyz, p1); + VectorCopy(v2->xyz, p2); + + vec3_t n0, n1, n2; + VectorCopy(v0->normal, n0); + VectorCopy(v1->normal, n1); + VectorCopy(v2->normal, n2); + + const vec2_t p01 = {p1[0] - p0[0], p1[1] - p0[1]}; + const vec2_t p02 = {p2[0] - p0[0], p2[1] - p0[1]}; + + const float zarea = std::fabsf(p02[0]*p01[1] - p02[1]*p01[0]); + if ( zarea <= 1.0 ) + { + // Triangle's area is too small to consider. + continue; + } + + // Generate the positions of the surface sprites. + // + // Pick random points inside of each triangle, using barycentric + // coordinates. + const float step = density * Q_rsqrt(zarea); + for ( float a = 0.0f; a < 1.0f; a += step ) + { + for ( float b = 0.0f, bend = (1.0f - a); b < bend; b += step ) + { + float x = random()*step + a; + float y = random()*step + b; + float z = 1.0f - x - y; + + // Ensure we're inside the triangle bounds. + if ( x > 1.0f ) continue; + if ( (x + y ) > 1.0f ) continue; + + // Calculate position inside triangle. + // pos = (((p0*x) + p1*y) + p2*z) + sprite_t sprite = {}; + VectorMA(sprite.position, x, p0, sprite.position); + VectorMA(sprite.position, y, p1, sprite.position); + VectorMA(sprite.position, z, p2, sprite.position); + + VectorMA(sprite.normal, x, n0, sprite.normal); + VectorMA(sprite.normal, y, n1, sprite.normal); + VectorMA(sprite.normal, z, n2, sprite.normal); + VectorNormalize(sprite.normal); + + // We have 4 copies for each corner of the quad + sprites.push_back(sprite); + } + } + } + + uint32_t hash = 0; + for ( int i = 0; bundle->image[i]; ++i ) + { + hash = UpdateHash(bundle->image[i]->imgName, hash); + } + + out->surfaceType = SF_SPRITES; + out->spriteType = surfaceSprite->type; + out->numSprites = sprites.size(); + out->vbo = R_CreateVBO((byte *)sprites.data(), + sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); + out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), + bundle, stage->stateBits); + out->shader->stages[0]->glslShaderGroup = &tr.spriteShader; + out->numAttributes = 2; + out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( + sizeof(vertexAttribute_t) * 2, h_low); + + out->attributes[0].vbo = out->vbo; + out->attributes[0].index = 0; + out->attributes[0].numComponents = 3; + out->attributes[0].integerAttribute = qfalse; + out->attributes[0].type = GL_FLOAT; + out->attributes[0].normalize = GL_FALSE; + out->attributes[0].stride = sizeof(sprite_t); + out->attributes[0].offset = offsetof(sprite_t, position); + out->attributes[0].stepRate = 1; + + out->attributes[1].vbo = out->vbo; + out->attributes[1].index = 1; + out->attributes[1].numComponents = 3; + out->attributes[1].integerAttribute = qfalse; + out->attributes[1].type = GL_FLOAT; + out->attributes[1].normalize = GL_FALSE; + out->attributes[1].stride = sizeof(sprite_t); + out->attributes[1].stepRate = 1; +} + +static void R_GenerateSurfaceSprites( const world_t *world ) +{ + msurface_t *surfaces = world->surfaces; + for ( int i = 0, numSurfaces = world->numsurfaces; i < numSurfaces; ++i ) + { + msurface_t *surf = surfaces + i; + const srfBspSurface_t *bspSurf = (srfBspSurface_t *)surf->data; + switch ( bspSurf->surfaceType ) + { + case SF_FACE: + case SF_GRID: + case SF_TRIANGLES: + { + const shader_t *shader = surf->shader; + if ( !shader->numSurfaceSpriteStages ) + { + continue; + } + + surf->numSurfaceSprites = shader->numSurfaceSpriteStages; + surf->surfaceSprites = (srfSprites_t *)ri->Hunk_Alloc( + sizeof(srfSprites_t) * surf->numSurfaceSprites, h_low); + + int surfaceSpriteNum = 0; + for ( int j = 0, numStages = shader->numUnfoggedPasses; + j < numStages; ++j ) + { + const shaderStage_t *stage = shader->stages[j]; + if ( !stage ) + { + break; + } + + if ( !stage->ss || stage->ss->type == SURFSPRITE_NONE ) + { + continue; + } + + srfSprites_t *sprite = surf->surfaceSprites + surfaceSpriteNum; + R_GenerateSurfaceSprites(bspSurf, stage, sprite); + ++surfaceSpriteNum; + } + break; + } + + default: + break; + } + } +} /* ================= @@ -3479,6 +3653,8 @@ void RE_LoadWorldMap( const char *name ) { R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); + + R_GenerateSurfaceSprites(&s_worldData); // determine vertex light directions R_CalcVertexLightDirs(); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index b211510478..772dd9100e 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -39,6 +39,7 @@ PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC qglMultiDrawElementsBaseVertex; // Vertex arrays PFNGLVERTEXATTRIBPOINTERPROC qglVertexAttribPointer; PFNGLVERTEXATTRIBIPOINTERPROC qglVertexAttribIPointer; +PFNGLVERTEXATTRIBDIVISORPROC qglVertexAttribDivisor; PFNGLENABLEVERTEXATTRIBARRAYPROC qglEnableVertexAttribArray; PFNGLDISABLEVERTEXATTRIBARRAYPROC qglDisableVertexAttribArray; @@ -311,6 +312,7 @@ void GLimp_InitExtensions() // Vertex arrays GetGLFunction (qglVertexAttribPointer, "glVertexAttribPointer", qtrue); GetGLFunction (qglVertexAttribIPointer, "glVertexAttribIPointer", qtrue); + GetGLFunction (qglVertexAttribDivisor, "glVertexAttribDivisor", qtrue); GetGLFunction (qglEnableVertexAttribArray, "glEnableVertexAttribArray", qtrue); GetGLFunction (qglDisableVertexAttribArray, "glDisableVertexAttribArray", qtrue); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 1dbe2cf5cd..205c265888 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -58,6 +58,8 @@ extern const char *fallbackShader_dglow_downsample_vp; extern const char *fallbackShader_dglow_downsample_fp; extern const char *fallbackShader_dglow_upsample_vp; extern const char *fallbackShader_dglow_upsample_fp; +extern const char *fallbackShader_surface_sprites_vp; +extern const char *fallbackShader_surface_sprites_fp; typedef struct uniformInfo_s { @@ -1594,6 +1596,15 @@ int GLSL_BeginLoadGPUShaders(void) ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); } + attribs = ATTR_POSITION | ATTR_NORMAL; + extradefines[0] = '\0'; + if (!GLSL_BeginLoadGPUShader(&tr.spriteShader, "surface_sprites", attribs, + qtrue, extradefines, fallbackShader_surface_sprites_vp, + fallbackShader_surface_sprites_fp)) + { + ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); + } + return startTime; } @@ -1889,6 +1900,13 @@ void GLSL_EndLoadGPUShaders ( int startTime ) numEtcShaders++; + if (!GLSL_EndLoadGPUShader(&tr.spriteShader)) + ri->Error(ERR_FATAL, "Could not compile surface sprites shader!"); + + GLSL_InitUniforms(&tr.spriteShader); + GLSL_FinishGPUShader(&tr.spriteShader); + numEtcShaders++; + #if 0 attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; @@ -2025,23 +2043,6 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA GLSL_VertexAttribPointers(stateBits, vertexArrays); - uint32_t diff = stateBits ^ glState.vertexAttribsState; - if ( diff ) - { - for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) - { - // FIXME: Use BitScanForward? - if (diff & j) - { - if(stateBits & j) - qglEnableVertexAttribArray(i); - else - qglDisableVertexAttribArray(i); - } - } - - glState.vertexAttribsState = stateBits; - } } void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays) @@ -2060,7 +2061,7 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); } - const struct + static const struct { int numComponents; GLboolean integerAttribute; @@ -2085,41 +2086,24 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal2 }; + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { int attributeIndex = vertexArrays->enabledAttributes[i]; + vertexAttribute_t& attrib = attribs[i]; - if ( glState.currentVaoVbo[attributeIndex] == glState.currentVBO->vertexesVBO && - glState.currentVaoOffsets[attributeIndex] == vertexArrays->offsets[attributeIndex] && - glState.currentVaoStrides[attributeIndex] == vertexArrays->strides[attributeIndex] ) - { - // No change - continue; - } - - if ( attributes[attributeIndex].integerAttribute ) - { - qglVertexAttribIPointer(attributeIndex, - attributes[attributeIndex].numComponents, - attributes[attributeIndex].type, - vertexArrays->strides[attributeIndex], - BUFFER_OFFSET(vertexArrays->offsets[attributeIndex])); - } - else - { - qglVertexAttribPointer(attributeIndex, - attributes[attributeIndex].numComponents, - attributes[attributeIndex].type, - attributes[attributeIndex].normalize, - vertexArrays->strides[attributeIndex], - BUFFER_OFFSET(vertexArrays->offsets[attributeIndex])); - } - - glState.currentVaoVbo[attributeIndex] = glState.currentVBO->vertexesVBO; - glState.currentVaoStrides[attributeIndex] = vertexArrays->strides[attributeIndex]; - glState.currentVaoOffsets[attributeIndex] = vertexArrays->offsets[attributeIndex]; - glState.vertexAttribPointersSet |= (1 << attributeIndex); + attrib.vbo = glState.currentVBO; + attrib.index = attributeIndex; + attrib.numComponents = attributes[attributeIndex].numComponents; + attrib.integerAttribute = attributes[attributeIndex].integerAttribute; + attrib.type = attributes[attributeIndex].type; + attrib.normalize = attributes[attributeIndex].normalize; + attrib.stride = vertexArrays->strides[attributeIndex]; + attrib.offset = vertexArrays->offsets[attributeIndex]; + attrib.stepRate = 0; } + + GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 0bf62bace6..2463078772 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -235,6 +235,7 @@ cvar_t *r_marksOnTriangleMeshes; cvar_t *r_aviMotionJpegQuality; cvar_t *r_screenshotJpegQuality; +cvar_t *r_surfaceSprites; // the limits apply to the sum of all scenes in a frame -- // the main view, all the 3D icons, etc @@ -1094,11 +1095,9 @@ void GL_SetDefaultState( void ) // in a multitexture environment GL_SelectTexture( 1 ); GL_TextureMode( r_textureMode->string ); - //GL_TexEnv( GL_MODULATE ); GL_SelectTexture( 0 ); GL_TextureMode( r_textureMode->string ); - //GL_TexEnv( GL_MODULATE ); //qglShadeModel( GL_SMOOTH ); qglDepthFunc( GL_LEQUAL ); @@ -1523,6 +1522,7 @@ void R_Register( void ) r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); + r_surfaceSprites = ri->Cvar_Get("r_surfaceSprites", "1", CVAR_ARCHIVE); r_maxpolys = ri->Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0); r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0 ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a0e5a810cb..838c05b084 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -246,6 +246,7 @@ extern cvar_t *r_marksOnTriangleMeshes; extern cvar_t *r_aviMotionJpegQuality; extern cvar_t *r_screenshotJpegQuality; +extern cvar_t *r_surfaceSprites; extern cvar_t *r_maxpolys; extern int max_polys; @@ -623,6 +624,46 @@ typedef struct { } texModInfo_t; +enum surfaceSpriteType_t +{ + SURFSPRITE_NONE, + SURFSPRITE_VERTICAL, + SURFSPRITE_ORIENTED, + SURFSPRITE_EFFECT, + SURFSPRITE_WEATHERFX, + SURFSPRITE_FLATTENED, +}; + +enum surfaceSpriteOrientation_t +{ + SURFSPRITE_FACING_NORMAL, + SURFSPRITE_FACING_UP, + SURFSPRITE_FACING_DOWN, + SURFSPRITE_FACING_ANY, +}; + +struct surfaceSprite_t +{ + surfaceSpriteType_t type; + + float width; + float height; + float density; + float wind; + float windIdle; + float fadeDist; + float fadeMax; + float fadeScale; + float fxAlphaStart; + float fxAlphaEnd; + float fxDuration; + float vertSkew; + + vec2_t variance; + vec2_t fxGrow; + surfaceSpriteOrientation_t facing; +}; + #define MAX_IMAGE_ANIMATIONS (32) typedef struct { @@ -716,7 +757,7 @@ typedef struct { vec4_t normalScale; vec4_t specularScale; - qboolean isSurfaceSprite; + surfaceSprite_t *ss; } shaderStage_t; @@ -789,6 +830,7 @@ typedef struct shader_s { deformStage_t deforms[MAX_SHADER_DEFORMS]; int numUnfoggedPasses; + int numSurfaceSpriteStages; shaderStage_t *stages[MAX_SHADER_STAGES]; void (*optimalStageIteratorFunc)( void ); @@ -1147,6 +1189,13 @@ typedef struct shaderProgram_s char *uniformBuffer; } shaderProgram_t; +struct technique_t +{ + shaderProgram_t *depthPrepass; + shaderProgram_t *shadow; + shaderProgram_t *forward; +}; + // trRefdef_t holds everything that comes in refdef_t, // as well as the locally generated scene information typedef struct { @@ -1277,6 +1326,7 @@ typedef enum { SF_ENTITY, // beams, rails, lightning, etc that can be determined by entity SF_VBO_MESH, SF_VBO_MDVMESH, + SF_SPRITES, SF_NUM_SURFACE_TYPES, SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) @@ -1335,6 +1385,21 @@ typedef struct srfFlare_s { vec3_t color; } srfFlare_t; +struct vertexAttribute_t; +struct srfSprites_t +{ + surfaceType_t surfaceType; + + shader_t *shader; + surfaceSpriteType_t spriteType; + int numSprites; + VBO_t *vbo; + IBO_t *ibo; + + int numAttributes; + vertexAttribute_t *attributes; +}; + typedef struct { vec3_t xyz; @@ -1527,6 +1592,9 @@ typedef struct msurface_s { int cubemapIndex; cullinfo_t cullinfo; + int numSurfaceSprites; + srfSprites_t *surfaceSprites; + surfaceType_t *data; // any of srf*_t } msurface_t; @@ -1814,6 +1882,18 @@ typedef struct { #define FUNCTABLE_SIZE2 10 #define FUNCTABLE_MASK (FUNCTABLE_SIZE-1) +struct vertexAttribute_t +{ + VBO_t *vbo; + int index; + int numComponents; + GLboolean integerAttribute; + GLenum type; + GLboolean normalize; + int stride; + int offset; + int stepRate; +}; // the renderer front end should never modify glstate_t typedef struct glstate_s { @@ -1823,7 +1903,7 @@ typedef struct glstate_s { int faceCulling; uint32_t glStateBits; uint32_t vertexAttribsState; - uint32_t vertexAttribPointersSet; + vertexAttribute_t currentVaoAttribs[ATTR_INDEX_MAX]; uint32_t vertexAttribsNewFrame; uint32_t vertexAttribsOldFrame; float vertexAttribsInterpolation; @@ -1839,9 +1919,6 @@ typedef struct glstate_s { matrix_t modelview; matrix_t projection; matrix_t modelviewProjection; - int currentVaoVbo[ATTR_INDEX_MAX]; - int currentVaoStrides[ATTR_INDEX_MAX]; - int currentVaoOffsets[ATTR_INDEX_MAX]; } glstate_t; typedef enum { @@ -2090,7 +2167,7 @@ typedef struct trGlobals_s { shaderProgram_t glowCompositeShader; shaderProgram_t dglowDownsample; shaderProgram_t dglowUpsample; - + shaderProgram_t spriteShader; // ----------------------------------------- @@ -2400,6 +2477,7 @@ int R_CullLocalPointAndRadius( const vec3_t origin, float radius ); void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum); void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, orientationr_t *ori ); +void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ); /* ** GL wrapper/helper functions @@ -2417,6 +2495,12 @@ void GL_SetModelviewMatrix(matrix_t matrix); //void GL_TexEnv( int env ); void GL_Cull( int cullType ); void GL_PolygonOffset( qboolean enabled ); +void GL_VertexAttribPointers(size_t numAttributes, + vertexAttribute_t *attributes); +void GL_DrawIndexed(GLenum primitiveType, int numIndices, int offset, + int numInstances, int baseVertex); +void GL_MultiDrawIndexed(GLenum primitiveType, int *numIndices, + glIndex_t **offsets, int numDraws); #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) @@ -2489,6 +2573,10 @@ shader_t *R_FindShaderByName( const char *name ); void R_InitShaders( qboolean server ); void R_ShaderList_f( void ); void R_RemapShader(const char *oldShader, const char *newShader, const char *timeOffset); +shader_t *R_CreateShaderFromTextureBundle( + const char *name, + const textureBundle_t *bundle, + uint32_t stateBits); /* ==================================================================== diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index cc73652617..22a4c299f6 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2892,4 +2892,4 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) { RE_EndScene(); } -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 70c51e6d2a..004fdee331 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -44,14 +44,21 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { - qglDrawRangeElements(GL_TRIANGLES, minIndex, maxIndex, numIndexes, GL_INDEX_TYPE, BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)) + (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0)); + int offset = firstIndex * sizeof(glIndex_t) + + (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + + GL_DrawIndexed(GL_TRIANGLES, numIndexes, offset, 1, 0); } static void R_DrawMultiElementsVBO( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex, GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex) { - qglMultiDrawElements(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives); + GL_MultiDrawIndexed( + GL_TRIANGLES, + multiDrawNumIndexes, + multiDrawFirstIndex, + multiDrawPrimitives); } @@ -72,7 +79,7 @@ R_BindAnimatedImageToTMU ================= */ -static void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { +void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { int index; if ( bundle->isVideoMap ) { @@ -1221,7 +1228,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays break; } - if ( pStage->isSurfaceSprite ) + if ( pStage->ss ) { continue; } @@ -1753,8 +1760,6 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) } } - - /* ** RB_StageIteratorGeneric */ diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 73c161078d..ae23e71b37 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -722,6 +722,482 @@ static const char *animMapNames[] = { "oneshotanimMap" }; +static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) +{ + const char *token; + const char **text = &buffer; + surfaceSpriteType_t sstype = SURFSPRITE_NONE; + + // spritetype + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", + shader.name); + return false; + } + + if ( !Q_stricmp(token, "vertical") ) + { + sstype = SURFSPRITE_VERTICAL; + } + else if ( !Q_stricmp(token, "oriented") ) + { + sstype = SURFSPRITE_ORIENTED; + } + else if ( !Q_stricmp(token, "effect") ) + { + sstype = SURFSPRITE_EFFECT; + } + else if ( !Q_stricmp(token, "flattened") ) + { + sstype = SURFSPRITE_FLATTENED; + } + else + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: invalid type in shader '%s'\n", + shader.name); + return false; + } + + // width + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", + shader.name); + return false; + } + + float width = atof(token); + if ( width <= 0.0f ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: invalid width in shader '%s'\n", + shader.name); + return false; + } + + // height + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", + shader.name); + return false; + } + + float height = atof(token); + if ( height <= 0.0f ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: invalid height in shader '%s'\n", + shader.name); + return false; + } + + // density + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", + shader.name); + return false; + } + + float density = atof(token); + if ( density <= 0.0f ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: invalid density in shader '%s'\n", + shader.name); + return false; + } + + // fadedist + token = COM_ParseExt( text, qfalse ); + if ( token[0] == '\0' ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", + shader.name); + return false; + } + + float fadedist = atof(token); + if ( fadedist < 32.0f ) + { + ri->Printf(PRINT_ALL, + S_COLOR_YELLOW "WARNING: invalid fadedist (%.2f < 32) in shader '%s'\n", + fadedist, shader.name); + return false; + } + + if ( !stage->ss ) + { + stage->ss = (surfaceSprite_t *)Hunk_Alloc( sizeof( surfaceSprite_t ), h_low ); + + } + + // These are all set by the command lines. + stage->ss->type = sstype; + stage->ss->width = width; + stage->ss->height = height; + stage->ss->density = density; + stage->ss->fadeDist = fadedist; + + // These are defaults that can be overwritten. + stage->ss->fadeMax = fadedist * 1.33f; + stage->ss->fadeScale = 0.0f; + stage->ss->wind = 0.0f; + stage->ss->windIdle = 0.0f; + stage->ss->variance[0] = 0.0f; + stage->ss->variance[1] = 0.0f; + stage->ss->facing = SURFSPRITE_FACING_NORMAL; + + // A vertical parameter that needs a default regardless + stage->ss->vertSkew = 0.0f; + + // These are effect parameters that need defaults nonetheless. + stage->ss->fxDuration = 1000; // 1 second + stage->ss->fxGrow[0] = 0.0f; + stage->ss->fxGrow[1] = 0.0f; + stage->ss->fxAlphaStart = 1.0f; + stage->ss->fxAlphaEnd = 0.0f; + + return true; +} + +// Parses the following keywords in a shader stage: +// +// ssFademax +// ssFadescale +// ssVariance +// ssHangdown +// ssAnyangle +// ssFaceup +// ssWind +// ssWindIdle +// ssVertSkew +// ssFXDuration +// ssFXGrow +// ssFXAlphaRange +// ssFXWeather +static bool ParseSurfaceSpritesOptional( + const char *param, + const char *buffer, + shaderStage_t *stage +) +{ + const char *token; + const char **text = &buffer; + float value; + + if (!stage->ss) + { + stage->ss = (surfaceSprite_t *)Hunk_Alloc( sizeof( surfaceSprite_t ), h_low ); + } + + // TODO: Tidy this up some how. There's a lot of repeated code + + // + // fademax + // + if (!Q_stricmp(param, "ssFademax")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fademax in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value <= stage->ss->fadeDist) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fademax (%.2f <= fadeDist(%.2f)) in shader '%s'\n", value, stage->ss->fadeDist, shader.name ); + return false; + } + stage->ss->fadeMax=value; + return true; + } + + // + // fadescale + // + if (!Q_stricmp(param, "ssFadescale")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fadescale in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + stage->ss->fadeScale=value; + return true; + } + + // + // variance + // + if (!Q_stricmp(param, "ssVariance")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance width in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance width in shader '%s'\n", shader.name ); + return false; + } + stage->ss->variance[0]=value; + + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance height in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance height in shader '%s'\n", shader.name ); + return false; + } + stage->ss->variance[1]=value; + return true; + } + + // + // hangdown + // + if (!Q_stricmp(param, "ssHangdown")) + { + if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Hangdown facing overrides previous facing in shader '%s'\n", shader.name ); + return false; + } + stage->ss->facing=SURFSPRITE_FACING_DOWN; + return true; + } + + // + // anyangle + // + if (!Q_stricmp(param, "ssAnyangle")) + { + if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Anyangle facing overrides previous facing in shader '%s'\n", shader.name ); + return false; + } + stage->ss->facing=SURFSPRITE_FACING_ANY; + return true; + } + + // + // faceup + // + if (!Q_stricmp(param, "ssFaceup")) + { + if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Faceup facing overrides previous facing in shader '%s'\n", shader.name ); + return false; + } + stage->ss->facing=SURFSPRITE_FACING_UP; + return true; + } + + // + // wind + // + if (!Q_stricmp(param, "ssWind")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite wind in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0.0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite wind in shader '%s'\n", shader.name ); + return false; + } + stage->ss->wind=value; + if (stage->ss->windIdle <= 0) + { // Also override the windidle, it usually is the same as wind + stage->ss->windIdle = value; + } + return true; + } + + // + // windidle + // + if (!Q_stricmp(param, "ssWindidle")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite windidle in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0.0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite windidle in shader '%s'\n", shader.name ); + return false; + } + stage->ss->windIdle=value; + return true; + } + + // + // vertskew + // + if (!Q_stricmp(param, "ssVertskew")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite vertskew in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0.0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite vertskew in shader '%s'\n", shader.name ); + return false; + } + stage->ss->vertSkew=value; + return true; + } + + // + // fxduration + // + if (!Q_stricmp(param, "ssFXDuration")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite duration in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value <= 0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite duration in shader '%s'\n", shader.name ); + return false; + } + stage->ss->fxDuration=value; + return true; + } + + // + // fxgrow + // + if (!Q_stricmp(param, "ssFXGrow")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow width in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow width in shader '%s'\n", shader.name ); + return false; + } + stage->ss->fxGrow[0]=value; + + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow height in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow height in shader '%s'\n", shader.name ); + return false; + } + stage->ss->fxGrow[1]=value; + return true; + } + + // + // fxalpharange + // + if (!Q_stricmp(param, "ssFXAlphaRange")) + { + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha start in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0 || value > 1.0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha start in shader '%s'\n", shader.name ); + return false; + } + stage->ss->fxAlphaStart=value; + + token = COM_ParseExt( text, qfalse); + if (token[0]==0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha end in shader '%s'\n", shader.name ); + return false; + } + value = atof(token); + if (value < 0 || value > 1.0) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha end in shader '%s'\n", shader.name ); + return false; + } + stage->ss->fxAlphaEnd=value; + return true; + } + + // + // fxweather + // + if (!Q_stricmp(param, "ssFXWeather")) + { + if (stage->ss->type != SURFSPRITE_EFFECT) + { + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: weather applied to non-effect surfacesprite in shader '%s'\n", shader.name ); + return false; + } + stage->ss->type = SURFSPRITE_WEATHERFX; + return true; + } + + // + // invalid ss command. + // + ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid optional surfacesprite param '%s' in shader '%s'\n", param, shader.name ); + return false; +} + /* =================== ParseStage @@ -1483,12 +1959,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // surfaceSprites ... // - else if ( !Q_stricmp( token, "surfaceSprites" ) ) + else if ( !Q_stricmp( token, "surfacesprites" ) ) { - // Mark this stage as a surface sprite so we can skip it for now - stage->isSurfaceSprite = qtrue; - SkipRestOfLine( text ); - /*char buffer[1024] = ""; + char buffer[1024] = {}; while ( 1 ) { @@ -1499,7 +1972,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strcat( buffer, sizeof( buffer ), " " ); } - ParseSurfaceSprites( buffer, stage );*/ + bool hasSS = (stage->ss != nullptr); + if ( ParseSurfaceSprites( buffer, stage ) && !hasSS ) + { + ++shader.numSurfaceSpriteStages; + } continue; } @@ -1516,23 +1993,26 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // ssGrow // ssWeather // - else if (!Q_stricmpn(token, "ss", 2)) // <--- NOTE ONLY COMPARING FIRST TWO LETTERS + else if (!Q_stricmpn(token, "ss", 2)) { - SkipRestOfLine( text ); - /*char buffer[1024] = ""; - char param[128]; - strcpy(param,token); + char buffer[1024] = {}; + char param[128] = {}; + Q_strncpyz( param, token, sizeof( param ) ); while ( 1 ) { token = COM_ParseExt( text, qfalse ); - if ( token[0] == 0 ) + if ( token[0] == '\0' ) break; Q_strcat( buffer, sizeof( buffer ), token ); Q_strcat( buffer, sizeof( buffer ), " " ); } - ParseSurfaceSpritesOptional( param, buffer, stage );*/ + bool hasSS = (stage->ss != nullptr); + if ( ParseSurfaceSpritesOptional( param, buffer, stage ) && !hasSS ) + { + ++shader.numSurfaceSpriteStages; + } continue; } @@ -4292,6 +4772,26 @@ static void ScanAndLoadShaderFiles( void ) } +shader_t *R_CreateShaderFromTextureBundle( + const char *name, + const textureBundle_t *bundle, + uint32_t stateBits) +{ + shader_t *result = R_FindShaderByName(name); + if ( result == tr.defaultShader ) + { + Com_Memset(&shader, 0, sizeof(shader)); + Com_Memset(&stages, 0, sizeof(stages)); + + Q_strncpyz(shader.name, name, sizeof(shader.name)); + + stages[0].active = qtrue; + stages[0].bundle[0] = *bundle; + stages[0].stateBits = stateBits; + result = FinishShader(); + } + return result; +} /* ==================== diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index e9c996f936..217fd36388 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2109,6 +2109,29 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) static void RB_SurfaceSkip( void *surf ) { } +static void RB_SurfaceSprites( srfSprites_t *surf ) +{ + if ( !r_surfaceSprites->integer ) + { + return; + } + + RB_EndSurface(); + + // TODO: Check which pass (z-prepass/shadow/forward) we're rendering for? + shader_t *shader = surf->shader; + shaderStage_t *firstStage = shader->stages[0]; + shaderProgram_t *program = firstStage->glslShaderGroup; + + GLSL_BindProgram(program); + GL_State(firstStage->stateBits); + GL_VertexAttribPointers(surf->numAttributes, surf->attributes); + R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); + GLSL_SetUniformMatrix4x4(program, + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + //GL_DrawIndexed(GL_TRIANGLES, 6, 0, surf->numSprites, 0); + qglDrawArraysInstanced(GL_TRIANGLES, 0, 6, surf->numSprites); +} void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceBad, // SF_BAD, @@ -2125,4 +2148,5 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceEntity, // SF_ENTITY (void(*)(void*))RB_SurfaceVBOMesh, // SF_VBO_MESH, (void(*)(void*))RB_SurfaceVBOMDVMesh, // SF_VBO_MDVMESH + (void(*)(void*))RB_SurfaceSprites, // SF_SPRITES }; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index e361993ce8..0a1b870cee 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -223,7 +223,6 @@ void R_BindVBO(VBO_t * vbo) if(glState.currentVBO != vbo) { glState.currentVBO = vbo; - glState.vertexAttribPointersSet = 0; glState.vertexAttribsInterpolation = 0; glState.vertexAttribsOldFrame = 0; @@ -299,7 +298,6 @@ void R_BindNullIBO(void) { qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glState.currentIBO = NULL; - glState.vertexAttribPointersSet = 0; } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 96d79fcb59..41b977e7e5 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -341,7 +341,21 @@ static void R_AddWorldSurface( msurface_t *surf, int entityNum, int dlightBits, pshadowBits = ( pshadowBits != 0 ); }*/ - R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, R_IsPostRenderEntity (entityNum, tr.currentEntity), surf->cubemapIndex ); + bool isPostRenderEntity = + R_IsPostRenderEntity(entityNum, tr.currentEntity); + R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, + dlightBits, isPostRenderEntity, surf->cubemapIndex ); + + if ( surf->numSurfaceSprites ) + { + for ( int i = 0, numSprites = surf->numSurfaceSprites; + i < numSprites; ++i ) + { + srfSprites_t *sprites = surf->surfaceSprites + i; + R_AddDrawSurf((surfaceType_t *)sprites, entityNum, sprites->shader, + surf->fogIndex, dlightBits, isPostRenderEntity, 0); + } + } } /* From 5b6e991a5ce045b0f1133f21b9a3f6038ffe3cf1 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 21 Feb 2016 23:13:21 +0000 Subject: [PATCH 329/708] Rend2: Orientate the sprites towards the camera Still need to add some shader flags to let the game choose the combination. --- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 11 ++++++++++- codemp/rd-rend2/tr_surface.cpp | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index d656409ca3..e549e90ae1 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -2,6 +2,7 @@ in vec3 attr_Position; in vec3 attr_Normal; uniform mat4 u_ModelViewProjectionMatrix; +uniform vec3 u_ViewOrigin; out vec2 var_TexCoords; @@ -26,7 +27,15 @@ void main() vec2(0.0, 0.0) ); - vec4 worldPos = vec4(attr_Position + offsets[gl_VertexID], 1.0); +#if 1 + vec2 toCamera = normalize(u_ViewOrigin.xy - attr_Position.xy); + vec2 perp = vec2(toCamera.y, -toCamera.x); + vec3 offset = vec3(perp*offsets[gl_VertexID].x, offsets[gl_VertexID].z); +#else + vec3 offset = offsets[gl_VertexID]; +#endif + + vec4 worldPos = vec4(attr_Position + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; var_TexCoords = texcoords[gl_VertexID]; } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 217fd36388..a9a7afdac8 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2129,7 +2129,8 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); GLSL_SetUniformMatrix4x4(program, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - //GL_DrawIndexed(GL_TRIANGLES, 6, 0, surf->numSprites, 0); + GLSL_SetUniformVec3(program, + UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); qglDrawArraysInstanced(GL_TRIANGLES, 0, 6, surf->numSprites); } From 2061924cc7f15b330349c756736fbd32f3511398 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 12:33:21 +0000 Subject: [PATCH 330/708] Rend2: Rough first impl for uniform buffer support --- codemp/rd-rend2/glsl/surface_sprites_fp.glsl | 17 ++++++++ codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 46 +++++++++++++++----- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_cmds.cpp | 5 +++ codemp/rd-rend2/tr_glsl.cpp | 38 +++++++++++----- codemp/rd-rend2/tr_init.cpp | 17 ++++++++ codemp/rd-rend2/tr_local.h | 34 ++++++++++++++- codemp/rd-rend2/tr_surface.cpp | 29 ++++++++++++ codemp/rd-rend2/tr_vbo.cpp | 1 + 10 files changed, 164 insertions(+), 27 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl index 57e927f759..6101d5b328 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl @@ -2,14 +2,31 @@ uniform sampler2D u_DiffuseMap; in vec2 var_TexCoords; +#if defined(ALPHA_TEST) +uniform float u_AlphaTestValue; +#endif + +layout(std140) uniform SurfaceSprite +{ + float u_Width; + float u_Height; + float u_FadeStartDistance; + float u_FadeEndDistance; + float u_FadeScale; + float u_WidthVariance; + float u_HeightVariance; +}; + out vec4 out_Color; out vec4 out_Glow; void main() { out_Color = texture(u_DiffuseMap, var_TexCoords); +//#if defined(ALPHA_TEST) if ( out_Color.a < 0.5 ) discard; +//#endif out_Glow = vec4(0.0); } diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index e549e90ae1..994dc281b9 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -4,18 +4,39 @@ in vec3 attr_Normal; uniform mat4 u_ModelViewProjectionMatrix; uniform vec3 u_ViewOrigin; +layout(std140) uniform SurfaceSprite +{ + float u_Width; + float u_Height; + float u_FadeStartDistance; + float u_FadeEndDistance; + float u_FadeScale; + float u_WidthVariance; + float u_HeightVariance; +}; + out vec2 var_TexCoords; void main() { + vec3 V = u_ViewOrigin - attr_Position; int vertexID = gl_VertexID; - const vec3 offsets[] = vec3[]( - vec3(-10.0, 0.0, 0.0), - vec3( 10.0, 0.0, 0.0), - vec3(-10.0, 0.0, 40.0), - vec3( 10.0, 0.0, 0.0), - vec3( 10.0, 0.0, 40.0), - vec3(-10.0, 0.0, 40.0) + + float width = u_Width * (1.0 + u_WidthVariance*0.5); + float height = u_Height * (1.0 + u_HeightVariance*0.5); + + float distanceToCamera = length(V); + float widthScale = smoothstep(u_FadeStartDistance, u_FadeEndDistance, + distanceToCamera); + width += u_FadeScale * widthScale * u_Width; + + vec3 offsets[] = vec3[]( + vec3(-width * 0.5, 0.0, 0.0), + vec3( width * 0.5, 0.0, 0.0), + vec3(-width * 0.5, 0.0, height), + vec3( width * 0.5, 0.0, 0.0), + vec3( width * 0.5, 0.0, height), + vec3(-width * 0.5, 0.0, height) ); const vec2 texcoords[] = vec2[]( @@ -27,12 +48,15 @@ void main() vec2(0.0, 0.0) ); -#if 1 - vec2 toCamera = normalize(u_ViewOrigin.xy - attr_Position.xy); + vec3 preOffset = offsets[gl_VertexID]; + preOffset.x += width; + +#if defined(FACE_CAMERA) + vec2 toCamera = normalize(V.xy); vec2 perp = vec2(toCamera.y, -toCamera.x); - vec3 offset = vec3(perp*offsets[gl_VertexID].x, offsets[gl_VertexID].z); + vec3 offset = vec3(perp*preOffset.x, preOffset.z); #else - vec3 offset = offsets[gl_VertexID]; + vec3 offset = preOffset; #endif vec4 worldPos = vec4(attr_Position + offset, 1.0); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e9b4a237a0..811fd7d88b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1746,7 +1746,7 @@ static const void *RB_SwapBuffers( const void *data ) { } int frameNumber = backEndData->realFrameNumber; - gpuFrame_t *currentFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; + gpuFrame_t *currentFrame = backEndData->currentFrame; assert( !currentFrame->sync ); currentFrame->sync = qglFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 ); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a233befc2f..4221da53df 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3482,7 +3482,7 @@ static void R_GenerateSurfaceSprites( } out->surfaceType = SF_SPRITES; - out->spriteType = surfaceSprite->type; + out->sprite = surfaceSprite; out->numSprites = sprites.size(); out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index e29c96ce0b..786b1f2301 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -476,6 +476,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { int frameNumber = backEndData->realFrameNumber; gpuFrame_t *thisFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; + backEndData->currentFrame = thisFrame; if ( thisFrame->sync ) { GLsync sync = thisFrame->sync; @@ -502,6 +503,10 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } qglDeleteSync( sync ); thisFrame->sync = NULL; + + // Set the frame uniform buffer + qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo); + thisFrame->uboWriteOffset = 0; } tr.frameCount++; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 205c265888..803a8fd960 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -61,6 +61,10 @@ extern const char *fallbackShader_dglow_upsample_fp; extern const char *fallbackShader_surface_sprites_vp; extern const char *fallbackShader_surface_sprites_fp; +const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { + { 10, "SurfaceSprite", sizeof(SurfaceSpriteBlock) } +}; + typedef struct uniformInfo_s { char *name; @@ -682,25 +686,20 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, void GLSL_InitUniforms(shaderProgram_t *program) { - int i, size; - - GLint *uniforms; - - program->uniforms = (GLint *)Z_Malloc (UNIFORM_COUNT * sizeof (*program->uniforms), TAG_GENERAL); - program->uniformBufferOffsets = (short *)Z_Malloc (UNIFORM_COUNT * sizeof (*program->uniformBufferOffsets), TAG_GENERAL); + program->uniforms = (GLint *)Z_Malloc( + UNIFORM_COUNT * sizeof(*program->uniforms), TAG_GENERAL); + program->uniformBufferOffsets = (short *)Z_Malloc( + UNIFORM_COUNT * sizeof(*program->uniformBufferOffsets), TAG_GENERAL); - uniforms = program->uniforms; - - size = 0; - for (i = 0; i < UNIFORM_COUNT; i++) + GLint *uniforms = program->uniforms; + int size = 0; + for (int i = 0; i < UNIFORM_COUNT; i++) { uniforms[i] = qglGetUniformLocation(program->program, uniformsInfo[i].name); - if (uniforms[i] == -1) continue; program->uniformBufferOffsets[i] = size; - switch(uniformsInfo[i].type) { case GLSL_INT: @@ -730,6 +729,21 @@ void GLSL_InitUniforms(shaderProgram_t *program) } program->uniformBuffer = (char *)Z_Malloc(size, TAG_SHADERTEXT, qtrue); + + program->uniformBlocks = 0; + for ( int i = 0; i < UNIFORM_BLOCK_COUNT; ++i ) + { + GLuint blockIndex = qglGetUniformBlockIndex(program->program, + uniformBlocksInfo[i].name); + if ( blockIndex == GL_INVALID_INDEX ) + { + continue; + } + + qglUniformBlockBinding(program->program, blockIndex, + uniformBlocksInfo[i].slot); + program->uniformBlocks |= (1u << i); + } } void GLSL_FinishGPUShader(shaderProgram_t *program) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 2463078772..870122795a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "ghoul2/g2_local.h" #include +static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; + glconfig_t glConfig; glconfigExt_t glConfigExt; glRefConfig_t glRefConfig; @@ -1577,16 +1579,29 @@ static void R_InitBackEndFrameData() GLuint timerQueries[MAX_GPU_TIMERS*MAX_FRAMES]; qglGenQueries(MAX_GPU_TIMERS*MAX_FRAMES, timerQueries); + GLuint ubos[MAX_FRAMES]; + qglGenBuffers(MAX_FRAMES, ubos); + for ( int i = 0; i < MAX_FRAMES; i++ ) { gpuFrame_t *frame = backEndData->frames + i; + frame->ubo = ubos[i]; + frame->uboWriteOffset = 0; + qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo); + + // TODO: persistently mapped UBOs + qglBufferData(GL_UNIFORM_BUFFER, FRAME_UNIFORM_BUFFER_SIZE, + nullptr, GL_DYNAMIC_DRAW); + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) { gpuTimer_t *timer = frame->timers + j; timer->queryName = timerQueries[i*MAX_GPU_TIMERS + j]; } } + + backEndData->currentFrame = backEndData->frames; } static void R_ShutdownBackEndFrameData() @@ -1598,6 +1613,8 @@ static void R_ShutdownBackEndFrameData() { gpuFrame_t *frame = backEndData->frames + i; + qglDeleteBuffers(1, &frame->ubo); + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) { gpuTimer_t *timer = frame->timers + j; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 838c05b084..3ceab32040 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -642,6 +642,17 @@ enum surfaceSpriteOrientation_t SURFSPRITE_FACING_ANY, }; +struct SurfaceSpriteBlock +{ + float width; + float height; + float fadeStartDistance; + float fadeEndDistance; + float fadeScale; + float widthVariance; + float heightVariance; +}; + struct surfaceSprite_t { surfaceSpriteType_t type; @@ -1079,6 +1090,20 @@ enum GLSL_MAT4x4, }; +enum uniformBlock_t +{ + UNIFORM_BLOCK_SURFACESPRITE, + UNIFORM_BLOCK_COUNT +}; + +struct uniformBlockInfo_t +{ + int slot; + const char *name; + size_t size; +}; +extern const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT]; + typedef enum { UNIFORM_DIFFUSEMAP = 0, @@ -1183,10 +1208,12 @@ typedef struct shaderProgram_s uint32_t attribs; // vertex array attributes // uniform parameters - int numUniforms; GLint *uniforms; short *uniformBufferOffsets; char *uniformBuffer; + + // uniform blocks + uint32_t uniformBlocks; } shaderProgram_t; struct technique_t @@ -1391,7 +1418,7 @@ struct srfSprites_t surfaceType_t surfaceType; shader_t *shader; - surfaceSpriteType_t spriteType; + const surfaceSprite_t *sprite; int numSprites; VBO_t *vbo; IBO_t *ibo; @@ -3182,6 +3209,8 @@ struct gpuTimedBlock_t struct gpuFrame_t { GLsync sync; + GLuint ubo; + size_t uboWriteOffset; int numTimers; int numTimedBlocks; @@ -3196,6 +3225,7 @@ struct gpuFrame_t typedef struct backEndData_s { unsigned realFrameNumber; gpuFrame_t frames[MAX_FRAMES]; + gpuFrame_t *currentFrame; drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index a9a7afdac8..a5669f3822 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2118,19 +2118,48 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) RB_EndSurface(); + // TODO: Do we want a 2-level lod system where far away sprites are + // just flat surfaces? + // TODO: Check which pass (z-prepass/shadow/forward) we're rendering for? shader_t *shader = surf->shader; shaderStage_t *firstStage = shader->stages[0]; shaderProgram_t *program = firstStage->glslShaderGroup; + assert(program->uniformBlocks & (1 << UNIFORM_BLOCK_SURFACESPRITE)); + + const surfaceSprite_t *ss = surf->sprite; + SurfaceSpriteBlock data = {}; + data.width = ss->width; + data.height = ss->height; + data.fadeStartDistance = ss->fadeDist; + data.fadeEndDistance = ss->fadeMax; + data.fadeScale = ss->fadeScale; + data.widthVariance = ss->variance[0]; + data.heightVariance = ss->variance[1]; + GLSL_BindProgram(program); GL_State(firstStage->stateBits); GL_VertexAttribPointers(surf->numAttributes, surf->attributes); R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); + + qglBufferSubData(GL_UNIFORM_BUFFER, + backEndData->currentFrame->uboWriteOffset, sizeof(data), + &data); + qglBindBufferRange(GL_UNIFORM_BUFFER, + uniformBlocksInfo[UNIFORM_BLOCK_SURFACESPRITE].slot, + backEndData->currentFrame->ubo, + backEndData->currentFrame->uboWriteOffset, + sizeof(data)); + + size_t alignedBlockSize = (sizeof(data) + 255) & ~255; + backEndData->currentFrame->uboWriteOffset += alignedBlockSize; + GLSL_SetUniformMatrix4x4(program, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(program, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + qglDrawArraysInstanced(GL_TRIANGLES, 0, 6, surf->numSprites); } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 0a1b870cee..46ece79979 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" + uint32_t R_VboPackTangent(vec4_t v) { return (((uint32_t)(v[3] * 1.5f + 2.0f )) << 30) From 0ff7ea25c332a5392c38ccbb27edc4d5205dee0f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 15:36:37 +0000 Subject: [PATCH 331/708] Rend2: Implement alpha fading on surface sprites --- codemp/rd-rend2/glsl/surface_sprites_fp.glsl | 6 +++++- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl index 6101d5b328..ea8af1e207 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl @@ -1,6 +1,7 @@ uniform sampler2D u_DiffuseMap; in vec2 var_TexCoords; +in float var_Alpha; #if defined(ALPHA_TEST) uniform float u_AlphaTestValue; @@ -22,9 +23,12 @@ out vec4 out_Glow; void main() { + const float alphaTestValue = 0.5; out_Color = texture(u_DiffuseMap, var_TexCoords); + out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; + //#if defined(ALPHA_TEST) - if ( out_Color.a < 0.5 ) + if ( out_Color.a < alphaTestValue ) discard; //#endif diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index 994dc281b9..451bbaa72c 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -16,6 +16,7 @@ layout(std140) uniform SurfaceSprite }; out vec2 var_TexCoords; +out float var_Alpha; void main() { @@ -26,9 +27,9 @@ void main() float height = u_Height * (1.0 + u_HeightVariance*0.5); float distanceToCamera = length(V); - float widthScale = smoothstep(u_FadeStartDistance, u_FadeEndDistance, + float fadeScale = smoothstep(u_FadeStartDistance, u_FadeEndDistance, distanceToCamera); - width += u_FadeScale * widthScale * u_Width; + width += u_FadeScale * fadeScale * u_Width; vec3 offsets[] = vec3[]( vec3(-width * 0.5, 0.0, 0.0), @@ -49,7 +50,6 @@ void main() ); vec3 preOffset = offsets[gl_VertexID]; - preOffset.x += width; #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); @@ -62,4 +62,5 @@ void main() vec4 worldPos = vec4(attr_Position + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; var_TexCoords = texcoords[gl_VertexID]; + var_Alpha = 1.0 - fadeScale; } From ca4ff0e525984bf079fb7f700b82d547d441037d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 16:02:09 +0000 Subject: [PATCH 332/708] Rend2: Extract uniform block updates into function --- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_surface.cpp | 14 +------------- codemp/rd-rend2/tr_vbo.cpp | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3ceab32040..45da655221 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2854,6 +2854,7 @@ void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); void RB_CommitInternalBufferData(); +void RB_UpdateUniformBlock(uniformBlock_t block, void *data); void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index a5669f3822..f08a23a249 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2142,19 +2142,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) GL_State(firstStage->stateBits); GL_VertexAttribPointers(surf->numAttributes, surf->attributes); R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); - - qglBufferSubData(GL_UNIFORM_BUFFER, - backEndData->currentFrame->uboWriteOffset, sizeof(data), - &data); - qglBindBufferRange(GL_UNIFORM_BUFFER, - uniformBlocksInfo[UNIFORM_BLOCK_SURFACESPRITE].slot, - backEndData->currentFrame->ubo, - backEndData->currentFrame->uboWriteOffset, - sizeof(data)); - - size_t alignedBlockSize = (sizeof(data) + 255) & ~255; - backEndData->currentFrame->uboWriteOffset += alignedBlockSize; - + RB_UpdateUniformBlock(UNIFORM_BLOCK_SURFACESPRITE, &data); GLSL_SetUniformMatrix4x4(program, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); GLSL_SetUniformVec3(program, diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 46ece79979..4550d3e2db 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -627,3 +627,17 @@ void RB_CommitInternalBufferData() tess.internalIBOCommitOffset = tess.internalIBOWriteOffset; tess.internalVBOCommitOffset = tess.internalVBOWriteOffset; } + +void RB_UpdateUniformBlock(uniformBlock_t block, void *data) +{ + const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; + gpuFrame_t *thisFrame = backEndData->currentFrame; + + qglBufferSubData(GL_UNIFORM_BUFFER, + thisFrame->uboWriteOffset, blockInfo->size, data); + qglBindBufferRange(GL_UNIFORM_BUFFER, blockInfo->slot, + thisFrame->ubo, thisFrame->uboWriteOffset, blockInfo->size); + + size_t alignedBlockSize = (blockInfo->size + 255) & ~255; + thisFrame->uboWriteOffset += alignedBlockSize; +} From 48e2170c3a93912e83a0437ad3b3ad02a4212378 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 19:06:58 +0000 Subject: [PATCH 333/708] Rend2: shader permutations for surface sprites This commit also turns off back face culling for surface sprites. --- codemp/rd-rend2/glsl/surface_sprites_fp.glsl | 4 +-- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 8 ++--- codemp/rd-rend2/tr_bsp.cpp | 8 +++-- codemp/rd-rend2/tr_glsl.cpp | 37 ++++++++++++++------ codemp/rd-rend2/tr_local.h | 12 ++++++- codemp/rd-rend2/tr_surface.cpp | 16 +++++++-- codemp/rd-rend2/tr_vbo.cpp | 1 + 7 files changed, 64 insertions(+), 22 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl index ea8af1e207..560f5417c6 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl @@ -27,10 +27,10 @@ void main() out_Color = texture(u_DiffuseMap, var_TexCoords); out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; -//#if defined(ALPHA_TEST) +#if defined(ALPHA_TEST) if ( out_Color.a < alphaTestValue ) discard; -//#endif +#endif out_Glow = vec4(0.0); } diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index 451bbaa72c..4927f70eeb 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -49,14 +49,14 @@ void main() vec2(0.0, 0.0) ); - vec3 preOffset = offsets[gl_VertexID]; + vec3 offset = offsets[gl_VertexID]; #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); - vec2 perp = vec2(toCamera.y, -toCamera.x); - vec3 offset = vec3(perp*preOffset.x, preOffset.z); + offset.xy *= vec2(toCamera.y, -toCamera.x); #else - vec3 offset = preOffset; + // Make this sprite face in some direction + //offset.xy *= attr_Normal.xy; #endif vec4 worldPos = vec4(attr_Position + offset, 1.0); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 4221da53df..1ea7e5206b 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3402,6 +3402,7 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) static void R_GenerateSurfaceSprites( const srfBspSurface_t *bspSurf, + const shader_t *shader, const shaderStage_t *stage, srfSprites_t *out) { @@ -3488,7 +3489,10 @@ static void R_GenerateSurfaceSprites( sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), bundle, stage->stateBits); - out->shader->stages[0]->glslShaderGroup = &tr.spriteShader; + // FIXME: Need a better way to handle this. + out->shader->cullType = shader->cullType; + out->shader->stages[0]->glslShaderGroup = tr.spriteShader; + out->shader->stages[0]->alphaTestCmp = stage->alphaTestCmp; out->numAttributes = 2; out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( sizeof(vertexAttribute_t) * 2, h_low); @@ -3552,7 +3556,7 @@ static void R_GenerateSurfaceSprites( const world_t *world ) } srfSprites_t *sprite = surf->surfaceSprites + surfaceSpriteNum; - R_GenerateSurfaceSprites(bspSurf, stage, sprite); + R_GenerateSurfaceSprites(bspSurf, shader, stage, sprite); ++surfaceSpriteNum; } break; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 803a8fd960..6491f73c64 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1611,12 +1611,25 @@ int GLSL_BeginLoadGPUShaders(void) } attribs = ATTR_POSITION | ATTR_NORMAL; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.spriteShader, "surface_sprites", attribs, - qtrue, extradefines, fallbackShader_surface_sprites_vp, - fallbackShader_surface_sprites_fp)) + for ( int i = 0; i < SSDEF_COUNT; ++i ) { - ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); + extradefines[0] = '\0'; + + if ( i & SSDEF_FACE_CAMERA ) + Q_strcat(extradefines, sizeof(extradefines), + "#define FACE_CAMERA\n"); + + if ( i & SSDEF_ALPHA_TEST ) + Q_strcat(extradefines, sizeof(extradefines), + "#define ALPHA_TEST\n"); + + if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", + attribs, qtrue, extradefines, + fallbackShader_surface_sprites_vp, + fallbackShader_surface_sprites_fp)) + { + ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); + } } return startTime; @@ -1914,12 +1927,16 @@ void GLSL_EndLoadGPUShaders ( int startTime ) numEtcShaders++; - if (!GLSL_EndLoadGPUShader(&tr.spriteShader)) - ri->Error(ERR_FATAL, "Could not compile surface sprites shader!"); + for ( int i = 0; i < SSDEF_COUNT; ++i ) + { + shaderProgram_t *program = tr.spriteShader + i; + if (!GLSL_EndLoadGPUShader(program)) + ri->Error(ERR_FATAL, "Could not compile surface sprites shader!"); - GLSL_InitUniforms(&tr.spriteShader); - GLSL_FinishGPUShader(&tr.spriteShader); - numEtcShaders++; + GLSL_InitUniforms(program); + GLSL_FinishGPUShader(program); + numEtcShaders++; + } #if 0 attribs = ATTR_POSITION | ATTR_TEXCOORD0; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 45da655221..9e18fcdccf 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1079,6 +1079,16 @@ enum LIGHTDEF_COUNT = 0x0800 }; +// Surface sprite shader flags +enum +{ + SSDEF_FACE_CAMERA = 0x01, + SSDEF_ALPHA_TEST = 0x02, + + SSDEF_ALL = 0x03, + SSDEF_COUNT = SSDEF_ALL + 1 +}; + enum { GLSL_INT, @@ -2194,7 +2204,7 @@ typedef struct trGlobals_s { shaderProgram_t glowCompositeShader; shaderProgram_t dglowDownsample; shaderProgram_t dglowUpsample; - shaderProgram_t spriteShader; + shaderProgram_t spriteShader[SSDEF_COUNT]; // ----------------------------------------- diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index f08a23a249..865f8aeb74 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2124,14 +2124,23 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) // TODO: Check which pass (z-prepass/shadow/forward) we're rendering for? shader_t *shader = surf->shader; shaderStage_t *firstStage = shader->stages[0]; - shaderProgram_t *program = firstStage->glslShaderGroup; + shaderProgram_t *programGroup = firstStage->glslShaderGroup; + const surfaceSprite_t *ss = surf->sprite; + + uint32_t shaderFlags = 0; + if ( firstStage->alphaTestCmp != ATEST_CMP_NONE ) + shaderFlags |= SSDEF_ALPHA_TEST; + if ( ss->type == SURFSPRITE_ORIENTED ) + shaderFlags |= SSDEF_FACE_CAMERA; + + shaderProgram_t *program = programGroup + shaderFlags; assert(program->uniformBlocks & (1 << UNIFORM_BLOCK_SURFACESPRITE)); - const surfaceSprite_t *ss = surf->sprite; SurfaceSpriteBlock data = {}; data.width = ss->width; - data.height = ss->height; + data.height = (ss->facing == SURFSPRITE_FACING_DOWN) + ? -ss->height : ss->height; data.fadeStartDistance = ss->fadeDist; data.fadeEndDistance = ss->fadeMax; data.fadeScale = ss->fadeScale; @@ -2140,6 +2149,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) GLSL_BindProgram(program); GL_State(firstStage->stateBits); + GL_Cull(CT_TWO_SIDED); GL_VertexAttribPointers(surf->numAttributes, surf->attributes); R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); RB_UpdateUniformBlock(UNIFORM_BLOCK_SURFACESPRITE, &data); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 4550d3e2db..9b6a61c663 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -638,6 +638,7 @@ void RB_UpdateUniformBlock(uniformBlock_t block, void *data) qglBindBufferRange(GL_UNIFORM_BUFFER, blockInfo->slot, thisFrame->ubo, thisFrame->uboWriteOffset, blockInfo->size); + // FIXME: Use actual ubo alignment size_t alignedBlockSize = (blockInfo->size + 255) & ~255; thisFrame->uboWriteOffset += alignedBlockSize; } From 65709cffff1abf2c6fee2958ce5a3f3cca0a2258 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 19:32:28 +0000 Subject: [PATCH 334/708] Rend2: Minor changes --- codemp/rd-rend2/tr_bsp.cpp | 4 +++- codemp/rd-rend2/tr_shader.cpp | 12 ++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 1ea7e5206b..bcfac863db 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3487,12 +3487,14 @@ static void R_GenerateSurfaceSprites( out->numSprites = sprites.size(); out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); + + // FIXME: Need a better way to handle this. out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), bundle, stage->stateBits); - // FIXME: Need a better way to handle this. out->shader->cullType = shader->cullType; out->shader->stages[0]->glslShaderGroup = tr.spriteShader; out->shader->stages[0]->alphaTestCmp = stage->alphaTestCmp; + out->numAttributes = 2; out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( sizeof(vertexAttribute_t) * 2, h_low); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ae23e71b37..61f5be8883 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3734,6 +3734,7 @@ from the current global working shader */ static shader_t *FinishShader( void ) { int stage; + uint32_t shaderStateBits = 0; qboolean hasLightmapStage = qfalse; // @@ -3748,6 +3749,7 @@ static shader_t *FinishShader( void ) { // if ( shader.polygonOffset && !shader.sort ) { shader.sort = SS_DECAL; + shaderStateBits |= GLS_POLYGON_OFFSET_FILL; } int lmStage; @@ -3844,14 +3846,6 @@ static shader_t *FinishShader( void ) { continue; } - // - // add additional state bits - // - if ( shader.polygonOffset ) - { - pStage->stateBits |= GLS_POLYGON_OFFSET_FILL; - } - // // ditch this stage if it's detail and detail textures are disabled // @@ -3878,6 +3872,8 @@ static shader_t *FinishShader( void ) { continue; } + pStage->stateBits |= shaderStateBits; + // // default texture coordinate generation // From 341396f300e6e478fdff550ec5b763e8a6a537ec Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 19:58:53 +0000 Subject: [PATCH 335/708] Rend2: Randomize direction of surface sprites Also fix shader code to rotate the surface sprites, broken in 48e2170c3. --- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 4 ++-- codemp/rd-rend2/tr_bsp.cpp | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index 4927f70eeb..30d1452161 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -53,10 +53,10 @@ void main() #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); - offset.xy *= vec2(toCamera.y, -toCamera.x); + offset.xy = offset.x*vec2(toCamera.y, -toCamera.x); #else // Make this sprite face in some direction - //offset.xy *= attr_Normal.xy; + offset.xy = offset.x*attr_Normal.xy; #endif vec4 worldPos = vec4(attr_Position + offset, 1.0); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index bcfac863db..a049777b38 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3450,8 +3450,8 @@ static void R_GenerateSurfaceSprites( { for ( float b = 0.0f, bend = (1.0f - a); b < bend; b += step ) { - float x = random()*step + a; - float y = random()*step + b; + float x = flrand(0.0f, 1.0f)*step + a; + float y = flrand(0.0f, 1.0f)*step + b; float z = 1.0f - x - y; // Ensure we're inside the triangle bounds. @@ -3465,10 +3465,11 @@ static void R_GenerateSurfaceSprites( VectorMA(sprite.position, y, p1, sprite.position); VectorMA(sprite.position, z, p2, sprite.position); - VectorMA(sprite.normal, x, n0, sprite.normal); - VectorMA(sprite.normal, y, n1, sprite.normal); - VectorMA(sprite.normal, z, n2, sprite.normal); - VectorNormalize(sprite.normal); + float nx = flrand(-1.0f, 1.0f); + float ny = std::sqrtf(1.0f - nx*nx); + ny *= irand(0, 1) ? -1 : 1; + + VectorSet(sprite.normal, nx, ny, 0.0f); // We have 4 copies for each corner of the quad sprites.push_back(sprite); @@ -3500,7 +3501,7 @@ static void R_GenerateSurfaceSprites( sizeof(vertexAttribute_t) * 2, h_low); out->attributes[0].vbo = out->vbo; - out->attributes[0].index = 0; + out->attributes[0].index = ATTR_INDEX_POSITION; out->attributes[0].numComponents = 3; out->attributes[0].integerAttribute = qfalse; out->attributes[0].type = GL_FLOAT; @@ -3510,12 +3511,13 @@ static void R_GenerateSurfaceSprites( out->attributes[0].stepRate = 1; out->attributes[1].vbo = out->vbo; - out->attributes[1].index = 1; + out->attributes[1].index = ATTR_INDEX_NORMAL; out->attributes[1].numComponents = 3; out->attributes[1].integerAttribute = qfalse; out->attributes[1].type = GL_FLOAT; out->attributes[1].normalize = GL_FALSE; out->attributes[1].stride = sizeof(sprite_t); + out->attributes[1].offset = offsetof(sprite_t, normal); out->attributes[1].stepRate = 1; } From 747bf0f7f51a2d0b01ba2d31d5d28dfc5137d2a7 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 20:13:15 +0000 Subject: [PATCH 336/708] Rend2: Facing up surface sprites Untested at the moment --- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 3 +++ codemp/rd-rend2/tr_bsp.cpp | 3 +++ codemp/rd-rend2/tr_glsl.cpp | 9 +++++++++ codemp/rd-rend2/tr_local.h | 3 ++- 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index 30d1452161..3153847510 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -54,6 +54,9 @@ void main() #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); offset.xy = offset.x*vec2(toCamera.y, -toCamera.x); +#elif defined(FACE_UP) + // Make this sprite face upwards + offset = offset.xxy; #else // Make this sprite face in some direction offset.xy = offset.x*attr_Normal.xy; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a049777b38..d77ab65316 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3465,6 +3465,9 @@ static void R_GenerateSurfaceSprites( VectorMA(sprite.position, y, p1, sprite.position); VectorMA(sprite.position, z, p2, sprite.position); + // x*x + y*y = 1.0 + // => y*y = 1.0 - x*x + // => y = -/+sqrt(1.0 - x*x) float nx = flrand(-1.0f, 1.0f); float ny = std::sqrtf(1.0f - nx*nx); ny *= irand(0, 1) ? -1 : 1; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6491f73c64..308f7e1d18 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1615,9 +1615,15 @@ int GLSL_BeginLoadGPUShaders(void) { extradefines[0] = '\0'; + if ( (i & SSDEF_FACE_CAMERA) && (i & SSDEF_FACE_UP) ) + continue; + if ( i & SSDEF_FACE_CAMERA ) Q_strcat(extradefines, sizeof(extradefines), "#define FACE_CAMERA\n"); + else if ( i & SSDEF_FACE_UP ) + Q_strcat(extradefines, sizeof(extradefines), + "#define FACE_UP\n"); if ( i & SSDEF_ALPHA_TEST ) Q_strcat(extradefines, sizeof(extradefines), @@ -1929,6 +1935,9 @@ void GLSL_EndLoadGPUShaders ( int startTime ) for ( int i = 0; i < SSDEF_COUNT; ++i ) { + if ( (i & SSDEF_FACE_CAMERA) && (i & SSDEF_FACE_UP) ) + continue; + shaderProgram_t *program = tr.spriteShader + i; if (!GLSL_EndLoadGPUShader(program)) ri->Error(ERR_FATAL, "Could not compile surface sprites shader!"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9e18fcdccf..bbbc16d25c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1084,8 +1084,9 @@ enum { SSDEF_FACE_CAMERA = 0x01, SSDEF_ALPHA_TEST = 0x02, + SSDEF_FACE_UP = 0x03, - SSDEF_ALL = 0x03, + SSDEF_ALL = 0x07, SSDEF_COUNT = SSDEF_ALL + 1 }; From 7802a2ec19e18c3acea90769cdc2dab654fc3d75 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 28 Feb 2016 20:22:33 +0000 Subject: [PATCH 337/708] Rend2: Fix surface sprites which face up --- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 27 ++++++++++++-------- codemp/rd-rend2/tr_local.h | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index 3153847510..e13824b064 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -31,13 +31,23 @@ void main() distanceToCamera); width += u_FadeScale * fadeScale * u_Width; + float halfWidth = width * 0.5; vec3 offsets[] = vec3[]( - vec3(-width * 0.5, 0.0, 0.0), - vec3( width * 0.5, 0.0, 0.0), - vec3(-width * 0.5, 0.0, height), - vec3( width * 0.5, 0.0, 0.0), - vec3( width * 0.5, 0.0, height), - vec3(-width * 0.5, 0.0, height) +#if defined(FACE_UP) + vec3(-halfWidth, -halfWidth, 0.0), + vec3( halfWidth, -halfWidth, 0.0), + vec3(-halfWidth, halfWidth, 0.0), + vec3( halfWidth, -halfWidth, 0.0), + vec3( halfWidth, halfWidth, 0.0), + vec3(-halfWidth, halfWidth, 0.0) +#else + vec3(-halfWidth, 0.0, 0.0), + vec3( halfWidth, 0.0, 0.0), + vec3(-halfWidth, 0.0, height), + vec3( halfWidth, 0.0, 0.0), + vec3( halfWidth, 0.0, height), + vec3(-halfWidth, 0.0, height) +#endif ); const vec2 texcoords[] = vec2[]( @@ -54,10 +64,7 @@ void main() #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); offset.xy = offset.x*vec2(toCamera.y, -toCamera.x); -#elif defined(FACE_UP) - // Make this sprite face upwards - offset = offset.xxy; -#else +#elif !defined(FACE_UP) // Make this sprite face in some direction offset.xy = offset.x*attr_Normal.xy; #endif diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bbbc16d25c..e2cdc37d6f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1084,7 +1084,7 @@ enum { SSDEF_FACE_CAMERA = 0x01, SSDEF_ALPHA_TEST = 0x02, - SSDEF_FACE_UP = 0x03, + SSDEF_FACE_UP = 0x04, SSDEF_ALL = 0x07, SSDEF_COUNT = SSDEF_ALL + 1 From e02282d6e19d45d044b212ba81f40d985ae03b40 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 1 Mar 2016 19:55:21 +0000 Subject: [PATCH 338/708] Rend2: Fix bad memory usage for extension strings --- codemp/rd-rend2/tr_init.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 870122795a..73dab4fe33 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -426,7 +426,7 @@ static const char *TruncateGLExtensionsString (const char *extensionsString, int extensionsLen = p - extensionsString - 1; } - truncatedExtensions = (char *)Hunk_Alloc(extensionsLen + 1, h_low); + truncatedExtensions = (char *)Z_Malloc(extensionsLen + 1, TAG_GENERAL); Q_strncpyz (truncatedExtensions, extensionsString, extensionsLen + 1); return truncatedExtensions; @@ -443,7 +443,7 @@ static const char *GetGLExtensionsString() extensionStringLen += strlen((const char *)glGetStringi(GL_EXTENSIONS, i)) + 1; } - char *extensionString = (char *)Hunk_Alloc(extensionStringLen + 1, h_low); + char *extensionString = (char *)Z_Malloc(extensionStringLen + 1, TAG_GENERAL); char *p = extensionString; for ( int i = 0; i < numExtensions; i++ ) { @@ -1753,6 +1753,9 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { if ( destroyWindow && restarting ) { + ri->Z_Free((void *)glConfig.extensions_string); + ri->Z_Free((void *)glConfigExt.originalExtensionString); + glDeleteVertexArrays(1, &tr.globalVao); SaveGhoul2InfoArray(); } From fec2b0246fc20500ab1fb676810d9364c39dfc14 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 1 Mar 2016 22:22:34 +0000 Subject: [PATCH 339/708] Rend2: Minor code changes --- codemp/rd-rend2/tr_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d77ab65316..ad6dd6ae7b 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3501,7 +3501,7 @@ static void R_GenerateSurfaceSprites( out->numAttributes = 2; out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( - sizeof(vertexAttribute_t) * 2, h_low); + sizeof(vertexAttribute_t) * out->numAttributes, h_low); out->attributes[0].vbo = out->vbo; out->attributes[0].index = ATTR_INDEX_POSITION; From 3dea4971e9d70f344a503cbadd75a7771d91d9a5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 7 Mar 2016 20:29:28 +0000 Subject: [PATCH 340/708] Rend2: Fix use of core GL3 functions --- codemp/rd-rend2/qgl.h | 3 +++ codemp/rd-rend2/tr_extensions.cpp | 21 ++++++++++++++------- codemp/rd-rend2/tr_init.cpp | 12 +++++++----- codemp/rd-rend2/tr_local.h | 1 + 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 45a65f4bb6..288f257aa6 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -557,6 +557,9 @@ extern PFNGLGETQUERYIVPROC qglGetQueryiv; extern PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; extern PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; +// GL state +extern PFNGLGETSTRINGIPROC qglGetStringi; + // Sync objects and fences extern PFNGLFENCESYNCPROC qglFenceSync; extern PFNGLDELETESYNCPROC qglDeleteSync; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 772dd9100e..9cf5a6590b 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -202,6 +202,9 @@ PFNGLGETQUERYIVPROC qglGetQueryiv; PFNGLGETQUERYOBJECTIVPROC qglGetQueryObjectiv; PFNGLGETQUERYOBJECTUIVPROC qglGetQueryObjectuiv; +// GL state +PFNGLGETSTRINGIPROC qglGetStringi; + // Sync objects and fences PFNGLFENCESYNCPROC qglFenceSync; PFNGLDELETESYNCPROC qglDeleteSync; @@ -290,12 +293,8 @@ static void __stdcall GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenu Com_Printf( S_COLOR_YELLOW "OpenGL -> [%s][%s][%s] %s\n", sourceText, severityText, typeText, message ); } -void GLW_InitTextureCompression( void ); -void GLimp_InitExtensions() +void GLimp_InitCoreFunctions() { - char *extension; - const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; - Com_Printf("Initializing OpenGL 3.2 functions\n"); // Drawing commands @@ -446,9 +445,7 @@ void GLimp_InitExtensions() // GLSL { char version[256]; - Q_strncpyz( version, (const char *) qglGetString (GL_SHADING_LANGUAGE_VERSION), sizeof( version ) ); - sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); ri->Printf(PRINT_ALL, "...using GLSL version %s\n", version); @@ -490,11 +487,21 @@ void GLimp_InitExtensions() GetGLFunction (qglGetQueryObjectiv, "glGetQueryObjectiv", qtrue); GetGLFunction (qglGetQueryObjectuiv, "glGetQueryObjectuiv", qtrue); + // GL state + GetGLFunction (qglGetStringi, "glGetStringi", qtrue); + // Sync objects and fences GetGLFunction (qglFenceSync, "glFenceSync", qtrue); GetGLFunction (qglDeleteSync, "glDeleteSync", qtrue); GetGLFunction (qglClientWaitSync, "glClientWaitSync", qtrue); GetGLFunction (qglWaitSync, "glWaitSync", qtrue); +} + +void GLW_InitTextureCompression( void ); +void GLimp_InitExtensions() +{ + char *extension; + const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; Com_Printf ("Initializing OpenGL extensions\n" ); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 73dab4fe33..d2e7d9ccb1 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -440,14 +440,14 @@ static const char *GetGLExtensionsString() for ( int i = 0; i < numExtensions; i++ ) { - extensionStringLen += strlen((const char *)glGetStringi(GL_EXTENSIONS, i)) + 1; + extensionStringLen += strlen((const char *)qglGetStringi(GL_EXTENSIONS, i)) + 1; } char *extensionString = (char *)Z_Malloc(extensionStringLen + 1, TAG_GENERAL); char *p = extensionString; for ( int i = 0; i < numExtensions; i++ ) { - const char *extension = (const char *)glGetStringi(GL_EXTENSIONS, i); + const char *extension = (const char *)qglGetStringi(GL_EXTENSIONS, i); while ( *extension != '\0' ) *p++ = *extension++; @@ -495,6 +495,8 @@ static void InitOpenGL( void ) window = ri->WIN_Init(&windowDesc, &glConfig); + GLimp_InitCoreFunctions(); + Com_Printf( "GL_RENDERER: %s\n", (char *)qglGetString (GL_RENDERER) ); // get our config strings @@ -535,8 +537,8 @@ static void InitOpenGL( void ) // Create the default VAO GLuint vao; - glGenVertexArrays(1, &vao); - glBindVertexArray(vao); + qglGenVertexArrays(1, &vao); + qglBindVertexArray(vao); tr.globalVao = vao; // set default state @@ -1756,7 +1758,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { ri->Z_Free((void *)glConfig.extensions_string); ri->Z_Free((void *)glConfigExt.originalExtensionString); - glDeleteVertexArrays(1, &tr.globalVao); + qglDeleteVertexArrays(1, &tr.globalVao); SaveGhoul2InfoArray(); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e2cdc37d6f..f25c3c3b6d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2626,6 +2626,7 @@ IMPLEMENTATION SPECIFIC FUNCTIONS QINLINE void GLimp_LogComment( char *comment ) {} void GLimp_InitExtensions(); +void GLimp_InitCoreFunctions(); /* ==================================================================== From 93b35bb1b4064b4b03a95b4836a77069b1cace63 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 12 Mar 2016 13:49:13 +0000 Subject: [PATCH 341/708] Rend2: Use indexed rendering for surface sprites This should reduce vertex load by about 33% for surface sprites as the post-transform cache can be used. --- codemp/rd-rend2/glsl/surface_sprites_vp.glsl | 19 ++++++------------- codemp/rd-rend2/tr_bsp.cpp | 4 ++++ codemp/rd-rend2/tr_surface.cpp | 3 ++- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl index e13824b064..c1241e476c 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites_vp.glsl @@ -21,7 +21,6 @@ out float var_Alpha; void main() { vec3 V = u_ViewOrigin - attr_Position; - int vertexID = gl_VertexID; float width = u_Width * (1.0 + u_WidthVariance*0.5); float height = u_Height * (1.0 + u_HeightVariance*0.5); @@ -34,29 +33,23 @@ void main() float halfWidth = width * 0.5; vec3 offsets[] = vec3[]( #if defined(FACE_UP) - vec3(-halfWidth, -halfWidth, 0.0), - vec3( halfWidth, -halfWidth, 0.0), - vec3(-halfWidth, halfWidth, 0.0), vec3( halfWidth, -halfWidth, 0.0), vec3( halfWidth, halfWidth, 0.0), - vec3(-halfWidth, halfWidth, 0.0) + vec3(-halfWidth, halfWidth, 0.0), + vec3(-halfWidth, -halfWidth, 0.0) #else - vec3(-halfWidth, 0.0, 0.0), - vec3( halfWidth, 0.0, 0.0), - vec3(-halfWidth, 0.0, height), vec3( halfWidth, 0.0, 0.0), vec3( halfWidth, 0.0, height), - vec3(-halfWidth, 0.0, height) + vec3(-halfWidth, 0.0, height), + vec3(-halfWidth, 0.0, 0.0) #endif ); const vec2 texcoords[] = vec2[]( - vec2(0.0, 1.0), - vec2(1.0, 1.0), - vec2(0.0, 0.0), vec2(1.0, 1.0), vec2(1.0, 0.0), - vec2(0.0, 0.0) + vec2(0.0, 0.0), + vec2(0.0, 1.0) ); vec3 offset = offsets[gl_VertexID]; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index ad6dd6ae7b..2dc82e5b47 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3486,12 +3486,16 @@ static void R_GenerateSurfaceSprites( hash = UpdateHash(bundle->image[i]->imgName, hash); } + uint16_t indices[] = { 0, 1, 2, 0, 2, 3 }; + out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; out->numSprites = sprites.size(); out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); + out->ibo = R_CreateIBO((byte *)indices, sizeof(indices), VBO_USAGE_STATIC); + // FIXME: Need a better way to handle this. out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), bundle, stage->stateBits); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 865f8aeb74..eedd6ab728 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2158,7 +2158,8 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) GLSL_SetUniformVec3(program, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - qglDrawArraysInstanced(GL_TRIANGLES, 0, 6, surf->numSprites); + R_BindIBO(surf->ibo); + qglDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, surf->numSprites); } void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { From 0149e70df698fb9aa7191341acf5438e1df874da Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 12 Mar 2016 23:10:11 +0000 Subject: [PATCH 342/708] Rend2: Corrected memory allocation for ubos --- codemp/rd-rend2/tr_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 308f7e1d18..9e9a76968c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -689,7 +689,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) program->uniforms = (GLint *)Z_Malloc( UNIFORM_COUNT * sizeof(*program->uniforms), TAG_GENERAL); program->uniformBufferOffsets = (short *)Z_Malloc( - UNIFORM_COUNT * sizeof(*program->uniformBufferOffsets), TAG_GENERAL); + UNIFORM_BLOCK_COUNT * sizeof(*program->uniformBufferOffsets), TAG_GENERAL); GLint *uniforms = program->uniforms; int size = 0; From d0811be134a5a515ed498442a012d6de1c835a4d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 12 Mar 2016 23:21:03 +0000 Subject: [PATCH 343/708] Revert "Rend2: Corrected memory allocation for ubos" This reverts commit 0149e70df698fb9aa7191341acf5438e1df874da. --- codemp/rd-rend2/tr_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 9e9a76968c..308f7e1d18 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -689,7 +689,7 @@ void GLSL_InitUniforms(shaderProgram_t *program) program->uniforms = (GLint *)Z_Malloc( UNIFORM_COUNT * sizeof(*program->uniforms), TAG_GENERAL); program->uniformBufferOffsets = (short *)Z_Malloc( - UNIFORM_BLOCK_COUNT * sizeof(*program->uniformBufferOffsets), TAG_GENERAL); + UNIFORM_COUNT * sizeof(*program->uniformBufferOffsets), TAG_GENERAL); GLint *uniforms = program->uniforms; int size = 0; From 87275b7e65e4ecfbcdbaccf03c760361853c32f8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Mar 2016 19:16:46 +0000 Subject: [PATCH 344/708] Rend2: Refactor image/model caching Previous system was allocating/freeing memory every time a lookup was made due to the std::string key in the map<>. These caching classes have been rewritten to use vectors. --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_bsp.cpp | 3 +- codemp/rd-rend2/tr_cache.cpp | 262 +++++++++++++++++---------------- codemp/rd-rend2/tr_cache.h | 124 ++++++++++++++++ codemp/rd-rend2/tr_ghoul2.cpp | 1 + codemp/rd-rend2/tr_init.cpp | 1 + codemp/rd-rend2/tr_local.h | 94 ------------ codemp/rd-rend2/tr_model.cpp | 13 +- 8 files changed, 270 insertions(+), 229 deletions(-) create mode 100644 codemp/rd-rend2/tr_cache.h diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 617a344405..e2eb4a1dc2 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -23,6 +23,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" "${MPDir}/rd-rend2/tr_cache.cpp" + "${MPDir}/rd-rend2/tr_cache.h" "${MPDir}/rd-rend2/tr_cmds.cpp" "${MPDir}/rd-rend2/tr_curve.cpp" "${MPDir}/rd-rend2/tr_decals.cpp" diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 2dc82e5b47..1ab2ad17a8 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_map.c #include "tr_local.h" +#include "tr_cache.h" #include /* @@ -2279,7 +2280,7 @@ static void R_LoadSubmodels( lump_t *l ) { out->bounds[1][j] = LittleFloat (in->maxs[j]); } - CModelCache->InsertLoaded (model->name, model->index); + CModelCache->InsertModelHandle(model->name, model->index); out->firstSurface = LittleLong( in->firstSurface ); out->numSurfaces = LittleLong( in->numSurfaces ); diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 6a0a08eae6..4c21228d5d 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -1,6 +1,20 @@ // tr_cache.cpp - Cache models, images, and more.. #include "tr_local.h" +#include "tr_cache.h" +#include + +namespace +{ + +void NormalizePath( char *out, const char *path, size_t outSize ) +{ + assert(outSize == MAX_QPATH); + Q_strncpyz(out, path, outSize); + Q_strlwr(out); +} + +} // This differs significantly from Raven's own caching code. // For starters, we are allowed to use ri-> whatever because we don't care about running on dedicated (use rd-vanilla!) @@ -8,28 +22,21 @@ CImageCacheManager *CImgCache = new CImageCacheManager(); CModelCacheManager *CModelCache = new CModelCacheManager(); -/* - * CCacheManager::SearchLoaded - * Return -1 if asset not currently loaded, return positive qhandle_t if found - */ -qhandle_t CCacheManager::SearchLoaded( const char *fileName ) +CachedFile::CachedFile() + : pDiskImage(nullptr) + , iLevelLastUsedOn(0) + , iPAKChecksum(-1) + , iAllocSize(0) { - loadedMap_t::iterator it = loaded.find(fileName); - if( it == loaded.end() ) - return -1; // asset not found - return it->second.handle; } -/* - * CCacheManager::InsertLoaded - * We have a loaded model/image, let's insert it into the list of loaded models - */ -void CCacheManager::InsertLoaded( const char *fileName, qhandle_t handle ) +CCacheManager::FileCache::iterator CCacheManager::FindFile( const char *path ) { - FileHash_t fh; - fh.handle = handle; - Q_strncpyz( fh.fileName, fileName, sizeof(fh.fileName) ); - loaded.insert(std::make_pair(fileName, fh)); + return std::find_if( + std::begin(files), std::end(files), [path]( const CachedFile& file ) + { + return strcmp(path, file.path) == 0; + }); } static const byte FakeGLAFile[] = @@ -55,23 +62,15 @@ static const byte FakeGLAFile[] = 0x00, 0x80, 0x00, 0x80, 0x00, 0x80 }; -/* - * CCacheManager::LoadFile - * Load the file and chuck the contents into ppFileBuffer, OR - * if we're cached already, chuck cached contents into ppFileBuffer - * and set *pbAlreadyCached to qtrue (otherwise, *pbAlreadyCached = false) - */ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ) { - char sFileName[MAX_QPATH]; - - Q_strncpyz(sFileName, pFileName, MAX_QPATH); - Q_strlwr (sFileName); + char path[MAX_QPATH]; + NormalizePath(path, pFileName, sizeof(path)); - auto cacheEntry = cache.find (sFileName); - if ( cacheEntry != cache.end() ) + auto cacheEntry = FindFile(path); + if ( cacheEntry != std::end(files) ) { - *ppFileBuffer = cacheEntry->second.pDiskImage; + *ppFileBuffer = cacheEntry->pDiskImage; *pbAlreadyCached = qtrue; return qtrue; @@ -80,18 +79,18 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb *pbAlreadyCached = qfalse; // special case intercept first... - if (!strcmp (sDEFAULT_GLA_NAME ".gla", pFileName)) + if (!strcmp (sDEFAULT_GLA_NAME ".gla", path)) { // return fake params as though it was found on disk... - void *pvFakeGLAFile = Z_Malloc (sizeof (FakeGLAFile), TAG_FILESYS, qfalse); + void *pvFakeGLAFile = Z_Malloc(sizeof (FakeGLAFile), TAG_FILESYS, qfalse); - memcpy (pvFakeGLAFile, &FakeGLAFile[0], sizeof (FakeGLAFile)); + memcpy(pvFakeGLAFile, &FakeGLAFile[0], sizeof (FakeGLAFile)); *ppFileBuffer = pvFakeGLAFile; return qtrue; } - int len = ri->FS_ReadFile( pFileName, ppFileBuffer ); + int len = ri->FS_ReadFile(path, ppFileBuffer); if ( len == -1 || *ppFileBuffer == NULL ) { return qfalse; @@ -102,11 +101,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb return qtrue; } -/* - * CCacheManager::Allocate - * Allocate appropriate memory for stuff dealing with cached images - * FIXME: only applies to models? - */ + void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ) { int iChecksum; @@ -119,25 +114,26 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode if( !bAlreadyFound ) return NULL; - /* Convert psModelFileName to lowercase */ - Q_strncpyz(sModelName, psModelFileName, MAX_QPATH); - Q_strlwr (sModelName); - - CachedFile_t *pFile; - auto cacheEntry = cache.find (sModelName); + NormalizePath(sModelName, psModelFileName, sizeof(sModelName)); - if (cacheEntry == cache.end()) - { /* Create this image. */ - pFile = &cache[sModelName]; + CachedFile *pFile = nullptr; + auto cacheEntry = FindFile(sModelName); + if (cacheEntry == files.end()) + { + /* Create this image. */ if( pvDiskBuffer ) Z_MorphMallocTag( pvDiskBuffer, eTag ); else - pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); - pFile->pDiskImage = pvDiskBuffer; - pFile->iAllocSize = iSize; + pvDiskBuffer = Z_Malloc(iSize, eTag, qfalse); - if( ri->FS_FileIsInPAK( psModelFileName, &iChecksum ) ) + files.emplace_back(); + pFile = &files.back(); + pFile->pDiskImage = pvDiskBuffer; + pFile->iAllocSize = iSize; + Q_strncpyz(pFile->path, sModelName, sizeof(pFile->path)); + + if( ri->FS_FileIsInPAK( sModelName, &iChecksum ) ) pFile->iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ *bAlreadyFound = qfalse; @@ -149,7 +145,7 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode * TODO: shader caching. */ *bAlreadyFound = qtrue; - pFile = &cacheEntry->second; + pFile = &(*cacheEntry); } pFile->iLevelLastUsedOn = tr.currentLevel; @@ -163,33 +159,28 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode */ void CCacheManager::DeleteAll( void ) { - for( auto it = cache.begin(); it != cache.end(); ++it ) + for ( auto& file : files ) { - Z_Free(it->second.pDiskImage); + Z_Free(file.pDiskImage); } - cache.clear(); - loaded.clear(); + files.swap(FileCache()); + + DeleteRemaining(); } void CImageCacheManager::DeleteLightMaps( void ) { - for( auto it = cache.begin(); it != cache.end(); /* empty */ ) + for( auto it = files.begin(); it != files.end(); /* empty */ ) { - CachedFile_t pFile = it->second; - if( pFile.fileName[0] == '*' && strstr(pFile.fileName, "lightmap") ) - { - if( pFile.pDiskImage ) - Z_Free( pFile.pDiskImage ); - - it = cache.erase(it); - } - else if( pFile.fileName[0] == '_' && strstr(pFile.fileName, "fatlightmap") ) + CachedFile& pFile = *it; + if( (pFile.path[0] == '*' && strstr(pFile.path, "lightmap")) || + (pFile.path[0] == '_' && strstr(pFile.path, "fatlightmap")) ) { if( pFile.pDiskImage ) Z_Free( pFile.pDiskImage ); - it = cache.erase(it); + it = files.erase(it); } else { @@ -207,20 +198,20 @@ void CCacheManager::DumpNonPure( void ) { ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure():\n"); - for(assetCache_t::iterator it = cache.begin(); it != cache.end(); /* empty */ ) + for ( auto it = files.begin(); it != files.end(); /* empty */ ) { int iChecksum; - int iInPak = ri->FS_FileIsInPAK( it->first.c_str(), &iChecksum ); + int iInPak = ri->FS_FileIsInPAK( it->path, &iChecksum ); - if( iInPak == -1 || iChecksum != it->second.iPAKChecksum ) + if( iInPak == -1 || iChecksum != it->iPAKChecksum ) { /* Erase the file because it doesn't match the checksum */ - ri->Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->first ); + ri->Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->path ); - if( it->second.pDiskImage ) - Z_Free( it->second.pDiskImage ); + if( it->pDiskImage ) + Z_Free( it->pDiskImage ); - it = cache.erase(it); + it = files.erase(it); } else { @@ -231,45 +222,63 @@ void CCacheManager::DumpNonPure( void ) ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); } -/* - * LevelLoadEnd virtual funcs - */ +CModelCacheManager::AssetCache::iterator CModelCacheManager::FindAsset( const char *path ) +{ + return std::find_if( + std::begin(assets), std::end(assets), [path]( const Asset& asset ) + { + return strcmp(path, asset.path) == 0; + }); +} -/* - * This function is /badly/ designed in vanilla. For starters, LETS NOT USE ANY INCREMENTERS BECAUSE THATS COOL - * Secondly, it randomly decides to keep track of the amount of model memory and break out of the loop if we run - * higher than r_modelpoolmegs...thing is, logically that doesn't make any sense, since you're freeing memory - * here, not allocating more of it. Fail. - */ -qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel ) +qhandle_t CModelCacheManager::GetModelHandle( const char *fileName ) +{ + char path[MAX_QPATH]; + NormalizePath(path, fileName, sizeof(path)); + + const auto it = FindAsset(path); + if( it == std::end(assets) ) + return -1; // asset not found + + return it->handle; +} + +void CModelCacheManager::InsertModelHandle( const char *fileName, qhandle_t handle ) +{ + char path[MAX_QPATH]; + NormalizePath(path, fileName, sizeof(path)); + + Asset asset; + asset.handle = handle; + Q_strncpyz(asset.path, path, sizeof(asset.path)); + assets.emplace_back(asset); +} + +qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) { qboolean bAtLeastOneModelFreed = qfalse; ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); - for(auto it = cache.begin(); it != cache.end(); /* empty */) + for ( auto it = files.begin(); it != files.end(); /* empty */ ) { - CachedFile_t pFile = it->second; - bool bDeleteThis = false; + bool bDeleteThis = false; - if( bDeleteEverythingNotUsedThisLevel ) - bDeleteThis = ( pFile.iLevelLastUsedOn != tr.currentLevel ); + if( deleteUnusedByLevel ) + bDeleteThis = (it->iLevelLastUsedOn != tr.currentLevel); else - bDeleteThis = ( pFile.iLevelLastUsedOn < tr.currentLevel ); + bDeleteThis = (it->iLevelLastUsedOn < tr.currentLevel); if( bDeleteThis ) { - const char *psModelName = it->first.c_str(); - - ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", psModelName); - - if( pFile.pDiskImage ) + ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", it->path); + if( it->pDiskImage ) { - Z_Free( pFile.pDiskImage ); + Z_Free( it->pDiskImage ); bAtLeastOneModelFreed = qtrue; // FIXME: is this correct? shouldn't it be in the next lower scope? } - it = cache.erase(it); + it = files.erase(it); } else { @@ -282,6 +291,11 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThis return bAtLeastOneModelFreed; } +void CModelCacheManager::DeleteRemaining() +{ + assets.swap(AssetCache()); +} + qboolean CImageCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel /* unused */ ) { return qtrue; @@ -291,12 +305,12 @@ qboolean CImageCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThis * Wrappers for the above funcs so they export properly. */ -qboolean C_Models_LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ) +qboolean C_Models_LevelLoadEnd( qboolean deleteUnusedByLevel ) { - return CModelCache->LevelLoadEnd( bDeleteEverythingNotUsedInThisLevel ); + return CModelCache->LevelLoadEnd(deleteUnusedByLevel); } -qboolean C_Images_LevelLoadEnd( void ) +qboolean C_Images_LevelLoadEnd() { return CImgCache->LevelLoadEnd( qfalse ); } @@ -308,64 +322,56 @@ qboolean C_Images_LevelLoadEnd( void ) void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ) { char sModelName[MAX_QPATH]; + NormalizePath(sModelName, psModelFileName, sizeof(sModelName)); - Q_strncpyz(sModelName, psModelFileName, sizeof(sModelName)); - Q_strlwr (sModelName); - - auto cacheEntry = cache.find (sModelName); - if ( cacheEntry == cache.end() ) + auto file = FindFile(sModelName); + if ( file == files.end() ) { return; } - CachedFile_t &rFile = cacheEntry->second; - if( rFile.pDiskImage == NULL ) + if( file->pDiskImage == NULL ) { /* Shouldn't even happen. */ assert(0); return; } - int iNameOffset = psShaderName - (char *)rFile.pDiskImage; - int iPokeOffset = (char*) piShaderIndexPoke - (char *)rFile.pDiskImage; + int iNameOffset = psShaderName - (char *)file->pDiskImage; + int iPokeOffset = (char*) piShaderIndexPoke - (char *)file->pDiskImage; - rFile.shaderCache.push_back( std::make_pair( iNameOffset, iPokeOffset ) ); + file->shaderCache.push_back(std::make_pair(iNameOffset, iPokeOffset)); } void CModelCacheManager::AllocateShaders( const char *psFileName ) { // if we already had this model entry, then re-register all the shaders it wanted... - // - char sModelName[MAX_QPATH]; - Q_strncpyz(sModelName, psFileName, sizeof(sModelName)); - Q_strlwr (sModelName); + char sModelName[MAX_QPATH]; + NormalizePath(sModelName, psFileName, sizeof(sModelName)); - auto cacheEntry = cache.find (sModelName); - if ( cacheEntry == cache.end() ) + auto file = FindFile(sModelName); + if ( file == files.end() ) { return; } - CachedFile_t &rFile = cacheEntry->second; - - if( rFile.pDiskImage == NULL ) + if( file->pDiskImage == NULL ) { /* Shouldn't even happen. */ assert(0); return; } - for( auto storedShader = rFile.shaderCache.begin(); storedShader != rFile.shaderCache.end(); ++storedShader ) + for( auto storedShader = file->shaderCache.begin(); storedShader != file->shaderCache.end(); ++storedShader ) { - int iShaderNameOffset = storedShader->first; - int iShaderPokeOffset = storedShader->second; + int iShaderNameOffset = storedShader->first; + int iShaderPokeOffset = storedShader->second; - char *psShaderName = &((char*)rFile.pDiskImage)[iShaderNameOffset]; - int *piShaderPokePtr = (int *) &((char*)rFile.pDiskImage)[iShaderPokeOffset]; + char *psShaderName = ((char*)file->pDiskImage + iShaderNameOffset); + int *piShaderPokePtr = (int *)((char*)file->pDiskImage + iShaderPokeOffset); - shader_t *sh = R_FindShader( psShaderName, lightmapsNone, stylesDefault, qtrue ); - + shader_t *sh = R_FindShader(psShaderName, lightmapsNone, stylesDefault, qtrue); if ( sh->defaultShader ) *piShaderPokePtr = 0; else diff --git a/codemp/rd-rend2/tr_cache.h b/codemp/rd-rend2/tr_cache.h new file mode 100644 index 0000000000..6deb47e714 --- /dev/null +++ b/codemp/rd-rend2/tr_cache.h @@ -0,0 +1,124 @@ +#pragma once + +#include +#include + +/* + * Cache information specific to each file (FIXME: do we need?) + */ +enum CacheType +{ + CACHE_NONE, + CACHE_IMAGE, + CACHE_MODEL +}; + +/* + * This stores the loaded file information that we need on retrieval + */ +struct Asset +{ + qhandle_t handle; + char path[MAX_QPATH]; +}; + +/* and shaderCache_t is needed for the model cache manager */ +typedef std::pair shaderCacheEntry_t; +typedef std::vector shaderCache_t; + +/* + * The actual data stored in the cache + */ +struct CachedFile +{ + void *pDiskImage; // pointer to data loaded from disk + int iLevelLastUsedOn; // level we last used this on + int iPAKChecksum; // -1 = not from PAK + int iAllocSize; // + + shaderCache_t shaderCache; + + char path[MAX_QPATH]; + + CachedFile(); +}; + +/* The actual manager itself, which is used in the model and image loading routines. */ +class CCacheManager +{ +public: + typedef std::vector FileCache; + +public: + virtual ~CCacheManager() {} + + /* + * Load the file and chuck the contents into ppFileBuffer, OR + * if we're cached already, chuck cached contents into ppFileBuffer + * and set *pbAlreadyCached to qtrue (otherwise, *pbAlreadyCached = false) + */ + qboolean LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ); + + /* + * Allocate appropriate memory for stuff dealing with cached images + * FIXME: only applies to models? + */ + void *Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ); + void DeleteAll( void ); + void DumpNonPure( void ); + + virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ) = 0; + +protected: + virtual void DeleteRemaining() {} + + Asset * AddAsset( const Asset& asset ); + CachedFile * AddFile( const CachedFile& file ); + + FileCache::iterator FindFile( const char *name ); + +protected: + FileCache files; +}; + +class CImageCacheManager : public CCacheManager +{ +public: + virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ); + + void DeleteLightMaps( void ); +}; + +class CModelCacheManager : public CCacheManager +{ +public: + typedef std::vector AssetCache; + +public: + /* + * Return -1 if asset not currently loaded, return positive qhandle_t if found + */ + qhandle_t GetModelHandle( const char *fileName ); + + /* + * We have a loaded model/image, let's insert it into the list of loaded models + */ + void InsertModelHandle( const char *fileName, qhandle_t handle ); + + virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ); + void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); + void AllocateShaders( const char *psFileName ); + +protected: + virtual void DeleteRemaining(); + +private: + AssetCache::iterator FindAsset( const char *name ); + AssetCache assets; +}; + +qboolean C_Models_LevelLoadEnd( qboolean deleteUnusedByLevel ); +qboolean C_Images_LevelLoadEnd(); + +extern CImageCacheManager *CImgCache; +extern CModelCacheManager *CModelCache; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 638b013dec..f1120c129a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -12,6 +12,7 @@ #pragma warning (disable: 4512) //default assignment operator could not be gened #endif #include "qcommon/disablewarnings.h" +#include "tr_cache.h" #define LL(x) x=LittleLong(x) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index d2e7d9ccb1..dbc2307c8e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #include "ghoul2/g2_local.h" +#include "tr_cache.h" #include static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index f25c3c3b6d..9479397416 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3308,103 +3308,9 @@ extern void R_ImageLoader_Init(void); // tr_cache.cpp -/* - * FileHash_t - * This stores the loaded file information that we need on retrieval - */ -typedef struct FileHash_s -{ - char fileName[MAX_QPATH]; - qhandle_t handle; -} FileHash_t; - -/* - * CacheType_e - * Cache information specific to each file (FIXME: do we need?) - */ -enum CacheType_e -{ - CACHE_NONE, - CACHE_IMAGE, - CACHE_MODEL -}; - -/* and shaderCache_t is needed for the model cache manager */ -typedef std::pair shaderCacheEntry_t; -typedef std::vector shaderCache_t; - -/* - * CachedFile_t - * The actual data stored in the cache - */ -typedef struct CachedFile_s -{ - void *pDiskImage; // pointer to data loaded from disk - char fileName[MAX_QPATH]; // filename - int iLevelLastUsedOn; // level we last used this on - int iPAKChecksum; // -1 = not from PAK - int iAllocSize; // - - CacheType_e eCacheType; // determine which member of the uCache we're going to use - shaderCache_t shaderCache; - - CachedFile_s() - { - pDiskImage = NULL; - iLevelLastUsedOn = 0; - iPAKChecksum = -1; - eCacheType = CACHE_NONE; - fileName[0] = '\0'; - iAllocSize = 0; - } -} CachedFile_t; -/* assetCache_t and loadedMap_t are two definitions that are needed for the manager */ -typedef std::map assetCache_t; -typedef std::unordered_map loadedMap_t; - -/* The actual manager itself, which is used in the model and image loading routines. */ -class CCacheManager -{ -public: - virtual ~CCacheManager() {} - - qhandle_t SearchLoaded( const char *fileName ); - void InsertLoaded( const char *fileName, qhandle_t handle ); - - qboolean LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ); - void *Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ); - void DeleteAll( void ); - void DumpNonPure( void ); - - virtual qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ) = 0; - -protected: - loadedMap_t loaded; - assetCache_t cache; -}; - -class CImageCacheManager : public CCacheManager -{ -public: - qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); - - void DeleteLightMaps( void ); -}; - -class CModelCacheManager : public CCacheManager -{ -public: - qboolean LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); - void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); - void AllocateShaders( const char *psFileName ); -}; -extern CImageCacheManager *CImgCache; -extern CModelCacheManager *CModelCache; -qboolean C_Models_LevelLoadEnd( qboolean bDeleteEverythingNotUsedInThisLevel ); -qboolean C_Images_LevelLoadEnd( void ); void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload); int C_GetLevel( void ); void C_LevelLoadEnd( void ); diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index c5cfc82c4e..5c0f37fad8 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_models.c -- model loading and caching #include "tr_local.h" +#include "tr_cache.h" #include #define LL(x) x=LittleLong(x) @@ -287,7 +288,7 @@ qhandle_t RE_RegisterModel( const char *name ) { } // search the currently loaded models - if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) + if( ( hModel = CModelCache->GetModelHandle( name ) ) != -1 ) return hModel; if ( name[0] == '*' ) @@ -352,7 +353,7 @@ qhandle_t RE_RegisterModel( const char *name ) { else { // Something loaded - CModelCache->InsertLoaded( name, hModel ); + CModelCache->InsertModelHandle( name, hModel ); return mod->index; } } @@ -382,7 +383,7 @@ qhandle_t RE_RegisterModel( const char *name ) { } } - CModelCache->InsertLoaded( name, hModel ); + CModelCache->InsertModelHandle( name, hModel ); return hModel; } @@ -731,7 +732,7 @@ qhandle_t RE_RegisterServerModel( const char *name ) { } // search the currently loaded models - if( ( hModel = CModelCache->SearchLoaded( name ) ) != -1 ) + if( ( hModel = CModelCache->GetModelHandle( name ) ) != -1 ) return hModel; if ( name[0] == '*' ) @@ -782,13 +783,13 @@ qhandle_t RE_RegisterServerModel( const char *name ) { if( hModel ) { // Something loaded - CModelCache->InsertLoaded( name, hModel ); + CModelCache->InsertModelHandle( name, hModel ); return mod->index; } } } - CModelCache->InsertLoaded( name, hModel ); + CModelCache->InsertModelHandle( name, hModel ); return hModel; } From b52145cf9c84eb89de6ae8992c38926f867a88b6 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Mar 2016 19:36:21 +0000 Subject: [PATCH 345/708] Rend2: remove image cache. Wasn't even used --- codemp/rd-rend2/tr_cache.cpp | 50 +++------------------ codemp/rd-rend2/tr_cache.h | 86 ++++++++++-------------------------- 2 files changed, 30 insertions(+), 106 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 4c21228d5d..9f8d28f899 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -19,7 +19,6 @@ void NormalizePath( char *out, const char *path, size_t outSize ) // This differs significantly from Raven's own caching code. // For starters, we are allowed to use ri-> whatever because we don't care about running on dedicated (use rd-vanilla!) -CImageCacheManager *CImgCache = new CImageCacheManager(); CModelCacheManager *CModelCache = new CModelCacheManager(); CachedFile::CachedFile() @@ -30,7 +29,7 @@ CachedFile::CachedFile() { } -CCacheManager::FileCache::iterator CCacheManager::FindFile( const char *path ) +CModelCacheManager::FileCache::iterator CModelCacheManager::FindFile( const char *path ) { return std::find_if( std::begin(files), std::end(files), [path]( const CachedFile& file ) @@ -62,7 +61,7 @@ static const byte FakeGLAFile[] = 0x00, 0x80, 0x00, 0x80, 0x00, 0x80 }; -qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ) +qboolean CModelCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ) { char path[MAX_QPATH]; NormalizePath(path, pFileName, sizeof(path)); @@ -102,7 +101,7 @@ qboolean CCacheManager::LoadFile( const char *pFileName, void **ppFileBuffer, qb } -void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ) +void* CModelCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ) { int iChecksum; char sModelName[MAX_QPATH]; @@ -157,7 +156,7 @@ void* CCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *psMode * CCacheManager::DeleteAll * Clears out the cache (done on renderer shutdown I suppose) */ -void CCacheManager::DeleteAll( void ) +void CModelCacheManager::DeleteAll( void ) { for ( auto& file : files ) { @@ -165,28 +164,7 @@ void CCacheManager::DeleteAll( void ) } files.swap(FileCache()); - - DeleteRemaining(); -} - -void CImageCacheManager::DeleteLightMaps( void ) -{ - for( auto it = files.begin(); it != files.end(); /* empty */ ) - { - CachedFile& pFile = *it; - if( (pFile.path[0] == '*' && strstr(pFile.path, "lightmap")) || - (pFile.path[0] == '_' && strstr(pFile.path, "fatlightmap")) ) - { - if( pFile.pDiskImage ) - Z_Free( pFile.pDiskImage ); - - it = files.erase(it); - } - else - { - ++it; - } - } + assets.swap(AssetCache()); } /* @@ -194,7 +172,7 @@ void CImageCacheManager::DeleteLightMaps( void ) * Scans the cache for assets which don't match the checksum, and dumps * those that don't match. */ -void CCacheManager::DumpNonPure( void ) +void CModelCacheManager::DumpNonPure( void ) { ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure():\n"); @@ -291,16 +269,6 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) return bAtLeastOneModelFreed; } -void CModelCacheManager::DeleteRemaining() -{ - assets.swap(AssetCache()); -} - -qboolean CImageCacheManager::LevelLoadEnd( qboolean bDeleteEverythingNotUsedThisLevel /* unused */ ) -{ - return qtrue; -} - /* * Wrappers for the above funcs so they export properly. */ @@ -312,7 +280,7 @@ qboolean C_Models_LevelLoadEnd( qboolean deleteUnusedByLevel ) qboolean C_Images_LevelLoadEnd() { - return CImgCache->LevelLoadEnd( qfalse ); + return qtrue; } /* @@ -395,9 +363,6 @@ void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) tr.numBSPModels = 0; - CImgCache->DeleteLightMaps(); - //R_Images_DeleteLightMaps(); - /* If we're switching to the same level, don't increment current level */ if (Q_stricmp( psMapName,sPrevMapName )) { @@ -414,7 +379,6 @@ int C_GetLevel( void ) void C_LevelLoadEnd( void ) { CModelCache->LevelLoadEnd( qfalse ); - CImgCache->LevelLoadEnd( qfalse ); ri->SND_RegisterAudio_LevelLoadEnd( qfalse ); ri->S_RestartMusic(); } \ No newline at end of file diff --git a/codemp/rd-rend2/tr_cache.h b/codemp/rd-rend2/tr_cache.h index 6deb47e714..7b6154a48f 100644 --- a/codemp/rd-rend2/tr_cache.h +++ b/codemp/rd-rend2/tr_cache.h @@ -3,16 +3,6 @@ #include #include -/* - * Cache information specific to each file (FIXME: do we need?) - */ -enum CacheType -{ - CACHE_NONE, - CACHE_IMAGE, - CACHE_MODEL -}; - /* * This stores the loaded file information that we need on retrieval */ @@ -43,82 +33,52 @@ struct CachedFile CachedFile(); }; -/* The actual manager itself, which is used in the model and image loading routines. */ -class CCacheManager +class CModelCacheManager { public: + typedef std::vector AssetCache; typedef std::vector FileCache; public: - virtual ~CCacheManager() {} - /* - * Load the file and chuck the contents into ppFileBuffer, OR - * if we're cached already, chuck cached contents into ppFileBuffer - * and set *pbAlreadyCached to qtrue (otherwise, *pbAlreadyCached = false) + * Return -1 if asset not currently loaded, return positive qhandle_t if found */ - qboolean LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ); + qhandle_t GetModelHandle( const char *fileName ); /* - * Allocate appropriate memory for stuff dealing with cached images - * FIXME: only applies to models? - */ - void *Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ); - void DeleteAll( void ); - void DumpNonPure( void ); - - virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ) = 0; - -protected: - virtual void DeleteRemaining() {} - - Asset * AddAsset( const Asset& asset ); - CachedFile * AddFile( const CachedFile& file ); - - FileCache::iterator FindFile( const char *name ); - -protected: - FileCache files; -}; + * We have a loaded model, let's insert it into the list of loaded models + */ + void InsertModelHandle( const char *fileName, qhandle_t handle ); -class CImageCacheManager : public CCacheManager -{ -public: - virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ); + qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ); + void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); + void AllocateShaders( const char *psFileName ); - void DeleteLightMaps( void ); -}; -class CModelCacheManager : public CCacheManager -{ -public: - typedef std::vector AssetCache; - -public: /* - * Return -1 if asset not currently loaded, return positive qhandle_t if found + * Load the file and chuck the contents into ppFileBuffer, OR + * if we're cached already, chuck cached contents into ppFileBuffer + * and set *pbAlreadyCached to qtrue (otherwise, *pbAlreadyCached = false) */ - qhandle_t GetModelHandle( const char *fileName ); + qboolean LoadFile( const char *pFileName, void **ppFileBuffer, qboolean *pbAlreadyCached ); /* - * We have a loaded model/image, let's insert it into the list of loaded models - */ - void InsertModelHandle( const char *fileName, qhandle_t handle ); - - virtual qboolean LevelLoadEnd( qboolean deleteUnusedByLevel ); - void StoreShaderRequest( const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke ); - void AllocateShaders( const char *psFileName ); - -protected: - virtual void DeleteRemaining(); + * Allocate appropriate memory for stuff dealing with cached images + * FIXME: only applies to models? + */ + void *Allocate( int iSize, void *pvDiskBuffer, const char *psModelFileName, qboolean *bAlreadyFound, memtag_t eTag ); + void DeleteAll( void ); + void DumpNonPure(); private: AssetCache::iterator FindAsset( const char *name ); + FileCache::iterator FindFile( const char *name ); + AssetCache assets; + FileCache files; }; qboolean C_Models_LevelLoadEnd( qboolean deleteUnusedByLevel ); qboolean C_Images_LevelLoadEnd(); -extern CImageCacheManager *CImgCache; extern CModelCacheManager *CModelCache; From c1aa88ce0977c014f32ab9f3fe3d1a8fa5832c6f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Mar 2016 19:39:47 +0000 Subject: [PATCH 346/708] Rend2: Move some functions around --- codemp/rd-rend2/tr_cache.cpp | 36 ------------------------------------ codemp/rd-rend2/tr_init.cpp | 32 ++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_local.h | 11 +---------- 3 files changed, 33 insertions(+), 46 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 9f8d28f899..247c4c3731 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -346,39 +346,3 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) *piShaderPokePtr = sh->index; } } - -/* - * These processes occur outside of the CacheManager class. They are exported by the renderer. - */ - -void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) -{ - static char sPrevMapName[MAX_QPATH]={0}; - bool bDeleteModels = eForceReload == eForceReload_MODELS || eForceReload == eForceReload_ALL; - - if( bDeleteModels ) - CModelCache->DeleteAll(); - else if( ri->Cvar_VariableIntegerValue( "sv_pure" ) ) - CModelCache->DumpNonPure(); - - tr.numBSPModels = 0; - - /* If we're switching to the same level, don't increment current level */ - if (Q_stricmp( psMapName,sPrevMapName )) - { - Q_strncpyz( sPrevMapName, psMapName, sizeof(sPrevMapName) ); - tr.currentLevel++; - } -} - -int C_GetLevel( void ) -{ - return tr.currentLevel; -} - -void C_LevelLoadEnd( void ) -{ - CModelCache->LevelLoadEnd( qfalse ); - ri->SND_RegisterAudio_LevelLoadEnd( qfalse ); - ri->S_RestartMusic(); -} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index dbc2307c8e..38e5348681 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1836,6 +1836,38 @@ void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} static void RE_SetRefractionProperties ( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate ) { } +void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) +{ + static char sPrevMapName[MAX_QPATH]={0}; + bool bDeleteModels = eForceReload == eForceReload_MODELS || eForceReload == eForceReload_ALL; + + if( bDeleteModels ) + CModelCache->DeleteAll(); + else if( ri->Cvar_VariableIntegerValue( "sv_pure" ) ) + CModelCache->DumpNonPure(); + + tr.numBSPModels = 0; + + /* If we're switching to the same level, don't increment current level */ + if (Q_stricmp( psMapName,sPrevMapName )) + { + Q_strncpyz( sPrevMapName, psMapName, sizeof(sPrevMapName) ); + tr.currentLevel++; + } +} + +int C_GetLevel( void ) +{ + return tr.currentLevel; +} + +void C_LevelLoadEnd( void ) +{ + CModelCache->LevelLoadEnd( qfalse ); + ri->SND_RegisterAudio_LevelLoadEnd( qfalse ); + ri->S_RestartMusic(); +} + /* @@@@@@@@@@@@@@@@@@@@@ GetRefAPI diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9479397416..8439829dcd 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3304,16 +3304,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT float ProjectRadius( float r, vec3_t location ); void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const char *psShaderName, int *piShaderIndexPoke); qboolean ShaderHashTableExists(void); -extern void R_ImageLoader_Init(void); - -// tr_cache.cpp - - - - -void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload); -int C_GetLevel( void ); -void C_LevelLoadEnd( void ); +void R_ImageLoader_Init(void); void RB_SurfaceGhoul( CRenderableSurface *surf ); From c18ba3f558012f5bb7f772350c352d3dfc433b6a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 13 Mar 2016 20:03:10 +0000 Subject: [PATCH 347/708] Rend2: Remove fogIndex from sort key In preparation for proper fog implementation --- codemp/rd-rend2/tr_backend.cpp | 3 ++- codemp/rd-rend2/tr_local.h | 11 ++++------- codemp/rd-rend2/tr_main.cpp | 15 +++++++-------- codemp/rd-rend2/tr_shader.cpp | 5 ++--- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 811fd7d88b..6c139f8f3d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -640,7 +640,8 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.pc.c_surfaces += numDrawSurfs; for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &postRender ); + fogNum = drawSurf->fogIndex; entityNum = drawSurf->entityNum; dlighted = drawSurf->lit; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8439829dcd..59fb590214 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1374,11 +1374,7 @@ typedef enum { the drawsurf sort data is packed into a single 32 bit value so it can be compared quickly during the qsorting process */ -#define QSORT_FOGNUM_SHIFT 0 -#define QSORT_FOGNUM_BITS 5 -#define QSORT_FOGNUM_MASK ((1 << QSORT_FOGNUM_BITS) - 1) - -#define QSORT_CUBEMAP_SHIFT (QSORT_FOGNUM_SHIFT + QSORT_FOGNUM_BITS) +#define QSORT_CUBEMAP_SHIFT 0 #define QSORT_CUBEMAP_BITS 6 #define QSORT_CUBEMAP_MASK ((1 << QSORT_CUBEMAP_BITS) - 1) @@ -1399,6 +1395,7 @@ typedef struct drawSurf_s { int entityNum; qboolean lit; surfaceType_t *surface; // any of surface*_t + int fogIndex; } drawSurf_t; #define MAX_FACE_POINTS 64 @@ -2491,8 +2488,8 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e ); void R_AddPolygonSurfaces( void ); -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *fogNum, int *postRender ); -uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int fogIndex, int postRender); +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postRender ); +uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender); void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 22a4c299f6..1339b16d56 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1418,8 +1418,9 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(&tr.viewParms); - R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &postRender ); entityNum = drawSurf->entityNum; + fogNum = drawSurf->fogIndex; RB_BeginSurface( shader, fogNum, cubemap ); rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); @@ -1747,21 +1748,19 @@ bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ) R_DecomposeSort ================= */ -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *fogNum, int *postRender ) +void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postRender ) { - *fogNum = (sort >> QSORT_FOGNUM_SHIFT) & QSORT_FOGNUM_MASK; *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & QSORT_SHADERNUM_MASK ]; *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & QSORT_POSTRENDER_MASK; *cubemap = (sort >> QSORT_CUBEMAP_SHIFT ) & QSORT_CUBEMAP_MASK; } -uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int fogIndex, int postRender) +uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender) { uint32_t key = 0; key |= (sortedShaderIndex & QSORT_SHADERNUM_MASK) << QSORT_SHADERNUM_SHIFT; key |= (cubemapIndex & QSORT_CUBEMAP_MASK) << QSORT_CUBEMAP_SHIFT; - key |= (fogIndex & QSORT_FOGNUM_MASK) << QSORT_FOGNUM_SHIFT; key |= (postRender & QSORT_POSTRENDER_MASK) << QSORT_POSTRENDER_SHIFT; return key; @@ -1792,10 +1791,11 @@ void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, in index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; surf = tr.refdef.drawSurfs + index; - surf->sort = R_CreateSortKey(shader->sortedIndex, cubemap, fogIndex, postRender); + surf->sort = R_CreateSortKey(shader->sortedIndex, cubemap, postRender); surf->entityNum = entityNum; surf->lit = (qboolean)dlightMap; surf->surface = surface; + surf->fogIndex = fogIndex; tr.refdef.numDrawSurfs++; } @@ -1829,11 +1829,10 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { for ( int i = 0 ; i < numDrawSurfs ; i++ ) { int entityNum; shader_t *shader; - int fogNum; int postRender; int cubemap; - R_DecomposeSort( (drawSurfs+i)->sort, &shader, &cubemap, &fogNum, &postRender ); + R_DecomposeSort( (drawSurfs+i)->sort, &shader, &cubemap, &postRender ); entityNum = drawSurfs[i].entityNum; if ( shader->sort > SS_PORTAL ) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 61f5be8883..8610ce40f1 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3463,18 +3463,17 @@ static void FixRenderCommandList( int newShader ) { int i; drawSurf_t *drawSurf; shader_t *shader; - int fogNum; int postRender; int sortedIndex; int cubemap; const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &fogNum, &postRender ); + R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &postRender ); sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = R_CreateSortKey(sortedIndex, cubemap, fogNum, postRender); + drawSurf->sort = R_CreateSortKey(sortedIndex, cubemap, postRender); } } curCmd = (const void *)(ds_cmd + 1); From 04e3d27dfad071500f6231ea415c29493e4be78d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 20 Mar 2016 17:44:49 +0000 Subject: [PATCH 348/708] Rend2: Start improving GLSL shader code handling First of many improvements to come --- codemp/rd-rend2/CMakeLists.txt | 14 +- .../glsl/{bokeh_fp.glsl => bokeh.glsl} | 15 + codemp/rd-rend2/glsl/bokeh_vp.glsl | 12 - ...calclevels4x_fp.glsl => calclevels4x.glsl} | 15 + codemp/rd-rend2/glsl/calclevels4x_vp.glsl | 12 - codemp/rd-rend2/glsl/compact.cpp | 129 +++++-- .../{depthblur_fp.glsl => depthblur.glsl} | 15 + codemp/rd-rend2/glsl/depthblur_vp.glsl | 12 - ...wnsample_fp.glsl => dglow_downsample.glsl} | 22 ++ codemp/rd-rend2/glsl/dglow_downsample_vp.glsl | 19 - ...w_upsample_fp.glsl => dglow_upsample.glsl} | 22 ++ codemp/rd-rend2/glsl/dglow_upsample_vp.glsl | 19 - .../glsl/{dlight_vp.glsl => dlight.glsl} | 30 ++ codemp/rd-rend2/glsl/dlight_fp.glsl | 27 -- .../glsl/{down4x_fp.glsl => down4x.glsl} | 16 + codemp/rd-rend2/glsl/down4x_vp.glsl | 13 - .../glsl/{fogpass_vp.glsl => fogpass.glsl} | 35 ++ codemp/rd-rend2/glsl/fogpass_fp.glsl | 32 -- ...ussian_blur_fp.glsl => gaussian_blur.glsl} | 24 ++ codemp/rd-rend2/glsl/gaussian_blur_vp.glsl | 21 -- .../glsl/{generic_vp.glsl => generic.glsl} | 39 +++ codemp/rd-rend2/glsl/generic_fp.glsl | 35 -- .../glsl/{lightall_fp.glsl => lightall.glsl} | 317 +++++++++++++++++ codemp/rd-rend2/glsl/lightall_vp.glsl | 314 ----------------- .../glsl/{pshadow_fp.glsl => pshadow.glsl} | 19 + codemp/rd-rend2/glsl/pshadow_vp.glsl | 16 - .../{shadowfill_vp.glsl => shadowfill.glsl} | 46 +++ codemp/rd-rend2/glsl/shadowfill_fp.glsl | 43 --- .../{shadowmask_fp.glsl => shadowmask.glsl} | 21 ++ codemp/rd-rend2/glsl/shadowmask_vp.glsl | 18 - .../rd-rend2/glsl/{ssao_fp.glsl => ssao.glsl} | 15 + codemp/rd-rend2/glsl/ssao_vp.glsl | 12 - ...e_sprites_vp.glsl => surface_sprites.glsl} | 39 +++ codemp/rd-rend2/glsl/surface_sprites_fp.glsl | 36 -- ...texturecolor_vp.glsl => texturecolor.glsl} | 15 + codemp/rd-rend2/glsl/texturecolor_fp.glsl | 12 - .../glsl/{tonemap_fp.glsl => tonemap.glsl} | 16 + codemp/rd-rend2/glsl/tonemap_vp.glsl | 13 - codemp/rd-rend2/tr_allocator.cpp | 53 +++ codemp/rd-rend2/tr_allocator.h | 58 ++++ codemp/rd-rend2/tr_glsl.cpp | 327 +++++++++++------- codemp/rd-rend2/tr_glsl_parse.cpp | 137 ++++++++ codemp/rd-rend2/tr_local.h | 45 ++- 43 files changed, 1319 insertions(+), 831 deletions(-) rename codemp/rd-rend2/glsl/{bokeh_fp.glsl => bokeh.glsl} (94%) delete mode 100644 codemp/rd-rend2/glsl/bokeh_vp.glsl rename codemp/rd-rend2/glsl/{calclevels4x_fp.glsl => calclevels4x.glsl} (85%) delete mode 100644 codemp/rd-rend2/glsl/calclevels4x_vp.glsl rename codemp/rd-rend2/glsl/{depthblur_fp.glsl => depthblur.glsl} (85%) delete mode 100644 codemp/rd-rend2/glsl/depthblur_vp.glsl rename codemp/rd-rend2/glsl/{dglow_downsample_fp.glsl => dglow_downsample.glsl} (80%) delete mode 100644 codemp/rd-rend2/glsl/dglow_downsample_vp.glsl rename codemp/rd-rend2/glsl/{dglow_upsample_fp.glsl => dglow_upsample.glsl} (74%) delete mode 100644 codemp/rd-rend2/glsl/dglow_upsample_vp.glsl rename codemp/rd-rend2/glsl/{dlight_vp.glsl => dlight.glsl} (88%) delete mode 100644 codemp/rd-rend2/glsl/dlight_fp.glsl rename codemp/rd-rend2/glsl/{down4x_fp.glsl => down4x.glsl} (85%) delete mode 100644 codemp/rd-rend2/glsl/down4x_vp.glsl rename codemp/rd-rend2/glsl/{fogpass_vp.glsl => fogpass.glsl} (89%) delete mode 100644 codemp/rd-rend2/glsl/fogpass_fp.glsl rename codemp/rd-rend2/glsl/{gaussian_blur_fp.glsl => gaussian_blur.glsl} (85%) delete mode 100644 codemp/rd-rend2/glsl/gaussian_blur_vp.glsl rename codemp/rd-rend2/glsl/{generic_vp.glsl => generic.glsl} (92%) delete mode 100644 codemp/rd-rend2/glsl/generic_fp.glsl rename codemp/rd-rend2/glsl/{lightall_fp.glsl => lightall.glsl} (61%) delete mode 100644 codemp/rd-rend2/glsl/lightall_vp.glsl rename codemp/rd-rend2/glsl/{pshadow_fp.glsl => pshadow.glsl} (87%) delete mode 100644 codemp/rd-rend2/glsl/pshadow_vp.glsl rename codemp/rd-rend2/glsl/{shadowfill_vp.glsl => shadowfill.glsl} (81%) delete mode 100644 codemp/rd-rend2/glsl/shadowfill_fp.glsl rename codemp/rd-rend2/glsl/{shadowmask_fp.glsl => shadowmask.glsl} (89%) delete mode 100644 codemp/rd-rend2/glsl/shadowmask_vp.glsl rename codemp/rd-rend2/glsl/{ssao_fp.glsl => ssao.glsl} (89%) delete mode 100644 codemp/rd-rend2/glsl/ssao_vp.glsl rename codemp/rd-rend2/glsl/{surface_sprites_vp.glsl => surface_sprites.glsl} (70%) delete mode 100644 codemp/rd-rend2/glsl/surface_sprites_fp.glsl rename codemp/rd-rend2/glsl/{texturecolor_vp.glsl => texturecolor.glsl} (53%) delete mode 100644 codemp/rd-rend2/glsl/texturecolor_fp.glsl rename codemp/rd-rend2/glsl/{tonemap_fp.glsl => tonemap.glsl} (84%) delete mode 100644 codemp/rd-rend2/glsl/tonemap_vp.glsl create mode 100644 codemp/rd-rend2/tr_allocator.cpp create mode 100644 codemp/rd-rend2/tr_allocator.h create mode 100644 codemp/rd-rend2/tr_glsl_parse.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 0413fee8f9..7a141c65a8 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -3,9 +3,7 @@ if(NOT InOpenJK) message(FATAL_ERROR "Use the top-level cmake script!") endif(NOT InOpenJK) -set(MPRend2IncludeDirectories ${MPDir}) set(MPRend2IncludeDirectories - "${MPRend2IncludeDirectories}" "${SharedDir}" "${MPDir}" "${MPDir}/rd-rend2" @@ -21,6 +19,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_bones.cpp" "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" + "${MPDir}/rd-rend2/tr_allocator.cpp" "${MPDir}/rd-rend2/tr_animation.cpp" "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" @@ -38,6 +37,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_flares.cpp" "${MPDir}/rd-rend2/tr_ghoul2.cpp" "${MPDir}/rd-rend2/tr_glsl.cpp" + "${MPDir}/rd-rend2/tr_glsl_parse.cpp" "${MPDir}/rd-rend2/tr_image.cpp" "${MPDir}/rd-rend2/tr_init.cpp" "${MPDir}/rd-rend2/tr_light.cpp" @@ -159,13 +159,19 @@ set_target_properties(${MPRend2} PROPERTIES COMPILE_DEFINITIONS "${SharedDefines # Hide symbols not explicitly marked public. set_property(TARGET ${MPRend2} APPEND PROPERTY COMPILE_OPTIONS ${OPENJK_VISIBILITY_FLAGS}) - set_target_properties(${MPRend2} PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") set_target_properties(${MPRend2} PROPERTIES PROJECT_LABEL "MP Rend2 Renderer") target_link_libraries(${MPRend2} ${MPRend2Libraries}) # GLSL shader file generator -add_executable(compact_glsl ${MPDir}/rd-rend2/glsl/compact.cpp) +add_executable(compact_glsl + ${MPDir}/rd-rend2/glsl/compact.cpp + ${MPDir}/rd-rend2/tr_allocator.cpp + ${MPDir}/rd-rend2/tr_allocator.h + ${MPDir}/rd-rend2/tr_glsl_parse.cpp + ) +set_target_properties(compact_glsl PROPERTIES COMPILE_DEFINITIONS "GLSL_BUILDTOOL") +set_target_properties(compact_glsl PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp COMMAND compact_glsl ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp ${MPRend2GLSLFiles} diff --git a/codemp/rd-rend2/glsl/bokeh_fp.glsl b/codemp/rd-rend2/glsl/bokeh.glsl similarity index 94% rename from codemp/rd-rend2/glsl/bokeh_fp.glsl rename to codemp/rd-rend2/glsl/bokeh.glsl index 2404cecffe..c2337c28be 100644 --- a/codemp/rd-rend2/glsl/bokeh_fp.glsl +++ b/codemp/rd-rend2/glsl/bokeh.glsl @@ -1,3 +1,18 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec2 var_TexCoords; + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); + var_TexCoords = attr_TexCoord0.st; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec4 u_Color; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/bokeh_vp.glsl b/codemp/rd-rend2/glsl/bokeh_vp.glsl deleted file mode 100644 index 8a5f1940bb..0000000000 --- a/codemp/rd-rend2/glsl/bokeh_vp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -in vec3 attr_Position; -in vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -out vec2 var_TexCoords; - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/codemp/rd-rend2/glsl/calclevels4x_fp.glsl b/codemp/rd-rend2/glsl/calclevels4x.glsl similarity index 85% rename from codemp/rd-rend2/glsl/calclevels4x_fp.glsl rename to codemp/rd-rend2/glsl/calclevels4x.glsl index 8f5189647c..be67b479e6 100644 --- a/codemp/rd-rend2/glsl/calclevels4x_fp.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x.glsl @@ -1,3 +1,18 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec2 var_TexCoords; + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); + var_TexCoords = attr_TexCoord0.st; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec4 u_Color; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl b/codemp/rd-rend2/glsl/calclevels4x_vp.glsl deleted file mode 100644 index 8a5f1940bb..0000000000 --- a/codemp/rd-rend2/glsl/calclevels4x_vp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -in vec3 attr_Position; -in vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -out vec2 var_TexCoords; - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 72a4cb6f63..9a7862aa7f 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -1,12 +1,20 @@ #include +#include #include #include +#include #include #include -typedef std::vector string_list; +#include "tr_local.h" +#include "tr_allocator.h" -bool should_be_escaped ( char c ) +namespace +{ + +using StringList = std::vector; + +bool ShouldEscape( char c ) { switch ( c ) { @@ -18,27 +26,27 @@ bool should_be_escaped ( char c ) } } -std::string& escape_string ( std::string& s ) +std::string& Escape( std::string& s ) { - std::string::difference_type escapable_characters = std::count_if( s.begin(), s.end(), should_be_escaped ); - if ( escapable_characters == 0 ) + std::string::difference_type escapableCharacters = std::count_if( s.begin(), s.end(), ShouldEscape ); + if ( escapableCharacters == 0 ) { return s; } - if ( s.capacity() < s.length() + escapable_characters ) + if ( (s.capacity() < s.length()) + escapableCharacters ) { // Grow if necessary. - s.resize (s.length() + escapable_characters); + s.resize(s.length() + escapableCharacters); } std::string::iterator it = s.begin(); while ( it != s.end() ) { char c = *it; - if ( should_be_escaped (c) ) + if ( ShouldEscape(c) ) { - it = s.insert (it, '\\'); + it = s.insert(it, '\\'); it += 2; } else @@ -50,14 +58,38 @@ std::string& escape_string ( std::string& s ) return s; } -bool ends_with ( const std::string& s, const std::string& suffix ) +bool EndsWith( const std::string& s, const std::string& suffix ) +{ + return s.compare(s.length() - suffix.length(), suffix.length(), suffix) == 0; +} + +const char *GetShaderSuffix( GPUShaderType type ) +{ + switch ( type ) + { + case GPUSHADER_VERTEX: return "_vp"; + case GPUSHADER_FRAGMENT: return "_fp"; + default: assert(!"Invalid shader type"); + } + return nullptr; +} + +const char *ToString( GPUShaderType type ) { - return s.compare (s.length() - suffix.length(), suffix.length(), suffix) == 0; + switch ( type ) + { + case GPUSHADER_VERTEX: return "GPUSHADER_VERTEX"; + case GPUSHADER_FRAGMENT: return "GPUSHADER_FRAGMENT"; + default: assert(!"Invalid shader type"); + } + return nullptr; } -int main ( int argc, char *argv[] ) +} // anonymous namespace + +int main( int argc, char *argv[] ) { - string_list args (argv, argv + argc); + StringList args(argv, argv + argc); if ( args.empty() ) { @@ -72,52 +104,93 @@ int main ( int argc, char *argv[] ) } std::string& outFile = args[1]; - string_list glslFiles (args.begin() + 2, args.end()); + StringList glslFiles(args.begin() + 2, args.end()); std::cout << "Outputting to " << outFile << '\n'; - std::string output = "#include \"tr_local.h\"\n\n"; + Allocator allocator(512 * 1024); + std::ostringstream ss; std::string line; - for ( string_list::const_iterator it = glslFiles.begin(); + + ss << "#include \"tr_local.h\"\n\n"; + for ( StringList::const_iterator it = glslFiles.begin(); it != glslFiles.end(); ++it ) { + // Get shader name from file name - if ( !ends_with (*it, ".glsl") ) + if ( !EndsWith(*it, ".glsl") ) { std::cerr << *it << " doesn't end with .glsl extension.\n"; continue; } - std::string::size_type lastSlash = it->find_last_of ("\\/"); - std::string shaderName (it->begin() + lastSlash + 1, it->end() - 5); + std::string::size_type lastSlash = it->find_last_of("\\/"); + std::string shaderName(it->begin() + lastSlash + 1, it->end() - 5); // Write, one line at a time to the output - std::ifstream fs (it->c_str(), std::ios::in); + std::ifstream fs(it->c_str()); if ( !fs ) { std::cerr << *it << " could not be opened.\n"; continue; } - output += "const char *fallbackShader_" + shaderName + " = \""; - while ( std::getline (fs, line) ) + std::streampos fileSize; + fs.seekg(0, std::ios::end); + fileSize = fs.tellg(); + fs.seekg(0, std::ios::beg); + + allocator.Reset(); + + char *programText = ojkAllocString(allocator, fileSize); + memset(programText, 0, (size_t)fileSize + 1); + fs.read(programText, fileSize); + + GPUProgramDesc programDesc = ParseProgramSource(allocator, programText); + for ( size_t i = 0, numShaders = programDesc.numShaders; i < numShaders; ++i ) { - if ( line.empty() ) + GPUShaderDesc& shaderDesc = programDesc.shaders[i]; + const char *suffix = GetShaderSuffix(shaderDesc.type); + + ss << "const char *fallback_" + shaderName + suffix + " = \""; + + const char *lineStart = shaderDesc.source; + const char *lineEnd = strchr(lineStart, '\n'); + while ( lineEnd ) { - continue; + line.assign(lineStart, lineEnd - lineStart); + ss << Escape(line); + ss << "\\n\"\n\""; + + lineStart = lineEnd + 1; + lineEnd = strchr(lineStart, '\n'); } - output += escape_string (line) + "\\n\"\n\""; + line.assign(lineStart); + ss << Escape(line) << "\";\n"; + } + + ss << "GPUShaderDesc fallback_" << shaderName << "Shaders[] = {\n"; + for ( size_t i = 0, numShaders = programDesc.numShaders; i < numShaders; ++i ) + { + GPUShaderDesc& shaderDesc = programDesc.shaders[i]; + const char *suffix = GetShaderSuffix(shaderDesc.type); + + ss << " { " << ToString(shaderDesc.type) << ", " + "fallback_" << shaderName << suffix << " },\n"; } - output += "\";\n\n"; + ss << "};\n"; + + ss << "extern const GPUProgramDesc fallback_" << shaderName << "Program = { " + << programDesc.numShaders << ", fallback_" << shaderName << "Shaders };\n\n"; } - std::ofstream ofs (outFile.c_str(), std::ios::out); + std::ofstream ofs(outFile.c_str()); if ( !ofs ) { std::cerr << "Could not create file " << outFile << '\n'; } - ofs << output; + ofs << ss.str(); } diff --git a/codemp/rd-rend2/glsl/depthblur_fp.glsl b/codemp/rd-rend2/glsl/depthblur.glsl similarity index 85% rename from codemp/rd-rend2/glsl/depthblur_fp.glsl rename to codemp/rd-rend2/glsl/depthblur.glsl index 102a9def8f..91b8b6a401 100644 --- a/codemp/rd-rend2/glsl/depthblur_fp.glsl +++ b/codemp/rd-rend2/glsl/depthblur.glsl @@ -1,3 +1,18 @@ +/*[Vertex]*/ +in vec4 attr_Position; +in vec4 attr_TexCoord0; + +out vec2 var_ScreenTex; + +void main() +{ + gl_Position = attr_Position; + var_ScreenTex = attr_TexCoord0.xy; + //vec2 screenCoords = gl_Position.xy / gl_Position.w; + //var_ScreenTex = screenCoords * 0.5 + 0.5; +} + +/*[Fragment]*/ uniform sampler2D u_ScreenImageMap; uniform sampler2D u_ScreenDepthMap; uniform vec4 u_ViewInfo; // zfar / znear, zfar diff --git a/codemp/rd-rend2/glsl/depthblur_vp.glsl b/codemp/rd-rend2/glsl/depthblur_vp.glsl deleted file mode 100644 index 22c12b3e9b..0000000000 --- a/codemp/rd-rend2/glsl/depthblur_vp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - -out vec2 var_ScreenTex; - -void main() -{ - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; -} diff --git a/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_downsample.glsl similarity index 80% rename from codemp/rd-rend2/glsl/dglow_downsample_fp.glsl rename to codemp/rd-rend2/glsl/dglow_downsample.glsl index 684bc21970..e68b019605 100644 --- a/codemp/rd-rend2/glsl/dglow_downsample_fp.glsl +++ b/codemp/rd-rend2/glsl/dglow_downsample.glsl @@ -1,3 +1,25 @@ +/*[Vertex]*/ +out vec2 var_TexCoords; + +void main() +{ + const vec2 positions[] = vec2[3]( + vec2(-1.0f, -1.0f), + vec2(-1.0f, 3.0f), + vec2( 3.0f, -1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl b/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl deleted file mode 100644 index 3dc80a8bbe..0000000000 --- a/codemp/rd-rend2/glsl/dglow_downsample_vp.glsl +++ /dev/null @@ -1,19 +0,0 @@ -out vec2 var_TexCoords; - -void main() -{ - const vec2 positions[] = vec2[3]( - vec2(-1.0f, -1.0f), - vec2(-1.0f, 3.0f), - vec2( 3.0f, -1.0f) - ); - - const vec2 texcoords[] = vec2[3]( - vec2( 0.0f, 1.0f), - vec2( 0.0f, -1.0f), - vec2( 2.0f, 1.0f) - ); - - gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); - var_TexCoords = texcoords[gl_VertexID]; -} diff --git a/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl b/codemp/rd-rend2/glsl/dglow_upsample.glsl similarity index 74% rename from codemp/rd-rend2/glsl/dglow_upsample_fp.glsl rename to codemp/rd-rend2/glsl/dglow_upsample.glsl index 1085dbe608..3cb3e1d79a 100644 --- a/codemp/rd-rend2/glsl/dglow_upsample_fp.glsl +++ b/codemp/rd-rend2/glsl/dglow_upsample.glsl @@ -1,3 +1,25 @@ +/*[Vertex]*/ +out vec2 var_TexCoords; + +void main() +{ + const vec2 positions[] = vec2[3]( + vec2(-1.0f, -1.0f), + vec2(-1.0f, 3.0f), + vec2( 3.0f, -1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl b/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl deleted file mode 100644 index 3dc80a8bbe..0000000000 --- a/codemp/rd-rend2/glsl/dglow_upsample_vp.glsl +++ /dev/null @@ -1,19 +0,0 @@ -out vec2 var_TexCoords; - -void main() -{ - const vec2 positions[] = vec2[3]( - vec2(-1.0f, -1.0f), - vec2(-1.0f, 3.0f), - vec2( 3.0f, -1.0f) - ); - - const vec2 texcoords[] = vec2[3]( - vec2( 0.0f, 1.0f), - vec2( 0.0f, -1.0f), - vec2( 2.0f, 1.0f) - ); - - gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); - var_TexCoords = texcoords[gl_VertexID]; -} diff --git a/codemp/rd-rend2/glsl/dlight_vp.glsl b/codemp/rd-rend2/glsl/dlight.glsl similarity index 88% rename from codemp/rd-rend2/glsl/dlight_vp.glsl rename to codemp/rd-rend2/glsl/dlight.glsl index 243333bc06..2168afdb82 100644 --- a/codemp/rd-rend2/glsl/dlight_vp.glsl +++ b/codemp/rd-rend2/glsl/dlight.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec2 attr_TexCoord0; in vec3 attr_Normal; @@ -175,3 +176,32 @@ void main() var_Color = u_Color * dlightmod; } + +/*[Fragment]*/ +uniform sampler2D u_DiffuseMap; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif + +in vec2 var_Tex1; +in vec4 var_Color; + +out vec4 out_Color; + +void main() +{ + vec4 color = texture(u_DiffuseMap, var_Tex1); + +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (color.a < u_AlphaTestValue) +# endif + discard; +#endif + + out_Color = color * var_Color; +} diff --git a/codemp/rd-rend2/glsl/dlight_fp.glsl b/codemp/rd-rend2/glsl/dlight_fp.glsl deleted file mode 100644 index 2b763e2c33..0000000000 --- a/codemp/rd-rend2/glsl/dlight_fp.glsl +++ /dev/null @@ -1,27 +0,0 @@ -uniform sampler2D u_DiffuseMap; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; -#endif - -in vec2 var_Tex1; -in vec4 var_Color; - -out vec4 out_Color; - -void main() -{ - vec4 color = texture(u_DiffuseMap, var_Tex1); - -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (color.a < u_AlphaTestValue) -# endif - discard; -#endif - - out_Color = color * var_Color; -} diff --git a/codemp/rd-rend2/glsl/down4x_fp.glsl b/codemp/rd-rend2/glsl/down4x.glsl similarity index 85% rename from codemp/rd-rend2/glsl/down4x_fp.glsl rename to codemp/rd-rend2/glsl/down4x.glsl index 9940996069..7034cb81e9 100644 --- a/codemp/rd-rend2/glsl/down4x_fp.glsl +++ b/codemp/rd-rend2/glsl/down4x.glsl @@ -1,3 +1,19 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); + var_TexCoords = attr_TexCoord0.st; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/down4x_vp.glsl b/codemp/rd-rend2/glsl/down4x_vp.glsl deleted file mode 100644 index 984c70f104..0000000000 --- a/codemp/rd-rend2/glsl/down4x_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -in vec3 attr_Position; -in vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -out vec2 var_TexCoords; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/codemp/rd-rend2/glsl/fogpass_vp.glsl b/codemp/rd-rend2/glsl/fogpass.glsl similarity index 89% rename from codemp/rd-rend2/glsl/fogpass_vp.glsl rename to codemp/rd-rend2/glsl/fogpass.glsl index db0e68ae7f..bfd9699dae 100644 --- a/codemp/rd-rend2/glsl/fogpass_vp.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec3 attr_Normal; @@ -229,3 +230,37 @@ void main() var_Scale = CalcFog(position) * u_Color.a * u_Color.a; } + +/*[Fragment]*/ +uniform vec4 u_Color; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif + +in float var_Scale; + +out vec4 out_Color; +out vec4 out_Glow; + +void main() +{ + out_Color.rgb = u_Color.rgb; + out_Color.a = sqrt(clamp(var_Scale, 0.0, 1.0)); + +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (out_Color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (out_Color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (out_Color.a < u_AlphaTestValue) +# endif + discard; +#endif + +#if defined(USE_GLOW_BUFFER) + out_Glow = out_Color; +#else + out_Glow = vec4(0.0); +#endif +} diff --git a/codemp/rd-rend2/glsl/fogpass_fp.glsl b/codemp/rd-rend2/glsl/fogpass_fp.glsl deleted file mode 100644 index 4530cbceef..0000000000 --- a/codemp/rd-rend2/glsl/fogpass_fp.glsl +++ /dev/null @@ -1,32 +0,0 @@ -uniform vec4 u_Color; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; -#endif - -in float var_Scale; - -out vec4 out_Color; -out vec4 out_Glow; - -void main() -{ - out_Color.rgb = u_Color.rgb; - out_Color.a = sqrt(clamp(var_Scale, 0.0, 1.0)); - -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (out_Color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (out_Color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (out_Color.a < u_AlphaTestValue) -# endif - discard; -#endif - -#if defined(USE_GLOW_BUFFER) - out_Glow = out_Color; -#else - out_Glow = vec4(0.0); -#endif -} diff --git a/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl b/codemp/rd-rend2/glsl/gaussian_blur.glsl similarity index 85% rename from codemp/rd-rend2/glsl/gaussian_blur_fp.glsl rename to codemp/rd-rend2/glsl/gaussian_blur.glsl index b76fed2f59..e6593f56ce 100644 --- a/codemp/rd-rend2/glsl/gaussian_blur_fp.glsl +++ b/codemp/rd-rend2/glsl/gaussian_blur.glsl @@ -1,3 +1,27 @@ +/*[Vertex]*/ +out vec2 var_TexCoords; + +void main() +{ + const vec2 positions[4] = vec2[]( + vec2 (-1.0, -1.0), + vec2 (1.0, -1.0), + vec2 (1.0, 1.0), + vec2 (-1.0, 1.0) + ); + + const vec2 texcoords[4] = vec2[]( + vec2 (0.0, 0.0), + vec2 (1.0, 0.0), + vec2 (1.0, 1.0), + vec2 (0.0, 1.0) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_TexCoords = texcoords[gl_VertexID]; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform vec4 u_Color; uniform vec2 u_InvTexRes; diff --git a/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl b/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl deleted file mode 100644 index d3965cfabb..0000000000 --- a/codemp/rd-rend2/glsl/gaussian_blur_vp.glsl +++ /dev/null @@ -1,21 +0,0 @@ -out vec2 var_TexCoords; - -void main() -{ - const vec2 positions[4] = vec2[]( - vec2 (-1.0, -1.0), - vec2 (1.0, -1.0), - vec2 (1.0, 1.0), - vec2 (-1.0, 1.0) - ); - - const vec2 texcoords[4] = vec2[]( - vec2 (0.0, 0.0), - vec2 (1.0, 0.0), - vec2 (1.0, 1.0), - vec2 (0.0, 1.0) - ); - - gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); - var_TexCoords = texcoords[gl_VertexID]; -} diff --git a/codemp/rd-rend2/glsl/generic_vp.glsl b/codemp/rd-rend2/glsl/generic.glsl similarity index 92% rename from codemp/rd-rend2/glsl/generic_vp.glsl rename to codemp/rd-rend2/glsl/generic.glsl index 481e3bfc35..49aa577c80 100644 --- a/codemp/rd-rend2/glsl/generic_vp.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec3 attr_Normal; @@ -356,3 +357,41 @@ void main() var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0)); #endif } + + +/*[Fragment]*/ +uniform sampler2D u_DiffuseMap; +#if defined(USE_ATEST) +uniform float u_AlphaTestValue; +#endif + +in vec2 var_DiffuseTex; + +in vec4 var_Color; + +out vec4 out_Color; +out vec4 out_Glow; + +void main() +{ + vec4 color = texture(u_DiffuseMap, var_DiffuseTex); + +#if defined(USE_ATEST) +# if USE_ATEST == ATEST_CMP_LT + if (color.a >= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GT + if (color.a <= u_AlphaTestValue) +# elif USE_ATEST == ATEST_CMP_GE + if (color.a < u_AlphaTestValue) +# endif + discard; +#endif + + out_Color = color * var_Color; + +#if defined(USE_GLOW_BUFFER) + out_Glow = out_Color; +#else + out_Glow = vec4(0.0); +#endif +} diff --git a/codemp/rd-rend2/glsl/generic_fp.glsl b/codemp/rd-rend2/glsl/generic_fp.glsl deleted file mode 100644 index a95f890be9..0000000000 --- a/codemp/rd-rend2/glsl/generic_fp.glsl +++ /dev/null @@ -1,35 +0,0 @@ -uniform sampler2D u_DiffuseMap; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; -#endif - -in vec2 var_DiffuseTex; - -in vec4 var_Color; - -out vec4 out_Color; -out vec4 out_Glow; - -void main() -{ - vec4 color = texture(u_DiffuseMap, var_DiffuseTex); - -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (color.a < u_AlphaTestValue) -# endif - discard; -#endif - - out_Color = color * var_Color; - -#if defined(USE_GLOW_BUFFER) - out_Glow = out_Color; -#else - out_Glow = vec4(0.0); -#endif -} diff --git a/codemp/rd-rend2/glsl/lightall_fp.glsl b/codemp/rd-rend2/glsl/lightall.glsl similarity index 61% rename from codemp/rd-rend2/glsl/lightall_fp.glsl rename to codemp/rd-rend2/glsl/lightall.glsl index 49a247f708..7a052e2295 100644 --- a/codemp/rd-rend2/glsl/lightall_fp.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -1,3 +1,320 @@ +/*[Vertex]*/ +in vec2 attr_TexCoord0; +#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) +in vec2 attr_TexCoord1; +in vec2 attr_TexCoord2; +in vec2 attr_TexCoord3; +in vec2 attr_TexCoord4; +#endif +in vec4 attr_Color; + +in vec3 attr_Position; +in vec3 attr_Normal; +#if defined(USE_VERT_TANGENT_SPACE) +in vec4 attr_Tangent; +#endif + +#if defined(USE_VERTEX_ANIMATION) +in vec3 attr_Position2; +in vec3 attr_Normal2; + #if defined(USE_VERT_TANGENT_SPACE) +in vec4 attr_Tangent2; + #endif +#elif defined(USE_SKELETAL_ANIMATION) +in uvec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; +#endif + +#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) +in vec3 attr_LightDirection; +#endif + +#if defined(USE_DELUXEMAP) +uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube +#endif + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +uniform vec3 u_ViewOrigin; +#endif + +#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; +uniform vec3 u_LocalViewOrigin; +uniform int u_TCGen1; +#endif + +#if defined(USE_TCMOD) +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; +#endif + +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; + +#if defined(USE_MODELMATRIX) +uniform mat4 u_ModelMatrix; +#endif + +#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +#elif defined(USE_SKELETAL_ANIMATION) +uniform mat4x3 u_BoneMatrices[20]; +#endif + +#if defined(USE_LIGHT_VECTOR) +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; + #if defined(USE_FAST_LIGHT) +uniform vec3 u_DirectedLight; +uniform vec3 u_AmbientLight; + #endif +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +uniform vec4 u_PrimaryLightOrigin; +uniform float u_PrimaryLightRadius; +#endif + +out vec4 var_TexCoords; +out vec4 var_Color; +out vec3 var_N; + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_VERT_TANGENT_SPACE) +out vec4 var_Normal; +out vec4 var_Tangent; +out vec4 var_Bitangent; + #else +out vec3 var_Normal; +out vec3 var_ViewDir; + #endif +#endif + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +out vec4 var_LightDir; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) +out vec4 var_PrimaryLightDir; +#endif + +#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) +vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) +{ + vec2 tex = attr_TexCoord0; + + switch (TCGen) + { + case TCGEN_LIGHTMAP: + tex = attr_TexCoord1; + break; + + case TCGEN_LIGHTMAP1: + tex = attr_TexCoord2; + break; + + case TCGEN_LIGHTMAP2: + tex = attr_TexCoord3; + break; + + case TCGEN_LIGHTMAP3: + tex = attr_TexCoord4; + break; + + case TCGEN_ENVIRONMENT_MAPPED: + { + vec3 viewer = normalize(u_LocalViewOrigin - position); + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; + } + break; + + case TCGEN_VECTOR: + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + break; + } + + return tex; +} +#endif + +#if defined(USE_TCMOD) +vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) +{ + float amplitude = offTurb.z; + float phase = offTurb.w * 2.0 * M_PI; + vec2 st2; + st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); + st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); + + vec2 offsetPos = vec2(position.x + position.z, position.y); + + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); + + return st2 + texOffset * amplitude; +} +#endif + + +float CalcLightAttenuation(float point, float normDist) +{ + // zero light at 1.0, approximating q3 style + // also don't attenuate directional light + float attenuation = (0.5 * normDist - 1.5) * point + 1.0; + + // clamp attenuation + #if defined(NO_LIGHT_CLAMP) + attenuation = max(attenuation, 0.0); + #else + attenuation = clamp(attenuation, 0.0, 1.0); + #endif + + return attenuation; +} + + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); + #endif +#elif defined(USE_SKELETAL_ANIMATION) + vec4 position4 = vec4(0.0); + vec4 normal4 = vec4(0.0); + vec4 originalPosition = vec4(attr_Position, 1.0); + vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec4 tangent4 = vec4(0.0); + vec4 originalTangent = vec4(attr_Tangent.xyz - vec3(0.5), 0.0); +#endif + + for (int i = 0; i < 4; i++) + { + uint boneIndex = attr_BoneIndexes[i]; + + mat4 boneMatrix = mat4( + vec4(u_BoneMatrices[boneIndex][0], 0.0), + vec4(u_BoneMatrices[boneIndex][1], 0.0), + vec4(u_BoneMatrices[boneIndex][2], 0.0), + vec4(u_BoneMatrices[boneIndex][3], 1.0) + ); + + position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; + normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + tangent4 += (boneMatrix * originalTangent) * attr_BoneWeights[i]; +#endif + } + + vec3 position = position4.xyz; + vec3 normal = normalize (normal4.xyz); +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 tangent = normalize (tangent4.xyz); +#endif +#else + vec3 position = attr_Position; + vec3 normal = attr_Normal; + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 tangent = attr_Tangent.xyz; + #endif +#endif + +#if !defined(USE_SKELETAL_ANIMATION) + normal = normal * 2.0 - vec3(1.0); + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + tangent = tangent * 2.0 - vec3(1.0); + #endif +#endif + +#if defined(USE_TCGEN) + vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); +#else + vec2 texCoords = attr_TexCoord0.st; +#endif + +#if defined(USE_TCMOD) + var_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); +#else + var_TexCoords.xy = texCoords; +#endif + + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + +#if defined(USE_MODELMATRIX) + position = (u_ModelMatrix * vec4(position, 1.0)).xyz; + normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; + #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; + #endif +#endif + +#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); +#endif + +#if defined(USE_LIGHT_VECTOR) + vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); +#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 L = attr_LightDirection * 2.0 - vec3(1.0); + #if defined(USE_MODELMATRIX) + L = (u_ModelMatrix * vec4(L, 0.0)).xyz; + #endif +#endif + +#if defined(USE_LIGHTMAP) + var_TexCoords.zw = GenTexCoords(u_TCGen1, vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); +#endif + + var_Color = u_VertColor * attr_Color + u_BaseColor; + +#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) + float sqrLightDist = dot(L, L); + float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); + float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); + + var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; +#endif + +#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) + var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); + var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; +#endif + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(USE_LIGHT_VECTOR) + var_LightDir = vec4(L, u_LightRadius * u_LightRadius); + #else + var_LightDir = vec4(L, 0.0); + #endif + #if defined(USE_DELUXEMAP) + var_LightDir -= u_EnableTextures.y * var_LightDir; + #endif +#endif + +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + vec3 viewDir = u_ViewOrigin - position; + #if defined(USE_VERT_TANGENT_SPACE) + // store view direction in tangent space to save on outs + var_Normal = vec4(normal, viewDir.x); + var_Tangent = vec4(tangent, viewDir.y); + var_Bitangent = vec4(bitangent, viewDir.z); + #else + var_Normal = normal; + var_ViewDir = viewDir; + #endif +#endif +} + +/*[Fragment]*/ uniform sampler2D u_DiffuseMap; #if defined(USE_LIGHTMAP) diff --git a/codemp/rd-rend2/glsl/lightall_vp.glsl b/codemp/rd-rend2/glsl/lightall_vp.glsl deleted file mode 100644 index b11927bcbc..0000000000 --- a/codemp/rd-rend2/glsl/lightall_vp.glsl +++ /dev/null @@ -1,314 +0,0 @@ -in vec2 attr_TexCoord0; -#if defined(USE_LIGHTMAP) || defined(USE_TCGEN) -in vec2 attr_TexCoord1; -in vec2 attr_TexCoord2; -in vec2 attr_TexCoord3; -in vec2 attr_TexCoord4; -#endif -in vec4 attr_Color; - -in vec3 attr_Position; -in vec3 attr_Normal; -#if defined(USE_VERT_TANGENT_SPACE) -in vec4 attr_Tangent; -#endif - -#if defined(USE_VERTEX_ANIMATION) -in vec3 attr_Position2; -in vec3 attr_Normal2; - #if defined(USE_VERT_TANGENT_SPACE) -in vec4 attr_Tangent2; - #endif -#elif defined(USE_SKELETAL_ANIMATION) -in uvec4 attr_BoneIndexes; -in vec4 attr_BoneWeights; -#endif - -#if defined(USE_LIGHT) && !defined(USE_LIGHT_VECTOR) -in vec3 attr_LightDirection; -#endif - -#if defined(USE_DELUXEMAP) -uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -uniform vec3 u_ViewOrigin; -#endif - -#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) -uniform int u_TCGen0; -uniform vec3 u_TCGen0Vector0; -uniform vec3 u_TCGen0Vector1; -uniform vec3 u_LocalViewOrigin; -uniform int u_TCGen1; -#endif - -#if defined(USE_TCMOD) -uniform vec4 u_DiffuseTexMatrix; -uniform vec4 u_DiffuseTexOffTurb; -#endif - -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_BaseColor; -uniform vec4 u_VertColor; - -#if defined(USE_MODELMATRIX) -uniform mat4 u_ModelMatrix; -#endif - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_SKELETAL_ANIMATION) -uniform mat4x3 u_BoneMatrices[20]; -#endif - -#if defined(USE_LIGHT_VECTOR) -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; - #if defined(USE_FAST_LIGHT) -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; - #endif -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec4 u_PrimaryLightOrigin; -uniform float u_PrimaryLightRadius; -#endif - -out vec4 var_TexCoords; -out vec4 var_Color; -out vec3 var_N; - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - #if defined(USE_VERT_TANGENT_SPACE) -out vec4 var_Normal; -out vec4 var_Tangent; -out vec4 var_Bitangent; - #else -out vec3 var_Normal; -out vec3 var_ViewDir; - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -out vec4 var_LightDir; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -out vec4 var_PrimaryLightDir; -#endif - -#if defined(USE_TCGEN) || defined(USE_LIGHTMAP) -vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) -{ - vec2 tex = attr_TexCoord0; - - switch (TCGen) - { - case TCGEN_LIGHTMAP: - tex = attr_TexCoord1; - break; - - case TCGEN_LIGHTMAP1: - tex = attr_TexCoord2; - break; - - case TCGEN_LIGHTMAP2: - tex = attr_TexCoord3; - break; - - case TCGEN_LIGHTMAP3: - tex = attr_TexCoord4; - break; - - case TCGEN_ENVIRONMENT_MAPPED: - { - vec3 viewer = normalize(u_LocalViewOrigin - position); - vec2 ref = reflect(viewer, normal).yz; - tex.s = ref.x * -0.5 + 0.5; - tex.t = ref.y * 0.5 + 0.5; - } - break; - - case TCGEN_VECTOR: - { - tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); - } - break; - } - - return tex; -} -#endif - -#if defined(USE_TCMOD) -vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) -{ - float amplitude = offTurb.z; - float phase = offTurb.w * 2.0 * M_PI; - vec2 st2; - st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); - st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); - - vec2 offsetPos = vec2(position.x + position.z, position.y); - - vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); - - return st2 + texOffset * amplitude; -} -#endif - - -float CalcLightAttenuation(float point, float normDist) -{ - // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) * point + 1.0; - - // clamp attenuation - #if defined(NO_LIGHT_CLAMP) - attenuation = max(attenuation, 0.0); - #else - attenuation = clamp(attenuation, 0.0, 1.0); - #endif - - return attenuation; -} - - -void main() -{ -#if defined(USE_VERTEX_ANIMATION) - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); - #endif -#elif defined(USE_SKELETAL_ANIMATION) - vec4 position4 = vec4(0.0); - vec4 normal4 = vec4(0.0); - vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec4 tangent4 = vec4(0.0); - vec4 originalTangent = vec4(attr_Tangent.xyz - vec3(0.5), 0.0); -#endif - - for (int i = 0; i < 4; i++) - { - uint boneIndex = attr_BoneIndexes[i]; - - mat4 boneMatrix = mat4( - vec4(u_BoneMatrices[boneIndex][0], 0.0), - vec4(u_BoneMatrices[boneIndex][1], 0.0), - vec4(u_BoneMatrices[boneIndex][2], 0.0), - vec4(u_BoneMatrices[boneIndex][3], 1.0) - ); - - position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; - normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - tangent4 += (boneMatrix * originalTangent) * attr_BoneWeights[i]; -#endif - } - - vec3 position = position4.xyz; - vec3 normal = normalize (normal4.xyz); -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = normalize (tangent4.xyz); -#endif -#else - vec3 position = attr_Position; - vec3 normal = attr_Normal; - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 tangent = attr_Tangent.xyz; - #endif -#endif - -#if !defined(USE_SKELETAL_ANIMATION) - normal = normal * 2.0 - vec3(1.0); - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - tangent = tangent * 2.0 - vec3(1.0); - #endif -#endif - -#if defined(USE_TCGEN) - vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); -#else - vec2 texCoords = attr_TexCoord0.st; -#endif - -#if defined(USE_TCMOD) - var_TexCoords.xy = ModTexCoords(texCoords, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); -#else - var_TexCoords.xy = texCoords; -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - -#if defined(USE_MODELMATRIX) - position = (u_ModelMatrix * vec4(position, 1.0)).xyz; - normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; - #endif -#endif - -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); -#endif - -#if defined(USE_LIGHT_VECTOR) - vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); -#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 L = attr_LightDirection * 2.0 - vec3(1.0); - #if defined(USE_MODELMATRIX) - L = (u_ModelMatrix * vec4(L, 0.0)).xyz; - #endif -#endif - -#if defined(USE_LIGHTMAP) - var_TexCoords.zw = GenTexCoords(u_TCGen1, vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); -#endif - - var_Color = u_VertColor * attr_Color + u_BaseColor; - -#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); - - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) - var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); - var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - #if defined(USE_LIGHT_VECTOR) - var_LightDir = vec4(L, u_LightRadius * u_LightRadius); - #else - var_LightDir = vec4(L, 0.0); - #endif - #if defined(USE_DELUXEMAP) - var_LightDir -= u_EnableTextures.y * var_LightDir; - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - vec3 viewDir = u_ViewOrigin - position; - #if defined(USE_VERT_TANGENT_SPACE) - // store view direction in tangent space to save on outs - var_Normal = vec4(normal, viewDir.x); - var_Tangent = vec4(tangent, viewDir.y); - var_Bitangent = vec4(bitangent, viewDir.z); - #else - var_Normal = normal; - var_ViewDir = viewDir; - #endif -#endif -} diff --git a/codemp/rd-rend2/glsl/pshadow_fp.glsl b/codemp/rd-rend2/glsl/pshadow.glsl similarity index 87% rename from codemp/rd-rend2/glsl/pshadow_fp.glsl rename to codemp/rd-rend2/glsl/pshadow.glsl index f2dd219be8..3238aaa2ee 100644 --- a/codemp/rd-rend2/glsl/pshadow_fp.glsl +++ b/codemp/rd-rend2/glsl/pshadow.glsl @@ -1,3 +1,22 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec3 attr_Normal; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec3 var_Position; +out vec3 var_Normal; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); + + var_Position = attr_Position; + var_Normal = attr_Normal * 2.0 - vec3(1.0); +} + +/*[Fragment]*/ uniform sampler2D u_ShadowMap; uniform vec3 u_LightForward; uniform vec3 u_LightUp; diff --git a/codemp/rd-rend2/glsl/pshadow_vp.glsl b/codemp/rd-rend2/glsl/pshadow_vp.glsl deleted file mode 100644 index a6699c15da..0000000000 --- a/codemp/rd-rend2/glsl/pshadow_vp.glsl +++ /dev/null @@ -1,16 +0,0 @@ -in vec3 attr_Position; -in vec3 attr_Normal; - -uniform mat4 u_ModelViewProjectionMatrix; - -out vec3 var_Position; -out vec3 var_Normal; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - - var_Position = attr_Position; - var_Normal = attr_Normal * 2.0 - vec3(1.0); -} diff --git a/codemp/rd-rend2/glsl/shadowfill_vp.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl similarity index 81% rename from codemp/rd-rend2/glsl/shadowfill_vp.glsl rename to codemp/rd-rend2/glsl/shadowfill.glsl index 746b75e7fe..dd8d425475 100644 --- a/codemp/rd-rend2/glsl/shadowfill_vp.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec3 attr_Normal; in vec4 attr_TexCoord0; @@ -173,3 +174,48 @@ void main() var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz; } + +/*[Fragment]*/ +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; + +in vec3 var_Position; + +out vec4 out_Color; + +void main() +{ +#if defined(USE_DEPTH) + float depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius; + #if 0 + // 32 bit precision + const vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1); + const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); + + vec4 comp; + comp = depth * bitSh; + comp.xyz = fract(comp.xyz); + comp -= comp.xxyz * bitMsk; + out_Color = comp; + #endif + + #if 1 + // 24 bit precision + const vec3 bitSh = vec3( 256 * 256, 256, 1); + const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); + + vec3 comp; + comp = depth * bitSh; + comp.xy = fract(comp.xy); + comp -= comp.xxy * bitMsk; + out_Color = vec4(comp, 1.0); + #endif + + #if 0 + // 8 bit precision + out_Color = vec4(depth, depth, depth, 1); + #endif +#else + out_Color = vec4(0, 0, 0, 1); +#endif +} diff --git a/codemp/rd-rend2/glsl/shadowfill_fp.glsl b/codemp/rd-rend2/glsl/shadowfill_fp.glsl deleted file mode 100644 index 97ae43fce7..0000000000 --- a/codemp/rd-rend2/glsl/shadowfill_fp.glsl +++ /dev/null @@ -1,43 +0,0 @@ -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; - -in vec3 var_Position; - -out vec4 out_Color; - -void main() -{ -#if defined(USE_DEPTH) - float depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius; - #if 0 - // 32 bit precision - const vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1); - const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - - vec4 comp; - comp = depth * bitSh; - comp.xyz = fract(comp.xyz); - comp -= comp.xxyz * bitMsk; - out_Color = comp; - #endif - - #if 1 - // 24 bit precision - const vec3 bitSh = vec3( 256 * 256, 256, 1); - const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); - - vec3 comp; - comp = depth * bitSh; - comp.xy = fract(comp.xy); - comp -= comp.xxy * bitMsk; - out_Color = vec4(comp, 1.0); - #endif - - #if 0 - // 8 bit precision - out_Color = vec4(depth, depth, depth, 1); - #endif -#else - out_Color = vec4(0, 0, 0, 1); -#endif -} diff --git a/codemp/rd-rend2/glsl/shadowmask_fp.glsl b/codemp/rd-rend2/glsl/shadowmask.glsl similarity index 89% rename from codemp/rd-rend2/glsl/shadowmask_fp.glsl rename to codemp/rd-rend2/glsl/shadowmask.glsl index 17f13b96db..d05938b24f 100644 --- a/codemp/rd-rend2/glsl/shadowmask_fp.glsl +++ b/codemp/rd-rend2/glsl/shadowmask.glsl @@ -1,3 +1,24 @@ +/*[Vertex]*/ +in vec4 attr_Position; +in vec4 attr_TexCoord0; + +uniform vec3 u_ViewForward; +uniform vec3 u_ViewLeft; +uniform vec3 u_ViewUp; +uniform vec4 u_ViewInfo; // zfar / znear + +out vec2 var_DepthTex; +out vec3 var_ViewDir; + +void main() +{ + gl_Position = attr_Position; + vec2 screenCoords = gl_Position.xy / gl_Position.w; + var_DepthTex = attr_TexCoord0.xy; + var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; +} + +/*[Fragment]*/ uniform sampler2D u_ScreenDepthMap; uniform sampler2D u_ShadowMap; diff --git a/codemp/rd-rend2/glsl/shadowmask_vp.glsl b/codemp/rd-rend2/glsl/shadowmask_vp.glsl deleted file mode 100644 index 5dc7c929d9..0000000000 --- a/codemp/rd-rend2/glsl/shadowmask_vp.glsl +++ /dev/null @@ -1,18 +0,0 @@ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - -uniform vec3 u_ViewForward; -uniform vec3 u_ViewLeft; -uniform vec3 u_ViewUp; -uniform vec4 u_ViewInfo; // zfar / znear - -out vec2 var_DepthTex; -out vec3 var_ViewDir; - -void main() -{ - gl_Position = attr_Position; - vec2 screenCoords = gl_Position.xy / gl_Position.w; - var_DepthTex = attr_TexCoord0.xy; - var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; -} diff --git a/codemp/rd-rend2/glsl/ssao_fp.glsl b/codemp/rd-rend2/glsl/ssao.glsl similarity index 89% rename from codemp/rd-rend2/glsl/ssao_fp.glsl rename to codemp/rd-rend2/glsl/ssao.glsl index 679fbc4d7a..0c2923baef 100644 --- a/codemp/rd-rend2/glsl/ssao_fp.glsl +++ b/codemp/rd-rend2/glsl/ssao.glsl @@ -1,3 +1,18 @@ +/*[Vertex]*/ +in vec4 attr_Position; +in vec4 attr_TexCoord0; + +out vec2 var_ScreenTex; + +void main() +{ + gl_Position = attr_Position; + var_ScreenTex = attr_TexCoord0.xy; + //vec2 screenCoords = gl_Position.xy / gl_Position.w; + //var_ScreenTex = screenCoords * 0.5 + 0.5; +} + +/*[Fragment]*/ uniform sampler2D u_ScreenDepthMap; uniform vec4 u_ViewInfo; // zfar / znear, zfar diff --git a/codemp/rd-rend2/glsl/ssao_vp.glsl b/codemp/rd-rend2/glsl/ssao_vp.glsl deleted file mode 100644 index 22c12b3e9b..0000000000 --- a/codemp/rd-rend2/glsl/ssao_vp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - -out vec2 var_ScreenTex; - -void main() -{ - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; -} diff --git a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl similarity index 70% rename from codemp/rd-rend2/glsl/surface_sprites_vp.glsl rename to codemp/rd-rend2/glsl/surface_sprites.glsl index c1241e476c..68bc2e95c2 100644 --- a/codemp/rd-rend2/glsl/surface_sprites_vp.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec3 attr_Normal; @@ -67,3 +68,41 @@ void main() var_TexCoords = texcoords[gl_VertexID]; var_Alpha = 1.0 - fadeScale; } + +/*[Fragment]*/ +uniform sampler2D u_DiffuseMap; + +in vec2 var_TexCoords; +in float var_Alpha; + +#if defined(ALPHA_TEST) +uniform float u_AlphaTestValue; +#endif + +layout(std140) uniform SurfaceSprite +{ + float u_Width; + float u_Height; + float u_FadeStartDistance; + float u_FadeEndDistance; + float u_FadeScale; + float u_WidthVariance; + float u_HeightVariance; +}; + +out vec4 out_Color; +out vec4 out_Glow; + +void main() +{ + const float alphaTestValue = 0.5; + out_Color = texture(u_DiffuseMap, var_TexCoords); + out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; + +#if defined(ALPHA_TEST) + if ( out_Color.a < alphaTestValue ) + discard; +#endif + + out_Glow = vec4(0.0); +} diff --git a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl b/codemp/rd-rend2/glsl/surface_sprites_fp.glsl deleted file mode 100644 index 560f5417c6..0000000000 --- a/codemp/rd-rend2/glsl/surface_sprites_fp.glsl +++ /dev/null @@ -1,36 +0,0 @@ -uniform sampler2D u_DiffuseMap; - -in vec2 var_TexCoords; -in float var_Alpha; - -#if defined(ALPHA_TEST) -uniform float u_AlphaTestValue; -#endif - -layout(std140) uniform SurfaceSprite -{ - float u_Width; - float u_Height; - float u_FadeStartDistance; - float u_FadeEndDistance; - float u_FadeScale; - float u_WidthVariance; - float u_HeightVariance; -}; - -out vec4 out_Color; -out vec4 out_Glow; - -void main() -{ - const float alphaTestValue = 0.5; - out_Color = texture(u_DiffuseMap, var_TexCoords); - out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; - -#if defined(ALPHA_TEST) - if ( out_Color.a < alphaTestValue ) - discard; -#endif - - out_Glow = vec4(0.0); -} diff --git a/codemp/rd-rend2/glsl/texturecolor_vp.glsl b/codemp/rd-rend2/glsl/texturecolor.glsl similarity index 53% rename from codemp/rd-rend2/glsl/texturecolor_vp.glsl rename to codemp/rd-rend2/glsl/texturecolor.glsl index e1f2061cc0..751a62e0e0 100644 --- a/codemp/rd-rend2/glsl/texturecolor_vp.glsl +++ b/codemp/rd-rend2/glsl/texturecolor.glsl @@ -1,3 +1,4 @@ +/*[Vertex]*/ in vec3 attr_Position; in vec4 attr_TexCoord0; @@ -11,3 +12,17 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); var_Tex1 = attr_TexCoord0.st; } + +/*[Fragment]*/ +uniform sampler2D u_DiffuseMap; +uniform vec4 u_Color; + +in vec2 var_Tex1; + +out vec4 out_Color; + + +void main() +{ + out_Color = texture(u_DiffuseMap, var_Tex1) * u_Color; +} diff --git a/codemp/rd-rend2/glsl/texturecolor_fp.glsl b/codemp/rd-rend2/glsl/texturecolor_fp.glsl deleted file mode 100644 index 29bb5c3c4f..0000000000 --- a/codemp/rd-rend2/glsl/texturecolor_fp.glsl +++ /dev/null @@ -1,12 +0,0 @@ -uniform sampler2D u_DiffuseMap; -uniform vec4 u_Color; - -in vec2 var_Tex1; - -out vec4 out_Color; - - -void main() -{ - out_Color = texture(u_DiffuseMap, var_Tex1) * u_Color; -} diff --git a/codemp/rd-rend2/glsl/tonemap_fp.glsl b/codemp/rd-rend2/glsl/tonemap.glsl similarity index 84% rename from codemp/rd-rend2/glsl/tonemap_fp.glsl rename to codemp/rd-rend2/glsl/tonemap.glsl index 1d84c1866d..7c62fbb40a 100644 --- a/codemp/rd-rend2/glsl/tonemap_fp.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -1,3 +1,19 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec4 attr_TexCoord0; + +uniform mat4 u_ModelViewProjectionMatrix; + +out vec2 var_TexCoords; + + +void main() +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); + var_TexCoords = attr_TexCoord0.st; +} + +/*[Fragment]*/ uniform sampler2D u_TextureMap; uniform sampler2D u_LevelsMap; uniform vec4 u_Color; diff --git a/codemp/rd-rend2/glsl/tonemap_vp.glsl b/codemp/rd-rend2/glsl/tonemap_vp.glsl deleted file mode 100644 index 984c70f104..0000000000 --- a/codemp/rd-rend2/glsl/tonemap_vp.glsl +++ /dev/null @@ -1,13 +0,0 @@ -in vec3 attr_Position; -in vec4 attr_TexCoord0; - -uniform mat4 u_ModelViewProjectionMatrix; - -out vec2 var_TexCoords; - - -void main() -{ - gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0); - var_TexCoords = attr_TexCoord0.st; -} diff --git a/codemp/rd-rend2/tr_allocator.cpp b/codemp/rd-rend2/tr_allocator.cpp new file mode 100644 index 0000000000..9214629518 --- /dev/null +++ b/codemp/rd-rend2/tr_allocator.cpp @@ -0,0 +1,53 @@ +#include +#include "tr_allocator.h" +#include "tr_local.h" + +Allocator::Allocator( size_t memorySize ) +#if defined(GLSL_BUILDTOOL) + : memoryBase(malloc(memorySize)) +#else + : memoryBase(Z_Malloc(memorySize, TAG_SHADERTEXT)) +#endif + , mark(memoryBase) + , end((char *)memoryBase + memorySize) +{ +} + +Allocator::~Allocator() +{ +#if defined(GLSL_BUILDTOOL) + free(memoryBase); +#else + Z_Free(memoryBase); +#endif +} + +void *Allocator::Alloc( size_t allocSize ) +{ + if ( (size_t)((char *)end - (char *)mark) < allocSize ) + { + return nullptr; + } + + void *result = mark; + size_t alignedSize = (allocSize + 15) & ~15; + + mark = (char *)mark + alignedSize; + + return result; +} + +void *Allocator::Mark() const +{ + return mark; +} + +void Allocator::Reset() +{ + mark = memoryBase; +} + +void Allocator::ResetTo( void *m ) +{ + mark = m; +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_allocator.h b/codemp/rd-rend2/tr_allocator.h new file mode 100644 index 0000000000..53efd586bf --- /dev/null +++ b/codemp/rd-rend2/tr_allocator.h @@ -0,0 +1,58 @@ +/* +=========================================================================== +Copyright (C) 2013 - 2016, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#pragma once + +class Allocator +{ +public: + Allocator( size_t memorySize ); + ~Allocator(); + + Allocator( const Allocator& ) = delete; + Allocator& operator=( const Allocator& ) = delete; + + void *Alloc( size_t allocSize ); + void *Mark() const; + void Reset(); + void ResetTo( void *mark ); + +private: + void *memoryBase; + void *mark; + void *end; +}; + +template +T *ojkAllocArray( Allocator& allocator, size_t count ) +{ + return static_cast(allocator.Alloc(sizeof(T) * count)); +} + +inline char *ojkAllocString( Allocator& allocator, size_t stringLength ) +{ + return ojkAllocArray(allocator, stringLength + 1); +} + +template +T *ojkAlloc( Allocator& allocator ) +{ + return ojkAllocArray(allocator, 1); +} diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 308f7e1d18..03a7ff7204 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -21,45 +21,29 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_glsl.c #include "tr_local.h" +#include "tr_allocator.h" void GLSL_BindNullProgram(void); -extern const char *fallbackShader_bokeh_vp; -extern const char *fallbackShader_bokeh_fp; -extern const char *fallbackShader_calclevels4x_vp; -extern const char *fallbackShader_calclevels4x_fp; -extern const char *fallbackShader_depthblur_vp; -extern const char *fallbackShader_depthblur_fp; -extern const char *fallbackShader_dlight_vp; -extern const char *fallbackShader_dlight_fp; -extern const char *fallbackShader_down4x_vp; -extern const char *fallbackShader_down4x_fp; -extern const char *fallbackShader_fogpass_vp; -extern const char *fallbackShader_fogpass_fp; -extern const char *fallbackShader_generic_vp; -extern const char *fallbackShader_generic_fp; -extern const char *fallbackShader_lightall_vp; -extern const char *fallbackShader_lightall_fp; -extern const char *fallbackShader_pshadow_vp; -extern const char *fallbackShader_pshadow_fp; -extern const char *fallbackShader_shadowfill_vp; -extern const char *fallbackShader_shadowfill_fp; -extern const char *fallbackShader_shadowmask_vp; -extern const char *fallbackShader_shadowmask_fp; -extern const char *fallbackShader_ssao_vp; -extern const char *fallbackShader_ssao_fp; -extern const char *fallbackShader_texturecolor_vp; -extern const char *fallbackShader_texturecolor_fp; -extern const char *fallbackShader_tonemap_vp; -extern const char *fallbackShader_tonemap_fp; -extern const char *fallbackShader_gaussian_blur_vp; -extern const char *fallbackShader_gaussian_blur_fp; -extern const char *fallbackShader_dglow_downsample_vp; -extern const char *fallbackShader_dglow_downsample_fp; -extern const char *fallbackShader_dglow_upsample_vp; -extern const char *fallbackShader_dglow_upsample_fp; -extern const char *fallbackShader_surface_sprites_vp; -extern const char *fallbackShader_surface_sprites_fp; +extern const GPUProgramDesc fallback_bokehProgram; +extern const GPUProgramDesc fallback_calclevels4xProgram; +extern const GPUProgramDesc fallback_depthblurProgram; +extern const GPUProgramDesc fallback_dlightProgram; +extern const GPUProgramDesc fallback_down4xProgram; +extern const GPUProgramDesc fallback_fogpassProgram; +extern const GPUProgramDesc fallback_gaussian_blurProgram; +extern const GPUProgramDesc fallback_genericProgram; +extern const GPUProgramDesc fallback_lightallProgram; +extern const GPUProgramDesc fallback_pshadowProgram; +extern const GPUProgramDesc fallback_shadowfillProgram; +extern const GPUProgramDesc fallback_shadowmaskProgram; +extern const GPUProgramDesc fallback_ssaoProgram; +extern const GPUProgramDesc fallback_texturecolorProgram; +extern const GPUProgramDesc fallback_tonemapProgram; +extern const GPUProgramDesc fallback_dglow_downsampleProgram; +extern const GPUProgramDesc fallback_dglow_upsampleProgram; +extern const GPUProgramDesc fallback_surface_spritesProgram; + const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { { 10, "SurfaceSprite", sizeof(SurfaceSpriteBlock) } @@ -271,7 +255,7 @@ static void GLSL_PrintShaderSource(GLuint shader) Z_Free(msg); } -static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, int size ) +static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, size_t size ) { float fbufWidthScale, fbufHeightScale; @@ -279,18 +263,10 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha Q_strcat(dest, size, "#version 150 core\n"); - // HACK: add some macros to avoid extra uniforms and save speed and code maintenance - //Q_strcat(dest, size, - // va("#ifndef r_SpecularExponent\n#define r_SpecularExponent %f\n#endif\n", r_specularExponent->value)); - //Q_strcat(dest, size, - // va("#ifndef r_SpecularScale\n#define r_SpecularScale %f\n#endif\n", r_specularScale->value)); - //Q_strcat(dest, size, - // va("#ifndef r_NormalScale\n#define r_NormalScale %f\n#endif\n", r_normalScale->value)); - - - Q_strcat(dest, size, "#ifndef M_PI\n#define M_PI 3.14159265358979323846\n#endif\n"); - - //Q_strcat(dest, size, va("#ifndef MAX_SHADOWMAPS\n#define MAX_SHADOWMAPS %i\n#endif\n", MAX_SHADOWMAPS)); + Q_strcat(dest, size, + "#ifndef M_PI\n" + "#define M_PI 3.14159265358979323846\n" + "#endif\n"); Q_strcat(dest, size, va("#ifndef deformGen_t\n" @@ -350,37 +326,41 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha CGEN_LIGHTING_DIFFUSE)); Q_strcat(dest, size, - va("#ifndef alphaGen_t\n" - "#define alphaGen_t\n" - "#define AGEN_LIGHTING_SPECULAR %i\n" - "#define AGEN_PORTAL %i\n" - "#endif\n", - AGEN_LIGHTING_SPECULAR, - AGEN_PORTAL)); + va("#ifndef alphaGen_t\n" + "#define alphaGen_t\n" + "#define AGEN_LIGHTING_SPECULAR %i\n" + "#define AGEN_PORTAL %i\n" + "#endif\n", + AGEN_LIGHTING_SPECULAR, + AGEN_PORTAL)); Q_strcat(dest, size, - va("#ifndef texenv_t\n" - "#define texenv_t\n" - "#define TEXENV_MODULATE %i\n" - "#define TEXENV_ADD %i\n" - "#define TEXENV_REPLACE %i\n" - "#endif\n", - 0x2100/* GL_MODULATE */, - 0x0104/* GL_ADD */, - GL_REPLACE)); + va("#ifndef texenv_t\n" + "#define texenv_t\n" + "#define TEXENV_MODULATE %i\n" + "#define TEXENV_ADD %i\n" + "#define TEXENV_REPLACE %i\n" + "#endif\n", + 0x2100/* GL_MODULATE */, + 0x0104/* GL_ADD */, + GL_REPLACE)); Q_strcat(dest, size, - va("#define ATEST_CMP_LT %d\n" - "#define ATEST_CMP_GT %d\n" - "#define ATEST_CMP_GE %d\n", - ATEST_CMP_LT, - ATEST_CMP_GT, - ATEST_CMP_GE)); + va("#define ATEST_CMP_LT %d\n" + "#define ATEST_CMP_GT %d\n" + "#define ATEST_CMP_GE %d\n", + ATEST_CMP_LT, + ATEST_CMP_GT, + ATEST_CMP_GE)); fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); Q_strcat(dest, size, - va("#ifndef r_FBufScale\n#define r_FBufScale vec2(%f, %f)\n#endif\n", fbufWidthScale, fbufHeightScale)); + va("#ifndef r_FBufScale\n" + "#define r_FBufScale vec2(%f, %f)\n" + "#endif\n", + fbufWidthScale, + fbufHeightScale)); if (extra) { @@ -1013,6 +993,20 @@ static bool GLSL_IsValidPermutationForLight (int lightType, int shaderCaps) return true; } +Block *FindBlock( const char *name, Block *blocks, size_t numBlocks ) +{ + for ( size_t i = 0; i < numBlocks; ++i ) + { + Block *block = blocks + i; + if ( Q_stricmpn(block->blockHeaderTitle, name, block->blockHeaderTitleLength) == 0 ) + { + return block; + } + } + + return nullptr; +} + void GLSL_InitSplashScreenShader() { const char *vs = @@ -1052,6 +1046,30 @@ void GLSL_InitSplashScreenShader() Q_strncpyz(tr.splashScreenShader.name, "splash", splashLen + 1); } +static const GPUProgramDesc *LoadProgramSource( + const char *programName, Allocator& allocator, const GPUProgramDesc& fallback ) +{ + const GPUProgramDesc *result = &fallback; + + if ( r_externalGLSL->integer ) + { + char *buffer; + char programPath[MAX_QPATH]; + Com_sprintf(programPath, sizeof(programPath), "glsl/%s.glsl", programName); + + long size = ri->FS_ReadFile(programPath, (void **)&buffer); + if ( size ) + { + GPUProgramDesc *externalProgramDesc = ojkAlloc(allocator); + *externalProgramDesc = ParseProgramSource(allocator, buffer); + result = externalProgramDesc; + ri->FS_FreeFile(buffer); + } + } + + return result; +} + int GLSL_BeginLoadGPUShaders(void) { int startTime; @@ -1104,7 +1122,7 @@ int GLSL_BeginLoadGPUShaders(void) { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal - { 3, false, GL_FLOAT, false, 24 }, // pos2 + { 3, false,p GL_FLOAT, false, 24 }, // pos2 { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // tangent { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 40 }, // normal } @@ -1117,6 +1135,11 @@ int GLSL_BeginLoadGPUShaders(void) startTime = ri->Milliseconds(); + Allocator allocator(512 * 1024); + const GPUProgramDesc *programDesc; + + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("generic", allocator, fallback_genericProgram); for (i = 0; i < GENERICDEF_COUNT; i++) { if (!GLSL_IsValidPermutationForGeneric (i)) @@ -1184,20 +1207,17 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, extradefines, fallbackShader_generic_vp, fallbackShader_generic_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); } } + allocator.Reset(); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - - if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, fallbackShader_texturecolor_vp, fallbackShader_texturecolor_fp)) - { - ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); - } - + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("fogpass", allocator, fallback_fogpassProgram); for (i = 0; i < FOGDEF_COUNT; i++) { if (!GLSL_IsValidPermutationForFog (i)) @@ -1244,13 +1264,17 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, fallbackShader_fogpass_vp, fallbackShader_fogpass_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("dlight", allocator, fallback_dlightProgram); for (i = 0; i < DLIGHTDEF_COUNT; i++) { attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0; @@ -1288,13 +1312,17 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, fallbackShader_dlight_vp, fallbackShader_dlight_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); } } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("lightall", allocator, fallback_lightallProgram); for (i = 0; i < LIGHTDEF_COUNT; i++) { int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; @@ -1444,59 +1472,93 @@ int GLSL_BeginLoadGPUShaders(void) if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); - if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, extradefines, fallbackShader_lightall_vp, fallbackShader_lightall_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); } } + allocator.Reset(); - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("texturecolor", allocator, fallback_texturecolorProgram); + attribs = ATTR_POSITION | ATTR_TEXCOORD0; + + if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, + programDesc->shaders[0].source, programDesc->shaders[1].source)) + { + ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); + } + allocator.Reset(); + + + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("shadowfill", allocator, fallback_shadowfillProgram); + attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, extradefines, fallbackShader_shadowfill_vp, fallbackShader_shadowfill_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, nullptr, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } + allocator.Reset(); + + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("pshadow", allocator, fallback_pshadowProgram); attribs = ATTR_POSITION | ATTR_NORMAL; extradefines[0] = '\0'; Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, fallbackShader_pshadow_vp, fallbackShader_pshadow_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("down4x", allocator, fallback_down4xProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, extradefines, fallbackShader_down4x_vp, fallbackShader_down4x_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, nullptr, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load down4x shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("bokeh", allocator, fallback_bokehProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, extradefines, fallbackShader_bokeh_vp, fallbackShader_bokeh_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, nullptr, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load bokeh shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("tonemap", allocator, fallback_tonemapProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, extradefines, fallbackShader_tonemap_vp, fallbackShader_tonemap_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, nullptr, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load tonemap shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("calclevels4x", allocator, fallback_calclevels4xProgram); for (i = 0; i < 2; i++) { attribs = ATTR_POSITION | ATTR_TEXCOORD0; @@ -1505,13 +1567,17 @@ int GLSL_BeginLoadGPUShaders(void) if (!i) Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); - if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, extradefines, fallbackShader_calclevels4x_vp, fallbackShader_calclevels4x_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); - } + } } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("shadowmask", allocator, fallback_shadowmaskProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; @@ -1526,22 +1592,28 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - - if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, fallbackShader_shadowmask_vp, fallbackShader_shadowmask_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("ssao", allocator, fallback_ssaoProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, extradefines, fallbackShader_ssao_vp, fallbackShader_ssao_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, nullptr, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load ssao shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("depthBlur", allocator, fallback_depthblurProgram); for (i = 0; i < 2; i++) { attribs = ATTR_POSITION | ATTR_TEXCOORD0; @@ -1553,63 +1625,62 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); - if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, extradefines, fallbackShader_depthblur_vp, fallbackShader_depthblur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } } + allocator.Reset(); -#if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - - if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, NULL, NULL)) - { - ri->Error(ERR_FATAL, "Could not load testcube shader!"); - } - - GLSL_InitUniforms(&tr.testcubeShader); - - qglUseProgram(tr.testcubeShader.program); - GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.testcubeShader); - - numEtcShaders++; -#endif + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("gaussian_blur", allocator, fallback_gaussian_blurProgram); attribs = 0; extradefines[0] = '\0'; Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, extradefines, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } attribs = 0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, extradefines, fallbackShader_gaussian_blur_vp, fallbackShader_gaussian_blur_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, + nullptr, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } + allocator.Reset(); + + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("dglow_downsample", allocator, fallback_dglow_downsampleProgram); attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, qtrue, extradefines, fallbackShader_dglow_downsample_vp, fallbackShader_dglow_downsample_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); } + allocator.Reset(); + + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("dglow_upsample", allocator, fallback_dglow_upsampleProgram); attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, extradefines, fallbackShader_dglow_upsample_vp, fallbackShader_dglow_upsample_fp)) + if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, extradefines, + programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); } + allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("surface_sprites", allocator, fallback_surface_spritesProgram); attribs = ATTR_POSITION | ATTR_NORMAL; for ( int i = 0; i < SSDEF_COUNT; ++i ) { @@ -1629,14 +1700,14 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define ALPHA_TEST\n"); - if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", - attribs, qtrue, extradefines, - fallbackShader_surface_sprites_vp, - fallbackShader_surface_sprites_fp)) + if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", attribs, qtrue, + extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) { ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); } } + allocator.Reset(); + return startTime; } diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp new file mode 100644 index 0000000000..cd09a3d1b9 --- /dev/null +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -0,0 +1,137 @@ +/* +=========================================================================== +Copyright (C) 2013 - 2016, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#include "tr_local.h" +#include "tr_allocator.h" +#if defined(GLSL_BUILDTOOL) +#include +#endif + +namespace +{ + +Block *FindBlock( const char *name, Block *blocks, size_t numBlocks ) +{ + for ( size_t i = 0; i < numBlocks; ++i ) + { + Block *block = blocks + i; + if ( strncmp(block->blockHeaderTitle, name, block->blockHeaderTitleLength) == 0 ) + { + return block; + } + } + + return nullptr; +} + +} + +GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) +{ + int numBlocks = 0; + Block blocks[MAX_BLOCKS]; + Block *prevBlock = nullptr; + + int i = 0; + while ( text[i] ) + { + int markerStart = i; + int markerEnd = -1; + + if ( strncmp(text + i, "/*[", 3) == 0 ) + { + int startHeaderTitle = i + 3; + int endHeaderTitle = -1; + int endHeaderText = -1; + int j = startHeaderTitle; + while ( text[j] ) + { + if ( text[j] == ']' ) + { + endHeaderTitle = j; + } + else if ( strncmp(text + j, "*/\n", 3) == 0 ) + { + endHeaderText = j; + break; + } + + ++j; + } + + if ( endHeaderTitle == -1 || endHeaderText == -1 ) + { +#if defined(GLSL_BUILDTOOL) + std::cerr << "Unclosed block marker\n"; +#else + Com_Printf(S_COLOR_YELLOW "Unclosed block marker\n"); +#endif + break; + } + + Block *block = blocks + numBlocks++; + block->blockHeaderTitle = text + startHeaderTitle; + block->blockHeaderTitleLength = endHeaderTitle - startHeaderTitle; + block->blockHeaderText = text + endHeaderTitle + 1; + block->blockHeaderTextLength = endHeaderText - endHeaderTitle - 1; + block->blockText = text + endHeaderText + 3; + block->blockTextLength = 0; + + if ( prevBlock ) + { + prevBlock->blockTextLength = (text + i) - prevBlock->blockText; + } + prevBlock = block; + + i = endHeaderText + 3; + continue; + } + + ++i; + } + + if ( prevBlock ) + { + prevBlock->blockTextLength = (text + i) - prevBlock->blockText; + } + + GPUProgramDesc theProgram = {}; + theProgram.numShaders = 2; + + Block *vertexBlock = FindBlock("Vertex", blocks, numBlocks); + Block *fragmentBlock = FindBlock("Fragment", blocks, numBlocks); + + theProgram.shaders = ojkAllocArray(allocator, theProgram.numShaders); + + char *vertexSource = ojkAllocString(allocator, vertexBlock->blockTextLength); + char *fragmentSource = ojkAllocString(allocator, fragmentBlock->blockTextLength); + + strncpy_s(vertexSource, vertexBlock->blockTextLength + 1, + vertexBlock->blockText, vertexBlock->blockTextLength); + strncpy_s(fragmentSource, fragmentBlock->blockTextLength + 1, + fragmentBlock->blockText, fragmentBlock->blockTextLength); + + theProgram.shaders[0].type = GPUSHADER_VERTEX; + theProgram.shaders[0].source = vertexSource; + theProgram.shaders[1].type = GPUSHADER_FRAGMENT; + theProgram.shaders[1].source = fragmentSource; + + return theProgram; +} diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index eedafb46b2..5c61618e89 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -24,11 +24,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #ifndef TR_LOCAL_H #define TR_LOCAL_H -#include "../qcommon/q_shared.h" -#include "../qcommon/qfiles.h" -#include "../qcommon/qcommon.h" -#include "../rd-common/tr_public.h" -#include "../rd-common/tr_common.h" +#include "qcommon/q_shared.h" +#include "qcommon/qfiles.h" +#include "qcommon/qcommon.h" +#include "rd-common/tr_public.h" +#include "rd-common/tr_common.h" #include "tr_extratypes.h" #include "tr_extramath.h" #include "tr_fbo.h" @@ -1117,6 +1117,38 @@ struct uniformBlockInfo_t }; extern const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT]; +#define MAX_BLOCKS (32) +#define MAX_BLOCK_NAME_LEN (32) +struct Block +{ + const char *blockText; + size_t blockTextLength; + + const char *blockHeaderTitle; + size_t blockHeaderTitleLength; + + const char *blockHeaderText; + size_t blockHeaderTextLength; +}; + +enum GPUShaderType +{ + GPUSHADER_VERTEX, + GPUSHADER_FRAGMENT +}; + +struct GPUShaderDesc +{ + GPUShaderType type; + const char *source; +}; + +struct GPUProgramDesc +{ + size_t numShaders; + GPUShaderDesc *shaders; +}; + typedef enum { UNIFORM_DIFFUSEMAP = 0, @@ -3307,4 +3339,7 @@ void R_ImageLoader_Init(void); void RB_SurfaceGhoul( CRenderableSurface *surf ); +class Allocator; +GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ); + #endif //TR_LOCAL_H From b2096dabff61bcf20ecd704b53e310e70f27e570 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 20 Mar 2016 18:27:04 +0000 Subject: [PATCH 349/708] Rend2: Fix surface sprites. Breakage caused by bad merge --- codemp/rd-rend2/tr_surface.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b7dee960a7..eedd6ab728 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2106,10 +2106,6 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) glState.vertexAnimation = qfalse; } -static void RB_SurfaceSprites( void *surfaceSprites ) -{ -} - static void RB_SurfaceSkip( void *surf ) { } From ed1e243f1be916fbc6f76408bf0dcc0af073d247 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 20 Mar 2016 21:19:53 +0000 Subject: [PATCH 350/708] Rend2: Remove unnecessary condition --- codemp/rd-rend2/tr_world.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 41b977e7e5..7871c97407 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -346,15 +346,12 @@ static void R_AddWorldSurface( msurface_t *surf, int entityNum, int dlightBits, R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, isPostRenderEntity, surf->cubemapIndex ); - if ( surf->numSurfaceSprites ) + for ( int i = 0, numSprites = surf->numSurfaceSprites; + i < numSprites; ++i ) { - for ( int i = 0, numSprites = surf->numSurfaceSprites; - i < numSprites; ++i ) - { - srfSprites_t *sprites = surf->surfaceSprites + i; - R_AddDrawSurf((surfaceType_t *)sprites, entityNum, sprites->shader, - surf->fogIndex, dlightBits, isPostRenderEntity, 0); - } + srfSprites_t *sprites = surf->surfaceSprites + i; + R_AddDrawSurf((surfaceType_t *)sprites, entityNum, sprites->shader, + surf->fogIndex, dlightBits, isPostRenderEntity, 0); } } From cb1476d38a2c6a296b53147c969c0da12344ccaa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 25 Mar 2016 11:57:32 +0000 Subject: [PATCH 351/708] Rend2: Remove USE_VERT_TANGENT_SPACE and refactor Refactored the lightall shader a bit to make it a bit more readable. Also renamed some defines, and corrected some vectors which needed normalizing. --- codemp/rd-rend2/glsl/lightall.glsl | 265 ++++++++++------------------- codemp/rd-rend2/tr_glsl.cpp | 15 +- 2 files changed, 92 insertions(+), 188 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 7a052e2295..dea6557350 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -1,4 +1,7 @@ /*[Vertex]*/ +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#define PER_PIXEL_LIGHTING +#endif in vec2 attr_TexCoord0; #if defined(USE_LIGHTMAP) || defined(USE_TCGEN) in vec2 attr_TexCoord1; @@ -10,16 +13,12 @@ in vec4 attr_Color; in vec3 attr_Position; in vec3 attr_Normal; -#if defined(USE_VERT_TANGENT_SPACE) in vec4 attr_Tangent; -#endif #if defined(USE_VERTEX_ANIMATION) in vec3 attr_Position2; in vec3 attr_Normal2; - #if defined(USE_VERT_TANGENT_SPACE) in vec4 attr_Tangent2; - #endif #elif defined(USE_SKELETAL_ANIMATION) in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; @@ -33,7 +32,7 @@ in vec3 attr_LightDirection; uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) uniform vec3 u_ViewOrigin; #endif @@ -82,18 +81,13 @@ out vec4 var_TexCoords; out vec4 var_Color; out vec3 var_N; -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - #if defined(USE_VERT_TANGENT_SPACE) +#if defined(PER_PIXEL_LIGHTING) out vec4 var_Normal; out vec4 var_Tangent; out vec4 var_Bitangent; - #else -out vec3 var_Normal; -out vec3 var_ViewDir; - #endif #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) out vec4 var_LightDir; #endif @@ -184,15 +178,13 @@ void main() #if defined(USE_VERTEX_ANIMATION) vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); - #endif #elif defined(USE_SKELETAL_ANIMATION) vec4 position4 = vec4(0.0); vec4 normal4 = vec4(0.0); vec4 originalPosition = vec4(attr_Position, 1.0); vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) vec4 tangent4 = vec4(0.0); vec4 originalTangent = vec4(attr_Tangent.xyz - vec3(0.5), 0.0); #endif @@ -210,27 +202,27 @@ void main() position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) tangent4 += (boneMatrix * originalTangent) * attr_BoneWeights[i]; #endif } vec3 position = position4.xyz; vec3 normal = normalize (normal4.xyz); -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) vec3 tangent = normalize (tangent4.xyz); #endif #else vec3 position = attr_Position; vec3 normal = attr_Normal; - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(PER_PIXEL_LIGHTING) vec3 tangent = attr_Tangent.xyz; #endif #endif #if !defined(USE_SKELETAL_ANIMATION) normal = normal * 2.0 - vec3(1.0); - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(PER_PIXEL_LIGHTING) tangent = tangent * 2.0 - vec3(1.0); #endif #endif @@ -252,18 +244,18 @@ void main() #if defined(USE_MODELMATRIX) position = (u_ModelMatrix * vec4(position, 1.0)).xyz; normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; - #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) + #if defined(PER_PIXEL_LIGHTING) tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; #endif #endif -#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); #endif #if defined(USE_LIGHT_VECTOR) vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); -#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#elif defined(PER_PIXEL_LIGHTING) vec3 L = attr_LightDirection * 2.0 - vec3(1.0); #if defined(USE_MODELMATRIX) L = (u_ModelMatrix * vec4(L, 0.0)).xyz; @@ -289,7 +281,7 @@ void main() var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) #if defined(USE_LIGHT_VECTOR) var_LightDir = vec4(L, u_LightRadius * u_LightRadius); #else @@ -300,21 +292,21 @@ void main() #endif #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) vec3 viewDir = u_ViewOrigin - position; - #if defined(USE_VERT_TANGENT_SPACE) + // store view direction in tangent space to save on outs var_Normal = vec4(normal, viewDir.x); var_Tangent = vec4(tangent, viewDir.y); var_Bitangent = vec4(bitangent, viewDir.z); - #else - var_Normal = normal; - var_ViewDir = viewDir; - #endif #endif } /*[Fragment]*/ +#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) +#define PER_PIXEL_LIGHTING +#endif + uniform sampler2D u_DiffuseMap; #if defined(USE_LIGHTMAP) @@ -346,7 +338,7 @@ uniform samplerCube u_CubeMap; uniform vec4 u_EnableTextures; #endif -#if defined(USE_LIGHT_VECTOR) && !defined(USE_FAST_LIGHT) +#if defined(USE_LIGHT_VECTOR) && !defined(USE_VERTEX_LIGHTING) uniform vec3 u_DirectedLight; uniform vec3 u_AmbientLight; #endif @@ -356,16 +348,14 @@ uniform vec3 u_PrimaryLightColor; uniform vec3 u_PrimaryLightAmbient; #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) uniform vec4 u_NormalScale; uniform vec4 u_SpecularScale; #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) -#if defined(USE_CUBEMAP) +#if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) uniform vec4 u_CubeMapInfo; #endif -#endif #if defined(USE_ATEST) uniform float u_AlphaTestValue; @@ -375,18 +365,10 @@ uniform float u_AlphaTestValue; in vec4 var_TexCoords; in vec4 var_Color; -#if (defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)) - #if defined(USE_VERT_TANGENT_SPACE) +#if defined(PER_PIXEL_LIGHTING) in vec4 var_Normal; in vec4 var_Tangent; in vec4 var_Bitangent; - #else -in vec3 var_Normal; -in vec3 var_ViewDir; - #endif -#endif - -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) in vec4 var_LightDir; #endif @@ -459,40 +441,19 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) float CalcFresnel(float EH) { -#if 1 // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf // not accurate, but fast return exp2(-10.0 * EH); -#elif 0 - // From http://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/ - return exp2((-5.55473 * EH - 6.98316) * EH); -#elif 0 - float blend = 1.0 - EH; - float blend2 = blend * blend; - blend *= blend2 * blend2; - - return blend; -#else - return pow(1.0 - EH, 5.0); -#endif } vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) { - #if 1 // from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf vec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss; t += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 ); float a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z; float a1 = t.w; return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); - #elif 0 - // from http://seblagarde.wordpress.com/2011/08/17/hello-world/ - return specular + CalcFresnel(NE) * clamp(vec3(gloss) - specular, 0.0, 1.0); - #else - // from http://advances.realtimerendering.com/s2011/Lazarov-Physically-Based-Lighting-in-Black-Ops%20%28Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course%29.pptx - return mix(specular.rgb, vec3(1.0), CalcFresnel(NE) / (4.0 - 3.0 * gloss)); - #endif } float CalcGGX(float NH, float gloss) @@ -513,14 +474,12 @@ float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) k *= k * 0.125; float k2 = 1.0 - k; - float invGeo1 = NL * k2 + k; float invGeo2 = NE * k2 + k; return 1.0 / (invGeo1 * invGeo2); } - vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess) { float distrib = CalcGGX(NH, gloss); @@ -532,7 +491,6 @@ vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float g return fSpecular * (distrib * vis); } - float CalcLightAttenuation(float point, float normDist) { // zero light at 1.0, approximating q3 style @@ -549,24 +507,54 @@ float CalcLightAttenuation(float point, float normDist) return attenuation; } -// from http://www.thetenthplanet.de/archives/1180 -mat3 cotangent_frame( vec3 N, vec3 p, vec2 uv ) +vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) { - // get edge vectors of the pixel triangle - vec3 dp1 = dFdx( p ); - vec3 dp2 = dFdy( p ); - vec2 duv1 = dFdx( uv ); - vec2 duv2 = dFdy( uv ); - - // solve the linear system - vec3 dp2perp = cross( dp2, N ); - vec3 dp1perp = cross( N, dp1 ); - vec3 T = dp2perp * duv1.x + dp1perp * duv2.x; - vec3 B = dp2perp * duv1.y + dp1perp * duv2.y; - - // construct a scale-invariant frame - float invmax = inversesqrt( max( dot(T,T), dot(B,B) ) ); - return mat3( T * invmax, B * invmax, N ); +#if defined(USE_PARALLAXMAP) + vec3 offsetDir = normalize(E * tangentToWorld); + offsetDir.xy *= -u_NormalScale.a / offsetDir.z; + + return offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); +#else + return vec2(0.0); +#endif +} + +vec3 CalcIBLContribution( in float gloss, in vec3 N, in vec3 E, in vec3 viewDir, in float NE, in vec3 specular ) +{ +#if defined(USE_CUBEMAP) + vec3 reflectance = EnvironmentBRDF(gloss, NE, specular); + + vec3 R = reflect(E, N); + + // parallax corrected cubemap (cheaper trick) + // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ + vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; + + vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; + + return cubeLightColor * reflectance; +#else + return vec3(0.0); +#endif +} + +vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld ) +{ + vec3 N = vertexNormal; + +#if defined(USE_NORMALMAP) + #if defined(SWIZZLE_NORMALMAP) + N.xy = texture(u_NormalMap, texCoords).ag - vec2(0.5); + #else + N.xy = texture(u_NormalMap, texCoords).rg - vec2(0.5); + #endif + + N.xy *= u_NormalScale.xy; + N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); + N = tangentToWorld * N; +#endif + + return normalize(N); } void main() @@ -575,17 +563,10 @@ void main() vec3 L, N, E, H; float NL, NH, NE, EH, attenuation; -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) - #if defined(USE_VERT_TANGENT_SPACE) +#if defined(PER_PIXEL_LIGHTING) mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); - #else - mat3 tangentToWorld = cotangent_frame(var_Normal, -var_ViewDir, var_TexCoords.xy); - viewDir = var_ViewDir; - #endif - E = normalize(viewDir); - L = var_LightDir.xyz; #if defined(USE_DELUXEMAP) L += (texture(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; @@ -601,13 +582,8 @@ void main() #endif vec2 texCoords = var_TexCoords.xy; - -#if defined(USE_PARALLAXMAP) - vec3 offsetDir = normalize(E * tangentToWorld); - - offsetDir.xy *= -u_NormalScale.a / offsetDir.z; - - texCoords += offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); +#if defined(PER_PIXEL_LIGHTING) + texCoords += GetParallaxOffset(texCoords, E, tangentToWorld); #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); @@ -622,7 +598,7 @@ void main() discard; #endif -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(PER_PIXEL_LIGHTING) #if defined(USE_LIGHTMAP) lightColor = lightmapColor.rgb * var_Color.rgb; ambientColor = vec3 (0.0); @@ -637,20 +613,7 @@ void main() attenuation = 1.0; #endif - #if defined(USE_NORMALMAP) - #if defined(SWIZZLE_NORMALMAP) - N.xy = texture(u_NormalMap, texCoords).ag - vec2(0.5); - #else - N.xy = texture(u_NormalMap, texCoords).rg - vec2(0.5); - #endif - N.xy *= u_NormalScale.xy; - N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); - N = tangentToWorld * N; - #else - N = var_Normal.xyz; - #endif - - N = normalize(N); + N = CalcNormal(var_Normal.xyz, texCoords, tangentToWorld); L /= sqrt(sqrLightDist); #if defined(USE_SHADOWMAP) @@ -658,23 +621,17 @@ void main() float shadowValue = texture(u_ShadowMap, shadowTex).r; // surfaces not facing the light are always shadowed - shadowValue *= float(dot(var_Normal.xyz, var_PrimaryLightDir.xyz) > 0.0); + vec3 primaryLightDir = normalize(var_PrimaryLightDir.xyz); + shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) - //vec3 shadowColor = min(u_PrimaryLightAmbient, lightColor); - vec3 shadowColor = u_PrimaryLightAmbient * lightColor; - - #if 0 - // Only shadow when the world light is parallel to the primary light - shadowValue = 1.0 + (shadowValue - 1.0) * clamp(dot(L, var_PrimaryLightDir.xyz), 0.0, 1.0); - #endif - lightColor = mix(shadowColor, lightColor, shadowValue); + lightColor = mix(u_PrimaryLightAmbient * lightColor, lightColor, shadowValue); #endif #endif #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) ambientColor = lightColor; - float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); + float surfNL = clamp(dot(N, L), 0.0, 1.0); // Scale the incoming light to compensate for the baked-in light angle // attenuation. @@ -690,12 +647,10 @@ void main() NL = clamp(dot(N, L), 0.0, 1.0); NE = clamp(dot(N, E), 0.0, 1.0); - #if defined(USE_SPECULARMAP) - vec4 specular = texture(u_SpecularMap, texCoords); - #else vec4 specular = vec4(1.0); + #if defined(USE_SPECULARMAP) + specular = texture(u_SpecularMap, texCoords); #endif - specular *= u_SpecularScale; float gloss = specular.a; @@ -704,7 +659,6 @@ void main() #if defined(SPECULAR_IS_METALLIC) // diffuse is actually base color, and red of specular is metallicness float metallic = specular.r; - specular.rgb = (0.96 * metallic) * diffuse.rgb + vec3(0.04); diffuse.rgb *= 1.0 - metallic; #else @@ -718,17 +672,13 @@ void main() float adjGloss = gloss; float adjShininess = shininess; - #if !defined(USE_LIGHT_VECTOR) - adjGloss *= r_deluxeSpecular; - adjShininess = exp2(adjGloss * 13.0); - #endif - H = normalize(L + E); - EH = clamp(dot(E, H), 0.0, 1.0); NH = clamp(dot(N, H), 0.0, 1.0); - #if !defined(USE_LIGHT_VECTOR) + #if defined(r_deluxeSpecular) + adjGloss *= r_deluxeSpecular; + adjShininess = exp2(adjGloss * 13.0); reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess) * r_deluxeSpecular; #else reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess); @@ -736,46 +686,14 @@ void main() #endif out_Color.rgb = lightColor * reflectance * (attenuation * NL); - -#if 0 - vec3 aSpecular = EnvironmentBRDF(gloss, NE, specular.rgb); - - // do ambient as two hemisphere lights, one straight up one straight down - float hemiDiffuseUp = N.z * 0.5 + 0.5; - float hemiDiffuseDown = 1.0 - hemiDiffuseUp; - float hemiSpecularUp = mix(hemiDiffuseUp, float(N.z >= 0.0), gloss); - float hemiSpecularDown = 1.0 - hemiSpecularUp; - - out_Color.rgb += ambientColor * 0.75 * (diffuse.rgb * hemiDiffuseUp + aSpecular * hemiSpecularUp); - out_Color.rgb += ambientColor * 0.25 * (diffuse.rgb * hemiDiffuseDown + aSpecular * hemiSpecularDown); -#else out_Color.rgb += ambientColor * (diffuse.rgb + specular.rgb); -#endif - - #if defined(USE_CUBEMAP) - reflectance = EnvironmentBRDF(gloss, NE, specular.rgb); - - vec3 R = reflect(E, N); - - // parallax corrected cubemap (cheaper trick) - // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ - vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - - vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; - - out_Color.rgb += cubeLightColor * reflectance; - #endif + out_Color.rgb += CalcIBLContribution(gloss, N, E, viewDir, NE, specular.rgb); #if defined(USE_PRIMARY_LIGHT) vec3 L2, H2; float NL2, EH2, NH2; - L2 = var_PrimaryLightDir.xyz; - - // enable when point lights are supported as primary lights - //sqrLightDist = dot(L2, L2); - //L2 /= sqrt(sqrLightDist); - + L2 = normalize(var_PrimaryLightDir.xyz); NL2 = clamp(dot(N, L2), 0.0, 1.0); H2 = normalize(L2 + E); @@ -786,17 +704,10 @@ void main() reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss, shininess); lightColor = u_PrimaryLightColor * var_Color.rgb; - - // enable when point lights are supported as primary lights - //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); - #if defined(USE_SHADOWMAP) lightColor *= shadowValue; #endif - // enable when point lights are supported as primary lights - //lightColor *= CalcLightAttenuation(float(u_PrimaryLightDir.w > 0.0), u_PrimaryLightDir.w / sqrLightDist); - out_Color.rgb += lightColor * reflectance * NL2; #endif diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 03a7ff7204..6bd040dd25 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1326,7 +1326,7 @@ int GLSL_BeginLoadGPUShaders(void) for (i = 0; i < LIGHTDEF_COUNT; i++) { int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; - qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); + qboolean allowVertexLighting = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); // skip impossible combos if (!GLSL_IsValidPermutationForLight (lightType, i)) @@ -1357,14 +1357,14 @@ int GLSL_BeginLoadGPUShaders(void) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT\n"); - if (fastLight) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_FAST_LIGHT\n"); + if (allowVertexLighting) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_LIGHTING\n"); switch (lightType) { case LIGHTDEF_USE_LIGHTMAP: Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHTMAP\n"); - if (r_deluxeMapping->integer && !fastLight) + if (r_deluxeMapping->integer && !allowVertexLighting) Q_strcat(extradefines, sizeof(extradefines), "#define USE_DELUXEMAP\n"); attribs |= ATTR_TEXCOORD1 | ATTR_LIGHTDIRECTION; break; @@ -1383,13 +1383,6 @@ int GLSL_BeginLoadGPUShaders(void) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_NORMALMAP\n"); - if (r_normalMapping->integer == 2) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_OREN_NAYAR\n"); - - if (r_normalMapping->integer == 3) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_TRIACE_OREN_NAYAR\n"); - - Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERT_TANGENT_SPACE\n"); attribs |= ATTR_TANGENT; if ((i & LIGHTDEF_USE_PARALLAXMAP) && r_parallaxMapping->integer) From 918999fbcc58dc344b34c7008976e16d23fbe970 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 25 Mar 2016 14:30:10 +0000 Subject: [PATCH 352/708] Rend2: Tidy up model cache code --- codemp/rd-rend2/tr_cache.cpp | 13 ++++--------- codemp/rd-rend2/tr_cache.h | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 247c4c3731..2384a610b8 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -153,7 +153,6 @@ void* CModelCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *p } /* - * CCacheManager::DeleteAll * Clears out the cache (done on renderer shutdown I suppose) */ void CModelCacheManager::DeleteAll( void ) @@ -168,7 +167,6 @@ void CModelCacheManager::DeleteAll( void ) } /* - * CCacheManager::DumpNonPure * Scans the cache for assets which don't match the checksum, and dumps * those that don't match. */ @@ -308,7 +306,7 @@ void CModelCacheManager::StoreShaderRequest( const char *psModelFileName, const int iNameOffset = psShaderName - (char *)file->pDiskImage; int iPokeOffset = (char*) piShaderIndexPoke - (char *)file->pDiskImage; - file->shaderCache.push_back(std::make_pair(iNameOffset, iPokeOffset)); + file->shaderCache.push_back(ShaderCacheEntry(iNameOffset, iPokeOffset)); } void CModelCacheManager::AllocateShaders( const char *psFileName ) @@ -331,13 +329,10 @@ void CModelCacheManager::AllocateShaders( const char *psFileName ) return; } - for( auto storedShader = file->shaderCache.begin(); storedShader != file->shaderCache.end(); ++storedShader ) + for( const ShaderCacheEntry& shader : file->shaderCache ) { - int iShaderNameOffset = storedShader->first; - int iShaderPokeOffset = storedShader->second; - - char *psShaderName = ((char*)file->pDiskImage + iShaderNameOffset); - int *piShaderPokePtr = (int *)((char*)file->pDiskImage + iShaderPokeOffset); + char *psShaderName = ((char*)file->pDiskImage + shader.nameOffset); + int *piShaderPokePtr = (int *)((char*)file->pDiskImage + shader.pokeOffset); shader_t *sh = R_FindShader(psShaderName, lightmapsNone, stylesDefault, qtrue); if ( sh->defaultShader ) diff --git a/codemp/rd-rend2/tr_cache.h b/codemp/rd-rend2/tr_cache.h index 7b6154a48f..c8c965fa64 100644 --- a/codemp/rd-rend2/tr_cache.h +++ b/codemp/rd-rend2/tr_cache.h @@ -13,8 +13,18 @@ struct Asset }; /* and shaderCache_t is needed for the model cache manager */ -typedef std::pair shaderCacheEntry_t; -typedef std::vector shaderCache_t; +struct ShaderCacheEntry +{ + ShaderCacheEntry( int nameOffset, int pokeOffset ) + : nameOffset(nameOffset) + , pokeOffset(pokeOffset) + { + } + + int nameOffset; + int pokeOffset; +}; +using ShaderCache = std::vector; /* * The actual data stored in the cache @@ -26,7 +36,7 @@ struct CachedFile int iPAKChecksum; // -1 = not from PAK int iAllocSize; // - shaderCache_t shaderCache; + ShaderCache shaderCache; char path[MAX_QPATH]; From 19270a2382dea413a31cee97cefa66d12887c6f1 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 25 Mar 2016 15:04:18 +0000 Subject: [PATCH 353/708] Rend2: Set #line to match the .glsl file Makes debugging easier --- codemp/rd-rend2/glsl/compact.cpp | 3 +- codemp/rd-rend2/tr_glsl.cpp | 79 ++++++++++++++++--------------- codemp/rd-rend2/tr_glsl_parse.cpp | 22 +++++++-- codemp/rd-rend2/tr_local.h | 2 + 4 files changed, 63 insertions(+), 43 deletions(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 9a7862aa7f..658a33061c 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -178,7 +178,8 @@ int main( int argc, char *argv[] ) const char *suffix = GetShaderSuffix(shaderDesc.type); ss << " { " << ToString(shaderDesc.type) << ", " - "fallback_" << shaderName << suffix << " },\n"; + "fallback_" << shaderName << suffix << ", " + << shaderDesc.firstLine << " },\n"; } ss << "};\n"; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6bd040dd25..408a555541 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -255,7 +255,7 @@ static void GLSL_PrintShaderSource(GLuint shader) Z_Free(msg); } -static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, char *dest, size_t size ) +static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, int firstLine, char *dest, size_t size ) { float fbufWidthScale, fbufHeightScale; @@ -369,7 +369,7 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, cha // OK we added a lot of stuff but if we do something bad in the GLSL shaders then we want the proper line // so we have to reset the line counting - Q_strcat(dest, size, "#line 0\n"); + Q_strcat(dest, size, va("#line %d\n", firstLine - 1)); } static int GLSL_EnqueueCompileGPUShader(GLuint program, GLuint *prevShader, const GLchar *buffer, int size, GLenum shaderType) @@ -623,8 +623,7 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) } static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, - int attribs, qboolean fragmentShader, const GLcharARB *extra, - const char *fallback_vp, const char *fallback_fp) + int attribs, qboolean fragmentShader, const GLcharARB *extra, const GPUProgramDesc& programDesc) { char vpCode[32000]; char fpCode[32000]; @@ -632,14 +631,18 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, int size; size_t vertexShaderCodeLen; + assert(programDesc.numShaders == 2); + assert(programDesc.shaders[0].type == GPUSHADER_VERTEX); + assert(programDesc.shaders[1].type == GPUSHADER_FRAGMENT); + size = sizeof(vpCode); - GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, vpCode, size); + GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, programDesc.shaders[0].firstLine, vpCode, size); vertexShaderCodeLen = strlen(vpCode); postHeader = &vpCode[vertexShaderCodeLen]; size -= vertexShaderCodeLen; - if (!GLSL_LoadGPUShaderText(name, fallback_vp, GL_VERTEX_SHADER, postHeader, size)) + if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[0].source, GL_VERTEX_SHADER, postHeader, size)) { return 0; } @@ -650,12 +653,12 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, size = sizeof(fpCode); - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, fpCode, size); + GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, programDesc.shaders[1].firstLine, fpCode, size); fragmentShaderCodeLen = strlen(fpCode); postHeader = &fpCode[fragmentShaderCodeLen]; size -= fragmentShaderCodeLen; - if (!GLSL_LoadGPUShaderText(name, fallback_fp, GL_FRAGMENT_SHADER, postHeader, size)) + if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[1].source, GL_FRAGMENT_SHADER, postHeader, size)) { return 0; } @@ -1208,7 +1211,7 @@ int GLSL_BeginLoadGPUShaders(void) } if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); } @@ -1264,8 +1267,8 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, extradefines, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } @@ -1312,8 +1315,8 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, extradefines, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); } @@ -1466,7 +1469,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); } @@ -1478,8 +1481,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("texturecolor", allocator, fallback_texturecolorProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, NULL, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); } @@ -1491,8 +1494,8 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, nullptr, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } @@ -1506,8 +1509,8 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, extradefines, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } @@ -1518,8 +1521,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("down4x", allocator, fallback_down4xProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, nullptr, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load down4x shader!"); } @@ -1530,8 +1533,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("bokeh", allocator, fallback_bokehProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, nullptr, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load bokeh shader!"); } @@ -1542,8 +1545,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("tonemap", allocator, fallback_tonemapProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, nullptr, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load tonemap shader!"); } @@ -1561,7 +1564,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); } @@ -1585,8 +1588,8 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, extradefines, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } @@ -1597,8 +1600,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("ssao", allocator, fallback_ssaoProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, nullptr, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load ssao shader!"); } @@ -1619,7 +1622,7 @@ int GLSL_BeginLoadGPUShaders(void) if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } @@ -1634,7 +1637,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } @@ -1642,7 +1645,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = 0; if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, - nullptr, programDesc->shaders[0].source, programDesc->shaders[1].source)) + nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } @@ -1654,7 +1657,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = 0; extradefines[0] = '\0'; if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); } @@ -1665,8 +1668,8 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("dglow_upsample", allocator, fallback_dglow_upsampleProgram); attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, extradefines, - programDesc->shaders[0].source, programDesc->shaders[1].source)) + if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); } @@ -1694,7 +1697,7 @@ int GLSL_BeginLoadGPUShaders(void) "#define ALPHA_TEST\n"); if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", attribs, qtrue, - extradefines, programDesc->shaders[0].source, programDesc->shaders[1].source)) + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); } diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index cd09a3d1b9..94cfb46533 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -50,6 +50,7 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) Block *prevBlock = nullptr; int i = 0; + int line = 1; while ( text[i] ) { int markerStart = i; @@ -70,8 +71,13 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) else if ( strncmp(text + j, "*/\n", 3) == 0 ) { endHeaderText = j; + line++; break; } + else if ( text[j] == '\n' ) + { + line++; + } ++j; } @@ -93,6 +99,7 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) block->blockHeaderTextLength = endHeaderText - endHeaderTitle - 1; block->blockText = text + endHeaderText + 3; block->blockTextLength = 0; + block->blockTextFirstLine = line; if ( prevBlock ) { @@ -103,6 +110,10 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) i = endHeaderText + 3; continue; } + else if ( text[i] == '\n' ) + { + line++; + } ++i; } @@ -128,10 +139,13 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) strncpy_s(fragmentSource, fragmentBlock->blockTextLength + 1, fragmentBlock->blockText, fragmentBlock->blockTextLength); - theProgram.shaders[0].type = GPUSHADER_VERTEX; - theProgram.shaders[0].source = vertexSource; - theProgram.shaders[1].type = GPUSHADER_FRAGMENT; - theProgram.shaders[1].source = fragmentSource; + theProgram.shaders[0].type = GPUSHADER_VERTEX; + theProgram.shaders[0].source = vertexSource; + theProgram.shaders[0].firstLine = vertexBlock->blockTextFirstLine; + + theProgram.shaders[1].type = GPUSHADER_FRAGMENT; + theProgram.shaders[1].source = fragmentSource; + theProgram.shaders[1].firstLine = fragmentBlock->blockTextFirstLine; return theProgram; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5c61618e89..afc019d14f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1123,6 +1123,7 @@ struct Block { const char *blockText; size_t blockTextLength; + int blockTextFirstLine; const char *blockHeaderTitle; size_t blockHeaderTitleLength; @@ -1141,6 +1142,7 @@ struct GPUShaderDesc { GPUShaderType type; const char *source; + int firstLine; }; struct GPUProgramDesc From 0b76ece2b92d22d7503c260088a11bbacfcf5bb0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 26 Mar 2016 09:27:17 +0000 Subject: [PATCH 354/708] Rend2: Add missing perfcounter uses --- codemp/rd-rend2/tr_shade.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 004fdee331..2f35b7b984 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1315,6 +1315,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } sp = &pStage->glslShaderGroup[index]; + backEnd.pc.c_lightallDraws++; } else { @@ -1360,6 +1361,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } sp = &tr.genericShader[index]; + backEnd.pc.c_genericDraws++; } } else if (pStage->glslShaderGroup == tr.lightallShader) From c2b7ad0d2a9650ecc227f29f0b9cd1fbb6ba5c15 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 27 Mar 2016 12:27:22 +0100 Subject: [PATCH 355/708] Rend2: Move some draw information into DrawItem --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_allocator.cpp | 41 +- codemp/rd-rend2/tr_allocator.h | 8 +- codemp/rd-rend2/tr_cmds.cpp | 4 + codemp/rd-rend2/tr_glsl.cpp | 76 +++ codemp/rd-rend2/tr_init.cpp | 23 +- codemp/rd-rend2/tr_local.h | 13 + codemp/rd-rend2/tr_shade.cpp | 946 +++++++++++++++++++++++-------- 8 files changed, 849 insertions(+), 263 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 7a141c65a8..c9822f5b08 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -20,6 +20,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" "${MPDir}/rd-rend2/tr_allocator.cpp" + "${MPDir}/rd-rend2/tr_allocator.h" "${MPDir}/rd-rend2/tr_animation.cpp" "${MPDir}/rd-rend2/tr_backend.cpp" "${MPDir}/rd-rend2/tr_bsp.cpp" diff --git a/codemp/rd-rend2/tr_allocator.cpp b/codemp/rd-rend2/tr_allocator.cpp index 9214629518..29eb1529f8 100644 --- a/codemp/rd-rend2/tr_allocator.cpp +++ b/codemp/rd-rend2/tr_allocator.cpp @@ -2,35 +2,58 @@ #include "tr_allocator.h" #include "tr_local.h" -Allocator::Allocator( size_t memorySize ) +Allocator::Allocator( void *memory, size_t memorySize, size_t alignment ) + : alignment(alignment) + , ownMemory(false) + , unalignedBase(memory) + , alignedBase(PADP(unalignedBase, alignment)) + , mark(alignedBase) + , end((char *)unalignedBase + memorySize) +{ + assert(unalignedBase); + assert(memorySize); + assert(alignment); +} + +Allocator::Allocator( size_t memorySize, size_t alignment ) + : alignment(alignment) + , ownMemory(true) #if defined(GLSL_BUILDTOOL) - : memoryBase(malloc(memorySize)) + , unalignedBase(malloc(memorySize)) #else - : memoryBase(Z_Malloc(memorySize, TAG_SHADERTEXT)) + , unalignedBase(Z_Malloc(memorySize, TAG_SHADERTEXT)) #endif - , mark(memoryBase) - , end((char *)memoryBase + memorySize) + , alignedBase(PADP(unalignedBase, alignment)) + , mark(alignedBase) + , end((char *)unalignedBase + memorySize) { + assert(unalignedBase); + assert(memorySize); + assert(alignment); } Allocator::~Allocator() { + if ( ownMemory ) + { #if defined(GLSL_BUILDTOOL) - free(memoryBase); + free(unalignedBase); #else - Z_Free(memoryBase); + Z_Free(unalignedBase); #endif + } } void *Allocator::Alloc( size_t allocSize ) { if ( (size_t)((char *)end - (char *)mark) < allocSize ) { + assert(!"Allocator is out of memory"); return nullptr; } void *result = mark; - size_t alignedSize = (allocSize + 15) & ~15; + size_t alignedSize = PAD(allocSize, alignment); mark = (char *)mark + alignedSize; @@ -44,7 +67,7 @@ void *Allocator::Mark() const void Allocator::Reset() { - mark = memoryBase; + mark = alignedBase; } void Allocator::ResetTo( void *m ) diff --git a/codemp/rd-rend2/tr_allocator.h b/codemp/rd-rend2/tr_allocator.h index 53efd586bf..4ed9e116c9 100644 --- a/codemp/rd-rend2/tr_allocator.h +++ b/codemp/rd-rend2/tr_allocator.h @@ -23,7 +23,8 @@ along with this program; if not, see . class Allocator { public: - Allocator( size_t memorySize ); + Allocator( void *memory, size_t memorySize, size_t alignment = 16 ); + Allocator( size_t memorySize, size_t alignment = 16 ); ~Allocator(); Allocator( const Allocator& ) = delete; @@ -35,7 +36,10 @@ class Allocator void ResetTo( void *mark ); private: - void *memoryBase; + size_t alignment; + bool ownMemory; + void *unalignedBase; + void *alignedBase; void *mark; void *end; }; diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 786b1f2301..7ebc03a82d 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ #include "tr_local.h" +#include "tr_allocator.h" /* ===================== @@ -494,6 +495,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // FIXME: Doesn't this mean the frame will never render? qglDeleteSync( sync ); thisFrame->sync = NULL; + backEndData->perFrameMemory->Reset(); ri->Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); return; @@ -507,6 +509,8 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // Set the frame uniform buffer qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo); thisFrame->uboWriteOffset = 0; + + backEndData->perFrameMemory->Reset(); } tr.frameCount++; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 408a555541..6da373acc6 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -737,6 +737,82 @@ void GLSL_FinishGPUShader(shaderProgram_t *program) #endif } +void GLSL_SetUniforms( shaderProgram_t *program, UniformData *uniformData ) +{ + UniformData *data = uniformData; + while ( data->index != UNIFORM_COUNT ) + { + switch ( uniformsInfo[data->index].type ) + { + case GLSL_INT: + { + assert(data->numElements == 1); + GLint *value = (GLint *)(data + 1); + GLSL_SetUniformInt(program, data->index, *value); + data = reinterpret_cast(value + data->numElements); + break; + } + + case GLSL_FLOAT: + { + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformFloatN(program, data->index, value, data->numElements); + data = reinterpret_cast(value + data->numElements); + break; + } + + case GLSL_VEC2: + { + assert(data->numElements == 1); + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformVec2(program, data->index, value); + data = reinterpret_cast(value + data->numElements*2); + break; + } + + case GLSL_VEC3: + { + assert(data->numElements == 1); + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformVec3(program, data->index, value); + data = reinterpret_cast(value + data->numElements*3); + break; + } + + case GLSL_VEC4: + { + assert(data->numElements == 1); + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformVec4(program, data->index, value); + data = reinterpret_cast(value + data->numElements*4); + break; + } + + case GLSL_MAT4x3: + { + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformMatrix4x3(program, data->index, value, data->numElements); + data = reinterpret_cast(value + data->numElements*12); + break; + } + + case GLSL_MAT4x4: + { + GLfloat *value = (GLfloat *)(data + 1); + GLSL_SetUniformMatrix4x4(program, data->index, value, data->numElements); + data = reinterpret_cast(value + data->numElements*16); + break; + } + + default: + { + assert(!"Invalid uniform data type"); + return; + } + } + } +} + void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) { GLint *uniforms = program->uniforms; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 39fa4eeaaf..82da066d54 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #include "ghoul2/g2_local.h" #include "tr_cache.h" +#include "tr_allocator.h" #include static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; @@ -1682,10 +1683,24 @@ void R_Init( void ) { max_polys = Q_min( r_maxpolys->integer, DEFAULT_MAX_POLYS ); max_polyverts = Q_min( r_maxpolyverts->integer, DEFAULT_MAX_POLYVERTS ); - ptr = (byte*)ri->Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts, h_low); - backEndData = (backEndData_t *) ptr; - backEndData->polys = (srfPoly_t *) ((char *) ptr + sizeof( *backEndData )); - backEndData->polyVerts = (polyVert_t *) ((char *) ptr + sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys); + ptr = (byte*)ri->Hunk_Alloc( + sizeof( *backEndData ) + + sizeof(srfPoly_t) * max_polys + + sizeof(polyVert_t) * max_polyverts + + sizeof(Allocator) + + PER_FRAME_MEMORY_BYtES, + h_low); + + backEndData = (backEndData_t *)ptr; + ptr = (byte *)(backEndData + 1); + + backEndData->polys = (srfPoly_t *)ptr; + ptr += sizeof(*backEndData->polys) * max_polys; + + backEndData->polyVerts = (polyVert_t *)ptr; + ptr += sizeof(*backEndData->polyVerts) * max_polyverts; + + backEndData->perFrameMemory = new(ptr) Allocator(ptr + sizeof(*backEndData->perFrameMemory), PER_FRAME_MEMORY_BYtES); R_InitNextFrame(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index afc019d14f..cde0455688 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1243,6 +1243,15 @@ typedef enum UNIFORM_COUNT } uniform_t; +struct UniformData +{ + uniform_t index; + int numElements; + + // uniform data follows immediately afterwards + //char data[1]; +}; + // shaderProgram_t represents a pair of one // GLSL vertex and one GLSL fragment shader typedef struct shaderProgram_s @@ -2929,6 +2938,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); void GLSL_SetUniformMatrix4x3(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); void GLSL_SetUniformMatrix4x4(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); +void GLSL_SetUniforms( shaderProgram_t *program, UniformData *uniformData ); shaderProgram_t *GLSL_GetGenericShaderProgram(int stage); @@ -3268,10 +3278,13 @@ struct gpuFrame_t // all of the information needed by the back end must be // contained in a backEndData_t. #define MAX_FRAMES (2) +#define PER_FRAME_MEMORY_BYtES (128 * 1024 * 1024) +class Allocator; typedef struct backEndData_s { unsigned realFrameNumber; gpuFrame_t frames[MAX_FRAMES]; gpuFrame_t *currentFrame; + Allocator *perFrameMemory; drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 2f35b7b984..e10cbf899d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_shade.c #include "tr_local.h" +#include "tr_allocator.h" /* @@ -423,7 +424,6 @@ static void ProjectDlightTexture( void ) { for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { dlight_t *dl; shaderProgram_t *sp; - vec4_t vector; if ( !( tess.dlightBits & ( 1 << l ) ) ) { continue; // this surface definately doesn't have any of this light @@ -1196,271 +1196,696 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) +struct SamplerBinding { - int stage; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; + image_t *image; + qhandle_t videoMapHandle; + uint8_t slot; +}; - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; +enum DrawCommandType +{ + DRAW_COMMAND_MULTI_INDEXED, + DRAW_COMMAND_INDEXED, + DRAW_COMMAND_ARRAYS +}; - ComputeDeformValues(&deformType, &deformGen, deformParams); +struct DrawCommand +{ + DrawCommandType type; + GLenum primitiveType; + int numInstances; - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + union DrawParams + { + struct MultiDrawIndexed + { + int numDraws; + GLsizei *numIndices; + glIndex_t **firstIndices; + } multiIndexed; - for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) + struct DrawIndexed + { + GLsizei numIndices; + glIndex_t firstIndex; + } indexed; + } params; +}; + +struct DrawItem +{ + uint32_t stateBits; + IBO_t *ibo; + shaderProgram_t *program; + + uint32_t numAttributes; + vertexAttribute_t *attributes; + + uint32_t numSamplerBindings; + SamplerBinding *samplerBindings; + + UniformData *uniformData; + + DrawCommand draw; +}; + +static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings ) +{ + for ( size_t i = 0; i < numBindings; ++i ) { - shaderStage_t *pStage = input->xstages[stage]; - shaderProgram_t *sp; - vec4_t texMatrix; - vec4_t texOffTurb; - int stateBits; - colorGen_t forceRGBGen = CGEN_BAD; - alphaGen_t forceAlphaGen = AGEN_IDENTITY; - int index = 0; - bool useAlphaTestGE192 = false; + const SamplerBinding& binding = bindings[i]; + if ( binding.videoMapHandle ) + { + int oldtmu = glState.currenttmu; + GL_SelectTexture(binding.slot); + ri->CIN_RunCinematic(binding.videoMapHandle - 1); + ri->CIN_UploadCinematic(binding.videoMapHandle - 1); + GL_SelectTexture(oldtmu); + } + else + { + GL_BindToTMU(binding.image, binding.slot); + } + } +} - if ( !pStage ) +static void RB_Draw( const DrawItem& drawItem ) +{ + GL_State(drawItem.stateBits); + //R_BindIBO(drawItem.ibo); + GLSL_BindProgram(drawItem.program); + + // FIXME: There was a reason I didn't have const on attributes. Can't remember at the moment + // what the reason was though. + //GL_VertexAttribPointers(drawItem.numAttributes, (vertexAttribute_t *)drawItem.attributes); + RB_BindTextures(drawItem.numSamplerBindings, drawItem.samplerBindings); + + GLSL_SetUniforms(drawItem.program, drawItem.uniformData); + + switch ( drawItem.draw.type ) + { + case DRAW_COMMAND_MULTI_INDEXED: { + GL_MultiDrawIndexed(drawItem.draw.primitiveType, + drawItem.draw.params.multiIndexed.numIndices, + drawItem.draw.params.multiIndexed.firstIndices, + drawItem.draw.params.multiIndexed.numDraws); break; } - if ( pStage->ss ) + case DRAW_COMMAND_INDEXED: { - continue; + GL_DrawIndexed(drawItem.draw.primitiveType, + drawItem.draw.params.indexed.numIndices, + drawItem.draw.params.indexed.firstIndex, + drawItem.draw.numInstances, 0); + break; } - stateBits = pStage->stateBits; + default: + { + assert(!"Invalid or unhandled draw type"); + break; + } + } +} - if (backEnd.currentEntity) +class UniformDataWriter +{ +public: + UniformDataWriter( Allocator& allocator ) + : allocator(allocator) + , uniformDataBase(static_cast(allocator.Mark())) + , failed(false) + , shaderProgram(nullptr) + { + } + + UniformDataWriter( const UniformDataWriter& ) = delete; + UniformDataWriter& operator=( const UniformDataWriter& ) = delete; + + void Start( shaderProgram_t *sp ) + { + shaderProgram = sp; + } + + UniformDataWriter& SetUniformInt( uniform_t uniform, int value ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(int)); + if ( !memory ) { - assert(backEnd.currentEntity->e.renderfx >= 0); + failed = true; + return *this; + } - if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) - { - // we want to be able to rip a hole in the thing being - // disintegrated, and by doing the depth-testing it avoids some - // kinds of artefacts, but will probably introduce others? - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; - useAlphaTestGE192 = true; - } + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = 1; - if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) - {//want to use RGBGen from ent - forceRGBGen = CGEN_ENTITY; - } + int *data = reinterpret_cast(header + 1); + *data = value; - if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) + return *this; + } + + UniformDataWriter& SetUniformFloat( uniform_t uniform, float value ) + { + return SetUniformFloat(uniform, &value, 1); + } + + UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(float) * count); + + return *this; + } + + UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec2_t) * count); + + return *this; + } + + UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec3_t) * count); + + return *this; + } + + UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec4_t) * count); + + return *this; + } + + UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*12*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 12 * count); + + return *this; + } + + UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*16*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 16 * count); + + return *this; + } + + UniformData *Finish() + { + UniformData *endSentinel = ojkAlloc(allocator); + if ( failed || !endSentinel ) + { + return nullptr; + } + + endSentinel->index = UNIFORM_COUNT; + + UniformData *result = uniformDataBase; + uniformDataBase = static_cast(allocator.Mark()); + failed = false; + shaderProgram = nullptr; + return result; + } + +private: + Allocator& allocator; + UniformData *uniformDataBase; + bool failed; + shaderProgram_t *shaderProgram; +}; + +class SamplerBindingsWriter +{ +public: + SamplerBindingsWriter( Allocator& allocator ) + : allocator(allocator) + , bindingsBase(static_cast(allocator.Mark())) + , failed(false) + , count(0) + { + } + + SamplerBindingsWriter( const SamplerBindingsWriter& ) = delete; + SamplerBindingsWriter& operator=( const SamplerBindingsWriter& ) = delete; + + SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ) + { + SamplerBinding *binding = ojkAlloc(allocator); + if ( !binding ) + { + failed = true; + return *this; + } + + binding->image = image; + binding->slot = unit; + binding->videoMapHandle = NULL_HANDLE; + ++count; + + return *this; + } + + SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ) + { + int index; + + if ( bundle->isVideoMap ) + { + SamplerBinding *binding = ojkAlloc(allocator); + if ( !binding ) { - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) - { - // depth write, so faces through the model will be stomped - // over by nearer ones. this works because we draw - // RF_FORCE_ENT_ALPHA stuff after everything else, including - // standard alpha surfs. - stateBits |= GLS_DEPTHMASK_TRUE; - } + failed = true; + return *this; } + + binding->image = nullptr; + binding->slot = unit; + binding->videoMapHandle = bundle->videoMapHandle + 1; + ++count; + + return *this; } - GL_State( stateBits ); + if ( bundle->numImageAnimations <= 1 ) + { + return AddStaticImage(bundle->image[0], unit); + } - if (backEnd.depthFill) + if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) { - if (pStage->glslShaderGroup == tr.lightallShader) - { - index = 0; + index = backEnd.currentEntity->e.skinNum; + } + else + { + // it is necessary to do this messy calc to make sure animations line up + // exactly with waveforms of the same frequency + index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); + index = Q_max(0, index >> FUNCTABLE_SIZE2); + } - if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) - { - index |= LIGHTDEF_ENTITY; + if ( bundle->oneShotAnimMap ) + { + index = Q_min(index, bundle->numImageAnimations - 1); + } + else + { + // loop + index %= bundle->numImageAnimations; + } - if (glState.vertexAnimation) - { - index |= LIGHTDEF_USE_VERTEX_ANIMATION; - } + return AddStaticImage(bundle->image[ index ], unit); + } - if (glState.skeletalAnimation) - { - index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } - } + SamplerBinding *Finish( int* numBindings ) + { + if ( failed ) + { + return nullptr; + } - if ( !useAlphaTestGE192 ) - { - if (pStage->alphaTestCmp != ATEST_CMP_NONE) - { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - switch ( pStage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= LIGHTDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= LIGHTDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= LIGHTDEF_USE_ATEST_GE; - break; - } - } - } - else - { - index |= LIGHTDEF_USE_ATEST_GE; - } + SamplerBinding *result = bindingsBase; - sp = &pStage->glslShaderGroup[index]; - backEnd.pc.c_lightallDraws++; - } - else - { - index = 0; + if ( numBindings ) + { + *numBindings = count; + } - if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) - { - index |= GENERICDEF_USE_DEFORM_VERTEXES; - } + bindingsBase = static_cast(allocator.Mark()); + failed = false; + count = 0; + return result; + } + +private: + Allocator& allocator; + SamplerBinding *bindingsBase; + bool failed; + int count; +}; + +static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stage, shaderProgram_t *glslShaderGroup, bool useAlphaTestGE192 ) +{ + uint32_t index; + shaderProgram_t *result = nullptr; + + if (backEnd.depthFill) + { + if (glslShaderGroup == tr.lightallShader) + { + index = 0; + + if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + { + index |= LIGHTDEF_ENTITY; if (glState.vertexAnimation) { - index |= GENERICDEF_USE_VERTEX_ANIMATION; + index |= LIGHTDEF_USE_VERTEX_ANIMATION; } if (glState.skeletalAnimation) { - index |= GENERICDEF_USE_SKELETAL_ANIMATION; + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; } + } - if ( !useAlphaTestGE192 ) + if ( !useAlphaTestGE192 ) + { + if (stage->alphaTestCmp != ATEST_CMP_NONE) { - if (pStage->alphaTestCmp != ATEST_CMP_NONE) + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + switch ( stage->alphaTestCmp ) { - index |= GENERICDEF_USE_TCGEN_AND_TCMOD; - switch ( pStage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= GENERICDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= GENERICDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= GENERICDEF_USE_ATEST_GE; - break; - } + case ATEST_CMP_LT: + index |= LIGHTDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= LIGHTDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= LIGHTDEF_USE_ATEST_GE; + break; } } - else - { - index |= GENERICDEF_USE_ATEST_GE; - } - - sp = &tr.genericShader[index]; - backEnd.pc.c_genericDraws++; } + else + { + index |= LIGHTDEF_USE_ATEST_GE; + } + + result = &stage->glslShaderGroup[index]; + backEnd.pc.c_lightallDraws++; } - else if (pStage->glslShaderGroup == tr.lightallShader) + else { - index = pStage->glslShaderIndex; + index = 0; - if (r_lightmap->integer && (index & LIGHTDEF_USE_LIGHTMAP)) + if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) { - index = LIGHTDEF_USE_LIGHTMAP; + index |= GENERICDEF_USE_DEFORM_VERTEXES; } - else + + if (glState.vertexAnimation) { - if (backEnd.currentEntity && - backEnd.currentEntity != &tr.worldEntity) - { - index |= LIGHTDEF_ENTITY; + index |= GENERICDEF_USE_VERTEX_ANIMATION; + } - if (glState.vertexAnimation) - { - index |= LIGHTDEF_USE_VERTEX_ANIMATION; - } + if (glState.skeletalAnimation) + { + index |= GENERICDEF_USE_SKELETAL_ANIMATION; + } - if (glState.skeletalAnimation) + if ( !useAlphaTestGE192 ) + { + if (stage->alphaTestCmp != ATEST_CMP_NONE) + { + index |= GENERICDEF_USE_TCGEN_AND_TCMOD; + switch ( stage->alphaTestCmp ) { - index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } + case ATEST_CMP_LT: + index |= GENERICDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= GENERICDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= GENERICDEF_USE_ATEST_GE; + break; + } } + } + else + { + index |= GENERICDEF_USE_ATEST_GE; + } + + result = &tr.genericShader[index]; + backEnd.pc.c_genericDraws++; + } + } + else if (stage->glslShaderGroup == tr.lightallShader) + { + index = stage->glslShaderIndex; + + if (r_lightmap->integer && (index & LIGHTDEF_USE_LIGHTMAP)) + { + index = LIGHTDEF_USE_LIGHTMAP; + } + else + { + if (backEnd.currentEntity && + backEnd.currentEntity != &tr.worldEntity) + { + index |= LIGHTDEF_ENTITY; - if (r_sunlightMode->integer && - (backEnd.viewParms.flags & VPF_USESUNLIGHT) && - (index & LIGHTDEF_LIGHTTYPE_MASK)) + if (glState.vertexAnimation) { - index |= LIGHTDEF_USE_SHADOWMAP; + index |= LIGHTDEF_USE_VERTEX_ANIMATION; } - if ( !useAlphaTestGE192 ) + if (glState.skeletalAnimation) { - if (pStage->alphaTestCmp != ATEST_CMP_NONE) + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + } + } + + if (r_sunlightMode->integer && + (backEnd.viewParms.flags & VPF_USESUNLIGHT) && + (index & LIGHTDEF_LIGHTTYPE_MASK)) + { + index |= LIGHTDEF_USE_SHADOWMAP; + } + + if ( !useAlphaTestGE192 ) + { + if (stage->alphaTestCmp != ATEST_CMP_NONE) + { + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; + switch ( stage->alphaTestCmp ) { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - switch ( pStage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= LIGHTDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= LIGHTDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= LIGHTDEF_USE_ATEST_GE; - break; - } + case ATEST_CMP_LT: + index |= LIGHTDEF_USE_ATEST_LT; + break; + case ATEST_CMP_GT: + index |= LIGHTDEF_USE_ATEST_GT; + break; + case ATEST_CMP_GE: + index |= LIGHTDEF_USE_ATEST_GE; + break; } } - else - { - index |= LIGHTDEF_USE_ATEST_GE; - } } + else + { + index |= LIGHTDEF_USE_ATEST_GE; + } + } + + result = &stage->glslShaderGroup[index]; + backEnd.pc.c_lightallDraws++; + } + else + { + result = GLSL_GetGenericShaderProgram(stageIndex); + backEnd.pc.c_genericDraws++; + } - sp = &pStage->glslShaderGroup[index]; + return result; +} - backEnd.pc.c_lightallDraws++; +static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) +{ + int stage; + + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; + + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; + + ComputeDeformValues(&deformType, &deformGen, deformParams); + + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) + { + Allocator uniformDataAlloc(backEndData->perFrameMemory->Alloc(1024), 1024, 1); + Allocator samplerBindingsAlloc(backEndData->perFrameMemory->Alloc(128), 128, 1); + + UniformDataWriter uniformDataWriter(uniformDataAlloc); + SamplerBindingsWriter samplerBindingsWriter(samplerBindingsAlloc); + + shaderStage_t *pStage = input->xstages[stage]; + shaderProgram_t *sp; + vec4_t texMatrix; + vec4_t texOffTurb; + int stateBits; + colorGen_t forceRGBGen = CGEN_BAD; + alphaGen_t forceAlphaGen = AGEN_IDENTITY; + int index = 0; + bool useAlphaTestGE192 = false; + + if ( !pStage ) + { + break; } - else + + if ( pStage->ss ) { - sp = GLSL_GetGenericShaderProgram(stage); + continue; + } - backEnd.pc.c_genericDraws++; + stateBits = pStage->stateBits; + + if (backEnd.currentEntity) + { + assert(backEnd.currentEntity->e.renderfx >= 0); + + if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) + { + // we want to be able to rip a hole in the thing being + // disintegrated, and by doing the depth-testing it avoids some + // kinds of artefacts, but will probably introduce others? + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; + useAlphaTestGE192 = true; + } + + if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) + {//want to use RGBGen from ent + forceRGBGen = CGEN_ENTITY; + } + + if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) + { + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + if ( backEnd.currentEntity->e.renderfx & RF_ALPHA_DEPTH ) + { + // depth write, so faces through the model will be stomped + // over by nearer ones. this works because we draw + // RF_FORCE_ENT_ALPHA stuff after everything else, including + // standard alpha surfs. + stateBits |= GLS_DEPTHMASK_TRUE; + } + } } - GLSL_BindProgram(sp); + sp = SelectShaderProgram(stage, pStage, pStage->glslShaderGroup, useAlphaTestGE192); + assert(sp); - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); + uniformDataWriter.Start(sp); + uniformDataWriter.SetUniformMatrix4x4( UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + uniformDataWriter.SetUniformVec3(UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); if (glState.skeletalAnimation) { - GLSL_SetUniformMatrix4x3 (sp, UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); + uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); } - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); if (deformType != DEFORM_NONE) { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); + uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } if ( input->fogNum ) { - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); } - { vec4_t baseColor; vec4_t vertColor; @@ -1480,8 +1905,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vertColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; } - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); + uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); + uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); } if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || @@ -1490,97 +1915,91 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vec4_t vec; VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec); - GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vec); + uniformDataWriter.SetUniformVec3(UNIFORM_AMBIENTLIGHT, vec); VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec); - GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, vec); + uniformDataWriter.SetUniformVec3(UNIFORM_DIRECTEDLIGHT, vec); VectorCopy(backEnd.currentEntity->lightDir, vec); vec[3] = 0.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vec); - GLSL_SetUniformVec3(sp, UNIFORM_MODELLIGHTDIR, backEnd.currentEntity->modelLightDir); + uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vec); + uniformDataWriter.SetUniformVec3(UNIFORM_MODELLIGHTDIR, backEnd.currentEntity->modelLightDir); - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, 0.0f); + uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, 0.0f); } if (pStage->alphaGen == AGEN_PORTAL) { - GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); + uniformDataWriter.SetUniformFloat(UNIFORM_PORTALRANGE, tess.shader->portalRange); } - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, forceRGBGen); - GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, forceAlphaGen); + uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, forceRGBGen); + uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, forceAlphaGen); if ( input->fogNum ) { vec4_t fogColorMask; - ComputeFogColorMask(pStage, fogColorMask); - - GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); } ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); + uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); + uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); - GLSL_SetUniformInt(sp, UNIFORM_TCGEN1, pStage->bundle[1].tcGen); + uniformDataWriter.SetUniformInt(UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + uniformDataWriter.SetUniformInt(UNIFORM_TCGEN1, pStage->bundle[1].tcGen); if (pStage->bundle[0].tcGen == TCGEN_VECTOR) { - vec3_t vec; - - VectorCopy(pStage->bundle[0].tcGenVectors[0], vec); - GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR0, vec); - VectorCopy(pStage->bundle[0].tcGenVectors[1], vec); - GLSL_SetUniformVec3(sp, UNIFORM_TCGEN0VECTOR1, vec); + uniformDataWriter.SetUniformVec3(UNIFORM_TCGEN0VECTOR0, pStage->bundle[0].tcGenVectors[0]); + uniformDataWriter.SetUniformVec3(UNIFORM_TCGEN0VECTOR1, pStage->bundle[0].tcGenVectors[1]); } - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); - GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); - GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); + uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); + uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); float alphaTestValue = useAlphaTestGE192 ? 0.75f : pStage->alphaTestValue; - GLSL_SetUniformFloat(sp, UNIFORM_ALPHA_TEST_VALUE, alphaTestValue); - - //GLSL_SetUniformFloat(sp, UNIFORM_MAPLIGHTSCALE, backEnd.refdef.mapLightScale); + uniformDataWriter.SetUniformFloat(UNIFORM_ALPHA_TEST_VALUE, alphaTestValue); // // do multitexture // + bool enableCubeMaps = + (r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex); + if ( backEnd.depthFill ) { if (pStage->alphaTestCmp == ATEST_CMP_NONE) - GL_BindToTMU( tr.whiteImage, 0 ); + samplerBindingsWriter.AddStaticImage(tr.whiteImage, 0); else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_COLORMAP], TB_COLORMAP ); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_COLORMAP], TB_COLORMAP); } else if ( pStage->glslShaderGroup == tr.lightallShader ) { int i; - vec4_t enableTextures; + vec4_t enableTextures = {}; if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { - GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP); - GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); - GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTCOLOR, backEnd.refdef.sunCol); - GLSL_SetUniformVec4(sp, UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); + samplerBindingsWriter.AddStaticImage(tr.screenShadowImage, TB_SHADOWMAP); + uniformDataWriter.SetUniformVec3(UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); + uniformDataWriter.SetUniformVec3(UNIFORM_PRIMARYLIGHTCOLOR, backEnd.refdef.sunCol); + uniformDataWriter.SetUniformVec4(UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); } - VectorSet4(enableTextures, 0, 0, 0, 0); if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && pStage->bundle[TB_LIGHTMAP].image[0]) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { if (i == TB_LIGHTMAP) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], i); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_LIGHTMAP], i); else - GL_BindToTMU( tr.whiteImage, i ); + samplerBindingsWriter.AddStaticImage(tr.whiteImage, i); } } else if (r_lightmap->integer == 3 && pStage->bundle[TB_DELUXEMAP].image[0]) @@ -1588,21 +2007,21 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { if (i == TB_LIGHTMAP) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], i); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_DELUXEMAP], i); else - GL_BindToTMU( tr.whiteImage, i ); + samplerBindingsWriter.AddStaticImage(tr.whiteImage, i); } } else { qboolean light = (qboolean)((pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) != 0); - qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); + qboolean allowVertexLighting = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); if (pStage->bundle[TB_DIFFUSEMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); if (pStage->bundle[TB_LIGHTMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_LIGHTMAP], TB_LIGHTMAP); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_LIGHTMAP], TB_LIGHTMAP); // bind textures that are sampled and used in the glsl shader, and // bind whiteImage to textures that are sampled but zeroed in the glsl shader @@ -1613,61 +2032,68 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // - disable texture sampling in glsl shader with #ifdefs, as before // -> increases the number of shaders that must be compiled // - if (light && !fastLight) + if (light && !allowVertexLighting) { if (pStage->bundle[TB_NORMALMAP].image[0]) { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); enableTextures[0] = 1.0f; } else if (r_normalMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); + { + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_NORMALMAP); + } if (pStage->bundle[TB_DELUXEMAP].image[0]) { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DELUXEMAP], TB_DELUXEMAP); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_DELUXEMAP], TB_DELUXEMAP); enableTextures[1] = 1.0f; } else if (r_deluxeMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_DELUXEMAP ); + { + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_DELUXEMAP); + } if (pStage->bundle[TB_SPECULARMAP].image[0]) { - R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); enableTextures[2] = 1.0f; } else if (r_specularMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); + { + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SPECULARMAP); + } } - enableTextures[3] = (r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex) ? 1.0f : 0.0f; + if ( enableCubeMaps ) + { + enableTextures[3] = 1.0f; + } } - GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); + uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); } else if ( pStage->bundle[1].image[0] != 0 ) { - R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); - R_BindAnimatedImageToTMU( &pStage->bundle[1], 1 ); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[0], 0); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[1], 1); } else { // // set state // - R_BindAnimatedImageToTMU( &pStage->bundle[0], 0 ); + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[0], 0); } // // testing cube map // - if (!(tr.viewParms.flags & VPF_NOCUBEMAPS) && - input->cubemapIndex && - r_cubeMapping->integer) + if ( enableCubeMaps ) { vec4_t vec; - GL_BindToTMU( tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + samplerBindingsWriter.AddStaticImage(tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.ori.origin[0]; vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.ori.origin[1]; @@ -1676,23 +2102,47 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays VectorScale4(vec, 1.0f / 1000.0f, vec); - GLSL_SetUniformVec4(sp, UNIFORM_CUBEMAPINFO, vec); + uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } CaptureDrawData(input, pStage, index, stage); - // - // draw - // - if (input->multiDrawPrimitives) + DrawItem item = {}; + item.stateBits = stateBits; + item.program = sp; + item.ibo = input->ibo; + + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, glState.currentVaoAttribs, + sizeof(*item.attributes)*vertexArrays->numVertexArrays); + + item.uniformData = uniformDataWriter.Finish(); + // FIXME: This is a bit ugly with the casting + item.samplerBindings = samplerBindingsWriter.Finish((int *)&item.numSamplerBindings); + item.draw.primitiveType = GL_TRIANGLES; + item.draw.numInstances = 1; + + if ( input->multiDrawPrimitives ) { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + item.draw.type = DRAW_COMMAND_MULTI_INDEXED; + item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; + item.draw.params.multiIndexed.firstIndices = input->multiDrawFirstIndex; + item.draw.params.multiIndexed.numIndices = input->multiDrawNumIndexes; } else { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + int offset = input->firstIndex * sizeof(glIndex_t) + + (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = offset; + item.draw.params.indexed.numIndices = input->numIndexes; } + RB_Draw(item); + // allow skipping out to show just lightmaps during development if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) { From 970e53f6bda313d58deaad98ed0cebeea521a4b5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 28 Mar 2016 18:55:56 +0100 Subject: [PATCH 356/708] Rend2: Build fix following cvar description change --- codemp/rd-rend2/tr_init.cpp | 388 +++++++++++++++++------------------ codemp/rd-rend2/tr_model.cpp | 2 +- 2 files changed, 195 insertions(+), 195 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 82da066d54..72054c134a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1342,229 +1342,229 @@ void R_Register( void ) // // latched and archived variables // - r_allowExtensions = ri->Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compress_textures", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_preferred_tc_method = ri->Cvar_Get( "r_ext_preferred_tc_method", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH); - r_arb_buffer_storage = ri->Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE ); - - r_dynamicGlow = ri->Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE ); - r_dynamicGlowPasses = ri->Cvar_Get( "r_dynamicGlowPasses", "5", CVAR_ARCHIVE ); - r_dynamicGlowDelta = ri->Cvar_Get( "r_dynamicGlowDelta", "0.8f", CVAR_ARCHIVE ); - r_dynamicGlowIntensity = ri->Cvar_Get( "r_dynamicGlowIntensity", "1.13f", CVAR_ARCHIVE ); - r_dynamicGlowSoft = ri->Cvar_Get( "r_dynamicGlowSoft", "1", CVAR_ARCHIVE ); - r_dynamicGlowWidth = ri->Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH ); - r_dynamicGlowHeight = ri->Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH ); - - r_debugContext = ri->Cvar_Get( "r_debugContext", "0", CVAR_LATCH ); - - r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH ); + r_allowExtensions = ri->Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH, "Allow GL extensions" ); + r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compress_textures", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable texture compression" ); + r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_preferred_tc_method = ri->Cvar_Get( "r_ext_preferred_tc_method", "0", CVAR_ARCHIVE | CVAR_LATCH, "Preferred texture compression method" ); + + r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable floating-point textures" ); + r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable ARB_half_float GL extension" ); + r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable framebuffer MSAA" ); + r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable seamless cube map filtering GL extension" ); + r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable 1010102 UI data type" ); + r_arb_buffer_storage = ri->Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable buffer storage GL extension" ); + r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE, "Disable/enable anisotropic texture filtering" ); + + r_dynamicGlow = ri->Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE, "" ); + r_dynamicGlowPasses = ri->Cvar_Get( "r_dynamicGlowPasses", "5", CVAR_ARCHIVE, "" ); + r_dynamicGlowDelta = ri->Cvar_Get( "r_dynamicGlowDelta", "0.8f", CVAR_ARCHIVE, "" ); + r_dynamicGlowIntensity = ri->Cvar_Get( "r_dynamicGlowIntensity", "1.13f", CVAR_ARCHIVE, "" ); + r_dynamicGlowSoft = ri->Cvar_Get( "r_dynamicGlowSoft", "1", CVAR_ARCHIVE, "" ); + r_dynamicGlowWidth = ri->Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH, "" ); + r_dynamicGlowHeight = ri->Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH, "" ); + + r_debugContext = ri->Cvar_Get( "r_debugContext", "0", CVAR_LATCH, "" ); + + r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); - r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH ); - r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_simpleMipMaps = ri->Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0); - r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH); + r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH, "" ); + r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_simpleMipMaps = ri->Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0, ""); + r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH, ""); ri->Cvar_CheckRange( r_subdivisions, 4, 80, qfalse ); - r_stereo = ri->Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH); - r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH); + r_stereo = ri->Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); + r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); - r_externalGLSL = ri->Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH ); - - r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE ); - - r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_forceToneMap = ri->Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT ); - r_forceToneMapMin = ri->Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT ); - r_forceToneMapAvg = ri->Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT ); - r_forceToneMapMax = ri->Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT ); - - r_autoExposure = ri->Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE ); - r_forceAutoExposure = ri->Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT ); - r_forceAutoExposureMin = ri->Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT ); - r_forceAutoExposureMax = ri->Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT ); - - r_cameraExposure = ri->Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT ); - - r_srgb = ri->Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_depthPrepass = ri->Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE ); - r_ssao = ri->Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE ); - - r_normalMapping = ri->Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_deluxeSpecular = ri->Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH ); - r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH ); - r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.1", CVAR_ARCHIVE | CVAR_LATCH ); - r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE ); - r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_genNormalMaps = ri->Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH ); - - r_forceSun = ri->Cvar_Get( "r_forceSun", "0", CVAR_CHEAT ); - r_forceSunMapLightScale = ri->Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT ); - r_forceSunLightScale = ri->Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT ); - r_forceSunAmbientScale = ri->Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT ); - r_drawSunRays = ri->Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH ); - r_sunlightMode = ri->Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH ); - - r_sunShadows = ri->Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowFilter = ri->Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowMapSize = ri->Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZNear = ri->Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZFar = ri->Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH ); - r_shadowCascadeZBias = ri->Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH ); - r_ignoreDstAlpha = ri->Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH ); + r_externalGLSL = ri->Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH, "" ); + + r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE, "" ); + + r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_forceToneMap = ri->Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT, "" ); + r_forceToneMapMin = ri->Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT, "" ); + r_forceToneMapAvg = ri->Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT, "" ); + r_forceToneMapMax = ri->Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT, "" ); + + r_autoExposure = ri->Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE, "" ); + r_forceAutoExposure = ri->Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT, "" ); + r_forceAutoExposureMin = ri->Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT, "" ); + r_forceAutoExposureMax = ri->Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT, "" ); + + r_cameraExposure = ri->Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT, "" ); + + r_srgb = ri->Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_depthPrepass = ri->Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE, "" ); + r_ssao = ri->Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE, "" ); + + r_normalMapping = ri->Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_deluxeSpecular = ri->Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); + r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_genNormalMaps = ri->Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_forceSun = ri->Cvar_Get( "r_forceSun", "0", CVAR_CHEAT, "" ); + r_forceSunMapLightScale = ri->Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT, "" ); + r_forceSunLightScale = ri->Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT, "" ); + r_forceSunAmbientScale = ri->Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT, "" ); + r_drawSunRays = ri->Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_sunlightMode = ri->Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_sunShadows = ri->Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowFilter = ri->Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowMapSize = ri->Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZNear = ri->Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZFar = ri->Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZBias = ri->Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_ignoreDstAlpha = ri->Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); // // temporary latched variables that can only change over a restart // - r_fullbright = ri->Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT ); - r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH ); - r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH ); - r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH ); + r_fullbright = ri->Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT, "" ); + r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH, "" ); + r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH, "" ); + r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH, "" ); // // archived variables that can change at any time // - r_lodCurveError = ri->Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT ); - r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE ); - r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE ); - r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT ); + r_lodCurveError = ri->Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT, "" ); + r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE, "" ); + r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE, "" ); + r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT, "" ); ri->Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); - r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM ); - r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE ); - r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE ); - r_ignoreGLErrors = ri->Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE ); - r_fastsky = ri->Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE ); - r_inGameVideo = ri->Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE ); - r_drawSun = ri->Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE ); - r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE ); - r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE); - r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE ); - r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE ); - r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE ); - r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE ); - - r_ambientScale = ri->Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT ); - r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT ); - - r_anaglyphMode = ri->Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE); - r_mergeMultidraws = ri->Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE); - r_mergeLeafSurfaces = ri->Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE); + r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM, "" ); + r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE, "" ); + r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE, "" ); + r_ignoreGLErrors = ri->Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE, "" ); + r_fastsky = ri->Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE, "" ); + r_inGameVideo = ri->Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE, "" ); + r_drawSun = ri->Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE, "" ); + r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE, "" ); + r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE, ""); + r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE, "" ); + r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE, "" ); + r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE, "" ); + r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE, "" ); + + r_ambientScale = ri->Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT, "" ); + r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT, "" ); + + r_anaglyphMode = ri->Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE, ""); + r_mergeMultidraws = ri->Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE, ""); + r_mergeLeafSurfaces = ri->Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE, ""); // // temporary variables that can change at any time // - r_showImages = ri->Cvar_Get( "r_showImages", "0", CVAR_TEMP ); - - r_debugLight = ri->Cvar_Get( "r_debuglight", "0", CVAR_TEMP ); - r_debugSort = ri->Cvar_Get( "r_debugSort", "0", CVAR_CHEAT ); - r_printShaders = ri->Cvar_Get( "r_printShaders", "0", 0 ); - r_saveFontData = ri->Cvar_Get( "r_saveFontData", "0", 0 ); - - r_nocurves = ri->Cvar_Get ("r_nocurves", "0", CVAR_CHEAT ); - r_drawworld = ri->Cvar_Get ("r_drawworld", "1", CVAR_CHEAT ); - r_lightmap = ri->Cvar_Get ("r_lightmap", "0", 0 ); - r_portalOnly = ri->Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT ); - - r_flareSize = ri->Cvar_Get ("r_flareSize", "40", CVAR_CHEAT); - r_flareFade = ri->Cvar_Get ("r_flareFade", "7", CVAR_CHEAT); - r_flareCoeff = ri->Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT); - - r_skipBackEnd = ri->Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT); - - r_measureOverdraw = ri->Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT ); - r_lodscale = ri->Cvar_Get( "r_lodscale", "5", CVAR_CHEAT ); - r_norefresh = ri->Cvar_Get ("r_norefresh", "0", CVAR_CHEAT); - r_drawentities = ri->Cvar_Get ("r_drawentities", "1", CVAR_CHEAT ); - r_ignore = ri->Cvar_Get( "r_ignore", "1", CVAR_CHEAT ); - r_nocull = ri->Cvar_Get ("r_nocull", "0", CVAR_CHEAT); - r_novis = ri->Cvar_Get ("r_novis", "0", CVAR_CHEAT); - r_showcluster = ri->Cvar_Get ("r_showcluster", "0", CVAR_CHEAT); - r_speeds = ri->Cvar_Get ("r_speeds", "0", CVAR_CHEAT); - r_verbose = ri->Cvar_Get( "r_verbose", "0", CVAR_CHEAT ); - r_logFile = ri->Cvar_Get( "r_logFile", "0", CVAR_CHEAT ); - r_debugSurface = ri->Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT); - r_nobind = ri->Cvar_Get ("r_nobind", "0", CVAR_CHEAT); - r_showtris = ri->Cvar_Get ("r_showtris", "0", CVAR_CHEAT); - r_showsky = ri->Cvar_Get ("r_showsky", "0", CVAR_CHEAT); - r_shownormals = ri->Cvar_Get ("r_shownormals", "0", CVAR_CHEAT); - r_clear = ri->Cvar_Get ("r_clear", "0", CVAR_CHEAT); - r_offsetFactor = ri->Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT ); - r_offsetUnits = ri->Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT ); - r_drawBuffer = ri->Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT ); - r_lockpvs = ri->Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT); - r_noportals = ri->Cvar_Get ("r_noportals", "0", CVAR_CHEAT); - r_shadows = ri->Cvar_Get( "cg_shadows", "1", 0 ); - - r_marksOnTriangleMeshes = ri->Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE); - - r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE); - r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE); - r_surfaceSprites = ri->Cvar_Get("r_surfaceSprites", "1", CVAR_ARCHIVE); - - r_aspectCorrectFonts = ri->Cvar_Get( "r_aspectCorrectFonts", "0", CVAR_ARCHIVE ); - r_maxpolys = ri->Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0); - r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0 ); + r_showImages = ri->Cvar_Get( "r_showImages", "0", CVAR_TEMP, "" ); + + r_debugLight = ri->Cvar_Get( "r_debuglight", "0", CVAR_TEMP, "" ); + r_debugSort = ri->Cvar_Get( "r_debugSort", "0", CVAR_CHEAT, "" ); + r_printShaders = ri->Cvar_Get( "r_printShaders", "0", 0, "" ); + r_saveFontData = ri->Cvar_Get( "r_saveFontData", "0", 0, "" ); + + r_nocurves = ri->Cvar_Get ("r_nocurves", "0", CVAR_CHEAT, "" ); + r_drawworld = ri->Cvar_Get ("r_drawworld", "1", CVAR_CHEAT, "" ); + r_lightmap = ri->Cvar_Get ("r_lightmap", "0", 0, "" ); + r_portalOnly = ri->Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); + + r_flareSize = ri->Cvar_Get ("r_flareSize", "40", CVAR_CHEAT, ""); + r_flareFade = ri->Cvar_Get ("r_flareFade", "7", CVAR_CHEAT, ""); + r_flareCoeff = ri->Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT, ""); + + r_skipBackEnd = ri->Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT, ""); + + r_measureOverdraw = ri->Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT, "" ); + r_lodscale = ri->Cvar_Get( "r_lodscale", "5", CVAR_CHEAT, "" ); + r_norefresh = ri->Cvar_Get ("r_norefresh", "0", CVAR_CHEAT, ""); + r_drawentities = ri->Cvar_Get ("r_drawentities", "1", CVAR_CHEAT, "" ); + r_ignore = ri->Cvar_Get( "r_ignore", "1", CVAR_CHEAT, "" ); + r_nocull = ri->Cvar_Get ("r_nocull", "0", CVAR_CHEAT, ""); + r_novis = ri->Cvar_Get ("r_novis", "0", CVAR_CHEAT, ""); + r_showcluster = ri->Cvar_Get ("r_showcluster", "0", CVAR_CHEAT, ""); + r_speeds = ri->Cvar_Get ("r_speeds", "0", CVAR_CHEAT, ""); + r_verbose = ri->Cvar_Get( "r_verbose", "0", CVAR_CHEAT, "" ); + r_logFile = ri->Cvar_Get( "r_logFile", "0", CVAR_CHEAT, "" ); + r_debugSurface = ri->Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT, ""); + r_nobind = ri->Cvar_Get ("r_nobind", "0", CVAR_CHEAT, ""); + r_showtris = ri->Cvar_Get ("r_showtris", "0", CVAR_CHEAT, ""); + r_showsky = ri->Cvar_Get ("r_showsky", "0", CVAR_CHEAT, ""); + r_shownormals = ri->Cvar_Get ("r_shownormals", "0", CVAR_CHEAT, ""); + r_clear = ri->Cvar_Get ("r_clear", "0", CVAR_CHEAT, ""); + r_offsetFactor = ri->Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT, "" ); + r_offsetUnits = ri->Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT, "" ); + r_drawBuffer = ri->Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT, "" ); + r_lockpvs = ri->Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT, ""); + r_noportals = ri->Cvar_Get ("r_noportals", "0", CVAR_CHEAT, ""); + r_shadows = ri->Cvar_Get( "cg_shadows", "1", 0, "" ); + + r_marksOnTriangleMeshes = ri->Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE, ""); + + r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE, ""); + r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE, ""); + r_surfaceSprites = ri->Cvar_Get("r_surfaceSprites", "1", CVAR_ARCHIVE, ""); + + r_aspectCorrectFonts = ri->Cvar_Get( "r_aspectCorrectFonts", "0", CVAR_ARCHIVE, "" ); + r_maxpolys = ri->Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0, ""); + r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0, "" ); /* Ghoul2 Insert Start */ #ifdef _DEBUG - r_noPrecacheGLA = ri->Cvar_Get( "r_noPrecacheGLA", "0", CVAR_CHEAT ); + r_noPrecacheGLA = ri->Cvar_Get( "r_noPrecacheGLA", "0", CVAR_CHEAT, "" ); #endif - r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT ); - r_Ghoul2AnimSmooth = ri->Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE ); - r_Ghoul2UnSqashAfterSmooth = ri->Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE ); - broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_ARCHIVE ); - broadsword_kickbones = ri->Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE ); - broadsword_kickorigin = ri->Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE ); - broadsword_dontstopanim = ri->Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE ); - broadsword_waitforshot = ri->Cvar_Get( "broadsword_waitforshot", "0", CVAR_NONE ); - broadsword_playflop = ri->Cvar_Get( "broadsword_playflop", "1", CVAR_NONE ); - broadsword_smallbbox = ri->Cvar_Get( "broadsword_smallbbox", "0", CVAR_NONE ); - broadsword_extra1 = ri->Cvar_Get( "broadsword_extra1", "0", CVAR_NONE ); - broadsword_extra2 = ri->Cvar_Get( "broadsword_extra2", "0", CVAR_NONE ); - broadsword_effcorr = ri->Cvar_Get( "broadsword_effcorr", "1", CVAR_NONE ); - broadsword_ragtobase = ri->Cvar_Get( "broadsword_ragtobase", "2", CVAR_NONE ); - broadsword_dircap = ri->Cvar_Get( "broadsword_dircap", "64", CVAR_NONE ); + r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT, "" ); + r_Ghoul2AnimSmooth = ri->Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE, "" ); + r_Ghoul2UnSqashAfterSmooth = ri->Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE, "" ); + broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_ARCHIVE, "" ); + broadsword_kickbones = ri->Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE, "" ); + broadsword_kickorigin = ri->Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE, "" ); + broadsword_dontstopanim = ri->Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE, "" ); + broadsword_waitforshot = ri->Cvar_Get( "broadsword_waitforshot", "0", CVAR_NONE, "" ); + broadsword_playflop = ri->Cvar_Get( "broadsword_playflop", "1", CVAR_NONE, "" ); + broadsword_smallbbox = ri->Cvar_Get( "broadsword_smallbbox", "0", CVAR_NONE, "" ); + broadsword_extra1 = ri->Cvar_Get( "broadsword_extra1", "0", CVAR_NONE, "" ); + broadsword_extra2 = ri->Cvar_Get( "broadsword_extra2", "0", CVAR_NONE, "" ); + broadsword_effcorr = ri->Cvar_Get( "broadsword_effcorr", "1", CVAR_NONE, "" ); + broadsword_ragtobase = ri->Cvar_Get( "broadsword_ragtobase", "2", CVAR_NONE, "" ); + broadsword_dircap = ri->Cvar_Get( "broadsword_dircap", "64", CVAR_NONE, "" ); /* Ghoul2 Insert End */ - se_language = ri->Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART ); + se_language = ri->Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "" ); for ( size_t i = 0; i < numCommands; i++ ) - ri->Cmd_AddCommand( commands[i].cmd, commands[i].func ); + ri->Cmd_AddCommand( commands[i].cmd, commands[i].func, "" ); } void R_InitQueries(void) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 5c0f37fad8..a563b35128 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -720,7 +720,7 @@ qhandle_t RE_RegisterServerModel( const char *name ) { if (!r_noServerGhoul2) { //keep it from choking when it gets to these checks in the g2 code. Registering all r_ cvars for the server would be a Bad Thing though. - r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", 0); + r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", 0, ""); } if ( !name || !name[0] ) { From 1a4b9f2263c7602443e1b21a74fc8799c4890836 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 2 Apr 2016 18:21:22 +0100 Subject: [PATCH 357/708] Rend2: Introduce render pass To facilitate reduction in state changes, render passes allows draws to be grouped up and then sorted according to a more optimal draw order. Just by collating all draw items into a list and drawing them in a tight loop has decreased frame times, presumably due to reduced CPU instruction cache trashing. This commit also fixes code for cvar descriptitons. --- codemp/rd-rend2/G2_misc.cpp | 4 +- codemp/rd-rend2/tr_backend.cpp | 154 ++++++++++++++++++++++ codemp/rd-rend2/tr_ghoul2.cpp | 1 + codemp/rd-rend2/tr_glsl.cpp | 32 +++-- codemp/rd-rend2/tr_local.h | 67 +++++++++- codemp/rd-rend2/tr_shade.cpp | 231 +++++++++++++-------------------- codemp/rd-rend2/tr_surface.cpp | 9 ++ 7 files changed, 337 insertions(+), 161 deletions(-) diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 6654f3384e..8166c6b6c9 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -542,7 +542,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, if ( cg_g2MarksAllModels == NULL ) { - cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0 ); + cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); } if (cg_g2MarksAllModels == NULL @@ -1493,7 +1493,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli if ( cg_g2MarksAllModels == NULL ) { - cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0 ); + cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); } if (cg_g2MarksAllModels == NULL diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 6c139f8f3d..51fbca6cc7 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA =========================================================================== */ #include "tr_local.h" +#include "tr_allocator.h" #include "glext.h" backEndData_t *backEndData; @@ -595,6 +596,128 @@ void RB_BeginDrawingView (void) { #define MAC_EVENT_PUMP_MSEC 5 +struct Pass +{ + int maxDrawItems; + int numDrawItems; + DrawItem *drawItems; +}; + +static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings ) +{ + for ( size_t i = 0; i < numBindings; ++i ) + { + const SamplerBinding& binding = bindings[i]; + if ( binding.videoMapHandle ) + { + int oldtmu = glState.currenttmu; + GL_SelectTexture(binding.slot); + ri->CIN_RunCinematic(binding.videoMapHandle - 1); + ri->CIN_UploadCinematic(binding.videoMapHandle - 1); + GL_SelectTexture(oldtmu); + } + else + { + GL_BindToTMU(binding.image, binding.slot); + } + } +} + +static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems ) +{ + for ( int i = 0; i < numDrawItems; ++i ) + { + const DrawItem& drawItem = drawItems[i]; + + int q3CullType = drawItem.cullType & 0xffff; + int glCullType = (drawItem.cullType >> 16) & 0xfff; + if ( glState.faceCulling != q3CullType ) + { + glState.faceCulling = q3CullType; + switch ( glCullType ) + { + case GL_NONE: + { + qglDisable(GL_CULL_FACE); + break; + } + + case GL_FRONT: + { + qglEnable(GL_CULL_FACE); + qglCullFace(GL_FRONT); + break; + } + + case GL_BACK: + { + qglEnable(GL_CULL_FACE); + qglCullFace(GL_BACK); + break; + } + } + } + + + GL_State(drawItem.stateBits); + R_BindIBO(drawItem.ibo); + GLSL_BindProgram(drawItem.program); + + // FIXME: There was a reason I didn't have const on attributes. Can't remember at the moment + // what the reason was though. + GL_VertexAttribPointers(drawItem.numAttributes, drawItem.attributes); + RB_BindTextures(drawItem.numSamplerBindings, drawItem.samplerBindings); + + GLSL_SetUniforms(drawItem.program, drawItem.uniformData); + + switch ( drawItem.draw.type ) + { + case DRAW_COMMAND_MULTI_INDEXED: + { + GL_MultiDrawIndexed(drawItem.draw.primitiveType, + drawItem.draw.params.multiIndexed.numIndices, + drawItem.draw.params.multiIndexed.firstIndices, + drawItem.draw.params.multiIndexed.numDraws); + break; + } + + case DRAW_COMMAND_INDEXED: + { + GL_DrawIndexed(drawItem.draw.primitiveType, + drawItem.draw.params.indexed.numIndices, + drawItem.draw.params.indexed.firstIndex, + drawItem.draw.numInstances, 0); + break; + } + + default: + { + assert(!"Invalid or unhandled draw type"); + break; + } + } + } +} + +void RB_AddDrawItem( Pass *pass, const DrawItem& drawItem ) +{ + // There will be no pass if we are drawing a 2D object. + if ( pass ) + { + if ( pass->numDrawItems >= pass->maxDrawItems ) + { + assert(!"Ran out of space for pass"); + return; + } + + memcpy(pass->drawItems + pass->numDrawItems++, &drawItem, sizeof(*pass->drawItems)); + } + else + { + RB_DrawItems(1, &drawItem); + } +} + /* ================== RB_RenderDrawSurfList @@ -617,6 +740,14 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { float depth[2]; + void *allocMark = backEndData->perFrameMemory->Mark(); + + assert(backEndData->currentPass == nullptr); + backEndData->currentPass = ojkAlloc(*backEndData->perFrameMemory); + *backEndData->currentPass = {}; + backEndData->currentPass->maxDrawItems = numDrawSurfs * 2; + backEndData->currentPass->drawItems = ojkAllocArray( + *backEndData->perFrameMemory, backEndData->currentPass->maxDrawItems); // save original time for entity shader offsets originalTime = backEnd.refdef.floatTime; @@ -799,6 +930,12 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { RB_EndSurface(); } + qglDepthRange(0.0f, 1.0f); + RB_DrawItems(backEndData->currentPass->numDrawItems, backEndData->currentPass->drawItems); + + backEndData->perFrameMemory->ResetTo(allocMark); + backEndData->currentPass = nullptr; + if (inQuery) { qglEndQuery(GL_SAMPLES_PASSED); } @@ -2026,6 +2163,23 @@ static const void *RB_EndTimedBlock( const void *data ) } +static void RB_Begin2DPass() +{ + if ( backEndData->currentPass ) + { + return; + } + + *backEndData->currentPass = {}; + backEndData->currentPass = ojkAllocArray(*backEndData->perFrameMemory, 8000); +} + +static void RB_End2DPass() +{ + +} + + /* ==================== RB_ExecuteRenderCommands diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index f1120c129a..446c52f823 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3476,6 +3476,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) R_BindIBO(surface->ibo); tess.useInternalVBO = qfalse; + tess.externalIBO = surface->ibo; tess.numIndexes += surface->numIndexes; tess.numVertexes += surface->numVertexes; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6da373acc6..badc8fa077 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2199,7 +2199,6 @@ void GLSL_BindNullProgram(void) } } - void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArraysOut) { VertexArraysProperties vertexArraysLocal; @@ -2224,25 +2223,14 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA CalculateVertexArraysFromVBO(stateBits, glState.currentVBO, vertexArrays); } - GLSL_VertexAttribPointers(stateBits, vertexArrays); + GLSL_VertexAttribPointers(vertexArrays); } -void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays) +void GL_VertexArraysToAttribs( vertexAttribute_t *attribs, + size_t attribsCount, const VertexArraysProperties *vertexArrays ) { - VBO_t *vbo = glState.currentVBO; - - if(!vbo) - { - ri->Error(ERR_FATAL, "GL_VertexAttribPointers: no VBO bound"); - return; - } - - // don't just call LogComment, or we will get a call to va() every frame! - if (r_logFile->integer) - { - GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); - } + assert(attribsCount == ATTR_INDEX_MAX); static const struct { @@ -2269,7 +2257,6 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal2 }; - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { int attributeIndex = vertexArrays->enabledAttributes[i]; @@ -2285,7 +2272,18 @@ void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties attrib.offset = vertexArrays->offsets[attributeIndex]; attrib.stepRate = 0; } +} + +void GLSL_VertexAttribPointers(const VertexArraysProperties *vertexArrays) +{ + // don't just call LogComment, or we will get a call to va() every frame! + if (r_logFile->integer) + { + GLimp_LogComment("--- GL_VertexAttribPointers() ---\n"); + } + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index cde0455688..f8361437c8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2701,6 +2701,7 @@ struct shaderCommands_s IBO_t *ibo; void *vboData; // If immutable buffers void *iboData; // are available + IBO_t *externalIBO; qboolean useInternalVBO; int internalVBOWriteOffset; int internalVBOCommitOffset; @@ -2759,8 +2760,6 @@ void RB_CheckOverflow( int verts, int indexes ); void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ); void RB_StageIteratorGeneric( void ); void RB_StageIteratorSky( void ); -void RB_StageIteratorVertexLitTexture( void ); -void RB_StageIteratorLightmappedMultitexture( void ); void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, float color[4] ); void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], float s1, float t1, float s2, float t2 ); @@ -2926,7 +2925,9 @@ int GLSL_BeginLoadGPUShaders(void); void GLSL_EndLoadGPUShaders( int startTime ); void GLSL_ShutdownGPUShaders(void); void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArrays); -void GLSL_VertexAttribPointers(uint32_t attribBits, const VertexArraysProperties *vertexArrays); +void GLSL_VertexAttribPointers(const VertexArraysProperties *vertexArrays); +void GL_VertexArraysToAttribs( vertexAttribute_t *attribs, + size_t attribsCount, const VertexArraysProperties *vertexArrays ); void GLSL_BindProgram(shaderProgram_t * program); void GLSL_BindNullProgram(void); @@ -3280,11 +3281,13 @@ struct gpuFrame_t #define MAX_FRAMES (2) #define PER_FRAME_MEMORY_BYtES (128 * 1024 * 1024) class Allocator; +struct Pass; typedef struct backEndData_s { unsigned realFrameNumber; gpuFrame_t frames[MAX_FRAMES]; gpuFrame_t *currentFrame; Allocator *perFrameMemory; + Pass *currentPass; drawSurf_t drawSurfs[MAX_DRAWSURFS]; dlight_t dlights[MAX_DLIGHTS]; @@ -3295,6 +3298,9 @@ typedef struct backEndData_s { renderCommandList_t commands; } backEndData_t; +struct DrawItem; +void RB_AddDrawItem( Pass *pass, const DrawItem& drawItem ); + extern int max_polys; extern int max_polyverts; @@ -3357,4 +3363,59 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ); class Allocator; GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ); +struct SamplerBinding +{ + image_t *image; + qhandle_t videoMapHandle; + uint8_t slot; +}; + +enum DrawCommandType +{ + DRAW_COMMAND_MULTI_INDEXED, + DRAW_COMMAND_INDEXED, + DRAW_COMMAND_ARRAYS +}; + +struct DrawCommand +{ + DrawCommandType type; + GLenum primitiveType; + int numInstances; + + union DrawParams + { + struct MultiDrawIndexed + { + int numDraws; + GLsizei *numIndices; + glIndex_t **firstIndices; + } multiIndexed; + + struct DrawIndexed + { + GLsizei numIndices; + glIndex_t firstIndex; + } indexed; + } params; +}; + +struct DrawItem +{ + uint32_t stateBits; + uint32_t cullType; // this is stupid. hi bits = GL cull type, lo bits = Q3 cull type + IBO_t *ibo; + shaderProgram_t *program; + + uint32_t numAttributes; + vertexAttribute_t *attributes; + + uint32_t numSamplerBindings; + SamplerBinding *samplerBindings; + + UniformData *uniformData; + + DrawCommand draw; +}; + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index e10cbf899d..7d0a687dad 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -205,6 +205,7 @@ void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { tess.xstages = state->stages; tess.numPasses = state->numUnfoggedPasses; tess.currentStageIteratorFunc = state->optimalStageIteratorFunc; + tess.externalIBO = nullptr; tess.useInternalVBO = qtrue; tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; @@ -1196,121 +1197,6 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -struct SamplerBinding -{ - image_t *image; - qhandle_t videoMapHandle; - uint8_t slot; -}; - -enum DrawCommandType -{ - DRAW_COMMAND_MULTI_INDEXED, - DRAW_COMMAND_INDEXED, - DRAW_COMMAND_ARRAYS -}; - -struct DrawCommand -{ - DrawCommandType type; - GLenum primitiveType; - int numInstances; - - union DrawParams - { - struct MultiDrawIndexed - { - int numDraws; - GLsizei *numIndices; - glIndex_t **firstIndices; - } multiIndexed; - - struct DrawIndexed - { - GLsizei numIndices; - glIndex_t firstIndex; - } indexed; - } params; -}; - -struct DrawItem -{ - uint32_t stateBits; - IBO_t *ibo; - shaderProgram_t *program; - - uint32_t numAttributes; - vertexAttribute_t *attributes; - - uint32_t numSamplerBindings; - SamplerBinding *samplerBindings; - - UniformData *uniformData; - - DrawCommand draw; -}; - -static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings ) -{ - for ( size_t i = 0; i < numBindings; ++i ) - { - const SamplerBinding& binding = bindings[i]; - if ( binding.videoMapHandle ) - { - int oldtmu = glState.currenttmu; - GL_SelectTexture(binding.slot); - ri->CIN_RunCinematic(binding.videoMapHandle - 1); - ri->CIN_UploadCinematic(binding.videoMapHandle - 1); - GL_SelectTexture(oldtmu); - } - else - { - GL_BindToTMU(binding.image, binding.slot); - } - } -} - -static void RB_Draw( const DrawItem& drawItem ) -{ - GL_State(drawItem.stateBits); - //R_BindIBO(drawItem.ibo); - GLSL_BindProgram(drawItem.program); - - // FIXME: There was a reason I didn't have const on attributes. Can't remember at the moment - // what the reason was though. - //GL_VertexAttribPointers(drawItem.numAttributes, (vertexAttribute_t *)drawItem.attributes); - RB_BindTextures(drawItem.numSamplerBindings, drawItem.samplerBindings); - - GLSL_SetUniforms(drawItem.program, drawItem.uniformData); - - switch ( drawItem.draw.type ) - { - case DRAW_COMMAND_MULTI_INDEXED: - { - GL_MultiDrawIndexed(drawItem.draw.primitiveType, - drawItem.draw.params.multiIndexed.numIndices, - drawItem.draw.params.multiIndexed.firstIndices, - drawItem.draw.params.multiIndexed.numDraws); - break; - } - - case DRAW_COMMAND_INDEXED: - { - GL_DrawIndexed(drawItem.draw.primitiveType, - drawItem.draw.params.indexed.numIndices, - drawItem.draw.params.indexed.firstIndex, - drawItem.draw.numInstances, 0); - break; - } - - default: - { - assert(!"Invalid or unhandled draw type"); - break; - } - } -} - class UniformDataWriter { public: @@ -1795,8 +1681,36 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); + GLenum cullType = GL_NONE; + + if ( !backEnd.projection2D ) + { + if ( input->shader->cullType != CT_TWO_SIDED ) + { + bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); + if ( backEnd.viewParms.isMirror ) + { + cullFront = !cullFront; + } + + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + { + cullFront = !cullFront; + } + + cullType = (cullFront ? GL_FRONT : GL_BACK); + } + } + + // Pack the cull types + cullType = (cullType << 16) | (input->shader->cullType & 0xfff); + + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) { + // FIXME: This seems a bit weird. Allocator uniformDataAlloc(backEndData->perFrameMemory->Alloc(1024), 1024, 1); Allocator samplerBindingsAlloc(backEndData->perFrameMemory->Alloc(128), 128, 1); @@ -2109,14 +2023,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays DrawItem item = {}; item.stateBits = stateBits; + item.cullType = cullType; item.program = sp; - item.ibo = input->ibo; + item.ibo = input->externalIBO ? input->externalIBO : input->ibo; item.numAttributes = vertexArrays->numVertexArrays; item.attributes = ojkAllocArray( *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, glState.currentVaoAttribs, - sizeof(*item.attributes)*vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); item.uniformData = uniformDataWriter.Finish(); // FIXME: This is a bit ugly with the casting @@ -2126,10 +2040,29 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( input->multiDrawPrimitives ) { - item.draw.type = DRAW_COMMAND_MULTI_INDEXED; - item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; - item.draw.params.multiIndexed.firstIndices = input->multiDrawFirstIndex; - item.draw.params.multiIndexed.numIndices = input->multiDrawNumIndexes; + if ( input->multiDrawPrimitives == 1 ) + { + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; + } + else + { + item.draw.type = DRAW_COMMAND_MULTI_INDEXED; + item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; + + item.draw.params.multiIndexed.firstIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.firstIndices, + input->multiDrawFirstIndex, + sizeof(glIndex_t *) * input->multiDrawPrimitives); + + item.draw.params.multiIndexed.numIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.numIndices, + input->multiDrawNumIndexes, + sizeof(GLsizei *) * input->multiDrawPrimitives); + } } else { @@ -2141,7 +2074,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.draw.params.indexed.numIndices = input->numIndexes; } - RB_Draw(item); + RB_AddDrawItem(backEndData->currentPass, item); // allow skipping out to show just lightmaps during development if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) @@ -2247,27 +2180,25 @@ void RB_StageIteratorGeneric( void ) backEnd.pc.c_staticVboDraws++; } + + // - // set face culling appropriately + // vertex arrays // - if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + VertexArraysProperties vertexArrays; + if ( tess.useInternalVBO ) { - if (input->shader->cullType == CT_TWO_SIDED) - GL_Cull( CT_TWO_SIDED ); - else if (input->shader->cullType == CT_FRONT_SIDED) - GL_Cull( CT_BACK_SIDED ); - else - GL_Cull( CT_FRONT_SIDED ); - + CalculateVertexArraysProperties(vertexAttribs, &vertexArrays); + for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) + { + int attributeIndex = vertexArrays.enabledAttributes[i]; + vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; + } } else - GL_Cull( input->shader->cullType ); - - // - // set vertex attribs and pointers - // - VertexArraysProperties vertexArrays; - GLSL_VertexAttribsState(vertexAttribs, &vertexArrays); + { + CalculateVertexArraysFromVBO(vertexAttribs, glState.currentVBO, &vertexArrays); + } if (backEnd.depthFill) { @@ -2283,6 +2214,25 @@ void RB_StageIteratorGeneric( void ) // if ( input->shader->sort == SS_OPAQUE ) { + // + // set face culling appropriately + // + if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + { + if (input->shader->cullType == CT_TWO_SIDED) + GL_Cull( CT_TWO_SIDED ); + else if (input->shader->cullType == CT_FRONT_SIDED) + GL_Cull( CT_BACK_SIDED ); + else + GL_Cull( CT_FRONT_SIDED ); + + } + else + GL_Cull( input->shader->cullType ); + + vertexAttribute_t attribs[ATTR_INDEX_MAX]; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), &vertexArrays); + GL_VertexAttribPointers(vertexArrays.numVertexArrays, attribs); RB_RenderShadowmap( input ); } } @@ -2293,6 +2243,7 @@ void RB_StageIteratorGeneric( void ) // RB_IterateStagesGeneric( input, &vertexArrays ); +#if 0 // don't do this for now while I get draw sorting working :) // // pshadows! // @@ -2330,6 +2281,7 @@ void RB_StageIteratorGeneric( void ) if ( tess.fogNum && tess.shader->fogPass ) { RB_FogPass(); } +#endif } RB_CommitInternalBufferData(); @@ -2416,6 +2368,7 @@ void RB_EndSurface( void ) { tess.numVertexes = 0; tess.firstIndex = 0; tess.multiDrawPrimitives = 0; + tess.externalIBO = nullptr; GLimp_LogComment( "----------\n" ); } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index eedd6ab728..5163966d7f 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -78,7 +78,14 @@ void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) } if (vbo != tess.vbo && ibo != tess.ibo) + { tess.useInternalVBO = qfalse; + } + + if ( ibo != tess.ibo ) + { + tess.externalIBO = ibo; + } } @@ -2073,6 +2080,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) R_BindIBO(surface->ibo); tess.useInternalVBO = qfalse; + tess.externalIBO = surface->ibo; tess.numIndexes += surface->numIndexes; tess.numVertexes += surface->numVerts; @@ -2159,6 +2167,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); R_BindIBO(surf->ibo); + tess.externalIBO = surf->ibo; qglDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, surf->numSprites); } From fcc236e3712e7451b2140ce3dcd93c8be3eb8fa8 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 2 Apr 2016 19:38:03 +0100 Subject: [PATCH 358/708] Rend2: Sort draw items by state This gives a further improvement on scenes with large number of draw calls, e.g. atlantica. --- codemp/rd-rend2/tr_backend.cpp | 48 ++++++++++++++++++++++++++-------- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shade.cpp | 14 +++++++++- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 51fbca6cc7..35d1e2df9f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" #include "tr_allocator.h" #include "glext.h" +#include backEndData_t *backEndData; backEndState_t backEnd; @@ -601,6 +602,7 @@ struct Pass int maxDrawItems; int numDrawItems; DrawItem *drawItems; + uint32_t *sortKeys; }; static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings ) @@ -623,11 +625,11 @@ static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings } } -static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems ) +static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t *drawOrder ) { for ( int i = 0; i < numDrawItems; ++i ) { - const DrawItem& drawItem = drawItems[i]; + const DrawItem& drawItem = drawItems[drawOrder[i]]; int q3CullType = drawItem.cullType & 0xffff; int glCullType = (drawItem.cullType >> 16) & 0xfff; @@ -699,7 +701,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems ) } } -void RB_AddDrawItem( Pass *pass, const DrawItem& drawItem ) +void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ) { // There will be no pass if we are drawing a 2D object. if ( pass ) @@ -710,14 +712,27 @@ void RB_AddDrawItem( Pass *pass, const DrawItem& drawItem ) return; } - memcpy(pass->drawItems + pass->numDrawItems++, &drawItem, sizeof(*pass->drawItems)); + pass->sortKeys[pass->numDrawItems] = sortKey; + memcpy(pass->drawItems + pass->numDrawItems, &drawItem, sizeof(*pass->drawItems)); + ++pass->numDrawItems; } else { - RB_DrawItems(1, &drawItem); + uint32_t drawOrder[] = {0}; + RB_DrawItems(1, &drawItem, drawOrder); } } +static Pass *RB_CreatePass( Allocator& allocator, int capacity ) +{ + Pass *pass = ojkAlloc(*backEndData->perFrameMemory); + *pass = {}; + pass->maxDrawItems = capacity; + pass->drawItems = ojkAllocArray(allocator, pass->maxDrawItems); + pass->sortKeys = ojkAllocArray(allocator, pass->maxDrawItems); + return pass; +} + /* ================== RB_RenderDrawSurfList @@ -743,11 +758,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { void *allocMark = backEndData->perFrameMemory->Mark(); assert(backEndData->currentPass == nullptr); - backEndData->currentPass = ojkAlloc(*backEndData->perFrameMemory); - *backEndData->currentPass = {}; - backEndData->currentPass->maxDrawItems = numDrawSurfs * 2; - backEndData->currentPass->drawItems = ojkAllocArray( - *backEndData->perFrameMemory, backEndData->currentPass->maxDrawItems); + backEndData->currentPass = RB_CreatePass(*backEndData->perFrameMemory, numDrawSurfs * 2); // save original time for entity shader offsets originalTime = backEnd.refdef.floatTime; @@ -930,8 +941,23 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { RB_EndSurface(); } + // FIXME: This should be pass of the draw item state qglDepthRange(0.0f, 1.0f); - RB_DrawItems(backEndData->currentPass->numDrawItems, backEndData->currentPass->drawItems); + + uint32_t *drawOrder = ojkAllocArray( + *backEndData->perFrameMemory, backEndData->currentPass->numDrawItems); + + uint32_t numDrawItems = backEndData->currentPass->numDrawItems; + for ( uint32_t i = 0; i < numDrawItems; ++i ) + drawOrder[i] = i; + + uint32_t *sortKeys = backEndData->currentPass->sortKeys; + std::sort(drawOrder, drawOrder + numDrawItems, [sortKeys]( uint32_t a, uint32_t b ) + { + return sortKeys[a] < sortKeys[b]; + }); + + RB_DrawItems(backEndData->currentPass->numDrawItems, backEndData->currentPass->drawItems, drawOrder); backEndData->perFrameMemory->ResetTo(allocMark); backEndData->currentPass = nullptr; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index f8361437c8..ad01297667 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3299,7 +3299,7 @@ typedef struct backEndData_s { } backEndData_t; struct DrawItem; -void RB_AddDrawItem( Pass *pass, const DrawItem& drawItem ); +void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ); extern int max_polys; extern int max_polyverts; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 7d0a687dad..5603f50291 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1666,6 +1666,17 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag return result; } +static uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) +{ + uint32_t key = 0; + uintptr_t shaderProgram = (uintptr_t)item.program; + + key |= (layer & 0xf) << 28; + key |= (stage & 0xf) << 24; + key |= shaderProgram & 0x00ffffff; + return key; +} + static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int stage; @@ -2074,7 +2085,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.draw.params.indexed.numIndices = input->numIndexes; } - RB_AddDrawItem(backEndData->currentPass, item); + uint32_t key = RB_CreateSortKey(item, stage, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); // allow skipping out to show just lightmaps during development if ( r_lightmap->integer && ( pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap ) ) From 560c596f5bc25a86010b24d68ffaf6a80b05f8cb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 2 Apr 2016 21:21:39 +0100 Subject: [PATCH 359/708] Rend2: Move depth range into DrawItem --- codemp/rd-rend2/tr_backend.cpp | 30 ++++++++++++++++++++++-------- codemp/rd-rend2/tr_init.cpp | 1 + codemp/rd-rend2/tr_local.h | 7 +++++++ codemp/rd-rend2/tr_shade.cpp | 2 ++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 35d1e2df9f..d39af8c130 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -151,6 +151,17 @@ void GL_Cull( int cullType ) { } } +void GL_DepthRange( float max ) +{ + if ( glState.maxDepthRange == max ) + { + return; + } + + qglDepthRange(0.0f, max); + glState.maxDepthRange = max; +} + /* ** GL_State ** @@ -660,8 +671,8 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t } } - GL_State(drawItem.stateBits); + GL_DepthRange(drawItem.maxDepthRange); R_BindIBO(drawItem.ibo); GLSL_BindProgram(drawItem.program); @@ -889,7 +900,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if( !sunflare ) - qglDepthRange( 0.0f, 1.0f ); + { + tess.maxDepthRange = 1.0f; + } break; @@ -904,7 +917,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if ( !oldDepthRange ) - qglDepthRange( 0.0f, 0.3f ); + { + tess.maxDepthRange = 0.3f; + } break; @@ -919,7 +934,9 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { } if ( !oldDepthRange ) - qglDepthRange( 0.0f, 0.0f ); + { + tess.maxDepthRange = 0.0f; + } break; } @@ -941,9 +958,6 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { RB_EndSurface(); } - // FIXME: This should be pass of the draw item state - qglDepthRange(0.0f, 1.0f); - uint32_t *drawOrder = ojkAllocArray( *backEndData->perFrameMemory, backEndData->currentPass->numDrawItems); @@ -973,7 +987,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetModelviewMatrix( backEnd.viewParms.world.modelViewMatrix ); // Restore depth range for subsequent rendering - qglDepthRange( 0.0f, 1.0f ); + GL_DepthRange(1.0f); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 72054c134a..5ef223c87f 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1116,6 +1116,7 @@ void GL_SetDefaultState( void ) // make sure our GL state vector is set correctly // glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE; + glState.maxDepthRange = 1.0f; qglUseProgram(0); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ad01297667..e9fbbc6ba4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1981,6 +1981,7 @@ typedef struct glstate_s { int currenttmu; int texEnv[2]; int faceCulling; + float maxDepthRange; uint32_t glStateBits; uint32_t vertexAttribsState; vertexAttribute_t currentVaoAttribs[ATTR_INDEX_MAX]; @@ -2574,6 +2575,7 @@ void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); //void GL_TexEnv( int env ); void GL_Cull( int cullType ); +void GL_DepthRange( float max ); void GL_PolygonOffset( qboolean enabled ); void GL_VertexAttribPointers(size_t numAttributes, vertexAttribute_t *attributes); @@ -2708,6 +2710,9 @@ struct shaderCommands_s int internalIBOWriteOffset; int internalIBOCommitOffset; + float minDepthRange; + float maxDepthRange; + stageVars_t svars QALIGN(16); //color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); @@ -3404,6 +3409,8 @@ struct DrawItem { uint32_t stateBits; uint32_t cullType; // this is stupid. hi bits = GL cull type, lo bits = Q3 cull type + float maxDepthRange; + IBO_t *ibo; shaderProgram_t *program; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 5603f50291..f012c28c3d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -207,6 +207,7 @@ void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { tess.currentStageIteratorFunc = state->optimalStageIteratorFunc; tess.externalIBO = nullptr; tess.useInternalVBO = qtrue; + tess.maxDepthRange = 1.0f; tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) { @@ -2036,6 +2037,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.stateBits = stateBits; item.cullType = cullType; item.program = sp; + item.maxDepthRange = input->maxDepthRange; item.ibo = input->externalIBO ? input->externalIBO : input->ibo; item.numAttributes = vertexArrays->numVertexArrays; From ec6aa45890de020b8ee04f6ba386ad146d7f3291 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 9 Apr 2016 13:44:36 +0100 Subject: [PATCH 360/708] Rend2: Add shadow fill into new render pass Things are a bit buggy, will fix later. e.g. shadows aren't being rendered properly. Probably something to do with the face culling being set wrong. --- codemp/rd-rend2/glsl/shadowfill.glsl | 52 ---------- codemp/rd-rend2/tr_backend.cpp | 8 +- codemp/rd-rend2/tr_shade.cpp | 146 +++++++++++++++------------ 3 files changed, 84 insertions(+), 122 deletions(-) diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index dd8d425475..d5b7be1475 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -3,27 +3,17 @@ in vec3 attr_Position; in vec3 attr_Normal; in vec4 attr_TexCoord0; -//#if defined(USE_VERTEX_ANIMATION) in vec3 attr_Position2; in vec3 attr_Normal2; -//#endif -//#if defined(USE_DEFORM_VERTEXES) uniform int u_DeformType; uniform int u_DeformFunc; uniform float u_DeformParams[7]; -//#endif uniform float u_Time; uniform mat4 u_ModelViewProjectionMatrix; -uniform mat4 u_ModelMatrix; - -//#if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; -//#endif - -out vec3 var_Position; float GetNoiseValue( float x, float y, float z, float t ) { @@ -168,54 +158,12 @@ void main() normal = normalize(normal - vec3(0.5)); position = DeformPosition(position, normal, attr_TexCoord0.st); - normal = DeformNormal( position, normal ); - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz; } /*[Fragment]*/ -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; - -in vec3 var_Position; - out vec4 out_Color; - void main() { -#if defined(USE_DEPTH) - float depth = length(u_LightOrigin.xyz - var_Position) / u_LightRadius; - #if 0 - // 32 bit precision - const vec4 bitSh = vec4( 256 * 256 * 256, 256 * 256, 256, 1); - const vec4 bitMsk = vec4( 0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); - - vec4 comp; - comp = depth * bitSh; - comp.xyz = fract(comp.xyz); - comp -= comp.xxyz * bitMsk; - out_Color = comp; - #endif - - #if 1 - // 24 bit precision - const vec3 bitSh = vec3( 256 * 256, 256, 1); - const vec3 bitMsk = vec3( 0, 1.0 / 256.0, 1.0 / 256.0); - - vec3 comp; - comp = depth * bitSh; - comp.xy = fract(comp.xy); - comp -= comp.xxy * bitMsk; - out_Color = vec4(comp, 1.0); - #endif - - #if 0 - // 8 bit precision - out_Color = vec4(depth, depth, depth, 1); - #endif -#else out_Color = vec4(0, 0, 0, 1); -#endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index d39af8c130..fc1f52beb3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -642,12 +642,10 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t { const DrawItem& drawItem = drawItems[drawOrder[i]]; - int q3CullType = drawItem.cullType & 0xffff; - int glCullType = (drawItem.cullType >> 16) & 0xfff; - if ( glState.faceCulling != q3CullType ) + if ( glState.faceCulling != drawItem.cullType ) { - glState.faceCulling = q3CullType; - switch ( glCullType ) + glState.faceCulling = drawItem.cullType; + switch ( drawItem.cullType ) { case GL_NONE: { diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f012c28c3d..3a72a17dff 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1714,9 +1714,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } } - // Pack the cull types - cullType = (cullType << 16) | (input->shader->cullType & 0xfff); - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); @@ -2102,7 +2099,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } -static void RB_RenderShadowmap( shaderCommands_t *input ) +static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { deform_t deformType; genFunc_t deformGen; @@ -2110,53 +2107,97 @@ static void RB_RenderShadowmap( shaderCommands_t *input ) ComputeDeformValues(&deformType, &deformGen, deformParams); + GLenum cullType = GL_NONE; + if ( !backEnd.projection2D ) { - shaderProgram_t *sp = &tr.shadowmapShader; - - vec4_t vector; + if ( input->shader->cullType != CT_TWO_SIDED ) + { + bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); + if ( backEnd.viewParms.isMirror ) + { + cullFront = !cullFront; + } - GLSL_BindProgram(sp); + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + { + cullFront = !cullFront; + } - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + // NOTE: This is intentionally backwards. Shadow maps cull front faces + // when the forward pass would cull the back face. + cullType = (cullFront ? GL_BACK : GL_FRONT); + } + } - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + Allocator uniformDataAlloc(backEndData->perFrameMemory->Alloc(128), 128, 1); + UniformDataWriter uniformDataWriter(uniformDataAlloc); + + shaderProgram_t *sp = &tr.shadowmapShader; + uniformDataWriter.Start(sp); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); + uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); + + DrawItem item = {}; + item.cullType = cullType; + item.program = sp; + item.maxDepthRange = input->maxDepthRange; + item.ibo = input->externalIBO ? input->externalIBO : input->ibo; + + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); + + item.uniformData = uniformDataWriter.Finish(); + item.draw.primitiveType = GL_TRIANGLES; + item.draw.numInstances = 1; - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) + if ( input->multiDrawPrimitives ) + { + if ( input->multiDrawPrimitives == 1 ) { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; } - - VectorCopy(backEnd.viewParms.ori.origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, backEnd.viewParms.zFar); - - GL_State( 0 ); - - // - // do multitexture - // - //if ( pStage->glslShaderGroup ) + else { - // - // draw - // + item.draw.type = DRAW_COMMAND_MULTI_INDEXED; + item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; - if (input->multiDrawPrimitives) - { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); - } + item.draw.params.multiIndexed.firstIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.firstIndices, + input->multiDrawFirstIndex, + sizeof(glIndex_t *) * input->multiDrawPrimitives); + + item.draw.params.multiIndexed.numIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.numIndices, + input->multiDrawNumIndexes, + sizeof(GLsizei *) * input->multiDrawPrimitives); } } + else + { + int offset = input->firstIndex * sizeof(glIndex_t) + + (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = offset; + item.draw.params.indexed.numIndices = input->numIndexes; + } + + // FIXME: Use depth to object + uint32_t key = 0; + RB_AddDrawItem(backEndData->currentPass, key, item); } /* @@ -2223,38 +2264,13 @@ void RB_StageIteratorGeneric( void ) } else if (backEnd.viewParms.flags & VPF_SHADOWMAP) { - // - // render shadowmap if in shadowmap mode - // if ( input->shader->sort == SS_OPAQUE ) { - // - // set face culling appropriately - // - if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW)) - { - if (input->shader->cullType == CT_TWO_SIDED) - GL_Cull( CT_TWO_SIDED ); - else if (input->shader->cullType == CT_FRONT_SIDED) - GL_Cull( CT_BACK_SIDED ); - else - GL_Cull( CT_FRONT_SIDED ); - - } - else - GL_Cull( input->shader->cullType ); - - vertexAttribute_t attribs[ATTR_INDEX_MAX]; - GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), &vertexArrays); - GL_VertexAttribPointers(vertexArrays.numVertexArrays, attribs); - RB_RenderShadowmap( input ); + RB_RenderShadowmap(input, &vertexArrays); } } else { - // - // call shader function - // RB_IterateStagesGeneric( input, &vertexArrays ); #if 0 // don't do this for now while I get draw sorting working :) From c3c5b4b4b3688d0812eb41b58b855ef9732bdc15 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 11 Apr 2016 19:33:51 +0100 Subject: [PATCH 361/708] Rend2: Fix per-frame memory usage On large scenes, it was likely that the per-frame memory heap would be overrun, causing indeterminate draw calls to be made. This commit fixes the issue. Also reduced per-frame memory heap size from 128MB to 32MB. --- codemp/rd-rend2/tr_allocator.cpp | 5 ++ codemp/rd-rend2/tr_allocator.h | 1 + codemp/rd-rend2/tr_init.cpp | 4 +- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shade.cpp | 79 ++++++++++++++++---------------- 5 files changed, 48 insertions(+), 43 deletions(-) diff --git a/codemp/rd-rend2/tr_allocator.cpp b/codemp/rd-rend2/tr_allocator.cpp index 29eb1529f8..bde46d276d 100644 --- a/codemp/rd-rend2/tr_allocator.cpp +++ b/codemp/rd-rend2/tr_allocator.cpp @@ -44,6 +44,11 @@ Allocator::~Allocator() } } +void *Allocator::Base() const +{ + return alignedBase; +} + void *Allocator::Alloc( size_t allocSize ) { if ( (size_t)((char *)end - (char *)mark) < allocSize ) diff --git a/codemp/rd-rend2/tr_allocator.h b/codemp/rd-rend2/tr_allocator.h index 4ed9e116c9..abdf00a65a 100644 --- a/codemp/rd-rend2/tr_allocator.h +++ b/codemp/rd-rend2/tr_allocator.h @@ -30,6 +30,7 @@ class Allocator Allocator( const Allocator& ) = delete; Allocator& operator=( const Allocator& ) = delete; + void *Base() const; void *Alloc( size_t allocSize ); void *Mark() const; void Reset(); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5ef223c87f..c6279fb7a7 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1689,7 +1689,7 @@ void R_Init( void ) { sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts + sizeof(Allocator) + - PER_FRAME_MEMORY_BYtES, + PER_FRAME_MEMORY_BYTES, h_low); backEndData = (backEndData_t *)ptr; @@ -1701,7 +1701,7 @@ void R_Init( void ) { backEndData->polyVerts = (polyVert_t *)ptr; ptr += sizeof(*backEndData->polyVerts) * max_polyverts; - backEndData->perFrameMemory = new(ptr) Allocator(ptr + sizeof(*backEndData->perFrameMemory), PER_FRAME_MEMORY_BYtES); + backEndData->perFrameMemory = new(ptr) Allocator(ptr + sizeof(*backEndData->perFrameMemory), PER_FRAME_MEMORY_BYTES); R_InitNextFrame(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e9fbbc6ba4..b98b789d09 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3284,7 +3284,7 @@ struct gpuFrame_t // all of the information needed by the back end must be // contained in a backEndData_t. #define MAX_FRAMES (2) -#define PER_FRAME_MEMORY_BYtES (128 * 1024 * 1024) +#define PER_FRAME_MEMORY_BYTES (32 * 1024 * 1024) class Allocator; struct Pass; typedef struct backEndData_s { diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 3a72a17dff..88e8f81f4c 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1201,11 +1201,10 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) class UniformDataWriter { public: - UniformDataWriter( Allocator& allocator ) - : allocator(allocator) - , uniformDataBase(static_cast(allocator.Mark())) - , failed(false) + UniformDataWriter() + : failed(false) , shaderProgram(nullptr) + , scratch(scratchBuffer, sizeof(scratchBuffer), 1) { } @@ -1222,7 +1221,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(int)); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(int)); if ( !memory ) { failed = true; @@ -1249,7 +1248,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*count); if ( !memory ) { failed = true; @@ -1269,7 +1268,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); if ( !memory ) { failed = true; @@ -1289,7 +1288,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); if ( !memory ) { failed = true; @@ -1309,7 +1308,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); if ( !memory ) { failed = true; @@ -1329,7 +1328,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*12*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*12*count); if ( !memory ) { failed = true; @@ -1349,7 +1348,7 @@ class UniformDataWriter if ( shaderProgram->uniforms[uniform] == -1 ) return *this; - void *memory = allocator.Alloc(sizeof(UniformData) + sizeof(float)*16*count); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*16*count); if ( !memory ) { failed = true; @@ -1364,9 +1363,9 @@ class UniformDataWriter return *this; } - UniformData *Finish() + UniformData *Finish( Allocator& destHeap ) { - UniformData *endSentinel = ojkAlloc(allocator); + UniformData *endSentinel = ojkAlloc(scratch); if ( failed || !endSentinel ) { return nullptr; @@ -1374,27 +1373,32 @@ class UniformDataWriter endSentinel->index = UNIFORM_COUNT; - UniformData *result = uniformDataBase; - uniformDataBase = static_cast(allocator.Mark()); + int uniformDataSize = (char *)scratch.Mark() - (char *)scratch.Base(); + + // Copy scratch buffer to per-frame heap + void *finalMemory = destHeap.Alloc(uniformDataSize); + UniformData *result = static_cast(finalMemory); + memcpy(finalMemory, scratch.Base(), uniformDataSize); + scratch.Reset(); + failed = false; shaderProgram = nullptr; + return result; } private: - Allocator& allocator; - UniformData *uniformDataBase; bool failed; shaderProgram_t *shaderProgram; + char scratchBuffer[2048]; + Allocator scratch; }; class SamplerBindingsWriter { public: - SamplerBindingsWriter( Allocator& allocator ) - : allocator(allocator) - , bindingsBase(static_cast(allocator.Mark())) - , failed(false) + SamplerBindingsWriter() + : failed(false) , count(0) { } @@ -1404,7 +1408,7 @@ class SamplerBindingsWriter SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ) { - SamplerBinding *binding = ojkAlloc(allocator); + SamplerBinding *binding = &scratch[count]; if ( !binding ) { failed = true; @@ -1425,7 +1429,7 @@ class SamplerBindingsWriter if ( bundle->isVideoMap ) { - SamplerBinding *binding = ojkAlloc(allocator); + SamplerBinding *binding = &scratch[count]; if ( !binding ) { failed = true; @@ -1470,29 +1474,28 @@ class SamplerBindingsWriter return AddStaticImage(bundle->image[ index ], unit); } - SamplerBinding *Finish( int* numBindings ) + SamplerBinding *Finish( Allocator& destHeap, int* numBindings ) { if ( failed ) { return nullptr; } - SamplerBinding *result = bindingsBase; + SamplerBinding *result = ojkAllocArray(destHeap, count); if ( numBindings ) { *numBindings = count; } - bindingsBase = static_cast(allocator.Mark()); + memcpy(result, scratch, sizeof(SamplerBinding)*count); failed = false; count = 0; return result; } private: - Allocator& allocator; - SamplerBinding *bindingsBase; + SamplerBinding scratch[32]; bool failed; int count; }; @@ -1717,15 +1720,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; + for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) { - // FIXME: This seems a bit weird. - Allocator uniformDataAlloc(backEndData->perFrameMemory->Alloc(1024), 1024, 1); - Allocator samplerBindingsAlloc(backEndData->perFrameMemory->Alloc(128), 128, 1); - - UniformDataWriter uniformDataWriter(uniformDataAlloc); - SamplerBindingsWriter samplerBindingsWriter(samplerBindingsAlloc); - shaderStage_t *pStage = input->xstages[stage]; shaderProgram_t *sp; vec4_t texMatrix; @@ -2042,9 +2041,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays *backEndData->perFrameMemory, vertexArrays->numVertexArrays); memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - item.uniformData = uniformDataWriter.Finish(); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); // FIXME: This is a bit ugly with the casting - item.samplerBindings = samplerBindingsWriter.Finish((int *)&item.numSamplerBindings); + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); item.draw.primitiveType = GL_TRIANGLES; item.draw.numInstances = 1; @@ -2132,8 +2132,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - Allocator uniformDataAlloc(backEndData->perFrameMemory->Alloc(128), 128, 1); - UniformDataWriter uniformDataWriter(uniformDataAlloc); + UniformDataWriter uniformDataWriter; shaderProgram_t *sp = &tr.shadowmapShader; uniformDataWriter.Start(sp); @@ -2155,7 +2154,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope *backEndData->perFrameMemory, vertexArrays->numVertexArrays); memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - item.uniformData = uniformDataWriter.Finish(); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); item.draw.primitiveType = GL_TRIANGLES; item.draw.numInstances = 1; From f3783a1b49a1aee31a81e8edf6ea49d355aa386a Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 16 Apr 2016 14:14:43 +0100 Subject: [PATCH 362/708] Rend2: Fix corrupted rendering following 1a4b9f2 After render passes were introduced, the rendering was deferred until the render pass was drawn. However, the dynamic vertex data relied on draws being issued immediately after the data had been updated. When the draws were deferred, the vertex data may be discarded or overwritten when the dynamic vertex buffer was full so some renders would be corrupted by drawing with incorrect vertex data. The solution to this is to have per-frame vertex buffers. The vertex buffer is cleared at the start of frame (when we know that the draws have been completed) so vertex data needs to be overwritten. --- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 40 +++++++++++- codemp/rd-rend2/tr_local.h | 18 +++--- codemp/rd-rend2/tr_shade.cpp | 12 ++-- codemp/rd-rend2/tr_surface.cpp | 8 ++- codemp/rd-rend2/tr_vbo.cpp | 107 +++++++++------------------------ 6 files changed, 90 insertions(+), 97 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index badc8fa077..a2ff0bc180 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2215,7 +2215,7 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) { int attributeIndex = vertexArrays->enabledAttributes[i]; - vertexArrays->offsets[attributeIndex] += tess.internalVBOCommitOffset; + vertexArrays->offsets[attributeIndex] += backEndData->currentFrame->dynamicVboCommitOffset; } } else diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c6279fb7a7..596aa13c78 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; +static size_t FRAME_VERTEX_BUFFER_SIZE = 8*1024*1024; +static size_t FRAME_INDEX_BUFFER_SIZE = 2*1024*1024; glconfig_t glConfig; glconfigExt_t glConfigExt; @@ -1593,6 +1595,7 @@ static void R_InitBackEndFrameData() for ( int i = 0; i < MAX_FRAMES; i++ ) { gpuFrame_t *frame = backEndData->frames + i; + const GLbitfield mapBits = GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT; frame->ubo = ubos[i]; frame->uboWriteOffset = 0; @@ -1602,6 +1605,32 @@ static void R_InitBackEndFrameData() qglBufferData(GL_UNIFORM_BUFFER, FRAME_UNIFORM_BUFFER_SIZE, nullptr, GL_DYNAMIC_DRAW); + frame->dynamicVbo = R_CreateVBO(nullptr, FRAME_VERTEX_BUFFER_SIZE, + VBO_USAGE_DYNAMIC); + frame->dynamicVboCommitOffset = 0; + frame->dynamicVboWriteOffset = 0; + + frame->dynamicIbo = R_CreateIBO(nullptr, FRAME_INDEX_BUFFER_SIZE, + VBO_USAGE_DYNAMIC); + frame->dynamicIboCommitOffset = 0; + frame->dynamicIboWriteOffset = 0; + + if ( glRefConfig.immutableBuffers ) + { + R_BindVBO(frame->dynamicVbo); + frame->dynamicVboMemory = qglMapBufferRange(GL_ARRAY_BUFFER, 0, + frame->dynamicVbo->vertexesSize, mapBits); + + R_BindIBO(frame->dynamicIbo); + frame->dynamicIboMemory = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, + frame->dynamicIbo->indexesSize, mapBits); + } + else + { + frame->dynamicVboMemory = nullptr; + frame->dynamicIboMemory = nullptr; + } + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) { gpuTimer_t *timer = frame->timers + j; @@ -1623,6 +1652,14 @@ static void R_ShutdownBackEndFrameData() qglDeleteBuffers(1, &frame->ubo); + if ( glRefConfig.immutableBuffers ) + { + R_BindVBO(frame->dynamicVbo); + R_BindIBO(frame->dynamicIbo); + qglUnmapBuffer(GL_ARRAY_BUFFER); + qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + } + for ( int j = 0; j < MAX_GPU_TIMERS; j++ ) { gpuTimer_t *timer = frame->timers + j; @@ -1714,6 +1751,8 @@ void R_Init( void ) { InitOpenGL(); + R_InitVBOs(); + R_InitBackEndFrameData(); R_InitImages(); @@ -1721,7 +1760,6 @@ void R_Init( void ) { int shadersStartTime = GLSL_BeginLoadGPUShaders(); - R_InitVBOs(); R_InitShaders (qfalse); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b98b789d09..0064ccf867 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2699,16 +2699,8 @@ struct shaderCommands_s uint32_t lightdir[SHADER_MAX_VERTEXES] QALIGN(16); //int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); - VBO_t *vbo; - IBO_t *ibo; - void *vboData; // If immutable buffers - void *iboData; // are available IBO_t *externalIBO; qboolean useInternalVBO; - int internalVBOWriteOffset; - int internalVBOCommitOffset; - int internalIBOWriteOffset; - int internalIBOCommitOffset; float minDepthRange; float maxDepthRange; @@ -3274,6 +3266,16 @@ struct gpuFrame_t GLuint ubo; size_t uboWriteOffset; + VBO_t *dynamicVbo; + void *dynamicVboMemory; + size_t dynamicVboWriteOffset; + size_t dynamicVboCommitOffset; + + IBO_t *dynamicIbo; + void *dynamicIboMemory; + size_t dynamicIboWriteOffset; + size_t dynamicIboCommitOffset; + int numTimers; int numTimedBlocks; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 88e8f81f4c..58f96127f3 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -46,7 +46,7 @@ R_DrawElements void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex, glIndex_t maxIndex ) { int offset = firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); GL_DrawIndexed(GL_TRIANGLES, numIndexes, offset, 1, 0); } @@ -2034,7 +2034,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.cullType = cullType; item.program = sp; item.maxDepthRange = input->maxDepthRange; - item.ibo = input->externalIBO ? input->externalIBO : input->ibo; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; item.attributes = ojkAllocArray( @@ -2077,7 +2077,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays else { int offset = input->firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); item.draw.type = DRAW_COMMAND_INDEXED; item.draw.params.indexed.firstIndex = offset; @@ -2147,7 +2147,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope item.cullType = cullType; item.program = sp; item.maxDepthRange = input->maxDepthRange; - item.ibo = input->externalIBO ? input->externalIBO : input->ibo; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; item.attributes = ojkAllocArray( @@ -2187,7 +2187,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope else { int offset = input->firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? tess.internalIBOCommitOffset : 0); + (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); item.draw.type = DRAW_COMMAND_INDEXED; item.draw.params.indexed.firstIndex = offset; @@ -2246,7 +2246,7 @@ void RB_StageIteratorGeneric( void ) for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) { int attributeIndex = vertexArrays.enabledAttributes[i]; - vertexArrays.offsets[attributeIndex] += tess.internalVBOCommitOffset; + vertexArrays.offsets[attributeIndex] += backEndData->currentFrame->dynamicVboCommitOffset; } } else diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 5163966d7f..fbf38aca8b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -77,12 +77,13 @@ void RB_CheckVBOandIBO(VBO_t *vbo, IBO_t *ibo) R_BindIBO(ibo); } - if (vbo != tess.vbo && ibo != tess.ibo) + if (vbo != backEndData->currentFrame->dynamicVbo && + ibo != backEndData->currentFrame->dynamicIbo) { tess.useInternalVBO = qfalse; } - if ( ibo != tess.ibo ) + if ( ibo != backEndData->currentFrame->dynamicIbo ) { tess.externalIBO = ibo; } @@ -385,8 +386,9 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn uint32_t *tangent; glIndex_t *outIndex; float *color; + gpuFrame_t *currentFrame = backEndData->currentFrame; - RB_CheckVBOandIBO(tess.vbo, tess.ibo); + RB_CheckVBOandIBO(currentFrame->dynamicVbo, currentFrame->dynamicIbo); RB_CHECKOVERFLOW( numVerts, numIndexes ); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 9b6a61c663..625f96025a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -309,9 +309,6 @@ R_InitVBOs */ void R_InitVBOs(void) { - int dataSize; - int offset; - ri->Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is @@ -322,53 +319,6 @@ void R_InitVBOs(void) tr.numVBOs = 0; tr.numIBOs = 0; - dataSize = 12 * 1024 * 1024; - tess.vbo = R_CreateVBO(NULL, dataSize, VBO_USAGE_DYNAMIC); - - offset = 0; - - tess.vbo->offsets[ATTR_INDEX_POSITION] = offset; offset += sizeof(tess.xyz[0]) * SHADER_MAX_VERTEXES; - tess.vbo->offsets[ATTR_INDEX_NORMAL] = offset; offset += sizeof(tess.normal[0]) * SHADER_MAX_VERTEXES; - // these next two are actually interleaved - tess.vbo->offsets[ATTR_INDEX_TEXCOORD0] = offset; offset += sizeof(tess.texCoords[0][0]) * 2 * SHADER_MAX_VERTEXES; - tess.vbo->offsets[ATTR_INDEX_TANGENT] = offset; offset += sizeof(tess.tangent[0]) * SHADER_MAX_VERTEXES; - - tess.vbo->offsets[ATTR_INDEX_COLOR] = offset; offset += sizeof(tess.vertexColors[0]) * SHADER_MAX_VERTEXES; - tess.vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offset; - - tess.vbo->strides[ATTR_INDEX_POSITION] = sizeof(tess.xyz[0]); - tess.vbo->strides[ATTR_INDEX_NORMAL] = sizeof(tess.normal[0]); - tess.vbo->strides[ATTR_INDEX_TANGENT] = sizeof(tess.tangent[0]); - tess.vbo->strides[ATTR_INDEX_COLOR] = sizeof(tess.vertexColors[0]); - tess.vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; - tess.vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); - - tess.vbo->sizes[ATTR_INDEX_POSITION] = sizeof(tess.xyz[0]); - tess.vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(tess.normal[0]); - tess.vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(tess.tangent[0]); - tess.vbo->sizes[ATTR_INDEX_COLOR] = sizeof(tess.vertexColors[0]); - tess.vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(tess.texCoords[0][0]) * 2; - tess.vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(tess.lightdir[0]); - - dataSize = 4 * 1024 * 1024; - tess.ibo = R_CreateIBO(NULL, dataSize, VBO_USAGE_DYNAMIC); - - if ( glRefConfig.immutableBuffers ) - { - R_BindVBO(tess.vbo); - GL_CheckErrors(); - - R_BindIBO(tess.ibo); - GL_CheckErrors(); - - tess.vboData = qglMapBufferRange(GL_ARRAY_BUFFER, 0, tess.vbo->vertexesSize, GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT); - GL_CheckErrors(); - - tess.iboData = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, 0, tess.ibo->indexesSize, GL_MAP_WRITE_BIT | GL_MAP_COHERENT_BIT | GL_MAP_PERSISTENT_BIT); - GL_CheckErrors(); - - } - R_BindNullVBO(); R_BindNullIBO(); @@ -384,14 +334,6 @@ void R_ShutdownVBOs(void) { ri->Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); - if ( glRefConfig.immutableBuffers ) - { - R_BindVBO(tess.vbo); - R_BindIBO(tess.ibo); - qglUnmapBuffer(GL_ARRAY_BUFFER); - qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); - } - R_BindNullVBO(); R_BindNullIBO(); @@ -531,6 +473,8 @@ Update the default VBO to replace the client side vertex arrays */ void RB_UpdateVBOs(unsigned int attribBits) { + gpuFrame_t *currentFrame = backEndData->currentFrame; + GLimp_LogComment("--- RB_UpdateVBOs ---\n"); backEnd.pc.c_dynamicVboDraws++; @@ -538,6 +482,7 @@ void RB_UpdateVBOs(unsigned int attribBits) // update the default VBO if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) { + VBO_t *frameVbo = currentFrame->dynamicVbo; GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; VertexArraysProperties vertexArrays = {}; CalculateVertexArraysProperties(attribBits, &vertexArrays); @@ -545,24 +490,24 @@ void RB_UpdateVBOs(unsigned int attribBits) int totalVertexDataSize = tess.numVertexes * vertexArrays.vertexDataSize; backEnd.pc.c_dynamicVboTotalSize += totalVertexDataSize; - if ( (tess.internalVBOWriteOffset + totalVertexDataSize) > tess.vbo->vertexesSize ) + if ( (currentFrame->dynamicVboWriteOffset + totalVertexDataSize) > frameVbo->vertexesSize ) { - tess.internalVBOCommitOffset = 0; - tess.internalVBOWriteOffset = 0; - mapFlags |= GL_MAP_INVALIDATE_BUFFER_BIT; + // TODO: Eh...resize? + assert(!"This shouldn't happen"); + return; } - R_BindVBO(tess.vbo); + R_BindVBO(frameVbo); - // orphan old buffer so we don't stall on it void *dstPtr; if ( glRefConfig.immutableBuffers ) { - dstPtr = (byte *)tess.vboData + tess.internalVBOWriteOffset; + dstPtr = (byte *)currentFrame->dynamicVboMemory + currentFrame->dynamicVboWriteOffset; } else { - dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, tess.internalVBOWriteOffset, totalVertexDataSize, mapFlags); + dstPtr = qglMapBufferRange(GL_ARRAY_BUFFER, currentFrame->dynamicVboWriteOffset, + totalVertexDataSize, mapFlags); } // Interleave the data @@ -572,8 +517,10 @@ void RB_UpdateVBOs(unsigned int attribBits) for ( int j = 0; j < vertexArrays.numVertexArrays; j++ ) { int attributeIndex = vertexArrays.enabledAttributes[j]; + void *stream = vertexArrays.streams[attributeIndex]; + size_t vertexSize = vertexArrays.sizes[attributeIndex]; - memcpy(writePtr, (byte *)vertexArrays.streams[attributeIndex] + i * vertexArrays.sizes[attributeIndex], vertexArrays.sizes[attributeIndex]); + memcpy(writePtr, (byte *)stream + i * vertexSize, vertexArrays.sizes[attributeIndex]); writePtr = (byte *)writePtr + vertexArrays.sizes[attributeIndex]; } } @@ -583,32 +530,34 @@ void RB_UpdateVBOs(unsigned int attribBits) qglUnmapBuffer(GL_ARRAY_BUFFER); } - tess.internalVBOWriteOffset += totalVertexDataSize; + currentFrame->dynamicVboWriteOffset += totalVertexDataSize; } // update the default IBO if(tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES) { + IBO_t *frameIbo = currentFrame->dynamicIbo; GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; int totalIndexDataSize = tess.numIndexes * sizeof(tess.indexes[0]); - R_BindIBO(tess.ibo); + R_BindIBO(frameIbo); - if ( (tess.internalIBOWriteOffset + totalIndexDataSize) > tess.ibo->indexesSize ) + if ( (currentFrame->dynamicIboWriteOffset + totalIndexDataSize) > frameIbo->indexesSize ) { - tess.internalIBOCommitOffset = 0; - tess.internalIBOWriteOffset = 0; - mapFlags |= GL_MAP_INVALIDATE_BUFFER_BIT; + // TODO: Resize the buffer? + assert(!"This shouldn't happen"); + return; } void *dst; if ( glRefConfig.immutableBuffers ) { - dst = (byte *)tess.iboData + tess.internalIBOWriteOffset; + dst = (byte *)currentFrame->dynamicIboMemory + currentFrame->dynamicIboWriteOffset; } else { - dst = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, tess.internalIBOCommitOffset, totalIndexDataSize, mapFlags); + dst = qglMapBufferRange(GL_ELEMENT_ARRAY_BUFFER, currentFrame->dynamicIboWriteOffset, + totalIndexDataSize, mapFlags); } memcpy(dst, tess.indexes, totalIndexDataSize); @@ -618,14 +567,16 @@ void RB_UpdateVBOs(unsigned int attribBits) qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); } - tess.internalIBOWriteOffset += totalIndexDataSize; + currentFrame->dynamicIboWriteOffset += totalIndexDataSize; } } void RB_CommitInternalBufferData() { - tess.internalIBOCommitOffset = tess.internalIBOWriteOffset; - tess.internalVBOCommitOffset = tess.internalVBOWriteOffset; + gpuFrame_t *currentFrame = backEndData->currentFrame; + + currentFrame->dynamicIboCommitOffset = currentFrame->dynamicIboWriteOffset; + currentFrame->dynamicVboCommitOffset = currentFrame->dynamicVboWriteOffset; } void RB_UpdateUniformBlock(uniformBlock_t block, void *data) From 2a5886a5e495c4192039518c349d73338f6b78b7 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 17 Apr 2016 10:26:27 +0100 Subject: [PATCH 363/708] Rend2: Add missing changes for previous commit --- codemp/rd-rend2/tr_cmds.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 7ebc03a82d..f620a7cf07 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -506,10 +506,16 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { qglDeleteSync( sync ); thisFrame->sync = NULL; - // Set the frame uniform buffer + // Resets resources qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo); thisFrame->uboWriteOffset = 0; + thisFrame->dynamicIboCommitOffset = 0; + thisFrame->dynamicIboWriteOffset = 0; + + thisFrame->dynamicVboCommitOffset = 0; + thisFrame->dynamicVboWriteOffset = 0; + backEndData->perFrameMemory->Reset(); } From c327b16fbfb17e95ce3c8121c3da4539abee5568 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 22 Apr 2016 21:50:21 +0100 Subject: [PATCH 364/708] Rend2: Add dlights back in --- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 1096 +++++++++++++++++--------------- 4 files changed, 582 insertions(+), 520 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index fc1f52beb3..4eb89836df 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -794,7 +794,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &postRender ); fogNum = drawSurf->fogIndex; entityNum = drawSurf->entityNum; - dlighted = drawSurf->lit; + dlighted = drawSurf->dlightBits; if ( shader == oldShader && fogNum == oldFogNum && diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 0064ccf867..fb7cd072d3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1438,7 +1438,7 @@ compared quickly during the qsorting process typedef struct drawSurf_s { uint32_t sort; // bit combination for fast compares int entityNum; - qboolean lit; + uint32_t dlightBits; surfaceType_t *surface; // any of surface*_t int fogIndex; } drawSurf_t; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1339b16d56..485170c63b 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1793,7 +1793,7 @@ void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, in surf->sort = R_CreateSortKey(shader->sortedIndex, cubemap, postRender); surf->entityNum = entityNum; - surf->lit = (qboolean)dlightMap; + surf->dlightBits = dlightMap; surf->surface = surface; surf->fogIndex = fogIndex; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 58f96127f3..8fa0c74b54 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -833,672 +833,753 @@ static void CaptureDrawData(shaderCommands_t *input, shaderStage_t *stage, int g } } -static void ForwardDlight( void ) { - int l; - //vec3_t origin; - //float scale; - float radius; - - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - - shaderCommands_t *input = &tess; - shaderStage_t *pStage = tess.xstages[0]; - - if ( !backEnd.refdef.num_dlights ) { - return; +class UniformDataWriter +{ +public: + UniformDataWriter() + : failed(false) + , shaderProgram(nullptr) + , scratch(scratchBuffer, sizeof(scratchBuffer), 1) + { } - - ComputeDeformValues(&deformType, &deformGen, deformParams); - - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - dlight_t *dl; - shaderProgram_t *sp; - vec4_t vector; - vec4_t texMatrix; - vec4_t texOffTurb; + UniformDataWriter( const UniformDataWriter& ) = delete; + UniformDataWriter& operator=( const UniformDataWriter& ) = delete; - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definately doesn't have any of this light - } + void Start( shaderProgram_t *sp ) + { + shaderProgram = sp; + } - dl = &backEnd.refdef.dlights[l]; - //VectorCopy( dl->transformed, origin ); - radius = dl->radius; - //scale = 1.0f / radius; + UniformDataWriter& SetUniformInt( uniform_t uniform, int value ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - //if (pStage->glslShaderGroup == tr.lightallShader) + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(int)); + if ( !memory ) { - int index = pStage->glslShaderIndex; - - index &= ~LIGHTDEF_LIGHTTYPE_MASK; - index |= LIGHTDEF_USE_LIGHT_VECTOR; - - sp = &tr.lightallShader[index]; + failed = true; + return *this; } - backEnd.pc.c_lightallDraws++; + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = 1; - GLSL_BindProgram(sp); + int *data = reinterpret_cast(header + 1); + *data = value; - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); + return *this; + } - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + UniformDataWriter& SetUniformFloat( uniform_t uniform, float value ) + { + return SetUniformFloat(uniform, &value, 1); + } - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) + UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*count); + if ( !memory ) { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + failed = true; + return *this; } - if ( input->fogNum ) { - vec4_t fogColorMask; + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(float) * count); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + return *this; + } - ComputeFogColorMask(pStage, fogColorMask); + UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - GLSL_SetUniformVec4(sp, UNIFORM_FOGCOLORMASK, fogColorMask); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); + if ( !memory ) + { + failed = true; + return *this; } - { - vec4_t baseColor; - vec4_t vertColor; + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec2_t) * count); - ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE, NULL, NULL); + return *this; + } - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, baseColor); - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, vertColor); - } + UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - if (pStage->alphaGen == AGEN_PORTAL) + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); + if ( !memory ) { - GLSL_SetUniformFloat(sp, UNIFORM_PORTALRANGE, tess.shader->portalRange); + failed = true; + return *this; } - GLSL_SetUniformInt(sp, UNIFORM_COLORGEN, pStage->rgbGen); - GLSL_SetUniformInt(sp, UNIFORM_ALPHAGEN, pStage->alphaGen); - - GLSL_SetUniformVec3(sp, UNIFORM_DIRECTEDLIGHT, dl->color); - - VectorSet(vector, 0, 0, 0); - GLSL_SetUniformVec3(sp, UNIFORM_AMBIENTLIGHT, vector); + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec3_t) * count); - VectorCopy(dl->origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + return *this; + } - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); + UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale); - GLSL_SetUniformVec4(sp, UNIFORM_SPECULARSCALE, pStage->specularScale); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec4_t) * count); - if (pStage->bundle[TB_DIFFUSEMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + return *this; + } - // bind textures that are sampled and used in the glsl shader, and - // bind whiteImage to textures that are sampled but zeroed in the glsl shader - // - // alternatives: - // - use the last bound texture - // -> costs more to sample a higher res texture then throw out the result - // - disable texture sampling in glsl shader with #ifdefs, as before - // -> increases the number of shaders that must be compiled - // + UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - if (pStage->bundle[TB_NORMALMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); - else if (r_normalMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_NORMALMAP ); + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*12*count); + if ( !memory ) + { + failed = true; + return *this; + } - if (pStage->bundle[TB_SPECULARMAP].image[0]) - R_BindAnimatedImageToTMU( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); - else if (r_specularMapping->integer) - GL_BindToTMU( tr.whiteImage, TB_SPECULARMAP ); + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 12 * count); - { - vec4_t enableTextures; + return *this; + } - VectorSet4(enableTextures, 0.0f, 0.0f, 0.0f, 0.0f); - GLSL_SetUniformVec4(sp, UNIFORM_ENABLETEXTURES, enableTextures); - } + UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ) + { + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; - if (r_dlightMode->integer >= 2) + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*16*count); + if ( !memory ) { - GL_SelectTexture(TB_SHADOWMAP); - GL_Bind(tr.shadowCubemaps[l]); - GL_SelectTexture(0); + failed = true; + return *this; } - ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, texMatrix); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - - GLSL_SetUniformInt(sp, UNIFORM_TCGEN0, pStage->bundle[0].tcGen); - GLSL_SetUniformInt(sp, UNIFORM_TCGEN1, pStage->bundle[1].tcGen); - - // - // draw - // + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 16 * count); - CaptureDrawData(input, pStage, 0, 0); + return *this; + } - if (input->multiDrawPrimitives) - { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else + UniformData *Finish( Allocator& destHeap ) + { + UniformData *endSentinel = ojkAlloc(scratch); + if ( failed || !endSentinel ) { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + return nullptr; } - backEnd.pc.c_totalIndexes += tess.numIndexes; - backEnd.pc.c_dlightIndexes += tess.numIndexes; - backEnd.pc.c_dlightVertexes += tess.numVertexes; - - RB_BinTriangleCounts(); - } -} + endSentinel->index = UNIFORM_COUNT; + int uniformDataSize = (char *)scratch.Mark() - (char *)scratch.Base(); -static void ProjectPshadowVBOGLSL( void ) { - int l; - vec3_t origin; - float radius; + // Copy scratch buffer to per-frame heap + void *finalMemory = destHeap.Alloc(uniformDataSize); + UniformData *result = static_cast(finalMemory); + memcpy(finalMemory, scratch.Base(), uniformDataSize); + scratch.Reset(); - shaderCommands_t *input = &tess; + failed = false; + shaderProgram = nullptr; - if ( !backEnd.refdef.num_pshadows ) { - return; + return result; } - for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { - pshadow_t *ps; - shaderProgram_t *sp; - vec4_t vector; - - if ( !( tess.pshadowBits & ( 1 << l ) ) ) { - continue; // this surface definately doesn't have any of this shadow - } +private: + bool failed; + shaderProgram_t *shaderProgram; + char scratchBuffer[2048]; + Allocator scratch; +}; - ps = &backEnd.refdef.pshadows[l]; - VectorCopy( ps->lightOrigin, origin ); - radius = ps->lightRadius; +class SamplerBindingsWriter +{ +public: + SamplerBindingsWriter() + : failed(false) + , count(0) + { + } - sp = &tr.pshadowShader; + SamplerBindingsWriter( const SamplerBindingsWriter& ) = delete; + SamplerBindingsWriter& operator=( const SamplerBindingsWriter& ) = delete; - GLSL_BindProgram(sp); + SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ) + { + SamplerBinding *binding = &scratch[count]; + if ( !binding ) + { + failed = true; + return *this; + } - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + binding->image = image; + binding->slot = unit; + binding->videoMapHandle = NULL_HANDLE; + ++count; - VectorCopy(origin, vector); - vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + return *this; + } - VectorScale(ps->lightViewAxis[0], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTFORWARD, vector); + SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ) + { + int index; - VectorScale(ps->lightViewAxis[1], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTRIGHT, vector); + if ( bundle->isVideoMap ) + { + SamplerBinding *binding = &scratch[count]; + if ( !binding ) + { + failed = true; + return *this; + } - VectorScale(ps->lightViewAxis[2], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTUP, vector); + binding->image = nullptr; + binding->slot = unit; + binding->videoMapHandle = bundle->videoMapHandle + 1; + ++count; - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + return *this; + } - GL_BindToTMU( tr.pshadowMaps[l], TB_DIFFUSEMAP ); + if ( bundle->numImageAnimations <= 1 ) + { + return AddStaticImage(bundle->image[0], unit); + } - // - // draw - // + if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) + { + index = backEnd.currentEntity->e.skinNum; + } + else + { + // it is necessary to do this messy calc to make sure animations line up + // exactly with waveforms of the same frequency + index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); + index = Q_max(0, index >> FUNCTABLE_SIZE2); + } - if (input->multiDrawPrimitives) + if ( bundle->oneShotAnimMap ) { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + index = Q_min(index, bundle->numImageAnimations - 1); } else { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); + // loop + index %= bundle->numImageAnimations; } - backEnd.pc.c_totalIndexes += tess.numIndexes; - //backEnd.pc.c_dlightIndexes += tess.numIndexes; - RB_BinTriangleCounts(); + return AddStaticImage(bundle->image[ index ], unit); } -} - - - -/* -=================== -RB_FogPass - -Blends a fog texture on top of everything else -=================== -*/ -static void RB_FogPass( void ) { - fog_t *fog; - vec4_t color; - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - shaderProgram_t *sp; - - deform_t deformType; - genFunc_t deformGen; - vec5_t deformParams; - - ComputeDeformValues(&deformType, &deformGen, deformParams); + SamplerBinding *Finish( Allocator& destHeap, int* numBindings ) { - int index = 0; + if ( failed ) + { + return nullptr; + } - if (deformGen != DGEN_NONE) - index |= FOGDEF_USE_DEFORM_VERTEXES; + SamplerBinding *result = ojkAllocArray(destHeap, count); - if (glState.vertexAnimation) - index |= FOGDEF_USE_VERTEX_ANIMATION; + if ( numBindings ) + { + *numBindings = count; + } - if (glState.skeletalAnimation) - index |= FOGDEF_USE_SKELETAL_ANIMATION; - - sp = &tr.fogShader[index]; + memcpy(result, scratch, sizeof(SamplerBinding)*count); + failed = false; + count = 0; + return result; } - backEnd.pc.c_fogDraws++; - - GLSL_BindProgram(sp); - - fog = tr.world->fogs + tess.fogNum; +private: + SamplerBinding scratch[32]; + bool failed; + int count; +}; - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); +static uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) +{ + uint32_t key = 0; + uintptr_t shaderProgram = (uintptr_t)item.program; - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) - { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } + assert(stage < 16); + layer = Q_min(layer, 15); - color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; - color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; - color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; - color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + key |= (layer & 0xf) << 28; + key |= (stage & 0xf) << 24; + key |= shaderProgram & 0x00ffffff; + return key; +} - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); +static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { + int l; + //vec3_t origin; + //float scale; + float radius; - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + deform_t deformType; + genFunc_t deformGen; + float deformParams[7]; + + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; - if ( tess.shader->fogPass == FP_EQUAL ) { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); - } else { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); - } + shaderCommands_t *input = &tess; + shaderStage_t *pStage = tess.xstages[0]; - if (tess.multiDrawPrimitives) - { - shaderCommands_t *input = &tess; - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + if ( !backEnd.refdef.num_dlights ) { + return; } -} + + ComputeDeformValues(&deformType, &deformGen, deformParams); + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); -static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) -{ - unsigned int vertexAttribs = shader->vertexAttribs; + GLenum cullType = GL_NONE; - if(glState.vertexAnimation) + if ( !backEnd.projection2D ) { - vertexAttribs &= ~ATTR_COLOR; - vertexAttribs |= ATTR_POSITION2; - if (vertexAttribs & ATTR_NORMAL) + if ( input->shader->cullType != CT_TWO_SIDED ) { - vertexAttribs |= ATTR_NORMAL2; - vertexAttribs |= ATTR_TANGENT2; + bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); + if ( backEnd.viewParms.isMirror ) + { + cullFront = !cullFront; + } + + if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) + { + cullFront = !cullFront; + } + + cullType = (cullFront ? GL_FRONT : GL_BACK); } } - if (glState.skeletalAnimation) - { - vertexAttribs |= ATTR_BONE_WEIGHTS; - vertexAttribs |= ATTR_BONE_INDEXES; - } + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - return vertexAttribs; -} + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; -class UniformDataWriter -{ -public: - UniformDataWriter() - : failed(false) - , shaderProgram(nullptr) - , scratch(scratchBuffer, sizeof(scratchBuffer), 1) - { - } + for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { + dlight_t *dl; + shaderProgram_t *sp; + vec4_t vector; + vec4_t texMatrix; + vec4_t texOffTurb; - UniformDataWriter( const UniformDataWriter& ) = delete; - UniformDataWriter& operator=( const UniformDataWriter& ) = delete; + if ( !( tess.dlightBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this light + } - void Start( shaderProgram_t *sp ) - { - shaderProgram = sp; - } + dl = &backEnd.refdef.dlights[l]; + //VectorCopy( dl->transformed, origin ); + radius = dl->radius; + //scale = 1.0f / radius; - UniformDataWriter& SetUniformInt( uniform_t uniform, int value ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; + //if (pStage->glslShaderGroup == tr.lightallShader) + { + int index = pStage->glslShaderIndex; - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(int)); - if ( !memory ) + index &= ~LIGHTDEF_LIGHTTYPE_MASK; + index |= LIGHTDEF_USE_LIGHT_VECTOR; + + sp = &tr.lightallShader[index]; + } + + backEnd.pc.c_lightallDraws++; + + uniformDataWriter.Start(sp); + + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + uniformDataWriter.SetUniformVec3(UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); + + uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) { - failed = true; - return *this; + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); + uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = 1; + if ( input->fogNum ) { + vec4_t fogColorMask; - int *data = reinterpret_cast(header + 1); - *data = value; + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); - return *this; - } + ComputeFogColorMask(pStage, fogColorMask); - UniformDataWriter& SetUniformFloat( uniform_t uniform, float value ) - { - return SetUniformFloat(uniform, &value, 1); - } + uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); + } - UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; + { + vec4_t baseColor; + vec4_t vertColor; - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*count); - if ( !memory ) + ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE, NULL, NULL); + + uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); + uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); + } + + if (pStage->alphaGen == AGEN_PORTAL) { - failed = true; - return *this; + uniformDataWriter.SetUniformFloat(UNIFORM_PORTALRANGE, tess.shader->portalRange); } - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(float) * count); + uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, pStage->rgbGen); + uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, pStage->alphaGen); - return *this; - } + uniformDataWriter.SetUniformVec3(UNIFORM_DIRECTEDLIGHT, dl->color); - UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; + VectorSet(vector, 0, 0, 0); + uniformDataWriter.SetUniformVec3(UNIFORM_AMBIENTLIGHT, vector); - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); - if ( !memory ) + VectorCopy(dl->origin, vector); + vector[3] = 1.0f; + uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vector); + + uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, radius); + + uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); + uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); + + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + + if (pStage->bundle[TB_DIFFUSEMAP].image[0]) + samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); + + // bind textures that are sampled and used in the glsl shader, and + // bind whiteImage to textures that are sampled but zeroed in the glsl shader + // + // alternatives: + // - use the last bound texture + // -> costs more to sample a higher res texture then throw out the result + // - disable texture sampling in glsl shader with #ifdefs, as before + // -> increases the number of shaders that must be compiled + // + + if (pStage->bundle[TB_NORMALMAP].image[0]) + samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); + else if (r_normalMapping->integer) + samplerBindingsWriter.AddStaticImage( tr.whiteImage, TB_NORMALMAP ); + + if (pStage->bundle[TB_SPECULARMAP].image[0]) + samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); + else if (r_specularMapping->integer) + samplerBindingsWriter.AddStaticImage( tr.whiteImage, TB_SPECULARMAP ); + + vec4_t enableTextures = {}; + uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); + + if (r_dlightMode->integer >= 2) { - failed = true; - return *this; + samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l], TB_SHADOWMAP); } - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec2_t) * count); + ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); + uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); + uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - return *this; - } + uniformDataWriter.SetUniformInt(UNIFORM_TCGEN0, pStage->bundle[0].tcGen); + uniformDataWriter.SetUniformInt(UNIFORM_TCGEN1, pStage->bundle[1].tcGen); - UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); - if ( !memory ) + CaptureDrawData(input, pStage, 0, 0); + + DrawItem item = {}; + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + item.cullType = cullType; + item.program = sp; + item.maxDepthRange = input->maxDepthRange; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + // FIXME: This is a bit ugly with the casting + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + item.draw.primitiveType = GL_TRIANGLES; + item.draw.numInstances = 1; + + + if ( input->multiDrawPrimitives ) { - failed = true; - return *this; + if ( input->multiDrawPrimitives == 1 ) + { + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; + } + else + { + item.draw.type = DRAW_COMMAND_MULTI_INDEXED; + item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; + + item.draw.params.multiIndexed.firstIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.firstIndices, + input->multiDrawFirstIndex, + sizeof(glIndex_t *) * input->multiDrawPrimitives); + + item.draw.params.multiIndexed.numIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(item.draw.params.multiIndexed.numIndices, + input->multiDrawNumIndexes, + sizeof(GLsizei *) * input->multiDrawPrimitives); + } } + else + { + int offset = input->firstIndex * sizeof(glIndex_t) + + (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec3_t) * count); + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.params.indexed.firstIndex = offset; + item.draw.params.indexed.numIndices = input->numIndexes; + } - return *this; + uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); + + backEnd.pc.c_totalIndexes += tess.numIndexes; + backEnd.pc.c_dlightIndexes += tess.numIndexes; + backEnd.pc.c_dlightVertexes += tess.numVertexes; + + RB_BinTriangleCounts(); } +} - UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); - if ( !memory ) - { - failed = true; - return *this; - } +static void ProjectPshadowVBOGLSL( void ) { + int l; + vec3_t origin; + float radius; - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec4_t) * count); + shaderCommands_t *input = &tess; - return *this; + if ( !backEnd.refdef.num_pshadows ) { + return; } - UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; + for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { + pshadow_t *ps; + shaderProgram_t *sp; + vec4_t vector; - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*12*count); - if ( !memory ) - { - failed = true; - return *this; + if ( !( tess.pshadowBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this shadow } - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, matrix, sizeof(float) * 12 * count); + ps = &backEnd.refdef.pshadows[l]; + VectorCopy( ps->lightOrigin, origin ); + radius = ps->lightRadius; + + sp = &tr.pshadowShader; + + GLSL_BindProgram(sp); + + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - return *this; - } + VectorCopy(origin, vector); + vector[3] = 1.0f; + GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); - UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; + VectorScale(ps->lightViewAxis[0], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTFORWARD, vector); - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*16*count); - if ( !memory ) - { - failed = true; - return *this; - } + VectorScale(ps->lightViewAxis[1], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTRIGHT, vector); - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, matrix, sizeof(float) * 16 * count); + VectorScale(ps->lightViewAxis[2], 1.0f / ps->viewRadius, vector); + GLSL_SetUniformVec3(sp, UNIFORM_LIGHTUP, vector); - return *this; - } + GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); - UniformData *Finish( Allocator& destHeap ) - { - UniformData *endSentinel = ojkAlloc(scratch); - if ( failed || !endSentinel ) + GL_BindToTMU( tr.pshadowMaps[l], TB_DIFFUSEMAP ); + + // + // draw + // + + if (input->multiDrawPrimitives) { - return nullptr; + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); } - endSentinel->index = UNIFORM_COUNT; - - int uniformDataSize = (char *)scratch.Mark() - (char *)scratch.Base(); + backEnd.pc.c_totalIndexes += tess.numIndexes; + //backEnd.pc.c_dlightIndexes += tess.numIndexes; + RB_BinTriangleCounts(); + } +} - // Copy scratch buffer to per-frame heap - void *finalMemory = destHeap.Alloc(uniformDataSize); - UniformData *result = static_cast(finalMemory); - memcpy(finalMemory, scratch.Base(), uniformDataSize); - scratch.Reset(); - failed = false; - shaderProgram = nullptr; - return result; - } +/* +=================== +RB_FogPass -private: - bool failed; - shaderProgram_t *shaderProgram; - char scratchBuffer[2048]; - Allocator scratch; -}; +Blends a fog texture on top of everything else +=================== +*/ +static void RB_FogPass( void ) { + fog_t *fog; + vec4_t color; + vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; + float eyeT = 0; + shaderProgram_t *sp; -class SamplerBindingsWriter -{ -public: - SamplerBindingsWriter() - : failed(false) - , count(0) - { - } + deform_t deformType; + genFunc_t deformGen; + vec5_t deformParams; - SamplerBindingsWriter( const SamplerBindingsWriter& ) = delete; - SamplerBindingsWriter& operator=( const SamplerBindingsWriter& ) = delete; + ComputeDeformValues(&deformType, &deformGen, deformParams); - SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ) { - SamplerBinding *binding = &scratch[count]; - if ( !binding ) - { - failed = true; - return *this; - } + int index = 0; - binding->image = image; - binding->slot = unit; - binding->videoMapHandle = NULL_HANDLE; - ++count; + if (deformGen != DGEN_NONE) + index |= FOGDEF_USE_DEFORM_VERTEXES; - return *this; + if (glState.vertexAnimation) + index |= FOGDEF_USE_VERTEX_ANIMATION; + + if (glState.skeletalAnimation) + index |= FOGDEF_USE_SKELETAL_ANIMATION; + + sp = &tr.fogShader[index]; } - SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ) - { - int index; + backEnd.pc.c_fogDraws++; - if ( bundle->isVideoMap ) - { - SamplerBinding *binding = &scratch[count]; - if ( !binding ) - { - failed = true; - return *this; - } + GLSL_BindProgram(sp); - binding->image = nullptr; - binding->slot = unit; - binding->videoMapHandle = bundle->videoMapHandle + 1; - ++count; + fog = tr.world->fogs + tess.fogNum; - return *this; - } + GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - if ( bundle->numImageAnimations <= 1 ) - { - return AddStaticImage(bundle->image[0], unit); - } + GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + + GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + if (deformType != DEFORM_NONE) + { + GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); + GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); + GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + } - if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) - { - index = backEnd.currentEntity->e.skinNum; - } - else - { - // it is necessary to do this messy calc to make sure animations line up - // exactly with waveforms of the same frequency - index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); - index = Q_max(0, index >> FUNCTABLE_SIZE2); - } + color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; + color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; + color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; + color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; + GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - if ( bundle->oneShotAnimMap ) - { - index = Q_min(index, bundle->numImageAnimations - 1); - } - else - { - // loop - index %= bundle->numImageAnimations; - } + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - return AddStaticImage(bundle->image[ index ], unit); + GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); + GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); + GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + + if ( tess.shader->fogPass == FP_EQUAL ) { + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + } else { + GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); } - SamplerBinding *Finish( Allocator& destHeap, int* numBindings ) + if (tess.multiDrawPrimitives) { - if ( failed ) - { - return nullptr; - } + shaderCommands_t *input = &tess; + R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); + } + else + { + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + } +} - SamplerBinding *result = ojkAllocArray(destHeap, count); - if ( numBindings ) +static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) +{ + unsigned int vertexAttribs = shader->vertexAttribs; + + if(glState.vertexAnimation) + { + vertexAttribs &= ~ATTR_COLOR; + vertexAttribs |= ATTR_POSITION2; + if (vertexAttribs & ATTR_NORMAL) { - *numBindings = count; + vertexAttribs |= ATTR_NORMAL2; + vertexAttribs |= ATTR_TANGENT2; } + } - memcpy(result, scratch, sizeof(SamplerBinding)*count); - failed = false; - count = 0; - return result; + if (glState.skeletalAnimation) + { + vertexAttribs |= ATTR_BONE_WEIGHTS; + vertexAttribs |= ATTR_BONE_INDEXES; } -private: - SamplerBinding scratch[32]; - bool failed; - int count; -}; + return vertexAttribs; +} static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stage, shaderProgram_t *glslShaderGroup, bool useAlphaTestGE192 ) { @@ -1670,17 +1751,6 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag return result; } -static uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) -{ - uint32_t key = 0; - uintptr_t shaderProgram = (uintptr_t)item.program; - - key |= (layer & 0xf) << 28; - key |= (stage & 0xf) << 24; - key |= shaderProgram & 0x00ffffff; - return key; -} - static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int stage; @@ -2283,6 +2353,7 @@ void RB_StageIteratorGeneric( void ) { ProjectPshadowVBOGLSL(); } +#endif // // now do any dynamic lighting needed @@ -2291,18 +2362,9 @@ void RB_StageIteratorGeneric( void ) tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - if (tess.shader->numUnfoggedPasses == 1 && - tess.xstages[0]->glslShaderGroup == tr.lightallShader && - (tess.xstages[0]->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) && - r_dlightMode->integer) - { - ForwardDlight(); - } - else - { - ProjectDlightTexture(); - } + ForwardDlight( &vertexArrays ); } +#if 0 // // now do fog From 70ad486c2d2839efe44c5186aed52977ab07f835 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 24 Apr 2016 18:20:55 +0100 Subject: [PATCH 365/708] Rend2: Improve back-face culling code --- codemp/rd-rend2/tr_backend.cpp | 51 +++---------------- codemp/rd-rend2/tr_shade.cpp | 92 ++++++++++++---------------------- 2 files changed, 39 insertions(+), 104 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 4eb89836df..779280c57d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -120,8 +120,6 @@ void GL_Cull( int cullType ) { return; } - glState.faceCulling = cullType; - if ( backEnd.projection2D ) { return; @@ -133,22 +131,15 @@ void GL_Cull( int cullType ) { } else { - qboolean cullFront; - qglEnable( GL_CULL_FACE ); - - cullFront = (qboolean)(cullType == CT_FRONT_SIDED); - if ( backEnd.viewParms.isMirror ) - { - cullFront = (qboolean)(!cullFront); - } + qboolean cullFront = (qboolean)(cullType == CT_FRONT_SIDED); + + if ( glState.faceCulling == CT_TWO_SIDED ) + qglEnable( GL_CULL_FACE ); - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - { - cullFront = (qboolean)(!cullFront); - } - - qglCullFace( cullFront ? GL_FRONT : GL_BACK ); + qglCullFace( cullFront ? GL_FRONT : GL_BACK); } + + glState.faceCulling = cullType; } void GL_DepthRange( float max ) @@ -642,33 +633,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t { const DrawItem& drawItem = drawItems[drawOrder[i]]; - if ( glState.faceCulling != drawItem.cullType ) - { - glState.faceCulling = drawItem.cullType; - switch ( drawItem.cullType ) - { - case GL_NONE: - { - qglDisable(GL_CULL_FACE); - break; - } - - case GL_FRONT: - { - qglEnable(GL_CULL_FACE); - qglCullFace(GL_FRONT); - break; - } - - case GL_BACK: - { - qglEnable(GL_CULL_FACE); - qglCullFace(GL_BACK); - break; - } - } - } - + GL_Cull(drawItem.cullType); GL_State(drawItem.stateBits); GL_DepthRange(drawItem.maxDepthRange); R_BindIBO(drawItem.ibo); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 8fa0c74b54..b16800ffe0 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1149,6 +1149,29 @@ static uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) return key; } +static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntity_t *refEntity, cullType_t shaderCullType ) +{ + assert(refEntity); + + cullType_t cullType = CT_TWO_SIDED; + if ( !backEnd.projection2D ) + { + if ( shaderCullType != CT_TWO_SIDED ) + { + bool cullFront = (shaderCullType == CT_FRONT_SIDED); + if ( viewParms->isMirror ) + cullFront = !cullFront; + + if ( refEntity->mirrored ) + cullFront = !cullFront; + + cullType = (cullFront ? CT_FRONT_SIDED : CT_BACK_SIDED); + } + } + + return cullType; +} + static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { int l; //vec3_t origin; @@ -1173,26 +1196,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - GLenum cullType = GL_NONE; - - if ( !backEnd.projection2D ) - { - if ( input->shader->cullType != CT_TWO_SIDED ) - { - bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); - if ( backEnd.viewParms.isMirror ) - { - cullFront = !cullFront; - } - - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - { - cullFront = !cullFront; - } - - cullType = (cullFront ? GL_FRONT : GL_BACK); - } - } + cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); @@ -1766,26 +1770,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - GLenum cullType = GL_NONE; - - if ( !backEnd.projection2D ) - { - if ( input->shader->cullType != CT_TWO_SIDED ) - { - bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); - if ( backEnd.viewParms.isMirror ) - { - cullFront = !cullFront; - } - - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - { - cullFront = !cullFront; - } - - cullType = (cullFront ? GL_FRONT : GL_BACK); - } - } + cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); @@ -2177,27 +2162,12 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope ComputeDeformValues(&deformType, &deformGen, deformParams); - GLenum cullType = GL_NONE; - if ( !backEnd.projection2D ) - { - if ( input->shader->cullType != CT_TWO_SIDED ) - { - bool cullFront = (input->shader->cullType == CT_FRONT_SIDED); - if ( backEnd.viewParms.isMirror ) - { - cullFront = !cullFront; - } - - if ( backEnd.currentEntity && backEnd.currentEntity->mirrored ) - { - cullFront = !cullFront; - } - - // NOTE: This is intentionally backwards. Shadow maps cull front faces - // when the forward pass would cull the back face. - cullType = (cullFront ? GL_BACK : GL_FRONT); - } - } + cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); + // Reduce shadow acne by using back face culling instead of front + if ( cullType == CT_FRONT_SIDED ) + cullType = CT_BACK_SIDED; + else if ( cullType == CT_BACK_SIDED ) + cullType = CT_FRONT_SIDED; vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); From a5a267284ca3e798c8c8b97fc5970830fbc62688 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 29 Apr 2016 21:14:54 +0100 Subject: [PATCH 366/708] Rend2: Fix back-face culling --- codemp/rd-rend2/tr_backend.cpp | 31 ++++++++++++------------- codemp/rd-rend2/tr_fbo.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 14 ++++++------ codemp/rd-rend2/tr_main.cpp | 41 ++++++++++++++++------------------ codemp/rd-rend2/tr_shade.cpp | 17 +++++--------- 6 files changed, 47 insertions(+), 60 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 779280c57d..a3cc2c8002 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -121,13 +121,12 @@ void GL_Cull( int cullType ) { } if ( backEnd.projection2D ) - { - return; - } + cullType = CT_TWO_SIDED; if ( cullType == CT_TWO_SIDED ) { - qglDisable( GL_CULL_FACE ); + if ( glState.faceCulling != CT_TWO_SIDED ) + qglDisable( GL_CULL_FACE ); } else { @@ -571,8 +570,6 @@ void RB_BeginDrawingView (void) { return; } - glState.faceCulling = -1; // force face culling to set next time - // we will only draw a sun if there was sky rendered in this view backEnd.skyRenderedThisView = qfalse; @@ -1002,7 +999,7 @@ void RB_SetGL2D (void) { GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); - qglDisable( GL_CULL_FACE ); + GL_Cull(CT_TWO_SIDED); // set time for 2D shaders backEnd.refdef.time = ri->Milliseconds(); @@ -1424,15 +1421,15 @@ static const void *RB_DrawSurfs( const void *data ) { // clear the z buffer, set the modelview, etc RB_BeginDrawingView (); - if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) - { - qglEnable(GL_DEPTH_CLAMP); - } - if (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW))) { FBO_t *oldFbo = glState.currentFBO; + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) + { + qglEnable(GL_DEPTH_CLAMP); + } + backEnd.depthFill = qtrue; qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); @@ -1457,7 +1454,7 @@ static const void *RB_DrawSurfs( const void *data ) { FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0); } - if (r_sunlightMode->integer && backEnd.viewParms.flags & VPF_USESUNLIGHT) + if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT)) { vec4_t quadVerts[4]; vec2_t texCoords[4]; @@ -1625,11 +1622,11 @@ static const void *RB_DrawSurfs( const void *data ) { // reset viewport and scissor FBO_Bind(oldFbo); SetViewportAndScissor(); - } - if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) - { - qglDisable(GL_DEPTH_CLAMP); + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) + { + qglDisable(GL_DEPTH_CLAMP); + } } if (!(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index b6b9f7dc47..4b5a23e41b 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -791,7 +791,7 @@ void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexS Matrix16Ortho(0, width, height, 0, 0, 1, projection); - qglDisable( GL_CULL_FACE ); + GL_Cull(CT_TWO_SIDED); GL_BindToTMU(src, TB_COLORMAP); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 596aa13c78..aea75f09f6 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -274,7 +274,7 @@ void R_Splash() GLSL_InitSplashScreenShader(); - qglDisable( GL_CULL_FACE ); + GL_Cull(CT_TWO_SIDED); image_t *pImage = R_FindImageFile( "menu/splash", IMGTYPE_COLORALPHA, IMGFLAG_NONE); if (pImage ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fb7cd072d3..617dc615b1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1348,14 +1348,14 @@ typedef struct { typedef enum { VPF_NONE = 0x00, - VPF_NOVIEWMODEL = 0x01, - VPF_SHADOWMAP = 0x02, - VPF_DEPTHSHADOW = 0x04, - VPF_DEPTHCLAMP = 0x08, - VPF_ORTHOGRAPHIC = 0x10, + VPF_NOVIEWMODEL = 0x01, // Don't render the view model + VPF_SHADOWMAP = 0x02, // Rendering to shadow map + VPF_DEPTHSHADOW = 0x04, // Rendering depth-only + VPF_DEPTHCLAMP = 0x08, // Perform depth clamping when rendering z pass + VPF_ORTHOGRAPHIC = 0x10, // Use orthographic projection VPF_USESUNLIGHT = 0x20, - VPF_FARPLANEFRUSTUM = 0x40, - VPF_NOCUBEMAPS = 0x80, + VPF_FARPLANEFRUSTUM = 0x40, // Use far clipping plane + VPF_NOCUBEMAPS = 0x80, // Don't render cubemaps VPF_NOPOSTPROCESS = 0x100 } viewParmFlags_t; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 485170c63b..1770d126c2 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2115,7 +2115,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = (int)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); + shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); shadowParms.zFar = tr.refdef.dlights[i].radius; VectorCopy( tr.refdef.dlights[i].origin, shadowParms.ori.origin ); @@ -2690,27 +2690,24 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) // Moving the Light in Texel-Sized Increments // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx // - if (lightViewIndependentOfCameraView) - { - float cascadeBound, worldUnitsPerTexel, invWorldUnitsPerTexel; - - cascadeBound = MAX(lightviewBounds[1][0] - lightviewBounds[0][0], lightviewBounds[1][1] - lightviewBounds[0][1]); - cascadeBound = MAX(cascadeBound, lightviewBounds[1][2] - lightviewBounds[0][2]); - worldUnitsPerTexel = cascadeBound / tr.sunShadowFbo[level]->width; - invWorldUnitsPerTexel = 1.0f / worldUnitsPerTexel; - - VectorScale(lightviewBounds[0], invWorldUnitsPerTexel, lightviewBounds[0]); - lightviewBounds[0][0] = floor(lightviewBounds[0][0]); - lightviewBounds[0][1] = floor(lightviewBounds[0][1]); - lightviewBounds[0][2] = floor(lightviewBounds[0][2]); - VectorScale(lightviewBounds[0], worldUnitsPerTexel, lightviewBounds[0]); - - VectorScale(lightviewBounds[1], invWorldUnitsPerTexel, lightviewBounds[1]); - lightviewBounds[1][0] = floor(lightviewBounds[1][0]); - lightviewBounds[1][1] = floor(lightviewBounds[1][1]); - lightviewBounds[1][2] = floor(lightviewBounds[1][2]); - VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); - } + float cascadeBound, worldUnitsPerTexel, invWorldUnitsPerTexel; + + cascadeBound = MAX(lightviewBounds[1][0] - lightviewBounds[0][0], lightviewBounds[1][1] - lightviewBounds[0][1]); + cascadeBound = MAX(cascadeBound, lightviewBounds[1][2] - lightviewBounds[0][2]); + worldUnitsPerTexel = cascadeBound / tr.sunShadowFbo[level]->width; + invWorldUnitsPerTexel = 1.0f / worldUnitsPerTexel; + + VectorScale(lightviewBounds[0], invWorldUnitsPerTexel, lightviewBounds[0]); + lightviewBounds[0][0] = floor(lightviewBounds[0][0]); + lightviewBounds[0][1] = floor(lightviewBounds[0][1]); + lightviewBounds[0][2] = floor(lightviewBounds[0][2]); + VectorScale(lightviewBounds[0], worldUnitsPerTexel, lightviewBounds[0]); + + VectorScale(lightviewBounds[1], invWorldUnitsPerTexel, lightviewBounds[1]); + lightviewBounds[1][0] = floor(lightviewBounds[1][0]); + lightviewBounds[1][1] = floor(lightviewBounds[1][1]); + lightviewBounds[1][2] = floor(lightviewBounds[1][2]); + VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); //ri->Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); //ri->Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b16800ffe0..8e2a1bc29b 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1156,7 +1156,7 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit cullType_t cullType = CT_TWO_SIDED; if ( !backEnd.projection2D ) { - if ( shaderCullType != CT_TWO_SIDED ) + if ( shaderCullType != CT_TWO_SIDED ) { bool cullFront = (shaderCullType == CT_FRONT_SIDED); if ( viewParms->isMirror ) @@ -1165,6 +1165,9 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit if ( refEntity->mirrored ) cullFront = !cullFront; + if ( viewParms->flags & VPF_DEPTHSHADOW ) + cullFront = !cullFront; + cullType = (cullFront ? CT_FRONT_SIDED : CT_BACK_SIDED); } } @@ -2163,11 +2166,6 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope ComputeDeformValues(&deformType, &deformGen, deformParams); cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); - // Reduce shadow acne by using back face culling instead of front - if ( cullType == CT_FRONT_SIDED ) - cullType = CT_BACK_SIDED; - else if ( cullType == CT_BACK_SIDED ) - cullType = CT_FRONT_SIDED; vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); @@ -2274,8 +2272,6 @@ void RB_StageIteratorGeneric( void ) backEnd.pc.c_staticVboDraws++; } - - // // vertex arrays // @@ -2294,11 +2290,8 @@ void RB_StageIteratorGeneric( void ) CalculateVertexArraysFromVBO(vertexAttribs, glState.currentVBO, &vertexArrays); } - if (backEnd.depthFill) + if ( backEnd.depthFill ) { - // - // render depth if in depthfill mode - // RB_IterateStagesGeneric( input, &vertexArrays ); } else if (backEnd.viewParms.flags & VPF_SHADOWMAP) From d2af4fe479d1a6135e69860285046e33ff505711 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 1 May 2016 14:05:14 +0100 Subject: [PATCH 367/708] Rend2: Fix OSX build failures --- codemp/rd-rend2/tr_cache.cpp | 4 ++-- codemp/rd-rend2/tr_cache.h | 4 ++-- codemp/rd-rend2/tr_glsl_parse.cpp | 11 +++++++++++ codemp/rd-rend2/tr_shade.cpp | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 2384a610b8..1d40035abe 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -162,8 +162,8 @@ void CModelCacheManager::DeleteAll( void ) Z_Free(file.pDiskImage); } - files.swap(FileCache()); - assets.swap(AssetCache()); + FileCache().swap(files); + AssetCache().swap(assets); } /* diff --git a/codemp/rd-rend2/tr_cache.h b/codemp/rd-rend2/tr_cache.h index c8c965fa64..b4fccc188e 100644 --- a/codemp/rd-rend2/tr_cache.h +++ b/codemp/rd-rend2/tr_cache.h @@ -46,8 +46,8 @@ struct CachedFile class CModelCacheManager { public: - typedef std::vector AssetCache; - typedef std::vector FileCache; + using AssetCache = std::vector; + using FileCache = std::vector; public: /* diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index 94cfb46533..4f7c47e385 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -41,6 +41,17 @@ Block *FindBlock( const char *name, Block *blocks, size_t numBlocks ) return nullptr; } +#if defined(__clang__) +void strncpy_s( char *dest, size_t destSize, const char *src, size_t srcSize ) +{ + // This isn't really a safe version, but I know the inputs to expect. + size_t len = std::min(srcSize, destSize); + memcpy(dest, src, len); + if ( (destSize - len) > 0 ) + memset(dest + len, 0, destSize - len); +} +#endif + } GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 8e2a1bc29b..c00e78e4e7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1366,7 +1366,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { if ( input->multiDrawPrimitives == 1 ) { item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; } else @@ -2111,7 +2111,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( input->multiDrawPrimitives == 1 ) { item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; } else @@ -2201,7 +2201,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope if ( input->multiDrawPrimitives == 1 ) { item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(input->multiDrawFirstIndex[0]); + item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; } else From db57b4f8615a8425b1680953017b99d8481dfec9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 2 May 2016 09:26:14 +0100 Subject: [PATCH 368/708] Rend2: Implement RF_VOLUMETRIC renderfx. --- codemp/rd-rend2/glsl/generic.glsl | 19 +++++++++++++++++-- codemp/rd-rend2/glsl/lightall.glsl | 28 +++++++++++++++++++++++----- codemp/rd-rend2/tr_glsl.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_shade.cpp | 14 +++++++++++--- 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 49aa577c80..623b397f90 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -48,6 +48,9 @@ uniform mat4 u_ModelViewProjectionMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; +uniform vec3 u_ViewForward; +uniform float u_FXVolumetricBase; + #if defined(USE_RGBAGEN) uniform int u_ColorGen; uniform int u_AlphaGen; @@ -347,11 +350,23 @@ void main() var_DiffuseTex = tex; #endif + if ( u_FXVolumetricBase > 0.0 ) + { + vec3 viewForward = u_ViewForward; + float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); + d = d * d; + d = d * d; + + var_Color = vec4(u_FXVolumetricBase * (1.0 - d)); + } + else + { #if defined(USE_RGBAGEN) - var_Color = CalcColor(position, normal); + var_Color = CalcColor(position, normal); #else - var_Color = u_VertColor * attr_Color + u_BaseColor; + var_Color = u_VertColor * attr_Color + u_BaseColor; #endif + } #if defined(USE_FOG) var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0)); diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index dea6557350..1f49fc6f7f 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -77,6 +77,9 @@ uniform vec4 u_PrimaryLightOrigin; uniform float u_PrimaryLightRadius; #endif +uniform vec3 u_ViewForward; +uniform float u_FXVolumetricBase; + out vec4 var_TexCoords; out vec4 var_Color; out vec3 var_N; @@ -266,15 +269,30 @@ void main() var_TexCoords.zw = GenTexCoords(u_TCGen1, vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); #endif - var_Color = u_VertColor * attr_Color + u_BaseColor; + if ( u_FXVolumetricBase > 0.0 ) + { + vec3 viewForward = u_ViewForward; +#if defined(USE_MODELMATRIX) + viewForward = (u_ModelMatrix * vec4(viewForward, 0.0)).xyz; +#endif + float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); + d = d * d; + d = d * d; + + var_Color = vec4(u_FXVolumetricBase * (1.0 - d)); + } + else + { + var_Color = u_VertColor * attr_Color + u_BaseColor; #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); + float sqrLightDist = dot(L, L); + float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); + float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; + var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; #endif + } #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a2ff0bc180..debb01e67f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -145,6 +145,8 @@ static uniformInfo_t uniformsInfo[] = { "u_BoneMatrices", GLSL_MAT4x3, 20 }, { "u_AlphaTestValue", GLSL_FLOAT, 1 }, + + { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 617dc615b1..eff407e60d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1240,6 +1240,8 @@ typedef enum UNIFORM_BONE_MATRICES, UNIFORM_ALPHA_TEST_VALUE, + UNIFORM_FX_VOLUMETRIC_BASE, + UNIFORM_COUNT } uniform_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c00e78e4e7..eda20bbb25 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1866,10 +1866,17 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); } + float volumetricBaseValue = 0.0f; + if ( backEnd.currentEntity->e.renderfx & RF_VOLUMETRIC ) + { + volumetricBaseValue = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWFORWARD, backEnd.refdef.viewaxis[0]); + } + else { vec4_t baseColor; vec4_t vertColor; - + ComputeShaderColors(pStage, baseColor, vertColor, stateBits, &forceRGBGen, &forceAlphaGen); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) @@ -1879,8 +1886,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays VectorScale(vertColor, backEnd.refdef.colorScale, vertColor); } - if ( backEnd.currentEntity != NULL && - (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) ) + if (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) { vertColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; } @@ -1889,6 +1895,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); } + uniformDataWriter.SetUniformFloat(UNIFORM_FX_VOLUMETRIC_BASE, volumetricBaseValue); + if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || pStage->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) { From 97d2737cb21c4178387b0bc0df34ca88b79443d9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 2 May 2016 16:25:44 +0100 Subject: [PATCH 369/708] Rend2: Fix erroneous condition to grow string This was causing issues where null bytes were being copied into the shader file. --- codemp/rd-rend2/glsl/compact.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 658a33061c..7a2fc52ca6 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -34,7 +34,7 @@ std::string& Escape( std::string& s ) return s; } - if ( (s.capacity() < s.length()) + escapableCharacters ) + if ( s.capacity() < (s.length() + escapableCharacters) ) { // Grow if necessary. s.resize(s.length() + escapableCharacters); From c2c2c2ae9edb0f2fa03050bdbbaa280ccee53f6c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 3 May 2016 10:57:49 +0100 Subject: [PATCH 370/708] Rend2: Fix use of depth range --- codemp/rd-rend2/tr_backend.cpp | 24 ++++++++---------------- codemp/rd-rend2/tr_local.h | 7 ++++--- codemp/rd-rend2/tr_shade.cpp | 4 ++-- codemp/rd-rend2/tr_sky.cpp | 10 +++++----- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a3cc2c8002..5d594d20bf 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -141,14 +141,15 @@ void GL_Cull( int cullType ) { glState.faceCulling = cullType; } -void GL_DepthRange( float max ) +void GL_DepthRange( float min, float max ) { - if ( glState.maxDepthRange == max ) + if ( glState.minDepthRange == min && glState.maxDepthRange == max ) { return; } - qglDepthRange(0.0f, max); + qglDepthRange(min, max); + glState.minDepthRange = min; glState.maxDepthRange = max; } @@ -632,7 +633,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t GL_Cull(drawItem.cullType); GL_State(drawItem.stateBits); - GL_DepthRange(drawItem.maxDepthRange); + GL_DepthRange(drawItem.minDepthRange, drawItem.maxDepthRange); R_BindIBO(drawItem.ibo); GLSL_BindProgram(drawItem.program); @@ -863,7 +864,6 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { { tess.maxDepthRange = 1.0f; } - break; case 1: @@ -876,11 +876,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix( temp.projectionMatrix ); } - if ( !oldDepthRange ) - { - tess.maxDepthRange = 0.3f; - } - + tess.maxDepthRange = 0.3f; break; case 2: @@ -893,11 +889,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix( temp.projectionMatrix ); } - if ( !oldDepthRange ) - { - tess.maxDepthRange = 0.0f; - } - + tess.maxDepthRange = 0.0f; break; } @@ -947,7 +939,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetModelviewMatrix( backEnd.viewParms.world.modelViewMatrix ); // Restore depth range for subsequent rendering - GL_DepthRange(1.0f); + GL_DepthRange(0.0f, 1.0f); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index eff407e60d..9cdb468528 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1983,6 +1983,7 @@ typedef struct glstate_s { int currenttmu; int texEnv[2]; int faceCulling; + float minDepthRange; float maxDepthRange; uint32_t glStateBits; uint32_t vertexAttribsState; @@ -2577,7 +2578,7 @@ void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); //void GL_TexEnv( int env ); void GL_Cull( int cullType ); -void GL_DepthRange( float max ); +void GL_DepthRange( float min, float max ); void GL_PolygonOffset( qboolean enabled ); void GL_VertexAttribPointers(size_t numAttributes, vertexAttribute_t *attributes); @@ -2704,7 +2705,6 @@ struct shaderCommands_s IBO_t *externalIBO; qboolean useInternalVBO; - float minDepthRange; float maxDepthRange; stageVars_t svars QALIGN(16); @@ -3412,7 +3412,8 @@ struct DrawCommand struct DrawItem { uint32_t stateBits; - uint32_t cullType; // this is stupid. hi bits = GL cull type, lo bits = Q3 cull type + uint32_t cullType; // this is stupid + float minDepthRange; float maxDepthRange; IBO_t *ibo; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index eda20bbb25..52559f3cdc 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -142,7 +142,7 @@ static void DrawTris (shaderCommands_t *input) { GL_Bind( tr.whiteImage ); GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); - qglDepthRange( 0, 0 ); + GL_DepthRange(0.0f, 0.0f); { shaderProgram_t *sp = &tr.textureColorShader; @@ -165,7 +165,7 @@ static void DrawTris (shaderCommands_t *input) { } } - qglDepthRange( 0, 1 ); + GL_DepthRange(0.0f, 1.0f); } diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 8c370d197c..50ad91ae36 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -827,7 +827,7 @@ void RB_DrawSun( float scale, shader_t *shader ) { VectorScale( vec2, size, vec2 ); // farthest depth range - qglDepthRange( 1.0, 1.0 ); + GL_DepthRange(1.0f, 1.0f); RB_BeginSurface( shader, 0, 0 ); @@ -836,7 +836,7 @@ void RB_DrawSun( float scale, shader_t *shader ) { RB_EndSurface(); // back to normal depth range - qglDepthRange( 0.0, 1.0 ); + GL_DepthRange(0.0f, 1.0f); } @@ -865,9 +865,9 @@ void RB_StageIteratorSky( void ) { // front of everything to allow developers to see how // much sky is getting sucked in if ( r_showsky->integer ) { - qglDepthRange( 0.0, 0.0 ); + GL_DepthRange(0.0f, 0.0f); } else { - qglDepthRange( 1.0, 1.0 ); + GL_DepthRange(1.0f, 1.0f); } // draw the outer skybox @@ -903,7 +903,7 @@ void RB_StageIteratorSky( void ) { // back to normal depth range - qglDepthRange( 0.0, 1.0 ); + GL_DepthRange(0.0f, 1.0f); // note that sky was drawn so we will draw a sun later backEnd.skyRenderedThisView = qtrue; From b13418e2ed266c08ace710ebf2a8d54aa83288f9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 3 May 2016 11:16:44 +0100 Subject: [PATCH 371/708] Rend2: Fix RF_VOLUMETRIC implementation This isn't particularly pretty - when a refent is flagged with RF_VOLUMETRIC, shaderRGBA[0] (the base value as it's called in the code) might reach zero. However, the shaders rely on zero meaning the entity is not volumetric. This can cause problems where the volumetric entity is rendered incorrectly for a split second. To avoid this, zero and positive numbers are now treated as volumetric in the shader with anything else being an ordinary entity. --- codemp/rd-rend2/glsl/generic.glsl | 2 +- codemp/rd-rend2/tr_shade.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 623b397f90..8fb346b5ed 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -350,7 +350,7 @@ void main() var_DiffuseTex = tex; #endif - if ( u_FXVolumetricBase > 0.0 ) + if ( u_FXVolumetricBase >= 0.0 ) { vec3 viewForward = u_ViewForward; float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 52559f3cdc..f7a2bfd453 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1866,7 +1866,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); } - float volumetricBaseValue = 0.0f; + float volumetricBaseValue = -1.0f; if ( backEnd.currentEntity->e.renderfx & RF_VOLUMETRIC ) { volumetricBaseValue = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; From 4babf973e1b00b956b0eedb44a19c481aa51bb2d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 3 May 2016 13:55:22 +0100 Subject: [PATCH 372/708] Rend2: Actually fix depth range properly --- codemp/rd-rend2/tr_backend.cpp | 37 +++++++++++----------------------- codemp/rd-rend2/tr_init.cpp | 3 ++- codemp/rd-rend2/tr_local.h | 10 ++++----- codemp/rd-rend2/tr_shade.cpp | 22 +++++++++++++++----- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5d594d20bf..0213427248 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -143,14 +143,14 @@ void GL_Cull( int cullType ) { void GL_DepthRange( float min, float max ) { - if ( glState.minDepthRange == min && glState.maxDepthRange == max ) + if ( glState.minDepth == min && glState.maxDepth == max ) { return; } qglDepthRange(min, max); - glState.minDepthRange = min; - glState.maxDepthRange = max; + glState.minDepth = min; + glState.maxDepth = max; } /* @@ -633,7 +633,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t GL_Cull(drawItem.cullType); GL_State(drawItem.stateBits); - GL_DepthRange(drawItem.minDepthRange, drawItem.maxDepthRange); + GL_DepthRange(drawItem.minDepth, drawItem.maxDepth); R_BindIBO(drawItem.ibo); GLSL_BindProgram(drawItem.program); @@ -808,7 +808,6 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // change the modelview matrix if needed // if ( entityNum != oldEntityNum ) { - qboolean sunflare = qfalse; depthRange = 0; if ( entityNum != REFENTITYNUM_WORLD ) { @@ -852,44 +851,32 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // if (oldDepthRange != depthRange) { - switch ( depthRange ) { + switch ( depthRange ) + { default: case 0: - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) { - GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix ); - } - - if( !sunflare ) - { - tess.maxDepthRange = 1.0f; + GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); } break; case 1: - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) { viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - - GL_SetProjectionMatrix( temp.projectionMatrix ); + GL_SetProjectionMatrix(temp.projectionMatrix); } - - tess.maxDepthRange = 0.3f; break; case 2: - if(backEnd.viewParms.stereoFrame != STEREO_CENTER) + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) { viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - - GL_SetProjectionMatrix( temp.projectionMatrix ); + GL_SetProjectionMatrix(temp.projectionMatrix); } - - tess.maxDepthRange = 0.0f; break; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index aea75f09f6..9c9d1fb2cd 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1118,7 +1118,8 @@ void GL_SetDefaultState( void ) // make sure our GL state vector is set correctly // glState.glStateBits = GLS_DEPTHTEST_DISABLE | GLS_DEPTHMASK_TRUE; - glState.maxDepthRange = 1.0f; + glState.maxDepth = 1.0f; + qglDepthRange(0.0f, 1.0f); qglUseProgram(0); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9cdb468528..19efbc2ced 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1983,8 +1983,8 @@ typedef struct glstate_s { int currenttmu; int texEnv[2]; int faceCulling; - float minDepthRange; - float maxDepthRange; + float minDepth; + float maxDepth; uint32_t glStateBits; uint32_t vertexAttribsState; vertexAttribute_t currentVaoAttribs[ATTR_INDEX_MAX]; @@ -2705,8 +2705,6 @@ struct shaderCommands_s IBO_t *externalIBO; qboolean useInternalVBO; - float maxDepthRange; - stageVars_t svars QALIGN(16); //color4ub_t constantColor255[SHADER_MAX_VERTEXES] QALIGN(16); @@ -3413,8 +3411,8 @@ struct DrawItem { uint32_t stateBits; uint32_t cullType; // this is stupid - float minDepthRange; - float maxDepthRange; + float minDepth; + float maxDepth; IBO_t *ibo; shaderProgram_t *program; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f7a2bfd453..a38a586215 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -207,7 +207,6 @@ void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { tess.currentStageIteratorFunc = state->optimalStageIteratorFunc; tess.externalIBO = nullptr; tess.useInternalVBO = qtrue; - tess.maxDepthRange = 1.0f; tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; if (tess.shader->clampTime && tess.shaderTime >= tess.shader->clampTime) { @@ -1175,6 +1174,20 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit return cullType; } +static float RB_GetMaxDepth( const trRefEntity_t *re ) +{ + if ( re->e.renderfx & RF_NODEPTH ) + { + return 0.0f; + } + else if ( re->e.renderfx & RF_DEPTHHACK ) + { + return 0.3f; + } + + return 1.0f; +} + static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { int l; //vec3_t origin; @@ -1345,7 +1358,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; item.cullType = cullType; item.program = sp; - item.maxDepthRange = input->maxDepthRange; + item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1360,7 +1373,6 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { item.draw.primitiveType = GL_TRIANGLES; item.draw.numInstances = 1; - if ( input->multiDrawPrimitives ) { if ( input->multiDrawPrimitives == 1 ) @@ -2099,7 +2111,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.stateBits = stateBits; item.cullType = cullType; item.program = sp; - item.maxDepthRange = input->maxDepthRange; + item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -2192,7 +2204,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope DrawItem item = {}; item.cullType = cullType; item.program = sp; - item.maxDepthRange = input->maxDepthRange; + item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; From e29c8c86b1c157a34b3d97615703cd91f3356ad0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 May 2016 17:23:07 +0100 Subject: [PATCH 373/708] Rend2: Fix sky rendering Since the introduction of render passes, draw calls are collected into an array. After all draws calls are collected, they are sorted and then executed. The draw call for the sky was setting the depth range at the time of draw call collection, and was not recorded. This caused the sky to be rendered with incorrect depth range, and sometimes rendered incorrectly. --- codemp/rd-rend2/tr_backend.cpp | 297 +++++++++++++++++++- codemp/rd-rend2/tr_local.h | 76 ++++- codemp/rd-rend2/tr_shade.cpp | 494 +++++---------------------------- codemp/rd-rend2/tr_sky.cpp | 211 ++++++-------- 4 files changed, 529 insertions(+), 549 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 0213427248..3de4c4dc26 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -597,6 +597,301 @@ void RB_BeginDrawingView (void) { #define MAC_EVENT_PUMP_MSEC 5 +UniformDataWriter::UniformDataWriter() + : failed(false) + , shaderProgram(nullptr) + , scratch(scratchBuffer, sizeof(scratchBuffer), 1) +{ +} + +void UniformDataWriter::Start( shaderProgram_t *sp ) +{ + shaderProgram = sp; +} + +UniformDataWriter& UniformDataWriter::SetUniformInt( uniform_t uniform, int value ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(int)); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = 1; + + int *data = reinterpret_cast(header + 1); + *data = value; + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformFloat( uniform_t uniform, float value ) +{ + return SetUniformFloat(uniform, &value, 1); +} + +UniformDataWriter& UniformDataWriter::SetUniformFloat( uniform_t uniform, float *values, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(float) * count); + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformVec2( uniform_t uniform, float x, float y ) +{ + vec2_t values = {x, y}; + return SetUniformVec2(uniform, values); +} + +UniformDataWriter& UniformDataWriter::SetUniformVec2( uniform_t uniform, float *values, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec2_t) * count); + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformVec3( uniform_t uniform, float x, float y, float z ) +{ + vec3_t values = {x, y, z}; + return SetUniformVec3(uniform, values); +} + +UniformDataWriter& UniformDataWriter::SetUniformVec3( uniform_t uniform, float *values, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec3_t) * count); + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, float x, float y, float z, float w ) +{ + vec4_t values = {x, y, z, w}; + return SetUniformVec4(uniform, values); +} + +UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, float *values, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, values, sizeof(vec4_t) * count); + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*12*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 12 * count); + + return *this; +} + +UniformDataWriter& UniformDataWriter::SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count ) +{ + if ( shaderProgram->uniforms[uniform] == -1 ) + return *this; + + void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*16*count); + if ( !memory ) + { + failed = true; + return *this; + } + + UniformData *header = static_cast(memory); + header->index = uniform; + header->numElements = count; + memcpy(header + 1, matrix, sizeof(float) * 16 * count); + + return *this; +} + +UniformData *UniformDataWriter::Finish( Allocator& destHeap ) +{ + UniformData *endSentinel = ojkAlloc(scratch); + if ( failed || !endSentinel ) + { + return nullptr; + } + + endSentinel->index = UNIFORM_COUNT; + + int uniformDataSize = (char *)scratch.Mark() - (char *)scratch.Base(); + + // Copy scratch buffer to per-frame heap + void *finalMemory = destHeap.Alloc(uniformDataSize); + UniformData *result = static_cast(finalMemory); + memcpy(finalMemory, scratch.Base(), uniformDataSize); + scratch.Reset(); + + failed = false; + shaderProgram = nullptr; + + return result; +} + +SamplerBindingsWriter::SamplerBindingsWriter() + : failed(false) + , count(0) +{ +} + +SamplerBindingsWriter& SamplerBindingsWriter::AddStaticImage( image_t *image, int unit ) +{ + SamplerBinding *binding = &scratch[count]; + if ( !binding ) + { + failed = true; + return *this; + } + + binding->image = image; + binding->slot = unit; + binding->videoMapHandle = NULL_HANDLE; + ++count; + + return *this; +} + +SamplerBindingsWriter& SamplerBindingsWriter::AddAnimatedImage( textureBundle_t *bundle, int unit ) +{ + int index; + + if ( bundle->isVideoMap ) + { + SamplerBinding *binding = &scratch[count]; + if ( !binding ) + { + failed = true; + return *this; + } + + binding->image = nullptr; + binding->slot = unit; + binding->videoMapHandle = bundle->videoMapHandle + 1; + ++count; + + return *this; + } + + if ( bundle->numImageAnimations <= 1 ) + { + return AddStaticImage(bundle->image[0], unit); + } + + if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) + { + index = backEnd.currentEntity->e.skinNum; + } + else + { + // it is necessary to do this messy calc to make sure animations line up + // exactly with waveforms of the same frequency + index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); + index = Q_max(0, index >> FUNCTABLE_SIZE2); + } + + if ( bundle->oneShotAnimMap ) + { + index = Q_min(index, bundle->numImageAnimations - 1); + } + else + { + // loop + index %= bundle->numImageAnimations; + } + + return AddStaticImage(bundle->image[ index ], unit); +} + +SamplerBinding *SamplerBindingsWriter::Finish( Allocator& destHeap, int* numBindings ) +{ + if ( failed ) + { + return nullptr; + } + + SamplerBinding *result = ojkAllocArray(destHeap, count); + + if ( numBindings ) + { + *numBindings = count; + } + + memcpy(result, scratch, sizeof(SamplerBinding)*count); + failed = false; + count = 0; + return result; +} + struct Pass { int maxDrawItems; @@ -633,7 +928,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t GL_Cull(drawItem.cullType); GL_State(drawItem.stateBits); - GL_DepthRange(drawItem.minDepth, drawItem.maxDepth); + GL_DepthRange(drawItem.depthRange.minDepth, drawItem.depthRange.maxDepth); R_BindIBO(drawItem.ibo); GLSL_BindProgram(drawItem.program); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 19efbc2ced..0fefa03b4d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "qcommon/qcommon.h" #include "rd-common/tr_public.h" #include "rd-common/tr_common.h" +#include "tr_allocator.h" #include "tr_extratypes.h" #include "tr_extramath.h" #include "tr_fbo.h" @@ -3305,9 +3306,6 @@ typedef struct backEndData_s { renderCommandList_t commands; } backEndData_t; -struct DrawItem; -void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ); - extern int max_polys; extern int max_polyverts; @@ -3370,6 +3368,12 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ); class Allocator; GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ); +struct DepthRange +{ + float minDepth; + float maxDepth; +}; + struct SamplerBinding { image_t *image; @@ -3411,8 +3415,7 @@ struct DrawItem { uint32_t stateBits; uint32_t cullType; // this is stupid - float minDepth; - float maxDepth; + DepthRange depthRange; IBO_t *ibo; shaderProgram_t *program; @@ -3428,4 +3431,67 @@ struct DrawItem DrawCommand draw; }; +class UniformDataWriter +{ +public: + UniformDataWriter(); + + void Start( shaderProgram_t *sp ); + + UniformDataWriter& SetUniformInt( uniform_t uniform, int value ); + UniformDataWriter& SetUniformFloat( uniform_t uniform, float value ); + UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ); + + UniformDataWriter& SetUniformVec2( uniform_t uniform, float x, float y ); + UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ); + + UniformDataWriter& SetUniformVec3( uniform_t uniform, float x, float y, float z ); + UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ); + + UniformDataWriter& SetUniformVec4( uniform_t uniform, float x, float y, float z, float w ); + UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ); + + UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ); + UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ); + + UniformData *Finish( Allocator& destHeap ); + +private: + bool failed; + shaderProgram_t *shaderProgram; + char scratchBuffer[2048]; + Allocator scratch; +}; + +class SamplerBindingsWriter +{ +public: + SamplerBindingsWriter(); + + SamplerBindingsWriter( const SamplerBindingsWriter& ) = delete; + SamplerBindingsWriter& operator=( const SamplerBindingsWriter& ) = delete; + + SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ); + + SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ); + + SamplerBinding *Finish( Allocator& destHeap, int* numBindings ); + +private: + SamplerBinding scratch[32]; + bool failed; + int count; +}; + +void RB_FillDrawCommand( + DrawCommand& drawCmd, + GLenum primitiveType, + int numInstances, + const shaderCommands_t *input +); + +uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); +void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ); +DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ); + #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index a38a586215..132a9e8a29 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -832,309 +832,7 @@ static void CaptureDrawData(shaderCommands_t *input, shaderStage_t *stage, int g } } -class UniformDataWriter -{ -public: - UniformDataWriter() - : failed(false) - , shaderProgram(nullptr) - , scratch(scratchBuffer, sizeof(scratchBuffer), 1) - { - } - - UniformDataWriter( const UniformDataWriter& ) = delete; - UniformDataWriter& operator=( const UniformDataWriter& ) = delete; - - void Start( shaderProgram_t *sp ) - { - shaderProgram = sp; - } - - UniformDataWriter& SetUniformInt( uniform_t uniform, int value ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(int)); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = 1; - - int *data = reinterpret_cast(header + 1); - *data = value; - - return *this; - } - - UniformDataWriter& SetUniformFloat( uniform_t uniform, float value ) - { - return SetUniformFloat(uniform, &value, 1); - } - - UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(float) * count); - - return *this; - } - - UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec2_t)*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec2_t) * count); - - return *this; - } - - UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec3_t)*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec3_t) * count); - - return *this; - } - - UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(vec4_t)*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, values, sizeof(vec4_t) * count); - - return *this; - } - - UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*12*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, matrix, sizeof(float) * 12 * count); - - return *this; - } - - UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ) - { - if ( shaderProgram->uniforms[uniform] == -1 ) - return *this; - - void *memory = scratch.Alloc(sizeof(UniformData) + sizeof(float)*16*count); - if ( !memory ) - { - failed = true; - return *this; - } - - UniformData *header = static_cast(memory); - header->index = uniform; - header->numElements = count; - memcpy(header + 1, matrix, sizeof(float) * 16 * count); - - return *this; - } - - UniformData *Finish( Allocator& destHeap ) - { - UniformData *endSentinel = ojkAlloc(scratch); - if ( failed || !endSentinel ) - { - return nullptr; - } - - endSentinel->index = UNIFORM_COUNT; - - int uniformDataSize = (char *)scratch.Mark() - (char *)scratch.Base(); - - // Copy scratch buffer to per-frame heap - void *finalMemory = destHeap.Alloc(uniformDataSize); - UniformData *result = static_cast(finalMemory); - memcpy(finalMemory, scratch.Base(), uniformDataSize); - scratch.Reset(); - - failed = false; - shaderProgram = nullptr; - - return result; - } - -private: - bool failed; - shaderProgram_t *shaderProgram; - char scratchBuffer[2048]; - Allocator scratch; -}; - -class SamplerBindingsWriter -{ -public: - SamplerBindingsWriter() - : failed(false) - , count(0) - { - } - - SamplerBindingsWriter( const SamplerBindingsWriter& ) = delete; - SamplerBindingsWriter& operator=( const SamplerBindingsWriter& ) = delete; - - SamplerBindingsWriter& AddStaticImage( image_t *image, int unit ) - { - SamplerBinding *binding = &scratch[count]; - if ( !binding ) - { - failed = true; - return *this; - } - - binding->image = image; - binding->slot = unit; - binding->videoMapHandle = NULL_HANDLE; - ++count; - - return *this; - } - - SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ) - { - int index; - - if ( bundle->isVideoMap ) - { - SamplerBinding *binding = &scratch[count]; - if ( !binding ) - { - failed = true; - return *this; - } - - binding->image = nullptr; - binding->slot = unit; - binding->videoMapHandle = bundle->videoMapHandle + 1; - ++count; - - return *this; - } - - if ( bundle->numImageAnimations <= 1 ) - { - return AddStaticImage(bundle->image[0], unit); - } - - if (backEnd.currentEntity->e.renderfx & RF_SETANIMINDEX ) - { - index = backEnd.currentEntity->e.skinNum; - } - else - { - // it is necessary to do this messy calc to make sure animations line up - // exactly with waveforms of the same frequency - index = Q_ftol( tess.shaderTime * bundle->imageAnimationSpeed * FUNCTABLE_SIZE ); - index = Q_max(0, index >> FUNCTABLE_SIZE2); - } - - if ( bundle->oneShotAnimMap ) - { - index = Q_min(index, bundle->numImageAnimations - 1); - } - else - { - // loop - index %= bundle->numImageAnimations; - } - - return AddStaticImage(bundle->image[ index ], unit); - } - - SamplerBinding *Finish( Allocator& destHeap, int* numBindings ) - { - if ( failed ) - { - return nullptr; - } - - SamplerBinding *result = ojkAllocArray(destHeap, count); - - if ( numBindings ) - { - *numBindings = count; - } - - memcpy(result, scratch, sizeof(SamplerBinding)*count); - failed = false; - count = 0; - return result; - } - -private: - SamplerBinding scratch[32]; - bool failed; - int count; -}; - -static uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) +uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ) { uint32_t key = 0; uintptr_t shaderProgram = (uintptr_t)item.program; @@ -1174,18 +872,78 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit return cullType; } -static float RB_GetMaxDepth( const trRefEntity_t *re ) +DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ) { - if ( re->e.renderfx & RF_NODEPTH ) + DepthRange range = {0.0f, 1.0f}; + if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) { - return 0.0f; + if ( r_showsky->integer ) + { + range.minDepth = 1.0f; + range.maxDepth = 1.0f; + } + else + { + range.maxDepth = 0.0f; + } + } + else if ( re->e.renderfx & RF_NODEPTH ) + { + range.maxDepth = 0.0f; } else if ( re->e.renderfx & RF_DEPTHHACK ) { - return 0.3f; + range.maxDepth = 0.3f; + } + + return range; +} + +void RB_FillDrawCommand( + DrawCommand& drawCmd, + GLenum primitiveType, + int numInstances, + const shaderCommands_t *input +) +{ + drawCmd.primitiveType = primitiveType; + drawCmd.numInstances = numInstances; + + if ( input->multiDrawPrimitives ) + { + if ( input->multiDrawPrimitives == 1 ) + { + drawCmd.type = DRAW_COMMAND_INDEXED; + drawCmd.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); + drawCmd.params.indexed.numIndices = input->multiDrawNumIndexes[0]; + } + else + { + drawCmd.type = DRAW_COMMAND_MULTI_INDEXED; + drawCmd.params.multiIndexed.numDraws = input->multiDrawPrimitives; + + drawCmd.params.multiIndexed.firstIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(drawCmd.params.multiIndexed.firstIndices, + input->multiDrawFirstIndex, + sizeof(glIndex_t *) * input->multiDrawPrimitives); + + drawCmd.params.multiIndexed.numIndices = + ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); + memcpy(drawCmd.params.multiIndexed.numIndices, + input->multiDrawNumIndexes, + sizeof(GLsizei *) * input->multiDrawPrimitives); + } } + else + { + int offset = input->firstIndex * sizeof(glIndex_t) + + (input->useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - return 1.0f; + drawCmd.type = DRAW_COMMAND_INDEXED; + drawCmd.params.indexed.firstIndex = offset; + drawCmd.params.indexed.numIndices = input->numIndexes; + } } static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { @@ -1358,7 +1116,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; item.cullType = cullType; item.program = sp; - item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); + item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1370,44 +1128,8 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); - item.draw.primitiveType = GL_TRIANGLES; - item.draw.numInstances = 1; - - if ( input->multiDrawPrimitives ) - { - if ( input->multiDrawPrimitives == 1 ) - { - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); - item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; - } - else - { - item.draw.type = DRAW_COMMAND_MULTI_INDEXED; - item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; - - item.draw.params.multiIndexed.firstIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.firstIndices, - input->multiDrawFirstIndex, - sizeof(glIndex_t *) * input->multiDrawPrimitives); - - item.draw.params.multiIndexed.numIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.numIndices, - input->multiDrawNumIndexes, - sizeof(GLsizei *) * input->multiDrawPrimitives); - } - } - else - { - int offset = input->firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = offset; - item.draw.params.indexed.numIndices = input->numIndexes; - } + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); @@ -2111,7 +1833,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.stateBits = stateBits; item.cullType = cullType; item.program = sp; - item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); + item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -2123,44 +1845,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); - item.draw.primitiveType = GL_TRIANGLES; - item.draw.numInstances = 1; - if ( input->multiDrawPrimitives ) - { - if ( input->multiDrawPrimitives == 1 ) - { - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); - item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; - } - else - { - item.draw.type = DRAW_COMMAND_MULTI_INDEXED; - item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; - - item.draw.params.multiIndexed.firstIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.firstIndices, - input->multiDrawFirstIndex, - sizeof(glIndex_t *) * input->multiDrawPrimitives); - - item.draw.params.multiIndexed.numIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.numIndices, - input->multiDrawNumIndexes, - sizeof(GLsizei *) * input->multiDrawPrimitives); - } - } - else - { - int offset = input->firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = offset; - item.draw.params.indexed.numIndices = input->numIndexes; - } + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); uint32_t key = RB_CreateSortKey(item, stage, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); @@ -2204,7 +1890,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope DrawItem item = {}; item.cullType = cullType; item.program = sp; - item.maxDepth = RB_GetMaxDepth(backEnd.currentEntity); + item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -2213,44 +1899,8 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - item.draw.primitiveType = GL_TRIANGLES; - item.draw.numInstances = 1; - if ( input->multiDrawPrimitives ) - { - if ( input->multiDrawPrimitives == 1 ) - { - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); - item.draw.params.indexed.numIndices = input->multiDrawNumIndexes[0]; - } - else - { - item.draw.type = DRAW_COMMAND_MULTI_INDEXED; - item.draw.params.multiIndexed.numDraws = input->multiDrawPrimitives; - - item.draw.params.multiIndexed.firstIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.firstIndices, - input->multiDrawFirstIndex, - sizeof(glIndex_t *) * input->multiDrawPrimitives); - - item.draw.params.multiIndexed.numIndices = - ojkAllocArray(*backEndData->perFrameMemory, input->multiDrawPrimitives); - memcpy(item.draw.params.multiIndexed.numIndices, - input->multiDrawNumIndexes, - sizeof(GLsizei *) * input->multiDrawPrimitives); - } - } - else - { - int offset = input->firstIndex * sizeof(glIndex_t) + - (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.params.indexed.firstIndex = offset; - item.draw.params.indexed.numIndices = input->numIndexes; - } + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); // FIXME: Use depth to object uint32_t key = 0; diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 50ad91ae36..b53af238f8 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -362,23 +362,20 @@ static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; static void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] ) { + const uint32_t SKY_BOX_VERTEX_ATTRIBUTES = ATTR_POSITION | ATTR_TEXCOORD0; int s, t; int firstVertex = tess.numVertexes; - //int firstIndex = tess.numIndexes; int minIndex = tess.minIndex; int maxIndex = tess.maxIndex; vec4_t color; - //tess.numVertexes = 0; - //tess.numIndexes = 0; tess.firstIndex = tess.numIndexes; - GL_Bind( image ); - GL_Cull( CT_TWO_SIDED ); - - for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) + for ( t = mins[1]+HALF_SKY_SUBDIVISIONS; + t <= maxs[1]+HALF_SKY_SUBDIVISIONS; t++ ) { - for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) + for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; + s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) { tess.xyz[tess.numVertexes][0] = s_skyPoints[t][s][0]; tess.xyz[tess.numVertexes][1] = s_skyPoints[t][s][1]; @@ -397,22 +394,25 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max } } - for ( t = 0; t < maxs[1] - mins[1]; t++ ) + float ssize = maxs[0] - mins[0]; + float tsize = maxs[1] - mins[1]; + float ssizePlusOne = ssize + 1.0f; + for ( t = 0; t < tsize; t++ ) { - for ( s = 0; s < maxs[0] - mins[0]; s++ ) + for ( s = 0; s < ssize; s++ ) { - if (tess.numIndexes + 6 >= SHADER_MAX_INDEXES) + if ((tess.numIndexes + 6) >= SHADER_MAX_INDEXES) { ri->Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); } - tess.indexes[tess.numIndexes++] = s + t * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = s + t * ssizePlusOne + firstVertex; + tess.indexes[tess.numIndexes++] = s + (t + 1) * ssizePlusOne + firstVertex; + tess.indexes[tess.numIndexes++] = (s + 1) + t * ssizePlusOne + firstVertex; - tess.indexes[tess.numIndexes++] = (s + 1) + t * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = s + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; - tess.indexes[tess.numIndexes++] = (s + 1) + (t + 1) * (maxs[0] - mins[0] + 1) + firstVertex; + tess.indexes[tess.numIndexes++] = (s + 1) + t * ssizePlusOne + firstVertex; + tess.indexes[tess.numIndexes++] = s + (t + 1) * ssizePlusOne + firstVertex; + tess.indexes[tess.numIndexes++] = (s + 1) + (t + 1) * ssizePlusOne + firstVertex; } } @@ -420,58 +420,59 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max tess.maxIndex = tess.numVertexes; tess.useInternalVBO = qtrue; - // FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function - RB_UpdateVBOs(ATTR_POSITION | ATTR_TEXCOORD0); -/* - { - shaderProgram_t *sp = &tr.textureColorShader; - - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); - GLSL_BindProgram(sp); - - GLSL_SetUniformMatrix16(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - color[0] = - color[1] = - color[2] = tr.identityLight; - color[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - } -*/ - { - shaderProgram_t *sp = &tr.lightallShader[0]; - vec4_t vector; - - GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD0, NULL); - GLSL_BindProgram(sp); - - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - - color[0] = - color[1] = - color[2] = backEnd.refdef.colorScale; - color[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_BASECOLOR, color); - - color[0] = - color[1] = - color[2] = - color[3] = 0.0f; - GLSL_SetUniformVec4(sp, UNIFORM_VERTCOLOR, color); - - VectorSet4(vector, 1.0, 0.0, 0.0, 1.0); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXMATRIX, vector); - - VectorSet4(vector, 0.0, 0.0, 0.0, 0.0); - GLSL_SetUniformVec4(sp, UNIFORM_DIFFUSETEXOFFTURB, vector); - } - - R_DrawElementsVBO(tess.numIndexes - tess.firstIndex, tess.firstIndex, tess.minIndex, tess.maxIndex); + RB_UpdateVBOs(SKY_BOX_VERTEX_ATTRIBUTES); - //qglDrawElements(GL_TRIANGLES, tess.numIndexes - tess.firstIndex, GL_INDEX_TYPE, BUFFER_OFFSET(tess.firstIndex * sizeof(glIndex_t))); - - //R_BindNullVBO(); - //R_BindNullIBO(); + VertexArraysProperties vertexArrays; + CalculateVertexArraysProperties(SKY_BOX_VERTEX_ATTRIBUTES, &vertexArrays); + for ( int i = 0; i < vertexArrays.numVertexArrays; i++ ) + { + int attributeIndex = vertexArrays.enabledAttributes[i]; + vertexArrays.offsets[attributeIndex] += + backEndData->currentFrame->dynamicVboCommitOffset; + } + + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), &vertexArrays); + + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; + + shaderProgram_t *sp = &tr.lightallShader[0]; + float colorScale = backEnd.refdef.colorScale; + uniformDataWriter.Start(sp); + uniformDataWriter.SetUniformMatrix4x4( + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec4( + UNIFORM_BASECOLOR, colorScale, colorScale, colorScale, 1.0f); + uniformDataWriter.SetUniformVec4( + UNIFORM_VERTCOLOR, 0.0f, 0.0f, 0.0f, 0.0f); + uniformDataWriter.SetUniformVec4( + UNIFORM_DIFFUSETEXMATRIX, 1.0f, 0.0f, 0.0f, 1.0f); + uniformDataWriter.SetUniformVec4( + UNIFORM_DIFFUSETEXOFFTURB, 0.0f, 0.0f, 0.0f, 0.0f); + + samplerBindingsWriter.AddStaticImage(image, TB_DIFFUSEMAP); + + DrawItem item = {}; + item.cullType = CT_TWO_SIDED; + item.program = sp; + item.depthRange = RB_GetDepthRange(backEnd.currentEntity, tess.shader); + item.ibo = backEndData->currentFrame->dynamicIbo; + item.numAttributes = vertexArrays.numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays.numVertexArrays); + memcpy(item.attributes, attribs, + sizeof(*item.attributes) * item.numAttributes); + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, &tess); + item.draw.params.indexed.numIndices -= tess.firstIndex; + + uint32_t key = RB_CreateSortKey(item, 0, SS_ENVIRONMENT); + RB_AddDrawItem(backEndData->currentPass, key, item); RB_CommitInternalBufferData(); @@ -534,9 +535,11 @@ static void DrawSkyBox( shader_t *shader ) // // iterate through the subdivisions // - for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) + for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; + t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) { - for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) + for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; + s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, @@ -566,7 +569,8 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad { for ( s = mins[0]+HALF_SKY_SUBDIVISIONS; s <= maxs[0]+HALF_SKY_SUBDIVISIONS; s++ ) { - VectorAdd( s_skyPoints[t][s], backEnd.viewParms.ori.origin, tess.xyz[tess.numVertexes] ); + VectorAdd( s_skyPoints[t][s], backEnd.viewParms.ori.origin, + tess.xyz[tess.numVertexes] ); tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; @@ -607,39 +611,12 @@ static void FillCloudBox( const shader_t *shader, int stage ) { int i; - for ( i =0; i < 6; i++ ) + // don't want to draw the bottom + for ( i =0; i < 5; i++ ) { int sky_mins_subd[2], sky_maxs_subd[2]; int s, t; - float MIN_T; - - if ( 1 ) // FIXME? shader->sky.fullClouds ) - { - MIN_T = -HALF_SKY_SUBDIVISIONS; - - // still don't want to draw the bottom, even if fullClouds - if ( i == 5 ) - continue; - } - else - { - switch( i ) - { - case 0: - case 1: - case 2: - case 3: - MIN_T = -1; - break; - case 5: - // don't draw clouds beneath you - continue; - case 4: // top - default: - MIN_T = -HALF_SKY_SUBDIVISIONS; - break; - } - } + const float MIN_T = -HALF_SKY_SUBDIVISIONS; sky_mins[0][i] = floor( sky_mins[0][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; sky_mins[1][i] = floor( sky_mins[1][i] * HALF_SKY_SUBDIVISIONS ) / HALF_SKY_SUBDIVISIONS; @@ -678,9 +655,11 @@ static void FillCloudBox( const shader_t *shader, int stage ) // // iterate through the subdivisions // - for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) + for ( t = sky_mins_subd[1]+HALF_SKY_SUBDIVISIONS; + t <= sky_maxs_subd[1]+HALF_SKY_SUBDIVISIONS; t++ ) { - for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) + for ( s = sky_mins_subd[0]+HALF_SKY_SUBDIVISIONS; + s <= sky_maxs_subd[0]+HALF_SKY_SUBDIVISIONS; s++ ) { MakeSkyVec( ( s - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, ( t - HALF_SKY_SUBDIVISIONS ) / ( float ) HALF_SKY_SUBDIVISIONS, @@ -871,25 +850,18 @@ void RB_StageIteratorSky( void ) { } // draw the outer skybox - if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) { + if ( tess.shader->sky.outerbox[0] && + tess.shader->sky.outerbox[0] != tr.defaultImage ) { + // FIXME: this could be a lot cleaner + matrix_t trans, product; matrix_t oldmodelview; - - GL_State( 0 ); - //qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]); - { - // FIXME: this could be a lot cleaner - matrix_t trans, product; - - Matrix16Copy( glState.modelview, oldmodelview ); - Matrix16Translation( backEnd.viewParms.ori.origin, trans ); - Matrix16Multiply( glState.modelview, trans, product ); - GL_SetModelviewMatrix( product ); - - } + Matrix16Copy( glState.modelview, oldmodelview ); + Matrix16Translation( backEnd.viewParms.ori.origin, trans ); + Matrix16Multiply( glState.modelview, trans, product ); + GL_SetModelviewMatrix( product ); DrawSkyBox( tess.shader ); - GL_SetModelviewMatrix( oldmodelview ); } @@ -899,9 +871,6 @@ void RB_StageIteratorSky( void ) { RB_StageIteratorGeneric(); - // draw the inner skybox - - // back to normal depth range GL_DepthRange(0.0f, 1.0f); From 6271e513d425d809cdc88fe05297f6c62ad87983 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 May 2016 19:22:42 +0100 Subject: [PATCH 374/708] Rend2: Remove some unnecessary depth range calls --- codemp/rd-rend2/tr_backend.cpp | 3 --- codemp/rd-rend2/tr_shade.cpp | 3 +++ codemp/rd-rend2/tr_sky.cpp | 26 +++++--------------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3de4c4dc26..844ba81eed 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1219,9 +1219,6 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { // go back to the world modelview matrix GL_SetModelviewMatrix( backEnd.viewParms.world.modelViewMatrix ); - - // Restore depth range for subsequent rendering - GL_DepthRange(0.0f, 1.0f); } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 132a9e8a29..c73336d2a4 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -877,6 +877,9 @@ DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ) DepthRange range = {0.0f, 1.0f}; if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) { + // r_showsky will let all the sky blocks be drawn in + // front of everything to allow developers to see how + // much sky is getting sucked in if ( r_showsky->integer ) { range.minDepth = 1.0f; diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index b53af238f8..65c06c7b82 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -784,16 +784,12 @@ void RB_DrawSun( float scale, shader_t *shader ) { return; } - //qglLoadMatrixf( backEnd.viewParms.world.modelViewMatrix ); - //qglTranslatef (backEnd.viewParms.ori.origin[0], backEnd.viewParms.ori.origin[1], backEnd.viewParms.ori.origin[2]); - { - // FIXME: this could be a lot cleaner - matrix_t translation, modelview; + // FIXME: this could be a lot cleaner + matrix_t translation, modelview; - Matrix16Translation( backEnd.viewParms.ori.origin, translation ); - Matrix16Multiply( backEnd.viewParms.world.modelViewMatrix, translation, modelview ); - GL_SetModelviewMatrix( modelview ); - } + Matrix16Translation( backEnd.viewParms.ori.origin, translation ); + Matrix16Multiply( backEnd.viewParms.world.modelViewMatrix, translation, modelview ); + GL_SetModelviewMatrix( modelview ); dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3) size = dist * scale; @@ -840,15 +836,6 @@ void RB_StageIteratorSky( void ) { // to be drawn RB_ClipSkyPolygons( &tess ); - // r_showsky will let all the sky blocks be drawn in - // front of everything to allow developers to see how - // much sky is getting sucked in - if ( r_showsky->integer ) { - GL_DepthRange(0.0f, 0.0f); - } else { - GL_DepthRange(1.0f, 1.0f); - } - // draw the outer skybox if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) { @@ -871,9 +858,6 @@ void RB_StageIteratorSky( void ) { RB_StageIteratorGeneric(); - // back to normal depth range - GL_DepthRange(0.0f, 1.0f); - // note that sky was drawn so we will draw a sun later backEnd.skyRenderedThisView = qtrue; } From f3c9ac0d32df4f7b1f48acbce669978d4d1cfc85 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 5 May 2016 19:39:27 +0100 Subject: [PATCH 375/708] Rend2: disable r_showtris for now This is kind of broken because it doesn't pick the correct shaders for animation. --- codemp/rd-rend2/tr_shade.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c73336d2a4..d4692d61f3 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -139,6 +139,7 @@ Draws triangle outlines for debugging ================ */ static void DrawTris (shaderCommands_t *input) { +#if 0 GL_Bind( tr.whiteImage ); GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); @@ -166,6 +167,7 @@ static void DrawTris (shaderCommands_t *input) { } GL_DepthRange(0.0f, 1.0f); +#endif } From 60d8e94ffa6dfa53c70f8f3407ce099c30aede8f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 6 May 2016 21:00:40 +0100 Subject: [PATCH 376/708] Rend2: Fix remaining issues with sky rendering --- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 9c9d1fb2cd..65779e93ac 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -280,7 +280,7 @@ void R_Splash() if (pImage ) GL_Bind( pImage ); - GL_State(GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO); + GL_State(0); GLSL_BindProgram(&tr.splashScreenShader); qglDrawArrays(GL_TRIANGLES, 0, 3); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index d4692d61f3..f217312667 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -877,12 +877,12 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ) { DepthRange range = {0.0f, 1.0f}; - if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) + if ( shader->isSky ) { // r_showsky will let all the sky blocks be drawn in // front of everything to allow developers to see how // much sky is getting sucked in - if ( r_showsky->integer ) + if ( !r_showsky->integer ) { range.minDepth = 1.0f; range.maxDepth = 1.0f; From cc9e5df8acbca68f6b9b0ae2d324f623ec010541 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 7 May 2016 21:05:25 +0100 Subject: [PATCH 377/708] Rend2: Fixed compiler warnings on OS X + clang --- codemp/rd-rend2/G2_API.cpp | 80 ++++++++++++-------------- codemp/rd-rend2/tr_backend.cpp | 17 ------ codemp/rd-rend2/tr_bsp.cpp | 6 +- codemp/rd-rend2/tr_extensions.cpp | 2 +- codemp/rd-rend2/tr_ghoul2.cpp | 22 +------ codemp/rd-rend2/tr_glsl.cpp | 4 +- codemp/rd-rend2/tr_glsl_parse.cpp | 3 - codemp/rd-rend2/tr_image.cpp | 10 ++-- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 4 +- codemp/rd-rend2/tr_model.cpp | 6 +- codemp/rd-rend2/tr_shade.cpp | 95 ++----------------------------- codemp/rd-rend2/tr_shader.cpp | 2 + codemp/rd-rend2/tr_shadows.cpp | 3 +- codemp/rd-rend2/tr_sky.cpp | 1 - 16 files changed, 66 insertions(+), 193 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 8e5128f8ba..72ae005eac 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -889,7 +889,7 @@ qboolean G2API_SetSurfaceOnOff(CGhoul2Info_v &ghoul2, const char *surfaceName, c { CGhoul2Info *ghlInfo = NULL; - if (&ghoul2 && ghoul2.size()>0) + if (ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -1286,7 +1286,7 @@ qboolean G2API_SetBoneAnim(CGhoul2Info_v &ghoul2, const int modelIndex, const ch { setFrame=0.0f; } - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1488,7 +1488,7 @@ qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const const Eorientations up, const Eorientations left, const Eorientations forward, qhandle_t *modelList, int blendTime, int currentTime ) { - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; @@ -1825,7 +1825,7 @@ int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneN { // assert(ghoul2.size()>modelIndex); - if (&ghoul2 && ghoul2.size()>modelIndex) + if (ghoul2.size()>modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; if (G2_SetupModelPointers(ghlInfo)) @@ -1856,9 +1856,7 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In if (G2_SetupModelPointers(ghoul2From)&&G2_SetupModelPointers(ghoul2To)) { // make sure we have a model to attach, a model to attach to, and a bolt on that model - if (&ghoul2From && - &ghoul2To && - (ghoul2From.size() > modelFrom) && + if ((ghoul2From.size() > modelFrom) && (ghoul2To.size() > toModel) && ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) { @@ -1874,12 +1872,9 @@ qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2In void G2API_SetBoltInfo(CGhoul2Info_v &ghoul2, int modelIndex, int boltInfo) { - if (&ghoul2) + if (ghoul2.size() > modelIndex) { - if (ghoul2.size() > modelIndex) - { - ghoul2[modelIndex].mModelBoltLink = boltInfo; - } + ghoul2[modelIndex].mModelBoltLink = boltInfo; } } @@ -1922,7 +1917,7 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde { assert(ghoul2.size() > modelIndex); - if (&ghoul2 && (ghoul2.size() > modelIndex)) + if (ghoul2.size() > modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; @@ -2115,7 +2110,7 @@ void G2API_ListBones(CGhoul2Info *ghlInfo, int frame) qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2) { int i; - if (&ghoul2 && ghoul2.size()) + if (ghoul2.size()) { for (i=0; i modelFrom) { - // assume we actually have a model to copy from - if (ghoul2From.size() > modelFrom) + // if we don't have enough models on the to side, resize us so we do + if (ghoul2To.size() <= modelTo) { - // if we don't have enough models on the to side, resize us so we do - if (ghoul2To.size() <= modelTo) - { - assert (modelTo < 5); - ghoul2To.resize(modelTo + 1); + assert (modelTo < 5); + ghoul2To.resize(modelTo + 1); #if 0 - forceReconstruct = qtrue; + forceReconstruct = qtrue; #endif - } - // do the copy + } + // do the copy - if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) - { //remove the bonecache before we stomp over this instance. - if (ghoul2To[modelTo].mBoneCache) - { - RemoveBoneCache(ghoul2To[modelTo].mBoneCache); - ghoul2To[modelTo].mBoneCache = 0; - } + if (ghoul2To.IsValid() && ghoul2To.size() >= modelTo) + { //remove the bonecache before we stomp over this instance. + if (ghoul2To[modelTo].mBoneCache) + { + RemoveBoneCache(ghoul2To[modelTo].mBoneCache); + ghoul2To[modelTo].mBoneCache = 0; } - ghoul2To[modelTo] = ghoul2From[modelFrom]; + } + ghoul2To[modelTo] = ghoul2From[modelFrom]; #if 0 - if (forceReconstruct) - { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, - //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns - //a completely invalid matrix - ghoul2To[0].mSkelFrameNum = 0; - } -#endif + if (forceReconstruct) + { //rww - we should really do this shouldn't we? If we don't mark a reconstruct after this, + //and we do a GetBoltMatrix in the same frame, it doesn't reconstruct the skeleton and returns + //a completely invalid matrix + ghoul2To[0].mSkelFrameNum = 0; } +#endif } } @@ -2615,7 +2606,7 @@ char *G2API_GetGLAName(CGhoul2Info_v &ghoul2, int modelIndex) { if (G2_SetupModelPointers(ghoul2)) { - if (&ghoul2 && (ghoul2.size() > modelIndex)) + if (ghoul2.size() > modelIndex) { //model_t *mod = R_GetModelByHandle(RE_RegisterModel(ghoul2[modelIndex].mFileName)); //return mod->mdxm->animName; @@ -2631,7 +2622,7 @@ qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex) { CGhoul2Info *ghlInfo = NULL; - if (&ghoul2 && ghoul2.size()>0) + if (ghoul2.size()>0) { ghlInfo = &ghoul2[0]; } @@ -2642,7 +2633,6 @@ qboolean G2API_SetNewOrigin(CGhoul2Info_v &ghoul2, const int boltIndex) { char modelName[MAX_QPATH]; if (ghlInfo->currentModel && - ghlInfo->currentModel->name && ghlInfo->currentModel->name[0]) { strcpy(modelName, ghlInfo->currentModel->name); @@ -2718,7 +2708,7 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) for (i = 0; i < mdxm->numSurfaces; i++) { - if (surf->shader && surf->shader[0]) + if (surf->shader[0]) { //found a surface with a shader name, ok. return qfalse; } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 844ba81eed..2c7a1e28fc 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2434,23 +2434,6 @@ static const void *RB_EndTimedBlock( const void *data ) } -static void RB_Begin2DPass() -{ - if ( backEndData->currentPass ) - { - return; - } - - *backEndData->currentPass = {}; - backEndData->currentPass = ojkAllocArray(*backEndData->perFrameMemory, 8000); -} - -static void RB_End2DPass() -{ - -} - - /* ==================== RB_ExecuteRenderCommands diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 1ab2ad17a8..80edb4560d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2719,6 +2719,8 @@ R_LoadEntities void R_LoadEntities( lump_t *l ) { const char *p; char *token, *s; + char vertexRemapShaderText[] = "vertexremapshader"; + char remapShaderText[] = "remapshader"; char keyname[MAX_TOKEN_CHARS]; char value[MAX_TOKEN_CHARS]; world_t *w; @@ -2761,7 +2763,7 @@ void R_LoadEntities( lump_t *l ) { Q_strncpyz(value, token, sizeof(value)); // check for remapping of shaders for vertex lighting - s = "vertexremapshader"; + s = vertexRemapShaderText; if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { @@ -2775,7 +2777,7 @@ void R_LoadEntities( lump_t *l ) { continue; } // check for remapping of shaders - s = "remapshader"; + s = remapShaderText; if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 9cf5a6590b..db0ca58977 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -500,7 +500,7 @@ void GLimp_InitCoreFunctions() void GLW_InitTextureCompression( void ); void GLimp_InitExtensions() { - char *extension; + const char *extension; const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" }; Com_Printf ("Initializing OpenGL extensions\n" ); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 446c52f823..1ef2b0b9ce 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -113,22 +113,6 @@ qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); extern cvar_t *r_Ghoul2AnimSmooth; extern cvar_t *r_Ghoul2UnSqashAfterSmooth; -static inline int G2_Find_Bone_ByNum(const model_t *mod, boneInfo_v &blist, const int boneNum) -{ - size_t i = 0; - - while (i < blist.size()) - { - if (blist[i].boneNumber == boneNum) - { - return i; - } - i++; - } - - return -1; -} - const static mdxaBone_t identityMatrix = { { @@ -1343,7 +1327,7 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat skel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); //find/add the bone in the list - if (!skel->name || !skel->name[0]) + if (!skel->name[0]) { bListIndex = -1; } @@ -1382,7 +1366,7 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat pskel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[parent]); //taking bone matrix for the skeleton frame and parent's animFrameMatrix into account, determine our final animFrameMatrix - if (!pskel->name || !pskel->name[0]) + if (!pskel->name[0]) { parentBlistIndex = -1; } @@ -4240,8 +4224,6 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean float *v0, *v1, *v2; float *uv0, *uv1, *uv2; vec3_t normal = { 0.0f, 0.0f, 0.0f }; - vec3_t tangent = { 0.0f, 0.0f, 0.0f }; - vec3_t bitangent = { 0.0f, 0.0f, 0.0f }; index[0] = t[k].indexes[0]; index[1] = t[k].indexes[1]; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index debb01e67f..3a5980b9ce 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -51,7 +51,7 @@ const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { typedef struct uniformInfo_s { - char *name; + const char *name; int type; int size; } @@ -1871,7 +1871,6 @@ void GLSL_EndLoadGPUShaders ( int startTime ) for (i = 0; i < LIGHTDEF_COUNT; i++) { int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; - qboolean fastLight = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); // skip impossible combos if (!GLSL_IsValidPermutationForLight (lightType, i)) @@ -2307,6 +2306,7 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) case ATEST_CMP_LT: shaderAttribs |= GENERICDEF_USE_ATEST_LT; break; case ATEST_CMP_GT: shaderAttribs |= GENERICDEF_USE_ATEST_GT; break; case ATEST_CMP_GE: shaderAttribs |= GENERICDEF_USE_ATEST_GE; break; + default: break; } } diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index 4f7c47e385..33f1011d71 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -64,9 +64,6 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) int line = 1; while ( text[i] ) { - int markerStart = i; - int markerEnd = -1; - if ( strncmp(text + i, "/*[", 3) == 0 ) { int startHeaderTitle = i + 3; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 265758d665..2139dd2343 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -73,7 +73,7 @@ void R_GammaCorrect( byte *buffer, int bufSize ) { } typedef struct { - char *name; + const char *name; int minimize, maximize; } textureMode_t; @@ -181,7 +181,7 @@ int R_SumOfUsedImages( void ) { return total; } -static float GetReadableSize( int bytes, char **units ) +static float GetReadableSize( int bytes, const char **units ) { float result = bytes; *units = "b "; @@ -215,14 +215,14 @@ R_ImageList_f void R_ImageList_f( void ) { int i; int estTotalSize = 0; - char *sizeSuffix; + const char *sizeSuffix; image_t *image = tr.images; ri->Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); for ( i = 0 ; i < tr.numImages ; i++, image = image->poolNext ) { - char *format = "???? "; + const char *format = "???? "; int estSize; estSize = image->uploadHeight * image->uploadWidth; @@ -2305,6 +2305,7 @@ static image_t *R_AllocImage() return result; } +#if 0 static void R_FreeImage( image_t *imageToFree ) { if ( imageToFree ) @@ -2339,6 +2340,7 @@ static void R_FreeImage( image_t *imageToFree ) } } } +#endif /* ================ diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 65779e93ac..bf8913bf5e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -564,7 +564,7 @@ static void InitOpenGL( void ) GL_CheckErrors ================== */ -void GL_CheckErrs( char *file, int line ) { +void GL_CheckErrs( const char *file, int line ) { #if defined(_DEBUG) GLenum err; char s[64]; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 0fefa03b4d..df437e8d5a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2572,7 +2572,7 @@ void GL_BindToTMU( image_t *image, int tmu ); void GL_SetDefaultState (void); void GL_SelectTexture( int unit ); void GL_TextureMode( const char *string ); -void GL_CheckErrs( char *file, int line ); +void GL_CheckErrs( const char *file, int line ); #define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__) void GL_State( uint32_t stateVector ); void GL_SetProjectionMatrix(matrix_t matrix); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1770d126c2..a0c1d8fb0f 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2368,7 +2368,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) VectorScale(lightDir, -1.0f, shadow->lightViewAxis[0]); VectorSet(up, 0, 0, -1); - if ( abs(DotProduct(up, shadow->lightViewAxis[0])) > 0.9f ) + if ( fabs(DotProduct(up, shadow->lightViewAxis[0])) > 0.9f ) { VectorSet(up, -1, 0, 0); } @@ -2597,7 +2597,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) } // Check if too close to parallel to light direction - if (abs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) + if (fabs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) { if (lightViewIndependentOfCameraView) { diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index a563b35128..bf9578ff45 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -72,7 +72,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) - ident = LittleLong(ident); + LL(ident); switch(ident) { @@ -196,7 +196,7 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) typedef struct { - char *ext; + const char *ext; qhandle_t (*ModelLoader)( const char *, model_t * ); } modelExtToLoaderMap_t; @@ -650,7 +650,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) ident = *(unsigned *)buf; if( !bAlreadyCached ) - ident = LittleLong(ident); + LL(ident); switch(ident) { diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f217312667..b6f6be7a89 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -408,95 +408,6 @@ static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float defor } } - -static void ProjectDlightTexture( void ) { - int l; - vec3_t origin; - float scale; - float radius; - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; - - if ( !backEnd.refdef.num_dlights ) { - return; - } - - ComputeDeformValues(&deformType, &deformGen, deformParams); - - for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - dlight_t *dl; - shaderProgram_t *sp; - - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definately doesn't have any of this light - } - - dl = &backEnd.refdef.dlights[l]; - - GL_Bind( tr.dlightImage ); - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - uint32_t shaderCaps = 0; - if ( dl->additive ) { - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - shaderCaps |= DLIGHTDEF_USE_ATEST_GT; - } - else { - GL_State( GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL ); - shaderCaps |= DLIGHTDEF_USE_ATEST_GT; - } - - if ( deformGen != DGEN_NONE ) - { - shaderCaps |= DLIGHTDEF_USE_DEFORM_VERTEXES; - } - - backEnd.pc.c_dlightDraws++; - - sp = &tr.dlightShader[shaderCaps]; - GLSL_BindProgram(sp); - - VectorCopy( dl->transformed, origin ); - radius = dl->radius; - scale = 1.0f / radius; - - vec4_t color = {dl->color[0], dl->color[1], dl->color[2], 1.0f}; - vec4_t dlightInfo = {origin[0], origin[1], origin[2], scale}; - - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) - { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); - } - - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - GLSL_SetUniformVec4(sp, UNIFORM_DLIGHTINFO, dlightInfo); - - if (tess.multiDrawPrimitives) - { - shaderCommands_t *input = &tess; - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); - } - - backEnd.pc.c_totalIndexes += tess.numIndexes; - backEnd.pc.c_dlightIndexes += tess.numIndexes; - backEnd.pc.c_dlightVertexes += tess.numVertexes; - - RB_BinTriangleCounts(); - } -} - - static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend, colorGen_t *forceRGBGen, alphaGen_t *forceAlphaGen ) { colorGen_t rgbGen = pStage->rgbGen; @@ -1369,6 +1280,8 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag case ATEST_CMP_GE: index |= LIGHTDEF_USE_ATEST_GE; break; + default: + break; } } } @@ -1415,6 +1328,8 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag case ATEST_CMP_GE: index |= GENERICDEF_USE_ATEST_GE; break; + default: + break; } } } @@ -1476,6 +1391,8 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag case ATEST_CMP_GE: index |= LIGHTDEF_USE_ATEST_GE; break; + default: + break; } } } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 8610ce40f1..655e6a1039 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3040,6 +3040,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, case ATEST_CMP_GE: defs |= LIGHTDEF_USE_ATEST_GE; break; + default: + break; } //ri->Printf(PRINT_ALL, ".\n"); diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 025a858af6..9e9d40b27c 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -59,9 +59,8 @@ void R_AddEdgeDef( int i1, int i2, int facing ) { } void R_RenderShadowEdges( void ) { - int i; - #if 0 + int i; int numTris; // dumb way -- render every triangle's edges diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 65c06c7b82..bf9dfd1c55 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -367,7 +367,6 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max int firstVertex = tess.numVertexes; int minIndex = tess.minIndex; int maxIndex = tess.maxIndex; - vec4_t color; tess.firstIndex = tess.numIndexes; From ac9cce8275a4d12120742f245f1b5440ebea406f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 8 May 2016 10:27:29 +0100 Subject: [PATCH 378/708] Rend2: Added fog back with render pass code --- codemp/rd-rend2/tr_shade.cpp | 104 ++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 45 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b6f6be7a89..093e9c96de 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -666,6 +666,7 @@ static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, fl *eyeT = DotProduct( backEnd.ori.viewOrigin, fogDepthVector ) + fogDepthVector[3]; } else { + VectorClear4(fogDepthVector); *eyeT = 1; // non-surface fog always has eye inside } } @@ -1138,11 +1139,13 @@ RB_FogPass Blends a fog texture on top of everything else =================== */ -static void RB_FogPass( void ) { - fog_t *fog; - vec4_t color; - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; +static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) +{ + fog_t *fog; + vec4_t color; + vec4_t fogDistanceVector; + vec4_t fogDepthVector = {}; + float eyeT = 0; shaderProgram_t *sp; deform_t deformType; @@ -1150,69 +1153,82 @@ static void RB_FogPass( void ) { vec5_t deformParams; ComputeDeformValues(&deformType, &deformGen, deformParams); + ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - { - int index = 0; + cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); - if (deformGen != DGEN_NONE) - index |= FOGDEF_USE_DEFORM_VERTEXES; + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - if (glState.vertexAnimation) - index |= FOGDEF_USE_VERTEX_ANIMATION; + UniformDataWriter uniformDataWriter; - if (glState.skeletalAnimation) - index |= FOGDEF_USE_SKELETAL_ANIMATION; - - sp = &tr.fogShader[index]; - } + int shaderBits = 0; - backEnd.pc.c_fogDraws++; + if (deformGen != DGEN_NONE) + shaderBits |= FOGDEF_USE_DEFORM_VERTEXES; - GLSL_BindProgram(sp); + if (glState.vertexAnimation) + shaderBits |= FOGDEF_USE_VERTEX_ANIMATION; + + if (glState.skeletalAnimation) + shaderBits |= FOGDEF_USE_SKELETAL_ANIMATION; + + sp = tr.fogShader + shaderBits; + uniformDataWriter.Start(sp); + + backEnd.pc.c_fogDraws++; fog = tr.world->fogs + tess.fogNum; - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - GLSL_SetUniformInt(sp, UNIFORM_DEFORMTYPE, deformType); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); if (deformType != DEFORM_NONE) { - GLSL_SetUniformInt(sp, UNIFORM_DEFORMFUNC, deformGen); - GLSL_SetUniformFloatN(sp, UNIFORM_DEFORMPARAMS, deformParams, 7); - GLSL_SetUniformFloat(sp, UNIFORM_TIME, tess.shaderTime); + uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); + uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); + uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, color); - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - - GLSL_SetUniformVec4(sp, UNIFORM_FOGDISTANCE, fogDistanceVector); - GLSL_SetUniformVec4(sp, UNIFORM_FOGDEPTH, fogDepthVector); - GLSL_SetUniformFloat(sp, UNIFORM_FOGEYET, eyeT); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); + uint32_t stateBits = 0; if ( tess.shader->fogPass == FP_EQUAL ) { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL; } else { - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA ); + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; } - if (tess.multiDrawPrimitives) - { - shaderCommands_t *input = &tess; - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); - } -} + DrawItem item = {}; + item.stateBits = stateBits; + item.cullType = cullType; + item.program = sp; + item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); + + uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); +} static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) { @@ -1919,15 +1935,13 @@ void RB_StageIteratorGeneric( void ) { ForwardDlight( &vertexArrays ); } -#if 0 // // now do fog // if ( tess.fogNum && tess.shader->fogPass ) { - RB_FogPass(); + RB_FogPass( &tess, &vertexArrays ); } -#endif } RB_CommitInternalBufferData(); From 4610427461d1531ad500a23327029e1652322b23 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 8 May 2016 10:32:14 +0100 Subject: [PATCH 379/708] Rend2: Change fog color from packed byte to vec4_t Doesn't really make sense for the fog color to be packed into 4 bytes when at run time we just change it back to floats. --- codemp/rd-rend2/tr_bsp.cpp | 8 +++++--- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shade.cpp | 17 +++-------------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 80edb4560d..1a476d0020 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2578,9 +2578,11 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { out->parms = shader->fogParms; - out->colorInt = ColorBytes4 ( shader->fogParms.color[0] * tr.identityLight, - shader->fogParms.color[1] * tr.identityLight, - shader->fogParms.color[2] * tr.identityLight, 1.0 ); + VectorSet4(out->color, + shader->fogParms.color[0] * tr.identityLight, + shader->fogParms.color[1] * tr.identityLight, + shader->fogParms.color[2] * tr.identityLight, + 1.0); d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; out->tcScale = 1.0f / ( d * 8 ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index df437e8d5a..2937719962 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1340,7 +1340,7 @@ typedef struct { int originalBrushNumber; vec3_t bounds[2]; - unsigned colorInt; // in packed byte format + vec4_t color; float tcScale; // texture coordinate vector scales fogParms_t parms; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 093e9c96de..c14bcb9ffc 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -491,14 +491,8 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t break; case CGEN_FOG: { - fog_t *fog; - - fog = tr.world->fogs + tess.fogNum; - - baseColor[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; - baseColor[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; - baseColor[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; - baseColor[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; + fog_t *fog = tr.world->fogs + tess.fogNum; + VectorCopy4(fog->color, baseColor); } break; case CGEN_WAVEFORM: @@ -1192,12 +1186,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } - color[0] = ((unsigned char *)(&fog->colorInt))[0] / 255.0f; - color[1] = ((unsigned char *)(&fog->colorInt))[1] / 255.0f; - color[2] = ((unsigned char *)(&fog->colorInt))[2] / 255.0f; - color[3] = ((unsigned char *)(&fog->colorInt))[3] / 255.0f; - uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, color); - + uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); From b633d3e7c13825dc93360478c090f256e61dabf2 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 8 May 2016 10:46:01 +0100 Subject: [PATCH 380/708] Rend2: Remove unnecessary div/mul for fog --- codemp/rd-rend2/glsl/fogpass.glsl | 2 +- codemp/rd-rend2/glsl/generic.glsl | 2 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 10 +++------- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index bfd9699dae..9b25508dd4 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -175,7 +175,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) float CalcFog(vec3 position) { - float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; + float s = dot(vec4(position, 1.0), u_FogDistance); float t = dot(vec4(position, 1.0), u_FogDepth); float eyeOutside = float(u_FogEyeT < 0.0); diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 8fb346b5ed..5ad6309c6e 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -284,7 +284,7 @@ vec4 CalcColor(vec3 position, vec3 normal) #if defined(USE_FOG) float CalcFog(vec3 position) { - float s = dot(vec4(position, 1.0), u_FogDistance) * 8.0; + float s = dot(vec4(position, 1.0), u_FogDistance); float t = dot(vec4(position, 1.0), u_FogDepth); float eyeOutside = float(u_FogEyeT < 0.0); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 1a476d0020..f0d41c9604 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2585,7 +2585,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { 1.0); d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; - out->tcScale = 1.0f / ( d * 8 ); + out->tcScale = 1.0f / d; // set the gradient vector sideNum = LittleLong( fogs->visibleSide ); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c14bcb9ffc..dbe53904e7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1191,13 +1191,9 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); - uint32_t stateBits = 0; - if ( tess.shader->fogPass == FP_EQUAL ) { - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL; - } else { - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - } - + uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + if ( tess.shader->fogPass == FP_EQUAL ) + stateBits |= GLS_DEPTHFUNC_EQUAL; DrawItem item = {}; item.stateBits = stateBits; From a31430ecb481a0cbe38a07bcae7421f13d6158fe Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 15 May 2016 20:33:51 +0100 Subject: [PATCH 381/708] Rend2: Basic reimplementation of fog Currently uses a linear falloff for fog thickness so doesn't match original JKA at the moment. Also doesn't implement 'global fog', which JKA introduced and doesn't exist at all yet in rend2. --- codemp/rd-rend2/glsl/fogpass.glsl | 62 ++++++++++++++++++++----------- codemp/rd-rend2/tr_bsp.cpp | 1 + codemp/rd-rend2/tr_glsl.cpp | 3 ++ codemp/rd-rend2/tr_local.h | 4 ++ codemp/rd-rend2/tr_shade.cpp | 7 ++-- 5 files changed, 52 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 9b25508dd4..d80c90c503 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -12,10 +12,6 @@ in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; - #if defined(USE_DEFORM_VERTEXES) uniform int u_DeformType; uniform int u_DeformFunc; @@ -33,7 +29,7 @@ uniform mat4x3 u_BoneMatrices[20]; uniform vec4 u_Color; -out float var_Scale; +out vec3 var_WSPosition; #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) @@ -173,20 +169,6 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) } #endif -float CalcFog(vec3 position) -{ - float s = dot(vec4(position, 1.0), u_FogDistance); - float t = dot(vec4(position, 1.0), u_FogDepth); - - float eyeOutside = float(u_FogEyeT < 0.0); - float fogged = float(t >= eyeOutside); - - t += 1e-6; - t *= fogged / (t - u_FogEyeT * eyeOutside); - - return s * t; -} - void main() { #if defined(USE_VERTEX_ANIMATION) @@ -228,7 +210,7 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - var_Scale = CalcFog(position) * u_Color.a * u_Color.a; + var_WSPosition = position; } /*[Fragment]*/ @@ -237,15 +219,51 @@ uniform vec4 u_Color; uniform float u_AlphaTestValue; #endif -in float var_Scale; +uniform vec4 u_FogPlane; +uniform float u_FogDepthToOpaque; +uniform bool u_FogHasPlane; +uniform vec3 u_ViewOrigin; +in vec3 var_WSPosition; out vec4 out_Color; out vec4 out_Glow; +float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane) +{ + // line: x = o + tv + // plane: (x . n) + d = 0 + // intersects: dot(o + tv, n) + d = 0 + // dot(o + tv, n) = -d + // dot(o, n) + t*dot(n, v) = -d + // t = -(d + dot(o, n)) / dot(n, v) + vec3 V = position - viewOrigin; + + // fogPlane is inverted in tr_bsp for some reason. + float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz); + + bool inFog = ((dot(viewOrigin, fogPlane.xyz) - fogPlane.w) >= 0.0) || !hasPlane; + bool intersects = (t > 0.0 && t <= 1.0); + + // this is valid only when t > 0.0. When t < 0.0, then intersection point is behind + // the camera, meaning we're facing away from the fog plane, which probably means + // we're inside the fog volume. + vec3 intersectsAt = viewOrigin + t*V; + + float distToVertexFromIntersection = distance(intersectsAt, position); + float distToVertexFromViewOrigin = distance(viewOrigin, position); + + float distToVertex = mix(distToVertexFromViewOrigin, + distToVertexFromIntersection, + !inFog && intersects); + + return min(distToVertex / depthToOpaque, 1.0); +} + void main() { + float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane); out_Color.rgb = u_Color.rgb; - out_Color.a = sqrt(clamp(var_Scale, 0.0, 1.0)); + out_Color.a = sqrt(clamp(fog, 0.0, 1.0)); #if defined(USE_ATEST) # if USE_ATEST == ATEST_CMP_LT diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f0d41c9604..9ee058e365 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2586,6 +2586,7 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; out->tcScale = 1.0f / d; + out->depthToOpaque = d; // set the gradient vector sideNum = LittleLong( fogs->visibleSide ); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3a5980b9ce..d9c36bc84a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -116,6 +116,9 @@ static uniformInfo_t uniformsInfo[] = { "u_FogDepth", GLSL_VEC4, 1 }, { "u_FogEyeT", GLSL_FLOAT, 1 }, { "u_FogColorMask", GLSL_VEC4, 1 }, + { "u_FogPlane", GLSL_VEC4, 1 }, + { "u_FogHasPlane", GLSL_INT, 1 }, + { "u_FogDepthToOpaque", GLSL_FLOAT, 1 }, { "u_ModelMatrix", GLSL_MAT4x4, 1 }, { "u_ModelViewProjectionMatrix", GLSL_MAT4x4, 1 }, diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2937719962..27428d0403 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1211,6 +1211,9 @@ typedef enum UNIFORM_FOGDEPTH, UNIFORM_FOGEYET, UNIFORM_FOGCOLORMASK, + UNIFORM_FOGPLANE, + UNIFORM_FOGHASPLANE, + UNIFORM_FOGDEPTHTOOPAQUE, UNIFORM_MODELMATRIX, UNIFORM_MODELVIEWPROJECTIONMATRIX, @@ -1342,6 +1345,7 @@ typedef struct { vec4_t color; float tcScale; // texture coordinate vector scales + float depthToOpaque; fogParms_t parms; // for clipping distance in fog when outside diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index dbe53904e7..8f8a395a67 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1187,9 +1187,10 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v } uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); + uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->depthToOpaque); + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) From 529730cdd1c0a05687b52af5b21f43154703486f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 17 May 2016 07:57:02 +0100 Subject: [PATCH 382/708] Rend2: Fix fog for models Still some issues remaining with ghoul2 models and the view weapon seems to be rendered in the wrong place now. --- codemp/rd-rend2/glsl/fogpass.glsl | 3 +- codemp/rd-rend2/glsl/generic.glsl | 80 +++++++++++++++++++++---------- codemp/rd-rend2/tr_backend.cpp | 10 ++-- codemp/rd-rend2/tr_local.h | 10 ++-- codemp/rd-rend2/tr_main.cpp | 2 + codemp/rd-rend2/tr_shade.cpp | 36 +++++--------- 6 files changed, 82 insertions(+), 59 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index d80c90c503..f62513e119 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -19,6 +19,7 @@ uniform float u_DeformParams[7]; #endif uniform float u_Time; +uniform mat4 u_ModelMatrix; uniform mat4 u_ModelViewProjectionMatrix; #if defined(USE_VERTEX_ANIMATION) @@ -210,7 +211,7 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - var_WSPosition = position; + var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; } /*[Fragment]*/ diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 5ad6309c6e..fb524f7d17 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -30,13 +30,6 @@ uniform vec3 u_TCGen0Vector0; uniform vec3 u_TCGen0Vector1; #endif -#if defined(USE_FOG) -uniform vec4 u_FogDistance; -uniform vec4 u_FogDepth; -uniform float u_FogEyeT; -uniform vec4 u_FogColorMask; -#endif - #if defined(USE_DEFORM_VERTEXES) uniform int u_DeformType; uniform int u_DeformFunc; @@ -45,6 +38,7 @@ uniform float u_Time; #endif uniform mat4 u_ModelViewProjectionMatrix; +uniform mat4 u_ModelMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; @@ -68,6 +62,9 @@ uniform mat4x3 u_BoneMatrices[20]; out vec2 var_DiffuseTex; out vec4 var_Color; +#if defined(USE_FOG) +out vec3 var_WSPosition; +#endif #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) @@ -281,22 +278,6 @@ vec4 CalcColor(vec3 position, vec3 normal) } #endif -#if defined(USE_FOG) -float CalcFog(vec3 position) -{ - float s = dot(vec4(position, 1.0), u_FogDistance); - float t = dot(vec4(position, 1.0), u_FogDepth); - - float eyeOutside = float(u_FogEyeT < 0.0); - float fogged = float(t < eyeOutside); - - t += 1e-6; - t *= fogged / (t - u_FogEyeT * eyeOutside); - - return s * t; -} -#endif - void main() { #if defined(USE_VERTEX_ANIMATION) @@ -369,7 +350,7 @@ void main() } #if defined(USE_FOG) - var_Color *= vec4(1.0) - u_FogColorMask * sqrt(clamp(CalcFog(position), 0.0, 1.0)); + var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; #endif } @@ -380,13 +361,57 @@ uniform sampler2D u_DiffuseMap; uniform float u_AlphaTestValue; #endif -in vec2 var_DiffuseTex; +#if defined(USE_FOG) +uniform vec4 u_FogPlane; +uniform float u_FogDepthToOpaque; +uniform bool u_FogHasPlane; +uniform vec3 u_ViewOrigin; +uniform vec4 u_FogColorMask; +#endif +in vec2 var_DiffuseTex; in vec4 var_Color; +#if defined(USE_FOG) +in vec3 var_WSPosition; +#endif out vec4 out_Color; out vec4 out_Glow; + +#if defined(USE_FOG) +float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane) +{ + // line: x = o + tv + // plane: (x . n) + d = 0 + // intersects: dot(o + tv, n) + d = 0 + // dot(o + tv, n) = -d + // dot(o, n) + t*dot(n, v) = -d + // t = -(d + dot(o, n)) / dot(n, v) + vec3 V = position - viewOrigin; + + // fogPlane is inverted in tr_bsp for some reason. + float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz); + + bool inFog = ((dot(viewOrigin, fogPlane.xyz) - fogPlane.w) >= 0.0) || !hasPlane; + bool intersects = (t > 0.0 && t <= 1.0); + + // this is valid only when t > 0.0. When t < 0.0, then intersection point is behind + // the camera, meaning we're facing away from the fog plane, which probably means + // we're inside the fog volume. + vec3 intersectsAt = viewOrigin + t*V; + + float distToVertexFromIntersection = distance(intersectsAt, position); + float distToVertexFromViewOrigin = distance(viewOrigin, position); + + float distToVertex = mix(distToVertexFromViewOrigin, + distToVertexFromIntersection, + !inFog && intersects); + + return min(distToVertex / depthToOpaque, 1.0); +} +#endif + void main() { vec4 color = texture(u_DiffuseMap, var_DiffuseTex); @@ -402,6 +427,11 @@ void main() discard; #endif +#if defined(USE_FOG) + float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane); + color *= vec4(1.0) - u_FogColorMask * fog; +#endif + out_Color = color * var_Color; #if defined(USE_GLOW_BUFFER) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 2c7a1e28fc..c6055b79a6 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -662,7 +662,7 @@ UniformDataWriter& UniformDataWriter::SetUniformVec2( uniform_t uniform, float x return SetUniformVec2(uniform, values); } -UniformDataWriter& UniformDataWriter::SetUniformVec2( uniform_t uniform, float *values, size_t count ) +UniformDataWriter& UniformDataWriter::SetUniformVec2( uniform_t uniform, const float *values, size_t count ) { if ( shaderProgram->uniforms[uniform] == -1 ) return *this; @@ -688,7 +688,7 @@ UniformDataWriter& UniformDataWriter::SetUniformVec3( uniform_t uniform, float x return SetUniformVec3(uniform, values); } -UniformDataWriter& UniformDataWriter::SetUniformVec3( uniform_t uniform, float *values, size_t count ) +UniformDataWriter& UniformDataWriter::SetUniformVec3( uniform_t uniform, const float *values, size_t count ) { if ( shaderProgram->uniforms[uniform] == -1 ) return *this; @@ -714,7 +714,7 @@ UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, float x return SetUniformVec4(uniform, values); } -UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, float *values, size_t count ) +UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, const float *values, size_t count ) { if ( shaderProgram->uniforms[uniform] == -1 ) return *this; @@ -734,7 +734,7 @@ UniformDataWriter& UniformDataWriter::SetUniformVec4( uniform_t uniform, float * return *this; } -UniformDataWriter& UniformDataWriter::SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count ) +UniformDataWriter& UniformDataWriter::SetUniformMatrix4x3( uniform_t uniform, const float *matrix, size_t count ) { if ( shaderProgram->uniforms[uniform] == -1 ) return *this; @@ -754,7 +754,7 @@ UniformDataWriter& UniformDataWriter::SetUniformMatrix4x3( uniform_t uniform, fl return *this; } -UniformDataWriter& UniformDataWriter::SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count ) +UniformDataWriter& UniformDataWriter::SetUniformMatrix4x4( uniform_t uniform, const float *matrix, size_t count ) { if ( shaderProgram->uniforms[uniform] == -1 ) return *this; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 27428d0403..72d6d97292 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3447,16 +3447,16 @@ class UniformDataWriter UniformDataWriter& SetUniformFloat( uniform_t uniform, float *values, size_t count ); UniformDataWriter& SetUniformVec2( uniform_t uniform, float x, float y ); - UniformDataWriter& SetUniformVec2( uniform_t uniform, float *values, size_t count = 1 ); + UniformDataWriter& SetUniformVec2( uniform_t uniform, const float *values, size_t count = 1 ); UniformDataWriter& SetUniformVec3( uniform_t uniform, float x, float y, float z ); - UniformDataWriter& SetUniformVec3( uniform_t uniform, float *values, size_t count = 1 ); + UniformDataWriter& SetUniformVec3( uniform_t uniform, const float *values, size_t count = 1 ); UniformDataWriter& SetUniformVec4( uniform_t uniform, float x, float y, float z, float w ); - UniformDataWriter& SetUniformVec4( uniform_t uniform, float *values, size_t count = 1 ); + UniformDataWriter& SetUniformVec4( uniform_t uniform, const float *values, size_t count = 1 ); - UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, float *matrix, size_t count = 1 ); - UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, float *matrix, size_t count = 1 ); + UniformDataWriter& SetUniformMatrix4x3( uniform_t uniform, const float *matrix, size_t count = 1 ); + UniformDataWriter& SetUniformMatrix4x4( uniform_t uniform, const float *matrix, size_t count = 1 ); UniformData *Finish( Allocator& destHeap ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index a0c1d8fb0f..8dca662b0f 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -803,9 +803,11 @@ static void R_RotateForViewer(viewParms_t *viewParms) viewerMatrix[11] = 0; viewerMatrix[15] = 1; + // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelViewMatrix ); + Matrix16Identity(tr.ori.modelMatrix); viewParms->world = tr.ori; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 8f8a395a67..f32c496a46 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1136,10 +1136,6 @@ Blends a fog texture on top of everything else static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { fog_t *fog; - vec4_t color; - vec4_t fogDistanceVector; - vec4_t fogDepthVector = {}; - float eyeT = 0; shaderProgram_t *sp; deform_t deformType; @@ -1147,7 +1143,6 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v vec5_t deformParams; ComputeDeformValues(&deformType, &deformGen, deformParams); - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); @@ -1175,6 +1170,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v fog = tr.world->fogs + tess.fogNum; uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); @@ -1418,19 +1414,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - int stage; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - deform_t deformType; genFunc_t deformGen; float deformParams[7]; ComputeDeformValues(&deformType, &deformGen, deformParams); - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; @@ -1439,7 +1428,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays UniformDataWriter uniformDataWriter; SamplerBindingsWriter samplerBindingsWriter; - for ( stage = 0; stage < MAX_SHADER_STAGES; stage++ ) + for ( int stage = 0; stage < MAX_SHADER_STAGES; stage++ ) { shaderStage_t *pStage = input->xstages[stage]; shaderProgram_t *sp; @@ -1519,9 +1508,17 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } if ( input->fogNum ) { - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); + const fog_t *fog = tr.world->fogs + input->fogNum; + + uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); + uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->depthToOpaque); + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); + + vec4_t fogColorMask; + ComputeFogColorMask(pStage, fogColorMask); + uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); } float volumetricBaseValue = -1.0f; @@ -1582,13 +1579,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, forceRGBGen); uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, forceAlphaGen); - if ( input->fogNum ) - { - vec4_t fogColorMask; - ComputeFogColorMask(pStage, fogColorMask); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); - } - ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); From 8b67447b303d8c177c21758c572d15d25c22aae0 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 22 May 2016 16:04:26 +0100 Subject: [PATCH 383/708] Rend2: Fix fog on ghoul2 models Forgot to set extra vertex attributes on the fog shader for skeletal animations. Also wasn't setting bone matrices during fog pass. --- codemp/rd-rend2/tr_glsl.cpp | 3 +++ codemp/rd-rend2/tr_shade.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d9c36bc84a..7d1935ea1e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1319,7 +1319,10 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); if (i & FOGDEF_USE_SKELETAL_ANIMATION) + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); + attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; + } switch ( i & FOGDEF_USE_ATEST_MASK ) { diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f32c496a46..126c2b79f2 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1173,6 +1173,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); if (deformType != DEFORM_NONE) From 6239840bead43f747500e5350362c47f2d2d7b25 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 24 May 2016 21:02:09 +0100 Subject: [PATCH 384/708] Implement global fog Not quite a full implementation - still need to clear the sky, but I'm planning to make a few changes around that area of code so I will do that at a later time. Also extended all the BSP loading functions to take a world_t* in preparation of loading multiple BSPs. --- codemp/rd-rend2/glsl/fogpass.glsl | 3 +- codemp/rd-rend2/tr_bsp.cpp | 451 +++++++++++++++--------------- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shade.cpp | 22 +- 4 files changed, 241 insertions(+), 237 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index f62513e119..633cf86ea6 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -257,7 +257,8 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d distToVertexFromIntersection, !inFog && intersects); - return min(distToVertex / depthToOpaque, 1.0); + float z = depthToOpaque * distToVertex; + return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } void main() diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 9ee058e365..b6cb69b233 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -199,7 +199,7 @@ R_LoadLightmaps */ #define DEFAULT_LIGHTMAP_SIZE 128 #define MAX_LIGHTMAP_PAGES 2 -static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { +static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { byte *buf, *buf_p; dsurface_t *surf; int len; @@ -329,7 +329,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) { // look for hdr lightmaps if (r_hdr->integer) { - Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", s_worldData.baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); + Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); //ri->Printf(PRINT_ALL, "looking for %s\n", filename); size = ri->FS_ReadFile(filename, (void **)&hdrLightmap); @@ -596,7 +596,7 @@ void RE_SetWorldVisData( const byte *vis ) { R_LoadVisibility ================= */ -static void R_LoadVisibility( lump_t *l ) { +static void R_LoadVisibility( world_t *worldData, lump_t *l ) { int len; byte *buf; @@ -606,19 +606,19 @@ static void R_LoadVisibility( lump_t *l ) { } buf = fileBase + l->fileofs; - s_worldData.numClusters = LittleLong( ((int *)buf)[0] ); - s_worldData.clusterBytes = LittleLong( ((int *)buf)[1] ); + worldData->numClusters = LittleLong( ((int *)buf)[0] ); + worldData->clusterBytes = LittleLong( ((int *)buf)[1] ); // CM_Load should have given us the vis data to share, so // we don't need to allocate another copy if ( tr.externalVisData ) { - s_worldData.vis = tr.externalVisData; + worldData->vis = tr.externalVisData; } else { byte *dest; dest = (byte *)ri->Hunk_Alloc( len - 8, h_low ); Com_Memcpy( dest, buf + 8, len - 8 ); - s_worldData.vis = dest; + worldData->vis = dest; } } @@ -630,16 +630,16 @@ static void R_LoadVisibility( lump_t *l ) { ShaderForShaderNum =============== */ -static shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNums, const byte *lightmapStyles, const byte *vertexStyles ) { +static shader_t *ShaderForShaderNum( const world_t *worldData, int shaderNum, const int *lightmapNums, const byte *lightmapStyles, const byte *vertexStyles ) { shader_t *shader; dshader_t *dsh; const byte *styles = lightmapStyles; int _shaderNum = LittleLong( shaderNum ); - if ( _shaderNum < 0 || _shaderNum >= s_worldData.numShaders ) { + if ( _shaderNum < 0 || _shaderNum >= worldData->numShaders ) { ri->Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); } - dsh = &s_worldData.shaders[ _shaderNum ]; + dsh = &worldData->shaders[ _shaderNum ]; if ( lightmapNums[0] == LIGHTMAP_BY_VERTEX ) { styles = vertexStyles; @@ -669,7 +669,7 @@ static shader_t *ShaderForShaderNum( int shaderNum, const int *lightmapNums, con ParseFace =============== */ -static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { +static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { int i, j; srfBspSurface_t *cv; glIndex_t *tri; @@ -688,7 +688,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles); + surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -827,7 +827,7 @@ static void ParseFace( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, ParseMesh =============== */ -static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { +static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { srfBspSurface_t *grid; int i, j; int width, height, numPoints; @@ -849,14 +849,14 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader value - surf->shader = ShaderForShaderNum( ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); + surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } // we may have a nodraw surface, because they might still need to // be around for movement clipping - if ( s_worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) { + if ( worldData->shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) { surf->data = &skipData; return; } @@ -939,7 +939,7 @@ static void ParseMesh ( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, ParseTriSurf =============== */ -static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { +static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { srfBspSurface_t *cv; glIndex_t *tri; int i, j; @@ -952,7 +952,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); + surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -1074,7 +1074,7 @@ static void ParseTriSurf( dsurface_t *ds, drawVert_t *verts, float *hdrVertColor ParseFlare =============== */ -static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes ) { +static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes ) { srfFlare_t *flare; int i; @@ -1085,7 +1085,7 @@ static void ParseFlare( dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader - surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); + surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -1155,13 +1155,13 @@ NOTE: never sync LoD through grid edges with merged points! FIXME: write generalized version that also avoids cracks between a patch and one that meets half way? ================= */ -void R_FixSharedVertexLodError_r( int start, srfBspSurface_t *grid1 ) { +void R_FixSharedVertexLodError_r( world_t *worldData, int start, srfBspSurface_t *grid1 ) { int j, k, l, m, n, offset1, offset2, touch; srfBspSurface_t *grid2; - for ( j = start; j < s_worldData.numsurfaces; j++ ) { + for ( j = start; j < worldData->numsurfaces; j++ ) { // - grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; + grid2 = (srfBspSurface_t *) worldData->surfaces[j].data; // if this surface is not a grid if ( grid2->surfaceType != SF_GRID ) continue; // if the LOD errors are already fixed for this patch @@ -1252,7 +1252,7 @@ void R_FixSharedVertexLodError_r( int start, srfBspSurface_t *grid1 ) { } if (touch) { grid2->lodFixed = 2; - R_FixSharedVertexLodError_r ( start, grid2 ); + R_FixSharedVertexLodError_r ( worldData, start, grid2 ); //NOTE: this would be correct but makes things really slow //grid2->lodFixed = 1; } @@ -1267,13 +1267,13 @@ This function assumes that all patches in one group are nicely stitched together If this is not the case this function will still do its job but won't fix the highest LoD cracks. ================= */ -void R_FixSharedVertexLodError( void ) { +void R_FixSharedVertexLodError( world_t *worldData ) { int i; srfBspSurface_t *grid1; - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + for ( i = 0; i < worldData->numsurfaces; i++ ) { // - grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; + grid1 = (srfBspSurface_t *) worldData->surfaces[i].data; // if this surface is not a grid if ( grid1->surfaceType != SF_GRID ) continue; @@ -1283,7 +1283,7 @@ void R_FixSharedVertexLodError( void ) { // grid1->lodFixed = 2; // recursively fix other patches in the same LOD group - R_FixSharedVertexLodError_r( i + 1, grid1); + R_FixSharedVertexLodError_r( worldData, i + 1, grid1); } } @@ -1293,13 +1293,13 @@ void R_FixSharedVertexLodError( void ) { R_StitchPatches =============== */ -int R_StitchPatches( int grid1num, int grid2num ) { +int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { float *v1, *v2; srfBspSurface_t *grid1, *grid2; int k, l, m, n, offset1, offset2, row, column; - grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; - grid2 = (srfBspSurface_t *) s_worldData.surfaces[grid2num].data; + grid1 = (srfBspSurface_t *) worldData->surfaces[grid1num].data; + grid2 = (srfBspSurface_t *) worldData->surfaces[grid2num].data; for (n = 0; n < 2; n++) { // if (n) offset1 = (grid1->height-1) * grid1->width; @@ -1348,7 +1348,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1392,7 +1392,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1445,7 +1445,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1489,7 +1489,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1543,7 +1543,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1589,7 +1589,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { if (!grid2) break; grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1642,7 +1642,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertColumn( grid2, l+1, row, grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1686,7 +1686,7 @@ int R_StitchPatches( int grid1num, int grid2num ) { grid2 = R_GridInsertRow( grid2, l+1, column, grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]); grid2->lodStitched = qfalse; - s_worldData.surfaces[grid2num].data = (surfaceType_t *) grid2; + worldData->surfaces[grid2num].data = (surfaceType_t *) grid2; return qtrue; } } @@ -1708,15 +1708,15 @@ of the patch (on the same row or column) the vertices will not be joined and cra might still appear at that side. =============== */ -int R_TryStitchingPatch( int grid1num ) { +int R_TryStitchingPatch( world_t *worldData, int grid1num ) { int j, numstitches; srfBspSurface_t *grid1, *grid2; numstitches = 0; - grid1 = (srfBspSurface_t *) s_worldData.surfaces[grid1num].data; - for ( j = 0; j < s_worldData.numsurfaces; j++ ) { + grid1 = (srfBspSurface_t *) worldData->surfaces[grid1num].data; + for ( j = 0; j < worldData->numsurfaces; j++ ) { // - grid2 = (srfBspSurface_t *) s_worldData.surfaces[j].data; + grid2 = (srfBspSurface_t *) worldData->surfaces[j].data; // if this surface is not a grid if ( grid2->surfaceType != SF_GRID ) continue; // grids in the same LOD group should have the exact same lod radius @@ -1726,7 +1726,7 @@ int R_TryStitchingPatch( int grid1num ) { if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue; if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue; // - while (R_StitchPatches(grid1num, j)) + while (R_StitchPatches(worldData, grid1num, j)) { numstitches++; } @@ -1739,7 +1739,7 @@ int R_TryStitchingPatch( int grid1num ) { R_StitchAllPatches =============== */ -void R_StitchAllPatches( void ) { +void R_StitchAllPatches( world_t *worldData ) { int i, stitched, numstitches; srfBspSurface_t *grid1; @@ -1747,9 +1747,9 @@ void R_StitchAllPatches( void ) { do { stitched = qfalse; - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + for ( i = 0; i < worldData->numsurfaces; i++ ) { // - grid1 = (srfBspSurface_t *) s_worldData.surfaces[i].data; + grid1 = (srfBspSurface_t *) worldData->surfaces[i].data; // if this surface is not a grid if ( grid1->surfaceType != SF_GRID ) continue; @@ -1760,7 +1760,7 @@ void R_StitchAllPatches( void ) { grid1->lodStitched = qtrue; stitched = qtrue; // - numstitches += R_TryStitchingPatch( i ); + numstitches += R_TryStitchingPatch( worldData, i ); } } while (stitched); @@ -1772,13 +1772,13 @@ void R_StitchAllPatches( void ) { R_MovePatchSurfacesToHunk =============== */ -void R_MovePatchSurfacesToHunk(void) { +void R_MovePatchSurfacesToHunk( world_t *worldData ) { int i, size; srfBspSurface_t *grid, *hunkgrid; - for ( i = 0; i < s_worldData.numsurfaces; i++ ) { + for ( i = 0; i < worldData->numsurfaces; i++ ) { // - grid = (srfBspSurface_t *) s_worldData.surfaces[i].data; + grid = (srfBspSurface_t *) worldData->surfaces[i].data; // if this surface is not a grid if ( grid->surfaceType != SF_GRID ) continue; @@ -1803,7 +1803,7 @@ void R_MovePatchSurfacesToHunk(void) { R_FreeSurfaceGridMesh( grid ); - s_worldData.surfaces[i].data = (surfaceType_t *) hunkgrid; + worldData->surfaces[i].data = (surfaceType_t *) hunkgrid; } } @@ -1861,7 +1861,7 @@ struct packedVertex_t R_CreateWorldVBOs =============== */ -static void R_CreateWorldVBOs(void) +static void R_CreateWorldVBOs( world_t *worldData ) { int i, j, k; @@ -1887,7 +1887,7 @@ static void R_CreateWorldVBOs(void) // count surfaces numSortedSurfaces = 0; - for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) + for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) { srfBspSurface_t *bspSurf; shader_t *shader = surface->shader; @@ -1917,7 +1917,7 @@ static void R_CreateWorldVBOs(void) surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); j = 0; - for(surface = &s_worldData.surfaces[0]; surface < &s_worldData.surfaces[s_worldData.numsurfaces]; surface++) + for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) { srfBspSurface_t *bspSurf; shader_t *shader = surface->shader; @@ -2106,7 +2106,7 @@ static void R_CreateWorldVBOs(void) R_LoadSurfaces =============== */ -static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { +static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lump_t *indexLump ) { dsurface_t *in; msurface_t *out; drawVert_t *dv; @@ -2122,24 +2122,24 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { numFlares = 0; if (surfs->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = surfs->filelen / sizeof(*in); dv = (drawVert_t *)(fileBase + verts->fileofs); if (verts->filelen % sizeof(*dv)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); indexes = (int *)(fileBase + indexLump->fileofs); if ( indexLump->filelen % sizeof(*indexes)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); out = (msurface_t *)ri->Hunk_Alloc ( count * sizeof(*out), h_low ); - s_worldData.surfaces = out; - s_worldData.numsurfaces = count; - s_worldData.surfacesViewCount = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesViewCount), h_low ); - s_worldData.surfacesDlightBits = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesDlightBits), h_low ); - s_worldData.surfacesPshadowBits = (int *)ri->Hunk_Alloc ( count * sizeof(*s_worldData.surfacesPshadowBits), h_low ); + worldData->surfaces = out; + worldData->numsurfaces = count; + worldData->surfacesViewCount = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesViewCount), h_low ); + worldData->surfacesDlightBits = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesDlightBits), h_low ); + worldData->surfacesPshadowBits = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesPshadowBits), h_low ); // load hdr vertex colors if (r_hdr->integer) @@ -2147,7 +2147,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { char filename[MAX_QPATH]; int size; - Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", s_worldData.baseName); + Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", worldData->baseName); //ri->Printf(PRINT_ALL, "looking for %s\n", filename); size = ri->FS_ReadFile(filename, (void **)&hdrVertColors); @@ -2165,7 +2165,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { // This ensures surfaces are close together to reduce L2 cache misses when using VBOs, // which don't actually use the verts and indexes in = (dsurface_t *)(fileBase + surfs->fileofs); - out = s_worldData.surfaces; + out = worldData->surfaces; for ( i = 0 ; i < count ; i++, in++, out++ ) { switch ( LittleLong( in->surfaceType ) ) { case MST_PATCH: @@ -2186,11 +2186,11 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { } in = (dsurface_t *)(fileBase + surfs->fileofs); - out = s_worldData.surfaces; + out = worldData->surfaces; for ( i = 0 ; i < count ; i++, in++, out++ ) { switch ( LittleLong( in->surfaceType ) ) { case MST_PATCH: - ParseMesh ( in, dv, hdrVertColors, out ); + ParseMesh ( worldData, in, dv, hdrVertColors, out ); { srfBspSurface_t *surface = (srfBspSurface_t *)out->data; @@ -2203,15 +2203,15 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { numMeshes++; break; case MST_TRIANGLE_SOUP: - ParseTriSurf( in, dv, hdrVertColors, out, indexes ); + ParseTriSurf( worldData, in, dv, hdrVertColors, out, indexes ); numTriSurfs++; break; case MST_PLANAR: - ParseFace( in, dv, hdrVertColors, out, indexes ); + ParseFace( worldData, in, dv, hdrVertColors, out, indexes ); numFaces++; break; case MST_FLARE: - ParseFlare( in, dv, out, indexes ); + ParseFlare( worldData, in, dv, out, indexes ); { out->cullinfo.type = CULLINFO_NONE; } @@ -2228,13 +2228,13 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { } #ifdef PATCH_STITCHING - R_StitchAllPatches(); + R_StitchAllPatches(worldData); #endif - R_FixSharedVertexLodError(); + R_FixSharedVertexLodError(worldData); #ifdef PATCH_STITCHING - R_MovePatchSurfacesToHunk(); + R_MovePatchSurfacesToHunk(worldData); #endif ri->Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", @@ -2248,18 +2248,18 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump ) { R_LoadSubmodels ================= */ -static void R_LoadSubmodels( lump_t *l ) { +static void R_LoadSubmodels( world_t *worldData, lump_t *l ) { dmodel_t *in; bmodel_t *out; int i, j, count; in = (dmodel_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - s_worldData.numBModels = count; - s_worldData.bmodels = out = (bmodel_t *)ri->Hunk_Alloc( count * sizeof(*out), h_low ); + worldData->numBModels = count; + worldData->bmodels = out = (bmodel_t *)ri->Hunk_Alloc( count * sizeof(*out), h_low ); for ( i=0 ; inumSurfaces; + worldData->numWorldSurfaces = out->numSurfaces; } } } @@ -2316,7 +2316,7 @@ static void R_SetParent (mnode_t *node, mnode_t *parent) R_LoadNodesAndLeafs ================= */ -static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { +static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *leafLump) { int i, j, p; dnode_t *in; dleaf_t *inLeaf; @@ -2326,16 +2326,16 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { in = (dnode_t *)(fileBase + nodeLump->fileofs); if (nodeLump->filelen % sizeof(dnode_t) || leafLump->filelen % sizeof(dleaf_t) ) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } numNodes = nodeLump->filelen / sizeof(dnode_t); numLeafs = leafLump->filelen / sizeof(dleaf_t); out = (mnode_t *)ri->Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); - s_worldData.nodes = out; - s_worldData.numnodes = numNodes + numLeafs; - s_worldData.numDecisionNodes = numNodes; + worldData->nodes = out; + worldData->numnodes = numNodes + numLeafs; + worldData->numDecisionNodes = numNodes; // load nodes for ( i=0 ; iplaneNum); - out->plane = s_worldData.planes + p; + out->plane = worldData->planes + p; out->contents = CONTENTS_NODE; // differentiate from leafs @@ -2355,9 +2355,9 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { { p = LittleLong (in->children[j]); if (p >= 0) - out->children[j] = s_worldData.nodes + p; + out->children[j] = worldData->nodes + p; else - out->children[j] = s_worldData.nodes + numNodes + (-1 - p); + out->children[j] = worldData->nodes + numNodes + (-1 - p); } } @@ -2374,8 +2374,8 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { out->cluster = LittleLong(inLeaf->cluster); out->area = LittleLong(inLeaf->area); - if ( out->cluster >= s_worldData.numClusters ) { - s_worldData.numClusters = out->cluster + 1; + if ( out->cluster >= worldData->numClusters ) { + worldData->numClusters = out->cluster + 1; } out->firstmarksurface = LittleLong(inLeaf->firstLeafSurface); @@ -2383,7 +2383,7 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { } // chain decendants - R_SetParent (s_worldData.nodes, NULL); + R_SetParent (worldData->nodes, NULL); } //============================================================================= @@ -2393,18 +2393,18 @@ static void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump) { R_LoadShaders ================= */ -static void R_LoadShaders( lump_t *l ) { +static void R_LoadShaders( world_t *worldData, lump_t *l ) { int i, count; dshader_t *in, *out; in = (dshader_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); out = (dshader_t *)ri->Hunk_Alloc ( count*sizeof(*out), h_low ); - s_worldData.shaders = out; - s_worldData.numShaders = count; + worldData->shaders = out; + worldData->numShaders = count; Com_Memcpy( out, in, count*sizeof(*out) ); @@ -2420,7 +2420,7 @@ static void R_LoadShaders( lump_t *l ) { R_LoadMarksurfaces ================= */ -static void R_LoadMarksurfaces (lump_t *l) +static void R_LoadMarksurfaces (world_t *worldData, lump_t *l) { int i, j, count; int *in; @@ -2428,12 +2428,12 @@ static void R_LoadMarksurfaces (lump_t *l) in = (int *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); out = (int *)ri->Hunk_Alloc ( count*sizeof(*out), h_low); - s_worldData.marksurfaces = out; - s_worldData.nummarksurfaces = count; + worldData->marksurfaces = out; + worldData->nummarksurfaces = count; for ( i=0 ; ifileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); out = (cplane_t *)ri->Hunk_Alloc ( count*2*sizeof(*out), h_low); - s_worldData.planes = out; - s_worldData.numplanes = count; + worldData->planes = out; + worldData->numplanes = count; for ( i=0 ; ifileofs); if (l->filelen % sizeof(*fogs)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } count = l->filelen / sizeof(*fogs); // create fog strucutres for them - s_worldData.numfogs = count + 1; - s_worldData.fogs = (fog_t *)ri->Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low); - out = s_worldData.fogs + 1; + worldData->numfogs = count + 1; + worldData->fogs = (fog_t *)ri->Hunk_Alloc ( worldData->numfogs*sizeof(*out), h_low); + worldData->globalFog = nullptr; + out = worldData->fogs + 1; if ( !count ) { return; @@ -2515,13 +2516,13 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { brushes = (dbrush_t *)(fileBase + brushesLump->fileofs); if (brushesLump->filelen % sizeof(*brushes)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } brushesCount = brushesLump->filelen / sizeof(*brushes); sides = (dbrushside_t *)(fileBase + sidesLump->fileofs); if (sidesLump->filelen % sizeof(*sides)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name); + ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } sidesCount = sidesLump->filelen / sizeof(*sides); @@ -2533,6 +2534,8 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { out->bounds[0][0] = out->bounds[0][1] = out->bounds[0][2] = MIN_WORLD_COORD; out->bounds[1][0] = out->bounds[1][1] = out->bounds[1][2] = MAX_WORLD_COORD; firstSide = -1; + + worldData->globalFog = worldData->fogs + i + 1; } else { @@ -2550,27 +2553,27 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { // brushes are always sorted with the axial sides first sideNum = firstSide + 0; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist; + out->bounds[0][0] = -worldData->planes[ planeNum ].dist; sideNum = firstSide + 1; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][0] = s_worldData.planes[ planeNum ].dist; + out->bounds[1][0] = worldData->planes[ planeNum ].dist; sideNum = firstSide + 2; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist; + out->bounds[0][1] = -worldData->planes[ planeNum ].dist; sideNum = firstSide + 3; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][1] = s_worldData.planes[ planeNum ].dist; + out->bounds[1][1] = worldData->planes[ planeNum ].dist; sideNum = firstSide + 4; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist; + out->bounds[0][2] = -worldData->planes[ planeNum ].dist; sideNum = firstSide + 5; planeNum = LittleLong( sides[ sideNum ].planeNum ); - out->bounds[1][2] = s_worldData.planes[ planeNum ].dist; + out->bounds[1][2] = worldData->planes[ planeNum ].dist; } // get information from the shader for fog parameters @@ -2586,7 +2589,6 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque; out->tcScale = 1.0f / d; - out->depthToOpaque = d; // set the gradient vector sideNum = LittleLong( fogs->visibleSide ); @@ -2594,8 +2596,8 @@ static void R_LoadFogs( lump_t *l, lump_t *brushesLump, lump_t *sidesLump ) { out->hasSurface = qtrue; if ( sideNum != -1 ) { planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum ); - VectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface ); - out->surface[3] = -s_worldData.planes[ planeNum ].dist; + VectorSubtract( vec3_origin, worldData->planes[ planeNum ].normal, out->surface ); + out->surface[3] = -worldData->planes[ planeNum ].dist; } out++; @@ -2610,31 +2612,28 @@ R_LoadLightGrid ================ */ -void R_LoadLightGrid( lump_t *l ) { +void R_LoadLightGrid( world_t *worldData, lump_t *l ) { int i; vec3_t maxs; - world_t *w; float *wMins, *wMaxs; - w = &s_worldData; - - w->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0]; - w->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1]; - w->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2]; + worldData->lightGridInverseSize[0] = 1.0f / worldData->lightGridSize[0]; + worldData->lightGridInverseSize[1] = 1.0f / worldData->lightGridSize[1]; + worldData->lightGridInverseSize[2] = 1.0f / worldData->lightGridSize[2]; - wMins = w->bmodels[0].bounds[0]; - wMaxs = w->bmodels[0].bounds[1]; + wMins = worldData->bmodels[0].bounds[0]; + wMaxs = worldData->bmodels[0].bounds[1]; for ( i = 0 ; i < 3 ; i++ ) { - w->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] ); - maxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] ); - w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1; + worldData->lightGridOrigin[i] = worldData->lightGridSize[i] * ceil( wMins[i] / worldData->lightGridSize[i] ); + maxs[i] = worldData->lightGridSize[i] * floor( wMaxs[i] / worldData->lightGridSize[i] ); + worldData->lightGridBounds[i] = (maxs[i] - worldData->lightGridOrigin[i])/worldData->lightGridSize[i] + 1; } - int numGridDataElements = l->filelen / sizeof(*w->lightGridData); + int numGridDataElements = l->filelen / sizeof(*worldData->lightGridData); - w->lightGridData = (mgrid_t *)ri->Hunk_Alloc( l->filelen, h_low ); - Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); + worldData->lightGridData = (mgrid_t *)ri->Hunk_Alloc( l->filelen, h_low ); + Com_Memcpy( worldData->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits for ( i = 0 ; i < numGridDataElements ; i++ ) @@ -2642,11 +2641,11 @@ void R_LoadLightGrid( lump_t *l ) { for(int j = 0; j < MAXLIGHTMAPS; j++) { R_ColorShiftLightingBytes( - w->lightGridData[i].ambientLight[j], - w->lightGridData[i].ambientLight[j]); + worldData->lightGridData[i].ambientLight[j], + worldData->lightGridData[i].ambientLight[j]); R_ColorShiftLightingBytes( - w->lightGridData[i].directLight[j], - w->lightGridData[i].directLight[j]); + worldData->lightGridData[i].directLight[j], + worldData->lightGridData[i].directLight[j]); } } @@ -2657,7 +2656,7 @@ void R_LoadLightGrid( lump_t *l ) { float *hdrLightGrid; int size; - Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", s_worldData.baseName); + Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", worldData->baseName); //ri->Printf(PRINT_ALL, "looking for %s\n", filename); size = ri->FS_ReadFile(filename, (void **)&hdrLightGrid); @@ -2673,16 +2672,16 @@ void R_LoadLightGrid( lump_t *l ) { ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridDataElements); } - w->hdrLightGrid = (float *)ri->Hunk_Alloc(size, h_low); + worldData->hdrLightGrid = (float *)ri->Hunk_Alloc(size, h_low); for (i = 0; i < numGridDataElements ; i++) { - w->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale; - w->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale; - w->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] * lightScale; - w->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] * lightScale; - w->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] * lightScale; - w->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] * lightScale; + worldData->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale; + worldData->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale; + worldData->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] * lightScale; + worldData->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] * lightScale; + worldData->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] * lightScale; + worldData->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] * lightScale; } } @@ -2697,21 +2696,17 @@ R_LoadLightGridArray ================ */ -void R_LoadLightGridArray( lump_t *l ) { - world_t *w; - - w = &s_worldData; - - w->numGridArrayElements = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2]; +void R_LoadLightGridArray( world_t *worldData, lump_t *l ) { + worldData->numGridArrayElements = worldData->lightGridBounds[0] * worldData->lightGridBounds[1] * worldData->lightGridBounds[2]; - if ( (unsigned)l->filelen != w->numGridArrayElements * sizeof(*w->lightGridArray) ) { + if ( (unsigned)l->filelen != worldData->numGridArrayElements * sizeof(*worldData->lightGridArray) ) { Com_Printf (S_COLOR_YELLOW "WARNING: light grid array mismatch\n" ); - w->lightGridData = NULL; + worldData->lightGridData = NULL; return; } - w->lightGridArray = (unsigned short *)Hunk_Alloc( l->filelen, h_low ); - memcpy( w->lightGridArray, (void *)(fileBase + l->fileofs), l->filelen ); + worldData->lightGridArray = (unsigned short *)Hunk_Alloc( l->filelen, h_low ); + memcpy( worldData->lightGridArray, (void *)(fileBase + l->fileofs), l->filelen ); } /* @@ -2719,7 +2714,7 @@ void R_LoadLightGridArray( lump_t *l ) { R_LoadEntities ================ */ -void R_LoadEntities( lump_t *l ) { +void R_LoadEntities( world_t *worldData, lump_t *l ) { const char *p; char *token, *s; char vertexRemapShaderText[] = "vertexremapshader"; @@ -2728,7 +2723,7 @@ void R_LoadEntities( lump_t *l ) { char value[MAX_TOKEN_CHARS]; world_t *w; - w = &s_worldData; + w = worldData; w->lightGridSize[0] = 64; w->lightGridSize[1] = 64; w->lightGridSize[2] = 128; @@ -2816,17 +2811,18 @@ R_GetEntityToken */ qboolean R_GetEntityToken( char *buffer, int size ) { char *s; + world_t *worldData = &s_worldData; if (size == -1) { //force reset - s_worldData.entityParsePoint = s_worldData.entityString; + worldData->entityParsePoint = worldData->entityString; return qtrue; } - s = COM_Parse( (const char **)&s_worldData.entityParsePoint ); + s = COM_Parse( (const char **)&worldData->entityParsePoint ); Q_strncpyz( buffer, s, size ); - if ( !s_worldData.entityParsePoint && !s[0] ) { - s_worldData.entityParsePoint = s_worldData.entityString; + if ( !worldData->entityParsePoint && !s[0] ) { + worldData->entityParsePoint = worldData->entityString; return qfalse; } else { return qtrue; @@ -2965,12 +2961,12 @@ static void R_LoadCubemapEntities(const char *cubemapEntityName) } } -static void R_AssignCubemapsToWorldSurfaces(void) +static void R_AssignCubemapsToWorldSurfaces(world_t *worldData) { world_t *w; int i; - w = &s_worldData; + w = worldData; for (i = 0; i < w->numsurfaces; i++) { @@ -3034,7 +3030,7 @@ R_MergeLeafSurfaces Merges surfaces that share a common leaf ================= */ -static void R_MergeLeafSurfaces(void) +static void R_MergeLeafSurfaces(world_t *worldData) { int i, j, k; int numWorldSurfaces; @@ -3053,18 +3049,18 @@ static void R_MergeLeafSurfaces(void) startTime = ri->Milliseconds(); - numWorldSurfaces = s_worldData.numWorldSurfaces; + numWorldSurfaces = worldData->numWorldSurfaces; // use viewcount to keep track of mergers for (i = 0; i < numWorldSurfaces; i++) { - s_worldData.surfacesViewCount[i] = -1; + worldData->surfacesViewCount[i] = -1; } // mark matching surfaces - for (i = 0; i < s_worldData.numnodes - s_worldData.numDecisionNodes; i++) + for (i = 0; i < worldData->numnodes - worldData->numDecisionNodes; i++) { - mnode_t *leaf = s_worldData.nodes + s_worldData.numDecisionNodes + i; + mnode_t *leaf = worldData->nodes + worldData->numDecisionNodes + i; for (j = 0; j < leaf->nummarksurfaces; j++) { @@ -3074,12 +3070,12 @@ static void R_MergeLeafSurfaces(void) int cubemapIndex1; int surfNum1; - surfNum1 = *(s_worldData.marksurfaces + leaf->firstmarksurface + j); + surfNum1 = *(worldData->marksurfaces + leaf->firstmarksurface + j); - if (s_worldData.surfacesViewCount[surfNum1] != -1) + if (worldData->surfacesViewCount[surfNum1] != -1) continue; - surf1 = s_worldData.surfaces + surfNum1; + surf1 = worldData->surfaces + surfNum1; if ((*surf1->data != SF_GRID) && (*surf1->data != SF_TRIANGLES) && (*surf1->data != SF_FACE)) continue; @@ -3098,7 +3094,7 @@ static void R_MergeLeafSurfaces(void) fogIndex1 = surf1->fogIndex; cubemapIndex1 = surf1->cubemapIndex; - s_worldData.surfacesViewCount[surfNum1] = surfNum1; + worldData->surfacesViewCount[surfNum1] = surfNum1; for (k = j + 1; k < leaf->nummarksurfaces; k++) { @@ -3108,12 +3104,12 @@ static void R_MergeLeafSurfaces(void) int cubemapIndex2; int surfNum2; - surfNum2 = *(s_worldData.marksurfaces + leaf->firstmarksurface + k); + surfNum2 = *(worldData->marksurfaces + leaf->firstmarksurface + k); - if (s_worldData.surfacesViewCount[surfNum2] != -1) + if (worldData->surfacesViewCount[surfNum2] != -1) continue; - surf2 = s_worldData.surfaces + surfNum2; + surf2 = worldData->surfaces + surfNum2; if ((*surf2->data != SF_GRID) && (*surf2->data != SF_TRIANGLES) && (*surf2->data != SF_FACE)) continue; @@ -3133,7 +3129,7 @@ static void R_MergeLeafSurfaces(void) if (cubemapIndex1 != cubemapIndex2) continue; - s_worldData.surfacesViewCount[surfNum2] = surfNum1; + worldData->surfacesViewCount[surfNum2] = surfNum1; } } } @@ -3143,7 +3139,7 @@ static void R_MergeLeafSurfaces(void) { qboolean merges = qfalse; - if (s_worldData.surfacesViewCount[i] != i) + if (worldData->surfacesViewCount[i] != i) continue; for (j = 0; j < numWorldSurfaces; j++) @@ -3151,7 +3147,7 @@ static void R_MergeLeafSurfaces(void) if (j == i) continue; - if (s_worldData.surfacesViewCount[j] == i) + if (worldData->surfacesViewCount[j] == i) { merges = qtrue; break; @@ -3159,7 +3155,7 @@ static void R_MergeLeafSurfaces(void) } if (!merges) - s_worldData.surfacesViewCount[i] = -1; + worldData->surfacesViewCount[i] = -1; } // count merged/unmerged surfaces @@ -3167,31 +3163,31 @@ static void R_MergeLeafSurfaces(void) numUnmergedSurfaces = 0; for (i = 0; i < numWorldSurfaces; i++) { - if (s_worldData.surfacesViewCount[i] == i) + if (worldData->surfacesViewCount[i] == i) { numMergedSurfaces++; } - else if (s_worldData.surfacesViewCount[i] == -1) + else if (worldData->surfacesViewCount[i] == -1) { numUnmergedSurfaces++; } } // Allocate merged surfaces - s_worldData.mergedSurfaces = (msurface_t *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfaces) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesViewCount = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesViewCount) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesDlightBits = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesDlightBits) * numMergedSurfaces, h_low); - s_worldData.mergedSurfacesPshadowBits = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); - s_worldData.numMergedSurfaces = numMergedSurfaces; + worldData->mergedSurfaces = (msurface_t *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); + worldData->mergedSurfacesViewCount = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); + worldData->mergedSurfacesDlightBits = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + worldData->mergedSurfacesPshadowBits = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + worldData->numMergedSurfaces = numMergedSurfaces; // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on - s_worldData.viewSurfaces = (int *)ri->Hunk_Alloc(sizeof(*s_worldData.viewSurfaces) * s_worldData.nummarksurfaces, h_low); + worldData->viewSurfaces = (int *)ri->Hunk_Alloc(sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); // copy view surfaces into mark surfaces - for (i = 0; i < s_worldData.nummarksurfaces; i++) + for (i = 0; i < worldData->nummarksurfaces; i++) { - s_worldData.viewSurfaces[i] = s_worldData.marksurfaces[i]; + worldData->viewSurfaces[i] = worldData->marksurfaces[i]; } // need to be synched here @@ -3200,7 +3196,7 @@ static void R_MergeLeafSurfaces(void) // actually merge surfaces numIboIndexes = 0; mergedSurfIndex = 0; - mergedSurf = s_worldData.mergedSurfaces; + mergedSurf = worldData->mergedSurfaces; for (i = 0; i < numWorldSurfaces; i++) { msurface_t *surf1; @@ -3214,10 +3210,10 @@ static void R_MergeLeafSurfaces(void) srfBspSurface_t *vboSurf; - if (s_worldData.surfacesViewCount[i] != i) + if (worldData->surfacesViewCount[i] != i) continue; - surf1 = s_worldData.surfaces + i; + surf1 = worldData->surfaces + i; // retrieve vbo vbo = ((srfBspSurface_t *)(surf1->data))->vbo; @@ -3231,10 +3227,10 @@ static void R_MergeLeafSurfaces(void) msurface_t *surf2; srfBspSurface_t *bspSurf; - if (s_worldData.surfacesViewCount[j] != i) + if (worldData->surfacesViewCount[j] != i) continue; - surf2 = s_worldData.surfaces + j; + surf2 = worldData->surfaces + j; bspSurf = (srfBspSurface_t *) surf2->data; numIndexes += bspSurf->numIndexes; @@ -3263,10 +3259,10 @@ static void R_MergeLeafSurfaces(void) msurface_t *surf2; srfBspSurface_t *bspSurf; - if (s_worldData.surfacesViewCount[j] != i) + if (worldData->surfacesViewCount[j] != i) continue; - surf2 = s_worldData.surfaces + j; + surf2 = worldData->surfaces + j; AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]); AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]); @@ -3326,13 +3322,13 @@ static void R_MergeLeafSurfaces(void) // redirect view surfaces to this surf for (j = 0; j < numWorldSurfaces; j++) { - if (s_worldData.surfacesViewCount[j] != i) + if (worldData->surfacesViewCount[j] != i) continue; - for (k = 0; k < s_worldData.nummarksurfaces; k++) + for (k = 0; k < worldData->nummarksurfaces; k++) { - int *mark = s_worldData.marksurfaces + k; - int *view = s_worldData.viewSurfaces + k; + int *mark = worldData->marksurfaces + k; + int *view = worldData->viewSurfaces + k; if (*mark == j) *view = -(mergedSurfIndex + 1); @@ -3351,17 +3347,17 @@ static void R_MergeLeafSurfaces(void) // reset viewcounts for (i = 0; i < numWorldSurfaces; i++) { - s_worldData.surfacesViewCount[i] = -1; + worldData->surfacesViewCount[i] = -1; } } -static void R_CalcVertexLightDirs( void ) +static void R_CalcVertexLightDirs( world_t *worldData ) { int i, k; msurface_t *surface; - for(k = 0, surface = &s_worldData.surfaces[0]; k < s_worldData.numsurfaces /* s_worldData.numWorldSurfaces */; k++, surface++) + for(k = 0, surface = &worldData->surfaces[0]; k < worldData->numsurfaces /* worldData->numWorldSurfaces */; k++, surface++) { srfBspSurface_t *bspSurf = (srfBspSurface_t *) surface->data; @@ -3375,7 +3371,7 @@ static void R_CalcVertexLightDirs( void ) bspSurf->verts[i].xyz, bspSurf->verts[i].lightdir, bspSurf->verts[i].normal, - &s_worldData ); + worldData ); break; @@ -3600,6 +3596,7 @@ void RE_LoadWorldMap( const char *name ) { void *v; } buffer; byte *startMarker; + world_t *worldData = &s_worldData; if ( tr.worldMapLoaded ) { ri->Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); @@ -3638,11 +3635,11 @@ void RE_LoadWorldMap( const char *name ) { // try will not look at the partially loaded version tr.world = NULL; - Com_Memset( &s_worldData, 0, sizeof( s_worldData ) ); - Q_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) ); + Com_Memset( worldData, 0, sizeof( *worldData ) ); + Q_strncpyz( worldData->name, name, sizeof( worldData->name ) ); - Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) ); - COM_StripExtension(s_worldData.baseName, s_worldData.baseName, sizeof(s_worldData.baseName)); + Q_strncpyz( worldData->baseName, COM_SkipPath( worldData->name ), sizeof( worldData->name ) ); + COM_StripExtension(worldData->baseName, worldData->baseName, sizeof(worldData->baseName)); startMarker = (byte *)ri->Hunk_Alloc(0, h_low); c_gridVerts = 0; @@ -3662,23 +3659,23 @@ void RE_LoadWorldMap( const char *name ) { } // load into heap - R_LoadEntities( &header->lumps[LUMP_ENTITIES] ); - R_LoadShaders( &header->lumps[LUMP_SHADERS] ); - R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES] ); - R_LoadPlanes (&header->lumps[LUMP_PLANES]); - R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); - R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); - R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]); - R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); - R_LoadSubmodels (&header->lumps[LUMP_MODELS]); - R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] ); - R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] ); - R_LoadLightGridArray( &header->lumps[LUMP_LIGHTARRAY] ); - - R_GenerateSurfaceSprites(&s_worldData); + R_LoadEntities( worldData, &header->lumps[LUMP_ENTITIES] ); + R_LoadShaders( worldData, &header->lumps[LUMP_SHADERS] ); + R_LoadLightmaps( worldData, &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES] ); + R_LoadPlanes( worldData, &header->lumps[LUMP_PLANES] ); + R_LoadFogs( worldData, &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); + R_LoadSurfaces( worldData, &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); + R_LoadMarksurfaces( worldData, &header->lumps[LUMP_LEAFSURFACES] ); + R_LoadNodesAndLeafs( worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS] ); + R_LoadSubmodels( worldData, &header->lumps[LUMP_MODELS] ); + R_LoadVisibility( worldData, &header->lumps[LUMP_VISIBILITY] ); + R_LoadLightGrid( worldData, &header->lumps[LUMP_LIGHTGRID] ); + R_LoadLightGridArray( worldData, &header->lumps[LUMP_LIGHTARRAY] ); + + R_GenerateSurfaceSprites(worldData); // determine vertex light directions - R_CalcVertexLightDirs(); + R_CalcVertexLightDirs(worldData); // load cubemaps if (r_cubeMapping->integer) @@ -3692,21 +3689,21 @@ void RE_LoadWorldMap( const char *name ) { if (tr.numCubemaps) { - R_AssignCubemapsToWorldSurfaces(); + R_AssignCubemapsToWorldSurfaces(worldData); } } // create static VBOS from the world - R_CreateWorldVBOs(); + R_CreateWorldVBOs(worldData); if (r_mergeLeafSurfaces->integer) { - R_MergeLeafSurfaces(); + R_MergeLeafSurfaces(worldData); } - s_worldData.dataSize = (byte *)ri->Hunk_Alloc(0, h_low) - startMarker; + worldData->dataSize = (byte *)ri->Hunk_Alloc(0, h_low) - startMarker; // only set tr.world now that we know the entire level has loaded properly - tr.world = &s_worldData; + tr.world = worldData; // make sure the VBO glState entries are safe R_BindNullVBO(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 72d6d97292..228b7ef116 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1345,7 +1345,6 @@ typedef struct { vec4_t color; float tcScale; // texture coordinate vector scales - float depthToOpaque; fogParms_t parms; // for clipping distance in fog when outside @@ -1760,6 +1759,7 @@ typedef struct { int numfogs; fog_t *fogs; + const fog_t *globalFog; vec3_t lightGridOrigin; vec3_t lightGridSize; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 126c2b79f2..0d4c162555 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1133,9 +1133,8 @@ RB_FogPass Blends a fog texture on top of everything else =================== */ -static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) +static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexArraysProperties *vertexArrays ) { - fog_t *fog; shaderProgram_t *sp; deform_t deformType; @@ -1167,8 +1166,6 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v backEnd.pc.c_fogDraws++; - fog = tr.world->fogs + tess.fogNum; - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); @@ -1186,7 +1183,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->depthToOpaque); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque); uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; @@ -1514,7 +1511,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->depthToOpaque); + uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->parms.depthForOpaque); uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); vec4_t fogColorMask; @@ -1916,8 +1913,17 @@ void RB_StageIteratorGeneric( void ) // // now do fog // - if ( tess.fogNum && tess.shader->fogPass ) { - RB_FogPass( &tess, &vertexArrays ); + const fog_t *fog = nullptr; + if ( tr.world ) + { + if ( tr.world->globalFog ) + fog = tr.world->globalFog; + else if ( tess.fogNum ) + fog = tr.world->fogs + tess.fogNum; + } + + if ( fog && tess.shader->fogPass ) { + RB_FogPass( &tess, fog, &vertexArrays ); } } From 46adfc12666c98aa94cfd8d6ddab471dc5f936b2 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 28 May 2016 15:38:15 +0100 Subject: [PATCH 385/708] Rend2: Shader cleanup, and small fixes * Fix some #defines * Remove r_deluxeSpecular * Fixes setting correct flags on dlight shader * Remove shininess variables as they were unused --- codemp/rd-rend2/glsl/lightall.glsl | 29 +++---------- codemp/rd-rend2/tr_glsl.cpp | 65 +++++++++++++++--------------- codemp/rd-rend2/tr_init.cpp | 2 - codemp/rd-rend2/tr_local.h | 42 +++++++++++-------- codemp/rd-rend2/tr_shade.cpp | 20 ++++----- 5 files changed, 72 insertions(+), 86 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 1f49fc6f7f..ee6f842ca4 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -52,10 +52,7 @@ uniform vec4 u_DiffuseTexOffTurb; uniform mat4 u_ModelViewProjectionMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; - -#if defined(USE_MODELMATRIX) uniform mat4 u_ModelMatrix; -#endif #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; @@ -244,13 +241,11 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); -#if defined(USE_MODELMATRIX) position = (u_ModelMatrix * vec4(position, 1.0)).xyz; normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; #if defined(PER_PIXEL_LIGHTING) tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; #endif -#endif #if defined(PER_PIXEL_LIGHTING) vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); @@ -260,9 +255,7 @@ void main() vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); #elif defined(PER_PIXEL_LIGHTING) vec3 L = attr_LightDirection * 2.0 - vec3(1.0); - #if defined(USE_MODELMATRIX) L = (u_ModelMatrix * vec4(L, 0.0)).xyz; - #endif #endif #if defined(USE_LIGHTMAP) @@ -272,9 +265,7 @@ void main() if ( u_FXVolumetricBase > 0.0 ) { vec3 viewForward = u_ViewForward; -#if defined(USE_MODELMATRIX) - viewForward = (u_ModelMatrix * vec4(viewForward, 0.0)).xyz; -#endif + float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); d = d * d; d = d * d; @@ -498,7 +489,7 @@ float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) return 1.0 / (invGeo1 * invGeo2); } -vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss, float shininess) +vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss) { float distrib = CalcGGX(NH, gloss); @@ -672,7 +663,6 @@ void main() specular *= u_SpecularScale; float gloss = specular.a; - float shininess = exp2(gloss * 13.0); #if defined(SPECULAR_IS_METALLIC) // diffuse is actually base color, and red of specular is metallicness @@ -686,21 +676,12 @@ void main() reflectance = diffuse.rgb; - #if defined(r_deluxeSpecular) || defined(USE_LIGHT_VECTOR) - float adjGloss = gloss; - float adjShininess = shininess; - + #if defined(USE_LIGHT_VECTOR) H = normalize(L + E); EH = clamp(dot(E, H), 0.0, 1.0); NH = clamp(dot(N, H), 0.0, 1.0); - #if defined(r_deluxeSpecular) - adjGloss *= r_deluxeSpecular; - adjShininess = exp2(adjGloss * 13.0); - reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess) * r_deluxeSpecular; - #else - reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, adjGloss, adjShininess); - #endif + reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss); #endif out_Color.rgb = lightColor * reflectance * (attenuation * NL); @@ -719,7 +700,7 @@ void main() NH2 = clamp(dot(N, H2), 0.0, 1.0); reflectance = diffuse.rgb; - reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss, shininess); + reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss); lightColor = u_PrimaryLightColor * var_Color.rgb; #if defined(USE_SHADOWMAP) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 7d1935ea1e..2129284f41 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1045,20 +1045,18 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) static bool GLSL_IsValidPermutationForGeneric (int shaderCaps) { - if ((shaderCaps & (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) == (GENERICDEF_USE_VERTEX_ANIMATION | GENERICDEF_USE_SKELETAL_ANIMATION)) - { + if ( (shaderCaps & GENERICDEF_USE_VERTEX_ANIMATION) && + (shaderCaps & GENERICDEF_USE_SKELETAL_ANIMATION) ) return false; - } return true; } static bool GLSL_IsValidPermutationForFog (int shaderCaps) { - if ((shaderCaps & (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) == (FOGDEF_USE_VERTEX_ANIMATION | FOGDEF_USE_SKELETAL_ANIMATION)) - { + if ( (shaderCaps & FOGDEF_USE_VERTEX_ANIMATION) && + (shaderCaps & FOGDEF_USE_SKELETAL_ANIMATION) ) return false; - } return true; } @@ -1074,6 +1072,10 @@ static bool GLSL_IsValidPermutationForLight (int lightType, int shaderCaps) if (!lightType && (shaderCaps & LIGHTDEF_USE_SHADOWMAP)) return false; + if ( (shaderCaps & LIGHTDEF_USE_SKELETAL_ANIMATION) && + (shaderCaps & LIGHTDEF_USE_VERTEX_ANIMATION) ) + return false; + return true; } @@ -1410,24 +1412,19 @@ int GLSL_BeginLoadGPUShaders(void) ///////////////////////////////////////////////////////////////////////////// programDesc = LoadProgramSource("lightall", allocator, fallback_lightallProgram); + qboolean useFastLight = (qboolean)(!r_normalMapping->integer && !r_specularMapping->integer); for (i = 0; i < LIGHTDEF_COUNT; i++) { int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; - qboolean allowVertexLighting = (qboolean)!(r_normalMapping->integer || r_specularMapping->integer); // skip impossible combos if (!GLSL_IsValidPermutationForLight (lightType, i)) - { continue; - } attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_COLOR | ATTR_NORMAL; extradefines[0] = '\0'; - if (r_deluxeSpecular->value > 0.000001f) - Q_strcat(extradefines, sizeof(extradefines), va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); - if (r_specularIsMetallic->value) Q_strcat(extradefines, sizeof(extradefines), "#define SPECULAR_IS_METALLIC\n"); @@ -1444,24 +1441,35 @@ int GLSL_BeginLoadGPUShaders(void) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT\n"); - if (allowVertexLighting) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_LIGHTING\n"); + if (useFastLight) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_FAST_LIGHT\n"); switch (lightType) { case LIGHTDEF_USE_LIGHTMAP: + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHTMAP\n"); - if (r_deluxeMapping->integer && !allowVertexLighting) + + if (r_deluxeMapping->integer && !useFastLight) Q_strcat(extradefines, sizeof(extradefines), "#define USE_DELUXEMAP\n"); + attribs |= ATTR_TEXCOORD1 | ATTR_LIGHTDIRECTION; break; + } + case LIGHTDEF_USE_LIGHT_VECTOR: + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VECTOR\n"); break; + } + case LIGHTDEF_USE_LIGHT_VERTEX: + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VERTEX\n"); attribs |= ATTR_LIGHTDIRECTION; break; + } + default: break; } @@ -1470,16 +1478,14 @@ int GLSL_BeginLoadGPUShaders(void) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_NORMALMAP\n"); - attribs |= ATTR_TANGENT; - if ((i & LIGHTDEF_USE_PARALLAXMAP) && r_parallaxMapping->integer) Q_strcat(extradefines, sizeof(extradefines), "#define USE_PARALLAXMAP\n"); + + attribs |= ATTR_TANGENT; } if (r_specularMapping->integer) - { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SPECULARMAP\n"); - } if (r_cubeMapping->integer) Q_strcat(extradefines, sizeof(extradefines), "#define USE_CUBEMAP\n"); @@ -1501,25 +1507,18 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } - if (i & LIGHTDEF_ENTITY) + if (i & LIGHTDEF_USE_VERTEX_ANIMATION) { - if (i & LIGHTDEF_USE_VERTEX_ANIMATION) - { - Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); - } - else if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) - { - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); - attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; - } - - Q_strcat(extradefines, sizeof(extradefines), "#define USE_MODELMATRIX\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; if (r_normalMapping->integer) - { attribs |= ATTR_TANGENT2; - } + } + else if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) + { + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); + attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } switch (i & LIGHTDEF_USE_ATEST_MASK) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index bf8913bf5e..eb09d9e2c6 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -131,7 +131,6 @@ cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_parallaxMapping; cvar_t *r_cubeMapping; -cvar_t *r_deluxeSpecular; cvar_t *r_specularIsMetallic; cvar_t *r_baseNormalX; cvar_t *r_baseNormalY; @@ -1418,7 +1417,6 @@ void R_Register( void ) r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_deluxeSpecular = ri->Cvar_Get( "r_deluxeSpecular", "0.3", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 228b7ef116..5c7948492d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1024,11 +1024,13 @@ enum GENERICDEF_USE_ATEST_LT = 0x0080, GENERICDEF_USE_ATEST_GT = 0x0100, GENERICDEF_USE_ATEST_GE = 0x0180, + GENERICDEF_USE_ATEST_MASK = GENERICDEF_USE_ATEST_LT | GENERICDEF_USE_ATEST_GT | GENERICDEF_USE_ATEST_GE, + GENERICDEF_ALL = 0x01FF, - GENERICDEF_COUNT = 0x0200, + GENERICDEF_COUNT = GENERICDEF_ALL + 1, }; enum @@ -1039,11 +1041,13 @@ enum FOGDEF_USE_ATEST_LT = 0x0008, FOGDEF_USE_ATEST_GT = 0x0010, FOGDEF_USE_ATEST_GE = 0x0018, + FOGDEF_USE_ATEST_MASK = FOGDEF_USE_ATEST_LT | FOGDEF_USE_ATEST_GT | FOGDEF_USE_ATEST_GE, + FOGDEF_ALL = 0x001F, - FOGDEF_COUNT = 0x0020, + FOGDEF_COUNT = FOGDEF_ALL + 1, }; enum @@ -1052,11 +1056,13 @@ enum DLIGHTDEF_USE_ATEST_LT = 0x0002, DLIGHTDEF_USE_ATEST_GT = 0x0004, DLIGHTDEF_USE_ATEST_GE = 0x0006, + DLIGHTDEF_USE_ATEST_MASK = DLIGHTDEF_USE_ATEST_LT | DLIGHTDEF_USE_ATEST_GT | DLIGHTDEF_USE_ATEST_GE, + DLIGHTDEF_ALL = 0x0007, - DLIGHTDEF_COUNT = 0x0008, + DLIGHTDEF_COUNT = DLIGHTDEF_ALL + 1, }; enum @@ -1064,22 +1070,25 @@ enum LIGHTDEF_USE_LIGHTMAP = 0x0001, LIGHTDEF_USE_LIGHT_VECTOR = 0x0002, LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, - LIGHTDEF_LIGHTTYPE_MASK = 0x0003, - LIGHTDEF_ENTITY = 0x0004, - LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0008, - LIGHTDEF_USE_PARALLAXMAP = 0x0010, - LIGHTDEF_USE_SHADOWMAP = 0x0020, - LIGHTDEF_USE_VERTEX_ANIMATION = 0x0040, - LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0080, - LIGHTDEF_USE_GLOW_BUFFER = 0x0100, - LIGHTDEF_USE_ATEST_LT = 0x0200, - LIGHTDEF_USE_ATEST_GT = 0x0400, - LIGHTDEF_USE_ATEST_GE = 0x0600, + LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0004, + LIGHTDEF_USE_PARALLAXMAP = 0x0008, + LIGHTDEF_USE_SHADOWMAP = 0x0010, + LIGHTDEF_USE_VERTEX_ANIMATION = 0x0020, + LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0040, + LIGHTDEF_USE_GLOW_BUFFER = 0x0080, + LIGHTDEF_USE_ATEST_LT = 0x0100, + LIGHTDEF_USE_ATEST_GT = 0x0200, + LIGHTDEF_USE_ATEST_GE = 0x0300, + + LIGHTDEF_LIGHTTYPE_MASK = LIGHTDEF_USE_LIGHTMAP | + LIGHTDEF_USE_LIGHT_VECTOR | + LIGHTDEF_USE_LIGHT_VERTEX, LIGHTDEF_USE_ATEST_MASK = LIGHTDEF_USE_ATEST_LT | LIGHTDEF_USE_ATEST_GT | LIGHTDEF_USE_ATEST_GE, - LIGHTDEF_ALL = 0x07FF, - LIGHTDEF_COUNT = 0x0800 + + LIGHTDEF_ALL = 0x03FF, + LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; // Surface sprite shader flags @@ -2469,7 +2478,6 @@ extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; extern cvar_t *r_cubeMapping; -extern cvar_t *r_deluxeSpecular; extern cvar_t *r_specularIsMetallic; extern cvar_t *r_baseNormalX; extern cvar_t *r_baseNormalY; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 0d4c162555..290ca9ec76 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -912,6 +912,12 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { index &= ~LIGHTDEF_LIGHTTYPE_MASK; index |= LIGHTDEF_USE_LIGHT_VECTOR; + if (glState.vertexAnimation) + index |= LIGHTDEF_USE_VERTEX_ANIMATION; + + if (glState.skeletalAnimation) + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + sp = &tr.lightallShader[index]; } @@ -924,6 +930,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { uniformDataWriter.SetUniformVec3(UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); + uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); if (deformType != DEFORM_NONE) @@ -1247,14 +1254,11 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { - index |= LIGHTDEF_ENTITY; - if (glState.vertexAnimation) { index |= LIGHTDEF_USE_VERTEX_ANIMATION; } - - if (glState.skeletalAnimation) + else if (glState.skeletalAnimation) { index |= LIGHTDEF_USE_SKELETAL_ANIMATION; } @@ -1302,8 +1306,7 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { index |= GENERICDEF_USE_VERTEX_ANIMATION; } - - if (glState.skeletalAnimation) + else if (glState.skeletalAnimation) { index |= GENERICDEF_USE_SKELETAL_ANIMATION; } @@ -1348,11 +1351,8 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag } else { - if (backEnd.currentEntity && - backEnd.currentEntity != &tr.worldEntity) + if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { - index |= LIGHTDEF_ENTITY; - if (glState.vertexAnimation) { index |= LIGHTDEF_USE_VERTEX_ANIMATION; From 21bfe4006569a11eb6376cd6f87f0c40ae03a3dd Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 29 May 2016 12:49:40 +0100 Subject: [PATCH 386/708] Rend2: Use metallic workflow for everything. * Removed r_baseGloss and r_specularIsMetallic. * Changed shading code to use metallic workflow, based on Frostbite's PBR Notes from Siggraph 2014. * Some changes still necessary, e.g. do lighting in linear space, preconvolve BRDF for cubemaps. --- codemp/rd-rend2/glsl/lightall.glsl | 145 ++++++++++++++--------------- codemp/rd-rend2/tr_glsl.cpp | 3 - codemp/rd-rend2/tr_init.cpp | 6 +- codemp/rd-rend2/tr_local.h | 2 - codemp/rd-rend2/tr_shader.cpp | 2 +- 5 files changed, 72 insertions(+), 86 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index ee6f842ca4..d6f9a12257 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -448,56 +448,36 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) } #endif -float CalcFresnel(float EH) +vec3 CalcFresnel( in vec3 f0, in vec3 f90, in float LH ) { - // From http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - // not accurate, but fast - return exp2(-10.0 * EH); + return f0 + (f90 - f0) * pow(1.0 - LH, 5.0); } -vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) +float CalcGGX( in float NH, in float roughness ) { - // from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - vec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss; - t += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 ); - float a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z; - float a1 = t.w; - return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); + float alphaSq = roughness*roughness; + float f = (NH * alphaSq - NH) * NH + 1.0; + return alphaSq / (f * f); } -float CalcGGX(float NH, float gloss) +float CalcVisibility( in float NL, in float NE, in float roughness ) { - // from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf - float a_sq = exp2(gloss * -13.0 + 1.0); - float d = ((NH * NH) * (a_sq - 1.0) + 1.0); - return a_sq / (d * d); -} + float alphaSq = roughness*roughness; -float CalcVisibility(float NH, float NL, float NE, float EH, float gloss) -{ - float roughness = exp2(gloss * -6.5); + float lambdaE = NL * sqrt((-NE * alphaSq + NE) * NE + alphaSq); + float lambdaL = NE * sqrt((-NL * alphaSq + NL) * NL + alphaSq); - // Modified from http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf - // NL, NE in numerator factored out from cook-torrance - float k = roughness + 1.0; - k *= k * 0.125; - - float k2 = 1.0 - k; - float invGeo1 = NL * k2 + k; - float invGeo2 = NE * k2 + k; - - return 1.0 / (invGeo1 * invGeo2); + return 0.5 / (lambdaE + lambdaL); } -vec3 CalcSpecular(vec3 specular, float NH, float NL, float NE, float EH, float gloss) +// http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/ +vec3 CalcSpecular( in vec3 specular, in float NH, in float NL, in float NE, in float LH, in float roughness) { - float distrib = CalcGGX(NH, gloss); - - vec3 fSpecular = mix(specular, vec3(1.0), CalcFresnel(EH)); - - float vis = CalcVisibility(NH, NL, NE, EH, gloss); + vec3 F = CalcFresnel(specular, vec3(1.0), LH); + float D = CalcGGX(NH, roughness); + float V = CalcVisibility(NL, NE, roughness); - return fSpecular * (distrib * vis); + return D * F * V; } float CalcLightAttenuation(float point, float normDist) @@ -528,10 +508,29 @@ vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) #endif } -vec3 CalcIBLContribution( in float gloss, in vec3 N, in vec3 E, in vec3 viewDir, in float NE, in vec3 specular ) +vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) +{ + // from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf + vec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss; + t += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 ); + float a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z; + float a1 = t.w; + return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); +} + +vec3 CalcIBLContribution( + in float roughness, + in vec3 N, + in vec3 E, + in vec3 viewDir, + in float NE, + in vec3 specular +) { #if defined(USE_CUBEMAP) - vec3 reflectance = EnvironmentBRDF(gloss, NE, specular); + // EnvironmentBRDF is supposed to work with gloss. Invert roughness for now, but this needs + // to be replaced at some point with preconvoluted cubemap code. + vec3 reflectance = EnvironmentBRDF(1.0 - roughness, NE, specular); vec3 R = reflect(E, N); @@ -539,7 +538,7 @@ vec3 CalcIBLContribution( in float gloss, in vec3 N, in vec3 E, in vec3 viewDir, // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, 7.0 - gloss * 7.0).rgb * u_EnableTextures.w; + vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, roughness * 7.0).rgb * u_EnableTextures.w; return cubeLightColor * reflectance; #else @@ -569,8 +568,7 @@ vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld void main() { vec3 viewDir, lightColor, ambientColor; - vec3 L, N, E, H; - float NL, NH, NE, EH, attenuation; + vec3 L, N, E; #if defined(PER_PIXEL_LIGHTING) mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); @@ -608,6 +606,8 @@ void main() #endif #if defined(PER_PIXEL_LIGHTING) + float attenuation; + #if defined(USE_LIGHTMAP) lightColor = lightmapColor.rgb * var_Color.rgb; ambientColor = vec3 (0.0); @@ -650,11 +650,6 @@ void main() // light is below the surface ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0); #endif - - vec3 reflectance; - - NL = clamp(dot(N, L), 0.0, 1.0); - NE = clamp(dot(N, E), 0.0, 1.0); vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) @@ -662,45 +657,43 @@ void main() #endif specular *= u_SpecularScale; - float gloss = specular.a; + // diffuse is actually base color, and red of specular is metalness + const vec3 DIELECTRIC_SPECULAR = vec3(0.04); + const vec3 METAL_DIFFUSE = vec3(0.0); - #if defined(SPECULAR_IS_METALLIC) - // diffuse is actually base color, and red of specular is metallicness - float metallic = specular.r; - specular.rgb = (0.96 * metallic) * diffuse.rgb + vec3(0.04); - diffuse.rgb *= 1.0 - metallic; - #else - // adjust diffuse by specular reflectance, to maintain energy conservation - diffuse.rgb *= vec3(1.0) - specular.rgb; - #endif + float metalness = specular.r; + float roughness = max(specular.a, 0.02); + specular.rgb = mix(DIELECTRIC_SPECULAR, diffuse.rgb, metalness); + diffuse.rgb = mix(diffuse.rgb, METAL_DIFFUSE, metalness); + + float NE = abs(dot(N, E)) + 1e-5; + float NL = clamp(dot(N, L), 0.0, 1.0); - reflectance = diffuse.rgb; + vec3 Fd = diffuse.rgb; + vec3 Fs = vec3(0.0); #if defined(USE_LIGHT_VECTOR) - H = normalize(L + E); - EH = clamp(dot(E, H), 0.0, 1.0); - NH = clamp(dot(N, H), 0.0, 1.0); + vec3 H = normalize(L + E); + float LH = clamp(dot(L, H), 0.0, 1.0); + float NH = clamp(dot(N, H), 0.0, 1.0); - reflectance += CalcSpecular(specular.rgb, NH, NL, NE, EH, gloss); + Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); #endif - out_Color.rgb = lightColor * reflectance * (attenuation * NL); - out_Color.rgb += ambientColor * (diffuse.rgb + specular.rgb); - out_Color.rgb += CalcIBLContribution(gloss, N, E, viewDir, NE, specular.rgb); + vec3 reflectance = Fd + Fs; + out_Color.rgb = lightColor * reflectance * (attenuation * NL); + out_Color.rgb += ambientColor * diffuse.rgb; + #if defined(USE_PRIMARY_LIGHT) - vec3 L2, H2; - float NL2, EH2, NH2; - - L2 = normalize(var_PrimaryLightDir.xyz); - NL2 = clamp(dot(N, L2), 0.0, 1.0); - - H2 = normalize(L2 + E); - EH2 = clamp(dot(E, H2), 0.0, 1.0); - NH2 = clamp(dot(N, H2), 0.0, 1.0); + vec3 L2 = normalize(var_PrimaryLightDir.xyz); + vec3 H2 = normalize(L2 + E); + float NL2 = clamp(dot(N, L2), 0.0, 1.0); + float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); + float NH2 = clamp(dot(N, H2), 0.0, 1.0); reflectance = diffuse.rgb; - reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, EH2, gloss); + reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, roughness); lightColor = u_PrimaryLightColor * var_Color.rgb; #if defined(USE_SHADOWMAP) @@ -709,6 +702,8 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif + + out_Color.rgb += CalcIBLContribution(roughness, N, E, viewDir, NE, specular.rgb); #else lightColor = var_Color.rgb; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 2129284f41..bc014f51db 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1425,9 +1425,6 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; - if (r_specularIsMetallic->value) - Q_strcat(extradefines, sizeof(extradefines), "#define SPECULAR_IS_METALLIC\n"); - if (r_dlightMode->integer >= 2) Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index eb09d9e2c6..6872ec973c 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -131,12 +131,10 @@ cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_parallaxMapping; cvar_t *r_cubeMapping; -cvar_t *r_specularIsMetallic; cvar_t *r_baseNormalX; cvar_t *r_baseNormalY; cvar_t *r_baseParallax; cvar_t *r_baseSpecular; -cvar_t *r_baseGloss; cvar_t *r_mergeLightmaps; cvar_t *r_dlightMode; cvar_t *r_pshadowDist; @@ -1416,13 +1414,11 @@ void R_Register( void ) r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_specularIsMetallic = ri->Cvar_Get( "r_specularIsMetallic", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseGloss = ri->Cvar_Get( "r_baseGloss", "0.1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5c7948492d..41c278ee98 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2478,12 +2478,10 @@ extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; extern cvar_t *r_cubeMapping; -extern cvar_t *r_specularIsMetallic; extern cvar_t *r_baseNormalX; extern cvar_t *r_baseNormalY; extern cvar_t *r_baseParallax; extern cvar_t *r_baseSpecular; -extern cvar_t *r_baseGloss; extern cvar_t *r_dlightMode; extern cvar_t *r_pshadowDist; extern cvar_t *r_recalcMD3Normals; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 655e6a1039..5ac151487d 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -112,7 +112,7 @@ static void ClearGlobalShader(void) stages[i].specularScale[0] = stages[i].specularScale[1] = stages[i].specularScale[2] = r_baseSpecular->value; - stages[i].specularScale[3] = r_baseGloss->value; + stages[i].specularScale[3] = 0.9; } shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; From 237fed994a1af236ed11f9d1ac048758d62512d5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 29 May 2016 21:44:37 +0100 Subject: [PATCH 387/708] Rend2: Post processing is now mandatory --- codemp/rd-rend2/glsl/lightall.glsl | 43 +++++++++++++++++++++++++----- codemp/rd-rend2/glsl/tonemap.glsl | 10 +++++++ codemp/rd-rend2/tr_backend.cpp | 4 +-- codemp/rd-rend2/tr_init.cpp | 2 -- codemp/rd-rend2/tr_local.h | 2 -- codemp/rd-rend2/tr_postprocess.cpp | 2 +- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index d6f9a12257..99414a493f 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -471,7 +471,14 @@ float CalcVisibility( in float NL, in float NE, in float roughness ) } // http://www.frostbite.com/2014/11/moving-frostbite-to-pbr/ -vec3 CalcSpecular( in vec3 specular, in float NH, in float NL, in float NE, in float LH, in float roughness) +vec3 CalcSpecular( + in vec3 specular, + in float NH, + in float NL, + in float NE, + in float LH, + in float roughness +) { vec3 F = CalcFresnel(specular, vec3(1.0), LH); float D = CalcGGX(NH, roughness); @@ -480,6 +487,17 @@ vec3 CalcSpecular( in vec3 specular, in float NH, in float NL, in float NE, in f return D * F * V; } +vec3 CalcDiffuse( + in vec3 diffuse, + in float NE, + in float NL, + in float LH, + in float roughness +) +{ + return diffuse; +} + float CalcLightAttenuation(float point, float normDist) { // zero light at 1.0, approximating q3 style @@ -565,6 +583,13 @@ vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld return normalize(N); } +vec3 sRGBToLinear( in vec3 srgb ) +{ + vec3 lo = srgb / 12.92; + vec3 hi = pow(((srgb + vec3(0.055)) / 1.055), vec3(2.4)); + return mix(lo, hi, greaterThan(srgb, vec3(0.04045))); +} + void main() { vec3 viewDir, lightColor, ambientColor; @@ -586,6 +611,7 @@ void main() #if defined(RGBM_LIGHTMAP) lightmapColor.rgb *= lightmapColor.a; #endif + //lightmapColor.rgb = sRGBToLinear(lightmapColor.rgb); #endif vec2 texCoords = var_TexCoords.xy; @@ -605,6 +631,8 @@ void main() discard; #endif + //diffuse.rgb = sRGBToLinear(diffuse.rgb); + #if defined(PER_PIXEL_LIGHTING) float attenuation; @@ -625,7 +653,7 @@ void main() N = CalcNormal(var_Normal.xyz, texCoords, tangentToWorld); L /= sqrt(sqrLightDist); - #if defined(USE_SHADOWMAP) + #if defined(USE_SHADOWMAP) vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; float shadowValue = texture(u_ShadowMap, shadowTex).r; @@ -654,6 +682,7 @@ void main() vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) specular = texture(u_SpecularMap, texCoords); + //specular.rgb = sRGBToLinear(specular.rgb); #endif specular *= u_SpecularScale; @@ -666,15 +695,15 @@ void main() specular.rgb = mix(DIELECTRIC_SPECULAR, diffuse.rgb, metalness); diffuse.rgb = mix(diffuse.rgb, METAL_DIFFUSE, metalness); + vec3 H = normalize(L + E); float NE = abs(dot(N, E)) + 1e-5; float NL = clamp(dot(N, L), 0.0, 1.0); + float LH = clamp(dot(L, H), 0.0, 1.0); - vec3 Fd = diffuse.rgb; + vec3 Fd = CalcDiffuse(diffuse.rgb, NE, NL, LH, roughness); vec3 Fs = vec3(0.0); #if defined(USE_LIGHT_VECTOR) - vec3 H = normalize(L + E); - float LH = clamp(dot(L, H), 0.0, 1.0); float NH = clamp(dot(N, H), 0.0, 1.0); Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); @@ -682,7 +711,7 @@ void main() vec3 reflectance = Fd + Fs; - out_Color.rgb = lightColor * reflectance * (attenuation * NL); + out_Color.rgb = lightColor * reflectance * (attenuation * NL); out_Color.rgb += ambientColor * diffuse.rgb; #if defined(USE_PRIMARY_LIGHT) @@ -692,7 +721,7 @@ void main() float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); float NH2 = clamp(dot(N, H2), 0.0, 1.0); - reflectance = diffuse.rgb; + reflectance = CalcDiffuse(diffuse.rgb, NE, NL2, L2H2, roughness); reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, roughness); lightColor = u_PrimaryLightColor * var_Color.rgb; diff --git a/codemp/rd-rend2/glsl/tonemap.glsl b/codemp/rd-rend2/glsl/tonemap.glsl index 7c62fbb40a..045aab7438 100644 --- a/codemp/rd-rend2/glsl/tonemap.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -26,6 +26,15 @@ out vec4 out_Color; const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); +vec3 LinearTosRGB( in vec3 color ) +{ + vec3 clampedColor = clamp(color, 0.0, 1.0); + + vec3 lo = 12.92 * clampedColor; + vec3 hi = 1.055 * pow(clampedColor, vec3(0.41666)) - 0.055; + return mix(lo, hi, greaterThanEqual(color, vec3(0.0031308))); +} + vec3 FilmicTonemap(vec3 x) { const float SS = 0.22; // Shoulder Strength @@ -59,6 +68,7 @@ void main() vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x)); color.rgb = FilmicTonemap(color.rgb) * fWhite; + //color.rgb = LinearTosRGB(color.rgb); out_Color = clamp(color, 0.0, 1.0); } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c6055b79a6..a989c3c72c 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1025,7 +1025,7 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { void *allocMark = backEndData->perFrameMemory->Mark(); assert(backEndData->currentPass == nullptr); - backEndData->currentPass = RB_CreatePass(*backEndData->perFrameMemory, numDrawSurfs * 2); + backEndData->currentPass = RB_CreatePass(*backEndData->perFrameMemory, numDrawSurfs * 4); // save original time for entity shader offsets originalTime = backEnd.refdef.floatTime; @@ -2228,7 +2228,7 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (!r_postProcess->integer || (tr.viewParms.flags & VPF_NOPOSTPROCESS)) + if (tr.viewParms.flags & VPF_NOPOSTPROCESS) { // do nothing return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 6872ec973c..5640074ce4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -108,7 +108,6 @@ cvar_t *r_externalGLSL; cvar_t *r_hdr; cvar_t *r_floatLightmap; -cvar_t *r_postProcess; cvar_t *r_toneMap; cvar_t *r_forceToneMap; @@ -1390,7 +1389,6 @@ void R_Register( void ) r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_postProcess = ri->Cvar_Get( "r_postProcess", "1", CVAR_ARCHIVE, "" ); r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_forceToneMap = ri->Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 41c278ee98..5bfadc1cff 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -137,7 +137,6 @@ extern cvar_t *r_mergeLeafSurfaces; extern cvar_t *r_cameraExposure; extern cvar_t *r_hdr; -extern cvar_t *r_postProcess; extern cvar_t *r_toneMap; extern cvar_t *r_forceToneMap; @@ -2453,7 +2452,6 @@ extern cvar_t *r_externalGLSL; extern cvar_t *r_hdr; extern cvar_t *r_floatLightmap; -extern cvar_t *r_postProcess; extern cvar_t *r_toneMap; extern cvar_t *r_forceToneMap; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 76727b226a..e356cf481f 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -79,7 +79,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in // tonemap color[0] = color[1] = - color[2] = pow(2, r_cameraExposure->value); //exp2(r_cameraExposure->value); + color[2] = powf(2.0f, r_cameraExposure->value); //exp2(r_cameraExposure->value); color[3] = 1.0f; if (autoExposure) From 794d41659758429aa17f8908af34294722deb430 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 30 May 2016 10:11:22 +0100 Subject: [PATCH 388/708] Rend2: Fix splash screen not showing --- codemp/rd-rend2/tr_init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5640074ce4..edbc0f591d 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -261,7 +261,7 @@ cvar_t *r_debugContext; cvar_t *r_aspectCorrectFonts; extern void RB_SetGL2D (void); -void R_Splash() +static void R_Splash() { const GLfloat black[] = { 0.0f, 0.0f, 0.0f, 1.0f }; @@ -276,7 +276,7 @@ void R_Splash() if (pImage ) GL_Bind( pImage ); - GL_State(0); + GL_State(GLS_DEPTHTEST_DISABLE); GLSL_BindProgram(&tr.splashScreenShader); qglDrawArrays(GL_TRIANGLES, 0, 3); From e310c64d66905859f413d338c399e68e413a0397 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 11 Jun 2016 10:59:28 +0100 Subject: [PATCH 389/708] Rend2: Correct return value for freeing images C_Images_LevelLoadEnd should return qfalse as it does not free any memory. Returning qtrue would mean Z_Malloc can potentially hang in an infinite loop as it tries to allocate memory after thinking memory has been freed. --- codemp/rd-rend2/tr_cache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 1d40035abe..3fe6b2b96c 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -278,7 +278,7 @@ qboolean C_Models_LevelLoadEnd( qboolean deleteUnusedByLevel ) qboolean C_Images_LevelLoadEnd() { - return qtrue; + return qfalse; } /* From 43d6aca06e6067c1064ce6b54561bef8c7be09ce Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 21 Jul 2016 21:46:47 +0100 Subject: [PATCH 390/708] Did something, not sure what. --- codemp/rd-rend2/glsl/dlight.glsl | 65 +++---- codemp/rd-rend2/glsl/lightall.glsl | 24 +-- codemp/rd-rend2/tr_backend.cpp | 299 ++++++++++++++++++++--------- codemp/rd-rend2/tr_shade.cpp | 99 ++++------ 4 files changed, 285 insertions(+), 202 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight.glsl b/codemp/rd-rend2/glsl/dlight.glsl index 2168afdb82..f23c8feb5d 100644 --- a/codemp/rd-rend2/glsl/dlight.glsl +++ b/codemp/rd-rend2/glsl/dlight.glsl @@ -3,8 +3,6 @@ in vec3 attr_Position; in vec2 attr_TexCoord0; in vec3 attr_Normal; -uniform vec4 u_DlightInfo; - #if defined(USE_DEFORM_VERTEXES) uniform int u_DeformType; uniform int u_DeformFunc; @@ -12,11 +10,14 @@ uniform float u_DeformParams[7]; uniform float u_Time; #endif -uniform vec4 u_Color; +uniform vec4 u_LightOrigin; +uniform float u_LightRadius; + +uniform mat4 u_ModelMatrix; uniform mat4 u_ModelViewProjectionMatrix; -out vec2 var_Tex1; -out vec4 var_Color; +out vec3 var_Normal; +out vec4 var_LightDirAndRadiusSq; #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) @@ -159,49 +160,47 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) void main() { vec3 position = attr_Position; - vec3 normal = attr_Normal * 2.0 - vec3(1.0); + vec3 normal = normalize(attr_Normal * 2.0 - vec3(1.0)); #if defined(USE_DEFORM_VERTEXES) position = DeformPosition(position, normal, attr_TexCoord0.st); - normal = DeformNormal( position, normal ); + normal = DeformNormal(position, normal); #endif gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - vec3 dist = u_DlightInfo.xyz - position; - - var_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5); - float dlightmod = step(0.0, dot(dist, normal)); - dlightmod *= clamp(2.0 * (1.0 - abs(dist.z) * u_DlightInfo.a), 0.0, 1.0); - var_Color = u_Color * dlightmod; + vec3 positionWS = (u_ModelMatrix * vec4(position, 1.0)).xyz; + vec3 L = u_LightOrigin.xyz - positionWS; + L = (u_ModelMatrix * vec4(L, 0.0)).xyz; + + var_Normal = normalize((u_ModelMatrix * vec4(normal, 0.0)).xyz); + var_LightDirAndRadiusSq = vec4(L, u_LightRadius * u_LightRadius); } /*[Fragment]*/ -uniform sampler2D u_DiffuseMap; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; -#endif +uniform vec3 u_DirectedLight; -in vec2 var_Tex1; -in vec4 var_Color; +in vec3 var_Normal; +in vec4 var_LightDirAndRadiusSq; out vec4 out_Color; +float CalcLightAttenuation(float normDist) +{ + // zero light at 1.0, approximating q3 style + // also don't attenuate directional light + float attenuation = (0.5 * normDist - 1.5) + 1.0; + return clamp(attenuation, 0.0, 1.0); +} + void main() { - vec4 color = texture(u_DiffuseMap, var_Tex1); - -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (color.a < u_AlphaTestValue) -# endif - discard; -#endif + float lightDistSq = dot(var_LightDirAndRadiusSq.xyz, var_LightDirAndRadiusSq.xyz); + vec3 N = normalize(var_Normal); + vec3 L = var_LightDirAndRadiusSq.xyz / sqrt(lightDistSq); + + float attenuation = CalcLightAttenuation(var_LightDirAndRadiusSq.w / lightDistSq); + float NL = clamp(dot(N, L), 0.0, 1.0); - out_Color = color * var_Color; + out_Color = vec4(NL * attenuation * u_DirectedLight, 1.0); } diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 99414a493f..421e10e27b 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -156,20 +156,12 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) #endif -float CalcLightAttenuation(float point, float normDist) +float CalcLightAttenuation(in bool isPoint, float normDist) { // zero light at 1.0, approximating q3 style // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) * point + 1.0; - - // clamp attenuation - #if defined(NO_LIGHT_CLAMP) - attenuation = max(attenuation, 0.0); - #else - attenuation = clamp(attenuation, 0.0, 1.0); - #endif - - return attenuation; + float attenuation = 1.0 + mix(0.0, 0.5 * normDist - 1.5, isPoint); + return clamp(attenuation, 0.0, 1.0); } @@ -503,15 +495,7 @@ float CalcLightAttenuation(float point, float normDist) // zero light at 1.0, approximating q3 style // also don't attenuate directional light float attenuation = (0.5 * normDist - 1.5) * point + 1.0; - - // clamp attenuation - #if defined(NO_LIGHT_CLAMP) - attenuation = max(attenuation, 0.0); - #else - attenuation = clamp(attenuation, 0.0, 1.0); - #endif - - return attenuation; + return clamp(attenuation, 0.0, 1.0); } vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a989c3c72c..5eae54e6a4 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1048,106 +1048,89 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { backEnd.pc.c_surfaces += numDrawSurfs; - for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &postRender ); - fogNum = drawSurf->fogIndex; - entityNum = drawSurf->entityNum; - dlighted = drawSurf->dlightBits; - - if ( shader == oldShader && - fogNum == oldFogNum && - postRender == oldPostRender && - cubemapIndex == oldCubemapIndex && - entityNum == oldEntityNum && - dlighted == oldDlighted ) - { - if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) - continue; + if ( backEnd.depthFill ) + { + for ( i = 0, drawSurf = drawSurfs; i < numDrawSurfs; i++, drawSurf++ ) { + R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); + fogNum = drawSurf->fogIndex; + entityNum = drawSurf->entityNum; - // fast path, same as previous sort - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - continue; - } + if ( shader == oldShader && entityNum == oldEntityNum ) + { + if ( shader && shader->sort != SS_OPAQUE ) + continue; - oldSort = drawSurf->sort; - - // - // change the tess parameters if needed - // a "entityMergable" shader is a shader that can have surfaces from seperate - // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && - ( shader != oldShader || - fogNum != oldFogNum || - dlighted != oldDlighted || - postRender != oldPostRender || - cubemapIndex != oldCubemapIndex || - (entityNum != oldEntityNum && !shader->entityMergable))) - { - if (oldShader != NULL) { - RB_EndSurface(); + // fast path, same as previous sort + rb_surfaceTable[*drawSurf->surface](drawSurf->surface); + continue; } - RB_BeginSurface( shader, fogNum, cubemapIndex ); - backEnd.pc.c_surfBatches++; - oldShader = shader; - oldFogNum = fogNum; - oldDlighted = dlighted; - oldPostRender = postRender; - oldCubemapIndex = cubemapIndex; - } - - if (backEnd.depthFill && shader && shader->sort != SS_OPAQUE) - continue; - - // - // change the modelview matrix if needed - // - if ( entityNum != oldEntityNum ) { - depthRange = 0; + oldSort = drawSurf->sort; - if ( entityNum != REFENTITYNUM_WORLD ) { - backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; - // we have to reset the shaderTime as well otherwise image animations start - // from the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - - // set up the transformation matrix - R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); - - // set up the dynamic lighting if needed - if ( backEnd.currentEntity->needDlights ) { - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); + // + // change the tess parameters if needed + // a "entityMergable" shader is a shader that can have surfaces from seperate + // entities merged into a single batch, like smoke and blood puff sprites + if ( shader && + (shader != oldShader || + (entityNum != oldEntityNum && !shader->entityMergable)) ) + { + if ( oldShader != NULL ) { + RB_EndSurface(); } - if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { - // No depth at all, very rare but some things for seeing through walls - depthRange = 2; - } - else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { - // hack the depth range to prevent view model from poking into walls - depthRange = 1; - } - } else { - backEnd.currentEntity = &tr.worldEntity; - backEnd.refdef.floatTime = originalTime; - backEnd.ori = backEnd.viewParms.world; - // we have to reset the shaderTime as well otherwise image animations on - // the world (like water) continue with the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); + RB_BeginSurface(shader, 0, 0); + backEnd.pc.c_surfBatches++; + oldShader = shader; } - GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); + if ( shader && shader->sort != SS_OPAQUE ) + continue; // - // change depthrange. Also change projection matrix so first person weapon does not look like coming - // out of the screen. + // change the modelview matrix if needed // - if (oldDepthRange != depthRange) - { - switch ( depthRange ) + if ( entityNum != oldEntityNum ) { + depthRange = 0; + + if ( entityNum != REFENTITYNUM_WORLD ) { + backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; + backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; + // we have to reset the shaderTime as well otherwise image animations start + // from the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + + // set up the transformation matrix + R_RotateForEntity(backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori); + + if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { + // No depth at all, very rare but some things for seeing through walls + depthRange = 2; + } + else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { + // hack the depth range to prevent view model from poking into walls + depthRange = 1; + } + } + else { + backEnd.currentEntity = &tr.worldEntity; + backEnd.refdef.floatTime = originalTime; + backEnd.ori = backEnd.viewParms.world; + // we have to reset the shaderTime as well otherwise image animations on + // the world (like water) continue with the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + } + + GL_SetModelviewMatrix(backEnd.ori.modelViewMatrix); + + // + // change depthrange. Also change projection matrix so first person weapon does not look like coming + // out of the screen. + // + if ( oldDepthRange != depthRange ) { + switch ( depthRange ) + { default: case 0: if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) @@ -1173,16 +1156,150 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { GL_SetProjectionMatrix(temp.projectionMatrix); } break; + } + + oldDepthRange = depthRange; } - oldDepthRange = depthRange; + oldEntityNum = entityNum; } - oldEntityNum = entityNum; + // add the triangles for this surface + rb_surfaceTable[*drawSurf->surface](drawSurf->surface); } + } + else + { + for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { + R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &postRender ); + fogNum = drawSurf->fogIndex; + entityNum = drawSurf->entityNum; + dlighted = drawSurf->dlightBits; + + if ( shader == oldShader && + fogNum == oldFogNum && + postRender == oldPostRender && + cubemapIndex == oldCubemapIndex && + entityNum == oldEntityNum && + dlighted == oldDlighted ) + { + // fast path, same as previous sort + rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + continue; + } + + oldSort = drawSurf->sort; + + // + // change the tess parameters if needed + // a "entityMergable" shader is a shader that can have surfaces from seperate + // entities merged into a single batch, like smoke and blood puff sprites + if ( shader != NULL && + ( shader != oldShader || + fogNum != oldFogNum || + dlighted != oldDlighted || + postRender != oldPostRender || + cubemapIndex != oldCubemapIndex || + (entityNum != oldEntityNum && !shader->entityMergable))) + { + if (oldShader != NULL) { + RB_EndSurface(); + } + + RB_BeginSurface( shader, fogNum, cubemapIndex ); + backEnd.pc.c_surfBatches++; + oldShader = shader; + oldFogNum = fogNum; + oldDlighted = dlighted; + oldPostRender = postRender; + oldCubemapIndex = cubemapIndex; + } - // add the triangles for this surface - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + // + // change the modelview matrix if needed + // + if ( entityNum != oldEntityNum ) { + depthRange = 0; + + if ( entityNum != REFENTITYNUM_WORLD ) { + backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; + backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; + // we have to reset the shaderTime as well otherwise image animations start + // from the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + + // set up the transformation matrix + R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); + + // set up the dynamic lighting if needed + if ( backEnd.currentEntity->needDlights ) { + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); + } + + if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { + // No depth at all, very rare but some things for seeing through walls + depthRange = 2; + } + else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { + // hack the depth range to prevent view model from poking into walls + depthRange = 1; + } + } else { + backEnd.currentEntity = &tr.worldEntity; + backEnd.refdef.floatTime = originalTime; + backEnd.ori = backEnd.viewParms.world; + // we have to reset the shaderTime as well otherwise image animations on + // the world (like water) continue with the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); + } + + GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); + + // + // change depthrange. Also change projection matrix so first person weapon does not look like coming + // out of the screen. + // + if (oldDepthRange != depthRange) + { + switch ( depthRange ) + { + default: + case 0: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); + } + break; + + case 1: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + viewParms_t temp = backEnd.viewParms; + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + GL_SetProjectionMatrix(temp.projectionMatrix); + } + break; + + case 2: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + viewParms_t temp = backEnd.viewParms; + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + GL_SetProjectionMatrix(temp.projectionMatrix); + } + break; + } + + oldDepthRange = depthRange; + } + + oldEntityNum = entityNum; + } + + // add the triangles for this surface + rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + } } backEnd.refdef.floatTime = originalTime; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 290ca9ec76..a05d842fe8 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -697,7 +697,7 @@ static void ComputeFogColorMask( shaderStage_t *pStage, vec4_t fogColorMask ) } } -static void CaptureDrawData(shaderCommands_t *input, shaderStage_t *stage, int glslShaderIndex, int stageIndex ) +static void CaptureDrawData(const shaderCommands_t *input, shaderStage_t *stage, int glslShaderIndex, int stageIndex ) { if ( !tr.numFramesToCapture ) return; @@ -857,21 +857,11 @@ void RB_FillDrawCommand( } } -static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { - int l; - //vec3_t origin; - //float scale; - float radius; - +static void ForwardDlight( const shaderCommands_t *input, VertexArraysProperties *vertexArrays ) +{ deform_t deformType; genFunc_t deformGen; float deformParams[7]; - - vec4_t fogDistanceVector, fogDepthVector = {0, 0, 0, 0}; - float eyeT = 0; - - shaderCommands_t *input = &tess; - shaderStage_t *pStage = tess.xstages[0]; if ( !backEnd.refdef.num_dlights ) { return; @@ -879,8 +869,6 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { ComputeDeformValues(&deformType, &deformGen, deformParams); - ComputeFogValues(fogDistanceVector, fogDepthVector, &eyeT); - cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; @@ -889,38 +877,49 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { UniformDataWriter uniformDataWriter; SamplerBindingsWriter samplerBindingsWriter; - for ( l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - dlight_t *dl; - shaderProgram_t *sp; - vec4_t vector; - vec4_t texMatrix; - vec4_t texOffTurb; - - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definately doesn't have any of this light - } + shaderStage_t *pStage = tess.xstages[0]; + int index; + shaderProgram_t *shaderGroup; + uint32_t stateBits = 0; + if ( input->shader->numUnfoggedPasses == 1 && + pStage->glslShaderGroup == tr.lightallShader && + (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) ) + { + index = pStage->glslShaderIndex; - dl = &backEnd.refdef.dlights[l]; - //VectorCopy( dl->transformed, origin ); - radius = dl->radius; - //scale = 1.0f / radius; + stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + shaderGroup = tr.lightallShader; + index &= ~LIGHTDEF_LIGHTTYPE_MASK; + index |= LIGHTDEF_USE_LIGHT_VECTOR; - //if (pStage->glslShaderGroup == tr.lightallShader) - { - int index = pStage->glslShaderIndex; + if (glState.vertexAnimation) + index |= LIGHTDEF_USE_VERTEX_ANIMATION; - index &= ~LIGHTDEF_LIGHTTYPE_MASK; - index |= LIGHTDEF_USE_LIGHT_VECTOR; + if (glState.skeletalAnimation) + index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + } + else + { + index = 0; - if (glState.vertexAnimation) - index |= LIGHTDEF_USE_VERTEX_ANIMATION; + stateBits = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + shaderGroup = tr.dlightShader; + if ( deformGen != DGEN_NONE ) + index |= DLIGHTDEF_USE_DEFORM_VERTEXES; + } - if (glState.skeletalAnimation) - index |= LIGHTDEF_USE_SKELETAL_ANIMATION; + shaderProgram_t *sp = shaderGroup + index; + for ( int l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { + vec4_t texMatrix; + vec4_t texOffTurb; - sp = &tr.lightallShader[index]; + if ( !( tess.dlightBits & ( 1 << l ) ) ) { + continue; // this surface definately doesn't have any of this light } + dlight_t *dl = &backEnd.refdef.dlights[l]; + float radius = dl->radius; + backEnd.pc.c_lightallDraws++; uniformDataWriter.Start(sp); @@ -940,18 +939,6 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } - if ( input->fogNum ) { - vec4_t fogColorMask; - - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDISTANCE, fogDistanceVector); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGDEPTH, fogDepthVector); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGEYET, eyeT); - - ComputeFogColorMask(pStage, fogColorMask); - - uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); - } - { vec4_t baseColor; vec4_t vertColor; @@ -972,13 +959,12 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { uniformDataWriter.SetUniformVec3(UNIFORM_DIRECTEDLIGHT, dl->color); - VectorSet(vector, 0, 0, 0); + vec4_t vector = {}; uniformDataWriter.SetUniformVec3(UNIFORM_AMBIENTLIGHT, vector); VectorCopy(dl->origin, vector); vector[3] = 1.0f; uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vector); - uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, radius); uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); @@ -1013,9 +999,7 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); if (r_dlightMode->integer >= 2) - { samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l], TB_SHADOWMAP); - } ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); @@ -1024,14 +1008,13 @@ static void ForwardDlight( const VertexArraysProperties *vertexArrays ) { uniformDataWriter.SetUniformInt(UNIFORM_TCGEN0, pStage->bundle[0].tcGen); uniformDataWriter.SetUniformInt(UNIFORM_TCGEN1, pStage->bundle[1].tcGen); - CaptureDrawData(input, pStage, 0, 0); DrawItem item = {}; // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light // where they aren't rendered - item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + item.stateBits = stateBits; item.cullType = cullType; item.program = sp; item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); @@ -1907,7 +1890,7 @@ void RB_StageIteratorGeneric( void ) tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - ForwardDlight( &vertexArrays ); + ForwardDlight(input, &vertexArrays); } // From c902684ef0782df1b98045b4a64ec3bd36d048cb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 14 Sep 2016 20:48:46 +0100 Subject: [PATCH 391/708] Fix compiler errors --- codemp/rd-rend2/CMakeLists.txt | 1 - codemp/rd-rend2/tr_surface.cpp | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index c9822f5b08..b1004842e8 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -93,7 +93,6 @@ set(MPRend2Files ${MPRend2Files} ${MPRend2RdCommonFiles}) set(MPRend2CommonFiles "${MPDir}/qcommon/matcomp.cpp" - "${MPDir}/qcommon/q_math.cpp" "${MPDir}/qcommon/q_shared.cpp" "${SharedCommonFiles}") source_group("common" FILES ${MPRend2CommonFiles}) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index fbf38aca8b..cb1b9440dd 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -741,7 +741,7 @@ static void RB_SurfaceSaberGlow() // Big hilt sprite // Please don't kill me Pat...I liked the hilt glow blob, but wanted a subtle pulse.:) Feel free to ditch it if you don't like it. --Jeff // Please don't kill me Jeff... The pulse is good, but now I want the halo bigger if the saber is shorter... --Pat - DoSprite( e->origin, 5.5f + random() * 0.25f, 0.0f );//random() * 360.0f ); + DoSprite( e->origin, 5.5f + Q_flrand(0.0f, 1.0f) * 0.25f, 0.0f );//random() * 360.0f ); } /* @@ -1102,14 +1102,14 @@ static float Q_crandom( int *seed ) { static void CreateShape() //---------------------------------------------------------------------------- { - VectorSet( sh1, 0.66f + crandom() * 0.1f, // fwd - 0.07f + crandom() * 0.025f, - 0.07f + crandom() * 0.025f ); + VectorSet( sh1, 0.66f + Q_flrand(-1.0f, 1.0f) * 0.1f, // fwd + 0.07f + Q_flrand(-1.0f, 1.0f) * 0.025f, + 0.07f + Q_flrand(-1.0f, 1.0f) * 0.025f ); // it seems to look best to have a point on one side of the ideal line, then the other point on the other side. - VectorSet( sh2, 0.33f + crandom() * 0.1f, // fwd - -sh1[1] + crandom() * 0.02f, // forcing point to be on the opposite side of the line -- right - -sh1[2] + crandom() * 0.02f );// up + VectorSet( sh2, 0.33f + Q_flrand(-1.0f, 1.0f) * 0.1f, // fwd + -sh1[1] + Q_flrand(-1.0f, 1.0f) * 0.02f, // forcing point to be on the opposite side of the line -- right + -sh1[2] + Q_flrand(-1.0f, 1.0f) * 0.02f );// up } //---------------------------------------------------------------------------- From f09b8b04cf4b0ad6e2dd4ad2870642a2f54de11b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 21 Oct 2016 21:58:26 +0100 Subject: [PATCH 392/708] Start of weather code --- code/qcommon/.cm_load.cpp.un~ | Bin 1851 -> 0 bytes codemp/rd-rend2/CMakeLists.txt | 2 + codemp/rd-rend2/tr_backend.cpp | 16 ++++ codemp/rd-rend2/tr_glsl.cpp | 69 +++++++------- codemp/rd-rend2/tr_glsl_parse.cpp | 8 ++ codemp/rd-rend2/tr_init.cpp | 5 + codemp/rd-rend2/tr_local.h | 23 ++++- codemp/rd-rend2/tr_main.cpp | 6 ++ codemp/rd-rend2/tr_weather.cpp | 151 ++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_weather.h | 31 ++++++ 10 files changed, 275 insertions(+), 36 deletions(-) delete mode 100644 code/qcommon/.cm_load.cpp.un~ create mode 100644 codemp/rd-rend2/tr_weather.cpp create mode 100644 codemp/rd-rend2/tr_weather.h diff --git a/code/qcommon/.cm_load.cpp.un~ b/code/qcommon/.cm_load.cpp.un~ deleted file mode 100644 index 47088cd71159f2493e94146ffbd55517447ce5fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1851 zcmWH`%$*;a=aT=FfvHc+Nto}^3dtkBoej&HqIvB6;;y)TvMqb+uplq;T^u6=1Irl( zRKNt}GDC$xGz>F@y^4R$0@T64$Pj-4NdZU*1b`Y@rbCzv4F7=usBjdJ83Krq1cvGi zBtybrY+!Ue2S*13!&eEQqG?FM4+?l58wgPFaCLMsZ3IUdC~lDfFm74q!30L53>FgP z(TI=)hU!WrGmxVUmV>}iHWw-Qd4L+&Z6N^2bmGiR(@;px%}>#_%Sla4)5|N(^#Rhs zrA29p$*IK(nw{e~ z!!^jy!(KtbBfnfBIlnX~MWH-ZAtSLYRUuI!uQVqI8~_UCnI##Sc?$WZMaZ5)3tfAl z8;pUbawg~Jm89mC6f4w#0tvfYbnRfOKu%`?>Z%3Oe0C6^kegUsl3E1KfIta20A)sC kMn&ZG(F_O=8?qRPkVFnupi#&f@F{wkITL1=Y2))%05n|Cu>b%7 diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index b1004842e8..d7462ec8c1 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -61,6 +61,8 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_surface.cpp" "${MPDir}/rd-rend2/tr_vbo.cpp" "${MPDir}/rd-rend2/tr_world.cpp" + "${MPDir}/rd-rend2/tr_weather.cpp" + "${MPDir}/rd-rend2/tr_weather.h" ) source_group("renderer" FILES ${MPRend2Files}) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5eae54e6a4..28fdfa57ad 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -424,6 +424,12 @@ void GL_MultiDrawIndexed( numDraws); } +void GL_Draw( GLenum primitiveType, int firstVertex, int numVertices, int numInstances ) +{ + assert(numInstances > 0); + qglDrawArraysInstanced(primitiveType, firstVertex, numVertices, numInstances); +} + void GL_SetProjectionMatrix(matrix_t matrix) { Matrix16Copy(matrix, glState.projection); @@ -959,6 +965,16 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t break; } + case DRAW_COMMAND_ARRAYS: + { + GL_Draw( + drawItem.draw.primitiveType, + drawItem.draw.params.arrays.firstVertex, + drawItem.draw.params.arrays.numVertices, + drawItem.draw.numInstances); + break; + } + default: { assert(!"Invalid or unhandled draw type"); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index bc014f51db..306b832e20 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -627,8 +627,12 @@ static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) return true; } -static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, - int attribs, qboolean fragmentShader, const GLcharARB *extra, const GPUProgramDesc& programDesc) +static int GLSL_BeginLoadGPUShader( + shaderProgram_t *program, + const char *name, + uint32_t attribs, + const GLcharARB *extra, + const GPUProgramDesc& programDesc) { char vpCode[32000]; char fpCode[32000]; @@ -652,24 +656,21 @@ static int GLSL_BeginLoadGPUShader(shaderProgram_t * program, const char *name, return 0; } - if (fragmentShader) - { - size_t fragmentShaderCodeLen; + size_t fragmentShaderCodeLen; - size = sizeof(fpCode); + size = sizeof(fpCode); - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, programDesc.shaders[1].firstLine, fpCode, size); - fragmentShaderCodeLen = strlen(fpCode); - postHeader = &fpCode[fragmentShaderCodeLen]; - size -= fragmentShaderCodeLen; + GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, programDesc.shaders[1].firstLine, fpCode, size); + fragmentShaderCodeLen = strlen(fpCode); + postHeader = &fpCode[fragmentShaderCodeLen]; + size -= fragmentShaderCodeLen; - if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[1].source, GL_FRAGMENT_SHADER, postHeader, size)) - { - return 0; - } + if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[1].source, GL_FRAGMENT_SHADER, postHeader, size)) + { + return 0; } - return GLSL_BeginLoadGPUShader2(program, name, attribs, vpCode, fragmentShader ? fpCode : NULL); + return GLSL_BeginLoadGPUShader2(program, name, attribs, vpCode, fpCode); } void GLSL_InitUniforms(shaderProgram_t *program) @@ -1293,7 +1294,7 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); @@ -1353,7 +1354,7 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); @@ -1401,7 +1402,7 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); @@ -1548,7 +1549,7 @@ int GLSL_BeginLoadGPUShaders(void) if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); - if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); @@ -1561,7 +1562,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("texturecolor", allocator, fallback_texturecolorProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); @@ -1574,7 +1575,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); @@ -1589,7 +1590,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); @@ -1601,7 +1602,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("down4x", allocator, fallback_down4xProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load down4x shader!"); @@ -1613,7 +1614,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("bokeh", allocator, fallback_bokehProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load bokeh shader!"); @@ -1625,7 +1626,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("tonemap", allocator, fallback_tonemapProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load tonemap shader!"); @@ -1643,7 +1644,7 @@ int GLSL_BeginLoadGPUShaders(void) if (!i) Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); - if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); @@ -1668,7 +1669,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); @@ -1680,7 +1681,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("ssao", allocator, fallback_ssaoProgram); attribs = ATTR_POSITION | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load ssao shader!"); @@ -1701,7 +1702,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); - if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); @@ -1716,7 +1717,7 @@ int GLSL_BeginLoadGPUShaders(void) extradefines[0] = '\0'; Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); @@ -1724,7 +1725,7 @@ int GLSL_BeginLoadGPUShaders(void) attribs = 0; - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, nullptr, *programDesc)) { ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); @@ -1736,7 +1737,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("dglow_downsample", allocator, fallback_dglow_downsampleProgram); attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); @@ -1748,7 +1749,7 @@ int GLSL_BeginLoadGPUShaders(void) programDesc = LoadProgramSource("dglow_upsample", allocator, fallback_dglow_upsampleProgram); attribs = 0; extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); @@ -1776,7 +1777,7 @@ int GLSL_BeginLoadGPUShaders(void) Q_strcat(extradefines, sizeof(extradefines), "#define ALPHA_TEST\n"); - if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", attribs, qtrue, + if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index 33f1011d71..118341a6ac 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -155,5 +155,13 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) theProgram.shaders[1].source = fragmentSource; theProgram.shaders[1].firstLine = fragmentBlock->blockTextFirstLine; + Block *geometryBlock = FindBlock("Geometry", blocks, numBlocks); + if ( geometryBlock ) + { + theProgram.shaders[2].type = GPUSHADER_FRAGMENT; + theProgram.shaders[2].source = fragmentSource; + theProgram.shaders[2].firstLine = fragmentBlock->blockTextFirstLine; + } + return theProgram; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index edbc0f591d..fa58167d7f 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "ghoul2/g2_local.h" #include "tr_cache.h" #include "tr_allocator.h" +#include "tr_weather.h" #include static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; @@ -1766,6 +1767,8 @@ void R_Init( void ) { R_InitQueries(); + R_InitWeatherSystem(); + GLSL_EndLoadGPUShaders (shadersStartTime); #if defined(_DEBUG) @@ -1795,6 +1798,8 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { R_ShutdownBackEndFrameData(); + R_ShutdownWeatherSystem(); + R_ShutdownFonts(); if ( tr.registered ) { R_IssuePendingRenderCommands(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5bfadc1cff..eff8cefcf4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1143,8 +1143,10 @@ struct Block enum GPUShaderType { + GPUSHADER_NONE, GPUSHADER_VERTEX, - GPUSHADER_FRAGMENT + GPUSHADER_FRAGMENT, + GPUSHADER_GEOMETRY, }; struct GPUShaderDesc @@ -1408,7 +1410,8 @@ SURFACES typedef byte color4ub_t[4]; // any changes in surfaceType must be mirrored in rb_surfaceTable[] -typedef enum { +typedef enum surfaceType_e +{ SF_BAD, SF_SKIP, // ignore SF_FACE, @@ -1424,6 +1427,7 @@ typedef enum { SF_VBO_MESH, SF_VBO_MDVMESH, SF_SPRITES, + SF_WEATHER, SF_NUM_SURFACE_TYPES, SF_MAX = 0x7fffffff // ensures that sizeof( surfaceType_t ) == sizeof( int ) @@ -1494,6 +1498,11 @@ struct srfSprites_t vertexAttribute_t *attributes; }; +struct srfWeather_t +{ + surfaceType_t surfaceType; +}; + typedef struct { vec3_t xyz; @@ -2141,6 +2150,7 @@ typedef struct { ** but may read fields that aren't dynamically modified ** by the frontend. */ +struct weatherSystem_t; typedef struct trGlobals_s { qboolean registered; // cleared at shutdown, set at beginRegistration @@ -2241,6 +2251,8 @@ typedef struct trGlobals_s { trRefEntity_t worldEntity; // point currentEntity at this when rendering world model_t *currentModel; + weatherSystem_t *weatherSystem; + // // GPU shader programs // @@ -2595,6 +2607,7 @@ void GL_DrawIndexed(GLenum primitiveType, int numIndices, int offset, int numInstances, int baseVertex); void GL_MultiDrawIndexed(GLenum primitiveType, int *numIndices, glIndex_t **offsets, int numDraws); +void GL_Draw( GLenum primitiveType, int firstVertex, int numVertices, int numInstances ); #define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) #define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) @@ -3416,6 +3429,12 @@ struct DrawCommand GLsizei numIndices; glIndex_t firstIndex; } indexed; + + struct DrawArrays + { + glIndex_t firstVertex; + GLsizei numVertices; + } arrays; } params; }; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 8dca662b0f..02a8fc7aa7 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_main.c -- main control flow for each frame #include "tr_local.h" +#include "tr_weather.h" #include // memcpy @@ -1997,6 +1998,11 @@ void R_GenerateDrawSurfs( void ) { R_SetupProjectionZ (&tr.viewParms); R_AddEntitySurfaces (); + + if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) + { + R_AddWeatherSurfaces(); + } } /* diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp new file mode 100644 index 0000000000..70d6670cff --- /dev/null +++ b/codemp/rd-rend2/tr_weather.cpp @@ -0,0 +1,151 @@ +/* +=========================================================================== +Copyright (C) 2016, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#include "tr_weather.h" +#include "tr_local.h" + +struct weatherSystem_t +{ + VBO_t *vbo; + int numVertices; + + srfWeather_t weatherSurface; +}; + +namespace +{ + struct rainVertex_t + { + vec3_t position; + vec3_t seed; + }; + + void GenerateRainModel( weatherSystem_t& ws ) + { + static const int MAX_RAIN_VERTICES = 1000; + rainVertex_t rainVertices[MAX_RAIN_VERTICES]; + + for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) + { + rainVertex_t& vertex = rainVertices[i]; + vertex.position[0] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[1] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[2] = Q_flrand(-1000.0f, 1000.0f); + vertex.seed[0] = Q_flrand(0.0f, 1.0f); + vertex.seed[1] = Q_flrand(0.0f, 1.0f); + vertex.seed[2] = Q_flrand(0.0f, 1.0f); + } + + ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_STATIC); + ws.numVertices = MAX_RAIN_VERTICES; + } +} + +void R_InitWeatherSystem() +{ + Com_Printf("Initializing weather system\n"); + tr.weatherSystem = (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); + GenerateRainModel(*tr.weatherSystem); +} + +void R_ShutdownWeatherSystem() +{ + if ( tr.weatherSystem ) + { + Com_Printf("Shutting down weather system\n"); + + Z_Free(tr.weatherSystem); + tr.weatherSystem = nullptr; + } + else + { + ri->Printf(PRINT_DEVELOPER, + "Weather system shutdown requested, but it is already shut down.\n"); + } +} + +void R_AddWeatherSurfaces() +{ + assert(tr.weatherSystem); + + R_AddDrawSurf( + (surfaceType_t *)&tr.weatherSystem->weatherSurface, + REFENTITYNUM_WORLD, + tr.defaultShader, + 0, /* fogIndex */ + qfalse, /* dlightMap */ + qfalse, /* postRender */ + 0 /* cubemapIndex */ + ); +} + +void R_RenderWeatherSurface( srfWeather_t *surf ) +{ + assert(tr.weatherSystem); + + const weatherSystem_t& ws = *tr.weatherSystem; + assert(surf == &ws.weatherSurface); + + RB_EndSurface(); + + DrawItem item = {}; + + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; + + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light + // where they aren't rendered + item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + item.cullType = CT_FRONT_SIDED; + item.program = nullptr; + item.depthRange = { 0.0f, 1.0f }; + + vertexAttribute_t attribs[2] = {}; + attribs[0].index = 0; + attribs[0].numComponents = 3; + attribs[0].offset = offsetof(rainVertex_t, position); + attribs[0].stride = sizeof(rainVertex_t); + attribs[0].type = GL_FLOAT; + attribs[0].vbo = ws.vbo; + attribs[1].index = 1; + attribs[1].numComponents = 3; + attribs[1].offset = offsetof(rainVertex_t, seed); + attribs[1].stride = sizeof(rainVertex_t); + attribs[1].type = GL_FLOAT; + attribs[1].vbo = ws.vbo; + + const size_t numAttribs = ARRAY_LEN(attribs); + item.numAttributes = numAttribs; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, numAttribs); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*numAttribs); + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + // FIXME: This is a bit ugly with the casting + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + + item.draw.type = DRAW_COMMAND_ARRAYS; + item.draw.numInstances = 100; + item.draw.primitiveType = GL_TRIANGLES; + + uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); + RB_AddDrawItem(backEndData->currentPass, key, item); +} diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h new file mode 100644 index 0000000000..a93e9aa195 --- /dev/null +++ b/codemp/rd-rend2/tr_weather.h @@ -0,0 +1,31 @@ +/* +=========================================================================== +Copyright (C) 2016, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ +#pragma once + +#include "qcommon/qcommon.h" + + +struct weatherSystem_t; +struct srfWeather_t; + +void R_InitWeatherSystem(); +void R_AddWeatherSurfaces(); +void R_ShutdownWeatherSystem(); +void R_RenderWeatherSurface( srfWeather_t *surfaceType ); From 28a977b0a7af6b2962a48103fef523ce0a9fa733 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 15 Dec 2016 21:25:05 +0000 Subject: [PATCH 393/708] Move some uses of globals into arguments --- codemp/rd-rend2/tr_backend.cpp | 30 +++++++++++++ codemp/rd-rend2/tr_local.h | 15 ++++++- codemp/rd-rend2/tr_main.cpp | 77 ++++++++++++++++++---------------- codemp/rd-rend2/tr_scene.cpp | 45 +++++++++----------- codemp/rd-rend2/tr_world.cpp | 70 +++++++++++++++++-------------- 5 files changed, 141 insertions(+), 96 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 28fdfa57ad..0bea7b099d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1040,6 +1040,36 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { void *allocMark = backEndData->perFrameMemory->Mark(); + /* + merging surfaces together that share the same shader (e.g. polys, patches) + upload per frame data - but this might be the same between render passes? + + how about: + tr.refdef.entities[] + + and .... entityCullInfo_t tr.refdef.entityCullInfo[] + struct visibleEntity_t + { + uint32_t frustumMask; // bitfield of frustums which intersect + EntityId entityId; + }; + + foreach ghoul2 model: + transform bones + + foreach visibleEntity: + upload per frame data + + for polygons: + merge them, create new surface and upload data + + for patch meshes: + merge them, create new surface and upload data + + + each surface corresponds to something which has all of its gpu data uploaded + */ + assert(backEndData->currentPass == nullptr); backEndData->currentPass = RB_CreatePass(*backEndData->perFrameMemory, numDrawSurfs * 4); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index eff8cefcf4..437aaa7fa3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1295,6 +1295,16 @@ struct technique_t shaderProgram_t *forward; }; +struct EntityCullInfo +{ + uint32_t frustumMask; +}; + +struct WorkingScene +{ + EntityCullInfo entityCullInfo[MAX_REFENTITIES]; +}; + // trRefdef_t holds everything that comes in refdef_t, // as well as the locally generated scene information typedef struct { @@ -1470,6 +1480,7 @@ typedef struct drawSurf_s { // as soon as it is called typedef struct srfPoly_s { surfaceType_t surfaceType; + struct srfPoly_s *next; qhandle_t hShader; int fogIndex; int numVerts; @@ -2556,7 +2567,7 @@ void R_AddBeamSurfaces( trRefEntity_t *e, int entityNum ); void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); void R_AddLightningBoltSurfaces( trRefEntity_t *e ); -void R_AddPolygonSurfaces( void ); +void R_AddPolygonSurfaces( const trRefdef_t *refdef ); void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postRender ); uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender); @@ -2798,7 +2809,7 @@ WORLD MAP */ void R_AddBrushModelSurfaces( trRefEntity_t *e, int entityNum ); -void R_AddWorldSurfaces( void ); +void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ); qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 02a8fc7aa7..fdce54fe52 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -817,19 +817,19 @@ static void R_RotateForViewer(viewParms_t *viewParms) /* ** SetFarClip */ -static void R_SetFarClip( void ) +static void R_SetFarClip( viewParms_t *viewParms, const trRefdef_t *refdef ) { float farthestCornerDistance = 0; int i; // if not rendering the world (icons, menus, etc) // set a 2k far clip plane - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + if ( refdef->rdflags & RDF_NOWORLDMODEL ) { // override the zfar then - if ( tr.refdef.rdflags & RDF_AUTOMAP ) - tr.viewParms.zFar = 32768.0f; + if ( refdef->rdflags & RDF_AUTOMAP ) + viewParms->zFar = 32768.0f; else - tr.viewParms.zFar = 2048.0f; + viewParms->zFar = 2048.0f; return; } @@ -843,42 +843,43 @@ static void R_SetFarClip( void ) if ( i & 1 ) { - v[0] = tr.viewParms.visBounds[0][0]; + v[0] = viewParms->visBounds[0][0]; } else { - v[0] = tr.viewParms.visBounds[1][0]; + v[0] = viewParms->visBounds[1][0]; } if ( i & 2 ) { - v[1] = tr.viewParms.visBounds[0][1]; + v[1] = viewParms->visBounds[0][1]; } else { - v[1] = tr.viewParms.visBounds[1][1]; + v[1] = viewParms->visBounds[1][1]; } if ( i & 4 ) { - v[2] = tr.viewParms.visBounds[0][2]; + v[2] = viewParms->visBounds[0][2]; } else { - v[2] = tr.viewParms.visBounds[1][2]; + v[2] = viewParms->visBounds[1][2]; } - distance = DistanceSquared( tr.viewParms.ori.origin, v ); + distance = DistanceSquared( viewParms->ori.origin, v ); if ( distance > farthestCornerDistance ) { farthestCornerDistance = distance; } } + // Bring in the zFar to the distanceCull distance // The sky renders at zFar so need to move it out a little // ...and make sure there is a minimum zfar to prevent problems - tr.viewParms.zFar = Com_Clamp(2048.0f, tr.distanceCull * (1.732), sqrtf( farthestCornerDistance )); + viewParms->zFar = Com_Clamp(2048.0f, tr.distanceCull * (1.732), sqrtf( farthestCornerDistance )); } /* @@ -1862,12 +1863,12 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); } -static void R_AddEntitySurface (int entityNum) +static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) { trRefEntity_t *ent; shader_t *shader; - ent = tr.currentEntity = &tr.refdef.entities[entityNum]; + ent = tr.currentEntity = &refdef->entities[entityNum]; ent->needDlights = qfalse; @@ -1960,15 +1961,13 @@ static void R_AddEntitySurface (int entityNum) R_AddEntitySurfaces ============= */ -void R_AddEntitySurfaces (void) { - int i; - +static void R_AddEntitySurfaces(const trRefdef_t *refdef) { if ( !r_drawentities->integer ) { return; } - for ( i = 0; i < tr.refdef.num_entities; i++) - R_AddEntitySurface(i); + for (int i = 0; i < refdef->num_entities; i++) + R_AddEntitySurface(refdef, i); } @@ -1977,10 +1976,10 @@ void R_AddEntitySurfaces (void) { R_GenerateDrawSurfs ==================== */ -void R_GenerateDrawSurfs( void ) { - R_AddWorldSurfaces (); +static void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { + R_AddWorldSurfaces(viewParms, refdef); - R_AddPolygonSurfaces(); + R_AddPolygonSurfaces(refdef); // set the projection matrix with the minimum zfar // now that we have the world bounded @@ -1991,13 +1990,13 @@ void R_GenerateDrawSurfs( void ) { // dynamically compute far clip plane distance if (!(tr.viewParms.flags & VPF_SHADOWMAP)) { - R_SetFarClip(); + R_SetFarClip(viewParms, refdef); } // we know the size of the clipping volume. Now set the rest of the projection matrix. - R_SetupProjectionZ (&tr.viewParms); + R_SetupProjectionZ(viewParms); - R_AddEntitySurfaces (); + R_AddEntitySurfaces(refdef); if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) { @@ -2089,7 +2088,7 @@ void R_RenderView (viewParms_t *parms) { R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); - R_GenerateDrawSurfs(); + R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); @@ -2496,7 +2495,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) for (j = 0; j < shadow->numEntities; j++) { - R_AddEntitySurface(shadow->entityNums[j]); + R_AddEntitySurface(&tr.refdef, shadow->entityNums[j]); } R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); @@ -2725,7 +2724,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) { int firstDrawSurf; - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); + Com_Memset(&shadowParms, 0, sizeof( shadowParms )); shadowParms.viewportX = 0; shadowParms.viewportY = 0; @@ -2739,7 +2738,8 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) shadowParms.targetFbo = tr.sunShadowFbo[level]; - shadowParms.flags = (viewParmFlags_t)( VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL ); + shadowParms.flags = (viewParmFlags_t)( + VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL); shadowParms.zFar = lightviewBounds[1][0]; VectorCopy(lightOrigin, shadowParms.ori.origin); @@ -2766,16 +2766,21 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); - R_AddWorldSurfaces (); + R_AddWorldSurfaces(&tr.viewParms, &tr.refdef); - R_AddPolygonSurfaces(); + R_AddPolygonSurfaces(&tr.refdef); - R_AddEntitySurfaces (); + R_AddEntitySurfaces(&tr.refdef); - R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); - } + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); - Matrix16Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelViewMatrix, tr.refdef.sunShadowMvp[level]); + Matrix16Multiply( + tr.viewParms.projectionMatrix, + tr.viewParms.world.modelViewMatrix, + tr.refdef.sunShadowMvp[level]); + } } } diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 09a5bb03a3..759808f7ab 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -89,17 +89,21 @@ R_AddPolygonSurfaces Adds all the scene's polys into this view's drawsurf list ===================== */ -void R_AddPolygonSurfaces( void ) { - int i; - shader_t *sh; - srfPoly_t *poly; - int fogMask; - - fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0); - - for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) { - sh = R_GetShaderByHandle( poly->hShader ); - R_AddDrawSurf( ( surfaceType_t * )poly, REFENTITYNUM_WORLD, sh, poly->fogIndex & fogMask, qfalse, R_IsPostRenderEntity (REFENTITYNUM_WORLD, tr.currentEntity), 0 /* cubemapIndex */ ); +void R_AddPolygonSurfaces( const trRefdef_t *refdef ) { + srfPoly_t *poly; + int fogMask = -((refdef->rdflags & RDF_NOFOG) == 0); + + int i; + for ( i = 0, poly = refdef->polys; i < refdef->numPolys ; i++, poly++ ) { + shader_t *sh = R_GetShaderByHandle( poly->hShader ); + R_AddDrawSurf( + (surfaceType_t *)poly, + REFENTITYNUM_WORLD, + sh, + poly->fogIndex & fogMask, + qfalse, + R_IsPostRenderEntity(REFENTITYNUM_WORLD, tr.currentEntity), + 0 /* cubemapIndex */ ); } } @@ -120,22 +124,11 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts return; } - if ( !hShader ) { - // This isn't a useful warning, and an hShader of zero isn't a null shader, it's - // the default shader. - //ri->Printf( PRINT_WARNING, "WARNING: RE_AddPolyToScene: NULL poly shader\n"); - //return; - } - for ( j = 0; j < numPolys; j++ ) { - if ( r_numpolyverts + numVerts > max_polyverts || r_numpolys >= max_polys ) { - /* - NOTE TTimo this was initially a PRINT_WARNING - but it happens a lot with high fighting scenes and particles - since we don't plan on changing the const and making for room for those effects - simply cut this message to developer only - */ - ri->Printf( PRINT_DEVELOPER, "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); + if ( (r_numpolyverts + numVerts) > max_polyverts || r_numpolys >= max_polys ) { + ri->Printf( + PRINT_DEVELOPER, + S_COLOR_YELLOW "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); return; } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 7871c97407..88831d8f72 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -425,7 +425,8 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, // if the node wasn't marked as potentially visible, exit // pvs is skipped for depth shadows - if (!(tr.viewParms.flags & VPF_DEPTHSHADOW) && node->visCounts[tr.visIndex] != tr.visCounts[tr.visIndex]) { + if (!(tr.viewParms.flags & VPF_DEPTHSHADOW) && + node->visCounts[tr.visIndex] != tr.visCounts[tr.visIndex]) { return; } @@ -780,43 +781,43 @@ static void R_MarkLeaves (void) { R_AddWorldSurfaces ============= */ -void R_AddWorldSurfaces (void) { +void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { int planeBits, dlightBits, pshadowBits; if ( !r_drawworld->integer ) { return; } - if ( tr.refdef.rdflags & RDF_NOWORLDMODEL ) { + if ( refdef->rdflags & RDF_NOWORLDMODEL ) { return; } // determine which leaves are in the PVS / areamask - if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) + if (!(viewParms->flags & VPF_DEPTHSHADOW)) R_MarkLeaves (); // clear out the visible min/max - ClearBounds( tr.viewParms.visBounds[0], tr.viewParms.visBounds[1] ); + ClearBounds(viewParms->visBounds[0], viewParms->visBounds[1]); // perform frustum culling and flag all the potentially visible surfaces - tr.refdef.num_dlights = Q_min (tr.refdef.num_dlights, 32) ; - tr.refdef.num_pshadows = Q_min (tr.refdef.num_pshadows, 32) ; + refdef->num_dlights = Q_min(refdef->num_dlights, 32); + refdef->num_pshadows = Q_min(refdef->num_pshadows, 32); - planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + planeBits = (viewParms->flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; - if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) + if ( viewParms->flags & VPF_DEPTHSHADOW ) { dlightBits = 0; pshadowBits = 0; } - else if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) + else if ( !(viewParms->flags & VPF_SHADOWMAP) ) { - dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; - pshadowBits = ( 1 << tr.refdef.num_pshadows ) - 1; + dlightBits = ( 1 << refdef->num_dlights ) - 1; + pshadowBits = ( 1 << refdef->num_pshadows ) - 1; } else { - dlightBits = ( 1 << tr.refdef.num_dlights ) - 1; + dlightBits = ( 1 << refdef->num_dlights ) - 1; pshadowBits = 0; } @@ -824,28 +825,33 @@ void R_AddWorldSurfaces (void) { // now add all the potentially visible surfaces // also mask invisible dlights for next frame - { - int i; - - tr.refdef.dlightMask = 0; + refdef->dlightMask = 0; - for (i = 0; i < tr.world->numWorldSurfaces; i++) - { - if (tr.world->surfacesViewCount[i] != tr.viewCount) - continue; + for (int i = 0; i < tr.world->numWorldSurfaces; i++) + { + if (tr.world->surfacesViewCount[i] != tr.viewCount) + continue; - R_AddWorldSurface( tr.world->surfaces + i, REFENTITYNUM_WORLD, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i] ); - tr.refdef.dlightMask |= tr.world->surfacesDlightBits[i]; - } - for (i = 0; i < tr.world->numMergedSurfaces; i++) - { - if (tr.world->mergedSurfacesViewCount[i] != tr.viewCount) - continue; + R_AddWorldSurface( + tr.world->surfaces + i, + REFENTITYNUM_WORLD, + tr.world->surfacesDlightBits[i], + tr.world->surfacesPshadowBits[i]); + refdef->dlightMask |= tr.world->surfacesDlightBits[i]; + } - R_AddWorldSurface( tr.world->mergedSurfaces + i, REFENTITYNUM_WORLD, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i] ); - tr.refdef.dlightMask |= tr.world->mergedSurfacesDlightBits[i]; - } + for (int i = 0; i < tr.world->numMergedSurfaces; i++) + { + if (tr.world->mergedSurfacesViewCount[i] != tr.viewCount) + continue; - tr.refdef.dlightMask = ~tr.refdef.dlightMask; + R_AddWorldSurface( + tr.world->mergedSurfaces + i, + REFENTITYNUM_WORLD, + tr.world->mergedSurfacesDlightBits[i], + tr.world->mergedSurfacesPshadowBits[i]); + refdef->dlightMask |= tr.world->mergedSurfacesDlightBits[i]; } + + refdef->dlightMask = ~refdef->dlightMask; } From b3a8116a517b1dd0bfbf9839ce2bd49431f712cb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 17 Dec 2016 16:54:07 +0000 Subject: [PATCH 394/708] Remove tr.currentEntity --- codemp/rd-rend2/tr_animation.cpp | 14 ++-- codemp/rd-rend2/tr_ghoul2.cpp | 12 ++-- codemp/rd-rend2/tr_light.cpp | 8 +-- codemp/rd-rend2/tr_local.h | 7 +- codemp/rd-rend2/tr_main.cpp | 99 ++++++++++++++----------- codemp/rd-rend2/tr_mesh.cpp | 2 +- codemp/rd-rend2/tr_model_iqm.cpp | 6 +- codemp/rd-rend2/tr_scene.cpp | 2 +- codemp/rd-rend2/tr_world.cpp | 120 ++++++++++++++++--------------- 9 files changed, 144 insertions(+), 126 deletions(-) diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 2ececac36a..b551cb694f 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -193,8 +193,10 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { header = (mdrHeader_t *)tr.currentModel->data.mdr; - personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); + personalModel = (qboolean)( + (ent->e.renderfx & RF_THIRD_PERSON) && + !(tr.viewParms.isPortal || + (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { @@ -288,7 +290,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, qfalse, R_IsPostRenderEntity (entityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, qfalse, R_IsPostRenderEntity(ent), 0 ); } // projection shadows work fine with personal models @@ -297,11 +299,11 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, qfalse, R_IsPostRenderEntity (entityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, qfalse, R_IsPostRenderEntity(ent), 0 ); } if (!personalModel) - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex ); surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd ); } @@ -421,4 +423,4 @@ void RB_MDRSurfaceAnim( mdrSurface_t *surface ) } tess.numVertexes += surface->numVerts; -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 1ef2b0b9ce..a57cf34e7a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2367,7 +2367,7 @@ void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, m #endif } -void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripping right from SP. +void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum ) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_RenderSurfaces.Start(); @@ -2426,7 +2426,7 @@ void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripp shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } - int cubemapIndex = R_CubemapForPoint (tr.currentEntity->e.origin); + int cubemapIndex = R_CubemapForPoint (ent->e.origin); // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) @@ -2437,7 +2437,7 @@ void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripp newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf ((surfaceType_t *)newSurf, entityNum, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity (entityNum, tr.currentEntity), cubemapIndex); + R_AddDrawSurf ((surfaceType_t *)newSurf, entityNum, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex); #ifdef _G2_GORE if (RS.gore_set && drawGore) @@ -2517,7 +2517,7 @@ void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripp last->goreChain=newSurf2; last=newSurf2; - R_AddDrawSurf ((surfaceType_t *)newSurf2, entityNum, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity (entityNum, tr.currentEntity), cubemapIndex); + R_AddDrawSurf ((surfaceType_t *)newSurf2, entityNum, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex); } } } @@ -2535,7 +2535,7 @@ void RenderSurfaces(CRenderSurface &RS, int entityNum) //also ended up just ripp for (i=0; i< surfInfo->numChildren; i++) { RS.surfaceNum = surfInfo->childIndexes[i]; - RenderSurfaces(RS, entityNum); + RenderSurfaces(RS, ent, entityNum); } #ifdef G2_PERFORMANCE_ANALYSIS @@ -3313,7 +3313,7 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { RS.renderfx |= RF_NOSHADOW; } - RenderSurfaces(RS, entityNum); + RenderSurfaces(RS, ent, entityNum); } } HackadelicOnClient=false; diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index f3b95198c8..9798ca38b7 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -58,7 +58,7 @@ R_DlightBmodel Determine which dynamic lights may effect this bmodel ============= */ -void R_DlightBmodel( bmodel_t *bmodel ) { +void R_DlightBmodel( bmodel_t *bmodel, trRefEntity_t *ent ) { int i, j; dlight_t *dl; int mask; @@ -88,7 +88,7 @@ void R_DlightBmodel( bmodel_t *bmodel ) { mask |= 1 << i; } - tr.currentEntity->needDlights = (qboolean)(mask != 0); + ent->needDlights = (qboolean)(mask != 0); // set the dlight bits in all the surfaces for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { @@ -488,7 +488,7 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w return qtrue; } -int R_CubemapForPoint( vec3_t point ) +int R_CubemapForPoint( const vec3_t point ) { int cubemapIndex = -1; @@ -514,4 +514,4 @@ int R_CubemapForPoint( vec3_t point ) } return cubemapIndex + 1; -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 437aaa7fa3..72831d571f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2258,7 +2258,6 @@ typedef struct trGlobals_s { vec3_t *cubemapOrigins; image_t **cubemaps; - trRefEntity_t *currentEntity; trRefEntity_t worldEntity; // point currentEntity at this when rendering world model_t *currentModel; @@ -2573,7 +2572,7 @@ void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postR uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender); void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); -bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ); +bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ); void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3); @@ -2835,12 +2834,12 @@ LIGHTS ============================================================ */ -void R_DlightBmodel( bmodel_t *bmodel ); +void R_DlightBmodel( bmodel_t *bmodel, trRefEntity_t *ent ); void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); void R_TransformDlights( int count, dlight_t *dl, orientationr_t *ori ); int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); -int R_CubemapForPoint( vec3_t point ); +int R_CubemapForPoint( const vec3_t point ); /* diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index fdce54fe52..3d913217be 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -770,19 +770,19 @@ R_RotateForViewer Sets up the modelview matrix for a given viewParm ================= */ -static void R_RotateForViewer(viewParms_t *viewParms) +static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) { float viewerMatrix[16]; vec3_t origin; - Com_Memset (&tr.ori, 0, sizeof(tr.ori)); + *ori = {}; tr.ori.axis[0][0] = 1; tr.ori.axis[1][1] = 1; tr.ori.axis[2][2] = 1; - VectorCopy (viewParms->ori.origin, tr.ori.viewOrigin); + VectorCopy(viewParms->ori.origin, ori->viewOrigin); // transform by the camera placement - VectorCopy( viewParms->ori.origin, origin ); + VectorCopy(viewParms->ori.origin, origin); viewerMatrix[0] = viewParms->ori.axis[0][0]; viewerMatrix[4] = viewParms->ori.axis[0][1]; @@ -804,14 +804,12 @@ static void R_RotateForViewer(viewParms_t *viewParms) viewerMatrix[11] = 0; viewerMatrix[15] = 1; - // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) - myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.ori.modelViewMatrix ); - Matrix16Identity(tr.ori.modelMatrix); - - viewParms->world = tr.ori; + myGlMultMatrix(viewerMatrix, s_flipMatrix, ori->modelViewMatrix); + Matrix16Identity(ori->modelMatrix); + viewParms->world = *ori; } /* @@ -1243,10 +1241,10 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) { - tr.currentEntity = &tr.refdef.entities[entityNum]; + const trRefEntity_t *currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.ori ); + R_RotateForEntity( currentEntity, &tr.viewParms, &tr.ori ); // rotate the plane, but keep the non-rotated version for matching // against the portalSurface entities @@ -1360,10 +1358,10 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) { - tr.currentEntity = &tr.refdef.entities[entityNum]; + const trRefEntity_t *currentEntity = &tr.refdef.entities[entityNum]; // get the orientation of the entity - R_RotateForEntity( tr.currentEntity, &tr.viewParms, &tr.ori ); + R_RotateForEntity( currentEntity, &tr.viewParms, &tr.ori ); // rotate the plane, but keep the non-rotated version for matching // against the portalSurface entities @@ -1420,7 +1418,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 unsigned int pointOr = 0; unsigned int pointAnd = (unsigned int)~0; - R_RotateForViewer(&tr.viewParms); + R_RotateForViewer(&tr.ori, &tr.viewParms); R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &postRender ); entityNum = drawSurf->entityNum; @@ -1735,13 +1733,8 @@ static void R_RadixSort( drawSurf_t *source, int size ) //========================================================================================== -bool R_IsPostRenderEntity ( int refEntityNum, const trRefEntity_t *refEntity ) +bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ) { - if ( refEntityNum == REFENTITYNUM_WORLD ) - { - return false; - } - return (refEntity->e.renderfx & RF_DISTORTION) || (refEntity->e.renderfx & RF_FORCEPOST) || (refEntity->e.renderfx & RF_FORCE_ENT_ALPHA); @@ -1863,13 +1856,10 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); } -static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) +static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int entityNum) { - trRefEntity_t *ent; shader_t *shader; - ent = tr.currentEntity = &refdef->entities[entityNum]; - ent->needDlights = qfalse; // @@ -1900,7 +1890,14 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) return; } shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), 0, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( + &entitySurface, + entityNum, + shader, + R_SpriteFogNum(ent), + 0, + R_IsPostRenderEntity(ent), + 0 /* cubeMap */ ); break; case RT_MODEL: @@ -1909,7 +1906,14 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) tr.currentModel = R_GetModelByHandle( ent->e.hModel ); if (!tr.currentModel) { - R_AddDrawSurf( &entitySurface, entityNum, tr.defaultShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0/* cubeMap */ ); + R_AddDrawSurf( + &entitySurface, + entityNum, + tr.defaultShader, + 0, + 0, + R_IsPostRenderEntity(ent), + 0/* cubeMap */ ); } else { switch ( tr.currentModel->type ) { case MOD_MESH: @@ -1939,7 +1943,14 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) break; } - R_AddDrawSurf( &entitySurface, entityNum, tr.defaultShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( + &entitySurface, + entityNum, + tr.defaultShader, + 0, + 0, + R_IsPostRenderEntity(ent), + 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); @@ -1949,7 +1960,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) break; case RT_ENT_CHAIN: shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity (entityNum, ent), 0 /* cubeMap */ ); + R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity(ent), 0 /* cubeMap */ ); break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); @@ -1961,13 +1972,18 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, int entityNum) R_AddEntitySurfaces ============= */ -static void R_AddEntitySurfaces(const trRefdef_t *refdef) { - if ( !r_drawentities->integer ) { +static void R_AddEntitySurfaces(const trRefdef_t *refdef) +{ + if ( !r_drawentities->integer ) + { return; } for (int i = 0; i < refdef->num_entities; i++) - R_AddEntitySurface(refdef, i); + { + trRefEntity_t *ent = refdef->entities + i; + R_AddEntitySurface(refdef, ent, i); + } } @@ -2084,7 +2100,7 @@ void R_RenderView (viewParms_t *parms) { tr.viewCount++; // set viewParms.world - R_RotateForViewer(&tr.viewParms); + R_RotateForViewer(&tr.ori, &tr.viewParms); R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); @@ -2432,7 +2448,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) tr.viewCount++; // set viewParms.world - R_RotateForViewer(&tr.viewParms); + R_RotateForViewer(&tr.ori, &tr.viewParms); { float xmin, xmax, ymin, ymax, znear, zfar; @@ -2495,7 +2511,9 @@ void R_RenderPshadowMaps(const refdef_t *fd) for (j = 0; j < shadow->numEntities; j++) { - R_AddEntitySurface(&tr.refdef, shadow->entityNums[j]); + int entityNum = shadow->entityNums[j]; + trRefEntity_t *ent = tr.refdef.entities + entityNum; + R_AddEntitySurface(&tr.refdef, ent, entityNum); } R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); @@ -2511,7 +2529,6 @@ static float CalcSplit(float n, float f, float i, float m) void R_RenderSunShadowMaps(const refdef_t *fd, int level) { - viewParms_t shadowParms; vec4_t lightDir, lightCol; vec3_t lightViewAxis[3]; vec3_t lightOrigin; @@ -2722,17 +2739,13 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) { - int firstDrawSurf; - - Com_Memset(&shadowParms, 0, sizeof( shadowParms )); - + viewParms_t shadowParms = {}; shadowParms.viewportX = 0; shadowParms.viewportY = 0; shadowParms.viewportWidth = tr.sunShadowFbo[level]->width; shadowParms.viewportHeight = tr.sunShadowFbo[level]->height; shadowParms.isPortal = qfalse; shadowParms.isMirror = qfalse; - shadowParms.fovX = 90; shadowParms.fovY = 90; @@ -2748,7 +2761,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) VectorCopy(lightViewAxis[1], shadowParms.ori.axis[1]); VectorCopy(lightViewAxis[2], shadowParms.ori.axis[2]); - VectorCopy(lightOrigin, shadowParms.pvsOrigin ); + VectorCopy(lightOrigin, shadowParms.pvsOrigin); { tr.viewCount++; @@ -2757,12 +2770,12 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) tr.viewParms.frameSceneNum = tr.frameSceneNum; tr.viewParms.frameCount = tr.frameCount; - firstDrawSurf = tr.refdef.numDrawSurfs; + int firstDrawSurf = tr.refdef.numDrawSurfs; tr.viewCount++; // set viewParms.world - R_RotateForViewer(&tr.viewParms); + R_RotateForViewer(&tr.ori, &tr.viewParms); R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 21d3ed93b0..90c20e7b4e 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -390,7 +390,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); + R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index 4325b0e9c0..a973946e7f 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -924,7 +924,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { && fogNum == 0 && !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.shadowShader, 0, 0, R_IsPostRenderEntity(ent), 0 ); } // projection shadows work fine with personal models @@ -932,11 +932,11 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { && fogNum == 0 && (ent->e.renderfx & RF_SHADOW_PLANE ) && shader->sort == SS_OPAQUE ) { - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, 0, R_IsPostRenderEntity (entityNum, ent), 0 ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, tr.projectionShadowShader, 0, 0, R_IsPostRenderEntity(ent), 0 ); } if( !personalModel ) { - R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, 0, R_IsPostRenderEntity (entityNum, ent), cubemapIndex ); + R_AddDrawSurf( (surfaceType_t *)surface, entityNum, shader, fogNum, 0, R_IsPostRenderEntity(ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 759808f7ab..1b08e97a23 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -102,7 +102,7 @@ void R_AddPolygonSurfaces( const trRefdef_t *refdef ) { sh, poly->fogIndex & fogMask, qfalse, - R_IsPostRenderEntity(REFENTITYNUM_WORLD, tr.currentEntity), + qfalse, 0 /* cubemapIndex */ ); } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 88831d8f72..35786dcdda 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -321,7 +321,7 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { R_AddWorldSurface ====================== */ -static void R_AddWorldSurface( msurface_t *surf, int entityNum, int dlightBits, int pshadowBits ) { +static void R_AddWorldSurface( msurface_t *surf, const trRefEntity_t *entity, int entityNum, int dlightBits, int pshadowBits ) { // FIXME: bmodel fog? // try to cull before dlighting or adding @@ -341,8 +341,13 @@ static void R_AddWorldSurface( msurface_t *surf, int entityNum, int dlightBits, pshadowBits = ( pshadowBits != 0 ); }*/ - bool isPostRenderEntity = - R_IsPostRenderEntity(entityNum, tr.currentEntity); + bool isPostRenderEntity = false; + if ( entityNum != REFENTITYNUM_WORLD ) + { + assert(entity); + isPostRenderEntity = R_IsPostRenderEntity(entity); + } + R_AddDrawSurf( surf->data, entityNum, surf->shader, surf->fogIndex, dlightBits, isPostRenderEntity, surf->cubemapIndex ); @@ -384,7 +389,7 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { } R_SetupEntityLighting( &tr.refdef, ent ); - R_DlightBmodel( bmodel ); + R_DlightBmodel( bmodel, ent ); for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { int surf = bmodel->firstSurface + i; @@ -392,7 +397,7 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { if (tr.world->surfacesViewCount[surf] != tr.viewCount) { tr.world->surfacesViewCount[surf] = tr.viewCount; - R_AddWorldSurface( tr.world->surfaces + surf, entityNum, tr.currentEntity->needDlights, 0 ); + R_AddWorldSurface(tr.world->surfaces + surf, ent, entityNum, ent->needDlights, 0); } } } @@ -417,8 +422,8 @@ void RE_SetRangedFog ( float range ) R_RecursiveWorldNode ================ */ -static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) { - +static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) +{ do { int newDlights[2]; unsigned int newPShadows[2]; @@ -498,22 +503,19 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, newDlights[0] = 0; newDlights[1] = 0; if ( dlightBits ) { - int i; - - for ( i = 0 ; i < tr.refdef.num_dlights ; i++ ) { - dlight_t *dl; - float dist; - - if ( dlightBits & ( 1 << i ) ) { - dl = &tr.refdef.dlights[i]; - dist = DotProduct( dl->origin, node->plane->normal ) - node->plane->dist; - - if ( dist > -dl->radius ) { - newDlights[0] |= ( 1 << i ); - } - if ( dist < dl->radius ) { - newDlights[1] |= ( 1 << i ); - } + for ( int i = 0 ; i < tr.refdef.num_dlights ; i++ ) { + if ( !(dlightBits & (1 << i)) ) { + continue; + } + + dlight_t *dl = &tr.refdef.dlights[i]; + float dist = DotProduct(dl->origin, node->plane->normal) - node->plane->dist; + + if ( dist > -dl->radius ) { + newDlights[0] |= ( 1 << i ); + } + if ( dist < dl->radius ) { + newDlights[1] |= ( 1 << i ); } } } @@ -521,22 +523,20 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, newPShadows[0] = 0; newPShadows[1] = 0; if ( pshadowBits ) { - int i; - - for ( i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { - pshadow_t *shadow; - float dist; - - if ( pshadowBits & ( 1 << i ) ) { - shadow = &tr.refdef.pshadows[i]; - dist = DotProduct( shadow->lightOrigin, node->plane->normal ) - node->plane->dist; - - if ( dist > -shadow->lightRadius ) { - newPShadows[0] |= ( 1 << i ); - } - if ( dist < shadow->lightRadius ) { - newPShadows[1] |= ( 1 << i ); - } + for ( int i = 0 ; i < tr.refdef.num_pshadows ; i++ ) { + if ( !(pshadowBits & (1 << i)) ) { + continue; + } + + pshadow_t *shadow = &tr.refdef.pshadows[i]; + float dist = DotProduct(shadow->lightOrigin, node->plane->normal) - node->plane->dist; + + if ( dist > -shadow->lightRadius ) { + newPShadows[0] |= ( 1 << i ); + } + + if ( dist < shadow->lightRadius ) { + newPShadows[1] |= ( 1 << i ); } } } @@ -698,12 +698,8 @@ Mark the leaves and nodes that are in the PVS for the current cluster =============== */ -static void R_MarkLeaves (void) { - const byte *vis; - mnode_t *leaf, *parent; - int i; - int cluster; - +static void R_MarkLeaves( void ) +{ // lockpvs lets designers walk around to determine the // extent of the current pvs if ( r_lockpvs->integer ) { @@ -711,13 +707,13 @@ static void R_MarkLeaves (void) { } // current viewcluster - leaf = R_PointInLeaf( tr.viewParms.pvsOrigin ); - cluster = leaf->cluster; + mnode_t *leaf = R_PointInLeaf(tr.viewParms.pvsOrigin); + int cluster = leaf->cluster; // if the cluster is the same and the area visibility matrix // hasn't changed, we don't need to mark everything again - for(i = 0; i < MAX_VISCOUNTS; i++) + for (int i = 0; i < MAX_VISCOUNTS; i++) { // if the areamask or r_showcluster was modified, invalidate all visclusters // this caused doors to open into undrawn areas @@ -725,12 +721,14 @@ static void R_MarkLeaves (void) { { tr.visClusters[i] = -2; } - else if(tr.visClusters[i] == cluster) + else if (tr.visClusters[i] == cluster) { - if(tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) + if (tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) { - ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); + ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", + cluster, leaf->area, i); } + tr.visIndex = i; return; } @@ -747,9 +745,10 @@ static void R_MarkLeaves (void) { } } - vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); + const byte *vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); - for (i=0,leaf=tr.world->nodes ; inumnodes ; i++, leaf++) { + int i; + for (i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++) { cluster = leaf->cluster; if ( cluster < 0 || cluster >= tr.world->numClusters ) { continue; @@ -765,10 +764,12 @@ static void R_MarkLeaves (void) { continue; // not visible } - parent = leaf; + mnode_t *parent = leaf; do { - if(parent->visCounts[tr.visIndex] == tr.visCounts[tr.visIndex]) + if (parent->visCounts[tr.visIndex] == tr.visCounts[tr.visIndex]) { break; + } + parent->visCounts[tr.visIndex] = tr.visCounts[tr.visIndex]; parent = parent->parent; } while (parent); @@ -793,8 +794,9 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { } // determine which leaves are in the PVS / areamask - if (!(viewParms->flags & VPF_DEPTHSHADOW)) - R_MarkLeaves (); + if (!(viewParms->flags & VPF_DEPTHSHADOW)) { + R_MarkLeaves(); + } // clear out the visible min/max ClearBounds(viewParms->visBounds[0], viewParms->visBounds[1]); @@ -821,7 +823,7 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { pshadowBits = 0; } - R_RecursiveWorldNode( tr.world->nodes, planeBits, dlightBits, pshadowBits); + R_RecursiveWorldNode(tr.world->nodes, planeBits, dlightBits, pshadowBits); // now add all the potentially visible surfaces // also mask invisible dlights for next frame @@ -834,6 +836,7 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { R_AddWorldSurface( tr.world->surfaces + i, + nullptr, REFENTITYNUM_WORLD, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i]); @@ -847,6 +850,7 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { R_AddWorldSurface( tr.world->mergedSurfaces + i, + nullptr, REFENTITYNUM_WORLD, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i]); From 3703aff1d86c1452f94c796070bfcf2857484069 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 17 Dec 2016 17:04:07 +0000 Subject: [PATCH 395/708] Refactor RB_RenderDrawSurfList --- codemp/rd-rend2/tr_backend.cpp | 584 ++++++++++++++++----------------- 1 file changed, 274 insertions(+), 310 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 0bea7b099d..f4781646ce 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -996,8 +996,7 @@ void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ) } pass->sortKeys[pass->numDrawItems] = sortKey; - memcpy(pass->drawItems + pass->numDrawItems, &drawItem, sizeof(*pass->drawItems)); - ++pass->numDrawItems; + pass->drawItems[pass->numDrawItems++] = drawItem; } else { @@ -1016,372 +1015,337 @@ static Pass *RB_CreatePass( Allocator& allocator, int capacity ) return pass; } -/* -================== -RB_RenderDrawSurfList -================== -*/ -static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) { - shader_t *shader, *oldShader; - int fogNum, oldFogNum; - int entityNum, oldEntityNum; - int dlighted, oldDlighted; - int postRender, oldPostRender; - int cubemapIndex, oldCubemapIndex; - int depthRange, oldDepthRange; - int i; - drawSurf_t *drawSurf; - int oldSort; - float originalTime; - FBO_t* fbo = NULL; - qboolean inQuery = qfalse; - - float depth[2]; - - void *allocMark = backEndData->perFrameMemory->Mark(); - - /* - merging surfaces together that share the same shader (e.g. polys, patches) - upload per frame data - but this might be the same between render passes? - - how about: - tr.refdef.entities[] - - and .... entityCullInfo_t tr.refdef.entityCullInfo[] - struct visibleEntity_t - { - uint32_t frustumMask; // bitfield of frustums which intersect - EntityId entityId; - }; - - foreach ghoul2 model: - transform bones - - foreach visibleEntity: - upload per frame data +static void RB_PrepareForEntity( int entityNum, int *oldDepthRange, float originalTime ) +{ + int depthRange = 0; - for polygons: - merge them, create new surface and upload data + if ( entityNum != REFENTITYNUM_WORLD ) + { + backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; + backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; + // we have to reset the shaderTime as well otherwise image animations start + // from the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - for patch meshes: - merge them, create new surface and upload data + // set up the transformation matrix + R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); + if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { + // No depth at all, very rare but some things for seeing through walls + depthRange = 2; + } + else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { + // hack the depth range to prevent view model from poking into walls + depthRange = 1; + } + } else { + backEnd.currentEntity = &tr.worldEntity; + backEnd.refdef.floatTime = originalTime; + backEnd.ori = backEnd.viewParms.world; - each surface corresponds to something which has all of its gpu data uploaded - */ + // we have to reset the shaderTime as well otherwise image animations on + // the world (like water) continue with the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; + } - assert(backEndData->currentPass == nullptr); - backEndData->currentPass = RB_CreatePass(*backEndData->perFrameMemory, numDrawSurfs * 4); + GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); - // save original time for entity shader offsets - originalTime = backEnd.refdef.floatTime; + // change depthrange. Also change projection matrix so first person weapon + // does not look like coming out of the screen. + if ( *oldDepthRange != depthRange ) + { + switch ( depthRange ) + { + default: + case 0: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); + } + break; - fbo = glState.currentFBO; + case 1: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + viewParms_t temp = backEnd.viewParms; + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + GL_SetProjectionMatrix(temp.projectionMatrix); + } + break; - // draw everything - oldEntityNum = -1; - backEnd.currentEntity = &tr.worldEntity; - oldShader = NULL; - oldFogNum = -1; - oldDepthRange = 0; - oldDlighted = 0; - oldPostRender = 0; - oldCubemapIndex = -1; - oldSort = -1; + case 2: + if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) + { + viewParms_t temp = backEnd.viewParms; + R_SetupProjection(&temp, r_znear->value, 0, qfalse); + GL_SetProjectionMatrix(temp.projectionMatrix); + } + break; + } - depth[0] = 0.f; - depth[1] = 1.f; + *oldDepthRange = depthRange; + } +} - backEnd.pc.c_surfaces += numDrawSurfs; +static void RB_SubmitDrawSurfsForDepthFill( + drawSurf_t *drawSurfs, + int numDrawSurfs, + float originalTime ) +{ + shader_t *oldShader = nullptr; + int oldEntityNum = -1; + int oldSort = -1; + int oldDepthRange = 0; - if ( backEnd.depthFill ) + drawSurf_t *drawSurf = drawSurfs; + for ( int i = 0; i < numDrawSurfs; i++, drawSurf++ ) { - for ( i = 0, drawSurf = drawSurfs; i < numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); - fogNum = drawSurf->fogIndex; - entityNum = drawSurf->entityNum; + shader_t *shader; + int cubemapIndex; + int postRender; + int entityNum; - if ( shader == oldShader && entityNum == oldEntityNum ) - { - if ( shader && shader->sort != SS_OPAQUE ) - continue; + R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); + assert(shader != nullptr); + entityNum = drawSurf->entityNum; - // fast path, same as previous sort - rb_surfaceTable[*drawSurf->surface](drawSurf->surface); - continue; - } + if ( shader == oldShader && entityNum == oldEntityNum ) + { + // fast path, same as previous sort + rb_surfaceTable[*drawSurf->surface](drawSurf->surface); + continue; + } - oldSort = drawSurf->sort; + oldSort = drawSurf->sort; - // - // change the tess parameters if needed - // a "entityMergable" shader is a shader that can have surfaces from seperate - // entities merged into a single batch, like smoke and blood puff sprites - if ( shader && - (shader != oldShader || - (entityNum != oldEntityNum && !shader->entityMergable)) ) + // change the tess parameters if needed + // a "entityMergable" shader is a shader that can have surfaces from + // seperate entities merged into a single batch, like smoke and blood + // puff sprites + if ( shader != oldShader || + (entityNum != oldEntityNum && !shader->entityMergable) ) + { + if ( oldShader != nullptr ) { - if ( oldShader != NULL ) { - RB_EndSurface(); - } - - RB_BeginSurface(shader, 0, 0); - backEnd.pc.c_surfBatches++; - oldShader = shader; + RB_EndSurface(); } - if ( shader && shader->sort != SS_OPAQUE ) + if ( shader->sort != SS_OPAQUE ) + { + oldShader = nullptr; continue; + } - // - // change the modelview matrix if needed - // - if ( entityNum != oldEntityNum ) { - depthRange = 0; - - if ( entityNum != REFENTITYNUM_WORLD ) { - backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; - // we have to reset the shaderTime as well otherwise image animations start - // from the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - - // set up the transformation matrix - R_RotateForEntity(backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori); - - if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { - // No depth at all, very rare but some things for seeing through walls - depthRange = 2; - } - else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { - // hack the depth range to prevent view model from poking into walls - depthRange = 1; - } - } - else { - backEnd.currentEntity = &tr.worldEntity; - backEnd.refdef.floatTime = originalTime; - backEnd.ori = backEnd.viewParms.world; - // we have to reset the shaderTime as well otherwise image animations on - // the world (like water) continue with the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - } + RB_BeginSurface(shader, 0, 0); + backEnd.pc.c_surfBatches++; + oldShader = shader; + } - GL_SetModelviewMatrix(backEnd.ori.modelViewMatrix); + // change the modelview matrix if needed + if ( entityNum != oldEntityNum ) + { + RB_PrepareForEntity(entityNum, &oldDepthRange, originalTime); + oldEntityNum = entityNum; + } - // - // change depthrange. Also change projection matrix so first person weapon does not look like coming - // out of the screen. - // - if ( oldDepthRange != depthRange ) - { - switch ( depthRange ) - { - default: - case 0: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); - } - break; - - case 1: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - - case 2: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - } - - oldDepthRange = depthRange; - } + // add the triangles for this surface + rb_surfaceTable[*drawSurf->surface](drawSurf->surface); + } - oldEntityNum = entityNum; - } + // draw the contents of the last shader batch + if ( oldShader != nullptr ) + { + RB_EndSurface(); + } +} - // add the triangles for this surface +static void RB_SubmitDrawSurfs( + drawSurf_t *drawSurfs, + int numDrawSurfs, + float originalTime ) +{ + shader_t *oldShader = nullptr; + int oldEntityNum = -1; + int oldSort = -1; + int oldFogNum = -1; + int oldDepthRange = 0; + int oldDlighted = 0; + int oldPostRender = 0; + int oldCubemapIndex = -1; + + drawSurf_t *drawSurf = drawSurfs; + for ( int i = 0; i < numDrawSurfs; i++, drawSurf++ ) + { + shader_t *shader; + int cubemapIndex; + int postRender; + int entityNum; + int fogNum; + int dlighted; + + R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); + assert(shader != nullptr); + fogNum = drawSurf->fogIndex; + entityNum = drawSurf->entityNum; + dlighted = drawSurf->dlightBits; + + if ( shader == oldShader && + fogNum == oldFogNum && + postRender == oldPostRender && + cubemapIndex == oldCubemapIndex && + entityNum == oldEntityNum && + dlighted == oldDlighted ) + { + // fast path, same as previous sort rb_surfaceTable[*drawSurf->surface](drawSurf->surface); + continue; } - } - else - { - for (i = 0, drawSurf = drawSurfs ; i < numDrawSurfs ; i++, drawSurf++) { - R_DecomposeSort( drawSurf->sort, &shader, &cubemapIndex, &postRender ); - fogNum = drawSurf->fogIndex; - entityNum = drawSurf->entityNum; - dlighted = drawSurf->dlightBits; - - if ( shader == oldShader && - fogNum == oldFogNum && - postRender == oldPostRender && - cubemapIndex == oldCubemapIndex && - entityNum == oldEntityNum && - dlighted == oldDlighted ) - { - // fast path, same as previous sort - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); - continue; - } - oldSort = drawSurf->sort; - - // - // change the tess parameters if needed - // a "entityMergable" shader is a shader that can have surfaces from seperate - // entities merged into a single batch, like smoke and blood puff sprites - if ( shader != NULL && - ( shader != oldShader || - fogNum != oldFogNum || - dlighted != oldDlighted || - postRender != oldPostRender || - cubemapIndex != oldCubemapIndex || - (entityNum != oldEntityNum && !shader->entityMergable))) + oldSort = drawSurf->sort; + + // + // change the tess parameters if needed + // a "entityMergable" shader is a shader that can have surfaces from seperate + // entities merged into a single batch, like smoke and blood puff sprites + if ( (shader != oldShader || + fogNum != oldFogNum || + dlighted != oldDlighted || + postRender != oldPostRender || + cubemapIndex != oldCubemapIndex || + (entityNum != oldEntityNum && !shader->entityMergable)) ) + { + if ( oldShader != nullptr ) { - if (oldShader != NULL) { - RB_EndSurface(); - } - - RB_BeginSurface( shader, fogNum, cubemapIndex ); - backEnd.pc.c_surfBatches++; - oldShader = shader; - oldFogNum = fogNum; - oldDlighted = dlighted; - oldPostRender = postRender; - oldCubemapIndex = cubemapIndex; + RB_EndSurface(); } - // - // change the modelview matrix if needed - // - if ( entityNum != oldEntityNum ) { - depthRange = 0; - - if ( entityNum != REFENTITYNUM_WORLD ) { - backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; - // we have to reset the shaderTime as well otherwise image animations start - // from the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - - // set up the transformation matrix - R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); - - // set up the dynamic lighting if needed - if ( backEnd.currentEntity->needDlights ) { - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); - } - - if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { - // No depth at all, very rare but some things for seeing through walls - depthRange = 2; - } - else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { - // hack the depth range to prevent view model from poking into walls - depthRange = 1; - } - } else { - backEnd.currentEntity = &tr.worldEntity; - backEnd.refdef.floatTime = originalTime; - backEnd.ori = backEnd.viewParms.world; - // we have to reset the shaderTime as well otherwise image animations on - // the world (like water) continue with the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.ori ); - } - - GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); + RB_BeginSurface(shader, fogNum, cubemapIndex); + backEnd.pc.c_surfBatches++; + oldShader = shader; + oldFogNum = fogNum; + oldDlighted = dlighted; + oldPostRender = postRender; + oldCubemapIndex = cubemapIndex; + } - // - // change depthrange. Also change projection matrix so first person weapon does not look like coming - // out of the screen. - // - if (oldDepthRange != depthRange) - { - switch ( depthRange ) - { - default: - case 0: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); - } - break; - - case 1: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - - case 2: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - } - - oldDepthRange = depthRange; - } + if ( entityNum != oldEntityNum ) + { + RB_PrepareForEntity(entityNum, &oldDepthRange, originalTime); - oldEntityNum = entityNum; + // set up the dynamic lighting if needed + if ( entityNum == REFENTITYNUM_WORLD || backEnd.currentEntity->needDlights ) + { + R_TransformDlights( + backEnd.refdef.num_dlights, + backEnd.refdef.dlights, + &backEnd.ori); } - // add the triangles for this surface - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + oldEntityNum = entityNum; } - } - backEnd.refdef.floatTime = originalTime; + // add the triangles for this surface + rb_surfaceTable[*drawSurf->surface](drawSurf->surface); + } // draw the contents of the last shader batch - if (oldShader != NULL) { + if ( oldShader != nullptr ) + { RB_EndSurface(); } +} +static void RB_SubmitRenderPass( + Pass& renderPass, + Allocator& allocator ) +{ uint32_t *drawOrder = ojkAllocArray( - *backEndData->perFrameMemory, backEndData->currentPass->numDrawItems); + allocator, renderPass.numDrawItems); - uint32_t numDrawItems = backEndData->currentPass->numDrawItems; + uint32_t numDrawItems = renderPass.numDrawItems; for ( uint32_t i = 0; i < numDrawItems; ++i ) drawOrder[i] = i; - uint32_t *sortKeys = backEndData->currentPass->sortKeys; + uint32_t *sortKeys = renderPass.sortKeys; std::sort(drawOrder, drawOrder + numDrawItems, [sortKeys]( uint32_t a, uint32_t b ) { return sortKeys[a] < sortKeys[b]; }); - RB_DrawItems(backEndData->currentPass->numDrawItems, backEndData->currentPass->drawItems, drawOrder); + RB_DrawItems(renderPass.numDrawItems, renderPass.drawItems, drawOrder); +} + +/* +================== +RB_RenderDrawSurfList +================== +*/ +static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) +{ + /* + merging surfaces together that share the same shader (e.g. polys, patches) + upload per frame data - but this might be the same between render passes? + + how about: + tr.refdef.entities[] + + and .... entityCullInfo_t tr.refdef.entityCullInfo[] + struct visibleEntity_t + { + uint32_t frustumMask; // bitfield of frustums which intersect + EntityId entityId; + }; + + foreach ghoul2 model: + transform bones + + foreach visibleEntity: + upload per frame data + + for polygons: + merge them, create new surface and upload data + + for patch meshes: + merge them, create new surface and upload data - backEndData->perFrameMemory->ResetTo(allocMark); - backEndData->currentPass = nullptr; - if (inQuery) { - qglEndQuery(GL_SAMPLES_PASSED); + each surface corresponds to something which has all of its gpu data uploaded + */ + + // Prepare memory for the current render pass + void *allocMark = backEndData->perFrameMemory->Mark(); + assert(backEndData->currentPass == nullptr); + backEndData->currentPass = RB_CreatePass( + *backEndData->perFrameMemory, numDrawSurfs * 4); + + // save original time for entity shader offsets + float originalTime = backEnd.refdef.floatTime; + FBO_t *fbo = glState.currentFBO; + + backEnd.currentEntity = &tr.worldEntity; + backEnd.pc.c_surfaces += numDrawSurfs; + + if ( backEnd.depthFill ) + { + RB_SubmitDrawSurfsForDepthFill(drawSurfs, numDrawSurfs, originalTime); + } + else + { + RB_SubmitDrawSurfs(drawSurfs, numDrawSurfs, originalTime); } - FBO_Bind(fbo); + // Do the drawing and release memory + RB_SubmitRenderPass( + *backEndData->currentPass, + *backEndData->perFrameMemory); - // go back to the world modelview matrix + backEndData->perFrameMemory->ResetTo(allocMark); + backEndData->currentPass = nullptr; - GL_SetModelviewMatrix( backEnd.viewParms.world.modelViewMatrix ); + // Reset things to how they were + backEnd.refdef.floatTime = originalTime; + FBO_Bind(fbo); + GL_SetModelviewMatrix(backEnd.viewParms.world.modelViewMatrix); } From f3569cdbf04853a61edd4ca8ffd9919a01d2a46b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 17 Dec 2016 23:01:38 +0000 Subject: [PATCH 396/708] Rend2: Refactor RB_DrawSurfs --- codemp/rd-rend2/tr_backend.cpp | 473 ++++++++++++++++++--------------- 1 file changed, 258 insertions(+), 215 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f4781646ce..f2d9caef13 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1797,278 +1797,321 @@ static const void *RB_RotatePic2 ( const void *data ) } -/* -============= -RB_DrawSurfs - -============= -*/ -static const void *RB_DrawSurfs( const void *data ) { - const drawSurfsCommand_t *cmd; - - // finish any 2D drawing if needed - if ( tess.numIndexes ) { - RB_EndSurface(); - } - - cmd = (const drawSurfsCommand_t *)data; - - backEnd.refdef = cmd->refdef; - backEnd.viewParms = cmd->viewParms; - - // clear the z buffer, set the modelview, etc - RB_BeginDrawingView (); - - if (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL) && (r_depthPrepass->integer || (backEnd.viewParms.flags & VPF_DEPTHSHADOW))) - { - FBO_t *oldFbo = glState.currentFBO; - - if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) - { - qglEnable(GL_DEPTH_CLAMP); - } - - backEnd.depthFill = qtrue; - qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); - RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); - qglColorMask(!backEnd.colorMask[0], !backEnd.colorMask[1], !backEnd.colorMask[2], !backEnd.colorMask[3]); - backEnd.depthFill = qfalse; - - if (tr.msaaResolveFbo) - { - // If we're using multisampling, resolve the depth first - FBO_FastBlit(tr.renderFbo, NULL, tr.msaaResolveFbo, NULL, GL_DEPTH_BUFFER_BIT, GL_NEAREST); - } - else if (tr.renderFbo == NULL) - { - // If we're rendering directly to the screen, copy the depth to a texture - GL_BindToTMU(tr.renderDepthImage, 0); - qglCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 0, 0, glConfig.vidWidth, glConfig.vidHeight, 0); - } - - if (r_ssao->integer) - { - // need the depth in a texture we can do GL_LINEAR sampling on, so copy it to an HDR image - FBO_BlitFromTexture(tr.renderDepthImage, NULL, NULL, tr.hdrDepthFbo, NULL, NULL, NULL, 0); - } - - if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT)) - { - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - vec4_t box; - - FBO_Bind(tr.screenShadowFbo); - - box[0] = backEnd.viewParms.viewportX * tr.screenShadowFbo->width / (float)glConfig.vidWidth; - box[1] = backEnd.viewParms.viewportY * tr.screenShadowFbo->height / (float)glConfig.vidHeight; - box[2] = backEnd.viewParms.viewportWidth * tr.screenShadowFbo->width / (float)glConfig.vidWidth; - box[3] = backEnd.viewParms.viewportHeight * tr.screenShadowFbo->height / (float)glConfig.vidHeight; - - qglViewport(box[0], box[1], box[2], box[3]); - qglScissor(box[0], box[1], box[2], box[3]); - - box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; - box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; - box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; - box[3] = box[1] + backEnd.viewParms.viewportHeight / (float)glConfig.vidHeight; - - texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; - texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; - texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; - texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; - - box[0] = -1.0f; - box[1] = -1.0f; - box[2] = 1.0f; - box[3] = 1.0f; - - VectorSet4(quadVerts[0], box[0], box[3], 0, 1); - VectorSet4(quadVerts[1], box[2], box[3], 0, 1); - VectorSet4(quadVerts[2], box[2], box[1], 0, 1); - VectorSet4(quadVerts[3], box[0], box[1], 0, 1); - - GL_State( GLS_DEPTHTEST_DISABLE ); - - GLSL_BindProgram(&tr.shadowmaskShader); +static void RB_RenderSunShadows() +{ + FBO_t *shadowFbo = tr.screenShadowFbo; - GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); - GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP); - GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); - GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + vec4_t box; - GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP, backEnd.refdef.sunShadowMvp[0]); - GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP2, backEnd.refdef.sunShadowMvp[1]); - GLSL_SetUniformMatrix4x4(&tr.shadowmaskShader, UNIFORM_SHADOWMVP3, backEnd.refdef.sunShadowMvp[2]); - - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); - { - vec4_t viewInfo; - vec3_t viewVector; + FBO_Bind(shadowFbo); + + const float viewportScaleX = shadowFbo->width / glConfig.vidWidth; + const float viewportScaleY = shadowFbo->height / glConfig.vidHeight; + + box[0] = backEnd.viewParms.viewportX * viewportScaleX; + box[1] = backEnd.viewParms.viewportY * viewportScaleY; + box[2] = backEnd.viewParms.viewportWidth * viewportScaleX; + box[3] = backEnd.viewParms.viewportHeight * viewportScaleY; + + qglViewport(box[0], box[1], box[2], box[3]); + qglScissor(box[0], box[1], box[2], box[3]); + + box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; + box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; + box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; + box[3] = box[1] + backEnd.viewParms.viewportHeight / (float)glConfig.vidHeight; + + texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; + texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; + texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; + texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; + + box[0] = -1.0f; + box[1] = -1.0f; + box[2] = 1.0f; + box[3] = 1.0f; + + VectorSet4(quadVerts[0], box[0], box[3], 0, 1); + VectorSet4(quadVerts[1], box[2], box[3], 0, 1); + VectorSet4(quadVerts[2], box[2], box[1], 0, 1); + VectorSet4(quadVerts[3], box[0], box[1], 0, 1); + + GL_State(GLS_DEPTHTEST_DISABLE); + GLSL_BindProgram(&tr.shadowmaskShader); + + GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); + GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP); + GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); + GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); + + GLSL_SetUniformMatrix4x4( + &tr.shadowmaskShader, + UNIFORM_SHADOWMVP, + backEnd.refdef.sunShadowMvp[0]); + GLSL_SetUniformMatrix4x4( + &tr.shadowmaskShader, + UNIFORM_SHADOWMVP2, + backEnd.refdef.sunShadowMvp[1]); + GLSL_SetUniformMatrix4x4( + &tr.shadowmaskShader, + UNIFORM_SHADOWMVP3, + backEnd.refdef.sunShadowMvp[2]); + GLSL_SetUniformVec3( + &tr.shadowmaskShader, + UNIFORM_VIEWORIGIN, + backEnd.refdef.vieworg); + + const float zmax = backEnd.viewParms.zFar; + const float ymax = zmax * tanf(backEnd.viewParms.fovY * M_PI / 360.0f); + const float xmax = zmax * tanf(backEnd.viewParms.fovX * M_PI / 360.0f); + + const float zmin = r_znear->value; + + vec3_t viewBasis[3]; + VectorScale(backEnd.refdef.viewaxis[0], zmax, viewBasis[0]); + VectorScale(backEnd.refdef.viewaxis[1], xmax, viewBasis[1]); + VectorScale(backEnd.refdef.viewaxis[2], ymax, viewBasis[2]); + + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWFORWARD, viewBasis[0]); + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWLEFT, viewBasis[1]); + GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWUP, viewBasis[2]); + + const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; + GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); - float zmax = backEnd.viewParms.zFar; - float ymax = zmax * tan(backEnd.viewParms.fovY * M_PI / 360.0f); - float xmax = zmax * tan(backEnd.viewParms.fovX * M_PI / 360.0f); + RB_InstantQuad2(quadVerts, texCoords); +} - float zmin = r_znear->value; +static void RB_RenderSSAO() +{ + const float zmax = backEnd.viewParms.zFar; + const float zmin = r_znear->value; + const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; - VectorScale(backEnd.refdef.viewaxis[0], zmax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWFORWARD, viewVector); - VectorScale(backEnd.refdef.viewaxis[1], xmax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWLEFT, viewVector); - VectorScale(backEnd.refdef.viewaxis[2], ymax, viewVector); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWUP, viewVector); + vec4_t quadVerts[4]; + vec2_t texCoords[4]; - VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + FBO_Bind(tr.quarterFbo[0]); - GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); - } + qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + VectorSet4(quadVerts[0], -1, 1, 0, 1); + VectorSet4(quadVerts[1], 1, 1, 0, 1); + VectorSet4(quadVerts[2], 1, -1, 0, 1); + VectorSet4(quadVerts[3], -1, -1, 0, 1); - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - } + texCoords[0][0] = 0; texCoords[0][1] = 1; + texCoords[1][0] = 1; texCoords[1][1] = 1; + texCoords[2][0] = 1; texCoords[2][1] = 0; + texCoords[3][0] = 0; texCoords[3][1] = 0; - if (r_ssao->integer) - { - vec4_t quadVerts[4]; - vec2_t texCoords[4]; + GL_State( GLS_DEPTHTEST_DISABLE ); - FBO_Bind(tr.quarterFbo[0]); + GLSL_BindProgram(&tr.ssaoShader); - qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); + GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); + GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); - VectorSet4(quadVerts[0], -1, 1, 0, 1); - VectorSet4(quadVerts[1], 1, 1, 0, 1); - VectorSet4(quadVerts[2], 1, -1, 0, 1); - VectorSet4(quadVerts[3], -1, -1, 0, 1); + RB_InstantQuad2(quadVerts, texCoords); - texCoords[0][0] = 0; texCoords[0][1] = 1; - texCoords[1][0] = 1; texCoords[1][1] = 1; - texCoords[2][0] = 1; texCoords[2][1] = 0; - texCoords[3][0] = 0; texCoords[3][1] = 0; + FBO_Bind(tr.quarterFbo[1]); - GL_State( GLS_DEPTHTEST_DISABLE ); + qglViewport(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); + qglScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); - GLSL_BindProgram(&tr.ssaoShader); + GLSL_BindProgram(&tr.depthBlurShader[0]); - GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); + GL_BindToTMU(tr.quarterImage[0], TB_COLORMAP); + GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - { - vec4_t viewInfo; + RB_InstantQuad2(quadVerts, texCoords); - float zmax = backEnd.viewParms.zFar; - float zmin = r_znear->value; + FBO_Bind(tr.screenSsaoFbo); - VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); + qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); - GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); - } + GLSL_BindProgram(&tr.depthBlurShader[1]); - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP); + GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); + RB_InstantQuad2(quadVerts, texCoords); +} - FBO_Bind(tr.quarterFbo[1]); +static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) +{ + backEnd.depthFill = qtrue; + qglColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); + RB_RenderDrawSurfList(drawSurfs, numDrawSurfs); + qglColorMask( + !backEnd.colorMask[0], + !backEnd.colorMask[1], + !backEnd.colorMask[2], + !backEnd.colorMask[3]); + backEnd.depthFill = qfalse; - qglViewport(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); - qglScissor(0, 0, tr.quarterFbo[1]->width, tr.quarterFbo[1]->height); + if (tr.msaaResolveFbo) + { + // If we're using multisampling, resolve the depth first + FBO_FastBlit( + tr.renderFbo, NULL, + tr.msaaResolveFbo, NULL, + GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } + else if (tr.renderFbo == NULL) + { + // If we're rendering directly to the screen, copy the depth to a texture + GL_BindToTMU(tr.renderDepthImage, 0); + qglCopyTexImage2D( + GL_TEXTURE_2D, 0, + GL_DEPTH_COMPONENT24, 0, + 0, glConfig.vidWidth, + glConfig.vidHeight, 0); + } +} - GLSL_BindProgram(&tr.depthBlurShader[0]); +static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) +{ + if ( backEnd.viewParms.flags & VPF_DEPTHSHADOW ) + { + return; + } - GL_BindToTMU(tr.quarterImage[0], TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + RB_RenderDrawSurfList(drawSurfs, numDrawSurfs); - { - vec4_t viewInfo; + if (r_drawSun->integer) + { + RB_DrawSun(0.1, tr.sunShader); + } - float zmax = backEnd.viewParms.zFar; - float zmin = r_znear->value; + if (r_drawSunRays->integer) + { + FBO_t *oldFbo = glState.currentFBO; + FBO_Bind(tr.sunRaysFbo); + + qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); + qglClear( GL_COLOR_BUFFER_BIT ); - VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; + qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); - GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - } + RB_DrawSun(0.3, tr.sunFlareShader); - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); + qglEndQuery(GL_SAMPLES_PASSED); + FBO_Bind(oldFbo); + } - FBO_Bind(tr.screenSsaoFbo); + // darken down any stencil shadows + RB_ShadowFinish(); - qglViewport(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); - qglScissor(0, 0, tr.screenSsaoFbo->width, tr.screenSsaoFbo->height); + // add light flares on lights that aren't obscured + RB_RenderFlares(); +} - GLSL_BindProgram(&tr.depthBlurShader[1]); +static void RB_GenerateMipmapsForCubemapFaceRender() +{ + if ( tr.renderCubeFbo == NULL || backEnd.viewParms.targetFbo != tr.renderCubeFbo ) + { + return; + } - GL_BindToTMU(tr.quarterImage[1], TB_COLORMAP); - GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); + FBO_Bind(NULL); + GL_SelectTexture(TB_CUBEMAP); + GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP); + qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); + GL_SelectTexture(0); +} - { - vec4_t viewInfo; +static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSurfs ) +{ + if ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) + { + return; + } - float zmax = backEnd.viewParms.zFar; - float zmin = r_znear->value; + if ( !r_depthPrepass->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW) ) + { + return; + } - VectorSet4(viewInfo, zmax / zmin, zmax, 0.0, 0.0); + FBO_t *oldFbo = glState.currentFBO; - GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); - } + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) + { + qglEnable(GL_DEPTH_CLAMP); + } + RB_RenderDepthOnly(drawSurfs, numDrawSurfs); - RB_InstantQuad2(quadVerts, texCoords); //, color, shaderProgram, invTexRes); - } + if (r_ssao->integer) + { + // need the depth in a texture we can do GL_LINEAR sampling on, so + // copy it to an HDR image + FBO_BlitFromTexture( + tr.renderDepthImage, + nullptr, + nullptr, + tr.hdrDepthFbo, + nullptr, + nullptr, + nullptr, 0); + } - // reset viewport and scissor - FBO_Bind(oldFbo); - SetViewportAndScissor(); + if ( r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) ) + { + RB_RenderSunShadows(); + } - if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) - { - qglDisable(GL_DEPTH_CLAMP); - } + if (r_ssao->integer) + { + RB_RenderSSAO(); } - if (!(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + // reset viewport and scissor + FBO_Bind(oldFbo); + SetViewportAndScissor(); + + if (backEnd.viewParms.flags & VPF_DEPTHCLAMP) { - RB_RenderDrawSurfList( cmd->drawSurfs, cmd->numDrawSurfs ); + qglDisable(GL_DEPTH_CLAMP); + } +} - if (r_drawSun->integer) - { - RB_DrawSun(0.1, tr.sunShader); - } +/* +============= +RB_DrawSurfs - if (r_drawSunRays->integer) - { - FBO_t *oldFbo = glState.currentFBO; - FBO_Bind(tr.sunRaysFbo); - - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - qglClear( GL_COLOR_BUFFER_BIT ); +============= +*/ +static const void *RB_DrawSurfs( const void *data ) { + const drawSurfsCommand_t *cmd; - tr.sunFlareQueryActive[tr.sunFlareQueryIndex] = qtrue; - qglBeginQuery(GL_SAMPLES_PASSED, tr.sunFlareQuery[tr.sunFlareQueryIndex]); + // finish any 2D drawing if needed + if ( tess.numIndexes ) { + RB_EndSurface(); + } - RB_DrawSun(0.3, tr.sunFlareShader); + cmd = (const drawSurfsCommand_t *)data; - qglEndQuery(GL_SAMPLES_PASSED); + backEnd.refdef = cmd->refdef; + backEnd.viewParms = cmd->viewParms; - FBO_Bind(oldFbo); - } + // clear the z buffer, set the modelview, etc + RB_BeginDrawingView (); - // darken down any stencil shadows - RB_ShadowFinish(); + RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); - // add light flares on lights that aren't obscured - RB_RenderFlares(); - } + RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); - if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) - { - FBO_Bind(NULL); - GL_SelectTexture(TB_CUBEMAP); - GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP); - qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); - GL_SelectTexture(0); - } + RB_GenerateMipmapsForCubemapFaceRender(); return (const void *)(cmd + 1); } From f0afab60a53ff78122c500cbd9f737c7d03f4f45 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 Dec 2016 00:15:56 +0000 Subject: [PATCH 397/708] Rend2: Refactor ghoul2 bone transform code --- codemp/ghoul2/ghoul2_shared.h | 56 +- codemp/rd-rend2/G2_API.cpp | 66 +- codemp/rd-rend2/G2_bones.cpp | 93 +- codemp/rd-rend2/tr_backend.cpp | 16 + codemp/rd-rend2/tr_ghoul2.cpp | 2015 +++++++++++++++----------------- codemp/rd-rend2/tr_local.h | 28 +- 6 files changed, 1044 insertions(+), 1230 deletions(-) diff --git a/codemp/ghoul2/ghoul2_shared.h b/codemp/ghoul2/ghoul2_shared.h index f20fa75c54..347850bee9 100644 --- a/codemp/ghoul2/ghoul2_shared.h +++ b/codemp/ghoul2/ghoul2_shared.h @@ -54,19 +54,17 @@ struct surfaceInfo_t int genPolySurfaceIndex; // used to point back to the original surface and poly if this is a generated surface int genLod; // used to determine original lod of original surface and poly hit location -surfaceInfo_t(): - offFlags(0), - surface(0), - genBarycentricJ(0), - genBarycentricI(0), - genPolySurfaceIndex(0), - genLod(0) - {} - + surfaceInfo_t() + : offFlags(0) + , surface(0) + , genBarycentricJ(0) + , genBarycentricI(0) + , genPolySurfaceIndex(0) + , genLod(0) + { + } }; - - #define MDXABONEDEF // used in the mdxformat.h file to stop redefinitions of the bone struct. // we save the whole structure here. @@ -153,26 +151,24 @@ struct boneInfo_t int airTime; //base is in air, be more quick and sensitive about collisions //rww - RAGDOLL_END -boneInfo_t(): - boneNumber(-1), - flags(0), - startFrame(0), - endFrame(0), - startTime(0), - pauseTime(0), - animSpeed(0), - blendFrame(0), - blendLerpFrame(0), - blendTime(0), - blendStart(0), - boneBlendTime(0), - boneBlendStart(0), - lastTime(0), - RagFlags(0) + boneInfo_t() + : boneNumber(-1) + , flags(0) + , startFrame(0) + , endFrame(0) + , startTime(0) + , pauseTime(0) + , animSpeed(0) + , blendFrame(0) + , blendLerpFrame(0) + , blendTime(0) + , blendStart(0) + , boneBlendTime(0) + , boneBlendStart(0) + , lastTime(0) + , RagFlags(0) { - matrix.matrix[0][0] = matrix.matrix[0][1] = matrix.matrix[0][2] = matrix.matrix[0][3] = - matrix.matrix[1][0] = matrix.matrix[1][1] = matrix.matrix[1][2] = matrix.matrix[1][3] = - matrix.matrix[2][0] = matrix.matrix[2][1] = matrix.matrix[2][2] = matrix.matrix[2][3] = 0.0f; + Com_Memset(&matrix, 0, sizeof(matrix)); } }; diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 72ae005eac..7abcf050bf 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1963,7 +1963,7 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde VectorNormalize((float*)use->matrix[1]); VectorNormalize((float*)use->matrix[2]); - Multiply_3x4Matrix(matrix, &worldMatrix, use); + Mat3x4_Multiply(matrix, &worldMatrix, use); return qtrue; } } @@ -2007,24 +2007,10 @@ qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const { mdxaBone_t bolt; -#if 0 //yeah, screw it - if (!gG2_GBMNoReconstruct) - { //This should only be used when you know what you're doing. - if (G2_NeedsRecalc(ghlInfo,tframeNum)) - { - G2_ConstructGhoulSkeleton(ghoul2,tframeNum,true,scale); - } - } - else - { - gG2_GBMNoReconstruct = qfalse; - } -#else if (G2_NeedsRecalc(ghlInfo,tframeNum)) { G2_ConstructGhoulSkeleton(ghoul2,tframeNum,true,scale); } -#endif G2_GetBoltMatrixLow(*ghlInfo,boltIndex,scale,bolt); // scale the bolt position by the scale factor for this model since at this point its still in model space @@ -2044,7 +2030,7 @@ qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const VectorNormalize((float*)&bolt.matrix[1]); VectorNormalize((float*)&bolt.matrix[2]); - Multiply_3x4Matrix(matrix, &worldMatrix, &bolt); + Mat3x4_Multiply(matrix, &worldMatrix, &bolt); #if G2API_DEBUG for ( int i = 0; i < 3; i++ ) { @@ -2062,13 +2048,13 @@ qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const vec3_t newangles = {0,270,0}; Create_Matrix(newangles, &rotMat); // make the model space matrix we have for this bolt into a world matrix - Multiply_3x4Matrix(&tempMatrix, &worldMatrix, &bolt); + Mat3x4_Multiply(&tempMatrix, &worldMatrix, &bolt); vec3_t origin; origin[0] = tempMatrix.matrix[0][3]; origin[1] = tempMatrix.matrix[1][3]; origin[2] = tempMatrix.matrix[2][3]; tempMatrix.matrix[0][3] = tempMatrix.matrix[1][3] = tempMatrix.matrix[2][3] = 0; - Multiply_3x4Matrix(matrix, &tempMatrix, &rotMat); + Mat3x4_Multiply(matrix, &tempMatrix, &rotMat); matrix->matrix[0][3] = origin[0]; matrix->matrix[1][3] = origin[1]; matrix->matrix[2][3] = origin[2]; @@ -2086,7 +2072,7 @@ qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const { G2WARNING(0,"G2API_GetBoltMatrix Failed on empty or bad model"); } - Multiply_3x4Matrix(matrix, &worldMatrix, (mdxaBone_t *)&identityMatrix); + Mat3x4_Multiply(matrix, &worldMatrix, (mdxaBone_t *)&identityMatrix); return qfalse; } @@ -2271,22 +2257,6 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh #else G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod); #endif - - //don't need to do this anymore now that I am using a flag for zone alloc. - /* - i = 0; - while (i < ghoul2.size()) - { - CGhoul2Info &g2 = ghoul2[i]; - int iSize = g2.currentModel->mdxm->numSurfaces * 4; - - int *zoneMem = (int *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); - memcpy(zoneMem, g2.mTransformedVertsArray, iSize); - g2.mTransformedVertsArray = zoneMem; - g2.mFlags |= GHOUL2_ZONETRANSALLOC; - i++; - } - */ } // pre generate the world matrix - used to transform the incoming ray @@ -2313,18 +2283,21 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh } -void G2API_CollisionDetect(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, - int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius) +void G2API_CollisionDetect( + CollisionRecord_t *collRecMap, + CGhoul2Info_v &ghoul2, + const vec3_t angles, + const vec3_t position, + int frameNumber, + int entNum, + vec3_t rayStart, + vec3_t rayEnd, + vec3_t scale, + IHeapAllocator *G2VertSpace, + int traceFlags, + int useLod, + float fRadius) { - /* - if (1) - { - G2API_CollisionDetectCache(collRecMap, ghoul2, angles, position, frameNumber, entNum, - rayStart, rayEnd, scale, G2VertSpace, traceFlags, useLod, fRadius); - return; - } - */ - if (G2_SetupModelPointers(ghoul2)) { vec3_t transRayStart, transRayEnd; @@ -2773,7 +2746,6 @@ void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore) } // make sure we have transformed the whole skeletons for each model - //G2_ConstructGhoulSkeleton(ghoul2, gore.currentTime, NULL, true, gore.angles, gore.position, gore.scale, false); G2_ConstructGhoulSkeleton(ghoul2, gore.currentTime, true, gore.scale); // pre generate the world matrix - used to transform the incoming ray diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 75762f6a2e..83257cc5d2 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -306,8 +306,8 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); skel = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[blist[index].boneNumber]); - Multiply_3x4Matrix(&temp1, boneOverride,&skel->BasePoseMatInv); - Multiply_3x4Matrix(boneOverride,&skel->BasePoseMat, &temp1); + Mat3x4_Multiply(&temp1, boneOverride,&skel->BasePoseMatInv); + Mat3x4_Multiply(boneOverride,&skel->BasePoseMat, &temp1); } else @@ -401,7 +401,7 @@ void G2_Generate_Matrix(const model_t *mod, boneInfo_v &blist, int index, const break; } - Multiply_3x4Matrix(boneOverride, &temp1,&permutation); + Mat3x4_Multiply(boneOverride, &temp1,&permutation); } @@ -1770,12 +1770,6 @@ void G2_SetRagDoll(CGhoul2Info_v &ghoul2V,CRagDollParams *parms) // only going to begin ragdoll once, everything else depends on what happens to the origin return; } -#if 0 -if (index>=0) -{ - Com_OPrintf("death %d %d\n",blist[index].startFrame,blist[index].endFrame); -} -#endif ghoul2.mFlags|=GHOUL2_RAG_PENDING|GHOUL2_RAG_DONE|GHOUL2_RAG_STARTED; // well anyway we are going live parms->CallRagDollBegin=qtrue; @@ -1839,7 +1833,6 @@ if (index>=0) BONE_ANIM_OVERRIDE_FREEZE|BONE_ANIM_BLEND, 1.0f,curTime,float(startFrame),150,0,true); -// should already be set G2_GenerateWorldMatrix(parms->angles, parms->position); G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); static const float fRadScale = 0.3f;//0.5f; @@ -1994,15 +1987,6 @@ if (index>=0) return; } G2_RagDollCurrentPosition(ghoul2V,model,curTime,parms->angles,parms->position,parms->scale); -#if 0 - if (rhand>0) - { - boneInfo_t &bone=blist[rhand]; - SRagEffector &e=ragEffectors[bone.ragIndex]; - VectorCopy(bone.originalOrigin,handPos); - VectorCopy(e.currentOrigin,handPos2); - } -#endif int k; CRagDollUpdateParams fparms; @@ -2601,7 +2585,6 @@ static void G2_RagDollCurrentPosition(CGhoul2Info_v &ghoul2V,int g2Index,int fra { CGhoul2Info &ghoul2=ghoul2V[g2Index]; assert(ghoul2.mFileName[0]); -//Com_OPrintf("angles %f %f %f\n",angles[0],angles[1],angles[2]); G2_GenerateWorldMatrix(angles,position); G2_ConstructGhoulSkeleton(ghoul2V, frameNum, false, scale); @@ -3355,7 +3338,7 @@ static inline void G2_RagGetWorldAnimMatrix(CGhoul2Info &ghoul2, boneInfo_t &bon //Use params to multiply world coordinate/dir matrix into the //bone matrix and give us a useable world position - Multiply_3x4Matrix(&retMatrix, &worldMatrix, &baseBoneMatrix); + Mat3x4_Multiply(&retMatrix, &worldMatrix, &baseBoneMatrix); assert(!Q_isnan(retMatrix.matrix[2][3])); } @@ -3389,7 +3372,7 @@ static inline void G2_RagGetPelvisLumbarOffsets(CGhoul2Info &ghoul2, CRagDollUpd //G2_GetRagBoneMatrixLow(ghoul2, boneIndex, x); int bolt = G2_Add_Bolt(&ghoul2, ghoul2.mBltlist, ghoul2.mSlist, "pelvis"); G2_GetBoltMatrixLow(ghoul2, bolt, params->scale, x); - Multiply_3x4Matrix(&final, &worldMatrix, &x); + Mat3x4_Multiply(&final, &worldMatrix, &x); G2API_GiveMeVectorFromMatrix(&final, ORIGIN, pos); G2API_GiveMeVectorFromMatrix(&final, POSITIVE_X, dir); #endif @@ -4021,7 +4004,7 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f Create_Matrix(tAngles,&curRot); //dest 2nd arg Inverse_Matrix(&curRot,&curRotInv); // dest 2nd arg - Multiply_3x4Matrix(&P,&ragBones[i],&curRotInv); //dest first arg + Mat3x4_Multiply(&P,&ragBones[i],&curRotInv); //dest first arg @@ -4063,8 +4046,8 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f tAngles[k]+=0.5f; Create_Matrix(tAngles,&temp2); //dest 2nd arg tAngles[k]-=0.5f; - Multiply_3x4Matrix(&temp1,&P,&temp2); //dest first arg - Multiply_3x4Matrix(&Gs[k],&temp1,&N); //dest first arg + Mat3x4_Multiply(&temp1,&P,&temp2); //dest first arg + Mat3x4_Multiply(&Gs[k],&temp1,&N); //dest first arg } @@ -4091,7 +4074,7 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f numRagDep++; for (k=0;k<3;k++) { - Multiply_3x4Matrix(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg + Mat3x4_Multiply(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg vec3_t tPosition; tPosition[0]=Enew[k].matrix[0][3]; tPosition[1]=Enew[k].matrix[1][3]; @@ -4208,8 +4191,8 @@ static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int f } Create_Matrix(bone.currentAngles,&temp1); - Multiply_3x4Matrix(&temp2,&temp1,bone.baseposeInv); - Multiply_3x4Matrix(&bone.ragOverrideMatrix,bone.basepose, &temp2); + Mat3x4_Multiply(&temp2,&temp1,bone.baseposeInv); + Mat3x4_Multiply(&bone.ragOverrideMatrix,bone.basepose, &temp2); assert( !Q_isnan(bone.ragOverrideMatrix.matrix[2][3])); } G2_Generate_MatrixRag(blist,ragBlistIndex[bone.boneNumber]); @@ -4298,7 +4281,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN Create_Matrix(tAngles, &curRot); //dest 2nd arg Inverse_Matrix(&curRot, &curRotInv); // dest 2nd arg - Multiply_3x4Matrix(&P, &ragBones[i], &curRotInv); //dest first arg + Mat3x4_Multiply(&P, &ragBones[i], &curRotInv); //dest first arg vec3_t delAngles; @@ -4309,8 +4292,8 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN tAngles[k] += 0.5f; Create_Matrix(tAngles, &temp2); //dest 2nd arg tAngles[k] -= 0.5f; - Multiply_3x4Matrix(&temp1, &P, &temp2); //dest first arg - Multiply_3x4Matrix(&Gs[k], &temp1, &N); //dest first arg + Mat3x4_Multiply(&temp1, &P, &temp2); //dest first arg + Mat3x4_Multiply(&Gs[k], &temp1, &N); //dest first arg } // fixme precompute this @@ -4337,7 +4320,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN numRagDep++; for (k=0;k<3;k++) { - Multiply_3x4Matrix(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg + Mat3x4_Multiply(&Enew[k],&Gs[k],&ragBones[depIndex]); //dest first arg vec3_t tPosition; tPosition[0]=Enew[k].matrix[0][3]; tPosition[1]=Enew[k].matrix[1][3]; @@ -4404,8 +4387,7 @@ static void G2_IKSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameN } } Create_Matrix(bone.currentAngles, &temp1); - Multiply_3x4Matrix(&temp2, &temp1, bone.baseposeInv); - Multiply_3x4Matrix(&bone.ragOverrideMatrix, bone.basepose, &temp2); + bone.ragOverrideMatrix = *bone.basepose * (temp1 * *bone.baseposeInv); assert( !Q_isnan(bone.ragOverrideMatrix.matrix[2][3])); G2_Generate_MatrixRag(blist, ragBlistIndex[bone.boneNumber]); @@ -4580,31 +4562,7 @@ void G2_InitIK(CGhoul2Info_v &ghoul2V, sharedRagDollUpdateParams_t *parms, int t // new base anim, unconscious flop int pcjFlags; -#if 0 - vec3_t pcjMin, pcjMax; - VectorClear(pcjMin); - VectorClear(pcjMax); - - pcjFlags=RAG_PCJ|RAG_PCJ_POST_MULT;//|RAG_EFFECTOR; - - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"model_root",RAG_PCJ_MODEL_ROOT|RAG_PCJ,10.0f,pcjMin,pcjMax,100); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"pelvis",RAG_PCJ_PELVIS|RAG_PCJ|RAG_PCJ_POST_MULT,10.0f,pcjMin,pcjMax,100); - - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lower_lumbar",pcjFlags,10.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"upper_lumbar",pcjFlags,10.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"thoracic",pcjFlags|RAG_EFFECTOR,12.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"cranium",pcjFlags,6.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rhumerus",pcjFlags,4.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lhumerus",pcjFlags,4.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rradius",pcjFlags,3.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lradius",pcjFlags,3.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rfemurYZ",pcjFlags,6.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"lfemurYZ",pcjFlags,6.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"rtibia",pcjFlags,4.0f,pcjMin,pcjMax,500); - G2_Set_Bone_Angles_IK(ghoul2, mod_a,blist,"ltibia",pcjFlags,4.0f,pcjMin,pcjMax,500); - G2_ConstructGhoulSkeleton(ghoul2V, curTime, false, parms->scale); -#endif //Only need the standard effectors for this. pcjFlags = RAG_PCJ|RAG_PCJ_POST_MULT|RAG_EFFECTOR; @@ -4718,28 +4676,9 @@ qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName { //otherwise if the bone is already flagged as rag, then we can't set it again. (non-active ik bones will be BONE_ANGLES_IK, active are considered rag) return qfalse; } -#if 0 //this is wrong now.. we're only initing effectors with initik now.. which SHOULDN'T be used as pcj's - if (!(bone.flags & BONE_ANGLES_IK) && !(bone.flags & BONE_ANGLES_RAGDOLL)) - { //IK system has not been inited yet, because any bone that can be IK should be in the ragdoll list, not flagged as BONE_ANGLES_RAGDOLL but as BONE_ANGLES_IK - sharedRagDollUpdateParams_t sRDUP; - sRDUP.me = 0; - VectorCopy(params->angles, sRDUP.angles); - VectorCopy(params->origin, sRDUP.position); - VectorCopy(params->scale, sRDUP.scale); - VectorClear(sRDUP.velocity); - G2_InitIK(ghoul2, &sRDUP, curTime, rmod_a, g2index); - G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); - } - else - { - G2_GenerateWorldMatrix(params->angles, params->origin); - G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); - } -#else G2_GenerateWorldMatrix(params->angles, params->origin); G2_ConstructGhoulSkeleton(ghoul2, curTime, false, params->scale); -#endif int pcjFlags = RAG_PCJ|RAG_PCJ_IK_CONTROLLED|RAG_PCJ_POST_MULT|RAG_EFFECTOR; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f2d9caef13..9e36d4efb7 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2085,6 +2085,20 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu } } +static void RB_TransformAllAnimations( drawSurf_t *drawSurfs, int numDrawSurfs ) +{ + drawSurf_t *drawSurf = drawSurfs; + for ( int i = 0; i < numDrawSurfs; ++i, ++drawSurf ) + { + if ( *drawSurf->surface != SF_MDX ) + { + continue; + } + + CRenderableSurface *g2Surface = reinterpret_cast(drawSurf); + } +} + /* ============= RB_DrawSurfs @@ -2107,6 +2121,8 @@ static const void *RB_DrawSurfs( const void *data ) { // clear the z buffer, set the modelview, etc RB_BeginDrawingView (); + RB_TransformAllAnimations(cmd->drawSurfs, cmd->numDrawSurfs); + RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a57cf34e7a..a7a85b0923 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -105,7 +105,7 @@ void ResetGhoul2RenderableSurfaceHeap() currentRenderSurfIndex = 0; } -bool HackadelicOnClient=false; // means this is a render traversal +bool HackadelicOnClient = false; // means this is a render traversal qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo); qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); @@ -113,7 +113,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info_v &ghoul2); extern cvar_t *r_Ghoul2AnimSmooth; extern cvar_t *r_Ghoul2UnSqashAfterSmooth; -const static mdxaBone_t identityMatrix = +static const mdxaBone_t identityMatrix = { { { 0.0f, -1.0f, 0.0f, 0.0f }, @@ -129,6 +129,137 @@ mdxaBone_t worldMatrixInv; qhandle_t goreShader=-1; #endif +// nasty little matrix multiply going on here.. +void Mat3x4_Multiply(mdxaBone_t *out, const mdxaBone_t *in2, const mdxaBone_t *in) +{ + assert(out != nullptr); + assert(in2 != nullptr); + assert(in != nullptr); + + // Let's say we are doing R = N * M + const float n00 = in2->matrix[0][0]; + const float n01 = in2->matrix[0][1]; + const float n02 = in2->matrix[0][2]; + const float n03 = in2->matrix[0][3]; + const float n10 = in2->matrix[1][0]; + const float n11 = in2->matrix[1][1]; + const float n12 = in2->matrix[1][2]; + const float n13 = in2->matrix[1][3]; + const float n20 = in2->matrix[2][0]; + const float n21 = in2->matrix[2][1]; + const float n22 = in2->matrix[2][2]; + const float n23 = in2->matrix[2][3]; + + const float m00 = in->matrix[0][0]; + const float m01 = in->matrix[0][1]; + const float m02 = in->matrix[0][2]; + const float m03 = in->matrix[0][3]; + const float m10 = in->matrix[1][0]; + const float m11 = in->matrix[1][1]; + const float m12 = in->matrix[1][2]; + const float m13 = in->matrix[1][3]; + const float m20 = in->matrix[2][0]; + const float m21 = in->matrix[2][1]; + const float m22 = in->matrix[2][2]; + const float m23 = in->matrix[2][3]; + + // first row of out + out->matrix[0][0] = (n00 * m00) + (n01 * m10) + (n02 * m20); + out->matrix[0][1] = (n00 * m01) + (n01 * m11) + (n02 * m21); + out->matrix[0][2] = (n00 * m02) + (n01 * m12) + (n02 * m22); + out->matrix[0][3] = (n00 * m03) + (n01 * m13) + (n02 * m23) + n03; + + // second row of outf out + out->matrix[1][0] = (n10 * m00) + (n11 * m10) + (n12 * m20); + out->matrix[1][1] = (n10 * m01) + (n11 * m11) + (n12 * m21); + out->matrix[1][2] = (n10 * m02) + (n11 * m12) + (n12 * m22); + out->matrix[1][3] = (n10 * m03) + (n11 * m13) + (n12 * m23) + n13; + + // third row of out out + out->matrix[2][0] = (n20 * m00) + (n21 * m10) + (n22 * m20); + out->matrix[2][1] = (n20 * m01) + (n21 * m11) + (n22 * m21); + out->matrix[2][2] = (n20 * m02) + (n21 * m12) + (n22 * m22); + out->matrix[2][3] = (n20 * m03) + (n21 * m13) + (n22 * m23) + n23; +} + +void Mat3x4_Scale( mdxaBone_t *result, const mdxaBone_t *lhs, const float scale ) +{ + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 3; ++j ) + { + result->matrix[i][j] = lhs->matrix[i][j] * scale; + } + } +} + +void Mat3x4_Lerp( + mdxaBone_t *result, + const mdxaBone_t *lhs, + const mdxaBone_t *rhs, + const float t ) +{ + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 4; ++j ) + { + result->matrix[i][j] = lhs->matrix[i][j] * t + rhs->matrix[i][j] * (1.0f - t); + } + } +} + +const mdxaBone_t operator +( const mdxaBone_t& lhs, const mdxaBone_t& rhs ) +{ + mdxaBone_t result; + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 4; ++j ) + { + result.matrix[i][j] = lhs.matrix[i][j] + rhs.matrix[i][j]; + } + } + return result; +} + +const mdxaBone_t operator -( const mdxaBone_t& lhs, const mdxaBone_t& rhs ) +{ + mdxaBone_t result; + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 4; ++j ) + { + result.matrix[i][j] = lhs.matrix[i][j] - rhs.matrix[i][j]; + } + } + return result; +} + +const mdxaBone_t operator *( const mdxaBone_t& lhs, const mdxaBone_t& rhs ) +{ + mdxaBone_t result; + Mat3x4_Multiply(&result, &lhs, &rhs); + return result; +} + +const mdxaBone_t operator *( const mdxaBone_t& lhs, const float scale ) +{ + mdxaBone_t result; + for ( int i = 0; i < 3; ++i ) + { + for ( int j = 0; j < 4; ++j ) + { + result.matrix[i][j] = lhs.matrix[i][j] * scale; + } + } + return result; +} + +const mdxaBone_t operator *( const float scale, const mdxaBone_t& rhs ) +{ + return rhs * scale; +} + + class CConstructBoneList { public: @@ -139,226 +270,175 @@ class CConstructBoneList boneInfo_v &boneList; CConstructBoneList( - int initsurfaceNum, - int *initboneUsedList, - surfaceInfo_v &initrootSList, - model_t *initcurrentModel, - boneInfo_v &initboneList): - - surfaceNum(initsurfaceNum), - boneUsedList(initboneUsedList), - rootSList(initrootSList), - currentModel(initcurrentModel), - boneList(initboneList) { } - + int initsurfaceNum, + int *initboneUsedList, + surfaceInfo_v& initrootSList, + model_t *initcurrentModel, + boneInfo_v& initboneList) + : surfaceNum(initsurfaceNum) + , boneUsedList(initboneUsedList) + , rootSList(initrootSList) + , currentModel(initcurrentModel) + , boneList(initboneList) + { + } }; class CTransformBone { public: - int touch; // for minimal recalculation - //rww - RAGDOLL_BEGIN - int touchRender; - //rww - RAGDOLL_END - mdxaBone_t boneMatrix; //final matrix - int parent; // only set once + int touch; // for minimal recalculation + int touchRender; + mdxaBone_t boneMatrix; //final matrix + int parent; // only set once CTransformBone() + : touch(0) + , touchRender(0) { - touch=0; - //rww - RAGDOLL_BEGIN - touchRender = 0; - //rww - RAGDOLL_END } }; struct SBoneCalc { - int newFrame; - int currentFrame; - float backlerp; - float blendFrame; - int blendOldFrame; - bool blendMode; - float blendLerp; + int newFrame; + int currentFrame; + float backlerp; + float blendFrame; + int blendOldFrame; + bool blendMode; + float blendLerp; }; class CBoneCache; -void G2_TransformBone(int index,CBoneCache &CB); +static void G2_TransformBone( int index, CBoneCache &CB ); class CBoneCache { - void SetRenderMatrix(CTransformBone *bone) { - } - - void EvalLow(int index) + void EvalLow( int index ) { - assert(index>=0&&index<(int)mBones.size()); - if (mFinalBones[index].touch!=mCurrentTouch) + assert(index >= 0 && index < (int)mBones.size()); + + if ( mFinalBones[index].touch != mCurrentTouch ) { // need to evaluate the bone - assert((mFinalBones[index].parent>=0&&mFinalBones[index].parent<(int)mFinalBones.size())||(index==0&&mFinalBones[index].parent==-1)); - if (mFinalBones[index].parent>=0) + assert((mFinalBones[index].parent >= 0 + && mFinalBones[index].parent < (int)mFinalBones.size()) || + (index == 0 && mFinalBones[index].parent == -1)); + + if ( mFinalBones[index].parent >= 0 ) { EvalLow(mFinalBones[index].parent); // make sure parent is evaluated - SBoneCalc &par=mBones[mFinalBones[index].parent]; - mBones[index].newFrame=par.newFrame; - mBones[index].currentFrame=par.currentFrame; - mBones[index].backlerp=par.backlerp; - mBones[index].blendFrame=par.blendFrame; - mBones[index].blendOldFrame=par.blendOldFrame; - mBones[index].blendMode=par.blendMode; - mBones[index].blendLerp=par.blendLerp; + + const SBoneCalc &par = mBones[mFinalBones[index].parent]; + SBoneCalc &bone = mBones[index]; + bone.newFrame = par.newFrame; + bone.currentFrame = par.currentFrame; + bone.backlerp = par.backlerp; + bone.blendFrame = par.blendFrame; + bone.blendOldFrame = par.blendOldFrame; + bone.blendMode = par.blendMode; + bone.blendLerp = par.blendLerp; } - G2_TransformBone(index,*this); - mFinalBones[index].touch=mCurrentTouch; + + G2_TransformBone(index, *this); + + mFinalBones[index].touch = mCurrentTouch; } } -//rww - RAGDOLL_BEGIN - void SmoothLow(int index) + + void SmoothLow( int index ) { - if (mSmoothBones[index].touch==mLastTouch) + if ( mSmoothBones[index].touch == mLastTouch ) { - int i; - float *oldM=&mSmoothBones[index].boneMatrix.matrix[0][0]; - float *newM=&mFinalBones[index].boneMatrix.matrix[0][0]; -#if 0 //this is just too slow. I need a better way. - static float smoothFactor; - - smoothFactor = mSmoothFactor; - - //Special rag smoothing -rww - if (smoothFactor < 0) - { //I need a faster way to do this but I do not want to store more in the bonecache - static int blistIndex; - assert(mod); - assert(rootBoneList); - blistIndex = G2_Find_Bone_ByNum(mod, *rootBoneList, index); + const mdxaBone_t& newM = mFinalBones[index].boneMatrix; + mdxaBone_t& oldM = mSmoothBones[index].boneMatrix; - assert(blistIndex != -1); - - boneInfo_t &bone = (*rootBoneList)[blistIndex]; - - if (bone.flags & BONE_ANGLES_RAGDOLL) - { - if ((bone.RagFlags & (0x00008)) || //pelvis - (bone.RagFlags & (0x00004))) //model_root - { //pelvis and root do not smooth much - smoothFactor = 0.2f; - } - else if (bone.solidCount > 4) - { //if stuck in solid a lot then snap out quickly - smoothFactor = 0.1f; - } - else - { //otherwise smooth a bunch - smoothFactor = 0.8f; - } - } - else - { //not a rag bone - smoothFactor = 0.3f; - } - } -#endif - - for (i=0;i<12;i++,oldM++,newM++) - { - *oldM=mSmoothFactor*(*oldM-*newM)+*newM; - } + oldM = mSmoothFactor * (oldM - newM) + newM; } else { - memcpy(&mSmoothBones[index].boneMatrix,&mFinalBones[index].boneMatrix,sizeof(mdxaBone_t)); + mSmoothBones[index].boneMatrix = mFinalBones[index].boneMatrix; } - mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); - mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)header + sizeof(mdxaHeader_t) + offsets->offsets[index]); - mdxaBone_t tempMatrix; - Multiply_3x4Matrix(&tempMatrix,&mSmoothBones[index].boneMatrix, &skel->BasePoseMat); - float maxl; - maxl=VectorLength(&skel->BasePoseMat.matrix[0][0]); + + const mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + const mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[index]); + + mdxaBone_t tempMatrix = + mSmoothBones[index].boneMatrix * skel->BasePoseMat; + const float maxl = VectorLength(&skel->BasePoseMat.matrix[0][0]); VectorNormalize(&tempMatrix.matrix[0][0]); VectorNormalize(&tempMatrix.matrix[1][0]); VectorNormalize(&tempMatrix.matrix[2][0]); + Mat3x4_Scale(&tempMatrix, &tempMatrix, maxl); + + mSmoothBones[index].boneMatrix = tempMatrix * skel->BasePoseMatInv; + mSmoothBones[index].touch = mCurrentTouch; - VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); - VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); - VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); - Multiply_3x4Matrix(&mSmoothBones[index].boneMatrix,&tempMatrix,&skel->BasePoseMatInv); - mSmoothBones[index].touch=mCurrentTouch; #ifdef _DEBUG for ( int i = 0; i < 3; i++ ) { for ( int j = 0; j < 4; j++ ) { - assert( !Q_isnan(mSmoothBones[index].boneMatrix.matrix[i][j])); + assert(!Q_isnan(mSmoothBones[index].boneMatrix.matrix[i][j])); } } #endif// _DEBUG } -//rww - RAGDOLL_END + public: - int frameSize; - const mdxaHeader_t *header; - const model_t *mod; + int frameSize; + const mdxaHeader_t *header; + const model_t *mod; // these are split for better cpu cache behavior std::vector mBones; std::vector mFinalBones; - std::vector mSmoothBones; // for render smoothing - //vector mSkels; - boneInfo_v *rootBoneList; - mdxaBone_t rootMatrix; - int incomingTime; + boneInfo_v *rootBoneList; + mdxaBone_t rootMatrix; + int incomingTime; - int mCurrentTouch; - //rww - RAGDOLL_BEGIN - int mCurrentTouchRender; - int mLastTouch; - int mLastLastTouch; - //rww - RAGDOLL_END + int mCurrentTouch; + int mCurrentTouchRender; + int mLastTouch; + int mLastLastTouch; // for render smoothing - bool mSmoothingActive; - bool mUnsquash; - float mSmoothFactor; - - CBoneCache(const model_t *amod,const mdxaHeader_t *aheader) : - header(aheader), - mod(amod) + bool mSmoothingActive; + bool mUnsquash; + float mSmoothFactor; + + CBoneCache( const model_t *amod, const mdxaHeader_t *aheader ) + : header(aheader) + , mod(amod) + , mBones(header->numBones) + , mFinalBones(header->numBones) + , mSmoothBones(header->numBones) + , mCurrentTouch(3) + , mLastTouch(2) + , mLastLastTouch(1) + , mSmoothingActive(false) + , mUnsquash(false) + , mSmoothFactor(0.0f) { assert(amod); assert(aheader); - mSmoothingActive=false; - mUnsquash=false; - mSmoothFactor=0.0f; - - int numBones=header->numBones; - mBones.resize(numBones); - mFinalBones.resize(numBones); - mSmoothBones.resize(numBones); -// mSkels.resize(numBones); - //rww - removed mSkels - mdxaSkelOffsets_t *offsets; - mdxaSkel_t *skel; - offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); - - int i; - for (i=0;inumBones; + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + + for ( int i = 0; i < numBones; ++i ) { - skel = (mdxaSkel_t *)((byte *)header + sizeof(mdxaHeader_t) + offsets->offsets[i]); - //mSkels[i]=skel; - //ditto - mFinalBones[i].parent=skel->parent; + mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[i]); + mFinalBones[i].parent = skel->parent; } - mCurrentTouch=3; -//rww - RAGDOLL_BEGIN - mLastTouch=2; - mLastLastTouch=1; -//rww - RAGDOLL_END } SBoneCalc &Root() @@ -366,115 +446,68 @@ class CBoneCache assert(mBones.size()); return mBones[0]; } - const mdxaBone_t &EvalUnsmooth(int index) + + const mdxaBone_t &EvalUnsmooth( int index ) { EvalLow(index); - if (mSmoothingActive&&mSmoothBones[index].touch) + if ( mSmoothingActive && mSmoothBones[index].touch ) { return mSmoothBones[index].boneMatrix; } - return mFinalBones[index].boneMatrix; - } - const mdxaBone_t &Eval(int index) - { - /* - bool wasEval=EvalLow(index); - if (mSmoothingActive) - { - if (mSmoothBones[index].touch!=incomingTime||wasEval) - { - float dif=float(incomingTime)-float(mSmoothBones[index].touch); - if (mSmoothBones[index].touch&&dif<300.0f) - { - if (dif<16.0f) // 60 fps - { - dif=16.0f; - } - if (dif>100.0f) // 10 fps - { - dif=100.0f; - } - float f=1.0f-pow(1.0f-mSmoothFactor,16.0f/dif); - - int i; - float *oldM=&mSmoothBones[index].boneMatrix.matrix[0][0]; - float *newM=&mFinalBones[index].boneMatrix.matrix[0][0]; - for (i=0;i<12;i++,oldM++,newM++) - { - *oldM=f*(*oldM-*newM)+*newM; - } - if (mUnsquash) - { - mdxaBone_t tempMatrix; - Multiply_3x4Matrix(&tempMatrix,&mSmoothBones[index].boneMatrix, &mSkels[index]->BasePoseMat); - float maxl; - maxl=VectorLength(&mSkels[index]->BasePoseMat.matrix[0][0]); - VectorNormalize(&tempMatrix.matrix[0][0]); - VectorNormalize(&tempMatrix.matrix[1][0]); - VectorNormalize(&tempMatrix.matrix[2][0]); - - VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); - VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); - VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); - Multiply_3x4Matrix(&mSmoothBones[index].boneMatrix,&tempMatrix,&mSkels[index]->BasePoseMatInv); - } - } - else - { - memcpy(&mSmoothBones[index].boneMatrix,&mFinalBones[index].boneMatrix,sizeof(mdxaBone_t)); - } - mSmoothBones[index].touch=incomingTime; - } - return mSmoothBones[index].boneMatrix; - } return mFinalBones[index].boneMatrix; - */ + } + const mdxaBone_t &Eval( int index ) + { //Hey, this is what sof2 does. Let's try it out. - assert(index>=0&&index<(int)mBones.size()); - if (mFinalBones[index].touch!=mCurrentTouch) + assert(index >= 0 && index <( int)mBones.size()); + if ( mFinalBones[index].touch != mCurrentTouch ) { EvalLow(index); } + return mFinalBones[index].boneMatrix; } - //rww - RAGDOLL_BEGIN - const inline mdxaBone_t &EvalRender(int index) + + const mdxaBone_t &EvalRender( int index ) { - assert(index>=0&&index<(int)mBones.size()); - if (mFinalBones[index].touch!=mCurrentTouch) + assert(index >= 0 && index < (int)mBones.size()); + if ( mFinalBones[index].touch != mCurrentTouch ) { - mFinalBones[index].touchRender=mCurrentTouchRender; + mFinalBones[index].touchRender = mCurrentTouchRender; EvalLow(index); } - if (mSmoothingActive) + + if ( mSmoothingActive ) { - if (mSmoothBones[index].touch!=mCurrentTouch) + if ( mSmoothBones[index].touch != mCurrentTouch ) { SmoothLow(index); } + return mSmoothBones[index].boneMatrix; } + return mFinalBones[index].boneMatrix; } - //rww - RAGDOLL_END - //rww - RAGDOLL_BEGIN - bool WasRendered(int index) + + bool WasRendered( int index ) { - assert(index>=0&&index<(int)mBones.size()); - return mFinalBones[index].touchRender==mCurrentTouchRender; + assert(index >= 0 && index < (int)mBones.size()); + return mFinalBones[index].touchRender == mCurrentTouchRender; } - int GetParent(int index) + + int GetParent( int index ) { - if (index==0) + if ( index == 0 ) { return -1; } - assert(index>=0&&index<(int)mBones.size()); + + assert( index > 0 && index < (int)mBones.size()); return mFinalBones[index].parent; } - //rww - RAGDOLL_END }; void RemoveBoneCache(CBoneCache *boneCache) @@ -615,7 +648,7 @@ void G2_RagGetBoneBasePoseMatrixLow(CGhoul2Info &ghoul2, int boneNum, mdxaBone_t mdxaSkelOffsets_t *offsets; offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); - Multiply_3x4Matrix(&retMatrix, &boneMatrix, &skel->BasePoseMat); + Mat3x4_Multiply(&retMatrix, &boneMatrix, &skel->BasePoseMat); if (scale[0]) { @@ -655,7 +688,7 @@ void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxa mdxaSkelOffsets_t *offsets; offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); - Multiply_3x4Matrix(&bolt, (mdxaBone_t *)&boneCache.Eval(boneNum), &skel->BasePoseMat); // DEST FIRST ARG + Mat3x4_Multiply(&bolt, (mdxaBone_t *)&boneCache.Eval(boneNum), &skel->BasePoseMat); // DEST FIRST ARG retBasepose=&skel->BasePoseMat; retBaseposeInv=&skel->BasePoseMatInv; @@ -675,7 +708,7 @@ void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxa VectorNormalize((float*)&bolt.matrix[1]); VectorNormalize((float*)&bolt.matrix[2]); - Multiply_3x4Matrix(&retMatrix,&worldMatrix, &bolt); + Mat3x4_Multiply(&retMatrix,&worldMatrix, &bolt); #ifdef _DEBUG for ( int i = 0; i < 3; i++ ) @@ -734,42 +767,43 @@ class CRenderSurface #endif CRenderSurface( - int initsurfaceNum, - surfaceInfo_v &initrootSList, - shader_t *initcust_shader, - int initfogNum, - qboolean initpersonalModel, - CBoneCache *initboneCache, - int initrenderfx, - skin_t *initskin, - model_t *initcurrentModel, - int initlod, + int initsurfaceNum, + surfaceInfo_v &initrootSList, + shader_t *initcust_shader, + int initfogNum, + qboolean initpersonalModel, + CBoneCache *initboneCache, + int initrenderfx, + skin_t *initskin, + model_t *initcurrentModel, + int initlod, #ifdef _G2_GORE - boltInfo_v &initboltList, - shader_t *initgore_shader, - CGoreSet *initgore_set + boltInfo_v &initboltList, + shader_t *initgore_shader, + CGoreSet *initgore_set #else - boltInfo_v &initboltList + boltInfo_v &initboltList #endif - ): - surfaceNum(initsurfaceNum), - rootSList(initrootSList), - cust_shader(initcust_shader), - fogNum(initfogNum), - personalModel(initpersonalModel), - boneCache(initboneCache), - renderfx(initrenderfx), - skin(initskin), - currentModel(initcurrentModel), - lod(initlod), + ) + : surfaceNum(initsurfaceNum) + , rootSList(initrootSList) + , cust_shader(initcust_shader) + , fogNum(initfogNum) + , personalModel(initpersonalModel) + , boneCache(initboneCache) + , renderfx(initrenderfx) + , skin(initskin) + , currentModel(initcurrentModel) + , lod(initlod) #ifdef _G2_GORE - boltList(initboltList), - gore_shader(initgore_shader), - gore_set(initgore_set) + , boltList(initboltList) + , gore_shader(initgore_shader) + , gore_set(initgore_set) #else - boltList(initboltList) + , boltList(initboltList) #endif - {} + { + } }; /* @@ -1017,32 +1051,12 @@ void G2_CreateMatrixFromQuaterion(mdxaBone_t *mat, vec4_t quat) mat->matrix[0][3] = mat->matrix[1][3] = mat->matrix[2][3] = 0; } -// nasty little matrix multiply going on here.. -void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in) -{ - // first row of out - out->matrix[0][0] = (in2->matrix[0][0] * in->matrix[0][0]) + (in2->matrix[0][1] * in->matrix[1][0]) + (in2->matrix[0][2] * in->matrix[2][0]); - out->matrix[0][1] = (in2->matrix[0][0] * in->matrix[0][1]) + (in2->matrix[0][1] * in->matrix[1][1]) + (in2->matrix[0][2] * in->matrix[2][1]); - out->matrix[0][2] = (in2->matrix[0][0] * in->matrix[0][2]) + (in2->matrix[0][1] * in->matrix[1][2]) + (in2->matrix[0][2] * in->matrix[2][2]); - out->matrix[0][3] = (in2->matrix[0][0] * in->matrix[0][3]) + (in2->matrix[0][1] * in->matrix[1][3]) + (in2->matrix[0][2] * in->matrix[2][3]) + in2->matrix[0][3]; - // second row of outf out - out->matrix[1][0] = (in2->matrix[1][0] * in->matrix[0][0]) + (in2->matrix[1][1] * in->matrix[1][0]) + (in2->matrix[1][2] * in->matrix[2][0]); - out->matrix[1][1] = (in2->matrix[1][0] * in->matrix[0][1]) + (in2->matrix[1][1] * in->matrix[1][1]) + (in2->matrix[1][2] * in->matrix[2][1]); - out->matrix[1][2] = (in2->matrix[1][0] * in->matrix[0][2]) + (in2->matrix[1][1] * in->matrix[1][2]) + (in2->matrix[1][2] * in->matrix[2][2]); - out->matrix[1][3] = (in2->matrix[1][0] * in->matrix[0][3]) + (in2->matrix[1][1] * in->matrix[1][3]) + (in2->matrix[1][2] * in->matrix[2][3]) + in2->matrix[1][3]; - // third row of out out - out->matrix[2][0] = (in2->matrix[2][0] * in->matrix[0][0]) + (in2->matrix[2][1] * in->matrix[1][0]) + (in2->matrix[2][2] * in->matrix[2][0]); - out->matrix[2][1] = (in2->matrix[2][0] * in->matrix[0][1]) + (in2->matrix[2][1] * in->matrix[1][1]) + (in2->matrix[2][2] * in->matrix[2][1]); - out->matrix[2][2] = (in2->matrix[2][0] * in->matrix[0][2]) + (in2->matrix[2][1] * in->matrix[1][2]) + (in2->matrix[2][2] * in->matrix[2][2]); - out->matrix[2][3] = (in2->matrix[2][0] * in->matrix[0][3]) + (in2->matrix[2][1] * in->matrix[1][3]) + (in2->matrix[2][2] * in->matrix[2][3]) + in2->matrix[2][3]; -} - - static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone) { const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3); - mdxaIndex_t *pIndex = (mdxaIndex_t *) ((byte*) pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); + mdxaIndex_t *pIndex = + (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); return pIndex->iIndex & 0x00FFFFFF; // this will cause problems for big-endian machines... ;-) } @@ -1057,16 +1071,22 @@ static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int #define DEBUG_G2_TIMING (0) #define DEBUG_G2_TIMING_RENDER_ONLY (1) -void G2_TimingModel(boneInfo_t &bone,int currentTime,int numFramesInFile,int ¤tFrame,int &newFrame,float &lerp) +void G2_TimingModel( + boneInfo_t &bone, + int currentTime, + int numFramesInFile, + int ¤tFrame, + int &newFrame, + float& lerp) { - assert(bone.startFrame>=0); - assert(bone.startFrame<=numFramesInFile); - assert(bone.endFrame>=0); - assert(bone.endFrame<=numFramesInFile); + assert(bone.startFrame >= 0); + assert(bone.startFrame <= numFramesInFile); + assert(bone.endFrame >= 0); + assert(bone.endFrame <= numFramesInFile); // yes - add in animation speed to current frame - float animSpeed = bone.animSpeed; - float time; + const float animSpeed = bone.animSpeed; + float time; if (bone.pauseTime) { time = (bone.pauseTime - bone.startTime) / 50.0f; @@ -1075,134 +1095,133 @@ void G2_TimingModel(boneInfo_t &bone,int currentTime,int numFramesInFile,int &cu { time = (currentTime - bone.startTime) / 50.0f; } - if (time<0.0f) - { - time=0.0f; - } - float newFrame_g = bone.startFrame + (time * animSpeed); - int animSize = bone.endFrame - bone.startFrame; - float endFrame = (float)bone.endFrame; + time = Q_max(0.0f, time); + float newLerpFrame = bone.startFrame + (time * animSpeed); + + const int numFramesInAnim = bone.endFrame - bone.startFrame; + const float endFrame = (float)bone.endFrame; + // we are supposed to be animating right? - if (animSize) + if ( numFramesInAnim > 0 ) { // did we run off the end? - if (((animSpeed > 0.0f) && (newFrame_g > endFrame - 1)) || - ((animSpeed < 0.0f) && (newFrame_g < endFrame+1))) + if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || + (animSpeed < 0.0f && newLerpFrame < (endFrame + 1)) ) { // yep - decide what to do - if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) + if ( bone.flags & BONE_ANIM_OVERRIDE_LOOP ) { // get our new animation frame back within the bounds of the animation set - if (animSpeed < 0.0f) + if ( animSpeed < 0.0f ) { // we don't use this case, or so I am told // if we do, let me know, I need to insure the mod works // should we be creating a virtual frame? - if ((newFrame_g < endFrame+1) && (newFrame_g >= endFrame)) + if ( (newLerpFrame < (endFrame + 1)) && (newLerpFrame >= endFrame) ) { - // now figure out what we are lerping between - // delta is the fraction between this frame and the next, since the new anim is always at a .0f; - lerp = float(endFrame+1)-newFrame_g; + // now figure out what we are lerping between delta is + // the fraction between this frame and the next, since + // the new anim is always at a .0f; + lerp = endFrame + 1 - newLerpFrame; + // frames are easy to calculate currentFrame = endFrame; - assert(currentFrame>=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&&newFrame endFrame - 1) && (newFrame_g < endFrame)) + if ( (newLerpFrame > (endFrame - 1)) && (newLerpFrame < endFrame)) { - // now figure out what we are lerping between - // delta is the fraction between this frame and the next, since the new anim is always at a .0f; - lerp = (newFrame_g - (int)newFrame_g); + // now figure out what we are lerping between delta is + // the fraction between this frame and the next, since + // the new anim is always at a .0f; + lerp = newLerpFrame - (int)newLerpFrame; + // frames are easy to calculate - currentFrame = (int)newFrame_g; - assert(currentFrame>=0&¤tFrame=0&&newFrame= endFrame) + if ( newLerpFrame >= endFrame ) { - newFrame_g=endFrame+fmod(newFrame_g-endFrame,animSize)-animSize; + newLerpFrame = + endFrame + fmod(newLerpFrame - endFrame, numFramesInAnim) - + numFramesInAnim; } - // now figure out what we are lerping between - // delta is the fraction between this frame and the next, since the new anim is always at a .0f; - lerp = (newFrame_g - (int)newFrame_g); + + // now figure out what we are lerping between delta is + // the fraction between this frame and the next, since + // the new anim is always at a .0f; + lerp = newLerpFrame - (int)newLerpFrame; + // frames are easy to calculate - currentFrame = (int)newFrame_g; - assert(currentFrame>=0&¤tFrame= endFrame - 1) + if ( newLerpFrame >= (endFrame - 1) ) { newFrame = bone.startFrame; - assert(newFrame>=0&&newFrame=0&&newFrame= bone.startFrame)) || (animSize < 10)); } else { - if (((bone.flags & (BONE_ANIM_OVERRIDE_FREEZE)) == (BONE_ANIM_OVERRIDE_FREEZE))) + if ( ((bone.flags & BONE_ANIM_OVERRIDE_FREEZE) == BONE_ANIM_OVERRIDE_FREEZE) ) { // if we are supposed to reset the default anim, then do so - if (animSpeed > 0.0f) + if ( animSpeed > 0.0f ) { currentFrame = bone.endFrame - 1; - assert(currentFrame>=0&¤tFrame=0&¤tFrame=0&&newFrame 0.0) { // frames are easy to calculate - currentFrame = (int)newFrame_g; + currentFrame = (int)newLerpFrame; - // figure out the difference between the two frames - we have to decide what frame and what percentage of that - // frame we want to display - lerp = (newFrame_g - currentFrame); + // figure out the difference between the two frames - we have + // to decide what frame and what percentage of that frame we + // want to display + lerp = (newLerpFrame - currentFrame); assert(currentFrame>=0&¤tFrame= (int)endFrame) { - // we only want to lerp with the first frame of the anim if we are looping + // we only want to lerp with the first frame of the anim if + // we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; - assert(newFrame>=0&&newFrame=0&&newFrame=0&&newFramebone.startFrame) { currentFrame=bone.startFrame; newFrame = currentFrame; - lerp=0.0f; + lerp = 0.0f; } else { - newFrame=currentFrame-1; + newFrame = currentFrame-1; + // are we now on the end frame? if (newFrame < endFrame+1) { - // we only want to lerp with the first frame of the anim if we are looping + // we only want to lerp with the first frame of the + // anim if we are looping if (bone.flags & BONE_ANIM_OVERRIDE_LOOP) { newFrame = bone.startFrame; - assert(newFrame>=0&&newFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0&¤tFrame=0&&newFrame=0.0f&&lerp<=1.0f); + + assert(currentFrame >= 0 && currentFrame < numFramesInFile); + assert(newFrame >= 0 && newFrame < numFramesInFile); + assert(lerp >= 0.0f && lerp <= 1.0f); } #ifdef _RAG_PRINT_TEST @@ -1324,7 +1341,7 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat assert(ghoul2.animModel); offsets = (mdxaSkelOffsets_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + skel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); //find/add the bone in the list if (!skel->name[0]) @@ -1363,9 +1380,10 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat G2_RagGetAnimMatrix(ghoul2, parent, matrix, frame); //assign the new skel ptr for our parent - pskel = (mdxaSkel_t *)((byte *)ghoul2.mBoneCache->header + sizeof(mdxaHeader_t) + offsets->offsets[parent]); + pskel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[parent]); - //taking bone matrix for the skeleton frame and parent's animFrameMatrix into account, determine our final animFrameMatrix + //taking bone matrix for the skeleton frame and parent's + //animFrameMatrix into account, determine our final animFrameMatrix if (!pskel->name[0]) { parentBlistIndex = -1; @@ -1385,7 +1403,7 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat assert(pbone.hasAnimFrameMatrix == frame); //this should have been calc'd in the recursive call - Multiply_3x4Matrix(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); + Mat3x4_Multiply(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); #ifdef _RAG_PRINT_TEST if (parentBlistIndex != -1 && bListIndex != -1) @@ -1400,7 +1418,7 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat } else { //root - Multiply_3x4Matrix(&bone.animFrameMatrix, &ghoul2.mBoneCache->rootMatrix, &animMatrix); + Mat3x4_Multiply(&bone.animFrameMatrix, &ghoul2.mBoneCache->rootMatrix, &animMatrix); #ifdef _RAG_PRINT_TEST if (bListIndex != -1) { @@ -1431,45 +1449,43 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat matrix = bone.animFrameMatrix; } -void G2_TransformBone (int child,CBoneCache &BC) +static void G2_TransformBone( int child, CBoneCache& BC ) { - SBoneCalc &TB=BC.mBones[child]; - static mdxaBone_t tbone[6]; -// mdxaFrame_t *aFrame=0; -// mdxaFrame_t *bFrame=0; -// mdxaFrame_t *aoldFrame=0; -// mdxaFrame_t *boldFrame=0; - static mdxaSkel_t *skel; - static mdxaSkelOffsets_t *offsets; - boneInfo_v &boneList = *BC.rootBoneList; - static int j, boneListIndex; - int angleOverride = 0; + SBoneCalc &TB = BC.mBones[child]; + mdxaBone_t currentBone; + boneInfo_v& boneList = *BC.rootBoneList; + int angleOverride = 0; #if DEBUG_G2_TIMING bool printTiming=false; #endif // should this bone be overridden by a bone in the bone list? - boneListIndex = G2_Find_Bone_In_List(boneList, child); + int boneListIndex = G2_Find_Bone_In_List(boneList, child); if (boneListIndex != -1) { // we found a bone in the list - we need to override something here. + boneInfo_t& bone = boneList[boneListIndex]; + int boneFlags = bone.flags; // do we override the rotational angles? - if ((boneList[boneListIndex].flags) & (BONE_ANGLES_TOTAL)) + if ( boneFlags & BONE_ANGLES_TOTAL ) { - angleOverride = (boneList[boneListIndex].flags) & (BONE_ANGLES_TOTAL); + angleOverride = boneFlags & BONE_ANGLES_TOTAL; } // set blending stuff if we need to - if (boneList[boneListIndex].flags & BONE_ANIM_BLEND) + if ( boneFlags & BONE_ANIM_BLEND ) { - float blendTime = BC.incomingTime - boneList[boneListIndex].blendStart; - // only set up the blend anim if we actually have some blend time left on this bone anim - otherwise we might corrupt some blend higher up the hiearchy - if (blendTime>=0.0f&&blendTime < boneList[boneListIndex].blendTime) + const float blendTime = BC.incomingTime - bone.blendStart; + + // only set up the blend anim if we actually have some blend time + // left on this bone anim - otherwise we might corrupt some blend + // higher up the hiearchy + if ( blendTime >= 0.0f && blendTime < bone.blendTime ) { - TB.blendFrame = boneList[boneListIndex].blendFrame; - TB.blendOldFrame = boneList[boneListIndex].blendLerpFrame; - TB.blendLerp = (blendTime / boneList[boneListIndex].blendTime); + TB.blendFrame = bone.blendFrame; + TB.blendOldFrame = bone.blendLerpFrame; + TB.blendLerp = (blendTime / bone.blendTime); TB.blendMode = true; } else @@ -1477,78 +1493,99 @@ void G2_TransformBone (int child,CBoneCache &BC) TB.blendMode = false; } } - else if (/*r_Ghoul2NoBlend->integer||*/((boneList[boneListIndex].flags) & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE))) - // turn off blending if we are just doing a straing animation override + else if ( boneFlags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE) ) { + // turn off blending if we are just doing a straing animation + // override TB.blendMode = false; } - // should this animation be overridden by an animation in the bone list? - if ((boneList[boneListIndex].flags) & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) + // should this animation be overridden by an animation in the bone + // list? + if (boneFlags & (BONE_ANIM_OVERRIDE_LOOP | BONE_ANIM_OVERRIDE)) { - G2_TimingModel(boneList[boneListIndex],BC.incomingTime,BC.header->numFrames,TB.currentFrame,TB.newFrame,TB.backlerp); + G2_TimingModel( + bone, + BC.incomingTime, + BC.header->numFrames, + TB.currentFrame, + TB.newFrame, + TB.backlerp); } + #if DEBUG_G2_TIMING printTiming=true; #endif - /* - if ((r_Ghoul2NoLerp->integer)||((boneList[boneListIndex].flags) & (BONE_ANIM_NO_LERP))) - { - TB.backlerp = 0.0f; - } - */ - //rwwFIXMEFIXME: Use? } + // figure out where the location of the bone animation data is - assert(TB.newFrame>=0&&TB.newFramenumFrames); - if (!(TB.newFrame>=0&&TB.newFramenumFrames)) + if ( !(TB.newFrame >= 0 && TB.newFrame < BC.header->numFrames) ) { - TB.newFrame=0; + TB.newFrame = 0; } -// aFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.newFrame * BC.frameSize ); - assert(TB.currentFrame>=0&&TB.currentFramenumFrames); - if (!(TB.currentFrame>=0&&TB.currentFramenumFrames)) + + if ( !(TB.currentFrame >= 0 && TB.currentFrame < BC.header->numFrames) ) { - TB.currentFrame=0; + TB.currentFrame = 0; } -// aoldFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.currentFrame * BC.frameSize ); // figure out where the location of the blended animation data is - assert(!(TB.blendFrame < 0.0 || TB.blendFrame >= (BC.header->numFrames+1))); - if (TB.blendFrame < 0.0 || TB.blendFrame >= (BC.header->numFrames+1) ) + if ( TB.blendFrame < 0.0 || TB.blendFrame >= (BC.header->numFrames + 1) ) { - TB.blendFrame=0.0; + TB.blendFrame = 0.0; } -// bFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + (int)TB.blendFrame * BC.frameSize ); - assert(TB.blendOldFrame>=0&&TB.blendOldFramenumFrames); - if (!(TB.blendOldFrame>=0&&TB.blendOldFramenumFrames)) + + if ( !(TB.blendOldFrame >= 0 && TB.blendOldFrame < BC.header->numFrames) ) { - TB.blendOldFrame=0; + TB.blendOldFrame = 0; } + #if DEBUG_G2_TIMING #if DEBUG_G2_TIMING_RENDER_ONLY if (!HackadelicOnClient) { - printTiming=false; + printTiming = false; } #endif + if (printTiming) { char mess[1000]; if (TB.blendMode) { - sprintf(mess,"b %2d %5d %4d %4d %4d %4d %f %f\n",boneListIndex,BC.incomingTime,(int)TB.newFrame,(int)TB.currentFrame,(int)TB.blendFrame,(int)TB.blendOldFrame,TB.backlerp,TB.blendLerp); + sprintf( + mess, + "b %2d %5d %4d %4d %4d %4d %f %f\n", + boneListIndex, + BC.incomingTime, + (int)TB.newFrame, + (int)TB.currentFrame, + (int)TB.blendFrame, + (int)TB.blendOldFrame, + TB.backlerp, + TB.blendLerp); } else { - sprintf(mess,"a %2d %5d %4d %4d %f\n",boneListIndex,BC.incomingTime,TB.newFrame,TB.currentFrame,TB.backlerp); + sprintf( + mess, + "a %2d %5d %4d %4d %f\n", + boneListIndex, + BC.incomingTime, + TB.newFrame, + TB.currentFrame, + TB.backlerp); } + Com_OPrintf("%s",mess); + const boneInfo_t &bone=boneList[boneListIndex]; if (bone.flags&BONE_ANIM_BLEND) { - sprintf(mess," bfb[%2d] %5d %5d (%5d-%5d) %4.2f %4x bt(%5d-%5d) %7.2f %5d\n", + sprintf( + mess, + " bfb[%2d] %5d %5d (%5d-%5d) %4.2f %4x bt(%5d-%5d) %7.2f %5d\n", boneListIndex, BC.incomingTime, bone.startTime, @@ -1559,8 +1596,7 @@ void G2_TransformBone (int child,CBoneCache &BC) bone.blendStart, bone.blendStart+bone.blendTime, bone.blendFrame, - bone.blendLerpFrame - ); + bone.blendLerpFrame); } else { @@ -1571,126 +1607,79 @@ void G2_TransformBone (int child,CBoneCache &BC) bone.startFrame, bone.endFrame, bone.animSpeed, - bone.flags - ); + bone.flags); } -// Com_OPrintf("%s",mess); } #endif -// boldFrame = (mdxaFrame_t *)((byte *)BC.header + BC.header->ofsFrames + TB.blendOldFrame * BC.frameSize ); -// mdxaCompBone_t *compBonePointer = (mdxaCompBone_t *)((byte *)BC.header + BC.header->ofsCompBonePool); - - assert(child>=0&&childnumBones); -// assert(bFrame->boneIndexes[child]>=0); -// assert(boldFrame->boneIndexes[child]>=0); -// assert(aFrame->boneIndexes[child]>=0); -// assert(aoldFrame->boneIndexes[child]>=0); + assert(child >=0 && child < BC.header->numBones); // decide where the transformed bone is going - - // are we blending with another frame of anim? - if (TB.blendMode) - { - float backlerp = TB.blendFrame - (int)TB.blendFrame; - float frontlerp = 1.0 - backlerp; - -// MC_UnCompress(tbone[3].matrix,compBonePointer[bFrame->boneIndexes[child]].Comp); -// MC_UnCompress(tbone[4].matrix,compBonePointer[boldFrame->boneIndexes[child]].Comp); - UnCompressBone(tbone[3].matrix, child, BC.header, TB.blendFrame); - UnCompressBone(tbone[4].matrix, child, BC.header, TB.blendOldFrame); - - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&tbone[5])[j] = (backlerp * ((float *)&tbone[3])[j]) - + (frontlerp * ((float *)&tbone[4])[j]); - } - } - // - // lerp this bone - use the temp space on the ref entity to put the bone transforms into - // - if (!TB.backlerp) + // lerp this bone - use the temp space on the ref entity to put the bone + // transforms into + if ( !TB.backlerp ) { -// MC_UnCompress(tbone[2].matrix,compBonePointer[aoldFrame->boneIndexes[child]].Comp); - UnCompressBone(tbone[2].matrix, child, BC.header, TB.currentFrame); - - // blend in the other frame if we need to - if (TB.blendMode) - { - float blendFrontlerp = 1.0 - TB.blendLerp; - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&tbone[2])[j] = (TB.blendLerp * ((float *)&tbone[2])[j]) - + (blendFrontlerp * ((float *)&tbone[5])[j]); - } - } - - if (!child) - { - // now multiply by the root matrix, so we can offset this model should we need to - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &tbone[2]); - } + UnCompressBone(currentBone.matrix, child, BC.header, TB.currentFrame); } else { - float frontlerp = 1.0 - TB.backlerp; -// MC_UnCompress(tbone[0].matrix,compBonePointer[aFrame->boneIndexes[child]].Comp); -// MC_UnCompress(tbone[1].matrix,compBonePointer[aoldFrame->boneIndexes[child]].Comp); - UnCompressBone(tbone[0].matrix, child, BC.header, TB.newFrame); - UnCompressBone(tbone[1].matrix, child, BC.header, TB.currentFrame); + mdxaBone_t newFrameBone; + mdxaBone_t currentFrameBone; + UnCompressBone(newFrameBone.matrix, child, BC.header, TB.newFrame); + UnCompressBone(currentFrameBone.matrix, child, BC.header, TB.currentFrame); + Mat3x4_Lerp(¤tBone, &newFrameBone, ¤tFrameBone, TB.backlerp); + } - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&tbone[2])[j] = (TB.backlerp * ((float *)&tbone[0])[j]) - + (frontlerp * ((float *)&tbone[1])[j]); - } + // are we blending with another frame of anim? + // blend in the other frame if we need to + if ( TB.blendMode ) + { + mdxaBone_t blendFrameBone; + mdxaBone_t blendOldFrameBone; + UnCompressBone(blendFrameBone.matrix, child, BC.header, TB.blendFrame); + UnCompressBone(blendOldFrameBone.matrix, child, BC.header, TB.blendOldFrame); - // blend in the other frame if we need to - if (TB.blendMode) - { - float blendFrontlerp = 1.0 - TB.blendLerp; - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&tbone[2])[j] = (TB.blendLerp * ((float *)&tbone[2])[j]) - + (blendFrontlerp * ((float *)&tbone[5])[j]); - } - } + const float backlerp = TB.blendFrame - (int)TB.blendFrame; + mdxaBone_t lerpFrameBone; + Mat3x4_Lerp(&lerpFrameBone, &blendFrameBone, &blendOldFrameBone, backlerp); + Mat3x4_Lerp(¤tBone, ¤tBone, &lerpFrameBone, TB.blendLerp); + } - if (!child) - { - // now multiply by the root matrix, so we can offset this model should we need to - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &tbone[2]); - } + if ( !child ) + { + // now multiply by the root matrix, so we can offset this model + // should we need to + BC.mFinalBones[child].boneMatrix = BC.rootMatrix * currentBone; } + // figure out where the bone hirearchy info is - offsets = (mdxaSkelOffsets_t *)((byte *)BC.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)BC.header + sizeof(mdxaHeader_t) + offsets->offsets[child]); -// skel = BC.mSkels[child]; - //rww - removed mSkels - - int parent=BC.mFinalBones[child].parent; - assert((parent==-1&&child==0)||(parent>=0&&parent<(int)BC.mBones.size())); - if (angleOverride & BONE_ANGLES_REPLACE) - { - bool isRag=!!(angleOverride & BONE_ANGLES_RAGDOLL); - if (!isRag) - { //do the same for ik.. I suppose. - isRag = !!(angleOverride & BONE_ANGLES_IK); - } + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)BC.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[child]); + + int parent = BC.mFinalBones[child].parent; + assert((parent == -1 && child == 0) || (parent >= 0 && parent < (int)BC.mBones.size())); + + if ( angleOverride & BONE_ANGLES_REPLACE ) + { + const bool isRag = + ((angleOverride & (BONE_ANGLES_RAGDOLL | BONE_ANGLES_IK)) != 0); - mdxaBone_t &bone = BC.mFinalBones[child].boneMatrix; - boneInfo_t &boneOverride = boneList[boneListIndex]; + mdxaBone_t& bone = BC.mFinalBones[child].boneMatrix; + const boneInfo_t& boneOverride = boneList[boneListIndex]; + // give us the matrix the animation thinks we should have, so we + // can get the correct X&Y coors + const mdxaBone_t firstPass = BC.mFinalBones[parent].boneMatrix * currentBone; if (isRag) { - mdxaBone_t temp, firstPass; - // give us the matrix the animation thinks we should have, so we can get the correct X&Y coors - Multiply_3x4Matrix(&firstPass, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); - // this is crazy, we are gonna drive the animation to ID while we are doing post mults to compensate. - Multiply_3x4Matrix(&temp,&firstPass, &skel->BasePoseMat); - float matrixScale = VectorLength((float*)&temp); - static mdxaBone_t toMatrix = + // this is crazy, we are gonna drive the animation to ID while we + // are doing post mults to compensate. + mdxaBone_t temp = firstPass * skel->BasePoseMat; + const float matrixScale = VectorLength((float*)&temp); + mdxaBone_t toMatrix = { { { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -1698,53 +1687,40 @@ void G2_TransformBone (int child,CBoneCache &BC) { 0.0f, 0.0f, 1.0f, 0.0f } } }; - toMatrix.matrix[0][0]=matrixScale; - toMatrix.matrix[1][1]=matrixScale; - toMatrix.matrix[2][2]=matrixScale; - toMatrix.matrix[0][3]=temp.matrix[0][3]; - toMatrix.matrix[1][3]=temp.matrix[1][3]; - toMatrix.matrix[2][3]=temp.matrix[2][3]; - - Multiply_3x4Matrix(&temp, &toMatrix,&skel->BasePoseMatInv); //dest first arg - - float blendTime = BC.incomingTime - boneList[boneListIndex].boneBlendStart; - float blendLerp = (blendTime / boneList[boneListIndex].boneBlendTime); - if (blendLerp>0.0f) + toMatrix.matrix[0][0] = matrixScale; + toMatrix.matrix[1][1] = matrixScale; + toMatrix.matrix[2][2] = matrixScale; + toMatrix.matrix[0][3] = temp.matrix[0][3]; + toMatrix.matrix[1][3] = temp.matrix[1][3]; + toMatrix.matrix[2][3] = temp.matrix[2][3]; + + temp = toMatrix * skel->BasePoseMatInv; + + float blendTime = BC.incomingTime - boneOverride.boneBlendStart; + float blendLerp = (blendTime / boneOverride.boneBlendTime); + if (blendLerp > 0.0f) { // has started - if (blendLerp>1.0f) + if (blendLerp > 1.0f) { - // done -// Multiply_3x4Matrix(&bone, &BC.mFinalBones[parent].boneMatrix,&temp); - memcpy (&bone,&temp, sizeof(mdxaBone_t)); + bone = temp; } else { -// mdxaBone_t lerp; - // now do the blend into the destination - float blendFrontlerp = 1.0 - blendLerp; - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&bone)[j] = (blendLerp * ((float *)&temp)[j]) - + (blendFrontlerp * ((float *)&tbone[2])[j]); - } -// Multiply_3x4Matrix(&bone, &BC.mFinalBones[parent].boneMatrix,&lerp); + Mat3x4_Lerp(&bone, &temp, ¤tBone, blendLerp); } } } else { - mdxaBone_t temp, firstPass; - - // give us the matrix the animation thinks we should have, so we can get the correct X&Y coors - Multiply_3x4Matrix(&firstPass, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); - - // are we attempting to blend with the base animation? and still within blend time? - if (boneOverride.boneBlendTime && (((boneOverride.boneBlendTime + boneOverride.boneBlendStart) < BC.incomingTime))) + // are we attempting to blend with the base animation? and still + // within blend time? + if (boneOverride.boneBlendTime > 0.0f && + (((boneOverride.boneBlendStart + boneOverride.boneBlendTime) < BC.incomingTime))) { // ok, we are supposed to be blending. Work out lerp - float blendTime = BC.incomingTime - boneList[boneListIndex].boneBlendStart; - float blendLerp = (blendTime / boneList[boneListIndex].boneBlendTime); + const float blendTime = BC.incomingTime - boneOverride.boneBlendStart; + const float blendLerp = (blendTime / boneOverride.boneBlendTime); if (blendLerp <= 1) { @@ -1753,246 +1729,127 @@ void G2_TransformBone (int child,CBoneCache &BC) assert(0); } - // now work out the matrix we want to get *to* - firstPass is where we are coming *from* - Multiply_3x4Matrix(&temp, &firstPass, &skel->BasePoseMat); - - float matrixScale = VectorLength((float*)&temp); - - mdxaBone_t newMatrixTemp; - - if (HackadelicOnClient) - { - for (int i=0; i<3;i++) - { - for(int x=0;x<3; x++) - { - newMatrixTemp.matrix[i][x] = boneOverride.newMatrix.matrix[i][x]*matrixScale; - } - } + // now work out the matrix we want to get *to* - firstPass + // is where we are coming *from* + mdxaBone_t temp = firstPass * skel->BasePoseMat; + const float matrixScale = VectorLength((const float*)&temp); - newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; - newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; - newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; - } - else - { - for (int i=0; i<3;i++) - { - for(int x=0;x<3; x++) - { - newMatrixTemp.matrix[i][x] = boneOverride.matrix.matrix[i][x]*matrixScale; - } - } + const mdxaBone_t& m = + HackadelicOnClient ? boneOverride.newMatrix : boneOverride.matrix; - newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; - newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; - newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; - } - - Multiply_3x4Matrix(&temp, &newMatrixTemp,&skel->BasePoseMatInv); + mdxaBone_t newMatrixTemp; + Mat3x4_Scale(&newMatrixTemp, &m, matrixScale); + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; - // now do the blend into the destination - float blendFrontlerp = 1.0 - blendLerp; - for ( j = 0 ; j < 12 ; j++ ) - { - ((float *)&bone)[j] = (blendLerp * ((float *)&temp)[j]) - + (blendFrontlerp * ((float *)&firstPass)[j]); - } + temp = newMatrixTemp * skel->BasePoseMatInv; + Mat3x4_Lerp(&bone, &temp, &firstPass, blendLerp); } else { bone = firstPass; } } - // no, so just override it directly else { + // no, so just override it directly + const mdxaBone_t temp = firstPass * skel->BasePoseMat; + const float matrixScale = VectorLength((const float*)&temp); - Multiply_3x4Matrix(&temp,&firstPass, &skel->BasePoseMat); - float matrixScale = VectorLength((float*)&temp); + const mdxaBone_t& m = + HackadelicOnClient ? boneOverride.newMatrix : boneOverride.matrix; - mdxaBone_t newMatrixTemp; - - if (HackadelicOnClient) - { - for (int i=0; i<3;i++) - { - for(int x=0;x<3; x++) - { - newMatrixTemp.matrix[i][x] = boneOverride.newMatrix.matrix[i][x]*matrixScale; - } - } - - newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; - newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; - newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; - } - else - { - for (int i=0; i<3;i++) - { - for(int x=0;x<3; x++) - { - newMatrixTemp.matrix[i][x] = boneOverride.matrix.matrix[i][x]*matrixScale; - } - } - - newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; - newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; - newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; - } - - Multiply_3x4Matrix(&bone, &newMatrixTemp,&skel->BasePoseMatInv); + mdxaBone_t newMatrixTemp; + Mat3x4_Scale(&newMatrixTemp, &m, matrixScale); + newMatrixTemp.matrix[0][3] = temp.matrix[0][3]; + newMatrixTemp.matrix[1][3] = temp.matrix[1][3]; + newMatrixTemp.matrix[2][3] = temp.matrix[2][3]; + + bone = newMatrixTemp * skel->BasePoseMatInv; } } } else if (angleOverride & BONE_ANGLES_PREMULT) { - if ((angleOverride&BONE_ANGLES_RAGDOLL) || (angleOverride&BONE_ANGLES_IK)) - { - mdxaBone_t tmp; - if (!child) - { - if (HackadelicOnClient) - { - Multiply_3x4Matrix(&tmp, &BC.rootMatrix, &boneList[boneListIndex].newMatrix); - } - else - { - Multiply_3x4Matrix(&tmp, &BC.rootMatrix, &boneList[boneListIndex].matrix); - } - } - else - { - if (HackadelicOnClient) - { - Multiply_3x4Matrix(&tmp, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].newMatrix); - } - else - { - Multiply_3x4Matrix(&tmp, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].matrix); - } - } - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix,&tmp, &tbone[2]); - } - else + const mdxaBone_t& boneA = + child ? BC.mFinalBones[parent].boneMatrix : BC.rootMatrix; + + const mdxaBone_t& boneB = + HackadelicOnClient ? + boneList[boneListIndex].newMatrix : + boneList[boneListIndex].matrix; + + BC.mFinalBones[child].boneMatrix = boneA * boneB; + + if ((angleOverride & (BONE_ANGLES_RAGDOLL | BONE_ANGLES_IK)) == 0) { - if (!child) - { - // use the in coming root matrix as our basis - if (HackadelicOnClient) - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &boneList[boneListIndex].newMatrix); - } - else - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.rootMatrix, &boneList[boneListIndex].matrix); - } - } - else - { - // convert from 3x4 matrix to a 4x4 matrix - if (HackadelicOnClient) - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].newMatrix); - } - else - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &boneList[boneListIndex].matrix); - } - } + BC.mFinalBones[child].boneMatrix = + BC.mFinalBones[child].boneMatrix * currentBone; } } - else - // now transform the matrix by it's parent, asumming we have a parent, and we aren't overriding the angles absolutely - if (child) + else if (child) { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &BC.mFinalBones[parent].boneMatrix, &tbone[2]); + // now transform the matrix by it's parent, asumming we have a parent, and + // we aren't overriding the angles absolutely + BC.mFinalBones[child].boneMatrix = + BC.mFinalBones[parent].boneMatrix * currentBone; } // now multiply our resulting bone by an override matrix should we need to if (angleOverride & BONE_ANGLES_POSTMULT) { - mdxaBone_t tempMatrix; - memcpy (&tempMatrix,&BC.mFinalBones[child].boneMatrix, sizeof(mdxaBone_t)); - if (HackadelicOnClient) - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &tempMatrix, &boneList[boneListIndex].newMatrix); - } - else - { - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix, &tempMatrix, &boneList[boneListIndex].matrix); - } - } - /* - if (r_Ghoul2UnSqash->integer) - { - mdxaBone_t tempMatrix; - Multiply_3x4Matrix(&tempMatrix,&BC.mFinalBones[child].boneMatrix, &skel->BasePoseMat); - float maxl; - maxl=VectorLength(&skel->BasePoseMat.matrix[0][0]); - VectorNormalize(&tempMatrix.matrix[0][0]); - VectorNormalize(&tempMatrix.matrix[1][0]); - VectorNormalize(&tempMatrix.matrix[2][0]); + const mdxaBone_t& postMultMatrix = + HackadelicOnClient ? + boneList[boneListIndex].newMatrix : + boneList[boneListIndex].matrix; - VectorScale(&tempMatrix.matrix[0][0],maxl,&tempMatrix.matrix[0][0]); - VectorScale(&tempMatrix.matrix[1][0],maxl,&tempMatrix.matrix[1][0]); - VectorScale(&tempMatrix.matrix[2][0],maxl,&tempMatrix.matrix[2][0]); - Multiply_3x4Matrix(&BC.mFinalBones[child].boneMatrix,&tempMatrix,&skel->BasePoseMatInv); + BC.mFinalBones[child].boneMatrix = + BC.mFinalBones[child].boneMatrix * postMultMatrix; } - */ - //rwwFIXMEFIXME: Care? - } -void G2_SetUpBolts( mdxaHeader_t *header, CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, boltInfo_v &boltList) +void G2_SetUpBolts( + mdxaHeader_t *header, + CGhoul2Info &ghoul2, + mdxaBone_v &bonePtr, + boltInfo_v &boltList) { - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)header + sizeof(mdxaHeader_t)); - for (size_t i=0; ioffsets[boltList[i].boneNumber]); - Multiply_3x4Matrix(&boltList[i].position, &bonePtr[boltList[i].boneNumber].second, &skel->BasePoseMat); + continue; } + + // figure out where the bone hirearchy info is + mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boltList[i].boneNumber]); + boltList[i].position = bonePtr[boltList[i].boneNumber].second * skel->BasePoseMat; } } -//rww - RAGDOLL_BEGIN #define GHOUL2_RAG_STARTED 0x0010 -//rww - RAGDOLL_END //rwwFIXMEFIXME: Move this into the stupid header or something. -void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGhoul2Info &ghoul2, int time,bool smooth=true) +static void G2_TransformGhoulBones( + boneInfo_v &rootBoneList, + mdxaBone_t &rootMatrix, + CGhoul2Info &ghoul2, + int time, + bool smooth = true) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_G2_TransformGhoulBones.Start(); G2PerformanceCounter_G2_TransformGhoulBones++; #endif - /* - model_t *currentModel; - model_t *animModel; - mdxaHeader_t *aHeader; - - //currentModel = R_GetModelByHandle(RE_RegisterModel(ghoul2.mFileName)); - currentModel = R_GetModelByHandle(ghoul2.mModel); - assert(currentModel); - assert(currentModel->mdxm); - - animModel = R_GetModelByHandle(currentModel->mdxm->animIndex); - assert(animModel); - aHeader = animModel->mdxa; - assert(aHeader); - */ model_t *currentModel = (model_t *)ghoul2.currentModel; mdxaHeader_t *aHeader = (mdxaHeader_t *)ghoul2.aHeader; - assert(ghoul2.aHeader); assert(ghoul2.currentModel); assert(ghoul2.currentModel->data.glm && ghoul2.currentModel->data.glm->header); @@ -2020,34 +1877,11 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh if (HackadelicOnClient && smooth && !ri->Cvar_VariableIntegerValue( "dedicated" )) { ghoul2.mBoneCache->mLastTouch=ghoul2.mBoneCache->mLastLastTouch; - /* - float val=r_Ghoul2AnimSmooth->value; - if (smooth&&val>0.0f&&val<1.0f) - { - // if (HackadelicOnClient) - // { - ghoul2.mBoneCache->mLastTouch=ghoul2.mBoneCache->mLastLastTouch; - // } - - ghoul2.mBoneCache->mSmoothFactor=val; - ghoul2.mBoneCache->mSmoothingActive=true; - if (r_Ghoul2UnSqashAfterSmooth->integer) - { - ghoul2.mBoneCache->mUnsquash=true; - } - } - else - { - ghoul2.mBoneCache->mSmoothFactor=1.0f; - } - */ // master smoothing control float val=r_Ghoul2AnimSmooth->value; if (val>0.0f&&val<1.0f) { - //if (ghoul2.mFlags&GHOUL2_RESERVED_FOR_RAGDOLL) -#if 1 if(ghoul2.mFlags & GHOUL2_CRAZY_SMOOTH) { val = 0.9f; @@ -2063,7 +1897,7 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh bone.firstCollisionTime>time-250 && bone.firstCollisionTime time) { @@ -2077,9 +1911,7 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh } } } -#endif -// ghoul2.mBoneCache->mSmoothFactor=(val + 1.0f-pow(1.0f-val,50.0f/dif))/2.0f; // meaningless formula ghoul2.mBoneCache->mSmoothFactor=val; // meaningless formula ghoul2.mBoneCache->mSmoothingActive=true; @@ -2096,7 +1928,6 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh ghoul2.mBoneCache->mCurrentTouch++; -//rww - RAGDOLL_BEGIN if (HackadelicOnClient) { ghoul2.mBoneCache->mLastLastTouch=ghoul2.mBoneCache->mCurrentTouch; @@ -2106,9 +1937,8 @@ void G2_TransformGhoulBones(boneInfo_v &rootBoneList,mdxaBone_t &rootMatrix, CGh { ghoul2.mBoneCache->mCurrentTouchRender=0; } -//rww - RAGDOLL_END - ghoul2.mBoneCache->frameSize = 0;// can be deleted in new G2 format //(size_t)( &((mdxaFrame_t *)0)->boneIndexes[ ghoul2.aHeader->numBones ] ); + ghoul2.mBoneCache->frameSize = 0; ghoul2.mBoneCache->rootBoneList=&rootBoneList; ghoul2.mBoneCache->rootMatrix=rootMatrix; @@ -2341,29 +2171,41 @@ void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int bolt } -// now go through all the generated surfaces that aren't included in the model surface hierarchy and create the correct bolt info for them +// now go through all the generated surfaces that aren't included in the model +// surface hierarchy and create the correct bolt info for them void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, model_t *mod_t) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts.Start(); #endif + // look through the surfaces off the end of the pre-defined model surfaces - for (size_t i=0; i< ghoul2.mSlist.size(); i++) + for ( size_t i = 0, numSurfaces = ghoul2.mSlist.size(); i < numSurfaces; i++ ) { - // only look for bolts if we are actually a generated surface, and not just an overriden one + // only look for bolts if we are actually a generated surface, and not + // just an overriden one if (ghoul2.mSlist[i].offFlags & G2SURFACEFLAG_GENERATED) { - // well alrighty then. Lets see if there is a bolt that is attempting to use it - int boltNum = G2_Find_Bolt_Surface_Num(ghoul2.mBltlist, i, G2SURFACEFLAG_GENERATED); - // yes - ok, processing time. + // well alrighty then. Lets see if there is a bolt that is + // attempting to use it + int boltNum = G2_Find_Bolt_Surface_Num( + ghoul2.mBltlist, i, G2SURFACEFLAG_GENERATED); + if (boltNum != -1) { - G2_ProcessSurfaceBolt(bonePtr, NULL, boltNum, ghoul2.mBltlist, &ghoul2.mSlist[i], mod_t); + G2_ProcessSurfaceBolt( + bonePtr, + nullptr, + boltNum, + ghoul2.mBltlist, + &ghoul2.mSlist[i], mod_t); } } } + #ifdef G2_PERFORMANCE_ANALYSIS - G2Time_G2_ProcessGeneratedSurfaceBolts += G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts.End(); + G2Time_G2_ProcessGeneratedSurfaceBolts += + G2PerformanceTimer_G2_ProcessGeneratedSurfaceBolts.End(); #endif } @@ -2372,7 +2214,8 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_RenderSurfaces.Start(); #endif - int i; + + int i; const shader_t *shader = 0; int offFlags = 0; #ifdef _G2_GORE @@ -2684,75 +2527,93 @@ void G2_ConstructUsedBoneList(CConstructBoneList &CBL) } -// sort all the ghoul models in this list so if they go in reference order. This will ensure the bolt on's are attached to the right place -// on the previous model, since it ensures the model being attached to is built and rendered first. - -// NOTE!! This assumes at least one model will NOT have a parent. If it does - we are screwed -static void G2_Sort_Models(CGhoul2Info_v &ghoul2, int * const modelList, int * const modelCount) +// sort all the ghoul models in this list so if they go in reference order. +// This will ensure the bolt on's are attached to the right place on the +// previous model, since it ensures the model being attached to is built and +// rendered first. +// NOTE!! This assumes at least one model will NOT have a parent. If it does - +// we are screwed +static void G2_Sort_Models( + CGhoul2Info_v& ghoul2, + int *const modelList, + int modelListCapacity, + int *const modelCount ) { - int startPoint, endPoint; - int i, boltTo, j; - *modelCount = 0; - // first walk all the possible ghoul2 models, and stuff the out array with those with no parents - for (i=0; i> MODEL_SHIFT) & MODEL_AND; - // is it any of the models we just added to the list? - for (j=startPoint; j> MODEL_SHIFT) & MODEL_AND; + + // is it any of the models we just added to the list? + for ( int j = startPoint; j < endPoint; ++j ) + { + // is this my parent model? + if ( boltTo == modelList[j] ) { - // is this my parent model? - if (boltTo == modelList[j]) - { - // yes, insert into list and exit now - modelList[(*modelCount)++] = i; - break; - } + // yes, insert into list and exit now + modelList[(*modelCount)++] = i; + break; } } } + // update start and end points startPoint = endPoint; endPoint = *modelCount; @@ -3014,133 +2875,129 @@ void G2_ProcessSurfaceBolt2(CBoneCache &boneCache, const mdxmSurface_t *surface, retMatrix.matrix[2][1] = axes[0][2]; retMatrix.matrix[2][2] = -axes[2][2]; } - } -void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix) +void G2_GetBoltMatrixLow( + CGhoul2Info& ghoul2, + int boltNum, + const vec3_t scale, + mdxaBone_t& retMatrix) { - if (!ghoul2.mBoneCache) + if ( !ghoul2.mBoneCache ) { - retMatrix=identityMatrix; + retMatrix = identityMatrix; return; } - assert(ghoul2.mBoneCache); - CBoneCache &boneCache=*ghoul2.mBoneCache; + + CBoneCache& boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - boltInfo_v &boltList=ghoul2.mBltlist; - //Raz: This was causing a client crash when rendering a model with no valid g2 bolts, such as Ragnos =] - if ( boltList.size() < 1 ) { - retMatrix=identityMatrix; + boltInfo_v& boltList = ghoul2.mBltlist; + if ( boltList.empty() || boltNum >= boltList.size() ) + { + retMatrix = identityMatrix; return; } - assert(boltNum>=0&&boltNum<(int)boltList.size()); -#if 0 //rwwFIXMEFIXME: Disable this before release!!!!!! I am just trying to find a crash bug. - if (boltNum < 0 || boltNum >= boltList.size()) - { - char fName[MAX_QPATH]; - char mName[MAX_QPATH]; - int bLink = ghoul2.mModelBoltLink; + boltInfo_t& bolt = boltList[boltNum]; + int boltBone = bolt.boneNumber; + int boltSurface = bolt.surfaceNumber; - if (ghoul2.currentModel) - { - strcpy(mName, ghoul2.currentModel->name); - } - else - { - strcpy(mName, "NULL!"); - } - - if (ghoul2.mFileName && ghoul2.mFileName[0]) - { - strcpy(fName, ghoul2.mFileName); - } - else - { - strcpy(fName, "None?!"); - } - - Com_Error(ERR_DROP, "Write down or save this error message, show it to Rich\nBad bolt index on model %s (filename %s), index %i boltlink %i\n", mName, fName, boltNum, bLink); - } -#endif - if (boltList[boltNum].boneNumber>=0) + if ( boltBone >= 0 ) { - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boltList[boltNum].boneNumber]); - Multiply_3x4Matrix(&retMatrix, (mdxaBone_t *)&boneCache.EvalUnsmooth(boltList[boltNum].boneNumber), &skel->BasePoseMat); + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boltBone]); + + Mat3x4_Multiply( + &retMatrix, + (mdxaBone_t *)&boneCache.EvalUnsmooth(boltBone), + &skel->BasePoseMat); } - else if (boltList[boltNum].surfaceNumber>=0) + else if ( boltSurface >= 0 ) { - const surfaceInfo_t *surfInfo=0; + const surfaceInfo_t *surfInfo = nullptr; + for ( const surfaceInfo_t& t : ghoul2.mSlist ) { - for (size_t i=0;isurface<10000) + + if ( !surface && surfInfo && surfInfo->surface < 10000 ) { - surface = (mdxmSurface_t *)G2_FindSurface_BC(boneCache.mod,surfInfo->surface, 0); + surface = (mdxmSurface_t *)G2_FindSurface_BC( + boneCache.mod, surfInfo->surface, 0); } - G2_ProcessSurfaceBolt2(boneCache,surface,boltNum,boltList,surfInfo,(model_t *)boneCache.mod,retMatrix); + + G2_ProcessSurfaceBolt2( + boneCache, + surface, + boltNum, + boltList, + surfInfo, + (model_t *)boneCache.mod, + retMatrix); } else { - // we have a bolt without a bone or surface, not a huge problem but we ought to at least clear the bolt matrix - retMatrix=identityMatrix; + // we have a bolt without a bone or surface, not a huge problem but we + // ought to at least clear the bolt matrix + retMatrix = identityMatrix; } } -static void RootMatrix(CGhoul2Info_v &ghoul2,int time,const vec3_t scale,mdxaBone_t &retMatrix) +static void RootMatrix( + CGhoul2Info_v &ghoul2, + int time, + const vec3_t scale, + mdxaBone_t &retMatrix) { - int i; - for (i=0; ie.ghoul2); + + CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)ent->e.ghoul2); if ( !ghoul2.IsValid() ) { return; } - // if we don't want server ghoul2 models and this is one, or we just don't want ghoul2 models at all, then return + + // if we don't want server ghoul2 models and this is one, or we just don't + // want ghoul2 models at all, then return if (r_noServerGhoul2->integer) { return; } + if (!G2_SetupModelPointers(ghoul2)) { return; } - int currentTime=G2API_GetTime(tr.refdef.time); - + int currentTime = G2API_GetTime(tr.refdef.time); - // cull the entire model if merged bounding box of both frames - // is outside the view frustum. - cull = R_GCullModel (ent ); + // cull the entire model if merged bounding box of both frames is outside + // the view frustum. + int cull = R_GCullModel(ent); if ( cull == CULL_OUT ) { return; } - HackadelicOnClient=true; + + HackadelicOnClient = true; + // are any of these models setting a new origin? - RootMatrix(ghoul2,currentTime, ent->e.modelScale,rootMatrix); + mdxaBone_t rootMatrix; + RootMatrix(ghoul2, currentTime, ent->e.modelScale, rootMatrix); // don't add third_person objects if not in a portal - personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); + qboolean personalModel = (qboolean)( + (ent->e.renderfx & RF_THIRD_PERSON) && + !(tr.viewParms.isPortal || + (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); int modelList[256]; - assert(ghoul2.size()<=255); - modelList[255]=548; + assert(ghoul2.size() < ARRAY_LEN(modelList)); + modelList[255] = 548; // set up lighting now that we know we aren't culled - if ( !personalModel || r_shadows->integer > 1 ) { - R_SetupEntityLighting( &tr.refdef, ent ); + if ( !personalModel || r_shadows->integer > 1 ) + { + R_SetupEntityLighting(&tr.refdef, ent); } // see if we are in a fog volume - fogNum = R_GComputeFogNum( ent ); + int fogNum = R_GComputeFogNum(ent); // order sort the ghoul 2 models so bolt ons get bolted to the right model - G2_Sort_Models(ghoul2, modelList, &modelCount); - assert(modelList[255]==548); + int modelCount; + G2_Sort_Models(ghoul2, modelList, ARRAY_LEN(modelList), &modelCount); + assert(modelList[255] == 548); #ifdef _G2_GORE - if (goreShader == -1) + if ( goreShader == -1 ) { - goreShader=RE_RegisterShader("gfx/damage/burnmark1"); + goreShader = RE_RegisterShader("gfx/damage/burnmark1"); } #endif @@ -3225,98 +3082,109 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) { G2_GenerateWorldMatrix(ent->e.angles, ent->e.origin); // walk each possible model for this entity and try rendering it out - for (j=0; je.customShader) - { - cust_shader = R_GetShaderByHandle(ent->e.customShader ); - } - else + continue; + } + + if ( (g2Info.mFlags & (GHOUL2_NOMODEL | GHOUL2_NORENDER)) != 0 ) + { + continue; + } + + // figure out whether we should be using a custom shader for this model + skin_t *skin = nullptr; + shader_t *cust_shader = nullptr; + + if (ent->e.customShader) + { + cust_shader = R_GetShaderByHandle(ent->e.customShader ); + } + else + { + cust_shader = nullptr; + // figure out the custom skin thing + if (g2Info.mCustomSkin) { - cust_shader = NULL; - // figure out the custom skin thing - if (ghoul2[i].mCustomSkin) - { - skin = R_GetSkinByHandle(ghoul2[i].mCustomSkin ); - } - else if (ent->e.customSkin) - { - skin = R_GetSkinByHandle(ent->e.customSkin ); - } - else if ( ghoul2[i].mSkin > 0 && ghoul2[i].mSkin < tr.numSkins ) - { - skin = R_GetSkinByHandle( ghoul2[i].mSkin ); - } + skin = R_GetSkinByHandle(g2Info.mCustomSkin ); } - - if (j&&ghoul2[i].mModelBoltLink != -1) + else if (ent->e.customSkin) { - int boltMod = (ghoul2[i].mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; - int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; - mdxaBone_t bolt; - G2_GetBoltMatrixLow(ghoul2[boltMod],boltNum,ent->e.modelScale,bolt); - G2_TransformGhoulBones(ghoul2[i].mBlist,bolt, ghoul2[i],currentTime); + skin = R_GetSkinByHandle(ent->e.customSkin ); } - else + else if ( g2Info.mSkin > 0 && g2Info.mSkin < tr.numSkins ) { - G2_TransformGhoulBones(ghoul2[i].mBlist, rootMatrix, ghoul2[i],currentTime); + skin = R_GetSkinByHandle( g2Info.mSkin ); } - whichLod = G2_ComputeLOD( ent, ghoul2[i].currentModel, ghoul2[i].mLodBias ); - G2_FindOverrideSurface(-1,ghoul2[i].mSlist); //reset the quick surface override lookup; + } + + if ( j && g2Info.mModelBoltLink != -1 ) + { + int boltMod = (g2Info.mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; + int boltNum = (g2Info.mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + + mdxaBone_t bolt; + G2_GetBoltMatrixLow(ghoul2[boltMod], boltNum, ent->e.modelScale, bolt); + G2_TransformGhoulBones(g2Info.mBlist, bolt, g2Info, currentTime); + } + else + { + G2_TransformGhoulBones(g2Info.mBlist, rootMatrix, g2Info,currentTime); + } + + int whichLod = G2_ComputeLOD( ent, g2Info.currentModel, g2Info.mLodBias ); + G2_FindOverrideSurface(-1, g2Info.mSlist); //reset the quick surface override lookup; #ifdef _G2_GORE - CGoreSet *gore=0; - if (ghoul2[i].mGoreSetTag) + CGoreSet *gore = nullptr; + if ( g2Info.mGoreSetTag ) + { + gore = FindGoreSet(g2Info.mGoreSetTag); + if ( !gore ) // my gore is gone, so remove it { - gore=FindGoreSet(ghoul2[i].mGoreSetTag); - if (!gore) // my gore is gone, so remove it - { - ghoul2[i].mGoreSetTag=0; - } + g2Info.mGoreSetTag = 0; } + } - CRenderSurface RS (ghoul2[i].mSurfaceRoot, - ghoul2[i].mSlist, - cust_shader, - fogNum, - personalModel, - ghoul2[i].mBoneCache, - ent->e.renderfx, - skin, - (model_t *)ghoul2[i].currentModel, - whichLod, - ghoul2[i].mBltlist, - gore_shader, - gore); + CRenderSurface RS(g2Info.mSurfaceRoot, + g2Info.mSlist, + cust_shader, + fogNum, + personalModel, + g2Info.mBoneCache, + ent->e.renderfx, + skin, + (model_t *)g2Info.currentModel, + whichLod, + g2Info.mBltlist, + nullptr, + gore); #else - CRenderSurface RS(ghoul2[i].mSurfaceRoot, - ghoul2[i].mSlist, - cust_shader, - fogNum, - personalModel, - ghoul2[i].mBoneCache, - ent->e.renderfx, - skin, - (model_t *)ghoul2[i].currentModel, - whichLod, - ghoul2[i].mBltlist); + CRenderSurface RS(g2Info.mSurfaceRoot, + g2Info.mSlist, + cust_shader, + fogNum, + personalModel, + g2Info.mBoneCache, + ent->e.renderfx, + skin, + (model_t *)g2Info.currentModel, + whichLod, + g2Info.mBltlist); #endif - if (!personalModel && (RS.renderfx & RF_SHADOW_PLANE) && !bInShadowRange(ent->e.origin)) - { - RS.renderfx |= RF_NOSHADOW; - } - - RenderSurfaces(RS, ent, entityNum); + if ( !personalModel && (RS.renderfx & RF_SHADOW_PLANE) ) + { + RS.renderfx |= RF_NOSHADOW; } + + RenderSurfaces(RS, ent, entityNum); } - HackadelicOnClient=false; + + HackadelicOnClient = false; #ifdef G2_PERFORMANCE_ANALYSIS G2Time_R_AddGHOULSurfaces += G2PerformanceTimer_R_AddGHOULSurfaces.End(); @@ -3350,60 +3218,77 @@ bool G2_NeedsRecalc(CGhoul2Info *ghlInfo,int frameNum) /* ============== -G2_ConstructGhoulSkeleton - builds a complete skeleton for all ghoul models in a CGhoul2Info_v class - using LOD 0 +G2_ConstructGhoulSkeleton +builds a complete skeleton for all ghoul models in a CGhoul2Info_v class +using LOD 0 ============== */ -void G2_ConstructGhoulSkeleton( CGhoul2Info_v &ghoul2,const int frameNum,bool checkForNewOrigin,const vec3_t scale) +void G2_ConstructGhoulSkeleton( + CGhoul2Info_v &ghoul2, + const int frameNum, + bool checkForNewOrigin, + const vec3_t scale) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_G2_ConstructGhoulSkeleton.Start(); #endif - int i, j; - int modelCount; - mdxaBone_t rootMatrix; - + int modelCount; + mdxaBone_t rootMatrix; int modelList[256]; - assert(ghoul2.size()<=255); - modelList[255]=548; - if (checkForNewOrigin) + assert(ghoul2.size() <= ARRAY_LEN(modelList)); + modelList[255] = 548; + + if ( checkForNewOrigin ) { - RootMatrix(ghoul2,frameNum,scale,rootMatrix); + RootMatrix(ghoul2, frameNum, scale, rootMatrix); } else { rootMatrix = identityMatrix; } - G2_Sort_Models(ghoul2, modelList, &modelCount); - assert(modelList[255]==548); + G2_Sort_Models(ghoul2, modelList, ARRAY_LEN(modelList), &modelCount); + assert(modelList[255] == 548); - for (j=0; j> MODEL_SHIFT) & MODEL_AND; - int boltNum = (ghoul2[i].mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + continue; + } - mdxaBone_t bolt; - G2_GetBoltMatrixLow(ghoul2[boltMod],boltNum,scale,bolt); - G2_TransformGhoulBones(ghoul2[i].mBlist,bolt,ghoul2[i],frameNum,checkForNewOrigin); - } + if ( j && g2Info.mModelBoltLink != -1 ) + { + int boltMod = (g2Info.mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; + int boltNum = (g2Info.mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + + mdxaBone_t bolt; + G2_GetBoltMatrixLow(ghoul2[boltMod], boltNum, scale, bolt); + G2_TransformGhoulBones( + g2Info.mBlist, + bolt, + g2Info, + frameNum, + checkForNewOrigin); + } + else #ifdef _G2_LISTEN_SERVER_OPT - else if (ghoul2[i].entityNum == ENTITYNUM_NONE || ghoul2[i].mSkelFrameNum != frameNum) -#else - else + if (g2Info.entityNum == ENTITYNUM_NONE || g2Info.mSkelFrameNum != frameNum) #endif - { - G2_TransformGhoulBones(ghoul2[i].mBlist,rootMatrix,ghoul2[i],frameNum,checkForNewOrigin); - } + { + G2_TransformGhoulBones( + g2Info.mBlist, + rootMatrix, + g2Info, + frameNum, + checkForNewOrigin); } } + #ifdef G2_PERFORMANCE_ANALYSIS G2Time_G2_ConstructGhoulSkeleton += G2PerformanceTimer_G2_ConstructGhoulSkeleton.End(); #endif diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 72831d571f..8eb03b9e96 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3364,19 +3364,25 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); void RE_TakeVideoFrame( int width, int height, byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); -/* -Ghoul2 Insert Start -*/ // tr_ghoul2.cpp -void Multiply_3x4Matrix(mdxaBone_t *out, mdxaBone_t *in2, mdxaBone_t *in); -extern qboolean R_LoadMDXM (model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); -extern qboolean R_LoadMDXA (model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); -bool LoadTGAPalletteImage ( const char *name, byte **pic, int *width, int *height); -void RE_InsertModelIntoHash(const char *name, model_t *mod); +void Mat3x4_Multiply(mdxaBone_t *out, const mdxaBone_t *in2, const mdxaBone_t *in); +void Mat3x4_Scale( mdxaBone_t *result, const mdxaBone_t *lhs, const float scale ); +void Mat3x4_Lerp( + mdxaBone_t *result, + const mdxaBone_t *lhs, + const mdxaBone_t *rhs, + const float t ); +const mdxaBone_t operator +( const mdxaBone_t& lhs, const mdxaBone_t& rhs ); +const mdxaBone_t operator -( const mdxaBone_t& lhs, const mdxaBone_t& rhs ); +const mdxaBone_t operator *( const mdxaBone_t& lhs, const mdxaBone_t& rhs ); +const mdxaBone_t operator *( const mdxaBone_t& lhs, const float scale ); +const mdxaBone_t operator *( const float scale, const mdxaBone_t& rhs ); + +qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); +qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); +bool LoadTGAPalletteImage( const char *name, byte **pic, int *width, int *height); +void RE_InsertModelIntoHash( const char *name, model_t *mod ); void ResetGhoul2RenderableSurfaceHeap(); -/* -Ghoul2 Insert End -*/ void R_InitDecals( void ); void RE_ClearDecals( void ); From 235ed47ccf51511cf781f5f9ab02191e749825a9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 Dec 2016 19:28:47 +0000 Subject: [PATCH 398/708] Rend2: Some more ghoul2 code tidying --- codemp/rd-rend2/G2_API.cpp | 30 ++++- codemp/rd-rend2/G2_bones.cpp | 49 +++++-- codemp/rd-rend2/tr_ghoul2.cpp | 241 +++++++++++++++------------------- 3 files changed, 165 insertions(+), 155 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 7abcf050bf..23bde192d1 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1447,14 +1447,21 @@ qboolean G2API_StopBoneAnim(CGhoul2Info *ghlInfo, const char *boneName) return qfalse; } -qboolean G2API_SetBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index, const vec3_t angles, const int flags, - const Eorientations yaw, const Eorientations pitch, const Eorientations roll, - qhandle_t *modelList, int blendTime, int currentTime) +qboolean G2API_SetBoneAnglesIndex( + CGhoul2Info *ghlInfo, + const int index, + const vec3_t angles, + const int flags, + const Eorientations yaw, + const Eorientations pitch, + const Eorientations roll, + qhandle_t *modelList, + int blendTime, + int currentTime) { qboolean setPtrs = qfalse; qboolean res = qfalse; - //rww - RAGDOLL_BEGIN if (ghlInfo) { res = G2_SetupModelPointers(ghlInfo); @@ -1468,7 +1475,6 @@ qboolean G2API_SetBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index, const v } } } - //rww - RAGDOLL_END if (!setPtrs) { @@ -1479,8 +1485,20 @@ qboolean G2API_SetBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index, const v { // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Set_Bone_Angles_Index( ghlInfo->mBlist, index, angles, flags, yaw, pitch, roll, modelList, ghlInfo->mModelindex, blendTime, currentTime); + return G2_Set_Bone_Angles_Index( + ghlInfo->mBlist, + index, + angles, + flags, + yaw, + pitch, + roll, + modelList, + ghlInfo->mModelindex, + blendTime, + currentTime); } + return qfalse; } diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index 83257cc5d2..a2805fe845 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -428,16 +428,24 @@ qboolean G2_Remove_Bone (CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *bo #define DEBUG_PCJ (0) -// Given a model handle, and a bone name, we want to set angles specifically for overriding -qboolean G2_Set_Bone_Angles_Index( boneInfo_v &blist, const int index, - const float *angles, const int flags, const Eorientations yaw, - const Eorientations pitch, const Eorientations roll, qhandle_t *modelList, - const int modelIndex, const int blendTime, const int currentTime) +// Given a model handle, and a bone name, we want to set angles specifically +// for overriding +qboolean G2_Set_Bone_Angles_Index( + boneInfo_v &blist, + const int index, + const float *angles, + const int flags, + const Eorientations yaw, + const Eorientations pitch, + const Eorientations roll, + qhandle_t *modelList, + const int modelIndex, + const int blendTime, + const int currentTime) { - if ((index >= (int)blist.size()) || (blist[index].boneNumber == -1)) + if ( index >= (int)blist.size() || blist[index].boneNumber == -1 ) { // we are attempting to set a bone override that doesn't exist - assert(0); return qfalse; } @@ -445,29 +453,42 @@ qboolean G2_Set_Bone_Angles_Index( boneInfo_v &blist, const int index, { if (blist[index].flags & BONE_ANGLES_RAGDOLL) { - return qtrue; // don't accept any calls on ragdoll bones + // don't accept any calls on ragdoll bones + return qtrue; } } if (flags & (BONE_ANGLES_PREMULT | BONE_ANGLES_POSTMULT)) { - // you CANNOT call this with an index with these kinds of bone overrides - we need the model details for these kinds of bone angle overrides - assert(0); + // you CANNOT call this with an index with these kinds of bone + // overrides - we need the model details for these kinds of bone angle + // overrides return qfalse; } // yes, so set the angles and flags correctly - blist[index].flags &= ~(BONE_ANGLES_TOTAL); + blist[index].flags &= ~BONE_ANGLES_TOTAL; blist[index].flags |= flags; blist[index].boneBlendStart = currentTime; blist[index].boneBlendTime = blendTime; + #if DEBUG_PCJ - Com_OPrintf("PCJ %2d %6d (%6.2f,%6.2f,%6.2f) %d %d %d %d\n",index,currentTime,angles[0],angles[1],angles[2],yaw,pitch,roll,flags); + Com_OPrintf( + "PCJ %2d %6d (%6.2f,%6.2f,%6.2f) %d %d %d %d\n", + index, + currentTime, + angles[0], + angles[1], + angles[2], + yaw, + pitch, + roll, + flags); #endif - G2_Generate_Matrix(NULL, blist, index, angles, flags, yaw, pitch, roll); - return qtrue; + G2_Generate_Matrix(nullptr, blist, index, angles, flags, yaw, pitch, roll); + return qtrue; } // Given a model handle, and a bone name, we want to set angles specifically for overriding diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a7a85b0923..2e02982a1a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2649,123 +2649,92 @@ void *G2_FindSurface_BC(const model_s *mod, int index, int lod) return (void *)current; } -//#define G2EVALRENDER - // We've come across a surface that's designated as a bolt surface, process it and put it in the appropriate bolt place -void G2_ProcessSurfaceBolt2(CBoneCache &boneCache, const mdxmSurface_t *surface, int boltNum, boltInfo_v &boltList, const surfaceInfo_t *surfInfo, const model_t *mod,mdxaBone_t &retMatrix) +void G2_ProcessSurfaceBolt2( + CBoneCache &boneCache, + const mdxmSurface_t *surface, + int boltNum, + boltInfo_v &boltList, + const surfaceInfo_t *surfInfo, + const model_t *mod, + mdxaBone_t &retMatrix) { - mdxmVertex_t *v, *vert0, *vert1, *vert2; - vec3_t axes[3], sides[3]; - float pTri[3][3], d; - int j, k; + float pTri[3][3]; - // now there are two types of tag surface - model ones and procedural generated types - lets decide which one we have here. + // now there are two types of tag surface - model ones and procedural + // generated types - lets decide which one we have here. if (surfInfo && surfInfo->offFlags == G2SURFACEFLAG_GENERATED) { - int surfNumber = surfInfo->genPolySurfaceIndex & 0x0ffff; - int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; + const int surfNumber = surfInfo->genPolySurfaceIndex & 0x0ffff; + const int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; // find original surface our original poly was in. - mdxmSurface_t *originalSurf = (mdxmSurface_t *)G2_FindSurface_BC(mod, surfNumber, surfInfo->genLod); - mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); + const mdxmSurface_t *originalSurf = + (mdxmSurface_t *)G2_FindSurface_BC(mod, surfNumber, surfInfo->genLod); + const mdxmTriangle_t *originalTriangleIndexes = + (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); // get the original polys indexes - int index0 = originalTriangleIndexes[polyNumber].indexes[0]; - int index1 = originalTriangleIndexes[polyNumber].indexes[1]; - int index2 = originalTriangleIndexes[polyNumber].indexes[2]; + const int index0 = originalTriangleIndexes[polyNumber].indexes[0]; + const int index1 = originalTriangleIndexes[polyNumber].indexes[1]; + const int index2 = originalTriangleIndexes[polyNumber].indexes[2]; // decide where the original verts are - vert0 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert0+=index0; - - vert1 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert1+=index1; - - vert2 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert2+=index2; + const mdxmVertex_t *surfVerts = + (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); + const mdxmVertex_t *verts[3] = { + surfVerts + index0, + surfVerts + index1, + surfVerts + index2 + }; // clear out the triangle verts to be - VectorClear( pTri[0] ); - VectorClear( pTri[1] ); - VectorClear( pTri[2] ); - int *piBoneReferences = (int*) ((byte*)originalSurf + originalSurf->ofsBoneReferences); - -// mdxmWeight_t *w; - - // now go and transform just the points we need from the surface that was hit originally -// w = vert0->weights; - float fTotalWeight = 0.0f; - int iNumWeights = G2_GetVertWeights( vert0 ); - for ( k = 0 ; k < iNumWeights ; k++ ) - { - int iBoneIndex = G2_GetVertBoneIndex( vert0, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert0, k, fTotalWeight, iNumWeights ); - -#ifdef G2EVALRENDER - const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); -#else - const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); -#endif + VectorClear(pTri[0]); + VectorClear(pTri[1]); + VectorClear(pTri[2]); + const int *piBoneReferences = + (int *)((byte*)originalSurf + originalSurf->ofsBoneReferences); - pTri[0][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert0->vertCoords ) + bone.matrix[0][3] ); - pTri[0][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert0->vertCoords ) + bone.matrix[1][3] ); - pTri[0][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert0->vertCoords ) + bone.matrix[2][3] ); - } - -// w = vert1->weights; - fTotalWeight = 0.0f; - iNumWeights = G2_GetVertWeights( vert1 ); - for ( k = 0 ; k < iNumWeights ; k++) - { - int iBoneIndex = G2_GetVertBoneIndex( vert1, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert1, k, fTotalWeight, iNumWeights ); - -#ifdef G2EVALRENDER - const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); -#else - const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); -#endif - - pTri[1][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert1->vertCoords ) + bone.matrix[0][3] ); - pTri[1][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert1->vertCoords ) + bone.matrix[1][3] ); - pTri[1][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert1->vertCoords ) + bone.matrix[2][3] ); + for ( int i = 0; i < 3; ++i ) + { + // now go and transform just the points we need from the surface that + // was hit originally + const int iNumWeights = G2_GetVertWeights(verts[i]); + float fTotalWeight = 0.0f; + for ( int k = 0 ; k < iNumWeights ; k++ ) + { + const int iBoneIndex = G2_GetVertBoneIndex(verts[i], k); + const float fBoneWeight = G2_GetVertBoneWeight( + verts[i], k, fTotalWeight, iNumWeights); + const mdxaBone_t &bone = boneCache.Eval(piBoneReferences[iBoneIndex]); + + pTri[i][0] += fBoneWeight * + (DotProduct(bone.matrix[0], verts[i]->vertCoords) + bone.matrix[0][3]); + pTri[i][1] += fBoneWeight * + (DotProduct(bone.matrix[1], verts[i]->vertCoords) + bone.matrix[1][3]); + pTri[i][2] += fBoneWeight * + (DotProduct(bone.matrix[2], verts[i]->vertCoords) + bone.matrix[2][3]); + } } -// w = vert2->weights; - fTotalWeight = 0.0f; - iNumWeights = G2_GetVertWeights( vert2 ); - for ( k = 0 ; k < iNumWeights ; k++) - { - int iBoneIndex = G2_GetVertBoneIndex( vert2, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert2, k, fTotalWeight, iNumWeights ); - -#ifdef G2EVALRENDER - const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); -#else - const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); -#endif - - pTri[2][0] += fBoneWeight * ( DotProduct( bone.matrix[0], vert2->vertCoords ) + bone.matrix[0][3] ); - pTri[2][1] += fBoneWeight * ( DotProduct( bone.matrix[1], vert2->vertCoords ) + bone.matrix[1][3] ); - pTri[2][2] += fBoneWeight * ( DotProduct( bone.matrix[2], vert2->vertCoords ) + bone.matrix[2][3] ); - } - - vec3_t normal; - vec3_t up; - vec3_t right; - vec3_t vec0, vec1; - // work out baryCentricK - float baryCentricK = 1.0 - (surfInfo->genBarycentricI + surfInfo->genBarycentricJ); + const float baryCentricK = + 1.0f - (surfInfo->genBarycentricI + surfInfo->genBarycentricJ); // now we have the model transformed into model space, now generate an origin. - retMatrix.matrix[0][3] = (pTri[0][0] * surfInfo->genBarycentricI) + (pTri[1][0] * surfInfo->genBarycentricJ) + (pTri[2][0] * baryCentricK); - retMatrix.matrix[1][3] = (pTri[0][1] * surfInfo->genBarycentricI) + (pTri[1][1] * surfInfo->genBarycentricJ) + (pTri[2][1] * baryCentricK); - retMatrix.matrix[2][3] = (pTri[0][2] * surfInfo->genBarycentricI) + (pTri[1][2] * surfInfo->genBarycentricJ) + (pTri[2][2] * baryCentricK); + for ( int i = 0; i < 3; ++i ) + { + retMatrix.matrix[i][3] = + (pTri[0][i] * surfInfo->genBarycentricI) + + (pTri[1][i] * surfInfo->genBarycentricJ) + + (pTri[2][i] * baryCentricK); + } // generate a normal to this new triangle + vec3_t vec0, vec1; VectorSubtract(pTri[0], pTri[1], vec0); VectorSubtract(pTri[2], pTri[1], vec1); + vec3_t normal; CrossProduct(vec0, vec1, normal); VectorNormalize(normal); @@ -2776,6 +2745,7 @@ void G2_ProcessSurfaceBolt2(CBoneCache &boneCache, const mdxmSurface_t *surface, // up will be towards point 0 of the original triangle. // so lets work it out. Vector is hit point - point 0 + vec3_t up; up[0] = retMatrix.matrix[0][3] - pTri[0][0]; up[1] = retMatrix.matrix[1][3] - pTri[0][1]; up[2] = retMatrix.matrix[2][3] - pTri[0][2]; @@ -2789,80 +2759,81 @@ void G2_ProcessSurfaceBolt2(CBoneCache &boneCache, const mdxmSurface_t *surface, retMatrix.matrix[2][1] = up[2]; // right is always straight - + vec3_t right; CrossProduct( normal, up, right ); + // that's the up vector retMatrix.matrix[0][2] = right[0]; retMatrix.matrix[1][2] = right[1]; retMatrix.matrix[2][2] = right[2]; - } // no, we are looking at a normal model tag else { // whip through and actually transform each vertex - v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); - int *piBoneReferences = (int*) ((byte*)surface + surface->ofsBoneReferences); - for ( j = 0; j < 3; j++ ) + const mdxmVertex_t *v = + (const mdxmVertex_t *)((byte *)surface + surface->ofsVerts); + const int *piBoneReferences = + (const int*)((byte *)surface + surface->ofsBoneReferences); + for ( int j = 0; j < 3; j++ ) { -// mdxmWeight_t *w; - - VectorClear( pTri[j] ); - // w = v->weights; + VectorClear(pTri[j]); const int iNumWeights = G2_GetVertWeights( v ); - float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++) + for ( int k = 0 ; k < iNumWeights ; k++) { - int iBoneIndex = G2_GetVertBoneIndex( v, k ); - float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); - -#ifdef G2EVALRENDER - const mdxaBone_t &bone=boneCache.EvalRender(piBoneReferences[iBoneIndex]); -#else - const mdxaBone_t &bone=boneCache.Eval(piBoneReferences[iBoneIndex]); -#endif - - pTri[j][0] += fBoneWeight * ( DotProduct( bone.matrix[0], v->vertCoords ) + bone.matrix[0][3] ); - pTri[j][1] += fBoneWeight * ( DotProduct( bone.matrix[1], v->vertCoords ) + bone.matrix[1][3] ); - pTri[j][2] += fBoneWeight * ( DotProduct( bone.matrix[2], v->vertCoords ) + bone.matrix[2][3] ); + const int iBoneIndex = G2_GetVertBoneIndex(v, k); + const float fBoneWeight = + G2_GetVertBoneWeight(v, k, fTotalWeight, iNumWeights); + const mdxaBone_t &bone = boneCache.Eval(piBoneReferences[iBoneIndex]); + + pTri[j][0] += fBoneWeight * + (DotProduct(bone.matrix[0], v->vertCoords) + bone.matrix[0][3]); + pTri[j][1] += fBoneWeight * + (DotProduct(bone.matrix[1], v->vertCoords) + bone.matrix[1][3]); + pTri[j][2] += fBoneWeight * + (DotProduct(bone.matrix[2], v->vertCoords) + bone.matrix[2][3]); } - v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; + v++; } // clear out used arrays - memset( axes, 0, sizeof( axes ) ); - memset( sides, 0, sizeof( sides ) ); + vec3_t axes[3] = {}; + vec3_t sides[3] = {}; // work out actual sides of the tag triangle - for ( j = 0; j < 3; j++ ) + for ( int j = 0; j < 3; j++ ) { - sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0]; - sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1]; - sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2]; + sides[j][0] = pTri[(j + 1) % 3][0] - pTri[j][0]; + sides[j][1] = pTri[(j + 1) % 3][1] - pTri[j][1]; + sides[j][2] = pTri[(j + 1) % 3][2] - pTri[j][2]; } - // do math trig to work out what the matrix will be from this triangle's translated position - VectorNormalize2( sides[iG2_TRISIDE_LONGEST], axes[0] ); - VectorNormalize2( sides[iG2_TRISIDE_SHORTEST], axes[1] ); + // do math trig to work out what the matrix will be from this + // triangle's translated position + VectorNormalize2(sides[iG2_TRISIDE_LONGEST], axes[0]); + VectorNormalize2(sides[iG2_TRISIDE_SHORTEST], axes[1]); - // project shortest side so that it is exactly 90 degrees to the longer side - d = DotProduct( axes[0], axes[1] ); - VectorMA( axes[0], -d, axes[1], axes[0] ); - VectorNormalize2( axes[0], axes[0] ); + // project shortest side so that it is exactly 90 degrees to the longer + // side + float d = DotProduct(axes[0], axes[1]); + VectorMA(axes[0], -d, axes[1], axes[0]); + VectorNormalize2(axes[0], axes[0]); - CrossProduct( sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2] ); - VectorNormalize2( axes[2], axes[2] ); + CrossProduct(sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2]); + VectorNormalize2(axes[2], axes[2]); - // set up location in world space of the origin point in out going matrix + // set up location in world space of the origin point in out going + // matrix retMatrix.matrix[0][3] = pTri[MDX_TAG_ORIGIN][0]; retMatrix.matrix[1][3] = pTri[MDX_TAG_ORIGIN][1]; retMatrix.matrix[2][3] = pTri[MDX_TAG_ORIGIN][2]; - // copy axis to matrix - do some magic to orient minus Y to positive X and so on so bolt on stuff is oriented correctly + // copy axis to matrix - do some magic to orient minus Y to positive X + // and so on so bolt on stuff is oriented correctly retMatrix.matrix[0][0] = axes[1][0]; retMatrix.matrix[0][1] = axes[0][0]; retMatrix.matrix[0][2] = -axes[2][0]; From a82830a6594d97802ddfd49281efe51698d4f2f1 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 24 Dec 2016 21:29:57 +0000 Subject: [PATCH 399/708] Rend2: Tiny bit more code tidying --- codemp/rd-rend2/tr_backend.cpp | 14 ++-- codemp/rd-rend2/tr_ghoul2.cpp | 120 +++++++++++++++++++-------------- codemp/rd-rend2/tr_local.h | 16 ++--- codemp/rd-rend2/tr_main.cpp | 24 +++++-- 4 files changed, 100 insertions(+), 74 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 9e36d4efb7..736c5e81f3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1116,8 +1116,6 @@ static void RB_SubmitDrawSurfsForDepthFill( continue; } - oldSort = drawSurf->sort; - // change the tess parameters if needed // a "entityMergable" shader is a shader that can have surfaces from // seperate entities merged into a single batch, like smoke and blood @@ -1125,15 +1123,15 @@ static void RB_SubmitDrawSurfsForDepthFill( if ( shader != oldShader || (entityNum != oldEntityNum && !shader->entityMergable) ) { - if ( oldShader != nullptr ) + if ( shader->sort != SS_OPAQUE ) { - RB_EndSurface(); + // Don't draw yet, let's see what's to come + continue; } - if ( shader->sort != SS_OPAQUE ) + if ( oldShader != nullptr ) { - oldShader = nullptr; - continue; + RB_EndSurface(); } RB_BeginSurface(shader, 0, 0); @@ -1141,6 +1139,8 @@ static void RB_SubmitDrawSurfsForDepthFill( oldShader = shader; } + oldSort = drawSurf->sort; + // change the modelview matrix if needed if ( entityNum != oldEntityNum ) { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 2e02982a1a..c4c192be89 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2273,94 +2273,110 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) - { // set the surface info to point at the where the transformed bone list is going to be for when the surface gets rendered out + { + // set the surface info to point at the where the transformed bone + // list is going to be for when the surface gets rendered out CRenderableSurface *newSurf = AllocGhoul2RenderableSurface(); newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; assert (newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; - R_AddDrawSurf ((surfaceType_t *)newSurf, entityNum, (shader_t *)shader, RS.fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex); + R_AddDrawSurf( + (surfaceType_t *)newSurf, + entityNum, + (shader_t *)shader, + RS.fogNum, + qfalse, + R_IsPostRenderEntity(ent), + cubemapIndex); #ifdef _G2_GORE - if (RS.gore_set && drawGore) + if ( RS.gore_set && drawGore ) { int curTime = G2API_GetTime(tr.refdef.time); - std::pair::iterator,std::multimap::iterator> range= - RS.gore_set->mGoreRecords.equal_range(RS.surfaceNum); - std::multimap::iterator k,kcur; - CRenderableSurface *last=newSurf; - for (k=range.first;k!=range.second;) + + auto range = RS.gore_set->mGoreRecords.equal_range(RS.surfaceNum); + CRenderableSurface *last = newSurf; + for ( auto k = range.first; k != range.second; /* blank */ ) { - kcur=k; + auto kcur = k; k++; - GoreTextureCoordinates *tex=FindGoreRecord((*kcur).second.mGoreTag); - if (!tex || // it is gone, lets get rid of it - (kcur->second.mDeleteTime && curTime>=kcur->second.mDeleteTime)) // out of time - { - if (tex) - { - (*tex).~GoreTextureCoordinates(); - //I don't know what's going on here, it should call the destructor for - //this when it erases the record but sometimes it doesn't. -rww - } + GoreTextureCoordinates *tex = FindGoreRecord(kcur->second.mGoreTag); + if (!tex || // it is gone, lets get rid of it + (kcur->second.mDeleteTime && + curTime >= kcur->second.mDeleteTime)) // out of time + { RS.gore_set->mGoreRecords.erase(kcur); } else if (tex->tex[RS.lod]) { CRenderableSurface *newSurf2 = AllocGhoul2RenderableSurface(); - *newSurf2=*newSurf; - newSurf2->goreChain=0; - newSurf2->alternateTex=tex->tex[RS.lod]; - newSurf2->scale=1.0f; - newSurf2->fade=1.0f; - newSurf2->impactTime=1.0f; // done with - int magicFactor42=500; // ms, impact time - if (curTime>(*kcur).second.mGoreGrowStartTime && curTime<(*kcur).second.mGoreGrowStartTime+magicFactor42) + *newSurf2 = *newSurf; + newSurf2->goreChain = 0; + newSurf2->alternateTex = tex->tex[RS.lod]; + newSurf2->scale = 1.0f; + newSurf2->fade = 1.0f; + newSurf2->impactTime = 1.0f; // done with + int magicFactor42 = 500; // ms, impact time + if (curTime > kcur->second.mGoreGrowStartTime && + curTime < (kcur->second.mGoreGrowStartTime + magicFactor42) ) { - newSurf2->impactTime=float(curTime-(*kcur).second.mGoreGrowStartTime)/float(magicFactor42); // linear + newSurf2->impactTime = + float(curTime - kcur->second.mGoreGrowStartTime) / + float(magicFactor42); // linear } - if (curTime<(*kcur).second.mGoreGrowEndTime) + + if (curTime < kcur->second.mGoreGrowEndTime) { - newSurf2->scale=1.0f/((curTime-(*kcur).second.mGoreGrowStartTime)*(*kcur).second.mGoreGrowFactor + (*kcur).second.mGoreGrowOffset); - if (newSurf2->scale<1.0f) - { - newSurf2->scale=1.0f; - } + newSurf2->scale = Q_max( + 1.0f, + 1.0f / + ((curTime - kcur->second.mGoreGrowStartTime) * + kcur->second.mGoreGrowFactor + + kcur->second.mGoreGrowOffset)); } + shader_t *gshader; - if ((*kcur).second.shader) + if (kcur->second.shader) { - gshader=R_GetShaderByHandle((*kcur).second.shader); + gshader = R_GetShaderByHandle(kcur->second.shader); } else { - gshader=R_GetShaderByHandle(goreShader); + gshader = R_GetShaderByHandle(goreShader); } // Set fade on surf. - //Only if we have a fade time set, and let us fade on rgb if we want -rww - if ((*kcur).second.mDeleteTime && (*kcur).second.mFadeTime) + // Only if we have a fade time set, and let us fade on + // rgb if we want -rww + if (kcur->second.mDeleteTime && kcur->second.mFadeTime) { - if ((*kcur).second.mDeleteTime - curTime < (*kcur).second.mFadeTime) + if ( (kcur->second.mDeleteTime - curTime) < kcur->second.mFadeTime ) { - newSurf2->fade=(float)((*kcur).second.mDeleteTime - curTime)/(*kcur).second.mFadeTime; - if ((*kcur).second.mFadeRGB) - { //RGB fades are scaled from 2.0f to 3.0f (simply to differentiate) - newSurf2->fade += 2.0f; - - if (newSurf2->fade < 2.01f) - { - newSurf2->fade = 2.01f; - } + newSurf2->fade = + (float)(kcur->second.mDeleteTime - curTime) / + kcur->second.mFadeTime; + if (kcur->second.mFadeRGB) + { + // RGB fades are scaled from 2.0f to 3.0f + // (simply to differentiate) + newSurf2->fade = Q_max(2.01f, newSurf2->fade + 2.0f); } } } - last->goreChain=newSurf2; - last=newSurf2; - R_AddDrawSurf ((surfaceType_t *)newSurf2, entityNum, gshader, RS.fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex); + last->goreChain = newSurf2; + last = newSurf2; + R_AddDrawSurf( + (surfaceType_t *)newSurf2, + entityNum, + gshader, + RS.fogNum, + qfalse, + R_IsPostRenderEntity(ent), + cubemapIndex); } } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8eb03b9e96..7ee538bbbf 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3068,17 +3068,17 @@ class CRenderableSurface } #endif -CRenderableSurface(): - ident(SF_MDX), - boneCache(0), + CRenderableSurface(): + ident(SF_MDX), + boneCache(0), #ifdef _G2_GORE - surfaceData(0), - alternateTex(0), - goreChain(0) + surfaceData(0), + alternateTex(0), + goreChain(0) #else - surfaceData(0) + surfaceData(0) #endif - {} + {} #ifdef _G2_GORE void Init() diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 3d913217be..e7f2877025 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1933,13 +1933,14 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int R_AddGhoulSurfaces(ent, entityNum); break; case MOD_BAD: // null model axis - if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal) { + if ( (ent->e.renderfx & RF_THIRD_PERSON) && !tr.viewParms.isPortal ) { break; } - if( ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2)) ) + if ( ent->e.ghoul2 && + G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2)) ) { - R_AddGhoulSurfaces( ent, entityNum ); + R_AddGhoulSurfaces(ent, entityNum); break; } @@ -1959,9 +1960,16 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int } break; case RT_ENT_CHAIN: - shader = R_GetShaderByHandle( ent->e.customShader ); - R_AddDrawSurf( &entitySurface, entityNum, shader, R_SpriteFogNum( ent ), false, R_IsPostRenderEntity(ent), 0 /* cubeMap */ ); - break; + shader = R_GetShaderByHandle(ent->e.customShader); + R_AddDrawSurf( + &entitySurface, + entityNum, + shader, + R_SpriteFogNum(ent), + false, + R_IsPostRenderEntity(ent), + 0 /* cubeMap */ ); + break; default: ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); } @@ -2516,7 +2524,9 @@ void R_RenderPshadowMaps(const refdef_t *fd) R_AddEntitySurface(&tr.refdef, ent, entityNum); } - R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); } } } From 1f874cf4a429d66ebd926b91f50fa972652da0f5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 25 Dec 2016 12:40:26 +0000 Subject: [PATCH 400/708] Rend2: More code tidying --- codemp/rd-rend2/G2_API.cpp | 607 +++++++++++++-------- codemp/rd-rend2/tr_ghoul2.cpp | 986 ++++++++++++++++++---------------- codemp/rd-rend2/tr_local.h | 71 +-- 3 files changed, 953 insertions(+), 711 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 23bde192d1..34397ec321 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -1502,17 +1502,26 @@ qboolean G2API_SetBoneAnglesIndex( return qfalse; } -qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName, const vec3_t angles, const int flags, - const Eorientations up, const Eorientations left, const Eorientations forward, - qhandle_t *modelList, int blendTime, int currentTime ) +qboolean G2API_SetBoneAngles( + CGhoul2Info_v &ghoul2, + const int modelIndex, + const char *boneName, + const vec3_t angles, + const int flags, + const Eorientations up, + const Eorientations left, + const Eorientations forward, + qhandle_t *modelList, + int blendTime, + int currentTime) { - if (ghoul2.size()>modelIndex) + if (ghoul2.size() > modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; qboolean setPtrs = qfalse; qboolean res = qfalse; - //rww - RAGDOLL_BEGIN + // rww - RAGDOLL_BEGIN if (ghlInfo) { res = G2_SetupModelPointers(ghlInfo); @@ -1526,7 +1535,7 @@ qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const } } } - //rww - RAGDOLL_END + // rww - RAGDOLL_END if (!setPtrs) { @@ -1535,34 +1544,75 @@ qboolean G2API_SetBoneAngles(CGhoul2Info_v &ghoul2, const int modelIndex, const if (res) { - // ensure we flush the cache + // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Set_Bone_Angles(ghlInfo, ghlInfo->mBlist, boneName, angles, flags, up, left, forward, modelList, ghlInfo->mModelindex, blendTime, currentTime); + return G2_Set_Bone_Angles( + ghlInfo, + ghlInfo->mBlist, + boneName, + angles, + flags, + up, + left, + forward, + modelList, + ghlInfo->mModelindex, + blendTime, + currentTime); } } return qfalse; } -qboolean G2API_SetBoneAnglesMatrixIndex(CGhoul2Info *ghlInfo, const int index, const mdxaBone_t &matrix, - const int flags, qhandle_t *modelList, int blendTime, int currentTime) +qboolean G2API_SetBoneAnglesMatrixIndex( + CGhoul2Info *ghlInfo, + const int index, + const mdxaBone_t &matrix, + const int flags, + qhandle_t *modelList, + int blendTime, + int currentTime) { if (G2_SetupModelPointers(ghlInfo)) { // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Set_Bone_Angles_Matrix_Index(ghlInfo->mBlist, index, matrix, flags, modelList, ghlInfo->mModelindex, blendTime, currentTime); + return G2_Set_Bone_Angles_Matrix_Index( + ghlInfo->mBlist, + index, + matrix, + flags, + modelList, + ghlInfo->mModelindex, + blendTime, + currentTime); } return qfalse; } -qboolean G2API_SetBoneAnglesMatrix(CGhoul2Info *ghlInfo, const char *boneName, const mdxaBone_t &matrix, - const int flags, qhandle_t *modelList, int blendTime, int currentTime) +qboolean G2API_SetBoneAnglesMatrix( + CGhoul2Info *ghlInfo, + const char *boneName, + const mdxaBone_t &matrix, + const int flags, + qhandle_t *modelList, + int blendTime, + int currentTime) { if (G2_SetupModelPointers(ghlInfo)) { // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Set_Bone_Angles_Matrix(ghlInfo->mFileName, ghlInfo->mBlist, boneName, matrix, flags, modelList, ghlInfo->mModelindex, blendTime, currentTime); + return G2_Set_Bone_Angles_Matrix( + ghlInfo->mFileName, + ghlInfo->mBlist, + boneName, + matrix, + flags, + modelList, + ghlInfo->mModelindex, + blendTime, + currentTime); } return qfalse; } @@ -1573,7 +1623,7 @@ qboolean G2API_StopBoneAnglesIndex(CGhoul2Info *ghlInfo, const int index) { // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Stop_Bone_Angles_Index(ghlInfo->mBlist, index); + return G2_Stop_Bone_Angles_Index(ghlInfo->mBlist, index); } return qfalse; } @@ -1584,12 +1634,12 @@ qboolean G2API_StopBoneAngles(CGhoul2Info *ghlInfo, const char *boneName) { // ensure we flush the cache ghlInfo->mSkelFrameNum = 0; - return G2_Stop_Bone_Angles(ghlInfo->mFileName, ghlInfo->mBlist, boneName); + return G2_Stop_Bone_Angles( + ghlInfo->mFileName, ghlInfo->mBlist, boneName); } return qfalse; } - void G2API_AbsurdSmoothing(CGhoul2Info_v &ghoul2, qboolean status) { assert(ghoul2.size()); @@ -1640,10 +1690,11 @@ extern int ragSSCount; extern int ragTraceCount; #endif -void G2API_AnimateG2ModelsRag(CGhoul2Info_v &ghoul2, int AcurrentTime,CRagDollUpdateParams *params) +void G2API_AnimateG2ModelsRag( + CGhoul2Info_v &ghoul2, int AcurrentTime, CRagDollUpdateParams *params) { int model; - int currentTime=G2API_GetTime(AcurrentTime); + int currentTime = G2API_GetTime(AcurrentTime); #ifdef _DEBUG ragTraceTime = 0; @@ -1656,56 +1707,47 @@ void G2API_AnimateG2ModelsRag(CGhoul2Info_v &ghoul2, int AcurrentTime,CRagDollUp { if (ghoul2[model].mModel) { - G2_Animate_Bone_List(ghoul2,currentTime,model,params); + G2_Animate_Bone_List(ghoul2, currentTime, model, params); } } -#ifdef _DEBUG - /* - if (ragTraceTime) - { - Com_Printf("Rag trace time: %i (%i STARTSOLID, %i TOTAL)\n", ragTraceTime, ragSSCount, ragTraceCount); - } - */ - - //keep sane limits here, if it gets too slow an assert is proper. -// assert(ragTraceTime < 150); -// assert(ragTraceCount < 1500); -#endif } -//rww - RAGDOLL_END +// rww - RAGDOLL_END -int G2_Find_Bone_Rag(CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName); +int G2_Find_Bone_Rag( + CGhoul2Info *ghlInfo, boneInfo_v &blist, const char *boneName); #define RAG_PCJ (0x00001) #define RAG_EFFECTOR (0x00100) -static inline boneInfo_t *G2_GetRagBoneConveniently(CGhoul2Info_v &ghoul2, const char *boneName) +static boneInfo_t * +G2_GetRagBoneConveniently(CGhoul2Info_v &ghoul2, const char *boneName) { assert(ghoul2.size()); CGhoul2Info *ghlInfo = &ghoul2[0]; if (!(ghlInfo->mFlags & GHOUL2_RAG_STARTED)) - { //can't do this if not in ragdoll + { // can't do this if not in ragdoll return NULL; } int boneIndex = G2_Find_Bone_Rag(ghlInfo, ghlInfo->mBlist, boneName); if (boneIndex < 0) - { //bad bone specification + { // bad bone specification return NULL; } boneInfo_t *bone = &ghlInfo->mBlist[boneIndex]; if (!(bone->flags & BONE_ANGLES_RAGDOLL)) - { //only want to return rag bones + { // only want to return rag bones return NULL; } return bone; } -qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max) +qboolean G2API_RagPCJConstraint( + CGhoul2Info_v &ghoul2, const char *boneName, vec3_t min, vec3_t max) { boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); @@ -1715,7 +1757,7 @@ qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec } if (!(bone->RagFlags & RAG_PCJ)) - { //this function is only for PCJ bones + { // this function is only for PCJ bones return qfalse; } @@ -1725,7 +1767,8 @@ qboolean G2API_RagPCJConstraint(CGhoul2Info_v &ghoul2, const char *boneName, vec return qtrue; } -qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, const float speed) +qboolean G2API_RagPCJGradientSpeed( + CGhoul2Info_v &ghoul2, const char *boneName, const float speed) { boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); @@ -1735,7 +1778,7 @@ qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, } if (!(bone->RagFlags & RAG_PCJ)) - { //this function is only for PCJ bones + { // this function is only for PCJ bones return qfalse; } @@ -1744,7 +1787,8 @@ qboolean G2API_RagPCJGradientSpeed(CGhoul2Info_v &ghoul2, const char *boneName, return qtrue; } -qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos) +qboolean +G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos) { boneInfo_t *bone = G2_GetRagBoneConveniently(ghoul2, boneName); @@ -1754,12 +1798,12 @@ qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3 } if (!(bone->RagFlags & RAG_EFFECTOR)) - { //this function is only for effectors + { // this function is only for effectors return qfalse; } if (!pos) - { //go back to none in case we have one then + { // go back to none in case we have one then bone->hasOverGoal = false; } else @@ -1770,7 +1814,13 @@ qboolean G2API_RagEffectorGoal(CGhoul2Info_v &ghoul2, const char *boneName, vec3 return qtrue; } -qboolean G2API_GetRagBonePos(CGhoul2Info_v &ghoul2, const char *boneName, vec3_t pos, vec3_t entAngles, vec3_t entPos, vec3_t entScale) +qboolean G2API_GetRagBonePos( + CGhoul2Info_v &ghoul2, + const char *boneName, + vec3_t pos, + vec3_t entAngles, + vec3_t entPos, + vec3_t entScale) { //do something? return qfalse; } @@ -1818,14 +1868,30 @@ qboolean G2API_RagForceSolve(CGhoul2Info_v &ghoul2, qboolean force) return qtrue; } -qboolean G2_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params); -qboolean G2API_SetBoneIKState(CGhoul2Info_v &ghoul2, int time, const char *boneName, int ikState, sharedSetBoneIKStateParams_t *params) +qboolean G2_SetBoneIKState( + CGhoul2Info_v &ghoul2, + int time, + const char *boneName, + int ikState, + sharedSetBoneIKStateParams_t *params); +qboolean G2API_SetBoneIKState( + CGhoul2Info_v &ghoul2, + int time, + const char *boneName, + int ikState, + sharedSetBoneIKStateParams_t *params) { return G2_SetBoneIKState(ghoul2, time, boneName, ikState, params); } -qboolean G2_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params); -qboolean G2API_IKMove(CGhoul2Info_v &ghoul2, int time, sharedIKMoveParams_t *params) +qboolean G2_IKMove( + CGhoul2Info_v &ghoul2, + int time, + sharedIKMoveParams_t *params); +qboolean G2API_IKMove( + CGhoul2Info_v &ghoul2, + int time, + sharedIKMoveParams_t *params) { return G2_IKMove(ghoul2, time, params); } @@ -1834,21 +1900,23 @@ qboolean G2API_RemoveBolt(CGhoul2Info *ghlInfo, const int index) { if (G2_SetupModelPointers(ghlInfo)) { - return G2_Remove_Bolt( ghlInfo->mBltlist, index); + return G2_Remove_Bolt(ghlInfo->mBltlist, index); } return qfalse; } -int G2API_AddBolt(CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName) +int G2API_AddBolt( + CGhoul2Info_v &ghoul2, const int modelIndex, const char *boneName) { -// assert(ghoul2.size()>modelIndex); + // assert(ghoul2.size()>modelIndex); - if (ghoul2.size()>modelIndex) + if (ghoul2.size() > modelIndex) { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; if (G2_SetupModelPointers(ghlInfo)) { - return G2_Add_Bolt(ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, boneName); + return G2_Add_Bolt( + ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, boneName); } } return -1; @@ -1858,31 +1926,39 @@ int G2API_AddBoltSurfNum(CGhoul2Info *ghlInfo, const int surfIndex) { if (G2_SetupModelPointers(ghlInfo)) { - return G2_Add_Bolt_Surf_Num(ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, surfIndex); + return G2_Add_Bolt_Surf_Num( + ghlInfo, ghlInfo->mBltlist, ghlInfo->mSlist, surfIndex); } return -1; } - -qboolean G2API_AttachG2Model(CGhoul2Info_v &ghoul2From, int modelFrom, CGhoul2Info_v &ghoul2To, int toBoltIndex, int toModel) +qboolean G2API_AttachG2Model( + CGhoul2Info_v &ghoul2From, + int modelFrom, + CGhoul2Info_v &ghoul2To, + int toBoltIndex, + int toModel) { - assert( toBoltIndex >= 0 ); - if ( toBoltIndex < 0 ) + assert(toBoltIndex >= 0); + if (toBoltIndex < 0) { return qfalse; } - if (G2_SetupModelPointers(ghoul2From)&&G2_SetupModelPointers(ghoul2To)) + + if (G2_SetupModelPointers(ghoul2From) && G2_SetupModelPointers(ghoul2To)) { - // make sure we have a model to attach, a model to attach to, and a bolt on that model - if ((ghoul2From.size() > modelFrom) && - (ghoul2To.size() > toModel) && - ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) + // make sure we have a model to attach, a model to attach to, and a + // bolt on that model + if ((ghoul2From.size() > modelFrom) && (ghoul2To.size() > toModel) && + ((ghoul2To[toModel].mBltlist[toBoltIndex].boneNumber != -1) || + (ghoul2To[toModel].mBltlist[toBoltIndex].surfaceNumber != -1))) { // encode the bolt address into the model bolt link - toModel &= MODEL_AND; - toBoltIndex &= BOLT_AND; - ghoul2From[modelFrom].mModelBoltLink = (toModel << MODEL_SHIFT) | (toBoltIndex << BOLT_SHIFT); - return qtrue; + toModel &= MODEL_AND; + toBoltIndex &= BOLT_AND; + ghoul2From[modelFrom].mModelBoltLink = + (toModel << MODEL_SHIFT) | (toBoltIndex << BOLT_SHIFT); + return qtrue; } } return qfalse; @@ -1906,32 +1982,50 @@ qboolean G2API_DetachG2Model(CGhoul2Info *ghlInfo) return qfalse; } -qboolean G2API_AttachEnt(int *boltInfo, CGhoul2Info_v& ghoul2, int modelIndex, int toBoltIndex, int entNum, int toModelNum) -{ +qboolean G2API_AttachEnt( + int *boltInfo, + CGhoul2Info_v &ghoul2, + int modelIndex, + int toBoltIndex, + int entNum, + int toModelNum) +{ CGhoul2Info *ghlInfoTo = &ghoul2[modelIndex]; if (boltInfo && G2_SetupModelPointers(ghlInfoTo)) { - // make sure we have a model to attach, a model to attach to, and a bolt on that model - if ( ghlInfoTo->mBltlist.size() && ((ghlInfoTo->mBltlist[toBoltIndex].boneNumber != -1) || (ghlInfoTo->mBltlist[toBoltIndex].surfaceNumber != -1))) + // make sure we have a model to attach, a model to attach to, and a + // bolt on that model + if (ghlInfoTo->mBltlist.size() && + ((ghlInfoTo->mBltlist[toBoltIndex].boneNumber != -1) || + (ghlInfoTo->mBltlist[toBoltIndex].surfaceNumber != -1))) { // encode the bolt address into the model bolt link - toModelNum &= MODEL_AND; - toBoltIndex &= BOLT_AND; - entNum &= ENTITY_AND; - *boltInfo = (toBoltIndex << BOLT_SHIFT) | (toModelNum << MODEL_SHIFT) | (entNum << ENTITY_SHIFT); - return qtrue; + toModelNum &= MODEL_AND; + toBoltIndex &= BOLT_AND; + entNum &= ENTITY_AND; + *boltInfo = (toBoltIndex << BOLT_SHIFT) | + (toModelNum << MODEL_SHIFT) | + (entNum << ENTITY_SHIFT); + return qtrue; } } return qfalse; - } qboolean gG2_GBMNoReconstruct; qboolean gG2_GBMUseSPMethod; -qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, - const vec3_t position, const int frameNum, qhandle_t *modelList, const vec3_t scale ) +qboolean G2API_GetBoltMatrix_SPMethod( + CGhoul2Info_v &ghoul2, + const int modelIndex, + const int boltIndex, + mdxaBone_t *matrix, + const vec3_t angles, + const vec3_t position, + const int frameNum, + qhandle_t *modelList, + const vec3_t scale) { assert(ghoul2.size() > modelIndex); @@ -1939,9 +2033,9 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde { CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; - //assert(boltIndex < ghlInfo->mBltlist.size()); - - if (ghlInfo && (boltIndex < (int)ghlInfo->mBltlist.size()) && boltIndex >= 0 ) + if (ghlInfo && + (boltIndex < (int)ghlInfo->mBltlist.size()) && + boltIndex >= 0) { // make sure we have transformed the skeleton if (!gG2_GBMNoReconstruct) @@ -1953,14 +2047,15 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde mdxaBone_t scaled; mdxaBone_t *use; - use=&ghlInfo->mBltlist[boltIndex].position; + use = &ghlInfo->mBltlist[boltIndex].position; - if (scale[0]||scale[1]||scale[2]) + if (scale[0] || scale[1] || scale[2]) { - scaled=*use; - use=&scaled; + scaled = *use; + use = &scaled; - // scale the bolt position by the scale factor for this model since at this point its still in model space + // scale the bolt position by the scale factor for this model + // since at this point its still in model space if (scale[0]) { scaled.matrix[0][3] *= scale[0]; @@ -1974,12 +2069,13 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde scaled.matrix[2][3] *= scale[2]; } } + // pre generate the world matrix G2_GenerateWorldMatrix(angles, position); - VectorNormalize((float*)use->matrix[0]); - VectorNormalize((float*)use->matrix[1]); - VectorNormalize((float*)use->matrix[2]); + VectorNormalize((float *)use->matrix[0]); + VectorNormalize((float *)use->matrix[1]); + VectorNormalize((float *)use->matrix[2]); Mat3x4_Multiply(matrix, &worldMatrix, use); return qtrue; @@ -1988,97 +2084,130 @@ qboolean G2API_GetBoltMatrix_SPMethod(CGhoul2Info_v &ghoul2, const int modelInde return qfalse; } -#define G2ERROR(exp,m) ((void)0) //rwwFIXMEFIXME: This is because I'm lazy. -#define G2WARNING(exp,m) ((void)0) -#define G2NOTE(exp,m) ((void)0) -#define G2ANIM(ghlInfo,m) ((void)0) -bool G2_NeedsRecalc(CGhoul2Info *ghlInfo,int frameNum); -void G2_GetBoltMatrixLow(CGhoul2Info &ghoul2,int boltNum,const vec3_t scale,mdxaBone_t &retMatrix); -void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv); - -//qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, -// const vec3_t position, const int AframeNum, qhandle_t *modelList, const vec3_t scale ) -qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const int boltIndex, mdxaBone_t *matrix, const vec3_t angles, - const vec3_t position, const int frameNum, qhandle_t *modelList, vec3_t scale ) +#define G2ERROR(exp, m) ((void)0) // rwwFIXMEFIXME: This is because I'm lazy. +#define G2WARNING(exp, m) ((void)0) +#define G2NOTE(exp, m) ((void)0) +#define G2ANIM(ghlInfo, m) ((void)0) +bool G2_NeedsRecalc(CGhoul2Info *ghlInfo, int frameNum); +void G2_GetBoltMatrixLow( + CGhoul2Info &ghoul2, + int boltNum, + const vec3_t scale, + mdxaBone_t &retMatrix); +void G2_GetBoneMatrixLow( + CGhoul2Info &ghoul2, + int boneNum, + const vec3_t scale, + mdxaBone_t &retMatrix, + mdxaBone_t *&retBasepose, + mdxaBone_t *&retBaseposeInv); + +qboolean G2API_GetBoltMatrix( + CGhoul2Info_v &ghoul2, + const int modelIndex, + const int boltIndex, + mdxaBone_t *matrix, + const vec3_t angles, + const vec3_t position, + const int frameNum, + qhandle_t *modelList, + vec3_t scale) { -// G2ERROR(ghoul2.IsValid(),"Invalid ghlInfo"); - G2ERROR(matrix,"NULL matrix"); - G2ERROR(modelIndex>=0&&modelIndex= 0 && modelIndex < ghoul2.size(), + "Invalid ModelIndex"); + const static mdxaBone_t identityMatrix = { { - { 0.0f, -1.0f, 0.0f, 0.0f }, - { 1.0f, 0.0f, 0.0f, 0.0f }, - { 0.0f, 0.0f, 1.0f, 0.0f } + {0.0f, -1.0f, 0.0f, 0.0f}, + {1.0f, 0.0f, 0.0f, 0.0f}, + {0.0f, 0.0f, 1.0f, 0.0f} } }; + G2_GenerateWorldMatrix(angles, position); if (G2_SetupModelPointers(ghoul2)) { - if (matrix&&modelIndex>=0&&modelIndex= 0 && modelIndex < ghoul2.size()) { - int tframeNum=G2API_GetTime(frameNum); + int tframeNum = G2API_GetTime(frameNum); CGhoul2Info *ghlInfo = &ghoul2[modelIndex]; - G2ERROR(boltIndex >= 0 && (boltIndex < ghlInfo->mBltlist.size()),va("Invalid Bolt Index (%d:%s)",boltIndex,ghlInfo->mFileName)); - - if (boltIndex >= 0 && ghlInfo && (boltIndex < (int)ghlInfo->mBltlist.size()) ) + G2ERROR + (boltIndex >= 0 && (boltIndex < ghlInfo->mBltlist.size()), + va("Invalid Bolt Index (%d:%s)", + boltIndex, + ghlInfo->mFileName)); + + if (boltIndex >= 0 && ghlInfo && + (boltIndex < (int)ghlInfo->mBltlist.size())) { mdxaBone_t bolt; - if (G2_NeedsRecalc(ghlInfo,tframeNum)) + if (G2_NeedsRecalc(ghlInfo, tframeNum)) { - G2_ConstructGhoulSkeleton(ghoul2,tframeNum,true,scale); + G2_ConstructGhoulSkeleton(ghoul2, tframeNum, true, scale); } - G2_GetBoltMatrixLow(*ghlInfo,boltIndex,scale,bolt); - // scale the bolt position by the scale factor for this model since at this point its still in model space + G2_GetBoltMatrixLow(*ghlInfo, boltIndex, scale, bolt); + + // scale the bolt position by the scale factor for this model + // since at this point its still in model space if (scale[0]) { bolt.matrix[0][3] *= scale[0]; } + if (scale[1]) { bolt.matrix[1][3] *= scale[1]; } + if (scale[2]) { bolt.matrix[2][3] *= scale[2]; } - VectorNormalize((float*)&bolt.matrix[0]); - VectorNormalize((float*)&bolt.matrix[1]); - VectorNormalize((float*)&bolt.matrix[2]); - Mat3x4_Multiply(matrix, &worldMatrix, &bolt); + VectorNormalize((float *)&bolt.matrix[0]); + VectorNormalize((float *)&bolt.matrix[1]); + VectorNormalize((float *)&bolt.matrix[2]); + + Mat3x4_Multiply(matrix, &worldMatrix, &bolt); #if G2API_DEBUG - for ( int i = 0; i < 3; i++ ) + for (int i = 0; i < 3; i++) { - for ( int j = 0; j < 4; j++ ) + for (int j = 0; j < 4; j++) { - assert( !_isnan(matrix->matrix[i][j])); + assert(!_isnan(matrix->matrix[i][j])); } } -#endif// _DEBUG - G2ANIM(ghlInfo,"G2API_GetBoltMatrix"); +#endif // _DEBUG + G2ANIM(ghlInfo, "G2API_GetBoltMatrix"); if (!gG2_GBMUseSPMethod) - { //this is horribly stupid and I hate it. But lots of game code is written to assume this 90 degree offset thing. - mdxaBone_t rotMat, tempMatrix; - vec3_t newangles = {0,270,0}; + { + // this is horribly stupid and I hate it. But lots of game + // code is written to assume this 90 degree offset thing. + mdxaBone_t rotMat, tempMatrix; + vec3_t newangles = {0, 270, 0}; Create_Matrix(newangles, &rotMat); - // make the model space matrix we have for this bolt into a world matrix - Mat3x4_Multiply(&tempMatrix, &worldMatrix, &bolt); + + // make the model space matrix we have for this bolt into a + // world matrix + Mat3x4_Multiply(&tempMatrix, &worldMatrix, &bolt); vec3_t origin; origin[0] = tempMatrix.matrix[0][3]; origin[1] = tempMatrix.matrix[1][3]; origin[2] = tempMatrix.matrix[2][3]; - tempMatrix.matrix[0][3] = tempMatrix.matrix[1][3] = tempMatrix.matrix[2][3] = 0; + tempMatrix.matrix[0][3] = + tempMatrix.matrix[1][3] = + tempMatrix.matrix[2][3] = 0; Mat3x4_Multiply(matrix, &tempMatrix, &rotMat); matrix->matrix[0][3] = origin[0]; matrix->matrix[1][3] = origin[1]; matrix->matrix[2][3] = origin[2]; } else - { //reset it + { // reset it gG2_GBMUseSPMethod = qfalse; } @@ -2088,7 +2217,7 @@ qboolean G2API_GetBoltMatrix(CGhoul2Info_v &ghoul2, const int modelIndex, const } else { - G2WARNING(0,"G2API_GetBoltMatrix Failed on empty or bad model"); + G2WARNING(0, "G2API_GetBoltMatrix Failed on empty or bad model"); } Mat3x4_Multiply(matrix, &worldMatrix, (mdxaBone_t *)&identityMatrix); return qfalse; @@ -2113,10 +2242,9 @@ void G2API_ListBones(CGhoul2Info *ghlInfo, int frame) // decide if we have Ghoul2 models associated with this ghoul list or not qboolean G2API_HaveWeGhoul2Models(CGhoul2Info_v &ghoul2) { - int i; if (ghoul2.size()) { - for (i=0; idata.glm->header->animName; } -/************************************************************************************************ - * G2API_GetAnimFileName - * obtains the name of a model's .gla (animation) file - * - * Input - * pointer to list of CGhoul2Info's, WraithID of specific model in that list - * - * Output - * true if a good filename was obtained, false otherwise - * - ************************************************************************************************/ qboolean G2API_GetAnimFileName(CGhoul2Info *ghlInfo, char **filename) { if (G2_SetupModelPointers(ghlInfo)) @@ -2184,82 +2304,93 @@ qboolean G2API_GetAnimFileName(CGhoul2Info *ghlInfo, char **filename) SV_QsortEntityNumbers ======================= */ -static int QDECL QsortDistance( const void *a, const void *b ) { - const float &ea = ((CollisionRecord_t*)a)->mDistance; - const float &eb = ((CollisionRecord_t*)b)->mDistance; +static int QDECL QsortDistance(const void *a, const void *b) +{ + const float &ea = ((CollisionRecord_t *)a)->mDistance; + const float &eb = ((CollisionRecord_t *)b)->mDistance; - if ( ea < eb ) { + if (ea < eb) + { return -1; } return 1; } -static inline bool G2_NeedRetransform(CGhoul2Info *g2, int frameNum) -{ //see if we need to do another transform - size_t i = 0; +static bool G2_NeedRetransform(CGhoul2Info *g2, int frameNum) +{ + // see if we need to do another transform bool needTrans = false; - while (i < g2->mBlist.size()) + for (auto &bone : g2->mBlist) { - float time; - boneInfo_t &bone = g2->mBlist[i]; - + float time; if (bone.pauseTime) { time = (bone.pauseTime - bone.startTime) / 50.0f; } else - { + { time = (frameNum - bone.startTime) / 50.0f; } - int newFrame = bone.startFrame + (time * bone.animSpeed); + const int newFrame = bone.startFrame + (time * bone.animSpeed); if (newFrame < bone.endFrame || (bone.flags & BONE_ANIM_OVERRIDE_LOOP) || (bone.flags & BONE_NEED_TRANSFORM)) - { //ok, we're gonna have to do it. bone is apparently animating. + { + // ok, we're gonna have to do it. bone is apparently animating. bone.flags &= ~BONE_NEED_TRANSFORM; needTrans = true; } - i++; } return needTrans; } -void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, const vec3_t angles, const vec3_t position, - int frameNumber, int entNum, vec3_t rayStart, vec3_t rayEnd, vec3_t scale, IHeapAllocator *G2VertSpace, int traceFlags, int useLod, float fRadius) -{ //this will store off the transformed verts for the next trace - this is slower, but for models that do not animate - //frequently it is much much faster. -rww -#if 0 // UNUSED - int *test = ghoul2[0].mTransformedVertsArray; -#endif +void G2API_CollisionDetectCache( + CollisionRecord_t *collRecMap, + CGhoul2Info_v &ghoul2, + const vec3_t angles, + const vec3_t position, + int frameNumber, + int entNum, + vec3_t rayStart, + vec3_t rayEnd, + vec3_t scale, + IHeapAllocator *G2VertSpace, + int traceFlags, + int useLod, + float fRadius) +{ + // this will store off the transformed verts for the next trace - this is + // slower, but for models that do not animate frequently it is much much + // faster. -rww if (G2_SetupModelPointers(ghoul2)) { - vec3_t transRayStart, transRayEnd; + vec3_t transRayStart, transRayEnd; + + int tframeNum = G2API_GetTime(frameNumber); - int tframeNum=G2API_GetTime(frameNumber); // make sure we have transformed the whole skeletons for each model - if (G2_NeedRetransform(&ghoul2[0], tframeNum) || !ghoul2[0].mTransformedVertsArray) - { //optimization, only create new transform space if we need to, otherwise - //store it off! + if (G2_NeedRetransform(&ghoul2[0], tframeNum) || + !ghoul2[0].mTransformedVertsArray) + { + // optimization, only create new transform space if we need to, + // otherwise store it off! int i = 0; while (i < ghoul2.size()) { CGhoul2Info &g2 = ghoul2[i]; - /* - if ((g2.mFlags & GHOUL2_ZONETRANSALLOC) && g2.mTransformedVertsArray) - { //clear it out, yo. - Z_Free(g2.mTransformedVertsArray); - g2.mTransformedVertsArray = 0; - } - */ - if (!g2.mTransformedVertsArray || !(g2.mFlags & GHOUL2_ZONETRANSALLOC)) - { //reworked so we only alloc once! - //if we have a pointer, but not a ghoul2_zonetransalloc flag, then that means - //it is a miniheap pointer. Just stomp over it. - int iSize = g2.currentModel->data.glm->header->numSurfaces * 4; - g2.mTransformedVertsArray = (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); + if (!g2.mTransformedVertsArray || + !(g2.mFlags & GHOUL2_ZONETRANSALLOC)) + { + // reworked so we only alloc once! if we have a pointer, + // but not a ghoul2_zonetransalloc flag, then that means it + // is a miniheap pointer. Just stomp over it. + int iSize = + g2.currentModel->data.glm->header->numSurfaces * 4; + g2.mTransformedVertsArray = + (size_t *)Z_Malloc(iSize, TAG_GHOUL2, qtrue); } g2.mFlags |= GHOUL2_ZONETRANSALLOC; @@ -2271,7 +2402,13 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh // now having done that, time to build the model #ifdef _G2_GORE - G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod, false); + G2_TransformModel( + ghoul2, + frameNumber, + scale, + G2VertSpace, + useLod, + false); #else G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod); #endif @@ -2285,22 +2422,41 @@ void G2API_CollisionDetectCache(CollisionRecord_t *collRecMap, CGhoul2Info_v &gh TransformAndTranslatePoint(rayStart, transRayStart, &worldMatrixInv); TransformAndTranslatePoint(rayEnd, transRayEnd, &worldMatrixInv); - // now walk each model and check the ray against each poly - sigh, this is SO expensive. I wish there was a better way to do this. + // now walk each model and check the ray against each poly - sigh, this + // is SO expensive. I wish there was a better way to do this. + G2_TraceModels( + ghoul2, + transRayStart, + transRayEnd, + collRecMap, + entNum, + traceFlags, + useLod, + fRadius #ifdef _G2_GORE - G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius,0,0,0,0,0,qfalse); -#else - G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius); + , + 0, + 0, + 0, + 0, + 0, + qfalse #endif + ); + int i; - for ( i = 0; i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; i ++ ); + for (i = 0; + i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; + i++) + { + } - // now sort the resulting array of collision records so they are distance ordered - qsort( collRecMap, i, - sizeof( CollisionRecord_t ), QsortDistance ); + // now sort the resulting array of collision records so they are + // distance ordered + qsort(collRecMap, i, sizeof(CollisionRecord_t), QsortDistance); } } - void G2API_CollisionDetect( CollisionRecord_t *collRecMap, CGhoul2Info_v &ghoul2, @@ -2318,7 +2474,7 @@ void G2API_CollisionDetect( { if (G2_SetupModelPointers(ghoul2)) { - vec3_t transRayStart, transRayEnd; + vec3_t transRayStart, transRayEnd; // make sure we have transformed the whole skeletons for each model G2_ConstructGhoulSkeleton(ghoul2, frameNumber, true, scale); @@ -2328,9 +2484,10 @@ void G2API_CollisionDetect( G2VertSpace->ResetHeap(); - // now having done that, time to build the model +// now having done that, time to build the model #ifdef _G2_GORE - G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod, false); + G2_TransformModel( + ghoul2, frameNumber, scale, G2VertSpace, useLod, false); #else G2_TransformModel(ghoul2, frameNumber, scale, G2VertSpace, useLod); #endif @@ -2340,18 +2497,38 @@ void G2API_CollisionDetect( TransformAndTranslatePoint(rayStart, transRayStart, &worldMatrixInv); TransformAndTranslatePoint(rayEnd, transRayEnd, &worldMatrixInv); - // now walk each model and check the ray against each poly - sigh, this is SO expensive. I wish there was a better way to do this. + // now walk each model and check the ray against each poly - sigh, this + // is SO expensive. I wish there was a better way to do this. + G2_TraceModels( + ghoul2, + transRayStart, + transRayEnd, + collRecMap, + entNum, + traceFlags, + useLod, + fRadius #ifdef _G2_GORE - G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius,0,0,0,0,0,qfalse); -#else - G2_TraceModels(ghoul2, transRayStart, transRayEnd, collRecMap, entNum, traceFlags, useLod, fRadius); + , + 0, + 0, + 0, + 0, + 0, + qfalse #endif + ); + int i; - for ( i = 0; i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; i ++ ); + for (i = 0; + i < MAX_G2_COLLISIONS && collRecMap[i].mEntityNum != -1; + i++) + { + } - // now sort the resulting array of collision records so they are distance ordered - qsort( collRecMap, i, - sizeof( CollisionRecord_t ), QsortDistance ); + // now sort the resulting array of collision records so they are + // distance ordered + qsort(collRecMap, i, sizeof(CollisionRecord_t), QsortDistance); } } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index c4c192be89..1cec7c8c2a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -532,7 +532,7 @@ const mdxaBone_t &EvalBoneCache(int index,CBoneCache *boneCache) return boneCache->Eval(index); } -//rww - RAGDOLL_BEGIN +// rww - RAGDOLL_BEGIN const mdxaHeader_t *G2_GetModA(CGhoul2Info &ghoul2) { if (!ghoul2.mBoneCache) @@ -547,43 +547,46 @@ const mdxaHeader_t *G2_GetModA(CGhoul2Info &ghoul2) int G2_GetBoneDependents(CGhoul2Info &ghoul2,int boneNum,int *tempDependents,int maxDep) { // fixme, these should be precomputed - if (!ghoul2.mBoneCache||!maxDep) + if (!ghoul2.mBoneCache || !maxDep) { return 0; } - CBoneCache &boneCache=*ghoul2.mBoneCache; - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); - int i; - int ret=0; - for (i=0;inumChildren;i++) + CBoneCache &boneCache = *ghoul2.mBoneCache; + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = + (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); + + int numDependencies = 0; + for (int i = 0; i < skel->numChildren; i++) { if (!maxDep) { return i; // number added } - *tempDependents=skel->children[i]; - assert(*tempDependents>0&&*tempDependentsnumBones); + + *tempDependents = skel->children[i]; + assert(*tempDependents > 0 && *tempDependents < boneCache.header->numBones); maxDep--; tempDependents++; - ret++; + numDependencies++; } - for (i=0;inumChildren;i++) + + for (int i = 0; i < skel->numChildren; i++) { - int num=G2_GetBoneDependents(ghoul2,skel->children[i],tempDependents,maxDep); - tempDependents+=num; - ret+=num; - maxDep-=num; - assert(maxDep>=0); + int num = G2_GetBoneDependents(ghoul2, skel->children[i], tempDependents, maxDep); + tempDependents += num; + numDependencies += num; + maxDep -= num; + assert(maxDep >= 0); if (!maxDep) { break; } } - return ret; + + return numDependencies; } bool G2_WasBoneRendered(CGhoul2Info &ghoul2,int boneNum) @@ -592,31 +595,36 @@ bool G2_WasBoneRendered(CGhoul2Info &ghoul2,int boneNum) { return false; } - CBoneCache &boneCache=*ghoul2.mBoneCache; + CBoneCache &boneCache = *ghoul2.mBoneCache; return boneCache.WasRendered(boneNum); } -void G2_GetBoneBasepose(CGhoul2Info &ghoul2,int boneNum,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +void G2_GetBoneBasepose( + CGhoul2Info &ghoul2, + int boneNum, + mdxaBone_t *&retBasepose, + mdxaBone_t *&retBaseposeInv) { if (!ghoul2.mBoneCache) { // yikes - retBasepose=const_cast(&identityMatrix); - retBaseposeInv=const_cast(&identityMatrix); + retBasepose = const_cast(&identityMatrix); + retBaseposeInv = const_cast(&identityMatrix); return; } + assert(ghoul2.mBoneCache); - CBoneCache &boneCache=*ghoul2.mBoneCache; + CBoneCache &boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - assert(boneNum>=0&&boneNumnumBones); + assert(boneNum >= 0 && boneNum < boneCache.header->numBones); - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); - retBasepose=&skel->BasePoseMat; - retBaseposeInv=&skel->BasePoseMatInv; + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); + + retBasepose = &skel->BasePoseMat; + retBaseposeInv = &skel->BasePoseMatInv; } char *G2_GetBoneNameFromSkel(CGhoul2Info &ghoul2, int boneNum) @@ -625,122 +633,156 @@ char *G2_GetBoneNameFromSkel(CGhoul2Info &ghoul2, int boneNum) { return NULL; } - CBoneCache &boneCache=*ghoul2.mBoneCache; + + CBoneCache &boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - assert(boneNum>=0&&boneNumnumBones); + assert(boneNum >= 0 && boneNum < boneCache.header->numBones); - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); return skel->name; } -void G2_RagGetBoneBasePoseMatrixLow(CGhoul2Info &ghoul2, int boneNum, mdxaBone_t &boneMatrix, mdxaBone_t &retMatrix, vec3_t scale) +void G2_RagGetBoneBasePoseMatrixLow( + CGhoul2Info &ghoul2, + int boneNum, + mdxaBone_t &boneMatrix, + mdxaBone_t &retMatrix, + vec3_t scale) { assert(ghoul2.mBoneCache); - CBoneCache &boneCache=*ghoul2.mBoneCache; + CBoneCache &boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - assert(boneNum>=0&&boneNumnumBones); + assert(boneNum >= 0 && boneNum < boneCache.header->numBones); + + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); Mat3x4_Multiply(&retMatrix, &boneMatrix, &skel->BasePoseMat); if (scale[0]) { retMatrix.matrix[0][3] *= scale[0]; } + if (scale[1]) { retMatrix.matrix[1][3] *= scale[1]; } + if (scale[2]) { retMatrix.matrix[2][3] *= scale[2]; } - VectorNormalize((float*)&retMatrix.matrix[0]); - VectorNormalize((float*)&retMatrix.matrix[1]); - VectorNormalize((float*)&retMatrix.matrix[2]); + VectorNormalize((float *)&retMatrix.matrix[0]); + VectorNormalize((float *)&retMatrix.matrix[1]); + VectorNormalize((float *)&retMatrix.matrix[2]); } -void G2_GetBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +void G2_GetBoneMatrixLow( + CGhoul2Info &ghoul2, + int boneNum, + const vec3_t scale, + mdxaBone_t &retMatrix, + mdxaBone_t *&retBasepose, + mdxaBone_t *&retBaseposeInv) { - if (!ghoul2.mBoneCache) + if ( !ghoul2.mBoneCache ) { - retMatrix=identityMatrix; + retMatrix = identityMatrix; // yikes - retBasepose=const_cast(&identityMatrix); - retBaseposeInv=const_cast(&identityMatrix); + retBasepose = const_cast(&identityMatrix); + retBaseposeInv = const_cast(&identityMatrix); return; } + mdxaBone_t bolt; assert(ghoul2.mBoneCache); - CBoneCache &boneCache=*ghoul2.mBoneCache; + CBoneCache &boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - assert(boneNum>=0&&boneNumnumBones); + assert(boneNum >= 0 && boneNum < boneCache.header->numBones); - mdxaSkel_t *skel; - mdxaSkelOffsets_t *offsets; - offsets = (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); - skel = (mdxaSkel_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t) + offsets->offsets[boneNum]); - Mat3x4_Multiply(&bolt, (mdxaBone_t *)&boneCache.Eval(boneNum), &skel->BasePoseMat); // DEST FIRST ARG - retBasepose=&skel->BasePoseMat; - retBaseposeInv=&skel->BasePoseMatInv; + mdxaSkelOffsets_t *offsets = + (mdxaSkelOffsets_t *)((byte *)boneCache.header + sizeof(mdxaHeader_t)); + mdxaSkel_t *skel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[boneNum]); + + Mat3x4_Multiply( + &bolt, + &boneCache.Eval(boneNum), + &skel->BasePoseMat); + retBasepose = &skel->BasePoseMat; + retBaseposeInv = &skel->BasePoseMatInv; if (scale[0]) { bolt.matrix[0][3] *= scale[0]; } + if (scale[1]) { bolt.matrix[1][3] *= scale[1]; } + if (scale[2]) { bolt.matrix[2][3] *= scale[2]; } - VectorNormalize((float*)&bolt.matrix[0]); - VectorNormalize((float*)&bolt.matrix[1]); - VectorNormalize((float*)&bolt.matrix[2]); - Mat3x4_Multiply(&retMatrix,&worldMatrix, &bolt); - + VectorNormalize((float *)&bolt.matrix[0]); + VectorNormalize((float *)&bolt.matrix[1]); + VectorNormalize((float *)&bolt.matrix[2]); + + Mat3x4_Multiply(&retMatrix, &worldMatrix, &bolt); + #ifdef _DEBUG - for ( int i = 0; i < 3; i++ ) + for (int i = 0; i < 3; i++) { - for ( int j = 0; j < 4; j++ ) + for (int j = 0; j < 4; j++) { - assert( !Q_isnan(retMatrix.matrix[i][j])); + assert(!Q_isnan(retMatrix.matrix[i][j])); } } -#endif// _DEBUG +#endif // _DEBUG } -int G2_GetParentBoneMatrixLow(CGhoul2Info &ghoul2,int boneNum,const vec3_t scale,mdxaBone_t &retMatrix,mdxaBone_t *&retBasepose,mdxaBone_t *&retBaseposeInv) +int G2_GetParentBoneMatrixLow( + CGhoul2Info &ghoul2, + int boneNum, + const vec3_t scale, + mdxaBone_t &retMatrix, + mdxaBone_t *&retBasepose, + mdxaBone_t *&retBaseposeInv) { - int parent=-1; - if (ghoul2.mBoneCache) + int parent = -1; + if ( ghoul2.mBoneCache ) { - CBoneCache &boneCache=*ghoul2.mBoneCache; + CBoneCache &boneCache = *ghoul2.mBoneCache; assert(boneCache.mod); - assert(boneNum>=0&&boneNumnumBones); - parent=boneCache.GetParent(boneNum); - if (parent<0||parent>=boneCache.header->numBones) + assert(boneNum >= 0 && boneNum < boneCache.header->numBones); + + parent = boneCache.GetParent(boneNum); + if ( parent < 0 || parent >= boneCache.header->numBones ) { - parent=-1; - retMatrix=identityMatrix; + parent = -1; + retMatrix = identityMatrix; + // yikes - retBasepose=const_cast(&identityMatrix); - retBaseposeInv=const_cast(&identityMatrix); + retBasepose = const_cast(&identityMatrix); + retBaseposeInv = const_cast(&identityMatrix); } else { - G2_GetBoneMatrixLow(ghoul2,parent,scale,retMatrix,retBasepose,retBaseposeInv); + G2_GetBoneMatrixLow( + ghoul2, + parent, + scale, + retMatrix, + retBasepose, + retBaseposeInv); } } return parent; @@ -785,22 +827,20 @@ class CRenderSurface boltInfo_v &initboltList #endif ) - : surfaceNum(initsurfaceNum) - , rootSList(initrootSList) - , cust_shader(initcust_shader) - , fogNum(initfogNum) - , personalModel(initpersonalModel) - , boneCache(initboneCache) - , renderfx(initrenderfx) - , skin(initskin) - , currentModel(initcurrentModel) - , lod(initlod) + : surfaceNum(initsurfaceNum) + , rootSList(initrootSList) + , cust_shader(initcust_shader) + , fogNum(initfogNum) + , personalModel(initpersonalModel) + , boneCache(initboneCache) + , renderfx(initrenderfx) + , skin(initskin) + , currentModel(initcurrentModel) + , lod(initlod) + , boltList(initboltList) #ifdef _G2_GORE - , boltList(initboltList) - , gore_shader(initgore_shader) - , gore_set(initgore_set) -#else - , boltList(initboltList) + , gore_shader(initgore_shader) + , gore_set(initgore_set) #endif { } @@ -926,7 +966,11 @@ static int G2_ComputeLOD( trRefEntity_t *ent, const model_t *currentModel, int l largestScale = 1; } - if ( ( projectedRadius = ProjectRadius( 0.75*largestScale*ent->e.radius, ent->e.origin ) ) != 0 ) //we reduce the radius to make the LOD match other model types which use the actual bound box size + projectedRadius = ProjectRadius( 0.75*largestScale*ent->e.radius, ent->e.origin ); + + // we reduce the radius to make the LOD match other model types which use + // the actual bound box size + if ( projectedRadius != 0 ) { lodscale = (r_lodscale->value+r_autolodscalevalue->value); if ( lodscale > 20 ) @@ -978,10 +1022,10 @@ void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) float t = 1 + mat->matrix[0][0] + mat->matrix[1][1] + mat->matrix[2][2]; float s; - //If the trace of the matrix is greater than zero, then - //perform an "instant" calculation. - //Important note wrt. rouning errors: - //Test if ( T > 0.00000001 ) to avoid large distortions! + // If the trace of the matrix is greater than zero, then + // perform an "instant" calculation. + // Important note wrt. rouning errors: + // Test if ( T > 0.00000001 ) to avoid large distortions! if (t > 0.00000001) { s = sqrt(t) * 2; @@ -992,26 +1036,28 @@ void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) } else { - //If the trace of the matrix is equal to zero then identify - //which major diagonal element has the greatest value. + // If the trace of the matrix is equal to zero then identify + // which major diagonal element has the greatest value. - //Depending on this, calculate the following: - - if ( mat->matrix[0][0] > mat->matrix[1][1] && mat->matrix[0][0] > mat->matrix[2][2] ) { // Column 0: + // Depending on this, calculate the following: + if ( mat->matrix[0][0] > mat->matrix[1][1] && mat->matrix[0][0] > mat->matrix[2][2] ) { + // Column 0: s = sqrt( 1.0 + mat->matrix[0][0] - mat->matrix[1][1] - mat->matrix[2][2])* 2; quat[0] = 0.25 * s; quat[1] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; quat[2] = (mat->matrix[2][0] + mat->matrix[0][2] ) / s; quat[3] = (mat->matrix[1][2] - mat->matrix[2][1] ) / s; - } else if ( mat->matrix[1][1] > mat->matrix[2][2] ) { // Column 1: + } else if ( mat->matrix[1][1] > mat->matrix[2][2] ) { + // Column 1: s = sqrt( 1.0 + mat->matrix[1][1] - mat->matrix[0][0] - mat->matrix[2][2] ) * 2; quat[0] = (mat->matrix[0][1] + mat->matrix[1][0] ) / s; quat[1] = 0.25 * s; quat[2] = (mat->matrix[1][2] + mat->matrix[2][1] ) / s; quat[3] = (mat->matrix[2][0] - mat->matrix[0][2] ) / s; - } else { // Column 2: + } else { + // Column 2: s = sqrt( 1.0 + mat->matrix[2][2] - mat->matrix[0][0] - mat->matrix[1][1] ) * 2; quat[0] = (mat->matrix[2][0]+ mat->matrix[0][2] ) / s; quat[1] = (mat->matrix[1][2] + mat->matrix[2][1] ) / s; @@ -1023,18 +1069,17 @@ void G2_CreateQuaterion(mdxaBone_t *mat, vec4_t quat) void G2_CreateMatrixFromQuaterion(mdxaBone_t *mat, vec4_t quat) { - - float xx = quat[0] * quat[0]; - float xy = quat[0] * quat[1]; - float xz = quat[0] * quat[2]; - float xw = quat[0] * quat[3]; + const float xx = quat[0] * quat[0]; + const float xy = quat[0] * quat[1]; + const float xz = quat[0] * quat[2]; + const float xw = quat[0] * quat[3]; - float yy = quat[1] * quat[1]; - float yz = quat[1] * quat[2]; - float yw = quat[1] * quat[3]; + const float yy = quat[1] * quat[1]; + const float yz = quat[1] * quat[2]; + const float yw = quat[1] * quat[3]; - float zz = quat[2] * quat[2]; - float zw = quat[2] * quat[3]; + const float zz = quat[2] * quat[2]; + const float zw = quat[2] * quat[3]; mat->matrix[0][0] = 1 - 2 * ( yy + zz ); mat->matrix[1][0] = 2 * ( xy - zw ); @@ -1054,18 +1099,24 @@ void G2_CreateMatrixFromQuaterion(mdxaBone_t *mat, vec4_t quat) static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone) { const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3); - - mdxaIndex_t *pIndex = + const mdxaIndex_t *pIndex = (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); - return pIndex->iIndex & 0x00FFFFFF; // this will cause problems for big-endian machines... ;-) + // this will cause problems for big-endian machines... ;-) + return pIndex->iIndex & 0x00FFFFFF; } - -/*static inline*/ void UnCompressBone(float mat[3][4], int iBoneIndex, const mdxaHeader_t *pMDXAHeader, int iFrame) +/*static inline*/ void UnCompressBone( + float mat[3][4], + int iBoneIndex, + const mdxaHeader_t *pMDXAHeader, + int iFrame) { - mdxaCompQuatBone_t *pCompBonePool = (mdxaCompQuatBone_t *) ((byte *)pMDXAHeader + pMDXAHeader->ofsCompBonePool); - MC_UnCompressQuat(mat, pCompBonePool[ G2_GetBonePoolIndex( pMDXAHeader, iFrame, iBoneIndex ) ].Comp); + mdxaCompQuatBone_t *pCompBonePool = + (mdxaCompQuatBone_t *)((byte *)pMDXAHeader + pMDXAHeader->ofsCompBonePool); + MC_UnCompressQuat( + mat, + pCompBonePool[G2_GetBonePoolIndex(pMDXAHeader, iFrame, iBoneIndex)].Comp); } #define DEBUG_G2_TIMING (0) @@ -1319,12 +1370,17 @@ void G2_TimingModel( #ifdef _RAG_PRINT_TEST void G2_RagPrintMatrix(mdxaBone_t *mat); #endif -//basically construct a seperate skeleton with full hierarchy to store a matrix -//off which will give us the desired settling position given the frame in the skeleton -//that should be used -rww -int G2_Add_Bone (const model_t *mod, boneInfo_v &blist, const char *boneName); +// basically construct a seperate skeleton with full hierarchy to store a matrix +// off which will give us the desired settling position given the frame in the skeleton +// that should be used -rww +int G2_Add_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName); int G2_Find_Bone(const model_t *mod, boneInfo_v &blist, const char *boneName); -void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &matrix, const int frame) + +void G2_RagGetAnimMatrix( + CGhoul2Info &ghoul2, + const int boneNum, + mdxaBone_t &matrix, + const int frame) { mdxaBone_t animMatrix; mdxaSkel_t *skel; @@ -1376,14 +1432,14 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat parent = skel->parent; if (boneNum > 0 && parent > -1) { - //recursively call to assure all parent matrices are set up + // recursively call to assure all parent matrices are set up G2_RagGetAnimMatrix(ghoul2, parent, matrix, frame); - //assign the new skel ptr for our parent + // assign the new skel ptr for our parent pskel = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[parent]); - //taking bone matrix for the skeleton frame and parent's - //animFrameMatrix into account, determine our final animFrameMatrix + // taking bone matrix for the skeleton frame and parent's + // animFrameMatrix into account, determine our final animFrameMatrix if (!pskel->name[0]) { parentBlistIndex = -1; @@ -1401,7 +1457,8 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat boneInfo_t &pbone = ghoul2.mBlist[parentBlistIndex]; - assert(pbone.hasAnimFrameMatrix == frame); //this should have been calc'd in the recursive call + // this should have been calc'd in the recursive call + assert(pbone.hasAnimFrameMatrix == frame); Mat3x4_Multiply(&bone.animFrameMatrix, &pbone.animFrameMatrix, &animMatrix); @@ -1417,7 +1474,8 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat #endif } else - { //root + { + // root Mat3x4_Multiply(&bone.animFrameMatrix, &ghoul2.mBoneCache->rootMatrix, &animMatrix); #ifdef _RAG_PRINT_TEST if (bListIndex != -1) @@ -1429,10 +1487,6 @@ void G2_RagGetAnimMatrix(CGhoul2Info &ghoul2, const int boneNum, mdxaBone_t &mat Com_Printf("BAD LIST INDEX: %s\n", skel->name); } #endif - //bone.animFrameMatrix = ghoul2.mBoneCache->mFinalBones[boneNum].boneMatrix; - //Maybe use this for the root, so that the orientation is in sync with the current - //root matrix? However this would require constant recalculation of this base - //skeleton which I currently do not want. } //never need to figure it out again @@ -1847,8 +1901,8 @@ static void G2_TransformGhoulBones( G2PerformanceCounter_G2_TransformGhoulBones++; #endif - model_t *currentModel = (model_t *)ghoul2.currentModel; - mdxaHeader_t *aHeader = (mdxaHeader_t *)ghoul2.aHeader; + model_t *currentModel = (model_t *)ghoul2.currentModel; + mdxaHeader_t *aHeader = (mdxaHeader_t *)ghoul2.aHeader; assert(ghoul2.aHeader); assert(ghoul2.currentModel); @@ -1874,30 +1928,30 @@ static void G2_TransformGhoulBones( ghoul2.mBoneCache->mUnsquash=false; // master smoothing control - if (HackadelicOnClient && smooth && !ri->Cvar_VariableIntegerValue( "dedicated" )) + if (HackadelicOnClient && smooth && !ri->Cvar_VariableIntegerValue("dedicated")) { - ghoul2.mBoneCache->mLastTouch=ghoul2.mBoneCache->mLastLastTouch; + ghoul2.mBoneCache->mLastTouch = ghoul2.mBoneCache->mLastLastTouch; // master smoothing control - float val=r_Ghoul2AnimSmooth->value; - if (val>0.0f&&val<1.0f) + float val = r_Ghoul2AnimSmooth->value; + if (val > 0.0f && val < 1.0f) { - if(ghoul2.mFlags & GHOUL2_CRAZY_SMOOTH) + if (ghoul2.mFlags & GHOUL2_CRAZY_SMOOTH) { val = 0.9f; } - else if(ghoul2.mFlags & GHOUL2_RAG_STARTED) + else if (ghoul2.mFlags & GHOUL2_RAG_STARTED) { - for (size_t k=0;ktime-250 && - bone.firstCollisionTime (time - 250) && + bone.firstCollisionTime < time) { - val=0.9f; + val = 0.9f; } else if (bone.airTime > time) { @@ -1912,46 +1966,46 @@ static void G2_TransformGhoulBones( } } - ghoul2.mBoneCache->mSmoothFactor=val; // meaningless formula - ghoul2.mBoneCache->mSmoothingActive=true; + ghoul2.mBoneCache->mSmoothFactor = val; // meaningless formula + ghoul2.mBoneCache->mSmoothingActive = true; if (r_Ghoul2UnSqashAfterSmooth->integer) { - ghoul2.mBoneCache->mUnsquash=true; + ghoul2.mBoneCache->mUnsquash = true; } } } else { - ghoul2.mBoneCache->mSmoothFactor=1.0f; + ghoul2.mBoneCache->mSmoothFactor = 1.0f; } ghoul2.mBoneCache->mCurrentTouch++; if (HackadelicOnClient) { - ghoul2.mBoneCache->mLastLastTouch=ghoul2.mBoneCache->mCurrentTouch; - ghoul2.mBoneCache->mCurrentTouchRender=ghoul2.mBoneCache->mCurrentTouch; + ghoul2.mBoneCache->mLastLastTouch = ghoul2.mBoneCache->mCurrentTouch; + ghoul2.mBoneCache->mCurrentTouchRender = ghoul2.mBoneCache->mCurrentTouch; } else { - ghoul2.mBoneCache->mCurrentTouchRender=0; + ghoul2.mBoneCache->mCurrentTouchRender = 0; } ghoul2.mBoneCache->frameSize = 0; - ghoul2.mBoneCache->rootBoneList=&rootBoneList; - ghoul2.mBoneCache->rootMatrix=rootMatrix; - ghoul2.mBoneCache->incomingTime=time; + ghoul2.mBoneCache->rootBoneList = &rootBoneList; + ghoul2.mBoneCache->rootMatrix = rootMatrix; + ghoul2.mBoneCache->incomingTime = time; - SBoneCalc &TB=ghoul2.mBoneCache->Root(); - TB.newFrame=0; - TB.currentFrame=0; - TB.backlerp=0.0f; - TB.blendFrame=0; - TB.blendOldFrame=0; - TB.blendMode=false; - TB.blendLerp=0; + SBoneCalc &TB = ghoul2.mBoneCache->Root(); + TB.newFrame = 0; + TB.currentFrame = 0; + TB.backlerp = 0.0f; + TB.blendFrame = 0; + TB.blendOldFrame = 0; + TB.blendMode = false; + TB.blendLerp = 0; #ifdef G2_PERFORMANCE_ANALYSIS G2Time_G2_TransformGhoulBones += G2PerformanceTimer_G2_TransformGhoulBones.End(); @@ -1967,87 +2021,122 @@ static void G2_TransformGhoulBones( // We've come across a surface that's designated as a bolt surface, process it and put it in the appropriate bolt place -void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int boltNum, boltInfo_v &boltList, surfaceInfo_t *surfInfo, model_t *mod) +void G2_ProcessSurfaceBolt( + mdxaBone_v &bonePtr, + mdxmSurface_t *surface, + int boltNum, + boltInfo_v &boltList, + surfaceInfo_t *surfInfo, + model_t *mod) { - mdxmVertex_t *v, *vert0, *vert1, *vert2; - vec3_t axes[3], sides[3]; - float pTri[3][3], d; - int j, k; + mdxmVertex_t *v, *vert0, *vert1, *vert2; + vec3_t axes[3], sides[3]; + float pTri[3][3], d; + int j, k; - // now there are two types of tag surface - model ones and procedural generated types - lets decide which one we have here. + // now there are two types of tag surface - model ones and procedural + // generated types - lets decide which one we have here. if (surfInfo && surfInfo->offFlags == G2SURFACEFLAG_GENERATED) { int surfNumber = surfInfo->genPolySurfaceIndex & 0x0ffff; - int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; + int polyNumber = (surfInfo->genPolySurfaceIndex >> 16) & 0x0ffff; // find original surface our original poly was in. - mdxmSurface_t *originalSurf = (mdxmSurface_t *)G2_FindSurface((void*)mod, surfNumber, surfInfo->genLod); - mdxmTriangle_t *originalTriangleIndexes = (mdxmTriangle_t *)((byte*)originalSurf + originalSurf->ofsTriangles); + mdxmSurface_t *originalSurf = + (mdxmSurface_t *)G2_FindSurface((void *)mod, surfNumber, surfInfo->genLod); + mdxmTriangle_t *originalTriangleIndexes = + (mdxmTriangle_t *)((byte *)originalSurf + originalSurf->ofsTriangles); - // get the original polys indexes + // get the original polys indexes int index0 = originalTriangleIndexes[polyNumber].indexes[0]; int index1 = originalTriangleIndexes[polyNumber].indexes[1]; int index2 = originalTriangleIndexes[polyNumber].indexes[2]; // decide where the original verts are - vert0 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert0+= index0; + vert0 = (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); + vert0 += index0; - vert1 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert1+= index1; - - vert2 = (mdxmVertex_t *) ((byte *)originalSurf + originalSurf->ofsVerts); - vert2+= index2; + vert1 = (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); + vert1 += index1; - // clear out the triangle verts to be - VectorClear( pTri[0] ); - VectorClear( pTri[1] ); - VectorClear( pTri[2] ); + vert2 = (mdxmVertex_t *)((byte *)originalSurf + originalSurf->ofsVerts); + vert2 += index2; -// mdxmWeight_t *w; + // clear out the triangle verts to be + VectorClear(pTri[0]); + VectorClear(pTri[1]); + VectorClear(pTri[2]); - int *piBoneRefs = (int*) ((byte*)originalSurf + originalSurf->ofsBoneReferences); + int *piBoneRefs = (int *)((byte *)originalSurf + originalSurf->ofsBoneReferences); - // now go and transform just the points we need from the surface that was hit originally -// w = vert0->weights; + // now go and transform just the points we need from the surface that + // was hit originally + // w = vert0->weights; float fTotalWeight = 0.0f; - int iNumWeights = G2_GetVertWeights( vert0 ); - for ( k = 0 ; k < iNumWeights ; k++ ) - { - int iBoneIndex = G2_GetVertBoneIndex( vert0, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert0, k, fTotalWeight, iNumWeights ); - - pTri[0][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); - pTri[0][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); - pTri[0][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert0->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + int iNumWeights = G2_GetVertWeights(vert0); + for (k = 0; k < iNumWeights; k++) + { + int iBoneIndex = G2_GetVertBoneIndex(vert0, k); + float fBoneWeight = G2_GetVertBoneWeight(vert0, k, fTotalWeight, iNumWeights); + + pTri[0][0] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert0->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3]); + pTri[0][1] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert0->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3]); + pTri[0][2] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert0->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3]); } -// w = vert1->weights; - fTotalWeight = 0.0f; - iNumWeights = G2_GetVertWeights( vert1 ); - for ( k = 0 ; k < iNumWeights ; k++ ) - { - int iBoneIndex = G2_GetVertBoneIndex( vert1, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert1, k, fTotalWeight, iNumWeights ); - pTri[1][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); - pTri[1][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); - pTri[1][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert1->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); - } -// w = vert2->weights; fTotalWeight = 0.0f; - iNumWeights = G2_GetVertWeights( vert2 ); - for ( k = 0 ; k < iNumWeights ; k++ ) - { - int iBoneIndex = G2_GetVertBoneIndex( vert2, k ); - float fBoneWeight = G2_GetVertBoneWeight( vert2, k, fTotalWeight, iNumWeights ); + iNumWeights = G2_GetVertWeights(vert1); + for (k = 0; k < iNumWeights; k++) + { + int iBoneIndex = G2_GetVertBoneIndex(vert1, k); + float fBoneWeight = G2_GetVertBoneWeight(vert1, k, fTotalWeight, iNumWeights); + + pTri[1][0] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert1->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3]); + pTri[1][1] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert1->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3]); + pTri[1][2] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert1->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3]); + } - pTri[2][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); - pTri[2][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); - pTri[2][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert2->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); + fTotalWeight = 0.0f; + iNumWeights = G2_GetVertWeights(vert2); + for (k = 0; k < iNumWeights; k++) + { + int iBoneIndex = G2_GetVertBoneIndex(vert2, k); + float fBoneWeight = G2_GetVertBoneWeight(vert2, k, fTotalWeight, iNumWeights); + + pTri[2][0] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], vert2->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3]); + pTri[2][1] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], vert2->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3]); + pTri[2][2] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], vert2->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3]); } - - vec3_t normal; + + vec3_t normal; vec3_t up; vec3_t right; vec3_t vec0, vec1; @@ -2055,9 +2144,15 @@ void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int bolt float baryCentricK = 1.0 - (surfInfo->genBarycentricI + surfInfo->genBarycentricJ); // now we have the model transformed into model space, now generate an origin. - boltList[boltNum].position.matrix[0][3] = (pTri[0][0] * surfInfo->genBarycentricI) + (pTri[1][0] * surfInfo->genBarycentricJ) + (pTri[2][0] * baryCentricK); - boltList[boltNum].position.matrix[1][3] = (pTri[0][1] * surfInfo->genBarycentricI) + (pTri[1][1] * surfInfo->genBarycentricJ) + (pTri[2][1] * baryCentricK); - boltList[boltNum].position.matrix[2][3] = (pTri[0][2] * surfInfo->genBarycentricI) + (pTri[1][2] * surfInfo->genBarycentricJ) + (pTri[2][2] * baryCentricK); + boltList[boltNum].position.matrix[0][3] = (pTri[0][0] * surfInfo->genBarycentricI) + + (pTri[1][0] * surfInfo->genBarycentricJ) + + (pTri[2][0] * baryCentricK); + boltList[boltNum].position.matrix[1][3] = (pTri[0][1] * surfInfo->genBarycentricI) + + (pTri[1][1] * surfInfo->genBarycentricJ) + + (pTri[2][1] * baryCentricK); + boltList[boltNum].position.matrix[2][3] = (pTri[0][2] * surfInfo->genBarycentricI) + + (pTri[1][2] * surfInfo->genBarycentricJ) + + (pTri[2][2] * baryCentricK); // generate a normal to this new triangle VectorSubtract(pTri[0], pTri[1], vec0); @@ -2087,74 +2182,85 @@ void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int bolt // right is always straight - CrossProduct( normal, up, right ); + CrossProduct(normal, up, right); // that's the up vector boltList[boltNum].position.matrix[0][2] = right[0]; boltList[boltNum].position.matrix[1][2] = right[1]; boltList[boltNum].position.matrix[2][2] = right[2]; - - } // no, we are looking at a normal model tag else { - int *piBoneRefs = (int*) ((byte*)surface + surface->ofsBoneReferences); + int *piBoneRefs = (int *)((byte *)surface + surface->ofsBoneReferences); - // whip through and actually transform each vertex - v = (mdxmVertex_t *) ((byte *)surface + surface->ofsVerts); - for ( j = 0; j < 3; j++ ) - { -// mdxmWeight_t *w; + // whip through and actually transform each vertex + v = (mdxmVertex_t *)((byte *)surface + surface->ofsVerts); + for (j = 0; j < 3; j++) + { + // mdxmWeight_t *w; - VectorClear( pTri[j] ); - // w = v->weights; + VectorClear(pTri[j]); + // w = v->weights; - const int iNumWeights = G2_GetVertWeights( v ); + const int iNumWeights = G2_GetVertWeights(v); float fTotalWeight = 0.0f; - for ( k = 0 ; k < iNumWeights ; k++ ) - { - int iBoneIndex = G2_GetVertBoneIndex( v, k ); - float fBoneWeight = G2_GetVertBoneWeight( v, k, fTotalWeight, iNumWeights ); + for (k = 0; k < iNumWeights; k++) + { + int iBoneIndex = G2_GetVertBoneIndex(v, k); + float fBoneWeight = G2_GetVertBoneWeight(v, k, fTotalWeight, iNumWeights); + + // bone = bonePtr + piBoneRefs[w->boneIndex]; + pTri[j][0] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], v->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3]); + pTri[j][1] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], v->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3]); + pTri[j][2] += + fBoneWeight * + (DotProduct(bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], v->vertCoords) + + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3]); + } - //bone = bonePtr + piBoneRefs[w->boneIndex]; - pTri[j][0] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[0][3] ); - pTri[j][1] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[1][3] ); - pTri[j][2] += fBoneWeight * ( DotProduct( bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2], v->vertCoords ) + bonePtr[piBoneRefs[iBoneIndex]].second.matrix[2][3] ); - } - - v++;// = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surface->maxVertBoneWeights]; - } + v++; + } - // clear out used arrays - memset( axes, 0, sizeof( axes ) ); - memset( sides, 0, sizeof( sides ) ); + // clear out used arrays + memset(axes, 0, sizeof(axes)); + memset(sides, 0, sizeof(sides)); - // work out actual sides of the tag triangle - for ( j = 0; j < 3; j++ ) - { - sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0]; - sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1]; - sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2]; - } + // work out actual sides of the tag triangle + for (j = 0; j < 3; j++) + { + sides[j][0] = pTri[(j + 1) % 3][0] - pTri[j][0]; + sides[j][1] = pTri[(j + 1) % 3][1] - pTri[j][1]; + sides[j][2] = pTri[(j + 1) % 3][2] - pTri[j][2]; + } - // do math trig to work out what the matrix will be from this triangle's translated position - VectorNormalize2( sides[iG2_TRISIDE_LONGEST], axes[0] ); - VectorNormalize2( sides[iG2_TRISIDE_SHORTEST], axes[1] ); + // do math trig to work out what the matrix will be from this + // triangle's translated position + VectorNormalize2(sides[iG2_TRISIDE_LONGEST], axes[0]); + VectorNormalize2(sides[iG2_TRISIDE_SHORTEST], axes[1]); - // project shortest side so that it is exactly 90 degrees to the longer side - d = DotProduct( axes[0], axes[1] ); - VectorMA( axes[0], -d, axes[1], axes[0] ); - VectorNormalize2( axes[0], axes[0] ); + // project shortest side so that it is exactly 90 degrees to the longer + // side + d = DotProduct(axes[0], axes[1]); + VectorMA(axes[0], -d, axes[1], axes[0]); + VectorNormalize2(axes[0], axes[0]); - CrossProduct( sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2] ); - VectorNormalize2( axes[2], axes[2] ); + CrossProduct(sides[iG2_TRISIDE_LONGEST], sides[iG2_TRISIDE_SHORTEST], axes[2]); + VectorNormalize2(axes[2], axes[2]); - // set up location in world space of the origin point in out going matrix - boltList[boltNum].position.matrix[0][3] = pTri[MDX_TAG_ORIGIN][0]; - boltList[boltNum].position.matrix[1][3] = pTri[MDX_TAG_ORIGIN][1]; - boltList[boltNum].position.matrix[2][3] = pTri[MDX_TAG_ORIGIN][2]; + // set up location in world space of the origin point in out going + // matrix + boltList[boltNum].position.matrix[0][3] = pTri[MDX_TAG_ORIGIN][0]; + boltList[boltNum].position.matrix[1][3] = pTri[MDX_TAG_ORIGIN][1]; + boltList[boltNum].position.matrix[2][3] = pTri[MDX_TAG_ORIGIN][2]; - // copy axis to matrix - do some magic to orient minus Y to positive X and so on so bolt on stuff is oriented correctly + // copy axis to matrix - do some magic to orient minus Y to positive X + // and so on so bolt on stuff is oriented correctly boltList[boltNum].position.matrix[0][0] = axes[1][0]; boltList[boltNum].position.matrix[0][1] = axes[0][0]; boltList[boltNum].position.matrix[0][2] = -axes[2][0]; @@ -2167,12 +2273,10 @@ void G2_ProcessSurfaceBolt(mdxaBone_v &bonePtr, mdxmSurface_t *surface, int bolt boltList[boltNum].position.matrix[2][1] = axes[0][2]; boltList[boltNum].position.matrix[2][2] = -axes[2][2]; } - } - // now go through all the generated surfaces that aren't included in the model -// surface hierarchy and create the correct bolt info for them +// surface hierarchy and create the correct bolt info for them void G2_ProcessGeneratedSurfaceBolts(CGhoul2Info &ghoul2, mdxaBone_v &bonePtr, model_t *mod_t) { #ifdef G2_PERFORMANCE_ANALYSIS @@ -2215,20 +2319,23 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum G2PerformanceTimer_RenderSurfaces.Start(); #endif - int i; - const shader_t *shader = 0; - int offFlags = 0; + int i; + const shader_t *shader = 0; + int offFlags = 0; #ifdef _G2_GORE - bool drawGore = true; + bool drawGore = true; #endif assert(RS.currentModel); assert(RS.currentModel->data.glm && RS.currentModel->data.glm->header); // back track and get the surfinfo struct for this surface - mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)RS.currentModel->data.glm->header + sizeof(mdxmHeader_t)); - mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); - + mdxmSurface_t *surface = + (mdxmSurface_t *)G2_FindSurface(RS.currentModel, RS.surfaceNum, RS.lod); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *) + ((byte *)RS.currentModel->data.glm->header + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *) + ((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + // see if we have an override surface in the surface list const surfaceInfo_t *surfOverride = G2_FindOverrideSurface(RS.surfaceNum, RS.rootSList); @@ -2402,23 +2509,32 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum #endif } -// Go through the model and deal with just the surfaces that are tagged as bolt on points - this is for the server side skeleton construction -void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, - mdxaBone_v &bonePtr, model_t *currentModel, int lod, boltInfo_v &boltList) +// Go through the model and deal with just the surfaces that are tagged as bolt +// on points - this is for the server side skeleton construction +void ProcessModelBoltSurfaces( + int surfaceNum, + surfaceInfo_v &rootSList, + mdxaBone_v &bonePtr, + model_t *currentModel, + int lod, + boltInfo_v &boltList) { #ifdef G2_PERFORMANCE_ANALYSIS G2PerformanceTimer_ProcessModelBoltSurfaces.Start(); #endif - int i; - int offFlags = 0; - + int i; + int offFlags = 0; + // back track and get the surfinfo struct for this surface - mdxmSurface_t *surface = (mdxmSurface_t *)G2_FindSurface((void *)currentModel, surfaceNum, 0); - mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *)((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); - mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); - + mdxmSurface_t *surface = (mdxmSurface_t *) + G2_FindSurface((void *)currentModel, surfaceNum, 0); + mdxmHierarchyOffsets_t *surfIndexes = (mdxmHierarchyOffsets_t *) + ((byte *)currentModel->data.glm->header + sizeof(mdxmHeader_t)); + mdxmSurfHierarchy_t *surfInfo = (mdxmSurfHierarchy_t *) + ((byte *)surfIndexes + surfIndexes->offsets[surface->thisSurfaceIndex]); + // see if we have an override surface in the surface list - surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); + surfaceInfo_t *surfOverride = G2_FindOverrideSurface(surfaceNum, rootSList); // really, we should use the default flags for this surface unless it's been overriden offFlags = surfInfo->flags; @@ -2450,7 +2566,8 @@ void ProcessModelBoltSurfaces(int surfaceNum, surfaceInfo_v &rootSList, // now recursively call for the children for (i=0; i< surfInfo->numChildren; i++) { - ProcessModelBoltSurfaces(surfInfo->childIndexes[i], rootSList, bonePtr, currentModel, lod, boltList); + ProcessModelBoltSurfaces( + surfInfo->childIndexes[i], rootSList, bonePtr, currentModel, lod, boltList); } #ifdef G2_PERFORMANCE_ANALYSIS @@ -3718,8 +3835,8 @@ Bone 52: "face_always_": */ - -qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { +qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached) +{ int i,l, j; mdxmHeader_t *pinmodel, *mdxm; mdxmLOD_t *lod; @@ -3761,15 +3878,15 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean if (!bAlreadyFound) { - // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the - // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since - // we've hijacked that memory block... + // horrible new hackery, if !bAlreadyFound then we've just done a + // tag-morph, so we need to set the bool reference passed into this + // function to true, to tell the caller NOT to do an ri->FS_Freefile + // since we've hijacked that memory block... // // Aaaargh. Kill me now... // bAlreadyCached = qtrue; assert( mdxm == buffer ); -// memcpy( mdxm, buffer, size ); // and don't do this now, since it's the same thing LL(mdxm->ident); LL(mdxm->version); @@ -3780,7 +3897,8 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean LL(mdxm->ofsEnd); } - // first up, go load in the animation file we need that has the skeletal animation info for this model + // first up, go load in the animation file we need that has the skeletal + // animation info for this model mdxm->animIndex = RE_RegisterModel(va ("%s.gla",mdxm->animName)); if (!mdxm->animIndex) @@ -3863,62 +3981,25 @@ qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *mod_name, qboolean triCount += surf->numTriangles; if ( surf->numVerts > SHADER_MAX_VERTEXES ) { - Com_Error (ERR_DROP, "R_LoadMDXM: %s has more than %i verts on a surface (%i)", - mod_name, SHADER_MAX_VERTEXES, surf->numVerts ); + Com_Error( + ERR_DROP, + "R_LoadMDXM: %s has more than %i verts on a surface (%i)", + mod_name, + SHADER_MAX_VERTEXES, + surf->numVerts); } if ( surf->numTriangles*3 > SHADER_MAX_INDEXES ) { - Com_Error (ERR_DROP, "R_LoadMDXM: %s has more than %i triangles on a surface (%i)", - mod_name, SHADER_MAX_INDEXES / 3, surf->numTriangles ); + Com_Error( + ERR_DROP, + "R_LoadMDXM: %s has more than %i triangles on a surface (%i)", + mod_name, + SHADER_MAX_INDEXES / 3, + surf->numTriangles); } // change to surface identifier surf->ident = SF_MDX; // register the shaders -#if 0 //#ifndef _M_IX86 -// -// optimisation, we don't bother doing this for standard intel case since our data's already in that format... -// - // FIXME - is this correct? - // do all the bone reference data - boneRef = (int *) ( (byte *)surf + surf->ofsBoneReferences ); - for ( j = 0 ; j < surf->numBoneReferences ; j++ ) - { - LL(boneRef[j]); - } - - // swap all the triangles - tri = (mdxmTriangle_t *) ( (byte *)surf + surf->ofsTriangles ); - for ( j = 0 ; j < surf->numTriangles ; j++, tri++ ) - { - LL(tri->indexes[0]); - LL(tri->indexes[1]); - LL(tri->indexes[2]); - } - - // swap all the vertexes - v = (mdxmVertex_t *) ( (byte *)surf + surf->ofsVerts ); - for ( j = 0 ; j < surf->numVerts ; j++ ) - { - v->normal[0] = LittleFloat( v->normal[0] ); - v->normal[1] = LittleFloat( v->normal[1] ); - v->normal[2] = LittleFloat( v->normal[2] ); - - v->texCoords[0] = LittleFloat( v->texCoords[0] ); - v->texCoords[1] = LittleFloat( v->texCoords[1] ); - - v->numWeights = LittleLong( v->numWeights ); - v->offset[0] = LittleFloat( v->offset[0] ); - v->offset[1] = LittleFloat( v->offset[1] ); - v->offset[2] = LittleFloat( v->offset[2] ); - - for ( k = 0 ; k < /*v->numWeights*/surf->maxVertBoneWeights ; k++ ) - { - v->weights[k].boneIndex = LittleLong( v->weights[k].boneIndex ); - v->weights[k].boneWeight = LittleFloat( v->weights[k].boneWeight ); - } - v = (mdxmVertex_t *)&v->weights[/*v->numWeights*/surf->maxVertBoneWeights]; - } -#endif if (isAnOldModelFile) { @@ -4355,11 +4436,13 @@ void ShiftMemoryDown(mdxaSkelOffsets_t *offsets, mdxaHeader_t *mdxa, int boneInd memmove((nextBone+CHILD_PADDING), nextBone, size); memset(nextBone, 0, CHILD_PADDING); *endMarker += CHILD_PADDING; - //Move the whole thing down CHILD_PADDING amount in memory, clear the new preceding space, and increment the end pointer. + // Move the whole thing down CHILD_PADDING amount in memory, clear the new + // preceding space, and increment the end pointer. i = boneIndex+1; - //Now add CHILD_PADDING amount to every offset beginning at the offset of the bone that was moved. + // Now add CHILD_PADDING amount to every offset beginning at the offset of + // the bone that was moved. while (i < mdxa->numBones) { offsets->offsets[i] += CHILD_PADDING; @@ -4369,7 +4452,8 @@ void ShiftMemoryDown(mdxaSkelOffsets_t *offsets, mdxaHeader_t *mdxa, int boneInd mdxa->ofsFrames += CHILD_PADDING; mdxa->ofsCompBonePool += CHILD_PADDING; mdxa->ofsEnd += CHILD_PADDING; - //ofsSkel does not need to be updated because we are only moving memory after that point. + // ofsSkel does not need to be updated because we are only moving memory + // after that point. } //Proper/desired hierarchy list @@ -4403,7 +4487,11 @@ static const char *BoneHierarchyList[] = }; //Gets the index of a child or parent. If child is passed as qfalse then parent is assumed. -int BoneParentChildIndex(mdxaHeader_t *mdxa, mdxaSkelOffsets_t *offsets, mdxaSkel_t *boneInfo, qboolean child) +int BoneParentChildIndex( + mdxaHeader_t *mdxa, + mdxaSkelOffsets_t *offsets, + mdxaSkel_t *boneInfo, + qboolean child) { int i = 0; int matchindex = -1; @@ -4413,7 +4501,9 @@ int BoneParentChildIndex(mdxaHeader_t *mdxa, mdxaSkelOffsets_t *offsets, mdxaSke while (BoneHierarchyList[i]) { if (!Q_stricmp(boneInfo->name, BoneHierarchyList[i])) - { //we have a match, the slot above this will be our desired parent. (or below for child) + { + // we have a match, the slot above this will be our desired parent. + // (or below for child) if (child) { match = BoneHierarchyList[i+1]; @@ -4456,14 +4546,15 @@ int BoneParentChildIndex(mdxaHeader_t *mdxa, mdxaSkelOffsets_t *offsets, mdxaSke R_LoadMDXA - load a Ghoul 2 animation file ================= */ -qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached ) { +qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean &bAlreadyCached) +{ - mdxaHeader_t *pinmodel, *mdxa; - int version; - int size; + mdxaHeader_t *pinmodel, *mdxa; + int version; + int size; #ifdef CREATE_LIMB_HIERARCHY - int oSize = 0; - byte *sizeMarker; + int oSize = 0; + byte *sizeMarker; #endif #if 0 //#ifndef _M_IX86 @@ -4473,27 +4564,32 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean mdxaSkel_t *boneInfo; #endif - pinmodel = (mdxaHeader_t *)buffer; + pinmodel = (mdxaHeader_t *)buffer; + // + // read some fields from the binary, but only LittleLong() them when we know this wasn't an + // already-cached model... // - // read some fields from the binary, but only LittleLong() them when we know this wasn't an already-cached model... - // version = (pinmodel->version); - size = (pinmodel->ofsEnd); + size = (pinmodel->ofsEnd); if (!bAlreadyCached) { LL(version); LL(size); } - - if (version != MDXA_VERSION) { - Com_Printf (S_COLOR_YELLOW "R_LoadMDXA: %s has wrong version (%i should be %i)\n", - mod_name, version, MDXA_VERSION); + + if (version != MDXA_VERSION) + { + Com_Printf( + S_COLOR_YELLOW "R_LoadMDXA: %s has wrong version (%i should be %i)\n", + mod_name, + version, + MDXA_VERSION); return qfalse; } - mod->type = MOD_MDXA; - mod->dataSize += size; + mod->type = MOD_MDXA; + mod->dataSize += size; qboolean bAlreadyFound = qfalse; @@ -4501,29 +4597,32 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean oSize = size; int childNumber = (NUM_ROOTPARENTS + NUM_OTHERPARENTS); - size += (childNumber*(CHILD_PADDING*8)); //Allocate us some extra space so we can shift memory down. -#endif //CREATE_LIMB_HIERARCHY - //mdxa = mod->mdxa = (mdxaHeader_t*)ri->Hunk_Alloc( size, h_dontcare ); - mdxa = (mdxaHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA ); + // Allocate us some extra space so we can shift memory down. + size += (childNumber * (CHILD_PADDING * 8)); +#endif // CREATE_LIMB_HIERARCHY + + mdxa = (mdxaHeader_t *)CModelCache->Allocate( + size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLA); mod->data.gla = mdxa; - assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? + // I should probably eliminate 'bAlreadyFound', but wtf? + assert(bAlreadyCached == bAlreadyFound); if (!bAlreadyFound) { #ifdef CREATE_LIMB_HIERARCHY - memcpy( mdxa, buffer, oSize ); + memcpy(mdxa, buffer, oSize); #else - // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the - // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since - // we've hijacked that memory block... + // horrible new hackery, if !bAlreadyFound then we've just done a + // tag-morph, so we need to set the bool reference passed into this + // function to true, to tell the caller NOT to do an + // ri->FS_Freefile since we've hijacked that memory block... // // Aaaargh. Kill me now... // bAlreadyCached = qtrue; - assert( mdxa == buffer ); -// memcpy( mdxa, buffer, size ); // and don't do this now, since it's the same thing + assert(mdxa == buffer); #endif LL(mdxa->ident); LL(mdxa->version); @@ -4536,38 +4635,37 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean #ifdef CREATE_LIMB_HIERARCHY if (!bAlreadyFound) { - mdxaSkel_t *boneParent; -#if 0 //#ifdef _M_IX86 - mdxaSkel_t *boneInfo; - int i, k; -#endif + mdxaSkel_t *boneParent; sizeMarker = (byte *)mdxa + mdxa->ofsEnd; - //rww - This is probably temporary until we put actual hierarchy in for the models. - //It is necessary for the correct operation of ragdoll. - mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); + // rww - This is probably temporary until we put actual hierarchy in + // for the models. It is necessary for the correct operation of + // ragdoll. + mdxaSkelOffsets_t *offsets = (mdxaSkelOffsets_t *)((byte *)mdxa + sizeof(mdxaHeader_t)); - for ( i = 0 ; i < mdxa->numBones ; i++) + for (i = 0; i < mdxa->numBones; i++) { - boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + boneInfo = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[i]); if (boneInfo) { char *bname = boneInfo->name; if (BoneIsRootParent(bname)) - { //These are the main parent bones. We don't want to change their parents, but we want to give them children. + { + // These are the main parent bones. We don't want to change + // their parents, but we want to give them children. ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); - boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); + boneInfo = (mdxaSkel_t *)((byte *)offsets + offsets->offsets[i]); int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); if (newChild != -1) { boneInfo->numChildren++; - boneInfo->children[boneInfo->numChildren-1] = newChild; + boneInfo->children[boneInfo->numChildren - 1] = newChild; } else { @@ -4577,17 +4675,17 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean else if (BoneIsOtherParent(bname) || BoneIsBottom(bname)) { if (!BoneIsBottom(bname)) - { //unless it's last in the chain it has the next bone as a child. + { // unless it's last in the chain it has the next bone as a child. ShiftMemoryDown(offsets, mdxa, i, &sizeMarker); - boneInfo = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); - + boneInfo = (mdxaSkel_t *) + ((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[i]); int newChild = BoneParentChildIndex(mdxa, offsets, boneInfo, qtrue); if (newChild != -1) { boneInfo->numChildren++; - boneInfo->children[boneInfo->numChildren-1] = newChild; + boneInfo->children[boneInfo->numChildren - 1] = newChild; } else { @@ -4595,12 +4693,14 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean } } - //Before we set the parent we want to remove this as a child for whoever was parenting it. + // Before we set the parent we want to remove this as a + // child for whoever was parenting it. int oldParent = boneInfo->parent; if (oldParent > -1) { - boneParent = (mdxaSkel_t *)((byte *)mdxa + sizeof(mdxaHeader_t) + offsets->offsets[oldParent]); + boneParent = (mdxaSkel_t *) + ((byte *)offsets + offsets->offsets[oldParent]); } else { @@ -4614,14 +4714,14 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean while (k < boneParent->numChildren) { if (boneParent->children[k] == i) - { //this bone is the child + { // this bone is the child k++; while (k < boneParent->numChildren) { - boneParent->children[k-1] = boneParent->children[k]; + boneParent->children[k - 1] = boneParent->children[k]; k++; } - boneParent->children[k-1] = 0; + boneParent->children[k - 1] = 0; boneParent->numChildren--; break; } @@ -4629,7 +4729,8 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean } } - //Now that we have cleared the original parent of ownership, mark the bone's new parent. + // Now that we have cleared the original parent of + // ownership, mark the bone's new parent. int newParent = BoneParentChildIndex(mdxa, offsets, boneInfo, qfalse); if (newParent != -1) @@ -4644,64 +4745,19 @@ qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *mod_name, qboolean } } } -#endif //CREATE_LIMB_HIERARCHY +#endif // CREATE_LIMB_HIERARCHY - if ( mdxa->numFrames < 1 ) { - Com_Printf (S_COLOR_YELLOW "R_LoadMDXA: %s has no frames\n", mod_name ); + if (mdxa->numFrames < 1) + { + Com_Printf(S_COLOR_YELLOW "R_LoadMDXA: %s has no frames\n", mod_name); return qfalse; } if (bAlreadyFound) { - return qtrue; // All done, stop here, do not LittleLong() etc. Do not pass go... - } - -#if 0 //#ifndef _M_IX86 - - // - // optimisation, we don't bother doing this for standard intel case since our data's already in that format... - // - - // swap all the skeletal info - boneInfo = (mdxaSkel_t *)( (byte *)mdxa + mdxa->ofsSkel); - for ( i = 0 ; i < mdxa->numBones ; i++) - { - LL(boneInfo->numChildren); - LL(boneInfo->parent); - for (k=0; knumChildren; k++) - { - LL(boneInfo->children[k]); - } - - // get next bone - boneInfo += (size_t)( &((mdxaSkel_t *)0)->children[ boneInfo->numChildren ] ); + return qtrue; // All done, stop here, do not LittleLong() etc. Do not pass go... } - - // swap all the frames - frameSize = (size_t)( &((mdxaFrame_t *)0)->bones[ mdxa->numBones ] ); - for ( i = 0 ; i < mdxa->numFrames ; i++) - { - cframe = (mdxaFrame_t *) ( (byte *)mdxa + mdxa->ofsFrames + i * frameSize ); - cframe->radius = LittleFloat( cframe->radius ); - for ( j = 0 ; j < 3 ; j++ ) - { - cframe->bounds[0][j] = LittleFloat( cframe->bounds[0][j] ); - cframe->bounds[1][j] = LittleFloat( cframe->bounds[1][j] ); - cframe->localOrigin[j] = LittleFloat( cframe->localOrigin[j] ); - } - for ( j = 0 ; j < mdxa->numBones * sizeof( mdxaBone_t ) / 2 ; j++ ) - { - ((short *)cframe->bones)[j] = LittleShort( ((short *)cframe->bones)[j] ); - } - } -#endif return qtrue; } - - - - - - diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7ee538bbbf..c6b0a88927 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3037,27 +3037,34 @@ Ghoul2 Insert Start class CRenderableSurface { public: + // ident of this surface - required so the materials renderer knows what + // sort of surface this refers to + int ident; + + CBoneCache *boneCache; + mdxmVBOMesh_t *vboMesh; + + // pointer to surface data loaded into file - only used by client renderer + // DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of + // wack on the game + mdxmSurface_t *surfaceData; + #ifdef _G2_GORE - int ident; -#else - const int ident; // ident of this surface - required so the materials renderer knows what sort of surface this refers to -#endif - CBoneCache *boneCache; - mdxmVBOMesh_t *vboMesh; - mdxmSurface_t *surfaceData; // pointer to surface data loaded into file - only used by client renderer DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of wack on the game -#ifdef _G2_GORE - float *alternateTex; // alternate texture coordinates. - void *goreChain; + // alternate texture coordinates + float *alternateTex; + void *goreChain; - float scale; - float fade; - float impactTime; // this is a number between 0 and 1 that dictates the progression of the bullet impact + float scale; + float fade; + + // this is a number between 0 and 1 that dictates the progression of the + // bullet impact + float impactTime; #endif -#ifdef _G2_GORE - CRenderableSurface& operator= ( const CRenderableSurface& src ) + CRenderableSurface& operator =( const CRenderableSurface& src ) { - ident = src.ident; + ident = src.ident; boneCache = src.boneCache; surfaceData = src.surfaceData; alternateTex = src.alternateTex; @@ -3066,29 +3073,31 @@ class CRenderableSurface return *this; } -#endif - CRenderableSurface(): - ident(SF_MDX), - boneCache(0), + CRenderableSurface() + : ident(SF_MDX) + , boneCache(nullptr) + , vboMesh(nullptr) + , surfaceData(nullptr) #ifdef _G2_GORE - surfaceData(0), - alternateTex(0), - goreChain(0) -#else - surfaceData(0) + , alternateTex(nullptr) + , goreChain(nullptr) + , scale(1.0f) + , fade(0.0f) + , impactTime(0.0f) #endif - {} + { + } #ifdef _G2_GORE void Init() { ident = SF_MDX; - boneCache=0; - surfaceData=0; - alternateTex=0; - goreChain=0; - vboMesh = NULL; + boneCache = nullptr; + surfaceData = nullptr; + alternateTex = nullptr; + goreChain = nullptr; + vboMesh = nullptr; } #endif }; From b4b97e55b14e067a8facaa950a7f3c11d198ecaa Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 15 Jan 2017 16:16:36 +0000 Subject: [PATCH 401/708] Rend2: Refactor BSP loading into new function --- codemp/rd-rend2/tr_bsp.cpp | 221 +++++++++++++++++++++++-------------- codemp/rd-rend2/tr_local.h | 4 + 2 files changed, 142 insertions(+), 83 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b6cb69b233..2447942757 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -38,9 +38,6 @@ void RE_LoadWorldMap( const char *name ); static world_t s_worldData; static byte *fileBase; -int c_subdivisions; -int c_gridVerts; - //=============================================================================== static void HSVtoRGB( float h, float s, float v, float rgb[3] ) @@ -2266,7 +2263,6 @@ static void R_LoadSubmodels( world_t *worldData, lump_t *l ) { model = R_AllocModel(); - assert( model != NULL ); // this should never happen if ( model == NULL ) { ri->Error(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed"); } @@ -3077,8 +3073,12 @@ static void R_MergeLeafSurfaces(world_t *worldData) surf1 = worldData->surfaces + surfNum1; - if ((*surf1->data != SF_GRID) && (*surf1->data != SF_TRIANGLES) && (*surf1->data != SF_FACE)) + if ((*surf1->data != SF_GRID) && + (*surf1->data != SF_TRIANGLES) && + (*surf1->data != SF_FACE)) + { continue; + } shader1 = surf1->shader; @@ -3111,7 +3111,9 @@ static void R_MergeLeafSurfaces(world_t *worldData) surf2 = worldData->surfaces + surfNum2; - if ((*surf2->data != SF_GRID) && (*surf2->data != SF_TRIANGLES) && (*surf2->data != SF_FACE)) + if ((*surf2->data != SF_GRID) && + (*surf2->data != SF_TRIANGLES) && + (*surf2->data != SF_FACE)) continue; shader2 = surf2->shader; @@ -3174,15 +3176,25 @@ static void R_MergeLeafSurfaces(world_t *worldData) } // Allocate merged surfaces - worldData->mergedSurfaces = (msurface_t *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); - worldData->mergedSurfacesViewCount = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); - worldData->mergedSurfacesDlightBits = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); - worldData->mergedSurfacesPshadowBits = (int *)ri->Hunk_Alloc(sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + worldData->mergedSurfaces = + (msurface_t *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); + worldData->mergedSurfacesViewCount = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); + worldData->mergedSurfacesDlightBits = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + worldData->mergedSurfacesPshadowBits = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); worldData->numMergedSurfaces = numMergedSurfaces; // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on - worldData->viewSurfaces = (int *)ri->Hunk_Alloc(sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); + worldData->viewSurfaces = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); // copy view surfaces into mark surfaces for (i = 0; i < worldData->nummarksurfaces; i++) @@ -3581,96 +3593,93 @@ static void R_GenerateSurfaceSprites( const world_t *world ) } } -/* -================= -RE_LoadWorldMap - -Called directly from cgame -================= -*/ -void RE_LoadWorldMap( const char *name ) { - int i; - dheader_t *header; +world_t *R_LoadBSP(const char *name, int *bspIndex) +{ union { byte *b; void *v; } buffer; - byte *startMarker; - world_t *worldData = &s_worldData; - if ( tr.worldMapLoaded ) { - ri->Error( ERR_DROP, "ERROR: attempted to redundantly load world map" ); + world_t *worldData; + if (bspIndex == nullptr) + { + worldData = &s_worldData; } + else + { + if (tr.numBspModels >= MAX_SUB_BSP) + { + // too many + return nullptr; + } - // set default map light scale - tr.mapLightScale = 1.0f; - tr.sunShadowScale = 0.5f; - - // set default sun direction to be used if it isn't - // overridden by a shader - tr.sunDirection[0] = 0.45f; - tr.sunDirection[1] = 0.3f; - tr.sunDirection[2] = 0.9f; - - VectorNormalize( tr.sunDirection ); - - // set default autoexposure settings - tr.autoExposureMinMax[0] = -2.0f; - tr.autoExposureMinMax[1] = 2.0f; - - // set default tone mapping settings - tr.toneMinAvgMaxLevel[0] = -8.0f; - tr.toneMinAvgMaxLevel[1] = -2.0f; - tr.toneMinAvgMaxLevel[2] = 0.0f; - - tr.worldMapLoaded = qtrue; - - // load it - ri->FS_ReadFile( name, &buffer.v ); - if ( !buffer.b ) { - ri->Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); + *bspIndex = tr.numBspModels; + worldData = tr.bspModels[tr.numBspModels]; + ++tr.numBspModels; } - // clear tr.world so if the level fails to load, the next - // try will not look at the partially loaded version - tr.world = NULL; + // load it + ri->FS_ReadFile(name, &buffer.v); + if (!buffer.b) + { + if (bspIndex == nullptr) + { + ri->Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); + } - Com_Memset( worldData, 0, sizeof( *worldData ) ); - Q_strncpyz( worldData->name, name, sizeof( worldData->name ) ); + return nullptr; + } - Q_strncpyz( worldData->baseName, COM_SkipPath( worldData->name ), sizeof( worldData->name ) ); + Com_Memset(worldData, 0, sizeof(*worldData)); + Q_strncpyz(worldData->name, name, sizeof(worldData->name)); + Q_strncpyz(worldData->baseName, COM_SkipPath(worldData->name), sizeof(worldData->name)); COM_StripExtension(worldData->baseName, worldData->baseName, sizeof(worldData->baseName)); - startMarker = (byte *)ri->Hunk_Alloc(0, h_low); - c_gridVerts = 0; - - header = (dheader_t *)buffer.b; + byte *startMarker = (byte *)ri->Hunk_Alloc(0, h_low); + dheader_t *header = (dheader_t *)buffer.b; fileBase = (byte *)header; - i = LittleLong (header->version); - if ( i != BSP_VERSION ) { - ri->Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)", - name, i, BSP_VERSION); + int bspVersion = LittleLong(header->version); + if (bspVersion != BSP_VERSION) + { + ri->Error( + ERR_DROP, + "R_LoadBSP: %s has wrong version number (%i should be %i)", + name, + bspVersion, + BSP_VERSION); } // swap all the lumps - for (i=0 ; ilumps[LUMP_ENTITIES] ); - R_LoadShaders( worldData, &header->lumps[LUMP_SHADERS] ); - R_LoadLightmaps( worldData, &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES] ); - R_LoadPlanes( worldData, &header->lumps[LUMP_PLANES] ); - R_LoadFogs( worldData, &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] ); - R_LoadSurfaces( worldData, &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] ); - R_LoadMarksurfaces( worldData, &header->lumps[LUMP_LEAFSURFACES] ); - R_LoadNodesAndLeafs( worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS] ); - R_LoadSubmodels( worldData, &header->lumps[LUMP_MODELS] ); - R_LoadVisibility( worldData, &header->lumps[LUMP_VISIBILITY] ); - R_LoadLightGrid( worldData, &header->lumps[LUMP_LIGHTGRID] ); - R_LoadLightGridArray( worldData, &header->lumps[LUMP_LIGHTARRAY] ); + R_LoadEntities(worldData, &header->lumps[LUMP_ENTITIES]); + R_LoadShaders(worldData, &header->lumps[LUMP_SHADERS]); + R_LoadLightmaps( + worldData, + &header->lumps[LUMP_LIGHTMAPS], + &header->lumps[LUMP_SURFACES]); + R_LoadPlanes(worldData, &header->lumps[LUMP_PLANES]); + R_LoadFogs( + worldData, + &header->lumps[LUMP_FOGS], + &header->lumps[LUMP_BRUSHES], + &header->lumps[LUMP_BRUSHSIDES]); + R_LoadSurfaces( + worldData, + &header->lumps[LUMP_SURFACES], + &header->lumps[LUMP_DRAWVERTS], + &header->lumps[LUMP_DRAWINDEXES]); + R_LoadMarksurfaces(worldData, &header->lumps[LUMP_LEAFSURFACES]); + R_LoadNodesAndLeafs(worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); + R_LoadSubmodels(worldData, &header->lumps[LUMP_MODELS]); + R_LoadVisibility(worldData, &header->lumps[LUMP_VISIBILITY]); + R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); + R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); R_GenerateSurfaceSprites(worldData); @@ -3702,9 +3711,6 @@ void RE_LoadWorldMap( const char *name ) { worldData->dataSize = (byte *)ri->Hunk_Alloc(0, h_low) - startMarker; - // only set tr.world now that we know the entire level has loaded properly - tr.world = worldData; - // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); @@ -3715,5 +3721,54 @@ void RE_LoadWorldMap( const char *name ) { R_RenderAllCubemaps(); } - ri->FS_FreeFile( buffer.v ); + ri->FS_FreeFile(buffer.v); + + return worldData; +} + +/* +================= +RE_LoadWorldMap + +Called directly from cgame +================= +*/ +void RE_LoadWorldMap( const char *name ) { + if (tr.worldMapLoaded) + { + ri->Error(ERR_DROP, "ERROR: attempted to redundantly load world map"); + } + + world_t *world = R_LoadBSP(name); + if (world == nullptr) + { + // clear tr.world so the next/ try will not look at the partially + // loaded version + tr.world = nullptr; + return; + } + + tr.worldMapLoaded = qtrue; + tr.world = world; + + // set default map light scale + tr.mapLightScale = 1.0f; + tr.sunShadowScale = 0.5f; + + // set default sun direction to be used if it isn't + // overridden by a shader + tr.sunDirection[0] = 0.45f; + tr.sunDirection[1] = 0.3f; + tr.sunDirection[2] = 0.9f; + + VectorNormalize(tr.sunDirection); + + // set default autoexposure settings + tr.autoExposureMinMax[0] = -2.0f; + tr.autoExposureMinMax[1] = 2.0f; + + // set default tone mapping settings + tr.toneMinAvgMaxLevel[0] = -8.0f; + tr.toneMinAvgMaxLevel[1] = -2.0f; + tr.toneMinAvgMaxLevel[2] = 0.0f; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c6b0a88927..977bea4558 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2321,6 +2321,9 @@ typedef struct trGlobals_s { model_t *models[MAX_MOD_KNOWN]; int numModels; + world_t *bspModels[MAX_SUB_BSP]; + int numBspModels; + int numImages; image_t *images; image_t *imagesFreeList; @@ -2640,6 +2643,7 @@ qhandle_t RE_RegisterModel( const char *name ); qhandle_t RE_RegisterServerSkin( const char *name ); qhandle_t RE_RegisterSkin( const char *name ); void RE_Shutdown( qboolean destroyWindow ); +world_t *R_LoadBSP(const char *name, int *bspIndex = nullptr); qboolean R_GetEntityToken( char *buffer, int size ); From 9db8cfa6ed1629fe59922f3187911d99cf76e347 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 22 Jan 2017 12:58:21 +0000 Subject: [PATCH 402/708] Rend2: Add misc_bsp support --- codemp/rd-rend2/tr_bsp.cpp | 14 ++++---- codemp/rd-rend2/tr_local.h | 4 +-- codemp/rd-rend2/tr_model.cpp | 27 +++++++++++++-- codemp/rd-rend2/tr_world.cpp | 65 ++++++++++++++++++------------------ 4 files changed, 67 insertions(+), 43 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 2447942757..e24704d594 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2245,7 +2245,7 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu R_LoadSubmodels ================= */ -static void R_LoadSubmodels( world_t *worldData, lump_t *l ) { +static void R_LoadSubmodels( world_t *worldData, int worldIndex, lump_t *l ) { dmodel_t *in; bmodel_t *out; int i, j, count; @@ -2278,10 +2278,11 @@ static void R_LoadSubmodels( world_t *worldData, lump_t *l ) { CModelCache->InsertModelHandle(model->name, model->index); + out->worldIndex = worldIndex; out->firstSurface = LittleLong( in->firstSurface ); out->numSurfaces = LittleLong( in->numSurfaces ); - if(i == 0) + if (i == 0) { // Add this for limiting VBO surface creation worldData->numWorldSurfaces = out->numSurfaces; @@ -3601,6 +3602,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } buffer; world_t *worldData; + int worldIndex = -1; if (bspIndex == nullptr) { worldData = &s_worldData; @@ -3613,7 +3615,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) return nullptr; } - *bspIndex = tr.numBspModels; + worldIndex = *bspIndex = tr.numBspModels; worldData = tr.bspModels[tr.numBspModels]; ++tr.numBspModels; } @@ -3635,7 +3637,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) Q_strncpyz(worldData->baseName, COM_SkipPath(worldData->name), sizeof(worldData->name)); COM_StripExtension(worldData->baseName, worldData->baseName, sizeof(worldData->baseName)); - byte *startMarker = (byte *)ri->Hunk_Alloc(0, h_low); + const byte *startMarker = (const byte *)ri->Hunk_Alloc(0, h_low); dheader_t *header = (dheader_t *)buffer.b; fileBase = (byte *)header; @@ -3676,7 +3678,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) &header->lumps[LUMP_DRAWINDEXES]); R_LoadMarksurfaces(worldData, &header->lumps[LUMP_LEAFSURFACES]); R_LoadNodesAndLeafs(worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); - R_LoadSubmodels(worldData, &header->lumps[LUMP_MODELS]); + R_LoadSubmodels(worldData, worldIndex, &header->lumps[LUMP_MODELS]); R_LoadVisibility(worldData, &header->lumps[LUMP_VISIBILITY]); R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); @@ -3709,7 +3711,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_MergeLeafSurfaces(worldData); } - worldData->dataSize = (byte *)ri->Hunk_Alloc(0, h_low) - startMarker; + worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; // make sure the VBO glState entries are safe R_BindNullVBO(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 977bea4558..d06134c41f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1700,7 +1700,6 @@ typedef struct cullinfo_s { } cullinfo_t; typedef struct msurface_s { - //int viewCount; // if == tr.viewCount, already added struct shader_s *shader; int fogIndex; int cubemapIndex; @@ -1735,7 +1734,8 @@ typedef struct mnode_s { typedef struct { vec3_t bounds[2]; // for culling - int firstSurface; + int worldIndex; + int firstSurface; int numSurfaces; } bmodel_t; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index bf9578ff45..0553e643d4 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -255,6 +255,30 @@ model_t *R_AllocModel( void ) { return mod; } +static qhandle_t RE_RegisterBSP(const char *name) +{ + char bspFilePath[MAX_QPATH]; + Com_sprintf(bspFilePath, sizeof(bspFilePath), "maps/%s.bsp", name + 1); + + int bspIndex; + world_t *world = R_LoadBSP(bspFilePath, &bspIndex); + if (world == nullptr) + { + return 0; + } + + char bspModelIdent[MAX_QPATH]; + Com_sprintf(bspModelIdent, sizeof(bspModelIdent), "*%d-0", bspIndex); + + qhandle_t modelHandle = CModelCache->GetModelHandle(bspModelIdent); + if (modelHandle == -1) + { + return 0; + } + + return modelHandle; +} + /* ==================== RE_RegisterModel @@ -301,8 +325,7 @@ qhandle_t RE_RegisterModel( const char *name ) { if( name[0] == '#' ) { - // TODO: BSP models - return 0; + return RE_RegisterBSP(name); } // allocate a new model_t diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 35786dcdda..bc4901ffee 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -22,6 +22,17 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" +static world_t *R_GetWorld(int worldIndex) +{ + if (worldIndex == -1) + { + return tr.world; + } + else + { + return tr.bspModels[worldIndex]; + } +} /* ================ @@ -321,7 +332,13 @@ static int R_PshadowSurface( msurface_t *surf, int pshadowBits ) { R_AddWorldSurface ====================== */ -static void R_AddWorldSurface( msurface_t *surf, const trRefEntity_t *entity, int entityNum, int dlightBits, int pshadowBits ) { +static void R_AddWorldSurface( + msurface_t *surf, + const trRefEntity_t *entity, + int entityNum, + int dlightBits, + int pshadowBits) +{ // FIXME: bmodel fog? // try to cull before dlighting or adding @@ -374,16 +391,9 @@ R_AddBrushModelSurfaces ================= */ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { - bmodel_t *bmodel; - int clip; - model_t *pModel; - int i; - - pModel = R_GetModelByHandle( ent->e.hModel ); - - bmodel = pModel->data.bmodel; - - clip = R_CullLocalBox( bmodel->bounds ); + model_t *pModel = R_GetModelByHandle( ent->e.hModel ); + bmodel_t *bmodel = pModel->data.bmodel; + int clip = R_CullLocalBox( bmodel->bounds ); if ( clip == CULL_OUT ) { return; } @@ -391,13 +401,14 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { R_SetupEntityLighting( &tr.refdef, ent ); R_DlightBmodel( bmodel, ent ); - for ( i = 0 ; i < bmodel->numSurfaces ; i++ ) { + for ( int i = 0 ; i < bmodel->numSurfaces ; i++ ) { int surf = bmodel->firstSurface + i; + world_t *world = R_GetWorld(bmodel->worldIndex); - if (tr.world->surfacesViewCount[surf] != tr.viewCount) + if (world->surfacesViewCount[surf] != tr.viewCount) { - tr.world->surfacesViewCount[surf] = tr.viewCount; - R_AddWorldSurface(tr.world->surfaces + surf, ent, entityNum, ent->needDlights, 0); + world->surfacesViewCount[surf] = tr.viewCount; + R_AddWorldSurface(world->surfaces + surf, ent, entityNum, ent->needDlights, 0); } } } @@ -558,25 +569,13 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, tr.pc.c_leafs++; // add to z buffer bounds - if ( node->mins[0] < tr.viewParms.visBounds[0][0] ) { - tr.viewParms.visBounds[0][0] = node->mins[0]; - } - if ( node->mins[1] < tr.viewParms.visBounds[0][1] ) { - tr.viewParms.visBounds[0][1] = node->mins[1]; - } - if ( node->mins[2] < tr.viewParms.visBounds[0][2] ) { - tr.viewParms.visBounds[0][2] = node->mins[2]; - } + tr.viewParms.visBounds[0][0] = std::min(node->mins[0], tr.viewParms.visBounds[0][0]); + tr.viewParms.visBounds[0][1] = std::min(node->mins[1], tr.viewParms.visBounds[0][1]); + tr.viewParms.visBounds[0][2] = std::min(node->mins[2], tr.viewParms.visBounds[0][2]); - if ( node->maxs[0] > tr.viewParms.visBounds[1][0] ) { - tr.viewParms.visBounds[1][0] = node->maxs[0]; - } - if ( node->maxs[1] > tr.viewParms.visBounds[1][1] ) { - tr.viewParms.visBounds[1][1] = node->maxs[1]; - } - if ( node->maxs[2] > tr.viewParms.visBounds[1][2] ) { - tr.viewParms.visBounds[1][2] = node->maxs[2]; - } + tr.viewParms.visBounds[1][0] = std::min(node->maxs[0], tr.viewParms.visBounds[1][0]); + tr.viewParms.visBounds[1][1] = std::min(node->maxs[1], tr.viewParms.visBounds[1][1]); + tr.viewParms.visBounds[1][2] = std::min(node->maxs[2], tr.viewParms.visBounds[1][2]); // add merged and unmerged surfaces if (tr.world->viewSurfaces && !r_nocurves->integer) From c48507f46786cbb2b94d52dd3be4d21029b578f5 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 10 Feb 2017 23:01:08 +0000 Subject: [PATCH 403/708] Support geometry shader and add weather glsl --- codemp/rd-rend2/glsl/compact.cpp | 2 ++ codemp/rd-rend2/glsl/weather.glsl | 46 +++++++++++++++++++++++++ codemp/rd-rend2/tr_glsl.cpp | 21 ++++++++++++ codemp/rd-rend2/tr_glsl_parse.cpp | 57 ++++++++++++++++++------------- codemp/rd-rend2/tr_local.h | 3 +- 5 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 codemp/rd-rend2/glsl/weather.glsl diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 7a2fc52ca6..d13d164440 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -69,6 +69,7 @@ const char *GetShaderSuffix( GPUShaderType type ) { case GPUSHADER_VERTEX: return "_vp"; case GPUSHADER_FRAGMENT: return "_fp"; + case GPUSHADER_GEOMETRY: return "_gp"; default: assert(!"Invalid shader type"); } return nullptr; @@ -80,6 +81,7 @@ const char *ToString( GPUShaderType type ) { case GPUSHADER_VERTEX: return "GPUSHADER_VERTEX"; case GPUSHADER_FRAGMENT: return "GPUSHADER_FRAGMENT"; + case GPUSHADER_GEOMETRY: return "GPUSHADER_GEOMETRY"; default: assert(!"Invalid shader type"); } return nullptr; diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl new file mode 100644 index 0000000000..841d8226df --- /dev/null +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -0,0 +1,46 @@ +/*[Vertex]*/ +in vec3 in_Position; + +void main() +{ + gl_Position = vec4(in_Position, 1.0); +} + +/*[Geometry]*/ +layout(points) in; +layout(triangle_strip, max_vertices = 4) out; + +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec3 u_ViewOrigin; + +void main() +{ + const vec2 dirs[] = vec2[]( + vec2(-2.0, -2.0), + vec2( 2.0, -2.0), + vec2( 2.0, 2.0), + vec2(-2.0, 2.0) + ); + + vec3 V = u_ViewOrigin - gl_in.gl_Position; + vec2 toCamera = normalize(V.xy); + toCamera.xy = vec2(toCamera.y, -toCamera.x); + + for (int i = 0; i < 4; ++i) + { + vec3 P = gl_in.gl_Position.xyz; + vec4 worldPos = vec4(P.xy + dirs[i] * toCamera, P.z, 1.0); + gl_Position = u_ModelViewProjection * worldPos; + EmitVertex(); + } + + EndPrimitive(); +} + +/*[Fragment]*/ +out vec4 out_Color; + +void main() +{ + out_Color = vec4(1.0, 1.0, 0.0, 1.0); +} diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 306b832e20..2dec732d0c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -43,6 +43,7 @@ extern const GPUProgramDesc fallback_tonemapProgram; extern const GPUProgramDesc fallback_dglow_downsampleProgram; extern const GPUProgramDesc fallback_dglow_upsampleProgram; extern const GPUProgramDesc fallback_surface_spritesProgram; +extern const GPUProgramDesc fallback_weatherProgram; const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { @@ -1785,6 +1786,16 @@ int GLSL_BeginLoadGPUShaders(void) } allocator.Reset(); + ///////////////////////////////////////////////////////////////////////////// + programDesc = LoadProgramSource("weather", allocator, fallback_weatherProgram); + attribs = ATTR_POSITION; + + if (!GLSL_BeginLoadGPUShader(&tr.weatherShader, "weather", attribs, + nullptr, *programDesc)) + { + ri->Error(ERR_FATAL, "Could not load weather shader!"); + } + allocator.Reset(); return startTime; } @@ -2094,6 +2105,16 @@ void GLSL_EndLoadGPUShaders ( int startTime ) numEtcShaders++; } + if (!GLSL_EndLoadGPUShader(&tr.weatherShader)) + { + ri->Error(ERR_FATAL, "Could not load weather shader!"); + } + + GLSL_InitUniforms(&tr.weatherShader); + GLSL_FinishGPUShader(&tr.weatherShader); + + numEtcShaders++; + #if 0 attribs = ATTR_POSITION | ATTR_TEXCOORD0; extradefines[0] = '\0'; diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index 118341a6ac..252e39ee8a 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -131,36 +131,47 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) prevBlock->blockTextLength = (text + i) - prevBlock->blockText; } - GPUProgramDesc theProgram = {}; - theProgram.numShaders = 2; + static const char *shaderBlockNames[GPUSHADER_TYPE_COUNT] = { + "Vertex", "Fragment", "Geometry" + }; - Block *vertexBlock = FindBlock("Vertex", blocks, numBlocks); - Block *fragmentBlock = FindBlock("Fragment", blocks, numBlocks); + GPUProgramDesc theProgram = {}; + const Block *parsedBlocks[GPUSHADER_TYPE_COUNT] = {}; + for ( const auto& shaderBlockName : shaderBlockNames ) + { + Block *block = FindBlock(shaderBlockName, blocks, numBlocks); + if ( block ) + { + parsedBlocks[theProgram.numShaders++] = block; + } + } theProgram.shaders = ojkAllocArray(allocator, theProgram.numShaders); - char *vertexSource = ojkAllocString(allocator, vertexBlock->blockTextLength); - char *fragmentSource = ojkAllocString(allocator, fragmentBlock->blockTextLength); - - strncpy_s(vertexSource, vertexBlock->blockTextLength + 1, - vertexBlock->blockText, vertexBlock->blockTextLength); - strncpy_s(fragmentSource, fragmentBlock->blockTextLength + 1, - fragmentBlock->blockText, fragmentBlock->blockTextLength); + int shaderIndex = 0; + for ( int shaderType = 0; + shaderType < theProgram.numShaders; + ++shaderType ) + { + const Block *block = parsedBlocks[shaderType]; + if ( !block ) + { + continue; + } - theProgram.shaders[0].type = GPUSHADER_VERTEX; - theProgram.shaders[0].source = vertexSource; - theProgram.shaders[0].firstLine = vertexBlock->blockTextFirstLine; + char *source = ojkAllocString(allocator, block->blockTextLength); - theProgram.shaders[1].type = GPUSHADER_FRAGMENT; - theProgram.shaders[1].source = fragmentSource; - theProgram.shaders[1].firstLine = fragmentBlock->blockTextFirstLine; + strncpy_s( + source, + block->blockTextLength + 1, + block->blockText, + block->blockTextLength); - Block *geometryBlock = FindBlock("Geometry", blocks, numBlocks); - if ( geometryBlock ) - { - theProgram.shaders[2].type = GPUSHADER_FRAGMENT; - theProgram.shaders[2].source = fragmentSource; - theProgram.shaders[2].firstLine = fragmentBlock->blockTextFirstLine; + GPUShaderDesc& shaderDesc = theProgram.shaders[shaderIndex]; + shaderDesc.type = static_cast(shaderType); + shaderDesc.source = source; + shaderDesc.firstLine = block->blockTextFirstLine; + ++shaderIndex; } return theProgram; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d06134c41f..2b503daaf6 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1143,10 +1143,10 @@ struct Block enum GPUShaderType { - GPUSHADER_NONE, GPUSHADER_VERTEX, GPUSHADER_FRAGMENT, GPUSHADER_GEOMETRY, + GPUSHADER_TYPE_COUNT }; struct GPUShaderDesc @@ -2287,6 +2287,7 @@ typedef struct trGlobals_s { shaderProgram_t dglowDownsample; shaderProgram_t dglowUpsample; shaderProgram_t spriteShader[SSDEF_COUNT]; + shaderProgram_t weatherShader; // ----------------------------------------- From 059db600c3119d553be515c56cd9fc04f1468b47 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Feb 2017 10:25:03 +0000 Subject: [PATCH 404/708] Rewrite GLSL loading code to support geom shaders Also add beginnings of weather system... --- codemp/rd-rend2/glsl/compact.cpp | 2 +- codemp/rd-rend2/glsl/weather.glsl | 6 +- codemp/rd-rend2/tr_allocator.cpp | 7 +- codemp/rd-rend2/tr_allocator.h | 1 + codemp/rd-rend2/tr_backend.cpp | 5 +- codemp/rd-rend2/tr_glsl.cpp | 1419 +++++++++++++++-------------- codemp/rd-rend2/tr_glsl_parse.cpp | 6 +- codemp/rd-rend2/tr_init.cpp | 5 +- codemp/rd-rend2/tr_local.h | 11 +- codemp/rd-rend2/tr_surface.cpp | 2 + codemp/rd-rend2/tr_weather.cpp | 15 +- codemp/rd-rend2/tr_weather.h | 2 +- 12 files changed, 781 insertions(+), 700 deletions(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index d13d164440..4c39d68943 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -181,7 +181,7 @@ int main( int argc, char *argv[] ) ss << " { " << ToString(shaderDesc.type) << ", " "fallback_" << shaderName << suffix << ", " - << shaderDesc.firstLine << " },\n"; + << shaderDesc.firstLineNumber << " },\n"; } ss << "};\n"; diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 841d8226df..474f1679ae 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -22,15 +22,15 @@ void main() vec2(-2.0, 2.0) ); - vec3 V = u_ViewOrigin - gl_in.gl_Position; + vec3 P = gl_in[0].gl_Position.xyz; + vec3 V = u_ViewOrigin - P; vec2 toCamera = normalize(V.xy); toCamera.xy = vec2(toCamera.y, -toCamera.x); for (int i = 0; i < 4; ++i) { - vec3 P = gl_in.gl_Position.xyz; vec4 worldPos = vec4(P.xy + dirs[i] * toCamera, P.z, 1.0); - gl_Position = u_ModelViewProjection * worldPos; + gl_Position = u_ModelViewProjectionMatrix * worldPos; EmitVertex(); } diff --git a/codemp/rd-rend2/tr_allocator.cpp b/codemp/rd-rend2/tr_allocator.cpp index bde46d276d..4da0228c8c 100644 --- a/codemp/rd-rend2/tr_allocator.cpp +++ b/codemp/rd-rend2/tr_allocator.cpp @@ -49,6 +49,11 @@ void *Allocator::Base() const return alignedBase; } +size_t Allocator::GetSize() const +{ + return (size_t)((char *)end - (char *)alignedBase); +} + void *Allocator::Alloc( size_t allocSize ) { if ( (size_t)((char *)end - (char *)mark) < allocSize ) @@ -78,4 +83,4 @@ void Allocator::Reset() void Allocator::ResetTo( void *m ) { mark = m; -} \ No newline at end of file +} diff --git a/codemp/rd-rend2/tr_allocator.h b/codemp/rd-rend2/tr_allocator.h index abdf00a65a..1b891af62c 100644 --- a/codemp/rd-rend2/tr_allocator.h +++ b/codemp/rd-rend2/tr_allocator.h @@ -30,6 +30,7 @@ class Allocator Allocator( const Allocator& ) = delete; Allocator& operator=( const Allocator& ) = delete; + size_t GetSize() const; void *Base() const; void *Alloc( size_t allocSize ); void *Mark() const; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 736c5e81f3..cadf574fa8 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -935,7 +935,10 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t GL_Cull(drawItem.cullType); GL_State(drawItem.stateBits); GL_DepthRange(drawItem.depthRange.minDepth, drawItem.depthRange.maxDepth); - R_BindIBO(drawItem.ibo); + if ( drawItem.ibo != nullptr ) + { + R_BindIBO(drawItem.ibo); + } GLSL_BindProgram(drawItem.program); // FIXME: There was a reason I didn't have const on attributes. Can't remember at the moment diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 2dec732d0c..e647bca068 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -261,7 +261,12 @@ static void GLSL_PrintShaderSource(GLuint shader) Z_Free(msg); } -static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, int firstLine, char *dest, size_t size ) +static size_t GLSL_GetShaderHeader( + GLenum shaderType, + const GLcharARB *extra, + int firstLineNumber, + char *dest, + size_t size) { float fbufWidthScale, fbufHeightScale; @@ -373,60 +378,102 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLcharARB *extra, int Q_strcat(dest, size, extra); } - // OK we added a lot of stuff but if we do something bad in the GLSL shaders then we want the proper line - // so we have to reset the line counting - Q_strcat(dest, size, va("#line %d\n", firstLine - 1)); + // OK we added a lot of stuff but if we do something bad in the GLSL + // shaders then we want the proper line so we have to reset the line + // counting + Q_strcat(dest, size, va("#line %d\n", firstLineNumber - 1)); + + return strlen(dest); } -static int GLSL_EnqueueCompileGPUShader(GLuint program, GLuint *prevShader, const GLchar *buffer, int size, GLenum shaderType) +static bool GLSL_IsGPUShaderCompiled (GLuint shader) { - GLuint shader; + GLint compiled; + qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); + return (compiled == GL_TRUE); +} - shader = qglCreateShader(shaderType); +static GLuint GLSL_CompileGPUShader( + GLuint program, + const GLchar *buffer, + int size, + GLenum shaderType) +{ + GLuint shader = qglCreateShader(shaderType); + if ( shader == 0 ) + { + return 0; + } qglShaderSource(shader, 1, &buffer, &size); - - // compile shader qglCompileShader(shader); - *prevShader = shader; + if ( !GLSL_IsGPUShaderCompiled(shader) ) + { + GLSL_PrintShaderSource(shader); + GLSL_PrintShaderInfoLog(shader, qfalse); + + qglDeleteShader(shader); - return 1; + ri->Error(ERR_FATAL, "Couldn't compile shader"); + return 0; + } + + return shader; } -static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, - GLenum shaderType, char *dest, int destSize) +static const char *GLSL_GetShaderFileSuffix( GLenum shaderType ) { - char filename[MAX_QPATH]; - GLcharARB *buffer = NULL; - const GLcharARB *shaderText = NULL; - int size; - int result; + static struct + { + GLenum shaderType; + const char *extension; + } shaderToFileExtensionSuffix[] = { + { GL_VERTEX_SHADER, "vp" }, + { GL_FRAGMENT_SHADER, "fp" }, + { GL_GEOMETRY_SHADER, "gp" }, + }; - if(shaderType == GL_VERTEX_SHADER) + for ( const auto& suffix : shaderToFileExtensionSuffix ) { - Com_sprintf(filename, sizeof(filename), "glsl/%s_vp.glsl", name); - } - else - { - Com_sprintf(filename, sizeof(filename), "glsl/%s_fp.glsl", name); + if ( shaderType == suffix.shaderType ) + { + return suffix.extension; + } } - if ( r_externalGLSL->integer ) { - size = ri->FS_ReadFile( filename, (void **)&buffer ); - } - else { - size = 0; - buffer = NULL; + return nullptr; +} + +static size_t GLSL_LoadGPUShaderSource( + const char *name, + const char *fallback, + GLenum shaderType, + char *dest, + int destSize) +{ + const char *shaderSuffix = GLSL_GetShaderFileSuffix(shaderType); + assert(shaderSuffix != nullptr); + + char filename[MAX_QPATH]; + Com_sprintf(filename, sizeof(filename), "glsl/%s_%s.glsl", name, shaderSuffix); + + int shaderTextLen = 0; + GLcharARB *buffer = nullptr; + if ( r_externalGLSL->integer ) + { + shaderTextLen = ri->FS_ReadFile(filename, (void **)&buffer); } - if(!buffer) + const char *shaderText = nullptr; + if ( !buffer ) { - if (fallback) + if ( fallback ) { ri->Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename); shaderText = fallback; - size = strlen(shaderText); + shaderTextLen = strlen(shaderText); + ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); } else { @@ -440,17 +487,14 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, shaderText = buffer; } - if (size > destSize) - { - result = 0; - } - else + int result = 0; + if ( destSize >= (shaderTextLen + 1) ) { - Q_strncpyz(dest, shaderText, size + 1); - result = 1; + Q_strncpyz(dest, shaderText, destSize); + result = strlen(dest); } - if (buffer) + if ( buffer ) { ri->FS_FreeFile(buffer); } @@ -460,16 +504,15 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback, static void GLSL_LinkProgram(GLuint program) { - GLint linked; - qglLinkProgram(program); + GLint linked; qglGetProgramiv(program, GL_LINK_STATUS, &linked); - if(!linked) + if ( linked != GL_TRUE ) { GLSL_PrintProgramInfoLog(program, qfalse); ri->Printf(PRINT_ALL, "\n"); - ri->Error(ERR_DROP, "shaders failed to link"); + ri->Error(ERR_FATAL, "shaders failed to link"); } } @@ -498,180 +541,233 @@ static void GLSL_ShowProgramUniforms(GLuint program) qglUseProgram(0); } -static int GLSL_BeginLoadGPUShader2(shaderProgram_t * program, const char *name, int attribs, const char *vpCode, const char *fpCode) +static void GLSL_BindShaderInterface( shaderProgram_t *program ) { - size_t nameBufSize = strlen (name) + 1; - - ri->Printf(PRINT_DEVELOPER, "------- GPU shader -------\n"); - - program->name = (char *)Z_Malloc (nameBufSize, TAG_GENERAL); - Q_strncpyz(program->name, name, nameBufSize); - - program->program = qglCreateProgram(); - program->attribs = attribs; + static const char *shaderInputNames[] = { + "attr_Position", // ATTR_INDEX_POSITION + "attr_TexCoord0", // ATTR_INDEX_TEXCOORD0 + "attr_TexCoord1", // ATTR_INDEX_TEXCOORD1 + "attr_TexCoord2", // ATTR_INDEX_TEXCOORD2 + "attr_TexCoord3", // ATTR_INDEX_TEXCOORD3 + "attr_TexCoord4", // ATTR_INDEX_TEXCOORD4 + "attr_Tangent", // ATTR_INDEX_TANGENT + "attr_Normal", // ATTR_INDEX_NORMAL + "attr_Color", // ATTR_INDEX_COLOR + "attr_PaintColor", // ATTR_INDEX_PAINTCOLOR + "attr_LightDirection", // ATTR_INDEX_LIGHTDIRECTION + "attr_BoneIndexes", // ATTR_INDEX_BONE_INDEXES + "attr_BoneWeights", // ATTR_INDEX_BONE_WEIGHTS + "attr_Position2", // ATTR_INDEX_POSITION2 + "attr_Tangent2", // ATTR_INDEX_TANGENT2 + "attr_Normal2", // ATTR_INDEX_NORMAL2 + }; - if (!(GLSL_EnqueueCompileGPUShader(program->program, &program->vertexShader, vpCode, strlen(vpCode), GL_VERTEX_SHADER))) - { - ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_VERTEX_SHADER\n", name); - qglDeleteProgram(program->program); - return 0; - } + static const char *shaderOutputNames[] = { + "out_Color", // Color output + "out_Glow", // Glow output + }; - if(fpCode) + const uint32_t attribs = program->attribs; + for ( int attribIndex = 0; attribIndex < ATTR_INDEX_MAX; ++attribIndex ) { - if(!(GLSL_EnqueueCompileGPUShader(program->program, &program->fragmentShader, fpCode, strlen(fpCode), GL_FRAGMENT_SHADER))) + if ( !(attribs & (1u << attribIndex)) ) { - ri->Printf(PRINT_ALL, "GLSL_BeginLoadGPUShader2: Unable to load \"%s\" as GL_FRAGMENT_SHADER\n", name); - qglDeleteProgram(program->program); - return 0; + continue; } - } - - return 1; -} -static bool GLSL_IsGPUShaderCompiled (GLuint shader) -{ - GLint compiled; + qglBindAttribLocation(program->program, attribIndex, shaderInputNames[attribIndex]); + } - qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled); - if (!compiled) + for ( int outputIndex = 0; outputIndex < ARRAY_LEN(shaderOutputNames); ++outputIndex ) { - GLSL_PrintShaderSource(shader); - GLSL_PrintShaderInfoLog(shader, qfalse); - ri->Error(ERR_DROP, "Couldn't compile shader"); - return qfalse; + qglBindFragDataLocation(program->program, outputIndex, shaderOutputNames[outputIndex]); } - return qtrue; } -static bool GLSL_EndLoadGPUShader (shaderProgram_t *program) +GLenum ToGLShaderType( GPUShaderType type ) { - uint32_t attribs = program->attribs; - - if (!GLSL_IsGPUShaderCompiled (program->vertexShader)) + switch ( type ) { - return false; - } + case GPUSHADER_VERTEX: + return GL_VERTEX_SHADER; - if (!GLSL_IsGPUShaderCompiled (program->fragmentShader)) - { - return false; - } + case GPUSHADER_FRAGMENT: + return GL_FRAGMENT_SHADER; - qglAttachShader(program->program, program->vertexShader); - qglAttachShader(program->program, program->fragmentShader); + case GPUSHADER_GEOMETRY: + return GL_GEOMETRY_SHADER; - qglBindFragDataLocation (program->program, 0, "out_Color"); - qglBindFragDataLocation (program->program, 1, "out_Glow"); + default: + assert(!"Invalid shader type"); + return 0; + } - if(attribs & ATTR_POSITION) - qglBindAttribLocation(program->program, ATTR_INDEX_POSITION, "attr_Position"); + return 0; +} - if(attribs & ATTR_TEXCOORD0) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD0, "attr_TexCoord0"); +class ShaderProgramBuilder +{ + public: + ShaderProgramBuilder(); + ~ShaderProgramBuilder(); - if(attribs & ATTR_TEXCOORD1) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD1, "attr_TexCoord1"); + ShaderProgramBuilder( const ShaderProgramBuilder& ) = delete; + ShaderProgramBuilder& operator=( const ShaderProgramBuilder& ) = delete; - if(attribs & ATTR_TEXCOORD2) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD2, "attr_TexCoord2"); + void Start( const char *name, const uint32_t attribs ); + bool AddShader( const GPUShaderDesc& shaderDesc, const char *extra ); + bool Build( shaderProgram_t *program ); - if(attribs & ATTR_TEXCOORD3) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD3, "attr_TexCoord3"); + private: + static const size_t MAX_SHADER_SOURCE_LEN = 16384; - if(attribs & ATTR_TEXCOORD4) - qglBindAttribLocation(program->program, ATTR_INDEX_TEXCOORD4, "attr_TexCoord4"); + void ReleaseShaders(); - if(attribs & ATTR_TANGENT) - qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT, "attr_Tangent"); + const char *name; + uint32_t attribs; + GLuint program; + GLuint shaderNames[GPUSHADER_TYPE_COUNT]; + size_t numShaderNames; + std::string shaderSource; +}; - if(attribs & ATTR_NORMAL) - qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL, "attr_Normal"); +ShaderProgramBuilder::ShaderProgramBuilder() + : name(nullptr) + , attribs(0) + , program(0) + , shaderNames() + , numShaderNames(0) + , shaderSource(MAX_SHADER_SOURCE_LEN, '\0') +{ +} - if(attribs & ATTR_COLOR) - qglBindAttribLocation(program->program, ATTR_INDEX_COLOR, "attr_Color"); +ShaderProgramBuilder::~ShaderProgramBuilder() +{ + if ( program ) + { + ReleaseShaders(); + qglDeleteProgram(program); + } +} - if(attribs & ATTR_PAINTCOLOR) - qglBindAttribLocation(program->program, ATTR_INDEX_PAINTCOLOR, "attr_PaintColor"); +void ShaderProgramBuilder::Start( const char *name, const uint32_t attribs ) +{ + this->program = qglCreateProgram(); + this->name = name; + this->attribs = attribs; +} - if(attribs & ATTR_LIGHTDIRECTION) - qglBindAttribLocation(program->program, ATTR_INDEX_LIGHTDIRECTION, "attr_LightDirection"); +bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const char *extra ) +{ + static const int MAX_ATTEMPTS = 3; + const GLenum apiShader = ToGLShaderType(shaderDesc.type); + + size_t sourceLen = 0; + size_t headerLen = 0; + int attempts = 0; + while ( sourceLen == 0 && attempts < MAX_ATTEMPTS ) + { + headerLen = GLSL_GetShaderHeader( + apiShader, + extra, + shaderDesc.firstLineNumber, + &shaderSource[0], + shaderSource.size()); + + sourceLen = GLSL_LoadGPUShaderSource( + name, + shaderDesc.source, + apiShader, + &shaderSource[headerLen], + shaderSource.size() - headerLen); + + if ( sourceLen == 0 ) + { + shaderSource.resize(shaderSource.size() * 2); + } + + ++attempts; + } - if(attribs & ATTR_POSITION2) - qglBindAttribLocation(program->program, ATTR_INDEX_POSITION2, "attr_Position2"); + if ( sourceLen == 0 ) + { + ri->Printf( + PRINT_ALL, + "ShaderProgramBuilder::AddShader: Failed to allocate enough memory for " + "shader '%s'\n", + name); - if(attribs & ATTR_NORMAL2) - qglBindAttribLocation(program->program, ATTR_INDEX_NORMAL2, "attr_Normal2"); + return false; + } - if(attribs & ATTR_TANGENT2) - qglBindAttribLocation(program->program, ATTR_INDEX_TANGENT2, "attr_Tangent2"); + const GLuint shader = GLSL_CompileGPUShader( + program, + shaderSource.c_str(), + sourceLen + headerLen, + apiShader); + if ( shader == 0 ) + { + ri->Printf( + PRINT_ALL, + "ShaderProgramBuilder::AddShader: Unable to load \"%s\"\n", + name); + return false; + } - if(attribs & ATTR_BONE_INDEXES) - qglBindAttribLocation(program->program, ATTR_INDEX_BONE_INDEXES, "attr_BoneIndexes"); + qglAttachShader(program, shader); + shaderNames[numShaderNames++] = shader; - if(attribs & ATTR_BONE_WEIGHTS) - qglBindAttribLocation(program->program, ATTR_INDEX_BONE_WEIGHTS, "attr_BoneWeights"); + return true; +} - GLSL_LinkProgram(program->program); +bool ShaderProgramBuilder::Build( shaderProgram_t *shaderProgram ) +{ + const size_t nameBufferSize = strlen(name) + 1; + shaderProgram->name = (char *)Z_Malloc(nameBufferSize, TAG_GENERAL); + Q_strncpyz(shaderProgram->name, name, nameBufferSize); - // Won't be needing these anymore... - qglDetachShader (program->program, program->vertexShader); - qglDetachShader (program->program, program->fragmentShader); + shaderProgram->program = program; + shaderProgram->attribs = attribs; - qglDeleteShader (program->vertexShader); - qglDeleteShader (program->fragmentShader); + GLSL_BindShaderInterface(shaderProgram); + GLSL_LinkProgram(shaderProgram->program); - program->vertexShader = program->fragmentShader = 0; + ReleaseShaders(); + program = 0; return true; } -static int GLSL_BeginLoadGPUShader( - shaderProgram_t *program, - const char *name, - uint32_t attribs, - const GLcharARB *extra, - const GPUProgramDesc& programDesc) +void ShaderProgramBuilder::ReleaseShaders() { - char vpCode[32000]; - char fpCode[32000]; - char *postHeader; - int size; - size_t vertexShaderCodeLen; - - assert(programDesc.numShaders == 2); - assert(programDesc.shaders[0].type == GPUSHADER_VERTEX); - assert(programDesc.shaders[1].type == GPUSHADER_FRAGMENT); - - size = sizeof(vpCode); - - GLSL_GetShaderHeader(GL_VERTEX_SHADER, extra, programDesc.shaders[0].firstLine, vpCode, size); - vertexShaderCodeLen = strlen(vpCode); - postHeader = &vpCode[vertexShaderCodeLen]; - size -= vertexShaderCodeLen; - - if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[0].source, GL_VERTEX_SHADER, postHeader, size)) + for ( size_t i = 0; i < numShaderNames; ++i ) { - return 0; + qglDetachShader(program, shaderNames[i]); + qglDeleteShader(shaderNames[i]); } - size_t fragmentShaderCodeLen; - - size = sizeof(fpCode); - - GLSL_GetShaderHeader(GL_FRAGMENT_SHADER, extra, programDesc.shaders[1].firstLine, fpCode, size); - fragmentShaderCodeLen = strlen(fpCode); - postHeader = &fpCode[fragmentShaderCodeLen]; - size -= fragmentShaderCodeLen; + numShaderNames = 0; +} - if (!GLSL_LoadGPUShaderText(name, programDesc.shaders[1].source, GL_FRAGMENT_SHADER, postHeader, size)) +static bool GLSL_LoadGPUShader( + ShaderProgramBuilder& builder, + shaderProgram_t *program, + const char *name, + const uint32_t attribs, + const GLcharARB *extra, + const GPUProgramDesc& programDesc) +{ + builder.Start(name, attribs); + for ( int i = 0; i < programDesc.numShaders; ++i ) { - return 0; + const GPUShaderDesc& shaderDesc = programDesc.shaders[i]; + if ( !builder.AddShader(shaderDesc, extra) ) + { + return false; + } } - - return GLSL_BeginLoadGPUShader2(program, name, attribs, vpCode, fpCode); + return builder.Build(program); } void GLSL_InitUniforms(shaderProgram_t *program) @@ -1158,84 +1254,24 @@ static const GPUProgramDesc *LoadProgramSource( return result; } -int GLSL_BeginLoadGPUShaders(void) +static int GLSL_LoadGPUProgramGeneric( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) { - int startTime; - int i; - char extradefines[1200]; - int attribs; - -#if 0 - // vertex size = 48 bytes - VertexFormat bspVertexFormat = { - { - { 3, false, GL_FLOAT, false, 0 }, // position - { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 - { 2, false, GL_HALF_FLOAT, false, 16 }, // tc1 - { 2, false, GL_HALF_FLOAT, false, 20 }, // tc2 - { 2, false, GL_HALF_FLOAT, false, 24 }, // tc3 - { 2, false, GL_HALF_FLOAT, false, 28 }, // tc4 - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 32 }, // tangent - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // normal - { 4, false, GL_FLOAT, false, 40 }, // color - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 44 }, // light dir - } - }; - - // vertex size = 32 bytes - VertexFormat rectVertexFormat = { - { - { 3, false, GL_FLOAT, false, 0 }, // position - { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 - { 4, false, GL_FLOAT, false, 16 } // color - } - }; - - // vertex size = 32 bytes - VertexFormat g2VertexFormat = { - { - { 3, false, GL_FLOAT, false, 0 }, // position - { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal - { 4, true, GL_UNSIGNED_BYTE, false, 24 }, // bone indices - { 4, false, GL_UNSIGNED_BYTE, true, 28 }, // bone weights - } - }; - - // vertex size = 44 bytes - VertexFormat md3VertexFormat = { - { - { 3, false, GL_FLOAT, false, 0 }, // position - { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal - { 3, false,p GL_FLOAT, false, 24 }, // pos2 - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // tangent - { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 40 }, // normal - } - }; -#endif - - ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); - - R_IssuePendingRenderCommands(); - - startTime = ri->Milliseconds(); + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - Allocator allocator(512 * 1024); - const GPUProgramDesc *programDesc; - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("generic", allocator, fallback_genericProgram); - for (i = 0; i < GENERICDEF_COUNT; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("generic", allocator, fallback_genericProgram); + for ( int i = 0; i < GENERICDEF_COUNT; i++ ) { - if (!GLSL_IsValidPermutationForGeneric (i)) + if (!GLSL_IsValidPermutationForGeneric(i)) { continue; } - attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_NORMAL | ATTR_COLOR; + uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_NORMAL | ATTR_COLOR; extradefines[0] = '\0'; if (i & GENERICDEF_USE_DEFORM_VERTEXES) @@ -1295,25 +1331,46 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.genericShader[i], "generic", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.genericShader[i], "generic", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load generic shader!"); } + + GLSL_InitUniforms(&tr.genericShader[i]); + + qglUseProgram(tr.genericShader[i].program); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); + qglUseProgram(0); + + GLSL_FinishGPUShader(&tr.genericShader[i]); + + ++numPrograms; } - allocator.Reset(); + return numPrograms; +} + +static int GLSL_LoadGPUProgramFogPass( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("fogpass", allocator, fallback_fogpassProgram); - for (i = 0; i < FOGDEF_COUNT; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("fogpass", allocator, fallback_fogpassProgram); + for ( int i = 0; i < FOGDEF_COUNT; i++ ) { if (!GLSL_IsValidPermutationForFog (i)) { continue; } - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; + uint32_t attribs = + (ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0); extradefines[0] = '\0'; if (i & FOGDEF_USE_DEFORM_VERTEXES) @@ -1355,20 +1412,34 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.fogShader[i], "fogpass", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.fogShader[i], "fogpass", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load fogpass shader!"); } + + GLSL_InitUniforms(&tr.fogShader[i]); + GLSL_FinishGPUShader(&tr.fogShader[i]); + + ++numPrograms; } - allocator.Reset(); + return numPrograms; +} + +static int GLSL_LoadGPUProgramDLight( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("dlight", allocator, fallback_dlightProgram); - for (i = 0; i < DLIGHTDEF_COUNT; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("dlight", allocator, fallback_dlightProgram); + for ( int i = 0; i < DLIGHTDEF_COUNT; i++ ) { - attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0; + uint32_t attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0; extradefines[0] = '\0'; if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) @@ -1403,19 +1474,39 @@ int GLSL_BeginLoadGPUShaders(void) break; } - if (!GLSL_BeginLoadGPUShader(&tr.dlightShader[i], "dlight", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load dlight shader!"); } + + GLSL_InitUniforms(&tr.dlightShader[i]); + + qglUseProgram(tr.dlightShader[i].program); + GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + qglUseProgram(0); + + GLSL_FinishGPUShader(&tr.dlightShader[i]); + + ++numPrograms; } - allocator.Reset(); + return numPrograms; +} + +static int GLSL_LoadGPUProgramLightAll( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("lightall", allocator, fallback_lightallProgram); - qboolean useFastLight = (qboolean)(!r_normalMapping->integer && !r_specularMapping->integer); - for (i = 0; i < LIGHTDEF_COUNT; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("lightall", allocator, fallback_lightallProgram); + const bool useFastLight = + (!r_normalMapping->integer && !r_specularMapping->integer); + for ( int i = 0; i < LIGHTDEF_COUNT; i++ ) { int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; @@ -1423,7 +1514,7 @@ int GLSL_BeginLoadGPUShaders(void) if (!GLSL_IsValidPermutationForLight (lightType, i)) continue; - attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_COLOR | ATTR_NORMAL; + uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_COLOR | ATTR_NORMAL; extradefines[0] = '\0'; @@ -1550,385 +1641,121 @@ int GLSL_BeginLoadGPUShaders(void) if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); - if (!GLSL_BeginLoadGPUShader(&tr.lightallShader[i], "lightall", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.lightallShader[i], "lightall", attribs, extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load lightall shader!"); } - } - allocator.Reset(); - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("texturecolor", allocator, fallback_texturecolorProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; + GLSL_InitUniforms(&tr.lightallShader[i]); - if (!GLSL_BeginLoadGPUShader(&tr.textureColorShader, "texturecolor", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); + qglUseProgram(tr.lightallShader[i].program); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_NORMALMAP, TB_NORMALMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); + qglUseProgram(0); + + GLSL_FinishGPUShader(&tr.lightallShader[i]); + + ++numPrograms; } - allocator.Reset(); + return numPrograms; +} - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("shadowfill", allocator, fallback_shadowfillProgram); - attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; - extradefines[0] = '\0'; +static int GLSL_LoadGPUProgramBasic( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc, + shaderProgram_t *shaderProgram, + const char *programName, + const GPUProgramDesc& programFallback, + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0) +{ + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - if (!GLSL_BeginLoadGPUShader(&tr.shadowmapShader, "shadowfill", attribs, + const GPUProgramDesc *programDesc = + LoadProgramSource(programName, allocator, programFallback); + if (!GLSL_LoadGPUShader(builder, shaderProgram, programName, attribs, nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); + ri->Error(ERR_FATAL, "Could not load %s shader!", programName); } - allocator.Reset(); + return 1; +} - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("pshadow", allocator, fallback_pshadowProgram); - attribs = ATTR_POSITION | ATTR_NORMAL; - extradefines[0] = '\0'; - Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); +static int GLSL_LoadGPUProgramTextureColor( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.textureColorShader, + "texturecolor", + fallback_texturecolorProgram); - if (!GLSL_BeginLoadGPUShader(&tr.pshadowShader, "pshadow", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load pshadow shader!"); - } - allocator.Reset(); + GLSL_InitUniforms(&tr.textureColorShader); + qglUseProgram(tr.textureColorShader.program); + GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); + qglUseProgram(0); - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("down4x", allocator, fallback_down4xProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; + GLSL_FinishGPUShader(&tr.textureColorShader); - if (!GLSL_BeginLoadGPUShader(&tr.down4xShader, "down4x", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load down4x shader!"); - } - allocator.Reset(); + return 1; +} +static int GLSL_LoadGPUProgramDepthFill( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("bokeh", allocator, fallback_bokehProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("shadowfill", allocator, fallback_shadowfillProgram); + const uint32_t attribs = + ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; - if (!GLSL_BeginLoadGPUShader(&tr.bokehShader, "bokeh", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load bokeh shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("tonemap", allocator, fallback_tonemapProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - - if (!GLSL_BeginLoadGPUShader(&tr.tonemapShader, "tonemap", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load tonemap shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("calclevels4x", allocator, fallback_calclevels4xProgram); - for (i = 0; i < 2; i++) - { - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - - if (!i) - Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); - - if (!GLSL_BeginLoadGPUShader(&tr.calclevels4xShader[i], "calclevels4x", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); - } - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("shadowmask", allocator, fallback_shadowmaskProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - - if (r_shadowFilter->integer >= 1) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER\n"); - - if (r_shadowFilter->integer >= 2) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); - - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_CASCADE\n"); - - Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); - Q_strcat(extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - - if (!GLSL_BeginLoadGPUShader(&tr.shadowmaskShader, "shadowmask", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("ssao", allocator, fallback_ssaoProgram); - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - - if (!GLSL_BeginLoadGPUShader(&tr.ssaoShader, "ssao", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load ssao shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("depthBlur", allocator, fallback_depthblurProgram); - for (i = 0; i < 2; i++) - { - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - - if (i & 1) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTICAL_BLUR\n"); - else - Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); - - - if (!GLSL_BeginLoadGPUShader(&tr.depthBlurShader[i], "depthBlur", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); - } - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("gaussian_blur", allocator, fallback_gaussian_blurProgram); - attribs = 0; extradefines[0] = '\0'; - Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); - - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[0], "gaussian_blur", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); - } - - attribs = 0; - - if (!GLSL_BeginLoadGPUShader(&tr.gaussianBlurShader[1], "gaussian_blur", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.shadowmapShader, "shadowfill", attribs, nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("dglow_downsample", allocator, fallback_dglow_downsampleProgram); - attribs = 0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowDownsample, "dglow_downsample", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); - } - allocator.Reset(); - - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("dglow_upsample", allocator, fallback_dglow_upsampleProgram); - attribs = 0; - extradefines[0] = '\0'; - if (!GLSL_BeginLoadGPUShader(&tr.dglowUpsample, "dglow_upsample", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); - } - allocator.Reset(); - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("surface_sprites", allocator, fallback_surface_spritesProgram); - attribs = ATTR_POSITION | ATTR_NORMAL; - for ( int i = 0; i < SSDEF_COUNT; ++i ) - { - extradefines[0] = '\0'; - - if ( (i & SSDEF_FACE_CAMERA) && (i & SSDEF_FACE_UP) ) - continue; - - if ( i & SSDEF_FACE_CAMERA ) - Q_strcat(extradefines, sizeof(extradefines), - "#define FACE_CAMERA\n"); - else if ( i & SSDEF_FACE_UP ) - Q_strcat(extradefines, sizeof(extradefines), - "#define FACE_UP\n"); - - if ( i & SSDEF_ALPHA_TEST ) - Q_strcat(extradefines, sizeof(extradefines), - "#define ALPHA_TEST\n"); - - if (!GLSL_BeginLoadGPUShader(tr.spriteShader + i, "surface_sprites", attribs, - extradefines, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); - } + ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); } - allocator.Reset(); - - ///////////////////////////////////////////////////////////////////////////// - programDesc = LoadProgramSource("weather", allocator, fallback_weatherProgram); - attribs = ATTR_POSITION; - if (!GLSL_BeginLoadGPUShader(&tr.weatherShader, "weather", attribs, - nullptr, *programDesc)) - { - ri->Error(ERR_FATAL, "Could not load weather shader!"); - } - allocator.Reset(); + GLSL_InitUniforms(&tr.shadowmapShader); + GLSL_FinishGPUShader(&tr.shadowmapShader); - return startTime; + return 1; } -void GLSL_EndLoadGPUShaders ( int startTime ) +static int GLSL_LoadGPUProgramPShadow( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) { - int i; - int numGenShaders = 0, numLightShaders = 0, numEtcShaders = 0; - - for (i = 0; i < GENERICDEF_COUNT; i++) - { - if (!GLSL_IsValidPermutationForGeneric (i)) - { - continue; - } - - if (!GLSL_EndLoadGPUShader(&tr.genericShader[i])) - { - ri->Error(ERR_FATAL, "Could not load fogpass shader!"); - } - - GLSL_InitUniforms(&tr.genericShader[i]); - - qglUseProgram(tr.genericShader[i].program); - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - GLSL_SetUniformInt(&tr.genericShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.genericShader[i]); - - numGenShaders++; - } - - if (!GLSL_EndLoadGPUShader (&tr.textureColorShader)) - { - ri->Error(ERR_FATAL, "Could not load texturecolor shader!"); - } - - GLSL_InitUniforms(&tr.textureColorShader); - - qglUseProgram(tr.textureColorShader.program); - GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.textureColorShader); - - numEtcShaders++; - - for (i = 0; i < FOGDEF_COUNT; i++) - { - if (!GLSL_IsValidPermutationForFog (i)) - { - continue; - } - - if (!GLSL_EndLoadGPUShader(&tr.fogShader[i])) - { - ri->Error(ERR_FATAL, "Could not load fogpass shader!"); - } - - GLSL_InitUniforms(&tr.fogShader[i]); - GLSL_FinishGPUShader(&tr.fogShader[i]); - - numEtcShaders++; - } - - - for (i = 0; i < DLIGHTDEF_COUNT; i++) - { - if (!GLSL_EndLoadGPUShader(&tr.dlightShader[i])) - { - ri->Error(ERR_FATAL, "Could not load dlight shader!"); - } - - GLSL_InitUniforms(&tr.dlightShader[i]); - - qglUseProgram(tr.dlightShader[i].program); - GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.dlightShader[i]); - - numEtcShaders++; - } - - - for (i = 0; i < LIGHTDEF_COUNT; i++) - { - int lightType = i & LIGHTDEF_LIGHTTYPE_MASK; - - // skip impossible combos - if (!GLSL_IsValidPermutationForLight (lightType, i)) - { - continue; - } - - if (!GLSL_EndLoadGPUShader(&tr.lightallShader[i])) - { - ri->Error(ERR_FATAL, "Could not load lightall shader!"); - } - - GLSL_InitUniforms(&tr.lightallShader[i]); - - qglUseProgram(tr.lightallShader[i].program); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_LIGHTMAP, TB_LIGHTMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_NORMALMAP, TB_NORMALMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.lightallShader[i]); - - numLightShaders++; - } + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - if (!GLSL_EndLoadGPUShader(&tr.shadowmapShader)) - { - ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); - } - - GLSL_InitUniforms(&tr.shadowmapShader); - GLSL_FinishGPUShader(&tr.shadowmapShader); + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("pshadow", allocator, fallback_pshadowProgram); + const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL; - numEtcShaders++; + extradefines[0] = '\0'; + Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_EndLoadGPUShader(&tr.pshadowShader)) + if (!GLSL_LoadGPUShader(builder, &tr.pshadowShader, "pshadow", attribs, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load pshadow shader!"); } - + GLSL_InitUniforms(&tr.pshadowShader); qglUseProgram(tr.pshadowShader.program); @@ -1937,13 +1764,20 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.pshadowShader); - numEtcShaders++; + return 1; +} + +static int GLSL_LoadGPUProgramDownscale4x( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.down4xShader, + "down4x", + fallback_down4xProgram); - if (!GLSL_EndLoadGPUShader(&tr.down4xShader)) - { - ri->Error(ERR_FATAL, "Could not load down4x shader!"); - } - GLSL_InitUniforms(&tr.down4xShader); qglUseProgram(tr.down4xShader.program); @@ -1952,13 +1786,20 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.down4xShader); - numEtcShaders++; + return 1; +} + +static int GLSL_LoadGPUProgramBokeh( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.bokehShader, + "bokeh", + fallback_bokehProgram); - if (!GLSL_EndLoadGPUShader(&tr.bokehShader)) - { - ri->Error(ERR_FATAL, "Could not load bokeh shader!"); - } - GLSL_InitUniforms(&tr.bokehShader); qglUseProgram(tr.bokehShader.program); @@ -1967,13 +1808,20 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.bokehShader); - numEtcShaders++; + return 1; +} + +static int GLSL_LoadGPUProgramTonemap( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.tonemapShader, + "tonemap", + fallback_tonemapProgram); - if (!GLSL_EndLoadGPUShader(&tr.tonemapShader)) - { - ri->Error(ERR_FATAL, "Could not load tonemap shader!"); - } - GLSL_InitUniforms(&tr.tonemapShader); qglUseProgram(tr.tonemapShader.program); @@ -1983,15 +1831,33 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.tonemapShader); - numEtcShaders++; + return 1; +} + +static int GLSL_LoadGPUProgramCalcLuminanceLevel( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - for (i = 0; i < 2; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("calclevels4x", allocator, fallback_calclevels4xProgram); + for ( int i = 0; i < 2; i++ ) { - if (!GLSL_EndLoadGPUShader(&tr.calclevels4xShader[i])) + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0; + extradefines[0] = '\0'; + + if (!i) + Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); + + if (!GLSL_LoadGPUShader(builder, &tr.calclevels4xShader[i], "calclevels4x", attribs, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); } - + GLSL_InitUniforms(&tr.calclevels4xShader[i]); qglUseProgram(tr.calclevels4xShader[i].program); @@ -2000,14 +1866,45 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.calclevels4xShader[i]); - numEtcShaders++; + ++numPrograms; } - if (!GLSL_EndLoadGPUShader(&tr.shadowmaskShader)) + return numPrograms; +} + +static int GLSL_LoadGPUProgramShadowMask( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); + + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("shadowmask", allocator, fallback_shadowmaskProgram); + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0; + extradefines[0] = '\0'; + + if (r_shadowFilter->integer >= 1) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER\n"); + + if (r_shadowFilter->integer >= 2) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); + + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_CASCADE\n"); + + Q_strcat( + extradefines, sizeof(extradefines), + va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); + Q_strcat( + extradefines, sizeof(extradefines), + va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); + + if (!GLSL_LoadGPUShader(builder, &tr.shadowmaskShader, "shadowmask", attribs, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); } - + GLSL_InitUniforms(&tr.shadowmaskShader); qglUseProgram(tr.shadowmaskShader.program); @@ -2019,12 +1916,19 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.shadowmaskShader); - numEtcShaders++; + return 1; +} - if (!GLSL_EndLoadGPUShader(&tr.ssaoShader)) - { - ri->Error(ERR_FATAL, "Could not load ssao shader!"); - } +static int GLSL_LoadGPUProgramSSAO( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.ssaoShader, + "ssao", + fallback_ssaoProgram); GLSL_InitUniforms(&tr.ssaoShader); @@ -2034,11 +1938,32 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.ssaoShader); - numEtcShaders++; + return 1; +} + +static int GLSL_LoadGPUProgramDepthBlur( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - for (i = 0; i < 2; i++) + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("depthBlur", allocator, fallback_depthblurProgram); + for ( int i = 0; i < 2; i++ ) { - if (!GLSL_EndLoadGPUShader(&tr.depthBlurShader[i])) + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0; + extradefines[0] = '\0'; + + if (i & 1) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTICAL_BLUR\n"); + else + Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); + + + if (!GLSL_LoadGPUShader(builder, &tr.depthBlurShader[i], "depthBlur", attribs, + extradefines, *programDesc)) { ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); } @@ -2052,88 +1977,230 @@ void GLSL_EndLoadGPUShaders ( int startTime ) GLSL_FinishGPUShader(&tr.depthBlurShader[i]); - numEtcShaders++; + ++numPrograms; } - for (i = 0; i < 2; i++) - { - if (!GLSL_EndLoadGPUShader(&tr.gaussianBlurShader[i])) - { - ri->Error(ERR_FATAL, "Could not load gaussian blur shader!"); - } + return numPrograms; +} - GLSL_InitUniforms(&tr.gaussianBlurShader[i]); +static int GLSL_LoadGPUProgramGaussianBlur( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - GLSL_FinishGPUShader(&tr.gaussianBlurShader[i]); + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("gaussian_blur", allocator, fallback_gaussian_blurProgram); + const uint32_t attribs = 0; + + extradefines[0] = '\0'; + Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); - numEtcShaders++; + if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[0], "gaussian_blur", attribs, + extradefines, *programDesc)) + { + ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } - if (!GLSL_EndLoadGPUShader(&tr.dglowDownsample)) + if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[1], "gaussian_blur", attribs, + nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load dynamic glow downsample shader!"); + ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } - GLSL_InitUniforms(&tr.dglowDownsample); + int numPrograms = 0; + for ( int i = 0; i < 2; i++ ) + { + GLSL_InitUniforms(&tr.gaussianBlurShader[i]); + GLSL_FinishGPUShader(&tr.gaussianBlurShader[i]); + ++numPrograms; + } - GLSL_FinishGPUShader(&tr.dglowDownsample); + return numPrograms; +} - numEtcShaders++; +static int GLSL_LoadGPUProgramDynamicGlowUpsample( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.dglowUpsample, + "dglow_upsample", + fallback_dglow_upsampleProgram, + 0); - if (!GLSL_EndLoadGPUShader(&tr.dglowUpsample)) - { - ri->Error(ERR_FATAL, "Could not load dynamic glow upsample shader!"); - } + GLSL_InitUniforms(&tr.dglowDownsample); + GLSL_FinishGPUShader(&tr.dglowDownsample); + return 1; +} - GLSL_InitUniforms(&tr.dglowUpsample); +static int GLSL_LoadGPUProgramDynamicGlowDownsample( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.dglowDownsample, + "dglow_downsample", + fallback_dglow_downsampleProgram, + 0); + GLSL_InitUniforms(&tr.dglowUpsample); GLSL_FinishGPUShader(&tr.dglowUpsample); + return 1; +} - numEtcShaders++; +static int GLSL_LoadGPUProgramSurfaceSprites( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + int numPrograms = 0; + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("surface_sprites", allocator, fallback_surface_spritesProgram); + const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL; for ( int i = 0; i < SSDEF_COUNT; ++i ) { + extradefines[0] = '\0'; + if ( (i & SSDEF_FACE_CAMERA) && (i & SSDEF_FACE_UP) ) continue; + if ( i & SSDEF_FACE_CAMERA ) + Q_strcat(extradefines, sizeof(extradefines), + "#define FACE_CAMERA\n"); + else if ( i & SSDEF_FACE_UP ) + Q_strcat(extradefines, sizeof(extradefines), + "#define FACE_UP\n"); + + if ( i & SSDEF_ALPHA_TEST ) + Q_strcat(extradefines, sizeof(extradefines), + "#define ALPHA_TEST\n"); + shaderProgram_t *program = tr.spriteShader + i; - if (!GLSL_EndLoadGPUShader(program)) - ri->Error(ERR_FATAL, "Could not compile surface sprites shader!"); + if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, + extradefines, *programDesc)) + { + ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); + } GLSL_InitUniforms(program); GLSL_FinishGPUShader(program); - numEtcShaders++; + ++numPrograms; } - if (!GLSL_EndLoadGPUShader(&tr.weatherShader)) - { - ri->Error(ERR_FATAL, "Could not load weather shader!"); - } + return numPrograms; +} + +static int GLSL_LoadGPUProgramWeather( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc ) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.weatherShader, + "weather", + fallback_weatherProgram, + ATTR_POSITION); GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); - numEtcShaders++; + return 1; +} +void GLSL_LoadGPUShaders() +{ #if 0 - attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; + // vertex size = 48 bytes + VertexFormat bspVertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 2, false, GL_HALF_FLOAT, false, 16 }, // tc1 + { 2, false, GL_HALF_FLOAT, false, 20 }, // tc2 + { 2, false, GL_HALF_FLOAT, false, 24 }, // tc3 + { 2, false, GL_HALF_FLOAT, false, 28 }, // tc4 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 32 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // normal + { 4, false, GL_FLOAT, false, 40 }, // color + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 44 }, // light dir + } + }; - if (!GLSL_InitGPUShader(&tr.testcubeShader, "testcube", attribs, qtrue, extradefines, qtrue, NULL, NULL)) - { - ri->Error(ERR_FATAL, "Could not load testcube shader!"); - } + // vertex size = 32 bytes + VertexFormat rectVertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_FLOAT, false, 16 } // color + } + }; - GLSL_InitUniforms(&tr.testcubeShader); + // vertex size = 32 bytes + VertexFormat g2VertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal + { 4, true, GL_UNSIGNED_BYTE, false, 24 }, // bone indices + { 4, false, GL_UNSIGNED_BYTE, true, 28 }, // bone weights + } + }; - qglUseProgram(tr.testcubeShader.program); - GLSL_SetUniformInt(&tr.testcubeShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - qglUseProgram(0); + // vertex size = 44 bytes + VertexFormat md3VertexFormat = { + { + { 3, false, GL_FLOAT, false, 0 }, // position + { 2, false, GL_HALF_FLOAT, false, 12 }, // tc0 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 16 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 20 }, // normal + { 3, false,p GL_FLOAT, false, 24 }, // pos2 + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 36 }, // tangent + { 4, false, GL_UNSIGNED_INT_2_10_10_10_REV, true, 40 }, // normal + } + }; +#endif + + ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); - GLSL_FinishGPUShader(&tr.testcubeShader); + R_IssuePendingRenderCommands(); - numEtcShaders++; -#endif + int startTime = ri->Milliseconds(); + + Allocator allocator(512 * 1024); + ShaderProgramBuilder builder; + + int numGenShaders = 0; + int numLightShaders = 0; + int numEtcShaders = 0; + numGenShaders += GLSL_LoadGPUProgramGeneric(builder, allocator); + numLightShaders += GLSL_LoadGPUProgramLightAll(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramFogPass(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDLight(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramTextureColor(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDepthFill(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramPShadow(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDownscale4x(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramBokeh(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramTonemap(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramCalcLuminanceLevel(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramShadowMask(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramSSAO(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDepthBlur(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramGaussianBlur(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDynamicGlowUpsample(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramDynamicGlowDownsample(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramSurfaceSprites(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramWeather(builder, allocator); ri->Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index 252e39ee8a..d96665ee87 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -168,9 +168,9 @@ GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) block->blockTextLength); GPUShaderDesc& shaderDesc = theProgram.shaders[shaderIndex]; - shaderDesc.type = static_cast(shaderType); - shaderDesc.source = source; - shaderDesc.firstLine = block->blockTextFirstLine; + shaderDesc.type = static_cast(shaderType); + shaderDesc.source = source; + shaderDesc.firstLineNumber = block->blockTextFirstLine; ++shaderIndex; } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index fa58167d7f..0904fe65e2 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1752,8 +1752,7 @@ void R_Init( void ) { FBO_Init(); - int shadersStartTime = GLSL_BeginLoadGPUShaders(); - + GLSL_LoadGPUShaders(); R_InitShaders (qfalse); @@ -1769,8 +1768,6 @@ void R_Init( void ) { R_InitWeatherSystem(); - GLSL_EndLoadGPUShaders (shadersStartTime); - #if defined(_DEBUG) GLenum err = qglGetError(); if ( err != GL_NO_ERROR ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2b503daaf6..886bbef7d9 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1153,7 +1153,7 @@ struct GPUShaderDesc { GPUShaderType type; const char *source; - int firstLine; + int firstLineNumber; }; struct GPUProgramDesc @@ -1274,10 +1274,8 @@ typedef struct shaderProgram_s { char *name; - GLuint program; - GLuint vertexShader; - GLuint fragmentShader; - uint32_t attribs; // vertex array attributes + GLuint program; + uint32_t attribs; // vertex array attributes // uniform parameters GLint *uniforms; @@ -2955,8 +2953,7 @@ GLSL */ void GLSL_InitSplashScreenShader(); -int GLSL_BeginLoadGPUShaders(void); -void GLSL_EndLoadGPUShaders( int startTime ); +void GLSL_LoadGPUShaders(); void GLSL_ShutdownGPUShaders(void); void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexArrays); void GLSL_VertexAttribPointers(const VertexArraysProperties *vertexArrays); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index cb1b9440dd..85466328dc 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ // tr_surf.c #include "tr_local.h" +#include "tr_weather.h" /* @@ -2189,4 +2190,5 @@ void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { (void(*)(void*))RB_SurfaceVBOMesh, // SF_VBO_MESH, (void(*)(void*))RB_SurfaceVBOMDVMesh, // SF_VBO_MDVMESH (void(*)(void*))RB_SurfaceSprites, // SF_SPRITES + (void(*)(void*))RB_SurfaceWeather, // SF_WEATHER }; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 70d6670cff..2b11dcd1e4 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -63,6 +63,7 @@ void R_InitWeatherSystem() Com_Printf("Initializing weather system\n"); tr.weatherSystem = (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); GenerateRainModel(*tr.weatherSystem); + tr.weatherSystem->weatherSurface.surfaceType = SF_WEATHER; } void R_ShutdownWeatherSystem() @@ -96,7 +97,7 @@ void R_AddWeatherSurfaces() ); } -void R_RenderWeatherSurface( srfWeather_t *surf ) +void RB_SurfaceWeather( srfWeather_t *surf ) { assert(tr.weatherSystem); @@ -107,14 +108,22 @@ void R_RenderWeatherSurface( srfWeather_t *surf ) DrawItem item = {}; - UniformDataWriter uniformDataWriter; SamplerBindingsWriter samplerBindingsWriter; + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(&tr.weatherShader); + uniformDataWriter.SetUniformMatrix4x4( + UNIFORM_MODELVIEWPROJECTIONMATRIX, + glState.modelviewProjection); + uniformDataWriter.SetUniformVec3( + UNIFORM_VIEWORIGIN, + backEnd.viewParms.ori.origin); + // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light // where they aren't rendered item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; item.cullType = CT_FRONT_SIDED; - item.program = nullptr; + item.program = &tr.weatherShader; item.depthRange = { 0.0f, 1.0f }; vertexAttribute_t attribs[2] = {}; diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index a93e9aa195..640fab7b59 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -28,4 +28,4 @@ struct srfWeather_t; void R_InitWeatherSystem(); void R_AddWeatherSurfaces(); void R_ShutdownWeatherSystem(); -void R_RenderWeatherSurface( srfWeather_t *surfaceType ); +void RB_SurfaceWeather( srfWeather_t *surfaceType ); From c7003da2b81f3dfc974e4b6023cda27a9cd47b71 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Feb 2017 16:22:07 +0000 Subject: [PATCH 405/708] Fixes to weather rendering --- codemp/rd-rend2/glsl/weather.glsl | 20 ++++++++++---------- codemp/rd-rend2/tr_init.cpp | 1 + codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shader.cpp | 5 +++++ codemp/rd-rend2/tr_weather.cpp | 28 +++++++++++++--------------- 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 474f1679ae..e9523dd52f 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,9 +1,9 @@ /*[Vertex]*/ -in vec3 in_Position; +in vec3 attr_Position; void main() { - gl_Position = vec4(in_Position, 1.0); + gl_Position = vec4(attr_Position, 1.0); } /*[Geometry]*/ @@ -15,21 +15,21 @@ uniform vec3 u_ViewOrigin; void main() { - const vec2 dirs[] = vec2[]( - vec2(-2.0, -2.0), - vec2( 2.0, -2.0), - vec2( 2.0, 2.0), - vec2(-2.0, 2.0) + const vec2 offsets[] = vec2[]( + vec2(-4.0, -4.0), + vec2( 4.0, -4.0), + vec2(-4.0, 4.0), + vec2( 4.0, 4.0) ); vec3 P = gl_in[0].gl_Position.xyz; vec3 V = u_ViewOrigin - P; - vec2 toCamera = normalize(V.xy); - toCamera.xy = vec2(toCamera.y, -toCamera.x); + vec2 toCamera = normalize(vec2(V.y, -V.x)); for (int i = 0; i < 4; ++i) { - vec4 worldPos = vec4(P.xy + dirs[i] * toCamera, P.z, 1.0); + vec3 offset = vec3(offsets[i].x * toCamera.xy, offsets[i].y); + vec4 worldPos = vec4(P + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; EmitVertex(); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 0904fe65e2..30e2db92ce 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1127,6 +1127,7 @@ void GL_SetDefaultState( void ) qglDepthMask( GL_TRUE ); qglDisable( GL_DEPTH_TEST ); qglEnable( GL_SCISSOR_TEST ); + qglEnable(GL_PROGRAM_POINT_SIZE); qglDisable( GL_CULL_FACE ); qglDisable( GL_BLEND ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 886bbef7d9..5887b35078 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2239,6 +2239,7 @@ typedef struct trGlobals_s { shader_t *shadowShader; shader_t *distortionShader; shader_t *projectionShadowShader; + shader_t *weatherInternalShader; shader_t *flareShader; shader_t *sunShader; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 5ac151487d..ba11d716b7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4825,6 +4825,11 @@ static void CreateInternalShaders( void ) { shader.defaultShader = qfalse; tr.distortionShader = FinishShader(); shader.defaultShader = qtrue; + + // weather shader placeholder + Q_strncpyz(shader.name, "", sizeof(shader.name)); + shader.sort = SS_SEE_THROUGH; + tr.weatherInternalShader = FinishShader(); } static void CreateExternalShaders( void ) { diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 2b11dcd1e4..2632143088 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -45,9 +45,9 @@ namespace for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-1000.0f, 1000.0f); - vertex.position[1] = Q_flrand(-1000.0f, 1000.0f); - vertex.position[2] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[0] = Q_flrand(-500.0f, 500.0f); + vertex.position[1] = Q_flrand(-500.0f, 500.0f); + vertex.position[2] = Q_flrand(-500.0f, 500.0f); vertex.seed[0] = Q_flrand(0.0f, 1.0f); vertex.seed[1] = Q_flrand(0.0f, 1.0f); vertex.seed[2] = Q_flrand(0.0f, 1.0f); @@ -89,7 +89,7 @@ void R_AddWeatherSurfaces() R_AddDrawSurf( (surfaceType_t *)&tr.weatherSystem->weatherSurface, REFENTITYNUM_WORLD, - tr.defaultShader, + tr.weatherInternalShader, 0, /* fogIndex */ qfalse, /* dlightMap */ qfalse, /* postRender */ @@ -109,6 +109,9 @@ void RB_SurfaceWeather( srfWeather_t *surf ) DrawItem item = {}; SamplerBindingsWriter samplerBindingsWriter; + // FIXME: This is a bit ugly with the casting + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); @@ -118,16 +121,15 @@ void RB_SurfaceWeather( srfWeather_t *surf ) uniformDataWriter.SetUniformVec3( UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - item.stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; + item.stateBits = GLS_DEPTHFUNC_LESS; item.cullType = CT_FRONT_SIDED; item.program = &tr.weatherShader; item.depthRange = { 0.0f, 1.0f }; vertexAttribute_t attribs[2] = {}; - attribs[0].index = 0; + attribs[0].index = ATTR_INDEX_POSITION; attribs[0].numComponents = 3; attribs[0].offset = offsetof(rainVertex_t, position); attribs[0].stride = sizeof(rainVertex_t); @@ -144,16 +146,12 @@ void RB_SurfaceWeather( srfWeather_t *surf ) item.numAttributes = numAttribs; item.attributes = ojkAllocArray( *backEndData->perFrameMemory, numAttribs); - memcpy(item.attributes, attribs, sizeof(*item.attributes)*numAttribs); - - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - // FIXME: This is a bit ugly with the casting - item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 100; - item.draw.primitiveType = GL_TRIANGLES; + item.draw.primitiveType = GL_POINTS; + item.draw.params.arrays.numVertices = ws.numVertices; uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); RB_AddDrawItem(backEndData->currentPass, key, item); From b58b6f0cef2c04bf99bcfa724e094d0a246a0c1c Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 26 Feb 2017 11:50:45 +0000 Subject: [PATCH 406/708] Improve wrapping of rain particles --- codemp/rd-rend2/glsl/weather.glsl | 31 +++++++++++++++++++++++++------ codemp/rd-rend2/tr_glsl.cpp | 3 ++- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 4 +++- codemp/rd-rend2/tr_weather.cpp | 22 +++++++++++++--------- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index e9523dd52f..0f2ffa394e 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,9 +1,28 @@ /*[Vertex]*/ in vec3 attr_Position; +in vec3 attr_Color; + +uniform vec2 u_MapZExtents; +uniform float u_Time; +uniform vec3 u_ViewOrigin; void main() { - gl_Position = vec4(attr_Position, 1.0); + int z = gl_InstanceID / 25; + int remaining = gl_InstanceID - (z * 25); + int y = remaining % 5; + int x = remaining / 5; + + float zOffset = mod( + 1000.0 * float(z) + u_Time * 1000.0, + u_MapZExtents.y - u_MapZExtents.x - 2000.0); + vec3 offset = vec3( + 1000.0 * float(x - 2), + 1000.0 * float(y - 2), + u_MapZExtents.y - zOffset); + offset.xy += attr_Color.xy * u_Time; + + gl_Position = vec4(attr_Position + offset, 1.0); } /*[Geometry]*/ @@ -16,10 +35,10 @@ uniform vec3 u_ViewOrigin; void main() { const vec2 offsets[] = vec2[]( - vec2(-4.0, -4.0), - vec2( 4.0, -4.0), - vec2(-4.0, 4.0), - vec2( 4.0, 4.0) + vec2(-0.5, -5.0), + vec2( 0.5, -5.0), + vec2(-0.5, 5.0), + vec2( 0.5, 5.0) ); vec3 P = gl_in[0].gl_Position.xyz; @@ -42,5 +61,5 @@ out vec4 out_Color; void main() { - out_Color = vec4(1.0, 1.0, 0.0, 1.0); + out_Color = vec4(0.2, 0.8, 0.2, 1.0); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e647bca068..8fe017ba52 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -151,6 +151,7 @@ static uniformInfo_t uniformsInfo[] = { "u_AlphaTestValue", GLSL_FLOAT, 1 }, { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, + { "u_MapZExtents", GLSL_VEC2, 1 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) @@ -2108,7 +2109,7 @@ static int GLSL_LoadGPUProgramWeather( &tr.weatherShader, "weather", fallback_weatherProgram, - ATTR_POSITION); + ATTR_POSITION | ATTR_COLOR); GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5887b35078..72a016f503 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1255,6 +1255,7 @@ typedef enum UNIFORM_ALPHA_TEST_VALUE, UNIFORM_FX_VOLUMETRIC_BASE, + UNIFORM_MAPZEXTENTS, UNIFORM_COUNT } uniform_t; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index a05d842fe8..ea6e542b06 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1173,7 +1173,9 @@ static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexA uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque); + uniformDataWriter.SetUniformFloat( + UNIFORM_FOGDEPTHTOOPAQUE, + sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque); uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 2632143088..03b4120411 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -45,12 +45,12 @@ namespace for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-500.0f, 500.0f); - vertex.position[1] = Q_flrand(-500.0f, 500.0f); - vertex.position[2] = Q_flrand(-500.0f, 500.0f); - vertex.seed[0] = Q_flrand(0.0f, 1.0f); - vertex.seed[1] = Q_flrand(0.0f, 1.0f); - vertex.seed[2] = Q_flrand(0.0f, 1.0f); + vertex.position[0] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[1] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[2] = Q_flrand(-1000.0f, 1000.0f); + vertex.seed[0] = Q_flrand(-2.0f, 2.0f); + vertex.seed[1] = Q_flrand(-2.0f, 2.0f); + vertex.seed[2] = Q_flrand(-20.0f, 0.0f); } ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_STATIC); @@ -61,7 +61,8 @@ namespace void R_InitWeatherSystem() { Com_Printf("Initializing weather system\n"); - tr.weatherSystem = (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); + tr.weatherSystem = + (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); GenerateRainModel(*tr.weatherSystem); tr.weatherSystem->weatherSurface.surfaceType = SF_WEATHER; } @@ -121,6 +122,9 @@ void RB_SurfaceWeather( srfWeather_t *surf ) uniformDataWriter.SetUniformVec3( UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + const vec2_t mapZExtents = { -3000.0, 9000.0 }; + uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); item.stateBits = GLS_DEPTHFUNC_LESS; @@ -135,7 +139,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) attribs[0].stride = sizeof(rainVertex_t); attribs[0].type = GL_FLOAT; attribs[0].vbo = ws.vbo; - attribs[1].index = 1; + attribs[1].index = ATTR_INDEX_COLOR; attribs[1].numComponents = 3; attribs[1].offset = offsetof(rainVertex_t, seed); attribs[1].stride = sizeof(rainVertex_t); @@ -149,7 +153,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); item.draw.type = DRAW_COMMAND_ARRAYS; - item.draw.numInstances = 100; + item.draw.numInstances = 225; item.draw.primitiveType = GL_POINTS; item.draw.params.arrays.numVertices = ws.numVertices; From 90ef65fc274a5231ea01be869255be578131bf9b Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 26 Feb 2017 12:06:45 +0000 Subject: [PATCH 407/708] Make rain slightly transparent --- codemp/rd-rend2/glsl/weather.glsl | 10 +++++----- codemp/rd-rend2/tr_weather.cpp | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 0f2ffa394e..211c985ada 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -35,10 +35,10 @@ uniform vec3 u_ViewOrigin; void main() { const vec2 offsets[] = vec2[]( - vec2(-0.5, -5.0), - vec2( 0.5, -5.0), - vec2(-0.5, 5.0), - vec2( 0.5, 5.0) + vec2(-0.5, -7.0), + vec2( 0.5, -7.0), + vec2(-0.5, 7.0), + vec2( 0.5, 7.0) ); vec3 P = gl_in[0].gl_Position.xyz; @@ -61,5 +61,5 @@ out vec4 out_Color; void main() { - out_Color = vec4(0.2, 0.8, 0.2, 1.0); + out_Color = vec4(0.7, 0.8, 0.7, 0.4); } diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 03b4120411..06e85379f4 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -127,7 +127,8 @@ void RB_SurfaceWeather( srfWeather_t *surf ) uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - item.stateBits = GLS_DEPTHFUNC_LESS; + item.stateBits = + GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; item.cullType = CT_FRONT_SIDED; item.program = &tr.weatherShader; item.depthRange = { 0.0f, 1.0f }; From 4bb955c6a1b02c2da3a9c22df985c8fee581190d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 2 Jun 2017 02:11:15 +0200 Subject: [PATCH 408/708] PBR IBL Added pre-computed environment LUT Added pre-convolution of cubemaps Fixed Blendstates --- codemp/rd-rend2/glsl/lightall.glsl | 9 +- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 101 ++++++++++++++++++++++ codemp/rd-rend2/tr_backend.cpp | 76 ++++++++++++++++ codemp/rd-rend2/tr_bsp.cpp | 13 +-- codemp/rd-rend2/tr_cmds.cpp | 17 ++++ codemp/rd-rend2/tr_extramath.cpp | 18 ++++ codemp/rd-rend2/tr_extramath.h | 2 + codemp/rd-rend2/tr_fbo.cpp | 9 ++ codemp/rd-rend2/tr_glsl.cpp | 40 +++++++++ codemp/rd-rend2/tr_image.cpp | 85 ++++++++++++++++++ codemp/rd-rend2/tr_local.h | 17 +++- codemp/rd-rend2/tr_shade.cpp | 1 + codemp/rd-rend2/tr_shader.cpp | 4 +- codemp/rd-rend2/tr_world.cpp | 12 +-- 14 files changed, 385 insertions(+), 19 deletions(-) create mode 100644 codemp/rd-rend2/glsl/prefilterEnvMap.glsl diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 421e10e27b..901c7c245e 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -332,6 +332,7 @@ uniform sampler2D u_ShadowMap; #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; +uniform sampler2D u_EnvBrdfMap; #endif #if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) @@ -532,7 +533,9 @@ vec3 CalcIBLContribution( #if defined(USE_CUBEMAP) // EnvironmentBRDF is supposed to work with gloss. Invert roughness for now, but this needs // to be replaced at some point with preconvoluted cubemap code. - vec3 reflectance = EnvironmentBRDF(1.0 - roughness, NE, specular); + //vec3 reflectance = EnvironmentBRDF(1.0 - roughness, NE, specular); + + vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(1.0 - roughness, NE)).rgb; vec3 R = reflect(E, N); @@ -540,9 +543,9 @@ vec3 CalcIBLContribution( // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; - vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, roughness * 7.0).rgb * u_EnableTextures.w; + vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; - return cubeLightColor * reflectance; + return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); #else return vec3(0.0); #endif diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl new file mode 100644 index 0000000000..d2c0f20094 --- /dev/null +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -0,0 +1,101 @@ +/*[Vertex]*/ +in vec4 attr_Position; +in vec4 attr_TexCoord0; + +out vec2 var_ScreenTex; + +void main() +{ + gl_Position = attr_Position; + var_ScreenTex = attr_TexCoord0.xy; + //vec2 screenCoords = gl_Position.xy / gl_Position.w; + //var_ScreenTex = screenCoords * 0.5 + 0.5; +} + +/*[Fragment]*/ +uniform vec4 u_ViewInfo; // cubeface, mip_level, max_mip_level, 0.0 +uniform samplerCube u_CubeMap; +in vec2 var_ScreenTex; + +out vec4 out_Color; + +// from http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html +float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 +} + +vec2 hammersley2D(uint i, uint N) { + return vec2(float(i)/float(N), radicalInverse_VdC(i)); +} + +vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) +{ + float a = Roughness * Roughness; + float Phi = 2 * M_PI * Xi.x; + float CosTheta = sqrt((1-Xi.y) / (1+(a*a -1) * Xi.y)); + float SinTheta = sqrt( 1 - CosTheta * CosTheta); + + vec3 H; + H.x = SinTheta * cos( Phi ); + H.y = SinTheta * sin( Phi ); + H.z = CosTheta; + + vec3 UpVector = abs(N.z) < 0.999 ? vec3(0,0,1) : vec3(1,0,0); + vec3 TangentX = normalize(cross(UpVector , N)); + vec3 TangentY = cross(N , TangentX); + + return TangentX * H.x + TangentY * H.y + N * H.z; +} + +vec3 PrefilterEnvMap( float Roughness, vec3 R ) +{ + vec3 N = R; + vec3 V = R; + vec3 PrefilteredColor = vec3(0.0); + float TotalWeight = 0.0; + uint NumSamples = uint(1024); + for ( uint i = uint(0); i < NumSamples; i++ ) + { + vec2 Xi = hammersley2D( i, NumSamples ); + vec3 H = ImportanceSampleGGX( Xi, Roughness, N ); + vec3 L = 2 * dot( V, H ) * H - V; + float NoL = clamp((dot( N, L )),0.0,1.0); + if ( NoL > 0 ) + { + PrefilteredColor += textureLod(u_CubeMap, L, 0.0).rgb * NoL; + TotalWeight += NoL; + } + } + return PrefilteredColor / TotalWeight; +} + +void main() +{ + float cubeFace = u_ViewInfo.x; + vec2 vector; + vector.x = (var_ScreenTex.x - 0.5) * 2.0; + vector.y = (var_ScreenTex.y - 0.5) * 2.0; + // from http://www.codinglabs.net/article_physically_based_rendering.aspx + + vec3 normal = normalize( vec3(vector.xy, 1) ); + if(cubeFace==2) + normal = normalize( vec3(vector.x, 1, -vector.y) ); + else if(cubeFace==3) + normal = normalize( vec3(vector.x, -1, vector.y) ); + else if(cubeFace==0) + normal = normalize( vec3( 1, vector.y,-vector.x) ); + else if(cubeFace==1) + normal = normalize( vec3( -1, vector.y, vector.x) ); + else if(cubeFace==5) + normal = normalize( vec3(-vector.x, vector.y, -1) ); + + float roughness = u_ViewInfo.y / u_ViewInfo.z; + vec3 result = PrefilterEnvMap(roughness, normal); + + out_Color = vec4(result, 1.0); +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index cadf574fa8..a4484bb74a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1799,6 +1799,79 @@ static const void *RB_RotatePic2 ( const void *data ) return (const void *)(cmd + 1); } +/* +============= +RB_PrefilterEnvMap +============= +*/ + +static const void *RB_PrefilterEnvMap(const void *data) { + + const convolveCubemapCommand_t *cmd = (const convolveCubemapCommand_t *)data; + + // finish any 2D drawing if needed + if (tess.numIndexes) + RB_EndSurface(); + + RB_SetGL2D(); + + image_t *cubemap = tr.cubemaps[cmd->cubemap]; + + if (!cubemap) + return (const void *)(cmd + 1); + + int cubeMipSize = cubemap->width; + int numMips = 0; + + int width = cubemap->width; + int height = cubemap->height; + + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + + VectorSet4(quadVerts[0], -1, 1, 0, 1); + VectorSet4(quadVerts[1], 1, 1, 0, 1); + VectorSet4(quadVerts[2], 1, -1, 0, 1); + VectorSet4(quadVerts[3], -1, -1, 0, 1); + + texCoords[0][0] = 0; texCoords[0][1] = 0; + texCoords[1][0] = 1; texCoords[1][1] = 0; + texCoords[2][0] = 1; texCoords[2][1] = 1; + texCoords[3][0] = 0; texCoords[3][1] = 1; + + while (cubeMipSize) + { + cubeMipSize >>= 1; + numMips++; + } + numMips = MAX(1, numMips - 2); + + FBO_Bind(tr.preFilterEnvMapFbo); + GL_BindToTMU(cubemap, TB_CUBEMAP); + + GLSL_BindProgram(&tr.prefilterEnvMapShader); + + for (int level = 1; level <= numMips; level++) + { + width = width / 2.0; + height = height / 2.0; + qglViewport(0, 0, width, height); + qglScissor(0, 0, width, height); + for (int cubemapSide = 0; cubemapSide < 6; cubemapSide++) + { + vec4_t viewInfo; + VectorSet4(viewInfo, cubemapSide, level, numMips, 0.0); + GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); + RB_InstantQuad2(quadVerts, texCoords); + qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cubemapSide, level, 0, 0, 0, 0, width, height); + } + } + + GL_SelectTexture(0); + + return (const void *)(cmd + 1); +} + static void RB_RenderSunShadows() { @@ -2673,6 +2746,9 @@ void RB_ExecuteRenderCommands( const void *data ) { case RC_CAPSHADOWMAP: data = RB_CaptureShadowMap(data); break; + case RC_CONVOLVECUBEMAP: + data = RB_PrefilterEnvMap( data ); + break; case RC_POSTPROCESS: data = RB_PostProcess(data); break; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e24704d594..73b21bdaff 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3016,6 +3016,7 @@ static void R_RenderAllCubemaps(void) R_IssuePendingRenderCommands(); R_InitNextFrame(); } + R_AddConvolveCubemapCmd(i); } } @@ -3717,12 +3718,6 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_BindNullVBO(); R_BindNullIBO(); - // Render all cubemaps - if (r_cubeMapping->integer && tr.numCubemaps) - { - R_RenderAllCubemaps(); - } - ri->FS_FreeFile(buffer.v); return worldData; @@ -3773,4 +3768,10 @@ void RE_LoadWorldMap( const char *name ) { tr.toneMinAvgMaxLevel[0] = -8.0f; tr.toneMinAvgMaxLevel[1] = -2.0f; tr.toneMinAvgMaxLevel[2] = 0.0f; + + // Render all cubemaps + if (r_cubeMapping->integer && tr.numCubemaps) + { + R_RenderAllCubemaps(); + } } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index f620a7cf07..a4d8c8bf40 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -244,6 +244,23 @@ void R_AddCapShadowmapCmd( int map, int cubeSide ) { cmd->cubeSide = cubeSide; } +/* +============= +R_AddConvolveCubemapsCmd + +============= +*/ +void R_AddConvolveCubemapCmd( int cubemap ) { + convolveCubemapCommand_t *cmd; + + cmd = (convolveCubemapCommand_t *)R_GetCommandBuffer( sizeof( *cmd )); + if ( !cmd ) { + return; + } + cmd->commandId = RC_CONVOLVECUBEMAP; + + cmd->cubemap = cubemap; +} /* ============= diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 180715819d..497c859052 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -238,3 +238,21 @@ unsigned short FloatToHalf(float in) return out; } + +uint32_t ReverseBits(uint32_t v) +{ + v = ((v >> 1) & 0x55555555) | ((v & 0x55555555) << 1); + v = ((v >> 2) & 0x33333333) | ((v & 0x33333333) << 2); + v = ((v >> 4) & 0x0F0F0F0F) | ((v & 0x0F0F0F0F) << 4); + v = ((v >> 8) & 0x00FF00FF) | ((v & 0x00FF00FF) << 8); + v = (v >> 16) | (v << 16); + return v; +} + +float GSmithCorrelated(float roughness, float ndotv, float ndotl) +{ + float m2 = roughness * roughness; + float visV = ndotl * sqrt(ndotv * (ndotv - ndotv * m2) + m2); + float visL = ndotv * sqrt(ndotl * (ndotl - ndotl * m2) + m2); + return 0.5f / (visV + visL); +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index bb77b4eeb0..9d867255cf 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -102,5 +102,7 @@ void BoundingSphereOfSpheres(vec3_t origin1, float radius1, vec3_t origin2, floa int NextPowerOfTwo(int in); unsigned short FloatToHalf(float in); +uint32_t ReverseBits(uint32_t v); +float GSmithCorrelated(float roughness, float ndotv, float ndotl); #endif diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 4b5a23e41b..3d2ee28d85 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -636,6 +636,15 @@ void FBO_Init(void) R_CheckFBO(tr.renderCubeFbo); } + if (tr.renderCubeImage != NULL) + { + tr.preFilterEnvMapFbo = FBO_Create("_preFilterEnvMapFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); + FBO_Bind(tr.preFilterEnvMapFbo); + FBO_AttachTextureImage(tr.prefilterEnvMapImage, 0); + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.preFilterEnvMapFbo); + } + GL_CheckErrors(); FBO_Bind(NULL); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 8fe017ba52..f081b8f107 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -28,6 +28,7 @@ void GLSL_BindNullProgram(void); extern const GPUProgramDesc fallback_bokehProgram; extern const GPUProgramDesc fallback_calclevels4xProgram; extern const GPUProgramDesc fallback_depthblurProgram; +extern const GPUProgramDesc fallback_prefilterEnvMapProgram; extern const GPUProgramDesc fallback_dlightProgram; extern const GPUProgramDesc fallback_down4xProgram; extern const GPUProgramDesc fallback_fogpassProgram; @@ -70,6 +71,7 @@ static uniformInfo_t uniformsInfo[] = { "u_TextureMap", GLSL_INT, 1 }, { "u_LevelsMap", GLSL_INT, 1 }, { "u_CubeMap", GLSL_INT, 1 }, + { "u_EnvBrdfMap", GLSL_INT, 1 }, { "u_ScreenImageMap", GLSL_INT, 1 }, { "u_ScreenDepthMap", GLSL_INT, 1 }, @@ -374,6 +376,20 @@ static size_t GLSL_GetShaderHeader( fbufWidthScale, fbufHeightScale)); + if (r_cubeMapping->integer) + { + int cubeMipSize = CUBE_MAP_SIZE; // r_cubemapSize->integer; + int numRoughnessMips = 0; + + while (cubeMipSize) + { + cubeMipSize >>= 1; + numRoughnessMips++; + } + numRoughnessMips = MAX(1, numRoughnessMips - 2); + Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", numRoughnessMips)); + } + if (extra) { Q_strcat(dest, size, extra); @@ -1658,6 +1674,7 @@ static int GLSL_LoadGPUProgramLightAll( GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_ENVBRDFMAP, TB_ENVBRDFMAP); qglUseProgram(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); @@ -1942,6 +1959,28 @@ static int GLSL_LoadGPUProgramSSAO( return 1; } +static int GLSL_LoadGPUProgramPrefilterEnvMap( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc) +{ + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.prefilterEnvMapShader, + "prefilterEnvMap", + fallback_prefilterEnvMapProgram); + + GLSL_InitUniforms(&tr.prefilterEnvMapShader); + + qglUseProgram(tr.prefilterEnvMapShader.program); + GLSL_SetUniformInt(&tr.prefilterEnvMapShader, UNIFORM_CUBEMAP, TB_CUBEMAP); + qglUseProgram(0); + + GLSL_FinishGPUShader(&tr.prefilterEnvMapShader); + + return 1; +} + static int GLSL_LoadGPUProgramDepthBlur( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) @@ -2196,6 +2235,7 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramCalcLuminanceLevel(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramShadowMask(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramSSAO(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramPrefilterEnvMap(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDepthBlur(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramGaussianBlur(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDynamicGlowUpsample(builder, allocator); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 2139dd2343..1b2af88aaf 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2869,6 +2869,89 @@ static void R_CreateFogImage( void ) { qglTexParameterfv( GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor ); } +/* +================ +R_CreateEnvBrdfLUT +from https://github.com/knarkowicz/IntegrateDFG +================ +*/ +#define LUT_WIDTH 128 +#define LUT_HEIGHT 128 +static void R_CreateEnvBrdfLUT(void) { + if (!r_cubeMapping->integer) + return; + + int x, y; + uint16_t data[LUT_WIDTH][LUT_HEIGHT][4]; + int b; + + float const MATH_PI = 3.14159f; + unsigned const sampleNum = 1024; + + for (unsigned y = 0; y < LUT_HEIGHT; ++y) + { + float const ndotv = (y + 0.5f) / LUT_HEIGHT; + + for (unsigned x = 0; x < LUT_WIDTH; ++x) + { + float const gloss = (x + 0.5f) / LUT_WIDTH; + float const roughness = powf(1.0f - gloss, 2.0f); + + float const vx = sqrtf(1.0f - ndotv * ndotv); + float const vy = 0.0f; + float const vz = ndotv; + + float scale = 0.0f; + float bias = 0.0f; + + for (unsigned i = 0; i < sampleNum; ++i) + { + float const e1 = (float)i / sampleNum; + float const e2 = (float)((double)ReverseBits(i) / (double)0x100000000LL); + + float const phi = 2.0f * MATH_PI * e1; + float const cosPhi = cosf(phi); + float const sinPhi = sinf(phi); + float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (roughness * roughness - 1.0f) * e2)); + float const sinTheta = sqrtf(1.0f - cosTheta * cosTheta); + + float const hx = sinTheta * cosf(phi); + float const hy = sinTheta * sinf(phi); + float const hz = cosTheta; + + float const vdh = vx * hx + vy * hy + vz * hz; + float const lx = 2.0f * vdh * hx - vx; + float const ly = 2.0f * vdh * hy - vy; + float const lz = 2.0f * vdh * hz - vz; + + float const ndotl = MAX(lz, 0.0f); + float const ndoth = MAX(hz, 0.0f); + float const vdoth = MAX(vdh, 0.0f); + + if (ndotl > 0.0f) + { + float const gsmith = GSmithCorrelated(roughness, ndotv, ndotl); + float const ndotlVisPDF = ndotl * gsmith * (4.0f * vdoth / ndoth); + float const fc = powf(1.0f - vdoth, 5.0f); + + scale += ndotlVisPDF * (1.0f - fc); + bias += ndotlVisPDF * fc; + } + } + scale /= sampleNum; + bias /= sampleNum; + + data[y][x][0] = FloatToHalf(scale); + data[y][x][1] = FloatToHalf(bias); + data[y][x][2] = 0.0f; + data[y][x][3] = 0.0f; + } + } + + tr.envBrdfImage = R_CreateImage("*envBrdfLUT", (byte*)data, 128, 128, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA16F); + return; +} + /* ================== R_CreateDefaultImage @@ -2949,6 +3032,7 @@ void R_CreateBuiltinImages( void ) { R_CreateDlightImage(); R_CreateFogImage(); + R_CreateEnvBrdfLUT(); int width, height, hdrFormat, rgbFormat; @@ -3042,6 +3126,7 @@ void R_CreateBuiltinImages( void ) { if (r_cubeMapping->integer) { tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); + tr.prefilterEnvMapImage = R_CreateImage("*prefilterEnvMapFbo", NULL, CUBE_MAP_SIZE / 2, CUBE_MAP_SIZE / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 72a016f503..98bdbde7c7 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -60,7 +60,7 @@ typedef unsigned int glIndex_t; #define MAX_CALC_PSHADOWS 64 #define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces #define PSHADOW_MAP_SIZE 512 -#define CUBE_MAP_MIPS 7 +#define CUBE_MAP_MIPS 8 #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) /* @@ -710,7 +710,8 @@ enum TB_SPECULARMAP = 4, TB_SHADOWMAP = 5, TB_CUBEMAP = 6, - NUM_TEXTURE_BUNDLES = 7 + TB_ENVBRDFMAP = 7, + NUM_TEXTURE_BUNDLES = 8 }; typedef enum @@ -1173,6 +1174,7 @@ typedef enum UNIFORM_TEXTUREMAP, UNIFORM_LEVELSMAP, UNIFORM_CUBEMAP, + UNIFORM_ENVBRDFMAP, UNIFORM_SCREENIMAGEMAP, UNIFORM_SCREENDEPTHMAP, @@ -2217,6 +2219,8 @@ typedef struct trGlobals_s { image_t *screenSsaoImage; image_t *hdrDepthImage; image_t *renderCubeImage; + image_t *prefilterEnvMapImage; + image_t *envBrdfImage; image_t *textureDepthImage; @@ -2235,6 +2239,7 @@ typedef struct trGlobals_s { FBO_t *screenSsaoFbo; FBO_t *hdrDepthFbo; FBO_t *renderCubeFbo; + FBO_t *preFilterEnvMapFbo; shader_t *defaultShader; shader_t *shadowShader; @@ -2282,6 +2287,7 @@ typedef struct trGlobals_s { shaderProgram_t ssaoShader; shaderProgram_t depthBlurShader[2]; shaderProgram_t testcubeShader; + shaderProgram_t prefilterEnvMapShader; shaderProgram_t gaussianBlurShader[2]; shaderProgram_t glowCompositeShader; shaderProgram_t dglowDownsample; @@ -3255,6 +3261,11 @@ typedef struct capShadowmapCommand_s { int cubeSide; } capShadowmapCommand_t; +typedef struct convolveCubemapCommand_s { + int commandId; + int cubemap; +} convolveCubemapCommand_t; + typedef struct postProcessCommand_s { int commandId; trRefdef_t refdef; @@ -3286,6 +3297,7 @@ typedef enum { RC_COLORMASK, RC_CLEARDEPTH, RC_CAPSHADOWMAP, + RC_CONVOLVECUBEMAP, RC_POSTPROCESS, RC_BEGIN_TIMED_BLOCK, RC_END_TIMED_BLOCK @@ -3363,6 +3375,7 @@ void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); void R_AddCapShadowmapCmd( int dlight, int cubeSide ); +void R_AddConvolveCubemapCmd( int cubemap ); void R_AddPostProcessCmd (void); qhandle_t R_BeginTimedBlockCmd( const char *name ); void R_EndTimedBlockCmd( qhandle_t timerHandle ); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ea6e542b06..540b836df8 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1713,6 +1713,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vec4_t vec; samplerBindingsWriter.AddStaticImage(tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + samplerBindingsWriter.AddStaticImage(tr.envBrdfImage, TB_ENVBRDFMAP); vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.ori.origin[0]; vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.ori.origin[1]; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ba11d716b7..4dba3193d5 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -310,7 +310,7 @@ static int NameToSrcBlendMode( const char *name ) { if ( r_ignoreDstAlpha->integer ) { - return GLS_DSTBLEND_ONE; + return GLS_SRCBLEND_ONE; } return GLS_SRCBLEND_DST_ALPHA; @@ -319,7 +319,7 @@ static int NameToSrcBlendMode( const char *name ) { if ( r_ignoreDstAlpha->integer ) { - return GLS_DSTBLEND_ZERO; + return GLS_SRCBLEND_ZERO; } return GLS_SRCBLEND_ONE_MINUS_DST_ALPHA; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index bc4901ffee..0094a33b5c 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -569,13 +569,13 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, tr.pc.c_leafs++; // add to z buffer bounds - tr.viewParms.visBounds[0][0] = std::min(node->mins[0], tr.viewParms.visBounds[0][0]); - tr.viewParms.visBounds[0][1] = std::min(node->mins[1], tr.viewParms.visBounds[0][1]); - tr.viewParms.visBounds[0][2] = std::min(node->mins[2], tr.viewParms.visBounds[0][2]); + tr.viewParms.visBounds[0][0] = MIN(node->mins[0], tr.viewParms.visBounds[0][0]); + tr.viewParms.visBounds[0][1] = MIN(node->mins[1], tr.viewParms.visBounds[0][1]); + tr.viewParms.visBounds[0][2] = MIN(node->mins[2], tr.viewParms.visBounds[0][2]); - tr.viewParms.visBounds[1][0] = std::min(node->maxs[0], tr.viewParms.visBounds[1][0]); - tr.viewParms.visBounds[1][1] = std::min(node->maxs[1], tr.viewParms.visBounds[1][1]); - tr.viewParms.visBounds[1][2] = std::min(node->maxs[2], tr.viewParms.visBounds[1][2]); + tr.viewParms.visBounds[1][0] = MIN(node->maxs[0], tr.viewParms.visBounds[1][0]); + tr.viewParms.visBounds[1][1] = MIN(node->maxs[1], tr.viewParms.visBounds[1][1]); + tr.viewParms.visBounds[1][2] = MIN(node->maxs[2], tr.viewParms.visBounds[1][2]); // add merged and unmerged surfaces if (tr.world->viewSurfaces && !r_nocurves->integer) From 5f6be224c92f67c7d19443a91839dbf6c444077c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 2 Jun 2017 23:48:07 +0200 Subject: [PATCH 409/708] Cleanup --- codemp/rd-rend2/glsl/lightall.glsl | 6 +----- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 17 +++++++---------- codemp/rd-rend2/tr_backend.cpp | 22 +++++----------------- codemp/rd-rend2/tr_glsl.cpp | 11 +---------- codemp/rd-rend2/tr_image.cpp | 12 ++++++------ 5 files changed, 20 insertions(+), 48 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 901c7c245e..2605294783 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -332,7 +332,7 @@ uniform sampler2D u_ShadowMap; #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; -uniform sampler2D u_EnvBrdfMap; +uniform sampler2D u_EnvBrdfMap; #endif #if defined(USE_NORMALMAP) || defined(USE_DELUXEMAP) || defined(USE_SPECULARMAP) || defined(USE_CUBEMAP) @@ -531,10 +531,6 @@ vec3 CalcIBLContribution( ) { #if defined(USE_CUBEMAP) - // EnvironmentBRDF is supposed to work with gloss. Invert roughness for now, but this needs - // to be replaced at some point with preconvoluted cubemap code. - //vec3 reflectance = EnvironmentBRDF(1.0 - roughness, NE, specular); - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(1.0 - roughness, NE)).rgb; vec3 R = reflect(E, N); diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index d2c0f20094..842020bc4d 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -8,12 +8,10 @@ void main() { gl_Position = attr_Position; var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; } /*[Fragment]*/ -uniform vec4 u_ViewInfo; // cubeface, mip_level, max_mip_level, 0.0 +uniform vec4 u_ViewInfo; // cubeface, mip_level, max_mip_level, roughness uniform samplerCube u_CubeMap; in vec2 var_ScreenTex; @@ -58,8 +56,8 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) vec3 V = R; vec3 PrefilteredColor = vec3(0.0); float TotalWeight = 0.0; - uint NumSamples = uint(1024); - for ( uint i = uint(0); i < NumSamples; i++ ) + uint NumSamples = 1024u; + for ( uint i = 0u; i < NumSamples; i++ ) { vec2 Xi = hammersley2D( i, NumSamples ); vec3 H = ImportanceSampleGGX( Xi, Roughness, N ); @@ -77,12 +75,10 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) void main() { float cubeFace = u_ViewInfo.x; - vec2 vector; - vector.x = (var_ScreenTex.x - 0.5) * 2.0; - vector.y = (var_ScreenTex.y - 0.5) * 2.0; + vec2 vector = (var_ScreenTex - vec2(0.5)) * 2.0; // from http://www.codinglabs.net/article_physically_based_rendering.aspx - vec3 normal = normalize( vec3(vector.xy, 1) ); + vec3 normal = normalize( vec3(vector.xy, 1) ); if(cubeFace==2) normal = normalize( vec3(vector.x, 1, -vector.y) ); else if(cubeFace==3) @@ -94,7 +90,8 @@ void main() else if(cubeFace==5) normal = normalize( vec3(-vector.x, vector.y, -1) ); - float roughness = u_ViewInfo.y / u_ViewInfo.z; + float roughness = u_ViewInfo.w; + vec3 result = PrefilterEnvMap(roughness, normal); out_Color = vec4(result, 1.0); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a4484bb74a..f8843dc2bc 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1820,12 +1820,6 @@ static const void *RB_PrefilterEnvMap(const void *data) { if (!cubemap) return (const void *)(cmd + 1); - int cubeMipSize = cubemap->width; - int numMips = 0; - - int width = cubemap->width; - int height = cubemap->height; - vec4_t quadVerts[4]; vec2_t texCoords[4]; @@ -1839,19 +1833,15 @@ static const void *RB_PrefilterEnvMap(const void *data) { texCoords[2][0] = 1; texCoords[2][1] = 1; texCoords[3][0] = 0; texCoords[3][1] = 1; - while (cubeMipSize) - { - cubeMipSize >>= 1; - numMips++; - } - numMips = MAX(1, numMips - 2); - FBO_Bind(tr.preFilterEnvMapFbo); GL_BindToTMU(cubemap, TB_CUBEMAP); GLSL_BindProgram(&tr.prefilterEnvMapShader); - for (int level = 1; level <= numMips; level++) + int width = cubemap->width; + int height = cubemap->height; + + for (int level = 1; level <= CUBE_MAP_MIPS; level++) { width = width / 2.0; height = height / 2.0; @@ -1860,15 +1850,13 @@ static const void *RB_PrefilterEnvMap(const void *data) { for (int cubemapSide = 0; cubemapSide < 6; cubemapSide++) { vec4_t viewInfo; - VectorSet4(viewInfo, cubemapSide, level, numMips, 0.0); + VectorSet4(viewInfo, cubemapSide, level, CUBE_MAP_MIPS, (level / (float)CUBE_MAP_MIPS)); GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); RB_InstantQuad2(quadVerts, texCoords); qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cubemapSide, level, 0, 0, 0, 0, width, height); } } - GL_SelectTexture(0); - return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index f081b8f107..3ae9505749 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -378,16 +378,7 @@ static size_t GLSL_GetShaderHeader( if (r_cubeMapping->integer) { - int cubeMipSize = CUBE_MAP_SIZE; // r_cubemapSize->integer; - int numRoughnessMips = 0; - - while (cubeMipSize) - { - cubeMipSize >>= 1; - numRoughnessMips++; - } - numRoughnessMips = MAX(1, numRoughnessMips - 2); - Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", numRoughnessMips)); + Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", CUBE_MAP_MIPS)); } if (extra) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 1b2af88aaf..6adf76104c 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2875,9 +2875,11 @@ R_CreateEnvBrdfLUT from https://github.com/knarkowicz/IntegrateDFG ================ */ -#define LUT_WIDTH 128 -#define LUT_HEIGHT 128 static void R_CreateEnvBrdfLUT(void) { + + static const int LUT_WIDTH = 128; + static const int LUT_HEIGHT = 128; + if (!r_cubeMapping->integer) return; @@ -2885,7 +2887,6 @@ static void R_CreateEnvBrdfLUT(void) { uint16_t data[LUT_WIDTH][LUT_HEIGHT][4]; int b; - float const MATH_PI = 3.14159f; unsigned const sampleNum = 1024; for (unsigned y = 0; y < LUT_HEIGHT; ++y) @@ -2909,7 +2910,7 @@ static void R_CreateEnvBrdfLUT(void) { float const e1 = (float)i / sampleNum; float const e2 = (float)((double)ReverseBits(i) / (double)0x100000000LL); - float const phi = 2.0f * MATH_PI * e1; + float const phi = 2.0f * M_PI * e1; float const cosPhi = cosf(phi); float const sinPhi = sinf(phi); float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (roughness * roughness - 1.0f) * e2)); @@ -2948,8 +2949,7 @@ static void R_CreateEnvBrdfLUT(void) { } } - tr.envBrdfImage = R_CreateImage("*envBrdfLUT", (byte*)data, 128, 128, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA16F); - return; + tr.envBrdfImage = R_CreateImage("*envBrdfLUT", (byte*)data, LUT_WIDTH, LUT_HEIGHT, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA16F); } /* From cc25793e038ed69af62f54a56c496b18a4ff6633 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 8 Nov 2017 16:31:26 +0800 Subject: [PATCH 410/708] Fix pointer/integer relational comparison shader.lightmapIndexes is an array, so can't compare it directly against zero. In the vanilla renderer, the first element of the array is compared so the same is done here. --- codemp/rd-rend2/tr_shader.cpp | 4 ++-- codemp/rd-rend2/tr_weather.cpp | 21 ++++++++++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4dba3193d5..8cf98b3994 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3962,7 +3962,7 @@ static shader_t *FinishShader( void ) { // stage = CollapseStagesToGLSL(); - if ( shader.lightmapIndex >= 0 && !hasLightmapStage ) { + if ( shader.lightmapIndex[0] >= 0 && !hasLightmapStage ) { ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); // Don't set this, it will just add duplicate shaders to the hash //shader.lightmapIndex = LIGHTMAP_NONE; @@ -4565,7 +4565,7 @@ void R_ShaderList_f (void) { ri->Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); - if (shader->lightmapIndex >= 0 ) { + if (shader->lightmapIndex[0] >= 0 ) { ri->Printf (PRINT_ALL, "L "); } else { ri->Printf (PRINT_ALL, " "); diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 06e85379f4..2aa596ed85 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -87,15 +87,18 @@ void R_AddWeatherSurfaces() { assert(tr.weatherSystem); - R_AddDrawSurf( - (surfaceType_t *)&tr.weatherSystem->weatherSurface, - REFENTITYNUM_WORLD, - tr.weatherInternalShader, - 0, /* fogIndex */ - qfalse, /* dlightMap */ - qfalse, /* postRender */ - 0 /* cubemapIndex */ - ); + if (false) + { + R_AddDrawSurf( + (surfaceType_t *)&tr.weatherSystem->weatherSurface, + REFENTITYNUM_WORLD, + tr.weatherInternalShader, + 0, /* fogIndex */ + qfalse, /* dlightMap */ + qfalse, /* postRender */ + 0 /* cubemapIndex */ + ); + } } void RB_SurfaceWeather( srfWeather_t *surf ) From 8f2d051eca349a0bf5a3b0e59ebba1a2bbb66f1f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 8 Nov 2017 17:31:08 +0800 Subject: [PATCH 411/708] Hard code the alpha testing functions Should reduce the number of shaders to compile by ~4x --- codemp/rd-rend2/glsl/fogpass.glsl | 34 +++-- codemp/rd-rend2/glsl/generic.glsl | 34 +++-- codemp/rd-rend2/glsl/lightall.glsl | 34 +++-- codemp/rd-rend2/glsl/surface_sprites.glsl | 4 - codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_glsl.cpp | 144 +++------------------- codemp/rd-rend2/tr_local.h | 56 +++------ codemp/rd-rend2/tr_shade.cpp | 73 ++--------- codemp/rd-rend2/tr_shader.cpp | 40 ++---- codemp/rd-rend2/tr_surface.cpp | 2 +- 10 files changed, 126 insertions(+), 297 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 633cf86ea6..37541a9ab1 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -216,8 +216,8 @@ void main() /*[Fragment]*/ uniform vec4 u_Color; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; +#if defined(USE_ALPHA_TEST) +uniform int u_AlphaTestType; #endif uniform vec4 u_FogPlane; @@ -267,15 +267,27 @@ void main() out_Color.rgb = u_Color.rgb; out_Color.a = sqrt(clamp(fog, 0.0, 1.0)); -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (out_Color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (out_Color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (out_Color.a < u_AlphaTestValue) -# endif - discard; +#if defined(USE_ALPHA_TEST) + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + if (out_Color.a == 0.0) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_LT128) + { + if (out_Color.a >= 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE128) + { + if (out_Color.a < 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + if (out_Color.a < 0.75) + discard; + } #endif #if defined(USE_GLOW_BUFFER) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index fb524f7d17..a36ab25dbe 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -357,8 +357,8 @@ void main() /*[Fragment]*/ uniform sampler2D u_DiffuseMap; -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; +#if defined(USE_ALPHA_TEST) +uniform int u_AlphaTestType; #endif #if defined(USE_FOG) @@ -416,15 +416,27 @@ void main() { vec4 color = texture(u_DiffuseMap, var_DiffuseTex); -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (color.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (color.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (color.a < u_AlphaTestValue) -# endif - discard; +#if defined(USE_ALPHA_TEST) + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + if (color.a == 0.0) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_LT128) + { + if (color.a >= 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE128) + { + if (color.a < 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + if (color.a < 0.75) + discard; + } #endif #if defined(USE_FOG) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 2605294783..5778ad1a57 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -359,8 +359,8 @@ uniform vec4 u_SpecularScale; uniform vec4 u_CubeMapInfo; #endif -#if defined(USE_ATEST) -uniform float u_AlphaTestValue; +#if defined(USE_ALPHA_TEST) +uniform int u_AlphaTestType; #endif @@ -603,15 +603,27 @@ void main() #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); -#if defined(USE_ATEST) -# if USE_ATEST == ATEST_CMP_LT - if (diffuse.a >= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GT - if (diffuse.a <= u_AlphaTestValue) -# elif USE_ATEST == ATEST_CMP_GE - if (diffuse.a < u_AlphaTestValue) -# endif - discard; +#if defined(USE_ALPHA_TEST) + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + if (diffuse.a == 0.0) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_LT128) + { + if (diffuse.a >= 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE128) + { + if (diffuse.a < 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + if (diffuse.a < 0.75) + discard; + } #endif //diffuse.rgb = sRGBToLinear(diffuse.rgb); diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 68bc2e95c2..12c3bb4fe1 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -75,10 +75,6 @@ uniform sampler2D u_DiffuseMap; in vec2 var_TexCoords; in float var_Alpha; -#if defined(ALPHA_TEST) -uniform float u_AlphaTestValue; -#endif - layout(std140) uniform SurfaceSprite { float u_Width; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 73b21bdaff..27e1c0770a 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3517,7 +3517,7 @@ static void R_GenerateSurfaceSprites( bundle, stage->stateBits); out->shader->cullType = shader->cullType; out->shader->stages[0]->glslShaderGroup = tr.spriteShader; - out->shader->stages[0]->alphaTestCmp = stage->alphaTestCmp; + out->shader->stages[0]->alphaTestType = stage->alphaTestType; out->numAttributes = 2; out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3ae9505749..91830aae23 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -150,7 +150,7 @@ static uniformInfo_t uniformsInfo[] = { "u_CubeMapInfo", GLSL_VEC4, 1 }, { "u_BoneMatrices", GLSL_MAT4x3, 20 }, - { "u_AlphaTestValue", GLSL_FLOAT, 1 }, + { "u_AlphaTestType", GLSL_INT, 1 }, { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, { "u_MapZExtents", GLSL_VEC2, 1 }, @@ -360,12 +360,14 @@ static size_t GLSL_GetShaderHeader( GL_REPLACE)); Q_strcat(dest, size, - va("#define ATEST_CMP_LT %d\n" - "#define ATEST_CMP_GT %d\n" - "#define ATEST_CMP_GE %d\n", - ATEST_CMP_LT, - ATEST_CMP_GT, - ATEST_CMP_GE)); + va("#define ALPHA_TEST_GT0 %d\n" + "#define ALPHA_TEST_LT128 %d\n" + "#define ALPHA_TEST_GE128 %d\n" + "#define ALPHA_TEST_GE192 %d\n", + ALPHA_TEST_GT0, + ALPHA_TEST_LT128, + ALPHA_TEST_GE128, + ALPHA_TEST_GE192)); fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); @@ -1312,32 +1314,8 @@ static int GLSL_LoadGPUProgramGeneric( if (i & GENERICDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); - switch ( i & GENERICDEF_USE_ATEST_MASK ) - { - case GENERICDEF_USE_ATEST_LT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_LT\n"); - break; - } - - case GENERICDEF_USE_ATEST_GT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GT\n"); - break; - } - - case GENERICDEF_USE_ATEST_GE: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GE\n"); - break; - } - - default: - break; - } + if (i & GENERICDEF_USE_ALPHA_TEST) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); if (!GLSL_LoadGPUShader(builder, &tr.genericShader[i], "generic", attribs, extradefines, *programDesc)) @@ -1393,32 +1371,8 @@ static int GLSL_LoadGPUProgramFogPass( attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } - switch ( i & FOGDEF_USE_ATEST_MASK ) - { - case FOGDEF_USE_ATEST_LT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_LT\n"); - break; - } - - case FOGDEF_USE_ATEST_GT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GT\n"); - break; - } - - case FOGDEF_USE_ATEST_GE: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GE\n"); - break; - } - - default: - break; - } + if (i & FOGDEF_USE_ALPHA_TEST) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); if (!GLSL_LoadGPUShader(builder, &tr.fogShader[i], "fogpass", attribs, extradefines, *programDesc)) @@ -1451,36 +1405,10 @@ static int GLSL_LoadGPUProgramDLight( extradefines[0] = '\0'; if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) - { Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); - } - - switch ( i & DLIGHTDEF_USE_ATEST_MASK ) - { - case DLIGHTDEF_USE_ATEST_LT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_LT\n"); - break; - } - - case DLIGHTDEF_USE_ATEST_GT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GT\n"); - break; - } - - case DLIGHTDEF_USE_ATEST_GE: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GE\n"); - break; - } - default: - break; - } + if (i & DLIGHTDEF_USE_ALPHA_TEST) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, extradefines, *programDesc)) @@ -1619,32 +1547,8 @@ static int GLSL_LoadGPUProgramLightAll( attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } - switch (i & LIGHTDEF_USE_ATEST_MASK) - { - case LIGHTDEF_USE_ATEST_LT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_LT\n"); - break; - } - - case LIGHTDEF_USE_ATEST_GT: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GT\n"); - break; - } - - case LIGHTDEF_USE_ATEST_GE: - { - Q_strcat(extradefines, sizeof(extradefines), - "#define USE_ATEST ATEST_CMP_GE\n"); - break; - } - - default: - break; - } + if (i & LIGHTDEF_USE_ALPHA_TEST) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); @@ -2418,20 +2322,10 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) int shaderAttribs = 0; if (tess.fogNum && pStage->adjustColorsForFog) - { shaderAttribs |= GENERICDEF_USE_FOG; - } - if ( pStage->alphaTestCmp != ATEST_CMP_NONE ) - { - switch ( pStage->alphaTestCmp ) - { - case ATEST_CMP_LT: shaderAttribs |= GENERICDEF_USE_ATEST_LT; break; - case ATEST_CMP_GT: shaderAttribs |= GENERICDEF_USE_ATEST_GT; break; - case ATEST_CMP_GE: shaderAttribs |= GENERICDEF_USE_ATEST_GE; break; - default: break; - } - } + if ( pStage->alphaTestType != ALPHA_TEST_NONE ) + shaderAttribs |= GENERICDEF_USE_ALPHA_TEST; switch (pStage->rgbGen) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 98bdbde7c7..69acca84b4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -725,12 +725,13 @@ typedef enum ST_GLSL } stageType_t; -enum AlphaTestCmp +enum AlphaTestType { - ATEST_CMP_NONE, - ATEST_CMP_LT, - ATEST_CMP_GT, - ATEST_CMP_GE, + ALPHA_TEST_NONE, + ALPHA_TEST_GT0, + ALPHA_TEST_LT128, + ALPHA_TEST_GE128, + ALPHA_TEST_GE192, }; // any change in the LIGHTMAP_* defines here MUST be reflected in @@ -745,8 +746,7 @@ typedef struct { qboolean isDetail; qboolean glow; - AlphaTestCmp alphaTestCmp; - float alphaTestValue; + AlphaTestType alphaTestType; textureBundle_t bundle[NUM_TEXTURE_BUNDLES]; @@ -1021,15 +1021,9 @@ enum GENERICDEF_USE_RGBAGEN = 0x0010, GENERICDEF_USE_SKELETAL_ANIMATION = 0x0020, GENERICDEF_USE_GLOW_BUFFER = 0x0040, - GENERICDEF_USE_ATEST_LT = 0x0080, - GENERICDEF_USE_ATEST_GT = 0x0100, - GENERICDEF_USE_ATEST_GE = 0x0180, + GENERICDEF_USE_ALPHA_TEST = 0x0080, - GENERICDEF_USE_ATEST_MASK = GENERICDEF_USE_ATEST_LT | - GENERICDEF_USE_ATEST_GT | - GENERICDEF_USE_ATEST_GE, - - GENERICDEF_ALL = 0x01FF, + GENERICDEF_ALL = 0x00FF, GENERICDEF_COUNT = GENERICDEF_ALL + 1, }; @@ -1038,30 +1032,18 @@ enum FOGDEF_USE_DEFORM_VERTEXES = 0x0001, FOGDEF_USE_VERTEX_ANIMATION = 0x0002, FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, - FOGDEF_USE_ATEST_LT = 0x0008, - FOGDEF_USE_ATEST_GT = 0x0010, - FOGDEF_USE_ATEST_GE = 0x0018, - - FOGDEF_USE_ATEST_MASK = FOGDEF_USE_ATEST_LT | - FOGDEF_USE_ATEST_GT | - FOGDEF_USE_ATEST_GE, + FOGDEF_USE_ALPHA_TEST = 0x0008, - FOGDEF_ALL = 0x001F, + FOGDEF_ALL = 0x000F, FOGDEF_COUNT = FOGDEF_ALL + 1, }; enum { DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, - DLIGHTDEF_USE_ATEST_LT = 0x0002, - DLIGHTDEF_USE_ATEST_GT = 0x0004, - DLIGHTDEF_USE_ATEST_GE = 0x0006, - - DLIGHTDEF_USE_ATEST_MASK = DLIGHTDEF_USE_ATEST_LT | - DLIGHTDEF_USE_ATEST_GT | - DLIGHTDEF_USE_ATEST_GE, + DLIGHTDEF_USE_ALPHA_TEST = 0x0002, - DLIGHTDEF_ALL = 0x0007, + DLIGHTDEF_ALL = 0x0003, DLIGHTDEF_COUNT = DLIGHTDEF_ALL + 1, }; @@ -1076,22 +1058,16 @@ enum LIGHTDEF_USE_VERTEX_ANIMATION = 0x0020, LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0040, LIGHTDEF_USE_GLOW_BUFFER = 0x0080, - LIGHTDEF_USE_ATEST_LT = 0x0100, - LIGHTDEF_USE_ATEST_GT = 0x0200, - LIGHTDEF_USE_ATEST_GE = 0x0300, + LIGHTDEF_USE_ALPHA_TEST = 0x0100, LIGHTDEF_LIGHTTYPE_MASK = LIGHTDEF_USE_LIGHTMAP | LIGHTDEF_USE_LIGHT_VECTOR | LIGHTDEF_USE_LIGHT_VERTEX, - LIGHTDEF_USE_ATEST_MASK = LIGHTDEF_USE_ATEST_LT | - LIGHTDEF_USE_ATEST_GT | - LIGHTDEF_USE_ATEST_GE, - LIGHTDEF_ALL = 0x03FF, + LIGHTDEF_ALL = 0x01FF, LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; -// Surface sprite shader flags enum { SSDEF_FACE_CAMERA = 0x01, @@ -1254,7 +1230,7 @@ typedef enum UNIFORM_CUBEMAPINFO, UNIFORM_BONE_MATRICES, - UNIFORM_ALPHA_TEST_VALUE, + UNIFORM_ALPHA_TEST_TYPE, UNIFORM_FX_VOLUMETRIC_BASE, UNIFORM_MAPZEXTENTS, diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 540b836df8..e6dd6ea215 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1251,28 +1251,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if ( !useAlphaTestGE192 ) { - if (stage->alphaTestCmp != ATEST_CMP_NONE) - { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - switch ( stage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= LIGHTDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= LIGHTDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= LIGHTDEF_USE_ATEST_GE; - break; - default: - break; - } - } + if (stage->alphaTestType != ALPHA_TEST_NONE) + index |= LIGHTDEF_USE_ALPHA_TEST; } else { - index |= LIGHTDEF_USE_ATEST_GE; + index |= LIGHTDEF_USE_ALPHA_TEST; } result = &stage->glslShaderGroup[index]; @@ -1298,28 +1282,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if ( !useAlphaTestGE192 ) { - if (stage->alphaTestCmp != ATEST_CMP_NONE) - { - index |= GENERICDEF_USE_TCGEN_AND_TCMOD; - switch ( stage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= GENERICDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= GENERICDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= GENERICDEF_USE_ATEST_GE; - break; - default: - break; - } - } + if (stage->alphaTestType != ALPHA_TEST_NONE) + index |= GENERICDEF_USE_TCGEN_AND_TCMOD | GENERICDEF_USE_ALPHA_TEST; } else { - index |= GENERICDEF_USE_ATEST_GE; + index |= GENERICDEF_USE_ALPHA_TEST; } result = &tr.genericShader[index]; @@ -1358,28 +1326,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if ( !useAlphaTestGE192 ) { - if (stage->alphaTestCmp != ATEST_CMP_NONE) - { - index |= LIGHTDEF_USE_TCGEN_AND_TCMOD; - switch ( stage->alphaTestCmp ) - { - case ATEST_CMP_LT: - index |= LIGHTDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - index |= LIGHTDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - index |= LIGHTDEF_USE_ATEST_GE; - break; - default: - break; - } - } + if (stage->alphaTestType != ALPHA_TEST_NONE) + index |= LIGHTDEF_USE_TCGEN_AND_TCMOD | LIGHTDEF_USE_ALPHA_TEST; } else { - index |= LIGHTDEF_USE_ATEST_GE; + index |= LIGHTDEF_USE_ALPHA_TEST; } } @@ -1579,8 +1531,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); - float alphaTestValue = useAlphaTestGE192 ? 0.75f : pStage->alphaTestValue; - uniformDataWriter.SetUniformFloat(UNIFORM_ALPHA_TEST_VALUE, alphaTestValue); + const AlphaTestType alphaTestType = + useAlphaTestGE192 ? ALPHA_TEST_GE192 : pStage->alphaTestType; + uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, alphaTestType); // // do multitexture @@ -1590,7 +1543,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( backEnd.depthFill ) { - if (pStage->alphaTestCmp == ATEST_CMP_NONE) + if (pStage->alphaTestType == ALPHA_TEST_NONE) samplerBindingsWriter.AddStaticImage(tr.whiteImage, 0); else if ( pStage->bundle[TB_COLORMAP].image[0] != 0 ) samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_COLORMAP], TB_COLORMAP); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 8cf98b3994..372c9bf743 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -244,34 +244,20 @@ ParseAlphaTestFunc */ static void ParseAlphaTestFunc( shaderStage_t *stage, const char *funcname ) { - stage->alphaTestCmp = ATEST_CMP_NONE; + stage->alphaTestType = ALPHA_TEST_NONE; if ( !Q_stricmp( funcname, "GT0" ) ) - { - stage->alphaTestCmp = ATEST_CMP_GT; - stage->alphaTestValue = 0.0f; - } + stage->alphaTestType = ALPHA_TEST_GT0; else if ( !Q_stricmp( funcname, "LT128" ) ) - { - stage->alphaTestCmp = ATEST_CMP_LT; - stage->alphaTestValue = 0.5f; - } + stage->alphaTestType = ALPHA_TEST_LT128; else if ( !Q_stricmp( funcname, "GE128" ) ) - { - stage->alphaTestCmp = ATEST_CMP_GE; - stage->alphaTestValue = 0.5f; - } + stage->alphaTestType = ALPHA_TEST_GE128; else if ( !Q_stricmp( funcname, "GE192" ) ) - { - stage->alphaTestCmp = ATEST_CMP_GE; - stage->alphaTestValue = 0.75f; - } + stage->alphaTestType = ALPHA_TEST_GE192; else - { ri->Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); - } } @@ -3029,20 +3015,8 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (diffuse->glow) defs |= LIGHTDEF_USE_GLOW_BUFFER; - switch ( diffuse->alphaTestCmp ) - { - case ATEST_CMP_LT: - defs |= LIGHTDEF_USE_ATEST_LT; - break; - case ATEST_CMP_GT: - defs |= LIGHTDEF_USE_ATEST_GT; - break; - case ATEST_CMP_GE: - defs |= LIGHTDEF_USE_ATEST_GE; - break; - default: - break; - } + if (diffuse->alphaTestType != ALPHA_TEST_NONE) + defs |= LIGHTDEF_USE_ALPHA_TEST; //ri->Printf(PRINT_ALL, ".\n"); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 85466328dc..c7d673aa1b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2139,7 +2139,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) const surfaceSprite_t *ss = surf->sprite; uint32_t shaderFlags = 0; - if ( firstStage->alphaTestCmp != ATEST_CMP_NONE ) + if ( firstStage->alphaTestType != ALPHA_TEST_NONE ) shaderFlags |= SSDEF_ALPHA_TEST; if ( ss->type == SURFSPRITE_ORIENTED ) From 5d82a8508fd6c59b2f0673babaaba79f9236c8f3 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 8 Nov 2017 21:10:53 +0800 Subject: [PATCH 412/708] Asynchronously readback screenshot data Reduces some of the hitching.... but could do with the actual file writing to happen in a separate thread. --- codemp/rd-rend2/tr_cmds.cpp | 4 + codemp/rd-rend2/tr_init.cpp | 254 ++++++++++++++++++++++-------------- codemp/rd-rend2/tr_local.h | 16 +++ 3 files changed, 179 insertions(+), 95 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index a4d8c8bf40..240e925513 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -523,6 +523,10 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { qglDeleteSync( sync ); thisFrame->sync = NULL; + // Perform readback operations + if (thisFrame->screenshotReadback.pbo > 0) + R_SaveScreenshot(&thisFrame->screenshotReadback); + // Resets resources qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo); thisFrame->uboWriteOffset = 0; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 30e2db92ce..ed2c65de28 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -614,8 +614,8 @@ FIXME: the statics don't get a reinit between fs_game changes ============================================================================== */ -/* -================== +/* +================== RB_ReadPixels Reads an image but takes care of alignment issues for reading RGB images. @@ -628,163 +628,227 @@ alignment of packAlign to ensure efficient copying. Stores the length of padding after a line of pixels to address padlen Return value must be freed with ri->Hunk_FreeTempMemory() -================== -*/ +================== +*/ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen) { byte *buffer, *bufstart; int padwidth, linelen; GLint packAlign; - + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); - + linelen = width * 3; padwidth = PAD(linelen, packAlign); - + // Allocate a few more bytes so that we can choose an alignment we like buffer = (byte *)ri->Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); - + bufstart = (byte*)(PADP((intptr_t) buffer + *offset, packAlign)); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); - + *offset = bufstart - buffer; *padlen = padwidth - linelen; - + return buffer; } /* ================== -RB_TakeScreenshot +R_SaveScreenshotTGA ================== */ -void RB_TakeScreenshot(int x, int y, int width, int height, char *fileName) +void R_SaveScreenshotTGA(const screenshotReadback_t *screenshotReadback) { - byte *allbuf, *buffer; - byte *srcptr, *destptr; - byte *endline, *endmem; - byte temp; - - int linelen, padlen; - size_t offset = 18, memcount; - - allbuf = RB_ReadPixels(x, y, width, height, &offset, &padlen); - buffer = allbuf + offset - 18; - - Com_Memset (buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = width & 255; - buffer[13] = width >> 8; - buffer[14] = height & 255; - buffer[15] = height >> 8; - buffer[16] = 24; // pixel size + const size_t headerSize = 18; + const int width = screenshotReadback->width; + const int height = screenshotReadback->height; + const int stride = screenshotReadback->strideInBytes; + const int linelen = screenshotReadback->rowInBytes; - // swap rgb to bgr and remove padding from line endings - linelen = width * 3; - - srcptr = destptr = allbuf + offset; - endmem = srcptr + (linelen + padlen) * height; - - while(srcptr < endmem) - { - endline = srcptr + linelen; + const size_t pixelBufferSize = stride * height; + const size_t bufferSize = headerSize + pixelBufferSize; + + qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); - while(srcptr < endline) + byte *pixels = static_cast(qglMapBuffer( + GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); + if (pixels != nullptr) + { + byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(bufferSize); + + Com_Memset(buffer, 0, 18); + buffer[2] = 2; // uncompressed type + buffer[12] = width & 255; + buffer[13] = width >> 8; + buffer[14] = height & 255; + buffer[15] = height >> 8; + buffer[16] = 24; // pixel size + + const byte *srcptr = pixels + headerSize; + const byte *endmem = srcptr + bufferSize; + byte *destptr = buffer + headerSize; + + while (srcptr < endmem) { - temp = srcptr[0]; - *destptr++ = srcptr[2]; - *destptr++ = srcptr[1]; - *destptr++ = temp; + const byte *endline = srcptr + linelen; + + while (srcptr < endline) + { + // swap rgb to bgr + const byte temp = srcptr[0]; + *destptr++ = srcptr[2]; + *destptr++ = srcptr[1]; + *destptr++ = temp; + + srcptr += 3; + } - srcptr += 3; + srcptr = endline; } - - // Skip the pad - srcptr += padlen; - } - memcount = linelen * height; + qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); - // gamma correct - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(allbuf + offset, memcount); + if (glConfig.deviceSupportsGamma) + R_GammaCorrect(buffer + headerSize, pixelBufferSize); - ri->FS_WriteFile(fileName, buffer, memcount + 18); - - ri->Hunk_FreeTempMemory(allbuf); + ri->FS_WriteFile(screenshotReadback->filename, buffer, bufferSize); + ri->Hunk_FreeTempMemory(buffer); + } } /* ================== -R_TakeScreenshotPNG +R_SaveScreenshotPNG ================== */ -void RB_TakeScreenshotPNG( int x, int y, int width, int height, char *fileName ) { - byte *buffer; - size_t offset = 0, memcount; - int padlen; +void R_SaveScreenshotPNG(const screenshotReadback_t *screenshotReadback) +{ + const int width = screenshotReadback->width; + const int height = screenshotReadback->height; + const int stride = screenshotReadback->strideInBytes; - buffer = RB_ReadPixels( x, y, width, height, &offset, &padlen ); - memcount = (width * 3 + padlen) * height; + const size_t pixelBufferSize = stride * height; - // gamma correct - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer + offset, memcount); + qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); - RE_SavePNG( fileName, buffer, width, height, 3 ); - ri->Hunk_FreeTempMemory( buffer ); + byte *pixels = static_cast(qglMapBuffer( + GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); + if (pixels != nullptr) + { + byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); + Com_Memcpy(buffer, pixels, pixelBufferSize); + qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); + + if (glConfig.deviceSupportsGamma) + R_GammaCorrect(buffer, pixelBufferSize); + + RE_SavePNG(screenshotReadback->filename, buffer, width, height, 3); + + ri->Hunk_FreeTempMemory(buffer); + } } /* ================== -RB_TakeScreenshotJPEG +R_SaveScreenshotJPG ================== */ -void RB_TakeScreenshotJPEG(int x, int y, int width, int height, char *fileName) +void R_SaveScreenshotJPG(const screenshotReadback_t *screenshotReadback) { - byte *buffer; - size_t offset = 0, memcount; - int padlen; + const int width = screenshotReadback->width; + const int height = screenshotReadback->height; + const int stride = screenshotReadback->strideInBytes; - buffer = RB_ReadPixels(x, y, width, height, &offset, &padlen); - memcount = (width * 3 + padlen) * height; + const size_t pixelBufferSize = stride * height; - // gamma correct - if(glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer + offset, memcount); + qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); + + byte *pixels = static_cast(qglMapBuffer( + GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); + if (pixels != nullptr) + { + byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); + Com_Memcpy(buffer, pixels, pixelBufferSize); + qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); + + if (glConfig.deviceSupportsGamma) + R_GammaCorrect(buffer, pixelBufferSize); + + RE_SaveJPG( + screenshotReadback->filename, + r_screenshotJpegQuality->integer, + width, + height, + buffer, + stride - screenshotReadback->rowInBytes); + ri->Hunk_FreeTempMemory(buffer); + } +} + +void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) +{ + switch (screenshotReadback->format) + { + case SSF_JPEG: + R_SaveScreenshotJPG(screenshotReadback); + break; + case SSF_TGA: + R_SaveScreenshotTGA(screenshotReadback); + break; + case SSF_PNG: + R_SaveScreenshotPNG(screenshotReadback); + break; + } - RE_SaveJPG(fileName, r_screenshotJpegQuality->integer, width, height, buffer + offset, padlen); - ri->Hunk_FreeTempMemory(buffer); + qglDeleteBuffers(1, &screenshotReadback->pbo); + screenshotReadback->pbo = 0; } /* ================== -RB_TakeScreenshotCmd +R_TakeScreenshotCmd ================== */ const void *RB_TakeScreenshotCmd( const void *data ) { - const screenshotCommand_t *cmd; + const screenshotCommand_t *cmd; cmd = (const screenshotCommand_t *)data; // finish any 2D drawing if needed - if(tess.numIndexes) + if (tess.numIndexes) RB_EndSurface(); - switch( cmd->format ) { - case SSF_JPEG: - RB_TakeScreenshotJPEG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); - break; - case SSF_TGA: - RB_TakeScreenshot( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); - break; - case SSF_PNG: - RB_TakeScreenshotPNG( cmd->x, cmd->y, cmd->width, cmd->height, cmd->fileName ); - break; - } - + const int frameNumber = backEndData->realFrameNumber; + gpuFrame_t *thisFrame = &backEndData->frames[frameNumber % MAX_FRAMES]; + screenshotReadback_t *screenshot = &thisFrame->screenshotReadback; + + GLint packAlign; + qglGetIntegerv(GL_PACK_ALIGNMENT, &packAlign); + + const int linelen = cmd->width * 3; + const int strideInBytes = PAD(linelen, packAlign); + + qglGenBuffers(1, &screenshot->pbo); + qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshot->pbo); + qglBufferData( + GL_PIXEL_PACK_BUFFER, + strideInBytes * cmd->height, + nullptr, + GL_STATIC_COPY); + qglReadPixels( + cmd->x, cmd->y, cmd->width, cmd->height, GL_RGB, GL_UNSIGNED_BYTE, 0); + + screenshot->strideInBytes = strideInBytes; + screenshot->rowInBytes = linelen; + screenshot->width = cmd->width; + screenshot->height = cmd->height; + screenshot->format = cmd->format; + Q_strncpyz( + screenshot->filename, cmd->fileName, sizeof(screenshot->filename)); + return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 69acca84b4..b25f489304 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2643,6 +2643,9 @@ void R_SkinList_f( void ); void R_FontList_f( void ); // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516 const void *RB_TakeScreenshotCmd( const void *data ); + +void R_SaveScreenshot(struct screenshotReadback_t *screenshotReadback); + void R_ScreenShotTGA_f( void ); void R_ScreenShotPNG_f( void ); void R_ScreenShotJPEG_f( void ); @@ -3292,6 +3295,17 @@ struct gpuTimedBlock_t GLuint endTimer; }; +struct screenshotReadback_t +{ + GLuint pbo; + int strideInBytes; + int rowInBytes; + int width; + int height; + screenshotFormat_t format; + char filename[MAX_QPATH]; +}; + #define MAX_GPU_TIMERS (512) struct gpuFrame_t { @@ -3299,6 +3313,8 @@ struct gpuFrame_t GLuint ubo; size_t uboWriteOffset; + screenshotReadback_t screenshotReadback; + VBO_t *dynamicVbo; void *dynamicVboMemory; size_t dynamicVboWriteOffset; From 1b1a04d4f5599d3ce32a65fb43c9a1a38c75c0b7 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 9 Nov 2017 15:51:07 +0800 Subject: [PATCH 413/708] Consolidate common save screenshot code Also fix TGA screenshot saving - some problems with out of bounds reads etc. --- codemp/rd-rend2/tr_init.cpp | 211 +++++++++++++++++------------------- 1 file changed, 101 insertions(+), 110 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index ed2c65de28..c1c7bb3ab3 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -631,7 +631,8 @@ Return value must be freed with ri->Hunk_FreeTempMemory() ================== */ -byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *padlen) +static byte *RB_ReadPixels( + int x, int y, int width, int height, size_t *offset, int *padlen) { byte *buffer, *bufstart; int padwidth, linelen; @@ -654,68 +655,60 @@ byte *RB_ReadPixels(int x, int y, int width, int height, size_t *offset, int *pa return buffer; } +static void ConvertRGBtoBGR( + byte *dst, const byte *src, int stride, int width, int height) +{ + const byte *row = src; + for (int y = 0; y < height; ++y) + { + const byte *pixelRGB = row; + for (int x = 0; x < width; ++x) + { + // swap rgb to bgr + const byte temp = pixelRGB[0]; + *dst++ = pixelRGB[2]; + *dst++ = pixelRGB[1]; + *dst++ = temp; + + pixelRGB += 3; + } + + row += stride; + } +} + /* ================== R_SaveScreenshotTGA ================== */ -void R_SaveScreenshotTGA(const screenshotReadback_t *screenshotReadback) +static void R_SaveScreenshotTGA( + const screenshotReadback_t *screenshotReadback, + byte *pixels, + size_t pixelBufferSize) { - const size_t headerSize = 18; const int width = screenshotReadback->width; const int height = screenshotReadback->height; const int stride = screenshotReadback->strideInBytes; - const int linelen = screenshotReadback->rowInBytes; - const size_t pixelBufferSize = stride * height; + const size_t headerSize = 18; const size_t bufferSize = headerSize + pixelBufferSize; - qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); + byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(bufferSize); - byte *pixels = static_cast(qglMapBuffer( - GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); - if (pixels != nullptr) - { - byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(bufferSize); - - Com_Memset(buffer, 0, 18); - buffer[2] = 2; // uncompressed type - buffer[12] = width & 255; - buffer[13] = width >> 8; - buffer[14] = height & 255; - buffer[15] = height >> 8; - buffer[16] = 24; // pixel size - - const byte *srcptr = pixels + headerSize; - const byte *endmem = srcptr + bufferSize; - byte *destptr = buffer + headerSize; - - while (srcptr < endmem) - { - const byte *endline = srcptr + linelen; - - while (srcptr < endline) - { - // swap rgb to bgr - const byte temp = srcptr[0]; - *destptr++ = srcptr[2]; - *destptr++ = srcptr[1]; - *destptr++ = temp; - - srcptr += 3; - } - - srcptr = endline; - } - - qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); + // Write TGA header + Com_Memset(buffer, 0, headerSize); + buffer[2] = 2; // uncompressed type + buffer[12] = width & 255; + buffer[13] = width >> 8; + buffer[14] = height & 255; + buffer[15] = height >> 8; + buffer[16] = 24; // pixel size - if (glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer + headerSize, pixelBufferSize); + ConvertRGBtoBGR(buffer + headerSize, pixels, stride, width, height); - ri->FS_WriteFile(screenshotReadback->filename, buffer, bufferSize); - ri->Hunk_FreeTempMemory(buffer); - } + ri->FS_WriteFile(screenshotReadback->filename, buffer, bufferSize); + ri->Hunk_FreeTempMemory(buffer); } /* @@ -723,31 +716,16 @@ void R_SaveScreenshotTGA(const screenshotReadback_t *screenshotReadback) R_SaveScreenshotPNG ================== */ -void R_SaveScreenshotPNG(const screenshotReadback_t *screenshotReadback) +static void R_SaveScreenshotPNG( + const screenshotReadback_t *screenshotReadback, + byte *pixels) { - const int width = screenshotReadback->width; - const int height = screenshotReadback->height; - const int stride = screenshotReadback->strideInBytes; - - const size_t pixelBufferSize = stride * height; - - qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); - - byte *pixels = static_cast(qglMapBuffer( - GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); - if (pixels != nullptr) - { - byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); - Com_Memcpy(buffer, pixels, pixelBufferSize); - qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); - - if (glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer, pixelBufferSize); - - RE_SavePNG(screenshotReadback->filename, buffer, width, height, 3); - - ri->Hunk_FreeTempMemory(buffer); - } + RE_SavePNG( + screenshotReadback->filename, + pixels, + screenshotReadback->width, + screenshotReadback->height, + 3); } /* @@ -755,52 +733,65 @@ void R_SaveScreenshotPNG(const screenshotReadback_t *screenshotReadback) R_SaveScreenshotJPG ================== */ - -void R_SaveScreenshotJPG(const screenshotReadback_t *screenshotReadback) +static void R_SaveScreenshotJPG( + const screenshotReadback_t *screenshotReadback, + byte *pixels) { - const int width = screenshotReadback->width; - const int height = screenshotReadback->height; - const int stride = screenshotReadback->strideInBytes; - - const size_t pixelBufferSize = stride * height; + RE_SaveJPG( + screenshotReadback->filename, + r_screenshotJpegQuality->integer, + screenshotReadback->width, + screenshotReadback->height, + pixels, + screenshotReadback->strideInBytes - screenshotReadback->rowInBytes); +} +void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) +{ qglBindBuffer(GL_PIXEL_PACK_BUFFER, screenshotReadback->pbo); - byte *pixels = static_cast(qglMapBuffer( - GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); - if (pixels != nullptr) + byte *pixelBuffer = static_cast( + qglMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY)); + + if (pixelBuffer == nullptr) { - byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); - Com_Memcpy(buffer, pixels, pixelBufferSize); - qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); + ri->Printf( + PRINT_ALL, + S_COLOR_RED "Failed to read screenshot data from GPU\n"); + } + else + { + const int height = screenshotReadback->height; + const int stride = screenshotReadback->strideInBytes; + const size_t pixelBufferSize = stride * height; + + byte *pixels = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); + Com_Memcpy(pixels, pixelBuffer, pixelBufferSize); if (glConfig.deviceSupportsGamma) - R_GammaCorrect(buffer, pixelBufferSize); - - RE_SaveJPG( - screenshotReadback->filename, - r_screenshotJpegQuality->integer, - width, - height, - buffer, - stride - screenshotReadback->rowInBytes); - ri->Hunk_FreeTempMemory(buffer); - } -} + R_GammaCorrect(pixels, pixelBufferSize); -void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) -{ - switch (screenshotReadback->format) - { - case SSF_JPEG: - R_SaveScreenshotJPG(screenshotReadback); - break; - case SSF_TGA: - R_SaveScreenshotTGA(screenshotReadback); - break; - case SSF_PNG: - R_SaveScreenshotPNG(screenshotReadback); - break; + switch (screenshotReadback->format) + { + case SSF_JPEG: + R_SaveScreenshotJPG( + screenshotReadback, pixels); + break; + + case SSF_TGA: + R_SaveScreenshotTGA( + screenshotReadback, pixels, pixelBufferSize); + break; + + case SSF_PNG: + R_SaveScreenshotPNG( + screenshotReadback, pixels); + break; + } + + ri->Hunk_FreeTempMemory(pixels); + + qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); } qglDeleteBuffers(1, &screenshotReadback->pbo); From 7e9338a26641c62e8d4114c8b3365556aa461b6f Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 9 Nov 2017 16:27:57 +0800 Subject: [PATCH 414/708] Refactor TGA saving code --- codemp/rd-rend2/tr_init.cpp | 41 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index c1c7bb3ab3..cc026c3e3a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -677,20 +677,14 @@ static void ConvertRGBtoBGR( } } -/* -================== -R_SaveScreenshotTGA -================== -*/ -static void R_SaveScreenshotTGA( - const screenshotReadback_t *screenshotReadback, - byte *pixels, - size_t pixelBufferSize) +static void R_SaveTGA( + const char *filename, + const byte *pixels, + size_t pixelBufferSize, + int width, + int height, + int stride) { - const int width = screenshotReadback->width; - const int height = screenshotReadback->height; - const int stride = screenshotReadback->strideInBytes; - const size_t headerSize = 18; const size_t bufferSize = headerSize + pixelBufferSize; @@ -707,10 +701,29 @@ static void R_SaveScreenshotTGA( ConvertRGBtoBGR(buffer + headerSize, pixels, stride, width, height); - ri->FS_WriteFile(screenshotReadback->filename, buffer, bufferSize); + ri->FS_WriteFile(filename, buffer, bufferSize); ri->Hunk_FreeTempMemory(buffer); } +/* +================== +R_SaveScreenshotTGA +================== +*/ +static void R_SaveScreenshotTGA( + const screenshotReadback_t *screenshotReadback, + byte *pixels, + size_t pixelBufferSize) +{ + R_SaveTGA( + screenshotReadback->filename, + pixels, + pixelBufferSize, + screenshotReadback->width, + screenshotReadback->height, + screenshotReadback->strideInBytes); +} + /* ================== R_SaveScreenshotPNG From 5b0329d8c2ed467df0646526395f2228ad6562c3 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 9 Nov 2017 16:29:24 +0800 Subject: [PATCH 415/708] Unmap PBO buffer as soon as we're finished with it --- codemp/rd-rend2/tr_init.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index cc026c3e3a..7867c65613 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -780,6 +780,7 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) byte *pixels = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); Com_Memcpy(pixels, pixelBuffer, pixelBufferSize); + qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); if (glConfig.deviceSupportsGamma) R_GammaCorrect(pixels, pixelBufferSize); @@ -803,8 +804,6 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) } ri->Hunk_FreeTempMemory(pixels); - - qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); } qglDeleteBuffers(1, &screenshotReadback->pbo); From abd303f0c8470b13f2461aa1e70f739f1a6f8e5d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 9 Nov 2017 16:31:11 +0800 Subject: [PATCH 416/708] Some more tidying up of screenshot code --- codemp/rd-rend2/tr_init.cpp | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 7867c65613..82f08c989a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -680,12 +680,12 @@ static void ConvertRGBtoBGR( static void R_SaveTGA( const char *filename, const byte *pixels, - size_t pixelBufferSize, int width, int height, int stride) { const size_t headerSize = 18; + const size_t pixelBufferSize = stride * height; const size_t bufferSize = headerSize + pixelBufferSize; byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(bufferSize); @@ -711,14 +711,11 @@ R_SaveScreenshotTGA ================== */ static void R_SaveScreenshotTGA( - const screenshotReadback_t *screenshotReadback, - byte *pixels, - size_t pixelBufferSize) + const screenshotReadback_t *screenshotReadback, byte *pixels) { R_SaveTGA( screenshotReadback->filename, pixels, - pixelBufferSize, screenshotReadback->width, screenshotReadback->height, screenshotReadback->strideInBytes); @@ -730,8 +727,7 @@ R_SaveScreenshotPNG ================== */ static void R_SaveScreenshotPNG( - const screenshotReadback_t *screenshotReadback, - byte *pixels) + const screenshotReadback_t *screenshotReadback, byte *pixels) { RE_SavePNG( screenshotReadback->filename, @@ -747,8 +743,7 @@ R_SaveScreenshotJPG ================== */ static void R_SaveScreenshotJPG( - const screenshotReadback_t *screenshotReadback, - byte *pixels) + const screenshotReadback_t *screenshotReadback, byte *pixels) { RE_SaveJPG( screenshotReadback->filename, @@ -788,18 +783,15 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) switch (screenshotReadback->format) { case SSF_JPEG: - R_SaveScreenshotJPG( - screenshotReadback, pixels); + R_SaveScreenshotJPG(screenshotReadback, pixels); break; case SSF_TGA: - R_SaveScreenshotTGA( - screenshotReadback, pixels, pixelBufferSize); + R_SaveScreenshotTGA(screenshotReadback, pixels); break; case SSF_PNG: - R_SaveScreenshotPNG( - screenshotReadback, pixels); + R_SaveScreenshotPNG(screenshotReadback, pixels); break; } From a6b6bf0ea6bbe8168567a83628b4928858aa03fb Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Thu, 9 Nov 2017 16:50:46 +0800 Subject: [PATCH 417/708] Use Nvidia and AMD device when available On laptops which have dual GPUs, it's desirable to use the dedicated graphics device instead of the integrated one. --- codemp/rd-rend2/tr_init.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 82f08c989a..5a02a0cca7 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -32,6 +32,13 @@ static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; static size_t FRAME_VERTEX_BUFFER_SIZE = 8*1024*1024; static size_t FRAME_INDEX_BUFFER_SIZE = 2*1024*1024; +#if defined(_WIN32) +extern "C" { + _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; +} +#endif + glconfig_t glConfig; glconfigExt_t glConfigExt; glRefConfig_t glRefConfig; From 6193ed02d5a5d2ddeb4e909eb12a73414a1b6a19 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:27:42 +1100 Subject: [PATCH 418/708] Fix compiler warning --- codemp/rd-rend2/tr_backend.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f8843dc2bc..288720be5b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2158,8 +2158,6 @@ static void RB_TransformAllAnimations( drawSurf_t *drawSurfs, int numDrawSurfs ) { continue; } - - CRenderableSurface *g2Surface = reinterpret_cast(drawSurf); } } From 3d4b0823676bb56a316c8a245a97d5c533be7559 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:27:54 +1100 Subject: [PATCH 419/708] Remove unused variables and some manual hoisting Hoisted some loop variables into outer scope as they didn't change. --- codemp/rd-rend2/tr_image.cpp | 57 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 6adf76104c..1180042869 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2872,7 +2872,7 @@ static void R_CreateFogImage( void ) { /* ================ R_CreateEnvBrdfLUT -from https://github.com/knarkowicz/IntegrateDFG +based on https://github.com/knarkowicz/IntegrateDFG ================ */ static void R_CreateEnvBrdfLUT(void) { @@ -2883,36 +2883,31 @@ static void R_CreateEnvBrdfLUT(void) { if (!r_cubeMapping->integer) return; - int x, y; - uint16_t data[LUT_WIDTH][LUT_HEIGHT][4]; - int b; + uint16_t data[LUT_WIDTH][LUT_HEIGHT][4]; - unsigned const sampleNum = 1024; + unsigned const numSamples = 1024; for (unsigned y = 0; y < LUT_HEIGHT; ++y) { - float const ndotv = (y + 0.5f) / LUT_HEIGHT; + float const NdotV = (y + 0.5f) / LUT_HEIGHT; + float const vx = sqrtf(1.0f - NdotV * NdotV); + float const vy = 0.0f; + float const vz = NdotV; for (unsigned x = 0; x < LUT_WIDTH; ++x) { float const gloss = (x + 0.5f) / LUT_WIDTH; float const roughness = powf(1.0f - gloss, 2.0f); - float const vx = sqrtf(1.0f - ndotv * ndotv); - float const vy = 0.0f; - float const vz = ndotv; - float scale = 0.0f; float bias = 0.0f; - for (unsigned i = 0; i < sampleNum; ++i) + for (unsigned i = 0; i < numSamples; ++i) { - float const e1 = (float)i / sampleNum; + float const e1 = (float)i / numSamples; float const e2 = (float)((double)ReverseBits(i) / (double)0x100000000LL); float const phi = 2.0f * M_PI * e1; - float const cosPhi = cosf(phi); - float const sinPhi = sinf(phi); float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (roughness * roughness - 1.0f) * e2)); float const sinTheta = sqrtf(1.0f - cosTheta * cosTheta); @@ -2921,26 +2916,25 @@ static void R_CreateEnvBrdfLUT(void) { float const hz = cosTheta; float const vdh = vx * hx + vy * hy + vz * hz; - float const lx = 2.0f * vdh * hx - vx; - float const ly = 2.0f * vdh * hy - vy; float const lz = 2.0f * vdh * hz - vz; - float const ndotl = MAX(lz, 0.0f); - float const ndoth = MAX(hz, 0.0f); - float const vdoth = MAX(vdh, 0.0f); + float const NdotL = MAX(lz, 0.0f); + float const NdotH = MAX(hz, 0.0f); + float const VdotH = MAX(vdh, 0.0f); - if (ndotl > 0.0f) + if (NdotL > 0.0f) { - float const gsmith = GSmithCorrelated(roughness, ndotv, ndotl); - float const ndotlVisPDF = ndotl * gsmith * (4.0f * vdoth / ndoth); - float const fc = powf(1.0f - vdoth, 5.0f); + float const gsmith = GSmithCorrelated(roughness, NdotV, NdotL); + float const NdotLVisPDF = NdotL * gsmith * (4.0f * VdotH / NdotH); + float const fc = powf(1.0f - VdotH, 5.0f); - scale += ndotlVisPDF * (1.0f - fc); - bias += ndotlVisPDF * fc; + scale += NdotLVisPDF * (1.0f - fc); + bias += NdotLVisPDF * fc; } } - scale /= sampleNum; - bias /= sampleNum; + + scale /= numSamples; + bias /= numSamples; data[y][x][0] = FloatToHalf(scale); data[y][x][1] = FloatToHalf(bias); @@ -2949,7 +2943,14 @@ static void R_CreateEnvBrdfLUT(void) { } } - tr.envBrdfImage = R_CreateImage("*envBrdfLUT", (byte*)data, LUT_WIDTH, LUT_HEIGHT, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA16F); + tr.envBrdfImage = R_CreateImage( + "*envBrdfLUT", + (byte*)data, + LUT_WIDTH, + LUT_HEIGHT, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + GL_RGBA16F); } /* From 66e843b7f0650ee5cec7549e88ff09edf944708d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:32:26 +1100 Subject: [PATCH 420/708] Small fix to cubemap integration Should be roughness^4 instead of roughness^2 --- codemp/rd-rend2/tr_image.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 1180042869..57f77a0666 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2898,6 +2898,8 @@ static void R_CreateEnvBrdfLUT(void) { { float const gloss = (x + 0.5f) / LUT_WIDTH; float const roughness = powf(1.0f - gloss, 2.0f); + float const m = roughness * roughness; + float const m2 = m * m; float scale = 0.0f; float bias = 0.0f; @@ -2908,7 +2910,7 @@ static void R_CreateEnvBrdfLUT(void) { float const e2 = (float)((double)ReverseBits(i) / (double)0x100000000LL); float const phi = 2.0f * M_PI * e1; - float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (roughness * roughness - 1.0f) * e2)); + float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (m2 - 1.0f) * e2)); float const sinTheta = sqrtf(1.0f - cosTheta * cosTheta); float const hx = sinTheta * cosf(phi); From a6481f33b6fa170c9259eb6cb35b14db38c24915 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:35:56 +1100 Subject: [PATCH 421/708] Some renaming in cubemap integration code --- codemp/rd-rend2/tr_image.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 57f77a0666..94521513a4 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2926,12 +2926,12 @@ static void R_CreateEnvBrdfLUT(void) { if (NdotL > 0.0f) { - float const gsmith = GSmithCorrelated(roughness, NdotV, NdotL); - float const NdotLVisPDF = NdotL * gsmith * (4.0f * VdotH / NdotH); - float const fc = powf(1.0f - VdotH, 5.0f); + float const visibility = GSmithCorrelated(roughness, NdotV, NdotL); + float const NdotLVisPDF = NdotL * visibility * (4.0f * VdotH / NdotH); + float const fresnel = powf(1.0f - VdotH, 5.0f); - scale += NdotLVisPDF * (1.0f - fc); - bias += NdotLVisPDF * fc; + scale += NdotLVisPDF * (1.0f - fresnel); + bias += NdotLVisPDF * fresnel; } } From 216a6fa33a836f7ee3340af7471d1a71a9f3d705 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:41:49 +1100 Subject: [PATCH 422/708] Small fix to GGX equation --- codemp/rd-rend2/tr_extramath.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 497c859052..767c2901c9 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -249,10 +249,12 @@ uint32_t ReverseBits(uint32_t v) return v; } -float GSmithCorrelated(float roughness, float ndotv, float ndotl) +float GSmithCorrelated(float roughness, float NdotV, float NdotL) { - float m2 = roughness * roughness; - float visV = ndotl * sqrt(ndotv * (ndotv - ndotv * m2) + m2); - float visL = ndotv * sqrt(ndotl * (ndotl - ndotl * m2) + m2); + const float m = roughness * roughness; + const float m2 = m * m; + const float visV = NdotL * sqrtf(NdotV * (NdotV - NdotV * m2) + m2); + const float visL = NdotV * sqrtf(NdotL * (NdotL - NdotL * m2) + m2); + return 0.5f / (visV + visL); -} \ No newline at end of file +} From 6b6869c815939a5e8e9c49d214010b6be23122be Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 21 Nov 2017 22:45:19 +1100 Subject: [PATCH 423/708] Don't invert roughness when calculating BRDF --- codemp/rd-rend2/glsl/lightall.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 5778ad1a57..21643e3251 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -531,7 +531,7 @@ vec3 CalcIBLContribution( ) { #if defined(USE_CUBEMAP) - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(1.0 - roughness, NE)).rgb; + vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; vec3 R = reflect(E, N); From 3dba1e1de03c62d8f10e2a4d584545ba1c9b4163 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 22 Nov 2017 20:33:57 +1100 Subject: [PATCH 424/708] Remove unused GLSL function --- codemp/rd-rend2/glsl/lightall.glsl | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 21643e3251..bbc05e2ad2 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -511,16 +511,6 @@ vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) #endif } -vec3 EnvironmentBRDF(float gloss, float NE, vec3 specular) -{ - // from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf - vec4 t = vec4( 1/0.96, 0.475, (0.0275 - 0.25 * 0.04)/0.96,0.25 ) * gloss; - t += vec4( 0.0, 0.0, (0.015 - 0.75 * 0.04)/0.96,0.75 ); - float a0 = t.x * min( t.y, exp2( -9.28 * NE ) ) + t.z; - float a1 = t.w; - return clamp( a0 + specular * ( a1 - a0 ), 0.0, 1.0 ); -} - vec3 CalcIBLContribution( in float roughness, in vec3 N, From 8c4de67bb8cb4625b625b1fa3ecc3dad3e6db3db Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 24 Nov 2017 11:47:52 +1100 Subject: [PATCH 425/708] Make some small code style changes --- codemp/rd-rend2/tr_backend.cpp | 23 ++++++++++++----------- codemp/rd-rend2/tr_main.cpp | 11 +++++++++-- codemp/rd-rend2/tr_surface.cpp | 13 ++++++------- codemp/rd-rend2/tr_vbo.cpp | 2 +- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 288720be5b..2aeb0701d1 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1954,23 +1954,24 @@ static void RB_RenderSSAO() const float zmin = r_znear->value; const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; - vec4_t quadVerts[4]; - vec2_t texCoords[4]; FBO_Bind(tr.quarterFbo[0]); qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - VectorSet4(quadVerts[0], -1, 1, 0, 1); - VectorSet4(quadVerts[1], 1, 1, 0, 1); - VectorSet4(quadVerts[2], 1, -1, 0, 1); - VectorSet4(quadVerts[3], -1, -1, 0, 1); - - texCoords[0][0] = 0; texCoords[0][1] = 1; - texCoords[1][0] = 1; texCoords[1][1] = 1; - texCoords[2][0] = 1; texCoords[2][1] = 0; - texCoords[3][0] = 0; texCoords[3][1] = 0; + vec4_t quadVerts[4] = { + {-1.0f, 1.0f, 0.0f, 1.0f}, + { 1.0f, 1.0f, 0.0f, 1.0f}, + { 1.0f, -1.0f, 0.0f, 1.0f}, + {-1.0f, -1.0f, 0.0f, 1.0f}, + }; + vec2_t texCoords[4] = { + {0.0f, 1.0f}, + {1.0f, 1.0f}, + {1.0f, 0.0f}, + {0.0f, 0.0f}, + }; GL_State( GLS_DEPTHTEST_DISABLE ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index e7f2877025..b0cd3d3f66 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1768,8 +1768,15 @@ uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender R_AddDrawSurf ================= */ -void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, - int dlightMap, int postRender, int cubemap ) { +void R_AddDrawSurf( + surfaceType_t *surface, + int entityNum, + shader_t *shader, + int fogIndex, + int dlightMap, + int postRender, + int cubemap) +{ int index; drawSurf_t *surf; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index c7d673aa1b..630d38310d 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2019,23 +2019,22 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { break; case RT_ENT_CHAIN: { - int i, count, start; - static trRefEntity_t tempEnt = *backEnd.currentEntity; + static trRefEntity_t tempEnt = *backEnd.currentEntity; + //rww - if not static then currentEntity is garbage because //this is a local. This was not static in sof2.. but I guess //they never check ce.renderfx so it didn't show up. - start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; - count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; + const int start = backEnd.currentEntity->e.uRefEnt.uMini.miniStart; + const int count = backEnd.currentEntity->e.uRefEnt.uMini.miniCount; assert(count > 0); backEnd.currentEntity = &tempEnt; assert(backEnd.currentEntity->e.renderfx >= 0); - for(i=0;ie, &backEnd.refdef.entities[start+i].e, sizeof(backEnd.refdef.entities[start+i].e)); - + backEnd.currentEntity->e = backEnd.refdef.entities[j].e; assert(backEnd.currentEntity->e.renderfx >= 0); RB_SurfaceEntity(surfType); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 625f96025a..ac31435cfc 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -480,7 +480,7 @@ void RB_UpdateVBOs(unsigned int attribBits) backEnd.pc.c_dynamicVboDraws++; // update the default VBO - if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) + if (tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES) { VBO_t *frameVbo = currentFrame->dynamicVbo; GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; From ddd58a846c0d4cc0feeeb83aaefac287ff7c9a4d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Fri, 24 Nov 2017 20:57:31 +0800 Subject: [PATCH 426/708] Fix typo --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5a02a0cca7..a3d601fd31 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -34,7 +34,7 @@ static size_t FRAME_INDEX_BUFFER_SIZE = 2*1024*1024; #if defined(_WIN32) extern "C" { - _declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; + __declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001; __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; } #endif From 113156d2fee5ae94eaf19e86b2d6422584fe5373 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 25 Nov 2017 16:52:37 +0800 Subject: [PATCH 427/708] Fix invalid texture format for f32 depth texture This also fixes a problem where SSAO wasn't working. --- codemp/rd-rend2/tr_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 94521513a4..5fbb8feebe 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3105,7 +3105,7 @@ void R_CreateBuiltinImages( void ) { if (r_ssao->integer) { tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_INTENSITY32F_ARB); + tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_R32F); } if (r_shadows->integer == 4) From 0e1496a41b62d3ed454839391258a1ede504334d Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 26 Nov 2017 00:25:56 +0800 Subject: [PATCH 428/708] Make some code formatting changes --- codemp/rd-rend2/tr_fbo.cpp | 138 +++++++++++++++++----------------- codemp/rd-rend2/tr_image.cpp | 142 +++++++++++++++++++++++++---------- 2 files changed, 169 insertions(+), 111 deletions(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 3d2ee28d85..6909318906 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -372,7 +372,6 @@ FBO_Init void FBO_Init(void) { int i; - // int width, height, hdrFormat, multisample; int hdrFormat, multisample; ri->Printf(PRINT_ALL, "------- FBO_Init -------\n"); @@ -419,39 +418,40 @@ void FBO_Init(void) // otherwise just render straight to the screen (tr.renderFbo = NULL) if (multisample) { - tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_Bind(tr.renderFbo); + tr.renderFbo = FBO_Create( + "_render", tr.renderDepthImage->width, + tr.renderDepthImage->height); + FBO_Bind(tr.renderFbo); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 1, multisample); FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, multisample); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderFbo); - tr.msaaResolveFbo = FBO_Create("_msaaResolve", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_Bind(tr.msaaResolveFbo); + tr.msaaResolveFbo = FBO_Create( + "_msaaResolve", tr.renderDepthImage->width, + tr.renderDepthImage->height); + FBO_Bind(tr.msaaResolveFbo); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.msaaResolveFbo); } else { - tr.renderFbo = FBO_Create("_render", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_Bind(tr.renderFbo); + tr.renderFbo = FBO_Create( + "_render", tr.renderDepthImage->width, + tr.renderDepthImage->height); + FBO_Bind(tr.renderFbo); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderFbo); @@ -459,24 +459,20 @@ void FBO_Init(void) // clear render buffer // this fixes the corrupt screen bug with r_hdr 1 on older hardware - if (tr.renderFbo) - { - FBO_Bind(tr.renderFbo); - qglClearColor( 1, 0, 0.5, 1 ); - qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); - FBO_Bind(NULL); - } + FBO_Bind(tr.renderFbo); + qglClearColor( 1, 0, 0.5, 1 ); + qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // glow buffers { for ( int i = 0; i < ARRAY_LEN(tr.glowImageScaled); i++ ) { - tr.glowFboScaled[i] = FBO_Create (va ("*glowScaled%d", i), tr.glowImageScaled[i]->width, tr.glowImageScaled[i]->height); + tr.glowFboScaled[i] = FBO_Create( + va("*glowScaled%d", i), tr.glowImageScaled[i]->width, + tr.glowImageScaled[i]->height); FBO_Bind (tr.glowFboScaled[i]); - FBO_AttachTextureImage (tr.glowImageScaled[i], 0); - FBO_SetupDrawBuffers(); R_CheckFBO (tr.glowFboScaled[i]); @@ -485,13 +481,13 @@ void FBO_Init(void) if (r_drawSunRays->integer) { - tr.sunRaysFbo = FBO_Create("_sunRays", tr.renderDepthImage->width, tr.renderDepthImage->height); - FBO_Bind(tr.sunRaysFbo); + tr.sunRaysFbo = FBO_Create( + "_sunRays", tr.renderDepthImage->width, + tr.renderDepthImage->height); + FBO_Bind(tr.sunRaysFbo); FBO_AttachTextureImage(tr.sunRaysImage, 0); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.sunRaysFbo); @@ -503,15 +499,13 @@ void FBO_Init(void) { for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) { - tr.pshadowFbos[i] = FBO_Create(va("_shadowmap%d", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); - FBO_Bind(tr.pshadowFbos[i]); + tr.pshadowFbos[i] = FBO_Create( + va("_shadowmap%d", i), tr.pshadowMaps[i]->width, + tr.pshadowMaps[i]->height); - //FBO_CreateBuffer(tr.pshadowFbos[i], GL_RGBA8, 0, 0); + FBO_Bind(tr.pshadowFbos[i]); FBO_AttachTextureImage(tr.pshadowMaps[i], 0); - FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24, 0, 0); - //R_AttachFBOTextureDepth(tr.textureDepthImage->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.pshadowFbos[i]); @@ -523,27 +517,25 @@ void FBO_Init(void) { for ( i = 0; i < 3; i++) { - tr.sunShadowFbo[i] = FBO_Create("_sunshadowmap", tr.sunShadowDepthImage[i]->width, tr.sunShadowDepthImage[i]->height); - FBO_Bind(tr.sunShadowFbo[i]); + tr.sunShadowFbo[i] = FBO_Create( + "_sunshadowmap", tr.sunShadowDepthImage[i]->width, + tr.sunShadowDepthImage[i]->height); - //FBO_CreateBuffer(tr.sunShadowFbo[i], GL_RGBA8, 0, 0); - //FBO_AttachTextureImage(tr.sunShadowImage, 0); + FBO_Bind(tr.sunShadowFbo[i]); qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); - - //FBO_CreateBuffer(tr.sunShadowFbo, GL_DEPTH_COMPONENT24, 0, 0); R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.sunShadowFbo[i]); } - tr.screenShadowFbo = FBO_Create("_screenshadow", tr.screenShadowImage->width, tr.screenShadowImage->height); + tr.screenShadowFbo = FBO_Create( + "_screenshadow", tr.screenShadowImage->width, + tr.screenShadowImage->height); + FBO_Bind(tr.screenShadowFbo); - FBO_AttachTextureImage(tr.screenShadowImage, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.screenShadowFbo); @@ -551,36 +543,36 @@ void FBO_Init(void) for (i = 0; i < 2; i++) { - tr.textureScratchFbo[i] = FBO_Create(va("_texturescratch%d", i), tr.textureScratchImage[i]->width, tr.textureScratchImage[i]->height); - FBO_Bind(tr.textureScratchFbo[i]); + tr.textureScratchFbo[i] = FBO_Create( + va("_texturescratch%d", i), tr.textureScratchImage[i]->width, + tr.textureScratchImage[i]->height); - //FBO_CreateBuffer(tr.textureScratchFbo[i], GL_RGBA8, 0, 0); + FBO_Bind(tr.textureScratchFbo[i]); FBO_AttachTextureImage(tr.textureScratchImage[i], 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.textureScratchFbo[i]); } { - tr.calcLevelsFbo = FBO_Create("_calclevels", tr.calcLevelsImage->width, tr.calcLevelsImage->height); - FBO_Bind(tr.calcLevelsFbo); + tr.calcLevelsFbo = FBO_Create( + "_calclevels", tr.calcLevelsImage->width, + tr.calcLevelsImage->height); - //FBO_CreateBuffer(tr.calcLevelsFbo, hdrFormat, 0, 0); + FBO_Bind(tr.calcLevelsFbo); FBO_AttachTextureImage(tr.calcLevelsImage, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.calcLevelsFbo); } { - tr.targetLevelsFbo = FBO_Create("_targetlevels", tr.targetLevelsImage->width, tr.targetLevelsImage->height); - FBO_Bind(tr.targetLevelsFbo); + tr.targetLevelsFbo = FBO_Create( + "_targetlevels", tr.targetLevelsImage->width, + tr.targetLevelsImage->height); - //FBO_CreateBuffer(tr.targetLevelsFbo, hdrFormat, 0, 0); + FBO_Bind(tr.targetLevelsFbo); FBO_AttachTextureImage(tr.targetLevelsImage, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.targetLevelsFbo); @@ -588,12 +580,12 @@ void FBO_Init(void) for (i = 0; i < 2; i++) { - tr.quarterFbo[i] = FBO_Create(va("_quarter%d", i), tr.quarterImage[i]->width, tr.quarterImage[i]->height); - FBO_Bind(tr.quarterFbo[i]); + tr.quarterFbo[i] = FBO_Create( + va("_quarter%d", i), tr.quarterImage[i]->width, + tr.quarterImage[i]->height); - //FBO_CreateBuffer(tr.quarterFbo[i], hdrFormat, 0, 0); + FBO_Bind(tr.quarterFbo[i]); FBO_AttachTextureImage(tr.quarterImage[i], 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.quarterFbo[i]); @@ -601,20 +593,21 @@ void FBO_Init(void) if (r_ssao->integer) { - tr.hdrDepthFbo = FBO_Create("_hdrDepth", tr.hdrDepthImage->width, tr.hdrDepthImage->height); - FBO_Bind(tr.hdrDepthFbo); + tr.hdrDepthFbo = FBO_Create( + "_hdrDepth", tr.hdrDepthImage->width, tr.hdrDepthImage->height); + FBO_Bind(tr.hdrDepthFbo); FBO_AttachTextureImage(tr.hdrDepthImage, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.hdrDepthFbo); - tr.screenSsaoFbo = FBO_Create("_screenssao", tr.screenSsaoImage->width, tr.screenSsaoImage->height); + tr.screenSsaoFbo = FBO_Create( + "_screenssao", tr.screenSsaoImage->width, + tr.screenSsaoImage->height); + FBO_Bind(tr.screenSsaoFbo); - FBO_AttachTextureImage(tr.screenSsaoImage, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.screenSsaoFbo); @@ -622,15 +615,16 @@ void FBO_Init(void) if (tr.renderCubeImage != NULL) { - tr.renderCubeFbo = FBO_Create("_renderCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); + tr.renderCubeFbo = FBO_Create( + "_renderCubeFbo", tr.renderCubeImage->width, + tr.renderCubeImage->height); + FBO_Bind(tr.renderCubeFbo); - - R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); + R_AttachFBOTexture2D( + GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); glState.currentFBO->colorImage[0] = tr.renderCubeImage; glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; - FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderCubeFbo); @@ -638,10 +632,14 @@ void FBO_Init(void) if (tr.renderCubeImage != NULL) { - tr.preFilterEnvMapFbo = FBO_Create("_preFilterEnvMapFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); + tr.preFilterEnvMapFbo = FBO_Create( + "_preFilterEnvMapFbo", tr.renderCubeImage->width, + tr.renderCubeImage->height); + FBO_Bind(tr.preFilterEnvMapFbo); FBO_AttachTextureImage(tr.prefilterEnvMapImage, 0); FBO_SetupDrawBuffers(); + R_CheckFBO(tr.preFilterEnvMapFbo); } diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 5fbb8feebe..b014507a3a 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2988,7 +2988,9 @@ static void R_CreateDefaultImage( void ) { data[x][DEFAULT_SIZE-1][2] = data[x][DEFAULT_SIZE-1][3] = 255; } - tr.defaultImage = R_CreateImage("*default", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_MIPMAP, 0); + tr.defaultImage = R_CreateImage( + "*default", (byte *)data, DEFAULT_SIZE, DEFAULT_SIZE, + IMGTYPE_COLORALPHA, IMGFLAG_MIPMAP, GL_RGBA8); } /* @@ -3004,68 +3006,90 @@ void R_CreateBuiltinImages( void ) { // we use a solid white image instead of disabling texturing Com_Memset( data, 255, sizeof( data ) ); - tr.whiteImage = R_CreateImage("*white", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, 0); + tr.whiteImage = R_CreateImage( + "*white", (byte *)data, 8, 8, IMGTYPE_COLORALPHA, IMGFLAG_NONE, + GL_RGBA8); if (r_dlightMode->integer >= 2) { - for( x = 0; x < MAX_DLIGHTS; x++) + for (x = 0; x < MAX_DLIGHTS; x++) { - tr.shadowCubemaps[x] = R_CreateImage(va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); + tr.shadowCubemaps[x] = R_CreateImage( + va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, + PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, + IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); } } - // with overbright bits active, we need an image which is some fraction of full color, - // for default lightmaps, etc - for (x=0 ; xinteger) hdrFormat = GL_RGBA16F; - rgbFormat = GL_RGBA8; + int rgbFormat = GL_RGBA8; - tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.renderImage = R_CreateImage( + "_render", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.glowImage = R_CreateImage("*glow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImage = R_CreateImage( + "*glow", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); int glowImageWidth = width; int glowImageHeight = height; - for ( int i = 0; i < ARRAY_LEN(tr.glowImageScaled); i++ ) + for (int i = 0; i < ARRAY_LEN(tr.glowImageScaled); i++) { - tr.glowImageScaled[i] = R_CreateImage(va("*glowScaled%d", i), NULL, glowImageWidth, glowImageHeight, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.glowImageScaled[i] = R_CreateImage( + va("*glowScaled%d", i), NULL, glowImageWidth, glowImageHeight, + IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + hdrFormat); + glowImageWidth = Q_max(1, glowImageWidth >> 1); glowImageHeight = Q_max(1, glowImageHeight >> 1); } if (r_drawSunRays->integer) - tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); + tr.sunRaysImage = R_CreateImage( + "*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); - tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + tr.renderDepthImage = R_CreateImage( + "*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + tr.textureDepthImage = R_CreateImage( + "*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, + IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + GL_DEPTH_COMPONENT24); { unsigned short sdata[4]; @@ -3088,48 +3112,84 @@ void R_CreateBuiltinImages( void ) { p = data; } - tr.calcLevelsImage = R_CreateImage("*calcLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.targetLevelsImage = R_CreateImage("*targetLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); - tr.fixedLevelsImage = R_CreateImage("*fixedLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.calcLevelsImage = R_CreateImage( + "*calcLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.targetLevelsImage = R_CreateImage( + "*targetLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); + tr.fixedLevelsImage = R_CreateImage( + "*fixedLevels", (byte *)p, 1, 1, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); } for (x = 0; x < 2; x++) { - tr.textureScratchImage[x] = R_CreateImage(va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.textureScratchImage[x] = R_CreateImage( + va("*textureScratch%d", x), NULL, 256, 256, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } + for (x = 0; x < 2; x++) { - tr.quarterImage[x] = R_CreateImage(va("*quarter%d", x), NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.quarterImage[x] = R_CreateImage( + va("*quarter%d", x), NULL, width / 2, height / 2, + IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + GL_RGBA8); } if (r_ssao->integer) { - tr.screenSsaoImage = R_CreateImage("*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); - tr.hdrDepthImage = R_CreateImage("*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_R32F); + tr.screenSsaoImage = R_CreateImage( + "*screenSsao", NULL, width / 2, height / 2, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.hdrDepthImage = R_CreateImage( + "*hdrDepth", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_R32F); } if (r_shadows->integer == 4) { - for( x = 0; x < MAX_DRAWN_PSHADOWS; x++) + for (x = 0; x < MAX_DRAWN_PSHADOWS; x++) { - tr.pshadowMaps[x] = R_CreateImage(va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.pshadowMaps[x] = R_CreateImage( + va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, + PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } } if (r_sunlightMode->integer) { - for ( x = 0; x < 3; x++) + for (x = 0; x < 3; x++) { - tr.sunShadowDepthImage[x] = R_CreateImage(va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + tr.sunShadowDepthImage[x] = R_CreateImage( + va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, + r_shadowMapSize->integer, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + GL_DEPTH_COMPONENT24); } - tr.screenShadowImage = R_CreateImage("*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + tr.screenShadowImage = R_CreateImage( + "*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); } if (r_cubeMapping->integer) { - tr.renderCubeImage = R_CreateImage("*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, rgbFormat); - tr.prefilterEnvMapImage = R_CreateImage("*prefilterEnvMapFbo", NULL, CUBE_MAP_SIZE / 2, CUBE_MAP_SIZE / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat); + tr.renderCubeImage = R_CreateImage( + "*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE | + IMGFLAG_MIPMAP | + IMGFLAG_CUBEMAP, + rgbFormat); + + tr.prefilterEnvMapImage = R_CreateImage( + "*prefilterEnvMapFbo", NULL, CUBE_MAP_SIZE / 2, CUBE_MAP_SIZE / 2, + IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + rgbFormat); } } From 8a1b14941925fcad457c1dba267685b811872dde Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 29 Nov 2017 06:55:37 +0000 Subject: [PATCH 429/708] Use DrawItems for surface sprites --- codemp/rd-rend2/tr_backend.cpp | 34 +++++++++++---- codemp/rd-rend2/tr_bsp.cpp | 33 +++++++-------- codemp/rd-rend2/tr_local.h | 17 ++++++-- codemp/rd-rend2/tr_shade.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 76 +++++++++++++++++++++++----------- codemp/rd-rend2/tr_vbo.cpp | 17 ++++++-- 6 files changed, 122 insertions(+), 59 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 2aeb0701d1..38fced7506 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -395,6 +395,7 @@ void GL_VertexAttribPointers( void GL_DrawIndexed( GLenum primitiveType, int numIndices, + GLenum indexType, int offset, int numInstances, int baseVertex) @@ -403,7 +404,7 @@ void GL_DrawIndexed( qglDrawElementsInstancedBaseVertex( primitiveType, numIndices, - GL_INDEX_TYPE, + indexType, BUFFER_OFFSET(offset), numInstances, baseVertex); @@ -926,7 +927,24 @@ static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings } } -static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t *drawOrder ) +static void RB_BindAndUpdateUniformBlocks( + size_t numBindings, + const UniformBlockBinding *bindings) +{ + for (size_t i = 0; i < numBindings; ++i) + { + const UniformBlockBinding& binding = bindings[i]; + if (binding.data) + RB_BindAndUpdateUniformBlock(binding.block, binding.data); + else + RB_BindUniformBlock(binding.block); + } +} + +static void RB_DrawItems( + int numDrawItems, + const DrawItem *drawItems, + uint32_t *drawOrder) { for ( int i = 0; i < numDrawItems; ++i ) { @@ -936,15 +954,15 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t GL_State(drawItem.stateBits); GL_DepthRange(drawItem.depthRange.minDepth, drawItem.depthRange.maxDepth); if ( drawItem.ibo != nullptr ) - { R_BindIBO(drawItem.ibo); - } + GLSL_BindProgram(drawItem.program); - // FIXME: There was a reason I didn't have const on attributes. Can't remember at the moment - // what the reason was though. GL_VertexAttribPointers(drawItem.numAttributes, drawItem.attributes); RB_BindTextures(drawItem.numSamplerBindings, drawItem.samplerBindings); + RB_BindAndUpdateUniformBlocks( + drawItem.numUniformBlockBindings, + drawItem.uniformBlockBindings); GLSL_SetUniforms(drawItem.program, drawItem.uniformData); @@ -963,6 +981,7 @@ static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, uint32_t { GL_DrawIndexed(drawItem.draw.primitiveType, drawItem.draw.params.indexed.numIndices, + drawItem.draw.params.indexed.indexType, drawItem.draw.params.indexed.firstIndex, drawItem.draw.numInstances, 0); break; @@ -2076,9 +2095,6 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) // darken down any stencil shadows RB_ShadowFinish(); - - // add light flares on lights that aren't obscured - RB_RenderFlares(); } static void RB_GenerateMipmapsForCubemapFaceRender() diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 27e1c0770a..3e9b5930f7 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3416,16 +3416,10 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) return (hash ^ (hash >> 10) ^ (hash >> 20)); } -static void R_GenerateSurfaceSprites( - const srfBspSurface_t *bspSurf, - const shader_t *shader, - const shaderStage_t *stage, - srfSprites_t *out) +static std::vector R_CreateSurfaceSpritesVertexData( + const srfBspSurface_t *bspSurf, + float density) { - const surfaceSprite_t *surfaceSprite = stage->ss; - const textureBundle_t *bundle = &stage->bundle[0]; - - const float density = surfaceSprite->density; const srfVert_t *verts = bspSurf->verts; const glIndex_t *indexes = bspSurf->indexes; @@ -3495,14 +3489,25 @@ static void R_GenerateSurfaceSprites( } } } + return sprites; +} + +static void R_GenerateSurfaceSprites( + const srfBspSurface_t *bspSurf, + const shader_t *shader, + const shaderStage_t *stage, + srfSprites_t *out) +{ + const surfaceSprite_t *surfaceSprite = stage->ss; + const textureBundle_t *bundle = &stage->bundle[0]; uint32_t hash = 0; for ( int i = 0; bundle->image[i]; ++i ) - { hash = UpdateHash(bundle->image[i]->imgName, hash); - } uint16_t indices[] = { 0, 1, 2, 0, 2, 3 }; + std::vector sprites = + R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density); out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; @@ -3559,9 +3564,7 @@ static void R_GenerateSurfaceSprites( const world_t *world ) { const shader_t *shader = surf->shader; if ( !shader->numSurfaceSpriteStages ) - { continue; - } surf->numSurfaceSprites = shader->numSurfaceSpriteStages; surf->surfaceSprites = (srfSprites_t *)ri->Hunk_Alloc( @@ -3573,14 +3576,10 @@ static void R_GenerateSurfaceSprites( const world_t *world ) { const shaderStage_t *stage = shader->stages[j]; if ( !stage ) - { break; - } if ( !stage->ss || stage->ss->type == SURFSPRITE_NONE ) - { continue; - } srfSprites_t *sprite = surf->surfaceSprites + surfaceSpriteNum; R_GenerateSurfaceSprites(bspSurf, shader, stage, sprite); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b25f489304..fe43aed4ff 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2599,8 +2599,8 @@ void GL_DepthRange( float min, float max ); void GL_PolygonOffset( qboolean enabled ); void GL_VertexAttribPointers(size_t numAttributes, vertexAttribute_t *attributes); -void GL_DrawIndexed(GLenum primitiveType, int numIndices, int offset, - int numInstances, int baseVertex); +void GL_DrawIndexed(GLenum primitiveType, int numIndices, GLenum indexType, + int offset, int numInstances, int baseVertex); void GL_MultiDrawIndexed(GLenum primitiveType, int *numIndices, glIndex_t **offsets, int numDraws); void GL_Draw( GLenum primitiveType, int firstVertex, int numVertices, int numInstances ); @@ -2926,7 +2926,8 @@ void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); void RB_CommitInternalBufferData(); -void RB_UpdateUniformBlock(uniformBlock_t block, void *data); +void RB_BindUniformBlock(uniformBlock_t block); +void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data); void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); @@ -3436,6 +3437,12 @@ struct SamplerBinding uint8_t slot; }; +struct UniformBlockBinding +{ + void *data; + uniformBlock_t block; +}; + enum DrawCommandType { DRAW_COMMAND_MULTI_INDEXED, @@ -3460,6 +3467,7 @@ struct DrawCommand struct DrawIndexed { + GLenum indexType; GLsizei numIndices; glIndex_t firstIndex; } indexed; @@ -3487,6 +3495,9 @@ struct DrawItem uint32_t numSamplerBindings; SamplerBinding *samplerBindings; + uint32_t numUniformBlockBindings; + UniformBlockBinding *uniformBlockBindings; + UniformData *uniformData; DrawCommand draw; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index e6dd6ea215..ff88cdfa00 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -48,7 +48,7 @@ void R_DrawElementsVBO( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex int offset = firstIndex * sizeof(glIndex_t) + (tess.useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); - GL_DrawIndexed(GL_TRIANGLES, numIndexes, offset, 1, 0); + GL_DrawIndexed(GL_TRIANGLES, numIndexes, GL_INDEX_TYPE, offset, 1, 0); } @@ -825,6 +825,7 @@ void RB_FillDrawCommand( if ( input->multiDrawPrimitives == 1 ) { drawCmd.type = DRAW_COMMAND_INDEXED; + drawCmd.params.indexed.indexType = GL_INDEX_TYPE; drawCmd.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); drawCmd.params.indexed.numIndices = input->multiDrawNumIndexes[0]; } @@ -852,6 +853,7 @@ void RB_FillDrawCommand( (input->useInternalVBO ? backEndData->currentFrame->dynamicIboCommitOffset : 0); drawCmd.type = DRAW_COMMAND_INDEXED; + drawCmd.params.indexed.indexType = GL_INDEX_TYPE; drawCmd.params.indexed.firstIndex = offset; drawCmd.params.indexed.numIndices = input->numIndexes; } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 630d38310d..37536c2182 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2122,9 +2122,7 @@ static void RB_SurfaceSkip( void *surf ) { static void RB_SurfaceSprites( srfSprites_t *surf ) { if ( !r_surfaceSprites->integer ) - { return; - } RB_EndSurface(); @@ -2147,30 +2145,58 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) shaderProgram_t *program = programGroup + shaderFlags; assert(program->uniformBlocks & (1 << UNIFORM_BLOCK_SURFACESPRITE)); - SurfaceSpriteBlock data = {}; - data.width = ss->width; - data.height = (ss->facing == SURFSPRITE_FACING_DOWN) - ? -ss->height : ss->height; - data.fadeStartDistance = ss->fadeDist; - data.fadeEndDistance = ss->fadeMax; - data.fadeScale = ss->fadeScale; - data.widthVariance = ss->variance[0]; - data.heightVariance = ss->variance[1]; - - GLSL_BindProgram(program); - GL_State(firstStage->stateBits); - GL_Cull(CT_TWO_SIDED); - GL_VertexAttribPointers(surf->numAttributes, surf->attributes); - R_BindAnimatedImageToTMU(&firstStage->bundle[0], TB_DIFFUSEMAP); - RB_UpdateUniformBlock(UNIFORM_BLOCK_SURFACESPRITE, &data); - GLSL_SetUniformMatrix4x4(program, - UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - GLSL_SetUniformVec3(program, - UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - - R_BindIBO(surf->ibo); + SurfaceSpriteBlock *surfaceSpriteBlock = + ojkAlloc(*backEndData->perFrameMemory); + *surfaceSpriteBlock = {}; + surfaceSpriteBlock->width = ss->width; + surfaceSpriteBlock->height = + (ss->facing == SURFSPRITE_FACING_DOWN) ? -ss->height : ss->height; + surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; + surfaceSpriteBlock->fadeEndDistance = ss->fadeMax; + surfaceSpriteBlock->fadeScale = ss->fadeScale; + surfaceSpriteBlock->widthVariance = ss->variance[0]; + surfaceSpriteBlock->heightVariance = ss->variance[1]; + + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(program); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + + SamplerBindingsWriter samplerBindingsWriter; + samplerBindingsWriter.AddAnimatedImage(&firstStage->bundle[0], TB_COLORMAP); + + DrawItem item = {}; + item.stateBits = firstStage->stateBits; + item.cullType = CT_TWO_SIDED; + item.program = program; + item.depthRange = DepthRange{0.0f, 1.0f}; + item.ibo = surf->ibo; tess.externalIBO = surf->ibo; - qglDrawElementsInstanced(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0, surf->numSprites); + + item.numAttributes = surf->numAttributes; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, surf->numAttributes); + memcpy(item.attributes, surf->attributes, sizeof(*item.attributes)*surf->numAttributes); + + item.numUniformBlockBindings = 1; + item.uniformBlockBindings = ojkAllocArray(*backEndData->perFrameMemory, item.numUniformBlockBindings); + item.uniformBlockBindings[0].data = surfaceSpriteBlock; + item.uniformBlockBindings[0].block = UNIFORM_BLOCK_SURFACESPRITE; + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.primitiveType = GL_TRIANGLES; + item.draw.numInstances = surf->numSprites; + item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT; + item.draw.params.indexed.firstIndex = 0; + item.draw.params.indexed.numIndices = 6; + +uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); + uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); } void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index ac31435cfc..ebfbedbede 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -579,17 +579,26 @@ void RB_CommitInternalBufferData() currentFrame->dynamicVboCommitOffset = currentFrame->dynamicVboWriteOffset; } -void RB_UpdateUniformBlock(uniformBlock_t block, void *data) +void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data) { const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; gpuFrame_t *thisFrame = backEndData->currentFrame; + RB_BindUniformBlock(block); + qglBufferSubData(GL_UNIFORM_BUFFER, thisFrame->uboWriteOffset, blockInfo->size, data); - qglBindBufferRange(GL_UNIFORM_BUFFER, blockInfo->slot, - thisFrame->ubo, thisFrame->uboWriteOffset, blockInfo->size); // FIXME: Use actual ubo alignment - size_t alignedBlockSize = (blockInfo->size + 255) & ~255; + const size_t alignedBlockSize = (blockInfo->size + 255) & ~255; thisFrame->uboWriteOffset += alignedBlockSize; } + +void RB_BindUniformBlock(uniformBlock_t block) +{ + const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; + gpuFrame_t *thisFrame = backEndData->currentFrame; + + qglBindBufferRange(GL_UNIFORM_BUFFER, blockInfo->slot, + thisFrame->ubo, thisFrame->uboWriteOffset, blockInfo->size); +} From a04f3a32096fce9732b2bb9d96f5e01c14595d64 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Wed, 29 Nov 2017 21:43:40 +0000 Subject: [PATCH 430/708] Extend tess to support 1+MAXLIGHTMAPS texcoords --- codemp/rd-rend2/tr_glsl.cpp | 6 +- codemp/rd-rend2/tr_local.h | 4 +- codemp/rd-rend2/tr_model_iqm.cpp | 2 +- codemp/rd-rend2/tr_shade_calc.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 6 -- codemp/rd-rend2/tr_surface.cpp | 8 +- codemp/rd-rend2/tr_vbo.cpp | 152 +++++++++++++++++++++++++----- 7 files changed, 140 insertions(+), 40 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 91830aae23..d12d4e6c8b 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2255,8 +2255,10 @@ void GLSL_VertexAttribsState(uint32_t stateBits, VertexArraysProperties *vertexA } -void GL_VertexArraysToAttribs( vertexAttribute_t *attribs, - size_t attribsCount, const VertexArraysProperties *vertexArrays ) +void GL_VertexArraysToAttribs( + vertexAttribute_t *attribs, + size_t attribsCount, + const VertexArraysProperties *vertexArrays) { assert(attribsCount == ATTR_INDEX_MAX); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fe43aed4ff..fbb890edd1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2713,13 +2713,14 @@ typedef struct stageVars #define MAX_MULTIDRAW_PRIMITIVES 16384 +const int NUM_TESS_TEXCOORDS = 1 + MAXLIGHTMAPS; struct shaderCommands_s { glIndex_t indexes[SHADER_MAX_INDEXES] QALIGN(16); vec4_t xyz[SHADER_MAX_VERTEXES] QALIGN(16); uint32_t normal[SHADER_MAX_VERTEXES] QALIGN(16); uint32_t tangent[SHADER_MAX_VERTEXES] QALIGN(16); - vec2_t texCoords[SHADER_MAX_VERTEXES][2] QALIGN(16); + vec2_t texCoords[SHADER_MAX_VERTEXES][NUM_TESS_TEXCOORDS] QALIGN(16); vec4_t vertexColors[SHADER_MAX_VERTEXES] QALIGN(16); uint32_t lightdir[SHADER_MAX_VERTEXES] QALIGN(16); //int vertexDlightBits[SHADER_MAX_VERTEXES] QALIGN(16); @@ -2903,6 +2904,7 @@ struct VertexArraysProperties int offsets[ATTR_INDEX_MAX]; int sizes[ATTR_INDEX_MAX]; int strides[ATTR_INDEX_MAX]; + int streamStrides[ATTR_INDEX_MAX]; void *streams[ATTR_INDEX_MAX]; }; diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index a973946e7f..fd12d4b985 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -1026,7 +1026,7 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) { vec4_t *outXYZ; uint32_t *outNormal; uint32_t *outTangent; - vec2_t (*outTexCoord)[2]; + vec2_t (*outTexCoord)[NUM_TESS_TEXCOORDS]; vec4_t *outColor; int frame = data->num_frames ? backEnd.currentEntity->e.frame % data->num_frames : 0; diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 309fe7057d..14f43851f9 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -215,7 +215,7 @@ void RB_CalcBulgeVertexes( deformStage_t *ds ) { now = backEnd.refdef.time * ds->bulgeSpeed * 0.001f; - for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += 4, normal++ ) { + for ( i = 0; i < tess.numVertexes; i++, xyz += 4, st += NUM_TESS_TEXCOORDS*2, normal++ ) { int off; float scale; vec3_t fNormal; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 372c9bf743..f0be32e38c 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2781,12 +2781,6 @@ static void ComputeVertexAttribs(void) // dlights always need ATTR_NORMAL shader.vertexAttribs = ATTR_POSITION | ATTR_NORMAL; - // portals always need normals, for SurfIsOffscreen() - if (shader.isPortal) - { - shader.vertexAttribs |= ATTR_NORMAL; - } - if (shader.defaultShader) { shader.vertexAttribs |= ATTR_TEXCOORD0; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 37536c2182..714b097fe4 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -428,7 +428,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn { dv = verts; texCoords = tess.texCoords[ tess.numVertexes ][0]; - for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=4 ) + for ( i = 0 ; i < numVerts ; i++, dv++, texCoords+=NUM_TESS_TEXCOORDS*2 ) VectorCopy2(dv->st, texCoords); } @@ -436,7 +436,7 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn { dv = verts; lightCoords = tess.texCoords[ tess.numVertexes ][1]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=4 ) + for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=NUM_TESS_TEXCOORDS*2 ) VectorCopy2(dv->lightmap[0], lightCoords); } @@ -1882,13 +1882,13 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { VectorCopy2(dv->st, texCoords); - texCoords += 4; + texCoords += NUM_TESS_TEXCOORDS*2; } if ( tess.shader->vertexAttribs & ATTR_TEXCOORD1 ) { VectorCopy2(dv->lightmap[0], lightCoords); - lightCoords += 4; + lightCoords += NUM_TESS_TEXCOORDS*2; } if ( tess.shader->vertexAttribs & ATTR_COLOR ) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index ebfbedbede..df75434a22 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -395,7 +395,14 @@ void R_VBOList_f(void) ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", indexesSize / (1024.0f * 1024.0f)); } -void AddVertexArray(VertexArraysProperties *properties, int attributeIndex, size_t size, int stride, int offset, void *stream ) +void AddVertexArray( + VertexArraysProperties *properties, + int attributeIndex, + size_t size, + int stride, + int offset, + void *stream, + int streamStride) { properties->enabledAttributes[properties->numVertexArrays] = attributeIndex; properties->offsets[attributeIndex] = offset; @@ -403,6 +410,7 @@ void AddVertexArray(VertexArraysProperties *properties, int attributeIndex, size properties->sizes[attributeIndex] = size; properties->strides[attributeIndex] = stride; properties->streams[attributeIndex] = stream; + properties->streamStrides[attributeIndex] = streamStride; properties->numVertexArrays++; } @@ -412,45 +420,131 @@ void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties properties->vertexDataSize = 0; properties->numVertexArrays = 0; - if(attributes & ATTR_BITS) + if (!attributes) + { + attributes = + ATTR_POSITION | + ATTR_TEXCOORD0 | + ATTR_TEXCOORD1 | + ATTR_NORMAL | + ATTR_TANGENT | + ATTR_COLOR | + ATTR_LIGHTDIRECTION; + } + + if (attributes & ATTR_BITS) { if (attributes & ATTR_POSITION) - AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); + AddVertexArray( + properties, + ATTR_INDEX_POSITION, + sizeof(tess.xyz[0]), + 0, + properties->vertexDataSize, + tess.xyz, + sizeof(tess.xyz[0])); if (attributes & ATTR_TEXCOORD0) - AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][0]); + AddVertexArray( + properties, + ATTR_INDEX_TEXCOORD0, + sizeof(tess.texCoords[0][0]), + 0, + properties->vertexDataSize, + tess.texCoords[0][0], + sizeof(tess.texCoords[0][0]) * NUM_TESS_TEXCOORDS); if (attributes & ATTR_TEXCOORD1) - AddVertexArray(properties, ATTR_INDEX_TEXCOORD1, sizeof(tess.texCoords[0][1]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][1]); + AddVertexArray( + properties, + ATTR_INDEX_TEXCOORD1, + sizeof(tess.texCoords[0][1]), + 0, + properties->vertexDataSize, + tess.texCoords[0][1], + sizeof(tess.texCoords[0][0]) * NUM_TESS_TEXCOORDS); + + if (attributes & ATTR_TEXCOORD2) + AddVertexArray( + properties, + ATTR_INDEX_TEXCOORD2, + sizeof(tess.texCoords[0][2]) * 2, + 0, + properties->vertexDataSize, + tess.texCoords[0][2], + sizeof(tess.texCoords[0][0]) * NUM_TESS_TEXCOORDS); +; + + if (attributes & ATTR_TEXCOORD3) + AddVertexArray( + properties, + ATTR_INDEX_TEXCOORD3, + sizeof(tess.texCoords[0][3]) * 2, + 0, + properties->vertexDataSize, + tess.texCoords[0][3], + sizeof(tess.texCoords[0][0]) * NUM_TESS_TEXCOORDS); + + + if (attributes & ATTR_TEXCOORD4) + AddVertexArray( + properties, + ATTR_INDEX_TEXCOORD4, + sizeof(tess.texCoords[0][4]) * 2, + 0, + properties->vertexDataSize, + tess.texCoords[0][4], + sizeof(tess.texCoords[0][0]) * NUM_TESS_TEXCOORDS); if (attributes & ATTR_NORMAL) - AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); + AddVertexArray( + properties, + ATTR_INDEX_NORMAL, + sizeof(tess.normal[0]), + 0, + properties->vertexDataSize, + tess.normal, + sizeof(tess.normal[0])); if (attributes & ATTR_TANGENT) - AddVertexArray(properties, ATTR_INDEX_TANGENT, sizeof(tess.tangent[0]), 0, properties->vertexDataSize, tess.tangent); + AddVertexArray( + properties, + ATTR_INDEX_TANGENT, + sizeof(tess.tangent[0]), + 0, + properties->vertexDataSize, + tess.tangent, + sizeof(tess.tangent[0])); if (attributes & ATTR_COLOR) - AddVertexArray(properties, ATTR_INDEX_COLOR, sizeof(tess.vertexColors[0]), 0, properties->vertexDataSize, tess.vertexColors); + AddVertexArray( + properties, + ATTR_INDEX_COLOR, + sizeof(tess.vertexColors[0]), + 0, + properties->vertexDataSize, + tess.vertexColors, + sizeof(tess.vertexColors[0])); if (attributes & ATTR_LIGHTDIRECTION) - AddVertexArray(properties, ATTR_INDEX_LIGHTDIRECTION, sizeof(tess.lightdir[0]), 0, properties->vertexDataSize, tess.lightdir); - } - else - { - AddVertexArray(properties, ATTR_INDEX_POSITION, sizeof(tess.xyz[0]), 0, properties->vertexDataSize, tess.xyz); - AddVertexArray(properties, ATTR_INDEX_TEXCOORD0, sizeof(tess.texCoords[0][0]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][0]); - AddVertexArray(properties, ATTR_INDEX_TEXCOORD1, sizeof(tess.texCoords[0][1]) * 2, 0, properties->vertexDataSize, tess.texCoords[0][1]); - AddVertexArray(properties, ATTR_INDEX_NORMAL, sizeof(tess.normal[0]), 0, properties->vertexDataSize, tess.normal); - AddVertexArray(properties, ATTR_INDEX_TANGENT, sizeof(tess.tangent[0]), 0, properties->vertexDataSize, tess.tangent); - AddVertexArray(properties, ATTR_INDEX_COLOR, sizeof(tess.vertexColors[0]), 0, properties->vertexDataSize, tess.vertexColors); - AddVertexArray(properties, ATTR_INDEX_LIGHTDIRECTION, sizeof(tess.lightdir[0]), 0, properties->vertexDataSize, tess.lightdir); + AddVertexArray( + properties, + ATTR_INDEX_LIGHTDIRECTION, + sizeof(tess.lightdir[0]), + 0, + properties->vertexDataSize, + tess.lightdir, + sizeof(tess.lightdir[0])); } for ( int i = 0; i < properties->numVertexArrays; i++ ) properties->strides[properties->enabledAttributes[i]] = properties->vertexDataSize; } -void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties) +void CalculateVertexArraysFromVBO( + uint32_t attributes, + const VBO_t *vbo, + VertexArraysProperties *properties) { properties->vertexDataSize = 0; properties->numVertexArrays = 0; @@ -458,7 +552,14 @@ void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexA for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) { if ( attributes & j ) - AddVertexArray(properties, i, vbo->sizes[i], vbo->strides[i], vbo->offsets[i], NULL); + AddVertexArray( + properties, + i, + vbo->sizes[i], + vbo->strides[i], + vbo->offsets[i], + NULL, + 0); } } @@ -516,12 +617,13 @@ void RB_UpdateVBOs(unsigned int attribBits) { for ( int j = 0; j < vertexArrays.numVertexArrays; j++ ) { - int attributeIndex = vertexArrays.enabledAttributes[j]; + const int attributeIndex = vertexArrays.enabledAttributes[j]; + const size_t attribSize = vertexArrays.sizes[attributeIndex]; + const int streamStride = vertexArrays.streamStrides[attributeIndex]; void *stream = vertexArrays.streams[attributeIndex]; - size_t vertexSize = vertexArrays.sizes[attributeIndex]; - memcpy(writePtr, (byte *)stream + i * vertexSize, vertexArrays.sizes[attributeIndex]); - writePtr = (byte *)writePtr + vertexArrays.sizes[attributeIndex]; + memcpy(writePtr, (byte *)stream + i * streamStride, attribSize); + writePtr = (byte *)writePtr + attribSize; } } From 2a3ff4e4e5ad97e42924726b5a1aaa4aac966978 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sat, 2 Dec 2017 07:57:05 +0000 Subject: [PATCH 431/708] Enable/fill in extra texcoords properly --- codemp/rd-rend2/tr_surface.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 714b097fe4..d2273bc62b 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -432,12 +432,15 @@ static void RB_SurfaceVertsAndIndexes( int numVerts, srfVert_t *verts, int numIn VectorCopy2(dv->st, texCoords); } - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD1 ) + for (int tc = 0; tc < MAXLIGHTMAPS; ++tc) { - dv = verts; - lightCoords = tess.texCoords[ tess.numVertexes ][1]; - for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=NUM_TESS_TEXCOORDS*2 ) - VectorCopy2(dv->lightmap[0], lightCoords); + if ( tess.shader->vertexAttribs & (ATTR_TEXCOORD1 + tc) ) + { + dv = verts; + lightCoords = tess.texCoords[ tess.numVertexes ][1 + tc]; + for ( i = 0 ; i < numVerts ; i++, dv++, lightCoords+=NUM_TESS_TEXCOORDS*2 ) + VectorCopy2(dv->lightmap[tc], lightCoords); + } } if ( tess.shader->vertexAttribs & ATTR_COLOR ) @@ -582,11 +585,13 @@ RB_SurfaceBSPTriangles ============= */ static void RB_SurfaceBSPTriangles( srfBspSurface_t *srf ) { +#if 0 if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } +#endif RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, srf->indexes, srf->dlightBits, srf->pshadowBits); @@ -1713,11 +1718,13 @@ RB_SurfaceFace ============== */ static void RB_SurfaceBSPFace( srfBspSurface_t *srf ) { +#if 0 if( RB_SurfaceVbo(srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } +#endif RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, srf->indexes, srf->dlightBits, srf->pshadowBits); @@ -1764,7 +1771,7 @@ Just copy the grid of points and triangulate static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { int i, j; float *xyz; - float *texCoords, *lightCoords; + float *texCoords, *lightCoords[MAXLIGHTMAPS]; uint32_t *normal; uint32_t *tangent; float *color; @@ -1781,11 +1788,13 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { int pshadowBits; //int *vDlightBits; +#if 0 if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } +#endif dlightBits = srf->dlightBits; tess.dlightBits |= dlightBits; @@ -1854,7 +1863,8 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { normal = &tess.normal[numVertexes]; tangent = &tess.tangent[numVertexes]; texCoords = tess.texCoords[numVertexes][0]; - lightCoords = tess.texCoords[numVertexes][1]; + for (int tc = 0; tc < MAXLIGHTMAPS; ++tc) + lightCoords[tc] = tess.texCoords[numVertexes][1 + tc]; color = tess.vertexColors[numVertexes]; lightdir = &tess.lightdir[numVertexes]; //vDlightBits = &tess.vertexDlightBits[numVertexes]; @@ -1879,16 +1889,20 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { { *tangent++ = R_VboPackTangent(dv->tangent); } + if ( tess.shader->vertexAttribs & ATTR_TEXCOORD0 ) { VectorCopy2(dv->st, texCoords); texCoords += NUM_TESS_TEXCOORDS*2; } - if ( tess.shader->vertexAttribs & ATTR_TEXCOORD1 ) + for (int tc = 0; tc < MAXLIGHTMAPS; ++tc) { - VectorCopy2(dv->lightmap[0], lightCoords); - lightCoords += NUM_TESS_TEXCOORDS*2; + if ( tess.shader->vertexAttribs & (ATTR_TEXCOORD1 + tc) ) + { + VectorCopy2(dv->lightmap[tc], lightCoords[tc]); + lightCoords[tc] += NUM_TESS_TEXCOORDS*2; + } } if ( tess.shader->vertexAttribs & ATTR_COLOR ) From d317faa70144f883a0a73d1321fadb68af46bdb9 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 3 Dec 2017 08:41:38 +0000 Subject: [PATCH 432/708] Add entityNum back into sort key --- codemp/rd-rend2/tr_backend.cpp | 6 ++---- codemp/rd-rend2/tr_bsp.cpp | 6 ++++-- codemp/rd-rend2/tr_init.cpp | 4 ++-- codemp/rd-rend2/tr_local.h | 11 +++++++---- codemp/rd-rend2/tr_main.cpp | 16 +++++++--------- codemp/rd-rend2/tr_shader.cpp | 5 +++-- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 38fced7506..c3724cbf8a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1127,9 +1127,8 @@ static void RB_SubmitDrawSurfsForDepthFill( int postRender; int entityNum; - R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); + R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemapIndex, &postRender); assert(shader != nullptr); - entityNum = drawSurf->entityNum; if ( shader == oldShader && entityNum == oldEntityNum ) { @@ -1205,10 +1204,9 @@ static void RB_SubmitDrawSurfs( int fogNum; int dlighted; - R_DecomposeSort(drawSurf->sort, &shader, &cubemapIndex, &postRender); + R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemapIndex, &postRender); assert(shader != nullptr); fogNum = drawSurf->fogIndex; - entityNum = drawSurf->entityNum; dlighted = drawSurf->dlightBits; if ( shader == oldShader && diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3e9b5930f7..a717e311d0 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -583,7 +583,7 @@ This is called by the clipmodel subsystem so we can share the 1.8 megs of space in big maps... ================= */ -void RE_SetWorldVisData( const byte *vis ) { +void RE_SetWorldVisData( const byte *vis ) { tr.externalVisData = vis; } @@ -593,7 +593,7 @@ void RE_SetWorldVisData( const byte *vis ) { R_LoadVisibility ================= */ -static void R_LoadVisibility( world_t *worldData, lump_t *l ) { +static void R_LoadVisibility( world_t *worldData, lump_t *l ) { int len; byte *buf; @@ -3705,11 +3705,13 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } // create static VBOS from the world +#if 0 R_CreateWorldVBOs(worldData); if (r_mergeLeafSurfaces->integer) { R_MergeLeafSurfaces(worldData); } +#endif worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index a3d601fd31..d8f9c02600 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -29,8 +29,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; -static size_t FRAME_VERTEX_BUFFER_SIZE = 8*1024*1024; -static size_t FRAME_INDEX_BUFFER_SIZE = 2*1024*1024; +static size_t FRAME_VERTEX_BUFFER_SIZE = 12*1024*1024; +static size_t FRAME_INDEX_BUFFER_SIZE = 4*1024*1024; #if defined(_WIN32) extern "C" { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fbb890edd1..81722eb55d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1428,7 +1428,11 @@ compared quickly during the qsorting process #define QSORT_CUBEMAP_BITS 6 #define QSORT_CUBEMAP_MASK ((1 << QSORT_CUBEMAP_BITS) - 1) -#define QSORT_SHADERNUM_SHIFT (QSORT_CUBEMAP_SHIFT + QSORT_CUBEMAP_BITS) +#define QSORT_ENTITYNUM_SHIFT (QSORT_CUBEMAP_SHIFT + QSORT_CUBEMAP_BITS) +#define QSORT_ENTITYNUM_BITS REFENTITYNUM_BITS +#define QSORT_ENTITYNUM_MASK ((1 << QSORT_ENTITYNUM_BITS) - 1) + +#define QSORT_SHADERNUM_SHIFT (QSORT_ENTITYNUM_SHIFT + QSORT_ENTITYNUM_BITS) #define QSORT_SHADERNUM_BITS SHADERNUM_BITS #define QSORT_SHADERNUM_MASK ((1 << QSORT_SHADERNUM_BITS) - 1) @@ -1442,7 +1446,6 @@ compared quickly during the qsorting process typedef struct drawSurf_s { uint32_t sort; // bit combination for fast compares - int entityNum; uint32_t dlightBits; surfaceType_t *surface; // any of surface*_t int fogIndex; @@ -2554,8 +2557,8 @@ void R_AddLightningBoltSurfaces( trRefEntity_t *e ); void R_AddPolygonSurfaces( const trRefdef_t *refdef ); -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postRender ); -uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender); +void R_DecomposeSort( uint32_t sort, int *entityNum, shader_t **shader, int *cubemap, int *postRender ); +uint32_t R_CreateSortKey(int entityNum, int sortedShaderIndex, int cubemapIndex, int postRender); void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index b0cd3d3f66..60c68e1c5c 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1420,8 +1420,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 R_RotateForViewer(&tr.ori, &tr.viewParms); - R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &postRender ); - entityNum = drawSurf->entityNum; + R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemap, &postRender); fogNum = drawSurf->fogIndex; RB_BeginSurface( shader, fogNum, cubemap ); @@ -1745,20 +1744,22 @@ bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ) R_DecomposeSort ================= */ -void R_DecomposeSort( uint32_t sort, shader_t **shader, int *cubemap, int *postRender ) +void R_DecomposeSort( uint32_t sort, int *entityNum, shader_t **shader, int *cubemap, int *postRender ) { *shader = tr.sortedShaders[ ( sort >> QSORT_SHADERNUM_SHIFT ) & QSORT_SHADERNUM_MASK ]; *postRender = (sort >> QSORT_POSTRENDER_SHIFT ) & QSORT_POSTRENDER_MASK; + *entityNum = (sort >> QSORT_ENTITYNUM_SHIFT) & QSORT_ENTITYNUM_MASK; *cubemap = (sort >> QSORT_CUBEMAP_SHIFT ) & QSORT_CUBEMAP_MASK; } -uint32_t R_CreateSortKey(int sortedShaderIndex, int cubemapIndex, int postRender) +uint32_t R_CreateSortKey(int entityNum, int sortedShaderIndex, int cubemapIndex, int postRender) { uint32_t key = 0; key |= (sortedShaderIndex & QSORT_SHADERNUM_MASK) << QSORT_SHADERNUM_SHIFT; key |= (cubemapIndex & QSORT_CUBEMAP_MASK) << QSORT_CUBEMAP_SHIFT; key |= (postRender & QSORT_POSTRENDER_MASK) << QSORT_POSTRENDER_SHIFT; + key |= (entityNum & QSORT_ENTITYNUM_MASK) << QSORT_ENTITYNUM_SHIFT; return key; } @@ -1795,8 +1796,7 @@ void R_AddDrawSurf( index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; surf = tr.refdef.drawSurfs + index; - surf->sort = R_CreateSortKey(shader->sortedIndex, cubemap, postRender); - surf->entityNum = entityNum; + surf->sort = R_CreateSortKey(entityNum, shader->sortedIndex, cubemap, postRender); surf->dlightBits = dlightMap; surf->surface = surface; surf->fogIndex = fogIndex; @@ -1836,9 +1836,7 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { int postRender; int cubemap; - R_DecomposeSort( (drawSurfs+i)->sort, &shader, &cubemap, &postRender ); - entityNum = drawSurfs[i].entityNum; - + R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &cubemap, &postRender ); if ( shader->sort > SS_PORTAL ) { break; } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f0be32e38c..9c6307d611 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3436,14 +3436,15 @@ static void FixRenderCommandList( int newShader ) { int postRender; int sortedIndex; int cubemap; + int entityNum; const drawSurfsCommand_t *ds_cmd = (const drawSurfsCommand_t *)curCmd; for( i = 0, drawSurf = ds_cmd->drawSurfs; i < ds_cmd->numDrawSurfs; i++, drawSurf++ ) { - R_DecomposeSort( drawSurf->sort, &shader, &cubemap, &postRender ); + R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &cubemap, &postRender ); sortedIndex = (( drawSurf->sort >> QSORT_SHADERNUM_SHIFT ) & (MAX_SHADERS-1)); if( sortedIndex >= newShader ) { sortedIndex++; - drawSurf->sort = R_CreateSortKey(sortedIndex, cubemap, postRender); + drawSurf->sort = R_CreateSortKey(entityNum, sortedIndex, cubemap, postRender); } } curCmd = (const void *)(ds_cmd + 1); From bd52988ff2cf0317376095d9110483bc4abf57bf Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 3 Dec 2017 15:39:02 +0000 Subject: [PATCH 433/708] Remove leaf surface and multidraw merging --- codemp/rd-rend2/tr_bsp.cpp | 649 --------------------------------- codemp/rd-rend2/tr_init.cpp | 5 - codemp/rd-rend2/tr_local.h | 6 - codemp/rd-rend2/tr_surface.cpp | 75 ---- 4 files changed, 735 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index a717e311d0..e7c0b8a38d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1804,300 +1804,6 @@ void R_MovePatchSurfacesToHunk( world_t *worldData ) { } } - -/* -================= -BSPSurfaceCompare -compare function for qsort() -================= -*/ -static int BSPSurfaceCompare(const void *a, const void *b) -{ - msurface_t *aa, *bb; - - aa = *(msurface_t **) a; - bb = *(msurface_t **) b; - - // shader first - if(aa->shader->sortedIndex < bb->shader->sortedIndex) - return -1; - - else if(aa->shader->sortedIndex > bb->shader->sortedIndex) - return 1; - - // by fogIndex - if(aa->fogIndex < bb->fogIndex) - return -1; - - else if(aa->fogIndex > bb->fogIndex) - return 1; - - // by cubemapIndex - if(aa->cubemapIndex < bb->cubemapIndex) - return -1; - - else if(aa->cubemapIndex > bb->cubemapIndex) - return 1; - - - return 0; -} - -struct packedVertex_t -{ - vec3_t position; - uint32_t normal; - uint32_t tangent; - vec2_t texcoords[1 + MAXLIGHTMAPS]; - vec4_t colors[MAXLIGHTMAPS]; - uint32_t lightDirection; -}; - -/* -=============== -R_CreateWorldVBOs -=============== -*/ -static void R_CreateWorldVBOs( world_t *worldData ) -{ - int i, j, k; - - int numVerts; - packedVertex_t *verts; - - int numIndexes; - glIndex_t *indexes; - - int numSortedSurfaces, numSurfaces; - msurface_t *surface, **firstSurf, **lastSurf, **currSurf; - msurface_t **surfacesSorted; - - VBO_t *vbo; - IBO_t *ibo; - - int maxVboSize = 64 * 1024 * 1024; - int maxIboSize = 16 * 1024 * 1024; - - int startTime, endTime; - - startTime = ri->Milliseconds(); - - // count surfaces - numSortedSurfaces = 0; - for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) - { - srfBspSurface_t *bspSurf; - shader_t *shader = surface->shader; - - if (shader->isPortal) - continue; - - if (shader->isSky) - continue; - - if (ShaderRequiresCPUDeforms(shader)) - continue; - - // check for this now so we can use srfBspSurface_t* universally in the rest of the function - if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) - continue; - - bspSurf = (srfBspSurface_t *) surface->data; - - if (!bspSurf->numIndexes || !bspSurf->numVerts) - continue; - - numSortedSurfaces++; - } - - // presort surfaces - surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); - - j = 0; - for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) - { - srfBspSurface_t *bspSurf; - shader_t *shader = surface->shader; - - if (shader->isPortal) - continue; - - if (shader->isSky) - continue; - - if (ShaderRequiresCPUDeforms(shader)) - continue; - - // check for this now so we can use srfBspSurface_t* universally in the rest of the function - if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) - continue; - - bspSurf = (srfBspSurface_t *) surface->data; - - if (!bspSurf->numIndexes || !bspSurf->numVerts) - continue; - - surfacesSorted[j++] = surface; - } - - qsort(surfacesSorted, numSortedSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); - - k = 0; - for(firstSurf = lastSurf = surfacesSorted; firstSurf < &surfacesSorted[numSortedSurfaces]; firstSurf = lastSurf) - { - int currVboSize, currIboSize; - - // Find range of surfaces to merge by: - // - Collecting a number of surfaces which fit under maxVboSize/maxIboSize, or - // - All the surfaces with a single shader which go over maxVboSize/maxIboSize - currVboSize = currIboSize = 0; - while (currVboSize < maxVboSize && currIboSize < maxIboSize && lastSurf < &surfacesSorted[numSortedSurfaces]) - { - int addVboSize, addIboSize, currShaderIndex; - - addVboSize = addIboSize = 0; - currShaderIndex = (*lastSurf)->shader->sortedIndex; - - for(currSurf = lastSurf; currSurf < &surfacesSorted[numSortedSurfaces] && (*currSurf)->shader->sortedIndex == currShaderIndex; currSurf++) - { - srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - - addVboSize += bspSurf->numVerts * sizeof(srfVert_t); - addIboSize += bspSurf->numIndexes * sizeof(glIndex_t); - } - - if ((currVboSize != 0 && addVboSize + currVboSize > maxVboSize) - || (currIboSize != 0 && addIboSize + currIboSize > maxIboSize)) - break; - - lastSurf = currSurf; - - currVboSize += addVboSize; - currIboSize += addIboSize; - } - - // count verts/indexes/surfaces - numVerts = 0; - numIndexes = 0; - numSurfaces = 0; - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) - { - srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - - numVerts += bspSurf->numVerts; - numIndexes += bspSurf->numIndexes; - numSurfaces++; - } - - ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); - - // create arrays - verts = (packedVertex_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); - indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); - - // set up indices and copy vertices - numVerts = 0; - numIndexes = 0; - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) - { - srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - glIndex_t *surfIndex; - - bspSurf->firstIndex = numIndexes; - bspSurf->minIndex = numVerts + bspSurf->indexes[0]; - bspSurf->maxIndex = numVerts + bspSurf->indexes[0]; - - for(i = 0, surfIndex = bspSurf->indexes; i < bspSurf->numIndexes; i++, surfIndex++) - { - indexes[numIndexes++] = numVerts + *surfIndex; - bspSurf->minIndex = MIN(bspSurf->minIndex, numVerts + *surfIndex); - bspSurf->maxIndex = MAX(bspSurf->maxIndex, numVerts + *surfIndex); - } - - bspSurf->firstVert = numVerts; - - for(i = 0; i < bspSurf->numVerts; i++) - { - packedVertex_t& vert = verts[numVerts++]; - - VectorCopy (bspSurf->verts[i].xyz, vert.position); - vert.normal = R_VboPackNormal (bspSurf->verts[i].normal); - vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); - VectorCopy2 (bspSurf->verts[i].st, vert.texcoords[0]); - - for (int j = 0; j < MAXLIGHTMAPS; j++) - { - VectorCopy2 (bspSurf->verts[i].lightmap[j], vert.texcoords[1 + j]); - } - - for (int j = 0; j < MAXLIGHTMAPS; j++) - { - VectorCopy4 (bspSurf->verts[i].vertexColors[j], vert.colors[j]); - } - - vert.lightDirection = R_VboPackNormal (bspSurf->verts[i].lightdir); - } - } - - vbo = R_CreateVBO((byte *)verts, sizeof (packedVertex_t) * numVerts, VBO_USAGE_STATIC); - ibo = R_CreateIBO((byte *)indexes, numIndexes * sizeof (glIndex_t), VBO_USAGE_STATIC); - - // Setup the offsets and strides - vbo->offsets[ATTR_INDEX_POSITION] = offsetof(packedVertex_t, position); - vbo->offsets[ATTR_INDEX_NORMAL] = offsetof(packedVertex_t, normal); - vbo->offsets[ATTR_INDEX_TANGENT] = offsetof(packedVertex_t, tangent); - vbo->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(packedVertex_t, texcoords[0]); - vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[1]); - vbo->offsets[ATTR_INDEX_TEXCOORD2] = offsetof(packedVertex_t, texcoords[2]); - vbo->offsets[ATTR_INDEX_TEXCOORD3] = offsetof(packedVertex_t, texcoords[3]); - vbo->offsets[ATTR_INDEX_TEXCOORD4] = offsetof(packedVertex_t, texcoords[4]); - vbo->offsets[ATTR_INDEX_COLOR] = offsetof(packedVertex_t, colors); - vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offsetof(packedVertex_t, lightDirection); - - const size_t packedVertexSize = sizeof(packedVertex_t); - vbo->strides[ATTR_INDEX_POSITION] = packedVertexSize; - vbo->strides[ATTR_INDEX_NORMAL] = packedVertexSize; - vbo->strides[ATTR_INDEX_TANGENT] = packedVertexSize; - vbo->strides[ATTR_INDEX_TEXCOORD0] = packedVertexSize; - vbo->strides[ATTR_INDEX_TEXCOORD1] = packedVertexSize; - vbo->strides[ATTR_INDEX_TEXCOORD2] = packedVertexSize; - vbo->strides[ATTR_INDEX_TEXCOORD3] = packedVertexSize; - vbo->strides[ATTR_INDEX_TEXCOORD4] = packedVertexSize; - vbo->strides[ATTR_INDEX_COLOR] = packedVertexSize; - vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = packedVertexSize; - - vbo->sizes[ATTR_INDEX_POSITION] = sizeof(verts->position); - vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(verts->normal); - vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(verts->texcoords[0]); - vbo->sizes[ATTR_INDEX_TEXCOORD1] = sizeof(verts->texcoords[0]); - vbo->sizes[ATTR_INDEX_TEXCOORD2] = sizeof(verts->texcoords[0]); - vbo->sizes[ATTR_INDEX_TEXCOORD3] = sizeof(verts->texcoords[0]); - vbo->sizes[ATTR_INDEX_TEXCOORD4] = sizeof(verts->texcoords[0]); - vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(verts->tangent); - vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(verts->lightDirection); - vbo->sizes[ATTR_INDEX_COLOR] = sizeof(verts->colors); - - // point bsp surfaces to VBO - for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) - { - srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; - - bspSurf->vbo = vbo; - bspSurf->ibo = ibo; - } - - ri->Hunk_FreeTempMemory(indexes); - ri->Hunk_FreeTempMemory(verts); - - k++; - } - - Z_Free(surfacesSorted); - - endTime = ri->Milliseconds(); - ri->Printf(PRINT_ALL, "world VBOs calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); -} - /* =============== R_LoadSurfaces @@ -3020,352 +2726,6 @@ static void R_RenderAllCubemaps(void) } } - -/* -================= -R_MergeLeafSurfaces - -Merges surfaces that share a common leaf -================= -*/ -static void R_MergeLeafSurfaces(world_t *worldData) -{ - int i, j, k; - int numWorldSurfaces; - int mergedSurfIndex; - int numMergedSurfaces; - int numUnmergedSurfaces; - VBO_t *vbo; - IBO_t *ibo; - - msurface_t *mergedSurf; - - glIndex_t *iboIndexes, *outIboIndexes; - int numIboIndexes; - - int startTime, endTime; - - startTime = ri->Milliseconds(); - - numWorldSurfaces = worldData->numWorldSurfaces; - - // use viewcount to keep track of mergers - for (i = 0; i < numWorldSurfaces; i++) - { - worldData->surfacesViewCount[i] = -1; - } - - // mark matching surfaces - for (i = 0; i < worldData->numnodes - worldData->numDecisionNodes; i++) - { - mnode_t *leaf = worldData->nodes + worldData->numDecisionNodes + i; - - for (j = 0; j < leaf->nummarksurfaces; j++) - { - msurface_t *surf1; - shader_t *shader1; - int fogIndex1; - int cubemapIndex1; - int surfNum1; - - surfNum1 = *(worldData->marksurfaces + leaf->firstmarksurface + j); - - if (worldData->surfacesViewCount[surfNum1] != -1) - continue; - - surf1 = worldData->surfaces + surfNum1; - - if ((*surf1->data != SF_GRID) && - (*surf1->data != SF_TRIANGLES) && - (*surf1->data != SF_FACE)) - { - continue; - } - - shader1 = surf1->shader; - - if(shader1->isSky) - continue; - - if(shader1->isPortal) - continue; - - if(ShaderRequiresCPUDeforms(shader1)) - continue; - - fogIndex1 = surf1->fogIndex; - cubemapIndex1 = surf1->cubemapIndex; - - worldData->surfacesViewCount[surfNum1] = surfNum1; - - for (k = j + 1; k < leaf->nummarksurfaces; k++) - { - msurface_t *surf2; - shader_t *shader2; - int fogIndex2; - int cubemapIndex2; - int surfNum2; - - surfNum2 = *(worldData->marksurfaces + leaf->firstmarksurface + k); - - if (worldData->surfacesViewCount[surfNum2] != -1) - continue; - - surf2 = worldData->surfaces + surfNum2; - - if ((*surf2->data != SF_GRID) && - (*surf2->data != SF_TRIANGLES) && - (*surf2->data != SF_FACE)) - continue; - - shader2 = surf2->shader; - - if (shader1 != shader2) - continue; - - fogIndex2 = surf2->fogIndex; - - if (fogIndex1 != fogIndex2) - continue; - - cubemapIndex2 = surf2->cubemapIndex; - - if (cubemapIndex1 != cubemapIndex2) - continue; - - worldData->surfacesViewCount[surfNum2] = surfNum1; - } - } - } - - // don't add surfaces that don't merge to any others to the merged list - for (i = 0; i < numWorldSurfaces; i++) - { - qboolean merges = qfalse; - - if (worldData->surfacesViewCount[i] != i) - continue; - - for (j = 0; j < numWorldSurfaces; j++) - { - if (j == i) - continue; - - if (worldData->surfacesViewCount[j] == i) - { - merges = qtrue; - break; - } - } - - if (!merges) - worldData->surfacesViewCount[i] = -1; - } - - // count merged/unmerged surfaces - numMergedSurfaces = 0; - numUnmergedSurfaces = 0; - for (i = 0; i < numWorldSurfaces; i++) - { - if (worldData->surfacesViewCount[i] == i) - { - numMergedSurfaces++; - } - else if (worldData->surfacesViewCount[i] == -1) - { - numUnmergedSurfaces++; - } - } - - // Allocate merged surfaces - worldData->mergedSurfaces = - (msurface_t *)ri->Hunk_Alloc( - sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); - worldData->mergedSurfacesViewCount = - (int *)ri->Hunk_Alloc( - sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); - worldData->mergedSurfacesDlightBits = - (int *)ri->Hunk_Alloc( - sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); - worldData->mergedSurfacesPshadowBits = - (int *)ri->Hunk_Alloc( - sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); - worldData->numMergedSurfaces = numMergedSurfaces; - - // view surfaces are like mark surfaces, except negative ones represent merged surfaces - // -1 represents 0, -2 represents 1, and so on - worldData->viewSurfaces = - (int *)ri->Hunk_Alloc( - sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); - - // copy view surfaces into mark surfaces - for (i = 0; i < worldData->nummarksurfaces; i++) - { - worldData->viewSurfaces[i] = worldData->marksurfaces[i]; - } - - // need to be synched here - R_IssuePendingRenderCommands(); - - // actually merge surfaces - numIboIndexes = 0; - mergedSurfIndex = 0; - mergedSurf = worldData->mergedSurfaces; - for (i = 0; i < numWorldSurfaces; i++) - { - msurface_t *surf1; - - vec3_t bounds[2]; - - int numSurfsToMerge; - int numIndexes; - int numVerts; - int firstIndex; - - srfBspSurface_t *vboSurf; - - if (worldData->surfacesViewCount[i] != i) - continue; - - surf1 = worldData->surfaces + i; - - // retrieve vbo - vbo = ((srfBspSurface_t *)(surf1->data))->vbo; - - // count verts, indexes, and surfaces - numSurfsToMerge = 0; - numIndexes = 0; - numVerts = 0; - for (j = i; j < numWorldSurfaces; j++) - { - msurface_t *surf2; - srfBspSurface_t *bspSurf; - - if (worldData->surfacesViewCount[j] != i) - continue; - - surf2 = worldData->surfaces + j; - - bspSurf = (srfBspSurface_t *) surf2->data; - numIndexes += bspSurf->numIndexes; - numVerts += bspSurf->numVerts; - numSurfsToMerge++; - } - - if (numVerts == 0 || numIndexes == 0 || numSurfsToMerge < 2) - { - continue; - } - - // create ibo - ibo = tr.ibos[tr.numIBOs++] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); - memset(ibo, 0, sizeof(*ibo)); - numIboIndexes = 0; - - // allocate indexes - iboIndexes = outIboIndexes = (glIndex_t*)Z_Malloc(numIndexes * sizeof(*outIboIndexes), TAG_BSP); - - // Merge surfaces (indexes) and calculate bounds - ClearBounds(bounds[0], bounds[1]); - firstIndex = numIboIndexes; - for (j = i; j < numWorldSurfaces; j++) - { - msurface_t *surf2; - srfBspSurface_t *bspSurf; - - if (worldData->surfacesViewCount[j] != i) - continue; - - surf2 = worldData->surfaces + j; - - AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]); - AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]); - - bspSurf = (srfBspSurface_t *) surf2->data; - for (k = 0; k < bspSurf->numIndexes; k++) - { - *outIboIndexes++ = bspSurf->indexes[k] + bspSurf->firstVert; - numIboIndexes++; - } - break; - } - - vboSurf = (srfBspSurface_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); - memset(vboSurf, 0, sizeof(*vboSurf)); - vboSurf->surfaceType = SF_VBO_MESH; - - vboSurf->vbo = vbo; - vboSurf->ibo = ibo; - - vboSurf->numIndexes = numIndexes; - vboSurf->numVerts = numVerts; - vboSurf->firstIndex = firstIndex; - - vboSurf->minIndex = *(iboIndexes + firstIndex); - vboSurf->maxIndex = *(iboIndexes + firstIndex); - - for (j = 0; j < numIndexes; j++) - { - vboSurf->minIndex = MIN(vboSurf->minIndex, *(iboIndexes + firstIndex + j)); - vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j)); - } - - VectorCopy(bounds[0], vboSurf->cullBounds[0]); - VectorCopy(bounds[1], vboSurf->cullBounds[1]); - - VectorCopy(bounds[0], mergedSurf->cullinfo.bounds[0]); - VectorCopy(bounds[1], mergedSurf->cullinfo.bounds[1]); - - mergedSurf->cullinfo.type = CULLINFO_BOX; - mergedSurf->data = (surfaceType_t *)vboSurf; - mergedSurf->fogIndex = surf1->fogIndex; - mergedSurf->cubemapIndex = surf1->cubemapIndex; - mergedSurf->shader = surf1->shader; - - // finish up the ibo - qglGenBuffers(1, &ibo->indexesVBO); - - R_BindIBO(ibo); - qglBufferData(GL_ELEMENT_ARRAY_BUFFER, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW); - R_BindNullIBO(); - - GL_CheckErrors(); - - Z_Free(iboIndexes); - - // redirect view surfaces to this surf - for (j = 0; j < numWorldSurfaces; j++) - { - if (worldData->surfacesViewCount[j] != i) - continue; - - for (k = 0; k < worldData->nummarksurfaces; k++) - { - int *mark = worldData->marksurfaces + k; - int *view = worldData->viewSurfaces + k; - - if (*mark == j) - *view = -(mergedSurfIndex + 1); - } - } - - mergedSurfIndex++; - mergedSurf++; - } - - endTime = ri->Milliseconds(); - - ri->Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", - numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); - - // reset viewcounts - for (i = 0; i < numWorldSurfaces; i++) - { - worldData->surfacesViewCount[i] = -1; - } -} - - static void R_CalcVertexLightDirs( world_t *worldData ) { int i, k; @@ -3704,15 +3064,6 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } } - // create static VBOS from the world -#if 0 - R_CreateWorldVBOs(worldData); - if (r_mergeLeafSurfaces->integer) - { - R_MergeLeafSurfaces(worldData); - } -#endif - worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; // make sure the VBO glState entries are safe diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index d8f9c02600..7eb6ec4ae4 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -107,9 +107,6 @@ cvar_t *r_arb_seamless_cube_map; cvar_t *r_arb_vertex_type_2_10_10_10_rev; cvar_t *r_arb_buffer_storage; -cvar_t *r_mergeMultidraws; -cvar_t *r_mergeLeafSurfaces; - cvar_t *r_cameraExposure; cvar_t *r_externalGLSL; @@ -1542,8 +1539,6 @@ void R_Register( void ) r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT, "" ); r_anaglyphMode = ri->Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE, ""); - r_mergeMultidraws = ri->Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE, ""); - r_mergeLeafSurfaces = ri->Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE, ""); // // temporary variables that can change at any time diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 81722eb55d..274a604833 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -131,9 +131,6 @@ extern cvar_t *r_arb_half_float_pixel; extern cvar_t *r_ext_framebuffer_multisample; extern cvar_t *r_arb_seamless_cube_map; -extern cvar_t *r_mergeMultidraws; -extern cvar_t *r_mergeLeafSurfaces; - extern cvar_t *r_cameraExposure; extern cvar_t *r_hdr; @@ -2456,9 +2453,6 @@ extern cvar_t *r_skipBackEnd; extern cvar_t *r_anaglyphMode; -extern cvar_t *r_mergeMultidraws; -extern cvar_t *r_mergeLeafSurfaces; - extern cvar_t *r_externalGLSL; extern cvar_t *r_hdr; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index d2273bc62b..0da7063a1e 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -475,7 +475,6 @@ static qboolean RB_SurfaceVbo( VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck) { - int i, mergeForward, mergeBack; GLvoid *firstIndexOffset, *lastIndexOffset; if (!vbo || !ibo) @@ -496,83 +495,9 @@ static qboolean RB_SurfaceVbo( tess.dlightBits |= dlightBits; tess.pshadowBits |= pshadowBits; - // merge this into any existing multidraw primitives - mergeForward = -1; - mergeBack = -1; firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)); lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(glIndex_t)); - if (r_mergeMultidraws->integer) - { - i = 0; - - if (r_mergeMultidraws->integer == 1) - { - // lazy merge, only check the last primitive - if (tess.multiDrawPrimitives) - { - i = tess.multiDrawPrimitives - 1; - } - } - - for (; i < tess.multiDrawPrimitives; i++) - { - if (tess.multiDrawLastIndex[i] == firstIndexOffset) - { - mergeBack = i; - } - - if (lastIndexOffset == tess.multiDrawFirstIndex[i]) - { - mergeForward = i; - } - } - } - - if (mergeBack != -1 && mergeForward == -1) - { - tess.multiDrawNumIndexes[mergeBack] += numIndexes; - tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; - tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex); - tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex); - backEnd.pc.c_multidrawsMerged++; - } - else if (mergeBack == -1 && mergeForward != -1) - { - tess.multiDrawNumIndexes[mergeForward] += numIndexes; - tess.multiDrawFirstIndex[mergeForward] = (glIndex_t *)firstIndexOffset; - tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; - tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex); - tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex); - backEnd.pc.c_multidrawsMerged++; - } - else if (mergeBack != -1 && mergeForward != -1) - { - tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward]; - tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; - tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex)); - tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex)); - tess.multiDrawPrimitives--; - - if (mergeForward != tess.multiDrawPrimitives) - { - tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives]; - tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives]; - } - backEnd.pc.c_multidrawsMerged += 2; - } - else if (mergeBack == -1 && mergeForward == -1) - { - tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes; - tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = (glIndex_t *)firstIndexOffset; - tess.multiDrawLastIndex[tess.multiDrawPrimitives] = (glIndex_t *)lastIndexOffset; - tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex; - tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex; - tess.multiDrawPrimitives++; - } - - backEnd.pc.c_multidraws++; - tess.numIndexes += numIndexes; tess.numVertexes += numVerts; From 065df5a996f848b1b04dec4697c0c909f0457f40 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 3 Dec 2017 15:39:24 +0000 Subject: [PATCH 434/708] Fix lightmap merging (renamed as lightmap atlas...) Also enable it by default --- codemp/rd-rend2/tr_bsp.cpp | 147 +++++++++++++++++++++--------------- codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 4 +- 3 files changed, 91 insertions(+), 62 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e7c0b8a38d..c49b26f2f0 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -242,35 +242,26 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } } - image = (byte *)Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); // don't want to use TAG_BSP :< but it's the only one that fits + image = (byte *)Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); if (tr.worldDeluxeMapping) numLightmaps >>= 1; - if (r_mergeLightmaps->integer && numLightmaps >= 1024 ) - { - // FIXME: fat light maps don't support more than 1024 light maps - ri->Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n"); - numLightmaps = 1024; - } - - // use fat lightmaps of an appropriate size if (r_mergeLightmaps->integer) { - tr.fatLightmapSize = 512; - tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize; + const int targetLightmapsPerX = (int)ceilf(sqrtf(numLightmaps)); - // at most MAX_LIGHTMAP_PAGES - while (tr.fatLightmapStep * tr.fatLightmapStep * MAX_LIGHTMAP_PAGES < numLightmaps && tr.fatLightmapSize != glConfig.maxTextureSize ) - { - tr.fatLightmapSize <<= 1; - tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize; - } + int lightmapsPerX = 1; + while (lightmapsPerX < targetLightmapsPerX) + lightmapsPerX *= 2; + + tr.lightmapsPerAtlasSide[0] = lightmapsPerX; + tr.lightmapsPerAtlasSide[1] = (int)ceilf((float)numLightmaps / lightmapsPerX); - tr.numLightmaps = numLightmaps / (tr.fatLightmapStep * tr.fatLightmapStep); + tr.lightmapAtlasSize[0] = tr.lightmapsPerAtlasSide[0] * LIGHTMAP_WIDTH; + tr.lightmapAtlasSize[1] = tr.lightmapsPerAtlasSide[1] * LIGHTMAP_HEIGHT; - if (numLightmaps % (tr.fatLightmapStep * tr.fatLightmapStep) != 0) - tr.numLightmaps++; + tr.numLightmaps = 1; } else { @@ -293,11 +284,25 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { { for (i = 0; i < tr.numLightmaps; i++) { - tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat ); + tr.lightmaps[i] = R_CreateImage( + va("_lightmapatlas%d", i), + NULL, + tr.lightmapAtlasSize[0], + tr.lightmapAtlasSize[1], + IMGTYPE_COLORALPHA, + IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + textureInternalFormat); if (tr.worldDeluxeMapping) { - tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); + tr.deluxemaps[i] = R_CreateImage( + va("_fatdeluxemap%d", i), + NULL, + tr.lightmapAtlasSize[0], + tr.lightmapAtlasSize[1], + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + 0); } } } @@ -310,11 +315,9 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (r_mergeLightmaps->integer) { - int lightmaponpage = i % (tr.fatLightmapStep * tr.fatLightmapStep); - xoff = (lightmaponpage % tr.fatLightmapStep) * tr.lightmapSize; - yoff = (lightmaponpage / tr.fatLightmapStep) * tr.lightmapSize; - - lightmapnum /= (tr.fatLightmapStep * tr.fatLightmapStep); + xoff = (i % tr.lightmapsPerAtlasSide[0]) * tr.lightmapSize; + yoff = (i / tr.lightmapsPerAtlasSide[0]) * tr.lightmapSize; + lightmapnum = 0; } // if (tr.worldLightmapping) @@ -467,9 +470,24 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } if (r_mergeLightmaps->integer) - R_UpdateSubImage(tr.lightmaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize); + R_UpdateSubImage( + tr.lightmaps[lightmapnum], + image, + xoff, + yoff, + tr.lightmapSize, + tr.lightmapSize); else - tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat ); + tr.lightmaps[i] = R_CreateImage( + va("*lightmap%d", i), + image, + tr.lightmapSize, + tr.lightmapSize, + IMGTYPE_COLORALPHA, + IMGFLAG_NOLIGHTSCALE | + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, + textureInternalFormat ); if (hdrLightmap) ri->FS_FreeFile(hdrLightmap); @@ -497,11 +515,26 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (r_mergeLightmaps->integer) { - R_UpdateSubImage(tr.deluxemaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize ); + R_UpdateSubImage( + tr.deluxemaps[lightmapnum], + image, + xoff, + yoff, + tr.lightmapSize, + tr.lightmapSize); } else { - tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 ); + tr.deluxemaps[i] = R_CreateImage( + va("*deluxemap%d", i), + image, + tr.lightmapSize, + tr.lightmapSize, + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, + 0); } } } @@ -522,15 +555,12 @@ static float FatPackU(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - if(tr.fatLightmapSize > 0) + if (tr.lightmapAtlasSize[0] > 0) { - int x; - - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - - x = lightmapnum % tr.fatLightmapStep; + const int lightmapXOffset = lightmapnum % tr.lightmapsPerAtlasSide[0]; + const float invLightmapSide = 1.0f / tr.lightmapsPerAtlasSide[0]; - return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x); + return (lightmapXOffset * invLightmapSide) + (input * invLightmapSide); } return input; @@ -544,15 +574,12 @@ static float FatPackV(float input, int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - if(tr.fatLightmapSize > 0) + if (tr.lightmapAtlasSize[1] > 0) { - int y; - - lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep); - - y = lightmapnum / tr.fatLightmapStep; + const int lightmapYOffset = lightmapnum / tr.lightmapsPerAtlasSide[0]; + const float invLightmapSide = 1.0f / tr.lightmapsPerAtlasSide[1]; - return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y); + return (lightmapYOffset * invLightmapSide) + (input * invLightmapSide); } return input; @@ -567,10 +594,8 @@ static int FatLightmap(int lightmapnum) if (tr.worldDeluxeMapping) lightmapnum >>= 1; - if (tr.fatLightmapSize > 0) - { - return lightmapnum / (tr.fatLightmapStep * tr.fatLightmapStep); - } + if (tr.lightmapAtlasSize[0] > 0) + return 0; return lightmapnum; } @@ -732,8 +757,8 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - cv->verts[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), realLightmapNum[j]); - cv->verts[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), realLightmapNum[j]); + cv->verts[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); + cv->verts[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); if (hdrVertColors) { @@ -835,9 +860,7 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve int realLightmapNum[MAXLIGHTMAPS]; for ( j = 0; j < MAXLIGHTMAPS; j++ ) - { - realLightmapNum[j] = FatLightmap (LittleLong (ds->lightmapNum[j])); - } + realLightmapNum[j] = FatLightmap(LittleLong (ds->lightmapNum[j])); surf->numSurfaceSprites = 0; surf->surfaceSprites = nullptr; @@ -883,8 +906,8 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - points[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), realLightmapNum[j]); - points[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), realLightmapNum[j]); + points[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); + points[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); if (hdrVertColors) { @@ -941,6 +964,10 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * glIndex_t *tri; int i, j; int numVerts, numIndexes, badTriangles; + int realLightmapNum[MAXLIGHTMAPS]; + + for ( j = 0; j < MAXLIGHTMAPS; j++ ) + realLightmapNum[j] = FatLightmap(LittleLong (ds->lightmapNum[j])); surf->numSurfaceSprites = 0; surf->surfaceSprites = nullptr; @@ -949,7 +976,7 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * surf->fogIndex = LittleLong( ds->fogNum ) + 1; // get shader - surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); + surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); if ( r_singleShader->integer && !surf->shader->isSky ) { surf->shader = tr.defaultShader; } @@ -992,8 +1019,10 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - cv->verts[i].lightmap[j][0] = LittleFloat(verts[i].lightmap[j][0]); - cv->verts[i].lightmap[j][1] = LittleFloat(verts[i].lightmap[j][1]); + cv->verts[i].lightmap[j][0] = FatPackU( + LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); + cv->verts[i].lightmap[j][1] = FatPackV( + LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); if (hdrVertColors) { diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 7eb6ec4ae4..73f206413e 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1484,7 +1484,7 @@ void R_Register( void ) r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); - r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 274a604833..9b182cd1e3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2232,8 +2232,8 @@ typedef struct trGlobals_s { image_t **lightmaps; image_t **deluxemaps; - int fatLightmapSize; - int fatLightmapStep; + vec2i_t lightmapAtlasSize; + vec2i_t lightmapsPerAtlasSide; int numCubemaps; vec3_t *cubemapOrigins; From 7a85bb02ab30419322752a91d42d11b32ee4c727 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Sun, 3 Dec 2017 15:41:39 +0000 Subject: [PATCH 435/708] Always upload lightmaps as GL_RGBA8 For the time being, this makes sense as we don't have any HDR lightmaps. --- codemp/rd-rend2/tr_bsp.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c49b26f2f0..e91546d483 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -201,7 +201,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { dsurface_t *surf; int len; byte *image; - int i, j, numLightmaps, textureInternalFormat = 0; + int i, j, numLightmaps; float maxIntensity = 0; double sumIntensity = 0; @@ -275,11 +275,6 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } - if (glRefConfig.floatLightmap) - textureInternalFormat = GL_RGBA16F; - else - textureInternalFormat = GL_RGBA8; - if (r_mergeLightmaps->integer) { for (i = 0; i < tr.numLightmaps; i++) @@ -291,7 +286,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.lightmapAtlasSize[1], IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - textureInternalFormat); + GL_RGBA8); if (tr.worldDeluxeMapping) { @@ -487,7 +482,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - textureInternalFormat ); + GL_RGBA8); if (hdrLightmap) ri->FS_FreeFile(hdrLightmap); From d9b968f47d434749bdc2c33f44dc61d5790511f2 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Mon, 4 Dec 2017 09:49:07 +0000 Subject: [PATCH 436/708] Format some code --- codemp/rd-rend2/tr_bsp.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e91546d483..03996cc783 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -261,6 +261,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.lightmapAtlasSize[0] = tr.lightmapsPerAtlasSide[0] * LIGHTMAP_WIDTH; tr.lightmapAtlasSize[1] = tr.lightmapsPerAtlasSide[1] * LIGHTMAP_HEIGHT; + // FIXME: What happens if we need more? tr.numLightmaps = 1; } else @@ -752,8 +753,10 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver for ( j = 0; j < MAXLIGHTMAPS; j++ ) { - cv->verts[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); - cv->verts[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); + cv->verts[i].lightmap[j][0] = FatPackU( + LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); + cv->verts[i].lightmap[j][1] = FatPackV( + LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); if (hdrVertColors) { @@ -776,7 +779,6 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver color[1] = verts[i].color[j][1]; color[2] = verts[i].color[j][2]; } - } color[3] = verts[i].color[j][3] / 255.0f; From adfa8d17a4b099f0c29577591da9a95ab145ec14 Mon Sep 17 00:00:00 2001 From: Xycaleth Date: Tue, 26 Dec 2017 10:31:21 +0000 Subject: [PATCH 437/708] Rend2: Change ri-> to ri. --- codemp/rd-rend2/G2_API.cpp | 22 +- codemp/rd-rend2/G2_bones.cpp | 60 +-- codemp/rd-rend2/G2_misc.cpp | 4 +- codemp/rd-rend2/tr_animation.cpp | 2 +- codemp/rd-rend2/tr_backend.cpp | 42 +-- codemp/rd-rend2/tr_bsp.cpp | 200 +++++----- codemp/rd-rend2/tr_cache.cpp | 20 +- codemp/rd-rend2/tr_cmds.cpp | 50 +-- codemp/rd-rend2/tr_curve.cpp | 16 +- codemp/rd-rend2/tr_extensions.cpp | 30 +- codemp/rd-rend2/tr_extramath.cpp | 8 +- codemp/rd-rend2/tr_fbo.cpp | 60 +-- codemp/rd-rend2/tr_ghoul2.cpp | 38 +- codemp/rd-rend2/tr_glsl.cpp | 100 ++--- codemp/rd-rend2/tr_image.cpp | 64 ++-- codemp/rd-rend2/tr_init.cpp | 568 ++++++++++++++--------------- codemp/rd-rend2/tr_light.cpp | 2 +- codemp/rd-rend2/tr_main.cpp | 18 +- codemp/rd-rend2/tr_mesh.cpp | 6 +- codemp/rd-rend2/tr_model.cpp | 98 ++--- codemp/rd-rend2/tr_model_iqm.cpp | 14 +- codemp/rd-rend2/tr_postprocess.cpp | 2 +- codemp/rd-rend2/tr_scene.cpp | 14 +- codemp/rd-rend2/tr_shade.cpp | 14 +- codemp/rd-rend2/tr_shade_calc.cpp | 10 +- codemp/rd-rend2/tr_shader.cpp | 384 +++++++++---------- codemp/rd-rend2/tr_skin.cpp | 12 +- codemp/rd-rend2/tr_sky.cpp | 8 +- codemp/rd-rend2/tr_subs.cpp | 22 +- codemp/rd-rend2/tr_surface.cpp | 6 +- codemp/rd-rend2/tr_vbo.cpp | 46 +-- codemp/rd-rend2/tr_weather.cpp | 2 +- codemp/rd-rend2/tr_world.cpp | 16 +- 33 files changed, 979 insertions(+), 979 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index 34397ec321..a47a36301b 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -227,7 +227,7 @@ qboolean G2API_OverrideServerWithClientData(CGhoul2Info_v& ghoul2, int modelInde CGhoul2Info *serverInstance = &ghoul2[modelIndex]; CGhoul2Info *clientInstance; - if (ri->Cvar_VariableIntegerValue( "dedicated" )) + if (ri.Cvar_VariableIntegerValue( "dedicated" )) { //No client to get from! return qfalse; } @@ -644,7 +644,7 @@ void RestoreGhoul2InfoArray() TheGhoul2InfoArray(); size_t size; - const void *data = ri->PD_Load (PERSISTENT_G2DATA, &size); + const void *data = ri.PD_Load (PERSISTENT_G2DATA, &size); if ( data == NULL ) { return; @@ -665,7 +665,7 @@ void SaveGhoul2InfoArray() assert (written == size); - if ( !ri->PD_Store (PERSISTENT_G2DATA, data, size) ) + if ( !ri.PD_Store (PERSISTENT_G2DATA, data, size) ) { Com_Printf (S_COLOR_RED "ERROR: Failed to store persistent renderer data.\n"); } @@ -752,12 +752,12 @@ void G2API_CleanGhoul2Models(CGhoul2Info_v **ghoul2Ptr) qboolean G2_ShouldRegisterServer(void) { - vm_t *currentVM = ri->GetCurrentVM(); + vm_t *currentVM = ri.GetCurrentVM(); if ( currentVM && currentVM->slot == VM_GAME ) { - if ( ri->Cvar_VariableIntegerValue( "cl_running" ) && - ri->Com_TheHunkMarkHasBeenMade() && ShaderHashTableExists()) + if ( ri.Cvar_VariableIntegerValue( "cl_running" ) && + ri.Com_TheHunkMarkHasBeenMade() && ShaderHashTableExists()) { //if the hunk has been marked then we are now loading client assets so don't load on server. return qfalse; } @@ -2953,14 +2953,14 @@ void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore) int lod; ResetGoreTag(); - const int lodbias=Com_Clamp ( 0, 2,G2_DecideTraceLod(ghoul2[0], ri->Cvar_VariableIntegerValue( "r_lodbias" ))); + const int lodbias=Com_Clamp ( 0, 2,G2_DecideTraceLod(ghoul2[0], ri.Cvar_VariableIntegerValue( "r_lodbias" ))); const int maxLod =Com_Clamp (0,ghoul2[0].currentModel->numLods,3); //limit to the number of lods the main model has for(lod=lodbias;lodGetG2VertSpaceServer()->ResetHeap(); + ri.GetG2VertSpaceServer()->ResetHeap(); - G2_TransformModel(ghoul2, gore.currentTime, gore.scale,ri->GetG2VertSpaceServer(),lod,true); + G2_TransformModel(ghoul2, gore.currentTime, gore.scale,ri.GetG2VertSpaceServer(),lod,true); // now walk each model and compute new texture coordinates G2_TraceModels(ghoul2, transHitLocation, transRayDirection, 0, gore.entNum, 0,lod,0.0f,gore.SSize,gore.TSize,gore.theta,gore.shader,&gore,qtrue); @@ -2978,7 +2978,7 @@ qboolean G2_TestModelPointers(CGhoul2Info *ghlInfo) // returns true if the model ghlInfo->mValid=false; if (ghlInfo->mModelindex != -1) { - if (ri->Cvar_VariableIntegerValue( "dedicated" ) || + if (ri.Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); @@ -3071,7 +3071,7 @@ qboolean G2_SetupModelPointers(CGhoul2Info *ghlInfo) // returns true if the mode // RJ - experimental optimization! if (!ghlInfo->mModel || 1) { - if (ri->Cvar_VariableIntegerValue( "dedicated" ) || + if (ri.Cvar_VariableIntegerValue( "dedicated" ) || (G2_ShouldRegisterServer())) //supreme hackery! { ghlInfo->mModel = RE_RegisterServerModel(ghlInfo->mFileName); diff --git a/codemp/rd-rend2/G2_bones.cpp b/codemp/rd-rend2/G2_bones.cpp index a2805fe845..13169ee43a 100644 --- a/codemp/rd-rend2/G2_bones.cpp +++ b/codemp/rd-rend2/G2_bones.cpp @@ -2678,11 +2678,11 @@ int ragTraceCount = 0; void Rag_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const int passEntityNum, const int contentmask, const EG2_Collision eG2TraceType, const int useLod ) { #ifdef _DEBUG - int ragPreTrace = ri->Milliseconds(); + int ragPreTrace = ri.Milliseconds(); #endif - if ( ri->CGVMLoaded() ) + if ( ri.CGVMLoaded() ) { - ragCallbackTraceLine_t *callData = (ragCallbackTraceLine_t *)ri->GetSharedMemory(); + ragCallbackTraceLine_t *callData = (ragCallbackTraceLine_t *)ri.GetSharedMemory(); VectorCopy(start, callData->start); VectorCopy(end, callData->end); @@ -2691,7 +2691,7 @@ void Rag_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const v callData->ignore = passEntityNum; callData->mask = contentmask; - ri->CGVM_RagCallback( RAG_CALLBACK_TRACELINE ); + ri.CGVM_RagCallback( RAG_CALLBACK_TRACELINE ); *results = callData->tr; } @@ -2699,12 +2699,12 @@ void Rag_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const v { results->entityNum = ENTITYNUM_NONE; //SV_Trace(results, start, mins, maxs, end, passEntityNum, contentmask, eG2TraceType, useLod); - ri->CM_BoxTrace(results, start, end, mins, maxs, 0, contentmask, 0); + ri.CM_BoxTrace(results, start, end, mins, maxs, 0, contentmask, 0); results->entityNum = results->fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; } #ifdef _DEBUG - int ragPostTrace = ri->Milliseconds(); + int ragPostTrace = ri.Milliseconds(); ragTraceTime += (ragPostTrace - ragPreTrace); if (results->startsolid) @@ -2875,24 +2875,24 @@ static inline bool G2_ApplyRealBonePhysics(boneInfo_t &bone, SRagEffector &e, CR #ifdef _DEBUG_BONE_NAMES static inline void G2_RagDebugBox(vec3_t mins, vec3_t maxs, int duration) { - if ( !ri->CGVMLoaded() ) + if ( !ri.CGVMLoaded() ) return; - ragCallbackDebugBox_t *callData = (ragCallbackDebugBox_t *)ri->GetSharedMemory(); + ragCallbackDebugBox_t *callData = (ragCallbackDebugBox_t *)ri.GetSharedMemory(); callData->duration = duration; VectorCopy(mins, callData->mins); VectorCopy(maxs, callData->maxs); - ri->CGVM_RagCallback( RAG_CALLBACK_DEBUGBOX ); + ri.CGVM_RagCallback( RAG_CALLBACK_DEBUGBOX ); } static inline void G2_RagDebugLine(vec3_t start, vec3_t end, int time, int color, int radius) { - if ( !ri->CGVMLoaded() ) + if ( !ri.CGVMLoaded() ) return; - ragCallbackDebugLine_t *callData = (ragCallbackDebugLine_t *)ri->GetSharedMemory(); + ragCallbackDebugLine_t *callData = (ragCallbackDebugLine_t *)ri.GetSharedMemory(); VectorCopy(start, callData->start); VectorCopy(end, callData->end); @@ -2900,7 +2900,7 @@ static inline void G2_RagDebugLine(vec3_t start, vec3_t end, int time, int color callData->color = color; callData->radius = radius; - ri->CGVM_RagCallback( RAG_CALLBACK_DEBUGLINE ); + ri.CGVM_RagCallback( RAG_CALLBACK_DEBUGLINE ); } #endif @@ -3033,15 +3033,15 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve { //SRagDollEffectorCollision args(e.currentOrigin,tr); //params->EffectorCollision(args); - if ( ri->CGVMLoaded() ) + if ( ri.CGVMLoaded() ) { //make a callback and see if the cgame wants to help us out - ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri.GetSharedMemory(); VectorCopy(e.currentOrigin, callData->bonePos); callData->entNum = params->me; callData->solidCount = bone.solidCount; - ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); } } } @@ -3060,15 +3060,15 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve //SRagDollEffectorCollision args(e.currentOrigin,tr); //args.useTracePlane=true; //params->EffectorCollision(args); - if ( ri->CGVMLoaded() ) + if ( ri.CGVMLoaded() ) { //make a callback and see if the cgame wants to help us out - ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri.GetSharedMemory(); VectorCopy(e.currentOrigin, callData->bonePos); callData->entNum = params->me; callData->solidCount = bone.solidCount; - ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); } } } @@ -3153,15 +3153,15 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve //SRagDollEffectorCollision args(e.currentOrigin,tr); //args.useTracePlane=true; //params->EffectorCollision(args); - if ( ri->CGVMLoaded() ) + if ( ri.CGVMLoaded() ) { //make a callback and see if the cgame wants to help us out - ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri.GetSharedMemory(); VectorCopy(e.currentOrigin, callData->bonePos); callData->entNum = params->me; callData->solidCount = bone.solidCount; - ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); } } } @@ -3188,15 +3188,15 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve //SRagDollEffectorCollision args(e.currentOrigin,tr); //args.useTracePlane=true; //params->EffectorCollision(args); - if ( ri->CGVMLoaded() ) + if ( ri.CGVMLoaded() ) { //make a callback and see if the cgame wants to help us out - ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri.GetSharedMemory(); VectorCopy(e.currentOrigin, callData->bonePos); callData->entNum = params->me; callData->solidCount = bone.solidCount; - ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); } } } @@ -3795,7 +3795,7 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve { bone.solidCount++; #if 0 - if ( ri->CGVMLoaded() && bone.solidCount > 8 ) + if ( ri.CGVMLoaded() && bone.solidCount > 8 ) { //make a callback and see if the cgame wants to help us out Rag_Trace(&solidTr, params->position, testMins, testMaxs, e.currentOrigin, ignoreNum, RAG_MASK, G2_NOCOLLIDE, 0); @@ -3804,13 +3804,13 @@ static bool G2_RagDollSettlePositionNumeroTrois(CGhoul2Info_v &ghoul2V, const ve (solidTr.plane.normal[2] < 0.1f || solidTr.plane.normal[2] > -0.1f))// && //don't do anything against flat around // e.currentOrigin[2] > pelvisPos[2]) { - ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri->GetSharedMemory(); + ragCallbackBoneInSolid_t *callData = (ragCallbackBoneInSolid_t *)ri.GetSharedMemory(); VectorCopy(e.currentOrigin, callData->bonePos); callData->entNum = params->me; callData->solidCount = bone.solidCount; - ri->CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONEINSOLID ); } } #endif @@ -3920,17 +3920,17 @@ static float AngleNormZero(float theta) static inline void G2_BoneSnap(CGhoul2Info_v &ghoul2V, boneInfo_t &bone, CRagDollUpdateParams *params) { - if ( !ri->CGVMLoaded() || !params ) + if ( !ri.CGVMLoaded() || !params ) { return; } - ragCallbackBoneSnap_t *callData = (ragCallbackBoneSnap_t *)ri->GetSharedMemory(); + ragCallbackBoneSnap_t *callData = (ragCallbackBoneSnap_t *)ri.GetSharedMemory(); callData->entNum = params->me; strcpy(callData->boneName, G2_Get_Bone_Name(&ghoul2V[0], ghoul2V[0].mBlist, bone.boneNumber)); - ri->CGVM_RagCallback( RAG_CALLBACK_BONESNAP ); + ri.CGVM_RagCallback( RAG_CALLBACK_BONESNAP ); } static void G2_RagDollSolve(CGhoul2Info_v &ghoul2V,int g2Index,float decay,int frameNum,const vec3_t currentOrg,bool limitAngles,CRagDollUpdateParams *params) diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 8166c6b6c9..2d98e9ef88 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -542,7 +542,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, if ( cg_g2MarksAllModels == NULL ) { - cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); + cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); } if (cg_g2MarksAllModels == NULL @@ -1493,7 +1493,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli if ( cg_g2MarksAllModels == NULL ) { - cg_g2MarksAllModels = ri->Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); + cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); } if (cg_g2MarksAllModels == NULL diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index b551cb694f..029b54272d 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -215,7 +215,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { || (ent->e.oldframe >= header->numFrames) || (ent->e.oldframe < 0) ) { - ri->Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", + ri.Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; ent->e.oldframe = 0; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c3724cbf8a..b84db3fe95 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -45,7 +45,7 @@ void GL_Bind( image_t *image ) { int texnum; if ( !image ) { - ri->Printf( PRINT_WARNING, "GL_Bind: NULL image\n" ); + ri.Printf( PRINT_WARNING, "GL_Bind: NULL image\n" ); texnum = tr.defaultImage->texnum; } else { texnum = image->texnum; @@ -78,7 +78,7 @@ void GL_SelectTexture( int unit ) } if (!(unit >= 0 && unit <= 31)) - ri->Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); + ri.Error( ERR_DROP, "GL_SelectTexture: unit = %i", unit ); qglActiveTexture( GL_TEXTURE0 + unit ); @@ -226,7 +226,7 @@ void GL_State( uint32_t stateBits ) srcFactor = GL_SRC_ALPHA_SATURATE; break; default: - ri->Error( ERR_DROP, "GL_State: invalid src blend state bits" ); + ri.Error( ERR_DROP, "GL_State: invalid src blend state bits" ); break; } @@ -257,7 +257,7 @@ void GL_State( uint32_t stateBits ) dstFactor = GL_ONE_MINUS_DST_ALPHA; break; default: - ri->Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); + ri.Error( ERR_DROP, "GL_State: invalid dst blend state bits" ); break; } @@ -916,8 +916,8 @@ static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings { int oldtmu = glState.currenttmu; GL_SelectTexture(binding.slot); - ri->CIN_RunCinematic(binding.videoMapHandle - 1); - ri->CIN_UploadCinematic(binding.videoMapHandle - 1); + ri.CIN_RunCinematic(binding.videoMapHandle - 1); + ri.CIN_UploadCinematic(binding.videoMapHandle - 1); GL_SelectTexture(oldtmu); } else @@ -1420,7 +1420,7 @@ void RB_SetGL2D (void) { GL_Cull(CT_TWO_SIDED); // set time for 2D shaders - backEnd.refdef.time = ri->Milliseconds(); + backEnd.refdef.time = ri.Milliseconds(); backEnd.refdef.floatTime = backEnd.refdef.time * 0.001f; // reset color scaling @@ -1457,7 +1457,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * start = 0; if ( r_speeds->integer ) { - start = ri->Milliseconds(); + start = ri.Milliseconds(); } // make sure rows and cols are powers of 2 @@ -1466,14 +1466,14 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * for ( j = 0 ; ( 1 << j ) < rows ; j++ ) { } if ( ( 1 << i ) != cols || ( 1 << j ) != rows) { - ri->Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); + ri.Error (ERR_DROP, "Draw_StretchRaw: size not a power of 2: %i by %i", cols, rows); } RE_UploadCinematic (cols, rows, data, client, dirty); if ( r_speeds->integer ) { - end = ri->Milliseconds(); - ri->Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); + end = ri.Milliseconds(); + ri.Printf( PRINT_ALL, "qglTexSubImage2D %i, %i: %i msec\n", cols, rows, end - start ); } // FIXME: HUGE hack @@ -2250,7 +2250,7 @@ void RB_ShowImages( void ) { qglFinish(); - start = ri->Milliseconds(); + start = ri.Milliseconds(); image = tr.images; for ( i=0 ; i < tr.numImages; i++, image = image->poolNext ) { @@ -2281,8 +2281,8 @@ void RB_ShowImages( void ) { qglFinish(); - end = ri->Milliseconds(); - ri->Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); + end = ri.Milliseconds(); + ri.Printf( PRINT_ALL, "%i msec to draw all images\n", end - start ); } @@ -2381,7 +2381,7 @@ static const void *RB_SwapBuffers( const void *data ) { long sum = 0; unsigned char *stencilReadback; - stencilReadback = (unsigned char *)ri->Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); + stencilReadback = (unsigned char *)ri.Hunk_AllocateTempMemory( glConfig.vidWidth * glConfig.vidHeight ); qglReadPixels( 0, 0, glConfig.vidWidth, glConfig.vidHeight, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, stencilReadback ); for ( i = 0; i < glConfig.vidWidth * glConfig.vidHeight; i++ ) { @@ -2389,7 +2389,7 @@ static const void *RB_SwapBuffers( const void *data ) { } backEnd.pc.c_overDraw += sum; - ri->Hunk_FreeTempMemory( stencilReadback ); + ri.Hunk_FreeTempMemory( stencilReadback ); } if (!backEnd.framePostProcessed) @@ -2411,8 +2411,8 @@ static const void *RB_SwapBuffers( const void *data ) { tr.numFramesToCapture--; if ( !tr.numFramesToCapture ) { - ri->Printf( PRINT_ALL, "Frames captured\n" ); - ri->FS_FCloseFile(tr.debugFile); + ri.Printf( PRINT_ALL, "Frames captured\n" ); + ri.FS_FCloseFile(tr.debugFile); tr.debugFile = 0; } } @@ -2427,7 +2427,7 @@ static const void *RB_SwapBuffers( const void *data ) { GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); - ri->WIN_Present( &window ); + ri.WIN_Present( &window ); backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; @@ -2705,7 +2705,7 @@ RB_ExecuteRenderCommands void RB_ExecuteRenderCommands( const void *data ) { int t1, t2; - t1 = ri->Milliseconds (); + t1 = ri.Milliseconds (); while ( 1 ) { data = PADP(data, sizeof(void *)); @@ -2766,7 +2766,7 @@ void RB_ExecuteRenderCommands( const void *data ) { RB_EndSurface(); // stop rendering - t2 = ri->Milliseconds (); + t2 = ri.Milliseconds (); backEnd.pc.msec = t2 - t1; return; } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 03996cc783..eb053cd465 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -269,11 +269,11 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.numLightmaps = numLightmaps; } - tr.lightmaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.lightmaps = (image_t **)ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); if (tr.worldDeluxeMapping) { - tr.deluxemaps = (image_t **)ri->Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); + tr.deluxemaps = (image_t **)ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } if (r_mergeLightmaps->integer) @@ -326,15 +326,15 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (r_hdr->integer) { Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); - //ri->Printf(PRINT_ALL, "looking for %s\n", filename); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri->FS_ReadFile(filename, (void **)&hdrLightmap); + size = ri.FS_ReadFile(filename, (void **)&hdrLightmap); } if (hdrLightmap) { byte *p = hdrLightmap; - //ri->Printf(PRINT_ALL, "found!\n"); + //ri.Printf(PRINT_ALL, "found!\n"); /* FIXME: don't just skip over this header and actually parse it */ while (size && !(*p == '\n' && *(p+1) == '\n')) @@ -344,7 +344,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } if (!size) - ri->Error(ERR_DROP, "Bad header for %s!", filename); + ri.Error(ERR_DROP, "Bad header for %s!", filename); size -= 2; p += 2; @@ -362,10 +362,10 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { #if 0 // HDRFILE_RGBE if (size != tr.lightmapSize * tr.lightmapSize * 4) - ri->Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); + ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); #else // HDRFILE_FLOAT if (size != tr.lightmapSize * tr.lightmapSize * 12) - ri->Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); + ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); #endif } else @@ -486,7 +486,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { GL_RGBA8); if (hdrLightmap) - ri->FS_FreeFile(hdrLightmap); + ri.FS_FreeFile(hdrLightmap); } if (tr.worldDeluxeMapping) @@ -536,7 +536,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } if ( r_lightmap->integer == 2 ) { - ri->Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); + ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); } Z_Free(image); @@ -634,7 +634,7 @@ static void R_LoadVisibility( world_t *worldData, lump_t *l ) { } else { byte *dest; - dest = (byte *)ri->Hunk_Alloc( len - 8, h_low ); + dest = (byte *)ri.Hunk_Alloc( len - 8, h_low ); Com_Memcpy( dest, buf + 8, len - 8 ); worldData->vis = dest; } @@ -655,7 +655,7 @@ static shader_t *ShaderForShaderNum( const world_t *worldData, int shaderNum, co int _shaderNum = LittleLong( shaderNum ); if ( _shaderNum < 0 || _shaderNum >= worldData->numShaders ) { - ri->Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); + ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", _shaderNum ); } dsh = &worldData->shaders[ _shaderNum ]; @@ -713,22 +713,22 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver numVerts = LittleLong(ds->numVerts); if (numVerts > MAX_FACE_POINTS) { - ri->Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); + ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); numVerts = MAX_FACE_POINTS; surf->shader = tr.defaultShader; } numIndexes = LittleLong(ds->numIndexes); - //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); + //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); cv = (srfBspSurface_t *)surf->data; cv->surfaceType = SF_FACE; cv->numIndexes = numIndexes; - cv->indexes = (glIndex_t *)ri->Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); + cv->indexes = (glIndex_t *)ri.Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); cv->numVerts = numVerts; - cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = (srfVert_t *)ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); // copy vertexes surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; @@ -797,7 +797,7 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver if(tri[j] >= numVerts) { - ri->Error(ERR_DROP, "Bad index in face surface"); + ri.Error(ERR_DROP, "Bad index in face surface"); } } @@ -810,7 +810,7 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver if (badTriangles) { - ri->Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); + ri.Printf(PRINT_WARNING, "Face has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); cv->numIndexes -= badTriangles * 3; } @@ -882,7 +882,7 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve height = LittleLong( ds->patchHeight ); if(width < 0 || width > MAX_PATCH_SIZE || height < 0 || height > MAX_PATCH_SIZE) - ri->Error(ERR_DROP, "ParseMesh: bad size"); + ri.Error(ERR_DROP, "ParseMesh: bad size"); verts += LittleLong( ds->firstVert ); numPoints = width * height; @@ -981,15 +981,15 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * numVerts = LittleLong(ds->numVerts); numIndexes = LittleLong(ds->numIndexes); - //cv = ri->Hunk_Alloc(sizeof(*cv), h_low); + //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); cv = (srfBspSurface_t *)surf->data; cv->surfaceType = SF_TRIANGLES; cv->numIndexes = numIndexes; - cv->indexes = (glIndex_t *)ri->Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); + cv->indexes = (glIndex_t *)ri.Hunk_Alloc(numIndexes * sizeof(cv->indexes[0]), h_low); cv->numVerts = numVerts; - cv->verts = (srfVert_t *)ri->Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); + cv->verts = (srfVert_t *)ri.Hunk_Alloc(numVerts * sizeof(cv->verts[0]), h_low); surf->data = (surfaceType_t *) cv; @@ -1060,7 +1060,7 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * if(tri[j] >= numVerts) { - ri->Error(ERR_DROP, "Bad index in face surface"); + ri.Error(ERR_DROP, "Bad index in face surface"); } } @@ -1073,7 +1073,7 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * if (badTriangles) { - ri->Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); + ri.Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); cv->numIndexes -= badTriangles * 3; } @@ -1113,7 +1113,7 @@ static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *ve surf->shader = tr.defaultShader; } - //flare = ri->Hunk_Alloc( sizeof( *flare ), h_low ); + //flare = ri.Hunk_Alloc( sizeof( *flare ), h_low ); flare = (srfFlare_t *)surf->data; flare->surfaceType = SF_FLARE; @@ -1364,7 +1364,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1408,7 +1408,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1461,7 +1461,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1505,7 +1505,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1559,7 +1559,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1603,7 +1603,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1658,7 +1658,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert column into grid2 right after after column l if (m) row = grid2->height-1; else row = 0; @@ -1702,7 +1702,7 @@ int R_StitchPatches( world_t *worldData, int grid1num, int grid2num ) { fabs(v1[2] - v2[2]) < .01) continue; // - //ri->Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); + //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" ); // insert row into grid2 right after after row l if (m) column = grid2->width-1; else column = 0; @@ -1787,7 +1787,7 @@ void R_StitchAllPatches( world_t *worldData ) { } } while (stitched); - ri->Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); + ri.Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches ); } /* @@ -1807,21 +1807,21 @@ void R_MovePatchSurfacesToHunk( world_t *worldData ) { continue; // size = sizeof(*grid); - hunkgrid = (srfBspSurface_t *)ri->Hunk_Alloc(size, h_low); + hunkgrid = (srfBspSurface_t *)ri.Hunk_Alloc(size, h_low); Com_Memcpy(hunkgrid, grid, size); - hunkgrid->widthLodError = (float *)ri->Hunk_Alloc( grid->width * 4, h_low ); + hunkgrid->widthLodError = (float *)ri.Hunk_Alloc( grid->width * 4, h_low ); Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 ); - hunkgrid->heightLodError = (float *)ri->Hunk_Alloc( grid->height * 4, h_low ); + hunkgrid->heightLodError = (float *)ri.Hunk_Alloc( grid->height * 4, h_low ); Com_Memcpy( hunkgrid->heightLodError, grid->heightLodError, grid->height * 4 ); hunkgrid->numIndexes = grid->numIndexes; - hunkgrid->indexes = (glIndex_t *)ri->Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); + hunkgrid->indexes = (glIndex_t *)ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); Com_Memcpy(hunkgrid->indexes, grid->indexes, grid->numIndexes * sizeof(glIndex_t)); hunkgrid->numVerts = grid->numVerts; - hunkgrid->verts = (srfVert_t *)ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + hunkgrid->verts = (srfVert_t *)ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); Com_Memcpy(hunkgrid->verts, grid->verts, grid->numVerts * sizeof(srfVert_t)); R_FreeSurfaceGridMesh( grid ); @@ -1851,24 +1851,24 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu numFlares = 0; if (surfs->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = surfs->filelen / sizeof(*in); dv = (drawVert_t *)(fileBase + verts->fileofs); if (verts->filelen % sizeof(*dv)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); indexes = (int *)(fileBase + indexLump->fileofs); if ( indexLump->filelen % sizeof(*indexes)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); - out = (msurface_t *)ri->Hunk_Alloc ( count * sizeof(*out), h_low ); + out = (msurface_t *)ri.Hunk_Alloc ( count * sizeof(*out), h_low ); worldData->surfaces = out; worldData->numsurfaces = count; - worldData->surfacesViewCount = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesViewCount), h_low ); - worldData->surfacesDlightBits = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesDlightBits), h_low ); - worldData->surfacesPshadowBits = (int *)ri->Hunk_Alloc ( count * sizeof(*worldData->surfacesPshadowBits), h_low ); + worldData->surfacesViewCount = (int *)ri.Hunk_Alloc ( count * sizeof(*worldData->surfacesViewCount), h_low ); + worldData->surfacesDlightBits = (int *)ri.Hunk_Alloc ( count * sizeof(*worldData->surfacesDlightBits), h_low ); + worldData->surfacesPshadowBits = (int *)ri.Hunk_Alloc ( count * sizeof(*worldData->surfacesPshadowBits), h_low ); // load hdr vertex colors if (r_hdr->integer) @@ -1877,15 +1877,15 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu int size; Com_sprintf( filename, sizeof( filename ), "maps/%s/vertlight.raw", worldData->baseName); - //ri->Printf(PRINT_ALL, "looking for %s\n", filename); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri->FS_ReadFile(filename, (void **)&hdrVertColors); + size = ri.FS_ReadFile(filename, (void **)&hdrVertColors); if (hdrVertColors) { - //ri->Printf(PRINT_ALL, "Found!\n"); + //ri.Printf(PRINT_ALL, "Found!\n"); if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv))) - ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); } } @@ -1901,13 +1901,13 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu // FIXME: do this break; case MST_TRIANGLE_SOUP: - out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfBspSurface_t), h_low); + out->data = (surfaceType_t *)ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low); break; case MST_PLANAR: - out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfBspSurface_t), h_low); + out->data = (surfaceType_t *)ri.Hunk_Alloc( sizeof(srfBspSurface_t), h_low); break; case MST_FLARE: - out->data = (surfaceType_t *)ri->Hunk_Alloc( sizeof(srfFlare_t), h_low); + out->data = (surfaceType_t *)ri.Hunk_Alloc( sizeof(srfFlare_t), h_low); break; default: break; @@ -1947,13 +1947,13 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu numFlares++; break; default: - ri->Error( ERR_DROP, "Bad surfaceType" ); + ri.Error( ERR_DROP, "Bad surfaceType" ); } } if (hdrVertColors) { - ri->FS_FreeFile(hdrVertColors); + ri.FS_FreeFile(hdrVertColors); } #ifdef PATCH_STITCHING @@ -1966,7 +1966,7 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu R_MovePatchSurfacesToHunk(worldData); #endif - ri->Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", + ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n", numFaces, numMeshes, numTriSurfs, numFlares ); } @@ -1984,11 +1984,11 @@ static void R_LoadSubmodels( world_t *worldData, int worldIndex, lump_t *l ) { in = (dmodel_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); worldData->numBModels = count; - worldData->bmodels = out = (bmodel_t *)ri->Hunk_Alloc( count * sizeof(*out), h_low ); + worldData->bmodels = out = (bmodel_t *)ri.Hunk_Alloc( count * sizeof(*out), h_low ); for ( i=0 ; iError(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed"); + ri.Error(ERR_DROP, "R_LoadSubmodels: R_AllocModel() failed"); } model->type = MOD_BRUSH; @@ -2055,12 +2055,12 @@ static void R_LoadNodesAndLeafs (world_t *worldData, lump_t *nodeLump, lump_t *l in = (dnode_t *)(fileBase + nodeLump->fileofs); if (nodeLump->filelen % sizeof(dnode_t) || leafLump->filelen % sizeof(dleaf_t) ) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } numNodes = nodeLump->filelen / sizeof(dnode_t); numLeafs = leafLump->filelen / sizeof(dleaf_t); - out = (mnode_t *)ri->Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); + out = (mnode_t *)ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low); worldData->nodes = out; worldData->numnodes = numNodes + numLeafs; @@ -2128,9 +2128,9 @@ static void R_LoadShaders( world_t *worldData, lump_t *l ) { in = (dshader_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - out = (dshader_t *)ri->Hunk_Alloc ( count*sizeof(*out), h_low ); + out = (dshader_t *)ri.Hunk_Alloc ( count*sizeof(*out), h_low ); worldData->shaders = out; worldData->numShaders = count; @@ -2157,9 +2157,9 @@ static void R_LoadMarksurfaces (world_t *worldData, lump_t *l) in = (int *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - out = (int *)ri->Hunk_Alloc ( count*sizeof(*out), h_low); + out = (int *)ri.Hunk_Alloc ( count*sizeof(*out), h_low); worldData->marksurfaces = out; worldData->nummarksurfaces = count; @@ -2186,9 +2186,9 @@ static void R_LoadPlanes( world_t *worldData, lump_t *l ) { in = (dplane_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*in)) - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); count = l->filelen / sizeof(*in); - out = (cplane_t *)ri->Hunk_Alloc ( count*2*sizeof(*out), h_low); + out = (cplane_t *)ri.Hunk_Alloc ( count*2*sizeof(*out), h_low); worldData->planes = out; worldData->numplanes = count; @@ -2229,13 +2229,13 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump fogs = (dfog_t *)(fileBase + l->fileofs); if (l->filelen % sizeof(*fogs)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } count = l->filelen / sizeof(*fogs); // create fog strucutres for them worldData->numfogs = count + 1; - worldData->fogs = (fog_t *)ri->Hunk_Alloc ( worldData->numfogs*sizeof(*out), h_low); + worldData->fogs = (fog_t *)ri.Hunk_Alloc ( worldData->numfogs*sizeof(*out), h_low); worldData->globalFog = nullptr; out = worldData->fogs + 1; @@ -2245,13 +2245,13 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump brushes = (dbrush_t *)(fileBase + brushesLump->fileofs); if (brushesLump->filelen % sizeof(*brushes)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } brushesCount = brushesLump->filelen / sizeof(*brushes); sides = (dbrushside_t *)(fileBase + sidesLump->fileofs); if (sidesLump->filelen % sizeof(*sides)) { - ri->Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); + ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",worldData->name); } sidesCount = sidesLump->filelen / sizeof(*sides); @@ -2269,14 +2269,14 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump else { if ( (unsigned)out->originalBrushNumber >= brushesCount ) { - ri->Error( ERR_DROP, "fog brushNumber out of range" ); + ri.Error( ERR_DROP, "fog brushNumber out of range" ); } brush = brushes + out->originalBrushNumber; firstSide = LittleLong( brush->firstSide ); if ( (unsigned)firstSide > sidesCount - 6 ) { - ri->Error( ERR_DROP, "fog brush sideNumber out of range" ); + ri.Error( ERR_DROP, "fog brush sideNumber out of range" ); } // brushes are always sorted with the axial sides first @@ -2361,7 +2361,7 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { int numGridDataElements = l->filelen / sizeof(*worldData->lightGridData); - worldData->lightGridData = (mgrid_t *)ri->Hunk_Alloc( l->filelen, h_low ); + worldData->lightGridData = (mgrid_t *)ri.Hunk_Alloc( l->filelen, h_low ); Com_Memcpy( worldData->lightGridData, (void *)(fileBase + l->fileofs), l->filelen ); // deal with overbright bits @@ -2386,22 +2386,22 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { int size; Com_sprintf( filename, sizeof( filename ), "maps/%s/lightgrid.raw", worldData->baseName); - //ri->Printf(PRINT_ALL, "looking for %s\n", filename); + //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - size = ri->FS_ReadFile(filename, (void **)&hdrLightGrid); + size = ri.FS_ReadFile(filename, (void **)&hdrLightGrid); if (hdrLightGrid) { float lightScale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); - //ri->Printf(PRINT_ALL, "found!\n"); + //ri.Printf(PRINT_ALL, "found!\n"); if (size != sizeof(float) * 6 * numGridDataElements) { - ri->Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridDataElements); + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridDataElements); } - worldData->hdrLightGrid = (float *)ri->Hunk_Alloc(size, h_low); + worldData->hdrLightGrid = (float *)ri.Hunk_Alloc(size, h_low); for (i = 0; i < numGridDataElements ; i++) { @@ -2415,7 +2415,7 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { } if (hdrLightGrid) - ri->FS_FreeFile(hdrLightGrid); + ri.FS_FreeFile(hdrLightGrid); } } @@ -2462,7 +2462,7 @@ void R_LoadEntities( world_t *worldData, lump_t *l ) { p = (char *)(fileBase + l->fileofs); // store for reference by the cgame - w->entityString = (char *)ri->Hunk_Alloc( l->filelen + 1, h_low ); + w->entityString = (char *)ri.Hunk_Alloc( l->filelen + 1, h_low ); strcpy( w->entityString, p ); w->entityParsePoint = w->entityString; @@ -2494,7 +2494,7 @@ void R_LoadEntities( world_t *worldData, lump_t *l ) { if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { - ri->Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); + ri.Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value ); break; } *s++ = 0; @@ -2508,7 +2508,7 @@ void R_LoadEntities( world_t *worldData, lump_t *l ) { if (!Q_strncmp(keyname, s, strlen(s)) ) { s = strchr(value, ';'); if (!s) { - ri->Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); + ri.Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value ); break; } *s++ = 0; @@ -2577,7 +2577,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int return qfalse; } if ( com_token[0] != '{' ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: found %s when expecting {\n",com_token ); return qfalse; } @@ -2587,7 +2587,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int // parse key if ( !R_GetEntityToken( keyname, sizeof( keyname ) ) ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); return qfalse; } @@ -2597,17 +2597,17 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int // parse value if ( !R_GetEntityToken( com_token, sizeof( com_token ) ) ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: EOF without closing brace\n" ); return qfalse; } if ( com_token[0] == '}' ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: closing brace without data\n" ); return qfalse; } if ( *numSpawnVars == MAX_SPAWN_VARS ) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VARS\n" ); return qfalse; } @@ -2616,7 +2616,7 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int if (numSpawnVarChars + keyLength + tokenLength > maxSpawnVarChars) { - ri->Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); + ri.Printf( PRINT_ALL, "R_ParseSpawnVars: MAX_SPAWN_VAR_CHARS\n" ); return qfalse; } @@ -2658,8 +2658,8 @@ static void R_LoadCubemapEntities(const char *cubemapEntityName) return; tr.numCubemaps = numCubemaps; - tr.cubemapOrigins = (vec3_t *)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); - tr.cubemaps = (image_t **)ri->Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + tr.cubemapOrigins = (vec3_t *)ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); + tr.cubemaps = (image_t **)ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); numCubemaps = 0; while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) @@ -2911,7 +2911,7 @@ static void R_GenerateSurfaceSprites( out->shader->stages[0]->alphaTestType = stage->alphaTestType; out->numAttributes = 2; - out->attributes = (vertexAttribute_t *)ri->Hunk_Alloc( + out->attributes = (vertexAttribute_t *)ri.Hunk_Alloc( sizeof(vertexAttribute_t) * out->numAttributes, h_low); out->attributes[0].vbo = out->vbo; @@ -2953,7 +2953,7 @@ static void R_GenerateSurfaceSprites( const world_t *world ) continue; surf->numSurfaceSprites = shader->numSurfaceSpriteStages; - surf->surfaceSprites = (srfSprites_t *)ri->Hunk_Alloc( + surf->surfaceSprites = (srfSprites_t *)ri.Hunk_Alloc( sizeof(srfSprites_t) * surf->numSurfaceSprites, h_low); int surfaceSpriteNum = 0; @@ -3007,12 +3007,12 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } // load it - ri->FS_ReadFile(name, &buffer.v); + ri.FS_ReadFile(name, &buffer.v); if (!buffer.b) { if (bspIndex == nullptr) { - ri->Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); + ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name); } return nullptr; @@ -3023,14 +3023,14 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) Q_strncpyz(worldData->baseName, COM_SkipPath(worldData->name), sizeof(worldData->name)); COM_StripExtension(worldData->baseName, worldData->baseName, sizeof(worldData->baseName)); - const byte *startMarker = (const byte *)ri->Hunk_Alloc(0, h_low); + const byte *startMarker = (const byte *)ri.Hunk_Alloc(0, h_low); dheader_t *header = (dheader_t *)buffer.b; fileBase = (byte *)header; int bspVersion = LittleLong(header->version); if (bspVersion != BSP_VERSION) { - ri->Error( + ri.Error( ERR_DROP, "R_LoadBSP: %s has wrong version number (%i should be %i)", name, @@ -3090,13 +3090,13 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } } - worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; + worldData->dataSize = (const byte *)ri.Hunk_Alloc(0, h_low) - startMarker; // make sure the VBO glState entries are safe R_BindNullVBO(); R_BindNullIBO(); - ri->FS_FreeFile(buffer.v); + ri.FS_FreeFile(buffer.v); return worldData; } @@ -3111,7 +3111,7 @@ Called directly from cgame void RE_LoadWorldMap( const char *name ) { if (tr.worldMapLoaded) { - ri->Error(ERR_DROP, "ERROR: attempted to redundantly load world map"); + ri.Error(ERR_DROP, "ERROR: attempted to redundantly load world map"); } world_t *world = R_LoadBSP(name); diff --git a/codemp/rd-rend2/tr_cache.cpp b/codemp/rd-rend2/tr_cache.cpp index 3fe6b2b96c..4b546f90c9 100644 --- a/codemp/rd-rend2/tr_cache.cpp +++ b/codemp/rd-rend2/tr_cache.cpp @@ -89,13 +89,13 @@ qboolean CModelCacheManager::LoadFile( const char *pFileName, void **ppFileBuffe return qtrue; } - int len = ri->FS_ReadFile(path, ppFileBuffer); + int len = ri.FS_ReadFile(path, ppFileBuffer); if ( len == -1 || *ppFileBuffer == NULL ) { return qfalse; } - ri->Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); + ri.Printf( PRINT_DEVELOPER, "C_LoadFile(): Loaded %s from disk\n", pFileName ); return qtrue; } @@ -132,7 +132,7 @@ void* CModelCacheManager::Allocate( int iSize, void *pvDiskBuffer, const char *p pFile->iAllocSize = iSize; Q_strncpyz(pFile->path, sModelName, sizeof(pFile->path)); - if( ri->FS_FileIsInPAK( sModelName, &iChecksum ) ) + if( ri.FS_FileIsInPAK( sModelName, &iChecksum ) ) pFile->iPAKChecksum = iChecksum; /* Otherwise, it will be -1. */ *bAlreadyFound = qfalse; @@ -172,17 +172,17 @@ void CModelCacheManager::DeleteAll( void ) */ void CModelCacheManager::DumpNonPure( void ) { - ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure():\n"); + ri.Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure():\n"); for ( auto it = files.begin(); it != files.end(); /* empty */ ) { int iChecksum; - int iInPak = ri->FS_FileIsInPAK( it->path, &iChecksum ); + int iInPak = ri.FS_FileIsInPAK( it->path, &iChecksum ); if( iInPak == -1 || iChecksum != it->iPAKChecksum ) { /* Erase the file because it doesn't match the checksum */ - ri->Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->path ); + ri.Printf( PRINT_DEVELOPER, "Dumping none pure model \"%s\"", it->path ); if( it->pDiskImage ) Z_Free( it->pDiskImage ); @@ -195,7 +195,7 @@ void CModelCacheManager::DumpNonPure( void ) } } - ri->Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); + ri.Printf( PRINT_DEVELOPER, "CCacheManager::DumpNonPure(): Ok\n"); } CModelCacheManager::AssetCache::iterator CModelCacheManager::FindAsset( const char *path ) @@ -234,7 +234,7 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) { qboolean bAtLeastOneModelFreed = qfalse; - ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); + ri.Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd():\n"); for ( auto it = files.begin(); it != files.end(); /* empty */ ) { @@ -247,7 +247,7 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) if( bDeleteThis ) { - ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", it->path); + ri.Printf( PRINT_DEVELOPER, S_COLOR_GREEN "Dumping \"%s\"", it->path); if( it->pDiskImage ) { Z_Free( it->pDiskImage ); @@ -262,7 +262,7 @@ qboolean CModelCacheManager::LevelLoadEnd( qboolean deleteUnusedByLevel ) } } - ri->Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); + ri.Printf( PRINT_DEVELOPER, S_COLOR_GREEN "CModelCacheManager::LevelLoadEnd(): Ok\n"); return bAtLeastOneModelFreed; } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 240e925513..ec4d45a450 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -40,57 +40,57 @@ void R_PerformanceCounters( void ) { } if (r_speeds->integer == 1) { - ri->Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", + ri.Printf (PRINT_ALL, "%i/%i/%i shaders/batches/surfs %i leafs %i verts %i/%i tris %.2f mtex %.2f dc\n", backEnd.pc.c_shaders, backEnd.pc.c_surfBatches, backEnd.pc.c_surfaces, tr.pc.c_leafs, backEnd.pc.c_vertexes, backEnd.pc.c_indexes/3, backEnd.pc.c_totalIndexes/3, R_SumOfUsedImages()/(1000000.0f), backEnd.pc.c_overDraw / (float)(glConfig.vidWidth * glConfig.vidHeight) ); } else if (r_speeds->integer == 2) { - ri->Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + ri.Printf (PRINT_ALL, "(patch) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", tr.pc.c_sphere_cull_patch_in, tr.pc.c_sphere_cull_patch_clip, tr.pc.c_sphere_cull_patch_out, tr.pc.c_box_cull_patch_in, tr.pc.c_box_cull_patch_clip, tr.pc.c_box_cull_patch_out ); - ri->Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", + ri.Printf (PRINT_ALL, "(md3) %i sin %i sclip %i sout %i bin %i bclip %i bout\n", tr.pc.c_sphere_cull_md3_in, tr.pc.c_sphere_cull_md3_clip, tr.pc.c_sphere_cull_md3_out, tr.pc.c_box_cull_md3_in, tr.pc.c_box_cull_md3_clip, tr.pc.c_box_cull_md3_out ); } else if (r_speeds->integer == 3) { - ri->Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); + ri.Printf (PRINT_ALL, "viewcluster: %i\n", tr.viewCluster ); } else if (r_speeds->integer == 4) { if ( backEnd.pc.c_dlightVertexes ) { - ri->Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", + ri.Printf (PRINT_ALL, "dlight srf:%i culled:%i verts:%i tris:%i\n", tr.pc.c_dlightSurfaces, tr.pc.c_dlightSurfacesCulled, backEnd.pc.c_dlightVertexes, backEnd.pc.c_dlightIndexes / 3 ); } } else if (r_speeds->integer == 5 ) { - ri->Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); + ri.Printf( PRINT_ALL, "zFar: %.0f\n", tr.viewParms.zFar ); } else if (r_speeds->integer == 6 ) { - ri->Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", + ri.Printf( PRINT_ALL, "flare adds:%i tests:%i renders:%i\n", backEnd.pc.c_flareAdds, backEnd.pc.c_flareTests, backEnd.pc.c_flareRenders ); } else if (r_speeds->integer == 7 ) { - ri->Printf( PRINT_ALL, "VBO draws: static %i dynamic %i (%.2fKB)\nMultidraws: %i merged %i\n", + ri.Printf( PRINT_ALL, "VBO draws: static %i dynamic %i (%.2fKB)\nMultidraws: %i merged %i\n", backEnd.pc.c_staticVboDraws, backEnd.pc.c_dynamicVboDraws, backEnd.pc.c_dynamicVboTotalSize / (1024.0f), backEnd.pc.c_multidraws, backEnd.pc.c_multidrawsMerged ); - ri->Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", + ri.Printf( PRINT_ALL, "GLSL binds: %i draws: gen %i light %i fog %i dlight %i\n", backEnd.pc.c_glslShaderBinds, backEnd.pc.c_genericDraws, backEnd.pc.c_lightallDraws, backEnd.pc.c_fogDraws, backEnd.pc.c_dlightDraws); } else if (r_speeds->integer == 8) { - ri->Printf( PRINT_ALL, "0-19: %d 20-49: %d 50-99: %d 100-299: %d\n", + ri.Printf( PRINT_ALL, "0-19: %d 20-49: %d 50-99: %d 100-299: %d\n", backEnd.pc.c_triangleCountBins[TRI_BIN_0_19], backEnd.pc.c_triangleCountBins[TRI_BIN_20_49], backEnd.pc.c_triangleCountBins[TRI_BIN_50_99], backEnd.pc.c_triangleCountBins[TRI_BIN_100_299]); - ri->Printf( PRINT_ALL, "300-599: %d 600-999: %d 1000-1499: %d 1500-1999: %d\n", + ri.Printf( PRINT_ALL, "300-599: %d 600-999: %d 1000-1499: %d 1500-1999: %d\n", backEnd.pc.c_triangleCountBins[TRI_BIN_300_599], backEnd.pc.c_triangleCountBins[TRI_BIN_600_999], backEnd.pc.c_triangleCountBins[TRI_BIN_1000_1499], backEnd.pc.c_triangleCountBins[TRI_BIN_1500_1999]); - ri->Printf( PRINT_ALL, "2000-2999: %d 3000+: %d\n", + ri.Printf( PRINT_ALL, "2000-2999: %d 3000+: %d\n", backEnd.pc.c_triangleCountBins[TRI_BIN_2000_2999], backEnd.pc.c_triangleCountBins[TRI_BIN_3000_PLUS]); } @@ -114,15 +114,15 @@ void R_PerformanceCounters( void ) { diffInNs = endTime - startTime; diffInMs = diffInNs / 1e6f; - ri->Printf( PRINT_ALL, "%s: %.3fms ", timedBlock->name, diffInMs ); + ri.Printf( PRINT_ALL, "%s: %.3fms ", timedBlock->name, diffInMs ); if ( (i % 7) == 6 ) { - ri->Printf( PRINT_ALL, "\n" ); + ri.Printf( PRINT_ALL, "\n" ); } } - ri->Printf( PRINT_ALL, "\n" ); + ri.Printf( PRINT_ALL, "\n" ); } Com_Memset( &tr.pc, 0, sizeof( tr.pc ) ); @@ -190,7 +190,7 @@ void *R_GetCommandBuffer( int bytes ) { // always leave room for the end of list command if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) { if ( bytes > MAX_RENDER_COMMANDS - 4 ) { - ri->Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); + ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); } // if we run out of room, just start dropping commands return NULL; @@ -501,7 +501,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { GLenum result = qglClientWaitSync( sync, 0, 0 ); if ( result != GL_ALREADY_SIGNALED ) { - ri->Printf( PRINT_DEVELOPER, "OpenGL: GPU is more than %d frames behind! Waiting for this frame to finish...\n", MAX_FRAMES ); + ri.Printf( PRINT_DEVELOPER, "OpenGL: GPU is more than %d frames behind! Waiting for this frame to finish...\n", MAX_FRAMES ); static const GLuint64 HALF_SECOND = 500 * 1000 * 1000; do @@ -514,7 +514,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { thisFrame->sync = NULL; backEndData->perFrameMemory->Reset(); - ri->Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); + ri.Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); return; } } @@ -550,14 +550,14 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { { if ( glConfig.stencilBits < 4 ) { - ri->Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); - ri->Cvar_Set( "r_measureOverdraw", "0" ); + ri.Printf( PRINT_ALL, "Warning: not enough stencil bits to measure overdraw: %d\n", glConfig.stencilBits ); + ri.Cvar_Set( "r_measureOverdraw", "0" ); r_measureOverdraw->modified = qfalse; } else if ( r_shadows->integer == 2 ) { - ri->Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); - ri->Cvar_Set( "r_measureOverdraw", "0" ); + ri.Printf( PRINT_ALL, "Warning: stencil shadows and overdraw measurement are mutually exclusive\n" ); + ri.Cvar_Set( "r_measureOverdraw", "0" ); r_measureOverdraw->modified = qfalse; } else @@ -622,7 +622,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { } else if ( stereoFrame == STEREO_RIGHT ) { cmd->buffer = (int)GL_BACK_RIGHT; } else { - ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); } } else @@ -683,7 +683,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { return; } else - ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame ); R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer); colcmd->commandId = RC_COLORMASK; @@ -691,7 +691,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { else { if(stereoFrame != STEREO_CENTER) - ri->Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); + ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame ); if( !(cmd = (drawBufferCommand_t *)R_GetCommandBuffer(sizeof(*cmd))) ) return; diff --git a/codemp/rd-rend2/tr_curve.cpp b/codemp/rd-rend2/tr_curve.cpp index 9ce6ce0d39..bdb8494242 100644 --- a/codemp/rd-rend2/tr_curve.cpp +++ b/codemp/rd-rend2/tr_curve.cpp @@ -387,13 +387,13 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, size = (width * height - 1) * sizeof( srfVert_t ) + sizeof( *grid ); #ifdef PATCH_STITCHING - grid = /*ri->Hunk_Alloc*/ (srfBspSurface_t *)Z_Malloc( size, TAG_GRIDMESH ); + grid = /*ri.Hunk_Alloc*/ (srfBspSurface_t *)Z_Malloc( size, TAG_GRIDMESH ); Com_Memset(grid, 0, size); - grid->widthLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( width * 4, TAG_GRIDMESH ); + grid->widthLodError = /*ri.Hunk_Alloc*/ (float *)Z_Malloc( width * 4, TAG_GRIDMESH ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = /*ri->Hunk_Alloc*/ (float *)Z_Malloc( height * 4, TAG_GRIDMESH ); + grid->heightLodError = /*ri.Hunk_Alloc*/ (float *)Z_Malloc( height * 4, TAG_GRIDMESH ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numIndexes = numIndexes; @@ -403,21 +403,21 @@ srfBspSurface_t *R_CreateSurfaceGridMesh(int width, int height, grid->numVerts = (width * height); grid->verts = (srfVert_t *)Z_Malloc(grid->numVerts * sizeof(srfVert_t), TAG_GRIDMESH); #else - grid = ri->Hunk_Alloc( size ); + grid = ri.Hunk_Alloc( size ); Com_Memset(grid, 0, size); - grid->widthLodError = ri->Hunk_Alloc( width * 4 ); + grid->widthLodError = ri.Hunk_Alloc( width * 4 ); Com_Memcpy( grid->widthLodError, errorTable[0], width * 4 ); - grid->heightLodError = ri->Hunk_Alloc( height * 4 ); + grid->heightLodError = ri.Hunk_Alloc( height * 4 ); Com_Memcpy( grid->heightLodError, errorTable[1], height * 4 ); grid->numIndexes = numIndexes; - grid->indexes = (glIndex_t *)ri->Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); + grid->indexes = (glIndex_t *)ri.Hunk_Alloc(grid->numIndexes * sizeof(glIndex_t), h_low); Com_Memcpy(grid->indexes, indexes, numIndexes * sizeof(glIndex_t)); grid->numVerts = (width * height); - grid->verts = ri->Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); + grid->verts = ri.Hunk_Alloc(grid->numVerts * sizeof(srfVert_t), h_low); #endif grid->width = width; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index db0ca58977..ed4a78a532 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -#define GL_GetProcAddress ri->GL_GetProcAddress +#define GL_GetProcAddress ri.GL_GetProcAddress // Drawing commands PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; @@ -448,7 +448,7 @@ void GLimp_InitCoreFunctions() Q_strncpyz( version, (const char *) qglGetString (GL_SHADING_LANGUAGE_VERSION), sizeof( version ) ); sscanf(version, "%d.%d", &glRefConfig.glslMajorVersion, &glRefConfig.glslMinorVersion); - ri->Printf(PRINT_ALL, "...using GLSL version %s\n", version); + ri.Printf(PRINT_ALL, "...using GLSL version %s\n", version); } // Framebuffer and renderbuffers @@ -523,16 +523,16 @@ void GLimp_InitExtensions() { Com_Printf ("...ignoring GL_EXT_texture_filter_anisotropic\n" ); } - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + ri.Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) { - ri->Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); + ri.Cvar_SetValue( "r_ext_texture_filter_anisotropic_avail", glConfig.maxTextureFilterAnisotropy ); } } else { Com_Printf ("...GL_EXT_texture_filter_anisotropic not found\n" ); - ri->Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); + ri.Cvar_Set( "r_ext_texture_filter_anisotropic_avail", "0" ); } // Memory info @@ -555,11 +555,11 @@ void GLimp_InitExtensions() if (r_ext_compressed_textures->integer) glRefConfig.textureCompression |= TCR_LATC; - ri->Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension); + ri.Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension); } else { - ri->Printf(PRINT_ALL, result[2], extension); + ri.Printf(PRINT_ALL, result[2], extension); } // GL_ARB_texture_compression_bptc @@ -569,11 +569,11 @@ void GLimp_InitExtensions() if (r_ext_compressed_textures->integer >= 2) glRefConfig.textureCompression |= TCR_BPTC; - ri->Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension); + ri.Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension); } else { - ri->Printf(PRINT_ALL, result[2], extension); + ri.Printf(PRINT_ALL, result[2], extension); } // GL_ARB_texture_storage @@ -589,11 +589,11 @@ void GLimp_InitExtensions() glRefConfig.immutableTextures = loaded; - ri->Printf(PRINT_ALL, result[loaded], extension); + ri.Printf(PRINT_ALL, result[loaded], extension); } else { - ri->Printf(PRINT_ALL, result[2], extension); + ri.Printf(PRINT_ALL, result[2], extension); } // GL_ARB_buffer_storage @@ -613,11 +613,11 @@ void GLimp_InitExtensions() } glRefConfig.immutableBuffers = loaded; - ri->Printf(PRINT_ALL, result[loaded], extension); + ri.Printf(PRINT_ALL, result[loaded], extension); } else { - ri->Printf(PRINT_ALL, result[2], extension); + ri.Printf(PRINT_ALL, result[2], extension); } // GL_ARB_debug_output @@ -639,7 +639,7 @@ void GLimp_InitExtensions() } glRefConfig.debugContext = loaded; - ri->Printf(PRINT_ALL, result[loaded], extension); + ri.Printf(PRINT_ALL, result[loaded], extension); } // GL_ARB_timer_query @@ -654,7 +654,7 @@ void GLimp_InitExtensions() glRefConfig.timerQuery = loaded; - ri->Printf(PRINT_ALL, result[loaded], extension); + ri.Printf(PRINT_ALL, result[loaded], extension); } // use float lightmaps? diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 767c2901c9..ee5bdf9e33 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -91,10 +91,10 @@ qboolean Matrix16Compare( const matrix_t a, const matrix_t b ) void Matrix16Dump( const matrix_t in ) { - ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); - ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); - ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); - ri->Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 0], in[ 4], in[ 8], in[12]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 1], in[ 5], in[ 9], in[13]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 2], in[ 6], in[10], in[14]); + ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); } void Matrix16Translation( vec3_t vec, matrix_t out ) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 6909318906..6a8a65d44f 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -52,41 +52,41 @@ qboolean R_CheckFBO(const FBO_t * fbo) break; case GL_FRAMEBUFFER_UNSUPPORTED: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Unsupported framebuffer format\n", fbo->name); break; case GL_FRAMEBUFFER_UNDEFINED: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Default framebuffer was checked, but does not exist\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Default framebuffer was checked, but does not exist\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete attachment\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, no attachments attached\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, no attachments attached\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched multisampling values\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched multisampling values\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched layer targets\n", + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, mismatched layer targets\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing draw buffer\n", fbo->name); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) Framebuffer incomplete, missing read buffer\n", fbo->name); break; default: - ri->Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); - //ri->Error(ERR_FATAL, "R_CheckFBO: (%s) unknown error 0x%X", fbo->name, code); + ri.Printf(PRINT_WARNING, "R_CheckFBO: (%s) unknown error 0x%X\n", fbo->name, code); + //ri.Error(ERR_FATAL, "R_CheckFBO: (%s) unknown error 0x%X", fbo->name, code); //assert(0); break; } @@ -105,25 +105,25 @@ FBO_t *FBO_Create(const char *name, int width, int height) if(strlen(name) >= MAX_QPATH) { - ri->Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); + ri.Error(ERR_DROP, "FBO_Create: \"%s\" is too long", name); } if(width <= 0 || width > glRefConfig.maxRenderbufferSize) { - ri->Error(ERR_DROP, "FBO_Create: bad width %i", width); + ri.Error(ERR_DROP, "FBO_Create: bad width %i", width); } if(height <= 0 || height > glRefConfig.maxRenderbufferSize) { - ri->Error(ERR_DROP, "FBO_Create: bad height %i", height); + ri.Error(ERR_DROP, "FBO_Create: bad height %i", height); } if(tr.numFBOs == MAX_FBOS) { - ri->Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); + ri.Error(ERR_DROP, "FBO_Create: MAX_FBOS hit"); } - fbo = tr.fbos[tr.numFBOs] = (FBO_t *)ri->Hunk_Alloc(sizeof(*fbo), h_low); + fbo = tr.fbos[tr.numFBOs] = (FBO_t *)ri.Hunk_Alloc(sizeof(*fbo), h_low); Q_strncpyz(fbo->name, name, sizeof(fbo->name)); fbo->index = tr.numFBOs++; fbo->width = width; @@ -182,7 +182,7 @@ void FBO_CreateBuffer(FBO_t *fbo, int format, int index, int multisample) break; default: - ri->Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); + ri.Printf(PRINT_WARNING, "FBO_CreateBuffer: invalid format %d\n", format); return; } @@ -222,7 +222,7 @@ void R_AttachFBOTexture1D(int texId, int index) { if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri->Printf(PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index); + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture1D: invalid attachment index %i\n", index); return; } @@ -238,13 +238,13 @@ void R_AttachFBOTexture2D(int target, int texId, int index) { if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)) { - ri->Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); return; } if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri->Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); return; } @@ -260,7 +260,7 @@ void R_AttachFBOTexture3D(int texId, int index, int zOffset) { if(index < 0 || index >= glRefConfig.maxColorAttachments) { - ri->Printf(PRINT_WARNING, "R_AttachFBOTexture3D: invalid attachment index %i\n", index); + ri.Printf(PRINT_WARNING, "R_AttachFBOTexture3D: invalid attachment index %i\n", index); return; } @@ -292,7 +292,7 @@ void FBO_AttachTextureImage(image_t *img, int index) { if (!glState.currentFBO) { - ri->Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); + ri.Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); return; } @@ -305,7 +305,7 @@ static void FBO_SetupDrawBuffers() { if (!glState.currentFBO) { - ri->Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); + ri.Printf(PRINT_WARNING, "FBO: attempted to attach a texture image with no FBO bound!\n"); return; } @@ -374,7 +374,7 @@ void FBO_Init(void) int i; int hdrFormat, multisample; - ri->Printf(PRINT_ALL, "------- FBO_Init -------\n"); + ri.Printf(PRINT_ALL, "------- FBO_Init -------\n"); tr.numFBOs = 0; @@ -411,7 +411,7 @@ void FBO_Init(void) if (multisample != r_ext_framebuffer_multisample->integer) { - ri->Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); + ri.Cvar_SetValue("r_ext_framebuffer_multisample", (float)multisample); } // only create a render FBO if we need to resolve MSAA or do HDR @@ -658,7 +658,7 @@ void FBO_Shutdown(void) int i, j; FBO_t *fbo; - ri->Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); + ri.Printf(PRINT_ALL, "------- FBO_Shutdown -------\n"); FBO_Bind(NULL); @@ -693,17 +693,17 @@ void R_FBOList_f(void) int i; FBO_t *fbo; - ri->Printf(PRINT_ALL, " size name\n"); - ri->Printf(PRINT_ALL, "----------------------------------------------------------\n"); + ri.Printf(PRINT_ALL, " size name\n"); + ri.Printf(PRINT_ALL, "----------------------------------------------------------\n"); for(i = 0; i < tr.numFBOs; i++) { fbo = tr.fbos[i]; - ri->Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); + ri.Printf(PRINT_ALL, " %4i: %4i %4i %s\n", i, fbo->width, fbo->height, fbo->name); } - ri->Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); + ri.Printf(PRINT_ALL, " %i FBOs\n", tr.numFBOs); } void FBO_BlitFromTexture(struct image_s *src, vec4i_t inSrcBox, vec2_t inSrcTexScale, FBO_t *dst, vec4i_t inDstBox, struct shaderProgram_s *shaderProgram, vec4_t inColor, int blend) @@ -836,7 +836,7 @@ void FBO_Blit(FBO_t *src, vec4i_t inSrcBox, vec2_t srcTexScale, FBO_t *dst, vec4 if (!src) { - ri->Printf(PRINT_WARNING, "Tried to blit from a NULL FBO!\n"); + ri.Printf(PRINT_WARNING, "Tried to blit from a NULL FBO!\n"); return; } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 1cec7c8c2a..661cde953c 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -89,7 +89,7 @@ static CRenderableSurface *AllocGhoul2RenderableSurface() { if ( currentRenderSurfIndex >= MAX_RENDERABLE_SURFACES ) { - ri->Error( ERR_DROP, "AllocRenderableSurface: Reached maximum number of Ghoul2 renderable surfaces (%d)", MAX_RENDERABLE_SURFACES ); + ri.Error( ERR_DROP, "AllocRenderableSurface: Reached maximum number of Ghoul2 renderable surfaces (%d)", MAX_RENDERABLE_SURFACES ); return NULL; } @@ -1928,7 +1928,7 @@ static void G2_TransformGhoulBones( ghoul2.mBoneCache->mUnsquash=false; // master smoothing control - if (HackadelicOnClient && smooth && !ri->Cvar_VariableIntegerValue("dedicated")) + if (HackadelicOnClient && smooth && !ri.Cvar_VariableIntegerValue("dedicated")) { ghoul2.mBoneCache->mLastTouch = ghoul2.mBoneCache->mLastLastTouch; @@ -3869,7 +3869,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); - mod->data.glm = (mdxmData_t *)ri->Hunk_Alloc (sizeof (mdxmData_t), h_low); + mod->data.glm = (mdxmData_t *)ri.Hunk_Alloc (sizeof (mdxmData_t), h_low); mod->data.glm->header = mdxm; //RE_RegisterModels_Malloc(size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM); @@ -3880,7 +3880,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & { // horrible new hackery, if !bAlreadyFound then we've just done a // tag-morph, so we need to set the bool reference passed into this - // function to true, to tell the caller NOT to do an ri->FS_Freefile + // function to true, to tell the caller NOT to do an ri.FS_Freefile // since we've hijacked that memory block... // // Aaaargh. Kill me now... @@ -4026,7 +4026,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Make a copy on the GPU lod = (mdxmLOD_t *)((byte *)mdxm + mdxm->ofsLODs); - mod->data.glm->vboModels = (mdxmVBOModel_t *)ri->Hunk_Alloc (sizeof (mdxmVBOModel_t) * mdxm->numLODs, h_low); + mod->data.glm->vboModels = (mdxmVBOModel_t *)ri.Hunk_Alloc (sizeof (mdxmVBOModel_t) * mdxm->numLODs, h_low); for ( l = 0; l < mdxm->numLODs; l++ ) { mdxmVBOModel_t *vboModel = &mod->data.glm->vboModels[l]; @@ -4051,11 +4051,11 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vec3_t *bitangentsf; // +1 to add total vertex count - int *baseVertexes = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); - int *indexOffsets = (int *)ri->Hunk_AllocateTempMemory (sizeof (int) * mdxm->numSurfaces); + int *baseVertexes = (int *)ri.Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); + int *indexOffsets = (int *)ri.Hunk_AllocateTempMemory (sizeof (int) * mdxm->numSurfaces); vboModel->numVBOMeshes = mdxm->numSurfaces; - vboModel->vboMeshes = (mdxmVBOMesh_t *)ri->Hunk_Alloc (sizeof (mdxmVBOMesh_t) * mdxm->numSurfaces, h_low); + vboModel->vboMeshes = (mdxmVBOMesh_t *)ri.Hunk_Alloc (sizeof (mdxmVBOMesh_t) * mdxm->numSurfaces, h_low); vboMeshes = vboModel->vboMeshes; surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4074,8 +4074,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & baseVertexes[mdxm->numSurfaces] = numVerts; - tangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts); - bitangentsf = (vec3_t *)ri->Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts);; + tangentsf = (vec3_t *)ri.Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts); + bitangentsf = (vec3_t *)ri.Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts);; dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); @@ -4085,7 +4085,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & dataSize += numVerts * sizeof (*tangents); // Allocate and write to memory - data = (byte *)ri->Hunk_AllocateTempMemory (dataSize); + data = (byte *)ri.Hunk_AllocateTempMemory (dataSize); verts = (vec3_t *)(data + stride); ofsPosition = stride; @@ -4248,9 +4248,9 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & VBO_t *vbo = R_CreateVBO (data, dataSize, VBO_USAGE_STATIC); - ri->Hunk_FreeTempMemory (data); - ri->Hunk_FreeTempMemory (tangentsf); - ri->Hunk_FreeTempMemory (bitangentsf); + ri.Hunk_FreeTempMemory (data); + ri.Hunk_FreeTempMemory (tangentsf); + ri.Hunk_FreeTempMemory (bitangentsf); vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; @@ -4274,7 +4274,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); // Fill in the index buffer - glIndex_t *indices = (glIndex_t *)ri->Hunk_AllocateTempMemory (sizeof (glIndex_t) * numTriangles * 3); + glIndex_t *indices = (glIndex_t *)ri.Hunk_AllocateTempMemory (sizeof (glIndex_t) * numTriangles * 3); glIndex_t *index = indices; surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4302,7 +4302,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & IBO_t *ibo = R_CreateIBO ((byte *)indices, sizeof (glIndex_t) * numTriangles * 3, VBO_USAGE_STATIC); - ri->Hunk_FreeTempMemory (indices); + ri.Hunk_FreeTempMemory (indices); surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); @@ -4323,8 +4323,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vboModel->vbo = vbo; vboModel->ibo = ibo; - ri->Hunk_FreeTempMemory (indexOffsets); - ri->Hunk_FreeTempMemory (baseVertexes); + ri.Hunk_FreeTempMemory (indexOffsets); + ri.Hunk_FreeTempMemory (baseVertexes); lod = (mdxmLOD_t *)((byte *)lod + lod->ofsEnd); } @@ -4617,7 +4617,7 @@ qboolean R_LoadMDXA(model_t *mod, void *buffer, const char *mod_name, qboolean & // horrible new hackery, if !bAlreadyFound then we've just done a // tag-morph, so we need to set the bool reference passed into this // function to true, to tell the caller NOT to do an - // ri->FS_Freefile since we've hijacked that memory block... + // ri.FS_Freefile since we've hijacked that memory block... // // Aaaargh. Kill me now... // diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d12d4e6c8b..9510f0b43a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -166,11 +166,11 @@ static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) if (maxLength <= 0) { - ri->Printf(printLevel, "No compile log.\n"); + ri.Printf(printLevel, "No compile log.\n"); return; } - ri->Printf(printLevel, "compile log:\n"); + ri.Printf(printLevel, "compile log:\n"); if (maxLength < 1023) { @@ -178,7 +178,7 @@ static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) msgPart[maxLength + 1] = '\0'; - ri->Printf(printLevel, "%s\n", msgPart); + ri.Printf(printLevel, "%s\n", msgPart); } else { @@ -190,7 +190,7 @@ static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) { Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - ri->Printf(printLevel, "%s\n", msgPart); + ri.Printf(printLevel, "%s\n", msgPart); } Z_Free(msg); @@ -209,11 +209,11 @@ static void GLSL_PrintShaderInfoLog(GLuint object, qboolean developerOnly) if (maxLength <= 0) { - ri->Printf(printLevel, "No compile log.\n"); + ri.Printf(printLevel, "No compile log.\n"); return; } - ri->Printf(printLevel, "compile log:\n"); + ri.Printf(printLevel, "compile log:\n"); if (maxLength < 1023) { @@ -221,7 +221,7 @@ static void GLSL_PrintShaderInfoLog(GLuint object, qboolean developerOnly) msgPart[maxLength + 1] = '\0'; - ri->Printf(printLevel, "%s\n", msgPart); + ri.Printf(printLevel, "%s\n", msgPart); } else { @@ -233,7 +233,7 @@ static void GLSL_PrintShaderInfoLog(GLuint object, qboolean developerOnly) { Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - ri->Printf(printLevel, "%s\n", msgPart); + ri.Printf(printLevel, "%s\n", msgPart); } Z_Free(msg); @@ -258,7 +258,7 @@ static void GLSL_PrintShaderSource(GLuint shader) { char msgPart[1024]; Q_strncpyz(msgPart, msg + i, sizeof(msgPart)); - ri->Printf(PRINT_ALL, "%s\n", msgPart); + ri.Printf(PRINT_ALL, "%s\n", msgPart); } Z_Free(msg); @@ -425,7 +425,7 @@ static GLuint GLSL_CompileGPUShader( qglDeleteShader(shader); - ri->Error(ERR_FATAL, "Couldn't compile shader"); + ri.Error(ERR_FATAL, "Couldn't compile shader"); return 0; } @@ -472,7 +472,7 @@ static size_t GLSL_LoadGPUShaderSource( GLcharARB *buffer = nullptr; if ( r_externalGLSL->integer ) { - shaderTextLen = ri->FS_ReadFile(filename, (void **)&buffer); + shaderTextLen = ri.FS_ReadFile(filename, (void **)&buffer); } const char *shaderText = nullptr; @@ -480,20 +480,20 @@ static size_t GLSL_LoadGPUShaderSource( { if ( fallback ) { - ri->Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename); + ri.Printf(PRINT_DEVELOPER, "...loading built-in '%s'\n", filename); shaderText = fallback; shaderTextLen = strlen(shaderText); - ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); + ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); } else { - ri->Printf(PRINT_DEVELOPER, "couldn't load '%s'\n", filename); + ri.Printf(PRINT_DEVELOPER, "couldn't load '%s'\n", filename); return 0; } } else { - ri->Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); + ri.Printf(PRINT_DEVELOPER, "...loading '%s'\n", filename); shaderText = buffer; } @@ -506,7 +506,7 @@ static size_t GLSL_LoadGPUShaderSource( if ( buffer ) { - ri->FS_FreeFile(buffer); + ri.FS_FreeFile(buffer); } return result; @@ -521,8 +521,8 @@ static void GLSL_LinkProgram(GLuint program) if ( linked != GL_TRUE ) { GLSL_PrintProgramInfoLog(program, qfalse); - ri->Printf(PRINT_ALL, "\n"); - ri->Error(ERR_FATAL, "shaders failed to link"); + ri.Printf(PRINT_ALL, "\n"); + ri.Error(ERR_FATAL, "shaders failed to link"); } } @@ -545,7 +545,7 @@ static void GLSL_ShowProgramUniforms(GLuint program) { qglGetActiveUniform(program, i, sizeof(uniformName), NULL, &size, &type, uniformName); - ri->Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); + ri.Printf(PRINT_DEVELOPER, "active uniform: '%s'\n", uniformName); } qglUseProgram(0); @@ -702,7 +702,7 @@ bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const cha if ( sourceLen == 0 ) { - ri->Printf( + ri.Printf( PRINT_ALL, "ShaderProgramBuilder::AddShader: Failed to allocate enough memory for " "shader '%s'\n", @@ -718,7 +718,7 @@ bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const cha apiShader); if ( shader == 0 ) { - ri->Printf( + ri.Printf( PRINT_ALL, "ShaderProgramBuilder::AddShader: Unable to load \"%s\"\n", name); @@ -936,7 +936,7 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value) if (uniformsInfo[uniformNum].type != GLSL_INT) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformInt: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -960,7 +960,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu if (uniformsInfo[uniformNum].type != GLSL_FLOAT) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloat: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -984,7 +984,7 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t if (uniformsInfo[uniformNum].type != GLSL_VEC2) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -1009,7 +1009,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t if (uniformsInfo[uniformNum].type != GLSL_VEC3) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec3: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -1033,7 +1033,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t if (uniformsInfo[uniformNum].type != GLSL_VEC4) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec4: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -1057,13 +1057,13 @@ void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float if (uniformsInfo[uniformNum].type != GLSL_FLOAT) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } if (uniformsInfo[uniformNum].size < numFloats) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: uniform %i only has %d elements! Tried to set %d\n", + ri.Printf( PRINT_WARNING, "GLSL_SetUniformFloatN: uniform %i only has %d elements! Tried to set %d\n", uniformNum, uniformsInfo[uniformNum].size, numFloats ); @@ -1090,7 +1090,7 @@ void GLSL_SetUniformMatrix4x3(shaderProgram_t *program, int uniformNum, const fl if (uniformsInfo[uniformNum].type != GLSL_MAT4x3) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x3: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x3: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -1118,7 +1118,7 @@ void GLSL_SetUniformMatrix4x4(shaderProgram_t *program, int uniformNum, const fl if (uniformsInfo[uniformNum].type != GLSL_MAT4x4) { - ri->Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x4: wrong type for uniform %i in program %s\n", uniformNum, program->name); + ri.Printf( PRINT_WARNING, "GLSL_SetUniformMatrix4x4: wrong type for uniform %i in program %s\n", uniformNum, program->name); return; } @@ -1251,13 +1251,13 @@ static const GPUProgramDesc *LoadProgramSource( char programPath[MAX_QPATH]; Com_sprintf(programPath, sizeof(programPath), "glsl/%s.glsl", programName); - long size = ri->FS_ReadFile(programPath, (void **)&buffer); + long size = ri.FS_ReadFile(programPath, (void **)&buffer); if ( size ) { GPUProgramDesc *externalProgramDesc = ojkAlloc(allocator); *externalProgramDesc = ParseProgramSource(allocator, buffer); result = externalProgramDesc; - ri->FS_FreeFile(buffer); + ri.FS_FreeFile(buffer); } } @@ -1320,7 +1320,7 @@ static int GLSL_LoadGPUProgramGeneric( if (!GLSL_LoadGPUShader(builder, &tr.genericShader[i], "generic", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load generic shader!"); + ri.Error(ERR_FATAL, "Could not load generic shader!"); } GLSL_InitUniforms(&tr.genericShader[i]); @@ -1377,7 +1377,7 @@ static int GLSL_LoadGPUProgramFogPass( if (!GLSL_LoadGPUShader(builder, &tr.fogShader[i], "fogpass", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load fogpass shader!"); + ri.Error(ERR_FATAL, "Could not load fogpass shader!"); } GLSL_InitUniforms(&tr.fogShader[i]); @@ -1413,7 +1413,7 @@ static int GLSL_LoadGPUProgramDLight( if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load dlight shader!"); + ri.Error(ERR_FATAL, "Could not load dlight shader!"); } GLSL_InitUniforms(&tr.dlightShader[i]); @@ -1556,7 +1556,7 @@ static int GLSL_LoadGPUProgramLightAll( if (!GLSL_LoadGPUShader(builder, &tr.lightallShader[i], "lightall", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load lightall shader!"); + ri.Error(ERR_FATAL, "Could not load lightall shader!"); } GLSL_InitUniforms(&tr.lightallShader[i]); @@ -1595,7 +1595,7 @@ static int GLSL_LoadGPUProgramBasic( if (!GLSL_LoadGPUShader(builder, shaderProgram, programName, attribs, nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load %s shader!", programName); + ri.Error(ERR_FATAL, "Could not load %s shader!", programName); } return 1; @@ -1640,7 +1640,7 @@ static int GLSL_LoadGPUProgramDepthFill( if (!GLSL_LoadGPUShader(builder, &tr.shadowmapShader, "shadowfill", attribs, nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load shadowfill shader!"); + ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); } GLSL_InitUniforms(&tr.shadowmapShader); @@ -1666,7 +1666,7 @@ static int GLSL_LoadGPUProgramPShadow( if (!GLSL_LoadGPUShader(builder, &tr.pshadowShader, "pshadow", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load pshadow shader!"); + ri.Error(ERR_FATAL, "Could not load pshadow shader!"); } GLSL_InitUniforms(&tr.pshadowShader); @@ -1768,7 +1768,7 @@ static int GLSL_LoadGPUProgramCalcLuminanceLevel( if (!GLSL_LoadGPUShader(builder, &tr.calclevels4xShader[i], "calclevels4x", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load calclevels4x shader!"); + ri.Error(ERR_FATAL, "Could not load calclevels4x shader!"); } GLSL_InitUniforms(&tr.calclevels4xShader[i]); @@ -1815,7 +1815,7 @@ static int GLSL_LoadGPUProgramShadowMask( if (!GLSL_LoadGPUShader(builder, &tr.shadowmaskShader, "shadowmask", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load shadowmask shader!"); + ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); } GLSL_InitUniforms(&tr.shadowmaskShader); @@ -1900,7 +1900,7 @@ static int GLSL_LoadGPUProgramDepthBlur( if (!GLSL_LoadGPUShader(builder, &tr.depthBlurShader[i], "depthBlur", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load depthBlur shader!"); + ri.Error(ERR_FATAL, "Could not load depthBlur shader!"); } GLSL_InitUniforms(&tr.depthBlurShader[i]); @@ -1935,13 +1935,13 @@ static int GLSL_LoadGPUProgramGaussianBlur( if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[0], "gaussian_blur", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); + ri.Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[1], "gaussian_blur", attribs, nullptr, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); + ri.Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } int numPrograms = 0; @@ -2022,7 +2022,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, extradefines, *programDesc)) { - ri->Error(ERR_FATAL, "Could not load surface sprites shader!"); + ri.Error(ERR_FATAL, "Could not load surface sprites shader!"); } GLSL_InitUniforms(program); @@ -2105,11 +2105,11 @@ void GLSL_LoadGPUShaders() }; #endif - ri->Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); + ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n"); R_IssuePendingRenderCommands(); - int startTime = ri->Milliseconds(); + int startTime = ri.Milliseconds(); Allocator allocator(512 * 1024); ShaderProgramBuilder builder; @@ -2138,16 +2138,16 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramSurfaceSprites(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramWeather(builder, allocator); - ri->Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", + ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n", numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders, - numEtcShaders, (ri->Milliseconds() - startTime) / 1000.0); + numEtcShaders, (ri.Milliseconds() - startTime) / 1000.0); } void GLSL_ShutdownGPUShaders(void) { int i; - ri->Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); + ri.Printf(PRINT_ALL, "------- GLSL_ShutdownGPUShaders -------\n"); for ( int i = 0; i < ATTR_INDEX_MAX; i++ ) qglDisableVertexAttribArray(i); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b014507a3a..052a2b5fbc 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -126,7 +126,7 @@ void GL_TextureMode( const char *string ) { if ( i == 6 ) { - ri->Printf (PRINT_ALL, "bad filter name\n"); + ri.Printf (PRINT_ALL, "bad filter name\n"); return; } @@ -135,7 +135,7 @@ void GL_TextureMode( const char *string ) { if ( r_ext_texture_filter_anisotropic->value > glConfig.maxTextureFilterAnisotropy ) { - ri->Cvar_SetValue ("r_ext_texture_filter_anisotropic", glConfig.maxTextureFilterAnisotropy); + ri.Cvar_SetValue ("r_ext_texture_filter_anisotropic", glConfig.maxTextureFilterAnisotropy); } // change all the existing mipmap texture objects @@ -218,7 +218,7 @@ void R_ImageList_f( void ) { const char *sizeSuffix; image_t *image = tr.images; - ri->Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); + ri.Printf(PRINT_ALL, "\n -w-- -h-- type -size- --name-------\n"); for ( i = 0 ; i < tr.numImages ; i++, image = image->poolNext ) { @@ -301,15 +301,15 @@ void R_ImageList_f( void ) { float printSize = GetReadableSize(estSize, &sizeSuffix); - ri->Printf(PRINT_ALL, "%4i: %4ix%4i %s %7.2f%s %s\n", i, image->uploadWidth, image->uploadHeight, format, printSize, sizeSuffix, image->imgName); + ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %7.2f%s %s\n", i, image->uploadWidth, image->uploadHeight, format, printSize, sizeSuffix, image->imgName); estTotalSize += estSize; } float printSize = GetReadableSize(estTotalSize, &sizeSuffix); - ri->Printf (PRINT_ALL, " ---------\n"); - ri->Printf (PRINT_ALL, " approx %i bytes (%.2f%s)\n", estTotalSize, printSize, sizeSuffix); - ri->Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); + ri.Printf (PRINT_ALL, " ---------\n"); + ri.Printf (PRINT_ALL, " approx %i bytes (%.2f%s)\n", estTotalSize, printSize, sizeSuffix); + ri.Printf (PRINT_ALL, " %i total images\n\n", tr.numImages ); } //======================================================================= @@ -336,7 +336,7 @@ static void ResampleTexture( byte *in, int inwidth, int inheight, byte *out, byte *pix1, *pix2, *pix3, *pix4; if (outwidth>2048) - ri->Error(ERR_DROP, "ResampleTexture: max width"); + ri.Error(ERR_DROP, "ResampleTexture: max width"); fracstep = inwidth*0x10000/outwidth; @@ -1319,7 +1319,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = (unsigned int *)ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = (unsigned int *)ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); inWidthMask = inWidth - 1; inHeightMask = inHeight - 1; @@ -1354,7 +1354,7 @@ static void R_MipMap2( byte *in, int inWidth, int inHeight ) { } Com_Memcpy( in, temp, outWidth * outHeight * 4 ); - ri->Hunk_FreeTempMemory( temp ); + ri.Hunk_FreeTempMemory( temp ); } @@ -1366,7 +1366,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) outWidth = inWidth >> 1; outHeight = inHeight >> 1; - temp = (byte *)ri->Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); + temp = (byte *)ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); for ( i = 0 ; i < outHeight ; i++ ) { byte *outbyte = temp + ( i * outWidth ) * 4; @@ -1396,7 +1396,7 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) } Com_Memcpy( in, temp, outWidth * outHeight * 4 ); - ri->Hunk_FreeTempMemory( temp ); + ri.Hunk_FreeTempMemory( temp ); } /* @@ -1632,7 +1632,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he int finalwidth, finalheight; //int startTime, endTime; - //startTime = ri->Milliseconds(); + //startTime = ri.Milliseconds(); finalwidth = scaled_width << r_imageUpsample->integer; finalheight = scaled_height << r_imageUpsample->integer; @@ -1649,7 +1649,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he finalheight >>= 1; } - *resampledBuffer = (byte *)ri->Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); + *resampledBuffer = (byte *)ri.Hunk_AllocateTempMemory( finalwidth * finalheight * 4 ); if (scaled_width != width || scaled_height != height) { @@ -1690,9 +1690,9 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he } - //endTime = ri->Milliseconds(); + //endTime = ri.Milliseconds(); - //ri->Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); + //ri.Printf(PRINT_ALL, "upsampled %dx%d to %dx%d in %dms\n", width, height, scaled_width, scaled_height, endTime - startTime); *data = *resampledBuffer; width = scaled_width; @@ -1701,7 +1701,7 @@ static void RawImage_ScaleToPower2( byte **data, int *inout_width, int *inout_he else if ( scaled_width != width || scaled_height != height ) { if (data && resampledBuffer) { - *resampledBuffer = (byte *)ri->Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); + *resampledBuffer = (byte *)ri.Hunk_AllocateTempMemory( scaled_width * scaled_height * 4 ); ResampleTexture (*data, width, height, *resampledBuffer, scaled_width, scaled_height); *data = *resampledBuffer; } @@ -2110,7 +2110,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla RawImage_ScaleToPower2(&data, &width, &height, &scaled_width, &scaled_height, type, flags, &resampledBuffer); } - scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = (byte *)ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); // // scan the texture for each channel's max values @@ -2229,9 +2229,9 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla GL_CheckErrors(); if ( scaledBuffer != 0 ) - ri->Hunk_FreeTempMemory( scaledBuffer ); + ri.Hunk_FreeTempMemory( scaledBuffer ); if ( resampledBuffer != 0 ) - ri->Hunk_FreeTempMemory( resampledBuffer ); + ri.Hunk_FreeTempMemory( resampledBuffer ); } @@ -2356,7 +2356,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT int glWrapClampMode; if (strlen(name) >= MAX_QPATH ) { - ri->Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); + ri.Error (ERR_DROP, "R_CreateImage: \"%s\" is too long", name); } if ( !strncmp( name, "*lightmap", 9 ) ) { isLightmap = qtrue; @@ -2502,7 +2502,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h RawImage_ScaleToPower2(&pic, &width, &height, &scaled_width, &scaled_height, image->type, image->flags, &resampledBuffer); - scaledBuffer = (byte *)ri->Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); + scaledBuffer = (byte *)ri.Hunk_AllocateTempMemory( sizeof( unsigned ) * scaled_width * scaled_height ); GL_SelectTexture( image->TMU ); GL_Bind(image); @@ -2564,9 +2564,9 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h GL_CheckErrors(); if ( scaledBuffer != 0 ) - ri->Hunk_FreeTempMemory( scaledBuffer ); + ri.Hunk_FreeTempMemory( scaledBuffer ); if ( resampledBuffer != 0 ) - ri->Hunk_FreeTempMemory( resampledBuffer ); + ri.Hunk_FreeTempMemory( resampledBuffer ); } static void R_CreateNormalMap ( const char *name, byte *pic, int width, int height, int flags ) @@ -2661,7 +2661,7 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig } } - ri->Free(blurPic); + ri.Free(blurPic); YCoCgAtoRGBA(pic, pic, width, height); } @@ -2701,7 +2701,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) // the white image can be used with any set of parms, but other mismatches are errors if ( strcmp( name, "*white" ) ) { if ( image->flags != flags ) { - ri->Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); + ri.Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); } } return image; @@ -2842,7 +2842,7 @@ static void R_CreateFogImage( void ) { float d; float borderColor[4]; - data = (byte *)ri->Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); + data = (byte *)ri.Hunk_AllocateTempMemory( FOG_S * FOG_T * 4 ); // S is distance, T is depth for (x=0 ; xHunk_FreeTempMemory( data ); + ri.Hunk_FreeTempMemory( data ); borderColor[0] = 1.0; borderColor[1] = 1.0; @@ -3218,13 +3218,13 @@ void R_SetColorMappings( void ) { tr.identityLightByte = 255 * tr.identityLight; if ( r_intensity->value <= 1 ) { - ri->Cvar_Set( "r_intensity", "1" ); + ri.Cvar_Set( "r_intensity", "1" ); } if ( r_gamma->value < 0.5f ) { - ri->Cvar_Set( "r_gamma", "0.5" ); + ri.Cvar_Set( "r_gamma", "0.5" ); } else if ( r_gamma->value > 3.0f ) { - ri->Cvar_Set( "r_gamma", "3.0" ); + ri.Cvar_Set( "r_gamma", "3.0" ); } g = r_gamma->value; @@ -3266,7 +3266,7 @@ void R_SetColorMappings( void ) { if ( glConfig.deviceSupportsGamma ) { - ri->WIN_SetGamma( &glConfig, s_gammatable, s_gammatable, s_gammatable ); + ri.WIN_SetGamma( &glConfig, s_gammatable, s_gammatable, s_gammatable ); } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 73f206413e..57a088d25b 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -285,7 +285,7 @@ static void R_Splash() GLSL_BindProgram(&tr.splashScreenShader); qglDrawArrays(GL_TRIANGLES, 0, 3); - ri->WIN_Present(&window); + ri.WIN_Present(&window); } /* @@ -500,7 +500,7 @@ static void InitOpenGL( void ) if ( r_debugContext->integer ) windowDesc.gl.contextFlags = GLCONTEXT_DEBUG; - window = ri->WIN_Init(&windowDesc, &glConfig); + window = ri.WIN_Init(&windowDesc, &glConfig); GLimp_InitCoreFunctions(); @@ -595,7 +595,7 @@ void GL_CheckErrs( const char *file, int line ) { break; } - ri->Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); + ri.Error( ERR_FATAL, "GL_CheckErrors: %s in %s at line %d", s , file, line); #endif } @@ -631,7 +631,7 @@ alignment of packAlign to ensure efficient copying. Stores the length of padding after a line of pixels to address padlen -Return value must be freed with ri->Hunk_FreeTempMemory() +Return value must be freed with ri.Hunk_FreeTempMemory() ================== */ @@ -648,7 +648,7 @@ static byte *RB_ReadPixels( padwidth = PAD(linelen, packAlign); // Allocate a few more bytes so that we can choose an alignment we like - buffer = (byte *)ri->Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); + buffer = (byte *)ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1); bufstart = (byte*)(PADP((intptr_t) buffer + *offset, packAlign)); qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart); @@ -692,7 +692,7 @@ static void R_SaveTGA( const size_t pixelBufferSize = stride * height; const size_t bufferSize = headerSize + pixelBufferSize; - byte *buffer = (byte *)ri->Hunk_AllocateTempMemory(bufferSize); + byte *buffer = (byte *)ri.Hunk_AllocateTempMemory(bufferSize); // Write TGA header Com_Memset(buffer, 0, headerSize); @@ -705,8 +705,8 @@ static void R_SaveTGA( ConvertRGBtoBGR(buffer + headerSize, pixels, stride, width, height); - ri->FS_WriteFile(filename, buffer, bufferSize); - ri->Hunk_FreeTempMemory(buffer); + ri.FS_WriteFile(filename, buffer, bufferSize); + ri.Hunk_FreeTempMemory(buffer); } /* @@ -767,7 +767,7 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) if (pixelBuffer == nullptr) { - ri->Printf( + ri.Printf( PRINT_ALL, S_COLOR_RED "Failed to read screenshot data from GPU\n"); } @@ -777,7 +777,7 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) const int stride = screenshotReadback->strideInBytes; const size_t pixelBufferSize = stride * height; - byte *pixels = (byte *)ri->Hunk_AllocateTempMemory(pixelBufferSize); + byte *pixels = (byte *)ri.Hunk_AllocateTempMemory(pixelBufferSize); Com_Memcpy(pixels, pixelBuffer, pixelBufferSize); qglUnmapBuffer(GL_PIXEL_PACK_BUFFER); @@ -799,7 +799,7 @@ void R_SaveScreenshot(screenshotReadback_t *screenshotReadback) break; } - ri->Hunk_FreeTempMemory(pixels); + ri.Hunk_FreeTempMemory(pixels); } qglDeleteBuffers(1, &screenshotReadback->pbo); @@ -916,7 +916,7 @@ static void R_LevelShot( void ) { allsource = RB_ReadPixels(0, 0, glConfig.vidWidth, glConfig.vidHeight, &offset, &padlen); source = allsource + offset; - buffer = (byte *)ri->Hunk_AllocateTempMemory(LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18); + buffer = (byte *)ri.Hunk_AllocateTempMemory(LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18); Com_Memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type buffer[12] = LEVELSHOTSIZE & 255; @@ -951,12 +951,12 @@ static void R_LevelShot( void ) { R_GammaCorrect( buffer + 18, LEVELSHOTSIZE * LEVELSHOTSIZE * 3 ); } - ri->FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 ); + ri.FS_WriteFile( checkname, buffer, LEVELSHOTSIZE * LEVELSHOTSIZE*3 + 18 ); - ri->Hunk_FreeTempMemory( buffer ); - ri->Hunk_FreeTempMemory( allsource ); + ri.Hunk_FreeTempMemory( buffer ); + ri.Hunk_FreeTempMemory( allsource ); - ri->Printf( PRINT_ALL, "Wrote %s\n", checkname ); + ri.Printf( PRINT_ALL, "Wrote %s\n", checkname ); } /* @@ -975,23 +975,23 @@ void R_ScreenShotTGA_f (void) { char checkname[MAX_OSPATH] = {0}; qboolean silent = qfalse; - if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { + if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) + if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) silent = qtrue; - if ( ri->Cmd_Argc() == 2 && !silent ) { + if ( ri.Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.tga", ri->Cmd_Argv( 1 ) ); + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.tga", ri.Cmd_Argv( 1 ) ); } else { // timestamp the file R_ScreenshotFilename( checkname, sizeof( checkname ), ".tga" ); - if ( ri->FS_FileExists( checkname ) ) { + if ( ri.FS_FileExists( checkname ) ) { Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } @@ -1000,30 +1000,30 @@ void R_ScreenShotTGA_f (void) { R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_TGA ); if ( !silent ) - ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); + ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); } void R_ScreenShotPNG_f (void) { char checkname[MAX_OSPATH] = {0}; qboolean silent = qfalse; - if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { + if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) + if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) silent = qtrue; - if ( ri->Cmd_Argc() == 2 && !silent ) { + if ( ri.Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.png", ri->Cmd_Argv( 1 ) ); + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.png", ri.Cmd_Argv( 1 ) ); } else { // timestamp the file R_ScreenshotFilename( checkname, sizeof( checkname ), ".png" ); - if ( ri->FS_FileExists( checkname ) ) { + if ( ri.FS_FileExists( checkname ) ) { Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } @@ -1032,30 +1032,30 @@ void R_ScreenShotPNG_f (void) { R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_PNG ); if ( !silent ) - ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); + ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); } void R_ScreenShotJPEG_f (void) { char checkname[MAX_OSPATH] = {0}; qboolean silent = qfalse; - if ( !strcmp( ri->Cmd_Argv(1), "levelshot" ) ) { + if ( !strcmp( ri.Cmd_Argv(1), "levelshot" ) ) { R_LevelShot(); return; } - if ( !strcmp( ri->Cmd_Argv(1), "silent" ) ) + if ( !strcmp( ri.Cmd_Argv(1), "silent" ) ) silent = qtrue; - if ( ri->Cmd_Argc() == 2 && !silent ) { + if ( ri.Cmd_Argc() == 2 && !silent ) { // explicit filename - Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.jpg", ri->Cmd_Argv( 1 ) ); + Com_sprintf( checkname, sizeof( checkname ), "screenshots/%s.jpg", ri.Cmd_Argv( 1 ) ); } else { // timestamp the file R_ScreenshotFilename( checkname, sizeof( checkname ), ".jpg" ); - if ( ri->FS_FileExists( checkname ) ) { + if ( ri.FS_FileExists( checkname ) ) { Com_Printf( "ScreenShot: Couldn't create a file\n"); return; } @@ -1064,7 +1064,7 @@ void R_ScreenShotJPEG_f (void) { R_TakeScreenshot( 0, 0, glConfig.vidWidth, glConfig.vidHeight, checkname, SSF_JPEG ); if ( !silent ) - ri->Printf (PRINT_ALL, "Wrote %s\n", checkname); + ri.Printf (PRINT_ALL, "Wrote %s\n", checkname); } //============================================================================ @@ -1115,7 +1115,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) memcount = RE_SaveJPGToBuffer(cmd->encodeBuffer, linelen * cmd->height, r_aviMotionJpegQuality->integer, cmd->width, cmd->height, cBuf, padlen); - ri->CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, memcount); } else { @@ -1144,7 +1144,7 @@ const void *RB_TakeVideoFrameCmd( const void *data ) srcptr += padlen; } - ri->CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); + ri.CL_WriteAVIVideoFrame(cmd->encodeBuffer, avipadwidth * cmd->height); } return (const void *)(cmd + 1); @@ -1201,7 +1201,7 @@ void GL_SetDefaultState( void ) ================ R_PrintLongString -Workaround for ri->Printf's 1024 characters buffer limit. +Workaround for ri.Printf's 1024 characters buffer limit. ================ */ void R_PrintLongString(const char *string) { @@ -1213,7 +1213,7 @@ void R_PrintLongString(const char *string) { while(size > 0) { Q_strncpyz(buffer, p, sizeof (buffer) ); - ri->Printf( PRINT_ALL, "%s", buffer ); + ri.Printf( PRINT_ALL, "%s", buffer ); p += 1023; size -= 1023; } @@ -1242,57 +1242,57 @@ static void GfxInfo_f( void ) "noborder " }; - int fullscreen = ri->Cvar_VariableIntegerValue("r_fullscreen"); - int noborder = ri->Cvar_VariableIntegerValue("r_noborder"); + int fullscreen = ri.Cvar_VariableIntegerValue("r_fullscreen"); + int noborder = ri.Cvar_VariableIntegerValue("r_noborder"); - ri->Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); - ri->Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); - ri->Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); - ri->Printf( PRINT_ALL, "GL_EXTENSIONS: " ); + ri.Printf( PRINT_ALL, "\nGL_VENDOR: %s\n", glConfig.vendor_string ); + ri.Printf( PRINT_ALL, "GL_RENDERER: %s\n", glConfig.renderer_string ); + ri.Printf( PRINT_ALL, "GL_VERSION: %s\n", glConfig.version_string ); + ri.Printf( PRINT_ALL, "GL_EXTENSIONS: " ); R_PrintLongString( glConfigExt.originalExtensionString ); - ri->Printf( PRINT_ALL, "\n" ); - ri->Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); - ri->Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); - ri->Printf( PRINT_ALL, "MODE: %d, %d x %d %s%s hz:", - ri->Cvar_VariableIntegerValue("r_mode"), + ri.Printf( PRINT_ALL, "\n" ); + ri.Printf( PRINT_ALL, "GL_MAX_TEXTURE_SIZE: %d\n", glConfig.maxTextureSize ); + ri.Printf( PRINT_ALL, "\nPIXELFORMAT: color(%d-bits) Z(%d-bit) stencil(%d-bits)\n", glConfig.colorBits, glConfig.depthBits, glConfig.stencilBits ); + ri.Printf( PRINT_ALL, "MODE: %d, %d x %d %s%s hz:", + ri.Cvar_VariableIntegerValue("r_mode"), glConfig.vidWidth, glConfig.vidHeight, fullscreen == 0 ? noborderstrings[noborder == 1] : noborderstrings[0], fsstrings[fullscreen == 1] ); if ( glConfig.displayFrequency ) { - ri->Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); + ri.Printf( PRINT_ALL, "%d\n", glConfig.displayFrequency ); } else { - ri->Printf( PRINT_ALL, "N/A\n" ); + ri.Printf( PRINT_ALL, "N/A\n" ); } if ( glConfig.deviceSupportsGamma ) { - ri->Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); + ri.Printf( PRINT_ALL, "GAMMA: hardware w/ %d overbright bits\n", tr.overbrightBits ); } else { - ri->Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); + ri.Printf( PRINT_ALL, "GAMMA: software w/ %d overbright bits\n", tr.overbrightBits ); } - ri->Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); - ri->Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); - ri->Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); + ri.Printf( PRINT_ALL, "texturemode: %s\n", r_textureMode->string ); + ri.Printf( PRINT_ALL, "picmip: %d\n", r_picmip->integer ); + ri.Printf( PRINT_ALL, "texture bits: %d\n", r_texturebits->integer ); if ( r_vertexLight->integer ) { - ri->Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); + ri.Printf( PRINT_ALL, "HACK: using vertex lightmap approximation\n" ); } - int displayRefresh = ri->Cvar_VariableIntegerValue("r_displayRefresh"); + int displayRefresh = ri.Cvar_VariableIntegerValue("r_displayRefresh"); if ( displayRefresh ) { - ri->Printf( PRINT_ALL, "Display refresh set to %d\n", displayRefresh ); + ri.Printf( PRINT_ALL, "Display refresh set to %d\n", displayRefresh ); } if ( r_finish->integer ) { - ri->Printf( PRINT_ALL, "Forcing glFinish\n" ); + ri.Printf( PRINT_ALL, "Forcing glFinish\n" ); } - ri->Printf( PRINT_ALL, "Dynamic Glow: %s\n", enablestrings[r_dynamicGlow->integer != 0] ); + ri.Printf( PRINT_ALL, "Dynamic Glow: %s\n", enablestrings[r_dynamicGlow->integer != 0] ); } /* @@ -1306,7 +1306,7 @@ void GfxMemInfo_f( void ) { case MI_NONE: { - ri->Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); + ri.Printf(PRINT_ALL, "No extension found for GPU memory info.\n"); } break; case MI_NVX: @@ -1314,19 +1314,19 @@ void GfxMemInfo_f( void ) int value; qglGetIntegerv(GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX, &value); - ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX, &value); - ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, &value); - ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX: %ikb\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX, &value); - ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTION_COUNT_NVX: %i\n", value); qglGetIntegerv(GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX, &value); - ri->Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); + ri.Printf(PRINT_ALL, "GPU_MEMORY_INFO_EVICTED_MEMORY_NVX: %ikb\n", value); } break; case MI_ATI: @@ -1335,13 +1335,13 @@ void GfxMemInfo_f( void ) int value[4]; qglGetIntegerv(GL_VBO_FREE_MEMORY_ATI, &value[0]); - ri->Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri.Printf(PRINT_ALL, "VBO_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); qglGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, &value[0]); - ri->Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri.Printf(PRINT_ALL, "TEXTURE_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); qglGetIntegerv(GL_RENDERBUFFER_FREE_MEMORY_ATI, &value[0]); - ri->Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); + ri.Printf(PRINT_ALL, "RENDERBUFFER_FREE_MEMORY_ATI: %ikb total %ikb largest aux: %ikb total %ikb largest\n", value[0], value[1], value[2], value[3]); } break; } @@ -1349,24 +1349,24 @@ void GfxMemInfo_f( void ) static void R_CaptureFrameData_f() { - int argc = ri->Cmd_Argc(); + int argc = ri.Cmd_Argc(); if ( argc <= 1 ) { - ri->Printf( PRINT_ALL, "Usage: %s \n", ri->Cmd_Argv(0)); + ri.Printf( PRINT_ALL, "Usage: %s \n", ri.Cmd_Argv(0)); return; } - const char *cmd = ri->Cmd_Argv(1); + const char *cmd = ri.Cmd_Argv(1); if ( Q_stricmp(cmd, "single") == 0 ) tr.numFramesToCapture = 1; else if ( Q_stricmp(cmd, "multi") == 0 ) - tr.numFramesToCapture = atoi(ri->Cmd_Argv(1)); + tr.numFramesToCapture = atoi(ri.Cmd_Argv(1)); - int len = ri->FS_FOpenFileByMode("rend2.log", &tr.debugFile, FS_APPEND); + int len = ri.FS_FOpenFileByMode("rend2.log", &tr.debugFile, FS_APPEND); if ( len == -1 || !tr.debugFile ) { - ri->Printf( PRINT_ERROR, "Failed to open rend2 log file\n" ); + ri.Printf( PRINT_ERROR, "Failed to open rend2 log file\n" ); tr.numFramesToCapture = 0; } } @@ -1407,223 +1407,223 @@ void R_Register( void ) // // latched and archived variables // - r_allowExtensions = ri->Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH, "Allow GL extensions" ); - r_ext_compressed_textures = ri->Cvar_Get( "r_ext_compress_textures", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable texture compression" ); - r_ext_multitexture = ri->Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); - r_ext_compiled_vertex_array = ri->Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); - r_ext_texture_env_add = ri->Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); - r_ext_preferred_tc_method = ri->Cvar_Get( "r_ext_preferred_tc_method", "0", CVAR_ARCHIVE | CVAR_LATCH, "Preferred texture compression method" ); - - r_ext_draw_range_elements = ri->Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); - r_ext_multi_draw_arrays = ri->Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); - r_ext_texture_float = ri->Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable floating-point textures" ); - r_arb_half_float_pixel = ri->Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable ARB_half_float GL extension" ); - r_ext_framebuffer_multisample = ri->Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable framebuffer MSAA" ); - r_arb_seamless_cube_map = ri->Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable seamless cube map filtering GL extension" ); - r_arb_vertex_type_2_10_10_10_rev = ri->Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable 1010102 UI data type" ); - r_arb_buffer_storage = ri->Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable buffer storage GL extension" ); - r_ext_texture_filter_anisotropic = ri->Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE, "Disable/enable anisotropic texture filtering" ); - - r_dynamicGlow = ri->Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE, "" ); - r_dynamicGlowPasses = ri->Cvar_Get( "r_dynamicGlowPasses", "5", CVAR_ARCHIVE, "" ); - r_dynamicGlowDelta = ri->Cvar_Get( "r_dynamicGlowDelta", "0.8f", CVAR_ARCHIVE, "" ); - r_dynamicGlowIntensity = ri->Cvar_Get( "r_dynamicGlowIntensity", "1.13f", CVAR_ARCHIVE, "" ); - r_dynamicGlowSoft = ri->Cvar_Get( "r_dynamicGlowSoft", "1", CVAR_ARCHIVE, "" ); - r_dynamicGlowWidth = ri->Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH, "" ); - r_dynamicGlowHeight = ri->Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH, "" ); - - r_debugContext = ri->Cvar_Get( "r_debugContext", "0", CVAR_LATCH, "" ); - - r_picmip = ri->Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - ri->Cvar_CheckRange( r_picmip, 0, 16, qtrue ); - r_roundImagesDown = ri->Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_colorMipLevels = ri->Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH, "" ); - r_detailTextures = ri->Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_texturebits = ri->Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_overBrightBits = ri->Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_simpleMipMaps = ri->Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_vertexLight = ri->Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_uiFullScreen = ri->Cvar_Get( "r_uifullscreen", "0", 0, ""); - r_subdivisions = ri->Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH, ""); - ri->Cvar_CheckRange( r_subdivisions, 4, 80, qfalse ); - r_stereo = ri->Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); - r_greyscale = ri->Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); - ri->Cvar_CheckRange(r_greyscale, 0, 1, qfalse); - - r_externalGLSL = ri->Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH, "" ); - - r_hdr = ri->Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_floatLightmap = ri->Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - - r_toneMap = ri->Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_forceToneMap = ri->Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT, "" ); - r_forceToneMapMin = ri->Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT, "" ); - r_forceToneMapAvg = ri->Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT, "" ); - r_forceToneMapMax = ri->Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT, "" ); - - r_autoExposure = ri->Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE, "" ); - r_forceAutoExposure = ri->Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT, "" ); - r_forceAutoExposureMin = ri->Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT, "" ); - r_forceAutoExposureMax = ri->Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT, "" ); - - r_cameraExposure = ri->Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT, "" ); - - r_srgb = ri->Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - - r_depthPrepass = ri->Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE, "" ); - r_ssao = ri->Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE, "" ); - - r_normalMapping = ri->Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_specularMapping = ri->Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_deluxeMapping = ri->Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_parallaxMapping = ri->Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_cubeMapping = ri->Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseNormalX = ri->Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseNormalY = ri->Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseParallax = ri->Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_baseSpecular = ri->Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_dlightMode = ri->Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_pshadowDist = ri->Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); - r_mergeLightmaps = ri->Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_imageUpsample = ri->Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_imageUpsampleMaxSize = ri->Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_imageUpsampleType = ri->Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_genNormalMaps = ri->Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - - r_forceSun = ri->Cvar_Get( "r_forceSun", "0", CVAR_CHEAT, "" ); - r_forceSunMapLightScale = ri->Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT, "" ); - r_forceSunLightScale = ri->Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT, "" ); - r_forceSunAmbientScale = ri->Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT, "" ); - r_drawSunRays = ri->Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_sunlightMode = ri->Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - - r_sunShadows = ri->Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_shadowFilter = ri->Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_shadowMapSize = ri->Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_shadowCascadeZNear = ri->Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_shadowCascadeZFar = ri->Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_shadowCascadeZBias = ri->Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_ignoreDstAlpha = ri->Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_allowExtensions = ri.Cvar_Get( "r_allowExtensions", "1", CVAR_ARCHIVE | CVAR_LATCH, "Allow GL extensions" ); + r_ext_compressed_textures = ri.Cvar_Get( "r_ext_compress_textures", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable texture compression" ); + r_ext_multitexture = ri.Cvar_Get( "r_ext_multitexture", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_compiled_vertex_array = ri.Cvar_Get( "r_ext_compiled_vertex_array", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_texture_env_add = ri.Cvar_Get( "r_ext_texture_env_add", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_preferred_tc_method = ri.Cvar_Get( "r_ext_preferred_tc_method", "0", CVAR_ARCHIVE | CVAR_LATCH, "Preferred texture compression method" ); + + r_ext_draw_range_elements = ri.Cvar_Get( "r_ext_draw_range_elements", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_multi_draw_arrays = ri.Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); + r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable floating-point textures" ); + r_arb_half_float_pixel = ri.Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable ARB_half_float GL extension" ); + r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable framebuffer MSAA" ); + r_arb_seamless_cube_map = ri.Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable seamless cube map filtering GL extension" ); + r_arb_vertex_type_2_10_10_10_rev = ri.Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable 1010102 UI data type" ); + r_arb_buffer_storage = ri.Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable buffer storage GL extension" ); + r_ext_texture_filter_anisotropic = ri.Cvar_Get( "r_ext_texture_filter_anisotropic", "16", CVAR_ARCHIVE, "Disable/enable anisotropic texture filtering" ); + + r_dynamicGlow = ri.Cvar_Get( "r_dynamicGlow", "0", CVAR_ARCHIVE, "" ); + r_dynamicGlowPasses = ri.Cvar_Get( "r_dynamicGlowPasses", "5", CVAR_ARCHIVE, "" ); + r_dynamicGlowDelta = ri.Cvar_Get( "r_dynamicGlowDelta", "0.8f", CVAR_ARCHIVE, "" ); + r_dynamicGlowIntensity = ri.Cvar_Get( "r_dynamicGlowIntensity", "1.13f", CVAR_ARCHIVE, "" ); + r_dynamicGlowSoft = ri.Cvar_Get( "r_dynamicGlowSoft", "1", CVAR_ARCHIVE, "" ); + r_dynamicGlowWidth = ri.Cvar_Get( "r_dynamicGlowWidth", "320", CVAR_ARCHIVE|CVAR_LATCH, "" ); + r_dynamicGlowHeight = ri.Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH, "" ); + + r_debugContext = ri.Cvar_Get( "r_debugContext", "0", CVAR_LATCH, "" ); + + r_picmip = ri.Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + ri.Cvar_CheckRange( r_picmip, 0, 16, qtrue ); + r_roundImagesDown = ri.Cvar_Get ("r_roundImagesDown", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_colorMipLevels = ri.Cvar_Get ("r_colorMipLevels", "0", CVAR_LATCH, "" ); + r_detailTextures = ri.Cvar_Get( "r_detailtextures", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_texturebits = ri.Cvar_Get( "r_texturebits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_overBrightBits = ri.Cvar_Get ("r_overBrightBits", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_simpleMipMaps = ri.Cvar_Get( "r_simpleMipMaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0, ""); + r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH, ""); + ri.Cvar_CheckRange( r_subdivisions, 4, 80, qfalse ); + r_stereo = ri.Cvar_Get( "r_stereo", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); + r_greyscale = ri.Cvar_Get("r_greyscale", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); + ri.Cvar_CheckRange(r_greyscale, 0, 1, qfalse); + + r_externalGLSL = ri.Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH, "" ); + + r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT, "" ); + r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT, "" ); + r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT, "" ); + r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT, "" ); + + r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE, "" ); + r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT, "" ); + r_forceAutoExposureMin = ri.Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT, "" ); + r_forceAutoExposureMax = ri.Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT, "" ); + + r_cameraExposure = ri.Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT, "" ); + + r_srgb = ri.Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE, "" ); + r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE, "" ); + + r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_dlightMode = ri.Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); + r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT, "" ); + r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT, "" ); + r_forceSunLightScale = ri.Cvar_Get( "r_forceSunLightScale", "1.0", CVAR_CHEAT, "" ); + r_forceSunAmbientScale = ri.Cvar_Get( "r_forceSunAmbientScale", "0.5", CVAR_CHEAT, "" ); + r_drawSunRays = ri.Cvar_Get( "r_drawSunRays", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_sunlightMode = ri.Cvar_Get( "r_sunlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + + r_sunShadows = ri.Cvar_Get( "r_sunShadows", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowFilter = ri.Cvar_Get( "r_shadowFilter", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowMapSize = ri.Cvar_Get( "r_shadowMapSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZNear = ri.Cvar_Get( "r_shadowCascadeZNear", "4", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZFar = ri.Cvar_Get( "r_shadowCascadeZFar", "3072", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_shadowCascadeZBias = ri.Cvar_Get( "r_shadowCascadeZBias", "-320", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_ignoreDstAlpha = ri.Cvar_Get( "r_ignoreDstAlpha", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); // // temporary latched variables that can only change over a restart // - r_fullbright = ri->Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT, "" ); - r_mapOverBrightBits = ri->Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH, "" ); - r_intensity = ri->Cvar_Get ("r_intensity", "1", CVAR_LATCH, "" ); - r_singleShader = ri->Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH, "" ); + r_fullbright = ri.Cvar_Get ("r_fullbright", "0", CVAR_LATCH|CVAR_CHEAT, "" ); + r_mapOverBrightBits = ri.Cvar_Get ("r_mapOverBrightBits", "0", CVAR_LATCH, "" ); + r_intensity = ri.Cvar_Get ("r_intensity", "1", CVAR_LATCH, "" ); + r_singleShader = ri.Cvar_Get ("r_singleShader", "0", CVAR_CHEAT | CVAR_LATCH, "" ); // // archived variables that can change at any time // - r_lodCurveError = ri->Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT, "" ); - r_lodbias = ri->Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE, "" ); - r_flares = ri->Cvar_Get ("r_flares", "0", CVAR_ARCHIVE, "" ); - r_znear = ri->Cvar_Get( "r_znear", "4", CVAR_CHEAT, "" ); - ri->Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); - r_autolodscalevalue = ri->Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM, "" ); - r_zproj = ri->Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE, "" ); - r_stereoSeparation = ri->Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE, "" ); - r_ignoreGLErrors = ri->Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE, "" ); - r_fastsky = ri->Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE, "" ); - r_inGameVideo = ri->Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE, "" ); - r_drawSun = ri->Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE, "" ); - r_dynamiclight = ri->Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE, "" ); - r_finish = ri->Cvar_Get ("r_finish", "0", CVAR_ARCHIVE, ""); - r_textureMode = ri->Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE, "" ); - r_markcount = ri->Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE, "" ); - r_gamma = ri->Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE, "" ); - r_facePlaneCull = ri->Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE, "" ); - - r_ambientScale = ri->Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT, "" ); - r_directedScale = ri->Cvar_Get( "r_directedScale", "1", CVAR_CHEAT, "" ); - - r_anaglyphMode = ri->Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE, ""); + r_lodCurveError = ri.Cvar_Get( "r_lodCurveError", "250", CVAR_ARCHIVE|CVAR_CHEAT, "" ); + r_lodbias = ri.Cvar_Get( "r_lodbias", "0", CVAR_ARCHIVE, "" ); + r_flares = ri.Cvar_Get ("r_flares", "0", CVAR_ARCHIVE, "" ); + r_znear = ri.Cvar_Get( "r_znear", "4", CVAR_CHEAT, "" ); + ri.Cvar_CheckRange( r_znear, 0.001f, 200, qfalse ); + r_autolodscalevalue = ri.Cvar_Get( "r_autolodscalevalue", "0", CVAR_ROM, "" ); + r_zproj = ri.Cvar_Get( "r_zproj", "64", CVAR_ARCHIVE, "" ); + r_stereoSeparation = ri.Cvar_Get( "r_stereoSeparation", "64", CVAR_ARCHIVE, "" ); + r_ignoreGLErrors = ri.Cvar_Get( "r_ignoreGLErrors", "1", CVAR_ARCHIVE, "" ); + r_fastsky = ri.Cvar_Get( "r_fastsky", "0", CVAR_ARCHIVE, "" ); + r_inGameVideo = ri.Cvar_Get( "r_inGameVideo", "1", CVAR_ARCHIVE, "" ); + r_drawSun = ri.Cvar_Get( "r_drawSun", "0", CVAR_ARCHIVE, "" ); + r_dynamiclight = ri.Cvar_Get( "r_dynamiclight", "1", CVAR_ARCHIVE, "" ); + r_finish = ri.Cvar_Get ("r_finish", "0", CVAR_ARCHIVE, ""); + r_textureMode = ri.Cvar_Get( "r_textureMode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE, "" ); + r_markcount = ri.Cvar_Get( "r_markcount", "100", CVAR_ARCHIVE, "" ); + r_gamma = ri.Cvar_Get( "r_gamma", "1", CVAR_ARCHIVE, "" ); + r_facePlaneCull = ri.Cvar_Get ("r_facePlaneCull", "1", CVAR_ARCHIVE, "" ); + + r_ambientScale = ri.Cvar_Get( "r_ambientScale", "0.6", CVAR_CHEAT, "" ); + r_directedScale = ri.Cvar_Get( "r_directedScale", "1", CVAR_CHEAT, "" ); + + r_anaglyphMode = ri.Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE, ""); // // temporary variables that can change at any time // - r_showImages = ri->Cvar_Get( "r_showImages", "0", CVAR_TEMP, "" ); - - r_debugLight = ri->Cvar_Get( "r_debuglight", "0", CVAR_TEMP, "" ); - r_debugSort = ri->Cvar_Get( "r_debugSort", "0", CVAR_CHEAT, "" ); - r_printShaders = ri->Cvar_Get( "r_printShaders", "0", 0, "" ); - r_saveFontData = ri->Cvar_Get( "r_saveFontData", "0", 0, "" ); - - r_nocurves = ri->Cvar_Get ("r_nocurves", "0", CVAR_CHEAT, "" ); - r_drawworld = ri->Cvar_Get ("r_drawworld", "1", CVAR_CHEAT, "" ); - r_lightmap = ri->Cvar_Get ("r_lightmap", "0", 0, "" ); - r_portalOnly = ri->Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); - - r_flareSize = ri->Cvar_Get ("r_flareSize", "40", CVAR_CHEAT, ""); - r_flareFade = ri->Cvar_Get ("r_flareFade", "7", CVAR_CHEAT, ""); - r_flareCoeff = ri->Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT, ""); - - r_skipBackEnd = ri->Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT, ""); - - r_measureOverdraw = ri->Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT, "" ); - r_lodscale = ri->Cvar_Get( "r_lodscale", "5", CVAR_CHEAT, "" ); - r_norefresh = ri->Cvar_Get ("r_norefresh", "0", CVAR_CHEAT, ""); - r_drawentities = ri->Cvar_Get ("r_drawentities", "1", CVAR_CHEAT, "" ); - r_ignore = ri->Cvar_Get( "r_ignore", "1", CVAR_CHEAT, "" ); - r_nocull = ri->Cvar_Get ("r_nocull", "0", CVAR_CHEAT, ""); - r_novis = ri->Cvar_Get ("r_novis", "0", CVAR_CHEAT, ""); - r_showcluster = ri->Cvar_Get ("r_showcluster", "0", CVAR_CHEAT, ""); - r_speeds = ri->Cvar_Get ("r_speeds", "0", CVAR_CHEAT, ""); - r_verbose = ri->Cvar_Get( "r_verbose", "0", CVAR_CHEAT, "" ); - r_logFile = ri->Cvar_Get( "r_logFile", "0", CVAR_CHEAT, "" ); - r_debugSurface = ri->Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT, ""); - r_nobind = ri->Cvar_Get ("r_nobind", "0", CVAR_CHEAT, ""); - r_showtris = ri->Cvar_Get ("r_showtris", "0", CVAR_CHEAT, ""); - r_showsky = ri->Cvar_Get ("r_showsky", "0", CVAR_CHEAT, ""); - r_shownormals = ri->Cvar_Get ("r_shownormals", "0", CVAR_CHEAT, ""); - r_clear = ri->Cvar_Get ("r_clear", "0", CVAR_CHEAT, ""); - r_offsetFactor = ri->Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT, "" ); - r_offsetUnits = ri->Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT, "" ); - r_drawBuffer = ri->Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT, "" ); - r_lockpvs = ri->Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT, ""); - r_noportals = ri->Cvar_Get ("r_noportals", "0", CVAR_CHEAT, ""); - r_shadows = ri->Cvar_Get( "cg_shadows", "1", 0, "" ); - - r_marksOnTriangleMeshes = ri->Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE, ""); - - r_aviMotionJpegQuality = ri->Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE, ""); - r_screenshotJpegQuality = ri->Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE, ""); - r_surfaceSprites = ri->Cvar_Get("r_surfaceSprites", "1", CVAR_ARCHIVE, ""); - - r_aspectCorrectFonts = ri->Cvar_Get( "r_aspectCorrectFonts", "0", CVAR_ARCHIVE, "" ); - r_maxpolys = ri->Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0, ""); - r_maxpolyverts = ri->Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0, "" ); + r_showImages = ri.Cvar_Get( "r_showImages", "0", CVAR_TEMP, "" ); + + r_debugLight = ri.Cvar_Get( "r_debuglight", "0", CVAR_TEMP, "" ); + r_debugSort = ri.Cvar_Get( "r_debugSort", "0", CVAR_CHEAT, "" ); + r_printShaders = ri.Cvar_Get( "r_printShaders", "0", 0, "" ); + r_saveFontData = ri.Cvar_Get( "r_saveFontData", "0", 0, "" ); + + r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT, "" ); + r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT, "" ); + r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0, "" ); + r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); + + r_flareSize = ri.Cvar_Get ("r_flareSize", "40", CVAR_CHEAT, ""); + r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT, ""); + r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT, ""); + + r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT, ""); + + r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT, "" ); + r_lodscale = ri.Cvar_Get( "r_lodscale", "5", CVAR_CHEAT, "" ); + r_norefresh = ri.Cvar_Get ("r_norefresh", "0", CVAR_CHEAT, ""); + r_drawentities = ri.Cvar_Get ("r_drawentities", "1", CVAR_CHEAT, "" ); + r_ignore = ri.Cvar_Get( "r_ignore", "1", CVAR_CHEAT, "" ); + r_nocull = ri.Cvar_Get ("r_nocull", "0", CVAR_CHEAT, ""); + r_novis = ri.Cvar_Get ("r_novis", "0", CVAR_CHEAT, ""); + r_showcluster = ri.Cvar_Get ("r_showcluster", "0", CVAR_CHEAT, ""); + r_speeds = ri.Cvar_Get ("r_speeds", "0", CVAR_CHEAT, ""); + r_verbose = ri.Cvar_Get( "r_verbose", "0", CVAR_CHEAT, "" ); + r_logFile = ri.Cvar_Get( "r_logFile", "0", CVAR_CHEAT, "" ); + r_debugSurface = ri.Cvar_Get ("r_debugSurface", "0", CVAR_CHEAT, ""); + r_nobind = ri.Cvar_Get ("r_nobind", "0", CVAR_CHEAT, ""); + r_showtris = ri.Cvar_Get ("r_showtris", "0", CVAR_CHEAT, ""); + r_showsky = ri.Cvar_Get ("r_showsky", "0", CVAR_CHEAT, ""); + r_shownormals = ri.Cvar_Get ("r_shownormals", "0", CVAR_CHEAT, ""); + r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT, ""); + r_offsetFactor = ri.Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT, "" ); + r_offsetUnits = ri.Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT, "" ); + r_drawBuffer = ri.Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT, "" ); + r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT, ""); + r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT, ""); + r_shadows = ri.Cvar_Get( "cg_shadows", "1", 0, "" ); + + r_marksOnTriangleMeshes = ri.Cvar_Get("r_marksOnTriangleMeshes", "0", CVAR_ARCHIVE, ""); + + r_aviMotionJpegQuality = ri.Cvar_Get("r_aviMotionJpegQuality", "90", CVAR_ARCHIVE, ""); + r_screenshotJpegQuality = ri.Cvar_Get("r_screenshotJpegQuality", "90", CVAR_ARCHIVE, ""); + r_surfaceSprites = ri.Cvar_Get("r_surfaceSprites", "1", CVAR_ARCHIVE, ""); + + r_aspectCorrectFonts = ri.Cvar_Get( "r_aspectCorrectFonts", "0", CVAR_ARCHIVE, "" ); + r_maxpolys = ri.Cvar_Get( "r_maxpolys", XSTRING( DEFAULT_MAX_POLYS ), 0, ""); + r_maxpolyverts = ri.Cvar_Get( "r_maxpolyverts", XSTRING( DEFAULT_MAX_POLYVERTS ), 0, "" ); /* Ghoul2 Insert Start */ #ifdef _DEBUG - r_noPrecacheGLA = ri->Cvar_Get( "r_noPrecacheGLA", "0", CVAR_CHEAT, "" ); + r_noPrecacheGLA = ri.Cvar_Get( "r_noPrecacheGLA", "0", CVAR_CHEAT, "" ); #endif - r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT, "" ); - r_Ghoul2AnimSmooth = ri->Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE, "" ); - r_Ghoul2UnSqashAfterSmooth = ri->Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE, "" ); - broadsword = ri->Cvar_Get( "broadsword", "0", CVAR_ARCHIVE, "" ); - broadsword_kickbones = ri->Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE, "" ); - broadsword_kickorigin = ri->Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE, "" ); - broadsword_dontstopanim = ri->Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE, "" ); - broadsword_waitforshot = ri->Cvar_Get( "broadsword_waitforshot", "0", CVAR_NONE, "" ); - broadsword_playflop = ri->Cvar_Get( "broadsword_playflop", "1", CVAR_NONE, "" ); - broadsword_smallbbox = ri->Cvar_Get( "broadsword_smallbbox", "0", CVAR_NONE, "" ); - broadsword_extra1 = ri->Cvar_Get( "broadsword_extra1", "0", CVAR_NONE, "" ); - broadsword_extra2 = ri->Cvar_Get( "broadsword_extra2", "0", CVAR_NONE, "" ); - broadsword_effcorr = ri->Cvar_Get( "broadsword_effcorr", "1", CVAR_NONE, "" ); - broadsword_ragtobase = ri->Cvar_Get( "broadsword_ragtobase", "2", CVAR_NONE, "" ); - broadsword_dircap = ri->Cvar_Get( "broadsword_dircap", "64", CVAR_NONE, "" ); + r_noServerGhoul2 = ri.Cvar_Get( "r_noserverghoul2", "0", CVAR_CHEAT, "" ); + r_Ghoul2AnimSmooth = ri.Cvar_Get( "r_ghoul2animsmooth", "0.3", CVAR_NONE, "" ); + r_Ghoul2UnSqashAfterSmooth = ri.Cvar_Get( "r_ghoul2unsqashaftersmooth", "1", CVAR_NONE, "" ); + broadsword = ri.Cvar_Get( "broadsword", "0", CVAR_ARCHIVE, "" ); + broadsword_kickbones = ri.Cvar_Get( "broadsword_kickbones", "1", CVAR_NONE, "" ); + broadsword_kickorigin = ri.Cvar_Get( "broadsword_kickorigin", "1", CVAR_NONE, "" ); + broadsword_dontstopanim = ri.Cvar_Get( "broadsword_dontstopanim", "0", CVAR_NONE, "" ); + broadsword_waitforshot = ri.Cvar_Get( "broadsword_waitforshot", "0", CVAR_NONE, "" ); + broadsword_playflop = ri.Cvar_Get( "broadsword_playflop", "1", CVAR_NONE, "" ); + broadsword_smallbbox = ri.Cvar_Get( "broadsword_smallbbox", "0", CVAR_NONE, "" ); + broadsword_extra1 = ri.Cvar_Get( "broadsword_extra1", "0", CVAR_NONE, "" ); + broadsword_extra2 = ri.Cvar_Get( "broadsword_extra2", "0", CVAR_NONE, "" ); + broadsword_effcorr = ri.Cvar_Get( "broadsword_effcorr", "1", CVAR_NONE, "" ); + broadsword_ragtobase = ri.Cvar_Get( "broadsword_ragtobase", "2", CVAR_NONE, "" ); + broadsword_dircap = ri.Cvar_Get( "broadsword_dircap", "64", CVAR_NONE, "" ); /* Ghoul2 Insert End */ - se_language = ri->Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "" ); + se_language = ri.Cvar_Get ( "se_language", "english", CVAR_ARCHIVE | CVAR_NORESTART, "" ); for ( size_t i = 0; i < numCommands; i++ ) - ri->Cmd_AddCommand( commands[i].cmd, commands[i].func, "" ); + ri.Cmd_AddCommand( commands[i].cmd, commands[i].func, "" ); } void R_InitQueries(void) @@ -1733,7 +1733,7 @@ void R_Init( void ) { byte *ptr; int i; - ri->Printf( PRINT_ALL, "----- R_Init -----\n" ); + ri.Printf( PRINT_ALL, "----- R_Init -----\n" ); // clear all our internal state Com_Memset( &tr, 0, sizeof( tr ) ); @@ -1777,7 +1777,7 @@ void R_Init( void ) { max_polys = Q_min( r_maxpolys->integer, DEFAULT_MAX_POLYS ); max_polyverts = Q_min( r_maxpolyverts->integer, DEFAULT_MAX_POLYVERTS ); - ptr = (byte*)ri->Hunk_Alloc( + ptr = (byte*)ri.Hunk_Alloc( sizeof( *backEndData ) + sizeof(srfPoly_t) * max_polys + sizeof(polyVert_t) * max_polyverts + @@ -1833,14 +1833,14 @@ void R_Init( void ) { #if defined(_DEBUG) GLenum err = qglGetError(); if ( err != GL_NO_ERROR ) - ri->Printf( PRINT_ALL, "glGetError() = 0x%x\n", err ); + ri.Printf( PRINT_ALL, "glGetError() = 0x%x\n", err ); #endif RestoreGhoul2InfoArray(); // print info GfxInfo_f(); - ri->Printf( PRINT_ALL, "----- finished R_Init -----\n" ); + ri.Printf( PRINT_ALL, "----- finished R_Init -----\n" ); } /* @@ -1850,10 +1850,10 @@ RE_Shutdown */ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { - ri->Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); + ri.Printf( PRINT_ALL, "RE_Shutdown( %i )\n", destroyWindow ); for ( size_t i = 0; i < numCommands; i++ ) - ri->Cmd_RemoveCommand( commands[i].cmd ); + ri.Cmd_RemoveCommand( commands[i].cmd ); R_ShutdownBackEndFrameData(); @@ -1870,8 +1870,8 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { if ( destroyWindow && restarting ) { - ri->Z_Free((void *)glConfig.extensions_string); - ri->Z_Free((void *)glConfigExt.originalExtensionString); + ri.Z_Free((void *)glConfig.extensions_string); + ri.Z_Free((void *)glConfigExt.originalExtensionString); qglDeleteVertexArrays(1, &tr.globalVao); SaveGhoul2InfoArray(); @@ -1880,7 +1880,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { // shut down platform specific OpenGL stuff if ( destroyWindow ) { - ri->WIN_Shutdown(); + ri.WIN_Shutdown(); } tr.registered = qfalse; @@ -1896,7 +1896,7 @@ Touch all images to make sure they are resident */ void RE_EndRegistration( void ) { R_IssuePendingRenderCommands(); - if (!ri->Sys_LowPhysicalMemory()) { + if (!ri.Sys_LowPhysicalMemory()) { RB_ShowImages(); } } @@ -1957,7 +1957,7 @@ void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) if( bDeleteModels ) CModelCache->DeleteAll(); - else if( ri->Cvar_VariableIntegerValue( "sv_pure" ) ) + else if( ri.Cvar_VariableIntegerValue( "sv_pure" ) ) CModelCache->DumpNonPure(); tr.numBSPModels = 0; @@ -1978,8 +1978,8 @@ int C_GetLevel( void ) void C_LevelLoadEnd( void ) { CModelCache->LevelLoadEnd( qfalse ); - ri->SND_RegisterAudio_LevelLoadEnd( qfalse ); - ri->S_RestartMusic(); + ri.SND_RegisterAudio_LevelLoadEnd( qfalse ); + ri.S_RestartMusic(); } /* @@ -1993,12 +1993,12 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { static refexport_t re; assert( rimp ); - ri = rimp; + ri = *rimp; Com_Memset( &re, 0, sizeof( re ) ); if ( apiVersion != REF_API_VERSION ) { - ri->Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", + ri.Printf(PRINT_ALL, "Mismatched REF_API_VERSION: expected %i, got %i\n", REF_API_VERSION, apiVersion ); return NULL; } diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 9798ca38b7..f2b6e27329 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -320,7 +320,7 @@ static void LogLight( trRefEntity_t *ent ) { max2 = ent->directedLight[2]; } - ri->Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); + ri.Printf( PRINT_ALL, "amb:%i dir:%i\n", max1, max2 ); } /* diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 60c68e1c5c..1378fff3b7 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -40,7 +40,7 @@ static float s_flipMatrix[16] = { }; -refimport_t *ri = NULL; +refimport_t ri; // entities that will have procedurally generated surfaces will just // point at this for their sorting surface @@ -1340,7 +1340,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, // to see a surface before the server has communicated the matching // portal surface entity, so we don't want to print anything here... - //ri->Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); + //ri.Printf( PRINT_ALL, "Portal surface without a portal entity\n" ); return qfalse; } @@ -1528,7 +1528,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { // don't recursively mirror if (tr.viewParms.isPortal) { - ri->Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); + ri.Printf( PRINT_DEVELOPER, "WARNING: recursive mirror/portal found\n" ); return qfalse; } @@ -1843,7 +1843,7 @@ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { // no shader should ever have this sort type if ( shader->sort == SS_BAD ) { - ri->Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); + ri.Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); } // if the mirror was completely clipped away, we may need to check another surface @@ -1959,7 +1959,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int 0 /* cubeMap */ ); break; default: - ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); + ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); break; } } @@ -1976,7 +1976,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int 0 /* cubeMap */ ); break; default: - ri->Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); + ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad reType" ); } } @@ -2083,7 +2083,7 @@ void R_DebugGraphics( void ) { GL_Bind( tr.whiteImage); GL_Cull( CT_FRONT_SIDED ); - ri->CM_DrawDebugSurface( R_DebugPolygon ); + ri.CM_DrawDebugSurface( R_DebugPolygon ); } @@ -2748,8 +2748,8 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) lightviewBounds[1][2] = floor(lightviewBounds[1][2]); VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); - //ri->Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); - //ri->Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); + //ri.Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); + //ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); } diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 90c20e7b4e..149bbc38f4 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -310,7 +310,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { || (ent->e.frame < 0) || (ent->e.oldframe >= tr.currentModel->data.mdv[0]->numFrames) || (ent->e.oldframe < 0) ) { - ri->Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", + ri.Printf( PRINT_DEVELOPER, "R_AddMD3Surfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; @@ -371,10 +371,10 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { } } if (shader == tr.defaultShader) { - ri->Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); + ri.Printf( PRINT_DEVELOPER, "WARNING: no shader for surface %s in skin %s\n", surface->name, skin->name); } else if (shader->defaultShader) { - ri->Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); + ri.Printf( PRINT_DEVELOPER, "WARNING: shader %s in skin %s not found\n", shader->name, skin->name); } //} else if ( surface->numShaders <= 0 ) { //shader = tr.defaultShader; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 0553e643d4..c12f079643 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -86,7 +86,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) loaded = R_LoadMDXM(mod, buf, name, bAlreadyCached); break; default: - ri->Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); + ri.Printf(PRINT_WARNING, "R_RegisterMD3: unknown ident for %s\n", name); break; } @@ -113,7 +113,7 @@ qhandle_t R_RegisterMD3(const char *name, model_t *mod) } #ifdef _DEBUG - ri->Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); + ri.Printf(PRINT_WARNING,"R_RegisterMD3: couldn't load %s\n", name); #endif mod->type = MOD_BAD; @@ -135,7 +135,7 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) qboolean loaded = qfalse; int filesize; - filesize = ri->FS_ReadFile(name, (void **) &buf.v); + filesize = ri.FS_ReadFile(name, (void **) &buf.v); if(!buf.u) { mod->type = MOD_BAD; @@ -146,11 +146,11 @@ qhandle_t R_RegisterMDR(const char *name, model_t *mod) if(ident == MDR_IDENT) loaded = R_LoadMDR(mod, buf.u, filesize, name); - ri->FS_FreeFile (buf.v); + ri.FS_FreeFile (buf.v); if(!loaded) { - ri->Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); + ri.Printf(PRINT_WARNING,"R_RegisterMDR: couldn't load mdr file %s\n", name); mod->type = MOD_BAD; return 0; } @@ -172,7 +172,7 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) qboolean loaded = qfalse; int filesize; - filesize = ri->FS_ReadFile(name, (void **) &buf.v); + filesize = ri.FS_ReadFile(name, (void **) &buf.v); if(!buf.u) { mod->type = MOD_BAD; @@ -181,11 +181,11 @@ qhandle_t R_RegisterIQM(const char *name, model_t *mod) loaded = R_LoadIQM(mod, buf.u, filesize, name); - ri->FS_FreeFile (buf.v); + ri.FS_FreeFile (buf.v); if(!loaded) { - ri->Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); + ri.Printf(PRINT_WARNING,"R_RegisterIQM: couldn't load iqm file %s\n", name); mod->type = MOD_BAD; return 0; } @@ -247,7 +247,7 @@ model_t *R_AllocModel( void ) { return NULL; } - mod = (model_t *)ri->Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); + mod = (model_t *)ri.Hunk_Alloc( sizeof( *tr.models[tr.numModels] ), h_low ); mod->index = tr.numModels; tr.models[tr.numModels] = mod; tr.numModels++; @@ -302,12 +302,12 @@ qhandle_t RE_RegisterModel( const char *name ) { char altName[ MAX_QPATH ]; if ( !name || !name[0] ) { - ri->Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); + ri.Printf( PRINT_ALL, "RE_RegisterModel: NULL name\n" ); return 0; } if ( strlen( name ) >= MAX_QPATH ) { - ri->Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Model name exceeds MAX_QPATH\n" ); return 0; } @@ -330,7 +330,7 @@ qhandle_t RE_RegisterModel( const char *name ) { // allocate a new model_t if ( ( mod = R_AllocModel() ) == NULL ) { - ri->Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); + ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); return 0; } @@ -398,7 +398,7 @@ qhandle_t RE_RegisterModel( const char *name ) { { if( orgNameFailed ) { - ri->Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", + ri.Printf( PRINT_DEVELOPER, "WARNING: %s not present, using %s instead\n", name, altName ); } @@ -456,7 +456,7 @@ qboolean R_LoadMDXA_Server( model_t *mod, void *buffer, const char *mod_name, qb if (!bAlreadyFound) { // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the - // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // bool reference passed into this function to true, to tell the caller NOT to do an ri.FS_Freefile since // we've hijacked that memory block... // // Aaaargh. Kill me now... @@ -522,7 +522,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb qboolean bAlreadyFound = qfalse; mdxm = (mdxmHeader_t*)CModelCache->Allocate( size, buffer, mod_name, &bAlreadyFound, TAG_MODEL_GLM ); - mod->data.glm = (mdxmData_t *)ri->Hunk_Alloc (sizeof (mdxmData_t), h_low); + mod->data.glm = (mdxmData_t *)ri.Hunk_Alloc (sizeof (mdxmData_t), h_low); mod->data.glm->header = mdxm; assert(bAlreadyCached == bAlreadyFound); // I should probably eliminate 'bAlreadyFound', but wtf? @@ -530,7 +530,7 @@ qboolean R_LoadMDXM_Server( model_t *mod, void *buffer, const char *mod_name, qb if (!bAlreadyFound) { // horrible new hackery, if !bAlreadyFound then we've just done a tag-morph, so we need to set the - // bool reference passed into this function to true, to tell the caller NOT to do an ri->FS_Freefile since + // bool reference passed into this function to true, to tell the caller NOT to do an ri.FS_Freefile since // we've hijacked that memory block... // // Aaaargh. Kill me now... @@ -684,7 +684,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) loaded = R_LoadMDXM_Server(mod, buf, namebuf, bAlreadyCached); break; default: - //ri->Printf(PRINT_WARNING, "R_RegisterMDX_Server: unknown ident for %s\n", name); + //ri.Printf(PRINT_WARNING, "R_RegisterMDX_Server: unknown ident for %s\n", name); break; } @@ -711,7 +711,7 @@ qhandle_t R_RegisterMDX_Server(const char *name, model_t *mod) } /*#ifdef _DEBUG - ri->Printf(PRINT_WARNING,"R_RegisterMDX_Server: couldn't load %s\n", name); + ri.Printf(PRINT_WARNING,"R_RegisterMDX_Server: couldn't load %s\n", name); #endif*/ mod->type = MOD_BAD; @@ -743,7 +743,7 @@ qhandle_t RE_RegisterServerModel( const char *name ) { if (!r_noServerGhoul2) { //keep it from choking when it gets to these checks in the g2 code. Registering all r_ cvars for the server would be a Bad Thing though. - r_noServerGhoul2 = ri->Cvar_Get( "r_noserverghoul2", "0", 0, ""); + r_noServerGhoul2 = ri.Cvar_Get( "r_noserverghoul2", "0", 0, ""); } if ( !name || !name[0] ) { @@ -768,7 +768,7 @@ qhandle_t RE_RegisterServerModel( const char *name ) { // allocate a new model_t if ( ( mod = R_AllocModel() ) == NULL ) { - ri->Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); + ri.Printf( PRINT_WARNING, "RE_RegisterModel: R_AllocModel() failed for '%s'\n", name); return 0; } @@ -852,14 +852,14 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN version = LittleLong(md3Model->version); if(version != MD3_VERSION) { - ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has wrong version (%i should be %i)\n", modName, version, MD3_VERSION); return qfalse; } mod->type = MOD_MESH; size = LittleLong(md3Model->ofsEnd); mod->dataSize += size; - //mdvModel = mod->mdv[lod] = (mdvModel_t *)ri->Hunk_Alloc(sizeof(mdvModel_t), h_low); + //mdvModel = mod->mdv[lod] = (mdvModel_t *)ri.Hunk_Alloc(sizeof(mdvModel_t), h_low); qboolean bAlreadyFound = qfalse; mdvModel = mod->data.mdv[lod] = (mdvModel_t *)CModelCache->Allocate( size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3 ); @@ -883,13 +883,13 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN if(md3Model->numFrames < 1) { - ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has no frames\n", modName); return qfalse; } // swap all the frames mdvModel->numFrames = md3Model->numFrames; - mdvModel->frames = frame = (mdvFrame_t *)ri->Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); + mdvModel->frames = frame = (mdvFrame_t *)ri.Hunk_Alloc(sizeof(*frame) * md3Model->numFrames, h_low); md3Frame = (md3Frame_t *) ((byte *) md3Model + md3Model->ofsFrames); for(i = 0; i < md3Model->numFrames; i++, frame++, md3Frame++) @@ -905,7 +905,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN // swap all the tags mdvModel->numTags = md3Model->numTags; - mdvModel->tags = tag = (mdvTag_t *)ri->Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); + mdvModel->tags = tag = (mdvTag_t *)ri.Hunk_Alloc(sizeof(*tag) * (md3Model->numTags * md3Model->numFrames), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags * md3Model->numFrames; i++, tag++, md3Tag++) @@ -920,7 +920,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN } - mdvModel->tagNames = tagName = (mdvTagName_t *)ri->Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); + mdvModel->tagNames = tagName = (mdvTagName_t *)ri.Hunk_Alloc(sizeof(*tagName) * (md3Model->numTags), h_low); md3Tag = (md3Tag_t *) ((byte *) md3Model + md3Model->ofsTags); for(i = 0; i < md3Model->numTags; i++, tagName++, md3Tag++) @@ -930,7 +930,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN // swap all the surfaces mdvModel->numSurfaces = md3Model->numSurfaces; - mdvModel->surfaces = surf = (mdvSurface_t *)ri->Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); + mdvModel->surfaces = surf = (mdvSurface_t *)ri.Hunk_Alloc(sizeof(*surf) * md3Model->numSurfaces, h_low); md3Surf = (md3Surface_t *) ((byte *) md3Model + md3Model->ofsSurfaces); for(i = 0; i < md3Model->numSurfaces; i++) @@ -949,14 +949,14 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN if(md3Surf->numVerts >= SHADER_MAX_VERTEXES) { - ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i verts on %s (%i).\n", modName, SHADER_MAX_VERTEXES - 1, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numVerts ); return qfalse; } if(md3Surf->numTriangles * 3 >= SHADER_MAX_INDEXES) { - ri->Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadMD3: %s has more than %i triangles on %s (%i).\n", modName, ( SHADER_MAX_INDEXES / 3 ) - 1, md3Surf->name[0] ? md3Surf->name : "a surface", md3Surf->numTriangles ); return qfalse; @@ -984,7 +984,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN // register the shaders surf->numShaderIndexes = md3Surf->numShaders; - surf->shaderIndexes = shaderIndex = (int *)ri->Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); + surf->shaderIndexes = shaderIndex = (int *)ri.Hunk_Alloc(sizeof(*shaderIndex) * md3Surf->numShaders, h_low); md3Shader = (md3Shader_t *) ((byte *) md3Surf + md3Surf->ofsShaders); for(j = 0; j < md3Surf->numShaders; j++, shaderIndex++, md3Shader++) @@ -1004,7 +1004,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN // swap all the triangles surf->numIndexes = md3Surf->numTriangles * 3; - surf->indexes = tri = (glIndex_t *)ri->Hunk_Alloc(sizeof(*tri) * 3 * md3Surf->numTriangles, h_low); + surf->indexes = tri = (glIndex_t *)ri.Hunk_Alloc(sizeof(*tri) * 3 * md3Surf->numTriangles, h_low); md3Tri = (md3Triangle_t *) ((byte *) md3Surf + md3Surf->ofsTriangles); for(j = 0; j < md3Surf->numTriangles; j++, tri += 3, md3Tri++) @@ -1016,7 +1016,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN // swap all the XyzNormals surf->numVerts = md3Surf->numVerts; - surf->verts = v = (mdvVertex_t *)ri->Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); + surf->verts = v = (mdvVertex_t *)ri.Hunk_Alloc(sizeof(*v) * (md3Surf->numVerts * md3Surf->numFrames), h_low); md3xyz = (md3XyzNormal_t *) ((byte *) md3Surf + md3Surf->ofsXyzNormals); for(j = 0; j < md3Surf->numVerts * md3Surf->numFrames; j++, md3xyz++, v++) @@ -1045,7 +1045,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN } // swap all the ST - surf->st = st = (mdvSt_t *)ri->Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); + surf->st = st = (mdvSt_t *)ri.Hunk_Alloc(sizeof(*st) * md3Surf->numVerts, h_low); md3st = (md3St_t *) ((byte *) md3Surf + md3Surf->ofsSt); for(j = 0; j < md3Surf->numVerts; j++, md3st++, st++) @@ -1116,7 +1116,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN srfVBOMDVMesh_t *vboSurf; mdvModel->numVBOSurfaces = mdvModel->numSurfaces; - mdvModel->vboSurfaces = (srfVBOMDVMesh_t *)ri->Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); + mdvModel->vboSurfaces = (srfVBOMDVMesh_t *)ri.Hunk_Alloc(sizeof(*mdvModel->vboSurfaces) * mdvModel->numSurfaces, h_low); vboSurf = mdvModel->vboSurfaces; surf = mdvModel->surfaces; @@ -1237,7 +1237,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char pinmodel->version = LittleLong(pinmodel->version); if (pinmodel->version != MDR_VERSION) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has wrong version (%i should be %i)\n", mod_name, pinmodel->version, MDR_VERSION); return qfalse; } @@ -1245,7 +1245,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if(size > filesize) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: Header of %s is broken. Wrong filesize declared!\n", mod_name); return qfalse; } @@ -1269,12 +1269,12 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if(pinmodel->numBones < 0 || sizeof(*mdr) + pinmodel->numFrames * (sizeof(*frame) + (pinmodel->numBones - 1) * sizeof(*frame->bones)) > size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } mod->dataSize += size; - mod->data.mdr = mdr = (mdrHeader_t*)ri->Hunk_Alloc( size, h_low ); + mod->data.mdr = mdr = (mdrHeader_t*)ri.Hunk_Alloc( size, h_low ); // Copy all the values over from the file and fix endian issues in the process, if necessary. @@ -1291,7 +1291,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char if ( mdr->numFrames < 1 ) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has no frames\n", mod_name); return qfalse; } @@ -1383,7 +1383,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if((byte *) (lod + 1) > (byte *) mdr + size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1399,7 +1399,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if((byte *) (surf + 1) > (byte *) mdr + size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1418,14 +1418,14 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // now do the checks that may fail. if ( surf->numVerts >= SHADER_MAX_VERTEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES-1, surf->name[0] ? surf->name : "a surface", surf->numVerts ); return qfalse; } if ( surf->numTriangles*3 >= SHADER_MAX_INDEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has more than %i triangles on %s (%i).\n", mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, surf->name[0] ? surf->name : "a surface", surf->numTriangles ); return qfalse; @@ -1453,7 +1453,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(curv->numWeights < 0 || (byte *) (v + 1) + (curv->numWeights - 1) * sizeof(*weight) > (byte *) mdr + size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1494,7 +1494,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(surf->numTriangles < 0 || (byte *) (tri + surf->numTriangles) > (byte *) mdr + size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1532,7 +1532,7 @@ static qboolean R_LoadMDR( model_t *mod, void *buffer, int filesize, const char // simple bounds check if(mdr->numTags < 0 || (byte *) (tag + mdr->numTags) > (byte *) mdr + size) { - ri->Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); + ri.Printf(PRINT_WARNING, "R_LoadMDR: %s has broken structure.\n", mod_name); return qfalse; } @@ -1637,14 +1637,14 @@ void R_Modellist_f( void ) { lods++; } } - ri->Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); + ri.Printf( PRINT_ALL, "%8i : (%i) %s\n",mod->dataSize, lods, mod->name ); total += mod->dataSize; } - ri->Printf( PRINT_ALL, "%8i : Total models\n", total ); + ri.Printf( PRINT_ALL, "%8i : Total models\n", total ); #if 0 // not working right with new hunk if ( tr.world ) { - ri->Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); + ri.Printf( PRINT_ALL, "\n%8i : %s\n", tr.world->dataSize, tr.world->name ); } #endif } diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index fd12d4b985..f161cbb4f9 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -163,7 +163,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na LL( header->version ); if( header->version != IQM_VERSION ) { - ri->Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s is a unsupported IQM version (%d), only version %d is supported.\n", mod_name, header->version, IQM_VERSION); return qfalse; } @@ -201,7 +201,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // check ioq3 joint limit if ( header->num_joints > IQM_MAX_JOINTS ) { - ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %d joints (%d).\n", mod_name, IQM_MAX_JOINTS, header->num_joints); return qfalse; } @@ -339,14 +339,14 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na // check ioq3 limits if ( mesh->num_vertexes >= SHADER_MAX_VERTEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i verts on %s (%i).\n", mod_name, SHADER_MAX_VERTEXES-1, meshName[0] ? meshName : "a surface", mesh->num_vertexes ); return qfalse; } if ( mesh->num_triangles*3 >= SHADER_MAX_INDEXES ) { - ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has more than %i triangles on %s (%i).\n", mod_name, ( SHADER_MAX_INDEXES / 3 ) - 1, meshName[0] ? meshName : "a surface", mesh->num_triangles ); return qfalse; @@ -363,7 +363,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } if( header->num_poses != header->num_joints && header->num_poses != 0 ) { - ri->Printf(PRINT_WARNING, "R_LoadIQM: %s has %d poses and %d joints, must have the same number or 0 poses\n", + ri.Printf(PRINT_WARNING, "R_LoadIQM: %s has %d poses and %d joints, must have the same number or 0 poses\n", mod_name, header->num_poses, header->num_joints ); return qfalse; } @@ -483,7 +483,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na } mod->type = MOD_IQM; - iqmData = (iqmData_t *)ri->Hunk_Alloc( size, h_low ); + iqmData = (iqmData_t *)ri.Hunk_Alloc( size, h_low ); mod->data.iqm = iqmData; // fill header @@ -866,7 +866,7 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { || (ent->e.frame < 0) || (ent->e.oldframe >= data->num_frames) || (ent->e.oldframe < 0) ) { - ri->Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", + ri.Printf( PRINT_DEVELOPER, "R_AddIQMSurfaces: no such frame %d to %d for '%s'\n", ent->e.oldframe, ent->e.frame, tr.currentModel->name ); ent->e.frame = 0; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index e356cf481f..4c3d8f135c 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -293,7 +293,7 @@ static qboolean RB_UpdateSunFlareVis(void) break; } - ri->Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); + ri.Printf(PRINT_DEVELOPER, "Waited %d iterations\n", iter); } qglGetQueryObjectuiv(tr.sunFlareQuery[tr.sunFlareQueryIndex], GL_QUERY_RESULT, &sampleCount); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 1b08e97a23..cdbc6e551b 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -126,7 +126,7 @@ void RE_AddPolyToScene( qhandle_t hShader, int numVerts, const polyVert_t *verts for ( j = 0; j < numPolys; j++ ) { if ( (r_numpolyverts + numVerts) > max_polyverts || r_numpolys >= max_polys ) { - ri->Printf( + ri.Printf( PRINT_DEVELOPER, S_COLOR_YELLOW "WARNING: RE_AddPolyToScene: r_max_polys or r_max_polyverts reached\n"); return; @@ -194,19 +194,19 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { return; } if ( r_numentities >= MAX_REFENTITIES ) { - ri->Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); + ri.Printf(PRINT_DEVELOPER, "RE_AddRefEntityToScene: Dropping refEntity, reached MAX_REFENTITIES\n"); return; } if ( Q_isnan(ent->origin[0]) || Q_isnan(ent->origin[1]) || Q_isnan(ent->origin[2]) ) { static qboolean firstTime = qtrue; if (firstTime) { firstTime = qfalse; - ri->Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); + ri.Printf( PRINT_WARNING, "RE_AddRefEntityToScene passed a refEntity which has an origin with a NaN component\n"); } return; } if ( (int)ent->reType < 0 || ent->reType >= RT_MAX_REF_ENTITY_TYPE ) { - ri->Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); + ri.Error( ERR_DROP, "RE_AddRefEntityToScene: bad reType %i", ent->reType ); } backEndData->entities[r_numentities].e = *ent; @@ -478,10 +478,10 @@ void RE_RenderScene( const refdef_t *fd ) { return; } - startTime = ri->Milliseconds(); + startTime = ri.Milliseconds(); if (!tr.world && !( fd->rdflags & RDF_NOWORLDMODEL ) ) { - ri->Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); + ri.Error (ERR_DROP, "R_RenderScene: NULL worldmodel"); } RE_BeginScene(fd); @@ -570,5 +570,5 @@ void RE_RenderScene( const refdef_t *fd ) { RE_EndScene(); - tr.frontEndMsec += ri->Milliseconds() - startTime; + tr.frontEndMsec += ri.Milliseconds() - startTime; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ff88cdfa00..4447722a38 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -86,8 +86,8 @@ void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { if ( bundle->isVideoMap ) { int oldtmu = glState.currenttmu; GL_SelectTexture(tmu); - ri->CIN_RunCinematic(bundle->videoMapHandle); - ri->CIN_UploadCinematic(bundle->videoMapHandle); + ri.CIN_RunCinematic(bundle->videoMapHandle); + ri.CIN_UploadCinematic(bundle->videoMapHandle); GL_SelectTexture(oldtmu); return; } @@ -286,7 +286,7 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr break; default: - ri->Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); + ri.Error( ERR_DROP, "ERROR: unknown texmod '%d' in shader '%s'", bundle->texMods[tm].type, tess.shader->name ); break; } @@ -720,7 +720,7 @@ static void CaptureDrawData(const shaderCommands_t *input, shaderStage_t *stage, glState.currentVBO->vertexesVBO, glState.currentIBO->indexesVBO, numIndexes / 3); - ri->FS_Write(data, strlen(data), tr.debugFile); + ri.FS_Write(data, strlen(data), tr.debugFile); } else { @@ -736,7 +736,7 @@ static void CaptureDrawData(const shaderCommands_t *input, shaderStage_t *stage, glState.currentVBO->vertexesVBO, glState.currentIBO->indexesVBO, input->numIndexes / 3); - ri->FS_Write(data, strlen(data), tr.debugFile); + ri.FS_Write(data, strlen(data), tr.debugFile); } } @@ -1907,10 +1907,10 @@ void RB_EndSurface( void ) { } if (input->indexes[SHADER_MAX_INDEXES-1] != 0) { - ri->Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); + ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit"); } if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) { - ri->Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); + ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); } if ( tess.shader == tr.shadowShader ) { diff --git a/codemp/rd-rend2/tr_shade_calc.cpp b/codemp/rd-rend2/tr_shade_calc.cpp index 14f43851f9..840bc8087a 100644 --- a/codemp/rd-rend2/tr_shade_calc.cpp +++ b/codemp/rd-rend2/tr_shade_calc.cpp @@ -45,7 +45,7 @@ static float *TableForFunc( genFunc_t func ) break; } - ri->Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); + ri.Error( ERR_DROP, "TableForFunc called with invalid function '%d' in shader '%s'", func, tess.shader->name ); return NULL; } @@ -371,10 +371,10 @@ static void AutospriteDeform( void ) { vec3_t leftDir, upDir; if ( tess.numVertexes & 3 ) { - ri->Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); + ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd vertex count\n", tess.shader->name ); } if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri->Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); + ri.Printf( PRINT_WARNING, "Autosprite shader %s had odd index count\n", tess.shader->name ); } oldVerts = tess.numVertexes; @@ -449,10 +449,10 @@ static void Autosprite2Deform( void ) { vec3_t forward; if ( tess.numVertexes & 3 ) { - ri->Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); + ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd vertex count\n", tess.shader->name ); } if ( tess.numIndexes != ( tess.numVertexes >> 2 ) * 6 ) { - ri->Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); + ri.Printf( PRINT_WARNING, "Autosprite2 shader %s had odd index count\n", tess.shader->name ); } if ( backEnd.currentEntity != &tr.worldEntity ) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 9c6307d611..dc48a4695a 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -169,7 +169,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char sh = R_GetShaderByHandle(h); } if (sh == NULL || sh == tr.defaultShader) { - ri->Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); + ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: shader %s not found\n", shaderName ); return; } @@ -180,7 +180,7 @@ void R_RemapShader(const char *shaderName, const char *newShaderName, const char } if (sh2 == NULL || sh2 == tr.defaultShader) { - ri->Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); + ri.Printf( PRINT_WARNING, "WARNING: R_RemapShader: new shader %s not found\n", newShaderName ); return; } @@ -214,14 +214,14 @@ static qboolean ParseVector( const char **text, int count, float *v ) { // FIXME: spaces are currently required after parens, should change parseext... token = COM_ParseExt( text, qfalse ); if ( strcmp( token, "(" ) ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); return qfalse; } for ( i = 0 ; i < count ; i++ ) { token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing vector element in shader '%s'\n", shader.name ); return qfalse; } v[i] = atof( token ); @@ -229,7 +229,7 @@ static qboolean ParseVector( const char **text, int count, float *v ) { token = COM_ParseExt( text, qfalse ); if ( strcmp( token, ")" ) ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parenthesis in shader '%s'\n", shader.name ); return qfalse; } @@ -255,7 +255,7 @@ static void ParseAlphaTestFunc( shaderStage_t *stage, const char *funcname ) else if ( !Q_stricmp( funcname, "GE192" ) ) stage->alphaTestType = ALPHA_TEST_GE192; else - ri->Printf( PRINT_WARNING, + ri.Printf( PRINT_WARNING, "WARNING: invalid alphaFunc name '%s' in shader '%s'\n", funcname, shader.name ); } @@ -315,7 +315,7 @@ static int NameToSrcBlendMode( const char *name ) return GLS_SRCBLEND_ALPHA_SATURATE; } - ri->Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); return GLS_SRCBLEND_ONE; } @@ -369,7 +369,7 @@ static int NameToDstBlendMode( const char *name ) return GLS_DSTBLEND_ONE_MINUS_SRC_COLOR; } - ri->Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown blend mode '%s' in shader '%s', substituting GL_ONE\n", name, shader.name ); return GLS_DSTBLEND_ONE; } @@ -409,7 +409,7 @@ static genFunc_t NameToGenFunc( const char *funcname ) return GF_RAND; } - ri->Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: invalid genfunc name '%s' in shader '%s'\n", funcname, shader.name ); return GF_SIN; } @@ -426,7 +426,7 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->func = NameToGenFunc( token ); @@ -435,7 +435,7 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->base = atof( token ); @@ -443,7 +443,7 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->amplitude = atof( token ); @@ -451,7 +451,7 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->phase = atof( token ); @@ -459,7 +459,7 @@ static void ParseWaveForm( const char **text, waveForm_t *wave ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing waveform parm in shader '%s'\n", shader.name ); return; } wave->frequency = atof( token ); @@ -478,7 +478,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) texModInfo_t *tmi; if ( stage->bundle[0].numTexMods == TR_MAX_TEXMODS ) { - ri->Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); + ri.Error( ERR_DROP, "ERROR: too many tcMod stages in shader '%s'", shader.name ); return; } @@ -495,28 +495,28 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb parms in shader '%s'\n", shader.name ); return; } tmi->wave.base = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.amplitude = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.phase = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod turb in shader '%s'\n", shader.name ); return; } tmi->wave.frequency = atof( token ); @@ -531,7 +531,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); return; } tmi->scale[0] = atof( token ); @@ -539,7 +539,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing scale parms in shader '%s'\n", shader.name ); return; } tmi->scale[1] = atof( token ); @@ -553,14 +553,14 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); return; } tmi->scroll[0] = atof( token ); token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing scale scroll parms in shader '%s'\n", shader.name ); return; } tmi->scroll[1] = atof( token ); @@ -574,7 +574,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.func = NameToGenFunc( token ); @@ -582,7 +582,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.base = atof( token ); @@ -590,7 +590,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.amplitude = atof( token ); @@ -598,7 +598,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.phase = atof( token ); @@ -606,7 +606,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing stretch parms in shader '%s'\n", shader.name ); return; } tmi->wave.frequency = atof( token ); @@ -621,7 +621,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[0][0] = atof( token ); @@ -629,7 +629,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[0][1] = atof( token ); @@ -637,7 +637,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[1][0] = atof( token ); @@ -645,7 +645,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->matrix[1][1] = atof( token ); @@ -653,7 +653,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->translate[0] = atof( token ); @@ -661,7 +661,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing transform parms in shader '%s'\n", shader.name ); return; } tmi->translate[1] = atof( token ); @@ -676,7 +676,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing tcMod rotate parms in shader '%s'\n", shader.name ); return; } tmi->rotateSpeed = atof( token ); @@ -691,7 +691,7 @@ static void ParseTexMod( const char *_text, shaderStage_t *stage ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown tcMod '%s' in shader '%s'\n", token, shader.name ); } } @@ -718,7 +718,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == '\0' ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", shader.name); return false; @@ -742,7 +742,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) } else { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid type in shader '%s'\n", shader.name); return false; @@ -752,7 +752,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == '\0' ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", shader.name); return false; @@ -761,7 +761,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) float width = atof(token); if ( width <= 0.0f ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid width in shader '%s'\n", shader.name); return false; @@ -771,7 +771,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == '\0' ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", shader.name); return false; @@ -780,7 +780,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) float height = atof(token); if ( height <= 0.0f ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid height in shader '%s'\n", shader.name); return false; @@ -790,7 +790,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == '\0' ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", shader.name); return false; @@ -799,7 +799,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) float density = atof(token); if ( density <= 0.0f ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid density in shader '%s'\n", shader.name); return false; @@ -809,7 +809,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) token = COM_ParseExt( text, qfalse ); if ( token[0] == '\0' ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfaceSprites params in shader '%s'\n", shader.name); return false; @@ -818,7 +818,7 @@ static bool ParseSurfaceSprites( const char *buffer, shaderStage_t *stage ) float fadedist = atof(token); if ( fadedist < 32.0f ) { - ri->Printf(PRINT_ALL, + ri.Printf(PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid fadedist (%.2f < 32) in shader '%s'\n", fadedist, shader.name); return false; @@ -899,13 +899,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fademax in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fademax in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value <= stage->ss->fadeDist) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fademax (%.2f <= fadeDist(%.2f)) in shader '%s'\n", value, stage->ss->fadeDist, shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fademax (%.2f <= fadeDist(%.2f)) in shader '%s'\n", value, stage->ss->fadeDist, shader.name ); return false; } stage->ss->fadeMax=value; @@ -920,7 +920,7 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fadescale in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fadescale in shader '%s'\n", shader.name ); return false; } value = atof(token); @@ -936,13 +936,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance width in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance width in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance width in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance width in shader '%s'\n", shader.name ); return false; } stage->ss->variance[0]=value; @@ -950,13 +950,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance height in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite variance height in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance height in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite variance height in shader '%s'\n", shader.name ); return false; } stage->ss->variance[1]=value; @@ -970,7 +970,7 @@ static bool ParseSurfaceSpritesOptional( { if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Hangdown facing overrides previous facing in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Hangdown facing overrides previous facing in shader '%s'\n", shader.name ); return false; } stage->ss->facing=SURFSPRITE_FACING_DOWN; @@ -984,7 +984,7 @@ static bool ParseSurfaceSpritesOptional( { if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Anyangle facing overrides previous facing in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Anyangle facing overrides previous facing in shader '%s'\n", shader.name ); return false; } stage->ss->facing=SURFSPRITE_FACING_ANY; @@ -998,7 +998,7 @@ static bool ParseSurfaceSpritesOptional( { if (stage->ss->facing != SURFSPRITE_FACING_NORMAL) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Faceup facing overrides previous facing in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: Faceup facing overrides previous facing in shader '%s'\n", shader.name ); return false; } stage->ss->facing=SURFSPRITE_FACING_UP; @@ -1013,13 +1013,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite wind in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite wind in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0.0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite wind in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite wind in shader '%s'\n", shader.name ); return false; } stage->ss->wind=value; @@ -1038,13 +1038,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite windidle in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite windidle in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0.0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite windidle in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite windidle in shader '%s'\n", shader.name ); return false; } stage->ss->windIdle=value; @@ -1059,13 +1059,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite vertskew in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite vertskew in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0.0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite vertskew in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite vertskew in shader '%s'\n", shader.name ); return false; } stage->ss->vertSkew=value; @@ -1080,13 +1080,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite duration in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite duration in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value <= 0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite duration in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite duration in shader '%s'\n", shader.name ); return false; } stage->ss->fxDuration=value; @@ -1101,13 +1101,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow width in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow width in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow width in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow width in shader '%s'\n", shader.name ); return false; } stage->ss->fxGrow[0]=value; @@ -1115,13 +1115,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow height in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite grow height in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow height in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite grow height in shader '%s'\n", shader.name ); return false; } stage->ss->fxGrow[1]=value; @@ -1136,13 +1136,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha start in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha start in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0 || value > 1.0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha start in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha start in shader '%s'\n", shader.name ); return false; } stage->ss->fxAlphaStart=value; @@ -1150,13 +1150,13 @@ static bool ParseSurfaceSpritesOptional( token = COM_ParseExt( text, qfalse); if (token[0]==0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha end in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: missing surfacesprite fxalpha end in shader '%s'\n", shader.name ); return false; } value = atof(token); if (value < 0 || value > 1.0) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha end in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid surfacesprite fxalpha end in shader '%s'\n", shader.name ); return false; } stage->ss->fxAlphaEnd=value; @@ -1170,7 +1170,7 @@ static bool ParseSurfaceSpritesOptional( { if (stage->ss->type != SURFSPRITE_EFFECT) { - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: weather applied to non-effect surfacesprite in shader '%s'\n", shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: weather applied to non-effect surfacesprite in shader '%s'\n", shader.name ); return false; } stage->ss->type = SURFSPRITE_WEATHERFX; @@ -1180,7 +1180,7 @@ static bool ParseSurfaceSpritesOptional( // // invalid ss command. // - ri->Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid optional surfacesprite param '%s' in shader '%s'\n", param, shader.name ); + ri.Printf( PRINT_ALL, S_COLOR_YELLOW "WARNING: invalid optional surfacesprite param '%s' in shader '%s'\n", param, shader.name ); return false; } @@ -1205,7 +1205,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qtrue ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); + ri.Printf( PRINT_WARNING, "WARNING: no matching '}' found\n" ); return qfalse; } @@ -1221,7 +1221,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -1235,7 +1235,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].isLightmap = qtrue; if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { #ifndef FINAL_BUILD - ri->Printf (PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); + ri.Printf (PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); #endif stage->bundle[0].image[0] = tr.whiteImage; } else { @@ -1247,7 +1247,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) { if (!tr.worldDeluxeMapping) { - ri->Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); return qfalse; } @@ -1294,7 +1294,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if ( !stage->bundle[0].image[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -1310,7 +1310,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -1344,7 +1344,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); if ( !stage->bundle[0].image[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -1357,7 +1357,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for '%s' keyword in shader '%s'\n", animMapNames[type], shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for '%s' keyword in shader '%s'\n", animMapNames[type], shader.name ); return qfalse; } stage->bundle[0].imageAnimationSpeed = atof( token ); @@ -1408,7 +1408,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].image[num] = R_FindImageFile( token, imgtype, flags ); if ( !stage->bundle[0].image[num] ) { - ri->Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } stage->bundle[0].numImageAnimations++; @@ -1420,10 +1420,10 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'videoMap' keyword in shader '%s'\n", shader.name ); return qfalse; } - stage->bundle[0].videoMapHandle = ri->CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); + stage->bundle[0].videoMapHandle = ri.CIN_PlayCinematic( token, 0, 0, 256, 256, (CIN_loop | CIN_silent | CIN_shader)); if (stage->bundle[0].videoMapHandle != -1) { stage->bundle[0].isVideoMap = qtrue; stage->bundle[0].image[0] = tr.scratchImage[stage->bundle[0].videoMapHandle]; @@ -1437,7 +1437,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'alphaFunc' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -1452,7 +1452,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'depthfunc' keyword in shader '%s'\n", shader.name ); return qfalse; } @@ -1470,7 +1470,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown depthfunc '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -1490,7 +1490,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); continue; } // check for "simple" blends first @@ -1510,7 +1510,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parm for blendFunc in shader '%s'\n", shader.name ); continue; } blendDstBits = NameToDstBlendMode( token ); @@ -1530,7 +1530,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if(token[0] == 0) { - ri->Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); + ri.Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); continue; } @@ -1558,7 +1558,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); + ri.Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); continue; } } @@ -1570,7 +1570,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular reflectance in shader '%s'\n", shader.name ); continue; } stage->specularScale[0] = @@ -1587,7 +1587,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specular exponent in shader '%s'\n", shader.name ); continue; } exponent = atof( token ); @@ -1605,7 +1605,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for gloss in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for gloss in shader '%s'\n", shader.name ); continue; } @@ -1619,7 +1619,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for parallaxDepth in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for parallaxDepth in shader '%s'\n", shader.name ); continue; } @@ -1635,7 +1635,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for normalScale in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for normalScale in shader '%s'\n", shader.name ); continue; } @@ -1670,7 +1670,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); continue; } @@ -1679,7 +1679,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt(text, qfalse); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for specularScale in shader '%s'\n", shader.name ); continue; } @@ -1714,7 +1714,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameters for rgbGen in shader '%s'\n", shader.name ); continue; } @@ -1790,7 +1790,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown rgbGen parameter '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -1802,7 +1802,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parameters for alphaGen in shader '%s'\n", shader.name ); continue; } @@ -1856,7 +1856,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if ( token[0] == 0 ) { shader.portalRange = 256; - ri->Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing range parameter for alphaGen portal in shader '%s', defaulting to 256\n", shader.name ); } else { @@ -1865,7 +1865,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown alphaGen parameter '%s' in shader '%s'\n", token, shader.name ); continue; } } @@ -1877,7 +1877,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing texgen parm in shader '%s'\n", shader.name ); continue; } @@ -1902,7 +1902,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown texgen parm in shader '%s'\n", shader.name ); } } // @@ -2004,7 +2004,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown parameter '%s' in shader '%s'\n", token, shader.name ); return qfalse; } } @@ -2072,12 +2072,12 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deform parm in shader '%s'\n", shader.name ); return; } if ( shader.numDeforms == MAX_SHADER_DEFORMS ) { - ri->Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: MAX_SHADER_DEFORMS in '%s'\n", shader.name ); return; } @@ -2114,7 +2114,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeWidth = atof( token ); @@ -2122,7 +2122,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeHeight = atof( token ); @@ -2130,7 +2130,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes bulge parm in shader '%s'\n", shader.name ); return; } ds->bulgeSpeed = atof( token ); @@ -2144,7 +2144,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } @@ -2155,7 +2155,7 @@ static void ParseDeform( const char **text ) { else { ds->deformationSpread = 100.0f; - ri->Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: illegal div value of 0 in deformVertexes command for shader '%s'\n", shader.name ); } ParseWaveForm( text, &ds->deformationWave ); @@ -2168,7 +2168,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->deformationWave.amplitude = atof( token ); @@ -2176,7 +2176,7 @@ static void ParseDeform( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->deformationWave.frequency = atof( token ); @@ -2191,7 +2191,7 @@ static void ParseDeform( const char **text ) { for ( i = 0 ; i < 3 ; i++ ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing deformVertexes parm in shader '%s'\n", shader.name ); return; } ds->moveVector[i] = atof( token ); @@ -2202,7 +2202,7 @@ static void ParseDeform( const char **text ) { return; } - ri->Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown deformVertexes subtype '%s' found in shader '%s'\n", token, shader.name ); } @@ -2229,7 +2229,7 @@ static void ParseSkyParms( const char **text ) { // outerbox token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing parameter in shader '%s'\n", shader.name ); return; } if ( strcmp( token, "-" ) ) { @@ -2249,7 +2249,7 @@ static void ParseSkyParms( const char **text ) { // cloudheight token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: 'skyParms' missing cloudheight in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: 'skyParms' missing cloudheight in shader '%s'\n", shader.name ); return; } shader.sky.cloudHeight = atof( token ); @@ -2261,7 +2261,7 @@ static void ParseSkyParms( const char **text ) { // innerbox token = COM_ParseExt( text, qfalse ); if ( strcmp( token, "-" ) ) { - ri->Printf( PRINT_WARNING, "WARNING: in shader '%s' 'skyParms', innerbox is not supported!", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: in shader '%s' 'skyParms', innerbox is not supported!", shader.name ); } shader.isSky = qtrue; @@ -2278,7 +2278,7 @@ void ParseSort( const char **text ) { token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing sort parameter in shader '%s'\n", shader.name ); return; } @@ -2438,7 +2438,7 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qtrue ); if ( token[0] != '{' ) { - ri->Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: expecting '{', found '%s' instead in shader '%s'\n", token, shader.name ); return qfalse; } @@ -2447,7 +2447,7 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qtrue ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: no concluding '}' in shader %s\n", shader.name ); return qfalse; } @@ -2460,7 +2460,7 @@ static qboolean ParseShader( const char **text ) else if ( token[0] == '{' ) { if ( s >= MAX_SHADER_STAGES ) { - ri->Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: too many stages in shader %s\n", shader.name ); return qfalse; } @@ -2530,12 +2530,12 @@ static qboolean ParseShader( const char **text ) if (tr.sunShadowScale < 0.0f) { - ri->Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 0.0.\n"); + ri.Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 0.0.\n"); tr.sunShadowScale = 0.0f; } else if (tr.sunShadowScale > 1.0f) { - ri->Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 1.0.\n"); + ri.Printf (PRINT_WARNING, "WARNING: q3gl2_sun's 'shadow scale' value must be between 0 and 1. Clamping to 1.0.\n"); tr.sunShadowScale = 1.0f; } } @@ -2643,7 +2643,7 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qfalse ); if ( !token[0] ) { - ri->Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing parm for 'fogParms' keyword in shader '%s'\n", shader.name ); continue; } shader.fogParms.depthForOpaque = atof( token ); @@ -2677,7 +2677,7 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qfalse ); if ( token[0] == 0 ) { - ri->Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: missing cull parms in shader '%s'\n", shader.name ); continue; } @@ -2691,7 +2691,7 @@ static qboolean ParseShader( const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: invalid cull parm '%s' in shader '%s'\n", token, shader.name ); } continue; } @@ -2703,7 +2703,7 @@ static qboolean ParseShader( const char **text ) } else { - ri->Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); + ri.Printf( PRINT_WARNING, "WARNING: unknown general shader parameter '%s' in '%s'\n", token, shader.name ); return qfalse; } } @@ -2927,14 +2927,14 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { int defs = 0; - //ri->Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); + //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); // reuse diffuse, mark others inactive diffuse->type = ST_GLSL; if (lightmap) { - //ri->Printf(PRINT_ALL, ", lightmap"); + //ri.Printf(PRINT_ALL, ", lightmap"); diffuse->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; defs |= LIGHTDEF_USE_LIGHTMAP; } @@ -2949,7 +2949,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap) { - //ri->Printf(PRINT_ALL, ", deluxemap"); + //ri.Printf(PRINT_ALL, ", deluxemap"); diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } @@ -2959,7 +2959,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, image_t *diffuseImg; if (normal) { - //ri->Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); + //ri.Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; @@ -2995,7 +2995,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, { if (specular) { - //ri->Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); + //ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; VectorCopy4(specular->specularScale, diffuse->specularScale); } @@ -3012,7 +3012,7 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (diffuse->alphaTestType != ALPHA_TEST_NONE) defs |= LIGHTDEF_USE_ALPHA_TEST; - //ri->Printf(PRINT_ALL, ".\n"); + //ri.Printf(PRINT_ALL, ".\n"); diffuse->glslShaderGroup = tr.lightallShader; diffuse->glslShaderIndex = defs; @@ -3024,16 +3024,16 @@ static qboolean CollapseStagesToGLSL(void) int i, j, numStages; qboolean skip = qfalse; - ri->Printf (PRINT_DEVELOPER, "Collapsing stages for shader '%s'\n", shader.name); + ri.Printf (PRINT_DEVELOPER, "Collapsing stages for shader '%s'\n", shader.name); // skip shaders with deforms if (shader.numDeforms != 0) { skip = qtrue; - ri->Printf (PRINT_DEVELOPER, "> Shader has vertex deformations. Aborting stage collapsing\n"); + ri.Printf (PRINT_DEVELOPER, "> Shader has vertex deformations. Aborting stage collapsing\n"); } - ri->Printf (PRINT_DEVELOPER, "> Original shader stage order:\n"); + ri.Printf (PRINT_DEVELOPER, "> Original shader stage order:\n"); for ( int i = 0; i < MAX_SHADER_STAGES; i++ ) { @@ -3044,7 +3044,7 @@ static qboolean CollapseStagesToGLSL(void) continue; } - ri->Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); + ri.Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); } if (!skip) @@ -3072,9 +3072,9 @@ static qboolean CollapseStagesToGLSL(void) stages[0].stateBits = stateBits0; stages[1].stateBits = stateBits1; - ri->Printf (PRINT_DEVELOPER, "> Swapped first and second stage.\n"); - ri->Printf (PRINT_DEVELOPER, "-> First stage is now: %s\n", stages[0].bundle[0].image[0]->imgName); - ri->Printf (PRINT_DEVELOPER, "-> Second stage is now: %s\n", stages[1].bundle[0].image[0]->imgName); + ri.Printf (PRINT_DEVELOPER, "> Swapped first and second stage.\n"); + ri.Printf (PRINT_DEVELOPER, "-> First stage is now: %s\n", stages[0].bundle[0].image[0]->imgName); + ri.Printf (PRINT_DEVELOPER, "-> Second stage is now: %s\n", stages[1].bundle[0].image[0]->imgName); } } } @@ -3216,7 +3216,7 @@ static qboolean CollapseStagesToGLSL(void) pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && pStage2->rgbGen != CGEN_EXACT_VERTEX) { - ri->Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); + ri.Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); lightmap = pStage2; lightmaps[j] = NULL; } @@ -3369,7 +3369,7 @@ static qboolean CollapseStagesToGLSL(void) } } - ri->Printf (PRINT_DEVELOPER, "> New shader stage order:\n"); + ri.Printf (PRINT_DEVELOPER, "> New shader stage order:\n"); for ( int i = 0; i < MAX_SHADER_STAGES; i++ ) { @@ -3380,7 +3380,7 @@ static qboolean CollapseStagesToGLSL(void) continue; } - ri->Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); + ri.Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); } return (qboolean)numStages; @@ -3533,11 +3533,11 @@ static shader_t *GeneratePermanentShader( void ) { int size, hash; if ( tr.numShaders == MAX_SHADERS ) { - ri->Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); + ri.Printf( PRINT_WARNING, "WARNING: GeneratePermanentShader - MAX_SHADERS hit\n"); return tr.defaultShader; } - newShader = (shader_t *)ri->Hunk_Alloc( sizeof( shader_t ), h_low ); + newShader = (shader_t *)ri.Hunk_Alloc( sizeof( shader_t ), h_low ); *newShader = shader; @@ -3559,12 +3559,12 @@ static shader_t *GeneratePermanentShader( void ) { if ( !stages[i].active ) { break; } - newShader->stages[i] = (shaderStage_t *)ri->Hunk_Alloc( sizeof( stages[i] ), h_low ); + newShader->stages[i] = (shaderStage_t *)ri.Hunk_Alloc( sizeof( stages[i] ), h_low ); *newShader->stages[i] = stages[i]; for ( b = 0 ; b < NUM_TEXTURE_BUNDLES ; b++ ) { size = newShader->stages[i]->bundle[b].numTexMods * sizeof( texModInfo_t ); - newShader->stages[i]->bundle[b].texMods = (texModInfo_t *)ri->Hunk_Alloc( size, h_low ); + newShader->stages[i]->bundle[b].texMods = (texModInfo_t *)ri.Hunk_Alloc( size, h_low ); Com_Memcpy( newShader->stages[i]->bundle[b].texMods, stages[i].bundle[b].texMods, size ); } } @@ -3810,7 +3810,7 @@ static shader_t *FinishShader( void ) { // check for a missing texture if ( !pStage->bundle[0].image[0] ) { - ri->Printf( PRINT_WARNING, "Shader %s, stage %d has no image. This stage will be ignored\n", shader.name, stage + 1 ); + ri.Printf( PRINT_WARNING, "Shader %s, stage %d has no image. This stage will be ignored\n", shader.name, stage + 1 ); pStage->active = qfalse; stage++; continue; @@ -3932,7 +3932,7 @@ static shader_t *FinishShader( void ) { stage = CollapseStagesToGLSL(); if ( shader.lightmapIndex[0] >= 0 && !hasLightmapStage ) { - ri->Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); + ri.Printf( PRINT_DEVELOPER, "WARNING: shader '%s' has lightmap but no lightmap stage!\n", shader.name ); // Don't set this, it will just add duplicate shaders to the hash //shader.lightmapIndex = LIGHTMAP_NONE; } @@ -4129,7 +4129,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte lightmapIndexes = lightmapsVertex; } else if ( lightmapIndexes[0] < LIGHTMAP_2D ) { // negative lightmap indexes cause stray pointers (think tr.lightmaps[lightmapIndex]) - ri->Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndexes[0] ); + ri.Printf( PRINT_WARNING, "WARNING: shader '%s' has invalid lightmap index of %d\n", name, lightmapIndexes[0] ); lightmapIndexes = lightmapsVertex; } @@ -4165,7 +4165,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte // enable this when building a pak file to get a global list // of all explicit shaders if ( r_printShaders->integer ) { - ri->Printf( PRINT_ALL, "*SHADER* %s\n", name ); + ri.Printf( PRINT_ALL, "*SHADER* %s\n", name ); } if ( !ParseShader( &shaderText ) ) { @@ -4201,7 +4201,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte image = R_FindImageFile( name, IMGTYPE_COLORALPHA, flags ); if ( !image ) { - ri->Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); + ri.Printf( PRINT_DEVELOPER, "Couldn't find image file for shader %s\n", name ); shader.defaultShader = qtrue; return FinishShader(); } @@ -4400,7 +4400,7 @@ qhandle_t RE_RegisterShaderLightMap( const char *name, const int *lightmapIndexe shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -4434,7 +4434,7 @@ qhandle_t RE_RegisterShader( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -4464,7 +4464,7 @@ qhandle_t RE_RegisterShaderNoMip( const char *name ) { shader_t *sh; if ( strlen( name ) >= MAX_QPATH ) { - ri->Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); + ri.Printf( PRINT_ALL, "Shader name exceeds MAX_QPATH\n" ); return 0; } @@ -4499,11 +4499,11 @@ it and returns a valid (possibly default) shader_t to be used internally. */ shader_t *R_GetShaderByHandle( qhandle_t hShader ) { if ( hShader < 0 ) { - ri->Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); return tr.defaultShader; } if ( hShader >= tr.numShaders ) { - ri->Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); + ri.Printf( PRINT_WARNING, "R_GetShaderByHandle: out of range hShader '%d'\n", hShader ); return tr.defaultShader; } return tr.shaders[hShader]; @@ -4522,47 +4522,47 @@ void R_ShaderList_f (void) { int count; shader_t *shader; - ri->Printf (PRINT_ALL, "-----------------------\n"); + ri.Printf (PRINT_ALL, "-----------------------\n"); count = 0; for ( i = 0 ; i < tr.numShaders ; i++ ) { - if ( ri->Cmd_Argc() > 1 ) { + if ( ri.Cmd_Argc() > 1 ) { shader = tr.sortedShaders[i]; } else { shader = tr.shaders[i]; } - ri->Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); + ri.Printf( PRINT_ALL, "%i ", shader->numUnfoggedPasses ); if (shader->lightmapIndex[0] >= 0 ) { - ri->Printf (PRINT_ALL, "L "); + ri.Printf (PRINT_ALL, "L "); } else { - ri->Printf (PRINT_ALL, " "); + ri.Printf (PRINT_ALL, " "); } if ( shader->explicitlyDefined ) { - ri->Printf( PRINT_ALL, "E " ); + ri.Printf( PRINT_ALL, "E " ); } else { - ri->Printf( PRINT_ALL, " " ); + ri.Printf( PRINT_ALL, " " ); } if ( shader->optimalStageIteratorFunc == RB_StageIteratorGeneric ) { - ri->Printf( PRINT_ALL, "gen " ); + ri.Printf( PRINT_ALL, "gen " ); } else if ( shader->optimalStageIteratorFunc == RB_StageIteratorSky ) { - ri->Printf( PRINT_ALL, "sky " ); + ri.Printf( PRINT_ALL, "sky " ); } else { - ri->Printf( PRINT_ALL, " " ); + ri.Printf( PRINT_ALL, " " ); } if ( shader->defaultShader ) { - ri->Printf (PRINT_ALL, ": %s (DEFAULTED)\n", shader->name); + ri.Printf (PRINT_ALL, ": %s (DEFAULTED)\n", shader->name); } else { - ri->Printf (PRINT_ALL, ": %s\n", shader->name); + ri.Printf (PRINT_ALL, ": %s\n", shader->name); } count++; } - ri->Printf (PRINT_ALL, "%i total shaders\n", count); - ri->Printf (PRINT_ALL, "------------------\n"); + ri.Printf (PRINT_ALL, "%i total shaders\n", count); + ri.Printf (PRINT_ALL, "------------------\n"); } /* @@ -4588,11 +4588,11 @@ static void ScanAndLoadShaderFiles( void ) long sum = 0, summand; // scan for shader files - shaderFiles = ri->FS_ListFiles( "shaders", ".shader", &numShaderFiles ); + shaderFiles = ri.FS_ListFiles( "shaders", ".shader", &numShaderFiles ); if ( !shaderFiles || !numShaderFiles ) { - ri->Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); + ri.Printf( PRINT_WARNING, "WARNING: no shader files found\n" ); return; } @@ -4614,17 +4614,17 @@ static void ScanAndLoadShaderFiles( void ) strcpy(ext, ".mtr"); } - if ( ri->FS_ReadFile( filename, NULL ) <= 0 ) + if ( ri.FS_ReadFile( filename, NULL ) <= 0 ) { Com_sprintf( filename, sizeof( filename ), "shaders/%s", shaderFiles[i] ); } } - ri->Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); - summand = ri->FS_ReadFile( filename, (void **)&buffers[i] ); + ri.Printf( PRINT_DEVELOPER, "...loading '%s'\n", filename ); + summand = ri.FS_ReadFile( filename, (void **)&buffers[i] ); if ( !buffers[i] ) - ri->Error( ERR_DROP, "Couldn't load %s", filename ); + ri.Error( ERR_DROP, "Couldn't load %s", filename ); // Do a simple check on the shader structure in that file to make sure one bad shader file cannot fuck up all other shaders. p = buffers[i]; @@ -4642,23 +4642,23 @@ static void ScanAndLoadShaderFiles( void ) token = COM_ParseExt(&p, qtrue); if(token[0] != '{' || token[1] != '\0') { - ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace", + ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing opening brace", filename, shaderName, shaderLine); if (token[0]) { - ri->Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine()); + ri.Printf(PRINT_WARNING, " (found \"%s\" on line %d)", token, COM_GetCurrentParseLine()); } - ri->Printf(PRINT_WARNING, ".\n"); - ri->FS_FreeFile(buffers[i]); + ri.Printf(PRINT_WARNING, ".\n"); + ri.FS_FreeFile(buffers[i]); buffers[i] = NULL; break; } if(!SkipBracedSection(&p, 1)) { - ri->Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", + ri.Printf(PRINT_WARNING, "WARNING: Ignoring shader file %s. Shader \"%s\" on line %d missing closing brace.\n", filename, shaderName, shaderLine); - ri->FS_FreeFile(buffers[i]); + ri.FS_FreeFile(buffers[i]); buffers[i] = NULL; break; } @@ -4670,7 +4670,7 @@ static void ScanAndLoadShaderFiles( void ) } // build single large buffer - s_shaderText = (char *)ri->Hunk_Alloc( sum + numShaderFiles*2, h_low ); + s_shaderText = (char *)ri.Hunk_Alloc( sum + numShaderFiles*2, h_low ); s_shaderText[ 0 ] = '\0'; textEnd = s_shaderText; @@ -4683,13 +4683,13 @@ static void ScanAndLoadShaderFiles( void ) strcat( textEnd, buffers[i] ); strcat( textEnd, "\n" ); textEnd += strlen( textEnd ); - ri->FS_FreeFile( buffers[i] ); + ri.FS_FreeFile( buffers[i] ); } COM_Compress( s_shaderText ); // free up memory - ri->FS_FreeFileList( shaderFiles ); + ri.FS_FreeFileList( shaderFiles ); Com_Memset(shaderTextHashTableSizes, 0, sizeof(shaderTextHashTableSizes)); size = 0; @@ -4710,7 +4710,7 @@ static void ScanAndLoadShaderFiles( void ) size += MAX_SHADERTEXT_HASH; - hashMem = (char *)ri->Hunk_Alloc( size * sizeof(char *), h_low ); + hashMem = (char *)ri.Hunk_Alloc( size * sizeof(char *), h_low ); for (i = 0; i < MAX_SHADERTEXT_HASH; i++) { shaderTextHashTable[i] = (char **) hashMem; @@ -4852,7 +4852,7 @@ R_InitShaders ================== */ void R_InitShaders( qboolean server ) { - ri->Printf( PRINT_ALL, "Initializing Shaders\n" ); + ri.Printf( PRINT_ALL, "Initializing Shaders\n" ); Com_Memset(hashTable, 0, sizeof(hashTable)); diff --git a/codemp/rd-rend2/tr_skin.cpp b/codemp/rd-rend2/tr_skin.cpp index 4b1cfa96e0..d14f211b6a 100644 --- a/codemp/rd-rend2/tr_skin.cpp +++ b/codemp/rd-rend2/tr_skin.cpp @@ -90,7 +90,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) char surfName[MAX_QPATH]; // load and parse the skin file - ri->FS_ReadFile( name, (void **)&text ); + ri.FS_ReadFile( name, (void **)&text ); if ( !text ) { #ifndef FINAL_BUILD Com_Printf( "WARNING: RE_RegisterSkin( '%s' ) failed to load!\n", name ); @@ -149,7 +149,7 @@ qhandle_t RE_RegisterIndividualSkin( const char *name , qhandle_t hSkin) skin->numSurfaces++; } - ri->FS_FreeFile( text ); + ri.FS_FreeFile( text ); // never let a skin have 0 shaders @@ -349,8 +349,8 @@ Mangled version of the above function to load .skin files on the server. qhandle_t RE_RegisterServerSkin( const char *name ) { qhandle_t r; - if (ri->Cvar_VariableIntegerValue( "cl_running" ) && - ri->Com_TheHunkMarkHasBeenMade() && + if (ri.Cvar_VariableIntegerValue( "cl_running" ) && + ri.Com_TheHunkMarkHasBeenMade() && ShaderHashTableExists()) { //If the client is running then we can go straight into the normal registerskin func return RE_RegisterSkin(name); @@ -374,10 +374,10 @@ void R_InitSkins( void ) { tr.numSkins = 1; // make the default skin have all default shaders - skin = tr.skins[0] = (struct skin_s *)ri->Hunk_Alloc( sizeof( skin_t ), h_low ); + skin = tr.skins[0] = (struct skin_s *)ri.Hunk_Alloc( sizeof( skin_t ), h_low ); Q_strncpyz( skin->name, "", sizeof( skin->name ) ); skin->numSurfaces = 1; - skin->surfaces[0] = (_skinSurface_t *)ri->Hunk_Alloc( sizeof( skinSurface_t ), h_low ); + skin->surfaces[0] = (_skinSurface_t *)ri.Hunk_Alloc( sizeof( skinSurface_t ), h_low ); skin->surfaces[0]->shader = tr.defaultShader; } diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index bf9dfd1c55..def1fad7b5 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -160,7 +160,7 @@ static void ClipSkyPolygon (int nump, vec3_t vecs, int stage) int i, j; if (nump > MAX_CLIP_VERTS-2) - ri->Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); + ri.Error (ERR_DROP, "ClipSkyPolygon: MAX_CLIP_VERTS"); if (stage == 6) { // fully clipped, so draw it AddSkyPolygon (nump, vecs); @@ -388,7 +388,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max if(tess.numVertexes >= SHADER_MAX_VERTEXES) { - ri->Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); + ri.Error(ERR_DROP, "SHADER_MAX_VERTEXES hit in DrawSkySideVBO()"); } } } @@ -402,7 +402,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max { if ((tess.numIndexes + 6) >= SHADER_MAX_INDEXES) { - ri->Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); + ri.Error(ERR_DROP, "SHADER_MAX_INDEXES hit in DrawSkySideVBO()"); } tess.indexes[tess.numIndexes++] = s + t * ssizePlusOne + firstVertex; @@ -577,7 +577,7 @@ static void FillCloudySkySide( const int mins[2], const int maxs[2], qboolean ad if ( tess.numVertexes >= SHADER_MAX_VERTEXES ) { - ri->Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); + ri.Error( ERR_DROP, "SHADER_MAX_VERTEXES hit in FillCloudySkySide()" ); } } } diff --git a/codemp/rd-rend2/tr_subs.cpp b/codemp/rd-rend2/tr_subs.cpp index 63a659c708..0228319861 100644 --- a/codemp/rd-rend2/tr_subs.cpp +++ b/codemp/rd-rend2/tr_subs.cpp @@ -33,7 +33,7 @@ void QDECL Com_Printf( const char *msg, ... ) Q_vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); - ri->Printf(PRINT_ALL, "%s", text); + ri.Printf(PRINT_ALL, "%s", text); } void QDECL Com_OPrintf( const char *msg, ... ) @@ -45,7 +45,7 @@ void QDECL Com_OPrintf( const char *msg, ... ) Q_vsnprintf(text, sizeof(text), msg, argptr); va_end(argptr); - ri->OPrintf("%s", text); + ri.OPrintf("%s", text); } void QDECL Com_Error( int level, const char *error, ... ) @@ -57,39 +57,39 @@ void QDECL Com_Error( int level, const char *error, ... ) Q_vsnprintf(text, sizeof(text), error, argptr); va_end(argptr); - ri->Error(level, "%s", text); + ri.Error(level, "%s", text); } // HUNK void *Hunk_AllocateTempMemory( int size ) { - return ri->Hunk_AllocateTempMemory( size ); + return ri.Hunk_AllocateTempMemory( size ); } void Hunk_FreeTempMemory( void *buf ) { - ri->Hunk_FreeTempMemory( buf ); + ri.Hunk_FreeTempMemory( buf ); } void *Hunk_Alloc( int size, ha_pref preference ) { - return ri->Hunk_Alloc( size, preference ); + return ri.Hunk_Alloc( size, preference ); } int Hunk_MemoryRemaining( void ) { - return ri->Hunk_MemoryRemaining(); + return ri.Hunk_MemoryRemaining(); } // ZONE void *Z_Malloc( int iSize, memtag_t eTag, qboolean bZeroit, int iAlign ) { - return ri->Z_Malloc( iSize, eTag, bZeroit, iAlign ); + return ri.Z_Malloc( iSize, eTag, bZeroit, iAlign ); } void Z_Free( void *ptr ) { - ri->Z_Free( ptr ); + ri.Z_Free( ptr ); } int Z_MemSize( memtag_t eTag ) { - return ri->Z_MemSize( eTag ); + return ri.Z_MemSize( eTag ); } void Z_MorphMallocTag( void *pvBuffer, memtag_t eDesiredTag ) { - ri->Z_MorphMallocTag( pvBuffer, eDesiredTag ); + ri.Z_MorphMallocTag( pvBuffer, eDesiredTag ); } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 0da7063a1e..ba27140777 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -56,10 +56,10 @@ void RB_CheckOverflow( int verts, int indexes ) { RB_EndSurface(); if ( verts >= SHADER_MAX_VERTEXES ) { - ri->Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); + ri.Error(ERR_DROP, "RB_CheckOverflow: verts > MAX (%d > %d)", verts, SHADER_MAX_VERTEXES ); } if ( indexes >= SHADER_MAX_INDEXES ) { - ri->Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); + ri.Error(ERR_DROP, "RB_CheckOverflow: indices > MAX (%d > %d)", indexes, SHADER_MAX_INDEXES ); } RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex ); @@ -1987,7 +1987,7 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { } static void RB_SurfaceBad( surfaceType_t *surfType ) { - ri->Printf( PRINT_ALL, "Bad surface tesselated.\n" ); + ri.Printf( PRINT_ALL, "Bad surface tesselated.\n" ); } static void RB_SurfaceFlare(srfFlare_t *surf) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index df75434a22..0ee601468a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -65,7 +65,7 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) return GL_STREAM_DRAW; default: - ri->Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); + ri.Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); return GL_INVALID_OPERATION; } } @@ -115,12 +115,12 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) VBO_t *vbo; if ( tr.numVBOs == MAX_VBOS ) { - ri->Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); + ri.Error( ERR_DROP, "R_CreateVBO: MAX_VBOS hit"); } R_IssuePendingRenderCommands(); - vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri->Hunk_Alloc(sizeof(*vbo), h_low); + vbo = tr.vbos[tr.numVBOs] = (VBO_t *)ri.Hunk_Alloc(sizeof(*vbo), h_low); memset(vbo, 0, sizeof(*vbo)); @@ -164,12 +164,12 @@ IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) IBO_t *ibo; if ( tr.numIBOs == MAX_IBOS ) { - ri->Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); + ri.Error( ERR_DROP, "R_CreateIBO: MAX_IBOS hit"); } R_IssuePendingRenderCommands(); - ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri.Hunk_Alloc(sizeof(*ibo), h_low); ibo->indexesSize = indexesSize; ibo->indexesVBO = tr.iboNames[tr.numIBOs]; @@ -212,7 +212,7 @@ void R_BindVBO(VBO_t * vbo) if(!vbo) { //R_BindNullVBO(); - ri->Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); + ri.Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); return; } @@ -267,7 +267,7 @@ void R_BindIBO(IBO_t * ibo) if(!ibo) { //R_BindNullIBO(); - ri->Error(ERR_DROP, "R_BindIBO: NULL ibo"); + ri.Error(ERR_DROP, "R_BindIBO: NULL ibo"); return; } @@ -309,7 +309,7 @@ R_InitVBOs */ void R_InitVBOs(void) { - ri->Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); + ri.Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is // actually created on first bind. @@ -332,7 +332,7 @@ R_ShutdownVBOs */ void R_ShutdownVBOs(void) { - ri->Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); + ri.Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); R_BindNullVBO(); R_BindNullIBO(); @@ -357,42 +357,42 @@ void R_VBOList_f(void) int vertexesSize = 0; int indexesSize = 0; - ri->Printf (PRINT_ALL, " vertex buffers\n"); - ri->Printf (PRINT_ALL, "----------------\n\n"); + ri.Printf (PRINT_ALL, " vertex buffers\n"); + ri.Printf (PRINT_ALL, "----------------\n\n"); - ri->Printf(PRINT_ALL, " id size (MB)\n"); - ri->Printf(PRINT_ALL, "---------------\n"); + ri.Printf(PRINT_ALL, " id size (MB)\n"); + ri.Printf(PRINT_ALL, "---------------\n"); for(i = 0; i < tr.numVBOs; i++) { vbo = tr.vbos[i]; - ri->Printf(PRINT_ALL, " %4i %4.2f\n", i, vbo->vertexesSize / (1024.0f * 1024.0f)); + ri.Printf(PRINT_ALL, " %4i %4.2f\n", i, vbo->vertexesSize / (1024.0f * 1024.0f)); vertexesSize += vbo->vertexesSize; } - ri->Printf(PRINT_ALL, " %d total buffers\n", tr.numVBOs); - ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", vertexesSize / (1024.0f * 1024.0f)); + ri.Printf(PRINT_ALL, " %d total buffers\n", tr.numVBOs); + ri.Printf(PRINT_ALL, " %.2f MB in total\n\n", vertexesSize / (1024.0f * 1024.0f)); - ri->Printf (PRINT_ALL, " index buffers\n"); - ri->Printf (PRINT_ALL, "---------------\n\n"); + ri.Printf (PRINT_ALL, " index buffers\n"); + ri.Printf (PRINT_ALL, "---------------\n\n"); - ri->Printf(PRINT_ALL, " id size (MB)\n"); - ri->Printf(PRINT_ALL, "---------------\n"); + ri.Printf(PRINT_ALL, " id size (MB)\n"); + ri.Printf(PRINT_ALL, "---------------\n"); for(i = 0; i < tr.numIBOs; i++) { ibo = tr.ibos[i]; - ri->Printf(PRINT_ALL, " %4i %4.2f\n", i, ibo->indexesSize / (1024.0f * 1024.0f)); + ri.Printf(PRINT_ALL, " %4i %4.2f\n", i, ibo->indexesSize / (1024.0f * 1024.0f)); indexesSize += ibo->indexesSize; } - ri->Printf(PRINT_ALL, " %d total buffers\n", tr.numIBOs); - ri->Printf(PRINT_ALL, " %.2f MB in total\n\n", indexesSize / (1024.0f * 1024.0f)); + ri.Printf(PRINT_ALL, " %d total buffers\n", tr.numIBOs); + ri.Printf(PRINT_ALL, " %.2f MB in total\n\n", indexesSize / (1024.0f * 1024.0f)); } void AddVertexArray( diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 2aa596ed85..684dccf468 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -78,7 +78,7 @@ void R_ShutdownWeatherSystem() } else { - ri->Printf(PRINT_DEVELOPER, + ri.Printf(PRINT_DEVELOPER, "Weather system shutdown requested, but it is already shut down.\n"); } } diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 0094a33b5c..4bbb2c4756 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -633,7 +633,7 @@ static mnode_t *R_PointInLeaf( const vec3_t p ) { cplane_t *plane; if ( !tr.world ) { - ri->Error (ERR_DROP, "R_PointInLeaf: bad model"); + ri.Error (ERR_DROP, "R_PointInLeaf: bad model"); } node = tr.world->nodes; @@ -675,14 +675,14 @@ qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ) { int leafnum; int cluster; - leafnum = ri->CM_PointLeafnum (p1); - cluster = ri->CM_LeafCluster (leafnum); + leafnum = ri.CM_PointLeafnum (p1); + cluster = ri.CM_LeafCluster (leafnum); //agh, the damn snapshot mask doesn't work for this - mask = (byte *) ri->CM_ClusterPVS (cluster); + mask = (byte *) ri.CM_ClusterPVS (cluster); - leafnum = ri->CM_PointLeafnum (p2); - cluster = ri->CM_LeafCluster (leafnum); + leafnum = ri.CM_PointLeafnum (p2); + cluster = ri.CM_LeafCluster (leafnum); if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) ) return qfalse; @@ -724,7 +724,7 @@ static void R_MarkLeaves( void ) { if (tr.visClusters[i] != tr.visClusters[tr.visIndex] && r_showcluster->integer) { - ri->Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", + ri.Printf(PRINT_ALL, "found cluster:%i area:%i index:%i\n", cluster, leaf->area, i); } @@ -740,7 +740,7 @@ static void R_MarkLeaves( void ) if ( r_showcluster->modified || r_showcluster->integer ) { r_showcluster->modified = qfalse; if ( r_showcluster->integer ) { - ri->Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); + ri.Printf( PRINT_ALL, "cluster:%i area:%i\n", cluster, leaf->area ); } } From 2653b98dcf34040ba4b45809eb8a6d7985778b5f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 8 May 2018 23:28:52 +0200 Subject: [PATCH 438/708] fix bad sun positions The position of the sun is set in R_LoadBSP, setting the default values after it will overwrite the defined ones from the sky shader. So I just put the setting of default values before calling R_LoadBSP. --- codemp/rd-rend2/tr_bsp.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index eb053cd465..5130825380 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3114,18 +3114,6 @@ void RE_LoadWorldMap( const char *name ) { ri.Error(ERR_DROP, "ERROR: attempted to redundantly load world map"); } - world_t *world = R_LoadBSP(name); - if (world == nullptr) - { - // clear tr.world so the next/ try will not look at the partially - // loaded version - tr.world = nullptr; - return; - } - - tr.worldMapLoaded = qtrue; - tr.world = world; - // set default map light scale tr.mapLightScale = 1.0f; tr.sunShadowScale = 0.5f; @@ -3147,6 +3135,18 @@ void RE_LoadWorldMap( const char *name ) { tr.toneMinAvgMaxLevel[1] = -2.0f; tr.toneMinAvgMaxLevel[2] = 0.0f; + world_t *world = R_LoadBSP(name); + if (world == nullptr) + { + // clear tr.world so the next/ try will not look at the partially + // loaded version + tr.world = nullptr; + return; + } + + tr.worldMapLoaded = qtrue; + tr.world = world; + // Render all cubemaps if (r_cubeMapping->integer && tr.numCubemaps) { From 3f2379743768f62a79862c75e0c70cec75cf9faf Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 8 May 2018 23:41:33 +0200 Subject: [PATCH 439/708] fix inverted roughness and wrong exponent for environment cubemapping --- codemp/rd-rend2/tr_image.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 052a2b5fbc..914e8bb0a0 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2896,8 +2896,7 @@ static void R_CreateEnvBrdfLUT(void) { for (unsigned x = 0; x < LUT_WIDTH; ++x) { - float const gloss = (x + 0.5f) / LUT_WIDTH; - float const roughness = powf(1.0f - gloss, 2.0f); + float const roughness = (x + 0.5f) / LUT_WIDTH; float const m = roughness * roughness; float const m2 = m * m; From 13513b389c43537161e2415501f98a891deeaec7 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 9 May 2018 00:34:20 +0200 Subject: [PATCH 440/708] fix extra render flags they were colliding with existing ones in tr_types. (RDF_ForceSightOn is already 128) --- codemp/rd-rend2/tr_extratypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_extratypes.h b/codemp/rd-rend2/tr_extratypes.h index a8454635a5..b840567cb6 100644 --- a/codemp/rd-rend2/tr_extratypes.h +++ b/codemp/rd-rend2/tr_extratypes.h @@ -27,8 +27,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // extra refdef flags start at 0x0008 //#define RDF_NOFOG 0x0008 // don't apply fog to polys added using RE_AddPolyToScene -#define RDF_EXTRA 128 // Makro - refdefex_t to follow after refdef_t -#define RDF_SUNLIGHT 256 // SmileTheory - render sunlight and shadows +#define RDF_EXTRA 256 // Makro - refdefex_t to follow after refdef_t +#define RDF_SUNLIGHT 512 // SmileTheory - render sunlight and shadows typedef struct { float blurFactor; From 390f88a365e9afaed5ae6eddc948c2881c674b30 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 9 May 2018 01:30:11 +0200 Subject: [PATCH 441/708] fix sunlight in cubemaps including shadows. Problem though is setting every cull type to two sided for cubemap rendering. --- codemp/rd-rend2/tr_backend.cpp | 16 +++++++++++++++- codemp/rd-rend2/tr_fbo.cpp | 2 +- codemp/rd-rend2/tr_main.cpp | 10 +++------- codemp/rd-rend2/tr_shade.cpp | 5 +++++ 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index b84db3fe95..ab76d124f3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2038,7 +2038,21 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) !backEnd.colorMask[3]); backEnd.depthFill = qfalse; - if (tr.msaaResolveFbo) + if (backEnd.viewParms.targetFbo == tr.renderCubeFbo && tr.msaaResolveFbo) + { + // If we're using multisampling and rendering a cubemap, resolve the depth to correct size first + vec4i_t frameBox; + frameBox[0] = backEnd.viewParms.viewportX; + frameBox[1] = backEnd.viewParms.viewportY; + frameBox[2] = backEnd.viewParms.viewportWidth; + frameBox[3] = backEnd.viewParms.viewportHeight; + FBO_FastBlit( + tr.renderCubeFbo, frameBox, + tr.msaaResolveFbo, frameBox, + GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } + else if (tr.msaaResolveFbo) { // If we're using multisampling, resolve the depth first FBO_FastBlit( diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 6a8a65d44f..4b4033c7a0 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -624,7 +624,7 @@ void FBO_Init(void) GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); glState.currentFBO->colorImage[0] = tr.renderCubeImage; glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; - FBO_CreateBuffer(tr.renderCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); + R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderCubeFbo); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1378fff3b7..1610bfba23 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2876,9 +2876,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) { RE_BeginScene(&refdef); - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if(0) //(glRefConfig.framebufferObject && r_sunlightMode->integer && (r_forceSun->integer || tr.sunShadows)) + if(r_sunlightMode->integer && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) { R_RenderSunShadowMaps(&refdef, 0); R_RenderSunShadowMaps(&refdef, 1); @@ -2908,11 +2906,9 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) VectorCopy( refdef.vieworg, parms.pvsOrigin ); - // FIXME: sun shadows aren't rendered correctly in cubemaps - // fix involves changing r_FBufScale to fit smaller cubemap image size, or rendering cubemap to framebuffer first - if (0) //(r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + if (r_sunlightMode->integer && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) { - parms.flags = VPF_USESUNLIGHT; + parms.flags |= VPF_USESUNLIGHT; } parms.targetFbo = tr.renderCubeFbo; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 4447722a38..d7c18534cb 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1359,6 +1359,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); + bool renderToCubemap = tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo; + // HACK: SomaZ: Not sure why this is needed, but fixes sunlight and shadows in cubemaps + if (renderToCubemap) + cullType = CT_TWO_SIDED; + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); From c21b4afe585674e862ee021618bb935bfc4ac391 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Fri, 11 May 2018 22:25:55 +0100 Subject: [PATCH 442/708] Revert "Remove leaf surface and multidraw merging" This reverts commit bd52988ff2cf0317376095d9110483bc4abf57bf. --- codemp/rd-rend2/tr_bsp.cpp | 649 ++++++++++++++++++++++++++++++++- codemp/rd-rend2/tr_init.cpp | 5 + codemp/rd-rend2/tr_local.h | 3 + codemp/rd-rend2/tr_surface.cpp | 75 ++++ 4 files changed, 731 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index eb053cd465..c2b1b62208 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1830,6 +1830,300 @@ void R_MovePatchSurfacesToHunk( world_t *worldData ) { } } + +/* +================= +BSPSurfaceCompare +compare function for qsort() +================= +*/ +static int BSPSurfaceCompare(const void *a, const void *b) +{ + msurface_t *aa, *bb; + + aa = *(msurface_t **) a; + bb = *(msurface_t **) b; + + // shader first + if(aa->shader->sortedIndex < bb->shader->sortedIndex) + return -1; + + else if(aa->shader->sortedIndex > bb->shader->sortedIndex) + return 1; + + // by fogIndex + if(aa->fogIndex < bb->fogIndex) + return -1; + + else if(aa->fogIndex > bb->fogIndex) + return 1; + + // by cubemapIndex + if(aa->cubemapIndex < bb->cubemapIndex) + return -1; + + else if(aa->cubemapIndex > bb->cubemapIndex) + return 1; + + + return 0; +} + +struct packedVertex_t +{ + vec3_t position; + uint32_t normal; + uint32_t tangent; + vec2_t texcoords[1 + MAXLIGHTMAPS]; + vec4_t colors[MAXLIGHTMAPS]; + uint32_t lightDirection; +}; + +/* +=============== +R_CreateWorldVBOs +=============== +*/ +static void R_CreateWorldVBOs( world_t *worldData ) +{ + int i, j, k; + + int numVerts; + packedVertex_t *verts; + + int numIndexes; + glIndex_t *indexes; + + int numSortedSurfaces, numSurfaces; + msurface_t *surface, **firstSurf, **lastSurf, **currSurf; + msurface_t **surfacesSorted; + + VBO_t *vbo; + IBO_t *ibo; + + int maxVboSize = 64 * 1024 * 1024; + int maxIboSize = 16 * 1024 * 1024; + + int startTime, endTime; + + startTime = ri->Milliseconds(); + + // count surfaces + numSortedSurfaces = 0; + for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) + { + srfBspSurface_t *bspSurf; + shader_t *shader = surface->shader; + + if (shader->isPortal) + continue; + + if (shader->isSky) + continue; + + if (ShaderRequiresCPUDeforms(shader)) + continue; + + // check for this now so we can use srfBspSurface_t* universally in the rest of the function + if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) + continue; + + bspSurf = (srfBspSurface_t *) surface->data; + + if (!bspSurf->numIndexes || !bspSurf->numVerts) + continue; + + numSortedSurfaces++; + } + + // presort surfaces + surfacesSorted = (msurface_t **)Z_Malloc(numSortedSurfaces * sizeof(*surfacesSorted), TAG_BSP); + + j = 0; + for(surface = &worldData->surfaces[0]; surface < &worldData->surfaces[worldData->numsurfaces]; surface++) + { + srfBspSurface_t *bspSurf; + shader_t *shader = surface->shader; + + if (shader->isPortal) + continue; + + if (shader->isSky) + continue; + + if (ShaderRequiresCPUDeforms(shader)) + continue; + + // check for this now so we can use srfBspSurface_t* universally in the rest of the function + if (!(*surface->data == SF_FACE || *surface->data == SF_GRID || *surface->data == SF_TRIANGLES)) + continue; + + bspSurf = (srfBspSurface_t *) surface->data; + + if (!bspSurf->numIndexes || !bspSurf->numVerts) + continue; + + surfacesSorted[j++] = surface; + } + + qsort(surfacesSorted, numSortedSurfaces, sizeof(*surfacesSorted), BSPSurfaceCompare); + + k = 0; + for(firstSurf = lastSurf = surfacesSorted; firstSurf < &surfacesSorted[numSortedSurfaces]; firstSurf = lastSurf) + { + int currVboSize, currIboSize; + + // Find range of surfaces to merge by: + // - Collecting a number of surfaces which fit under maxVboSize/maxIboSize, or + // - All the surfaces with a single shader which go over maxVboSize/maxIboSize + currVboSize = currIboSize = 0; + while (currVboSize < maxVboSize && currIboSize < maxIboSize && lastSurf < &surfacesSorted[numSortedSurfaces]) + { + int addVboSize, addIboSize, currShaderIndex; + + addVboSize = addIboSize = 0; + currShaderIndex = (*lastSurf)->shader->sortedIndex; + + for(currSurf = lastSurf; currSurf < &surfacesSorted[numSortedSurfaces] && (*currSurf)->shader->sortedIndex == currShaderIndex; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + + addVboSize += bspSurf->numVerts * sizeof(srfVert_t); + addIboSize += bspSurf->numIndexes * sizeof(glIndex_t); + } + + if ((currVboSize != 0 && addVboSize + currVboSize > maxVboSize) + || (currIboSize != 0 && addIboSize + currIboSize > maxIboSize)) + break; + + lastSurf = currSurf; + + currVboSize += addVboSize; + currIboSize += addIboSize; + } + + // count verts/indexes/surfaces + numVerts = 0; + numIndexes = 0; + numSurfaces = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + + numVerts += bspSurf->numVerts; + numIndexes += bspSurf->numIndexes; + numSurfaces++; + } + + ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); + + // create arrays + verts = (packedVertex_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); + indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); + + // set up indices and copy vertices + numVerts = 0; + numIndexes = 0; + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + glIndex_t *surfIndex; + + bspSurf->firstIndex = numIndexes; + bspSurf->minIndex = numVerts + bspSurf->indexes[0]; + bspSurf->maxIndex = numVerts + bspSurf->indexes[0]; + + for(i = 0, surfIndex = bspSurf->indexes; i < bspSurf->numIndexes; i++, surfIndex++) + { + indexes[numIndexes++] = numVerts + *surfIndex; + bspSurf->minIndex = MIN(bspSurf->minIndex, numVerts + *surfIndex); + bspSurf->maxIndex = MAX(bspSurf->maxIndex, numVerts + *surfIndex); + } + + bspSurf->firstVert = numVerts; + + for(i = 0; i < bspSurf->numVerts; i++) + { + packedVertex_t& vert = verts[numVerts++]; + + VectorCopy (bspSurf->verts[i].xyz, vert.position); + vert.normal = R_VboPackNormal (bspSurf->verts[i].normal); + vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); + VectorCopy2 (bspSurf->verts[i].st, vert.texcoords[0]); + + for (int j = 0; j < MAXLIGHTMAPS; j++) + { + VectorCopy2 (bspSurf->verts[i].lightmap[j], vert.texcoords[1 + j]); + } + + for (int j = 0; j < MAXLIGHTMAPS; j++) + { + VectorCopy4 (bspSurf->verts[i].vertexColors[j], vert.colors[j]); + } + + vert.lightDirection = R_VboPackNormal (bspSurf->verts[i].lightdir); + } + } + + vbo = R_CreateVBO((byte *)verts, sizeof (packedVertex_t) * numVerts, VBO_USAGE_STATIC); + ibo = R_CreateIBO((byte *)indexes, numIndexes * sizeof (glIndex_t), VBO_USAGE_STATIC); + + // Setup the offsets and strides + vbo->offsets[ATTR_INDEX_POSITION] = offsetof(packedVertex_t, position); + vbo->offsets[ATTR_INDEX_NORMAL] = offsetof(packedVertex_t, normal); + vbo->offsets[ATTR_INDEX_TANGENT] = offsetof(packedVertex_t, tangent); + vbo->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(packedVertex_t, texcoords[0]); + vbo->offsets[ATTR_INDEX_TEXCOORD1] = offsetof(packedVertex_t, texcoords[1]); + vbo->offsets[ATTR_INDEX_TEXCOORD2] = offsetof(packedVertex_t, texcoords[2]); + vbo->offsets[ATTR_INDEX_TEXCOORD3] = offsetof(packedVertex_t, texcoords[3]); + vbo->offsets[ATTR_INDEX_TEXCOORD4] = offsetof(packedVertex_t, texcoords[4]); + vbo->offsets[ATTR_INDEX_COLOR] = offsetof(packedVertex_t, colors); + vbo->offsets[ATTR_INDEX_LIGHTDIRECTION] = offsetof(packedVertex_t, lightDirection); + + const size_t packedVertexSize = sizeof(packedVertex_t); + vbo->strides[ATTR_INDEX_POSITION] = packedVertexSize; + vbo->strides[ATTR_INDEX_NORMAL] = packedVertexSize; + vbo->strides[ATTR_INDEX_TANGENT] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD0] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD1] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD2] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD3] = packedVertexSize; + vbo->strides[ATTR_INDEX_TEXCOORD4] = packedVertexSize; + vbo->strides[ATTR_INDEX_COLOR] = packedVertexSize; + vbo->strides[ATTR_INDEX_LIGHTDIRECTION] = packedVertexSize; + + vbo->sizes[ATTR_INDEX_POSITION] = sizeof(verts->position); + vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(verts->normal); + vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD1] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD2] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD3] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TEXCOORD4] = sizeof(verts->texcoords[0]); + vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(verts->tangent); + vbo->sizes[ATTR_INDEX_LIGHTDIRECTION] = sizeof(verts->lightDirection); + vbo->sizes[ATTR_INDEX_COLOR] = sizeof(verts->colors); + + // point bsp surfaces to VBO + for (currSurf = firstSurf; currSurf < lastSurf; currSurf++) + { + srfBspSurface_t *bspSurf = (srfBspSurface_t *) (*currSurf)->data; + + bspSurf->vbo = vbo; + bspSurf->ibo = ibo; + } + + ri->Hunk_FreeTempMemory(indexes); + ri->Hunk_FreeTempMemory(verts); + + k++; + } + + Z_Free(surfacesSorted); + + endTime = ri->Milliseconds(); + ri->Printf(PRINT_ALL, "world VBOs calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); +} + /* =============== R_LoadSurfaces @@ -2752,6 +3046,352 @@ static void R_RenderAllCubemaps(void) } } + +/* +================= +R_MergeLeafSurfaces + +Merges surfaces that share a common leaf +================= +*/ +static void R_MergeLeafSurfaces(world_t *worldData) +{ + int i, j, k; + int numWorldSurfaces; + int mergedSurfIndex; + int numMergedSurfaces; + int numUnmergedSurfaces; + VBO_t *vbo; + IBO_t *ibo; + + msurface_t *mergedSurf; + + glIndex_t *iboIndexes, *outIboIndexes; + int numIboIndexes; + + int startTime, endTime; + + startTime = ri->Milliseconds(); + + numWorldSurfaces = worldData->numWorldSurfaces; + + // use viewcount to keep track of mergers + for (i = 0; i < numWorldSurfaces; i++) + { + worldData->surfacesViewCount[i] = -1; + } + + // mark matching surfaces + for (i = 0; i < worldData->numnodes - worldData->numDecisionNodes; i++) + { + mnode_t *leaf = worldData->nodes + worldData->numDecisionNodes + i; + + for (j = 0; j < leaf->nummarksurfaces; j++) + { + msurface_t *surf1; + shader_t *shader1; + int fogIndex1; + int cubemapIndex1; + int surfNum1; + + surfNum1 = *(worldData->marksurfaces + leaf->firstmarksurface + j); + + if (worldData->surfacesViewCount[surfNum1] != -1) + continue; + + surf1 = worldData->surfaces + surfNum1; + + if ((*surf1->data != SF_GRID) && + (*surf1->data != SF_TRIANGLES) && + (*surf1->data != SF_FACE)) + { + continue; + } + + shader1 = surf1->shader; + + if(shader1->isSky) + continue; + + if(shader1->isPortal) + continue; + + if(ShaderRequiresCPUDeforms(shader1)) + continue; + + fogIndex1 = surf1->fogIndex; + cubemapIndex1 = surf1->cubemapIndex; + + worldData->surfacesViewCount[surfNum1] = surfNum1; + + for (k = j + 1; k < leaf->nummarksurfaces; k++) + { + msurface_t *surf2; + shader_t *shader2; + int fogIndex2; + int cubemapIndex2; + int surfNum2; + + surfNum2 = *(worldData->marksurfaces + leaf->firstmarksurface + k); + + if (worldData->surfacesViewCount[surfNum2] != -1) + continue; + + surf2 = worldData->surfaces + surfNum2; + + if ((*surf2->data != SF_GRID) && + (*surf2->data != SF_TRIANGLES) && + (*surf2->data != SF_FACE)) + continue; + + shader2 = surf2->shader; + + if (shader1 != shader2) + continue; + + fogIndex2 = surf2->fogIndex; + + if (fogIndex1 != fogIndex2) + continue; + + cubemapIndex2 = surf2->cubemapIndex; + + if (cubemapIndex1 != cubemapIndex2) + continue; + + worldData->surfacesViewCount[surfNum2] = surfNum1; + } + } + } + + // don't add surfaces that don't merge to any others to the merged list + for (i = 0; i < numWorldSurfaces; i++) + { + qboolean merges = qfalse; + + if (worldData->surfacesViewCount[i] != i) + continue; + + for (j = 0; j < numWorldSurfaces; j++) + { + if (j == i) + continue; + + if (worldData->surfacesViewCount[j] == i) + { + merges = qtrue; + break; + } + } + + if (!merges) + worldData->surfacesViewCount[i] = -1; + } + + // count merged/unmerged surfaces + numMergedSurfaces = 0; + numUnmergedSurfaces = 0; + for (i = 0; i < numWorldSurfaces; i++) + { + if (worldData->surfacesViewCount[i] == i) + { + numMergedSurfaces++; + } + else if (worldData->surfacesViewCount[i] == -1) + { + numUnmergedSurfaces++; + } + } + + // Allocate merged surfaces + worldData->mergedSurfaces = + (msurface_t *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); + worldData->mergedSurfacesViewCount = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); + worldData->mergedSurfacesDlightBits = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); + worldData->mergedSurfacesPshadowBits = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); + worldData->numMergedSurfaces = numMergedSurfaces; + + // view surfaces are like mark surfaces, except negative ones represent merged surfaces + // -1 represents 0, -2 represents 1, and so on + worldData->viewSurfaces = + (int *)ri->Hunk_Alloc( + sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); + + // copy view surfaces into mark surfaces + for (i = 0; i < worldData->nummarksurfaces; i++) + { + worldData->viewSurfaces[i] = worldData->marksurfaces[i]; + } + + // need to be synched here + R_IssuePendingRenderCommands(); + + // actually merge surfaces + numIboIndexes = 0; + mergedSurfIndex = 0; + mergedSurf = worldData->mergedSurfaces; + for (i = 0; i < numWorldSurfaces; i++) + { + msurface_t *surf1; + + vec3_t bounds[2]; + + int numSurfsToMerge; + int numIndexes; + int numVerts; + int firstIndex; + + srfBspSurface_t *vboSurf; + + if (worldData->surfacesViewCount[i] != i) + continue; + + surf1 = worldData->surfaces + i; + + // retrieve vbo + vbo = ((srfBspSurface_t *)(surf1->data))->vbo; + + // count verts, indexes, and surfaces + numSurfsToMerge = 0; + numIndexes = 0; + numVerts = 0; + for (j = i; j < numWorldSurfaces; j++) + { + msurface_t *surf2; + srfBspSurface_t *bspSurf; + + if (worldData->surfacesViewCount[j] != i) + continue; + + surf2 = worldData->surfaces + j; + + bspSurf = (srfBspSurface_t *) surf2->data; + numIndexes += bspSurf->numIndexes; + numVerts += bspSurf->numVerts; + numSurfsToMerge++; + } + + if (numVerts == 0 || numIndexes == 0 || numSurfsToMerge < 2) + { + continue; + } + + // create ibo + ibo = tr.ibos[tr.numIBOs++] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); + memset(ibo, 0, sizeof(*ibo)); + numIboIndexes = 0; + + // allocate indexes + iboIndexes = outIboIndexes = (glIndex_t*)Z_Malloc(numIndexes * sizeof(*outIboIndexes), TAG_BSP); + + // Merge surfaces (indexes) and calculate bounds + ClearBounds(bounds[0], bounds[1]); + firstIndex = numIboIndexes; + for (j = i; j < numWorldSurfaces; j++) + { + msurface_t *surf2; + srfBspSurface_t *bspSurf; + + if (worldData->surfacesViewCount[j] != i) + continue; + + surf2 = worldData->surfaces + j; + + AddPointToBounds(surf2->cullinfo.bounds[0], bounds[0], bounds[1]); + AddPointToBounds(surf2->cullinfo.bounds[1], bounds[0], bounds[1]); + + bspSurf = (srfBspSurface_t *) surf2->data; + for (k = 0; k < bspSurf->numIndexes; k++) + { + *outIboIndexes++ = bspSurf->indexes[k] + bspSurf->firstVert; + numIboIndexes++; + } + break; + } + + vboSurf = (srfBspSurface_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); + memset(vboSurf, 0, sizeof(*vboSurf)); + vboSurf->surfaceType = SF_VBO_MESH; + + vboSurf->vbo = vbo; + vboSurf->ibo = ibo; + + vboSurf->numIndexes = numIndexes; + vboSurf->numVerts = numVerts; + vboSurf->firstIndex = firstIndex; + + vboSurf->minIndex = *(iboIndexes + firstIndex); + vboSurf->maxIndex = *(iboIndexes + firstIndex); + + for (j = 0; j < numIndexes; j++) + { + vboSurf->minIndex = MIN(vboSurf->minIndex, *(iboIndexes + firstIndex + j)); + vboSurf->maxIndex = MAX(vboSurf->maxIndex, *(iboIndexes + firstIndex + j)); + } + + VectorCopy(bounds[0], vboSurf->cullBounds[0]); + VectorCopy(bounds[1], vboSurf->cullBounds[1]); + + VectorCopy(bounds[0], mergedSurf->cullinfo.bounds[0]); + VectorCopy(bounds[1], mergedSurf->cullinfo.bounds[1]); + + mergedSurf->cullinfo.type = CULLINFO_BOX; + mergedSurf->data = (surfaceType_t *)vboSurf; + mergedSurf->fogIndex = surf1->fogIndex; + mergedSurf->cubemapIndex = surf1->cubemapIndex; + mergedSurf->shader = surf1->shader; + + // finish up the ibo + qglGenBuffers(1, &ibo->indexesVBO); + + R_BindIBO(ibo); + qglBufferData(GL_ELEMENT_ARRAY_BUFFER, numIboIndexes * sizeof(*iboIndexes), iboIndexes, GL_STATIC_DRAW); + R_BindNullIBO(); + + GL_CheckErrors(); + + Z_Free(iboIndexes); + + // redirect view surfaces to this surf + for (j = 0; j < numWorldSurfaces; j++) + { + if (worldData->surfacesViewCount[j] != i) + continue; + + for (k = 0; k < worldData->nummarksurfaces; k++) + { + int *mark = worldData->marksurfaces + k; + int *view = worldData->viewSurfaces + k; + + if (*mark == j) + *view = -(mergedSurfIndex + 1); + } + } + + mergedSurfIndex++; + mergedSurf++; + } + + endTime = ri->Milliseconds(); + + ri->Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", + numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); + + // reset viewcounts + for (i = 0; i < numWorldSurfaces; i++) + { + worldData->surfacesViewCount[i] = -1; + } +} + + static void R_CalcVertexLightDirs( world_t *worldData ) { int i, k; @@ -3090,7 +3730,14 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } } - worldData->dataSize = (const byte *)ri.Hunk_Alloc(0, h_low) - startMarker; + // create static VBOS from the world + R_CreateWorldVBOs(worldData); + if (r_mergeLeafSurfaces->integer) + { + R_MergeLeafSurfaces(worldData); + } + + worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; // make sure the VBO glState entries are safe R_BindNullVBO(); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 57a088d25b..974dcabbbb 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -107,6 +107,9 @@ cvar_t *r_arb_seamless_cube_map; cvar_t *r_arb_vertex_type_2_10_10_10_rev; cvar_t *r_arb_buffer_storage; +cvar_t *r_mergeMultidraws; +cvar_t *r_mergeLeafSurfaces; + cvar_t *r_cameraExposure; cvar_t *r_externalGLSL; @@ -1539,6 +1542,8 @@ void R_Register( void ) r_directedScale = ri.Cvar_Get( "r_directedScale", "1", CVAR_CHEAT, "" ); r_anaglyphMode = ri.Cvar_Get("r_anaglyphMode", "0", CVAR_ARCHIVE, ""); + r_mergeMultidraws = ri.Cvar_Get("r_mergeMultidraws", "1", CVAR_ARCHIVE, ""); + r_mergeLeafSurfaces = ri.Cvar_Get("r_mergeLeafSurfaces", "1", CVAR_ARCHIVE, ""); // // temporary variables that can change at any time diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9b182cd1e3..95123b81db 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2453,6 +2453,9 @@ extern cvar_t *r_skipBackEnd; extern cvar_t *r_anaglyphMode; +extern cvar_t *r_mergeMultidraws; +extern cvar_t *r_mergeLeafSurfaces; + extern cvar_t *r_externalGLSL; extern cvar_t *r_hdr; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index ba27140777..6e458d02dd 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -475,6 +475,7 @@ static qboolean RB_SurfaceVbo( VBO_t *vbo, IBO_t *ibo, int numVerts, int numIndexes, int firstIndex, int minIndex, int maxIndex, int dlightBits, int pshadowBits, qboolean shaderCheck) { + int i, mergeForward, mergeBack; GLvoid *firstIndexOffset, *lastIndexOffset; if (!vbo || !ibo) @@ -495,9 +496,83 @@ static qboolean RB_SurfaceVbo( tess.dlightBits |= dlightBits; tess.pshadowBits |= pshadowBits; + // merge this into any existing multidraw primitives + mergeForward = -1; + mergeBack = -1; firstIndexOffset = BUFFER_OFFSET(firstIndex * sizeof(glIndex_t)); lastIndexOffset = BUFFER_OFFSET((firstIndex + numIndexes) * sizeof(glIndex_t)); + if (r_mergeMultidraws->integer) + { + i = 0; + + if (r_mergeMultidraws->integer == 1) + { + // lazy merge, only check the last primitive + if (tess.multiDrawPrimitives) + { + i = tess.multiDrawPrimitives - 1; + } + } + + for (; i < tess.multiDrawPrimitives; i++) + { + if (tess.multiDrawLastIndex[i] == firstIndexOffset) + { + mergeBack = i; + } + + if (lastIndexOffset == tess.multiDrawFirstIndex[i]) + { + mergeForward = i; + } + } + } + + if (mergeBack != -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack == -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeForward] += numIndexes; + tess.multiDrawFirstIndex[mergeForward] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex); + tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack != -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex)); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex)); + tess.multiDrawPrimitives--; + + if (mergeForward != tess.multiDrawPrimitives) + { + tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives]; + tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives]; + } + backEnd.pc.c_multidrawsMerged += 2; + } + else if (mergeBack == -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes; + tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[tess.multiDrawPrimitives] = (glIndex_t *)lastIndexOffset; + tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex; + tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex; + tess.multiDrawPrimitives++; + } + + backEnd.pc.c_multidraws++; + tess.numIndexes += numIndexes; tess.numVertexes += numVerts; From d12e2667269fae492d747a227c510a6f81d03105 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Fri, 11 May 2018 22:53:20 +0100 Subject: [PATCH 443/708] Revert "Don't invert roughness when calculating BRDF" This reverts commit 6b6869c815939a5e8e9c49d214010b6be23122be. --- codemp/rd-rend2/glsl/lightall.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index bbc05e2ad2..bd05e57346 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -521,7 +521,7 @@ vec3 CalcIBLContribution( ) { #if defined(USE_CUBEMAP) - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; + vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(1.0 - roughness, NE)).rgb; vec3 R = reflect(E, N); From 5ec75bc8f43389f27fe345d0d2140d188d177a5a Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 12 May 2018 12:15:23 +0100 Subject: [PATCH 444/708] Fix some struct accessors --- codemp/rd-rend2/tr_bsp.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c2b1b62208..c28c81fc36 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1906,7 +1906,7 @@ static void R_CreateWorldVBOs( world_t *worldData ) int startTime, endTime; - startTime = ri->Milliseconds(); + startTime = ri.Milliseconds(); // count surfaces numSortedSurfaces = 0; @@ -2015,11 +2015,11 @@ static void R_CreateWorldVBOs( world_t *worldData ) numSurfaces++; } - ri->Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); + ri.Printf(PRINT_ALL, "...calculating world VBO %d ( %i verts %i tris )\n", k, numVerts, numIndexes / 3); // create arrays - verts = (packedVertex_t *)ri->Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); - indexes = (glIndex_t *)ri->Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); + verts = (packedVertex_t *)ri.Hunk_AllocateTempMemory(numVerts * sizeof(packedVertex_t)); + indexes = (glIndex_t *)ri.Hunk_AllocateTempMemory(numIndexes * sizeof(glIndex_t)); // set up indices and copy vertices numVerts = 0; @@ -2112,16 +2112,16 @@ static void R_CreateWorldVBOs( world_t *worldData ) bspSurf->ibo = ibo; } - ri->Hunk_FreeTempMemory(indexes); - ri->Hunk_FreeTempMemory(verts); + ri.Hunk_FreeTempMemory(indexes); + ri.Hunk_FreeTempMemory(verts); k++; } Z_Free(surfacesSorted); - endTime = ri->Milliseconds(); - ri->Printf(PRINT_ALL, "world VBOs calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "world VBOs calculation time = %5.2f seconds\n", (endTime - startTime) / 1000.0); } /* @@ -3071,7 +3071,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) int startTime, endTime; - startTime = ri->Milliseconds(); + startTime = ri.Milliseconds(); numWorldSurfaces = worldData->numWorldSurfaces; @@ -3205,23 +3205,23 @@ static void R_MergeLeafSurfaces(world_t *worldData) // Allocate merged surfaces worldData->mergedSurfaces = - (msurface_t *)ri->Hunk_Alloc( + (msurface_t *)ri.Hunk_Alloc( sizeof(*worldData->mergedSurfaces) * numMergedSurfaces, h_low); worldData->mergedSurfacesViewCount = - (int *)ri->Hunk_Alloc( + (int *)ri.Hunk_Alloc( sizeof(*worldData->mergedSurfacesViewCount) * numMergedSurfaces, h_low); worldData->mergedSurfacesDlightBits = - (int *)ri->Hunk_Alloc( + (int *)ri.Hunk_Alloc( sizeof(*worldData->mergedSurfacesDlightBits) * numMergedSurfaces, h_low); worldData->mergedSurfacesPshadowBits = - (int *)ri->Hunk_Alloc( + (int *)ri.Hunk_Alloc( sizeof(*worldData->mergedSurfacesPshadowBits) * numMergedSurfaces, h_low); worldData->numMergedSurfaces = numMergedSurfaces; // view surfaces are like mark surfaces, except negative ones represent merged surfaces // -1 represents 0, -2 represents 1, and so on worldData->viewSurfaces = - (int *)ri->Hunk_Alloc( + (int *)ri.Hunk_Alloc( sizeof(*worldData->viewSurfaces) * worldData->nummarksurfaces, h_low); // copy view surfaces into mark surfaces @@ -3284,7 +3284,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) } // create ibo - ibo = tr.ibos[tr.numIBOs++] = (IBO_t*)ri->Hunk_Alloc(sizeof(*ibo), h_low); + ibo = tr.ibos[tr.numIBOs++] = (IBO_t*)ri.Hunk_Alloc(sizeof(*ibo), h_low); memset(ibo, 0, sizeof(*ibo)); numIboIndexes = 0; @@ -3316,7 +3316,7 @@ static void R_MergeLeafSurfaces(world_t *worldData) break; } - vboSurf = (srfBspSurface_t *)ri->Hunk_Alloc(sizeof(*vboSurf), h_low); + vboSurf = (srfBspSurface_t *)ri.Hunk_Alloc(sizeof(*vboSurf), h_low); memset(vboSurf, 0, sizeof(*vboSurf)); vboSurf->surfaceType = SF_VBO_MESH; @@ -3379,9 +3379,9 @@ static void R_MergeLeafSurfaces(world_t *worldData) mergedSurf++; } - endTime = ri->Milliseconds(); + endTime = ri.Milliseconds(); - ri->Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", + ri.Printf(PRINT_ALL, "Processed %d surfaces into %d merged, %d unmerged in %5.2f seconds\n", numWorldSurfaces, numMergedSurfaces, numUnmergedSurfaces, (endTime - startTime) / 1000.0f); // reset viewcounts @@ -3737,7 +3737,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_MergeLeafSurfaces(worldData); } - worldData->dataSize = (const byte *)ri->Hunk_Alloc(0, h_low) - startMarker; + worldData->dataSize = (const byte *)ri.Hunk_Alloc(0, h_low) - startMarker; // make sure the VBO glState entries are safe R_BindNullVBO(); From 1e5652f40994712aee2714fb8ee17c01ee0fc995 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 12 May 2018 13:22:54 +0100 Subject: [PATCH 445/708] Generate header file for GLSL strings with externs --- codemp/rd-rend2/CMakeLists.txt | 27 ++++++++++---- codemp/rd-rend2/glsl/compact.cpp | 60 +++++++++++++++++++++----------- codemp/rd-rend2/tr_glsl.cpp | 23 +----------- 3 files changed, 61 insertions(+), 49 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index d7462ec8c1..302aab6eb8 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -127,8 +127,14 @@ find_package(OpenGL REQUIRED) set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OPENGL_INCLUDE_DIR}) set(MPRend2Libraries ${MPRend2Libraries} ${OPENGL_LIBRARIES}) -source_group("renderer" FILES ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) -set(MPRend2Files ${MPRend2Files} ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) +source_group("renderer" + FILES + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) +set(MPRend2Files + ${MPRend2Files} + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp) set(MPRend2IncludeDirectories ${MPRend2IncludeDirectories} ${OpenJKLibDir}) add_library(${MPRend2} SHARED ${MPRend2Files}) @@ -164,17 +170,24 @@ set_property(TARGET ${MPRend2} APPEND PROPERTY COMPILE_OPTIONS ${OPENJK_VISIBILI set_target_properties(${MPRend2} PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") set_target_properties(${MPRend2} PROPERTIES PROJECT_LABEL "MP Rend2 Renderer") target_link_libraries(${MPRend2} ${MPRend2Libraries}) +target_include_directories(${MPRend2} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # GLSL shader file generator add_executable(compact_glsl ${MPDir}/rd-rend2/glsl/compact.cpp ${MPDir}/rd-rend2/tr_allocator.cpp ${MPDir}/rd-rend2/tr_allocator.h - ${MPDir}/rd-rend2/tr_glsl_parse.cpp - ) + ${MPDir}/rd-rend2/tr_glsl_parse.cpp) set_target_properties(compact_glsl PROPERTIES COMPILE_DEFINITIONS "GLSL_BUILDTOOL") set_target_properties(compact_glsl PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") add_custom_command( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp - COMMAND compact_glsl ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp ${MPRend2GLSLFiles} - DEPENDS compact_glsl ${MPRend2GLSLFiles}) + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + COMMAND + compact_glsl + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + ${MPRend2GLSLFiles} + DEPENDS + compact_glsl ${MPRend2GLSLFiles}) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 4c39d68943..cc03baa1ff 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -99,27 +99,33 @@ int main( int argc, char *argv[] ) return EXIT_FAILURE; } - if ( args.size() < 3 ) + if ( args.size() < 4 ) { - // 0 = exe, 1 = outfile, 2+ = glsl files + // 0 = exe, 1 = cpp file, 2 = h file, 2+ = glsl files return EXIT_FAILURE; } - std::string& outFile = args[1]; - StringList glslFiles(args.begin() + 2, args.end()); + std::string& shadersCppFile = args[1]; + std::string& shadersHeaderFile = args[2]; + StringList glslFiles(args.begin() + 3, args.end()); - std::cout << "Outputting to " << outFile << '\n'; + std::cout << "Outputting to '" << shadersCppFile << "' and '" << shadersHeaderFile << "'\n"; Allocator allocator(512 * 1024); - std::ostringstream ss; + std::ostringstream cppStream; + std::ostringstream headerStream; std::string line; - ss << "#include \"tr_local.h\"\n\n"; + headerStream << "// This file is auto-generated. DO NOT EDIT BY HAND\n"; + headerStream << "#pragma once\n\n"; + headerStream << "#include \"tr_local.h\"\n\n"; + + cppStream << "// This file is auto-generated. DO NOT EDIT BY HAND\n"; + cppStream << "#include \"tr_local.h\"\n\n"; for ( StringList::const_iterator it = glslFiles.begin(); it != glslFiles.end(); ++it ) { - // Get shader name from file name if ( !EndsWith(*it, ".glsl") ) { @@ -155,45 +161,59 @@ int main( int argc, char *argv[] ) GPUShaderDesc& shaderDesc = programDesc.shaders[i]; const char *suffix = GetShaderSuffix(shaderDesc.type); - ss << "const char *fallback_" + shaderName + suffix + " = \""; + cppStream << "const char *fallback_" + shaderName + suffix + " = \""; const char *lineStart = shaderDesc.source; const char *lineEnd = strchr(lineStart, '\n'); while ( lineEnd ) { line.assign(lineStart, lineEnd - lineStart); - ss << Escape(line); - ss << "\\n\"\n\""; + cppStream << Escape(line); + cppStream << "\\n\"\n\""; lineStart = lineEnd + 1; lineEnd = strchr(lineStart, '\n'); } line.assign(lineStart); - ss << Escape(line) << "\";\n"; + cppStream << Escape(line) << "\";\n"; } - ss << "GPUShaderDesc fallback_" << shaderName << "Shaders[] = {\n"; + cppStream << "GPUShaderDesc fallback_" << shaderName << "Shaders[] = {\n"; for ( size_t i = 0, numShaders = programDesc.numShaders; i < numShaders; ++i ) { GPUShaderDesc& shaderDesc = programDesc.shaders[i]; const char *suffix = GetShaderSuffix(shaderDesc.type); - ss << " { " << ToString(shaderDesc.type) << ", " + cppStream << " { " << ToString(shaderDesc.type) << ", " "fallback_" << shaderName << suffix << ", " << shaderDesc.firstLineNumber << " },\n"; } - ss << "};\n"; + cppStream << "};\n"; - ss << "extern const GPUProgramDesc fallback_" << shaderName << "Program = { " + cppStream << "extern const GPUProgramDesc fallback_" << shaderName << "Program = { " << programDesc.numShaders << ", fallback_" << shaderName << "Shaders };\n\n"; + + headerStream << "extern const GPUProgramDesc fallback_" << shaderName << "Program;\n"; } - std::ofstream ofs(outFile.c_str()); - if ( !ofs ) + std::ofstream cppFile(shadersCppFile); + if ( !cppFile ) + { + std::cerr << "Could not create file '" << shadersCppFile << "'\n"; + } + else { - std::cerr << "Could not create file " << outFile << '\n'; + cppFile << cppStream.str(); } - ofs << ss.str(); + std::ofstream headerFile(shadersHeaderFile); + if (!headerFile) + { + std::cerr << "Could not create file '" << shadersHeaderFile << "'\n"; + } + else + { + headerFile << headerStream.str(); + } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 9510f0b43a..99b0caa8d3 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -22,31 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_glsl.c #include "tr_local.h" #include "tr_allocator.h" +#include "glsl_shaders.h" void GLSL_BindNullProgram(void); -extern const GPUProgramDesc fallback_bokehProgram; -extern const GPUProgramDesc fallback_calclevels4xProgram; -extern const GPUProgramDesc fallback_depthblurProgram; -extern const GPUProgramDesc fallback_prefilterEnvMapProgram; -extern const GPUProgramDesc fallback_dlightProgram; -extern const GPUProgramDesc fallback_down4xProgram; -extern const GPUProgramDesc fallback_fogpassProgram; -extern const GPUProgramDesc fallback_gaussian_blurProgram; -extern const GPUProgramDesc fallback_genericProgram; -extern const GPUProgramDesc fallback_lightallProgram; -extern const GPUProgramDesc fallback_pshadowProgram; -extern const GPUProgramDesc fallback_shadowfillProgram; -extern const GPUProgramDesc fallback_shadowmaskProgram; -extern const GPUProgramDesc fallback_ssaoProgram; -extern const GPUProgramDesc fallback_texturecolorProgram; -extern const GPUProgramDesc fallback_tonemapProgram; -extern const GPUProgramDesc fallback_dglow_downsampleProgram; -extern const GPUProgramDesc fallback_dglow_upsampleProgram; -extern const GPUProgramDesc fallback_surface_spritesProgram; -extern const GPUProgramDesc fallback_weatherProgram; - - const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { { 10, "SurfaceSprite", sizeof(SurfaceSpriteBlock) } }; From f4e6778c17a4e5f0f95d7f2fe1b61f606307e092 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 12 May 2018 14:04:14 +0100 Subject: [PATCH 446/708] Start weather update transform feedback shader --- codemp/rd-rend2/glsl/weatherUpdate.glsl | 16 ++++ codemp/rd-rend2/tr_glsl.cpp | 103 +++++++++++++++++------- codemp/rd-rend2/tr_local.h | 15 +++- 3 files changed, 105 insertions(+), 29 deletions(-) create mode 100644 codemp/rd-rend2/glsl/weatherUpdate.glsl diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl new file mode 100644 index 0000000000..04599cd240 --- /dev/null +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -0,0 +1,16 @@ +/*[Vertex]*/ + +uniform float u_Gravity; +uniform float u_DeltaTime; + +in vec3 attr_Position; +in vec3 attr_Velocity; + +out vec3 xfb_Position; +out vec3 xfb_Velocity; + +void main() +{ + xfb_Position = attr_Position; + xfb_Velocity = attr_Velocity; +} diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 99b0caa8d3..4430669888 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -551,20 +551,28 @@ static void GLSL_BindShaderInterface( shaderProgram_t *program ) "attr_Normal2", // ATTR_INDEX_NORMAL2 }; + static const char *xfbVarNames[XFB_VAR_COUNT] = { + "xfb_Position", + "xfb_Velocity", + }; + static const char *shaderOutputNames[] = { "out_Color", // Color output "out_Glow", // Glow output }; const uint32_t attribs = program->attribs; - for ( int attribIndex = 0; attribIndex < ATTR_INDEX_MAX; ++attribIndex ) + if (attribs != 0) { - if ( !(attribs & (1u << attribIndex)) ) + for ( int attribIndex = 0; attribIndex < ATTR_INDEX_MAX; ++attribIndex ) { - continue; - } + if ( !(attribs & (1u << attribIndex)) ) + { + continue; + } - qglBindAttribLocation(program->program, attribIndex, shaderInputNames[attribIndex]); + qglBindAttribLocation(program->program, attribIndex, shaderInputNames[attribIndex]); + } } for ( int outputIndex = 0; outputIndex < ARRAY_LEN(shaderOutputNames); ++outputIndex ) @@ -572,6 +580,23 @@ static void GLSL_BindShaderInterface( shaderProgram_t *program ) qglBindFragDataLocation(program->program, outputIndex, shaderOutputNames[outputIndex]); } + const uint32_t xfbVars = program->xfbVariables; + if (xfbVars != 0) + { + size_t activeXfbVarsCount = 0; + const char *activeXfbVarNames[XFB_VAR_COUNT] = {}; + + for (uint32_t xfbVarIndex = 0; xfbVarIndex < XFB_VAR_COUNT; ++xfbVarIndex) + { + if ((xfbVars & (1u << xfbVarIndex)) != 0) + { + activeXfbVarNames[activeXfbVarsCount++] = xfbVarNames[xfbVarIndex]; + } + } + + qglTransformFeedbackVaryings( + program->program, activeXfbVarsCount, activeXfbVarNames, GL_INTERLEAVED_ATTRIBS); + } } GLenum ToGLShaderType( GPUShaderType type ) @@ -601,12 +626,15 @@ class ShaderProgramBuilder ShaderProgramBuilder(); ~ShaderProgramBuilder(); - ShaderProgramBuilder( const ShaderProgramBuilder& ) = delete; - ShaderProgramBuilder& operator=( const ShaderProgramBuilder& ) = delete; + ShaderProgramBuilder(const ShaderProgramBuilder&) = delete; + ShaderProgramBuilder& operator=(const ShaderProgramBuilder&) = delete; - void Start( const char *name, const uint32_t attribs ); - bool AddShader( const GPUShaderDesc& shaderDesc, const char *extra ); - bool Build( shaderProgram_t *program ); + void Start( + const char *name, + const uint32_t attribs, + const uint32_t xfbVariables); + bool AddShader(const GPUShaderDesc& shaderDesc, const char *extra); + bool Build(shaderProgram_t *program); private: static const size_t MAX_SHADER_SOURCE_LEN = 16384; @@ -615,6 +643,7 @@ class ShaderProgramBuilder const char *name; uint32_t attribs; + uint32_t xfbVariables; GLuint program; GLuint shaderNames[GPUSHADER_TYPE_COUNT]; size_t numShaderNames; @@ -640,11 +669,15 @@ ShaderProgramBuilder::~ShaderProgramBuilder() } } -void ShaderProgramBuilder::Start( const char *name, const uint32_t attribs ) +void ShaderProgramBuilder::Start( + const char *name, + const uint32_t attribs, + const uint32_t xfbVariables) { this->program = qglCreateProgram(); this->name = name; this->attribs = attribs; + this->xfbVariables = xfbVariables; } bool ShaderProgramBuilder::AddShader( const GPUShaderDesc& shaderDesc, const char *extra ) @@ -744,10 +777,11 @@ static bool GLSL_LoadGPUShader( shaderProgram_t *program, const char *name, const uint32_t attribs, + const uint32_t xfbVariables, const GLcharARB *extra, const GPUProgramDesc& programDesc) { - builder.Start(name, attribs); + builder.Start(name, attribs, xfbVariables); for ( int i = 0; i < programDesc.numShaders; ++i ) { const GPUShaderDesc& shaderDesc = programDesc.shaders[i]; @@ -1296,7 +1330,7 @@ static int GLSL_LoadGPUProgramGeneric( if (i & GENERICDEF_USE_ALPHA_TEST) Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); - if (!GLSL_LoadGPUShader(builder, &tr.genericShader[i], "generic", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.genericShader[i], "generic", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load generic shader!"); @@ -1353,7 +1387,7 @@ static int GLSL_LoadGPUProgramFogPass( if (i & FOGDEF_USE_ALPHA_TEST) Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); - if (!GLSL_LoadGPUShader(builder, &tr.fogShader[i], "fogpass", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.fogShader[i], "fogpass", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load fogpass shader!"); @@ -1389,7 +1423,7 @@ static int GLSL_LoadGPUProgramDLight( if (i & DLIGHTDEF_USE_ALPHA_TEST) Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); - if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load dlight shader!"); @@ -1532,7 +1566,7 @@ static int GLSL_LoadGPUProgramLightAll( if (i & LIGHTDEF_USE_GLOW_BUFFER) Q_strcat(extradefines, sizeof(extradefines), "#define USE_GLOW_BUFFER\n"); - if (!GLSL_LoadGPUShader(builder, &tr.lightallShader[i], "lightall", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.lightallShader[i], "lightall", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load lightall shader!"); @@ -1565,13 +1599,14 @@ static int GLSL_LoadGPUProgramBasic( shaderProgram_t *shaderProgram, const char *programName, const GPUProgramDesc& programFallback, - const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0) + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0, + const uint32_t xfbVariables = NO_XFB_VARS) { Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); const GPUProgramDesc *programDesc = LoadProgramSource(programName, allocator, programFallback); - if (!GLSL_LoadGPUShader(builder, shaderProgram, programName, attribs, + if (!GLSL_LoadGPUShader(builder, shaderProgram, programName, attribs, xfbVariables, nullptr, *programDesc)) { ri.Error(ERR_FATAL, "Could not load %s shader!", programName); @@ -1616,7 +1651,7 @@ static int GLSL_LoadGPUProgramDepthFill( ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; extradefines[0] = '\0'; - if (!GLSL_LoadGPUShader(builder, &tr.shadowmapShader, "shadowfill", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.shadowmapShader, "shadowfill", attribs, NO_XFB_VARS, nullptr, *programDesc)) { ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); @@ -1642,7 +1677,7 @@ static int GLSL_LoadGPUProgramPShadow( extradefines[0] = '\0'; Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); - if (!GLSL_LoadGPUShader(builder, &tr.pshadowShader, "pshadow", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.pshadowShader, "pshadow", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load pshadow shader!"); @@ -1745,7 +1780,7 @@ static int GLSL_LoadGPUProgramCalcLuminanceLevel( Q_strcat(extradefines, sizeof(extradefines), "#define FIRST_PASS\n"); if (!GLSL_LoadGPUShader(builder, &tr.calclevels4xShader[i], "calclevels4x", attribs, - extradefines, *programDesc)) + NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load calclevels4x shader!"); } @@ -1791,7 +1826,7 @@ static int GLSL_LoadGPUProgramShadowMask( extradefines, sizeof(extradefines), va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - if (!GLSL_LoadGPUShader(builder, &tr.shadowmaskShader, "shadowmask", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.shadowmaskShader, "shadowmask", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); @@ -1876,7 +1911,7 @@ static int GLSL_LoadGPUProgramDepthBlur( Q_strcat(extradefines, sizeof(extradefines), "#define USE_HORIZONTAL_BLUR\n"); - if (!GLSL_LoadGPUShader(builder, &tr.depthBlurShader[i], "depthBlur", attribs, + if (!GLSL_LoadGPUShader(builder, &tr.depthBlurShader[i], "depthBlur", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load depthBlur shader!"); @@ -1912,13 +1947,13 @@ static int GLSL_LoadGPUProgramGaussianBlur( Q_strcat (extradefines, sizeof (extradefines), "#define BLUR_X"); if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[0], "gaussian_blur", attribs, - extradefines, *programDesc)) + NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load gaussian_blur (X-direction) shader!"); } if (!GLSL_LoadGPUShader(builder, &tr.gaussianBlurShader[1], "gaussian_blur", attribs, - nullptr, *programDesc)) + NO_XFB_VARS, nullptr, *programDesc)) { ri.Error(ERR_FATAL, "Could not load gaussian_blur (Y-direction) shader!"); } @@ -1998,7 +2033,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( "#define ALPHA_TEST\n"); shaderProgram_t *program = tr.spriteShader + i; - if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, + if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, NO_XFB_VARS, extradefines, *programDesc)) { ri.Error(ERR_FATAL, "Could not load surface sprites shader!"); @@ -2027,6 +2062,18 @@ static int GLSL_LoadGPUProgramWeather( GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.weatherUpdateShader, + "weatherUpdate", + fallback_weatherUpdateProgram, + ATTR_POSITION | ATTR_COLOR, + XFB_VAR_POSITION | XFB_VAR_VELOCITY); + + GLSL_InitUniforms(&tr.weatherUpdateShader); + GLSL_FinishGPUShader(&tr.weatherUpdateShader); + return 1; } @@ -2164,11 +2211,13 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < 2; i++) GLSL_DeleteGPUShader(&tr.depthBlurShader[i]); + GLSL_DeleteGPUShader(&tr.weatherUpdateShader); + GLSL_DeleteGPUShader(&tr.weatherShader); + glState.currentProgram = 0; qglUseProgram(0); } - void GLSL_BindProgram(shaderProgram_t * program) { if(!program) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 95123b81db..c91cd26cf0 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -343,6 +343,15 @@ enum ATTR_INDEX_MAX }; +enum +{ + XFB_VAR_POSITION, + XFB_VAR_VELOCITY, + + XFB_VAR_COUNT +}; +static const int NO_XFB_VARS = 0; + typedef struct image_s { char imgName[MAX_QPATH]; // game path, including extension int width, height; // source image @@ -1244,14 +1253,15 @@ struct UniformData //char data[1]; }; -// shaderProgram_t represents a pair of one -// GLSL vertex and one GLSL fragment shader +// shaderProgram_t represents a collection of GLSL shaders which form a +// GLSL shader program typedef struct shaderProgram_s { char *name; GLuint program; uint32_t attribs; // vertex array attributes + uint32_t xfbVariables; // transform feedback variables // uniform parameters GLint *uniforms; @@ -2269,6 +2279,7 @@ typedef struct trGlobals_s { shaderProgram_t dglowDownsample; shaderProgram_t dglowUpsample; shaderProgram_t spriteShader[SSDEF_COUNT]; + shaderProgram_t weatherUpdateShader; shaderProgram_t weatherShader; // ----------------------------------------- From 1babc71fef783a1b9b138121273d348775b9b2d6 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 12 May 2018 14:07:03 +0100 Subject: [PATCH 447/708] Delete leaking shader programs --- codemp/rd-rend2/tr_glsl.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 4430669888..dd76774f96 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2211,6 +2211,19 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < 2; i++) GLSL_DeleteGPUShader(&tr.depthBlurShader[i]); + GLSL_DeleteGPUShader(&tr.testcubeShader); + GLSL_DeleteGPUShader(&tr.prefilterEnvMapShader); + + for (i = 0; i < 2; ++i) + GLSL_DeleteGPUShader(&tr.gaussianBlurShader[i]); + + GLSL_DeleteGPUShader(&tr.glowCompositeShader); + GLSL_DeleteGPUShader(&tr.dglowDownsample); + GLSL_DeleteGPUShader(&tr.dglowUpsample); + + for (i = 0; i < SSDEF_COUNT; ++i) + GLSL_DeleteGPUShader(&tr.spriteShader[i]); + GLSL_DeleteGPUShader(&tr.weatherUpdateShader); GLSL_DeleteGPUShader(&tr.weatherShader); From 62957ddb0d42bc24345d529e2fb413e30da11a47 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 12 May 2018 16:07:32 +0100 Subject: [PATCH 448/708] Add transform feedback flag to DrawItem --- codemp/rd-rend2/tr_backend.cpp | 26 ++++++++++++++++++++++---- codemp/rd-rend2/tr_local.h | 11 +++++++++-- codemp/rd-rend2/tr_shade.cpp | 22 +++++++++++----------- codemp/rd-rend2/tr_sky.cpp | 4 ++-- codemp/rd-rend2/tr_surface.cpp | 6 +++--- codemp/rd-rend2/tr_weather.cpp | 6 +++--- 6 files changed, 50 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index b84db3fe95..271d9a6ac6 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -941,6 +941,20 @@ static void RB_BindAndUpdateUniformBlocks( } } +static void RB_SetRenderState(const RenderState& renderState) +{ + GL_Cull(renderState.cullType); + GL_State(renderState.stateBits); + GL_DepthRange( + renderState.depthRange.minDepth, + renderState.depthRange.maxDepth); + + if (renderState.transformFeedback) + { + qglBeginTransformFeedback(GL_POINTS); + } +} + static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, @@ -950,10 +964,9 @@ static void RB_DrawItems( { const DrawItem& drawItem = drawItems[drawOrder[i]]; - GL_Cull(drawItem.cullType); - GL_State(drawItem.stateBits); - GL_DepthRange(drawItem.depthRange.minDepth, drawItem.depthRange.maxDepth); - if ( drawItem.ibo != nullptr ) + RB_SetRenderState(drawItem.renderState); + + if (drawItem.ibo != nullptr) R_BindIBO(drawItem.ibo); GLSL_BindProgram(drawItem.program); @@ -1003,6 +1016,11 @@ static void RB_DrawItems( break; } } + + if (drawItem.renderState.transformFeedback) + { + qglEndTransformFeedback(); + } } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c91cd26cf0..36eee653f0 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3493,11 +3493,18 @@ struct DrawCommand } params; }; -struct DrawItem +struct RenderState { + DepthRange depthRange; uint32_t stateBits; uint32_t cullType; // this is stupid - DepthRange depthRange; + + bool transformFeedback; +}; + +struct DrawItem +{ + RenderState renderState; IBO_t *ibo; shaderProgram_t *program; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 4447722a38..d0b0690975 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1016,10 +1016,10 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light // where they aren't rendered - item.stateBits = stateBits; - item.cullType = cullType; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; - item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1185,10 +1185,10 @@ static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexA stateBits |= GLS_DEPTHFUNC_EQUAL; DrawItem item = {}; - item.stateBits = stateBits; - item.cullType = cullType; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; - item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1683,10 +1683,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays CaptureDrawData(input, pStage, index, stage); DrawItem item = {}; - item.stateBits = stateBits; - item.cullType = cullType; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; - item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1741,9 +1741,9 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); DrawItem item = {}; - item.cullType = cullType; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); + item.renderState.cullType = cullType; item.program = sp; - item.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index def1fad7b5..55a1bc774b 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -453,9 +453,9 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max samplerBindingsWriter.AddStaticImage(image, TB_DIFFUSEMAP); DrawItem item = {}; - item.cullType = CT_TWO_SIDED; + item.renderState.cullType = CT_TWO_SIDED; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, tess.shader); item.program = sp; - item.depthRange = RB_GetDepthRange(backEnd.currentEntity, tess.shader); item.ibo = backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays.numVertexArrays; item.attributes = ojkAllocArray( diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 6e458d02dd..db927c525a 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2180,10 +2180,10 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) samplerBindingsWriter.AddAnimatedImage(&firstStage->bundle[0], TB_COLORMAP); DrawItem item = {}; - item.stateBits = firstStage->stateBits; - item.cullType = CT_TWO_SIDED; + item.renderState.stateBits = firstStage->stateBits; + item.renderState.cullType = CT_TWO_SIDED; + item.renderState.depthRange = DepthRange{0.0f, 1.0f}; item.program = program; - item.depthRange = DepthRange{0.0f, 1.0f}; item.ibo = surf->ibo; tess.externalIBO = surf->ibo; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 684dccf468..8fbaac173e 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -130,11 +130,11 @@ void RB_SurfaceWeather( srfWeather_t *surf ) uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - item.stateBits = + item.renderState.stateBits = GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - item.cullType = CT_FRONT_SIDED; + item.renderState.cullType = CT_FRONT_SIDED; + item.renderState.depthRange = { 0.0f, 1.0f }; item.program = &tr.weatherShader; - item.depthRange = { 0.0f, 1.0f }; vertexAttribute_t attribs[2] = {}; attribs[0].index = ATTR_INDEX_POSITION; From f70b8a34b7e83128a9a3c6302bb1535e7a63ac73 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 13 May 2018 15:52:09 +0100 Subject: [PATCH 449/708] Remove redundant calls to glVertexAttribDivisor Thanks to @SomaZ for pointing this out a while ago. --- codemp/rd-rend2/tr_backend.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 271d9a6ac6..a978f4ed1b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -341,10 +341,10 @@ void GL_VertexAttribPointers( for ( int i = 0; i < numAttributes; i++ ) { vertexAttribute_t& attrib = attributes[i]; + vertexAttribute_t& currentAttrib = glState.currentVaoAttribs[attrib.index]; newAttribs |= (1 << attrib.index); - if ( memcmp(&glState.currentVaoAttribs[attrib.index], &attrib, - sizeof(glState.currentVaoAttribs[attrib.index])) == 0 ) + if (memcmp(¤tAttrib, &attrib, sizeof(currentAttrib)) == 0) { // No change continue; @@ -368,9 +368,11 @@ void GL_VertexAttribPointers( attrib.stride, BUFFER_OFFSET(attrib.offset)); } - qglVertexAttribDivisor(attrib.index, attrib.stepRate); - glState.currentVaoAttribs[attrib.index] = attrib; + if (currentAttrib.stepRate != attrib.stepRate) + qglVertexAttribDivisor(attrib.index, attrib.stepRate); + + currentAttrib = attrib; } uint32_t diff = newAttribs ^ glState.vertexAttribsState; From c642c5bc267e26a77d5adf2e565dce7b1fd6c537 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 13 May 2018 16:36:06 +0100 Subject: [PATCH 450/708] Tentative work for rain simulation via xfb --- codemp/rd-rend2/glsl/weather.glsl | 21 +----- codemp/rd-rend2/glsl/weatherUpdate.glsl | 12 ++-- codemp/rd-rend2/tr_backend.cpp | 16 +++++ codemp/rd-rend2/tr_glsl.cpp | 92 +++++++++++++++---------- codemp/rd-rend2/tr_local.h | 6 +- codemp/rd-rend2/tr_vbo.cpp | 3 + codemp/rd-rend2/tr_weather.cpp | 86 +++++++++++++++++++---- 7 files changed, 160 insertions(+), 76 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 211c985ada..e80b69b0f7 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,28 +1,9 @@ /*[Vertex]*/ in vec3 attr_Position; -in vec3 attr_Color; - -uniform vec2 u_MapZExtents; -uniform float u_Time; -uniform vec3 u_ViewOrigin; void main() { - int z = gl_InstanceID / 25; - int remaining = gl_InstanceID - (z * 25); - int y = remaining % 5; - int x = remaining / 5; - - float zOffset = mod( - 1000.0 * float(z) + u_Time * 1000.0, - u_MapZExtents.y - u_MapZExtents.x - 2000.0); - vec3 offset = vec3( - 1000.0 * float(x - 2), - 1000.0 * float(y - 2), - u_MapZExtents.y - zOffset); - offset.xy += attr_Color.xy * u_Time; - - gl_Position = vec4(attr_Position + offset, 1.0); + gl_Position = vec4(attr_Position, 1.0); } /*[Geometry]*/ diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 04599cd240..ad02f79786 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -4,13 +4,15 @@ uniform float u_Gravity; uniform float u_DeltaTime; in vec3 attr_Position; -in vec3 attr_Velocity; +in vec3 attr_Color; -out vec3 xfb_Position; -out vec3 xfb_Velocity; +out vec3 var_Position; +out vec3 var_Velocity; void main() { - xfb_Position = attr_Position; - xfb_Velocity = attr_Velocity; + var_Position = attr_Position; + var_Position.z -= 0.05; + + var_Velocity = attr_Color; } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a978f4ed1b..a2d0bca2a5 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -953,10 +953,24 @@ static void RB_SetRenderState(const RenderState& renderState) if (renderState.transformFeedback) { + qglEnable(GL_RASTERIZER_DISCARD); qglBeginTransformFeedback(GL_POINTS); } } +static void RB_BindTransformFeedbackBuffer(VBO_t *buffer) +{ + if (glState.currentXFBBO != buffer) + { + if (buffer != nullptr) + qglBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffer->vertexesVBO); + else + qglBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0); + + glState.currentXFBBO = buffer; + } +} + static void RB_DrawItems( int numDrawItems, const DrawItem *drawItems, @@ -978,6 +992,7 @@ static void RB_DrawItems( RB_BindAndUpdateUniformBlocks( drawItem.numUniformBlockBindings, drawItem.uniformBlockBindings); + RB_BindTransformFeedbackBuffer(drawItem.transformFeedbackBuffer); GLSL_SetUniforms(drawItem.program, drawItem.uniformData); @@ -1022,6 +1037,7 @@ static void RB_DrawItems( if (drawItem.renderState.transformFeedback) { qglEndTransformFeedback(); + qglDisable(GL_RASTERIZER_DISCARD); } } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index dd76774f96..d57bdd8618 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -552,8 +552,8 @@ static void GLSL_BindShaderInterface( shaderProgram_t *program ) }; static const char *xfbVarNames[XFB_VAR_COUNT] = { - "xfb_Position", - "xfb_Velocity", + "var_Position", + "var_Velocity", }; static const char *shaderOutputNames[] = { @@ -751,6 +751,7 @@ bool ShaderProgramBuilder::Build( shaderProgram_t *shaderProgram ) shaderProgram->program = program; shaderProgram->attribs = attribs; + shaderProgram->xfbVariables = xfbVariables; GLSL_BindShaderInterface(shaderProgram); GLSL_LinkProgram(shaderProgram->program); @@ -866,6 +867,9 @@ void GLSL_FinishGPUShader(shaderProgram_t *program) void GLSL_SetUniforms( shaderProgram_t *program, UniformData *uniformData ) { UniformData *data = uniformData; + if (data == nullptr) + return; + while ( data->index != UNIFORM_COUNT ) { switch ( uniformsInfo[data->index].type ) @@ -1593,12 +1597,13 @@ static int GLSL_LoadGPUProgramLightAll( return numPrograms; } -static int GLSL_LoadGPUProgramBasic( +static int GLSL_LoadGPUProgramBasicWithDefinitions( ShaderProgramBuilder& builder, Allocator& scratchAlloc, shaderProgram_t *shaderProgram, const char *programName, const GPUProgramDesc& programFallback, + const char *extraDefines, const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0, const uint32_t xfbVariables = NO_XFB_VARS) { @@ -1606,8 +1611,14 @@ static int GLSL_LoadGPUProgramBasic( const GPUProgramDesc *programDesc = LoadProgramSource(programName, allocator, programFallback); - if (!GLSL_LoadGPUShader(builder, shaderProgram, programName, attribs, xfbVariables, - nullptr, *programDesc)) + if (!GLSL_LoadGPUShader( + builder, + shaderProgram, + programName, + attribs, + xfbVariables, + extraDefines, + *programDesc)) { ri.Error(ERR_FATAL, "Could not load %s shader!", programName); } @@ -1615,6 +1626,25 @@ static int GLSL_LoadGPUProgramBasic( return 1; } +static int GLSL_LoadGPUProgramBasic( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc, + shaderProgram_t *shaderProgram, + const char *programName, + const GPUProgramDesc& programFallback, + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0, + const uint32_t xfbVariables = NO_XFB_VARS) +{ + return GLSL_LoadGPUProgramBasicWithDefinitions( + builder, + scratchAlloc, + shaderProgram, + programName, + programFallback, + nullptr, + attribs, + xfbVariables); +} static int GLSL_LoadGPUProgramTextureColor( ShaderProgramBuilder& builder, @@ -1642,20 +1672,13 @@ static int GLSL_LoadGPUProgramDepthFill( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) { - Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - - char extradefines[1200]; - const GPUProgramDesc *programDesc = - LoadProgramSource("shadowfill", allocator, fallback_shadowfillProgram); - const uint32_t attribs = - ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0; - - extradefines[0] = '\0'; - if (!GLSL_LoadGPUShader(builder, &tr.shadowmapShader, "shadowfill", attribs, NO_XFB_VARS, - nullptr, *programDesc)) - { - ri.Error(ERR_FATAL, "Could not load shadowfill shader!"); - } + GLSL_LoadGPUProgramBasic( + builder, + scratchAlloc, + &tr.shadowmapShader, + "shadowfill", + fallback_shadowfillProgram, + ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0); GLSL_InitUniforms(&tr.shadowmapShader); GLSL_FinishGPUShader(&tr.shadowmapShader); @@ -1667,21 +1690,16 @@ static int GLSL_LoadGPUProgramPShadow( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) { - Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - - char extradefines[1200]; - const GPUProgramDesc *programDesc = - LoadProgramSource("pshadow", allocator, fallback_pshadowProgram); - const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL; - - extradefines[0] = '\0'; - Q_strcat(extradefines, sizeof(extradefines), "#define USE_PCF\n#define USE_DISCARD\n"); + const char *extradefines = "#define USE_PCF\n#define USE_DISCARD\n"; - if (!GLSL_LoadGPUShader(builder, &tr.pshadowShader, "pshadow", attribs, NO_XFB_VARS, - extradefines, *programDesc)) - { - ri.Error(ERR_FATAL, "Could not load pshadow shader!"); - } + GLSL_LoadGPUProgramBasicWithDefinitions( + builder, + scratchAlloc, + &tr.pshadowShader, + "pshadow", + fallback_pshadowProgram, + extradefines, + ATTR_POSITION | ATTR_NORMAL); GLSL_InitUniforms(&tr.pshadowShader); @@ -2057,24 +2075,26 @@ static int GLSL_LoadGPUProgramWeather( &tr.weatherShader, "weather", fallback_weatherProgram, - ATTR_POSITION | ATTR_COLOR); + ATTR_POSITION); GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); - GLSL_LoadGPUProgramBasic( + const char *extradefines = "#define DO_PARTICLE_UPDATE\n"; + GLSL_LoadGPUProgramBasicWithDefinitions( builder, scratchAlloc, &tr.weatherUpdateShader, "weatherUpdate", fallback_weatherUpdateProgram, + extradefines, ATTR_POSITION | ATTR_COLOR, XFB_VAR_POSITION | XFB_VAR_VELOCITY); GLSL_InitUniforms(&tr.weatherUpdateShader); GLSL_FinishGPUShader(&tr.weatherUpdateShader); - return 1; + return 2; } void GLSL_LoadGPUShaders() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 36eee653f0..29636f719d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -408,7 +408,8 @@ typedef struct { typedef enum { VBO_USAGE_STATIC, - VBO_USAGE_DYNAMIC + VBO_USAGE_DYNAMIC, + VBO_USAGE_XFB } vboUsage_t; typedef struct VBO_s @@ -2020,6 +2021,7 @@ typedef struct glstate_s { FBO_t *currentFBO; VBO_t *currentVBO; IBO_t *currentIBO; + VBO_t *currentXFBBO; matrix_t modelview; matrix_t projection; matrix_t modelviewProjection; @@ -3518,6 +3520,8 @@ struct DrawItem uint32_t numUniformBlockBindings; UniformBlockBinding *uniformBlockBindings; + VBO_t *transformFeedbackBuffer; + UniformData *uniformData; DrawCommand draw; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 0ee601468a..b6029aad6a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -64,6 +64,9 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) case VBO_USAGE_DYNAMIC: return GL_STREAM_DRAW; + case VBO_USAGE_XFB: + return GL_STREAM_COPY; + default: ri.Error (ERR_FATAL, "bad vboUsage_t given: %i", usage); return GL_INVALID_OPERATION; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 8fbaac173e..f9e6cb334d 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -20,10 +20,13 @@ along with this program; if not, see . #include "tr_weather.h" #include "tr_local.h" +#include struct weatherSystem_t { + VBO_t *lastVBO; VBO_t *vbo; + unsigned vboLastUpdateFrame; int numVertices; srfWeather_t weatherSurface; @@ -34,7 +37,7 @@ namespace struct rainVertex_t { vec3_t position; - vec3_t seed; + vec3_t velocity; }; void GenerateRainModel( weatherSystem_t& ws ) @@ -48,13 +51,66 @@ namespace vertex.position[0] = Q_flrand(-1000.0f, 1000.0f); vertex.position[1] = Q_flrand(-1000.0f, 1000.0f); vertex.position[2] = Q_flrand(-1000.0f, 1000.0f); - vertex.seed[0] = Q_flrand(-2.0f, 2.0f); - vertex.seed[1] = Q_flrand(-2.0f, 2.0f); - vertex.seed[2] = Q_flrand(-20.0f, 0.0f); + vertex.velocity[0] = Q_flrand(-2.0f, 2.0f); + vertex.velocity[1] = Q_flrand(-2.0f, 2.0f); + vertex.velocity[2] = Q_flrand(-20.0f, 0.0f); } - ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_STATIC); + ws.lastVBO = R_CreateVBO(nullptr, sizeof(rainVertices), VBO_USAGE_XFB); + ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_XFB); ws.numVertices = MAX_RAIN_VERTICES; + ws.vboLastUpdateFrame = 0; + } + + void RB_SimulateWeather(weatherSystem_t& ws) + { + if (ws.vboLastUpdateFrame == backEndData->realFrameNumber) + { + // Already simulated for this frame + return; + } + + // Intentionally switched. Previous frame's VBO would be in ws.vbo and + // this frame's VBO would be ws.lastVBO. + VBO_t *lastRainVBO = ws.vbo; + VBO_t *rainVBO = ws.lastVBO; + + vertexAttribute_t attribs[2] = {}; + attribs[0].index = ATTR_INDEX_POSITION; + attribs[0].numComponents = 3; + attribs[0].offset = offsetof(rainVertex_t, position); + attribs[0].stride = sizeof(rainVertex_t); + attribs[0].type = GL_FLOAT; + attribs[0].vbo = lastRainVBO; + attribs[1].index = ATTR_INDEX_COLOR; + attribs[1].numComponents = 3; + attribs[1].offset = offsetof(rainVertex_t, velocity); + attribs[1].stride = sizeof(rainVertex_t); + attribs[1].type = GL_FLOAT; + attribs[1].vbo = lastRainVBO; + + const size_t numAttribs = ARRAY_LEN(attribs); + + DrawItem item = {}; + item.renderState.transformFeedback = true; + item.transformFeedbackBuffer = rainVBO; + item.program = &tr.weatherUpdateShader; + item.numAttributes = numAttribs; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, numAttribs); + memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); + item.draw.type = DRAW_COMMAND_ARRAYS; + item.draw.numInstances = 1; + item.draw.primitiveType = GL_POINTS; + item.draw.params.arrays.numVertices = ws.numVertices; + + // This is a bit dodgy. Push this towards the front of the queue so we + // guarantee this happens before the actual drawing + const uint32_t key = RB_CreateSortKey(item, 0, SS_OPAQUE); + RB_AddDrawItem(backEndData->currentPass, key, item); + + ws.vboLastUpdateFrame = backEndData->realFrameNumber; + std::swap(ws.lastVBO, ws.vbo); } } @@ -87,7 +143,7 @@ void R_AddWeatherSurfaces() { assert(tr.weatherSystem); - if (false) + if (true) { R_AddDrawSurf( (surfaceType_t *)&tr.weatherSystem->weatherSurface, @@ -105,26 +161,27 @@ void RB_SurfaceWeather( srfWeather_t *surf ) { assert(tr.weatherSystem); - const weatherSystem_t& ws = *tr.weatherSystem; + weatherSystem_t& ws = *tr.weatherSystem; assert(surf == &ws.weatherSurface); RB_EndSurface(); + RB_SimulateWeather(ws); + DrawItem item = {}; SamplerBindingsWriter samplerBindingsWriter; - // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, - glState.modelviewProjection); + UNIFORM_MODELVIEWPROJECTIONMATRIX, + glState.modelviewProjection); uniformDataWriter.SetUniformVec3( - UNIFORM_VIEWORIGIN, - backEnd.viewParms.ori.origin); + UNIFORM_VIEWORIGIN, + backEnd.viewParms.ori.origin); const vec2_t mapZExtents = { -3000.0, 9000.0 }; uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); @@ -143,9 +200,10 @@ void RB_SurfaceWeather( srfWeather_t *surf ) attribs[0].stride = sizeof(rainVertex_t); attribs[0].type = GL_FLOAT; attribs[0].vbo = ws.vbo; + attribs[1].index = ATTR_INDEX_COLOR; attribs[1].numComponents = 3; - attribs[1].offset = offsetof(rainVertex_t, seed); + attribs[1].offset = offsetof(rainVertex_t, velocity); attribs[1].stride = sizeof(rainVertex_t); attribs[1].type = GL_FLOAT; attribs[1].vbo = ws.vbo; @@ -157,7 +215,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); item.draw.type = DRAW_COMMAND_ARRAYS; - item.draw.numInstances = 225; + item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; item.draw.params.arrays.numVertices = ws.numVertices; From 565323e28324a888d87ccdc075967b36557cbb82 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 13 May 2018 17:33:26 +0100 Subject: [PATCH 451/708] Fix transform feedback for weather --- codemp/rd-rend2/glsl/weather.glsl | 6 ++++++ codemp/rd-rend2/glsl/weatherUpdate.glsl | 7 ++++--- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_glsl.cpp | 4 ++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index e80b69b0f7..f943d8ff4d 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,9 +1,13 @@ /*[Vertex]*/ in vec3 attr_Position; +in vec3 attr_Color; // velocity + +out vec3 var_Velocity; void main() { gl_Position = vec4(attr_Position, 1.0); + var_Velocity = attr_Color; } /*[Geometry]*/ @@ -13,6 +17,8 @@ layout(triangle_strip, max_vertices = 4) out; uniform mat4 u_ModelViewProjectionMatrix; uniform vec3 u_ViewOrigin; +in vec3 var_Velocity[]; + void main() { const vec2 offsets[] = vec2[]( diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index ad02f79786..dfd4ef1c28 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -11,8 +11,9 @@ out vec3 var_Velocity; void main() { - var_Position = attr_Position; - var_Position.z -= 0.05; - var_Velocity = attr_Color; + var_Position = attr_Position + var_Velocity * 10.0; + + if (var_Position.z < -200.0) + var_Position.z = 3000.0; } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index a2d0bca2a5..ac2024afbf 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -980,8 +980,6 @@ static void RB_DrawItems( { const DrawItem& drawItem = drawItems[drawOrder[i]]; - RB_SetRenderState(drawItem.renderState); - if (drawItem.ibo != nullptr) R_BindIBO(drawItem.ibo); @@ -996,6 +994,8 @@ static void RB_DrawItems( GLSL_SetUniforms(drawItem.program, drawItem.uniformData); + RB_SetRenderState(drawItem.renderState); + switch ( drawItem.draw.type ) { case DRAW_COMMAND_MULTI_INDEXED: diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d57bdd8618..3cf9e150dd 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2075,7 +2075,7 @@ static int GLSL_LoadGPUProgramWeather( &tr.weatherShader, "weather", fallback_weatherProgram, - ATTR_POSITION); + ATTR_POSITION | ATTR_COLOR); GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); @@ -2089,7 +2089,7 @@ static int GLSL_LoadGPUProgramWeather( fallback_weatherUpdateProgram, extradefines, ATTR_POSITION | ATTR_COLOR, - XFB_VAR_POSITION | XFB_VAR_VELOCITY); + (1u << XFB_VAR_POSITION) | (1u << XFB_VAR_VELOCITY)); GLSL_InitUniforms(&tr.weatherUpdateShader); GLSL_FinishGPUShader(&tr.weatherUpdateShader); From 7787acf48a732636c255de9ea2fc736b5c7f70bb Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 13 May 2018 17:36:21 +0100 Subject: [PATCH 452/708] Remove DO_PARTICLE_UPDATE definition --- codemp/rd-rend2/tr_glsl.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3cf9e150dd..56d133ba76 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2080,14 +2080,12 @@ static int GLSL_LoadGPUProgramWeather( GLSL_InitUniforms(&tr.weatherShader); GLSL_FinishGPUShader(&tr.weatherShader); - const char *extradefines = "#define DO_PARTICLE_UPDATE\n"; - GLSL_LoadGPUProgramBasicWithDefinitions( + GLSL_LoadGPUProgramBasic( builder, scratchAlloc, &tr.weatherUpdateShader, "weatherUpdate", fallback_weatherUpdateProgram, - extradefines, ATTR_POSITION | ATTR_COLOR, (1u << XFB_VAR_POSITION) | (1u << XFB_VAR_VELOCITY)); From 8d83f8654b5e2a3ce1c64dd9e367f76a9a6a5185 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 13 May 2018 21:04:09 +0200 Subject: [PATCH 453/708] added cubemap "bounces" means, cubemaps render twice instead of once, but the second time they render, the generated ones are used while rendering. With that, cubemap mirrors can be seen in cubemap reflections. Will also fix appearence of glossy metals in cubemaps. Also reworked the convolution process to avoid the use of the dynamicVbo and dynamicIbo (simply not using the RB_InstantQuad2 code, but instead simply rendering a triangle and transforming it in the shader). Also use hdr Images for cubemaps when r_hdr 1. --- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 29 ++++++++------ codemp/rd-rend2/tr_backend.cpp | 49 +++++------------------ codemp/rd-rend2/tr_bsp.cpp | 34 ++++++++++------ codemp/rd-rend2/tr_cmds.cpp | 3 +- codemp/rd-rend2/tr_image.cpp | 4 +- codemp/rd-rend2/tr_local.h | 7 ++-- codemp/rd-rend2/tr_main.cpp | 6 ++- codemp/rd-rend2/tr_scene.cpp | 2 +- codemp/rd-rend2/tr_surface.cpp | 6 +++ 9 files changed, 65 insertions(+), 75 deletions(-) diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index 842020bc4d..d0b665ec9d 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -6,8 +6,10 @@ out vec2 var_ScreenTex; void main() { - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; + vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0); + gl_Position = vec4(position, 0.0, 1.0); + vec2 screenCoords = gl_Position.xy / gl_Position.w; + var_ScreenTex = screenCoords * 0.5 + 0.5; } /*[Fragment]*/ @@ -78,17 +80,18 @@ void main() vec2 vector = (var_ScreenTex - vec2(0.5)) * 2.0; // from http://www.codinglabs.net/article_physically_based_rendering.aspx - vec3 normal = normalize( vec3(vector.xy, 1) ); - if(cubeFace==2) - normal = normalize( vec3(vector.x, 1, -vector.y) ); - else if(cubeFace==3) - normal = normalize( vec3(vector.x, -1, vector.y) ); - else if(cubeFace==0) - normal = normalize( vec3( 1, vector.y,-vector.x) ); - else if(cubeFace==1) - normal = normalize( vec3( -1, vector.y, vector.x) ); - else if(cubeFace==5) - normal = normalize( vec3(-vector.x, vector.y, -1) ); + vec3 normal = normalize(vec3(-vector.x, -vector.y, -1)); + + if (cubeFace == 0) + normal = normalize(vec3(1, -vector.y, -vector.x)); + else if (cubeFace == 1) + normal = normalize(vec3(-1, -vector.y, vector.x)); + else if (cubeFace == 2) + normal = normalize(vec3(vector.x, 1, vector.y)); + else if (cubeFace == 3) + normal = normalize(vec3(vector.x, -1, -vector.y)); + else if (cubeFace == 4) + normal = normalize(vec3(vector.x, -vector.y, 1)); float roughness = u_ViewInfo.w; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index ab76d124f3..d53dceedc3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -514,8 +514,8 @@ void RB_BeginDrawingView (void) { // FIXME: hack for cubemap testing if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { - //qglFramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, backEnd.viewParms.targetFbo->colorImage[0]->texnum, 0); - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]->texnum, 0); + image_t *cubemap = tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]; + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); } } @@ -1834,22 +1834,9 @@ static const void *RB_PrefilterEnvMap(const void *data) { image_t *cubemap = tr.cubemaps[cmd->cubemap]; - if (!cubemap) + if (!cubemap || !cmd) return (const void *)(cmd + 1); - vec4_t quadVerts[4]; - vec2_t texCoords[4]; - - VectorSet4(quadVerts[0], -1, 1, 0, 1); - VectorSet4(quadVerts[1], 1, 1, 0, 1); - VectorSet4(quadVerts[2], 1, -1, 0, 1); - VectorSet4(quadVerts[3], -1, -1, 0, 1); - - texCoords[0][0] = 0; texCoords[0][1] = 0; - texCoords[1][0] = 1; texCoords[1][1] = 0; - texCoords[2][0] = 1; texCoords[2][1] = 1; - texCoords[3][0] = 0; texCoords[3][1] = 1; - FBO_Bind(tr.preFilterEnvMapFbo); GL_BindToTMU(cubemap, TB_CUBEMAP); @@ -1864,14 +1851,12 @@ static const void *RB_PrefilterEnvMap(const void *data) { height = height / 2.0; qglViewport(0, 0, width, height); qglScissor(0, 0, width, height); - for (int cubemapSide = 0; cubemapSide < 6; cubemapSide++) - { - vec4_t viewInfo; - VectorSet4(viewInfo, cubemapSide, level, CUBE_MAP_MIPS, (level / (float)CUBE_MAP_MIPS)); - GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); - qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cubemapSide, level, 0, 0, 0, 0, width, height); - } + + vec4_t viewInfo; + VectorSet4(viewInfo, cmd->cubeSide, level, CUBE_MAP_MIPS, (level / (float)CUBE_MAP_MIPS)); + GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); + RB_InstantTriangle(); + qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, level, 0, 0, 0, 0, width, height); } return (const void *)(cmd + 1); @@ -2109,20 +2094,6 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) RB_ShadowFinish(); } -static void RB_GenerateMipmapsForCubemapFaceRender() -{ - if ( tr.renderCubeFbo == NULL || backEnd.viewParms.targetFbo != tr.renderCubeFbo ) - { - return; - } - - FBO_Bind(NULL); - GL_SelectTexture(TB_CUBEMAP); - GL_BindToTMU(tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex], TB_CUBEMAP); - qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); - GL_SelectTexture(0); -} - static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSurfs ) { if ( backEnd.refdef.rdflags & RDF_NOWORLDMODEL ) @@ -2218,8 +2189,6 @@ static const void *RB_DrawSurfs( const void *data ) { RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); - RB_GenerateMipmapsForCubemapFaceRender(); - return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5130825380..140852f05f 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2726,7 +2726,6 @@ static void R_AssignCubemapsToWorldSurfaces(world_t *worldData) static void R_RenderAllCubemaps(void) { - int i, j; GLenum cubemapFormat = GL_RGBA8; if ( r_hdr->integer ) @@ -2734,21 +2733,30 @@ static void R_RenderAllCubemaps(void) cubemapFormat = GL_RGBA16F; } - for (i = 0; i < tr.numCubemaps; i++) + int numberOfBounces = 1; + for (int k = 0; k <= numberOfBounces; k++) { - tr.cubemaps[i] = R_CreateImage (va ("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); - } - - for (i = 0; i < tr.numCubemaps; i++) - { - for (j = 0; j < 6; j++) + qboolean bounce = qboolean(k != 0); + for (int i = 0; i < tr.numCubemaps; i++) { - RE_ClearScene(); - R_RenderCubemapSide(i, j, qfalse); - R_IssuePendingRenderCommands(); - R_InitNextFrame(); + if (!bounce) + tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); + + for (int j = 0; j < 6; j++) + { + RE_ClearScene(); + R_RenderCubemapSide(i, j, qfalse, bounce); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + } + for (int j = 0; j < 6; j++) + { + RE_ClearScene(); + R_AddConvolveCubemapCmd(i, j); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + } } - R_AddConvolveCubemapCmd(i); } } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index ec4d45a450..2dab59527c 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -250,7 +250,7 @@ R_AddConvolveCubemapsCmd ============= */ -void R_AddConvolveCubemapCmd( int cubemap ) { +void R_AddConvolveCubemapCmd( int cubemap , int cubeSide ) { convolveCubemapCommand_t *cmd; cmd = (convolveCubemapCommand_t *)R_GetCommandBuffer( sizeof( *cmd )); @@ -260,6 +260,7 @@ void R_AddConvolveCubemapCmd( int cubemap ) { cmd->commandId = RC_CONVOLVECUBEMAP; cmd->cubemap = cubemap; + cmd->cubeSide = cubeSide; } /* diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 914e8bb0a0..4ebe241786 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3183,12 +3183,12 @@ void R_CreateBuiltinImages( void ) { IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, - rgbFormat); + hdrFormat); tr.prefilterEnvMapImage = R_CreateImage( "*prefilterEnvMapFbo", NULL, CUBE_MAP_SIZE / 2, CUBE_MAP_SIZE / 2, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - rgbFormat); + hdrFormat); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9b182cd1e3..ec5d5f2a50 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2541,7 +2541,7 @@ void R_RenderView( viewParms_t *parms ); void R_RenderDlightCubemaps(const refdef_t *fd); void R_RenderPshadowMaps(const refdef_t *fd); void R_RenderSunShadowMaps(const refdef_t *fd, int level); -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ); +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, qboolean bounce); void R_AddMD3Surfaces( trRefEntity_t *e, int entityNum ); void R_AddNullModelSurfaces( trRefEntity_t *e, int entityNum ); @@ -2781,8 +2781,8 @@ void RB_StageIteratorSky( void ); void RB_AddQuadStamp( vec3_t origin, vec3_t left, vec3_t up, float color[4] ); void RB_AddQuadStampExt( vec3_t origin, vec3_t left, vec3_t up, float color[4], float s1, float t1, float s2, float t2 ); void RB_InstantQuad( vec4_t quadVerts[4] ); -//void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4], vec4_t color, shaderProgram_t *sp, vec2_t invTexRes); void RB_InstantQuad2(vec4_t quadVerts[4], vec2_t texCoords[4]); +void RB_InstantTriangle(); void RB_ShowImages( void ); @@ -3243,6 +3243,7 @@ typedef struct capShadowmapCommand_s { typedef struct convolveCubemapCommand_s { int commandId; int cubemap; + int cubeSide; } convolveCubemapCommand_t; typedef struct postProcessCommand_s { @@ -3367,7 +3368,7 @@ void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); void R_AddCapShadowmapCmd( int dlight, int cubeSide ); -void R_AddConvolveCubemapCmd( int cubemap ); +void R_AddConvolveCubemapCmd( int cubemap , int cubeSide ); void R_AddPostProcessCmd (void); qhandle_t R_BeginTimedBlockCmd( const char *name ); void R_EndTimedBlockCmd( qhandle_t timerHandle ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1610bfba23..5a80decd77 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2812,7 +2812,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) } } -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, qboolean bounce ) { refdef_t refdef; viewParms_t parms; @@ -2894,7 +2894,9 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene ) parms.viewportHeight = tr.renderCubeFbo->height; parms.isPortal = qfalse; parms.isMirror = qtrue; - parms.flags = VPF_NOVIEWMODEL | VPF_NOCUBEMAPS | VPF_NOPOSTPROCESS; + parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; + if (!bounce) + parms.flags |= VPF_NOCUBEMAPS; parms.fovX = 90; parms.fovY = 90; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index cdbc6e551b..e37cc09f02 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -522,7 +522,7 @@ void RE_RenderScene( const refdef_t *fd ) { { for (j = 0; j < 6; j++) { - R_RenderCubemapSide(i, j, qtrue); + R_RenderCubemapSide(i, j, qtrue, qfalse); } } } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index ba27140777..1ace4d6ba7 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -247,6 +247,12 @@ void RB_InstantQuad(vec4_t quadVerts[4]) RB_InstantQuad2(quadVerts, texCoords); } +void RB_InstantTriangle() +{ + qglDrawArrays(GL_TRIANGLES, 0, 3); +} + + /* ============== From 7c6178f8d1f4639d1dc31485780560469603f61e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 May 2018 12:36:16 +0200 Subject: [PATCH 454/708] fix inverted roughness for cubemaps again also deleted unnecessary divide for the filtering glsl --- codemp/rd-rend2/glsl/lightall.glsl | 2 +- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index bd05e57346..bbc05e2ad2 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -521,7 +521,7 @@ vec3 CalcIBLContribution( ) { #if defined(USE_CUBEMAP) - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(1.0 - roughness, NE)).rgb; + vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; vec3 R = reflect(E, N); diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index d0b665ec9d..8ffd768d96 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -8,7 +8,7 @@ void main() { vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0); gl_Position = vec4(position, 0.0, 1.0); - vec2 screenCoords = gl_Position.xy / gl_Position.w; + vec2 screenCoords = gl_Position.xy; var_ScreenTex = screenCoords * 0.5 + 0.5; } From 34780eee39c09c2abae8efb0b2414d83ea010e74 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 May 2018 15:02:35 +0200 Subject: [PATCH 455/708] actually render existing world vbos instead of dynamicVbos --- codemp/rd-rend2/tr_surface.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 577d7cf9db..eb6db4645d 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -591,13 +591,11 @@ RB_SurfaceBSPTriangles ============= */ static void RB_SurfaceBSPTriangles( srfBspSurface_t *srf ) { -#if 0 if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } -#endif RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, srf->indexes, srf->dlightBits, srf->pshadowBits); From 79a3b345265e4f8149a4a36f5e50dfd7901dc7e8 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 May 2018 15:11:31 +0200 Subject: [PATCH 456/708] new cvar r_cubeMappingBounces --- codemp/rd-rend2/tr_bsp.cpp | 3 +-- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 10d77cd3ef..c846aa2374 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3027,8 +3027,7 @@ static void R_RenderAllCubemaps(void) cubemapFormat = GL_RGBA16F; } - int numberOfBounces = 1; - for (int k = 0; k <= numberOfBounces; k++) + for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { qboolean bounce = qboolean(k != 0); for (int i = 0; i < tr.numCubemaps; i++) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 974dcabbbb..7fd8b3a6bc 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -138,6 +138,7 @@ cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_parallaxMapping; cvar_t *r_cubeMapping; +cvar_t *r_cubeMappingBounces; cvar_t *r_baseNormalX; cvar_t *r_baseNormalY; cvar_t *r_baseParallax; @@ -1481,6 +1482,7 @@ void R_Register( void ) r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_cubeMappingBounces = ri.Cvar_Get("r_cubeMappingBounces", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 70fd3cadd1..edf8365424 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2497,6 +2497,7 @@ extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; extern cvar_t *r_cubeMapping; +extern cvar_t *r_cubeMappingBounces; extern cvar_t *r_baseNormalX; extern cvar_t *r_baseNormalY; extern cvar_t *r_baseParallax; From 1c6cf039cba9adfc3445864863b0ce5828aacccf Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 May 2018 15:35:21 +0200 Subject: [PATCH 457/708] fix the rest of the bsp faces to use their vbo --- codemp/rd-rend2/tr_surface.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index eb6db4645d..3f6570d7fa 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -1722,13 +1722,11 @@ RB_SurfaceFace ============== */ static void RB_SurfaceBSPFace( srfBspSurface_t *srf ) { -#if 0 if( RB_SurfaceVbo(srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } -#endif RB_SurfaceVertsAndIndexes(srf->numVerts, srf->verts, srf->numIndexes, srf->indexes, srf->dlightBits, srf->pshadowBits); @@ -1792,13 +1790,11 @@ static void RB_SurfaceBSPGrid( srfBspSurface_t *srf ) { int pshadowBits; //int *vDlightBits; -#if 0 if( RB_SurfaceVbo (srf->vbo, srf->ibo, srf->numVerts, srf->numIndexes, srf->firstIndex, srf->minIndex, srf->maxIndex, srf->dlightBits, srf->pshadowBits, qtrue ) ) { return; } -#endif dlightBits = srf->dlightBits; tess.dlightBits |= dlightBits; From f76a34370ac4b6c92d552ce22a65b22599c684ae Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 May 2018 19:05:41 +0200 Subject: [PATCH 458/708] - remove stages - added direct way of defining normal and packed maps - specular shading instead of metal one - cpu builds specular gloss maps with albedo + packed texture - added roughness keyword - autoloading of _nh images - EnvBrdfLUT is now GL_RG16F instead of GL_RGBA16F - reduced number of used mips for convolved cubemaps for more accuracy at high roughness values - killed support for clamped (and animated) normal maps and specular maps --- codemp/rd-rend2/glsl/lightall.glsl | 11 +- codemp/rd-rend2/tr_backend.cpp | 5 +- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_image.cpp | 201 ++++++++++++-- codemp/rd-rend2/tr_local.h | 13 +- codemp/rd-rend2/tr_shader.cpp | 411 +++++++++++++++-------------- 6 files changed, 414 insertions(+), 229 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index bbc05e2ad2..6f70739615 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -671,14 +671,9 @@ void main() #endif specular *= u_SpecularScale; - // diffuse is actually base color, and red of specular is metalness - const vec3 DIELECTRIC_SPECULAR = vec3(0.04); - const vec3 METAL_DIFFUSE = vec3(0.0); - - float metalness = specular.r; - float roughness = max(specular.a, 0.02); - specular.rgb = mix(DIELECTRIC_SPECULAR, diffuse.rgb, metalness); - diffuse.rgb = mix(diffuse.rgb, METAL_DIFFUSE, metalness); + // energy conservation + diffuse.rgb *= vec3(1.0) - specular.rgb; + float roughness = max(1.0 - specular.a, 0.02); vec3 H = normalize(L + E); float NE = abs(dot(N, E)) + 1e-5; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5bb1f36d02..aa997798bd 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1880,8 +1880,9 @@ static const void *RB_PrefilterEnvMap(const void *data) { int width = cubemap->width; int height = cubemap->height; + float roughnessMips = (float)CUBE_MAP_MIPS - 4.0f; - for (int level = 1; level <= CUBE_MAP_MIPS; level++) + for (float level = 1.0f; level <= CUBE_MAP_MIPS; level++) { width = width / 2.0; height = height / 2.0; @@ -1889,7 +1890,7 @@ static const void *RB_PrefilterEnvMap(const void *data) { qglScissor(0, 0, width, height); vec4_t viewInfo; - VectorSet4(viewInfo, cmd->cubeSide, level, CUBE_MAP_MIPS, (level / (float)CUBE_MAP_MIPS)); + VectorSet4(viewInfo, cmd->cubeSide, level, roughnessMips, level / roughnessMips); GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); RB_InstantTriangle(); qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, level, 0, 0, 0, 0, width, height); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d57bdd8618..04e1a9baae 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -359,7 +359,7 @@ static size_t GLSL_GetShaderHeader( if (r_cubeMapping->integer) { - Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%d)\n", CUBE_MAP_MIPS)); + Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%i)\n", CUBE_MAP_MIPS - 4)); } if (extra) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 4ebe241786..0d858def17 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1976,23 +1976,35 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei { int dataFormat, dataType; - switch(internalFormat) - { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - dataFormat = GL_DEPTH_COMPONENT; - dataType = GL_UNSIGNED_BYTE; - break; - case GL_RGBA16F: - dataFormat = GL_RGBA; - dataType = GL_HALF_FLOAT; - break; - default: - dataFormat = GL_RGBA; - dataType = GL_UNSIGNED_BYTE; - break; + switch (internalFormat) + { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + dataFormat = GL_DEPTH_COMPONENT; + dataType = GL_UNSIGNED_BYTE; + break; + case GL_RG16F: + dataFormat = GL_RG; + dataType = GL_HALF_FLOAT; + break; + case GL_RGBA16F: + dataFormat = GL_RGBA; + dataType = GL_HALF_FLOAT; + break; + case GL_RG32F: + dataFormat = GL_RG; + dataType = GL_FLOAT; + break; + case GL_RGBA32F: + dataFormat = GL_RGBA; + dataType = GL_FLOAT; + break; + default: + dataFormat = GL_RGBA; + dataType = GL_UNSIGNED_BYTE; + break; } if ( subtexture ) @@ -2569,6 +2581,155 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri.Hunk_FreeTempMemory( resampledBuffer ); } +#define GAMMA 2.2f +#define INV_GAMMA 1.0 / GAMMA + +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) +{ + image_t *image; + char diffuseName[MAX_QPATH]; + char specularName[MAX_QPATH]; + int width, height, rmoWidth, rmoHeight; + byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; + long hash; + + if (!name) { + return; + } + + COM_StripExtension(name, diffuseName, MAX_QPATH); + Q_strcat(diffuseName, MAX_QPATH, "_diffuse"); + + COM_StripExtension(name, specularName, MAX_QPATH); + Q_strcat(specularName, MAX_QPATH, "_spec"); + + // + // see if the images are already loaded + // + hash = generateHashValue(diffuseName); + for (image = hashTable[hash]; image; image = image->next) { + if (!strcmp(diffuseName, image->imgName)) { + stage->bundle[TB_COLORMAP].image[0] = image; + // check for specular map + hash = generateHashValue(specularName); + for (image = hashTable[hash]; image; image = image->next) { + if (!strcmp(specularName, image->imgName)) { + stage->bundle[TB_SPECULARMAP].image[0] = image; + return; + } + } + } + } + + // + // load the pics from disk + // + R_LoadImage(name, &baseColorPic, &width, &height); + if (baseColorPic == NULL) { + return; + } + R_LoadImage(rmoName, &rmoPic, &rmoWidth, &rmoHeight); + if (rmoPic == NULL) { + return; + } + + if (width != rmoWidth || height != rmoHeight) + { + ri.Printf(PRINT_ALL, "WARNING: Can't build Specular Map for %s (different texture sizes for baseColor and rmo)\n", name); + return; + } + + specGlossPic = (byte *)Z_Malloc(width * height * 4, TAG_TEMP_WORKSPACE, qfalse); + diffusePic = (byte *)Z_Malloc(width * height * 4, TAG_TEMP_WORKSPACE, qfalse); + + float baseSpecular; + + switch (type) + { + case SPEC_RMOS: + case SPEC_MOSR: + baseSpecular = 0.08f; + break; + default: + baseSpecular = 0.04f; + break; + } + + for (int i = 0; i < width * height * 4; i += 4) + { + const float aoStrength = 0.5f; + float roughness, gloss, metalness, specular_variance, ao; + + switch (type) + { + case SPEC_RMO: + case SPEC_RMOS: + { + roughness = ByteToFloat(rmoPic[i + 0]); + gloss = (1.0 - roughness) + (0.04 * roughness); + metalness = ByteToFloat(rmoPic[i + 1]); + ao = ByteToFloat(rmoPic[i + 2]); + ao += (1.0 - ao) * (1.0 - aoStrength); + specular_variance = ByteToFloat(rmoPic[i + 3]); + } + break; + case SPEC_MOXR: + case SPEC_MOSR: + { + metalness = ByteToFloat(rmoPic[i + 0]); + ao = ByteToFloat(rmoPic[i + 1]); + ao += (1.0 - ao) * (1.0 - aoStrength); + specular_variance = ByteToFloat(rmoPic[i + 2]); + roughness = ByteToFloat(rmoPic[i + 3]); + gloss = (1.0 - roughness) + (0.04 * roughness); + } + break; + // should never reach this + default: + { + specular_variance = 1.0f; + metalness = 0.0f; + gloss = 0.02f; + ao = 1.0f; + } + break; + } + + float baseColor[4]; + // remove gamma correction because we want to work in linear space + baseColor[0] = pow(ByteToFloat(baseColorPic[i + 0]), GAMMA); + baseColor[1] = pow(ByteToFloat(baseColorPic[i + 1]), GAMMA); + baseColor[2] = pow(ByteToFloat(baseColorPic[i + 2]), GAMMA); + // don't remove gamma correction in alpha because this is data, not color + baseColor[3] = ByteToFloat(baseColorPic[i + 3]); + + baseSpecular *= specular_variance; + + // diffuse Color = baseColor * (1.0 - metalness) + // also gamma correct again + diffusePic[i + 0] = FloatToByte(pow(baseColor[0] * (1.0f - metalness) * ao, INV_GAMMA)); + diffusePic[i + 1] = FloatToByte(pow(baseColor[1] * (1.0f - metalness) * ao, INV_GAMMA)); + diffusePic[i + 2] = FloatToByte(pow(baseColor[2] * (1.0f - metalness) * ao, INV_GAMMA)); + diffusePic[i + 3] = FloatToByte(baseColor[3]); + + // specular Color = mix(baseSpecular, baseColor, metalness) + // also gamma correct again + specGlossPic[i + 0] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[0] * metalness, INV_GAMMA)); + specGlossPic[i + 1] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[1] * metalness, INV_GAMMA)); + specGlossPic[i + 2] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[2] * metalness, INV_GAMMA)); + // don't remove gamma correction in alpha because this is data, not color + specGlossPic[i + 3] = FloatToByte(gloss); + } + + stage->bundle[TB_COLORMAP].image[0] = R_CreateImage(diffuseName, diffusePic, width, height, IMGTYPE_COLORALPHA, flags, 0); + stage->bundle[TB_SPECULARMAP].image[0] = R_CreateImage(specularName, specGlossPic, width, height, IMGTYPE_COLORALPHA, flags, 0); + + Z_Free(diffusePic); + Z_Free(specGlossPic); + Z_Free(baseColorPic); + Z_Free(rmoPic); +} + static void R_CreateNormalMap ( const char *name, byte *pic, int width, int height, int flags ) { char normalName[MAX_QPATH]; @@ -2883,7 +3044,7 @@ static void R_CreateEnvBrdfLUT(void) { if (!r_cubeMapping->integer) return; - uint16_t data[LUT_WIDTH][LUT_HEIGHT][4]; + uint16_t data[LUT_WIDTH][LUT_HEIGHT][2]; unsigned const numSamples = 1024; @@ -2939,8 +3100,6 @@ static void R_CreateEnvBrdfLUT(void) { data[y][x][0] = FloatToHalf(scale); data[y][x][1] = FloatToHalf(bias); - data[y][x][2] = 0.0f; - data[y][x][3] = 0.0f; } } @@ -2951,7 +3110,7 @@ static void R_CreateEnvBrdfLUT(void) { LUT_HEIGHT, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_RGBA16F); + GL_RG16F); } /* diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index edf8365424..9809221170 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -726,12 +726,18 @@ typedef enum // material shader stage types ST_COLORMAP = 0, // vanilla Q3A style shader treatening ST_DIFFUSEMAP = 0, // treat color and diffusemap the same - ST_NORMALMAP, - ST_NORMALPARALLAXMAP, - ST_SPECULARMAP, ST_GLSL } stageType_t; +enum specularType +{ + SPEC_NONE, // no specular found + SPEC_RMO, // calculate spec from rmo texture with a specular of 0.04 for dielectric materials + SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input + SPEC_MOXR, // calculate spec from moxr texture with a specular of 0.04 for dielectric materials + SPEC_MOSR, // calculate spec from mosr texture with a specular of 0.0 - 0.08 from input +}; + enum AlphaTestType { ALPHA_TEST_NONE, @@ -3426,6 +3432,7 @@ void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t di void R_AddDecals( void ); image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); const char *RE_ShaderNameFromIndex(int index); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index dc48a4695a..48ae68974b 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -112,7 +112,7 @@ static void ClearGlobalShader(void) stages[i].specularScale[0] = stages[i].specularScale[1] = stages[i].specularScale[2] = r_baseSpecular->value; - stages[i].specularScale[3] = 0.9; + stages[i].specularScale[3] = 0.1; } shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; @@ -1197,6 +1197,10 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) unsigned blendDstBits = 0; unsigned depthFuncBits = 0; qboolean depthMaskExplicit = qfalse; + char bufferPackedTextureName[MAX_QPATH]; + char bufferBaseColorTextureName[MAX_QPATH]; + int buildSpecFromPacked = SPEC_NONE; + qboolean foundBaseColor = qfalse; stage->active = qtrue; @@ -1216,45 +1220,47 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // // map // - else if ( !Q_stricmp( token, "map" ) ) + else if (!Q_stricmp(token, "map")) { - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) + token = COM_ParseExt(text, qfalse); + if (!token[0]) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name ); + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name); return qfalse; } - if ( !Q_stricmp( token, "$whiteimage" ) ) + if (!Q_stricmp(token, "$whiteimage")) { stage->bundle[0].image[0] = tr.whiteImage; continue; } - else if ( !Q_stricmp( token, "$lightmap" ) ) + else if (!Q_stricmp(token, "$lightmap")) { stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { + if (shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps) { #ifndef FINAL_BUILD - ri.Printf (PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); + ri.Printf(PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); #endif stage->bundle[0].image[0] = tr.whiteImage; - } else { + } + else { stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; } continue; } - else if ( !Q_stricmp( token, "$deluxemap" ) ) + else if (!Q_stricmp(token, "$deluxemap")) { if (!tr.worldDeluxeMapping) { - ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); + ri.Printf(PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name); return qfalse; } stage->bundle[0].isLightmap = qtrue; - if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { + if (shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps) { stage->bundle[0].image[0] = tr.whiteImage; - } else { + } + else { stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } continue; @@ -1273,47 +1279,76 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) - { - type = IMGTYPE_NORMAL; - flags |= IMGFLAG_NOLIGHTSCALE; - - if (stage->type == ST_NORMALPARALLAXMAP) - type = IMGTYPE_NORMALHEIGHT; - } - else - { - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; - if (r_srgb->integer) - flags |= IMGFLAG_SRGB; - } + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; - stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); + Q_strncpyz(bufferBaseColorTextureName, token, sizeof(bufferBaseColorTextureName)); + stage->bundle[0].image[0] = R_FindImageFile(bufferBaseColorTextureName, type, flags); - if ( !stage->bundle[0].image[0] ) + if (!stage->bundle[0].image[0]) { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); return qfalse; } + + foundBaseColor = qtrue; } } // - // clampmap + // normalMap or normalHeightMap + // + else if (!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "normalHeightMap")) + { + imgType_t type = !Q_stricmp(token, "normalHeightMap") ? IMGTYPE_NORMALHEIGHT : IMGTYPE_NORMAL; + + token = COM_ParseExt(text, qfalse); + if (!token[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'normalMap' keyword in shader '%s'\n", shader.name); + return qfalse; + } + + int flags = IMGFLAG_NONE; + + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + + flags |= IMGFLAG_NOLIGHTSCALE; + stage->bundle[TB_NORMALMAP].image[0] = R_FindImageFile(token, type, flags); + + if (!stage->bundle[TB_NORMALMAP].image[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); + return qfalse; + } + + VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); + } + // + // specMap || specularMap // - else if ( !Q_stricmp( token, "clampmap" ) ) + else if (!Q_stricmp(token, "specMap") || !Q_stricmp(token, "specularMap")) { imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - token = COM_ParseExt( text, qfalse ); - if ( !token[0] ) + token = COM_ParseExt(text, qfalse); + if (!token[0]) { - ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name ); + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'specularMap' keyword in shader '%s'\n", shader.name); return qfalse; } + int flags = IMGFLAG_NONE; + if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -1323,28 +1358,80 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - if (stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP) + flags |= IMGFLAG_NOLIGHTSCALE; + + stage->bundle[TB_SPECULARMAP].image[0] = R_FindImageFile(token, type, flags); + + if (!stage->bundle[TB_SPECULARMAP].image[0]) { - type = IMGTYPE_NORMAL; - flags |= IMGFLAG_NOLIGHTSCALE; + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); + return qfalse; + } - if (stage->type == ST_NORMALPARALLAXMAP) - type = IMGTYPE_NORMALHEIGHT; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + } + // + // rmoMap || rmosMap + // + else if (!Q_stricmp(token, "rmoMap") || !Q_stricmp(token, "rmosMap")) + { + token = COM_ParseExt(text, qfalse); + if (!token[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'rmoMap' keyword in shader '%s'\n", shader.name); + return qfalse; } - else + buildSpecFromPacked = !Q_stricmp(token, "rmosMap") ? SPEC_RMOS : SPEC_RMO; + Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); + } + // + // moxrMap || mosrMap + // + else if (!Q_stricmp(token, "moxrMap") || !Q_stricmp(token, "mosrMap")) + { + token = COM_ParseExt(text, qfalse); + if (!token[0]) { - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'moxrMap' keyword in shader '%s'\n", shader.name); + return qfalse; + } + buildSpecFromPacked = !Q_stricmp(token, "mosrMap") ? SPEC_MOSR : SPEC_MOXR; + Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); + } + // + // clampmap + // + else if (!Q_stricmp(token, "clampmap")) + { + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; - if (r_srgb->integer) - flags |= IMGFLAG_SRGB; + token = COM_ParseExt(text, qfalse); + if (!token[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name); + return qfalse; } + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; + + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; - stage->bundle[0].image[0] = R_FindImageFile( token, type, flags ); - if ( !stage->bundle[0].image[0] ) + stage->bundle[0].image[0] = R_FindImageFile(token, type, flags); + if (!stage->bundle[0].image[0]) { - ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); return qfalse; } } @@ -1372,7 +1459,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) break; } num = stage->bundle[0].numImageAnimations; - if ( num < MAX_IMAGE_ANIMATIONS ) { + if (num < MAX_IMAGE_ANIMATIONS) { imgType_t imgtype = IMGTYPE_COLORALPHA; int flags = type == ANIMMAP_CLAMP ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; @@ -1388,22 +1475,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - if ( stage->type == ST_NORMALMAP || stage->type == ST_NORMALPARALLAXMAP ) - { - imgtype = IMGTYPE_NORMAL; - flags |= IMGFLAG_NOLIGHTSCALE; - - if ( stage->type == ST_NORMALPARALLAXMAP ) - imgtype = IMGTYPE_NORMALHEIGHT; - } - else - { - if ( r_genNormalMaps->integer ) - flags |= IMGFLAG_GENNORMALMAP; + if (r_genNormalMaps->integer) + flags |= IMGFLAG_GENNORMALMAP; - if ( r_srgb->integer ) - flags |= IMGFLAG_SRGB; - } + if (r_srgb->integer) + flags |= IMGFLAG_SRGB; stage->bundle[0].image[num] = R_FindImageFile( token, imgtype, flags ); if ( !stage->bundle[0].image[num] ) @@ -1523,46 +1599,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } } // - // stage - // - else if(!Q_stricmp(token, "stage")) - { - token = COM_ParseExt(text, qfalse); - if(token[0] == 0) - { - ri.Printf(PRINT_WARNING, "WARNING: missing parameters for stage in shader '%s'\n", shader.name); - continue; - } - - if(!Q_stricmp(token, "diffuseMap")) - { - stage->type = ST_DIFFUSEMAP; - } - else if(!Q_stricmp(token, "normalMap") || !Q_stricmp(token, "bumpMap")) - { - stage->type = ST_NORMALMAP; - VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); - } - else if(!Q_stricmp(token, "normalParallaxMap") || !Q_stricmp(token, "bumpParallaxMap")) - { - if (r_parallaxMapping->integer) - stage->type = ST_NORMALPARALLAXMAP; - else - stage->type = ST_NORMALMAP; - VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); - } - else if(!Q_stricmp(token, "specularMap")) - { - stage->type = ST_SPECULARMAP; - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); - } - else - { - ri.Printf(PRINT_WARNING, "WARNING: unknown stage parameter '%s' in shader '%s'\n", token, shader.name); - continue; - } - } - // // specularReflectance // else if (!Q_stricmp(token, "specularreflectance")) @@ -1612,6 +1648,21 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->specularScale[3] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); } // + // roughness + // + else if (!Q_stricmp(token, "roughness")) + { + float roughness; + token = COM_ParseExt(text, qfalse); + if (token[0] == 0) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for roughness in shader '%s'\n", shader.name); + continue; + } + + stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, 1.0 - atof(token)); + } + // // parallaxDepth // else if (!Q_stricmp(token, "parallaxdepth")) @@ -2009,6 +2060,27 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } } + // + // build specular and diffuse if albedo and packed textures were found + // + if (foundBaseColor && buildSpecFromPacked != SPEC_NONE) + { + int flags = IMGFLAG_NONE; + + if (!shader.noMipMaps) + flags |= IMGFLAG_MIPMAP; + + if (!shader.noPicMip) + flags |= IMGFLAG_PICMIP; + + if (shader.noTC) + flags |= IMGFLAG_NO_COMPRESSION; + + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked); + + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + } + // // if cgen isn't explicitly specified, use either identity or identitylighting // @@ -2921,21 +2993,20 @@ static void ComputeVertexAttribs(void) } } -static void CollapseStagesToLightall(shaderStage_t *diffuse, - shaderStage_t *normal, shaderStage_t *specular, shaderStage_t *lightmap, - qboolean useLightVector, qboolean useLightVertex, qboolean parallax, qboolean tcgen) +static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightmap, + qboolean useLightVector, qboolean useLightVertex, qboolean tcgen) { int defs = 0; - //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, diffuse->bundle[0].image[0]->imgName); + //ri.Printf(PRINT_ALL, "shader %s has diffuse %s", shader.name, stage->bundle[0].image[0]->imgName); // reuse diffuse, mark others inactive - diffuse->type = ST_GLSL; + stage->type = ST_GLSL; if (lightmap) { //ri.Printf(PRINT_ALL, ", lightmap"); - diffuse->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; + stage->bundle[TB_LIGHTMAP] = lightmap->bundle[0]; defs |= LIGHTDEF_USE_LIGHTMAP; } else if (useLightVector) @@ -2950,72 +3021,72 @@ static void CollapseStagesToLightall(shaderStage_t *diffuse, if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap) { //ri.Printf(PRINT_ALL, ", deluxemap"); - diffuse->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; - diffuse->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; + stage->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; + stage->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } if (r_normalMapping->integer) { image_t *diffuseImg; - if (normal) + if (stage->bundle[TB_NORMALMAP].image[0]) { - //ri.Printf(PRINT_ALL, ", normalmap %s", normal->bundle[0].image[0]->imgName); - diffuse->bundle[TB_NORMALMAP] = normal->bundle[0]; - if (parallax && r_parallaxMapping->integer) + if ((stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT) && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; - - VectorCopy4(normal->normalScale, diffuse->normalScale); + //ri.Printf(PRINT_ALL, ", normalmap %s", stage->bundle[TB_NORMALMAP].image[0]->imgName); } - else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = diffuse->bundle[TB_DIFFUSEMAP].image[0])) + else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0])) { char normalName[MAX_QPATH]; image_t *normalImg; int normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + qboolean parallax = qfalse; + + // try a normalheight image first + COM_StripExtension(diffuseImg->imgName, normalName, sizeof(normalName)); + Q_strcat(normalName, sizeof(normalName), "_nh"); - COM_StripExtension( diffuseImg->imgName, normalName, sizeof( normalName ) ); - Q_strcat( normalName, sizeof( normalName ), "_n" ); + normalImg = R_FindImageFile(normalName, IMGTYPE_NORMALHEIGHT, normalFlags); - normalImg = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); + if (normalImg) + { + parallax = qtrue; + } + else + { + // try a normal image ("_n" suffix) + normalName[strlen(normalName) - 1] = '\0'; + normalImg = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); + } if (normalImg) { - diffuse->bundle[TB_NORMALMAP] = diffuse->bundle[0]; - diffuse->bundle[TB_NORMALMAP].numImageAnimations = 0; - diffuse->bundle[TB_NORMALMAP].image[0] = normalImg; + stage->bundle[TB_NORMALMAP] = stage->bundle[0]; + stage->bundle[TB_NORMALMAP].numImageAnimations = 0; + stage->bundle[TB_NORMALMAP].image[0] = normalImg; if (parallax && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; - VectorSet4(diffuse->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); + VectorSet4(stage->normalScale, r_baseNormalX->value, r_baseNormalY->value, 1.0f, r_baseParallax->value); } } } - if (r_specularMapping->integer) - { - if (specular) - { - //ri.Printf(PRINT_ALL, ", specularmap %s", specular->bundle[0].image[0]->imgName); - diffuse->bundle[TB_SPECULARMAP] = specular->bundle[0]; - VectorCopy4(specular->specularScale, diffuse->specularScale); - } - } - - if (tcgen || diffuse->bundle[0].numTexMods) + if (tcgen || stage->bundle[0].numTexMods) { defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; } - if (diffuse->glow) + if (stage->glow) defs |= LIGHTDEF_USE_GLOW_BUFFER; - if (diffuse->alphaTestType != ALPHA_TEST_NONE) + if (stage->alphaTestType != ALPHA_TEST_NONE) defs |= LIGHTDEF_USE_ALPHA_TEST; //ri.Printf(PRINT_ALL, ".\n"); - diffuse->glslShaderGroup = tr.lightallShader; - diffuse->glslShaderIndex = defs; + stage->glslShaderGroup = tr.lightallShader; + stage->glslShaderIndex = defs; } @@ -3155,7 +3226,7 @@ static qboolean CollapseStagesToGLSL(void) for (i = 0; i < MAX_SHADER_STAGES; i++) { shaderStage_t *pStage = &stages[i]; - shaderStage_t *diffuse, *normal, *specular, *lightmap; + shaderStage_t *diffuse, *lightmap; qboolean parallax, tcgen, diffuselit, vertexlit; if (!pStage->active) @@ -3170,9 +3241,7 @@ static qboolean CollapseStagesToGLSL(void) continue; diffuse = pStage; - normal = NULL; parallax = qfalse; - specular = NULL; lightmap = NULL; @@ -3189,28 +3258,6 @@ static qboolean CollapseStagesToGLSL(void) switch(pStage2->type) { - case ST_NORMALMAP: - if (!normal) - { - normal = pStage2; - } - break; - - case ST_NORMALPARALLAXMAP: - if (!normal) - { - normal = pStage2; - parallax = qtrue; - } - break; - - case ST_SPECULARMAP: - if (!specular) - { - specular = pStage2; - } - break; - case ST_COLORMAP: if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && @@ -3248,7 +3295,7 @@ static qboolean CollapseStagesToGLSL(void) vertexlit = qtrue; } - CollapseStagesToLightall(diffuse, normal, specular, lightmap, diffuselit, vertexlit, parallax, tcgen); + CollapseStagesToLightall(diffuse, lightmap, diffuselit, vertexlit, tcgen); } // deactivate lightmap stages @@ -3268,30 +3315,6 @@ static qboolean CollapseStagesToGLSL(void) } } - // deactivate normal and specular stages - for (i = 0; i < MAX_SHADER_STAGES; i++) - { - shaderStage_t *pStage = &stages[i]; - - if (!pStage->active) - continue; - - if (pStage->type == ST_NORMALMAP) - { - pStage->active = qfalse; - } - - if (pStage->type == ST_NORMALPARALLAXMAP) - { - pStage->active = qfalse; - } - - if (pStage->type == ST_SPECULARMAP) - { - pStage->active = qfalse; - } - } - // remove inactive stages numStages = 0; for (i = 0; i < MAX_SHADER_STAGES; i++) From 1046cbd476de3f9e27ed4c9d80bc5f3525a00c20 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Mon, 14 May 2018 21:39:40 +0100 Subject: [PATCH 459/708] Small changes to the rain rendering --- codemp/rd-rend2/glsl/weatherUpdate.glsl | 16 ++++++++++++--- codemp/rd-rend2/tr_weather.cpp | 26 +++++++++++++++++-------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index dfd4ef1c28..95b11b441d 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -2,6 +2,7 @@ uniform float u_Gravity; uniform float u_DeltaTime; +uniform vec2 u_MapZExtents; in vec3 attr_Position; in vec3 attr_Color; @@ -9,11 +10,20 @@ in vec3 attr_Color; out vec3 var_Position; out vec3 var_Velocity; +vec3 NewParticlePosition() +{ + vec3 position = var_Position; + position.z += u_MapZExtents.y - u_MapZExtents.x; + + return position; +} + void main() { var_Velocity = attr_Color; - var_Position = attr_Position + var_Velocity * 10.0; + var_Position = attr_Position; + var_Position.z -= 800.0 * 0.16; - if (var_Position.z < -200.0) - var_Position.z = 3000.0; + if (var_Position.z < u_MapZExtents.x) + var_Position = NewParticlePosition() } diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index f9e6cb334d..0b10f7fb1a 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -42,15 +42,15 @@ namespace void GenerateRainModel( weatherSystem_t& ws ) { - static const int MAX_RAIN_VERTICES = 1000; + static const int MAX_RAIN_VERTICES = 5000; rainVertex_t rainVertices[MAX_RAIN_VERTICES]; for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-1000.0f, 1000.0f); - vertex.position[1] = Q_flrand(-1000.0f, 1000.0f); - vertex.position[2] = Q_flrand(-1000.0f, 1000.0f); + vertex.position[0] = Q_flrand(-1000.0f, 3000.0f); + vertex.position[1] = Q_flrand(-1000.0f, 3000.0f); + vertex.position[2] = Q_flrand(-1000.0f, 3000.0f); vertex.velocity[0] = Q_flrand(-2.0f, 2.0f); vertex.velocity[1] = Q_flrand(-2.0f, 2.0f); vertex.velocity[2] = Q_flrand(-20.0f, 0.0f); @@ -99,6 +99,18 @@ namespace item.attributes = ojkAllocArray( *backEndData->perFrameMemory, numAttribs); memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); + + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(&tr.weatherUpdateShader); + + const vec2_t mapZExtents = { + tr.world->bmodels[0].bounds[0][2], + tr.world->bmodels[0].bounds[1][2] + }; + uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; @@ -177,11 +189,9 @@ void RB_SurfaceWeather( srfWeather_t *surf ) UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, - glState.modelviewProjection); + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); uniformDataWriter.SetUniformVec3( - UNIFORM_VIEWORIGIN, - backEnd.viewParms.ori.origin); + UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); const vec2_t mapZExtents = { -3000.0, 9000.0 }; uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); From 6386ca93fb48a157d86c2ced55dc6e91f8f6830a Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Mon, 14 May 2018 22:13:20 +0100 Subject: [PATCH 460/708] Make rain follow camera This is temporary while I get zone visibility functioning. --- codemp/rd-rend2/glsl/weather.glsl | 7 ++++++- codemp/rd-rend2/glsl/weatherUpdate.glsl | 2 +- codemp/rd-rend2/tr_glsl.cpp | 1 + codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_weather.cpp | 12 ++++++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index f943d8ff4d..49a2b323a7 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,4 +1,6 @@ /*[Vertex]*/ +uniform vec2 u_ZoneOffset; + in vec3 attr_Position; in vec3 attr_Color; // velocity @@ -6,7 +8,10 @@ out vec3 var_Velocity; void main() { - gl_Position = vec4(attr_Position, 1.0); + gl_Position = vec4( + attr_Position.xy + u_ZoneOffset, + attr_Position.z, + 1.0); var_Velocity = attr_Color; } diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 95b11b441d..061631879f 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -25,5 +25,5 @@ void main() var_Position.z -= 800.0 * 0.16; if (var_Position.z < u_MapZExtents.x) - var_Position = NewParticlePosition() + var_Position = NewParticlePosition(); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 56d133ba76..0ff0d2506d 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -133,6 +133,7 @@ static uniformInfo_t uniformsInfo[] = { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, { "u_MapZExtents", GLSL_VEC2, 1 }, + { "u_ZoneOffset", GLSL_VEC2, 1 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 29636f719d..294b50a7a2 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1241,6 +1241,7 @@ typedef enum UNIFORM_FX_VOLUMETRIC_BASE, UNIFORM_MAPZEXTENTS, + UNIFORM_ZONEOFFSET, UNIFORM_COUNT } uniform_t; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 0b10f7fb1a..27431f4a5f 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -22,6 +22,14 @@ along with this program; if not, see . #include "tr_local.h" #include +struct LocalWeatherZone +{ + unsigned vboLastUpdateFrame; + VBO_t *lastVBO; + VBO_t *vbo; + int numVertices; +}; + struct weatherSystem_t { VBO_t *lastVBO; @@ -193,6 +201,10 @@ void RB_SurfaceWeather( srfWeather_t *surf ) uniformDataWriter.SetUniformVec3( UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); const vec2_t mapZExtents = { -3000.0, 9000.0 }; + uniformDataWriter.SetUniformVec2( + UNIFORM_ZONEOFFSET, + backEnd.viewParms.ori.origin[0], + backEnd.viewParms.ori.origin[1]); uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); From eb85fa58a6213007a7fb85606979abe203f47e9e Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 11:57:39 +0100 Subject: [PATCH 461/708] Draw 9 rain "zones" around the player's position Need a better name for zone. Rain chunk? Zones are a fixed size, and their positions follow the player's view position after being snapped to a grid whose cells are the same size. --- codemp/rd-rend2/glsl/weatherUpdate.glsl | 2 +- codemp/rd-rend2/tr_backend.cpp | 17 ++++--- codemp/rd-rend2/tr_local.h | 11 ++++- codemp/rd-rend2/tr_vbo.cpp | 35 ------------- codemp/rd-rend2/tr_weather.cpp | 65 ++++++++++++++++--------- 5 files changed, 63 insertions(+), 67 deletions(-) diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 061631879f..149b1f2471 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -22,7 +22,7 @@ void main() { var_Velocity = attr_Color; var_Position = attr_Position; - var_Position.z -= 800.0 * 0.16; + var_Position.z -= 600.0 * 0.16; if (var_Position.z < u_MapZExtents.x) var_Position = NewParticlePosition(); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index ac2024afbf..f5e6c1a1b6 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -958,16 +958,21 @@ static void RB_SetRenderState(const RenderState& renderState) } } -static void RB_BindTransformFeedbackBuffer(VBO_t *buffer) +static void RB_BindTransformFeedbackBuffer(const bufferBinding_t& binding) { - if (glState.currentXFBBO != buffer) - { - if (buffer != nullptr) - qglBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, buffer->vertexesVBO); + if (memcmp(&glState.currentXFBBO, &binding, sizeof(binding)) != 0) + { + if (binding.vbo != nullptr) + qglBindBufferRange( + GL_TRANSFORM_FEEDBACK_BUFFER, + 0, + binding.vbo->vertexesVBO, + binding.offset, + binding.size); else qglBindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, 0); - glState.currentXFBBO = buffer; + glState.currentXFBBO = binding; } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 294b50a7a2..dc8b116068 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1999,6 +1999,13 @@ struct vertexAttribute_t int stepRate; }; +struct bufferBinding_t +{ + VBO_t *vbo; + int offset; + int size; +}; + // the renderer front end should never modify glstate_t typedef struct glstate_s { int currenttextures[NUM_TEXTURE_BUNDLES]; @@ -2022,7 +2029,7 @@ typedef struct glstate_s { FBO_t *currentFBO; VBO_t *currentVBO; IBO_t *currentIBO; - VBO_t *currentXFBBO; + bufferBinding_t currentXFBBO; matrix_t modelview; matrix_t projection; matrix_t modelviewProjection; @@ -3521,7 +3528,7 @@ struct DrawItem uint32_t numUniformBlockBindings; UniformBlockBinding *uniformBlockBindings; - VBO_t *transformFeedbackBuffer; + bufferBinding_t transformFeedbackBuffer; UniformData *uniformData; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index b6029aad6a..cb26627bd3 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -73,41 +73,6 @@ static GLenum GetGLBufferUsage ( vboUsage_t usage ) } } -#if 0 -struct Attribute -{ - int index; - GLenum type; - int numElements; - qboolean normalised; - int offset; - int stride; - int stream; -}; - -const int MAX_ATTRIBUTES = 8; -struct VertexFormat -{ - Attribute attributes[MAX_ATTRIBUTES]; - int numAttributes; -}; - -const int MAX_VERTEX_STREAMS = 2; -struct VertexArrayObject -{ - GLuint vao; - IBO_t *ibo; - VBO_t *vbos[MAX_VERTEX_STREAMS]; - int numStreams; - VertexFormat format; -}; - -VertexArrayObject *R_GetVertexArrayObject( const VertexFormat& format ) -{ - return nullptr; -} -#endif - /* ============ R_CreateVBO diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 27431f4a5f..e04ffa131f 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -42,6 +42,9 @@ struct weatherSystem_t namespace { + const float ZONE_SIZE = 2000.0f; + const float HALF_ZONE_SIZE = ZONE_SIZE * 0.5f; + struct rainVertex_t { vec3_t position; @@ -56,9 +59,9 @@ namespace for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-1000.0f, 3000.0f); - vertex.position[1] = Q_flrand(-1000.0f, 3000.0f); - vertex.position[2] = Q_flrand(-1000.0f, 3000.0f); + vertex.position[0] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); + vertex.position[1] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); + vertex.position[2] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); vertex.velocity[0] = Q_flrand(-2.0f, 2.0f); vertex.velocity[1] = Q_flrand(-2.0f, 2.0f); vertex.velocity[2] = Q_flrand(-20.0f, 0.0f); @@ -101,7 +104,7 @@ namespace DrawItem item = {}; item.renderState.transformFeedback = true; - item.transformFeedbackBuffer = rainVBO; + item.transformFeedbackBuffer = {rainVBO, 0, rainVBO->vertexesSize}; item.program = &tr.weatherUpdateShader; item.numAttributes = numAttribs; item.attributes = ojkAllocArray( @@ -112,8 +115,9 @@ namespace uniformDataWriter.Start(&tr.weatherUpdateShader); const vec2_t mapZExtents = { - tr.world->bmodels[0].bounds[0][2], - tr.world->bmodels[0].bounds[1][2] + -1000.0f, 1000.0f + //tr.world->bmodels[0].bounds[0][2], + //tr.world->bmodels[0].bounds[1][2] }; uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); @@ -186,6 +190,12 @@ void RB_SurfaceWeather( srfWeather_t *surf ) RB_EndSurface(); + // Get look direction + // Determine which zones would be visible + // Update simulation in these zones - + // can do this in one go + // Render zones + RB_SimulateWeather(ws); DrawItem item = {}; @@ -194,21 +204,6 @@ void RB_SurfaceWeather( srfWeather_t *surf ) item.samplerBindings = samplerBindingsWriter.Finish( *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); - UniformDataWriter uniformDataWriter; - uniformDataWriter.Start(&tr.weatherShader); - uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3( - UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - const vec2_t mapZExtents = { -3000.0, 9000.0 }; - uniformDataWriter.SetUniformVec2( - UNIFORM_ZONEOFFSET, - backEnd.viewParms.ori.origin[0], - backEnd.viewParms.ori.origin[1]); - uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - item.renderState.stateBits = GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; item.renderState.cullType = CT_FRONT_SIDED; @@ -241,6 +236,30 @@ void RB_SurfaceWeather( srfWeather_t *surf ) item.draw.primitiveType = GL_POINTS; item.draw.params.arrays.numVertices = ws.numVertices; - uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); - RB_AddDrawItem(backEndData->currentPass, key, item); + const float *viewOrigin = backEnd.viewParms.ori.origin; + float centerZoneOffsetX = + std::floor((backEnd.viewParms.ori.origin[0] / ZONE_SIZE) + 0.5f) * ZONE_SIZE; + float centerZoneOffsetY = + std::floor((backEnd.viewParms.ori.origin[1] / ZONE_SIZE) + 0.5f) * ZONE_SIZE; + for (int y = -1; y <= 1; ++y) + { + for (int x = -1; x <= 1; ++x) + { + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(&tr.weatherShader); + uniformDataWriter.SetUniformMatrix4x4( + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec3( + UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + uniformDataWriter.SetUniformVec2( + UNIFORM_ZONEOFFSET, + centerZoneOffsetX + x * ZONE_SIZE, + centerZoneOffsetY + y * ZONE_SIZE); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + + uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); + RB_AddDrawItem(backEndData->currentPass, key, item); + } + } } From 9d7660b3902accbe7209610c0dbfb114f80f2117 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 12:07:57 +0100 Subject: [PATCH 462/708] Build vertex attributes at start up --- codemp/rd-rend2/tr_weather.cpp | 43 +++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index e04ffa131f..c8721d0b10 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -38,6 +38,7 @@ struct weatherSystem_t int numVertices; srfWeather_t weatherSurface; + vertexAttribute_t attribsTemplate[2]; }; namespace @@ -71,6 +72,20 @@ namespace ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_XFB); ws.numVertices = MAX_RAIN_VERTICES; ws.vboLastUpdateFrame = 0; + + ws.attribsTemplate[0].index = ATTR_INDEX_POSITION; + ws.attribsTemplate[0].numComponents = 3; + ws.attribsTemplate[0].offset = offsetof(rainVertex_t, position); + ws.attribsTemplate[0].stride = sizeof(rainVertex_t); + ws.attribsTemplate[0].type = GL_FLOAT; + ws.attribsTemplate[0].vbo = nullptr; + + ws.attribsTemplate[1].index = ATTR_INDEX_COLOR; + ws.attribsTemplate[1].numComponents = 3; + ws.attribsTemplate[1].offset = offsetof(rainVertex_t, velocity); + ws.attribsTemplate[1].stride = sizeof(rainVertex_t); + ws.attribsTemplate[1].type = GL_FLOAT; + ws.attribsTemplate[1].vbo = nullptr; } void RB_SimulateWeather(weatherSystem_t& ws) @@ -200,36 +215,22 @@ void RB_SurfaceWeather( srfWeather_t *surf ) DrawItem item = {}; - SamplerBindingsWriter samplerBindingsWriter; - item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); - item.renderState.stateBits = GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; item.renderState.cullType = CT_FRONT_SIDED; item.renderState.depthRange = { 0.0f, 1.0f }; item.program = &tr.weatherShader; - vertexAttribute_t attribs[2] = {}; - attribs[0].index = ATTR_INDEX_POSITION; - attribs[0].numComponents = 3; - attribs[0].offset = offsetof(rainVertex_t, position); - attribs[0].stride = sizeof(rainVertex_t); - attribs[0].type = GL_FLOAT; - attribs[0].vbo = ws.vbo; - - attribs[1].index = ATTR_INDEX_COLOR; - attribs[1].numComponents = 3; - attribs[1].offset = offsetof(rainVertex_t, velocity); - attribs[1].stride = sizeof(rainVertex_t); - attribs[1].type = GL_FLOAT; - attribs[1].vbo = ws.vbo; - - const size_t numAttribs = ARRAY_LEN(attribs); + const size_t numAttribs = ARRAY_LEN(ws.attribsTemplate); item.numAttributes = numAttribs; item.attributes = ojkAllocArray( *backEndData->perFrameMemory, numAttribs); - memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); + memcpy( + item.attributes, + ws.attribsTemplate, + sizeof(*item.attributes) * numAttribs); + item.attributes[0].vbo = ws.vbo; + item.attributes[1].vbo = ws.vbo; item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; From de1c1c8c8cb4538903c2ee5dd9c75f51e2710d6b Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 12:22:19 +0100 Subject: [PATCH 463/708] Give each rain chunk its own rain .. instead of having each chunk use the same rain --- codemp/rd-rend2/tr_weather.cpp | 77 ++++++++++++++++------------------ 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index c8721d0b10..121625c2c8 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -21,6 +21,7 @@ along with this program; if not, see . #include "tr_weather.h" #include "tr_local.h" #include +#include struct LocalWeatherZone { @@ -43,8 +44,10 @@ struct weatherSystem_t namespace { - const float ZONE_SIZE = 2000.0f; - const float HALF_ZONE_SIZE = ZONE_SIZE * 0.5f; + const float CHUNK_SIZE = 2000.0f; + const float HALF_CHUNK_SIZE = CHUNK_SIZE * 0.5f; + const int CHUNK_COUNT = 9; // in 3x3 arrangement + const int RAIN_VERTEX_COUNT = 5000; struct rainVertex_t { @@ -54,23 +57,27 @@ namespace void GenerateRainModel( weatherSystem_t& ws ) { - static const int MAX_RAIN_VERTICES = 5000; - rainVertex_t rainVertices[MAX_RAIN_VERTICES]; + std::vector rainVertices(RAIN_VERTEX_COUNT * CHUNK_COUNT); - for ( int i = 0; i < MAX_RAIN_VERTICES; ++i ) + for ( int i = 0; i < rainVertices.size(); ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); - vertex.position[1] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); - vertex.position[2] = Q_flrand(-HALF_ZONE_SIZE, HALF_ZONE_SIZE); + vertex.position[0] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); + vertex.position[1] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); + vertex.position[2] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); vertex.velocity[0] = Q_flrand(-2.0f, 2.0f); vertex.velocity[1] = Q_flrand(-2.0f, 2.0f); vertex.velocity[2] = Q_flrand(-20.0f, 0.0f); } - ws.lastVBO = R_CreateVBO(nullptr, sizeof(rainVertices), VBO_USAGE_XFB); - ws.vbo = R_CreateVBO((byte *)rainVertices, sizeof(rainVertices), VBO_USAGE_XFB); - ws.numVertices = MAX_RAIN_VERTICES; + ws.lastVBO = R_CreateVBO( + nullptr, + sizeof(rainVertex_t) * rainVertices.size(), + VBO_USAGE_XFB); + ws.vbo = R_CreateVBO( + (byte *)rainVertices.data(), + sizeof(rainVertex_t) * rainVertices.size(), + VBO_USAGE_XFB); ws.vboLastUpdateFrame = 0; ws.attribsTemplate[0].index = ATTR_INDEX_POSITION; @@ -101,30 +108,21 @@ namespace VBO_t *lastRainVBO = ws.vbo; VBO_t *rainVBO = ws.lastVBO; - vertexAttribute_t attribs[2] = {}; - attribs[0].index = ATTR_INDEX_POSITION; - attribs[0].numComponents = 3; - attribs[0].offset = offsetof(rainVertex_t, position); - attribs[0].stride = sizeof(rainVertex_t); - attribs[0].type = GL_FLOAT; - attribs[0].vbo = lastRainVBO; - attribs[1].index = ATTR_INDEX_COLOR; - attribs[1].numComponents = 3; - attribs[1].offset = offsetof(rainVertex_t, velocity); - attribs[1].stride = sizeof(rainVertex_t); - attribs[1].type = GL_FLOAT; - attribs[1].vbo = lastRainVBO; - - const size_t numAttribs = ARRAY_LEN(attribs); - DrawItem item = {}; item.renderState.transformFeedback = true; item.transformFeedbackBuffer = {rainVBO, 0, rainVBO->vertexesSize}; item.program = &tr.weatherUpdateShader; + + const size_t numAttribs = ARRAY_LEN(ws.attribsTemplate); item.numAttributes = numAttribs; item.attributes = ojkAllocArray( *backEndData->perFrameMemory, numAttribs); - memcpy(item.attributes, attribs, sizeof(*item.attributes) * numAttribs); + memcpy( + item.attributes, + ws.attribsTemplate, + sizeof(*item.attributes) * numAttribs); + item.attributes[0].vbo = lastRainVBO; + item.attributes[1].vbo = lastRainVBO; UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherUpdateShader); @@ -141,7 +139,7 @@ namespace item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; - item.draw.params.arrays.numVertices = ws.numVertices; + item.draw.params.arrays.numVertices = RAIN_VERTEX_COUNT * CHUNK_COUNT; // This is a bit dodgy. Push this towards the front of the queue so we // guarantee this happens before the actual drawing @@ -205,12 +203,6 @@ void RB_SurfaceWeather( srfWeather_t *surf ) RB_EndSurface(); - // Get look direction - // Determine which zones would be visible - // Update simulation in these zones - - // can do this in one go - // Render zones - RB_SimulateWeather(ws); DrawItem item = {}; @@ -235,16 +227,17 @@ void RB_SurfaceWeather( srfWeather_t *surf ) item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; - item.draw.params.arrays.numVertices = ws.numVertices; + item.draw.params.arrays.numVertices = RAIN_VERTEX_COUNT; const float *viewOrigin = backEnd.viewParms.ori.origin; float centerZoneOffsetX = - std::floor((backEnd.viewParms.ori.origin[0] / ZONE_SIZE) + 0.5f) * ZONE_SIZE; + std::floor((viewOrigin[0] / CHUNK_SIZE) + 0.5f) * CHUNK_SIZE; float centerZoneOffsetY = - std::floor((backEnd.viewParms.ori.origin[1] / ZONE_SIZE) + 0.5f) * ZONE_SIZE; + std::floor((viewOrigin[1] / CHUNK_SIZE) + 0.5f) * CHUNK_SIZE; + int chunkIndex = 0; for (int y = -1; y <= 1; ++y) { - for (int x = -1; x <= 1; ++x) + for (int x = -1; x <= 1; ++x, ++chunkIndex) { UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); @@ -254,11 +247,13 @@ void RB_SurfaceWeather( srfWeather_t *surf ) UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); uniformDataWriter.SetUniformVec2( UNIFORM_ZONEOFFSET, - centerZoneOffsetX + x * ZONE_SIZE, - centerZoneOffsetY + y * ZONE_SIZE); + centerZoneOffsetX + x * CHUNK_SIZE, + centerZoneOffsetY + y * CHUNK_SIZE); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + item.draw.params.arrays.firstVertex = RAIN_VERTEX_COUNT * chunkIndex; + uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); RB_AddDrawItem(backEndData->currentPass, key, item); } From 37c96a4a487ccb8156fc5963f981ce196598b154 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 12:50:56 +0100 Subject: [PATCH 464/708] Disable weather for now... --- codemp/rd-rend2/tr_weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 121625c2c8..e54c287ae0 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -180,7 +180,7 @@ void R_AddWeatherSurfaces() { assert(tr.weatherSystem); - if (true) + if (false) { R_AddDrawSurf( (surfaceType_t *)&tr.weatherSystem->weatherSurface, From 82ae2fbe7804d395b23d6cce5cee67d8d3ffa201 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 13:15:18 +0100 Subject: [PATCH 465/708] Increase rain count to 50k per chunk --- codemp/rd-rend2/glsl/weather.glsl | 2 +- codemp/rd-rend2/tr_weather.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 49a2b323a7..aff27e1e05 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -53,5 +53,5 @@ out vec4 out_Color; void main() { - out_Color = vec4(0.7, 0.8, 0.7, 0.4); + out_Color = vec4(0.7, 0.8, 0.7, 0.1); } diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index e54c287ae0..99e1c1e044 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -47,7 +47,7 @@ namespace const float CHUNK_SIZE = 2000.0f; const float HALF_CHUNK_SIZE = CHUNK_SIZE * 0.5f; const int CHUNK_COUNT = 9; // in 3x3 arrangement - const int RAIN_VERTEX_COUNT = 5000; + const int RAIN_VERTEX_COUNT = 50000; struct rainVertex_t { From b3a02ea3e93639c829cc2421fef08277d90f8ab4 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 19 May 2018 13:15:32 +0100 Subject: [PATCH 466/708] Add r_debugWeather cvar --- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_weather.cpp | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 974dcabbbb..c69e54a0a7 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -265,6 +265,7 @@ cvar_t *r_dynamicGlowWidth; cvar_t *r_dynamicGlowHeight; cvar_t *r_debugContext; +cvar_t *r_debugWeather; cvar_t *r_aspectCorrectFonts; @@ -1436,6 +1437,7 @@ void R_Register( void ) r_dynamicGlowHeight = ri.Cvar_Get( "r_dynamicGlowHeight", "240", CVAR_ARCHIVE|CVAR_LATCH, "" ); r_debugContext = ri.Cvar_Get( "r_debugContext", "0", CVAR_LATCH, "" ); + r_debugWeather = ri.Cvar_Get( "r_debugWeather", "0", CVAR_ARCHIVE, "" ); r_picmip = ri.Cvar_Get ("r_picmip", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); ri.Cvar_CheckRange( r_picmip, 0, 16, qtrue ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index dc8b116068..4601754aa8 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2556,6 +2556,7 @@ extern cvar_t *r_dynamicGlowWidth; extern cvar_t *r_dynamicGlowHeight; extern cvar_t *r_debugContext; +extern cvar_t *r_debugWeather; //==================================================================== diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 99e1c1e044..009e7580b8 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -180,7 +180,7 @@ void R_AddWeatherSurfaces() { assert(tr.weatherSystem); - if (false) + if (r_debugWeather->integer) { R_AddDrawSurf( (surfaceType_t *)&tr.weatherSystem->weatherSurface, From 68354a45467135f15caab81cd0259968c438f524 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 19 May 2018 22:34:10 +0200 Subject: [PATCH 467/708] env.json loading from SmileTheory - cubemaps are a struct now - passing the parralax value to the shader - little cleanup in tr_shader --- codemp/rd-rend2/json.h | 353 +++++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_backend.cpp | 6 +- codemp/rd-rend2/tr_bsp.cpp | 121 +++++++++-- codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_light.cpp | 2 +- codemp/rd-rend2/tr_local.h | 12 +- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_shade.cpp | 13 +- codemp/rd-rend2/tr_shader.cpp | 1 - 9 files changed, 484 insertions(+), 28 deletions(-) create mode 100644 codemp/rd-rend2/json.h diff --git a/codemp/rd-rend2/json.h b/codemp/rd-rend2/json.h new file mode 100644 index 0000000000..cfc5b3cac6 --- /dev/null +++ b/codemp/rd-rend2/json.h @@ -0,0 +1,353 @@ +/* +=========================================================================== +Copyright (C) 2016 James Canete + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +=========================================================================== +*/ + +#ifndef JSON_H +#define JSON_H + +enum +{ + JSONTYPE_STRING, // string + JSONTYPE_OBJECT, // object + JSONTYPE_ARRAY, // array + JSONTYPE_VALUE, // number, true, false, or null + JSONTYPE_ERROR // out of data +}; + +// -------------------------------------------------------------------------- +// Array Functions +// -------------------------------------------------------------------------- + +// Get pointer to first value in array +// When given pointer to an array, returns pointer to the first +// returns NULL if array is empty or not an array. +const char *JSON_ArrayGetFirstValue(const char *json, const char *jsonEnd); + +// Get pointer to next value in array +// When given pointer to a value, returns pointer to the next value +// returns NULL when no next value. +const char *JSON_ArrayGetNextValue(const char *json, const char *jsonEnd); + +// Get pointers to values in an array +// returns 0 if not an array, array is empty, or out of data +// returns number of values in the array and copies into index if successful +unsigned int JSON_ArrayGetIndex(const char *json, const char *jsonEnd, const char **indexes, unsigned int numIndexes); + +// Get pointer to indexed value from array +// returns NULL if not an array, no index, or out of data +const char *JSON_ArrayGetValue(const char *json, const char *jsonEnd, unsigned int index); + +// -------------------------------------------------------------------------- +// Object Functions +// -------------------------------------------------------------------------- + +// Get pointer to named value from object +// returns NULL if not an object, name not found, or out of data +const char *JSON_ObjectGetNamedValue(const char *json, const char *jsonEnd, const char *name); + +// -------------------------------------------------------------------------- +// Value Functions +// -------------------------------------------------------------------------- + +// Get type of value +// returns JSONTYPE_ERROR if out of data +unsigned int JSON_ValueGetType(const char *json, const char *jsonEnd); + +// Get value as string +// returns 0 if out of data +// returns length and copies into string if successful, including terminating nul. +// string values are stripped of enclosing quotes but not escaped +unsigned int JSON_ValueGetString(const char *json, const char *jsonEnd, char *outString, unsigned int stringLen); + +// Get value as appropriate type +// returns 0 if value is false, value is null, or out of data +// returns 1 if value is true +// returns value otherwise +double JSON_ValueGetDouble(const char *json, const char *jsonEnd); +float JSON_ValueGetFloat(const char *json, const char *jsonEnd); +int JSON_ValueGetInt(const char *json, const char *jsonEnd); + +#endif + +#ifdef JSON_IMPLEMENTATION +#include + +// -------------------------------------------------------------------------- +// Internal Functions +// -------------------------------------------------------------------------- + +static const char *JSON_SkipSeparators(const char *json, const char *jsonEnd); +static const char *JSON_SkipString(const char *json, const char *jsonEnd); +static const char *JSON_SkipStruct(const char *json, const char *jsonEnd); +static const char *JSON_SkipValue(const char *json, const char *jsonEnd); +static const char *JSON_SkipValueAndSeparators(const char *json, const char *jsonEnd); + +#define IS_SEPARATOR(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\r' || (x) == ',' || (x) == ':') +#define IS_STRUCT_OPEN(x) ((x) == '{' || (x) == '[') +#define IS_STRUCT_CLOSE(x) ((x) == '}' || (x) == ']') + +static const char *JSON_SkipSeparators(const char *json, const char *jsonEnd) +{ + while (json < jsonEnd && IS_SEPARATOR(*json)) + json++; + + return json; +} + +static const char *JSON_SkipString(const char *json, const char *jsonEnd) +{ + for (json++; json < jsonEnd && *json != '"'; json++) + if (*json == '\\') + json++; + + return (json + 1 > jsonEnd) ? jsonEnd : json + 1; +} + +static const char *JSON_SkipStruct(const char *json, const char *jsonEnd) +{ + json = JSON_SkipSeparators(json + 1, jsonEnd); + while (json < jsonEnd && !IS_STRUCT_CLOSE(*json)) + json = JSON_SkipValueAndSeparators(json, jsonEnd); + + return (json + 1 > jsonEnd) ? jsonEnd : json + 1; +} + +static const char *JSON_SkipValue(const char *json, const char *jsonEnd) +{ + if (json >= jsonEnd) + return jsonEnd; + else if (*json == '"') + json = JSON_SkipString(json, jsonEnd); + else if (IS_STRUCT_OPEN(*json)) + json = JSON_SkipStruct(json, jsonEnd); + else + { + while (json < jsonEnd && !IS_SEPARATOR(*json) && !IS_STRUCT_CLOSE(*json)) + json++; + } + + return json; +} + +static const char *JSON_SkipValueAndSeparators(const char *json, const char *jsonEnd) +{ + json = JSON_SkipValue(json, jsonEnd); + return JSON_SkipSeparators(json, jsonEnd); +} + +// returns 0 if value requires more parsing, 1 if no more data/false/null, 2 if true +static unsigned int JSON_NoParse(const char *json, const char *jsonEnd) +{ + if (!json || json >= jsonEnd || *json == 'f' || *json == 'n') + return 1; + + if (*json == 't') + return 2; + + return 0; +} + +// -------------------------------------------------------------------------- +// Array Functions +// -------------------------------------------------------------------------- + +const char *JSON_ArrayGetFirstValue(const char *json, const char *jsonEnd) +{ + if (!json || json >= jsonEnd || !IS_STRUCT_OPEN(*json)) + return NULL; + + json = JSON_SkipSeparators(json + 1, jsonEnd); + + return (json >= jsonEnd || IS_STRUCT_CLOSE(*json)) ? NULL : json; +} + +const char *JSON_ArrayGetNextValue(const char *json, const char *jsonEnd) +{ + if (!json || json >= jsonEnd || IS_STRUCT_CLOSE(*json)) + return NULL; + + json = JSON_SkipValueAndSeparators(json, jsonEnd); + + return (json >= jsonEnd || IS_STRUCT_CLOSE(*json)) ? NULL : json; +} + +unsigned int JSON_ArrayGetIndex(const char *json, const char *jsonEnd, const char **indexes, unsigned int numIndexes) +{ + unsigned int length = 0; + + for (json = JSON_ArrayGetFirstValue(json, jsonEnd); json; json = JSON_ArrayGetNextValue(json, jsonEnd)) + { + if (indexes && numIndexes) + { + *indexes++ = json; + numIndexes--; + } + length++; + } + + return length; +} + +const char *JSON_ArrayGetValue(const char *json, const char *jsonEnd, unsigned int index) +{ + for (json = JSON_ArrayGetFirstValue(json, jsonEnd); json && index; json = JSON_ArrayGetNextValue(json, jsonEnd)) + index--; + + return json; +} + +// -------------------------------------------------------------------------- +// Object Functions +// -------------------------------------------------------------------------- + +const char *JSON_ObjectGetNamedValue(const char *json, const char *jsonEnd, const char *name) +{ + unsigned int nameLen = strlen(name); + + for (json = JSON_ArrayGetFirstValue(json, jsonEnd); json; json = JSON_ArrayGetNextValue(json, jsonEnd)) + { + if (*json == '"') + { + const char *thisNameStart, *thisNameEnd; + + thisNameStart = json + 1; + json = JSON_SkipString(json, jsonEnd); + thisNameEnd = json - 1; + json = JSON_SkipSeparators(json, jsonEnd); + + if ((unsigned int)(thisNameEnd - thisNameStart) == nameLen) + if (strncmp(thisNameStart, name, nameLen) == 0) + return json; + } + } + + return NULL; +} + +// -------------------------------------------------------------------------- +// Value Functions +// -------------------------------------------------------------------------- + +unsigned int JSON_ValueGetType(const char *json, const char *jsonEnd) +{ + if (!json || json >= jsonEnd) + return JSONTYPE_ERROR; + else if (*json == '"') + return JSONTYPE_STRING; + else if (*json == '{') + return JSONTYPE_OBJECT; + else if (*json == '[') + return JSONTYPE_ARRAY; + + return JSONTYPE_VALUE; +} + +unsigned int JSON_ValueGetString(const char *json, const char *jsonEnd, char *outString, unsigned int stringLen) +{ + const char *stringEnd, *stringStart; + + if (!json) + { + *outString = '\0'; + return 0; + } + + stringStart = json; + stringEnd = JSON_SkipValue(stringStart, jsonEnd); + if (stringEnd >= jsonEnd) + { + *outString = '\0'; + return 0; + } + + // skip enclosing quotes if they exist + if (*stringStart == '"') + stringStart++; + + if (*(stringEnd - 1) == '"') + stringEnd--; + + stringLen--; + if (stringLen > stringEnd - stringStart) + stringLen = stringEnd - stringStart; + + json = stringStart; + while (stringLen--) + *outString++ = *json++; + *outString = '\0'; + + return stringEnd - stringStart; +} + +double JSON_ValueGetDouble(const char *json, const char *jsonEnd) +{ + char cValue[256]; + double dValue = 0.0; + unsigned int np = JSON_NoParse(json, jsonEnd); + + if (np) + return (double)(np - 1); + + if (!JSON_ValueGetString(json, jsonEnd, cValue, 256)) + return 0.0; + + sscanf(cValue, "%lf", &dValue); + + return dValue; +} + +float JSON_ValueGetFloat(const char *json, const char *jsonEnd) +{ + char cValue[256]; + float fValue = 0.0f; + unsigned int np = JSON_NoParse(json, jsonEnd); + + if (np) + return (float)(np - 1); + + if (!JSON_ValueGetString(json, jsonEnd, cValue, 256)) + return 0.0f; + + sscanf(cValue, "%f", &fValue); + + return fValue; +} + +int JSON_ValueGetInt(const char *json, const char *jsonEnd) +{ + char cValue[256]; + int iValue = 0; + unsigned int np = JSON_NoParse(json, jsonEnd); + + if (np) + return np - 1; + + if (!JSON_ValueGetString(json, jsonEnd, cValue, 256)) + return 0; + + sscanf(cValue, "%d", &iValue); + + return iValue; +} + +#undef IS_SEPARATOR +#undef IS_STRUCT_OPEN +#undef IS_STRUCT_CLOSE + +#endif diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e99bdd6de0..379445f9f4 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -516,7 +516,7 @@ void RB_BeginDrawingView (void) { // FIXME: hack for cubemap testing if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { - image_t *cubemap = tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex]; + image_t *cubemap = tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex].image; qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); } } @@ -1873,7 +1873,7 @@ static const void *RB_PrefilterEnvMap(const void *data) { RB_SetGL2D(); - image_t *cubemap = tr.cubemaps[cmd->cubemap]; + image_t *cubemap = tr.cubemaps[cmd->cubemap].image; if (!cubemap || !cmd) return (const void *)(cmd + 1); @@ -2481,7 +2481,7 @@ static const void *RB_CaptureShadowMap(const void *data) { if (tr.shadowCubemaps[cmd->map] != NULL) { - GL_Bind(tr.shadowCubemaps[cmd->map]); + GL_Bind(tr.shadowCubemaps[cmd->map]->image); qglCopyTexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE ); } } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c846aa2374..270e617550 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -22,6 +22,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_map.c #include "tr_local.h" + +#define JSON_IMPLEMENTATION +#include "json.h" +#undef JSON_IMPLEMENTATION + #include "tr_cache.h" #include @@ -2928,7 +2933,80 @@ static qboolean R_ParseSpawnVars( char *spawnVarChars, int maxSpawnVarChars, int return qtrue; } -static void R_LoadCubemapEntities(const char *cubemapEntityName) +void R_LoadEnvironmentJson(const char *baseName) +{ + char filename[MAX_QPATH]; + + union { + char *c; + void *v; + } buffer; + char *bufferEnd; + + const char *environmentArrayJson; + int filelen, i; + + Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/env.json", baseName); + + filelen = ri.FS_ReadFile(filename, &buffer.v); + if (!buffer.c) + return; + bufferEnd = buffer.c + filelen; + + ri.Printf(PRINT_ALL, "Loaded Enviroment JSON: %s\n", filename); + + if (JSON_ValueGetType(buffer.c, bufferEnd) != JSONTYPE_OBJECT) + { + ri.Printf(PRINT_ALL, "Bad %s: does not start with a object\n", filename); + ri.FS_FreeFile(buffer.v); + return; + } + //-----------------------------CUBEMAPS------------------------------------ + environmentArrayJson = JSON_ObjectGetNamedValue(buffer.c, bufferEnd, "Cubemaps"); + if (!environmentArrayJson) + { + ri.Printf(PRINT_ALL, "Bad %s: no Cubemaps\n", filename); + ri.FS_FreeFile(buffer.v); + return; + } + + if (JSON_ValueGetType(environmentArrayJson, bufferEnd) != JSONTYPE_ARRAY) + { + ri.Printf(PRINT_ALL, "Bad %s: Cubemaps not an array\n", filename); + ri.FS_FreeFile(buffer.v); + return; + } + + tr.numCubemaps = JSON_ArrayGetIndex(environmentArrayJson, bufferEnd, NULL, 0); + tr.cubemaps = (cubemap_t *)ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + + for (i = 0; i < tr.numCubemaps; i++) + { + cubemap_t *cubemap = &tr.cubemaps[i]; + const char *cubemapJson, *keyValueJson, *indexes[3]; + int j; + + cubemapJson = JSON_ArrayGetValue(environmentArrayJson, bufferEnd, i); + + keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Name"); + if (!JSON_ValueGetString(keyValueJson, bufferEnd, cubemap->name, MAX_QPATH)) + cubemap->name[0] = '\0'; + + keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Position"); + JSON_ArrayGetIndex(keyValueJson, bufferEnd, indexes, 3); + for (j = 0; j < 3; j++) + cubemap->origin[j] = JSON_ValueGetFloat(indexes[j], bufferEnd); + + cubemap->parallaxRadius = 1000.0f; + keyValueJson = JSON_ObjectGetNamedValue(cubemapJson, bufferEnd, "Radius"); + if (keyValueJson) + cubemap->parallaxRadius = JSON_ValueGetFloat(keyValueJson, bufferEnd); + } + + ri.FS_FreeFile(buffer.v); +} + +void R_LoadCubemapEntities(char *cubemapEntityName) { char spawnVarChars[2048]; int numSpawnVars; @@ -2937,7 +3015,7 @@ static void R_LoadCubemapEntities(const char *cubemapEntityName) // count cubemaps numCubemaps = 0; - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) { int i; @@ -2952,33 +3030,45 @@ static void R_LoadCubemapEntities(const char *cubemapEntityName) return; tr.numCubemaps = numCubemaps; - tr.cubemapOrigins = (vec3_t *)ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemapOrigins), h_low); - tr.cubemaps = (image_t **)ri.Hunk_Alloc( tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + tr.cubemaps = (cubemap_t *)ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low); + memset(tr.cubemaps, 0, tr.numCubemaps * sizeof(*tr.cubemaps)); numCubemaps = 0; - while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) { int i; + char name[MAX_QPATH]; qboolean isCubemap = qfalse; - qboolean positionSet = qfalse; + qboolean originSet = qfalse; vec3_t origin; + float parallaxRadius = 1000.0f; + name[0] = '\0'; for (i = 0; i < numSpawnVars; i++) { if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], cubemapEntityName)) isCubemap = qtrue; + if (!Q_stricmp(spawnVars[i][0], "name")) + Q_strncpyz(name, spawnVars[i][1], MAX_QPATH); + if (!Q_stricmp(spawnVars[i][0], "origin")) { sscanf(spawnVars[i][1], "%f %f %f", &origin[0], &origin[1], &origin[2]); - positionSet = qtrue; + originSet = qtrue; + } + else if (!Q_stricmp(spawnVars[i][0], "radius")) + { + sscanf(spawnVars[i][1], "%f", ¶llaxRadius); } } - if (isCubemap && positionSet) + if (isCubemap && originSet) { - //ri.Printf(PRINT_ALL, "cubemap at %f %f %f\n", origin[0], origin[1], origin[2]); - VectorCopy(origin, tr.cubemapOrigins[numCubemaps]); + cubemap_t *cubemap = &tr.cubemaps[numCubemaps]; + Q_strncpyz(cubemap->name, name, MAX_QPATH); + VectorCopy(origin, cubemap->origin); + cubemap->parallaxRadius = parallaxRadius; numCubemaps++; } } @@ -3033,7 +3123,7 @@ static void R_RenderAllCubemaps(void) for (int i = 0; i < tr.numCubemaps; i++) { if (!bounce) - tr.cubemaps[i] = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); + tr.cubemaps[i].image = R_CreateImage(va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); for (int j = 0; j < 6; j++) { @@ -3724,7 +3814,14 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) // load cubemaps if (r_cubeMapping->integer) { - R_LoadCubemapEntities("misc_cubemap"); + // Try loading an env.json file first + R_LoadEnvironmentJson(worldData->baseName); + + if (!tr.numCubemaps) + { + R_LoadCubemapEntities("misc_cubemap"); + } + if (!tr.numCubemaps) { // use deathmatch spawn points as cubemaps diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 0d858def17..a6956fed85 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3172,7 +3172,7 @@ void R_CreateBuiltinImages( void ) { { for (x = 0; x < MAX_DLIGHTS; x++) { - tr.shadowCubemaps[x] = R_CreateImage( + tr.shadowCubemaps[x]->image = R_CreateImage( va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index f2b6e27329..80bdf63168 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -502,7 +502,7 @@ int R_CubemapForPoint( const vec3_t point ) vec3_t diff; float length; - VectorSubtract(point, tr.cubemapOrigins[i], diff); + VectorSubtract(point, tr.cubemaps[i].origin, diff); length = DotProduct(diff, diff); if (shortest > length) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3dc56cd984..29956e2276 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -370,6 +370,13 @@ typedef struct image_s { struct image_s *poolNext; } image_t; +typedef struct cubemap_s { + char name[MAX_QPATH]; + vec3_t origin; + float parallaxRadius; + image_t *image; +} cubemap_t; + typedef struct dlight_s { vec3_t origin; vec3_t color; // range from 0.0 to 1.0, should be color normalized @@ -2202,7 +2209,7 @@ typedef struct trGlobals_s { image_t *whiteImage; // full of 0xff image_t *identityLightImage; // full of tr.identityLightByte - image_t *shadowCubemaps[MAX_DLIGHTS]; + cubemap_t *shadowCubemaps[MAX_DLIGHTS]; image_t *renderImage; @@ -2262,8 +2269,7 @@ typedef struct trGlobals_s { vec2i_t lightmapsPerAtlasSide; int numCubemaps; - vec3_t *cubemapOrigins; - image_t **cubemaps; + cubemap_t *cubemaps; trRefEntity_t worldEntity; // point currentEntity at this when rendering world model_t *currentModel; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 5a80decd77..63602bec0c 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2820,7 +2820,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, memset( &refdef, 0, sizeof( refdef ) ); refdef.rdflags = 0; - VectorCopy(tr.cubemapOrigins[cubemapIndex], refdef.vieworg); + VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg); switch(cubemapSide) { diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 7688f43c8e..9248b15d98 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1001,7 +1001,7 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); if (r_dlightMode->integer >= 2) - samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l], TB_SHADOWMAP); + samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l]->image, TB_SHADOWMAP); ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); @@ -1671,16 +1671,17 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( enableCubeMaps ) { vec4_t vec; + cubemap_t *cubemap = &tr.cubemaps[input->cubemapIndex - 1]; - samplerBindingsWriter.AddStaticImage(tr.cubemaps[input->cubemapIndex - 1], TB_CUBEMAP); + samplerBindingsWriter.AddStaticImage(cubemap->image, TB_CUBEMAP); samplerBindingsWriter.AddStaticImage(tr.envBrdfImage, TB_ENVBRDFMAP); - vec[0] = tr.cubemapOrigins[input->cubemapIndex - 1][0] - backEnd.viewParms.ori.origin[0]; - vec[1] = tr.cubemapOrigins[input->cubemapIndex - 1][1] - backEnd.viewParms.ori.origin[1]; - vec[2] = tr.cubemapOrigins[input->cubemapIndex - 1][2] - backEnd.viewParms.ori.origin[2]; + vec[0] = tr.cubemaps[input->cubemapIndex - 1].origin[0] - backEnd.viewParms.ori.origin[0]; + vec[1] = tr.cubemaps[input->cubemapIndex - 1].origin[1] - backEnd.viewParms.ori.origin[1]; + vec[2] = tr.cubemaps[input->cubemapIndex - 1].origin[2] - backEnd.viewParms.ori.origin[2]; vec[3] = 1.0f; - VectorScale4(vec, 1.0f / 1000.0f, vec); + VectorScale4(vec, 1.0f / cubemap->parallaxRadius, vec); uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 48ae68974b..3607f35511 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1652,7 +1652,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if (!Q_stricmp(token, "roughness")) { - float roughness; token = COM_ParseExt(text, qfalse); if (token[0] == 0) { From b187e0924c91e696498ae937febb19a7257a43a2 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 20 May 2018 10:38:33 +0100 Subject: [PATCH 468/708] Minor reformatting --- codemp/rd-rend2/tr_bsp.cpp | 24 ++++++++++++++++-------- codemp/rd-rend2/tr_weather.cpp | 8 -------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c28c81fc36..e10ef05c28 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3018,24 +3018,32 @@ static void R_AssignCubemapsToWorldSurfaces(world_t *worldData) } -static void R_RenderAllCubemaps(void) +static void R_RenderAllCubemaps() { - int i, j; GLenum cubemapFormat = GL_RGBA8; - - if ( r_hdr->integer ) + if (r_hdr->integer) { cubemapFormat = GL_RGBA16F; } - for (i = 0; i < tr.numCubemaps; i++) + for (int i = 0; i < tr.numCubemaps; i++) { - tr.cubemaps[i] = R_CreateImage (va ("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_MIPMAP | IMGFLAG_CUBEMAP, cubemapFormat); + tr.cubemaps[i] = R_CreateImage( + va("*cubeMap%d", i), + NULL, + CUBE_MAP_SIZE, + CUBE_MAP_SIZE, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE | + IMGFLAG_MIPMAP | + IMGFLAG_CUBEMAP, + cubemapFormat); } - for (i = 0; i < tr.numCubemaps; i++) + for (int i = 0; i < tr.numCubemaps; i++) { - for (j = 0; j < 6; j++) + for (int j = 0; j < 6; j++) { RE_ClearScene(); R_RenderCubemapSide(i, j, qfalse); diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 009e7580b8..8a35e48ce2 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -23,14 +23,6 @@ along with this program; if not, see . #include #include -struct LocalWeatherZone -{ - unsigned vboLastUpdateFrame; - VBO_t *lastVBO; - VBO_t *vbo; - int numVertices; -}; - struct weatherSystem_t { VBO_t *lastVBO; From 1144c84fd1cdb51b42bf6ac253a61d72361a05f3 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 20 May 2018 23:04:09 +0200 Subject: [PATCH 469/708] dlight shadows with r_dlightMode 2 --- codemp/rd-rend2/glsl/lightall.glsl | 52 ++++++++++++++++++++++++++++++ codemp/rd-rend2/tr_backend.cpp | 49 ++++------------------------ codemp/rd-rend2/tr_cmds.cpp | 20 ------------ codemp/rd-rend2/tr_fbo.cpp | 14 ++++++++ codemp/rd-rend2/tr_glsl.cpp | 6 +++- codemp/rd-rend2/tr_image.cpp | 33 ++++++++++++------- codemp/rd-rend2/tr_local.h | 7 ++-- codemp/rd-rend2/tr_main.cpp | 23 +++++++++---- codemp/rd-rend2/tr_scene.cpp | 1 + codemp/rd-rend2/tr_shade.cpp | 2 +- 10 files changed, 120 insertions(+), 87 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 6f70739615..290a0321db 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -343,6 +343,7 @@ uniform vec4 u_EnableTextures; #if defined(USE_LIGHT_VECTOR) && !defined(USE_VERTEX_LIGHTING) uniform vec3 u_DirectedLight; uniform vec3 u_AmbientLight; +uniform samplerCubeShadow u_ShadowMap2; #endif #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) @@ -499,6 +500,50 @@ float CalcLightAttenuation(float point, float normDist) return clamp(attenuation, 0.0, 1.0); } +#if defined(USE_LIGHT_VECTOR) && !defined(USE_VERTEX_LIGHTING) && defined(USE_DSHADOWS) +#define DEPTH_MAX_ERROR 0.000000059604644775390625 + +vec3 sampleOffsetDirections[20] = vec3[] +( + vec3(1, 1, 1), vec3(1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1), + vec3(1, 1, -1), vec3(1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1), + vec3(1, 1, 0), vec3(1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0), + vec3(1, 0, 1), vec3(-1, 0, 1), vec3(1, 0, -1), vec3(-1, 0, -1), + vec3(0, 1, 1), vec3(0, -1, 1), vec3(0, -1, -1), vec3(0, 1, -1) + ); + +float pcfShadow(samplerCubeShadow depthMap, vec3 L, float distance) +{ + float shadow = 0.0; + int samples = 20; + float diskRadius = 128.0/512.0; + for (int i = 0; i < samples; ++i) + { + shadow += texture(depthMap, vec4(L + sampleOffsetDirections[i] * diskRadius, distance)); + } + shadow /= float(samples); + return shadow; +} + +float getLightDepth(vec3 Vec, float f) +{ + vec3 AbsVec = abs(Vec); + float Z = max(AbsVec.x, max(AbsVec.y, AbsVec.z)); + + const float n = 1.0; + + float NormZComp = (f + n) / (f - n) - 2 * f*n / (Z* (f - n)); + + return ((NormZComp + 1.0) * 0.5) - DEPTH_MAX_ERROR; +} + +float getShadowValue(vec4 light) +{ + float distance = getLightDepth(light.xyz, sqrt(light.w)); + return pcfShadow(u_ShadowMap2, light.xyz, distance); +} +#endif + vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) { #if defined(USE_PARALLAXMAP) @@ -629,6 +674,13 @@ void main() lightColor = u_DirectedLight * var_Color.rgb; ambientColor = u_AmbientLight * var_Color.rgb; attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); + + #if defined(USE_DSHADOWS) + if (var_LightDir.w > 0.0) { + attenuation *= getShadowValue(var_LightDir); + } + #endif + #elif defined(USE_LIGHT_VERTEX) lightColor = var_Color.rgb; ambientColor = vec3 (0.0); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 379445f9f4..ab0dbde724 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -516,9 +516,14 @@ void RB_BeginDrawingView (void) { // FIXME: hack for cubemap testing if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) { - image_t *cubemap = tr.cubemaps[backEnd.viewParms.targetFboCubemapIndex].image; + image_t *cubemap = backEnd.viewParms.targetFboCubemap->image; qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); } + else if (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo) + { + image_t *cubemap = backEnd.viewParms.targetFboCubemap->image; + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); + } } // @@ -2460,45 +2465,6 @@ static const void *RB_SwapBuffers( const void *data ) { return (const void *)(cmd + 1); } -/* -============= -RB_CapShadowMap - -============= -*/ -static const void *RB_CaptureShadowMap(const void *data) -{ - const capShadowmapCommand_t *cmd = (const capShadowmapCommand_t *)data; - - // finish any 2D drawing if needed - if(tess.numIndexes) - RB_EndSurface(); - - if (cmd->map != -1) - { - GL_SelectTexture(0); - if (cmd->cubeSide != -1) - { - if (tr.shadowCubemaps[cmd->map] != NULL) - { - GL_Bind(tr.shadowCubemaps[cmd->map]->image); - qglCopyTexSubImage2D( GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE ); - } - } - else - { - if (tr.pshadowMaps[cmd->map] != NULL) - { - GL_Bind(tr.pshadowMaps[cmd->map]); - qglCopyTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, backEnd.refdef.x, glConfig.vidHeight - ( backEnd.refdef.y + PSHADOW_MAP_SIZE ), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE ); - } - } - } - - return (const void *)(cmd + 1); -} - - /* ============= RB_PostProcess @@ -2769,9 +2735,6 @@ void RB_ExecuteRenderCommands( const void *data ) { case RC_CLEARDEPTH: data = RB_ClearDepth(data); break; - case RC_CAPSHADOWMAP: - data = RB_CaptureShadowMap(data); - break; case RC_CONVOLVECUBEMAP: data = RB_PrefilterEnvMap( data ); break; diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 2dab59527c..5453850fa7 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -224,26 +224,6 @@ void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) { cmd->viewParms = tr.viewParms; } - -/* -============= -R_AddCapShadowmapCmd - -============= -*/ -void R_AddCapShadowmapCmd( int map, int cubeSide ) { - capShadowmapCommand_t *cmd; - - cmd = (capShadowmapCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); - if ( !cmd ) { - return; - } - cmd->commandId = RC_CAPSHADOWMAP; - - cmd->map = map; - cmd->cubeSide = cubeSide; -} - /* ============= R_AddConvolveCubemapsCmd diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 4b4033c7a0..2dccc86278 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -513,6 +513,20 @@ void FBO_Init(void) } #endif + if (r_dlightMode->integer >= 2) + { + tr.shadowCubeFbo = FBO_Create("_shadowCubeFbo", PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); + FBO_Bind(tr.shadowCubeFbo); + + FBO_CreateBuffer(tr.shadowCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); + + qglDrawBuffer(GL_NONE); + + FBO_SetupDrawBuffers(); + + R_CheckFBO(tr.shadowCubeFbo); + } + if (tr.sunShadowDepthImage[0] != NULL) { for ( i = 0; i < 3; i++) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5893d99000..6b33c7673b 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1504,6 +1504,9 @@ static int GLSL_LoadGPUProgramLightAll( case LIGHTDEF_USE_LIGHT_VECTOR: { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VECTOR\n"); + if (r_dlightMode->integer >= 2) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DSHADOWS\n"); + break; } @@ -1586,8 +1589,9 @@ static int GLSL_LoadGPUProgramLightAll( GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_ENVBRDFMAP, TB_ENVBRDFMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_ENVBRDFMAP, TB_ENVBRDFMAP); qglUseProgram(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index a6956fed85..b5d5045afa 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2415,6 +2415,12 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + int format = GL_BGRA; + if (internalFormat == GL_DEPTH_COMPONENT24) + { + format = GL_DEPTH_COMPONENT; + } + if (image->flags & IMGFLAG_MIPMAP) { qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); @@ -2435,18 +2441,18 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT { for ( int i = 0; i < 6; i++ ) { - qglTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexSubImage2D (GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, width, height, format, GL_UNSIGNED_BYTE, pic); } } } else { - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); - qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); + qglTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, pic); } if (image->flags & IMGFLAG_MIPMAP) @@ -3172,10 +3178,15 @@ void R_CreateBuiltinImages( void ) { { for (x = 0; x < MAX_DLIGHTS; x++) { - tr.shadowCubemaps[x]->image = R_CreateImage( - va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, - PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, - IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, 0); + tr.shadowCubemaps[x].image = R_CreateImage( + va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, + IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, + GL_DEPTH_COMPONENT24); + GL_Bind(tr.shadowCubemaps[x].image); + qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 29956e2276..dbcde53fa0 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1398,7 +1398,7 @@ typedef struct { int scissorX, scissorY, scissorWidth, scissorHeight; FBO_t *targetFbo; int targetFboLayer; - int targetFboCubemapIndex; + cubemap_t *targetFboCubemap; float fovX, fovY; float projectionMatrix[16]; cplane_t frustum[5]; @@ -2209,8 +2209,7 @@ typedef struct trGlobals_s { image_t *whiteImage; // full of 0xff image_t *identityLightImage; // full of tr.identityLightByte - cubemap_t *shadowCubemaps[MAX_DLIGHTS]; - + cubemap_t shadowCubemaps[MAX_DLIGHTS]; image_t *renderImage; image_t *glowImage; @@ -2239,6 +2238,7 @@ typedef struct trGlobals_s { FBO_t *sunRaysFbo; FBO_t *depthFbo; FBO_t *pshadowFbos[MAX_DRAWN_PSHADOWS]; + FBO_t *shadowCubeFbo; FBO_t *textureScratchFbo[2]; FBO_t *quarterFbo[2]; FBO_t *calcLevelsFbo; @@ -3314,7 +3314,6 @@ typedef enum { RC_VIDEOFRAME, RC_COLORMASK, RC_CLEARDEPTH, - RC_CAPSHADOWMAP, RC_CONVOLVECUBEMAP, RC_POSTPROCESS, RC_BEGIN_TIMED_BLOCK, diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 63602bec0c..4316c2b88f 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1021,7 +1021,7 @@ void R_SetupProjectionZ(viewParms_t *dest) { float zNear, zFar, depth; - zNear = r_znear->value; + zNear = dest->zNear; zFar = dest->zFar; depth = zFar - zNear; @@ -1547,6 +1547,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms = tr.viewParms; newParms.isPortal = qtrue; newParms.zFar = 0.0f; + newParms.zNear = r_znear->value; newParms.flags &= ~VPF_FARPLANEFRUSTUM; if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, newParms.pvsOrigin, &newParms.isMirror ) ) { @@ -2115,7 +2116,7 @@ void R_RenderView (viewParms_t *parms) { // set viewParms.world R_RotateForViewer(&tr.ori, &tr.viewParms); - R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue); + R_SetupProjection(&tr.viewParms, tr.viewParms.zNear, tr.viewParms.zFar, qtrue); R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); @@ -2130,19 +2131,21 @@ void R_RenderDlightCubemaps(const refdef_t *fd) { int i; + unsigned int bufferDlightMask = tr.refdef.dlightMask; + for (i = 0; i < tr.refdef.num_dlights; i++) { viewParms_t shadowParms; int j; // use previous frame to determine visible dlights - if ((1 << i) & tr.refdef.dlightMask) + if ((1 << i) & bufferDlightMask) continue; Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - shadowParms.viewportX = tr.refdef.x; - shadowParms.viewportY = glConfig.vidHeight - ( tr.refdef.y + PSHADOW_MAP_SIZE ); + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; shadowParms.viewportWidth = PSHADOW_MAP_SIZE; shadowParms.viewportHeight = PSHADOW_MAP_SIZE; shadowParms.isPortal = qfalse; @@ -2153,6 +2156,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); shadowParms.zFar = tr.refdef.dlights[i].radius; + shadowParms.zNear = 1.0f; VectorCopy( tr.refdef.dlights[i].origin, shadowParms.ori.origin ); @@ -2198,8 +2202,11 @@ void R_RenderDlightCubemaps(const refdef_t *fd) break; } + shadowParms.targetFbo = tr.shadowCubeFbo; + shadowParms.targetFboCubemap = &tr.shadowCubemaps[i]; + shadowParms.targetFboLayer = j; + R_RenderView(&shadowParms); - R_AddCapShadowmapCmd( i, j ); } } } @@ -2769,6 +2776,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) shadowParms.flags = (viewParmFlags_t)( VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL); shadowParms.zFar = lightviewBounds[1][0]; + shadowParms.zNear = r_znear->value; VectorCopy(lightOrigin, shadowParms.ori.origin); @@ -2898,6 +2906,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, if (!bounce) parms.flags |= VPF_NOCUBEMAPS; + parms.zNear = r_znear->value; parms.fovX = 90; parms.fovY = 90; @@ -2915,7 +2924,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, parms.targetFbo = tr.renderCubeFbo; parms.targetFboLayer = cubemapSide; - parms.targetFboCubemapIndex = cubemapIndex; + parms.targetFboCubemap = &tr.cubemaps[cubemapIndex]; R_RenderView(&parms); diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index e37cc09f02..6b29f9a563 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -539,6 +539,7 @@ void RE_RenderScene( const refdef_t *fd ) { parms.viewportWidth = tr.refdef.width; parms.viewportHeight = tr.refdef.height; parms.isPortal = qfalse; + parms.zNear = r_znear->value; parms.fovX = tr.refdef.fov_x; parms.fovY = tr.refdef.fov_y; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9248b15d98..58fe8c4092 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1001,7 +1001,7 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); if (r_dlightMode->integer >= 2) - samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l]->image, TB_SHADOWMAP); + samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l].image, TB_SHADOWMAP2); ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); From 7dfc03e08d0b10bf9b6948a1982bd3b72c87c564 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 20 May 2018 23:29:46 +0200 Subject: [PATCH 470/708] fix drawing sun rays... --- codemp/rd-rend2/tr_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 4c3d8f135c..bd3003fb02 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -321,7 +321,7 @@ void RB_SunRays(FBO_t *srcFbo, vec4i_t srcBox, FBO_t *dstFbo, vec4i_t dstBox) // From RB_DrawSun() { float dist; - matrix_t trans, model, mvp; + matrix_t trans, model; Matrix16Translation( backEnd.viewParms.ori.origin, trans ); Matrix16Multiply( backEnd.viewParms.world.modelViewMatrix, trans, model ); From 9b1fcbe355865ca3a1668488a5cfc6c335c48d5f Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Wed, 23 May 2018 20:48:17 +0100 Subject: [PATCH 471/708] Add ARCH_STRING definition to GLSL compactor --- codemp/rd-rend2/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 302aab6eb8..010c0306f7 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -178,8 +178,11 @@ add_executable(compact_glsl ${MPDir}/rd-rend2/tr_allocator.cpp ${MPDir}/rd-rend2/tr_allocator.h ${MPDir}/rd-rend2/tr_glsl_parse.cpp) -set_target_properties(compact_glsl PROPERTIES COMPILE_DEFINITIONS "GLSL_BUILDTOOL") -set_target_properties(compact_glsl PROPERTIES INCLUDE_DIRECTORIES "${MPRend2IncludeDirectories}") +target_compile_definitions(compact_glsl PRIVATE "GLSL_BUILDTOOL") +if (NOT WIN32 AND NOT APPLE) + target_compile_definitions(compact_glsl PRIVATE "ARCH_STRING=\"${Architecture}\"") +endif() +target_include_directories(compact_glsl PRIVATE "${MPRend2IncludeDirectories}") add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp From 20d51189276c2c553cd5637229eb5ddb78990ea9 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 24 May 2018 22:28:18 +0200 Subject: [PATCH 472/708] some cleanup also enabled to use clamped specular and normal maps again (happens automatically if the diffuse is a clampmap) --- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 7 ++-- codemp/rd-rend2/tr_cmds.cpp | 2 +- codemp/rd-rend2/tr_fbo.cpp | 1 + codemp/rd-rend2/tr_image.cpp | 36 ++++++++-------- codemp/rd-rend2/tr_local.h | 14 +++---- codemp/rd-rend2/tr_shader.cpp | 76 +++++++++------------------------- 7 files changed, 51 insertions(+), 87 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index ab0dbde724..1808fc7a9a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1878,7 +1878,7 @@ static const void *RB_PrefilterEnvMap(const void *data) { RB_SetGL2D(); - image_t *cubemap = tr.cubemaps[cmd->cubemap].image; + image_t *cubemap = cmd->cubemap->image; if (!cubemap || !cmd) return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 270e617550..68d8722bd9 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3015,7 +3015,7 @@ void R_LoadCubemapEntities(char *cubemapEntityName) // count cubemaps numCubemaps = 0; - while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) { int i; @@ -3031,10 +3031,9 @@ void R_LoadCubemapEntities(char *cubemapEntityName) tr.numCubemaps = numCubemaps; tr.cubemaps = (cubemap_t *)ri.Hunk_Alloc(tr.numCubemaps * sizeof(*tr.cubemaps), h_low); - memset(tr.cubemaps, 0, tr.numCubemaps * sizeof(*tr.cubemaps)); numCubemaps = 0; - while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + while(R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) { int i; char name[MAX_QPATH]; @@ -3135,7 +3134,7 @@ static void R_RenderAllCubemaps(void) for (int j = 0; j < 6; j++) { RE_ClearScene(); - R_AddConvolveCubemapCmd(i, j); + R_AddConvolveCubemapCmd(&tr.cubemaps[i], j); R_IssuePendingRenderCommands(); R_InitNextFrame(); } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 5453850fa7..8fe70f7872 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -230,7 +230,7 @@ R_AddConvolveCubemapsCmd ============= */ -void R_AddConvolveCubemapCmd( int cubemap , int cubeSide ) { +void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubeSide ) { convolveCubemapCommand_t *cmd; cmd = (convolveCubemapCommand_t *)R_GetCommandBuffer( sizeof( *cmd )); diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 2dccc86278..12525b2b93 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -521,6 +521,7 @@ void FBO_Init(void) FBO_CreateBuffer(tr.shadowCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); qglDrawBuffer(GL_NONE); + qglReadBuffer(GL_NONE); FBO_SetupDrawBuffers(); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b5d5045afa..f863ec2099 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2598,6 +2598,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c int width, height, rmoWidth, rmoHeight; byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; long hash; + qboolean foundDiffuse, foundSpecular = qfalse; if (!name) { return; @@ -2616,16 +2617,22 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c for (image = hashTable[hash]; image; image = image->next) { if (!strcmp(diffuseName, image->imgName)) { stage->bundle[TB_COLORMAP].image[0] = image; - // check for specular map - hash = generateHashValue(specularName); - for (image = hashTable[hash]; image; image = image->next) { - if (!strcmp(specularName, image->imgName)) { - stage->bundle[TB_SPECULARMAP].image[0] = image; - return; - } - } + foundDiffuse = qtrue; + break; } } + // check for specular map + hash = generateHashValue(specularName); + for (image = hashTable[hash]; image; image = image->next) { + if (!strcmp(specularName, image->imgName)) { + stage->bundle[TB_SPECULARMAP].image[0] = image; + foundSpecular = qtrue; + break; + } + } + + if (foundDiffuse && foundSpecular) + return; // // load the pics from disk @@ -2670,35 +2677,29 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c { case SPEC_RMO: case SPEC_RMOS: - { roughness = ByteToFloat(rmoPic[i + 0]); gloss = (1.0 - roughness) + (0.04 * roughness); metalness = ByteToFloat(rmoPic[i + 1]); ao = ByteToFloat(rmoPic[i + 2]); ao += (1.0 - ao) * (1.0 - aoStrength); specular_variance = ByteToFloat(rmoPic[i + 3]); - } - break; + break; case SPEC_MOXR: case SPEC_MOSR: - { metalness = ByteToFloat(rmoPic[i + 0]); ao = ByteToFloat(rmoPic[i + 1]); ao += (1.0 - ao) * (1.0 - aoStrength); specular_variance = ByteToFloat(rmoPic[i + 2]); roughness = ByteToFloat(rmoPic[i + 3]); gloss = (1.0 - roughness) + (0.04 * roughness); - } - break; + break; // should never reach this default: - { specular_variance = 1.0f; metalness = 0.0f; gloss = 0.02f; ao = 1.0f; - } - break; + break; } float baseColor[4]; @@ -2713,6 +2714,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // diffuse Color = baseColor * (1.0 - metalness) // also gamma correct again + // FIXME: AO should be handled in shader because it should only affect the ambient lighting diffusePic[i + 0] = FloatToByte(pow(baseColor[0] * (1.0f - metalness) * ao, INV_GAMMA)); diffusePic[i + 1] = FloatToByte(pow(baseColor[1] * (1.0f - metalness) * ao, INV_GAMMA)); diffusePic[i + 2] = FloatToByte(pow(baseColor[2] * (1.0f - metalness) * ao, INV_GAMMA)); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index dbcde53fa0..8c6a6dab88 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -738,9 +738,9 @@ typedef enum enum specularType { - SPEC_NONE, // no specular found - SPEC_RMO, // calculate spec from rmo texture with a specular of 0.04 for dielectric materials - SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input + SPEC_NONE, // no specular found + SPEC_RMO, // calculate spec from rmo texture with a specular of 0.04 for dielectric materials + SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input SPEC_MOXR, // calculate spec from moxr texture with a specular of 0.04 for dielectric materials SPEC_MOSR, // calculate spec from mosr texture with a specular of 0.0 - 0.08 from input }; @@ -3279,9 +3279,9 @@ typedef struct capShadowmapCommand_s { } capShadowmapCommand_t; typedef struct convolveCubemapCommand_s { - int commandId; - int cubemap; - int cubeSide; + int commandId; + cubemap_t *cubemap; + int cubeSide; } convolveCubemapCommand_t; typedef struct postProcessCommand_s { @@ -3405,7 +3405,7 @@ void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); void R_AddCapShadowmapCmd( int dlight, int cubeSide ); -void R_AddConvolveCubemapCmd( int cubemap , int cubeSide ); +void R_AddConvolveCubemapCmd(cubemap_t *cubemap, int cubeSide); void R_AddPostProcessCmd (void); qhandle_t R_BeginTimedBlockCmd( const char *name ); void R_EndTimedBlockCmd( qhandle_t timerHandle ); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 3607f35511..3a7fc7bc25 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1218,49 +1218,49 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) break; } // - // map + // map or clampmap // - else if (!Q_stricmp(token, "map")) + else if ( !Q_stricmp( token, "map" ) || (!Q_stricmp(token, "clampmap"))) { - token = COM_ParseExt(text, qfalse); - if (!token[0]) + int flags = !Q_stricmp(token, "clampmap") ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; + + token = COM_ParseExt( text, qfalse ); + if ( !token[0] ) { - ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name); + ri.Printf( PRINT_WARNING, "WARNING: missing parameter for 'map' keyword in shader '%s'\n", shader.name); return qfalse; } - if (!Q_stricmp(token, "$whiteimage")) + if ( !Q_stricmp( token, "$whiteimage" ) ) { stage->bundle[0].image[0] = tr.whiteImage; continue; } - else if (!Q_stricmp(token, "$lightmap")) + else if ( !Q_stricmp( token, "$lightmap" ) ) { stage->bundle[0].isLightmap = qtrue; - if (shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps) { + if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { #ifndef FINAL_BUILD - ri.Printf(PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); + ri.Printf (PRINT_ALL, S_COLOR_RED "Lightmap requested but none avilable for shader '%s'\n", shader.name); #endif stage->bundle[0].image[0] = tr.whiteImage; - } - else { + } else { stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; } continue; } - else if (!Q_stricmp(token, "$deluxemap")) + else if ( !Q_stricmp( token, "$deluxemap" ) ) { if (!tr.worldDeluxeMapping) { - ri.Printf(PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name); + ri.Printf( PRINT_WARNING, "WARNING: shader '%s' wants a deluxe map in a map compiled without them\n", shader.name ); return qfalse; } stage->bundle[0].isLightmap = qtrue; - if (shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps) { + if ( shader.lightmapIndex[0] < 0 || shader.lightmapIndex[0] >= tr.numLightmaps ) { stage->bundle[0].image[0] = tr.whiteImage; - } - else { + } else { stage->bundle[0].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } continue; @@ -1268,7 +1268,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else { imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_NONE; if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -1288,9 +1287,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strncpyz(bufferBaseColorTextureName, token, sizeof(bufferBaseColorTextureName)); stage->bundle[0].image[0] = R_FindImageFile(bufferBaseColorTextureName, type, flags); - if (!stage->bundle[0].image[0]) + if ( !stage->bundle[0].image[0] ) { - ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); + ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } @@ -1399,43 +1398,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // - // clampmap - // - else if (!Q_stricmp(token, "clampmap")) - { - imgType_t type = IMGTYPE_COLORALPHA; - int flags = IMGFLAG_CLAMPTOEDGE; - - token = COM_ParseExt(text, qfalse); - if (!token[0]) - { - ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'clampmap' keyword in shader '%s'\n", shader.name); - return qfalse; - } - - if (!shader.noMipMaps) - flags |= IMGFLAG_MIPMAP; - - if (!shader.noPicMip) - flags |= IMGFLAG_PICMIP; - - if (shader.noTC) - flags |= IMGFLAG_NO_COMPRESSION; - - if (r_genNormalMaps->integer) - flags |= IMGFLAG_GENNORMALMAP; - - if (r_srgb->integer) - flags |= IMGFLAG_SRGB; - - stage->bundle[0].image[0] = R_FindImageFile(token, type, flags); - if (!stage->bundle[0].image[0]) - { - ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); - return qfalse; - } - } - // // animMap .... // else if ( !Q_stricmp( token, "animMap" ) || !Q_stricmp( token, "clampanimMap" ) || !Q_stricmp( token, "oneshotanimMap" ) ) @@ -1459,7 +1421,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) break; } num = stage->bundle[0].numImageAnimations; - if (num < MAX_IMAGE_ANIMATIONS) { + if ( num < MAX_IMAGE_ANIMATIONS ) { imgType_t imgtype = IMGTYPE_COLORALPHA; int flags = type == ANIMMAP_CLAMP ? IMGFLAG_CLAMPTOEDGE : IMGFLAG_NONE; From 5ec13e6fac038399b117d53d7224ff88975ec159 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 24 May 2018 22:32:54 +0200 Subject: [PATCH 473/708] another small cleanup --- codemp/rd-rend2/tr_shade.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 58fe8c4092..59f09ec9c5 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1676,9 +1676,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddStaticImage(cubemap->image, TB_CUBEMAP); samplerBindingsWriter.AddStaticImage(tr.envBrdfImage, TB_ENVBRDFMAP); - vec[0] = tr.cubemaps[input->cubemapIndex - 1].origin[0] - backEnd.viewParms.ori.origin[0]; - vec[1] = tr.cubemaps[input->cubemapIndex - 1].origin[1] - backEnd.viewParms.ori.origin[1]; - vec[2] = tr.cubemaps[input->cubemapIndex - 1].origin[2] - backEnd.viewParms.ori.origin[2]; + vec[0] = cubemap->origin[0] - backEnd.viewParms.ori.origin[0]; + vec[1] = cubemap->origin[1] - backEnd.viewParms.ori.origin[1]; + vec[2] = cubemap->origin[2] - backEnd.viewParms.ori.origin[2]; vec[3] = 1.0f; VectorScale4(vec, 1.0f / cubemap->parallaxRadius, vec); From 943d3e2ff40ceda1443c3b365b1d59f9ca433ad2 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 25 May 2018 01:16:01 +0200 Subject: [PATCH 474/708] review changes --- codemp/rd-rend2/glsl/lightall.glsl | 18 ++++---- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 12 ++--- codemp/rd-rend2/tr_backend.cpp | 54 ++++++++++++----------- codemp/rd-rend2/tr_bsp.cpp | 4 +- codemp/rd-rend2/tr_fbo.cpp | 1 - codemp/rd-rend2/tr_image.cpp | 39 ++++++++-------- codemp/rd-rend2/tr_init.cpp | 1 + codemp/rd-rend2/tr_main.cpp | 4 +- codemp/rd-rend2/tr_shade.cpp | 9 ++-- codemp/rd-rend2/tr_shader.cpp | 4 +- 10 files changed, 76 insertions(+), 70 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 290a0321db..3b6498fe31 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -505,18 +505,18 @@ float CalcLightAttenuation(float point, float normDist) vec3 sampleOffsetDirections[20] = vec3[] ( - vec3(1, 1, 1), vec3(1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1), - vec3(1, 1, -1), vec3(1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1), - vec3(1, 1, 0), vec3(1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0), - vec3(1, 0, 1), vec3(-1, 0, 1), vec3(1, 0, -1), vec3(-1, 0, -1), - vec3(0, 1, 1), vec3(0, -1, 1), vec3(0, -1, -1), vec3(0, 1, -1) + vec3(1.0, 1.0, 1.0), vec3(1.0, -1.0, 1.0), vec3(-1.0, -1.0, 1.0), vec3(-1.0, 1.0, 1.0), + vec3(1.0, 1.0, -1.0), vec3(1.0, -1.0, -1.0), vec3(-1.0, -1.0, -1.0), vec3(-1.0, 1.0, -1.0), + vec3(1.0, 1.0, 0.0), vec3(1.0, -1.0, 0.0), vec3(-1.0, -1.0, 0.0), vec3(-1.0, 1.0, 0.0), + vec3(1.0, 0.0, 1.0), vec3(-1.0, 0.0, 1.0), vec3(1.0, 0.0, -1.0), vec3(-1.0, 0.0, -1.0), + vec3(0.0, 1.0, 1.0), vec3(0.0, -1.0, 1.0), vec3(0.0, -1.0, -1.0), vec3(0.0, 1.0, -1.0) ); -float pcfShadow(samplerCubeShadow depthMap, vec3 L, float distance) +float pcfShadow(in samplerCubeShadow depthMap, in vec3 L, in float distance) { float shadow = 0.0; int samples = 20; - float diskRadius = 128.0/512.0; + float diskRadius = 0.25; for (int i = 0; i < samples; ++i) { shadow += texture(depthMap, vec4(L + sampleOffsetDirections[i] * diskRadius, distance)); @@ -525,7 +525,7 @@ float pcfShadow(samplerCubeShadow depthMap, vec3 L, float distance) return shadow; } -float getLightDepth(vec3 Vec, float f) +float getLightDepth(in vec3 Vec, in float f) { vec3 AbsVec = abs(Vec); float Z = max(AbsVec.x, max(AbsVec.y, AbsVec.z)); @@ -537,7 +537,7 @@ float getLightDepth(vec3 Vec, float f) return ((NormZComp + 1.0) * 0.5) - DEPTH_MAX_ERROR; } -float getShadowValue(vec4 light) +float getShadowValue(in vec4 light) { float distance = getLightDepth(light.xyz, sqrt(light.w)); return pcfShadow(u_ShadowMap2, light.xyz, distance); diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index 8ffd768d96..d2c74af00b 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -80,18 +80,18 @@ void main() vec2 vector = (var_ScreenTex - vec2(0.5)) * 2.0; // from http://www.codinglabs.net/article_physically_based_rendering.aspx - vec3 normal = normalize(vec3(-vector.x, -vector.y, -1)); + vec3 normal = normalize(vec3(-vector.x, -vector.y, -1.0)); if (cubeFace == 0) - normal = normalize(vec3(1, -vector.y, -vector.x)); + normal = normalize(vec3(1.0, -vector.y, -vector.x)); else if (cubeFace == 1) - normal = normalize(vec3(-1, -vector.y, vector.x)); + normal = normalize(vec3(-1.0, -vector.y, vector.x)); else if (cubeFace == 2) - normal = normalize(vec3(vector.x, 1, vector.y)); + normal = normalize(vec3(vector.x, 1.0, vector.y)); else if (cubeFace == 3) - normal = normalize(vec3(vector.x, -1, -vector.y)); + normal = normalize(vec3(vector.x, -1.0, -vector.y)); else if (cubeFace == 4) - normal = normalize(vec3(vector.x, -vector.y, 1)); + normal = normalize(vec3(vector.x, -vector.y, 1.0)); float roughness = u_ViewInfo.w; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1808fc7a9a..c9ecf3c810 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1892,10 +1892,10 @@ static const void *RB_PrefilterEnvMap(const void *data) { int height = cubemap->height; float roughnessMips = (float)CUBE_MAP_MIPS - 4.0f; - for (float level = 1.0f; level <= CUBE_MAP_MIPS; level++) + for (int level = 1; level <= CUBE_MAP_MIPS; level++) { - width = width / 2.0; - height = height / 2.0; + width = width / 2; + height = height / 2; qglViewport(0, 0, width, height); qglScissor(0, 0, width, height); @@ -2070,28 +2070,32 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) !backEnd.colorMask[3]); backEnd.depthFill = qfalse; - if (backEnd.viewParms.targetFbo == tr.renderCubeFbo && tr.msaaResolveFbo) - { - // If we're using multisampling and rendering a cubemap, resolve the depth to correct size first - vec4i_t frameBox; - frameBox[0] = backEnd.viewParms.viewportX; - frameBox[1] = backEnd.viewParms.viewportY; - frameBox[2] = backEnd.viewParms.viewportWidth; - frameBox[3] = backEnd.viewParms.viewportHeight; - FBO_FastBlit( - tr.renderCubeFbo, frameBox, - tr.msaaResolveFbo, frameBox, - GL_DEPTH_BUFFER_BIT, - GL_NEAREST); - } - else if (tr.msaaResolveFbo) - { - // If we're using multisampling, resolve the depth first - FBO_FastBlit( - tr.renderFbo, NULL, - tr.msaaResolveFbo, NULL, - GL_DEPTH_BUFFER_BIT, - GL_NEAREST); + + if (tr.msaaResolveFbo) + { + if (backEnd.viewParms.targetFbo == tr.renderCubeFbo && tr.msaaResolveFbo) + { + // If we're using multisampling and rendering a cubemap, resolve the depth to correct size first + vec4i_t frameBox; + frameBox[0] = backEnd.viewParms.viewportX; + frameBox[1] = backEnd.viewParms.viewportY; + frameBox[2] = backEnd.viewParms.viewportWidth; + frameBox[3] = backEnd.viewParms.viewportHeight; + FBO_FastBlit( + tr.renderCubeFbo, frameBox, + tr.msaaResolveFbo, frameBox, + GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } + else + { + // If we're using multisampling, resolve the depth first + FBO_FastBlit( + tr.renderFbo, NULL, + tr.msaaResolveFbo, NULL, + GL_DEPTH_BUFFER_BIT, + GL_NEAREST); + } } else if (tr.renderFbo == NULL) { diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d75d519b6a..d61bbb5a70 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2946,7 +2946,7 @@ void R_LoadEnvironmentJson(const char *baseName) const char *environmentArrayJson; int filelen, i; - Com_sprintf(filename, MAX_QPATH, "cubemaps/%s/env.json", baseName); + Com_sprintf(filename, sizeof(filename), "cubemaps/%s/env.json", baseName); filelen = ri.FS_ReadFile(filename, &buffer.v); if (!buffer.c) @@ -3121,7 +3121,7 @@ static void R_RenderAllCubemaps() for (int i = 0; i < tr.numCubemaps; i++) { if (!bounce) - tr.cubemaps[i] = R_CreateImage( + tr.cubemaps[i].image = R_CreateImage( va("*cubeMap%d", i), NULL, CUBE_MAP_SIZE, diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 12525b2b93..f9ea57820d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -520,7 +520,6 @@ void FBO_Init(void) FBO_CreateBuffer(tr.shadowCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); - qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); FBO_SetupDrawBuffers(); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index f863ec2099..23041f8c16 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2587,9 +2587,6 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri.Hunk_FreeTempMemory( resampledBuffer ); } -#define GAMMA 2.2f -#define INV_GAMMA 1.0 / GAMMA - void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) { image_t *image; @@ -2604,11 +2601,11 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c return; } - COM_StripExtension(name, diffuseName, MAX_QPATH); - Q_strcat(diffuseName, MAX_QPATH, "_diffuse"); + COM_StripExtension(name, diffuseName, sizeof(diffuseName)); + Q_strcat(diffuseName, sizeof(diffuseName), "_diffuse"); - COM_StripExtension(name, specularName, MAX_QPATH); - Q_strcat(specularName, MAX_QPATH, "_spec"); + COM_StripExtension(name, specularName, sizeof(specularName)); + Q_strcat(specularName, sizeof(specularName), "_spec"); // // see if the images are already loaded @@ -2639,16 +2636,22 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // R_LoadImage(name, &baseColorPic, &width, &height); if (baseColorPic == NULL) { + Z_Free(baseColorPic); return; } + R_LoadImage(rmoName, &rmoPic, &rmoWidth, &rmoHeight); if (rmoPic == NULL) { + Z_Free(baseColorPic); + Z_Free(rmoPic); return; } if (width != rmoWidth || height != rmoHeight) { ri.Printf(PRINT_ALL, "WARNING: Can't build Specular Map for %s (different texture sizes for baseColor and rmo)\n", name); + Z_Free(baseColorPic); + Z_Free(rmoPic); return; } @@ -2704,9 +2707,9 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c float baseColor[4]; // remove gamma correction because we want to work in linear space - baseColor[0] = pow(ByteToFloat(baseColorPic[i + 0]), GAMMA); - baseColor[1] = pow(ByteToFloat(baseColorPic[i + 1]), GAMMA); - baseColor[2] = pow(ByteToFloat(baseColorPic[i + 2]), GAMMA); + baseColor[0] = RGBtosRGB(ByteToFloat(baseColorPic[i + 0])); + baseColor[1] = RGBtosRGB(ByteToFloat(baseColorPic[i + 1])); + baseColor[2] = RGBtosRGB(ByteToFloat(baseColorPic[i + 2])); // don't remove gamma correction in alpha because this is data, not color baseColor[3] = ByteToFloat(baseColorPic[i + 3]); @@ -2715,16 +2718,16 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // diffuse Color = baseColor * (1.0 - metalness) // also gamma correct again // FIXME: AO should be handled in shader because it should only affect the ambient lighting - diffusePic[i + 0] = FloatToByte(pow(baseColor[0] * (1.0f - metalness) * ao, INV_GAMMA)); - diffusePic[i + 1] = FloatToByte(pow(baseColor[1] * (1.0f - metalness) * ao, INV_GAMMA)); - diffusePic[i + 2] = FloatToByte(pow(baseColor[2] * (1.0f - metalness) * ao, INV_GAMMA)); + diffusePic[i + 0] = FloatToByte(sRGBtoRGB(baseColor[0] * (1.0f - metalness) * ao)); + diffusePic[i + 1] = FloatToByte(sRGBtoRGB(baseColor[1] * (1.0f - metalness) * ao)); + diffusePic[i + 2] = FloatToByte(sRGBtoRGB(baseColor[2] * (1.0f - metalness) * ao)); diffusePic[i + 3] = FloatToByte(baseColor[3]); // specular Color = mix(baseSpecular, baseColor, metalness) // also gamma correct again - specGlossPic[i + 0] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[0] * metalness, INV_GAMMA)); - specGlossPic[i + 1] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[1] * metalness, INV_GAMMA)); - specGlossPic[i + 2] = FloatToByte(pow(baseSpecular * (1.0f - metalness) + baseColor[2] * metalness, INV_GAMMA)); + specGlossPic[i + 0] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[0] * metalness)); + specGlossPic[i + 1] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[1] * metalness)); + specGlossPic[i + 2] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[2] * metalness)); // don't remove gamma correction in alpha because this is data, not color specGlossPic[i + 3] = FloatToByte(gloss); } @@ -2747,8 +2750,8 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig normalFlags = (flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; - COM_StripExtension(name, normalName, MAX_QPATH); - Q_strcat(normalName, MAX_QPATH, "_n"); + COM_StripExtension(name, normalName, sizeof(normalName)); + Q_strcat(normalName, sizeof(normalName), "_n"); // find normalmap in case it's there normalImage = R_FindImageFile(normalName, IMGTYPE_NORMAL, normalFlags); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 0b4b19dc16..60fc5c5f3d 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1485,6 +1485,7 @@ void R_Register( void ) r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMappingBounces = ri.Cvar_Get("r_cubeMappingBounces", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); + ri.Cvar_CheckRange(r_cubeMappingBounces, 0, 2, qfalse); r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseParallax = ri.Cvar_Get( "r_baseParallax", "0.05", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 4316c2b88f..edac3764c2 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2884,7 +2884,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, { RE_BeginScene(&refdef); - if(r_sunlightMode->integer && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + if(r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer || tr.sunShadows)) { R_RenderSunShadowMaps(&refdef, 0); R_RenderSunShadowMaps(&refdef, 1); @@ -2917,7 +2917,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, VectorCopy( refdef.vieworg, parms.pvsOrigin ); - if (r_sunlightMode->integer && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer || tr.sunShadows)) { parms.flags |= VPF_USESUNLIGHT; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 59f09ec9c5..f4d94ab270 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -774,6 +774,10 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit cullFront = !cullFront; cullType = (cullFront ? CT_FRONT_SIDED : CT_BACK_SIDED); + + // FIXME: SomaZ: Not sure why this is needed, but fixes sunlight and shadows in cubemaps + if ( tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo) + cullType = CT_TWO_SIDED; } } @@ -1359,11 +1363,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); - bool renderToCubemap = tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo; - // HACK: SomaZ: Not sure why this is needed, but fixes sunlight and shadows in cubemaps - if (renderToCubemap) - cullType = CT_TWO_SIDED; - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 3a7fc7bc25..4ffd1b6c25 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2991,11 +2991,11 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm image_t *diffuseImg; if (stage->bundle[TB_NORMALMAP].image[0]) { - if ((stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT) && r_parallaxMapping->integer) + if (stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT && r_parallaxMapping->integer) defs |= LIGHTDEF_USE_PARALLAXMAP; //ri.Printf(PRINT_ALL, ", normalmap %s", stage->bundle[TB_NORMALMAP].image[0]->imgName); } - else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0])) + else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0]) != NULL) { char normalName[MAX_QPATH]; image_t *normalImg; From 7ef25d8ccf5f2928ffae90cc6c75a8b187e0640f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 25 May 2018 02:12:21 +0200 Subject: [PATCH 475/708] review changes part 2 --- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 2 +- codemp/rd-rend2/tr_image.cpp | 48 +++++++++++++++++----------------- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c9ecf3c810..2a45737180 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1880,7 +1880,7 @@ static const void *RB_PrefilterEnvMap(const void *data) { image_t *cubemap = cmd->cubemap->image; - if (!cubemap || !cmd) + if (!cubemap) return (const void *)(cmd + 1); FBO_Bind(tr.preFilterEnvMapFbo); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d61bbb5a70..4c43f82279 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3117,7 +3117,7 @@ static void R_RenderAllCubemaps() for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { - qboolean bounce = qboolean(k != 0); + bool bounce = k != 0; for (int i = 0; i < tr.numCubemaps; i++) { if (!bounce) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 23041f8c16..d28980bf80 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2587,6 +2587,20 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri.Hunk_FreeTempMemory( resampledBuffer ); } +bool R_GetLoadedImage(const char *name, image_t *outImage) { + long hash; + image_t *image; + + hash = generateHashValue(name); + for (image = hashTable[hash]; image; image = image->next) { + if (!strcmp(name, image->imgName)) { + outImage = image; + return true; + } + } + return false; +} + void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) { image_t *image; @@ -2595,7 +2609,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c int width, height, rmoWidth, rmoHeight; byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; long hash; - qboolean foundDiffuse, foundSpecular = qfalse; + bool foundDiffuse, foundSpecular = false; if (!name) { return; @@ -2607,30 +2621,16 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c COM_StripExtension(name, specularName, sizeof(specularName)); Q_strcat(specularName, sizeof(specularName), "_spec"); - // - // see if the images are already loaded - // - hash = generateHashValue(diffuseName); - for (image = hashTable[hash]; image; image = image->next) { - if (!strcmp(diffuseName, image->imgName)) { - stage->bundle[TB_COLORMAP].image[0] = image; - foundDiffuse = qtrue; - break; - } - } - // check for specular map - hash = generateHashValue(specularName); - for (image = hashTable[hash]; image; image = image->next) { - if (!strcmp(specularName, image->imgName)) { - stage->bundle[TB_SPECULARMAP].image[0] = image; - foundSpecular = qtrue; - break; - } - } + //// + //// see if the images are already loaded + //// + foundDiffuse = R_GetLoadedImage(diffuseName, stage->bundle[TB_COLORMAP].image[0]); + foundSpecular = R_GetLoadedImage(specularName, stage->bundle[TB_SPECULARMAP].image[0]); - if (foundDiffuse && foundSpecular) + if (foundDiffuse && foundSpecular) { + ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); return; - + } // // load the pics from disk // @@ -2705,7 +2705,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c break; } - float baseColor[4]; + vec4_t baseColor; // remove gamma correction because we want to work in linear space baseColor[0] = RGBtosRGB(ByteToFloat(baseColorPic[i + 0])); baseColor[1] = RGBtosRGB(ByteToFloat(baseColorPic[i + 1])); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8c6a6dab88..8d16d41fd6 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2579,7 +2579,7 @@ void R_RenderView( viewParms_t *parms ); void R_RenderDlightCubemaps(const refdef_t *fd); void R_RenderPshadowMaps(const refdef_t *fd); void R_RenderSunShadowMaps(const refdef_t *fd, int level); -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, qboolean bounce); +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce); void R_AddMD3Surfaces( trRefEntity_t *e, int entityNum ); void R_AddNullModelSurfaces( trRefEntity_t *e, int entityNum ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index edac3764c2..7b2c596852 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2820,7 +2820,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) } } -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, qboolean bounce ) +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce ) { refdef_t refdef; viewParms_t parms; From d88e56f5f112122fde995b23f419366ab53ed392 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 27 May 2018 17:16:18 +0200 Subject: [PATCH 476/708] review changes part 3 --- codemp/rd-rend2/tr_bsp.cpp | 24 ++++++++++++------------ codemp/rd-rend2/tr_fbo.cpp | 5 +---- codemp/rd-rend2/tr_image.cpp | 32 +++++++++++--------------------- codemp/rd-rend2/tr_scene.cpp | 2 +- 4 files changed, 25 insertions(+), 38 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 4c43f82279..3312c658a3 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3114,24 +3114,24 @@ static void R_RenderAllCubemaps() { cubemapFormat = GL_RGBA16F; } - + for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; for (int i = 0; i < tr.numCubemaps; i++) - { + { if (!bounce) tr.cubemaps[i].image = R_CreateImage( - va("*cubeMap%d", i), - NULL, - CUBE_MAP_SIZE, - CUBE_MAP_SIZE, - IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE | - IMGFLAG_MIPMAP | - IMGFLAG_CUBEMAP, - cubemapFormat); + va("*cubeMap%d", i), + NULL, + CUBE_MAP_SIZE, + CUBE_MAP_SIZE, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE | + IMGFLAG_MIPMAP | + IMGFLAG_CUBEMAP, + cubemapFormat); for (int j = 0; j < 6; j++) { diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index f9ea57820d..de2498a96d 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -516,12 +516,9 @@ void FBO_Init(void) if (r_dlightMode->integer >= 2) { tr.shadowCubeFbo = FBO_Create("_shadowCubeFbo", PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); - FBO_Bind(tr.shadowCubeFbo); + FBO_Bind(tr.shadowCubeFbo); FBO_CreateBuffer(tr.shadowCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); - - qglReadBuffer(GL_NONE); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.shadowCubeFbo); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d28980bf80..5cc4d2b24d 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2587,13 +2587,19 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri.Hunk_FreeTempMemory( resampledBuffer ); } -bool R_GetLoadedImage(const char *name, image_t *outImage) { +bool R_GetLoadedImage(const char *name, image_t *outImage, int flags) { long hash; image_t *image; hash = generateHashValue(name); for (image = hashTable[hash]; image; image = image->next) { if (!strcmp(name, image->imgName)) { + // the white image can be used with any set of parms, but other mismatches are errors + if (strcmp(name, "*white")) { + if (image->flags != flags) { + ri.Printf(PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags); + } + } outImage = image; return true; } @@ -2624,8 +2630,8 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c //// //// see if the images are already loaded //// - foundDiffuse = R_GetLoadedImage(diffuseName, stage->bundle[TB_COLORMAP].image[0]); - foundSpecular = R_GetLoadedImage(specularName, stage->bundle[TB_SPECULARMAP].image[0]); + foundDiffuse = R_GetLoadedImage(diffuseName, stage->bundle[TB_COLORMAP].image[0], flags); + foundSpecular = R_GetLoadedImage(specularName, stage->bundle[TB_SPECULARMAP].image[0], flags); if (foundDiffuse && foundSpecular) { ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); @@ -2636,14 +2642,12 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // R_LoadImage(name, &baseColorPic, &width, &height); if (baseColorPic == NULL) { - Z_Free(baseColorPic); return; } R_LoadImage(rmoName, &rmoPic, &rmoWidth, &rmoHeight); if (rmoPic == NULL) { Z_Free(baseColorPic); - Z_Free(rmoPic); return; } @@ -2863,22 +2867,8 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) return NULL; } - hash = generateHashValue(name); - - // - // see if the image is already loaded - // - for (image=hashTable[hash]; image; image=image->next) { - if ( !strcmp( name, image->imgName ) ) { - // the white image can be used with any set of parms, but other mismatches are errors - if ( strcmp( name, "*white" ) ) { - if ( image->flags != flags ) { - ri.Printf( PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags ); - } - } - return image; - } - } + if (R_GetLoadedImage(name, image, flags)) + return image; // // load the pic from disk diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 6b29f9a563..c95682532a 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -522,7 +522,7 @@ void RE_RenderScene( const refdef_t *fd ) { { for (j = 0; j < 6; j++) { - R_RenderCubemapSide(i, j, qtrue, qfalse); + R_RenderCubemapSide(i, j, qtrue, false); } } } From 4cc373aca89ea40f5c20e42731bca5ca10710a7e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 27 May 2018 17:56:11 +0200 Subject: [PATCH 477/708] fixing R_GetLoadedImage --- codemp/rd-rend2/tr_image.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 5cc4d2b24d..fe49efc3ab 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2587,7 +2587,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h ri.Hunk_FreeTempMemory( resampledBuffer ); } -bool R_GetLoadedImage(const char *name, image_t *outImage, int flags) { +image_t* R_GetLoadedImage(const char *name, int flags) { long hash; image_t *image; @@ -2600,11 +2600,10 @@ bool R_GetLoadedImage(const char *name, image_t *outImage, int flags) { ri.Printf(PRINT_DEVELOPER, "WARNING: reused image %s with mixed flags (%i vs %i)\n", name, image->flags, flags); } } - outImage = image; - return true; + return image; } } - return false; + return NULL; } void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) @@ -2615,7 +2614,6 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c int width, height, rmoWidth, rmoHeight; byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; long hash; - bool foundDiffuse, foundSpecular = false; if (!name) { return; @@ -2630,10 +2628,10 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c //// //// see if the images are already loaded //// - foundDiffuse = R_GetLoadedImage(diffuseName, stage->bundle[TB_COLORMAP].image[0], flags); - foundSpecular = R_GetLoadedImage(specularName, stage->bundle[TB_SPECULARMAP].image[0], flags); + stage->bundle[TB_COLORMAP].image[0] = R_GetLoadedImage(diffuseName, flags); + stage->bundle[TB_SPECULARMAP].image[0] = R_GetLoadedImage(specularName, flags); - if (foundDiffuse && foundSpecular) { + if (stage->bundle[TB_COLORMAP].image[0] != NULL && stage->bundle[TB_SPECULARMAP].image[0] != NULL) { ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); return; } @@ -2867,7 +2865,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) return NULL; } - if (R_GetLoadedImage(name, image, flags)) + if ((image = R_GetLoadedImage(name, flags)) != NULL) return image; // From c7ecd928f34bad05be82512d8b6215e4d73ff678 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 27 May 2018 18:00:21 +0200 Subject: [PATCH 478/708] cleanup --- codemp/rd-rend2/tr_image.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index fe49efc3ab..8ab03124ce 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2608,12 +2608,10 @@ image_t* R_GetLoadedImage(const char *name, int flags) { void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) { - image_t *image; char diffuseName[MAX_QPATH]; char specularName[MAX_QPATH]; int width, height, rmoWidth, rmoHeight; byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; - long hash; if (!name) { return; @@ -2859,7 +2857,6 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) image_t *image; int width, height; byte *pic; - long hash; if (!name) { return NULL; From fe6616ff191fc0f7afba644e7adfb930716eff4b Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Wed, 23 May 2018 11:10:34 +0000 Subject: [PATCH 479/708] Make rend2 build and work on linux --- codemp/rd-rend2/CMakeLists.txt | 2 ++ codemp/rd-rend2/tr_bsp.cpp | 7 +++++-- codemp/rd-rend2/tr_extensions.cpp | 4 ++++ codemp/rd-rend2/tr_ghoul2.cpp | 9 ++++++++- codemp/rd-rend2/tr_glsl.cpp | 14 ++++++++++++-- codemp/rd-rend2/tr_glsl_parse.cpp | 4 +++- codemp/rd-rend2/tr_weather.cpp | 2 ++ shared/qcommon/q_platform.h | 9 ++++++++- 8 files changed, 44 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 010c0306f7..a7a166fd31 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -10,6 +10,8 @@ set(MPRend2IncludeDirectories "${GSLIncludeDirectory}" ) + + set(MPRend2Files "${MPDir}/rd-rend2/iqm.h" "${MPDir}/rd-rend2/glext.h" diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3312c658a3..b252473acb 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -30,6 +30,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_cache.h" #include +#include + /* Loads and prepares a map file for scene rendering. @@ -3547,6 +3549,7 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) return (hash ^ (hash >> 10) ^ (hash >> 20)); } + static std::vector R_CreateSurfaceSpritesVertexData( const srfBspSurface_t *bspSurf, float density) @@ -3575,7 +3578,7 @@ static std::vector R_CreateSurfaceSpritesVertexData( const vec2_t p01 = {p1[0] - p0[0], p1[1] - p0[1]}; const vec2_t p02 = {p2[0] - p0[0], p2[1] - p0[1]}; - const float zarea = std::fabsf(p02[0]*p01[1] - p02[1]*p01[0]); + const float zarea = std::fabs(p02[0]*p01[1] - p02[1]*p01[0]); if ( zarea <= 1.0 ) { // Triangle's area is too small to consider. @@ -3610,7 +3613,7 @@ static std::vector R_CreateSurfaceSpritesVertexData( // => y*y = 1.0 - x*x // => y = -/+sqrt(1.0 - x*x) float nx = flrand(-1.0f, 1.0f); - float ny = std::sqrtf(1.0f - nx*nx); + float ny = std::sqrt(1.0f - nx*nx); ny *= irand(0, 1) ? -1 : 1; VectorSet(sprite.normal, nx, ny, 0.0f); diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index ed4a78a532..38c0d8276d 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -256,6 +256,10 @@ static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionSt return qtrue; } +#ifndef WIN32 // [M] there's no __stdcall on linux +#define __stdcall +#endif + static void __stdcall GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 661cde953c..78586e5464 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3953,9 +3953,16 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); + // [Monsterovich] gcc throws an error here and Idk why but my custom code works! + // error: the value of 'surfInfo' is not usable in a constant expression + #ifndef WIN32 + #undef offsetof + #define offsetof(type, member) ((size_t)((char *)&(*(type *)0).member - (char *)&(*(type *)0))) + #endif + // find the next surface surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + offsetof (mdxmSurfHierarchy_t, childIndexes[surfInfo->numChildren]) ); - } + } // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) lod = (mdxmLOD_t *) ( (byte *)mdxm + mdxm->ofsLODs ); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6b33c7673b..2e10881bda 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -339,11 +339,20 @@ static size_t GLSL_GetShaderHeader( 0x0104/* GL_ADD */, GL_REPLACE)); + // [Monsterovich] The shader string is fucked up. I got this from error. + /* + #define ALPHA_TEST_GT0 1 + #define ALPHA_TEST_LT128 2 + #define ALPHA_TEST_GE128 3 + #d + efine ALPHA_TEST_GE192 4 + */ + // What is going on? O_O? Q_strcat(dest, size, va("#define ALPHA_TEST_GT0 %d\n" "#define ALPHA_TEST_LT128 %d\n" "#define ALPHA_TEST_GE128 %d\n" - "#define ALPHA_TEST_GE192 %d\n", + "/*lol*/\n#define ALPHA_TEST_GE192 %d\n\n", ALPHA_TEST_GT0, ALPHA_TEST_LT128, ALPHA_TEST_GE128, @@ -371,7 +380,8 @@ static size_t GLSL_GetShaderHeader( // OK we added a lot of stuff but if we do something bad in the GLSL // shaders then we want the proper line so we have to reset the line // counting - Q_strcat(dest, size, va("#line %d\n", firstLineNumber - 1)); + // [Monsterovich] The same thing here but I think that \n is just missing somewhere. + Q_strcat(dest, size, va("\n#line %d\n", firstLineNumber - 1)); return strlen(dest); } diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index d96665ee87..fe63bcb5c1 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -41,7 +41,8 @@ Block *FindBlock( const char *name, Block *blocks, size_t numBlocks ) return nullptr; } -#if defined(__clang__) +// [M] strncpy_s is not present on linux and VS only function +#ifndef WIN32 void strncpy_s( char *dest, size_t destSize, const char *src, size_t srcSize ) { // This isn't really a safe version, but I know the inputs to expect. @@ -52,6 +53,7 @@ void strncpy_s( char *dest, size_t destSize, const char *src, size_t srcSize ) } #endif + } GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 8a35e48ce2..59f3410009 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -22,6 +22,8 @@ along with this program; if not, see . #include "tr_local.h" #include #include +#include + struct weatherSystem_t { diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h index bddb7bdbea..f980b1c409 100644 --- a/shared/qcommon/q_platform.h +++ b/shared/qcommon/q_platform.h @@ -127,8 +127,15 @@ along with this program; if not, see . #define PATH_SEP '/' + // [M] Define it, define it now! DEWIT. #if !defined(ARCH_STRING) - #error ARCH_STRING should be defined by the build system + #if defined(__i386__) + #define ARCH_STRING "x86" + #elif defined(__x86_64__) + #define ARCH_STRING "x86_64" + #elif + #error Cannot identify ARCH_STRING, it should be defined by the build system + #endif #endif #if defined(__x86_64__) From 1760c5c3d5717690969f7f3ce2f4338872d90f64 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Wed, 23 May 2018 13:48:17 +0200 Subject: [PATCH 480/708] Oops --- shared/qcommon/q_platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h index f980b1c409..78da6eb63f 100644 --- a/shared/qcommon/q_platform.h +++ b/shared/qcommon/q_platform.h @@ -133,7 +133,7 @@ along with this program; if not, see . #define ARCH_STRING "x86" #elif defined(__x86_64__) #define ARCH_STRING "x86_64" - #elif + #else #error Cannot identify ARCH_STRING, it should be defined by the build system #endif #endif From edba864f2b95af1374eeede0b411c1800b698520 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sat, 26 May 2018 11:28:22 +0000 Subject: [PATCH 481/708] Done: requested changes --- codemp/rd-rend2/tr_bsp.cpp | 1 - codemp/rd-rend2/tr_extensions.cpp | 6 ++---- codemp/rd-rend2/tr_ghoul2.cpp | 9 +-------- codemp/rd-rend2/tr_glsl_parse.cpp | 2 +- codemp/rd-rend2/tr_shadows.cpp | 6 +++--- 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b252473acb..f910555f4e 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3549,7 +3549,6 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) return (hash ^ (hash >> 10) ^ (hash >> 20)); } - static std::vector R_CreateSurfaceSpritesVertexData( const srfBspSurface_t *bspSurf, float density) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 38c0d8276d..0c953b567b 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -256,11 +256,9 @@ static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionSt return qtrue; } -#ifndef WIN32 // [M] there's no __stdcall on linux -#define __stdcall -#endif -static void __stdcall GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenum severity, + +static void QCALL GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { const char *severityText = ""; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 78586e5464..9612dfbf20 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3953,15 +3953,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & CModelCache->StoreShaderRequest(mod_name, &surfInfo->shader[0], &surfInfo->shaderIndex); - // [Monsterovich] gcc throws an error here and Idk why but my custom code works! - // error: the value of 'surfInfo' is not usable in a constant expression - #ifndef WIN32 - #undef offsetof - #define offsetof(type, member) ((size_t)((char *)&(*(type *)0).member - (char *)&(*(type *)0))) - #endif - // find the next surface - surfInfo = (mdxmSurfHierarchy_t *)( (byte *)surfInfo + offsetof (mdxmSurfHierarchy_t, childIndexes[surfInfo->numChildren]) ); + surfInfo = (mdxmSurfHierarchy_t *)((byte *)surfInfo + offsetof(mdxmSurfHierarchy_t, childIndexes) + sizeof(int) * surfInfo->numChildren); } // swap all the LOD's (we need to do the middle part of this even for intel, because of shader reg and err-check) diff --git a/codemp/rd-rend2/tr_glsl_parse.cpp b/codemp/rd-rend2/tr_glsl_parse.cpp index fe63bcb5c1..94fdb9fb6b 100644 --- a/codemp/rd-rend2/tr_glsl_parse.cpp +++ b/codemp/rd-rend2/tr_glsl_parse.cpp @@ -42,7 +42,7 @@ Block *FindBlock( const char *name, Block *blocks, size_t numBlocks ) } // [M] strncpy_s is not present on linux and VS only function -#ifndef WIN32 +#if !defined(_WIN32) void strncpy_s( char *dest, size_t destSize, const char *src, size_t srcSize ) { // This isn't really a safe version, but I know the inputs to expect. diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 9e9d40b27c..5436969d98 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -59,7 +59,7 @@ void R_AddEdgeDef( int i1, int i2, int facing ) { } void R_RenderShadowEdges( void ) { -#if 0 +#if 1 int i; int numTris; @@ -88,8 +88,8 @@ void R_RenderShadowEdges( void ) { qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); qglEnd(); } -#else -#if 0 +//#else +#if 1 int c, c2; int j, k; int i2; From fae9c421c8377630f94dcd39aa0fcf67ffd7fc02 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sat, 26 May 2018 11:30:24 +0000 Subject: [PATCH 482/708] Fix --- codemp/rd-rend2/tr_shadows.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 5436969d98..9e9d40b27c 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -59,7 +59,7 @@ void R_AddEdgeDef( int i1, int i2, int facing ) { } void R_RenderShadowEdges( void ) { -#if 1 +#if 0 int i; int numTris; @@ -88,8 +88,8 @@ void R_RenderShadowEdges( void ) { qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); qglEnd(); } -//#else -#if 1 +#else +#if 0 int c, c2; int j, k; int i2; From d8af18a3bb2cf73712d9b3fc994e50675192afe3 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sat, 26 May 2018 13:33:14 +0200 Subject: [PATCH 483/708] Fix2 --- codemp/rd-rend2/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index a7a166fd31..8121bc9cc4 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -11,7 +11,6 @@ set(MPRend2IncludeDirectories ) - set(MPRend2Files "${MPDir}/rd-rend2/iqm.h" "${MPDir}/rd-rend2/glext.h" From 1aec78e7335d017b490265bb1fada6ea27aecf47 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sat, 26 May 2018 15:47:40 +0200 Subject: [PATCH 484/708] Cleaned up! --- codemp/rd-rend2/tr_glsl.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 2e10881bda..e904ce5464 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -339,20 +339,11 @@ static size_t GLSL_GetShaderHeader( 0x0104/* GL_ADD */, GL_REPLACE)); - // [Monsterovich] The shader string is fucked up. I got this from error. - /* - #define ALPHA_TEST_GT0 1 - #define ALPHA_TEST_LT128 2 - #define ALPHA_TEST_GE128 3 - #d - efine ALPHA_TEST_GE192 4 - */ - // What is going on? O_O? Q_strcat(dest, size, va("#define ALPHA_TEST_GT0 %d\n" "#define ALPHA_TEST_LT128 %d\n" "#define ALPHA_TEST_GE128 %d\n" - "/*lol*/\n#define ALPHA_TEST_GE192 %d\n\n", + "#define ALPHA_TEST_GE192 %d\n", ALPHA_TEST_GT0, ALPHA_TEST_LT128, ALPHA_TEST_GE128, @@ -377,10 +368,6 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, extra); } - // OK we added a lot of stuff but if we do something bad in the GLSL - // shaders then we want the proper line so we have to reset the line - // counting - // [Monsterovich] The same thing here but I think that \n is just missing somewhere. Q_strcat(dest, size, va("\n#line %d\n", firstLineNumber - 1)); return strlen(dest); From 858b91ff5a88e95c8cd027ad332d3fcba89fd5dd Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sun, 27 May 2018 21:35:29 +0200 Subject: [PATCH 485/708] Fixed remaining stuff --- codemp/rd-rend2/CMakeLists.txt | 1 - codemp/rd-rend2/tr_glsl.cpp | 3 +++ shared/qcommon/q_platform.h | 8 +------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 8121bc9cc4..010c0306f7 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -10,7 +10,6 @@ set(MPRend2IncludeDirectories "${GSLIncludeDirectory}" ) - set(MPRend2Files "${MPDir}/rd-rend2/iqm.h" "${MPDir}/rd-rend2/glext.h" diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e904ce5464..5a1356b815 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -368,6 +368,9 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, extra); } + // OK we added a lot of stuff but if we do something bad in the GLSL + // shaders then we want the proper line so we have to reset the line + // counting Q_strcat(dest, size, va("\n#line %d\n", firstLineNumber - 1)); return strlen(dest); diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h index 78da6eb63f..e4e69edc53 100644 --- a/shared/qcommon/q_platform.h +++ b/shared/qcommon/q_platform.h @@ -129,13 +129,7 @@ along with this program; if not, see . // [M] Define it, define it now! DEWIT. #if !defined(ARCH_STRING) - #if defined(__i386__) - #define ARCH_STRING "x86" - #elif defined(__x86_64__) - #define ARCH_STRING "x86_64" - #else - #error Cannot identify ARCH_STRING, it should be defined by the build system - #endif + #error ARCH_STRING should be defined by the build system #endif #if defined(__x86_64__) From cfb6290c05cdb7243aa06b54095f3f8b57bde65e Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sun, 27 May 2018 21:36:35 +0200 Subject: [PATCH 486/708] fix6 --- shared/qcommon/q_platform.h | 1 - 1 file changed, 1 deletion(-) diff --git a/shared/qcommon/q_platform.h b/shared/qcommon/q_platform.h index e4e69edc53..bddb7bdbea 100644 --- a/shared/qcommon/q_platform.h +++ b/shared/qcommon/q_platform.h @@ -127,7 +127,6 @@ along with this program; if not, see . #define PATH_SEP '/' - // [M] Define it, define it now! DEWIT. #if !defined(ARCH_STRING) #error ARCH_STRING should be defined by the build system #endif From 64d77729180979829135d4855a986b8711a7d491 Mon Sep 17 00:00:00 2001 From: Monsterovich Date: Sun, 27 May 2018 21:37:49 +0200 Subject: [PATCH 487/708] fix7 --- codemp/rd-rend2/tr_extensions.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 0c953b567b..bc962f60af 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -257,7 +257,6 @@ static qboolean GetGLFunction ( GLFuncType& glFunction, const char *glFunctionSt } - static void QCALL GLimp_OnError(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const void *userParam) { From 6cb1e26ea08ddc9ff76d9de17ebed18eb93346bf Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 27 May 2018 22:32:10 +0100 Subject: [PATCH 488/708] Render top-down depth view of map for weather Also took the chance to refactor some orthographic rendering code --- codemp/rd-rend2/tr_bsp.cpp | 3 + codemp/rd-rend2/tr_fbo.cpp | 20 ++- codemp/rd-rend2/tr_image.cpp | 9 + codemp/rd-rend2/tr_local.h | 47 +++--- codemp/rd-rend2/tr_main.cpp | 297 +++++++++++++-------------------- codemp/rd-rend2/tr_weather.cpp | 48 +++++- codemp/rd-rend2/tr_weather.h | 1 + 7 files changed, 219 insertions(+), 206 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f910555f4e..0dc17b2e88 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #undef JSON_IMPLEMENTATION #include "tr_cache.h" +#include "tr_weather.h" #include #include @@ -3913,4 +3914,6 @@ void RE_LoadWorldMap( const char *name ) { { R_RenderAllCubemaps(); } + + R_InitWeatherForMap(); } diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index de2498a96d..35409d7724 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -236,13 +236,15 @@ R_AttachFBOTexture2D */ void R_AttachFBOTexture2D(int target, int texId, int index) { - if(target != GL_TEXTURE_2D && (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X || target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)) + if (target != GL_TEXTURE_2D && + (target < GL_TEXTURE_CUBE_MAP_POSITIVE_X || + target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)) { ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid target %i\n", target); return; } - if(index < 0 || index >= glRefConfig.maxColorAttachments) + if (index < 0 || index >= glRefConfig.maxColorAttachments) { ri.Printf(PRINT_WARNING, "R_AttachFBOTexture2D: invalid attachment index %i\n", index); return; @@ -654,6 +656,20 @@ void FBO_Init(void) R_CheckFBO(tr.preFilterEnvMapFbo); } + if (tr.weatherDepthImage != nullptr) + { + tr.weatherDepthFbo = FBO_Create( + "_weatherDepthFbo", + tr.weatherDepthImage->width, + tr.weatherDepthImage->height); + + FBO_Bind(tr.weatherDepthFbo); + R_AttachFBOTextureDepth(tr.weatherDepthImage->texnum); + FBO_SetupDrawBuffers(); + + R_CheckFBO(tr.weatherDepthFbo); + } + GL_CheckErrors(); FBO_Bind(NULL); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 8ab03124ce..a37a1084a8 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3350,6 +3350,15 @@ void R_CreateBuiltinImages( void ) { IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat); } + + tr.weatherDepthImage = R_CreateImage( + "*weatherDepth", + nullptr, + 1024, + 1024, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + GL_DEPTH_COMPONENT24); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8d16d41fd6..c2c55dd0b6 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -412,6 +412,17 @@ typedef struct { float modelMatrix[16]; } orientationr_t; +void R_SetOrientationOriginAndAxis( + orientationr_t& orientation, + const vec3_t origin, + const vec3_t left, + const vec3_t forward, + const vec3_t up); +void R_SetOrientationOriginAndAxis( + orientationr_t& orientation, + const vec3_t origin, + const matrix3_t axis); + typedef enum { VBO_USAGE_STATIC, @@ -1287,23 +1298,6 @@ typedef struct shaderProgram_s uint32_t uniformBlocks; } shaderProgram_t; -struct technique_t -{ - shaderProgram_t *depthPrepass; - shaderProgram_t *shadow; - shaderProgram_t *forward; -}; - -struct EntityCullInfo -{ - uint32_t frustumMask; -}; - -struct WorkingScene -{ - EntityCullInfo entityCullInfo[MAX_REFENTITIES]; -}; - // trRefdef_t holds everything that comes in refdef_t, // as well as the locally generated scene information typedef struct { @@ -1371,8 +1365,7 @@ typedef struct { float surface[4]; } fog_t; -typedef enum { - VPF_NONE = 0x00, +enum viewParmFlag_t { VPF_NOVIEWMODEL = 0x01, // Don't render the view model VPF_SHADOWMAP = 0x02, // Rendering to shadow map VPF_DEPTHSHADOW = 0x04, // Rendering depth-only @@ -1382,7 +1375,8 @@ typedef enum { VPF_FARPLANEFRUSTUM = 0x40, // Use far clipping plane VPF_NOCUBEMAPS = 0x80, // Don't render cubemaps VPF_NOPOSTPROCESS = 0x100 -} viewParmFlags_t; +}; +using viewParmFlags_t = uint32_t; typedef struct { orientationr_t ori; @@ -2229,8 +2223,8 @@ typedef struct trGlobals_s { image_t *renderCubeImage; image_t *prefilterEnvMapImage; image_t *envBrdfImage; - image_t *textureDepthImage; + image_t *weatherDepthImage; FBO_t *renderFbo; FBO_t *glowFboScaled[6]; @@ -2249,6 +2243,7 @@ typedef struct trGlobals_s { FBO_t *hdrDepthFbo; FBO_t *renderCubeFbo; FBO_t *preFilterEnvMapFbo; + FBO_t *weatherDepthFbo; shader_t *defaultShader; shader_t *shadowShader; @@ -2573,6 +2568,16 @@ extern cvar_t *r_debugWeather; //==================================================================== +void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ); +void R_SetupViewParmsForOrthoRendering( + int viewportWidth, + int viewportHeight, + FBO_t *fbo, + viewParmFlags_t viewParmsFlags, + const orientationr_t& orientation, + const vec3_t viewBounds[2]); +void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ); + void R_SwapBuffers( int ); void R_RenderView( viewParms_t *parms ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 7b2c596852..5de72a3fc1 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -776,9 +776,9 @@ static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) vec3_t origin; *ori = {}; - tr.ori.axis[0][0] = 1; - tr.ori.axis[1][1] = 1; - tr.ori.axis[2][2] = 1; + ori->axis[0][0] = 1.0f; + ori->axis[1][1] = 1.0f; + ori->axis[2][2] = 1.0f; VectorCopy(viewParms->ori.origin, ori->viewOrigin); // transform by the camera placement @@ -1071,7 +1071,7 @@ void R_SetupProjectionZ(viewParms_t *dest) R_SetupProjectionOrtho =============== */ -void R_SetupProjectionOrtho(viewParms_t *dest, vec3_t viewBounds[2]) +void R_SetupProjectionOrtho(viewParms_t *dest, const vec3_t viewBounds[2]) { float xmin, xmax, ymin, ymax, znear, zfar; //viewParms_t *dest = &tr.viewParms; @@ -2006,29 +2006,32 @@ static void R_AddEntitySurfaces(const trRefdef_t *refdef) R_GenerateDrawSurfs ==================== */ -static void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { +void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { R_AddWorldSurfaces(viewParms, refdef); R_AddPolygonSurfaces(refdef); - // set the projection matrix with the minimum zfar - // now that we have the world bounded - // this needs to be done before entities are - // added, because they use the projection - // matrix for lod calculation - - // dynamically compute far clip plane distance - if (!(tr.viewParms.flags & VPF_SHADOWMAP)) + if ((viewParms->flags & VPF_ORTHOGRAPHIC) == 0) { - R_SetFarClip(viewParms, refdef); - } + // set the projection matrix with the minimum zfar + // now that we have the world bounded + // this needs to be done before entities are + // added, because they use the projection + // matrix for lod calculation + + // dynamically compute far clip plane distance + if (!(tr.viewParms.flags & VPF_SHADOWMAP)) + { + R_SetFarClip(viewParms, refdef); + } - // we know the size of the clipping volume. Now set the rest of the projection matrix. - R_SetupProjectionZ(viewParms); + // we know the size of the clipping volume. Now set the rest of the projection matrix. + R_SetupProjectionZ(viewParms); + } R_AddEntitySurfaces(refdef); - if ( !(tr.viewParms.flags & VPF_SHADOWMAP) ) + if ( !(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) ) { R_AddWeatherSurfaces(); } @@ -2154,7 +2157,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = (viewParmFlags_t)(VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); + shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL; shadowParms.zFar = tr.refdef.dlights[i].radius; shadowParms.zNear = 1.0f; @@ -2211,10 +2214,62 @@ void R_RenderDlightCubemaps(const refdef_t *fd) } } +void R_SetOrientationOriginAndAxis( + orientationr_t& orientation, + const vec3_t origin, + const vec3_t left, + const vec3_t forward, + const vec3_t up) +{ + VectorCopy(origin, orientation.origin); + VectorCopy(left, orientation.axis[0]); + VectorCopy(forward, orientation.axis[1]); + VectorCopy(up, orientation.axis[2]); +} + +void R_SetOrientationOriginAndAxis( + orientationr_t& orientation, + const vec3_t origin, + const matrix3_t axis) +{ + R_SetOrientationOriginAndAxis(orientation, origin, axis[0], axis[1], axis[2]); +} + +void R_SetupViewParmsForOrthoRendering( + int viewportWidth, + int viewportHeight, + FBO_t *fbo, + viewParmFlags_t viewParmFlags, + const orientationr_t& orientation, + const vec3_t viewBounds[2]) +{ + viewParms_t& viewParms = tr.viewParms; + + viewParms = {}; + viewParms.viewportWidth = viewportWidth; + viewParms.viewportHeight = viewportHeight; + viewParms.flags = viewParmFlags; + viewParms.targetFbo = fbo; + viewParms.zFar = viewBounds[1][0]; + VectorCopy(orientation.origin, viewParms.ori.origin); + for (int i = 0; i < 3; ++i) + VectorCopy(orientation.axis[i], viewParms.ori.axis[i]); + + VectorCopy(orientation.origin, viewParms.pvsOrigin); + + tr.viewCount++; + + viewParms.frameSceneNum = tr.frameSceneNum; + viewParms.frameCount = tr.frameCount; + + tr.viewCount++; + + R_RotateForViewer(&tr.ori, &viewParms); + R_SetupProjectionOrtho(&viewParms, viewBounds); +} void R_RenderPshadowMaps(const refdef_t *fd) { - viewParms_t shadowParms; int i; // first, make a list of shadows @@ -2429,117 +2484,35 @@ void R_RenderPshadowMaps(const refdef_t *fd) // next, render shadowmaps for ( i = 0; i < tr.refdef.num_pshadows; i++) { - int firstDrawSurf; pshadow_t *shadow = &tr.refdef.pshadows[i]; - int j; - - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); - - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - shadowParms.viewportWidth = PSHADOW_MAP_SIZE; - shadowParms.viewportHeight = PSHADOW_MAP_SIZE; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qfalse; - shadowParms.fovX = 90; - shadowParms.fovY = 90; + orientationr_t orientation; + R_SetOrientationOriginAndAxis(orientation, shadow->lightOrigin, shadow->lightViewAxis); - shadowParms.targetFbo = tr.pshadowFbos[i]; + const float viewRadius = shadow->viewRadius; + vec3_t shadowViewBounds[2]; + VectorSet(shadowViewBounds[0], -viewRadius, -viewRadius, 0.0f); + VectorSet(shadowViewBounds[1], viewRadius, viewRadius, shadow->lightRadius); - shadowParms.flags = (viewParmFlags_t)( VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL ); - shadowParms.zFar = shadow->lightRadius; - - VectorCopy(shadow->lightOrigin, shadowParms.ori.origin); - - VectorCopy(shadow->lightViewAxis[0], shadowParms.ori.axis[0]); - VectorCopy(shadow->lightViewAxis[1], shadowParms.ori.axis[1]); - VectorCopy(shadow->lightViewAxis[2], shadowParms.ori.axis[2]); + R_SetupViewParmsForOrthoRendering( + PSHADOW_MAP_SIZE, + PSHADOW_MAP_SIZE, + tr.pshadowFbos[i], + VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL, + orientation, + shadowViewBounds); + const int firstDrawSurf = tr.refdef.numDrawSurfs; + for (int j = 0; j < shadow->numEntities; j++) { - tr.viewCount++; - - tr.viewParms = shadowParms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.viewCount++; - - // set viewParms.world - R_RotateForViewer(&tr.ori, &tr.viewParms); - - { - float xmin, xmax, ymin, ymax, znear, zfar; - viewParms_t *dest = &tr.viewParms; - vec3_t pop; - - xmin = ymin = -shadow->viewRadius; - xmax = ymax = shadow->viewRadius; - znear = 0; - zfar = shadow->lightRadius; - - dest->projectionMatrix[0] = 2 / (xmax - xmin); - dest->projectionMatrix[4] = 0; - dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); - dest->projectionMatrix[12] =0; - - dest->projectionMatrix[1] = 0; - dest->projectionMatrix[5] = 2 / (ymax - ymin); - dest->projectionMatrix[9] = ( ymax + ymin ) / (ymax - ymin); // normally 0 - dest->projectionMatrix[13] = 0; - - dest->projectionMatrix[2] = 0; - dest->projectionMatrix[6] = 0; - dest->projectionMatrix[10] = 2 / (zfar - znear); - dest->projectionMatrix[14] = 0; - - dest->projectionMatrix[3] = 0; - dest->projectionMatrix[7] = 0; - dest->projectionMatrix[11] = 0; - dest->projectionMatrix[15] = 1; - - VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); - dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - - VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); - dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - - VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); - dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - - VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); - dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - - VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->ori.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); - dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); - - for (j = 0; j < 5; j++) - { - dest->frustum[j].type = PLANE_NON_AXIAL; - SetPlaneSignbits (&dest->frustum[j]); - } - - dest->flags |= VPF_FARPLANEFRUSTUM; - } - - for (j = 0; j < shadow->numEntities; j++) - { - int entityNum = shadow->entityNums[j]; - trRefEntity_t *ent = tr.refdef.entities + entityNum; - R_AddEntitySurface(&tr.refdef, ent, entityNum); - } - - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); + int entityNum = shadow->entityNums[j]; + trRefEntity_t *ent = tr.refdef.entities + entityNum; + R_AddEntitySurface(&tr.refdef, ent, entityNum); } + + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); } } @@ -2759,65 +2732,27 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) //ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); } + orientationr_t orientation = {}; + R_SetOrientationOriginAndAxis(orientation, lightOrigin, lightViewAxis); - { - viewParms_t shadowParms = {}; - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - shadowParms.viewportWidth = tr.sunShadowFbo[level]->width; - shadowParms.viewportHeight = tr.sunShadowFbo[level]->height; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qfalse; - shadowParms.fovX = 90; - shadowParms.fovY = 90; - - shadowParms.targetFbo = tr.sunShadowFbo[level]; + R_SetupViewParmsForOrthoRendering( + tr.sunShadowFbo[level]->width, + tr.sunShadowFbo[level]->height, + tr.sunShadowFbo[level], + VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL, + orientation, + lightviewBounds); - shadowParms.flags = (viewParmFlags_t)( - VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL); - shadowParms.zFar = lightviewBounds[1][0]; - shadowParms.zNear = r_znear->value; - - VectorCopy(lightOrigin, shadowParms.ori.origin); - - VectorCopy(lightViewAxis[0], shadowParms.ori.axis[0]); - VectorCopy(lightViewAxis[1], shadowParms.ori.axis[1]); - VectorCopy(lightViewAxis[2], shadowParms.ori.axis[2]); - - VectorCopy(lightOrigin, shadowParms.pvsOrigin); - - { - tr.viewCount++; - - tr.viewParms = shadowParms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - int firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.viewCount++; - - // set viewParms.world - R_RotateForViewer(&tr.ori, &tr.viewParms); - - R_SetupProjectionOrtho(&tr.viewParms, lightviewBounds); - - R_AddWorldSurfaces(&tr.viewParms, &tr.refdef); - - R_AddPolygonSurfaces(&tr.refdef); - - R_AddEntitySurfaces(&tr.refdef); - - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); - - Matrix16Multiply( - tr.viewParms.projectionMatrix, - tr.viewParms.world.modelViewMatrix, - tr.refdef.sunShadowMvp[level]); - } - } + const int firstDrawSurf = tr.refdef.numDrawSurfs; + R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); + + Matrix16Multiply( + tr.viewParms.projectionMatrix, + tr.viewParms.world.modelViewMatrix, + tr.refdef.sunShadowMvp[level]); } void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce ) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 59f3410009..aec553a153 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -89,6 +89,45 @@ namespace ws.attribsTemplate[1].vbo = nullptr; } + void GenerateDepthMap() + { + vec3_t mapSize; + VectorSubtract( + tr.world->bmodels[0].bounds[0], + tr.world->bmodels[0].bounds[1], + mapSize); + mapSize[2] = 0.0f; + + const vec3_t left = {0.0f, 1.0f, 0.0f}; + const vec3_t up = {0.0f, 0.0f, 1.0f}; + const vec3_t forward = {1.0f, 0.0f, 0.0f}; + + matrix3_t viewAxes; + vec3_t viewOrigin; + VectorMA(tr.world->bmodels[0].bounds[0], 0.5f, mapSize, viewOrigin); + + orientationr_t orientation; + R_SetOrientationOriginAndAxis(orientation, viewOrigin, left, forward, up); + + R_SetupViewParmsForOrthoRendering( + tr.weatherDepthFbo->width, + tr.weatherDepthFbo->height, + tr.weatherDepthFbo, + VPF_DEPTHCLAMP | VPF_DEPTHSHADOW | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL, + orientation, + tr.world->bmodels[0].bounds); + + const int firstDrawSurf = tr.refdef.numDrawSurfs; + + RE_ClearScene(); + R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + } + void RB_SimulateWeather(weatherSystem_t& ws) { if (ws.vboLastUpdateFrame == backEndData->realFrameNumber) @@ -145,18 +184,23 @@ namespace } } +void R_InitWeatherForMap() +{ + GenerateRainModel(*tr.weatherSystem); + GenerateDepthMap(); +} + void R_InitWeatherSystem() { Com_Printf("Initializing weather system\n"); tr.weatherSystem = (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); - GenerateRainModel(*tr.weatherSystem); tr.weatherSystem->weatherSurface.surfaceType = SF_WEATHER; } void R_ShutdownWeatherSystem() { - if ( tr.weatherSystem ) + if (tr.weatherSystem != nullptr) { Com_Printf("Shutting down weather system\n"); diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index 640fab7b59..654aed3c48 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -26,6 +26,7 @@ struct weatherSystem_t; struct srfWeather_t; void R_InitWeatherSystem(); +void R_InitWeatherForMap(); void R_AddWeatherSurfaces(); void R_ShutdownWeatherSystem(); void RB_SurfaceWeather( srfWeather_t *surfaceType ); From 04eed5bdae420e4d28638a8d14065406ae651b33 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 27 May 2018 23:32:30 +0100 Subject: [PATCH 489/708] Begin/end scene when rendering weather depth map --- codemp/rd-rend2/tr_weather.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index aec553a153..2cd0e7eebf 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -109,6 +109,16 @@ namespace orientationr_t orientation; R_SetOrientationOriginAndAxis(orientation, viewOrigin, left, forward, up); + refdef_t refdef = {}; + refdef.width = tr.weatherDepthFbo->width; + refdef.height = tr.weatherDepthFbo->height; + VectorCopy(orientation.origin, refdef.vieworg); + for (int i = 0; i < 3; ++i) + VectorCopy(orientation.axis[i], refdef.viewaxis[i]); + + RE_BeginScene(&refdef); + RE_ClearScene(); + R_SetupViewParmsForOrthoRendering( tr.weatherDepthFbo->width, tr.weatherDepthFbo->height, @@ -119,13 +129,13 @@ namespace const int firstDrawSurf = tr.refdef.numDrawSurfs; - RE_ClearScene(); R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf); R_IssuePendingRenderCommands(); R_InitNextFrame(); + RE_EndScene(); } void RB_SimulateWeather(weatherSystem_t& ws) From e33258e3ae48cdd5f6ae5df1206cf7b7594ef375 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 27 May 2018 23:37:28 +0100 Subject: [PATCH 490/708] Remove unnecessary field assignments Since we're building up viewParms ourselves, there's no need to set up anything in the refdef --- codemp/rd-rend2/tr_weather.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 2cd0e7eebf..16cda33ced 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -110,12 +110,6 @@ namespace R_SetOrientationOriginAndAxis(orientation, viewOrigin, left, forward, up); refdef_t refdef = {}; - refdef.width = tr.weatherDepthFbo->width; - refdef.height = tr.weatherDepthFbo->height; - VectorCopy(orientation.origin, refdef.vieworg); - for (int i = 0; i < 3; ++i) - VectorCopy(orientation.axis[i], refdef.viewaxis[i]); - RE_BeginScene(&refdef); RE_ClearScene(); From b567ae231f5ceca954237db4ef1467ad189e8f8b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 6 Jun 2018 17:33:06 +0200 Subject: [PATCH 491/708] make sure diffuse stage doesnt get a nullptr assigned --- codemp/rd-rend2/tr_image.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index a37a1084a8..cda7b5c8a1 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2612,6 +2612,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c char specularName[MAX_QPATH]; int width, height, rmoWidth, rmoHeight; byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; + image_t *image; if (!name) { return; @@ -2623,16 +2624,23 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c COM_StripExtension(name, specularName, sizeof(specularName)); Q_strcat(specularName, sizeof(specularName), "_spec"); - //// - //// see if the images are already loaded - //// - stage->bundle[TB_COLORMAP].image[0] = R_GetLoadedImage(diffuseName, flags); - stage->bundle[TB_SPECULARMAP].image[0] = R_GetLoadedImage(specularName, flags); + // + // see if the images are already loaded + // + image = R_GetLoadedImage(diffuseName, flags); + if (image != NULL) + { + stage->bundle[TB_COLORMAP].image[0] = image; - if (stage->bundle[TB_COLORMAP].image[0] != NULL && stage->bundle[TB_SPECULARMAP].image[0] != NULL) { - ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); - return; + image = R_GetLoadedImage(specularName, flags); + if (image != NULL) + { + stage->bundle[TB_SPECULARMAP].image[0] = R_GetLoadedImage(specularName, flags); + ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); + return; + } } + // // load the pics from disk // From ac21c0bb2dbf870c77f357f2508336f7389c8fdc Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 7 Jun 2018 19:45:06 +0200 Subject: [PATCH 492/708] fix swapped srgb2linear and vice versa --- codemp/rd-rend2/tr_image.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index cda7b5c8a1..60b6219cd4 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2693,14 +2693,14 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c metalness = ByteToFloat(rmoPic[i + 1]); ao = ByteToFloat(rmoPic[i + 2]); ao += (1.0 - ao) * (1.0 - aoStrength); - specular_variance = ByteToFloat(rmoPic[i + 3]); + specular_variance = (type == SPEC_RMOS) ? ByteToFloat(rmoPic[i + 3]) : 1.0f; break; case SPEC_MOXR: case SPEC_MOSR: metalness = ByteToFloat(rmoPic[i + 0]); ao = ByteToFloat(rmoPic[i + 1]); ao += (1.0 - ao) * (1.0 - aoStrength); - specular_variance = ByteToFloat(rmoPic[i + 2]); + specular_variance = (type == SPEC_MOSR) ? ByteToFloat(rmoPic[i + 2]) : 1.0f; roughness = ByteToFloat(rmoPic[i + 3]); gloss = (1.0 - roughness) + (0.04 * roughness); break; @@ -2715,27 +2715,27 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c vec4_t baseColor; // remove gamma correction because we want to work in linear space - baseColor[0] = RGBtosRGB(ByteToFloat(baseColorPic[i + 0])); - baseColor[1] = RGBtosRGB(ByteToFloat(baseColorPic[i + 1])); - baseColor[2] = RGBtosRGB(ByteToFloat(baseColorPic[i + 2])); + baseColor[0] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 0])); + baseColor[1] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 1])); + baseColor[2] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 2])); // don't remove gamma correction in alpha because this is data, not color baseColor[3] = ByteToFloat(baseColorPic[i + 3]); - baseSpecular *= specular_variance; + specular_variance *= baseSpecular; // diffuse Color = baseColor * (1.0 - metalness) // also gamma correct again // FIXME: AO should be handled in shader because it should only affect the ambient lighting - diffusePic[i + 0] = FloatToByte(sRGBtoRGB(baseColor[0] * (1.0f - metalness) * ao)); - diffusePic[i + 1] = FloatToByte(sRGBtoRGB(baseColor[1] * (1.0f - metalness) * ao)); - diffusePic[i + 2] = FloatToByte(sRGBtoRGB(baseColor[2] * (1.0f - metalness) * ao)); + diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * (1.0f - metalness) * ao)); + diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * (1.0f - metalness) * ao)); + diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * (1.0f - metalness) * ao)); diffusePic[i + 3] = FloatToByte(baseColor[3]); // specular Color = mix(baseSpecular, baseColor, metalness) // also gamma correct again - specGlossPic[i + 0] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[0] * metalness)); - specGlossPic[i + 1] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[1] * metalness)); - specGlossPic[i + 2] = FloatToByte(sRGBtoRGB(baseSpecular * (1.0f - metalness) + baseColor[2] * metalness)); + specGlossPic[i + 0] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[0] * metalness)); + specGlossPic[i + 1] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[1] * metalness)); + specGlossPic[i + 2] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[2] * metalness)); // don't remove gamma correction in alpha because this is data, not color specGlossPic[i + 3] = FloatToByte(gloss); } From cbfc344676a87c66ea7c55787d262c02c87bef50 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 27 May 2018 23:54:52 +0100 Subject: [PATCH 493/708] Tidy up refdef/viewparms set up for cubemaps --- codemp/rd-rend2/tr_main.cpp | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 5de72a3fc1..c750b2fff1 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2757,12 +2757,9 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce ) { - refdef_t refdef; - viewParms_t parms; + refdef_t refdef = {}; float oldColorScale = tr.refdef.colorScale; - memset( &refdef, 0, sizeof( refdef ) ); - refdef.rdflags = 0; VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg); switch(cubemapSide) @@ -2805,16 +2802,6 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, break; } - refdef.fov_x = 90; - refdef.fov_y = 90; - - refdef.x = 0; - refdef.y = 0; - refdef.width = tr.renderCubeFbo->width; - refdef.height = tr.renderCubeFbo->height; - - refdef.time = 0; - if (!subscene) { RE_BeginScene(&refdef); @@ -2829,13 +2816,9 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, tr.refdef.colorScale = 1.0f; - Com_Memset( &parms, 0, sizeof( parms ) ); - - parms.viewportX = 0; - parms.viewportY = 0; + viewParms_t parms = {}; parms.viewportWidth = tr.renderCubeFbo->width; parms.viewportHeight = tr.renderCubeFbo->height; - parms.isPortal = qfalse; parms.isMirror = qtrue; parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; if (!bounce) From dfde3ff237d443061b918f8e973bd871fec05ae4 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 3 Jun 2018 20:21:29 +0100 Subject: [PATCH 494/708] r_ssao 2 to debug SSAO output --- codemp/rd-rend2/tr_backend.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 2a45737180..62e1cc6c6d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2528,7 +2528,11 @@ const void *RB_PostProcess(const void *data) srcBox[1] = tr.screenSsaoImage->height - srcBox[1]; srcBox[3] = -srcBox[3]; - FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); + int blendMode = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + if (r_ssao->integer == 2) + blendMode = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO; + + FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, blendMode); } if (r_dynamicGlow->integer) From 332f5fbac04dc71c5a40906440fb62935cc69a89 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sat, 9 Jun 2018 09:54:54 +0100 Subject: [PATCH 495/708] Fix orientation when rendering weather depth --- codemp/rd-rend2/tr_backend.cpp | 5 +++++ codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 6 +++--- codemp/rd-rend2/tr_weather.cpp | 30 ++++++++++++++++++++++++------ 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 62e1cc6c6d..98b6ef0f70 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2580,6 +2580,11 @@ const void *RB_PostProcess(const void *data) if (1) RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); + if (r_debugWeather->integer == 2) + { + FBO_BlitFromTexture(tr.weatherDepthImage, NULL, NULL, NULL, nullptr, NULL, NULL, 0); + } + if (0 && r_sunlightMode->integer) { vec4i_t dstBox; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c2c55dd0b6..b438d4ce18 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -415,8 +415,8 @@ typedef struct { void R_SetOrientationOriginAndAxis( orientationr_t& orientation, const vec3_t origin, - const vec3_t left, const vec3_t forward, + const vec3_t left, const vec3_t up); void R_SetOrientationOriginAndAxis( orientationr_t& orientation, diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index c750b2fff1..2b38152cd5 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2217,13 +2217,13 @@ void R_RenderDlightCubemaps(const refdef_t *fd) void R_SetOrientationOriginAndAxis( orientationr_t& orientation, const vec3_t origin, - const vec3_t left, const vec3_t forward, + const vec3_t left, const vec3_t up) { VectorCopy(origin, orientation.origin); - VectorCopy(left, orientation.axis[0]); - VectorCopy(forward, orientation.axis[1]); + VectorCopy(forward, orientation.axis[0]); + VectorCopy(left, orientation.axis[1]); VectorCopy(up, orientation.axis[2]); } diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 16cda33ced..95a0d1bba2 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -92,34 +92,52 @@ namespace void GenerateDepthMap() { vec3_t mapSize; + vec3_t halfMapSize; VectorSubtract( tr.world->bmodels[0].bounds[0], tr.world->bmodels[0].bounds[1], mapSize); + VectorScale(mapSize, -0.5f, halfMapSize); mapSize[2] = 0.0f; + const vec3_t forward = {0.0f, 0.0f, -1.0f}; const vec3_t left = {0.0f, 1.0f, 0.0f}; - const vec3_t up = {0.0f, 0.0f, 1.0f}; - const vec3_t forward = {1.0f, 0.0f, 0.0f}; + const vec3_t up = {1.0f, 0.0f, 0.0f}; - matrix3_t viewAxes; vec3_t viewOrigin; - VectorMA(tr.world->bmodels[0].bounds[0], 0.5f, mapSize, viewOrigin); + VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin); + + ri.Printf(PRINT_ALL, "Rendering weather depth from (%.f %.f %.f)\n", + viewOrigin[0], viewOrigin[1], viewOrigin[2]); orientationr_t orientation; - R_SetOrientationOriginAndAxis(orientation, viewOrigin, left, forward, up); + R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up); refdef_t refdef = {}; + VectorCopy(orientation.origin, refdef.vieworg); + for (int i = 0; i < 3; ++i) + VectorCopy(orientation.axis[i], refdef.viewaxis[i]); + RE_BeginScene(&refdef); RE_ClearScene(); + const vec3_t viewBounds[2] = { + { 0.0f, -halfMapSize[0], -halfMapSize[1] }, + { halfMapSize[2] * 2.0f, halfMapSize[0], halfMapSize[1] } + }; + ri.Printf( + PRINT_ALL, + "Weather view bounds (%f %f %f) (%f %f %f)\n", + viewBounds[0][0], viewBounds[0][1], viewBounds[0][2], + viewBounds[1][0], viewBounds[1][1], viewBounds[1][2]); + R_SetupViewParmsForOrthoRendering( tr.weatherDepthFbo->width, tr.weatherDepthFbo->height, tr.weatherDepthFbo, VPF_DEPTHCLAMP | VPF_DEPTHSHADOW | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL, orientation, - tr.world->bmodels[0].bounds); + viewBounds); const int firstDrawSurf = tr.refdef.numDrawSurfs; From 34f5ead026d11a01f6cc9f817782bdf39517ccd9 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Mon, 3 Dec 2018 22:06:53 +0000 Subject: [PATCH 496/708] Fix misc_bsp rendering --- codemp/rd-rend2/tr_bsp.cpp | 17 +++++++++++++++-- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_world.cpp | 6 +++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 0dc17b2e88..9048c77861 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -626,6 +626,10 @@ static void R_LoadVisibility( world_t *worldData, lump_t *l ) { int len; byte *buf; + len = (worldData->numClusters + 63) & ~63; + worldData->novis = (byte *)ri.Hunk_Alloc(len, h_low); + Com_Memset(worldData->novis, 0xff, len); + len = l->filelen; if ( !len ) { return; @@ -2303,7 +2307,14 @@ static void R_LoadSubmodels( world_t *worldData, int worldIndex, lump_t *l ) { model->type = MOD_BRUSH; model->data.bmodel = out; - Com_sprintf( model->name, sizeof( model->name ), "*%d", i ); + if (worldIndex >= 0) + { + Com_sprintf( model->name, sizeof( model->name ), "*%d-%d", worldIndex, i ); + } + else + { + Com_sprintf( model->name, sizeof( model->name ), "*%d", i ); + } for (j=0 ; j<3 ; j++) { out->bounds[0][j] = LittleFloat (in->mins[j]); @@ -3750,7 +3761,9 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } worldIndex = *bspIndex = tr.numBspModels; - worldData = tr.bspModels[tr.numBspModels]; + + worldData = (world_t *)ri.Hunk_Alloc(sizeof(*worldData), h_low); + tr.bspModels[tr.numBspModels] = worldData; ++tr.numBspModels; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b438d4ce18..7176889c78 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1803,6 +1803,7 @@ typedef struct { int numClusters; int clusterBytes; const byte *vis; // may be passed in by CM_LoadMap to save space + byte *novis; // clusterBytes of 0xff (everything is visible) char *entityString; char *entityParsePoint; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 4bbb2c4756..ee05fd0217 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -660,7 +660,7 @@ R_ClusterPVS */ static const byte *R_ClusterPVS (int cluster) { if (!tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters ) { - return NULL; + return tr.world->novis; } return tr.world->vis + cluster * tr.world->clusterBytes; @@ -683,7 +683,7 @@ qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ) { leafnum = ri.CM_PointLeafnum (p2); cluster = ri.CM_LeafCluster (leafnum); - if ( mask && (!(mask[cluster>>3] & (1<<(cluster&7)) ) ) ) + if ( !(mask[cluster>>3] & (1<<(cluster&7))) ) return qfalse; return qtrue; @@ -754,7 +754,7 @@ static void R_MarkLeaves( void ) } // check general pvs - if ( vis && !(vis[cluster>>3] & (1<<(cluster&7))) ) { + if ( !(vis[cluster>>3] & (1<<(cluster&7))) ) { continue; } From 235d1a43541cfa25f2a9905792b1a9d68d033492 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 6 Apr 2019 17:49:15 +0200 Subject: [PATCH 497/708] deluxemapping patch - added r_deluxeSpecular like SmileTheroy did in ioq3 - fixed the ambient term in lightall for lightmaps --- codemp/rd-rend2/glsl/lightall.glsl | 8 +++++++- codemp/rd-rend2/tr_glsl.cpp | 5 +++++ codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 3b6498fe31..3b7a4d4037 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -705,7 +705,7 @@ void main() #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) ambientColor = lightColor; - float surfNL = clamp(dot(N, L), 0.0, 1.0); + float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); // Scale the incoming light to compensate for the baked-in light angle // attenuation. @@ -741,6 +741,12 @@ void main() Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); #endif + #if defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular) + float NH = clamp(dot(N, H), 0.0, 1.0); + + Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness) * r_deluxeSpecular; + #endif + vec3 reflectance = Fd + Fs; out_Color.rgb = lightColor * reflectance * (attenuation * NL); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 5a1356b815..a5c1619827 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -363,6 +363,11 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%i)\n", CUBE_MAP_MIPS - 4)); } + if (r_deluxeSpecular->value > 0.000001f) + { + Q_strcat(dest, size, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); + } + if (extra) { Q_strcat(dest, size, extra); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 60fc5c5f3d..130c89c3f9 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -136,6 +136,7 @@ cvar_t *r_ssao; cvar_t *r_normalMapping; cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; +cvar_t *r_deluxeSpecular; cvar_t *r_parallaxMapping; cvar_t *r_cubeMapping; cvar_t *r_cubeMappingBounces; @@ -1482,6 +1483,7 @@ void R_Register( void ) r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_deluxeSpecular = ri.Cvar_Get("r_deluxeSpecular", "1", CVAR_ARCHIVE | CVAR_LATCH, ""); r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_cubeMappingBounces = ri.Cvar_Get("r_cubeMappingBounces", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 7176889c78..e4f6731b28 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -154,6 +154,7 @@ extern cvar_t *r_ssao; extern cvar_t *r_normalMapping; extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; +extern cvar_t *r_deluxeSpecular; extern cvar_t *r_parallaxMapping; extern cvar_t *r_normalAmbient; extern cvar_t *r_mergeLightmaps; From 6980f2bc6da290684c130ff90530495cf3b53b94 Mon Sep 17 00:00:00 2001 From: Alex Lo Date: Sun, 7 Apr 2019 14:40:31 +0100 Subject: [PATCH 498/708] Fix #40: z-fighting on decal brushes Credit to @SomaZ for creating this fix! --- codemp/rd-rend2/tr_shader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4ffd1b6c25..cf0e948e6c 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3701,9 +3701,11 @@ static shader_t *FinishShader( void ) { // // set polygon offset // - if ( shader.polygonOffset && !shader.sort ) { - shader.sort = SS_DECAL; + if ( shader.polygonOffset ) { shaderStateBits |= GLS_POLYGON_OFFSET_FILL; + if ( !shader.sort ) { + shader.sort = SS_DECAL; + } } int lmStage; From c346e0fd8d85451309a96320b499803d9a8892b5 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 8 Apr 2019 23:03:54 +0200 Subject: [PATCH 499/708] fix DynamicGlow Uniforms where never initialized for the dglowDownsample shader, thous it never got the size of the image that should be processed. The result was that the shader read the same pixel over and over again instead of gathering multiple ones for smoothing out the output image. --- codemp/rd-rend2/tr_glsl.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a5c1619827..04f03456ed 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -64,6 +64,7 @@ static uniformInfo_t uniformsInfo[] = { "u_ShadowMvp3", GLSL_MAT4x4, 1 }, { "u_EnableTextures", GLSL_VEC4, 1 }, + { "u_DiffuseTexMatrix", GLSL_VEC4, 1 }, { "u_DiffuseTexOffTurb", GLSL_VEC4, 1 }, @@ -2009,8 +2010,8 @@ static int GLSL_LoadGPUProgramDynamicGlowUpsample( fallback_dglow_upsampleProgram, 0); - GLSL_InitUniforms(&tr.dglowDownsample); - GLSL_FinishGPUShader(&tr.dglowDownsample); + GLSL_InitUniforms(&tr.dglowUpsample); + GLSL_FinishGPUShader(&tr.dglowUpsample); return 1; } @@ -2026,8 +2027,8 @@ static int GLSL_LoadGPUProgramDynamicGlowDownsample( fallback_dglow_downsampleProgram, 0); - GLSL_InitUniforms(&tr.dglowUpsample); - GLSL_FinishGPUShader(&tr.dglowUpsample); + GLSL_InitUniforms(&tr.dglowDownsample); + GLSL_FinishGPUShader(&tr.dglowDownsample); return 1; } From cde6ef030f88e4919d241e998db40e2bcb0c7d01 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 6 Nov 2019 16:35:02 +0100 Subject: [PATCH 500/708] Add special case to DEFORM_BULGE Fixes https://github.com/xycaleth/OpenJK/issues/21 --- codemp/rd-rend2/glsl/generic.glsl | 7 +++++++ codemp/rd-rend2/tr_glsl.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index a36ab25dbe..c17374ac13 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -118,6 +118,13 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + normal * scale * bulgeHeight; } + case DEFORM_BULGE_UNIFORM: + { + float bulgeHeight = u_DeformParams[1]; // amplitude + + return pos + normal * bulgeHeight; + } + case DEFORM_WAVE: { float base = u_DeformParams[0]; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 04f03456ed..596167e5fe 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -270,6 +270,7 @@ static size_t GLSL_GetShaderHeader( "#define DEFORM_WAVE %i\n" "#define DEFORM_NORMALS %i\n" "#define DEFORM_BULGE %i\n" + "#define DEFORM_BULGE_UNIFORM %i\n" "#define DEFORM_MOVE %i\n" "#define DEFORM_PROJECTION_SHADOW %i\n" "#define WF_NONE %i\n" @@ -283,6 +284,7 @@ static size_t GLSL_GetShaderHeader( DEFORM_WAVE, DEFORM_NORMALS, DEFORM_BULGE, + DEFORM_BULGE_UNIFORM, DEFORM_MOVE, DEFORM_PROJECTION_SHADOW, GF_NONE, diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e4f6731b28..14ed5557b1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -506,6 +506,7 @@ typedef enum { DEFORM_WAVE, DEFORM_NORMALS, DEFORM_BULGE, + DEFORM_BULGE_UNIFORM, DEFORM_MOVE, DEFORM_PROJECTION_SHADOW, DEFORM_AUTOSPRITE, diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f4d94ab270..f1afff3f1d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -362,6 +362,10 @@ static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float defor deformParams[4] = 0.0f; deformParams[5] = 0.0f; deformParams[6] = 0.0f; + + if (ds->bulgeSpeed == 0.0f && ds->bulgeWidth == 0.0f) + *type = DEFORM_BULGE_UNIFORM; + break; case DEFORM_MOVE: From f212f364bdb8c418afe3a57bbfbc1f111d4bfd8e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 8 Nov 2019 19:08:36 +0100 Subject: [PATCH 501/708] Fix drawing sky portals Fixes https://github.com/xycaleth/OpenJK/issues/25 --- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_scene.cpp | 5 +++++ codemp/rd-rend2/tr_shade.cpp | 16 ++++++++++++++++ codemp/rd-rend2/tr_sky.cpp | 4 ++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 14ed5557b1..6bd953e961 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1801,7 +1801,7 @@ typedef struct { int numGridArrayElements; - + int skyboxportal; int numClusters; int clusterBytes; const byte *vis; // may be passed in by CM_LoadMap to save space diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index c95682532a..29149b2e18 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -436,6 +436,11 @@ void RE_BeginScene(const refdef_t *fd) tr.refdef.num_dlights = 0; } + if (fd->rdflags & RDF_SKYBOXPORTAL) + { + tr.world->skyboxportal = 1; + } + // a single frame may have multiple scenes draw inside it -- // a 3D game view, 3D status bar renderings, 3D menus, etc. // They need to be distinguished by the light flare code, because diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f1afff3f1d..6480b35f97 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1932,6 +1932,22 @@ void RB_EndSurface( void ) { return; } + if (tr.world) { + if (tr.world->skyboxportal) + { + // world + if (!(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL) && (tess.currentStageIteratorFunc == RB_StageIteratorSky)) + { // don't process these tris at all + return; + } + // portal sky + else if (!(backEnd.refdef.rdflags & RDF_DRAWSKYBOX) && (tess.currentStageIteratorFunc != RB_StageIteratorSky)) + { // /only/ process sky tris + return; + } + } + } + // // update performance counters // diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 55a1bc774b..68b34e84fc 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -830,6 +830,10 @@ void RB_StageIteratorSky( void ) { return; } + if (tr.world->skyboxportal && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) { + return; + } + // go through all the polygons and project them onto // the sky box to see which blocks on each side need // to be drawn From a2e0b5411b1a43bebfd87740f3a88ec7cfe40564 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 8 Nov 2019 19:32:33 +0100 Subject: [PATCH 502/708] Disintegration effect Fixes https://github.com/xycaleth/OpenJK/issues/43 --- codemp/rd-rend2/glsl/generic.glsl | 57 +++++++++++++++++++++++++++-- codemp/rd-rend2/glsl/lightall.glsl | 47 ++++++++++++++++++++++-- codemp/rd-rend2/tr_glsl.cpp | 33 +++++++++++------ codemp/rd-rend2/tr_local.h | 6 +++- codemp/rd-rend2/tr_shade.cpp | 58 +++++++++++++++++++++++++----- 5 files changed, 176 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index c17374ac13..ab1ff04155 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -54,6 +54,10 @@ uniform vec3 u_ModelLightDir; uniform float u_PortalRange; #endif +#if defined(USE_RGBAGEN) || defined(USE_DEFORM_VERTEXES) +uniform vec4 u_Disintegration; // origin, threshhold +#endif + #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; #elif defined(USE_SKELETAL_ANIMATION) @@ -173,6 +177,21 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos - lightPos * dot( pos, ground ) + groundDist; } + + case DEFORM_DISINTEGRATION: + { + vec3 delta = u_Disintegration.xyz - pos; + float distance = dot(delta, delta); + if ( distance < u_Disintegration.w ) + { + return normal * vec3(2.0, 2.0, 0.5) + pos; + } + else if ( distance < u_Disintegration.w + 50 ) + { + return normal * vec3(1.0, 1.0, 0.0) + pos; + } + return pos - normal * 0.01; + } } } @@ -264,7 +283,39 @@ vec4 CalcColor(vec3 position, vec3 normal) color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); } - + else if (u_ColorGen == CGEN_DISINTEGRATION_1) + { + vec3 delta = u_Disintegration.xyz - position; + float distance = dot(delta, delta); + if (distance < u_Disintegration.w) + { + color *= 0.0; + } + else if (distance < u_Disintegration.w + 60.0) + { + color *= vec4(0.0, 0.0, 0.0, 1.0); + } + else if (distance < u_Disintegration.w + 150.0) + { + color *= vec4(0.435295, 0.435295, 0.435295, 1.0); + } + else if (distance < u_Disintegration.w + 180.0) + { + color *= vec4(0.6862745, 0.6862745, 0.6862745, 1.0); + } + return color; + } + else if (u_ColorGen == CGEN_DISINTEGRATION_2) + { + vec3 delta = u_Disintegration.xyz - position; + float distance = dot(delta, delta); + if (distance < u_Disintegration.w) + { + color *= 0.0; + } + return color; + } + vec3 viewer = u_LocalViewOrigin - position; if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) @@ -422,7 +473,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d void main() { vec4 color = texture(u_DiffuseMap, var_DiffuseTex); - + color.a *= var_Color.a; #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { @@ -451,7 +502,7 @@ void main() color *= vec4(1.0) - u_FogColorMask * fog; #endif - out_Color = color * var_Color; + out_Color = vec4(color.rgb * var_Color.rgb, color.a); #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 3b7a4d4037..2cee5c599a 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -52,7 +52,9 @@ uniform vec4 u_DiffuseTexOffTurb; uniform mat4 u_ModelViewProjectionMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; +uniform vec4 u_Disintegration; uniform mat4 u_ModelMatrix; +uniform int u_ColorGen; #if defined(USE_VERTEX_ANIMATION) uniform float u_VertexLerp; @@ -95,6 +97,44 @@ out vec4 var_LightDir; out vec4 var_PrimaryLightDir; #endif +vec4 CalcColor(vec3 position) +{ + vec4 color = vec4(1.0); + if (u_ColorGen == CGEN_DISINTEGRATION_1) + { + vec3 delta = u_Disintegration.xyz - position; + float distance = dot(delta, delta); + if (distance < u_Disintegration.w) + { + color = vec4(0.0); + } + else if (distance < u_Disintegration.w + 60.0) + { + color = vec4(0.0, 0.0, 0.0, 1.0); + } + else if (distance < u_Disintegration.w + 150.0) + { + color = vec4(0.435295, 0.435295, 0.435295, 1.0); + } + else if (distance < u_Disintegration.w + 180.0) + { + color = vec4(0.6862745, 0.6862745, 0.6862745, 1.0); + } + return color; + } + else if (u_ColorGen == CGEN_DISINTEGRATION_2) + { + vec3 delta = u_Disintegration.xyz - position; + float distance = dot(delta, delta); + if (distance < u_Disintegration.w) + { + color = vec4(0.0); + } + return color; + } + return color; +} + #if defined(USE_TCGEN) || defined(USE_LIGHTMAP) vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) { @@ -164,7 +204,6 @@ float CalcLightAttenuation(in bool isPoint, float normDist) return clamp(attenuation, 0.0, 1.0); } - void main() { #if defined(USE_VERTEX_ANIMATION) @@ -231,6 +270,8 @@ void main() var_TexCoords.xy = texCoords; #endif + vec4 disintegration = CalcColor(position); + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); position = (u_ModelMatrix * vec4(position, 1.0)).xyz; @@ -276,6 +317,7 @@ void main() var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; #endif } + var_Color *= disintegration; #if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); @@ -638,6 +680,7 @@ void main() #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); + diffuse.a *= var_Color.a; #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { @@ -781,7 +824,7 @@ void main() out_Color.rgb = diffuse.rgb * lightColor; #endif - out_Color.a = diffuse.a * var_Color.a; + out_Color.a = diffuse.a; #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 596167e5fe..e6d948f698 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -83,15 +83,16 @@ static uniformInfo_t uniformsInfo[] = { "u_BaseColor", GLSL_VEC4, 1 }, { "u_VertColor", GLSL_VEC4, 1 }, - { "u_DlightInfo", GLSL_VEC4, 1 }, - { "u_LightForward", GLSL_VEC3, 1 }, - { "u_LightUp", GLSL_VEC3, 1 }, - { "u_LightRight", GLSL_VEC3, 1 }, - { "u_LightOrigin", GLSL_VEC4, 1 }, - { "u_ModelLightDir", GLSL_VEC3, 1 }, - { "u_LightRadius", GLSL_FLOAT, 1 }, - { "u_AmbientLight", GLSL_VEC3, 1 }, - { "u_DirectedLight", GLSL_VEC3, 1 }, + { "u_DlightInfo", GLSL_VEC4, 1 }, + { "u_LightForward", GLSL_VEC3, 1 }, + { "u_LightUp", GLSL_VEC3, 1 }, + { "u_LightRight", GLSL_VEC3, 1 }, + { "u_LightOrigin", GLSL_VEC4, 1 }, + { "u_ModelLightDir", GLSL_VEC3, 1 }, + { "u_LightRadius", GLSL_FLOAT, 1 }, + { "u_AmbientLight", GLSL_VEC3, 1 }, + { "u_DirectedLight", GLSL_VEC3, 1 }, + { "u_Disintegration", GLSL_VEC4, 1 }, { "u_PortalRange", GLSL_FLOAT, 1 }, @@ -273,6 +274,7 @@ static size_t GLSL_GetShaderHeader( "#define DEFORM_BULGE_UNIFORM %i\n" "#define DEFORM_MOVE %i\n" "#define DEFORM_PROJECTION_SHADOW %i\n" + "#define DEFORM_DISINTEGRATION %i\n" "#define WF_NONE %i\n" "#define WF_SIN %i\n" "#define WF_SQUARE %i\n" @@ -287,6 +289,7 @@ static size_t GLSL_GetShaderHeader( DEFORM_BULGE_UNIFORM, DEFORM_MOVE, DEFORM_PROJECTION_SHADOW, + DEFORM_DISINTEGRATION, GF_NONE, GF_SIN, GF_SQUARE, @@ -319,8 +322,12 @@ static size_t GLSL_GetShaderHeader( va("#ifndef colorGen_t\n" "#define colorGen_t\n" "#define CGEN_LIGHTING_DIFFUSE %i\n" + "#define CGEN_DISINTEGRATION_1 %i\n" + "#define CGEN_DISINTEGRATION_2 %i\n" "#endif\n", - CGEN_LIGHTING_DIFFUSE)); + CGEN_LIGHTING_DIFFUSE, + CGEN_DISINTEGRATION_1, + CGEN_DISINTEGRATION_2)); Q_strcat(dest, size, va("#ifndef alphaGen_t\n" @@ -2401,6 +2408,12 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) if ( pStage->alphaTestType != ALPHA_TEST_NONE ) shaderAttribs |= GENERICDEF_USE_ALPHA_TEST; + if (backEnd.currentEntity->e.renderfx & (RF_DISINTEGRATE1 | RF_DISINTEGRATE2)) + shaderAttribs |= GENERICDEF_USE_RGBAGEN; + + if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) + shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; + switch (pStage->rgbGen) { case CGEN_LIGHTING_DIFFUSE: diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6bd953e961..978f27ff44 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -518,7 +518,8 @@ typedef enum { DEFORM_TEXT4, DEFORM_TEXT5, DEFORM_TEXT6, - DEFORM_TEXT7 + DEFORM_TEXT7, + DEFORM_DISINTEGRATION } deform_t; // deformVertexes types that can be handled by the GPU @@ -571,6 +572,8 @@ typedef enum { CGEN_FOG, // standard fog CGEN_CONST, // fixed color CGEN_LIGHTMAPSTYLE, // lightmap style + CGEN_DISINTEGRATION_1, + CGEN_DISINTEGRATION_2 } colorGen_t; typedef enum { @@ -1225,6 +1228,7 @@ typedef enum UNIFORM_LIGHTRADIUS, UNIFORM_AMBIENTLIGHT, UNIFORM_DIRECTEDLIGHT, + UNIFORM_DISINTEGRATION, UNIFORM_PORTALRANGE, diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 6480b35f97..6fcf0050a2 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -330,6 +330,12 @@ static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float defor *type = DEFORM_NONE; *waveFunc = GF_NONE; + if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) + { + *type = DEFORM_DISINTEGRATION; + return; + } + if(!ShaderRequiresCPUDeforms(tess.shader)) { deformStage_t *ds; @@ -536,6 +542,8 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t case CGEN_LIGHTING_DIFFUSE: case CGEN_BAD: break; + default: + break; } // @@ -586,6 +594,8 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t baseColor[3] = 1.0f; vertColor[3] = 0.0f; break; + default: + break; } if ( forceAlphaGen != NULL ) @@ -1300,6 +1310,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag index |= GENERICDEF_USE_ALPHA_TEST; } + if (backEnd.currentEntity->e.renderfx & (RF_DISINTEGRATE1 | RF_DISINTEGRATE2)) + index |= GENERICDEF_USE_RGBAGEN; + + if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) + index |= GENERICDEF_USE_DEFORM_VERTEXES; + result = &tr.genericShader[index]; backEnd.pc.c_genericDraws++; } @@ -1384,6 +1400,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays alphaGen_t forceAlphaGen = AGEN_IDENTITY; int index = 0; bool useAlphaTestGE192 = false; + vec4_t disintegrationInfo; if ( !pStage ) { @@ -1401,16 +1418,27 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { assert(backEnd.currentEntity->e.renderfx >= 0); - if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) + if ( backEnd.currentEntity->e.renderfx & ( RF_DISINTEGRATE1 | RF_DISINTEGRATE2 )) { - // we want to be able to rip a hole in the thing being - // disintegrated, and by doing the depth-testing it avoids some - // kinds of artefacts, but will probably introduce others? - stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; - useAlphaTestGE192 = true; + if ( backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE1 ) + { + // we want to be able to rip a hole in the thing being + // disintegrated, and by doing the depth-testing it avoids some + // kinds of artefacts, but will probably introduce others? + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHMASK_TRUE; + forceRGBGen = CGEN_DISINTEGRATION_1; + useAlphaTestGE192 = true; + } + else + forceRGBGen = CGEN_DISINTEGRATION_2; + + disintegrationInfo[0] = backEnd.currentEntity->e.oldorigin[0]; + disintegrationInfo[1] = backEnd.currentEntity->e.oldorigin[1]; + disintegrationInfo[2] = backEnd.currentEntity->e.oldorigin[2]; + disintegrationInfo[3] = (backEnd.refdef.time - backEnd.currentEntity->e.endTime) * 0.045f; + disintegrationInfo[3] *= disintegrationInfo[3]; } - - if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) + else if ( backEnd.currentEntity->e.renderfx & RF_RGB_TINT ) {//want to use RGBGen from ent forceRGBGen = CGEN_ENTITY; } @@ -1452,6 +1480,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } + if ( disintegrationInfo != NULL ) + { + uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); + } + if ( input->fogNum ) { const fog_t *fog = tr.world->fogs + input->fogNum; @@ -1710,7 +1743,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - uint32_t key = RB_CreateSortKey(item, stage, input->shader->sort); + uint32_t key = 0; + if ((backEnd.currentEntity->e.renderfx & RF_DISTORTION) || + (backEnd.currentEntity->e.renderfx & RF_FORCEPOST) || + (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA)) + key = RB_CreateSortKey(item, 15, input->shader->sort); + else + key = RB_CreateSortKey(item, stage, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); // allow skipping out to show just lightmaps during development From 0b46a60a8e39a339a1d0bdba803b86beb97ed625 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 8 Nov 2019 19:50:47 +0100 Subject: [PATCH 503/708] Add missing API function Credits to Bucky for finding it. --- codemp/rd-rend2/tr_init.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 130c89c3f9..22b0ea72cc 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -2192,6 +2192,8 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { Ghoul2 Insert End */ + re.ext.Font_StrLenPixels = RE_Font_StrLenPixelsNew; + return &re; } } From e70600b7d336c5956e2a114d1e5d8f3ccabcc3d4 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 8 Nov 2019 20:47:41 +0100 Subject: [PATCH 504/708] Fix cg_shadows 3 Just for completeness --- codemp/rd-rend2/glsl/generic.glsl | 9 ++------- codemp/rd-rend2/tr_ghoul2.cpp | 14 ++++++++++++++ codemp/rd-rend2/tr_shade.cpp | 13 ++++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index ab1ff04155..7c7748f47b 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -168,14 +168,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) u_DeformParams[5], u_DeformParams[6]); - float d = dot( lightDir, ground ); - - lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; - d = 1.0 / dot( lightDir, ground ); - + float d = 1.0 / dot( lightDir, ground ); vec3 lightPos = lightDir * d; - - return pos - lightPos * dot( pos, ground ) + groundDist; + return pos - lightPos * (dot( pos, ground ) + groundDist); } case DEFORM_DISINTEGRATION: diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 9612dfbf20..1e9f1ea464 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2489,6 +2489,20 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum } #endif } + + // projection shadows work fine with personal models + if (r_shadows->integer == 3 + && RS.fogNum == 0 + && (RS.renderfx & (RF_NOSHADOW | RF_DEPTHHACK)) + && shader->sort == SS_OPAQUE) { + + CRenderableSurface *newSurf = AllocGhoul2RenderableSurface(); + newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; + assert(newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); + newSurf->surfaceData = surface; + newSurf->boneCache = RS.boneCache; + R_AddDrawSurf((surfaceType_t *)newSurf, entityNum, tr.projectionShadowShader, 0, qfalse, qfalse, 0); + } } // if we are turning off all descendants, then stop this recursion now diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 6fcf0050a2..31a38e26b2 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -407,9 +407,16 @@ static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float defor deformParams[1] = backEnd.ori.axis[1][2]; deformParams[2] = backEnd.ori.axis[2][2]; deformParams[3] = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; - deformParams[4] = backEnd.currentEntity->lightDir[0]; - deformParams[5] = backEnd.currentEntity->lightDir[1]; - deformParams[6] = backEnd.currentEntity->lightDir[2]; + + vec3_t lightDir; + VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); + lightDir[2] = 0.0f; + VectorNormalize(lightDir); + VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); + + deformParams[4] = lightDir[0]; + deformParams[5] = lightDir[1]; + deformParams[6] = lightDir[2]; break; default: From 514ef52e3eabef13d1f47d9da173a0b4a865f732 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 10 Nov 2019 23:32:44 +0100 Subject: [PATCH 505/708] Add cg_shadows 4 Based on ioq3s implementation with some additions and fixes --- codemp/rd-rend2/glsl/pshadow.glsl | 82 +++++------ codemp/rd-rend2/tr_fbo.cpp | 4 +- codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_local.h | 4 +- codemp/rd-rend2/tr_main.cpp | 232 ++++++++++++++++-------------- codemp/rd-rend2/tr_shade.cpp | 77 ++++++---- codemp/rd-rend2/tr_world.cpp | 4 +- 7 files changed, 212 insertions(+), 193 deletions(-) diff --git a/codemp/rd-rend2/glsl/pshadow.glsl b/codemp/rd-rend2/glsl/pshadow.glsl index 3238aaa2ee..680cadf8cd 100644 --- a/codemp/rd-rend2/glsl/pshadow.glsl +++ b/codemp/rd-rend2/glsl/pshadow.glsl @@ -29,19 +29,26 @@ in vec3 var_Normal; out vec4 out_Color; -float sampleDistMap(sampler2D texMap, vec2 uv, float scale) -{ - vec3 distv = texture(texMap, uv).xyz; - return dot(distv, vec3(1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0)) * scale; -} +#define PCF_SAMPLES 9 +#define TEXTURE_SCALE float(1.0/1024.0) + +const vec2 poissonDisc[PCF_SAMPLES] = vec2[PCF_SAMPLES]( +vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386), +vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417), +vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181), +vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854), +vec2(0.7320465, 0.6317794) +); void main() { vec3 lightToPos = var_Position - u_LightOrigin.xyz; vec2 st = vec2(-dot(u_LightRight, lightToPos), dot(u_LightUp, lightToPos)); - + vec3 L = normalize(-lightToPos); + vec3 normal = normalize(var_Normal); + float fade = length(st); - + #if defined(USE_DISCARD) if (fade >= 1.0) { @@ -50,70 +57,49 @@ void main() #endif fade = clamp(8.0 - fade * 8.0, 0.0, 1.0); - + st = st * 0.5 + vec2(0.5); -#if defined(USE_SOLID_PSHADOWS) - float intensity = max(sign(u_LightRadius - length(lightToPos)), 0.0); -#else float intensity = clamp((1.0 - dot(lightToPos, lightToPos) / (u_LightRadius * u_LightRadius)) * 2.0, 0.0, 1.0); -#endif - float lightDist = length(lightToPos); - float dist; #if defined(USE_DISCARD) - if (dot(u_LightForward, lightToPos) <= 0.0) + if (dot(normalize(-u_LightForward), L) <= 0.0) { discard; } - if (dot(var_Normal, lightToPos) > 0.0) + if (dot(normal, L) <= 0.0) { discard; } -#else - intensity *= max(sign(dot(u_LightForward, lightToPos)), 0.0); - intensity *= max(sign(-dot(var_Normal, lightToPos)), 0.0); #endif + intensity *= max(dot(normal, L), 0.0); intensity *= fade; -#if defined(USE_PCF) - float part; - - dist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, -1.0/512.0), u_LightRadius); - part = max(sign(lightDist - dist), 0.0); - - dist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, -1.0/512.0), u_LightRadius); - part += max(sign(lightDist - dist), 0.0); - - dist = sampleDistMap(u_ShadowMap, st + vec2(-1.0/512.0, 1.0/512.0), u_LightRadius); - part += max(sign(lightDist - dist), 0.0); - dist = sampleDistMap(u_ShadowMap, st + vec2( 1.0/512.0, 1.0/512.0), u_LightRadius); - part += max(sign(lightDist - dist), 0.0); - - #if defined(USE_DISCARD) - if (part <= 0.0) + float part = 0.0; +#if defined(USE_PCF) + float offsetScale = pow(lightDist, 4.0) * TEXTURE_SCALE * 0.00000001; + for (int i = 0; i < PCF_SAMPLES; ++i) { - discard; + part += float(texture(u_ShadowMap, st + offsetScale * poissonDisc[i]).r != 1.0); } - #endif - - intensity *= part * 0.25; #else - dist = sampleDistMap(u_ShadowMap, st, u_LightRadius); + part = float(texture(u_ShadowMap, st).r != 1.0); +#endif - #if defined(USE_DISCARD) - if (lightDist - dist <= 0.0) + if (part <= 0.0) { discard; } - #endif - - intensity *= max(sign(lightDist - dist), 0.0); + +#if defined(USE_PCF) + intensity *= part * 0.111; +#else + intensity *= part; #endif - - out_Color.rgb = vec3(0.0); + + out_Color.rgb = vec3(.0,.0,.0); out_Color.a = clamp(intensity, 0.0, 0.75); -} +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 35409d7724..733c573139 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -502,12 +502,12 @@ void FBO_Init(void) for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) { tr.pshadowFbos[i] = FBO_Create( - va("_shadowmap%d", i), tr.pshadowMaps[i]->width, + va("_shadowmap%i", i), tr.pshadowMaps[i]->width, tr.pshadowMaps[i]->height); FBO_Bind(tr.pshadowFbos[i]); - FBO_AttachTextureImage(tr.pshadowMaps[i], 0); FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24, 0, 0); + R_AttachFBOTextureDepth(tr.pshadowMaps[i]->texnum); FBO_SetupDrawBuffers(); R_CheckFBO(tr.pshadowFbos[i]); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 60b6219cd4..160a5bf6fb 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3322,7 +3322,7 @@ void R_CreateBuiltinImages( void ) { tr.pshadowMaps[x] = R_CreateImage( va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); } } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 978f27ff44..9933fd327f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -58,8 +58,8 @@ typedef unsigned int glIndex_t; #define MAX_IBOS 4096 #define MAX_CALC_PSHADOWS 64 -#define MAX_DRAWN_PSHADOWS 16 // do not increase past 32, because bit flags are used on surfaces -#define PSHADOW_MAP_SIZE 512 +#define MAX_DRAWN_PSHADOWS 32 // do not increase past 32, because bit flags are used on surfaces +#define PSHADOW_MAP_SIZE 1024 #define CUBE_MAP_MIPS 8 #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 2b38152cd5..1b708354b6 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2270,6 +2270,7 @@ void R_SetupViewParmsForOrthoRendering( void R_RenderPshadowMaps(const refdef_t *fd) { + viewParms_t shadowParms; int i; // first, make a list of shadows @@ -2302,34 +2303,21 @@ void R_RenderPshadowMaps(const refdef_t *fd) switch (model->type) { - case MOD_MESH: + case MOD_MDXM: + case MOD_BAD: { - mdvFrame_t *frame = &model->data.mdv[0]->frames[ent->e.frame]; - - radius = frame->radius * scale; - } - break; - - case MOD_MDR: - { - // FIXME: never actually tested this - mdrHeader_t *header = model->data.mdr; - int frameSize = (size_t)( &((mdrFrame_t *)0)->bones[ header->numBones ] ); - mdrFrame_t *frame = ( mdrFrame_t * ) ( ( byte * ) header + header->ofsFrames + frameSize * ent->e.frame); - - radius = frame->radius; - } - break; - case MOD_IQM: - { - // FIXME: never actually tested this - iqmData_t *data = model->data.iqm; - vec3_t diag; - float *framebounds; - - framebounds = data->bounds + 6*ent->e.frame; - VectorSubtract( framebounds+3, framebounds, diag ); - radius = 0.5f * VectorLength( diag ); + if (ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2))) + { + // scale the radius if needed + float largestScale = ent->e.modelScale[0]; + if (ent->e.modelScale[1] > largestScale) + largestScale = ent->e.modelScale[1]; + if (ent->e.modelScale[2] > largestScale) + largestScale = ent->e.modelScale[2]; + if (!largestScale) + largestScale = 1; + radius = ent->e.radius * largestScale * 1.2; + } } break; @@ -2341,7 +2329,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) continue; // Cull entities that are behind the viewer by more than lightRadius - VectorSubtract(ent->e.origin, fd->vieworg, diff); + VectorSubtract(ent->e.lightingOrigin, fd->vieworg, diff); if (DotProduct(diff, fd->viewaxis[0]) < -r_pshadowDist->value) continue; @@ -2351,7 +2339,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) shadow.entityNums[0] = i; shadow.viewRadius = radius; shadow.lightRadius = r_pshadowDist->value; - VectorCopy(ent->e.origin, shadow.viewOrigin); + VectorCopy(ent->e.lightingOrigin, shadow.viewOrigin); shadow.sort = DotProduct(diff, diff) / (radius * radius); VectorCopy(ent->e.origin, shadow.entityOrigins[0]); shadow.entityRadiuses[0] = radius; @@ -2379,60 +2367,6 @@ void R_RenderPshadowMaps(const refdef_t *fd) } } - // next, merge touching pshadows - for ( i = 0; i < tr.refdef.num_pshadows; i++) - { - pshadow_t *ps1 = &tr.refdef.pshadows[i]; - int j; - - for (j = i + 1; j < tr.refdef.num_pshadows; j++) - { - pshadow_t *ps2 = &tr.refdef.pshadows[j]; - int k; - qboolean touch; - - if (ps1->numEntities == 8) - break; - - touch = qfalse; - if (SpheresIntersect(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius)) - { - for (k = 0; k < ps1->numEntities; k++) - { - if (SpheresIntersect(ps1->entityOrigins[k], ps1->entityRadiuses[k], ps2->viewOrigin, ps2->viewRadius)) - { - touch = qtrue; - break; - } - } - } - - if (touch) - { - vec3_t newOrigin; - float newRadius; - - BoundingSphereOfSpheres(ps1->viewOrigin, ps1->viewRadius, ps2->viewOrigin, ps2->viewRadius, newOrigin, &newRadius); - VectorCopy(newOrigin, ps1->viewOrigin); - ps1->viewRadius = newRadius; - - ps1->entityNums[ps1->numEntities] = ps2->entityNums[0]; - VectorCopy(ps2->viewOrigin, ps1->entityOrigins[ps1->numEntities]); - ps1->entityRadiuses[ps1->numEntities] = ps2->viewRadius; - - ps1->numEntities++; - - for (k = j; k < tr.refdef.num_pshadows - 1; k++) - { - tr.refdef.pshadows[k] = tr.refdef.pshadows[k + 1]; - } - - j--; - tr.refdef.num_pshadows--; - } - } - } - // cap number of drawn pshadows if (tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS) { @@ -2447,14 +2381,18 @@ void R_RenderPshadowMaps(const refdef_t *fd) vec3_t ambientLight, directedLight, lightDir; VectorSet(lightDir, 0.57735f, 0.57735f, 0.57735f); -#if 1 - R_LightForPoint(shadow->viewOrigin, ambientLight, directedLight, lightDir); + R_LightForPoint(shadow->viewOrigin, ambientLight, directedLight, lightDir); +#if 1 + lightDir[2] = 0.0f; + VectorNormalize(lightDir); + VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); + VectorNormalize(lightDir); +#else // sometimes there's no light if (DotProduct(lightDir, lightDir) < 0.9f) VectorSet(lightDir, 0.0f, 0.0f, 1.0f); #endif - if (shadow->viewRadius * 3.0f > shadow->lightRadius) { shadow->lightRadius = shadow->viewRadius * 3.0f; @@ -2485,34 +2423,112 @@ void R_RenderPshadowMaps(const refdef_t *fd) for ( i = 0; i < tr.refdef.num_pshadows; i++) { pshadow_t *shadow = &tr.refdef.pshadows[i]; + int j; + + Com_Memset(&shadowParms, 0, sizeof(shadowParms)); + + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; + shadowParms.viewportWidth = PSHADOW_MAP_SIZE; + shadowParms.viewportHeight = PSHADOW_MAP_SIZE; + shadowParms.isPortal = qfalse; + shadowParms.isMirror = qfalse; - orientationr_t orientation; - R_SetOrientationOriginAndAxis(orientation, shadow->lightOrigin, shadow->lightViewAxis); + shadowParms.fovX = 90; + shadowParms.fovY = 90; + + shadowParms.targetFbo = tr.pshadowFbos[i]; - const float viewRadius = shadow->viewRadius; - vec3_t shadowViewBounds[2]; - VectorSet(shadowViewBounds[0], -viewRadius, -viewRadius, 0.0f); - VectorSet(shadowViewBounds[1], viewRadius, viewRadius, shadow->lightRadius); + shadowParms.flags = (viewParmFlags_t)(VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); + shadowParms.zFar = shadow->lightRadius; - R_SetupViewParmsForOrthoRendering( - PSHADOW_MAP_SIZE, - PSHADOW_MAP_SIZE, - tr.pshadowFbos[i], - VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL, - orientation, - shadowViewBounds); + VectorCopy(shadow->lightOrigin, shadowParms.ori.origin); + + VectorCopy(shadow->lightViewAxis[0], shadowParms.ori.axis[0]); + VectorCopy(shadow->lightViewAxis[1], shadowParms.ori.axis[1]); + VectorCopy(shadow->lightViewAxis[2], shadowParms.ori.axis[2]); - const int firstDrawSurf = tr.refdef.numDrawSurfs; - for (int j = 0; j < shadow->numEntities; j++) { - int entityNum = shadow->entityNums[j]; - trRefEntity_t *ent = tr.refdef.entities + entityNum; - R_AddEntitySurface(&tr.refdef, ent, entityNum); - } + tr.viewCount++; - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); + tr.viewParms = shadowParms; + tr.viewParms.frameSceneNum = tr.frameSceneNum; + tr.viewParms.frameCount = tr.frameCount; + + // set viewParms.world + R_RotateForViewer(&tr.ori, &tr.viewParms); + + { + float xmin, xmax, ymin, ymax, znear, zfar; + viewParms_t *dest = &tr.viewParms; + vec3_t pop; + + xmin = ymin = -shadow->viewRadius; + xmax = ymax = shadow->viewRadius; + znear = 0; + zfar = shadow->lightRadius; + + dest->projectionMatrix[0] = 2 / (xmax - xmin); + dest->projectionMatrix[4] = 0; + dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); + dest->projectionMatrix[12] = 0; + + dest->projectionMatrix[1] = 0; + dest->projectionMatrix[5] = 2 / (ymax - ymin); + dest->projectionMatrix[9] = (ymax + ymin) / (ymax - ymin); // normally 0 + dest->projectionMatrix[13] = 0; + + dest->projectionMatrix[2] = 0; + dest->projectionMatrix[6] = 0; + dest->projectionMatrix[10] = 2 / (zfar - znear); + dest->projectionMatrix[14] = 0; + + dest->projectionMatrix[3] = 0; + dest->projectionMatrix[7] = 0; + dest->projectionMatrix[11] = 0; + dest->projectionMatrix[15] = 1; + + VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); + dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); + + VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); + dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); + + VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); + dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); + + VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); + dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); + + VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->ori.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); + dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); + + for (j = 0; j < 5; j++) + { + dest->frustum[j].type = PLANE_NON_AXIAL; + SetPlaneSignbits(&dest->frustum[j]); + } + + dest->flags |= VPF_FARPLANEFRUSTUM; + } + + const int firstDrawSurf = tr.refdef.numDrawSurfs; + for (int j = 0; j < shadow->numEntities; j++) + { + int entityNum = shadow->entityNums[j]; + trRefEntity_t *ent = tr.refdef.entities + entityNum; + R_AddEntitySurface(&tr.refdef, ent, entityNum); + } + + R_SortAndSubmitDrawSurfs( + tr.refdef.drawSurfs + firstDrawSurf, + tr.refdef.numDrawSurfs - firstDrawSurf); + } } } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 31a38e26b2..a73bcc5781 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1071,18 +1071,25 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie } -static void ProjectPshadowVBOGLSL( void ) { +static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int l; vec3_t origin; float radius; - shaderCommands_t *input = &tess; - if ( !backEnd.refdef.num_pshadows ) { return; } - for ( l = 0 ; l < backEnd.refdef.num_pshadows ; l++ ) { + cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); + + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; + shaderStage_t *pStage = tess.xstages[0]; + + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + + for ( l = 0; l < backEnd.refdef.num_pshadows; l++ ) { pshadow_t *ps; shaderProgram_t *sp; vec4_t vector; @@ -1097,46 +1104,58 @@ static void ProjectPshadowVBOGLSL( void ) { sp = &tr.pshadowShader; - GLSL_BindProgram(sp); + uniformDataWriter.Start(sp); - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); VectorCopy(origin, vector); vector[3] = 1.0f; - GLSL_SetUniformVec4(sp, UNIFORM_LIGHTORIGIN, vector); + uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vector); - VectorScale(ps->lightViewAxis[0], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTFORWARD, vector); + VectorScale(ps->lightViewAxis[0], 1.0f, vector); + uniformDataWriter.SetUniformVec3(UNIFORM_LIGHTFORWARD, vector); VectorScale(ps->lightViewAxis[1], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTRIGHT, vector); + uniformDataWriter.SetUniformVec3(UNIFORM_LIGHTRIGHT, vector); VectorScale(ps->lightViewAxis[2], 1.0f / ps->viewRadius, vector); - GLSL_SetUniformVec3(sp, UNIFORM_LIGHTUP, vector); + uniformDataWriter.SetUniformVec3(UNIFORM_LIGHTUP, vector); + + uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, radius); - GLSL_SetUniformFloat(sp, UNIFORM_LIGHTRADIUS, radius); - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light // where they aren't rendered - GL_State( GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL ); + uint32_t stateBits = 0; + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL; - GL_BindToTMU( tr.pshadowMaps[l], TB_DIFFUSEMAP ); + samplerBindingsWriter.AddStaticImage(tr.pshadowMaps[l], TB_DIFFUSEMAP); - // - // draw - // + CaptureDrawData(input, pStage, 0, 0); - if (input->multiDrawPrimitives) - { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); - } + DrawItem item = {}; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + item.program = sp; + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); + + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + // FIXME: This is a bit ugly with the casting + item.samplerBindings = samplerBindingsWriter.Finish( + *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); + + uint32_t key = RB_CreateSortKey(item, 14, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); backEnd.pc.c_totalIndexes += tess.numIndexes; - //backEnd.pc.c_dlightIndexes += tess.numIndexes; + RB_BinTriangleCounts(); } } @@ -1884,7 +1903,6 @@ void RB_StageIteratorGeneric( void ) { RB_IterateStagesGeneric( input, &vertexArrays ); -#if 0 // don't do this for now while I get draw sorting working :) // // pshadows! // @@ -1893,9 +1911,8 @@ void RB_StageIteratorGeneric( void ) tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) { - ProjectPshadowVBOGLSL(); + ProjectPshadowVBOGLSL( input, &vertexArrays ); } -#endif // // now do any dynamic lighting needed diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index ee05fd0217..9b071392f6 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -353,10 +353,10 @@ static void R_AddWorldSurface( } // check for pshadows - /*if ( pshadowBits ) *//*{ + if ( pshadowBits ) { pshadowBits = R_PshadowSurface( surf, pshadowBits); pshadowBits = ( pshadowBits != 0 ); - }*/ + } bool isPostRenderEntity = false; if ( entityNum != REFENTITYNUM_WORLD ) From cc24aac997ce5393a15840dff154e14e883b2c4e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 12 Nov 2019 17:55:41 +0100 Subject: [PATCH 506/708] fix animation bug This basically broke all animations that have a negative animation speed. numFramesInAnim is computed by endFrame - startFrame so it's negative in this case. Thanks to @Bucky21659 for creating this fix --- codemp/rd-rend2/tr_ghoul2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 1e9f1ea464..db75b5b56e 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -1154,7 +1154,7 @@ void G2_TimingModel( const float endFrame = (float)bone.endFrame; // we are supposed to be animating right? - if ( numFramesInAnim > 0 ) + if ( numFramesInAnim != 0 ) { // did we run off the end? if ( (animSpeed > 0.0f && newLerpFrame > (endFrame - 1)) || From 1c74892f7e7bda96504ce172b34ddc9795529302 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 16 Nov 2019 01:34:30 +0100 Subject: [PATCH 507/708] fix fog --- codemp/rd-rend2/glsl/fogpass.glsl | 25 +++++++++---------------- codemp/rd-rend2/tr_shade.cpp | 3 ++- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 37541a9ab1..e8f419f78d 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -231,6 +231,8 @@ out vec4 out_Glow; float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane) { + bool inFog = dot(viewOrigin, fogPlane.xyz) - fogPlane.w >= 0.0 || !hasPlane; + // line: x = o + tv // plane: (x . n) + d = 0 // intersects: dot(o + tv, n) + d = 0 @@ -242,22 +244,13 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d // fogPlane is inverted in tr_bsp for some reason. float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz); - bool inFog = ((dot(viewOrigin, fogPlane.xyz) - fogPlane.w) >= 0.0) || !hasPlane; - bool intersects = (t > 0.0 && t <= 1.0); - - // this is valid only when t > 0.0. When t < 0.0, then intersection point is behind - // the camera, meaning we're facing away from the fog plane, which probably means - // we're inside the fog volume. - vec3 intersectsAt = viewOrigin + t*V; - - float distToVertexFromIntersection = distance(intersectsAt, position); - float distToVertexFromViewOrigin = distance(viewOrigin, position); + float distToVertexFromViewOrigin = length(V); + float distToIntersectionFromViewOrigin = max(t, 0.0) * distToVertexFromViewOrigin; - float distToVertex = mix(distToVertexFromViewOrigin, - distToVertexFromIntersection, - !inFog && intersects); + float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); + float distThroughFog = mix(distToVertexFromViewOrigin, distOutsideFog, !inFog); - float z = depthToOpaque * distToVertex; + float z = depthToOpaque * distThroughFog; return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } @@ -265,7 +258,7 @@ void main() { float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane); out_Color.rgb = u_Color.rgb; - out_Color.a = sqrt(clamp(fog, 0.0, 1.0)); + out_Color.a = fog; #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) @@ -293,6 +286,6 @@ void main() #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; #else - out_Glow = vec4(0.0); + out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); #endif } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index a73bcc5781..6c3df737ca 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1218,7 +1218,8 @@ static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexA uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); - uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); + qboolean hasPlane = fog == tr.world->globalFog ? qfalse : fog->hasSurface; + uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, hasPlane); uniformDataWriter.SetUniformFloat( UNIFORM_FOGDEPTHTOOPAQUE, sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque); From ae8b884c83f7a8d14ef26299df5dcd1c0d945782 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 16 Nov 2019 04:12:50 +0100 Subject: [PATCH 508/708] fix global fog without sky --- codemp/rd-rend2/tr_backend.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 98b6ef0f70..6a5eff401a 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -556,6 +556,17 @@ void RB_BeginDrawingView (void) { #endif } + if (tr.refdef.rdflags & RDF_AUTOMAP || (!(backEnd.refdef.rdflags & RDF_NOWORLDMODEL))) + { + if (tr.world && tr.world->globalFog) + { + const fog_t *fog = tr.world->globalFog; + + clearBits |= GL_COLOR_BUFFER_BIT; + qglClearColor(fog->parms.color[0], fog->parms.color[1], fog->parms.color[2], 1.0f); + } + } + // clear to white for shadow maps if (backEnd.viewParms.flags & VPF_SHADOWMAP) { From 3f98c245d60cebe2f64574f378e1a7cb599c94e3 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 16 Nov 2019 04:34:41 +0100 Subject: [PATCH 509/708] also allow vertex colored surfaces to use shaders + some cleanup --- codemp/rd-rend2/tr_shader.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index cf0e948e6c..b73a55ec02 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1326,7 +1326,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!stage->bundle[TB_NORMALMAP].image[0]) { - ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find normalMap '%s' in shader '%s'\n", token, shader.name); return qfalse; } @@ -1346,6 +1346,12 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } + if (!Q_stricmp(token, "$whiteimage")) + { + stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; + continue; + } + int flags = IMGFLAG_NONE; if (!shader.noMipMaps) @@ -1363,7 +1369,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!stage->bundle[TB_SPECULARMAP].image[0]) { - ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name); + ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find specMap '%s' in shader '%s'\n", token, shader.name); return qfalse; } @@ -3251,7 +3257,7 @@ static qboolean CollapseStagesToGLSL(void) } vertexlit = qfalse; - if (diffuse->rgbGen == CGEN_VERTEX_LIT || diffuse->rgbGen == CGEN_EXACT_VERTEX_LIT) + if (diffuse->rgbGen == CGEN_VERTEX_LIT || diffuse->rgbGen == CGEN_EXACT_VERTEX_LIT || diffuse->rgbGen == CGEN_VERTEX || diffuse->rgbGen == CGEN_EXACT_VERTEX) { vertexlit = qtrue; } From 89b3ec392fbe686e37f705d7aa20bab6d47e8df5 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 1 Dec 2019 20:41:02 +0100 Subject: [PATCH 510/708] fix fileSize of .glsl shader files See https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486 for more information. --- codemp/rd-rend2/glsl/compact.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index cc03baa1ff..d3f4e6c8b3 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -1,3 +1,5 @@ +#define NOMINMAX + #include #include #include @@ -144,9 +146,10 @@ int main( int argc, char *argv[] ) continue; } - std::streampos fileSize; - fs.seekg(0, std::ios::end); - fileSize = fs.tellg(); + //from: https://stackoverflow.com/questions/22984956/tellg-function-give-wrong-size-of-file/22986486 + fs.ignore(std::numeric_limits::max()); + std::streamsize fileSize = fs.gcount(); + fs.clear(); // Since ignore will have set eof. fs.seekg(0, std::ios::beg); allocator.Reset(); From ce06d8911a2d45b3d16dc8271991437adeffd6b1 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 5 Apr 2020 22:36:26 +0200 Subject: [PATCH 511/708] Fix force speed. The vanilla renderer forces the alpha value for entities with RF_FORCE_ENT_ALPHA. Since the evaulation is vertColor * attr_Color + baseColor we can force the alpha with setting vertColor 0.0 and the baseColor to the value we want to force for the whole model. --- codemp/rd-rend2/tr_shade.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 6c3df737ca..24e27b558a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1548,7 +1548,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA) { - vertColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; + baseColor[3] = backEnd.currentEntity->e.shaderRGBA[3] / 255.0f; + vertColor[3] = 0.0f; } uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); From f7f9a4e0a1e3a566a038fc4f04c5f91da38b3792 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 6 Apr 2020 11:51:31 +0200 Subject: [PATCH 512/708] Speedup vertex bone skinning --- codemp/rd-rend2/glsl/fogpass.glsl | 30 ++++++--------------- codemp/rd-rend2/glsl/generic.glsl | 30 ++++++--------------- codemp/rd-rend2/glsl/lightall.glsl | 43 ++++++++---------------------- 3 files changed, 27 insertions(+), 76 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index e8f419f78d..0f36b36df0 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -177,28 +177,14 @@ void main() vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) - vec4 position4 = vec4(0.0); - vec4 normal4 = vec4(0.0); - vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); - - for (int i = 0; i < 4; i++) - { - uint boneIndex = attr_BoneIndexes[i]; - - mat4 boneMatrix = mat4( - vec4(u_BoneMatrices[boneIndex][0], 0.0), - vec4(u_BoneMatrices[boneIndex][1], 0.0), - vec4(u_BoneMatrices[boneIndex][2], 0.0), - vec4(u_BoneMatrices[boneIndex][3], 1.0) - ); - - position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; - normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; - } - - vec3 position = position4.xyz; - vec3 normal = normalize(normal4.xyz); + mat4x3 influence = + u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + + u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + + u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + + u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + + vec3 position = influence * vec4(attr_Position, 1.0); + vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); #else vec3 position = attr_Position; vec3 normal = attr_Normal * 2.0 - vec3(1.0); diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 7c7748f47b..988c68bf45 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -338,28 +338,14 @@ void main() vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) - vec4 position4 = vec4(0.0); - vec4 normal4 = vec4(0.0); - vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); - - for (int i = 0; i < 4; i++) - { - uint boneIndex = attr_BoneIndexes[i]; - - mat4 boneMatrix = mat4( - vec4(u_BoneMatrices[boneIndex][0], 0.0), - vec4(u_BoneMatrices[boneIndex][1], 0.0), - vec4(u_BoneMatrices[boneIndex][2], 0.0), - vec4(u_BoneMatrices[boneIndex][3], 1.0) - ); - - position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; - normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; - } - - vec3 position = position4.xyz; - vec3 normal = normalize(normal4.xyz); + mat4x3 influence = + u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + + u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + + u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + + u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + + vec3 position = influence * vec4(attr_Position, 1.0); + vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); #else vec3 position = attr_Position; vec3 normal = attr_Normal * 2.0 - vec3(1.0); diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 2cee5c599a..f854019b55 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -211,38 +211,17 @@ void main() vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); #elif defined(USE_SKELETAL_ANIMATION) - vec4 position4 = vec4(0.0); - vec4 normal4 = vec4(0.0); - vec4 originalPosition = vec4(attr_Position, 1.0); - vec4 originalNormal = vec4(attr_Normal - vec3 (0.5), 0.0); -#if defined(PER_PIXEL_LIGHTING) - vec4 tangent4 = vec4(0.0); - vec4 originalTangent = vec4(attr_Tangent.xyz - vec3(0.5), 0.0); -#endif - - for (int i = 0; i < 4; i++) - { - uint boneIndex = attr_BoneIndexes[i]; - - mat4 boneMatrix = mat4( - vec4(u_BoneMatrices[boneIndex][0], 0.0), - vec4(u_BoneMatrices[boneIndex][1], 0.0), - vec4(u_BoneMatrices[boneIndex][2], 0.0), - vec4(u_BoneMatrices[boneIndex][3], 1.0) - ); - - position4 += (boneMatrix * originalPosition) * attr_BoneWeights[i]; - normal4 += (boneMatrix * originalNormal) * attr_BoneWeights[i]; -#if defined(PER_PIXEL_LIGHTING) - tangent4 += (boneMatrix * originalTangent) * attr_BoneWeights[i]; -#endif - } - - vec3 position = position4.xyz; - vec3 normal = normalize (normal4.xyz); -#if defined(PER_PIXEL_LIGHTING) - vec3 tangent = normalize (tangent4.xyz); -#endif + mat4x3 influence = + u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + + u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + + u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + + u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + + vec3 position = influence * vec4(attr_Position, 1.0); + vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); + #if defined(PER_PIXEL_LIGHTING) + vec3 tangent = normalize(influence * vec4(attr_Tangent.xyz - vec3(0.5), 0.0)); + #endif #else vec3 position = attr_Position; vec3 normal = attr_Normal; From fc3b8621398b3b14c5d283eb5c905d086e197b58 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 6 Apr 2020 14:01:54 +0200 Subject: [PATCH 513/708] Add cg_shadows 2 --- codemp/rd-rend2/glsl/shadowvolume.glsl | 97 ++++++++ codemp/rd-rend2/qgl.h | 3 + codemp/rd-rend2/tr_backend.cpp | 38 +++- codemp/rd-rend2/tr_extensions.cpp | 5 + codemp/rd-rend2/tr_fbo.cpp | 9 +- codemp/rd-rend2/tr_ghoul2.cpp | 15 ++ codemp/rd-rend2/tr_glsl.cpp | 28 +++ codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 4 + codemp/rd-rend2/tr_local.h | 25 +-- codemp/rd-rend2/tr_shade.cpp | 9 +- codemp/rd-rend2/tr_shadows.cpp | 300 ++++++------------------- 12 files changed, 281 insertions(+), 254 deletions(-) create mode 100644 codemp/rd-rend2/glsl/shadowvolume.glsl diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl new file mode 100644 index 0000000000..536314d95b --- /dev/null +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -0,0 +1,97 @@ +/*[Vertex]*/ +in vec3 attr_Position; +#if defined(USE_VERTEX_ANIMATION) +in vec3 attr_Position2; +#elif defined(USE_SKELETAL_ANIMATION) +in uvec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; +#endif + +uniform mat4 u_ModelViewProjectionMatrix; + +#if defined(USE_VERTEX_ANIMATION) +uniform float u_VertexLerp; +#elif defined(USE_SKELETAL_ANIMATION) +uniform mat4x3 u_BoneMatrices[20]; +#endif + +out vec3 var_Position; + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); +#elif defined(USE_SKELETAL_ANIMATION) + mat4x3 influence = + u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + + u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + + u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + + u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + + vec3 position = influence * vec4(attr_Position, 1.0); +#else + vec3 position = attr_Position; +#endif + var_Position = position; +} + +/*[Geometry]*/ +layout(triangles) in; +layout(triangle_strip, max_vertices = 18) out; + +uniform mat4 u_ModelViewProjectionMatrix; +uniform vec4 u_LightOrigin; // modelspace lightvector and length +in vec3 var_Position[]; + +void quad(vec3 first, vec3 second, vec3 L) +{ + gl_Position = u_ModelViewProjectionMatrix * vec4(first, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(first - L, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(second, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(second - L, 1.0); + EmitVertex(); + EndPrimitive(); +} + +void main() +{ + vec3 BmA = var_Position[1].xyz - var_Position[0].xyz; + vec3 CmA = var_Position[2].xyz - var_Position[0].xyz; + + if (dot(cross(BmA,CmA), -u_LightOrigin.xyz) > 0.0) { + vec3 L = u_LightOrigin.xyz*u_LightOrigin.w; + + // front cap + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[0].xyz, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[1].xyz, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[2].xyz, 1.0); + EmitVertex(); + EndPrimitive(); + + // sides + quad(var_Position[0], var_Position[1], L); + quad(var_Position[1], var_Position[2], L); + quad(var_Position[2], var_Position[0], L); + + // back cap + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[2].xyz - L, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[1].xyz - L, 1.0); + EmitVertex(); + gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[0].xyz - L, 1.0); + EmitVertex(); + EndPrimitive(); + } +} + +/*[Fragment]*/ +out vec4 out_Color; +void main() +{ + out_Color = vec4(0.0, 0.0, 0.0, 1.0); +} \ No newline at end of file diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 288f257aa6..844b94c6fc 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -361,6 +361,9 @@ #define qglVertexPointer glVertexPointer #define qglViewport glViewport +// Stencil commands +extern PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate; + // Drawing commands extern PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; extern PFNGLDRAWARRAYSINSTANCEDPROC qglDrawArraysInstanced; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 6a5eff401a..3d6fa91b6b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -177,10 +177,14 @@ void GL_State( uint32_t stateBits ) { qglDepthFunc( GL_EQUAL ); } - else if ( stateBits & GLS_DEPTHFUNC_GREATER) + else if ( stateBits & GLS_DEPTHFUNC_GREATER ) { qglDepthFunc( GL_GREATER ); } + else if ( stateBits & GLS_DEPTHFUNC_LESS ) + { + qglDepthFunc( GL_LESS ); + } else { qglDepthFunc( GL_LEQUAL ); @@ -270,6 +274,36 @@ void GL_State( uint32_t stateBits ) } } + // + // check colormask + // + if ( diff & GLS_COLORMASK_BITS ) + { + if ( stateBits & GLS_COLORMASK_BITS ) + { + qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + } + else + { + qglColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); + } + } + + // + // check stenciltest + // + if (diff & GLS_STENCILTEST_ENABLE) + { + if (stateBits & GLS_STENCILTEST_ENABLE) + { + qglEnable(GL_STENCIL_TEST); + } + else + { + qglDisable(GL_STENCIL_TEST); + } + } + // // check depthmask // @@ -2153,7 +2187,7 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) } // darken down any stencil shadows - RB_ShadowFinish(); + RB_ShadowFinish(); } static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSurfs ) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index bc962f60af..dd425c7603 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -25,6 +25,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define GL_GetProcAddress ri.GL_GetProcAddress +// Stencil commands +PFNGLSTENCILOPSEPARATEPROC qglStencilOpSeparate; + // Drawing commands PFNGLDRAWRANGEELEMENTSPROC qglDrawRangeElements; PFNGLDRAWARRAYSINSTANCEDPROC qglDrawArraysInstanced; @@ -477,6 +480,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglGenerateMipmap, "glGenerateMipmap", qtrue); GetGLFunction (qglDrawBuffers, "glDrawBuffers", qtrue); GetGLFunction (qglClearBufferfv, "glClearBufferfv", qtrue); + GetGLFunction (qglStencilOpSeparate, "glStencilOpSeparate", qtrue); // Queries GetGLFunction (qglGenQueries, "glGenQueries", qtrue); @@ -496,6 +500,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglDeleteSync, "glDeleteSync", qtrue); GetGLFunction (qglClientWaitSync, "glClientWaitSync", qtrue); GetGLFunction (qglWaitSync, "glWaitSync", qtrue); + } void GLW_InitTextureCompression( void ); diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 733c573139..b641945903 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -286,8 +286,7 @@ R_AttachFBOTexturePackedDepthStencil */ void R_AttachFBOTexturePackedDepthStencil(int texId) { - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, texId, 0); - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, 0); + qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, texId, 0); } void FBO_AttachTextureImage(image_t *img, int index) @@ -427,7 +426,7 @@ void FBO_Init(void) FBO_Bind(tr.renderFbo); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 0, multisample); FBO_CreateBuffer(tr.renderFbo, hdrFormat, 1, multisample); - FBO_CreateBuffer(tr.renderFbo, GL_DEPTH_COMPONENT24, 0, multisample); + FBO_CreateBuffer(tr.renderFbo, GL_DEPTH24_STENCIL8, 0, multisample); FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderFbo); @@ -439,7 +438,7 @@ void FBO_Init(void) FBO_Bind(tr.msaaResolveFbo); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + R_AttachFBOTexturePackedDepthStencil(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); R_CheckFBO(tr.msaaResolveFbo); @@ -453,7 +452,7 @@ void FBO_Init(void) FBO_Bind(tr.renderFbo); FBO_AttachTextureImage(tr.renderImage, 0); FBO_AttachTextureImage(tr.glowImage, 1); - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); + R_AttachFBOTexturePackedDepthStencil(tr.renderDepthImage->texnum); FBO_SetupDrawBuffers(); R_CheckFBO(tr.renderFbo); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index db75b5b56e..71da292ad2 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2490,6 +2490,21 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum #endif } + // stencil shadows can't do personal models unless I polyhedron clip + if (!RS.personalModel + && r_shadows->integer == 2 + && RS.fogNum == 0 + && (RS.renderfx & (RF_NOSHADOW | RF_DEPTHHACK)) + && shader->sort == SS_OPAQUE) { + + CRenderableSurface *newSurf = AllocGhoul2RenderableSurface(); + newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; + assert(newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); + newSurf->surfaceData = surface; + newSurf->boneCache = RS.boneCache; + R_AddDrawSurf((surfaceType_t *)newSurf, entityNum, tr.shadowShader, 0, qfalse, qfalse, 0); + } + // projection shadows work fine with personal models if (r_shadows->integer == 3 && RS.fogNum == 0 diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e6d948f698..82460e1b25 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1732,6 +1732,32 @@ static int GLSL_LoadGPUProgramPShadow( return 1; } +static int GLSL_LoadGPUProgramVShadow( + ShaderProgramBuilder& builder, + Allocator& scratchAlloc) +{ + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); + + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("shadowvolume", allocator, fallback_shadowvolumeProgram); + const uint32_t attribs = ATTR_POSITION | ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; + + extradefines[0] = '\0'; + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); + + if (!GLSL_LoadGPUShader(builder, &tr.volumeShadowShader, "shadowvolume", attribs, NO_XFB_VARS, + extradefines, *programDesc)) + { + ri.Error(ERR_FATAL, "Could not load shadowvolume shader!"); + } + + GLSL_InitUniforms(&tr.volumeShadowShader); + GLSL_FinishGPUShader(&tr.volumeShadowShader); + + return 1; +} + static int GLSL_LoadGPUProgramDownscale4x( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) @@ -2188,6 +2214,7 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramTextureColor(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDepthFill(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramPShadow(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramVShadow(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDownscale4x(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramBokeh(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramTonemap(builder, allocator); @@ -2236,6 +2263,7 @@ void GLSL_ShutdownGPUShaders(void) GLSL_DeleteGPUShader(&tr.shadowmapShader); GLSL_DeleteGPUShader(&tr.pshadowShader); + GLSL_DeleteGPUShader(&tr.volumeShadowShader); GLSL_DeleteGPUShader(&tr.down4xShader); GLSL_DeleteGPUShader(&tr.bokehShader); GLSL_DeleteGPUShader(&tr.tonemapShader); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 160a5bf6fb..8f955c8eec 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3252,7 +3252,7 @@ void R_CreateBuiltinImages( void ) { tr.renderDepthImage = R_CreateImage( "*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH24_STENCIL8); tr.textureDepthImage = R_CreateImage( "*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 22b0ea72cc..3232efdfe5 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1201,6 +1201,10 @@ void GL_SetDefaultState( void ) qglDisable( GL_BLEND ); qglEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); + + qglStencilFunc(GL_ALWAYS, 0, 0xff); + qglStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP); + qglStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_KEEP); } /* diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9933fd327f..8bda746e0f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2289,6 +2289,7 @@ typedef struct trGlobals_s { shaderProgram_t lightallShader[LIGHTDEF_COUNT]; shaderProgram_t shadowmapShader; shaderProgram_t pshadowShader; + shaderProgram_t volumeShadowShader; shaderProgram_t down4xShader; shaderProgram_t bokehShader; shaderProgram_t tonemapShader; @@ -2879,19 +2880,6 @@ int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, ve int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); int R_CubemapForPoint( const vec3_t point ); - -/* -============================================================ - -SHADOWS - -============================================================ -*/ - -void RB_ShadowTessEnd( void ); -void RB_ShadowFinish( void ); -void RB_ProjectionShadowDeform( void ); - /* ============================================================ @@ -2980,6 +2968,17 @@ void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data); void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); +/* +============================================================ + +SHADOWS + +============================================================ +*/ + +void RB_ShadowTessEnd(shaderCommands_t *input, const VertexArraysProperties *vertexArrays); +void RB_ShadowFinish(void); +void RB_ProjectionShadowDeform(void); /* ============================================================ diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 24e27b558a..d328203e29 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1901,6 +1901,10 @@ void RB_StageIteratorGeneric( void ) RB_RenderShadowmap(input, &vertexArrays); } } + else if (input->shader == tr.shadowShader && r_shadows->integer == 2) + { + RB_ShadowTessEnd( input, &vertexArrays ); + } else { RB_IterateStagesGeneric( input, &vertexArrays ); @@ -1988,11 +1992,6 @@ void RB_EndSurface( void ) { ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit"); } - if ( tess.shader == tr.shadowShader ) { - RB_ShadowTessEnd(); - return; - } - // for debugging of sort order issues, stop rendering after a given sort value if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) { return; diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 9e9d40b27c..7af9b07b32 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -21,233 +21,70 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "tr_local.h" - -/* - - for a projection shadow: - - point[x] += light vector * ( z - shadow plane ) - point[y] += - point[z] = shadow plane - - 1 0 light[x] / light[z] - -*/ - -typedef struct { - int i2; - int facing; -} edgeDef_t; - -#define MAX_EDGE_DEFS 32 - -static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS]; -static int numEdgeDefs[SHADER_MAX_VERTEXES]; -static int facing[SHADER_MAX_INDEXES/3]; - -void R_AddEdgeDef( int i1, int i2, int facing ) { - int c; - - c = numEdgeDefs[ i1 ]; - if ( c == MAX_EDGE_DEFS ) { - return; // overflow - } - edgeDefs[ i1 ][ c ].i2 = i2; - edgeDefs[ i1 ][ c ].facing = facing; - - numEdgeDefs[ i1 ]++; -} - -void R_RenderShadowEdges( void ) { -#if 0 - int i; - int numTris; - - // dumb way -- render every triangle's edges - numTris = tess.numIndexes / 3; - - for ( i = 0 ; i < numTris ; i++ ) { - int i1, i2, i3; - - if ( !facing[i] ) { - continue; - } - - i1 = tess.indexes[ i*3 + 0 ]; - i2 = tess.indexes[ i*3 + 1 ]; - i3 = tess.indexes[ i*3 + 2 ]; - - qglBegin( GL_TRIANGLE_STRIP ); - qglVertex3fv( tess.xyz[ i1 ] ); - qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); - qglVertex3fv( tess.xyz[ i2 ] ); - qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] ); - qglVertex3fv( tess.xyz[ i3 ] ); - qglVertex3fv( tess.xyz[ i3 + tess.numVertexes ] ); - qglVertex3fv( tess.xyz[ i1 ] ); - qglVertex3fv( tess.xyz[ i1 + tess.numVertexes ] ); - qglEnd(); - } -#else -#if 0 - int c, c2; - int j, k; - int i2; - int c_edges, c_rejected; - int hit[2]; - - // an edge is NOT a silhouette edge if its face doesn't face the light, - // or if it has a reverse paired edge that also faces the light. - // A well behaved polyhedron would have exactly two faces for each edge, - // but lots of models have dangling edges or overfanned edges - c_edges = 0; - c_rejected = 0; - - for ( i = 0 ; i < tess.numVertexes ; i++ ) { - c = numEdgeDefs[ i ]; - for ( j = 0 ; j < c ; j++ ) { - if ( !edgeDefs[ i ][ j ].facing ) { - continue; - } - - hit[0] = 0; - hit[1] = 0; - - i2 = edgeDefs[ i ][ j ].i2; - c2 = numEdgeDefs[ i2 ]; - for ( k = 0 ; k < c2 ; k++ ) { - if ( edgeDefs[ i2 ][ k ].i2 == i ) { - hit[ edgeDefs[ i2 ][ k ].facing ]++; - } - } - - // if it doesn't share the edge with another front facing - // triangle, it is a sil edge - if ( hit[ 1 ] == 0 ) { - qglBegin( GL_TRIANGLE_STRIP ); - qglVertex3fv( tess.xyz[ i ] ); - qglVertex3fv( tess.xyz[ i + tess.numVertexes ] ); - qglVertex3fv( tess.xyz[ i2 ] ); - qglVertex3fv( tess.xyz[ i2 + tess.numVertexes ] ); - qglEnd(); - c_edges++; - } else { - c_rejected++; - } - } - } -#endif -#endif -} - /* ================= RB_ShadowTessEnd -triangleFromEdge[ v1 ][ v2 ] - - - set triangle from edge( v1, v2, tri ) - if ( facing[ triangleFromEdge[ v1 ][ v2 ] ] && !facing[ triangleFromEdge[ v2 ][ v1 ] ) { - } ================= */ -void RB_ShadowTessEnd( void ) { +void RB_ShadowTessEnd( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int i; int numTris; - vec3_t lightDir; GLboolean rgba[4]; - // we can only do this if we have enough space in the vertex buffers - if ( tess.numVertexes >= SHADER_MAX_VERTEXES / 2 ) { + if (glConfig.stencilBits < 4) { + ri.Printf(PRINT_ALL, "no stencil bits for stencil writing\n"); return; } - if ( glConfig.stencilBits < 4 ) { + if (!input->numVertexes || !input->numIndexes || input->useInternalVBO) + { return; } - VectorCopy( backEnd.currentEntity->lightDir, lightDir ); - - // project vertexes away from light direction - for ( i = 0 ; i < tess.numVertexes ; i++ ) { - VectorMA( tess.xyz[i], -512, lightDir, tess.xyz[i+tess.numVertexes] ); + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); + + cullType_t cullType = CT_TWO_SIDED; + UniformDataWriter uniformDataWriter; + int stateBits = GLS_DEPTHFUNC_LESS | GLS_STENCILTEST_ENABLE | GLS_COLORMASK_BITS; + + uniformDataWriter.Start(&tr.volumeShadowShader); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); + + vec4_t lightDir; + VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); + lightDir[3] = 300.0f; + if (r_shadows->integer == 2) + { + lightDir[2] = 0.0f; + VectorNormalize(lightDir); + VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); + lightDir[3] = backEnd.currentEntity->e.lightingOrigin[2] - backEnd.currentEntity->e.shadowPlane + 64.0f; } + uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, lightDir); - // decide which triangles face the light - Com_Memset( numEdgeDefs, 0, 4 * tess.numVertexes ); - - numTris = tess.numIndexes / 3; - for ( i = 0 ; i < numTris ; i++ ) { - int i1, i2, i3; - vec3_t d1, d2, normal; - float *v1, *v2, *v3; - float d; - - i1 = tess.indexes[ i*3 + 0 ]; - i2 = tess.indexes[ i*3 + 1 ]; - i3 = tess.indexes[ i*3 + 2 ]; - - v1 = tess.xyz[ i1 ]; - v2 = tess.xyz[ i2 ]; - v3 = tess.xyz[ i3 ]; - - VectorSubtract( v2, v1, d1 ); - VectorSubtract( v3, v1, d2 ); - CrossProduct( d1, d2, normal ); - - d = DotProduct( normal, lightDir ); - if ( d > 0 ) { - facing[ i ] = 1; - } else { - facing[ i ] = 0; - } - - // create the edges - R_AddEdgeDef( i1, i2, facing[ i ] ); - R_AddEdgeDef( i2, i3, facing[ i ] ); - R_AddEdgeDef( i3, i1, facing[ i ] ); - } - - // draw the silhouette edges - - GL_Bind( tr.whiteImage ); - qglEnable( GL_CULL_FACE ); - GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + DrawItem item = {}; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + DepthRange range = { 0.0f, 1.0f }; + item.renderState.depthRange = range; + item.program = &tr.volumeShadowShader; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; - // don't write to the color buffer - qglGetBooleanv(GL_COLOR_WRITEMASK, rgba); - qglColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); + item.numAttributes = vertexArrays->numVertexArrays; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, vertexArrays->numVertexArrays); + memcpy(item.attributes, attribs, sizeof(*item.attributes)* vertexArrays->numVertexArrays); - qglEnable( GL_STENCIL_TEST ); - qglStencilFunc( GL_ALWAYS, 1, 255 ); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - // mirrors have the culling order reversed - if ( backEnd.viewParms.isMirror ) { - qglCullFace( GL_FRONT ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - R_RenderShadowEdges(); - - qglCullFace( GL_BACK ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); - - R_RenderShadowEdges(); - } else { - qglCullFace( GL_BACK ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_INCR ); - - R_RenderShadowEdges(); - - qglCullFace( GL_FRONT ); - qglStencilOp( GL_KEEP, GL_KEEP, GL_DECR ); - - R_RenderShadowEdges(); - } - - - // reenable writing to the color buffer - qglColorMask(rgba[0], rgba[1], rgba[2], rgba[3]); + uint32_t key = RB_CreateSortKey(item, 15, 15); + RB_AddDrawItem(backEndData->currentPass, key, item); } @@ -261,39 +98,46 @@ because otherwise shadows from different body parts would overlap and double darken. ================= */ -void RB_ShadowFinish( void ) { -#if 0 - if ( r_shadows->integer != 2 ) { +void RB_ShadowFinish(void) { + if (r_shadows->integer != 2) { return; } - if ( glConfig.stencilBits < 4 ) { + if (glConfig.stencilBits < 4) { return; } - qglEnable( GL_STENCIL_TEST ); - qglStencilFunc( GL_NOTEQUAL, 0, 255 ); - qglDisable (GL_CULL_FACE); + GL_Cull(CT_TWO_SIDED); + + GL_BindToTMU(tr.whiteImage, TB_COLORMAP); + + GL_State(GLS_STENCILTEST_ENABLE | GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO); - GL_Bind( tr.whiteImage ); + qglStencilFunc(GL_NOTEQUAL, 0, 0xff); + qglViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight); + qglScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight); + matrix_t projection; + Matrix16Ortho(0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, projection); - qglLoadIdentity (); + GL_Cull(CT_TWO_SIDED); + GLSL_BindProgram(&tr.textureColorShader); + vec4_t color; + VectorSet4(color, 0.6f, 0.6f, 0.6f, 1.0f); + GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color); + GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); - qglColor3f( 0.6f, 0.6f, 0.6f ); - GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO ); + vec4i_t dstBox, srcBox; + vec4_t quadVerts[4]; + vec2_t texCoords[4]; + VectorSet4(dstBox, 0, glConfig.vidHeight, glConfig.vidWidth, 0); -// qglColor3f( 1, 0, 0 ); -// GL_State( GLS_DEPTHMASK_TRUE | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ZERO ); + VectorSet4(quadVerts[0], dstBox[0], dstBox[1], 0, 1); + VectorSet4(quadVerts[1], dstBox[2], dstBox[1], 0, 1); + VectorSet4(quadVerts[2], dstBox[2], dstBox[3], 0, 1); + VectorSet4(quadVerts[3], dstBox[0], dstBox[3], 0, 1); - qglBegin( GL_QUADS ); - qglVertex3f( -100, 100, -10 ); - qglVertex3f( 100, 100, -10 ); - qglVertex3f( 100, -100, -10 ); - qglVertex3f( -100, -100, -10 ); - qglEnd (); + RB_InstantQuad2(quadVerts, texCoords); - qglColor4f(1,1,1,1); - qglDisable( GL_STENCIL_TEST ); -#endif + qglStencilFunc(GL_ALWAYS, 0, 0xff); } @@ -321,7 +165,7 @@ void RB_ProjectionShadowDeform( void ) { groundDist = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; - VectorCopy( backEnd.currentEntity->lightDir, lightDir ); + VectorCopy( backEnd.currentEntity->modelLightDir, lightDir ); d = DotProduct( lightDir, ground ); // don't let the shadows get too long or go negative if ( d < 0.5 ) { From 91266fba7883914849cf4f65e3f047eb5509b89d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 11 Apr 2020 19:28:32 +0200 Subject: [PATCH 514/708] Requested Changes --- codemp/rd-rend2/CMakeLists.txt | 2 +- codemp/rd-rend2/glsl/compact.cpp | 2 -- codemp/rd-rend2/glsl/generic.glsl | 27 ++++++++++++++------------- codemp/rd-rend2/glsl/lightall.glsl | 14 +++++++------- codemp/rd-rend2/tr_shade.cpp | 13 ++----------- codemp/rd-rend2/tr_world.cpp | 7 +++---- 6 files changed, 27 insertions(+), 38 deletions(-) diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 010c0306f7..b3e054e06e 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -178,7 +178,7 @@ add_executable(compact_glsl ${MPDir}/rd-rend2/tr_allocator.cpp ${MPDir}/rd-rend2/tr_allocator.h ${MPDir}/rd-rend2/tr_glsl_parse.cpp) -target_compile_definitions(compact_glsl PRIVATE "GLSL_BUILDTOOL") +target_compile_definitions(compact_glsl PRIVATE "GLSL_BUILDTOOL" "NOMINMAX") if (NOT WIN32 AND NOT APPLE) target_compile_definitions(compact_glsl PRIVATE "ARCH_STRING=\"${Architecture}\"") endif() diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index d3f4e6c8b3..0421af27e0 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -1,5 +1,3 @@ -#define NOMINMAX - #include #include #include diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 988c68bf45..7077ef82fa 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -176,16 +176,17 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_DISINTEGRATION: { vec3 delta = u_Disintegration.xyz - pos; - float distance = dot(delta, delta); - if ( distance < u_Disintegration.w ) + float sqrDistance = dot(delta, delta); + vec3 normalScale = vec3(-0.01); + if ( sqrDistance < u_Disintegration.w ) { - return normal * vec3(2.0, 2.0, 0.5) + pos; + normalScale = vec3(2.0, 2.0, 0.5); } - else if ( distance < u_Disintegration.w + 50 ) + else if ( sqrDistance < u_Disintegration.w + 50 ) { - return normal * vec3(1.0, 1.0, 0.0) + pos; + normalScale = vec3(1.0, 1.0, 0.0); } - return pos - normal * 0.01; + return pos + normal * normalScale; } } } @@ -281,20 +282,20 @@ vec4 CalcColor(vec3 position, vec3 normal) else if (u_ColorGen == CGEN_DISINTEGRATION_1) { vec3 delta = u_Disintegration.xyz - position; - float distance = dot(delta, delta); - if (distance < u_Disintegration.w) + float sqrDistance = dot(delta, delta); + if (sqrDistance < u_Disintegration.w) { color *= 0.0; } - else if (distance < u_Disintegration.w + 60.0) + else if (sqrDistance < u_Disintegration.w + 60.0) { color *= vec4(0.0, 0.0, 0.0, 1.0); } - else if (distance < u_Disintegration.w + 150.0) + else if (sqrDistance < u_Disintegration.w + 150.0) { color *= vec4(0.435295, 0.435295, 0.435295, 1.0); } - else if (distance < u_Disintegration.w + 180.0) + else if (sqrDistance < u_Disintegration.w + 180.0) { color *= vec4(0.6862745, 0.6862745, 0.6862745, 1.0); } @@ -303,8 +304,8 @@ vec4 CalcColor(vec3 position, vec3 normal) else if (u_ColorGen == CGEN_DISINTEGRATION_2) { vec3 delta = u_Disintegration.xyz - position; - float distance = dot(delta, delta); - if (distance < u_Disintegration.w) + float sqrDistance = dot(delta, delta); + if (sqrDistance < u_Disintegration.w) { color *= 0.0; } diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index f854019b55..bf3d06b80e 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -103,20 +103,20 @@ vec4 CalcColor(vec3 position) if (u_ColorGen == CGEN_DISINTEGRATION_1) { vec3 delta = u_Disintegration.xyz - position; - float distance = dot(delta, delta); - if (distance < u_Disintegration.w) + float sqrDistance = dot(delta, delta); + if (sqrDistance < u_Disintegration.w) { color = vec4(0.0); } - else if (distance < u_Disintegration.w + 60.0) + else if (sqrDistance < u_Disintegration.w + 60.0) { color = vec4(0.0, 0.0, 0.0, 1.0); } - else if (distance < u_Disintegration.w + 150.0) + else if (sqrDistance < u_Disintegration.w + 150.0) { color = vec4(0.435295, 0.435295, 0.435295, 1.0); } - else if (distance < u_Disintegration.w + 180.0) + else if (sqrDistance < u_Disintegration.w + 180.0) { color = vec4(0.6862745, 0.6862745, 0.6862745, 1.0); } @@ -125,8 +125,8 @@ vec4 CalcColor(vec3 position) else if (u_ColorGen == CGEN_DISINTEGRATION_2) { vec3 delta = u_Disintegration.xyz - position; - float distance = dot(delta, delta); - if (distance < u_Disintegration.w) + float sqrDistance = dot(delta, delta); + if (sqrDistance < u_Disintegration.w) { color = vec4(0.0); } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index d328203e29..8cb1e214a6 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1507,10 +1507,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); } - if ( disintegrationInfo != NULL ) - { - uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); - } + uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); if ( input->fogNum ) { const fog_t *fog = tr.world->fogs + input->fogNum; @@ -1771,13 +1768,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - uint32_t key = 0; - if ((backEnd.currentEntity->e.renderfx & RF_DISTORTION) || - (backEnd.currentEntity->e.renderfx & RF_FORCEPOST) || - (backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA)) - key = RB_CreateSortKey(item, 15, input->shader->sort); - else - key = RB_CreateSortKey(item, stage, input->shader->sort); + uint32_t key = RB_CreateSortKey(item, stage, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 9b071392f6..ab508eba90 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -352,10 +352,9 @@ static void R_AddWorldSurface( dlightBits = ( dlightBits != 0 ); } - // check for pshadows - if ( pshadowBits ) { - pshadowBits = R_PshadowSurface( surf, pshadowBits); - pshadowBits = ( pshadowBits != 0 ); + // set pshadows + if ( pshadowBits && r_shadows->integer == 4 ) { + R_PshadowSurface( surf, pshadowBits ); } bool isPostRenderEntity = false; From a21cd41a94aac96d1ac1702a0223c5fedaeaa6d1 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 12 Apr 2020 01:04:15 +0200 Subject: [PATCH 515/708] Dont multiply by 0.0 --- codemp/rd-rend2/glsl/generic.glsl | 2 +- codemp/rd-rend2/glsl/lightall.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 7077ef82fa..8c7b0aa4df 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -307,7 +307,7 @@ vec4 CalcColor(vec3 position, vec3 normal) float sqrDistance = dot(delta, delta); if (sqrDistance < u_Disintegration.w) { - color *= 0.0; + return vec4(0.0); } return color; } diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index bf3d06b80e..33d23121a4 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -128,7 +128,7 @@ vec4 CalcColor(vec3 position) float sqrDistance = dot(delta, delta); if (sqrDistance < u_Disintegration.w) { - color = vec4(0.0); + return vec4(0.0); } return color; } From 0f2d82df9512c505fc4a28fad08416de8113769a Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 14 Apr 2020 14:59:09 +0200 Subject: [PATCH 516/708] Update InstallConfig.cmake see https://github.com/JACoders/OpenJK/commit/8367be079cfb8a288152fb093b651cc2c6a56109 --- CMakeModules/InstallConfig.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeModules/InstallConfig.cmake b/CMakeModules/InstallConfig.cmake index 8e0094a6e9..0a0c909b5d 100644 --- a/CMakeModules/InstallConfig.cmake +++ b/CMakeModules/InstallConfig.cmake @@ -67,7 +67,6 @@ cpack_add_component_group(JK2SP DESCRIPTION "Jedi Outcast single player game") if(WIN32) - include(CPackNSIS) set(CPACK_NSIS_DISPLAY_NAME "OpenJK") set(CPACK_NSIS_PACKAGE_NAME "OpenJK") set(CPACK_NSIS_MUI_ICON "${SharedDir}/icons/icon.ico") From 7af8d61cd11e85d4c6d5751c0fd10d458a64dee1 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 14 Apr 2020 15:05:27 +0200 Subject: [PATCH 517/708] Fix new compilation warnings --- codemp/rd-rend2/tr_shadows.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 7af9b07b32..7769b19bd9 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -28,10 +28,6 @@ RB_ShadowTessEnd ================= */ void RB_ShadowTessEnd( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - int i; - int numTris; - GLboolean rgba[4]; - if (glConfig.stencilBits < 4) { ri.Printf(PRINT_ALL, "no stencil bits for stencil writing\n"); return; @@ -125,7 +121,7 @@ void RB_ShadowFinish(void) { GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, color); GLSL_SetUniformMatrix4x4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection); - vec4i_t dstBox, srcBox; + vec4i_t dstBox; vec4_t quadVerts[4]; vec2_t texCoords[4]; VectorSet4(dstBox, 0, glConfig.vidHeight, glConfig.vidWidth, 0); From 216f7a8c15c84cffc844094d53ab39cf7ec313cc Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 19 Apr 2020 13:54:15 +0200 Subject: [PATCH 518/708] Use driver-specified uniform block offset alignment see https://github.com/xycaleth/OpenJK/commit/cbf0a1620af667eb9311e66d5543a268ff1c0b58 --- codemp/rd-rend2/tr_extensions.cpp | 1 + codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_vbo.cpp | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index dd425c7603..523bdcb151 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -326,6 +326,7 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglIsVertexArray, "glIsVertexArray", qtrue); // Buffer objects + qglGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &glRefConfig.uniformBufferOffsetAlignment); GetGLFunction (qglBindBuffer, "glBindBuffer", qtrue); GetGLFunction (qglDeleteBuffers, "glDeleteBuffers", qtrue); GetGLFunction (qglGenBuffers, "glGenBuffers", qtrue); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8bda746e0f..2dbe35ff4e 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2083,6 +2083,7 @@ typedef struct { int maxColorAttachments; int textureCompression; + int uniformBufferOffsetAlignment; qboolean immutableTextures; qboolean immutableBuffers; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index cb26627bd3..a4f78e275a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -659,8 +659,8 @@ void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data) qglBufferSubData(GL_UNIFORM_BUFFER, thisFrame->uboWriteOffset, blockInfo->size, data); - // FIXME: Use actual ubo alignment - const size_t alignedBlockSize = (blockInfo->size + 255) & ~255; + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + const size_t alignedBlockSize = (blockInfo->size + alignment) & ~alignment; thisFrame->uboWriteOffset += alignedBlockSize; } From c10ea78b20a60b2ff1d4a8b3e1c0c752c7049f8c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 20 Apr 2020 18:27:44 +0200 Subject: [PATCH 519/708] Rework of Uniforms based on: https://github.com/xycaleth/OpenJK/tree/rend2-dev/shader-constants --- codemp/rd-rend2/glsl/dlight.glsl | 93 ++-- codemp/rd-rend2/glsl/fogpass.glsl | 164 ++++--- codemp/rd-rend2/glsl/generic.glsl | 227 +++++---- codemp/rd-rend2/glsl/lightall.glsl | 177 ++++--- codemp/rd-rend2/glsl/shadowfill.glsl | 76 +-- codemp/rd-rend2/glsl/surface_sprites.glsl | 10 +- codemp/rd-rend2/tr_backend.cpp | 550 ++++++++++++++++++++-- codemp/rd-rend2/tr_extensions.cpp | 2 + codemp/rd-rend2/tr_extramath.h | 1 + codemp/rd-rend2/tr_ghoul2.cpp | 45 +- codemp/rd-rend2/tr_glsl.cpp | 135 ++++-- codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 34 +- codemp/rd-rend2/tr_local.h | 189 +++++++- codemp/rd-rend2/tr_main.cpp | 4 +- codemp/rd-rend2/tr_shade.cpp | 489 +++++++------------ codemp/rd-rend2/tr_shadows.cpp | 3 +- codemp/rd-rend2/tr_sky.cpp | 32 +- codemp/rd-rend2/tr_surface.cpp | 41 +- codemp/rd-rend2/tr_vbo.cpp | 88 +++- codemp/rd-rend2/tr_weather.cpp | 2 +- 21 files changed, 1578 insertions(+), 786 deletions(-) diff --git a/codemp/rd-rend2/glsl/dlight.glsl b/codemp/rd-rend2/glsl/dlight.glsl index f23c8feb5d..9cb86e45dc 100644 --- a/codemp/rd-rend2/glsl/dlight.glsl +++ b/codemp/rd-rend2/glsl/dlight.glsl @@ -3,18 +3,44 @@ in vec3 attr_Position; in vec2 attr_TexCoord0; in vec3 attr_Normal; -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; -uniform float u_Time; -#endif +struct Light +{ + vec4 origin; + vec3 color; + float radius; +}; -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; +layout(std140) uniform Lights +{ + int u_NumLights; + Light u_Lights[32]; +}; -uniform mat4 u_ModelMatrix; -uniform mat4 u_ModelViewProjectionMatrix; +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 _u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; +}; + +uniform int u_LightIndex; + +layout(std140) uniform ShaderInstance +{ + vec4 u_DeformParams0; + vec4 u_DeformParams1; + float u_Time; + float u_PortalRange; + int u_DeformType; + int u_DeformFunc; +}; out vec3 var_Normal; out vec4 var_LightDirAndRadiusSq; @@ -62,9 +88,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_BULGE: { - float bulgeHeight = u_DeformParams[1]; // amplitude - float bulgeWidth = u_DeformParams[2]; // phase - float bulgeSpeed = u_DeformParams[3]; // frequency + float bulgeHeight = u_DeformParams0.y; // amplitude + float bulgeWidth = u_DeformParams0.z; // phase + float bulgeSpeed = u_DeformParams0.w; // frequency float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); @@ -73,11 +99,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_WAVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); @@ -87,11 +113,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_MOVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + vec3 direction = u_DeformParams1.xyz; float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); @@ -100,15 +126,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_PROJECTION_SHADOW: { - vec3 ground = vec3( - u_DeformParams[0], - u_DeformParams[1], - u_DeformParams[2]); - float groundDist = u_DeformParams[3]; - vec3 lightDir = vec3( - u_DeformParams[4], - u_DeformParams[5], - u_DeformParams[6]); + vec3 ground = u_DeformParams0.xyz; + float groundDist = u_DeformParams0.w; + vec3 lightDir = u_DeformParams1.xyz; float d = dot( lightDir, ground ); @@ -129,8 +149,8 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) return normal; } - float amplitude = u_DeformParams[1]; - float frequency = u_DeformParams[3]; + float amplitude = u_DeformParams0.y; + float frequency = u_DeformParams0.w; vec3 outNormal = normal; const float scale = 0.98; @@ -170,11 +190,12 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); vec3 positionWS = (u_ModelMatrix * vec4(position, 1.0)).xyz; - vec3 L = u_LightOrigin.xyz - positionWS; + Light light = u_Lights[u_LightIndex]; + vec3 L = light.origin.xyz - positionWS; L = (u_ModelMatrix * vec4(L, 0.0)).xyz; var_Normal = normalize((u_ModelMatrix * vec4(normal, 0.0)).xyz); - var_LightDirAndRadiusSq = vec4(L, u_LightRadius * u_LightRadius); + var_LightDirAndRadiusSq = vec4(L, light.radius * light.radius); } /*[Fragment]*/ diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 0f36b36df0..1065282d77 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -12,23 +12,35 @@ in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; -#endif - -uniform float u_Time; -uniform mat4 u_ModelMatrix; -uniform mat4 u_ModelViewProjectionMatrix; - -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_SKELETAL_ANIMATION) -uniform mat4x3 u_BoneMatrices[20]; -#endif - -uniform vec4 u_Color; +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + +layout(std140) uniform ShaderInstance +{ + vec4 u_DeformParams0; + vec4 u_DeformParams1; + float u_Time; + float u_PortalRange; + int u_DeformType; + int u_DeformFunc; +}; + +layout(std140) uniform Bones +{ + mat3x4 u_BoneMatrices[20]; +}; out vec3 var_WSPosition; @@ -75,9 +87,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_BULGE: { - float bulgeHeight = u_DeformParams[1]; // amplitude - float bulgeWidth = u_DeformParams[2]; // phase - float bulgeSpeed = u_DeformParams[3]; // frequency + float bulgeHeight = u_DeformParams0.y; // amplitude + float bulgeWidth = u_DeformParams0.z; // phase + float bulgeSpeed = u_DeformParams0.w; // frequency float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); @@ -86,11 +98,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_WAVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); @@ -100,11 +112,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_MOVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + vec3 direction = u_DeformParams1.xyz; float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); @@ -113,15 +125,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_PROJECTION_SHADOW: { - vec3 ground = vec3( - u_DeformParams[0], - u_DeformParams[1], - u_DeformParams[2]); - float groundDist = u_DeformParams[3]; - vec3 lightDir = vec3( - u_DeformParams[4], - u_DeformParams[5], - u_DeformParams[6]); + vec3 ground = u_DeformParams0.xyz; + float groundDist = u_DeformParams0.w; + vec3 lightDir = u_DeformParams1.xyz; float d = dot( lightDir, ground ); @@ -142,8 +148,8 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) return normal; } - float amplitude = u_DeformParams[1]; - float frequency = u_DeformParams[3]; + float amplitude = u_DeformParams0.y; + float frequency = u_DeformParams0.w; vec3 outNormal = normal; const float scale = 0.98; @@ -170,6 +176,16 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) } #endif +mat4x3 GetBoneMatrix(uint index) +{ + mat3x4 bone = u_BoneMatrices[index]; + return mat4x3( + bone[0].x, bone[1].x, bone[2].x, + bone[0].y, bone[1].y, bone[2].y, + bone[0].z, bone[1].z, bone[2].z, + bone[0].w, bone[1].w, bone[2].w); +} + void main() { #if defined(USE_VERTEX_ANIMATION) @@ -178,10 +194,10 @@ void main() normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) mat4x3 influence = - u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + - u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + - u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + - u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + + GetBoneMatrix(attr_BoneIndexes[1]) * attr_BoneWeights[1] + + GetBoneMatrix(attr_BoneIndexes[2]) * attr_BoneWeights[2] + + GetBoneMatrix(attr_BoneIndexes[3]) * attr_BoneWeights[3]; vec3 position = influence * vec4(attr_Position, 1.0); vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); @@ -201,23 +217,56 @@ void main() } /*[Fragment]*/ -uniform vec4 u_Color; #if defined(USE_ALPHA_TEST) uniform int u_AlphaTestType; #endif -uniform vec4 u_FogPlane; -uniform float u_FogDepthToOpaque; -uniform bool u_FogHasPlane; -uniform vec3 u_ViewOrigin; +struct Fog +{ + vec4 plane; + vec4 color; + float depthToOpaque; + bool hasPlane; +}; + +layout(std140) uniform Fogs +{ + int u_NumFogs; + Fog u_Fogs[16]; +}; + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + in vec3 var_WSPosition; out vec4 out_Color; out vec4 out_Glow; -float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane) +float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) { - bool inFog = dot(viewOrigin, fogPlane.xyz) - fogPlane.w >= 0.0 || !hasPlane; + bool inFog = dot(viewOrigin, fog.plane.xyz) - fog.plane.w >= 0.0 || !fog.hasPlane; // line: x = o + tv // plane: (x . n) + d = 0 @@ -228,7 +277,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d vec3 V = position - viewOrigin; // fogPlane is inverted in tr_bsp for some reason. - float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz); + float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); float distToVertexFromViewOrigin = length(V); float distToIntersectionFromViewOrigin = max(t, 0.0) * distToVertexFromViewOrigin; @@ -236,15 +285,16 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); float distThroughFog = mix(distToVertexFromViewOrigin, distOutsideFog, !inFog); - float z = depthToOpaque * distThroughFog; + float z = fog.depthToOpaque * distThroughFog; return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } void main() { - float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane); - out_Color.rgb = u_Color.rgb; - out_Color.a = fog; + Fog fog = u_Fogs[u_FogIndex]; + float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); + out_Color.rgb = fog.color.rgb; + out_Color.a = fogFactor; #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 8c7b0aa4df..f6bbfe8742 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -17,53 +17,68 @@ in vec2 attr_TexCoord0; in vec2 attr_TexCoord1; #endif +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + +layout(std140) uniform ShaderInstance +{ + vec4 u_DeformParams0; + vec4 u_DeformParams1; + float u_Time; + float u_PortalRange; + int u_DeformType; + int u_DeformFunc; +}; + +layout(std140) uniform Bones +{ + mat3x4 u_BoneMatrices[20]; +}; + uniform vec4 u_DiffuseTexMatrix; uniform vec4 u_DiffuseTexOffTurb; -#if defined(USE_TCGEN) || defined(USE_RGBAGEN) -uniform vec3 u_LocalViewOrigin; -#endif - #if defined(USE_TCGEN) uniform int u_TCGen0; uniform vec3 u_TCGen0Vector0; uniform vec3 u_TCGen0Vector1; #endif -#if defined(USE_DEFORM_VERTEXES) -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; -uniform float u_Time; -#endif - -uniform mat4 u_ModelViewProjectionMatrix; -uniform mat4 u_ModelMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; -uniform vec3 u_ViewForward; -uniform float u_FXVolumetricBase; - #if defined(USE_RGBAGEN) uniform int u_ColorGen; uniform int u_AlphaGen; -uniform vec3 u_AmbientLight; -uniform vec3 u_DirectedLight; -uniform vec3 u_ModelLightDir; -uniform float u_PortalRange; #endif +uniform float u_FXVolumetricBase; + #if defined(USE_RGBAGEN) || defined(USE_DEFORM_VERTEXES) uniform vec4 u_Disintegration; // origin, threshhold #endif -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_SKELETAL_ANIMATION) -uniform mat4x3 u_BoneMatrices[20]; -#endif - out vec2 var_DiffuseTex; out vec4 var_Color; #if defined(USE_FOG) @@ -113,29 +128,22 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_BULGE: { - float bulgeHeight = u_DeformParams[1]; // amplitude - float bulgeWidth = u_DeformParams[2]; // phase - float bulgeSpeed = u_DeformParams[3]; // frequency + float bulgeHeight = u_DeformParams0.y; // amplitude + float bulgeWidth = u_DeformParams0.z; // phase + float bulgeSpeed = u_DeformParams0.w; // frequency float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); return pos + normal * scale * bulgeHeight; } - case DEFORM_BULGE_UNIFORM: - { - float bulgeHeight = u_DeformParams[1]; // amplitude - - return pos + normal * bulgeHeight; - } - case DEFORM_WAVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); @@ -145,11 +153,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_MOVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + vec3 direction = u_DeformParams1.xyz; float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); @@ -158,21 +166,19 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_PROJECTION_SHADOW: { - vec3 ground = vec3( - u_DeformParams[0], - u_DeformParams[1], - u_DeformParams[2]); - float groundDist = u_DeformParams[3]; - vec3 lightDir = vec3( - u_DeformParams[4], - u_DeformParams[5], - u_DeformParams[6]); - - float d = 1.0 / dot( lightDir, ground ); + vec3 ground = u_DeformParams0.xyz; + float groundDist = u_DeformParams0.w; + vec3 lightDir = u_DeformParams1.xyz; + + float d = dot( lightDir, ground ); + + lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; + d = 1.0 / dot( lightDir, ground ); + vec3 lightPos = lightDir * d; - return pos - lightPos * (dot( pos, ground ) + groundDist); - } + return pos - lightPos * dot( pos, ground ) + groundDist; + } case DEFORM_DISINTEGRATION: { vec3 delta = u_Disintegration.xyz - pos; @@ -198,8 +204,8 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) return normal; } - float amplitude = u_DeformParams[1]; - float frequency = u_DeformParams[3]; + float amplitude = u_DeformParams0.y; + float frequency = u_DeformParams0.w; vec3 outNormal = normal; const float scale = 0.98; @@ -332,6 +338,16 @@ vec4 CalcColor(vec3 position, vec3 normal) } #endif +mat4x3 GetBoneMatrix(uint index) +{ + mat3x4 bone = u_BoneMatrices[index]; + return mat4x3( + bone[0].x, bone[1].x, bone[2].x, + bone[0].y, bone[1].y, bone[2].y, + bone[0].z, bone[1].z, bone[2].z, + bone[0].w, bone[1].w, bone[2].w); +} + void main() { #if defined(USE_VERTEX_ANIMATION) @@ -340,10 +356,10 @@ void main() normal = normalize(normal - vec3(0.5)); #elif defined(USE_SKELETAL_ANIMATION) mat4x3 influence = - u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + - u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + - u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + - u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + + GetBoneMatrix(attr_BoneIndexes[1]) * attr_BoneWeights[1] + + GetBoneMatrix(attr_BoneIndexes[2]) * attr_BoneWeights[2] + + GetBoneMatrix(attr_BoneIndexes[3]) * attr_BoneWeights[3]; vec3 position = influence * vec4(attr_Position, 1.0); vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); @@ -373,7 +389,7 @@ void main() if ( u_FXVolumetricBase >= 0.0 ) { - vec3 viewForward = u_ViewForward; + vec3 viewForward = u_ViewForward.xyz; float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); d = d * d; d = d * d; @@ -396,19 +412,51 @@ void main() /*[Fragment]*/ +struct Fog +{ + vec4 plane; + vec4 color; + float depthToOpaque; + bool hasPlane; +}; + +layout(std140) uniform Fogs +{ + int u_NumFogs; + Fog u_Fogs[16]; +}; + +uniform vec4 u_FogColorMask; + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + uniform sampler2D u_DiffuseMap; #if defined(USE_ALPHA_TEST) uniform int u_AlphaTestType; #endif -#if defined(USE_FOG) -uniform vec4 u_FogPlane; -uniform float u_FogDepthToOpaque; -uniform bool u_FogHasPlane; -uniform vec3 u_ViewOrigin; -uniform vec4 u_FogColorMask; -#endif - in vec2 var_DiffuseTex; in vec4 var_Color; #if defined(USE_FOG) @@ -420,8 +468,10 @@ out vec4 out_Glow; #if defined(USE_FOG) -float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float depthToOpaque, in bool hasPlane) +float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) { + bool inFog = dot(viewOrigin, fog.plane.xyz) - fog.plane.w >= 0.0 || !fog.hasPlane; + // line: x = o + tv // plane: (x . n) + d = 0 // intersects: dot(o + tv, n) + d = 0 @@ -431,24 +481,16 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in vec4 fogPlane, in float d vec3 V = position - viewOrigin; // fogPlane is inverted in tr_bsp for some reason. - float t = -(fogPlane.w + dot(viewOrigin, -fogPlane.xyz)) / dot(V, -fogPlane.xyz); - - bool inFog = ((dot(viewOrigin, fogPlane.xyz) - fogPlane.w) >= 0.0) || !hasPlane; - bool intersects = (t > 0.0 && t <= 1.0); - - // this is valid only when t > 0.0. When t < 0.0, then intersection point is behind - // the camera, meaning we're facing away from the fog plane, which probably means - // we're inside the fog volume. - vec3 intersectsAt = viewOrigin + t*V; + float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); - float distToVertexFromIntersection = distance(intersectsAt, position); - float distToVertexFromViewOrigin = distance(viewOrigin, position); + float distToVertexFromViewOrigin = length(V); + float distToIntersectionFromViewOrigin = max(t, 0.0) * distToVertexFromViewOrigin; - float distToVertex = mix(distToVertexFromViewOrigin, - distToVertexFromIntersection, - !inFog && intersects); + float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); + float distThroughFog = mix(distToVertexFromViewOrigin, distOutsideFog, !inFog); - return min(distToVertex / depthToOpaque, 1.0); + float z = fog.depthToOpaque * distThroughFog; + return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } #endif @@ -480,8 +522,9 @@ void main() #endif #if defined(USE_FOG) - float fog = CalcFog(u_ViewOrigin, var_WSPosition, u_FogPlane, u_FogDepthToOpaque, u_FogHasPlane); - color *= vec4(1.0) - u_FogColorMask * fog; + Fog fog = u_Fogs[u_FogIndex]; + float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); + color *= vec4(1.0) - u_FogColorMask * fogFactor; #endif out_Color = vec4(color.rgb * var_Color.rgb, color.a); diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 33d23121a4..438089f4bb 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -1,5 +1,5 @@ /*[Vertex]*/ -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) && !defined(USE_LIGHT_VECTOR) #define PER_PIXEL_LIGHTING #endif in vec2 attr_TexCoord0; @@ -28,19 +28,51 @@ in vec4 attr_BoneWeights; in vec3 attr_LightDirection; #endif +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; +}; +uniform float u_FXVolumetricBase; + +layout(std140) uniform Bones +{ + mat3x4 u_BoneMatrices[20]; +}; + #if defined(USE_DELUXEMAP) uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube #endif -#if defined(PER_PIXEL_LIGHTING) -uniform vec3 u_ViewOrigin; -#endif - #if defined(USE_TCGEN) || defined(USE_LIGHTMAP) uniform int u_TCGen0; uniform vec3 u_TCGen0Vector0; uniform vec3 u_TCGen0Vector1; -uniform vec3 u_LocalViewOrigin; uniform int u_TCGen1; #endif @@ -49,36 +81,11 @@ uniform vec4 u_DiffuseTexMatrix; uniform vec4 u_DiffuseTexOffTurb; #endif -uniform mat4 u_ModelViewProjectionMatrix; uniform vec4 u_BaseColor; uniform vec4 u_VertColor; uniform vec4 u_Disintegration; -uniform mat4 u_ModelMatrix; uniform int u_ColorGen; -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_SKELETAL_ANIMATION) -uniform mat4x3 u_BoneMatrices[20]; -#endif - -#if defined(USE_LIGHT_VECTOR) -uniform vec4 u_LightOrigin; -uniform float u_LightRadius; - #if defined(USE_FAST_LIGHT) -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; - #endif -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec4 u_PrimaryLightOrigin; -uniform float u_PrimaryLightRadius; -#endif - -uniform vec3 u_ViewForward; -uniform float u_FXVolumetricBase; - out vec4 var_TexCoords; out vec4 var_Color; out vec3 var_N; @@ -204,6 +211,16 @@ float CalcLightAttenuation(in bool isPoint, float normDist) return clamp(attenuation, 0.0, 1.0); } +mat4x3 GetBoneMatrix(uint index) +{ + mat3x4 bone = u_BoneMatrices[index]; + return mat4x3( + bone[0].x, bone[1].x, bone[2].x, + bone[0].y, bone[1].y, bone[2].y, + bone[0].z, bone[1].z, bone[2].z, + bone[0].w, bone[1].w, bone[2].w); +} + void main() { #if defined(USE_VERTEX_ANIMATION) @@ -212,10 +229,10 @@ void main() vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); #elif defined(USE_SKELETAL_ANIMATION) mat4x3 influence = - u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + - u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + - u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + - u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + + GetBoneMatrix(attr_BoneIndexes[1]) * attr_BoneWeights[1] + + GetBoneMatrix(attr_BoneIndexes[2]) * attr_BoneWeights[2] + + GetBoneMatrix(attr_BoneIndexes[3]) * attr_BoneWeights[3]; vec3 position = influence * vec4(attr_Position, 1.0); vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); @@ -264,7 +281,7 @@ void main() #endif #if defined(USE_LIGHT_VECTOR) - vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w); + vec3 L = vec3(0.0); #elif defined(PER_PIXEL_LIGHTING) vec3 L = attr_LightDirection * 2.0 - vec3(1.0); L = (u_ModelMatrix * vec4(L, 0.0)).xyz; @@ -276,7 +293,7 @@ void main() if ( u_FXVolumetricBase > 0.0 ) { - vec3 viewForward = u_ViewForward; + vec3 viewForward = u_ViewForward.xyz; float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); d = d * d; @@ -287,14 +304,6 @@ void main() else { var_Color = u_VertColor * attr_Color + u_BaseColor; - -#if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(u_LightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); - - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; -#endif } var_Color *= disintegration; @@ -304,18 +313,14 @@ void main() #endif #if defined(PER_PIXEL_LIGHTING) - #if defined(USE_LIGHT_VECTOR) - var_LightDir = vec4(L, u_LightRadius * u_LightRadius); - #else - var_LightDir = vec4(L, 0.0); - #endif + var_LightDir = vec4(L, 0.0); #if defined(USE_DELUXEMAP) var_LightDir -= u_EnableTextures.y * var_LightDir; #endif #endif #if defined(PER_PIXEL_LIGHTING) - vec3 viewDir = u_ViewOrigin - position; + vec3 viewDir = u_ViewOrigin.xyz - position; // store view direction in tangent space to save on outs var_Normal = vec4(normal, viewDir.x); @@ -325,9 +330,39 @@ void main() } /*[Fragment]*/ -#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) +#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) && !defined(USE_LIGHT_VECTOR) #define PER_PIXEL_LIGHTING #endif +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; +}; + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; +}; uniform sampler2D u_DiffuseMap; @@ -351,6 +386,8 @@ uniform sampler2D u_SpecularMap; uniform sampler2D u_ShadowMap; #endif +//uniform samplerCubeShadow u_ShadowMap2; + #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; uniform sampler2D u_EnvBrdfMap; @@ -361,21 +398,8 @@ uniform sampler2D u_EnvBrdfMap; uniform vec4 u_EnableTextures; #endif -#if defined(USE_LIGHT_VECTOR) && !defined(USE_VERTEX_LIGHTING) -uniform vec3 u_DirectedLight; -uniform vec3 u_AmbientLight; -uniform samplerCubeShadow u_ShadowMap2; -#endif - -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -uniform vec3 u_PrimaryLightColor; -uniform vec3 u_PrimaryLightAmbient; -#endif - -#if defined(PER_PIXEL_LIGHTING) uniform vec4 u_NormalScale; uniform vec4 u_SpecularScale; -#endif #if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) uniform vec4 u_CubeMapInfo; @@ -561,7 +585,8 @@ float getLightDepth(in vec3 Vec, in float f) float getShadowValue(in vec4 light) { float distance = getLightDepth(light.xyz, sqrt(light.w)); - return pcfShadow(u_ShadowMap2, light.xyz, distance); + //return pcfShadow(u_ShadowMap2, light.xyz, distance); + return 1.0; } #endif @@ -581,19 +606,21 @@ vec3 CalcIBLContribution( in float roughness, in vec3 N, in vec3 E, + in vec3 viewOrigin, in vec3 viewDir, in float NE, in vec3 specular ) { -#if defined(USE_CUBEMAP) +#if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; vec3 R = reflect(E, N); // parallax corrected cubemap (cheaper trick) // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ - vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; + vec3 eyeToCubeCenter = (u_CubeMapInfo.xyz - viewOrigin) * 0.001; + vec3 parallax = eyeToCubeCenter + u_CubeMapInfo.w * viewDir * 0.001; vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; @@ -693,9 +720,9 @@ void main() ambientColor = vec3 (0.0); attenuation = 1.0; #elif defined(USE_LIGHT_VECTOR) - lightColor = u_DirectedLight * var_Color.rgb; - ambientColor = u_AmbientLight * var_Color.rgb; - attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); + lightColor = vec3(0.0); + ambientColor = vec3(0.0); + attenuation = 0.0; #if defined(USE_DSHADOWS) if (var_LightDir.w > 0.0) { @@ -757,12 +784,6 @@ void main() vec3 Fd = CalcDiffuse(diffuse.rgb, NE, NL, LH, roughness); vec3 Fs = vec3(0.0); - #if defined(USE_LIGHT_VECTOR) - float NH = clamp(dot(N, H), 0.0, 1.0); - - Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); - #endif - #if defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular) float NH = clamp(dot(N, H), 0.0, 1.0); @@ -792,7 +813,7 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif - out_Color.rgb += CalcIBLContribution(roughness, N, E, viewDir, NE, specular.rgb); + out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb); #else lightColor = var_Color.rgb; diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index d5b7be1475..13deba9afc 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -6,14 +6,30 @@ in vec4 attr_TexCoord0; in vec3 attr_Position2; in vec3 attr_Normal2; -uniform int u_DeformType; -uniform int u_DeformFunc; -uniform float u_DeformParams[7]; - -uniform float u_Time; -uniform mat4 u_ModelViewProjectionMatrix; - -uniform float u_VertexLerp; +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float _u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + +layout(std140) uniform ShaderInstance +{ + vec4 u_DeformParams0; + vec4 u_DeformParams1; + float u_Time; + float u_PortalRange; + int u_DeformType; + int u_DeformFunc; +}; float GetNoiseValue( float x, float y, float z, float t ) { @@ -57,9 +73,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_BULGE: { - float bulgeHeight = u_DeformParams[1]; // amplitude - float bulgeWidth = u_DeformParams[2]; // phase - float bulgeSpeed = u_DeformParams[3]; // frequency + float bulgeHeight = u_DeformParams0.y; // amplitude + float bulgeWidth = u_DeformParams0.z; // phase + float bulgeSpeed = u_DeformParams0.w; // frequency float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); @@ -68,11 +84,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_WAVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - float spread = u_DeformParams[4]; + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); @@ -82,11 +98,11 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_MOVE: { - float base = u_DeformParams[0]; - float amplitude = u_DeformParams[1]; - float phase = u_DeformParams[2]; - float frequency = u_DeformParams[3]; - vec3 direction = vec3( u_DeformParams[4], u_DeformParams[5], u_DeformParams[6] ); + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + vec3 direction = u_DeformParams1.xyz; float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); @@ -95,15 +111,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) case DEFORM_PROJECTION_SHADOW: { - vec3 ground = vec3( - u_DeformParams[0], - u_DeformParams[1], - u_DeformParams[2]); - float groundDist = u_DeformParams[3]; - vec3 lightDir = vec3( - u_DeformParams[4], - u_DeformParams[5], - u_DeformParams[6]); + vec3 ground = u_DeformParams0.xyz; + float groundDist = u_DeformParams0.w; + vec3 lightDir = u_DeformParams1.xyz; float d = dot( lightDir, ground ); @@ -124,8 +134,8 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) return normal; } - float amplitude = u_DeformParams[1]; - float frequency = u_DeformParams[3]; + float amplitude = u_DeformParams0.y; + float frequency = u_DeformParams0.w; vec3 outNormal = normal; const float scale = 0.98; @@ -165,5 +175,5 @@ void main() out vec4 out_Color; void main() { - out_Color = vec4(0, 0, 0, 1); + out_Color = vec4(0.0, 0.0, 0.0, 1.0); } diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 12c3bb4fe1..6a200ddc84 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -3,7 +3,15 @@ in vec3 attr_Position; in vec3 attr_Normal; uniform mat4 u_ModelViewProjectionMatrix; -uniform vec3 u_ViewOrigin; + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; layout(std140) uniform SurfaceSprite { diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3d6fa91b6b..33e8b7a19f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -656,6 +656,47 @@ void RB_BeginDrawingView (void) { #define MAC_EVENT_PUMP_MSEC 5 +void DrawItemSetVertexAttributes( + DrawItem& drawItem, + const vertexAttribute_t *attributes, + uint32_t count, + Allocator& allocator) +{ + drawItem.numAttributes = count; + drawItem.attributes = ojkAllocArray(allocator, count); + memcpy( + drawItem.attributes, attributes, sizeof(*drawItem.attributes) * count); +} + +void DrawItemSetSamplerBindings( + DrawItem& drawItem, + const SamplerBinding *bindings, + uint32_t count, + Allocator& allocator) +{ + drawItem.numSamplerBindings = count; + drawItem.samplerBindings = ojkAllocArray(allocator, count); + memcpy( + drawItem.samplerBindings, + bindings, + sizeof(*drawItem.samplerBindings) * count); +} + +void DrawItemSetUniformBlockBindings( + DrawItem& drawItem, + const UniformBlockBinding *bindings, + uint32_t count, + Allocator& allocator) +{ + drawItem.numUniformBlockBindings = count; + drawItem.uniformBlockBindings = ojkAllocArray( + allocator, count); + memcpy( + drawItem.uniformBlockBindings, + bindings, + sizeof(*drawItem.uniformBlockBindings) * count); +} + UniformDataWriter::UniformDataWriter() : failed(false) , shaderProgram(nullptr) @@ -979,17 +1020,14 @@ static void RB_BindTextures( size_t numBindings, const SamplerBinding *bindings } } -static void RB_BindAndUpdateUniformBlocks( +static void RB_BindUniformBlocks( size_t numBindings, const UniformBlockBinding *bindings) { for (size_t i = 0; i < numBindings; ++i) { const UniformBlockBinding& binding = bindings[i]; - if (binding.data) - RB_BindAndUpdateUniformBlock(binding.block, binding.data); - else - RB_BindUniformBlock(binding.block); + RB_BindUniformBlock(binding.ubo, binding.block, binding.offset); } } @@ -1012,11 +1050,11 @@ static void RB_BindTransformFeedbackBuffer(const bufferBinding_t& binding) { if (memcmp(&glState.currentXFBBO, &binding, sizeof(binding)) != 0) { - if (binding.vbo != nullptr) + if (binding.buffer != 0) qglBindBufferRange( GL_TRANSFORM_FEEDBACK_BUFFER, 0, - binding.vbo->vertexesVBO, + binding.buffer, binding.offset, binding.size); else @@ -1042,7 +1080,7 @@ static void RB_DrawItems( GL_VertexAttribPointers(drawItem.numAttributes, drawItem.attributes); RB_BindTextures(drawItem.numSamplerBindings, drawItem.samplerBindings); - RB_BindAndUpdateUniformBlocks( + RB_BindUniformBlocks( drawItem.numUniformBlockBindings, drawItem.uniformBlockBindings); RB_BindTransformFeedbackBuffer(drawItem.transformFeedbackBuffer); @@ -1224,6 +1262,7 @@ static void RB_SubmitDrawSurfsForDepthFill( if ( shader == oldShader && entityNum == oldEntityNum ) { // fast path, same as previous sort + backEnd.currentDrawSurfIndex = i; rb_surfaceTable[*drawSurf->surface](drawSurf->surface); continue; } @@ -1260,7 +1299,10 @@ static void RB_SubmitDrawSurfsForDepthFill( oldEntityNum = entityNum; } + backEnd.currentDrawSurfIndex = i; + // add the triangles for this surface + assert(drawSurf->surface != nullptr); rb_surfaceTable[*drawSurf->surface](drawSurf->surface); } @@ -1308,6 +1350,7 @@ static void RB_SubmitDrawSurfs( dlighted == oldDlighted ) { // fast path, same as previous sort + backEnd.currentDrawSurfIndex = i; rb_surfaceTable[*drawSurf->surface](drawSurf->surface); continue; } @@ -1355,6 +1398,8 @@ static void RB_SubmitDrawSurfs( oldEntityNum = entityNum; } + backEnd.currentDrawSurfIndex = i; + // add the triangles for this surface rb_surfaceTable[*drawSurf->surface](drawSurf->surface); } @@ -2245,50 +2290,436 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu } } -static void RB_TransformAllAnimations( drawSurf_t *drawSurfs, int numDrawSurfs ) +static void RB_UpdateCameraConstants(gpuFrame_t *frame) { - drawSurf_t *drawSurf = drawSurfs; - for ( int i = 0; i < numDrawSurfs; ++i, ++drawSurf ) + const float zmax = backEnd.viewParms.zFar; + const float zmin = r_znear->value; + + CameraBlock cameraBlock = {}; + VectorSet4(cameraBlock.viewInfo, zmax / zmin, zmax, 0.0f, 0.0f); + VectorCopy(backEnd.refdef.viewaxis[0], cameraBlock.viewForward); + VectorCopy(backEnd.refdef.viewaxis[1], cameraBlock.viewLeft); + VectorCopy(backEnd.refdef.viewaxis[2], cameraBlock.viewUp); + VectorCopy(backEnd.refdef.vieworg, cameraBlock.viewOrigin); + tr.cameraUboOffset = RB_AppendConstantsData( + frame, &cameraBlock, sizeof(cameraBlock)); +} + +static void RB_UpdateSceneConstants(gpuFrame_t *frame) +{ + SceneBlock sceneBlock = {}; + VectorCopy4(backEnd.refdef.sunDir, sceneBlock.primaryLightOrigin); + VectorCopy(backEnd.refdef.sunAmbCol, sceneBlock.primaryLightAmbient); + VectorCopy(backEnd.refdef.sunCol, sceneBlock.primaryLightColor); + + tr.sceneUboOffset = RB_AppendConstantsData( + frame, &sceneBlock, sizeof(sceneBlock)); +} + +static void RB_UpdateLightsConstants(gpuFrame_t *frame) +{ + LightsBlock lightsBlock = {}; + lightsBlock.numLights = backEnd.refdef.num_dlights; + for (int i = 0; i < lightsBlock.numLights; ++i) + { + const dlight_t *dlight = backEnd.refdef.dlights + i; + LightsBlock::Light *lightData = lightsBlock.lights + i; + + VectorSet4( + lightData->origin, + dlight->origin[0], + dlight->origin[1], + dlight->origin[2], + 1.0f); + VectorCopy(dlight->color, lightData->color); + lightData->radius = dlight->radius; + } + + tr.lightsUboOffset = RB_AppendConstantsData( + frame, &lightsBlock, sizeof(lightsBlock)); +} + +static void RB_UpdateFogsConstants(gpuFrame_t *frame) +{ + FogsBlock fogsBlock = {}; + if (tr.world == nullptr) + { + fogsBlock.numFogs = 0; + } + else + { + fogsBlock.numFogs = tr.world->numfogs - 1; // Don't reserve fog 0 as 'null' + } + + for (int i = 0; i < fogsBlock.numFogs; ++i) + { + const fog_t *fog = tr.world->fogs + i + 1; + FogsBlock::Fog *fogData = fogsBlock.fogs + i; + + VectorCopy4(fog->surface, fogData->plane); + VectorCopy4(fog->color, fogData->color); + fogData->depthToOpaque = sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque; + fogData->hasPlane = fog == tr.world->globalFog ? qfalse : fog->hasSurface; + } + + tr.fogsUboOffset = RB_AppendConstantsData( + frame, &fogsBlock, sizeof(fogsBlock)); +} + +static void RB_UpdateEntityLightConstants( + EntityBlock& entityBlock, + const trRefEntity_t *refEntity) +{ + static const float normalizeFactor = 1.0f / 255.0f; + + VectorScale(refEntity->ambientLight, normalizeFactor, entityBlock.ambientLight); + VectorScale(refEntity->directedLight, normalizeFactor, entityBlock.directedLight); + VectorCopy(refEntity->modelLightDir, entityBlock.modelLightDir); + + VectorCopy(refEntity->lightDir, entityBlock.lightOrigin); + entityBlock.lightOrigin[3] = 0.0f; + entityBlock.lightRadius = 0.0f; +} + +static void RB_UpdateEntityMatrixConstants( + EntityBlock& entityBlock, + const trRefEntity_t *refEntity) +{ + matrix_t modelViewMatrix; + orientationr_t ori; + if (refEntity == &tr.worldEntity) { - if ( *drawSurf->surface != SF_MDX ) + ori = tr.viewParms.world; + Matrix16Identity(entityBlock.modelMatrix); + } + else + { + R_RotateForEntity(refEntity, &tr.viewParms, &ori); + Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); + } + + Matrix16Copy(ori.modelViewMatrix, modelViewMatrix); + VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); + + Matrix16Multiply( + tr.viewParms.projectionMatrix, + modelViewMatrix, + entityBlock.modelViewProjectionMatrix); +} + +static void RB_UpdateEntityModelConstants( + EntityBlock& entityBlock, + const trRefEntity_t *refEntity) +{ + static const float normalizeFactor = 1.0f / 255.0f; + + entityBlock.fxVolumetricBase = -1.0f; + if (refEntity->e.renderfx & RF_VOLUMETRIC) + entityBlock.fxVolumetricBase = refEntity->e.shaderRGBA[0] * normalizeFactor; + + entityBlock.vertexLerp = 0.0f; + if (refEntity->e.oldframe || refEntity->e.frame) + if (refEntity->e.oldframe != refEntity->e.frame) + entityBlock.vertexLerp = refEntity->e.backlerp; +} + +static void RB_UpdateSkyEntityConstants(gpuFrame_t *frame) +{ + EntityBlock skyEntityBlock = {}; + skyEntityBlock.fxVolumetricBase = -1.0f; + + matrix_t translation; + Matrix16Translation(backEnd.viewParms.ori.origin, translation); + + matrix_t modelViewMatrix; + Matrix16Multiply( + backEnd.viewParms.world.modelViewMatrix, + translation, + modelViewMatrix); + Matrix16Multiply( + backEnd.viewParms.projectionMatrix, + modelViewMatrix, + skyEntityBlock.modelViewProjectionMatrix); + + tr.skyEntityUboOffset = RB_AppendConstantsData( + frame, &skyEntityBlock, sizeof(skyEntityBlock)); +} + +static uint32_t RB_HashEntityShaderKey(int entityNum, int shaderNum) +{ + uint32_t hash = 0; + hash += entityNum; + hash += shaderNum * 119; + return (hash ^ (hash >> 10) ^ (hash >> 20)); +} + +void RB_InsertEntityShaderUboOffset( + EntityShaderUboOffset *offsetMap, + int mapSize, + int entityNum, + int shaderNum, + int uboOffset) +{ + int hash = RB_HashEntityShaderKey(entityNum, shaderNum) % mapSize; + while (offsetMap[hash].inuse) + hash = (hash + 1) % mapSize; + + EntityShaderUboOffset& offset = offsetMap[hash]; + offset.inuse = true; + offset.entityNum = entityNum; + offset.shaderNum = shaderNum; + offset.offset = uboOffset; +} + +int RB_GetEntityShaderUboOffset( + EntityShaderUboOffset *offsetMap, + int mapSize, + int entityNum, + int shaderNum) +{ + int hash = RB_HashEntityShaderKey(entityNum, shaderNum) % mapSize; + while (offsetMap[hash].inuse) + { + const EntityShaderUboOffset& uboOffset = offsetMap[hash]; + if (uboOffset.entityNum == entityNum && + uboOffset.shaderNum == shaderNum) + return uboOffset.offset; + hash = (hash + 1) % mapSize; + } + + return -1; +} + +static void ComputeDeformValues( + const shader_t *shader, + deform_t *type, + genFunc_t *waveFunc, + vec4_t deformParams0, + vec4_t deformParams1) +{ + // u_DeformGen + *type = DEFORM_NONE; + *waveFunc = GF_NONE; + + if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) + { + *type = DEFORM_DISINTEGRATION; + return; + } + + if (!ShaderRequiresCPUDeforms(shader)) + { + // only support the first one + const deformStage_t *ds = &shader->deforms[0]; + + switch (ds->deformation) { - continue; + case DEFORM_WAVE: + *type = DEFORM_WAVE; + *waveFunc = ds->deformationWave.func; + + deformParams0[0] = ds->deformationWave.base; + deformParams0[1] = ds->deformationWave.amplitude; + deformParams0[2] = ds->deformationWave.phase; + deformParams0[3] = ds->deformationWave.frequency; + deformParams1[0] = ds->deformationSpread; + deformParams1[1] = 0.0f; + deformParams1[2] = 0.0f; + break; + + case DEFORM_BULGE: + *type = DEFORM_BULGE; + + deformParams0[0] = 0.0f; + deformParams0[1] = ds->bulgeHeight; // amplitude + deformParams0[2] = ds->bulgeWidth; // phase + deformParams0[3] = ds->bulgeSpeed; // frequency + deformParams1[0] = 0.0f; + deformParams1[1] = 0.0f; + deformParams1[2] = 0.0f; + break; + + case DEFORM_MOVE: + *type = DEFORM_MOVE; + *waveFunc = ds->deformationWave.func; + + deformParams0[0] = ds->deformationWave.base; + deformParams0[1] = ds->deformationWave.amplitude; + deformParams0[2] = ds->deformationWave.phase; + deformParams0[3] = ds->deformationWave.frequency; + deformParams1[0] = ds->moveVector[0]; + deformParams1[1] = ds->moveVector[1]; + deformParams1[2] = ds->moveVector[2]; + + break; + + case DEFORM_NORMALS: + *type = DEFORM_NORMALS; + + deformParams0[0] = 0.0f; + deformParams0[1] = ds->deformationWave.amplitude; // amplitude + deformParams0[2] = 0.0f; // phase + deformParams0[3] = ds->deformationWave.frequency; // frequency + deformParams1[0] = 0.0f; + deformParams1[1] = 0.0f; + deformParams1[2] = 0.0f; + break; + + case DEFORM_PROJECTION_SHADOW: + *type = DEFORM_PROJECTION_SHADOW; + + deformParams0[0] = backEnd.ori.axis[0][2]; + deformParams0[1] = backEnd.ori.axis[1][2]; + deformParams0[2] = backEnd.ori.axis[2][2]; + deformParams0[3] = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; + + vec3_t lightDir; + VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); + lightDir[2] = 0.0f; + VectorNormalize(lightDir); + VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); + + deformParams1[0] = backEnd.currentEntity->lightDir[0]; + deformParams1[1] = backEnd.currentEntity->lightDir[1]; + deformParams1[2] = backEnd.currentEntity->lightDir[2]; + break; + + default: + break; } } } -/* -============= -RB_DrawSurfs -============= -*/ -static const void *RB_DrawSurfs( const void *data ) { - const drawSurfsCommand_t *cmd; +static void RB_UpdateShaderEntityConstants( + gpuFrame_t *frame, + const int entityNum, + const trRefEntity_t *refEntity, + const shader_t *shader) +{ + ShaderInstanceBlock shaderInstanceBlock = {}; + ComputeDeformValues( + shader, + (deform_t *)&shaderInstanceBlock.deformType, + (genFunc_t *)&shaderInstanceBlock.deformFunc, + shaderInstanceBlock.deformParams0, + shaderInstanceBlock.deformParams1); + shaderInstanceBlock.portalRange = shader->portalRange; + shaderInstanceBlock.time = + backEnd.refdef.floatTime - shader->timeOffset; + if (entityNum == REFENTITYNUM_WORLD) + shaderInstanceBlock.time -= refEntity->e.shaderTime; + + const int uboOffset = RB_AppendConstantsData( + frame, &shaderInstanceBlock, sizeof(shaderInstanceBlock)); + + RB_InsertEntityShaderUboOffset( + tr.shaderInstanceUboOffsetsMap, + tr.shaderInstanceUboOffsetsMapSize, + entityNum, + shader->index, + uboOffset); +} + +static void RB_UpdateShaderAndEntityConstants( + gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) +{ + //bool updatedEntities[MAX_REFENTITIES] = {}; - // finish any 2D drawing if needed - if ( tess.numIndexes ) { - RB_EndSurface(); + // Make the map bigger than it needs to be. Eases collisions and iterations + // through the map during lookup/insertion. + tr.shaderInstanceUboOffsetsMapSize = numDrawSurfs * 2; + tr.shaderInstanceUboOffsetsMap = ojkAllocArray( + *backEndData->perFrameMemory, + tr.shaderInstanceUboOffsetsMapSize); + + memset(tr.entityUboOffsets, 0, sizeof(tr.entityUboOffsets)); + memset( + tr.shaderInstanceUboOffsetsMap, 0, + sizeof(EntityShaderUboOffset) * tr.shaderInstanceUboOffsetsMapSize); + + for (int i = 0; i < numDrawSurfs; ++i) + { + const drawSurf_t *drawSurf = drawSurfs + i; + + shader_t *shader; + int ignored; + int entityNum; + + R_DecomposeSort( + drawSurf->sort, &entityNum, &shader, &ignored, &ignored); + + const trRefEntity_t *refEntity = backEnd.refdef.entities + entityNum; + //FIX ME: find out why this causes trouble! + //if (!updatedEntities[entityNum]) + { + EntityBlock entityBlock = {}; + + RB_UpdateEntityLightConstants(entityBlock, refEntity); + RB_UpdateEntityMatrixConstants(entityBlock, refEntity); + RB_UpdateEntityModelConstants(entityBlock, refEntity); + + if (tr.world != nullptr) + { + if (tr.world->globalFog != nullptr) + entityBlock.fogIndex = tr.world->globalFog - tr.world->fogs - 1; + else if (drawSurf->fogIndex > 0) + entityBlock.fogIndex = drawSurf->fogIndex - 1; + } + + tr.entityUboOffsets[entityNum] = RB_AppendConstantsData( + frame, &entityBlock, sizeof(entityBlock)); + //updatedEntities[entityNum] = true; + } + + RB_UpdateShaderEntityConstants(frame, entityNum, refEntity, shader); } - cmd = (const drawSurfsCommand_t *)data; + RB_UpdateSkyEntityConstants(frame); +} - backEnd.refdef = cmd->refdef; - backEnd.viewParms = cmd->viewParms; +static void RB_UpdateAnimationConstants( + gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) +{ + tr.animationBoneUboOffsets = ojkAllocArray( + *backEndData->perFrameMemory, numDrawSurfs); + memset(tr.animationBoneUboOffsets, 0, sizeof(int) * numDrawSurfs); - // clear the z buffer, set the modelview, etc - RB_BeginDrawingView (); + for (int i = 0; i < numDrawSurfs; ++i) + { + const drawSurf_t *drawSurf = drawSurfs + i; + if (*drawSurf->surface != SF_MDX) + continue; - RB_TransformAllAnimations(cmd->drawSurfs, cmd->numDrawSurfs); + SkeletonBoneMatricesBlock bonesBlock = {}; + RB_TransformBones( + (CRenderableSurface *)drawSurf->surface, + bonesBlock.matrices); - RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); + tr.animationBoneUboOffsets[i] = RB_AppendConstantsData( + frame, &bonesBlock, sizeof(bonesBlock)); + } +} - RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); +static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) +{ + gpuFrame_t *frame = backEndData->currentFrame; + RB_BeginConstantsUpdate(frame); - return (const void *)(cmd + 1); + RB_UpdateCameraConstants(frame); + RB_UpdateSceneConstants(frame); + RB_UpdateLightsConstants(frame); + RB_UpdateFogsConstants(frame); + + RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); + RB_UpdateAnimationConstants(frame, drawSurfs, numDrawSurfs); + + RB_EndConstantsUpdate(frame); } + + /* ============= RB_DrawBuffer @@ -2650,6 +3081,17 @@ const void *RB_PostProcess(const void *data) FBO_BlitFromTexture(tr.screenShadowImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); } + if (0 && r_ssao->integer) + { + vec4i_t dstBox; + VectorSet4(dstBox, 0, glConfig.vidHeight, 512, -512); + FBO_BlitFromTexture(tr.screenSsaoImage, NULL, NULL, NULL, dstBox, NULL, NULL, 0); + VectorSet4(dstBox, 512, glConfig.vidHeight, 512, -512); + FBO_BlitFromTexture(tr.quarterImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); + VectorSet4(dstBox, 1024, glConfig.vidHeight, 512, -512); + FBO_BlitFromTexture(tr.quarterImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); + } + if (0) { vec4i_t dstBox; @@ -2746,6 +3188,49 @@ static const void *RB_EndTimedBlock( const void *data ) } +/* +============= +RB_DrawSurfs + +============= +*/ +static const void *RB_DrawSurfs(const void *data) { + const drawSurfsCommand_t *cmd; + + // finish any 2D drawing if needed + if (tess.numIndexes) { + RB_EndSurface(); + } + + cmd = (const drawSurfsCommand_t *)data; + + backEnd.refdef = cmd->refdef; + backEnd.viewParms = cmd->viewParms; + + // clear the z buffer, set the modelview, etc + RB_BeginDrawingView(); + + beginTimedBlockCommand_t cmd2; + cmd2.commandId = RC_BEGIN_TIMED_BLOCK; + cmd2.name = "Update Constants"; + cmd2.timerHandle = tr.numTimedBlocks++; + RB_BeginTimedBlock(&cmd2); + + RB_UpdateConstants(cmd->drawSurfs, cmd->numDrawSurfs); + + endTimedBlockCommand_t cmd3; + cmd3.commandId = RC_END_TIMED_BLOCK; + cmd3.timerHandle = cmd2.timerHandle; + RB_EndTimedBlock(&cmd3); + + RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); + + RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); + + return (const void *)(cmd + 1); +} + + /* ==================== RB_ExecuteRenderCommands @@ -2819,3 +3304,4 @@ void RB_ExecuteRenderCommands( const void *data ) { } } + diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 523bdcb151..d57cd237f9 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -327,6 +327,8 @@ void GLimp_InitCoreFunctions() // Buffer objects qglGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &glRefConfig.uniformBufferOffsetAlignment); + qglGetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE, &glRefConfig.maxUniformBlockSize); + qglGetIntegerv(GL_MAX_UNIFORM_BUFFER_BINDINGS, &glRefConfig.maxUniformBufferBindings); GetGLFunction (qglBindBuffer, "glBindBuffer", qtrue); GetGLFunction (qglDeleteBuffers, "glDeleteBuffers", qtrue); GetGLFunction (qglGenBuffers, "glGenBuffers", qtrue); diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index 9d867255cf..302634bb23 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA typedef float matrix_t[16]; typedef float mat4x3_t[12]; +typedef float mat3x4_t[12]; typedef int vec2i_t[2]; typedef int vec3i_t[3]; typedef int vec4i_t[4]; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 71da292ad2..07ba3c37d3 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -87,10 +87,10 @@ static int currentRenderSurfIndex = 0; static CRenderableSurface *AllocGhoul2RenderableSurface() { - if ( currentRenderSurfIndex >= MAX_RENDERABLE_SURFACES ) + if ( currentRenderSurfIndex >= MAX_RENDERABLE_SURFACES - 1) { - ri.Error( ERR_DROP, "AllocRenderableSurface: Reached maximum number of Ghoul2 renderable surfaces (%d)", MAX_RENDERABLE_SURFACES ); - return NULL; + ResetGhoul2RenderableSurfaceHeap(); + ri.Printf( PRINT_DEVELOPER, "AllocRenderableSurface: Reached maximum number of Ghoul2 renderable surfaces (%d)\n", MAX_RENDERABLE_SURFACES ); } CRenderableSurface *rs = &renderSurfHeap[currentRenderSurfIndex++]; @@ -3440,30 +3440,24 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } -static void MDXABoneToMatrix ( const mdxaBone_t& bone, mat4x3_t& matrix ) +void RB_TransformBones(CRenderableSurface *surf, mat3x4_t *outMatrices) { - matrix[0] = bone.matrix[0][0]; - matrix[1] = bone.matrix[1][0]; - matrix[2] = bone.matrix[2][0]; - - matrix[3] = bone.matrix[0][1]; - matrix[4] = bone.matrix[1][1]; - matrix[5] = bone.matrix[2][1]; - - matrix[6] = bone.matrix[0][2]; - matrix[7] = bone.matrix[1][2]; - matrix[8] = bone.matrix[2][2]; + const mdxmSurface_t *surfData = surf->surfaceData; + const int *boneReferences = + (const int *)((const byte *)surfData + surfData->ofsBoneReferences); - matrix[9] = bone.matrix[0][3]; - matrix[10] = bone.matrix[1][3]; - matrix[11] = bone.matrix[2][3]; + for (int i = 0; i < surfData->numBoneReferences; ++i) + { + const mdxaBone_t& bone = surf->boneCache->EvalRender(boneReferences[i]); + Com_Memcpy( + outMatrices + i, + &bone.matrix[0][0], + sizeof(*outMatrices)); + } } void RB_SurfaceGhoul( CRenderableSurface *surf ) { - static mat4x3_t boneMatrices[20] = {}; - - mdxmSurface_t *surfData = surf->surfaceData; mdxmVBOMesh_t *surface = surf->vboMesh; if ( surface->vbo == NULL || surface->ibo == NULL ) @@ -3486,15 +3480,6 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.maxIndex = surface->maxIndex; tess.firstIndex = surface->indexOffset; - int *boneReferences = (int *)((byte *)surfData + surfData->ofsBoneReferences); - for ( int i = 0; i < surfData->numBoneReferences; i++ ) - { - const mdxaBone_t& bone = surf->boneCache->EvalRender (boneReferences[i]); - MDXABoneToMatrix (bone, boneMatrices[i]); - } - - glState.boneMatrices = boneMatrices; - glState.numBones = surfData->numBoneReferences; glState.skeletalAnimation = qtrue; RB_EndSurface(); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 82460e1b25..6e0aa80d4f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -27,7 +27,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA void GLSL_BindNullProgram(void); const uniformBlockInfo_t uniformBlocksInfo[UNIFORM_BLOCK_COUNT] = { - { 10, "SurfaceSprite", sizeof(SurfaceSpriteBlock) } + { 0, "Camera", sizeof(CameraBlock) }, + { 1, "Scene", sizeof(SceneBlock) }, + { 2, "Lights", sizeof(LightsBlock) }, + { 3, "Fogs", sizeof(FogsBlock) }, + { 4, "Entity", sizeof(EntityBlock) }, + { 5, "ShaderInstance", sizeof(ShaderInstanceBlock) }, + { 6, "Bones", sizeof(SkeletonBoneMatricesBlock) }, + { 10, "SurfaceSprite", sizeof(SurfaceSpriteBlock) }, }; typedef struct uniformInfo_s @@ -73,10 +80,6 @@ static uniformInfo_t uniformsInfo[] = { "u_TCGen0Vector1", GLSL_VEC3, 1 }, { "u_TCGen1", GLSL_INT, 1 }, - { "u_DeformType", GLSL_INT, 1 }, - { "u_DeformFunc", GLSL_INT, 1 }, - { "u_DeformParams", GLSL_FLOAT, 7 }, - { "u_ColorGen", GLSL_INT, 1 }, { "u_AlphaGen", GLSL_INT, 1 }, { "u_Color", GLSL_VEC4, 1 }, @@ -93,16 +96,9 @@ static uniformInfo_t uniformsInfo[] = { "u_AmbientLight", GLSL_VEC3, 1 }, { "u_DirectedLight", GLSL_VEC3, 1 }, { "u_Disintegration", GLSL_VEC4, 1 }, + { "u_LightIndex", GLSL_INT, 1 }, - { "u_PortalRange", GLSL_FLOAT, 1 }, - - { "u_FogDistance", GLSL_VEC4, 1 }, - { "u_FogDepth", GLSL_VEC4, 1 }, - { "u_FogEyeT", GLSL_FLOAT, 1 }, { "u_FogColorMask", GLSL_VEC4, 1 }, - { "u_FogPlane", GLSL_VEC4, 1 }, - { "u_FogHasPlane", GLSL_INT, 1 }, - { "u_FogDepthToOpaque", GLSL_FLOAT, 1 }, { "u_ModelMatrix", GLSL_MAT4x4, 1 }, { "u_ModelViewProjectionMatrix", GLSL_MAT4x4, 1 }, @@ -123,14 +119,8 @@ static uniformInfo_t uniformsInfo[] = { "u_AutoExposureMinMax", GLSL_VEC2, 1 }, { "u_ToneMinAvgMaxLinear", GLSL_VEC3, 1 }, - { "u_PrimaryLightOrigin", GLSL_VEC4, 1 }, - { "u_PrimaryLightColor", GLSL_VEC3, 1 }, - { "u_PrimaryLightAmbient", GLSL_VEC3, 1 }, - { "u_PrimaryLightRadius", GLSL_FLOAT, 1 }, - { "u_CubeMapInfo", GLSL_VEC4, 1 }, - { "u_BoneMatrices", GLSL_MAT4x3, 20 }, { "u_AlphaTestType", GLSL_INT, 1 }, { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, @@ -859,17 +849,105 @@ void GLSL_InitUniforms(shaderProgram_t *program) program->uniformBlocks = 0; for ( int i = 0; i < UNIFORM_BLOCK_COUNT; ++i ) { - GLuint blockIndex = qglGetUniformBlockIndex(program->program, - uniformBlocksInfo[i].name); - if ( blockIndex == GL_INVALID_INDEX ) - { + const GLuint blockIndex = qglGetUniformBlockIndex( + program->program, uniformBlocksInfo[i].name); + if (blockIndex == GL_INVALID_INDEX) continue; - } - - qglUniformBlockBinding(program->program, blockIndex, - uniformBlocksInfo[i].slot); + ri.Printf( + PRINT_DEVELOPER, + "Binding block %d (name '%s', size %zu bytes) to slot %d\n", + blockIndex, + uniformBlocksInfo[i].name, + uniformBlocksInfo[i].size, + uniformBlocksInfo[i].slot); + qglUniformBlockBinding( + program->program, blockIndex, uniformBlocksInfo[i].slot); program->uniformBlocks |= (1u << i); } + + GLint numActiveUniformBlocks = 0; + qglGetProgramiv(program->program, GL_ACTIVE_UNIFORM_BLOCKS, &numActiveUniformBlocks); + ri.Printf(PRINT_DEVELOPER, "..num uniform blocks: %d\n", numActiveUniformBlocks); + for (int i = 0; i < numActiveUniformBlocks; ++i) + { + char blockName[512]; + qglGetActiveUniformBlockName( + program->program, + i, + sizeof(blockName), + nullptr, + blockName); + + GLint blockSize = 0; + qglGetActiveUniformBlockiv( + program->program, i, GL_UNIFORM_BLOCK_DATA_SIZE, &blockSize); + + ri.Printf(PRINT_DEVELOPER, "..block %d: %s (%d bytes)\n", i, blockName, blockSize); + GLint numMembers = 0; + qglGetActiveUniformBlockiv( + program->program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numMembers); + + if (numMembers > 0) + { + GLuint memberIndices[128]; + qglGetActiveUniformBlockiv( + program->program, + i, + GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, + (GLint *)memberIndices); + + GLint memberOffsets[128]; + qglGetActiveUniformsiv( + program->program, + numMembers, + memberIndices, + GL_UNIFORM_OFFSET, + memberOffsets); + + GLint memberTypes[128]; + qglGetActiveUniformsiv( + program->program, + numMembers, + memberIndices, + GL_UNIFORM_TYPE, + memberTypes); + + for (int j = 0; j < numMembers; ++j) + { + char memberName[512]; + qglGetActiveUniformName( + program->program, + memberIndices[j], + sizeof(memberName), + nullptr, + memberName); + + ri.Printf(PRINT_DEVELOPER, "....uniform '%s'\n", memberName); + ri.Printf(PRINT_DEVELOPER, "......offset: %d\n", memberOffsets[j]); + switch (memberTypes[j]) + { + case GL_FLOAT: + ri.Printf(PRINT_DEVELOPER, "......type: float\n"); + break; + case GL_FLOAT_VEC2: + ri.Printf(PRINT_DEVELOPER, "......type: vec2\n"); + break; + case GL_FLOAT_VEC3: + ri.Printf(PRINT_DEVELOPER, "......type: vec3\n"); + break; + case GL_FLOAT_VEC4: + ri.Printf(PRINT_DEVELOPER, "......type: vec4\n"); + break; + case GL_INT: + ri.Printf(PRINT_DEVELOPER, "......type: int\n"); + break; + default: + ri.Printf(PRINT_DEVELOPER, "......type: other\n"); + break; + } + } + } + } } void GLSL_FinishGPUShader(shaderProgram_t *program) @@ -882,6 +960,9 @@ void GLSL_FinishGPUShader(shaderProgram_t *program) void GLSL_SetUniforms( shaderProgram_t *program, UniformData *uniformData ) { + if (uniformData == nullptr) + return; + UniformData *data = uniformData; if (data == nullptr) return; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 8f955c8eec..646a07de93 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3177,7 +3177,7 @@ void R_CreateBuiltinImages( void ) { for (x = 0; x < MAX_DLIGHTS; x++) { tr.shadowCubemaps[x].image = R_CreateImage( - va("*shadowcubemap%i", x), NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, + va("*shadowcubemap%i", x), NULL, DSHADOW_MAP_SIZE, DSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, GL_DEPTH_COMPONENT24); GL_Bind(tr.shadowCubemaps[x].image); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 3232efdfe5..845b71d804 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_weather.h" #include +static size_t STATIC_UNIFORM_BUFFER_SIZE = 1 * 1024 * 1024; static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; static size_t FRAME_VERTEX_BUFFER_SIZE = 12*1024*1024; static size_t FRAME_INDEX_BUFFER_SIZE = 4*1024*1024; @@ -1671,6 +1672,7 @@ static void R_InitBackEndFrameData() frame->ubo = ubos[i]; frame->uboWriteOffset = 0; + frame->uboSize = FRAME_UNIFORM_BUFFER_SIZE; qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo); // TODO: persistently mapped UBOs @@ -1713,6 +1715,33 @@ static void R_InitBackEndFrameData() backEndData->currentFrame = backEndData->frames; } +static void R_InitStaticConstants() +{ + EntityBlock entity2DBlock = {}; + entity2DBlock.fxVolumetricBase = -1.0f; + + Matrix16Identity(entity2DBlock.modelMatrix); + Matrix16Ortho( + 0.0f, + 640.0f, + 480.0f, + 0.0f, + 0.0f, + 1.0f, + entity2DBlock.modelViewProjectionMatrix); + + qglBindBuffer(GL_UNIFORM_BUFFER, tr.staticUbo); + qglBufferData( + GL_UNIFORM_BUFFER, + STATIC_UNIFORM_BUFFER_SIZE, + nullptr, + GL_STATIC_DRAW); + + tr.entity2DUboOffset = 0; + qglBufferSubData( + GL_UNIFORM_BUFFER, 0, sizeof(entity2DBlock), &entity2DBlock); +} + static void R_ShutdownBackEndFrameData() { if ( !backEndData ) @@ -1823,8 +1852,9 @@ void R_Init( void ) { InitOpenGL(); - R_InitVBOs(); + R_InitGPUBuffers(); + R_InitStaticConstants(); R_InitBackEndFrameData(); R_InitImages(); @@ -1881,7 +1911,7 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { R_ShutDownQueries(); FBO_Shutdown(); R_DeleteTextures(); - R_ShutdownVBOs(); + R_DestroyGPUBuffers(); GLSL_ShutdownGPUShaders(); if ( destroyWindow && restarting ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 2dbe35ff4e..5146513f66 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -60,6 +60,7 @@ typedef unsigned int glIndex_t; #define MAX_CALC_PSHADOWS 64 #define MAX_DRAWN_PSHADOWS 32 // do not increase past 32, because bit flags are used on surfaces #define PSHADOW_MAP_SIZE 1024 +#define DSHADOW_MAP_SIZE 512 #define CUBE_MAP_MIPS 8 #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) @@ -683,6 +684,91 @@ struct SurfaceSpriteBlock float fadeScale; float widthVariance; float heightVariance; + float pad0; +}; + +struct CameraBlock +{ + vec4_t viewInfo; + vec3_t viewOrigin; + float pad0; + vec3_t viewForward; + float pad1; + vec3_t viewLeft; + float pad2; + vec3_t viewUp; + float pad3; +}; + +struct SceneBlock +{ + vec4_t primaryLightOrigin; + vec3_t primaryLightAmbient; + float pad0; + vec3_t primaryLightColor; + float primaryLightRadius; +}; + +struct LightsBlock +{ + struct Light + { + vec4_t origin; + vec3_t color; + float radius; + }; + + int numLights; + float pad0[3]; + + Light lights[MAX_DLIGHTS]; +}; + +struct FogsBlock +{ + struct Fog + { + vec4_t plane; + vec4_t color; + float depthToOpaque; + int hasPlane; + float pad1[2]; + }; + + int numFogs; + float pad0[3]; + Fog fogs[16]; +}; + +struct EntityBlock +{ + matrix_t modelMatrix; + matrix_t modelViewProjectionMatrix; + vec4_t lightOrigin; + vec3_t ambientLight; + float lightRadius; + vec3_t directedLight; + float fxVolumetricBase; + vec3_t modelLightDir; + float vertexLerp; + vec3_t localViewOrigin; + int fogIndex; +}; + +struct ShaderInstanceBlock +{ + vec4_t deformParams0; + vec4_t deformParams1; + float time; + float portalRange; + int deformType; + int deformFunc; + float pad1; +}; + +struct SkeletonBoneMatricesBlock +{ + mat3x4_t matrices[20]; }; struct surfaceSprite_t @@ -1127,6 +1213,13 @@ enum enum uniformBlock_t { + UNIFORM_BLOCK_CAMERA, + UNIFORM_BLOCK_SCENE, + UNIFORM_BLOCK_LIGHTS, + UNIFORM_BLOCK_FOGS, + UNIFORM_BLOCK_ENTITY, + UNIFORM_BLOCK_SHADER_INSTANCE, + UNIFORM_BLOCK_BONES, UNIFORM_BLOCK_SURFACESPRITE, UNIFORM_BLOCK_COUNT }; @@ -1209,10 +1302,6 @@ typedef enum UNIFORM_TCGEN0VECTOR1, UNIFORM_TCGEN1, - UNIFORM_DEFORMTYPE, - UNIFORM_DEFORMFUNC, - UNIFORM_DEFORMPARAMS, - UNIFORM_COLORGEN, UNIFORM_ALPHAGEN, UNIFORM_COLOR, @@ -1229,16 +1318,9 @@ typedef enum UNIFORM_AMBIENTLIGHT, UNIFORM_DIRECTEDLIGHT, UNIFORM_DISINTEGRATION, + UNIFORM_LIGHTINDEX, - UNIFORM_PORTALRANGE, - - UNIFORM_FOGDISTANCE, - UNIFORM_FOGDEPTH, - UNIFORM_FOGEYET, UNIFORM_FOGCOLORMASK, - UNIFORM_FOGPLANE, - UNIFORM_FOGHASPLANE, - UNIFORM_FOGDEPTHTOOPAQUE, UNIFORM_MODELMATRIX, UNIFORM_MODELVIEWPROJECTIONMATRIX, @@ -1259,14 +1341,8 @@ typedef enum UNIFORM_AUTOEXPOSUREMINMAX, UNIFORM_TONEMINAVGMAXLINEAR, - UNIFORM_PRIMARYLIGHTORIGIN, - UNIFORM_PRIMARYLIGHTCOLOR, - UNIFORM_PRIMARYLIGHTAMBIENT, - UNIFORM_PRIMARYLIGHTRADIUS, - UNIFORM_CUBEMAPINFO, - UNIFORM_BONE_MATRICES, UNIFORM_ALPHA_TEST_TYPE, UNIFORM_FX_VOLUMETRIC_BASE, @@ -2013,9 +2089,10 @@ struct vertexAttribute_t int stepRate; }; +#define MAX_UBO_BINDINGS (16) struct bufferBinding_t { - VBO_t *vbo; + GLuint buffer; int offset; int size; }; @@ -2037,13 +2114,13 @@ typedef struct glstate_s { int vertexAttribsTexCoordOffset[2]; qboolean vertexAnimation; qboolean skeletalAnimation; - mat4x3_t *boneMatrices; - int numBones; shaderProgram_t *currentProgram; FBO_t *currentFBO; VBO_t *currentVBO; IBO_t *currentIBO; bufferBinding_t currentXFBBO; + GLuint currentGlobalUBO; + bufferBinding_t currentUBOs[MAX_UBO_BINDINGS]; matrix_t modelview; matrix_t projection; matrix_t modelviewProjection; @@ -2084,6 +2161,8 @@ typedef struct { int textureCompression; int uniformBufferOffsetAlignment; + int maxUniformBlockSize; + int maxUniformBufferBindings; qboolean immutableTextures; qboolean immutableBuffers; @@ -2153,6 +2232,7 @@ typedef struct { orientationr_t ori; backEndCounters_t pc; trRefEntity_t *currentEntity; + int currentDrawSurfIndex; qboolean skyRenderedThisView; // flag for drawing sun qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes @@ -2165,6 +2245,14 @@ typedef struct { qboolean depthFill; } backEndState_t; +struct EntityShaderUboOffset +{ + bool inuse; + int entityNum; + int shaderNum; + int offset; +}; + /* ** trGlobals_t ** @@ -2308,6 +2396,21 @@ typedef struct trGlobals_s { shaderProgram_t weatherUpdateShader; shaderProgram_t weatherShader; + GLuint staticUbo; + int entity2DUboOffset; + + int cameraUboOffset; + + int sceneUboOffset; + int lightsUboOffset; + int fogsUboOffset; + int skyEntityUboOffset; + int entityUboOffsets[MAX_REFENTITIES + 1]; + + int *animationBoneUboOffsets; + EntityShaderUboOffset *shaderInstanceUboOffsetsMap; + int shaderInstanceUboOffsetsMapSize; + // ----------------------------------------- viewParms_t viewParms; @@ -2958,14 +3061,18 @@ void R_BindNullVBO(void); void R_BindIBO(IBO_t * ibo); void R_BindNullIBO(void); -void R_InitVBOs(void); -void R_ShutdownVBOs(void); +void R_InitGPUBuffers(void); +void R_DestroyGPUBuffers(void); void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); void RB_CommitInternalBufferData(); -void RB_BindUniformBlock(uniformBlock_t block); -void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data); + +void RB_BindUniformBlock(GLuint ubo, uniformBlock_t block, int offset); +int RB_BindAndUpdateFrameUniformBlock(uniformBlock_t block, void *data); +void RB_BeginConstantsUpdate(struct gpuFrame_t *frame); +void RB_EndConstantsUpdate(const struct gpuFrame_t *frame); +int RB_AppendConstantsData(struct gpuFrame_t *frame, const void *data, size_t dataSize); void CalculateVertexArraysProperties(uint32_t attributes, VertexArraysProperties *properties); void CalculateVertexArraysFromVBO(uint32_t attributes, const VBO_t *vbo, VertexArraysProperties *properties); @@ -3143,6 +3250,7 @@ class CRenderableSurface void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); void RB_SurfaceGhoul( CRenderableSurface *surface ); +void RB_TransformBones(CRenderableSurface *surf, mat3x4_t *outMatrices); /* Ghoul2 Insert End */ @@ -3362,6 +3470,9 @@ struct gpuFrame_t GLsync sync; GLuint ubo; size_t uboWriteOffset; + size_t uboSize; + size_t uboMapBase; + void *uboMemory; screenshotReadback_t screenshotReadback; @@ -3489,7 +3600,8 @@ struct SamplerBinding struct UniformBlockBinding { - void *data; + GLuint ubo; + int offset; uniformBlock_t block; }; @@ -3562,6 +3674,31 @@ struct DrawItem DrawCommand draw; }; +void DrawItemSetSamplerBindings( + DrawItem& drawItem, + const SamplerBinding *bindings, + uint32_t count, + Allocator& allocator); +void DrawItemSetUniformBlockBindings( + DrawItem& drawItem, + const UniformBlockBinding *bindings, + uint32_t count, + Allocator& allocator); +void DrawItemSetVertexAttributes( + DrawItem& drawItem, + const vertexAttribute_t *attributes, + uint32_t count, + Allocator& allocator); + +template +void DrawItemSetUniformBlockBindings( + DrawItem& drawItem, + const UniformBlockBinding(&bindings)[N], + Allocator& allocator) +{ + DrawItemSetUniformBlockBindings(drawItem, &bindings[0], N, allocator); +} + class UniformDataWriter { public: diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1b708354b6..bd898bcc14 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2149,8 +2149,8 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.viewportX = 0; shadowParms.viewportY = 0; - shadowParms.viewportWidth = PSHADOW_MAP_SIZE; - shadowParms.viewportHeight = PSHADOW_MAP_SIZE; + shadowParms.viewportWidth = DSHADOW_MAP_SIZE; + shadowParms.viewportHeight = DSHADOW_MAP_SIZE; shadowParms.isPortal = qfalse; shadowParms.isMirror = qtrue; // because it is diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 8cb1e214a6..1a078a9d95 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -323,108 +323,6 @@ static void ComputeTexMods( shaderStage_t *pStage, int bundleNum, float *outMatr } } - -static void ComputeDeformValues(deform_t *type, genFunc_t *waveFunc, float deformParams[7]) -{ - // u_DeformGen - *type = DEFORM_NONE; - *waveFunc = GF_NONE; - - if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) - { - *type = DEFORM_DISINTEGRATION; - return; - } - - if(!ShaderRequiresCPUDeforms(tess.shader)) - { - deformStage_t *ds; - - // only support the first one - ds = &tess.shader->deforms[0]; - - switch (ds->deformation) - { - case DEFORM_WAVE: - *type = DEFORM_WAVE; - *waveFunc = ds->deformationWave.func; - - deformParams[0] = ds->deformationWave.base; - deformParams[1] = ds->deformationWave.amplitude; - deformParams[2] = ds->deformationWave.phase; - deformParams[3] = ds->deformationWave.frequency; - deformParams[4] = ds->deformationSpread; - deformParams[5] = 0.0f; - deformParams[6] = 0.0f; - break; - - case DEFORM_BULGE: - *type = DEFORM_BULGE; - - deformParams[0] = 0.0f; - deformParams[1] = ds->bulgeHeight; // amplitude - deformParams[2] = ds->bulgeWidth; // phase - deformParams[3] = ds->bulgeSpeed; // frequency - deformParams[4] = 0.0f; - deformParams[5] = 0.0f; - deformParams[6] = 0.0f; - - if (ds->bulgeSpeed == 0.0f && ds->bulgeWidth == 0.0f) - *type = DEFORM_BULGE_UNIFORM; - - break; - - case DEFORM_MOVE: - *type = DEFORM_MOVE; - *waveFunc = ds->deformationWave.func; - - deformParams[0] = ds->deformationWave.base; - deformParams[1] = ds->deformationWave.amplitude; - deformParams[2] = ds->deformationWave.phase; - deformParams[3] = ds->deformationWave.frequency; - deformParams[4] = ds->moveVector[0]; - deformParams[5] = ds->moveVector[1]; - deformParams[6] = ds->moveVector[2]; - - break; - - case DEFORM_NORMALS: - *type = DEFORM_NORMALS; - - deformParams[0] = 0.0f; - deformParams[1] = ds->deformationWave.amplitude; // amplitude - deformParams[2] = 0.0f; // phase - deformParams[3] = ds->deformationWave.frequency; // frequency - deformParams[4] = 0.0f; - deformParams[5] = 0.0f; - deformParams[6] = 0.0f; - break; - - case DEFORM_PROJECTION_SHADOW: - *type = DEFORM_PROJECTION_SHADOW; - - deformParams[0] = backEnd.ori.axis[0][2]; - deformParams[1] = backEnd.ori.axis[1][2]; - deformParams[2] = backEnd.ori.axis[2][2]; - deformParams[3] = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; - - vec3_t lightDir; - VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); - lightDir[2] = 0.0f; - VectorNormalize(lightDir); - VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); - - deformParams[4] = lightDir[0]; - deformParams[5] = lightDir[1]; - deformParams[6] = lightDir[2]; - break; - - default: - break; - } - } -} - static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor, int blend, colorGen_t *forceRGBGen, alphaGen_t *forceAlphaGen ) { colorGen_t rgbGen = pStage->rgbGen; @@ -648,45 +546,6 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t #endif } - -static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, float *eyeT) -{ - // from RB_CalcFogTexCoords() - fog_t *fog; - vec3_t local; - - if (!tess.fogNum) - return; - - fog = tr.world->fogs + tess.fogNum; - - VectorSubtract( backEnd.ori.origin, backEnd.viewParms.ori.origin, local ); - fogDistanceVector[0] = -backEnd.ori.modelViewMatrix[2]; - fogDistanceVector[1] = -backEnd.ori.modelViewMatrix[6]; - fogDistanceVector[2] = -backEnd.ori.modelViewMatrix[10]; - fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.ori.axis[0] ); - - // scale the fog vectors based on the fog's thickness - VectorScale4(fogDistanceVector, fog->tcScale, fogDistanceVector); - - // rotate the gradient vector for this orientation - if ( fog->hasSurface ) { - fogDepthVector[0] = fog->surface[0] * backEnd.ori.axis[0][0] + - fog->surface[1] * backEnd.ori.axis[0][1] + fog->surface[2] * backEnd.ori.axis[0][2]; - fogDepthVector[1] = fog->surface[0] * backEnd.ori.axis[1][0] + - fog->surface[1] * backEnd.ori.axis[1][1] + fog->surface[2] * backEnd.ori.axis[1][2]; - fogDepthVector[2] = fog->surface[0] * backEnd.ori.axis[2][0] + - fog->surface[1] * backEnd.ori.axis[2][1] + fog->surface[2] * backEnd.ori.axis[2][2]; - fogDepthVector[3] = -fog->surface[3] + DotProduct( backEnd.ori.origin, fog->surface ); - - *eyeT = DotProduct( backEnd.ori.viewOrigin, fogDepthVector ) + fogDepthVector[3]; - } else { - VectorClear4(fogDepthVector); - *eyeT = 1; // non-surface fog always has eye inside - } -} - - static void ComputeFogColorMask( shaderStage_t *pStage, vec4_t fogColorMask ) { switch(pStage->adjustColorsForFog) @@ -884,18 +743,101 @@ void RB_FillDrawCommand( } } -static void ForwardDlight( const shaderCommands_t *input, VertexArraysProperties *vertexArrays ) +static UniformBlockBinding GetEntityBlockUniformBinding( + const trRefEntity_t *refEntity) { - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.block = UNIFORM_BLOCK_ENTITY; + + if (refEntity == &backEnd.entity2D) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.entity2DUboOffset; + } + else + { + binding.ubo = currentFrameUbo; + if (refEntity == &tr.worldEntity) + { + binding.offset = tr.entityUboOffsets[REFENTITYNUM_WORLD]; + } + else + { + const int refEntityNum = refEntity - backEnd.refdef.entities; + binding.offset = tr.entityUboOffsets[refEntityNum]; + } + } + return binding; +} + +static UniformBlockBinding GetBonesBlockUniformBinding( + const trRefEntity_t *refEntity) +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.ubo = currentFrameUbo; + binding.block = UNIFORM_BLOCK_BONES; + + if (refEntity == &tr.worldEntity) + binding.offset = 0; + else if (refEntity == &backEnd.entity2D) + binding.offset = 0; + else + { + const int drawSurfNum = backEnd.currentDrawSurfIndex; + binding.offset = tr.animationBoneUboOffsets[drawSurfNum]; + } + + return binding; +} + +int RB_GetEntityShaderUboOffset( + EntityShaderUboOffset *offsetMap, + int mapSize, + int entityNum, + int shaderNum); +static UniformBlockBinding GetShaderInstanceBlockUniformBinding( + const trRefEntity_t *refEntity, const shader_t *shader) +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.ubo = currentFrameUbo; + binding.block = UNIFORM_BLOCK_SHADER_INSTANCE; + + if (refEntity == &tr.worldEntity) + { + binding.offset = RB_GetEntityShaderUboOffset( + tr.shaderInstanceUboOffsetsMap, + tr.shaderInstanceUboOffsetsMapSize, + REFENTITYNUM_WORLD, + shader->index); + } + else if (refEntity == &backEnd.entity2D) + { + binding.offset = 0; // FIXME: FIX THIS! + } + else + { + const int refEntityNum = refEntity - backEnd.refdef.entities; + binding.offset = RB_GetEntityShaderUboOffset( + tr.shaderInstanceUboOffsetsMap, + tr.shaderInstanceUboOffsetsMapSize, + refEntityNum, + shader->index); + } + + return binding; +} + +static void ForwardDlight( const shaderCommands_t *input, VertexArraysProperties *vertexArrays ) +{ if ( !backEnd.refdef.num_dlights ) { return; } - ComputeDeformValues(&deformType, &deformGen, deformParams); - + Allocator& frameAllocator = *backEndData->perFrameMemory; cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; @@ -931,41 +873,24 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie stateBits = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; shaderGroup = tr.dlightShader; - if ( deformGen != DGEN_NONE ) + if (input->shader->numDeforms && + !ShaderRequiresCPUDeforms(input->shader)) + { index |= DLIGHTDEF_USE_DEFORM_VERTEXES; + } } shaderProgram_t *sp = shaderGroup + index; for ( int l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - vec4_t texMatrix; - vec4_t texOffTurb; if ( !( tess.dlightBits & ( 1 << l ) ) ) { continue; // this surface definately doesn't have any of this light } - dlight_t *dl = &backEnd.refdef.dlights[l]; - float radius = dl->radius; - backEnd.pc.c_lightallDraws++; uniformDataWriter.Start(sp); - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - uniformDataWriter.SetUniformVec3(UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); - - uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); - - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) - { - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); - uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); - } - { vec4_t baseColor; vec4_t vertColor; @@ -976,28 +901,22 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); } +#if 0 // TODO: Revisit this later, isn't it simply an alphaGen? if (pStage->alphaGen == AGEN_PORTAL) { uniformDataWriter.SetUniformFloat(UNIFORM_PORTALRANGE, tess.shader->portalRange); } +#endif uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, pStage->rgbGen); uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, pStage->alphaGen); - uniformDataWriter.SetUniformVec3(UNIFORM_DIRECTEDLIGHT, dl->color); + uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, l); - vec4_t vector = {}; - uniformDataWriter.SetUniformVec3(UNIFORM_AMBIENTLIGHT, vector); - - VectorCopy(dl->origin, vector); - vector[3] = 1.0f; - uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vector); - uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, radius); - - uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); - uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); - - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); + uniformDataWriter.SetUniformVec4( + UNIFORM_NORMALSCALE, pStage->normalScale); + uniformDataWriter.SetUniformVec4( + UNIFORM_SPECULARSCALE, pStage->specularScale); if (pStage->bundle[TB_DIFFUSEMAP].image[0]) samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); @@ -1028,6 +947,8 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie if (r_dlightMode->integer >= 2) samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l].image, TB_SHADOWMAP2); + vec4_t texMatrix; + vec4_t texOffTurb; ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); @@ -1037,6 +958,15 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie CaptureDrawData(input, pStage, 0, 0); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.lightsUboOffset, UNIFORM_BLOCK_LIGHTS }, + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader), + GetBonesBlockUniformBinding(backEnd.currentEntity) + }; + DrawItem item = {}; // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light @@ -1046,17 +976,16 @@ static void ForwardDlight( const shaderCommands_t *input, VertexArraysPropertie item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + item.uniformData = uniformDataWriter.Finish(frameAllocator); - item.numAttributes = vertexArrays->numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + frameAllocator, (int *)&item.numSamplerBindings); + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); @@ -1169,66 +1098,43 @@ RB_FogPass Blends a fog texture on top of everything else =================== */ -static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexArraysProperties *vertexArrays ) +static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - shaderProgram_t *sp; - - deform_t deformType; - genFunc_t deformGen; - vec5_t deformParams; - - ComputeDeformValues(&deformType, &deformGen, deformParams); - cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - UniformDataWriter uniformDataWriter; - int shaderBits = 0; - if (deformGen != DGEN_NONE) + if (input->shader->numDeforms && !ShaderRequiresCPUDeforms(input->shader)) shaderBits |= FOGDEF_USE_DEFORM_VERTEXES; if (glState.vertexAnimation) shaderBits |= FOGDEF_USE_VERTEX_ANIMATION; - if (glState.skeletalAnimation) + else if (glState.skeletalAnimation) shaderBits |= FOGDEF_USE_SKELETAL_ANIMATION; - sp = tr.fogShader + shaderBits; - uniformDataWriter.Start(sp); + shaderProgram_t *sp = tr.fogShader + shaderBits; backEnd.pc.c_fogDraws++; - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); - - uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); - - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) - { - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); - uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); - } - - uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); - qboolean hasPlane = fog == tr.world->globalFog ? qfalse : fog->hasSurface; - uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, hasPlane); - uniformDataWriter.SetUniformFloat( - UNIFORM_FOGDEPTHTOOPAQUE, - sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque); - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); - uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) stateBits |= GLS_DEPTHFUNC_EQUAL; + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader), + GetBonesBlockUniformBinding(backEnd.currentEntity) + }; + + Allocator& frameAllocator = *backEndData->perFrameMemory; DrawItem item = {}; item.renderState.stateBits = stateBits; item.renderState.cullType = cullType; @@ -1236,16 +1142,14 @@ static void RB_FogPass( shaderCommands_t *input, const fog_t *fog, const VertexA item.program = sp; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; - item.numAttributes = vertexArrays->numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); + const uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); } @@ -1402,12 +1306,7 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; - - ComputeDeformValues(&deformType, &deformGen, deformParams); - + Allocator& frameAllocator = *backEndData->perFrameMemory; cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; @@ -1488,36 +1387,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays assert(sp); uniformDataWriter.Start(sp); - uniformDataWriter.SetUniformMatrix4x4( UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - uniformDataWriter.SetUniformVec3(UNIFORM_LOCALVIEWORIGIN, backEnd.ori.viewOrigin); - - if (glState.skeletalAnimation) - { - uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); - } - - uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); - if (deformType != DEFORM_NONE) - { - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); - uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); - } - - uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); - if ( input->fogNum ) { - const fog_t *fog = tr.world->fogs + input->fogNum; - - uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, fog->color); - uniformDataWriter.SetUniformVec4(UNIFORM_FOGPLANE, fog->surface); - uniformDataWriter.SetUniformInt(UNIFORM_FOGHASPLANE, fog->hasSurface); - uniformDataWriter.SetUniformFloat(UNIFORM_FOGDEPTHTOOPAQUE, fog->parms.depthForOpaque); - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.refdef.vieworg); - vec4_t fogColorMask; ComputeFogColorMask(pStage, fogColorMask); uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); @@ -1527,7 +1398,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if ( backEnd.currentEntity->e.renderfx & RF_VOLUMETRIC ) { volumetricBaseValue = backEnd.currentEntity->e.shaderRGBA[0] / 255.0f; - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWFORWARD, backEnd.refdef.viewaxis[0]); } else { @@ -1555,30 +1425,12 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformFloat(UNIFORM_FX_VOLUMETRIC_BASE, volumetricBaseValue); - if (pStage->rgbGen == CGEN_LIGHTING_DIFFUSE || - pStage->rgbGen == CGEN_LIGHTING_DIFFUSE_ENTITY) - { - vec4_t vec; - - VectorScale(backEnd.currentEntity->ambientLight, 1.0f / 255.0f, vec); - uniformDataWriter.SetUniformVec3(UNIFORM_AMBIENTLIGHT, vec); - - VectorScale(backEnd.currentEntity->directedLight, 1.0f / 255.0f, vec); - uniformDataWriter.SetUniformVec3(UNIFORM_DIRECTEDLIGHT, vec); - - VectorCopy(backEnd.currentEntity->lightDir, vec); - vec[3] = 0.0f; - uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vec); - uniformDataWriter.SetUniformVec3(UNIFORM_MODELLIGHTDIR, backEnd.currentEntity->modelLightDir); - - uniformDataWriter.SetUniformFloat(UNIFORM_LIGHTRADIUS, 0.0f); - } - +#if 0 // TODO: Revisit this, isn't it just a alphaGen? if (pStage->alphaGen == AGEN_PORTAL) { uniformDataWriter.SetUniformFloat(UNIFORM_PORTALRANGE, tess.shader->portalRange); } - +#endif uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, forceRGBGen); uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, forceAlphaGen); @@ -1594,8 +1446,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec3(UNIFORM_TCGEN0VECTOR1, pStage->bundle[0].tcGenVectors[1]); } - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELMATRIX, backEnd.ori.modelMatrix); - uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); @@ -1626,9 +1476,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { samplerBindingsWriter.AddStaticImage(tr.screenShadowImage, TB_SHADOWMAP); - uniformDataWriter.SetUniformVec3(UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol); - uniformDataWriter.SetUniformVec3(UNIFORM_PRIMARYLIGHTCOLOR, backEnd.refdef.sunCol); - uniformDataWriter.SetUniformVec4(UNIFORM_PRIMARYLIGHTORIGIN, backEnd.refdef.sunDir); } if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && @@ -1749,22 +1596,33 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays CaptureDrawData(input, pStage, index, stage); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, + { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader), + GetBonesBlockUniformBinding(backEnd.currentEntity) + }; + DrawItem item = {}; item.renderState.stateBits = stateBits; item.renderState.cullType = cullType; item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + item.uniformData = uniformDataWriter.Finish(frameAllocator); - item.numAttributes = vertexArrays->numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + frameAllocator, (int *)&item.numSamplerBindings); + + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); @@ -1786,32 +1644,22 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - deform_t deformType; - genFunc_t deformGen; - float deformParams[7]; - - ComputeDeformValues(&deformType, &deformGen, deformParams); - + Allocator& frameAllocator = *backEndData->perFrameMemory; cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - UniformDataWriter uniformDataWriter; - - shaderProgram_t *sp = &tr.shadowmapShader; - uniformDataWriter.Start(sp); - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformFloat(UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation); - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMTYPE, deformType); - uniformDataWriter.SetUniformInt(UNIFORM_DEFORMFUNC, deformGen); - uniformDataWriter.SetUniformFloat(UNIFORM_DEFORMPARAMS, deformParams, 7); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, tess.shaderTime); + const UniformBlockBinding uniformBlockBindings[] = { + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader) + }; DrawItem item = {}; item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.renderState.cullType = cullType; - item.program = sp; + item.program = &tr.shadowmapShader; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.numAttributes = vertexArrays->numVertexArrays; @@ -1819,7 +1667,10 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope *backEndData->perFrameMemory, vertexArrays->numVertexArrays); memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); @@ -1934,7 +1785,7 @@ void RB_StageIteratorGeneric( void ) } if ( fog && tess.shader->fogPass ) { - RB_FogPass( &tess, fog, &vertexArrays ); + RB_FogPass( &tess, &vertexArrays ); } } diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index 7769b19bd9..c4c06aa3fc 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -37,7 +37,7 @@ void RB_ShadowTessEnd( shaderCommands_t *input, const VertexArraysProperties *ve { return; } - +#if 0 vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); @@ -81,6 +81,7 @@ void RB_ShadowTessEnd( shaderCommands_t *input, const VertexArraysProperties *ve uint32_t key = RB_CreateSortKey(item, 15, 15); RB_AddDrawItem(backEndData->currentPass, key, item); +#endif } diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 68b34e84fc..ccd6074b85 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -435,12 +435,11 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max UniformDataWriter uniformDataWriter; SamplerBindingsWriter samplerBindingsWriter; + Allocator& frameAllocator = *backEndData->perFrameMemory; shaderProgram_t *sp = &tr.lightallShader[0]; float colorScale = backEnd.refdef.colorScale; uniformDataWriter.Start(sp); - uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); uniformDataWriter.SetUniformVec4( UNIFORM_BASECOLOR, colorScale, colorScale, colorScale, 1.0f); uniformDataWriter.SetUniformVec4( @@ -452,20 +451,25 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max samplerBindingsWriter.AddStaticImage(image, TB_DIFFUSEMAP); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.skyEntityUboOffset, UNIFORM_BLOCK_ENTITY } + }; + DrawItem item = {}; item.renderState.cullType = CT_TWO_SIDED; item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, tess.shader); item.program = sp; item.ibo = backEndData->currentFrame->dynamicIbo; - item.numAttributes = vertexArrays.numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays.numVertexArrays); - memcpy(item.attributes, attribs, - sizeof(*item.attributes) * item.numAttributes); + item.uniformData = uniformDataWriter.Finish(frameAllocator); - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + frameAllocator, (int *)&item.numSamplerBindings); + + DrawItemSetVertexAttributes( + item, attribs, vertexArrays.numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, &tess); item.draw.params.indexed.numIndices -= tess.firstIndex; @@ -842,17 +846,7 @@ void RB_StageIteratorSky( void ) { // draw the outer skybox if ( tess.shader->sky.outerbox[0] && tess.shader->sky.outerbox[0] != tr.defaultImage ) { - // FIXME: this could be a lot cleaner - matrix_t trans, product; - matrix_t oldmodelview; - - Matrix16Copy( glState.modelview, oldmodelview ); - Matrix16Translation( backEnd.viewParms.ori.origin, trans ); - Matrix16Multiply( glState.modelview, trans, product ); - - GL_SetModelviewMatrix( product ); DrawSkyBox( tess.shader ); - GL_SetModelviewMatrix( oldmodelview ); } // generate the vertexes for all the clouds, which will be drawn diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 3f6570d7fa..79c5acd8f0 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2171,35 +2171,42 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) surfaceSpriteBlock->widthVariance = ss->variance[0]; surfaceSpriteBlock->heightVariance = ss->variance[1]; + const int uboDataOffset = RB_BindAndUpdateFrameUniformBlock( + UNIFORM_BLOCK_SURFACESPRITE, &surfaceSpriteBlock); + UniformDataWriter uniformDataWriter; uniformDataWriter.Start(program); - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3(UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + + uniformDataWriter.SetUniformMatrix4x4( + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + + Allocator& frameAllocator = *backEndData->perFrameMemory; SamplerBindingsWriter samplerBindingsWriter; samplerBindingsWriter.AddAnimatedImage(&firstStage->bundle[0], TB_COLORMAP); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, uboDataOffset, UNIFORM_BLOCK_SURFACESPRITE }, + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } + }; + DrawItem item = {}; item.renderState.stateBits = firstStage->stateBits; item.renderState.cullType = CT_TWO_SIDED; item.renderState.depthRange = DepthRange{0.0f, 1.0f}; item.program = program; item.ibo = surf->ibo; - tess.externalIBO = surf->ibo; - - item.numAttributes = surf->numAttributes; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, surf->numAttributes); - memcpy(item.attributes, surf->attributes, sizeof(*item.attributes)*surf->numAttributes); - - item.numUniformBlockBindings = 1; - item.uniformBlockBindings = ojkAllocArray(*backEndData->perFrameMemory, item.numUniformBlockBindings); - item.uniformBlockBindings[0].data = surfaceSpriteBlock; - item.uniformBlockBindings[0].block = UNIFORM_BLOCK_SURFACESPRITE; + + item.uniformData = uniformDataWriter.Finish(frameAllocator); - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + frameAllocator, (int *)&item.numSamplerBindings); + + DrawItemSetVertexAttributes( + item, surf->attributes, surf->numAttributes, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); item.draw.type = DRAW_COMMAND_INDEXED; item.draw.primitiveType = GL_TRIANGLES; @@ -2208,7 +2215,9 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) item.draw.params.indexed.firstIndex = 0; item.draw.params.indexed.numIndices = 6; -uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); + tess.externalIBO = surf->ibo; + + uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); } diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index a4f78e275a..361a69cde5 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -272,17 +272,18 @@ void R_BindNullIBO(void) /* ============ -R_InitVBOs +R_InitGPUBuffers ============ */ -void R_InitVBOs(void) +void R_InitGPUBuffers(void) { - ri.Printf(PRINT_ALL, "------- R_InitVBOs -------\n"); + ri.Printf(PRINT_ALL, "------- R_InitGPUBuffers -------\n"); // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is // actually created on first bind. qglGenBuffers(MAX_IBOS, tr.iboNames); qglGenBuffers(MAX_VBOS, tr.vboNames); + qglGenBuffers(1, &tr.staticUbo); tr.numVBOs = 0; tr.numIBOs = 0; @@ -295,16 +296,17 @@ void R_InitVBOs(void) /* ============ -R_ShutdownVBOs +R_DestroyGPUBuffers ============ */ -void R_ShutdownVBOs(void) +void R_DestroyGPUBuffers(void) { - ri.Printf(PRINT_ALL, "------- R_ShutdownVBOs -------\n"); + ri.Printf(PRINT_ALL, "------- R_DestroyGPUBuffers -------\n"); R_BindNullVBO(); R_BindNullIBO(); + qglDeleteBuffers(1, &tr.staticUbo); qglDeleteBuffers(MAX_IBOS, tr.iboNames); qglDeleteBuffers(MAX_VBOS, tr.vboNames); @@ -649,12 +651,33 @@ void RB_CommitInternalBufferData() currentFrame->dynamicVboCommitOffset = currentFrame->dynamicVboWriteOffset; } -void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data) +void RB_BindUniformBlock(GLuint ubo, uniformBlock_t block, int offset) +{ + const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; + + assert(blockInfo->slot < MAX_UBO_BINDINGS); + + bufferBinding_t *currentBinding = glState.currentUBOs + blockInfo->slot; + if (currentBinding->buffer != ubo || + currentBinding->offset != offset || + currentBinding->size != blockInfo->size) + { + qglBindBufferRange( + GL_UNIFORM_BUFFER, blockInfo->slot, ubo, offset, blockInfo->size); + + currentBinding->buffer = ubo; + currentBinding->offset = offset; + currentBinding->size = blockInfo->size; + } +} + +int RB_BindAndUpdateFrameUniformBlock(uniformBlock_t block, void *data) { const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; gpuFrame_t *thisFrame = backEndData->currentFrame; + const int offset = thisFrame->uboWriteOffset; - RB_BindUniformBlock(block); + RB_BindUniformBlock(thisFrame->ubo, block, offset); qglBufferSubData(GL_UNIFORM_BUFFER, thisFrame->uboWriteOffset, blockInfo->size, data); @@ -662,13 +685,52 @@ void RB_BindAndUpdateUniformBlock(uniformBlock_t block, void *data) const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; const size_t alignedBlockSize = (blockInfo->size + alignment) & ~alignment; thisFrame->uboWriteOffset += alignedBlockSize; + + return offset; } -void RB_BindUniformBlock(uniformBlock_t block) +void RB_BeginConstantsUpdate(gpuFrame_t *frame) { - const uniformBlockInfo_t *blockInfo = uniformBlocksInfo + block; - gpuFrame_t *thisFrame = backEndData->currentFrame; + if (glState.currentGlobalUBO != frame->ubo) + { + qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo); + glState.currentGlobalUBO = frame->ubo; + } - qglBindBufferRange(GL_UNIFORM_BUFFER, blockInfo->slot, - thisFrame->ubo, thisFrame->uboWriteOffset, blockInfo->size); + const GLbitfield mapFlags = + GL_MAP_WRITE_BIT | + GL_MAP_UNSYNCHRONIZED_BIT | + GL_MAP_FLUSH_EXPLICIT_BIT; + + frame->uboMapBase = frame->uboWriteOffset; + frame->uboMemory = qglMapBufferRange( + GL_UNIFORM_BUFFER, + frame->uboWriteOffset, + frame->uboSize - frame->uboWriteOffset, + mapFlags); } + +int RB_AppendConstantsData( + gpuFrame_t *frame, const void *data, size_t dataSize) +{ + const size_t writeOffset = frame->uboWriteOffset; + const size_t relativeOffset = writeOffset - frame->uboMapBase; + + memcpy((char *)frame->uboMemory + relativeOffset, data, dataSize); + + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + const size_t alignedBlockSize = (dataSize + alignment) & ~alignment; + + frame->uboWriteOffset += alignedBlockSize; + assert(frame->uboWriteOffset > 0); + return writeOffset; +} + +void RB_EndConstantsUpdate(const gpuFrame_t *frame) +{ + qglFlushMappedBufferRange( + GL_UNIFORM_BUFFER, + frame->uboMapBase, + frame->uboWriteOffset - frame->uboMapBase); + qglUnmapBuffer(GL_UNIFORM_BUFFER); +} \ No newline at end of file diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 95a0d1bba2..5d8e3cd45a 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -165,7 +165,7 @@ namespace DrawItem item = {}; item.renderState.transformFeedback = true; - item.transformFeedbackBuffer = {rainVBO, 0, rainVBO->vertexesSize}; + item.transformFeedbackBuffer = {rainVBO->vertexesVBO, 0, rainVBO->vertexesSize}; item.program = &tr.weatherUpdateShader; const size_t numAttribs = ARRAY_LEN(ws.attribsTemplate); From 2f7d8d06c3cdd982ec65785286ed3af4f2bb0425 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 23 Apr 2020 19:00:30 +0200 Subject: [PATCH 520/708] Bring back the old performance Just batched entity ubos and just commit complete skeletons, not just parts. --- codemp/rd-rend2/glsl/fogpass.glsl | 10 ++-- codemp/rd-rend2/glsl/generic.glsl | 12 +++-- codemp/rd-rend2/glsl/lightall.glsl | 37 +++++++++---- codemp/rd-rend2/glsl/shadowvolume.glsl | 63 +++++++++++++++++----- codemp/rd-rend2/tr_backend.cpp | 72 +++++++++++++++++++------- codemp/rd-rend2/tr_ghoul2.cpp | 62 +++++++++++++++------- codemp/rd-rend2/tr_local.h | 16 ++++-- codemp/rd-rend2/tr_shade.cpp | 65 +++++++++++++++++++++-- codemp/rd-rend2/tr_shadows.cpp | 64 ----------------------- 9 files changed, 258 insertions(+), 143 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 1065282d77..598ed558ce 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -20,7 +20,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; @@ -37,10 +37,12 @@ layout(std140) uniform ShaderInstance int u_DeformFunc; }; +#if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[20]; + mat3x4 u_BoneMatrices[52]; }; +#endif out vec3 var_WSPosition; @@ -176,6 +178,7 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) } #endif +#if defined(USE_SKELETAL_ANIMATION) mat4x3 GetBoneMatrix(uint index) { mat3x4 bone = u_BoneMatrices[index]; @@ -185,6 +188,7 @@ mat4x3 GetBoneMatrix(uint index) bone[0].z, bone[1].z, bone[2].z, bone[0].w, bone[1].w, bone[2].w); } +#endif void main() { @@ -252,7 +256,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index f6bbfe8742..b620300bdc 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -34,7 +34,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; @@ -51,10 +51,12 @@ layout(std140) uniform ShaderInstance int u_DeformFunc; }; +#if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[20]; + mat3x4 u_BoneMatrices[52]; }; +#endif uniform vec4 u_DiffuseTexMatrix; uniform vec4 u_DiffuseTexOffTurb; @@ -73,8 +75,6 @@ uniform int u_ColorGen; uniform int u_AlphaGen; #endif -uniform float u_FXVolumetricBase; - #if defined(USE_RGBAGEN) || defined(USE_DEFORM_VERTEXES) uniform vec4 u_Disintegration; // origin, threshhold #endif @@ -338,6 +338,7 @@ vec4 CalcColor(vec3 position, vec3 normal) } #endif +#if defined(USE_SKELETAL_ANIMATION) mat4x3 GetBoneMatrix(uint index) { mat3x4 bone = u_BoneMatrices[index]; @@ -347,6 +348,7 @@ mat4x3 GetBoneMatrix(uint index) bone[0].z, bone[1].z, bone[2].z, bone[0].w, bone[1].w, bone[2].w); } +#endif void main() { @@ -445,7 +447,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 438089f4bb..3dfd40b054 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -1,5 +1,5 @@ /*[Vertex]*/ -#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) && !defined(USE_LIGHT_VECTOR) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #define PER_PIXEL_LIGHTING #endif in vec2 attr_TexCoord0; @@ -53,17 +53,18 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; }; -uniform float u_FXVolumetricBase; +#if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[20]; + mat3x4 u_BoneMatrices[52]; }; +#endif #if defined(USE_DELUXEMAP) uniform vec4 u_EnableTextures; // x = normal, y = deluxe, z = specular, w = cube @@ -211,6 +212,7 @@ float CalcLightAttenuation(in bool isPoint, float normDist) return clamp(attenuation, 0.0, 1.0); } +#if defined(USE_SKELETAL_ANIMATION) mat4x3 GetBoneMatrix(uint index) { mat3x4 bone = u_BoneMatrices[index]; @@ -220,6 +222,7 @@ mat4x3 GetBoneMatrix(uint index) bone[0].z, bone[1].z, bone[2].z, bone[0].w, bone[1].w, bone[2].w); } +#endif void main() { @@ -281,7 +284,7 @@ void main() #endif #if defined(USE_LIGHT_VECTOR) - vec3 L = vec3(0.0); + vec3 L = u_LocalLightOrigin.xyz - (position * u_LocalLightOrigin.w); #elif defined(PER_PIXEL_LIGHTING) vec3 L = attr_LightDirection * 2.0 - vec3(1.0); L = (u_ModelMatrix * vec4(L, 0.0)).xyz; @@ -304,6 +307,14 @@ void main() else { var_Color = u_VertColor * attr_Color + u_BaseColor; + + #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) + float sqrLightDist = dot(L, L); + float attenuation = CalcLightAttenuation(u_LocalLightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); + float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); + + var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; +#endif } var_Color *= disintegration; @@ -330,7 +341,7 @@ void main() } /*[Fragment]*/ -#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) && !defined(USE_LIGHT_VECTOR) +#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) #define PER_PIXEL_LIGHTING #endif layout(std140) uniform Scene @@ -358,7 +369,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; @@ -720,9 +731,9 @@ void main() ambientColor = vec3 (0.0); attenuation = 1.0; #elif defined(USE_LIGHT_VECTOR) - lightColor = vec3(0.0); - ambientColor = vec3(0.0); - attenuation = 0.0; + lightColor = u_DirectedLight * var_Color.rgb; + ambientColor = u_AmbientLight * var_Color.rgb; + attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); #if defined(USE_DSHADOWS) if (var_LightDir.w > 0.0) { @@ -784,6 +795,12 @@ void main() vec3 Fd = CalcDiffuse(diffuse.rgb, NE, NL, LH, roughness); vec3 Fs = vec3(0.0); + #if defined(USE_LIGHT_VECTOR) + float NH = clamp(dot(N, H), 0.0, 1.0); + + Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); + #endif + #if defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular) float NH = clamp(dot(N, H), 0.0, 1.0); diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl index 536314d95b..ac5817230c 100644 --- a/codemp/rd-rend2/glsl/shadowvolume.glsl +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -7,12 +7,36 @@ in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif -uniform mat4 u_ModelViewProjectionMatrix; +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; -#if defined(USE_VERTEX_ANIMATION) -uniform float u_VertexLerp; -#elif defined(USE_SKELETAL_ANIMATION) -uniform mat4x3 u_BoneMatrices[20]; +#if defined(USE_SKELETAL_ANIMATION) +layout(std140) uniform Bones +{ + mat3x4 u_BoneMatrices[52]; +}; + +mat4x3 GetBoneMatrix(uint index) +{ + mat3x4 bone = u_BoneMatrices[index]; + return mat4x3( + bone[0].x, bone[1].x, bone[2].x, + bone[0].y, bone[1].y, bone[2].y, + bone[0].z, bone[1].z, bone[2].z, + bone[0].w, bone[1].w, bone[2].w); +} #endif out vec3 var_Position; @@ -23,10 +47,10 @@ void main() vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); #elif defined(USE_SKELETAL_ANIMATION) mat4x3 influence = - u_BoneMatrices[attr_BoneIndexes[0]] * attr_BoneWeights[0] + - u_BoneMatrices[attr_BoneIndexes[1]] * attr_BoneWeights[1] + - u_BoneMatrices[attr_BoneIndexes[2]] * attr_BoneWeights[2] + - u_BoneMatrices[attr_BoneIndexes[3]] * attr_BoneWeights[3]; + GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + + GetBoneMatrix(attr_BoneIndexes[1]) * attr_BoneWeights[1] + + GetBoneMatrix(attr_BoneIndexes[2]) * attr_BoneWeights[2] + + GetBoneMatrix(attr_BoneIndexes[3]) * attr_BoneWeights[3]; vec3 position = influence * vec4(attr_Position, 1.0); #else @@ -39,8 +63,21 @@ void main() layout(triangles) in; layout(triangle_strip, max_vertices = 18) out; -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec4 u_LightOrigin; // modelspace lightvector and length +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; + int u_FogIndex; +}; + in vec3 var_Position[]; void quad(vec3 first, vec3 second, vec3 L) @@ -61,8 +98,8 @@ void main() vec3 BmA = var_Position[1].xyz - var_Position[0].xyz; vec3 CmA = var_Position[2].xyz - var_Position[0].xyz; - if (dot(cross(BmA,CmA), -u_LightOrigin.xyz) > 0.0) { - vec3 L = u_LightOrigin.xyz*u_LightOrigin.w; + if (dot(cross(BmA,CmA), -u_ModelLightDir.xyz) > 0.0) { + vec3 L = u_ModelLightDir.xyz*u_LocalLightRadius; // front cap gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[0].xyz, 1.0); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 33e8b7a19f..3f09ef9078 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1385,16 +1385,6 @@ static void RB_SubmitDrawSurfs( if ( entityNum != oldEntityNum ) { RB_PrepareForEntity(entityNum, &oldDepthRange, originalTime); - - // set up the dynamic lighting if needed - if ( entityNum == REFENTITYNUM_WORLD || backEnd.currentEntity->needDlights ) - { - R_TransformDlights( - backEnd.refdef.num_dlights, - backEnd.refdef.dlights, - &backEnd.ori); - } - oldEntityNum = entityNum; } @@ -2374,11 +2364,23 @@ static void RB_UpdateEntityLightConstants( VectorScale(refEntity->ambientLight, normalizeFactor, entityBlock.ambientLight); VectorScale(refEntity->directedLight, normalizeFactor, entityBlock.directedLight); - VectorCopy(refEntity->modelLightDir, entityBlock.modelLightDir); - VectorCopy(refEntity->lightDir, entityBlock.lightOrigin); + + vec3_t lightDir; + float lightRadius; + VectorCopy(refEntity->modelLightDir, lightDir); + lightRadius = 300.0f; + if (r_shadows->integer == 2) + { + lightDir[2] = 0.0f; + VectorNormalize(lightDir); + VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); + lightRadius = refEntity->e.lightingOrigin[2] - refEntity->e.shadowPlane + 64.0f; + } + + VectorCopy(lightDir, entityBlock.modelLightDir); entityBlock.lightOrigin[3] = 0.0f; - entityBlock.lightRadius = 0.0f; + entityBlock.lightRadius = lightRadius; } static void RB_UpdateEntityMatrixConstants( @@ -2638,6 +2640,10 @@ static void RB_UpdateShaderAndEntityConstants( tr.shaderInstanceUboOffsetsMap, 0, sizeof(EntityShaderUboOffset) * tr.shaderInstanceUboOffsetsMapSize); + int old_ubo = 0; + shader_t *oldShader = nullptr; + int oldEntityNum = -1; + for (int i = 0; i < numDrawSurfs; ++i) { const drawSurf_t *drawSurf = drawSurfs + i; @@ -2649,6 +2655,13 @@ static void RB_UpdateShaderAndEntityConstants( R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &ignored, &ignored); + if (shader == oldShader && + entityNum == oldEntityNum ) + { + tr.entityUboOffsets[entityNum] = old_ubo; + continue; + } + const trRefEntity_t *refEntity = backEnd.refdef.entities + entityNum; //FIX ME: find out why this causes trouble! //if (!updatedEntities[entityNum]) @@ -2671,6 +2684,9 @@ static void RB_UpdateShaderAndEntityConstants( frame, &entityBlock, sizeof(entityBlock)); //updatedEntities[entityNum] = true; } + old_ubo = tr.entityUboOffsets[entityNum]; + oldShader = shader; + oldEntityNum = entityNum; RB_UpdateShaderEntityConstants(frame, entityNum, refEntity, shader); } @@ -2691,13 +2707,33 @@ static void RB_UpdateAnimationConstants( if (*drawSurf->surface != SF_MDX) continue; - SkeletonBoneMatricesBlock bonesBlock = {}; RB_TransformBones( - (CRenderableSurface *)drawSurf->surface, - bonesBlock.matrices); + (CRenderableSurface *)drawSurf->surface); + } + + //now get offsets or add skeletons to ubo + for (int i = 0; i < numDrawSurfs; ++i) + { + const drawSurf_t *drawSurf = drawSurfs + i; + if (*drawSurf->surface != SF_MDX) + continue; + + CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; + int currentOffset = RB_GetBoneUboOffset(RS); + if (currentOffset < 0) + { + SkeletonBoneMatricesBlock bonesBlock = {}; + RB_FillBoneBlock(RS, bonesBlock.matrices); + + tr.animationBoneUboOffsets[i] = RB_AppendConstantsData( + frame, &bonesBlock, sizeof(bonesBlock)); - tr.animationBoneUboOffsets[i] = RB_AppendConstantsData( - frame, &bonesBlock, sizeof(bonesBlock)); + RB_SetBoneUboOffset(RS, tr.animationBoneUboOffsets[i]); + } + else + { + tr.animationBoneUboOffsets[i] = currentOffset; + } } } diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 07ba3c37d3..a06c7a395d 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -413,6 +413,10 @@ class CBoneCache bool mUnsquash; float mSmoothFactor; + // GPU Data + mat3x4_t boneMatrices[52]; + int uboOffset; + CBoneCache( const model_t *amod, const mdxaHeader_t *aheader ) : header(aheader) , mod(amod) @@ -425,6 +429,7 @@ class CBoneCache , mSmoothingActive(false) , mUnsquash(false) , mSmoothFactor(0.0f) + , uboOffset(-1) { assert(amod); assert(aheader); @@ -2389,6 +2394,12 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; + // render shadows? + if (r_shadows->integer == 2 + && (RS.renderfx & (RF_NOSHADOW | RF_DEPTHHACK)) + && shader->sort == SS_OPAQUE) + newSurf->genShadows = qtrue; + R_AddDrawSurf( (surfaceType_t *)newSurf, entityNum, @@ -2490,21 +2501,6 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum #endif } - // stencil shadows can't do personal models unless I polyhedron clip - if (!RS.personalModel - && r_shadows->integer == 2 - && RS.fogNum == 0 - && (RS.renderfx & (RF_NOSHADOW | RF_DEPTHHACK)) - && shader->sort == SS_OPAQUE) { - - CRenderableSurface *newSurf = AllocGhoul2RenderableSurface(); - newSurf->vboMesh = &RS.currentModel->data.glm->vboModels[RS.lod].vboMeshes[RS.surfaceNum]; - assert(newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); - newSurf->surfaceData = surface; - newSurf->boneCache = RS.boneCache; - R_AddDrawSurf((surfaceType_t *)newSurf, entityNum, tr.shadowShader, 0, qfalse, qfalse, 0); - } - // projection shadows work fine with personal models if (r_shadows->integer == 3 && RS.fogNum == 0 @@ -3440,7 +3436,7 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } -void RB_TransformBones(CRenderableSurface *surf, mat3x4_t *outMatrices) +void RB_TransformBones(CRenderableSurface *surf) { const mdxmSurface_t *surfData = surf->surfaceData; const int *boneReferences = @@ -3448,12 +3444,33 @@ void RB_TransformBones(CRenderableSurface *surf, mat3x4_t *outMatrices) for (int i = 0; i < surfData->numBoneReferences; ++i) { + int boneIndex = boneReferences[i]; const mdxaBone_t& bone = surf->boneCache->EvalRender(boneReferences[i]); Com_Memcpy( - outMatrices + i, + surf->boneCache->boneMatrices + boneIndex, &bone.matrix[0][0], - sizeof(*outMatrices)); + sizeof(mat3x4_t)); } + surf->boneCache->uboOffset = -1; +} + +int RB_GetBoneUboOffset(CRenderableSurface *surf) +{ + return surf->boneCache->uboOffset; + +} + +void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset) +{ + surf->boneCache->uboOffset = offset; +} + +void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices) +{ + Com_Memcpy( + outMatrices, + surf->boneCache->boneMatrices, + sizeof(surf->boneCache->boneMatrices)); } void RB_SurfaceGhoul( CRenderableSurface *surf ) @@ -3480,12 +3497,14 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.maxIndex = surface->maxIndex; tess.firstIndex = surface->indexOffset; + glState.genShadows = surf->genShadows; glState.skeletalAnimation = qtrue; RB_EndSurface(); // So we don't lerp surfaces that shouldn't be lerped glState.skeletalAnimation = qfalse; + glState.genShadows = qfalse; } /* @@ -4131,6 +4150,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & { // Positions and normals mdxmVertex_t *v = (mdxmVertex_t *)((byte *)surf + surf->ofsVerts); + int *boneRef = (int *)((byte *)surf + surf->ofsBoneReferences); for ( int k = 0; k < surf->numVerts; k++ ) { @@ -4151,7 +4171,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & { float weight = G2_GetVertBoneWeightNotSlow(&v[k], w); weights[w] = (byte)(weight * 255.0f); - bonerefs[w] = G2_GetVertBoneIndex(&v[k], w); + int packedIndex = G2_GetVertBoneIndex(&v[k], w); + bonerefs[w] = boneRef[packedIndex]; lastWeight -= weights[w]; } @@ -4160,7 +4181,8 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Ensure that all the weights add up to 1.0 weights[lastInfluence] = lastWeight; - bonerefs[lastInfluence] = G2_GetVertBoneIndex(&v[k], lastInfluence); + int packedIndex = G2_GetVertBoneIndex(&v[k], lastInfluence); + bonerefs[lastInfluence] = boneRef[packedIndex]; // Fill in the rest of the info with zeroes. for ( int w = numWeights; w < 4; w++ ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 5146513f66..edf9411352 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -768,7 +768,7 @@ struct ShaderInstanceBlock struct SkeletonBoneMatricesBlock { - mat3x4_t matrices[20]; + mat3x4_t matrices[52]; }; struct surfaceSprite_t @@ -2114,6 +2114,7 @@ typedef struct glstate_s { int vertexAttribsTexCoordOffset[2]; qboolean vertexAnimation; qboolean skeletalAnimation; + qboolean genShadows; shaderProgram_t *currentProgram; FBO_t *currentFBO; VBO_t *currentVBO; @@ -3190,6 +3191,9 @@ class CRenderableSurface CBoneCache *boneCache; mdxmVBOMesh_t *vboMesh; + // tell the renderer to render shadows for this surface + qboolean genShadows; + // pointer to surface data loaded into file - only used by client renderer // DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of // wack on the game @@ -3244,13 +3248,17 @@ class CRenderableSurface alternateTex = nullptr; goreChain = nullptr; vboMesh = nullptr; + genShadows = qfalse; } #endif }; void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); -void RB_SurfaceGhoul( CRenderableSurface *surface ); -void RB_TransformBones(CRenderableSurface *surf, mat3x4_t *outMatrices); +void RB_SurfaceGhoul( CRenderableSurface *surf ); +void RB_TransformBones(CRenderableSurface *surf); +int RB_GetBoneUboOffset(CRenderableSurface *surf); +void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset); +void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices); /* Ghoul2 Insert End */ @@ -3580,8 +3588,6 @@ void RE_RegisterModels_StoreShaderRequest(const char *psModelFileName, const cha qboolean ShaderHashTableExists(void); void R_ImageLoader_Init(void); -void RB_SurfaceGhoul( CRenderableSurface *surf ); - class Allocator; GPUProgramDesc ParseProgramSource( Allocator& allocator, const char *text ); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 1a078a9d95..df097b5da0 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1304,6 +1304,57 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag return result; } +/* +================= +RB_ShadowTessEnd + +================= +*/ +void RB_ShadowTessEnd(shaderCommands_t *input, const VertexArraysProperties *vertexArrays) { + if (glConfig.stencilBits < 4) { + ri.Printf(PRINT_ALL, "no stencil bits for stencil writing\n"); + return; + } + + if (!input->numVertexes || !input->numIndexes || input->useInternalVBO) + { + return; + } + + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); + + Allocator& frameAllocator = *backEndData->perFrameMemory; + + cullType_t cullType = CT_TWO_SIDED; + + int stateBits = GLS_DEPTHFUNC_LESS | GLS_STENCILTEST_ENABLE | GLS_COLORMASK_BITS; + + const UniformBlockBinding uniformBlockBindings[] = { + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetBonesBlockUniformBinding(backEnd.currentEntity) + }; + + DrawItem item = {}; + item.renderState.stateBits = stateBits; + item.renderState.cullType = cullType; + DepthRange range = { 0.0f, 1.0f }; + item.renderState.depthRange = range; + item.program = &tr.volumeShadowShader; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); + + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); + + const uint32_t key = RB_CreateSortKey(item, 15, 15); + RB_AddDrawItem(backEndData->currentPass, key, item); +} + static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { Allocator& frameAllocator = *backEndData->perFrameMemory; @@ -1743,10 +1794,6 @@ void RB_StageIteratorGeneric( void ) RB_RenderShadowmap(input, &vertexArrays); } } - else if (input->shader == tr.shadowShader && r_shadows->integer == 2) - { - RB_ShadowTessEnd( input, &vertexArrays ); - } else { RB_IterateStagesGeneric( input, &vertexArrays ); @@ -1762,6 +1809,14 @@ void RB_StageIteratorGeneric( void ) ProjectPshadowVBOGLSL( input, &vertexArrays ); } + // + // volumeshadows! + // + if (glState.genShadows && r_shadows->integer == 2) + { + RB_ShadowTessEnd( input, &vertexArrays ); + } + // // now do any dynamic lighting needed // @@ -1769,7 +1824,7 @@ void RB_StageIteratorGeneric( void ) tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { - ForwardDlight(input, &vertexArrays); + ForwardDlight( input, &vertexArrays ); } // diff --git a/codemp/rd-rend2/tr_shadows.cpp b/codemp/rd-rend2/tr_shadows.cpp index c4c06aa3fc..eb0b472dfc 100644 --- a/codemp/rd-rend2/tr_shadows.cpp +++ b/codemp/rd-rend2/tr_shadows.cpp @@ -21,70 +21,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "tr_local.h" -/* -================= -RB_ShadowTessEnd - -================= -*/ -void RB_ShadowTessEnd( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { - if (glConfig.stencilBits < 4) { - ri.Printf(PRINT_ALL, "no stencil bits for stencil writing\n"); - return; - } - - if (!input->numVertexes || !input->numIndexes || input->useInternalVBO) - { - return; - } -#if 0 - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; - GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - GL_VertexAttribPointers(vertexArrays->numVertexArrays, attribs); - - cullType_t cullType = CT_TWO_SIDED; - UniformDataWriter uniformDataWriter; - int stateBits = GLS_DEPTHFUNC_LESS | GLS_STENCILTEST_ENABLE | GLS_COLORMASK_BITS; - - uniformDataWriter.Start(&tr.volumeShadowShader); - uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformMatrix4x3(UNIFORM_BONE_MATRICES, &glState.boneMatrices[0][0], glState.numBones); - - vec4_t lightDir; - VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); - lightDir[3] = 300.0f; - if (r_shadows->integer == 2) - { - lightDir[2] = 0.0f; - VectorNormalize(lightDir); - VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); - lightDir[3] = backEnd.currentEntity->e.lightingOrigin[2] - backEnd.currentEntity->e.shadowPlane + 64.0f; - } - uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, lightDir); - - DrawItem item = {}; - item.renderState.stateBits = stateBits; - item.renderState.cullType = cullType; - DepthRange range = { 0.0f, 1.0f }; - item.renderState.depthRange = range; - item.program = &tr.volumeShadowShader; - item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; - - item.numAttributes = vertexArrays->numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, attribs, sizeof(*item.attributes)* vertexArrays->numVertexArrays); - - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - - RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - - uint32_t key = RB_CreateSortKey(item, 15, 15); - RB_AddDrawItem(backEndData->currentPass, key, item); -#endif -} - - /* ================= RB_ShadowFinish From d0548624e1f55eb7dc27771a89fda2a06ebef785 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 24 Apr 2020 10:18:43 +0200 Subject: [PATCH 521/708] Set max g2 bones via define Also fixing shell effects and disintegration. --- codemp/rd-rend2/glsl/fogpass.glsl | 2 +- codemp/rd-rend2/glsl/generic.glsl | 9 ++++++++- codemp/rd-rend2/glsl/lightall.glsl | 2 +- codemp/rd-rend2/glsl/shadowvolume.glsl | 2 +- codemp/rd-rend2/tr_backend.cpp | 17 ++++++++++++----- codemp/rd-rend2/tr_ghoul2.cpp | 4 +++- codemp/rd-rend2/tr_glsl.cpp | 4 ++++ codemp/rd-rend2/tr_local.h | 3 ++- codemp/rd-rend2/tr_shade.cpp | 5 +++-- codemp/rd-rend2/tr_world.cpp | 6 +++--- 10 files changed, 38 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 598ed558ce..747307793a 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -40,7 +40,7 @@ layout(std140) uniform ShaderInstance #if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[52]; + mat3x4 u_BoneMatrices[MAX_G2_BONES]; }; #endif diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index b620300bdc..c272b7e85b 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -54,7 +54,7 @@ layout(std140) uniform ShaderInstance #if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[52]; + mat3x4 u_BoneMatrices[MAX_G2_BONES]; }; #endif @@ -137,6 +137,13 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos + normal * scale * bulgeHeight; } + case DEFORM_BULGE_UNIFORM: + { + float bulgeHeight = u_DeformParams0.y; // amplitude + + return pos + normal * bulgeHeight; + } + case DEFORM_WAVE: { float base = u_DeformParams0.x; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 3dfd40b054..a09cd2841c 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -62,7 +62,7 @@ layout(std140) uniform Entity #if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[52]; + mat3x4 u_BoneMatrices[MAX_G2_BONES]; }; #endif diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl index ac5817230c..f23f1708dc 100644 --- a/codemp/rd-rend2/glsl/shadowvolume.glsl +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -25,7 +25,7 @@ layout(std140) uniform Entity #if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones { - mat3x4 u_BoneMatrices[52]; + mat3x4 u_BoneMatrices[MAX_G2_BONES]; }; mat4x3 GetBoneMatrix(uint index) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3f09ef9078..689213d972 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2493,6 +2493,7 @@ int RB_GetEntityShaderUboOffset( } static void ComputeDeformValues( + const trRefEntity_t *refEntity, const shader_t *shader, deform_t *type, genFunc_t *waveFunc, @@ -2503,7 +2504,7 @@ static void ComputeDeformValues( *type = DEFORM_NONE; *waveFunc = GF_NONE; - if (backEnd.currentEntity->e.renderfx & RF_DISINTEGRATE2) + if (refEntity->e.renderfx & RF_DISINTEGRATE2) { *type = DEFORM_DISINTEGRATION; return; @@ -2539,6 +2540,10 @@ static void ComputeDeformValues( deformParams1[0] = 0.0f; deformParams1[1] = 0.0f; deformParams1[2] = 0.0f; + + if (ds->bulgeSpeed == 0.0f && ds->bulgeWidth == 0.0f) + *type = DEFORM_BULGE_UNIFORM; + break; case DEFORM_MOVE: @@ -2601,6 +2606,7 @@ static void RB_UpdateShaderEntityConstants( { ShaderInstanceBlock shaderInstanceBlock = {}; ComputeDeformValues( + refEntity, shader, (deform_t *)&shaderInstanceBlock.deformType, (genFunc_t *)&shaderInstanceBlock.deformFunc, @@ -2626,7 +2632,7 @@ static void RB_UpdateShaderEntityConstants( static void RB_UpdateShaderAndEntityConstants( gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) { - //bool updatedEntities[MAX_REFENTITIES] = {}; + bool updatedEntities[MAX_REFENTITIES + 1] = {}; // Make the map bigger than it needs to be. Eases collisions and iterations // through the map during lookup/insertion. @@ -2664,7 +2670,7 @@ static void RB_UpdateShaderAndEntityConstants( const trRefEntity_t *refEntity = backEnd.refdef.entities + entityNum; //FIX ME: find out why this causes trouble! - //if (!updatedEntities[entityNum]) + if (!updatedEntities[entityNum] || entityNum == REFENTITYNUM_WORLD) { EntityBlock entityBlock = {}; @@ -2682,7 +2688,7 @@ static void RB_UpdateShaderAndEntityConstants( tr.entityUboOffsets[entityNum] = RB_AppendConstantsData( frame, &entityBlock, sizeof(entityBlock)); - //updatedEntities[entityNum] = true; + updatedEntities[entityNum] = true; } old_ubo = tr.entityUboOffsets[entityNum]; oldShader = shader; @@ -2701,6 +2707,7 @@ static void RB_UpdateAnimationConstants( *backEndData->perFrameMemory, numDrawSurfs); memset(tr.animationBoneUboOffsets, 0, sizeof(int) * numDrawSurfs); + // transform all bones for this frame for (int i = 0; i < numDrawSurfs; ++i) { const drawSurf_t *drawSurf = drawSurfs + i; @@ -2711,7 +2718,7 @@ static void RB_UpdateAnimationConstants( (CRenderableSurface *)drawSurf->surface); } - //now get offsets or add skeletons to ubo + // now get offsets or add skeletons to ubo for (int i = 0; i < numDrawSurfs; ++i) { const drawSurf_t *drawSurf = drawSurfs + i; diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a06c7a395d..6ed050f4ee 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -414,7 +414,7 @@ class CBoneCache float mSmoothFactor; // GPU Data - mat3x4_t boneMatrices[52]; + mat3x4_t boneMatrices[MAX_G2_BONES]; int uboOffset; CBoneCache( const model_t *amod, const mdxaHeader_t *aheader ) @@ -433,6 +433,8 @@ class CBoneCache { assert(amod); assert(aheader); + + Com_Memset(boneMatrices, 0, sizeof(boneMatrices)); int numBones = header->numBones; mdxaSkelOffsets_t *offsets = diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6e0aa80d4f..6fdb2bcbca 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -349,6 +349,10 @@ static size_t GLSL_GetShaderHeader( ALPHA_TEST_GE128, ALPHA_TEST_GE192)); + Q_strcat(dest, size, + va("#define MAX_G2_BONES %i\n", + MAX_G2_BONES)); + fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); Q_strcat(dest, size, diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index edf9411352..463bdbfd95 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -56,6 +56,7 @@ typedef unsigned int glIndex_t; #define MAX_VISCOUNTS 5 #define MAX_VBOS 4096 #define MAX_IBOS 4096 +#define MAX_G2_BONES 53 #define MAX_CALC_PSHADOWS 64 #define MAX_DRAWN_PSHADOWS 32 // do not increase past 32, because bit flags are used on surfaces @@ -768,7 +769,7 @@ struct ShaderInstanceBlock struct SkeletonBoneMatricesBlock { - mat3x4_t matrices[52]; + mat3x4_t matrices[MAX_G2_BONES]; }; struct surfaceSprite_t diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index df097b5da0..323950738d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1474,8 +1474,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); } - uniformDataWriter.SetUniformFloat(UNIFORM_FX_VOLUMETRIC_BASE, volumetricBaseValue); - #if 0 // TODO: Revisit this, isn't it just a alphaGen? if (pStage->alphaGen == AGEN_PORTAL) { @@ -1485,6 +1483,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, forceRGBGen); uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, forceAlphaGen); + if (backEnd.currentEntity->e.renderfx & (RF_DISINTEGRATE1 | RF_DISINTEGRATE2)) + uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); + ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index ab508eba90..b022e099be 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -572,9 +572,9 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, tr.viewParms.visBounds[0][1] = MIN(node->mins[1], tr.viewParms.visBounds[0][1]); tr.viewParms.visBounds[0][2] = MIN(node->mins[2], tr.viewParms.visBounds[0][2]); - tr.viewParms.visBounds[1][0] = MIN(node->maxs[0], tr.viewParms.visBounds[1][0]); - tr.viewParms.visBounds[1][1] = MIN(node->maxs[1], tr.viewParms.visBounds[1][1]); - tr.viewParms.visBounds[1][2] = MIN(node->maxs[2], tr.viewParms.visBounds[1][2]); + tr.viewParms.visBounds[1][0] = MAX(node->maxs[0], tr.viewParms.visBounds[1][0]); + tr.viewParms.visBounds[1][1] = MAX(node->maxs[1], tr.viewParms.visBounds[1][1]); + tr.viewParms.visBounds[1][2] = MAX(node->maxs[2], tr.viewParms.visBounds[1][2]); // add merged and unmerged surfaces if (tr.world->viewSurfaces && !r_nocurves->integer) From b206c3ae2210ca38f0d0a49aee7ecc0c14569fb1 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 24 Apr 2020 18:23:25 +0200 Subject: [PATCH 522/708] Fixing some bad volumetrics rendering The world entity is not present in backend.refdef.entities, so you have to point the refEntity directly to tr.worldEntity. --- codemp/rd-rend2/tr_backend.cpp | 12 +++++++----- codemp/rd-rend2/tr_surface.cpp | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 689213d972..adbaccf5c2 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2662,13 +2662,14 @@ static void RB_UpdateShaderAndEntityConstants( drawSurf->sort, &entityNum, &shader, &ignored, &ignored); if (shader == oldShader && - entityNum == oldEntityNum ) + (entityNum == oldEntityNum || shader->entityMergable)) { tr.entityUboOffsets[entityNum] = old_ubo; continue; } - const trRefEntity_t *refEntity = backEnd.refdef.entities + entityNum; + const trRefEntity_t *refEntity = entityNum == REFENTITYNUM_WORLD ? &tr.worldEntity : &backEnd.refdef.entities[entityNum]; + //FIX ME: find out why this causes trouble! if (!updatedEntities[entityNum] || entityNum == REFENTITYNUM_WORLD) { @@ -2690,9 +2691,10 @@ static void RB_UpdateShaderAndEntityConstants( frame, &entityBlock, sizeof(entityBlock)); updatedEntities[entityNum] = true; } - old_ubo = tr.entityUboOffsets[entityNum]; - oldShader = shader; - oldEntityNum = entityNum; + + old_ubo = tr.entityUboOffsets[entityNum]; + oldShader = shader; + oldEntityNum = entityNum; RB_UpdateShaderEntityConstants(frame, entityNum, refEntity, shader); } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 79c5acd8f0..df0471bfca 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2059,6 +2059,8 @@ static void RB_SurfaceEntity( surfaceType_t *surfType ) { RB_SurfaceAxis(); break; } + // FIX ME: just a testing hack. Pretty sure we can merge all of these + tess.shader->entityMergable = qtrue; } static void RB_SurfaceBad( surfaceType_t *surfType ) { From dcbac8fadf5a62a4ca2199bfa577348e8d5f1b87 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 29 Apr 2020 16:18:12 +0200 Subject: [PATCH 523/708] Mulitple fixes Added dlights back, added sprites to the shader constants and fixed sunlight shadows in cubemaps. --- codemp/rd-rend2/glsl/lightall.glsl | 59 +++++++++++++++++++- codemp/rd-rend2/tr_backend.cpp | 90 ++++++++++++++++++++++++++---- codemp/rd-rend2/tr_local.h | 13 ++++- codemp/rd-rend2/tr_main.cpp | 70 ++++++++++++----------- codemp/rd-rend2/tr_shade.cpp | 21 ++++--- codemp/rd-rend2/tr_surface.cpp | 23 +++----- 6 files changed, 201 insertions(+), 75 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index a09cd2841c..a0ec0b3a4d 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -375,6 +375,20 @@ layout(std140) uniform Entity vec3 u_LocalViewOrigin; }; +struct Light +{ + vec4 origin; + vec3 color; + float radius; +}; + +layout(std140) uniform Lights +{ + int u_NumLights; + Light u_Lights[32]; +}; + +uniform int u_LightIndex; uniform sampler2D u_DiffuseMap; #if defined(USE_LIGHTMAP) @@ -613,6 +627,44 @@ vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) #endif } +vec3 CalcDynamicLightContribution( + in float roughness, + in vec3 N, + in vec3 E, + in vec3 viewOrigin, + in vec3 viewDir, + in float NE, + in vec3 diffuse, + in vec3 specular +) +{ + vec3 outColor = vec3(0.0); + vec3 position = viewOrigin - viewDir; + for ( int i = 0; i < u_NumLights; i++ ) + { + if ( ( u_LightIndex & ( 1 << i ) ) == 0 ) { + continue; + } + Light light = u_Lights[i]; + + vec3 L = light.origin.xyz - position; + float sqrLightDist = dot(L, L); + + float attenuation = CalcLightAttenuation(1.0, light.radius * light.radius / sqrLightDist); + + L /= sqrt(sqrLightDist); + vec3 H = normalize(L + E); + float NL = clamp(dot(N, L), 0.0, 1.0); + float LH = clamp(dot(L, H), 0.0, 1.0); + float NH = clamp(dot(N, H), 0.0, 1.0); + + vec3 reflectance = diffuse + CalcSpecular(specular, NH, NL, NE, LH, roughness); + + outColor += light.color * reflectance * attenuation * NL; + } + return outColor; +} + vec3 CalcIBLContribution( in float roughness, in vec3 N, @@ -626,14 +678,14 @@ vec3 CalcIBLContribution( #if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; - vec3 R = reflect(E, N); + vec3 R = reflect(-E, N); // parallax corrected cubemap (cheaper trick) // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ vec3 eyeToCubeCenter = (u_CubeMapInfo.xyz - viewOrigin) * 0.001; vec3 parallax = eyeToCubeCenter + u_CubeMapInfo.w * viewDir * 0.001; - vec3 cubeLightColor = textureLod(u_CubeMap, R + parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; + vec3 cubeLightColor = textureLod(u_CubeMap, R - parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); #else @@ -830,6 +882,7 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif + out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb); out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb); #else @@ -846,6 +899,6 @@ void main() #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; #else - out_Glow = vec4(0.0); + out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); #endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index adbaccf5c2..fdc1e5371f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -108,7 +108,6 @@ void GL_BindToTMU( image_t *image, int tmu ) qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); else qglBindTexture( GL_TEXTURE_2D, texnum ); - GL_SelectTexture( oldtmu ); } } @@ -1992,6 +1991,11 @@ static const void *RB_PrefilterEnvMap(const void *data) { static void RB_RenderSunShadows() { + if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW) || + (backEnd.refdef.rdflags & RDF_NOWORLDMODEL) || + (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo)) + return; + FBO_t *shadowFbo = tr.screenShadowFbo; vec4_t quadVerts[4]; @@ -2391,12 +2395,12 @@ static void RB_UpdateEntityMatrixConstants( orientationr_t ori; if (refEntity == &tr.worldEntity) { - ori = tr.viewParms.world; + ori = backEnd.viewParms.world; Matrix16Identity(entityBlock.modelMatrix); } else { - R_RotateForEntity(refEntity, &tr.viewParms, &ori); + R_RotateForEntity(refEntity, &backEnd.viewParms, &ori); Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); } @@ -2404,7 +2408,7 @@ static void RB_UpdateEntityMatrixConstants( VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); Matrix16Multiply( - tr.viewParms.projectionMatrix, + backEnd.viewParms.projectionMatrix, modelViewMatrix, entityBlock.modelViewProjectionMatrix); } @@ -2578,17 +2582,17 @@ static void ComputeDeformValues( deformParams0[0] = backEnd.ori.axis[0][2]; deformParams0[1] = backEnd.ori.axis[1][2]; deformParams0[2] = backEnd.ori.axis[2][2]; - deformParams0[3] = backEnd.ori.origin[2] - backEnd.currentEntity->e.shadowPlane; + deformParams0[3] = backEnd.ori.origin[2] - refEntity->e.shadowPlane; vec3_t lightDir; - VectorCopy(backEnd.currentEntity->modelLightDir, lightDir); + VectorCopy(refEntity->modelLightDir, lightDir); lightDir[2] = 0.0f; VectorNormalize(lightDir); VectorSet(lightDir, lightDir[0] * 0.3f, lightDir[1] * 0.3f, 1.0f); - deformParams1[0] = backEnd.currentEntity->lightDir[0]; - deformParams1[1] = backEnd.currentEntity->lightDir[1]; - deformParams1[2] = backEnd.currentEntity->lightDir[2]; + deformParams1[0] = lightDir[0]; + deformParams1[1] = lightDir[1]; + deformParams1[2] = lightDir[2]; break; default: @@ -2671,7 +2675,7 @@ static void RB_UpdateShaderAndEntityConstants( const trRefEntity_t *refEntity = entityNum == REFENTITYNUM_WORLD ? &tr.worldEntity : &backEnd.refdef.entities[entityNum]; //FIX ME: find out why this causes trouble! - if (!updatedEntities[entityNum] || entityNum == REFENTITYNUM_WORLD) + if (!updatedEntities[entityNum]) { EntityBlock entityBlock = {}; @@ -2746,6 +2750,70 @@ static void RB_UpdateAnimationConstants( } } +static void Fill_SpriteBlock( srfSprites_t *surf , SurfaceSpriteBlock *surfaceSpriteBlock) +{ + const surfaceSprite_t *ss = surf->sprite; + + surfaceSpriteBlock->width = ss->width; + surfaceSpriteBlock->height = + (ss->facing == SURFSPRITE_FACING_DOWN) ? -ss->height : ss->height; + surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; + surfaceSpriteBlock->fadeEndDistance = ss->fadeMax; + surfaceSpriteBlock->fadeScale = ss->fadeScale; + surfaceSpriteBlock->widthVariance = ss->variance[0]; + surfaceSpriteBlock->heightVariance = ss->variance[1]; +} + +static void RB_UpdateSpriteConstants( + gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) +{ + if (!r_surfaceSprites->integer) + return; + + // FIX ME: horrible idea to reuse the hashing + tr.surfaceSpriteInstanceUboOffsetsMap = ojkAllocArray( + *backEndData->perFrameMemory, + 64); + memset( + tr.surfaceSpriteInstanceUboOffsetsMap, 0, + sizeof(EntityShaderUboOffset) * 64); + + shader_t *oldShader = nullptr; + + // get all the spriteData + for (int i = 0; i < numDrawSurfs; ++i) + { + const drawSurf_t *drawSurf = drawSurfs + i; + if (*drawSurf->surface != SF_SPRITES) + continue; + + shader_t *shader; + int ignored; + int entityNum; + + R_DecomposeSort( + drawSurf->sort, &entityNum, &shader, &ignored, &ignored); + + if (oldShader == shader) + continue; + + SurfaceSpriteBlock surfaceSpriteBlock = {}; + Fill_SpriteBlock((srfSprites_t*)drawSurf->surface, &surfaceSpriteBlock); + + const int uboOffset = RB_AppendConstantsData( + frame, &surfaceSpriteBlock, sizeof(surfaceSpriteBlock)); + + RB_InsertEntityShaderUboOffset( + tr.surfaceSpriteInstanceUboOffsetsMap, + 64, + REFENTITYNUM_WORLD, + shader->index, + uboOffset); + + oldShader = shader; + } +} + static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) { gpuFrame_t *frame = backEndData->currentFrame; @@ -2759,6 +2827,8 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); RB_UpdateAnimationConstants(frame, drawSurfs, numDrawSurfs); + RB_UpdateSpriteConstants(frame, drawSurfs, numDrawSurfs); + RB_EndConstantsUpdate(frame); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 463bdbfd95..b253816dc3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -56,7 +56,7 @@ typedef unsigned int glIndex_t; #define MAX_VISCOUNTS 5 #define MAX_VBOS 4096 #define MAX_IBOS 4096 -#define MAX_G2_BONES 53 +#define MAX_G2_BONES 72 #define MAX_CALC_PSHADOWS 64 #define MAX_DRAWN_PSHADOWS 32 // do not increase past 32, because bit flags are used on surfaces @@ -764,7 +764,7 @@ struct ShaderInstanceBlock float portalRange; int deformType; int deformFunc; - float pad1; + //float pad1; }; struct SkeletonBoneMatricesBlock @@ -1467,7 +1467,7 @@ typedef struct { vec3_t pvsOrigin; // may be different than or.origin for portals qboolean isPortal; // true if this view is through a portal qboolean isMirror; // the portal is a mirror, invert the face culling - int flags; + int flags; int frameSceneNum; // copied from tr.frameSceneNum int frameCount; // copied from tr.frameCount cplane_t portalPlane; // clip anything behind this if mirroring @@ -2408,6 +2408,8 @@ typedef struct trGlobals_s { int fogsUboOffset; int skyEntityUboOffset; int entityUboOffsets[MAX_REFENTITIES + 1]; + int surfaceSpriteUboOffsets[64]; //FIX ME: maybe not fixed size? + EntityShaderUboOffset *surfaceSpriteInstanceUboOffsetsMap; int *animationBoneUboOffsets; EntityShaderUboOffset *shaderInstanceUboOffsetsMap; @@ -3769,4 +3771,9 @@ uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ); DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ); +int RB_GetEntityShaderUboOffset( + EntityShaderUboOffset *offsetMap, + int mapSize, + int entityNum, + int shaderNum); #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index bd898bcc14..8f55fb61a8 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2777,57 +2777,63 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, float oldColorScale = tr.refdef.colorScale; VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg); + refdef.fov_x = 90; + refdef.fov_y = 90; + refdef.width = tr.renderCubeFbo->width; + refdef.height = tr.renderCubeFbo->height; + refdef.x = 0; + refdef.y = 0; switch(cubemapSide) { case 0: - // -X - VectorSet( refdef.viewaxis[0], -1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, -1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); + // +X + VectorSet(refdef.viewaxis[0], 1, 0, 0); + VectorSet(refdef.viewaxis[1], 0, 0, 1); + VectorSet(refdef.viewaxis[2], 0, -1, 0); break; case 1: - // +X - VectorSet( refdef.viewaxis[0], 1, 0, 0); - VectorSet( refdef.viewaxis[1], 0, 0, 1); - VectorSet( refdef.viewaxis[2], 0, 1, 0); + // -X + VectorSet(refdef.viewaxis[0], -1, 0, 0); + VectorSet(refdef.viewaxis[1], 0, 0, -1); + VectorSet(refdef.viewaxis[2], 0, -1, 0); break; case 2: - // -Y - VectorSet( refdef.viewaxis[0], 0, -1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, -1); + // +Y + VectorSet(refdef.viewaxis[0], 0, 1, 0); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, 0, 1); break; case 3: - // +Y - VectorSet( refdef.viewaxis[0], 0, 1, 0); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 0, 1); + // -Y + VectorSet(refdef.viewaxis[0], 0, -1, 0); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, 0, -1); break; case 4: - // -Z - VectorSet( refdef.viewaxis[0], 0, 0, -1); - VectorSet( refdef.viewaxis[1], 1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); + // +Z + VectorSet(refdef.viewaxis[0], 0, 0, 1); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, -1, 0); break; case 5: - // +Z - VectorSet( refdef.viewaxis[0], 0, 0, 1); - VectorSet( refdef.viewaxis[1], -1, 0, 0); - VectorSet( refdef.viewaxis[2], 0, 1, 0); + // -Z + VectorSet(refdef.viewaxis[0], 0, 0, -1); + VectorSet(refdef.viewaxis[1], 1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, -1, 0); break; } if (!subscene) { RE_BeginScene(&refdef); + } - if(r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer || tr.sunShadows)) - { - R_RenderSunShadowMaps(&refdef, 0); - R_RenderSunShadowMaps(&refdef, 1); - R_RenderSunShadowMaps(&refdef, 2); - } + if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer > 0 || tr.sunShadows)) + { + R_RenderSunShadowMaps(&refdef, 0); + R_RenderSunShadowMaps(&refdef, 1); + R_RenderSunShadowMaps(&refdef, 2); } tr.refdef.colorScale = 1.0f; @@ -2835,7 +2841,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, viewParms_t parms = {}; parms.viewportWidth = tr.renderCubeFbo->width; parms.viewportHeight = tr.renderCubeFbo->height; - parms.isMirror = qtrue; + parms.isMirror = qfalse; parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; if (!bounce) parms.flags |= VPF_NOCUBEMAPS; @@ -2851,7 +2857,7 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, VectorCopy( refdef.vieworg, parms.pvsOrigin ); - if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer || tr.sunShadows)) + if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer > 0 || tr.sunShadows)) { parms.flags |= VPF_USESUNLIGHT; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 323950738d..213e5e8a62 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -654,10 +654,6 @@ static cullType_t RB_GetCullType( const viewParms_t *viewParms, const trRefEntit cullFront = !cullFront; cullType = (cullFront ? CT_FRONT_SIDED : CT_BACK_SIDED); - - // FIXME: SomaZ: Not sure why this is needed, but fixes sunlight and shadows in cubemaps - if ( tr.renderCubeFbo && glState.currentFBO == tr.renderCubeFbo) - cullType = CT_TWO_SIDED; } } @@ -793,11 +789,6 @@ static UniformBlockBinding GetBonesBlockUniformBinding( return binding; } -int RB_GetEntityShaderUboOffset( - EntityShaderUboOffset *offsetMap, - int mapSize, - int entityNum, - int shaderNum); static UniformBlockBinding GetShaderInstanceBlockUniformBinding( const trRefEntity_t *refEntity, const shader_t *shader) { @@ -1646,11 +1637,19 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } + if (tess.dlightBits && + tess.shader->sort <= SS_OPAQUE && + !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) + uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, tess.dlightBits); + else + uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, 0); + CaptureDrawData(input, pStage, index, stage); const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.lightsUboOffset, UNIFORM_BLOCK_LIGHTS }, { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, GetEntityBlockUniformBinding(backEnd.currentEntity), @@ -1821,12 +1820,12 @@ void RB_StageIteratorGeneric( void ) // // now do any dynamic lighting needed // - if ( tess.dlightBits && + /*if ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) { ForwardDlight( input, &vertexArrays ); - } + }*/ // // now do fog diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index df0471bfca..5bc1aa620f 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2161,21 +2161,6 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) shaderProgram_t *program = programGroup + shaderFlags; assert(program->uniformBlocks & (1 << UNIFORM_BLOCK_SURFACESPRITE)); - SurfaceSpriteBlock *surfaceSpriteBlock = - ojkAlloc(*backEndData->perFrameMemory); - *surfaceSpriteBlock = {}; - surfaceSpriteBlock->width = ss->width; - surfaceSpriteBlock->height = - (ss->facing == SURFSPRITE_FACING_DOWN) ? -ss->height : ss->height; - surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; - surfaceSpriteBlock->fadeEndDistance = ss->fadeMax; - surfaceSpriteBlock->fadeScale = ss->fadeScale; - surfaceSpriteBlock->widthVariance = ss->variance[0]; - surfaceSpriteBlock->heightVariance = ss->variance[1]; - - const int uboDataOffset = RB_BindAndUpdateFrameUniformBlock( - UNIFORM_BLOCK_SURFACESPRITE, &surfaceSpriteBlock); - UniformDataWriter uniformDataWriter; uniformDataWriter.Start(program); @@ -2187,9 +2172,15 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) SamplerBindingsWriter samplerBindingsWriter; samplerBindingsWriter.AddAnimatedImage(&firstStage->bundle[0], TB_COLORMAP); + int offset = RB_GetEntityShaderUboOffset( + tr.surfaceSpriteInstanceUboOffsetsMap, + 64, + REFENTITYNUM_WORLD, + shader->index); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, uboDataOffset, UNIFORM_BLOCK_SURFACESPRITE }, + { currentFrameUbo, offset, UNIFORM_BLOCK_SURFACESPRITE }, { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } }; From a160ae834b220252a5292cc9e4e2204b3c09e70f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 10 Aug 2020 16:27:18 +0200 Subject: [PATCH 524/708] Better external lightmap support Loads external Lightmaps like the vanilla openjk renderer Also loads radiance hdr lightmaps now Removed r_srgb --- codemp/rd-rend2/CMakeLists.txt | 2 + codemp/rd-rend2/glsl/lightall.glsl | 19 - codemp/rd-rend2/glsl/tonemap.glsl | 15 +- codemp/rd-rend2/stb_image.h | 7546 ++++++++++++++++++++++++++++ codemp/rd-rend2/tr_bsp.cpp | 394 +- codemp/rd-rend2/tr_glsl.cpp | 48 +- codemp/rd-rend2/tr_image.cpp | 17 +- codemp/rd-rend2/tr_image_stb.cpp | 83 + codemp/rd-rend2/tr_init.cpp | 4 - codemp/rd-rend2/tr_local.h | 10 +- codemp/rd-rend2/tr_postprocess.cpp | 4 +- codemp/rd-rend2/tr_shader.cpp | 47 +- 12 files changed, 7926 insertions(+), 263 deletions(-) create mode 100644 codemp/rd-rend2/stb_image.h create mode 100644 codemp/rd-rend2/tr_image_stb.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index b3e054e06e..767540f961 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -14,6 +14,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/iqm.h" "${MPDir}/rd-rend2/glext.h" "${MPDir}/rd-rend2/qgl.h" + "${MPDir}/rd-rend2/stb_image.h" "${MPDir}/rd-rend2/G2_API.cpp" "${MPDir}/rd-rend2/G2_bolts.cpp" "${MPDir}/rd-rend2/G2_bones.cpp" @@ -40,6 +41,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_glsl.cpp" "${MPDir}/rd-rend2/tr_glsl_parse.cpp" "${MPDir}/rd-rend2/tr_image.cpp" + "${MPDir}/rd-rend2/tr_image_stb.cpp" "${MPDir}/rd-rend2/tr_init.cpp" "${MPDir}/rd-rend2/tr_light.cpp" "${MPDir}/rd-rend2/tr_local.h" diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index a0ec0b3a4d..e896abfd9d 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -698,12 +698,7 @@ vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld vec3 N = vertexNormal; #if defined(USE_NORMALMAP) - #if defined(SWIZZLE_NORMALMAP) N.xy = texture(u_NormalMap, texCoords).ag - vec2(0.5); - #else - N.xy = texture(u_NormalMap, texCoords).rg - vec2(0.5); - #endif - N.xy *= u_NormalScale.xy; N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); N = tangentToWorld * N; @@ -712,13 +707,6 @@ vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld return normalize(N); } -vec3 sRGBToLinear( in vec3 srgb ) -{ - vec3 lo = srgb / 12.92; - vec3 hi = pow(((srgb + vec3(0.055)) / 1.055), vec3(2.4)); - return mix(lo, hi, greaterThan(srgb, vec3(0.04045))); -} - void main() { vec3 viewDir, lightColor, ambientColor; @@ -737,10 +725,6 @@ void main() #if defined(USE_LIGHTMAP) vec4 lightmapColor = texture(u_LightMap, var_TexCoords.zw); - #if defined(RGBM_LIGHTMAP) - lightmapColor.rgb *= lightmapColor.a; - #endif - //lightmapColor.rgb = sRGBToLinear(lightmapColor.rgb); #endif vec2 texCoords = var_TexCoords.xy; @@ -773,8 +757,6 @@ void main() } #endif - //diffuse.rgb = sRGBToLinear(diffuse.rgb); - #if defined(PER_PIXEL_LIGHTING) float attenuation; @@ -831,7 +813,6 @@ void main() vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) specular = texture(u_SpecularMap, texCoords); - //specular.rgb = sRGBToLinear(specular.rgb); #endif specular *= u_SpecularScale; diff --git a/codemp/rd-rend2/glsl/tonemap.glsl b/codemp/rd-rend2/glsl/tonemap.glsl index 045aab7438..dc39403557 100644 --- a/codemp/rd-rend2/glsl/tonemap.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -24,14 +24,10 @@ in vec2 var_TexCoords; out vec4 out_Color; -const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); - vec3 LinearTosRGB( in vec3 color ) { - vec3 clampedColor = clamp(color, 0.0, 1.0); - - vec3 lo = 12.92 * clampedColor; - vec3 hi = 1.055 * pow(clampedColor, vec3(0.41666)) - 0.055; + vec3 lo = 12.92 * color; + vec3 hi = 1.055 * pow(color, vec3(0.4166666)) - 0.055; return mix(lo, hi, greaterThanEqual(color, vec3(0.0031308))); } @@ -68,7 +64,10 @@ void main() vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x)); color.rgb = FilmicTonemap(color.rgb) * fWhite; - //color.rgb = LinearTosRGB(color.rgb); - + + #if defined(USE_LINEAR_LIGHT) + color.rgb = LinearTosRGB(color.rgb); + #endif + out_Color = clamp(color, 0.0, 1.0); } diff --git a/codemp/rd-rend2/stb_image.h b/codemp/rd-rend2/stb_image.h new file mode 100644 index 0000000000..a184dddb43 --- /dev/null +++ b/codemp/rd-rend2/stb_image.h @@ -0,0 +1,7546 @@ +/* stb_image - v2.19 - public domain image loader - http://nothings.org/stb +no warranty implied; use at your own risk +Do this: +#define STB_IMAGE_IMPLEMENTATION +before you include this file in *one* C or C++ file to create the implementation. +// i.e. it should look like this: +#include ... +#include ... +#include ... +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" +You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. +And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free +QUICK NOTES: +Primarily of interest to game developers and other people who can +avoid problematic images and only need the trivial interface +JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) +PNG 1/2/4/8/16-bit-per-channel +TGA (not sure what subset, if a subset) +BMP non-1bpp, non-RLE +PSD (composited view only, no extra channels, 8/16 bit-per-channel) +GIF (*comp always reports as 4-channel) +HDR (radiance rgbE format) +PIC (Softimage PIC) +PNM (PPM and PGM binary only) +Animated GIF still needs a proper API, but here's one way to do it: +http://gist.github.com/urraka/685d9a6340b26b830d49 +- decode from memory or through FILE (define STBI_NO_STDIO to remove code) +- decode from arbitrary I/O callbacks +- SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) +Full documentation under "DOCUMENTATION" below. +LICENSE +See end of file for license information. +RECENT REVISION HISTORY: +2.19 (2018-02-11) fix warning +2.18 (2018-01-30) fix warnings +2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings +2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes +2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC +2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs +2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes +2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes +2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 +RGB-format JPEG; remove white matting in PSD; +allocate large structures on the stack; +correct channel count for PNG & BMP +2.10 (2016-01-22) avoid warning introduced in 2.09 +2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED +See end of file for full revision history. +============================ Contributors ========================= +Image formats Extensions, features +Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) +Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) +Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) +Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) +Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) +Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) +Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) +github:urraka (animated gif) Junggon Kim (PNM comments) +Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) +socks-the-fox (16-bit PNG) +Jeremy Sawicki (handle all ImageNet JPGs) +Optimizations & bugfixes Mikhail Morozov (1-bit BMP) +Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) +Arseny Kapoulkine +John-Mark Allen +Bug & warning fixes +Marc LeBlanc David Woo Guillaume George Martins Mozeiko +Christpher Lloyd Jerry Jansson Joseph Thomson Phil Jordan +Dave Moore Roy Eltham Hayaki Saito Nathan Reed +Won Chun Luke Graham Johan Duparc Nick Verigakis +the Horde3D community Thomas Ruf Ronny Chevalier github:rlyeh +Janez Zemva John Bartholomew Michal Cichon github:romigrou +Jonathan Blow Ken Hamada Tero Hanninen github:svdijk +Laurent Gomila Cort Stratton Sergio Gonzalez github:snagar +Aruelien Pocheville Thibault Reuille Cass Everitt github:Zelex +Ryamond Barbiero Paul Du Bois Engin Manap github:grim210 +Aldo Culquicondor Philipp Wiesemann Dale Weiler github:sammyhw +Oriol Ferrer Mesia Josh Tobin Matthew Gregan github:phprus +Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo +Christian Floisand Kevin Schmidt github:darealshinji +Blazej Dariusz Roszkowski github:Michaelangel007 +*/ + +#ifndef STBI_INCLUDE_STB_IMAGE_H +#define STBI_INCLUDE_STB_IMAGE_H + +// DOCUMENTATION +// +// Limitations: +// - no 12-bit-per-channel JPEG +// - no JPEGs with arithmetic coding +// - GIF always returns *comp=4 +// +// Basic usage (see HDR discussion below for HDR usage): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// // ... but 'n' will always be the number that it would have been if you said 0 +// stbi_image_free(data) +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *channels_in_file -- outputs # of image components in image file +// int desired_channels -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data, or NULL on an allocation failure or if the image is +// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'desired_channels' if desired_channels is non-zero, or +// *channels_in_file otherwise. If desired_channels is non-zero, +// *channels_in_file has the number of components that _would_ have been +// output otherwise. E.g. if you set desired_channels to 4, you will always +// get RGBA output, but you can check *channels_in_file to see if it's trivially +// opaque because e.g. there were only 3 channels in the source image. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *channels_in_file will be unchanged. The function +// stbi_failure_reason() can be queried for an extremely brief, end-user +// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS +// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. +// +// =========================================================================== +// +// Philosophy +// +// stb libraries are designed with the following priorities: +// +// 1. easy to use +// 2. easy to maintain +// 3. good performance +// +// Sometimes I let "good performance" creep up in priority over "easy to maintain", +// and for best performance I may provide less-easy-to-use APIs that give higher +// performance, in addition to the easy to use ones. Nevertheless, it's important +// to keep in mind that from the standpoint of you, a client of this library, +// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. +// +// Some secondary priorities arise directly from the first two, some of which +// make more explicit reasons why performance can't be emphasized. +// +// - Portable ("ease of use") +// - Small source code footprint ("easy to maintain") +// - No dependencies ("ease of use") +// +// =========================================================================== +// +// I/O callbacks +// +// I/O callbacks allow you to read from arbitrary sources, like packaged +// files or some other source. Data read from callbacks are processed +// through a small internal buffer (currently 128 bytes) to try to reduce +// overhead. +// +// The three functions you must define are "read" (reads some bytes of data), +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// +// =========================================================================== +// +// SIMD support +// +// The JPEG decoder will try to automatically use SIMD kernels on x86 when +// supported by the compiler. For ARM Neon support, you must explicitly +// request it. +// +// (The old do-it-yourself SIMD API is no longer supported in the current +// code.) +// +// On x86, SSE2 will automatically be used when available based on a run-time +// test; if not, the generic C versions are used as a fall-back. On ARM targets, +// the typical path is to have separate builds for NEON and non-NEON devices +// (at least this is true for iOS and Android). Therefore, the NEON support is +// toggled by a build flag: define STBI_NEON to get NEON loops. +// +// If for some reason you do not want to use any of SIMD code, or if +// you have issues compiling it, you can disable it entirely by +// defining STBI_NO_SIMD. +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image now supports loading HDR images in general, and currently +// the Radiance .HDR file format, although the support is provided +// generically. You can still load any file through the existing interface; +// if you attempt to load an HDR file, it will be automatically remapped to +// LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); +// +// =========================================================================== +// +// iPhone PNG support: +// +// By default we convert iphone-formatted PNGs back to RGB, even though +// they are internally encoded differently. You can disable this conversion +// by by calling stbi_convert_iphone_png_to_rgb(0), in which case +// you will always just get the native iphone "format" through (which +// is BGR stored in RGB). +// +// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per +// pixel to remove any premultiplied alpha *only* if the image file explicitly +// says there's premultiplied data (currently only happens in iPhone images, +// and only if iPhone convert-to-rgb processing is on). +// +// =========================================================================== +// +// ADDITIONAL CONFIGURATION +// +// - You can suppress implementation of any of the decoders to reduce +// your code footprint by #defining one or more of the following +// symbols before creating the implementation. +// +// STBI_NO_JPEG +// STBI_NO_PNG +// STBI_NO_BMP +// STBI_NO_PSD +// STBI_NO_TGA +// STBI_NO_GIF +// STBI_NO_HDR +// STBI_NO_PIC +// STBI_NO_PNM (.ppm and .pgm) +// +// - You can request *only* certain decoders and suppress all other ones +// (this will be more forward-compatible, as addition of new decoders +// doesn't require you to disable them explicitly): +// +// STBI_ONLY_JPEG +// STBI_ONLY_PNG +// STBI_ONLY_BMP +// STBI_ONLY_PSD +// STBI_ONLY_TGA +// STBI_ONLY_GIF +// STBI_ONLY_HDR +// STBI_ONLY_PIC +// STBI_ONLY_PNM (.ppm and .pgm) +// +// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still +// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB +// + + +#ifndef STBI_NO_STDIO +#include +#endif // STBI_NO_STDIO + +#define STBI_VERSION 1 + +enum +{ + STBI_default = 0, // only used for desired_channels + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 +}; + +typedef unsigned char stbi_uc; +typedef unsigned short stbi_us; + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef STB_IMAGE_STATIC +#define STBIDEF static +#else +#define STBIDEF extern +#endif + + ////////////////////////////////////////////////////////////////////////////// + // + // PRIMARY API - works on images of any type + // + + // + // load image by filename, open file, or memory buffer + // + + typedef struct + { + int(*read) (void *user, char *data, int size); // fill 'data' with 'size' bytes. return number of bytes actually read + void(*skip) (void *user, int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative + int(*eof) (void *user); // returns nonzero if we are at end of file/data + } stbi_io_callbacks; + + //////////////////////////////////// + // + // 8-bits-per-channel interface + // + + STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); +#ifndef STBI_NO_GIF + STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +#endif + + +#ifndef STBI_NO_STDIO + STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); + // for stbi_load_from_file, file pointer is left pointing immediately after image +#endif + + //////////////////////////////////// + // + // 16-bits-per-channel interface + // + + STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO + STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +#endif + + //////////////////////////////////// + // + // float-per-channel interface + // +#ifndef STBI_NO_LINEAR + STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); + +#ifndef STBI_NO_STDIO + STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +#endif +#endif + +#ifndef STBI_NO_HDR + STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); + STBIDEF void stbi_hdr_to_ldr_scale(float scale); +#endif // STBI_NO_HDR + +#ifndef STBI_NO_LINEAR + STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); + STBIDEF void stbi_ldr_to_hdr_scale(float scale); +#endif // STBI_NO_LINEAR + + // stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR + STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); + STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +#ifndef STBI_NO_STDIO + STBIDEF int stbi_is_hdr(char const *filename); + STBIDEF int stbi_is_hdr_from_file(FILE *f); +#endif // STBI_NO_STDIO + + + // get a VERY brief reason for failure + // NOT THREADSAFE + STBIDEF const char *stbi_failure_reason(void); + + // free the loaded image -- this is just free() + STBIDEF void stbi_image_free(void *retval_from_stbi_load); + + // get image dimensions & components without fully decoding + STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); + STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); + STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); + STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); + +#ifndef STBI_NO_STDIO + STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp); + STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp); + STBIDEF int stbi_is_16_bit(char const *filename); + STBIDEF int stbi_is_16_bit_from_file(FILE *f); +#endif + + + + // for image formats that explicitly notate that they have premultiplied alpha, + // we just return the colors as stored in the file. set this flag to force + // unpremultiplication. results are undefined if the unpremultiply overflow. + STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); + + // indicate whether we should process iphone images back to canonical format, + // or just pass them through "as-is" + STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); + + // flip the image vertically, so the first pixel in the output array is the bottom left + STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); + + // ZLIB client - used by PNG, available for other purposes + + STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); + STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); + STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); + STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + + STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); + STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBI_INCLUDE_STB_IMAGE_H + +#ifdef STB_IMAGE_IMPLEMENTATION + +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ + || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ + || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ + || defined(STBI_ONLY_ZLIB) +#ifndef STBI_ONLY_JPEG +#define STBI_NO_JPEG +#endif +#ifndef STBI_ONLY_PNG +#define STBI_NO_PNG +#endif +#ifndef STBI_ONLY_BMP +#define STBI_NO_BMP +#endif +#ifndef STBI_ONLY_PSD +#define STBI_NO_PSD +#endif +#ifndef STBI_ONLY_TGA +#define STBI_NO_TGA +#endif +#ifndef STBI_ONLY_GIF +#define STBI_NO_GIF +#endif +#ifndef STBI_ONLY_HDR +#define STBI_NO_HDR +#endif +#ifndef STBI_ONLY_PIC +#define STBI_NO_PIC +#endif +#ifndef STBI_ONLY_PNM +#define STBI_NO_PNM +#endif +#endif + +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#define STBI_NO_ZLIB +#endif + + +#include +#include // ptrdiff_t on osx +#include +#include +#include + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +#include // ldexp, pow +#endif + +#ifndef STBI_NO_STDIO +#include +#endif + +#ifndef STBI_ASSERT +#include +#define STBI_ASSERT(x) assert(x) +#endif + + +#ifndef _MSC_VER +#ifdef __cplusplus +#define stbi_inline inline +#else +#define stbi_inline +#endif +#else +#define stbi_inline __forceinline +#endif + + +#ifdef _MSC_VER +typedef unsigned short stbi__uint16; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; +#else +#include +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(stbi__uint32) == 4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif + +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif + +#ifdef STBI_HAS_LROTL +#define stbi_lrot(x,y) _lrotl(x,y) +#else +#define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) +#endif + +#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) +// ok +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) +// ok +#else +#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." +#endif + +#ifndef STBI_MALLOC +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p,newsz) realloc(p,newsz) +#define STBI_FREE(p) free(p) +#endif + +#ifndef STBI_REALLOC_SIZED +#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +// gcc doesn't support sse2 intrinsics unless you compile with -msse2, +// which in turn means it gets to use SSE2 everywhere. This is unfortunate, +// but previous attempts to provide the SSE2 functions with runtime +// detection caused numerous issues. The way architecture extensions are +// exposed in GCC/Clang is, sadly, not really suited for one-file libs. +// New behavior: if compiled with -msse2, we use SSE2 without any +// detection; if not, we don't use it at all. +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +// +// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the +// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. +// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not +// simultaneously enabling "-mstackrealign". +// +// See https://github.com/nothings/stb/issues/81 for more information. +// +// So default to no SSE2 on 32-bit MinGW. If you've read this far and added +// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) +#define STBI_SSE2 +#include + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 // not VC6 +#include // __cpuid +static int stbi__cpuid3(void) +{ + int info[4]; + __cpuid(info, 1); + return info[3]; +} +#else +static int stbi__cpuid3(void) +{ + int res; + __asm { + mov eax, 1 + cpuid + mov res, edx + } + return res; +} +#endif + +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +static int stbi__sse2_available(void) +{ + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#else // assume GCC-style if not VC++ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) + +static int stbi__sse2_available(void) +{ + // If we're even attempting to compile this on GCC/Clang, that means + // -msse2 is on, which means the compiler is allowed to use SSE2 + // instructions at will, and so are we. + return 1; +} +#endif +#endif + +// ARM NEON +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include +// assume GCC or Clang on ARM targets +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct +{ + stbi__uint32 img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; + + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; +} stbi__context; + + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *)buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *)buffer + len; +} + +// initialize a callback-based context +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) +{ + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; +} + +#ifndef STBI_NO_STDIO + +static int stbi__stdio_read(void *user, char *data, int size) +{ + return (int)fread(data, 1, size, (FILE*)user); +} + +static void stbi__stdio_skip(void *user, int n) +{ + fseek((FILE*)user, n, SEEK_CUR); +} + +static int stbi__stdio_eof(void *user) +{ + return feof((FILE*)user); +} + +static stbi_io_callbacks stbi__stdio_callbacks = +{ + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, +}; + +static void stbi__start_file(stbi__context *s, FILE *f) +{ + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *)f); +} + +//static void stop_file(stbi__context *s) { } + +#endif // !STBI_NO_STDIO + +static void stbi__rewind(stbi__context *s) +{ + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; +} + +enum +{ + STBI_ORDER_RGB, + STBI_ORDER_BGR +}; + +typedef struct +{ + int bits_per_channel; + int num_channels; + int channel_order; +} stbi__result_info; + +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNG +static int stbi__png_test(stbi__context *s); +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__png_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_BMP +static int stbi__bmp_test(stbi__context *s); +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_TGA +static int stbi__tga_test(stbi__context *s); +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s); +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__psd_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_HDR +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_test(stbi__context *s); +static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_GIF +static int stbi__gif_test(stbi__context *s); +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNM +static int stbi__pnm_test(stbi__context *s); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +// this is not threadsafe +static const char *stbi__g_failure_reason; + +STBIDEF const char *stbi_failure_reason(void) +{ + return stbi__g_failure_reason; +} + +static int stbi__err(const char *str) +{ + stbi__g_failure_reason = str; + return 0; +} + +static void *stbi__malloc(size_t size) +{ + return STBI_MALLOC(size); +} + +// stb_image uses ints pervasively, including for offset calculations. +// therefore the largest decoded image size we can support with the +// current code, even on 64-bit targets, is INT_MAX. this is not a +// significant limitation for the intended use case. +// +// we do, however, need to make sure our size calculations don't +// overflow. hence a few helper functions for size calculations that +// multiply integers together, making sure that they're non-negative +// and no overflow occurs. + +// return 1 if the sum is valid, 0 on overflow. +// negative terms are considered invalid. +static int stbi__addsizes_valid(int a, int b) +{ + if (b < 0) return 0; + // now 0 <= b <= INT_MAX, hence also + // 0 <= INT_MAX - b <= INTMAX. + // And "a + b <= INT_MAX" (which might overflow) is the + // same as a <= INT_MAX - b (no overflow) + return a <= INT_MAX - b; +} + +// returns 1 if the product is valid, 0 on overflow. +// negative factors are considered invalid. +static int stbi__mul2sizes_valid(int a, int b) +{ + if (a < 0 || b < 0) return 0; + if (b == 0) return 1; // mul-by-0 is always safe + // portable way to check for no overflows in a*b + return a <= INT_MAX / b; +} + +// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow +static int stbi__mad2sizes_valid(int a, int b, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); +} + +// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow +static int stbi__mad3sizes_valid(int a, int b, int c, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__addsizes_valid(a*b*c, add); +} + +// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); +} +#endif + +// mallocs with size overflow checking +static void *stbi__malloc_mad2(int a, int b, int add) +{ + if (!stbi__mad2sizes_valid(a, b, add)) return NULL; + return stbi__malloc(a*b + add); +} + +static void *stbi__malloc_mad3(int a, int b, int c, int add) +{ + if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; + return stbi__malloc(a*b*c + add); +} + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) +{ + if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; + return stbi__malloc(a*b*c*d + add); +} +#endif + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS +#define stbi__err(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) +#define stbi__err(x,y) stbi__err(y) +#else +#define stbi__err(x,y) stbi__err(x) +#endif + +#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) + +STBIDEF void stbi_image_free(void *retval_from_stbi_load) +{ + STBI_FREE(retval_from_stbi_load); +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_HDR +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +static int stbi__vertically_flip_on_load = 0; + +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load = flag_true_if_should_flip; +} + +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +{ + memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed + ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order + ri->num_channels = 0; + +#ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) return stbi__jpeg_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PNG + if (stbi__png_test(s)) return stbi__png_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) return stbi__bmp_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_GIF + if (stbi__gif_test(s)) return stbi__gif_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PSD + if (stbi__psd_test(s)) return stbi__psd_load(s, x, y, comp, req_comp, ri, bpc); +#endif +#ifndef STBI_NO_PIC + if (stbi__pic_test(s)) return stbi__pic_load(s, x, y, comp, req_comp, ri); +#endif +#ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) return stbi__pnm_load(s, x, y, comp, req_comp, ri); +#endif + +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x, y, comp, req_comp, ri); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } +#endif + +#ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s, x, y, comp, req_comp, ri); +#endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi_uc *reduced; + + reduced = (stbi_uc *)stbi__malloc(img_len); + if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling + + STBI_FREE(orig); + return reduced; +} + +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi__uint16 *enlarged; + + enlarged = (stbi__uint16 *)stbi__malloc(img_len * 2); + if (enlarged == NULL) return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff + + STBI_FREE(orig); + return enlarged; +} + +static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) +{ + int row; + size_t bytes_per_row = (size_t)w * bytes_per_pixel; + stbi_uc temp[2048]; + stbi_uc *bytes = (stbi_uc *)image; + + for (row = 0; row < (h >> 1); row++) { + stbi_uc *row0 = bytes + row*bytes_per_row; + stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; + // swap row0 with row1 + size_t bytes_left = bytes_per_row; + while (bytes_left) { + size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); + memcpy(temp, row0, bytes_copy); + memcpy(row0, row1, bytes_copy); + memcpy(row1, temp, bytes_copy); + row0 += bytes_copy; + row1 += bytes_copy; + bytes_left -= bytes_copy; + } + } +} + +static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) +{ + int slice; + int slice_size = w * h * bytes_per_pixel; + + stbi_uc *bytes = (stbi_uc *)image; + for (slice = 0; slice < z; ++slice) { + stbi__vertical_flip(bytes, w, h, bytes_per_pixel); + bytes += slice_size; + } +} + +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8); + + if (result == NULL) + return NULL; + + if (ri.bits_per_channel != 8) { + STBI_ASSERT(ri.bits_per_channel == 16); + result = stbi__convert_16_to_8((stbi__uint16 *)result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 8; + } + + // @TODO: move stbi__convert_format to here + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } + + return (unsigned char *)result; +} + +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16); + + if (result == NULL) + return NULL; + + if (ri.bits_per_channel != 16) { + STBI_ASSERT(ri.bits_per_channel == 8); + result = stbi__convert_8_to_16((stbi_uc *)result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 16; + } + + // @TODO: move stbi__convert_format16 to here + // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); + } + + return (stbi__uint16 *)result; +} + +#if !defined(STBI_NO_HDR) || !defined(STBI_NO_LINEAR) +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) +{ + if (stbi__vertically_flip_on_load && result != NULL) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); + } +} +#endif + +#ifndef STBI_NO_STDIO + +static FILE *stbi__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f = 0; +#else + f = fopen(filename, mode); +#endif + return f; +} + + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__uint16 *result; + stbi__context s; + stbi__start_file(&s, f); + result = stbi__load_and_postprocess_16bit(&s, x, y, comp, req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, -(int)(s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + stbi__uint16 *result; + if (!f) return (stbi_us *)stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file_16(f, x, y, comp, req_comp); + fclose(f); + return result; +} + + +#endif //!STBI_NO_STDIO + +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, desired_channels); +} + +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_16bit(&s, x, y, channels_in_file, desired_channels); +} + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_8bit(&s, x, y, comp, req_comp); +} + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_mem(&s, buffer, len); + + result = (unsigned char*)stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); + if (stbi__vertically_flip_on_load) { + stbi__vertical_flip_slices(result, *x, *y, *z, *comp); + } + + return result; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; +#ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + stbi__result_info ri; + float *hdr_data = stbi__hdr_load(s, x, y, comp, req_comp, &ri); + if (hdr_data) + stbi__float_postprocess(hdr_data, x, y, comp, req_comp); + return hdr_data; + } +#endif + data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); +} + +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} + +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f, x, y, comp, req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_file(&s, f); + return stbi__loadf_main(&s, x, y, comp, req_comp); +} +#endif // !STBI_NO_STDIO + +#endif // !STBI_NO_LINEAR + +// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is +// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always +// reports false! + +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) +{ +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; +#endif +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr(char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result = 0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +STBIDEF int stbi_is_hdr_from_file(FILE *f) +{ +#ifndef STBI_NO_HDR + long pos = ftell(f); + int res; + stbi__context s; + stbi__start_file(&s, f); + res = stbi__hdr_test(&s); + fseek(f, pos, SEEK_SET); + return res; +#else + STBI_NOTUSED(f); + return 0; +#endif +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) +{ +#ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__hdr_test(&s); +#else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; +#endif +} + +#ifndef STBI_NO_LINEAR +static float stbi__l2h_gamma = 2.2f, stbi__l2h_scale = 1.0f; + +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +#endif + +static float stbi__h2l_gamma_i = 1.0f / 2.2f, stbi__h2l_scale_i = 1.0f; + +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1 / gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1 / scale; } + + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum +{ + STBI__SCAN_load = 0, + STBI__SCAN_type, + STBI__SCAN_header +}; + +static void stbi__refill_buffer(stbi__context *s) +{ + int n = (s->io.read)(s->io_user_data, (char*)s->buffer_start, s->buflen); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + 1; + *s->img_buffer = 0; + } + else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +stbi_inline static int stbi__at_eof(stbi__context *s) +{ + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} + +static void stbi__skip(stbi__context *s, int n) +{ + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} + +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) +{ + if (s->io.read) { + int blen = (int)(s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char*)buffer + blen, n - blen); + res = (count == (n - blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } + + if (s->img_buffer + n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } + else + return 0; +} + +static int stbi__get16be(stbi__context *s) +{ + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} + +static stbi__uint32 stbi__get32be(stbi__context *s) +{ + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); +} + +#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) +// nothing +#else +static int stbi__get16le(stbi__context *s) +{ + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); +} +#endif + +#ifndef STBI_NO_BMP +static stbi__uint32 stbi__get32le(stbi__context *s) +{ + stbi__uint32 z = stbi__get16le(s); + return z + (stbi__get16le(s) << 16); +} +#endif + +#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings + + +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static stbi_uc stbi__compute_y(int r, int g, int b) +{ + return (stbi_uc)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} + +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i, j; + unsigned char *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *)stbi__malloc_mad3(req_comp, x, y, 0); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + unsigned char *src = data + j * x * img_n; + unsigned char *dest = good + j * x * req_comp; + +#define STBI__COMBO(a,b) ((a)*8+(b)) +#define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { dest[0] = src[0], dest[1] = 255; } break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } break; + STBI__CASE(1, 4) { dest[0] = dest[1] = dest[2] = src[0], dest[3] = 255; } break; + STBI__CASE(2, 1) { dest[0] = src[0]; } break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } break; + STBI__CASE(2, 4) { dest[0] = dest[1] = dest[2] = src[0], dest[3] = src[1]; } break; + STBI__CASE(3, 4) { dest[0] = src[0], dest[1] = src[1], dest[2] = src[2], dest[3] = 255; } break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } break; + STBI__CASE(3, 2) { dest[0] = stbi__compute_y(src[0], src[1], src[2]), dest[1] = 255; } break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y(src[0], src[1], src[2]); } break; + STBI__CASE(4, 2) { dest[0] = stbi__compute_y(src[0], src[1], src[2]), dest[1] = src[3]; } break; + STBI__CASE(4, 3) { dest[0] = src[0], dest[1] = src[1], dest[2] = src[2]; } break; + default: STBI_ASSERT(0); + } +#undef STBI__CASE + } + + STBI_FREE(data); + return good; +} + +static stbi__uint16 stbi__compute_y_16(int r, int g, int b) +{ + return (stbi__uint16)(((r * 77) + (g * 150) + (29 * b)) >> 8); +} + +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i, j; + stbi__uint16 *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (stbi__uint16 *)stbi__malloc(req_comp * x * y * 2); + if (good == NULL) { + STBI_FREE(data); + return (stbi__uint16 *)stbi__errpuc("outofmem", "Out of memory"); + } + + for (j = 0; j < (int)y; ++j) { + stbi__uint16 *src = data + j * x * img_n; + stbi__uint16 *dest = good + j * x * req_comp; + +#define STBI__COMBO(a,b) ((a)*8+(b)) +#define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1, 2) { dest[0] = src[0], dest[1] = 0xffff; } break; + STBI__CASE(1, 3) { dest[0] = dest[1] = dest[2] = src[0]; } break; + STBI__CASE(1, 4) { dest[0] = dest[1] = dest[2] = src[0], dest[3] = 0xffff; } break; + STBI__CASE(2, 1) { dest[0] = src[0]; } break; + STBI__CASE(2, 3) { dest[0] = dest[1] = dest[2] = src[0]; } break; + STBI__CASE(2, 4) { dest[0] = dest[1] = dest[2] = src[0], dest[3] = src[1]; } break; + STBI__CASE(3, 4) { dest[0] = src[0], dest[1] = src[1], dest[2] = src[2], dest[3] = 0xffff; } break; + STBI__CASE(3, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } break; + STBI__CASE(3, 2) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]), dest[1] = 0xffff; } break; + STBI__CASE(4, 1) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]); } break; + STBI__CASE(4, 2) { dest[0] = stbi__compute_y_16(src[0], src[1], src[2]), dest[1] = src[3]; } break; + STBI__CASE(4, 3) { dest[0] = src[0], dest[1] = src[1], dest[2] = src[2]; } break; + default: STBI_ASSERT(0); + } +#undef STBI__CASE + } + + STBI_FREE(data); + return good; +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +{ + int i, k, n; + float *output; + if (!data) return NULL; + output = (float *)stbi__malloc_mad4(x, y, comp, sizeof(float), 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp - 1; + for (i = 0; i < x*y; ++i) { + for (k = 0; k < n; ++k) { + output[i*comp + k] = (float)(pow(data[i*comp + k] / 255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + } + if (k < comp) output[i*comp + k] = data[i*comp + k] / 255.0f; + } + STBI_FREE(data); + return output; +} +#endif + +#ifndef STBI_NO_HDR +#define stbi__float2int(x) ((int) (x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) +{ + int i, k, n; + stbi_uc *output; + if (!data) return NULL; + output = (stbi_uc *)stbi__malloc_mad3(x, y, comp, 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp - 1; + for (i = 0; i < x*y; ++i) { + for (k = 0; k < n; ++k) { + float z = (float)pow(data[i*comp + k] * stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc)stbi__float2int(z); + } + if (k < comp) { + float z = data[i*comp + k] * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc)stbi__float2int(z); + } + } + STBI_FREE(data); + return output; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly + +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct +{ + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi__uint16 dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + + // sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + + // definition of jpeg image component + struct + { + int id; + int h, v; + int tq; + int hd, ha; + int dc_pred; + + int x, y, w2, h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + int jfif; + int app14_color_transform; // Adobe APP14 tag + int rgb; + + int scan_n, order[4]; + int restart_interval, todo; + + // kernels + void(*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void(*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); +} stbi__jpeg; + +static int stbi__build_huffman(stbi__huffman *h, int *count) +{ + int i, j, k = 0; + unsigned int code; + // build size list for each symbol (from JPEG spec) + for (i = 0; i < 16; ++i) + for (j = 0; j < count[i]; ++j) + h->size[k++] = (stbi_uc)(i + 1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for (j = 1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16)(code++); + if (code - 1 >= (1u << j)) return stbi__err("bad code lengths", "Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16 - j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i = 0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS - s); + int m = 1 << (FAST_BITS - s); + for (j = 0; j < m; ++j) { + h->fast[c + j] = (stbi_uc)i; + } + } + } + return 1; +} + +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) +{ + int i; + for (i = 0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) k += (~0U << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16)((k * 256) + (run * 16) + (len + magbits)); + } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) +{ + do { + unsigned int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes + if (c != 0) { + j->marker = (unsigned char)c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} + +// (1 << n) - 1 +static const stbi__uint32 stbi__bmask[17] = { 0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535 }; + +// decode a jpeg huffman value from the bitstream +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +{ + unsigned int temp; + int c, k; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k = FAST_BITS + 1; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); + + sgn = (stbi__int32)j->code_buffer >> 31; // sign bit is always in MSB + k = stbi_lrot(j->code_buffer, n); + STBI_ASSERT(n >= 0 && n < (int)(sizeof(stbi__bmask) / sizeof(*stbi__bmask))); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & ~sgn); +} + +// get some unsigned bits +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +{ + unsigned int k; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) +{ + unsigned int k; + if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static const stbi_uc stbi__jpeg_dezigzag[64 + 15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) +{ + int diff, dc, k; + int t; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0) return stbi__err("bad huffman code", "Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data, 0, 64 * sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short)(dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) * dequant[zig]); + } + else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } + else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +{ + int diff, dc; + int t; + if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data, 0, 64 * sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + diff = t ? stbi__extend_receive(j, t) : 0; + + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short)(dc << j->succ_low); + } + else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short)(1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) +{ + int k; + if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c, r, s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS) - 1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)((r >> 8) << shift); + } + else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } + else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short)(stbi__extend_receive(j, s) << shift); + } + } + } while (k <= j->spec_end); + } + else { + // refinement scan for these AC coefficients + + short bit = (short)(1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } + else { + k = j->spec_start; + do { + int r, s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + if (rs < 0) return stbi__err("bad huffman code", "Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } + else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } + else { + if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit) == 0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + else { + if (r == 0) { + *p = (short)s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +stbi_inline static stbi_uc stbi__clamp(int x) +{ + // trick to use a single test to catch both cases + if ((unsigned int)x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (stbi_uc)x; +} + +#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3*stbi__f2f(-1.847759065f); \ + t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2+p3); \ + t1 = stbi__fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ + t0 = t0*stbi__f2f( 0.298631336f); \ + t1 = t1*stbi__f2f( 2.053119869f); \ + t2 = t2*stbi__f2f( 3.072711026f); \ + t3 = t3*stbi__f2f( 1.501321110f); \ + p1 = p5 + p1*stbi__f2f(-0.899976223f); \ + p2 = p5 + p2*stbi__f2f(-2.562915447f); \ + p3 = p3*stbi__f2f(-1.961570560f); \ + p4 = p4*stbi__f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) +{ + int i, val[64], *v = val; + stbi_uc *o; + short *d = data; + + // columns + for (i = 0; i < 8; ++i, ++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[8] == 0 && d[16] == 0 && d[24] == 0 && d[32] == 0 + && d[40] == 0 && d[48] == 0 && d[56] == 0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] * 4; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } + else { + STBI__IDCT_1D(d[0], d[8], d[16], d[24], d[32], d[40], d[48], d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[0] = (x0 + t3) >> 10; + v[56] = (x0 - t3) >> 10; + v[8] = (x1 + t2) >> 10; + v[48] = (x1 - t2) >> 10; + v[16] = (x2 + t1) >> 10; + v[40] = (x2 - t1) >> 10; + v[24] = (x3 + t0) >> 10; + v[32] = (x3 - t0) >> 10; + } + } + + for (i = 0, v = val, o = out; i < 8; ++i, v += 8, o += out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128 << 17); + x1 += 65536 + (128 << 17); + x2 += 65536 + (128 << 17); + x3 += 65536 + (128 << 17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0 + t3) >> 17); + o[7] = stbi__clamp((x0 - t3) >> 17); + o[1] = stbi__clamp((x1 + t2) >> 17); + o[6] = stbi__clamp((x1 - t2) >> 17); + o[2] = stbi__clamp((x2 + t1) >> 17); + o[5] = stbi__clamp((x2 - t1) >> 17); + o[3] = stbi__clamp((x3 + t0) >> 17); + o[4] = stbi__clamp((x3 - t0) >> 17); + } +} + +#ifdef STBI_SSE2 +// sse2 integer IDCT. not the fastest possible implementation but it +// produces bit-identical results to the generic C version so it's +// fully "transparent". +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + + // dot product constant: even elems=x, odd elems=y +#define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) + + // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) + // out(1) = c1[even]*x + c1[odd]*y +#define dct_rot(out0,out1, x,y,c0,c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + + // out = in << 12 (in 16-bit, out 32-bit) +#define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + + // wide add +#define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + + // wide sub +#define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + + // butterfly a/b, add bias, then shift by "s" and pack +#define dct_bfly32o(out0, out1, a,b,bias,s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + + // 8-bit interleave step (for transposes) +#define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + + // 16-bit interleave step (for transposes) +#define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + +#define dct_pass(bias,shift) \ + { \ + /* even part */ \ + dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ + dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0,row7, x0,x7,bias,shift); \ + dct_bfly32o(row1,row6, x1,x6,bias,shift); \ + dct_bfly32o(row2,row5, x2,x5,bias,shift); \ + dct_bfly32o(row3,row4, x3,x4,bias,shift); \ + } + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f(0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f(0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f(3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f(2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f(1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128 << 17)); + + // load + row0 = _mm_load_si128((const __m128i *) (data + 0 * 8)); + row1 = _mm_load_si128((const __m128i *) (data + 1 * 8)); + row2 = _mm_load_si128((const __m128i *) (data + 2 * 8)); + row3 = _mm_load_si128((const __m128i *) (data + 3 * 8)); + row4 = _mm_load_si128((const __m128i *) (data + 4 * 8)); + row5 = _mm_load_si128((const __m128i *) (data + 5 * 8)); + row6 = _mm_load_si128((const __m128i *) (data + 6 * 8)); + row7 = _mm_load_si128((const __m128i *) (data + 7 * 8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *) out, p0); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p2); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p1); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p3); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif // STBI_SSE2 + +#ifdef STBI_NEON + +// NEON integer IDCT. should produce bit-identical +// results to the generic C version. +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f(0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f(1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f(0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f(2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f(3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f(1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + + // wide add +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + + // wide sub +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + + // butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ + dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ + dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ + dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ + } + + // load + row0 = vld1q_s16(data + 0 * 8); + row1 = vld1q_s16(data + 1 * 8); + row2 = vld1q_s16(data + 2 * 8); + row3 = vld1q_s16(data + 3 * 8); + row4 = vld1q_s16(data + 4 * 8); + row5 = vld1q_s16(data + 5 * 8); + row6 = vld1q_s16(data + 6 * 8); + row7 = vld1q_s16(data + 7 * 8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { + // these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. + // whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } +#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } +#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); out += out_stride; + vst1_u8(out, p1); out += out_stride; + vst1_u8(out, p2); out += out_stride; + vst1_u8(out, p3); out += out_stride; + vst1_u8(out, p4); out += out_stride; + vst1_u8(out, p5); out += out_stride; + vst1_u8(out, p6); out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif // STBI_NEON + +#define STBI__MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static stbi_uc stbi__get_marker(stbi__jpeg *j) +{ + stbi_uc x; + if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } + x = stbi__get8(j->s); + if (x != 0xff) return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); // consume repeated 0xff fill bytes + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, stbi__jpeg_reset the entropy decoder and +// the dc prediction +static void stbi__jpeg_reset(stbi__jpeg *j) +{ + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +{ + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i, j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc + z->img_comp[n].hd, z->huff_ac + ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2*j * 8 + i * 8, z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + else { // interleaved + int i, j, k, x, y; + STBI_SIMD_ALIGN(short, data[64]); + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x) * 8; + int y2 = (j*z->img_comp[n].v + y) * 8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc + z->img_comp[n].hd, z->huff_ac + ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2*y2 + x2, z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } + else { + if (z->scan_n == 1) { + int i, j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + else { // interleaved + int i, j, k, x, y; + for (j = 0; j < z->img_mcu_y; ++j) { + for (i = 0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k = 0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y = 0; y < z->img_comp[n].v; ++y) { + for (x = 0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x); + int y2 = (j*z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) +{ + int i; + for (i = 0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) +{ + if (z->progressive) { + // dequantize and idct the data + int i, j, n; + for (n = 0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x + 7) >> 3; + int h = (z->img_comp[n].y + 7) >> 3; + for (j = 0; j < h; ++j) { + for (i = 0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data + z->img_comp[n].w2*j * 8 + i * 8, z->img_comp[n].w2, data); + } + } + } + } +} + +static int stbi__process_marker(stbi__jpeg *z, int m) +{ + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker", "Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len", "Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s) - 2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4, sixteen = (p != 0); + int t = q & 15, i; + if (p != 0 && p != 1) return stbi__err("bad DQT type", "Corrupt JPEG"); + if (t > 3) return stbi__err("bad DQT table", "Corrupt JPEG"); + + for (i = 0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); + L -= (sixteen ? 129 : 65); + } + return L == 0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s) - 2; + while (L > 0) { + stbi_uc *v; + int sizes[16], i, n = 0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) return stbi__err("bad DHT header", "Corrupt JPEG"); + for (i = 0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc + th, sizes)) return 0; + v = z->huff_dc[th].values; + } + else { + if (!stbi__build_huffman(z->huff_ac + th, sizes)) return 0; + v = z->huff_ac[th].values; + } + for (i = 0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L == 0; + } + + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + L = stbi__get16be(z->s); + if (L < 2) { + if (m == 0xFE) + return stbi__err("bad COM len", "Corrupt JPEG"); + else + return stbi__err("bad APP len", "Corrupt JPEG"); + } + L -= 2; + + if (m == 0xE0 && L >= 5) { // JFIF APP0 segment + static const unsigned char tag[5] = { 'J','F','I','F','\0' }; + int ok = 1; + int i; + for (i = 0; i < 5; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 5; + if (ok) + z->jfif = 1; + } + else if (m == 0xEE && L >= 12) { // Adobe APP14 segment + static const unsigned char tag[6] = { 'A','d','o','b','e','\0' }; + int ok = 1; + int i; + for (i = 0; i < 6; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 6; + if (ok) { + stbi__get8(z->s); // version + stbi__get16be(z->s); // flags0 + stbi__get16be(z->s); // flags1 + z->app14_color_transform = stbi__get8(z->s); // color transform + L -= 6; + } + } + + stbi__skip(z->s, L); + return 1; + } + + return stbi__err("unknown marker", "Corrupt JPEG"); +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) +{ + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int)z->s->img_n) return stbi__err("bad SOS component count", "Corrupt JPEG"); + if (Ls != 6 + 2 * z->scan_n) return stbi__err("bad SOS len", "Corrupt JPEG"); + for (i = 0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) return 0; // no match + z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff", "Corrupt JPEG"); + z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff", "Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } + else { + if (z->spec_start != 0) return stbi__err("bad SOS", "Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS", "Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; +} + +static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) +{ + int i; + for (i = 0; i < ncomp; ++i) { + if (z->img_comp[i].raw_data) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; + z->img_comp[i].data = NULL; + } + if (z->img_comp[i].raw_coeff) { + STBI_FREE(z->img_comp[i].raw_coeff); + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].linebuf) { + STBI_FREE(z->img_comp[i].linebuf); + z->img_comp[i].linebuf = NULL; + } + } + return why; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) +{ + stbi__context *s = z->s; + int Lf, p, i, q, h_max = 1, v_max = 1, c; + Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len", "Corrupt JPEG"); // JPEG + p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit", "JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width", "Corrupt JPEG"); // JPEG requires + c = stbi__get8(s); + if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count", "Corrupt JPEG"); + s->img_n = c; + for (i = 0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8 + 3 * s->img_n) return stbi__err("bad SOF len", "Corrupt JPEG"); + + z->rgb = 0; + for (i = 0; i < s->img_n; ++i) { + static const unsigned char rgb[3] = { 'R', 'G', 'B' }; + z->img_comp[i].id = stbi__get8(s); + if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) + ++z->rgb; + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H", "Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V", "Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ", "Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) return 1; + + if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); + + for (i = 0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + // these sizes can't be more than 17 bits + z->img_mcu_x = (s->img_x + z->img_mcu_w - 1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h - 1) / z->img_mcu_h; + + for (i = 0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max - 1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max - 1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + // + // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) + // so these muls can't overflow with 32-bit ints (which we require) + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].linebuf = NULL; + z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); + if (z->img_comp[i].raw_data == NULL) + return stbi__free_jpeg_components(z, i + 1, stbi__err("outofmem", "Out of memory")); + // align blocks for idct using mmx/sse + z->img_comp[i].data = (stbi_uc*)(((size_t)z->img_comp[i].raw_data + 15) & ~15); + if (z->progressive) { + // w2, h2 are multiples of 8 (see above) + z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; + z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; + z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); + if (z->img_comp[i].raw_coeff == NULL) + return stbi__free_jpeg_components(z, i + 1, stbi__err("outofmem", "Out of memory")); + z->img_comp[i].coeff = (short*)(((size_t)z->img_comp[i].raw_coeff + 15) & ~15); + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +{ + int m; + z->jfif = 0; + z->app14_color_transform = -1; // valid values are 0,1,2 + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) return stbi__err("no SOI", "Corrupt JPEG"); + if (scan == STBI__SCAN_type) return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z, m)) return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) return 0; + return 1; +} + +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) +{ + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) return 0; + if (!stbi__parse_entropy_coded_data(j)) return 0; + if (j->marker == STBI__MARKER_none) { + // handle 0s at the end of image data from IP Kamera 9060 + while (!stbi__at_eof(j->s)) { + int x = stbi__get8(j->s); + if (x == 255) { + j->marker = stbi__get8(j->s); + break; + } + } + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + } + } + else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); + } + else { + if (!stbi__process_marker(j, m)) return 0; + } + m = stbi__get_marker(j); + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, + int w, int hs); + +#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i = 0; i < w; ++i) + out[i] = stbi__div4(3 * in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0] * 3 + input[1] + 2); + for (i = 1; i < w - 1; ++i) { + int n = 3 * input[i] + 2; + out[i * 2 + 0] = stbi__div4(n + input[i - 1]); + out[i * 2 + 1] = stbi__div4(n + input[i + 1]); + } + out[i * 2 + 0] = stbi__div4(input[w - 2] * 3 + input[w - 1] + 2); + out[i * 2 + 1] = input[w - 1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i, t0, t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + out[0] = stbi__div4(t1 + 2); + for (i = 1; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i = 0, t0, t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3 * in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3 * in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w - 1) & ~7); i += 8) { +#if defined(STBI_SSE2) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3 * in_near[i + 8] + in_far[i + 8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *) (out + i * 2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3 * in_near[i + 8] + in_far[i + 8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i * 2, o); +#endif + + // "previous" value for next iter + t1 = 3 * in_near[i + 7] + in_far[i + 7]; + } + + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3 * in_near[i] + in_far[i]; + out[i * 2 - 1] = stbi__div16(3 * t0 + t1 + 8); + out[i * 2] = stbi__div16(3 * t1 + t0 + 8); + } + out[w * 2 - 1] = stbi__div4(t1 + 2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // resample with nearest-neighbor + int i, j; + STBI_NOTUSED(in_far); + for (i = 0; i < w; ++i) + for (j = 0; j < hs; ++j) + out[i*hs + j] = in_near[i]; + return out; +} + +// this is a reduced-precision calculation of YCbCr-to-RGB introduced +// to make sure the code produces the same results in both SIMD and scalar +#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +{ + int i; + for (i = 0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned)g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned)b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) +{ + int i = 0; + +#ifdef STBI_SSE2 + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16((short)(1.40200f*4096.0f + 0.5f)); + __m128i cr_const1 = _mm_set1_epi16(-(short)(0.71414f*4096.0f + 0.5f)); + __m128i cb_const0 = _mm_set1_epi16(-(short)(0.34414f*4096.0f + 0.5f)); + __m128i cb_const1 = _mm_set1_epi16((short)(1.77200f*4096.0f + 0.5f)); + __m128i y_bias = _mm_set1_epi8((char)(unsigned char)128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i + 7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y + i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr + i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb + i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *) (out + 0), o0); + _mm_storeu_si128((__m128i *) (out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16((short)(1.40200f*4096.0f + 0.5f)); + int16x8_t cr_const1 = vdupq_n_s16(-(short)(0.71414f*4096.0f + 0.5f)); + int16x8_t cb_const0 = vdupq_n_s16(-(short)(0.34414f*4096.0f + 0.5f)); + int16x8_t cb_const1 = vdupq_n_s16((short)(1.77200f*4096.0f + 0.5f)); + + for (; i + 7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8 * 4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1 << 19); // rounding + int r, g, b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned)r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned)g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned)b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +// set up the kernels +static void stbi__setup_jpeg(stbi__jpeg *j) +{ + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; +#endif +} + +// clean up the temporary component buffers +static void stbi__cleanup_jpeg(stbi__jpeg *j) +{ + stbi__free_jpeg_components(j, j->s->img_n, 0); +} + +typedef struct +{ + resample_row_func resample; + stbi_uc *line0, *line1; + int hs, vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +// fast 0..255 * 0..255 => 0..255 rounded multiplication +static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) +{ + unsigned int t = x*y + 128; + return (stbi_uc)((t + (t >> 8)) >> 8); +} + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +{ + int n, decode_n, is_rgb; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; + + is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); + + if (z->s->img_n == 3 && n < 3 && !is_rgb) + decode_n = 1; + else + decode_n = z->s->img_n; + + // resample and color-convert + { + int k; + unsigned int i, j; + stbi_uc *output; + stbi_uc *coutput[4]; + + stbi__resample res_comp[4]; + + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *)stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs - 1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; + else r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *)stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); + if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + // now go ahead and resample + for (j = 0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k = 0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + if (is_rgb) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = y[i]; + out[1] = coutput[1][i]; + out[2] = coutput[2][i]; + out[3] = 255; + out += n; + } + } + else { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } + else if (z->s->img_n == 4) { + if (z->app14_color_transform == 0) { // CMYK + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); + out[3] = 255; + out += n; + } + } + else if (z->app14_color_transform == 2) { // YCCK + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); + out += n; + } + } + else { // YCbCr + alpha? Ignore the fourth channel for now + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } + else + for (i = 0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } + else { + if (is_rgb) { + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) + *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + else { + for (i = 0; i < z->s->img_x; ++i, out += 2) { + out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; + } + } + } + else if (z->s->img_n == 4 && z->app14_color_transform == 0) { + for (i = 0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); + out[0] = stbi__compute_y(r, g, b); + out[1] = 255; + out += n; + } + } + else if (z->s->img_n == 4 && z->app14_color_transform == 2) { + for (i = 0; i < z->s->img_x; ++i) { + out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); + out[1] = 255; + out += n; + } + } + else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i = 0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i = 0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + } + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output + return output; + } +} + +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + unsigned char* result; + stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); + STBI_NOTUSED(ri); + j->s = s; + stbi__setup_jpeg(j); + result = load_jpeg_image(j, x, y, comp, req_comp); + STBI_FREE(j); + return result; +} + +static int stbi__jpeg_test(stbi__context *s) +{ + int r; + stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); + stbi__rewind(s); + STBI_FREE(j); + return r; +} + +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) +{ + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind(j->s); + return 0; + } + if (x) *x = j->s->img_x; + if (y) *y = j->s->img_y; + if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) +{ + int result; + stbi__jpeg* j = (stbi__jpeg*)(stbi__malloc(sizeof(stbi__jpeg))); + j->s = s; + result = stbi__jpeg_info_raw(j, x, y, comp); + STBI_FREE(j); + return result; +} +#endif + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +#ifndef STBI_NO_ZLIB + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct +{ + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[288]; + stbi__uint16 value[288]; +} stbi__zhuffman; + +stbi_inline static int stbi__bitreverse16(int n) +{ + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +stbi_inline static int stbi__bit_reverse(int v, int bits) +{ + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16 - bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) +{ + int i, k = 0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i = 0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i = 1; i < 16; ++i) + if (sizes[i] >(1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i = 1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16)code; + z->firstsymbol[i] = (stbi__uint16)k; + code = (code + sizes[i]); + if (sizes[i]) + if (code - 1 >= (1 << i)) return stbi__err("bad codelengths", "Corrupt PNG"); + z->maxcode[i] = code << (16 - i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i = 0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16)((s << 9) | i); + z->size[c] = (stbi_uc)s; + z->value[c] = (stbi__uint16)i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s], s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +typedef struct +{ + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + stbi__uint32 code_buffer; + + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; + + stbi__zhuffman z_length, z_distance; +} stbi__zbuf; + +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) +{ + if (z->zbuffer >= z->zbuffer_end) return 0; + return *z->zbuffer++; +} + +static void stbi__fill_bits(stbi__zbuf *z) +{ + do { + STBI_ASSERT(z->code_buffer < (1U << z->num_bits)); + z->code_buffer |= (unsigned int)stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) +{ + unsigned int k; + if (z->num_bits < n) stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b, s, k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s = STBI__ZFAST_BITS + 1; ; ++s) + if (k < z->maxcode[s]) + break; + if (s == 16) return -1; // invalid code! + // code size is s, so: + b = (k >> (16 - s)) - z->firstcode[s] + z->firstsymbol[s]; + STBI_ASSERT(z->size[b] == s); + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b, s; + if (a->num_bits < 16) stbi__fill_bits(a); + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +{ + char *q; + int cur, limit, old_limit; + z->zout = zout; + if (!z->z_expandable) return stbi__err("output buffer limit", "Corrupt PNG"); + cur = (int)(z->zout - z->zout_start); + limit = old_limit = (int)(z->zout_end - z->zout_start); + while (cur + n > limit) + limit *= 2; + q = (char *)STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); + STBI_NOTUSED(old_limit); + if (q == NULL) return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; +} + +static const int stbi__zlength_base[31] = { + 3,4,5,6,7,8,9,10,11,13, + 15,17,19,23,27,31,35,43,51,59, + 67,83,99,115,131,163,195,227,258,0,0 }; + +static const int stbi__zlength_extra[31] = +{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + +static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, +257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0 }; + +static const int stbi__zdist_extra[32] = +{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13 }; + +static int stbi__parse_huffman_block(stbi__zbuf *a) +{ + char *zout = a->zout; + for (;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) return stbi__err("bad huffman code", "Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) return 0; + zout = a->zout; + } + *zout++ = (char)z; + } + else { + stbi_uc *p; + int len, dist; + if (z == 256) { + a->zout = zout; + return 1; + } + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0) return stbi__err("bad huffman code", "Corrupt PNG"); + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) return stbi__err("bad dist", "Corrupt PNG"); + if (zout + len > a->zout_end) { + if (!stbi__zexpand(a, zout, len)) return 0; + zout = a->zout; + } + p = (stbi_uc *)(zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { do *zout++ = v; while (--len); } + } + else { + if (len) { do *zout++ = *p++; while (--len); } + } + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) +{ + static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286 + 32 + 137];//padding for maximum single op + stbi_uc codelength_sizes[19]; + int i, n; + + int hlit = stbi__zreceive(a, 5) + 257; + int hdist = stbi__zreceive(a, 5) + 1; + int hclen = stbi__zreceive(a, 4) + 4; + int ntot = hlit + hdist; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i = 0; i < hclen; ++i) { + int s = stbi__zreceive(a, 3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc)s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; + + n = 0; + while (n < ntot) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc)c; + else { + stbi_uc fill = 0; + if (c == 16) { + c = stbi__zreceive(a, 2) + 3; + if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); + fill = lencodes[n - 1]; + } + else if (c == 17) + c = stbi__zreceive(a, 3) + 3; + else { + STBI_ASSERT(c == 18); + c = stbi__zreceive(a, 7) + 11; + } + if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); + memset(lencodes + n, fill, c); + n += c; + } + } + if (n != ntot) return stbi__err("bad codelengths", "Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes + hlit, hdist)) return 0; + return 1; +} + +static int stbi__parse_uncompressed_block(stbi__zbuf *a) +{ + stbi_uc header[4]; + int len, nlen, k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = (stbi_uc)(a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + STBI_ASSERT(a->num_bits == 0); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt", "Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer", "Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) +{ + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if ((cmf * 256 + flg) % 31 != 0) return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec + if (flg & 32) return stbi__err("no preset dict", "Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) return stbi__err("bad compression", "Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static const stbi_uc stbi__zdefault_length[288] = +{ + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 +}; +static const stbi_uc stbi__zdefault_distance[32] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 +}; +/* +Init algorithm: +{ +int i; // use <= to match clearly with spec +for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; +for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; +for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; +for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; +for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; +} +*/ + +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) +{ + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) return 0; + a->num_bits = 0; + a->code_buffer = 0; + do { + final = stbi__zreceive(a, 1); + type = stbi__zreceive(a, 2); + if (type == 0) { + if (!stbi__parse_uncompressed_block(a)) return 0; + } + else if (type == 3) { + return 0; + } + else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zbuild_huffman(&a->z_length, stbi__zdefault_length, 288)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; + } + else { + if (!stbi__compute_huffman_codes(a)) return 0; + } + if (!stbi__parse_huffman_block(a)) return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) +{ + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) +{ + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } + else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) +{ + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) +{ + stbi__zbuf a; + char *p = (char *)stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } + else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int)(a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) +{ + stbi__zbuf a; + char *p = (char *)stbi__malloc(16384); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *)buffer; + a.zbuffer_end = (stbi_uc *)buffer + len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) *outlen = (int)(a.zout - a.zout_start); + return a.zout_start; + } + else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *)ibuffer; + a.zbuffer_end = (stbi_uc *)ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int)(a.zout - a.zout_start); + else + return -1; +} +#endif + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + +#ifndef STBI_NO_PNG +typedef struct +{ + stbi__uint32 length; + stbi__uint32 type; +} stbi__pngchunk; + +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) +{ + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; +} + +static int stbi__check_png_header(stbi__context *s) +{ + static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; + int i; + for (i = 0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig", "Not a PNG"); + return 1; +} + +typedef struct +{ + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; +} stbi__png; + + +enum { + STBI__F_none = 0, + STBI__F_sub = 1, + STBI__F_up = 2, + STBI__F_avg = 3, + STBI__F_paeth = 4, + // synthetic filters used for first scanline to avoid needing a dummy row of 0s + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static stbi_uc first_row_filter[5] = +{ + STBI__F_none, + STBI__F_sub, + STBI__F_none, + STBI__F_avg_first, + STBI__F_paeth_first +}; + +static int stbi__paeth(int a, int b, int c) +{ + int p = a + b - c; + int pa = abs(p - a); + int pb = abs(p - b); + int pc = abs(p - c); + if (pa <= pb && pa <= pc) return a; + if (pb <= pc) return b; + return c; +} + +static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; + +// create the png data from post-deflated data +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) +{ + int bytes = (depth == 16 ? 2 : 1); + stbi__context *s = a->s; + stbi__uint32 i, j, stride = x*out_n*bytes; + stbi__uint32 img_len, img_width_bytes; + int k; + int img_n = s->img_n; // copy it into a local for later + + int output_bytes = out_n*bytes; + int filter_bytes = img_n*bytes; + int width = x; + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n + 1); + a->out = (stbi_uc *)stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into + if (!a->out) return stbi__err("outofmem", "Out of memory"); + + if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + img_len = (img_width_bytes + 1) * y; + + // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, + // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), + // so just check for raw_len < img_len always. + if (raw_len < img_len) return stbi__err("not enough pixels", "Corrupt PNG"); + + for (j = 0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *prior; + int filter = *raw++; + + if (filter > 4) + return stbi__err("invalid filter", "Corrupt PNG"); + + if (depth < 8) { + STBI_ASSERT(img_width_bytes <= x); + cur += x*out_n - img_width_bytes; // store output to the rightmost img_len bytes, so we can decode in place + filter_bytes = 1; + width = img_width_bytes; + } + prior = cur - stride; // bugfix: need to compute this after 'cur +=' computation above + + // if first row, use special filter that doesn't sample previous row + if (j == 0) filter = first_row_filter[filter]; + + // handle first byte explicitly + for (k = 0; k < filter_bytes; ++k) { + switch (filter) { + case STBI__F_none: cur[k] = raw[k]; break; + case STBI__F_sub: cur[k] = raw[k]; break; + case STBI__F_up: cur[k] = STBI__BYTECAST(raw[k] + prior[k]); break; + case STBI__F_avg: cur[k] = STBI__BYTECAST(raw[k] + (prior[k] >> 1)); break; + case STBI__F_paeth: cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(0, prior[k], 0)); break; + case STBI__F_avg_first: cur[k] = raw[k]; break; + case STBI__F_paeth_first: cur[k] = raw[k]; break; + } + } + + if (depth == 8) { + if (img_n != out_n) + cur[img_n] = 255; // first pixel + raw += img_n; + cur += out_n; + prior += out_n; + } + else if (depth == 16) { + if (img_n != out_n) { + cur[filter_bytes] = 255; // first pixel top byte + cur[filter_bytes + 1] = 255; // first pixel bottom byte + } + raw += filter_bytes; + cur += output_bytes; + prior += output_bytes; + } + else { + raw += 1; + cur += 1; + prior += 1; + } + + // this is a little gross, so that we don't switch per-pixel or per-component + if (depth < 8 || img_n == out_n) { + int nk = (width - 1)*filter_bytes; +#define STBI__CASE(f) \ + case f: \ + for (k=0; k < nk; ++k) + switch (filter) { + // "none" filter turns into a memcpy here; make that explicit. + case STBI__F_none: memcpy(cur, raw, nk); break; + STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k - filter_bytes]); } break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; + STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k - filter_bytes]) >> 1)); } break; + STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - filter_bytes], prior[k], prior[k - filter_bytes])); } break; + STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k - filter_bytes] >> 1)); } break; + STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - filter_bytes], 0, 0)); } break; + } +#undef STBI__CASE + raw += nk; + } + else { + STBI_ASSERT(img_n + 1 == out_n); +#define STBI__CASE(f) \ + case f: \ + for (i=x-1; i >= 1; --i, cur[filter_bytes]=255,raw+=filter_bytes,cur+=output_bytes,prior+=output_bytes) \ + for (k=0; k < filter_bytes; ++k) + switch (filter) { + STBI__CASE(STBI__F_none) { cur[k] = raw[k]; } break; + STBI__CASE(STBI__F_sub) { cur[k] = STBI__BYTECAST(raw[k] + cur[k - output_bytes]); } break; + STBI__CASE(STBI__F_up) { cur[k] = STBI__BYTECAST(raw[k] + prior[k]); } break; + STBI__CASE(STBI__F_avg) { cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k - output_bytes]) >> 1)); } break; + STBI__CASE(STBI__F_paeth) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - output_bytes], prior[k], prior[k - output_bytes])); } break; + STBI__CASE(STBI__F_avg_first) { cur[k] = STBI__BYTECAST(raw[k] + (cur[k - output_bytes] >> 1)); } break; + STBI__CASE(STBI__F_paeth_first) { cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k - output_bytes], 0, 0)); } break; + } +#undef STBI__CASE + + // the loop above sets the high byte of the pixels' alpha, but for + // 16 bit png files we also need the low byte set. we'll do that here. + if (depth == 16) { + cur = a->out + stride*j; // start at the beginning of the row again + for (i = 0; i < x; ++i, cur += output_bytes) { + cur[filter_bytes + 1] = 255; + } + } + } + } + + // we make a separate pass to expand bits to pixels; for performance, + // this could run two scanlines behind the above code, so it won't + // intefere with filtering but will still be in the cache. + if (depth < 8) { + for (j = 0; j < y; ++j) { + stbi_uc *cur = a->out + stride*j; + stbi_uc *in = a->out + stride*j + x*out_n - img_width_bytes; + // unpack 1/2/4-bit into a 8-bit buffer. allows us to keep the common 8-bit path optimal at minimal cost for 1/2/4-bit + // png guarante byte alignment, if width is not multiple of 8/4/2 we'll decode dummy trailing data that will be skipped in the later loop + stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range + + // note that the final byte might overshoot and write more data than desired. + // we can allocate enough data that this never writes out of memory, but it + // could also overwrite the next scanline. can it overwrite non-empty data + // on the next scanline? yes, consider 1-pixel-wide scanlines with 1-bit-per-pixel. + // so we need to explicitly clamp the final ones + + if (depth == 4) { + for (k = x*img_n; k >= 2; k -= 2, ++in) { + *cur++ = scale * ((*in >> 4)); + *cur++ = scale * ((*in) & 0x0f); + } + if (k > 0) *cur++ = scale * ((*in >> 4)); + } + else if (depth == 2) { + for (k = x*img_n; k >= 4; k -= 4, ++in) { + *cur++ = scale * ((*in >> 6)); + *cur++ = scale * ((*in >> 4) & 0x03); + *cur++ = scale * ((*in >> 2) & 0x03); + *cur++ = scale * ((*in) & 0x03); + } + if (k > 0) *cur++ = scale * ((*in >> 6)); + if (k > 1) *cur++ = scale * ((*in >> 4) & 0x03); + if (k > 2) *cur++ = scale * ((*in >> 2) & 0x03); + } + else if (depth == 1) { + for (k = x*img_n; k >= 8; k -= 8, ++in) { + *cur++ = scale * ((*in >> 7)); + *cur++ = scale * ((*in >> 6) & 0x01); + *cur++ = scale * ((*in >> 5) & 0x01); + *cur++ = scale * ((*in >> 4) & 0x01); + *cur++ = scale * ((*in >> 3) & 0x01); + *cur++ = scale * ((*in >> 2) & 0x01); + *cur++ = scale * ((*in >> 1) & 0x01); + *cur++ = scale * ((*in) & 0x01); + } + if (k > 0) *cur++ = scale * ((*in >> 7)); + if (k > 1) *cur++ = scale * ((*in >> 6) & 0x01); + if (k > 2) *cur++ = scale * ((*in >> 5) & 0x01); + if (k > 3) *cur++ = scale * ((*in >> 4) & 0x01); + if (k > 4) *cur++ = scale * ((*in >> 3) & 0x01); + if (k > 5) *cur++ = scale * ((*in >> 2) & 0x01); + if (k > 6) *cur++ = scale * ((*in >> 1) & 0x01); + } + if (img_n != out_n) { + int q; + // insert alpha = 255 + cur = a->out + stride*j; + if (img_n == 1) { + for (q = x - 1; q >= 0; --q) { + cur[q * 2 + 1] = 255; + cur[q * 2 + 0] = cur[q]; + } + } + else { + STBI_ASSERT(img_n == 3); + for (q = x - 1; q >= 0; --q) { + cur[q * 4 + 3] = 255; + cur[q * 4 + 2] = cur[q * 3 + 2]; + cur[q * 4 + 1] = cur[q * 3 + 1]; + cur[q * 4 + 0] = cur[q * 3 + 0]; + } + } + } + } + } + else if (depth == 16) { + // force the image data from big-endian to platform-native. + // this is done in a separate pass due to the decoding relying + // on the data being untouched, but could probably be done + // per-line during decode if care is taken. + stbi_uc *cur = a->out; + stbi__uint16 *cur16 = (stbi__uint16*)cur; + + for (i = 0; i < x*y*out_n; ++i, cur16++, cur += 2) { + *cur16 = (cur[0] << 8) | cur[1]; + } + } + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) +{ + int bytes = (depth == 16 ? 2 : 1); + int out_bytes = out_n * bytes; + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *)stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); + for (p = 0; p < 7; ++p) { + int xorig[] = { 0,4,0,2,0,1,0 }; + int yorig[] = { 0,0,4,0,2,0,1 }; + int xspc[] = { 8,8,4,4,2,2,1 }; + int yspc[] = { 8,8,8,4,4,2,2 }; + int i, j, x, y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p] - 1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p] - 1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { + STBI_FREE(final); + return 0; + } + for (j = 0; j < y; ++j) { + for (i = 0; i < x; ++i) { + int out_y = j*yspc[p] + yorig[p]; + int out_x = i*xspc[p] + xorig[p]; + memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, + a->out + (j*x + i)*out_bytes, out_bytes); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; + + return 1; +} + +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } + else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi__uint16 *p = (stbi__uint16*)z->out; + + // compute color-based transparency, assuming we've + // already got 65535 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 65535); + p += 2; + } + } + else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) +{ + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *)stbi__malloc_mad2(pixel_count, pal_img_n, 0); + if (p == NULL) return stbi__err("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p += 3; + } + } + else { + for (i = 0; i < pixel_count; ++i) { + int n = orig[i] * 4; + p[0] = palette[n]; + p[1] = palette[n + 1]; + p[2] = palette[n + 2]; + p[3] = palette[n + 3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; + + STBI_NOTUSED(len); + + return 1; +} + +static int stbi__unpremultiply_on_load = 0; +static int stbi__de_iphone_flag = 0; + +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) +{ + stbi__unpremultiply_on_load = flag_true_if_should_unpremultiply; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) +{ + stbi__de_iphone_flag = flag_true_if_should_convert; +} + +static void stbi__de_iphone(stbi__png *z) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } + else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i = 0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + stbi_uc half = a / 2; + p[0] = (p[2] * 255 + half) / a; + p[1] = (p[1] * 255 + half) / a; + p[2] = (t * 255 + half) / a; + } + else { + p[0] = p[2]; + p[2] = t; + } + p += 4; + } + } + else { + // convert bgr to rgb + for (i = 0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp) +{ + stbi_uc palette[1024], pal_img_n = 0; + stbi_uc has_trans = 0, tc[3]; + stbi__uint16 tc16[3]; + stbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0; + int first = 1, k, interlace = 0, color = 0, is_iphone = 0; + stbi__context *s = z->s; + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) return 0; + + if (scan == STBI__SCAN_type) return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C', 'g', 'B', 'I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I', 'H', 'D', 'R'): { + int comp, filter; + if (!first) return stbi__err("multiple IHDR", "Corrupt PNG"); + first = 0; + if (c.length != 13) return stbi__err("bad IHDR len", "Corrupt PNG"); + s->img_x = stbi__get32be(s); if (s->img_x > (1 << 24)) return stbi__err("too large", "Very large image (corrupt?)"); + s->img_y = stbi__get32be(s); if (s->img_y > (1 << 24)) return stbi__err("too large", "Very large image (corrupt?)"); + z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only", "PNG not supported: 1/2/4/8/16-bit only"); + color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3 && z->depth == 16) return stbi__err("bad ctype", "Corrupt PNG"); + if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype", "Corrupt PNG"); + comp = stbi__get8(s); if (comp) return stbi__err("bad comp method", "Corrupt PNG"); + filter = stbi__get8(s); if (filter) return stbi__err("bad filter method", "Corrupt PNG"); + interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method", "Corrupt PNG"); + if (!s->img_x || !s->img_y) return stbi__err("0-pixel image", "Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + if (scan == STBI__SCAN_header) return 1; + } + else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large", "Corrupt PNG"); + // if SCAN_header, have to scan to see if we have a tRNS + } + break; + } + + case STBI__PNG_TYPE('P', 'L', 'T', 'E'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256 * 3) return stbi__err("invalid PLTE", "Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) return stbi__err("invalid PLTE", "Corrupt PNG"); + for (i = 0; i < pal_len; ++i) { + palette[i * 4 + 0] = stbi__get8(s); + palette[i * 4 + 1] = stbi__get8(s); + palette[i * 4 + 2] = stbi__get8(s); + palette[i * 4 + 3] = 255; + } + break; + } + + case STBI__PNG_TYPE('t', 'R', 'N', 'S'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) return stbi__err("tRNS after IDAT", "Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } + if (pal_len == 0) return stbi__err("tRNS before PLTE", "Corrupt PNG"); + if (c.length > pal_len) return stbi__err("bad tRNS len", "Corrupt PNG"); + pal_img_n = 4; + for (i = 0; i < c.length; ++i) + palette[i * 4 + 3] = stbi__get8(s); + } + else { + if (!(s->img_n & 1)) return stbi__err("tRNS with alpha", "Corrupt PNG"); + if (c.length != (stbi__uint32)s->img_n * 2) return stbi__err("bad tRNS len", "Corrupt PNG"); + has_trans = 1; + if (z->depth == 16) { + for (k = 0; k < s->img_n; ++k) tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is + } + else { + for (k = 0; k < s->img_n; ++k) tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger + } + } + break; + } + + case STBI__PNG_TYPE('I', 'D', 'A', 'T'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) return stbi__err("no PLTE", "Corrupt PNG"); + if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; } + if ((int)(ioff + c.length) < (int)ioff) return 0; + if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; + stbi_uc *p; + if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + STBI_NOTUSED(idata_limit_old); + p = (stbi_uc *)STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata + ioff, c.length)) return stbi__err("outofdata", "Corrupt PNG"); + ioff += c.length; + break; + } + + case STBI__PNG_TYPE('I', 'E', 'N', 'D'): { + stbi__uint32 raw_len, bpl; + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) return 1; + if (z->idata == NULL) return stbi__err("no IDAT", "Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *)stbi_zlib_decode_malloc_guesssize_headerflag((char *)z->idata, ioff, raw_len, (int *)&raw_len, !is_iphone); + if (z->expanded == NULL) return 0; // zlib should set error + STBI_FREE(z->idata); z->idata = NULL; + if ((req_comp == s->img_n + 1 && req_comp != 3 && !pal_img_n) || has_trans) + s->img_out_n = s->img_n + 1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; + if (has_trans) { + if (z->depth == 16) { + if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; + } + else { + if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; + } + } + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) s->img_out_n = req_comp; + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } + else if (has_trans) { + // non-paletted image with tRNS -> source image has (constant) alpha + ++s->img_n; + } + STBI_FREE(z->expanded); z->expanded = NULL; + return 1; + } + + default: + // if critical, fail + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { +#ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); +#endif + return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, stbi__result_info *ri) +{ + void *result = NULL; + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp)) { + if (p->depth < 8) + ri->bits_per_channel = 8; + else + ri->bits_per_channel = p->depth; + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + if (ri->bits_per_channel == 8) + result = stbi__convert_format((unsigned char *)result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + else + result = stbi__convert_format16((stbi__uint16 *)result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) *n = p->s->img_n; + } + STBI_FREE(p->out); p->out = NULL; + STBI_FREE(p->expanded); p->expanded = NULL; + STBI_FREE(p->idata); p->idata = NULL; + + return result; +} + +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi__png p; + p.s = s; + return stbi__do_png(&p, x, y, comp, req_comp, ri); +} + +static int stbi__png_test(stbi__context *s) +{ + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) +{ + if (!stbi__parse_png_file(p, STBI__SCAN_header, 0)) { + stbi__rewind(p->s); + return 0; + } + if (x) *x = p->s->img_x; + if (y) *y = p->s->img_y; + if (comp) *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} + +static int stbi__png_is16(stbi__context *s) +{ + stbi__png p; + p.s = s; + if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); + return 0; + } + return 1; +} +#endif + +// Microsoft/Windows BMP image + +#ifndef STBI_NO_BMP +static int stbi__bmp_test_raw(stbi__context *s) +{ + int r; + int sz; + if (stbi__get8(s) != 'B') return 0; + if (stbi__get8(s) != 'M') return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) +{ + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; +} + + +// returns 0..31 for the highest set bit +static int stbi__high_bit(unsigned int z) +{ + int n = 0; + if (z == 0) return -1; + if (z >= 0x10000) n += 16, z >>= 16; + if (z >= 0x00100) n += 8, z >>= 8; + if (z >= 0x00010) n += 4, z >>= 4; + if (z >= 0x00004) n += 2, z >>= 2; + if (z >= 0x00002) n += 1, z >>= 1; + return n; +} + +static int stbi__bitcount(unsigned int a) +{ + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +// extract an arbitrarily-aligned N-bit value (N=bits) +// from v, and then make it 8-bits long and fractionally +// extend it to full full range. +static int stbi__shiftsigned(int v, int shift, int bits) +{ + static unsigned int mul_table[9] = { + 0, + 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, + 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, + }; + static unsigned int shift_table[9] = { + 0, 0,0,1,0,2,4,6,0, + }; + if (shift < 0) + v <<= -shift; + else + v >>= shift; + STBI_ASSERT(v >= 0 && v < 256); + v >>= (8 - bits); + STBI_ASSERT(bits >= 0 && bits <= 8); + return (int)((unsigned)v * mul_table[bits]) >> shift_table[bits]; +} + +typedef struct +{ + int bpp, offset, hsz; + unsigned int mr, mg, mb, ma, all_a; +} stbi__bmp_data; + +static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) +{ + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + info->offset = stbi__get32le(s); + info->hsz = hsz = stbi__get32le(s); + info->mr = info->mg = info->mb = info->ma = 0; + + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } + else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); + info->bpp = stbi__get16le(s); + if (hsz != 12) { + int compress = stbi__get32le(s); + if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (info->bpp == 16 || info->bpp == 32) { + if (compress == 0) { + if (info->bpp == 32) { + info->mr = 0xffu << 16; + info->mg = 0xffu << 8; + info->mb = 0xffu << 0; + info->ma = 0xffu << 24; + info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 + } + else { + info->mr = 31u << 10; + info->mg = 31u << 5; + info->mb = 31u << 0; + } + } + else if (compress == 3) { + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + // not documented, but generated by photoshop and handled by mspaint + if (info->mr == info->mg && info->mg == info->mb) { + // ?!?!? + return stbi__errpuc("bad BMP", "bad BMP"); + } + } + else + return stbi__errpuc("bad BMP", "bad BMP"); + } + } + else { + int i; + if (hsz != 108 && hsz != 124) + return stbi__errpuc("bad BMP", "bad BMP"); + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->ma = stbi__get32le(s); + stbi__get32le(s); // discard color space + for (i = 0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved + } + } + } + return (void *)1; +} + + +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + unsigned int mr = 0, mg = 0, mb = 0, ma = 0, all_a; + stbi_uc pal[256][4]; + int psize = 0, i, j, width; + int flip_vertically, pad, target; + stbi__bmp_data info; + STBI_NOTUSED(ri); + + info.all_a = 255; + if (stbi__bmp_parse_header(s, &info) == NULL) + return NULL; // error code already set + + flip_vertically = ((int)s->img_y) > 0; + s->img_y = abs((int)s->img_y); + + mr = info.mr; + mg = info.mg; + mb = info.mb; + ma = info.ma; + all_a = info.all_a; + + if (info.hsz == 12) { + if (info.bpp < 24) + psize = (info.offset - 14 - 24) / 3; + } + else { + if (info.bpp < 16) + psize = (info.offset - 14 - info.hsz) >> 2; + } + + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + + // sanity-check size + if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "Corrupt BMP"); + + out = (stbi_uc *)stbi__malloc_mad3(target, s->img_x, s->img_y, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + if (info.bpp < 16) { + int z = 0; + if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } + for (i = 0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (info.hsz != 12) stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, info.offset - 14 - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); + if (info.bpp == 1) width = (s->img_x + 7) >> 3; + else if (info.bpp == 4) width = (s->img_x + 1) >> 1; + else if (info.bpp == 8) width = s->img_x; + else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } + pad = (-width) & 3; + if (info.bpp == 1) { + for (j = 0; j < (int)s->img_y; ++j) { + int bit_offset = 7, v = stbi__get8(s); + for (i = 0; i < (int)s->img_x; ++i) { + int color = (v >> bit_offset) & 0x1; + out[z++] = pal[color][0]; + out[z++] = pal[color][1]; + out[z++] = pal[color][2]; + if ((--bit_offset) < 0) { + bit_offset = 7; + v = stbi__get8(s); + } + } + stbi__skip(s, pad); + } + } + else { + for (j = 0; j < (int)s->img_y; ++j) { + for (i = 0; i < (int)s->img_x; i += 2) { + int v = stbi__get8(s), v2 = 0; + if (info.bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + if (i + 1 == (int)s->img_x) break; + v = (info.bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + } + stbi__skip(s, pad); + } + } + } + else { + int rshift = 0, gshift = 0, bshift = 0, ashift = 0, rcount = 0, gcount = 0, bcount = 0, acount = 0; + int z = 0; + int easy = 0; + stbi__skip(s, info.offset - 14 - info.hsz); + if (info.bpp == 24) width = 3 * s->img_x; + else if (info.bpp == 16) width = 2 * s->img_x; + else /* bpp = 32 and pad = 0 */ width = 0; + pad = (-width) & 3; + if (info.bpp == 24) { + easy = 1; + } + else if (info.bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr) - 7; rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg) - 7; gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb) - 7; bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma) - 7; acount = stbi__bitcount(ma); + } + for (j = 0; j < (int)s->img_y; ++j) { + if (easy) { + for (i = 0; i < (int)s->img_x; ++i) { + unsigned char a; + out[z + 2] = stbi__get8(s); + out[z + 1] = stbi__get8(s); + out[z + 0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) out[z++] = a; + } + } + else { + int bpp = info.bpp; + for (i = 0; i < (int)s->img_x; ++i) { + stbi__uint32 v = (bpp == 16 ? (stbi__uint32)stbi__get16le(s) : stbi__get32le(s)); + unsigned int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) out[z++] = STBI__BYTECAST(a); + } + } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i = 4 * s->img_x*s->img_y - 1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j = 0; j < (int)s->img_y >> 1; ++j) { + stbi_uc *p1 = out + j *s->img_x*target; + stbi_uc *p2 = out + (s->img_y - 1 - j)*s->img_x*target; + for (i = 0; i < (int)s->img_x*target; ++i) { + t = p1[i], p1[i] = p2[i], p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + return out; +} +#endif + +// Targa Truevision - TGA +// by Jonathan Dummer +#ifndef STBI_NO_TGA +// returns STBI_rgb or whatever, 0 on error +static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) +{ + // only RGB or RGBA (incl. 16bit) or grey allowed + if (is_rgb16) *is_rgb16 = 0; + switch (bits_per_pixel) { + case 8: return STBI_grey; + case 16: if (is_grey) return STBI_grey_alpha; + // fallthrough + case 15: if (is_rgb16) *is_rgb16 = 1; + return STBI_rgb; + case 24: // fallthrough + case 32: return bits_per_pixel / 8; + default: return 0; + } +} + +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) +{ + int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; + int sz, tga_colormap_type; + stbi__get8(s); // discard Offset + tga_colormap_type = stbi__get8(s); // colormap type + if (tga_colormap_type > 1) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + tga_image_type = stbi__get8(s); // image type + if (tga_colormap_type == 1) { // colormapped (paletted) image + if (tga_image_type != 1 && tga_image_type != 9) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 4); // skip image x and y origin + tga_colormap_bpp = sz; + } + else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE + if ((tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11)) { + stbi__rewind(s); + return 0; // only RGB or grey allowed, +/- RLE + } + stbi__skip(s, 9); // skip colormap specification and image x/y origin + tga_colormap_bpp = 0; + } + tga_w = stbi__get16le(s); + if (tga_w < 1) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if (tga_h < 1) { + stbi__rewind(s); + return 0; // test height + } + tga_bits_per_pixel = stbi__get8(s); // bits per pixel + stbi__get8(s); // ignore alpha bits + if (tga_colormap_bpp != 0) { + if ((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { + // when using a colormap, tga_bits_per_pixel is the size of the indexes + // I don't think anything but 8 or 16bit indexes makes sense + stbi__rewind(s); + return 0; + } + tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); + } + else { + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); + } + if (!tga_comp) { + stbi__rewind(s); + return 0; + } + if (x) *x = tga_w; + if (y) *y = tga_h; + if (comp) *comp = tga_comp; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) +{ + int res = 0; + int sz, tga_color_type; + stbi__get8(s); // discard Offset + tga_color_type = stbi__get8(s); // color type + if (tga_color_type > 1) goto errorEnd; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if (tga_color_type == 1) { // colormapped (paletted) image + if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 + stbi__skip(s, 4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) goto errorEnd; + stbi__skip(s, 4); // skip image x and y origin + } + else { // "normal" image w/o colormap + if ((sz != 2) && (sz != 3) && (sz != 10) && (sz != 11)) goto errorEnd; // only RGB or grey allowed, +/- RLE + stbi__skip(s, 9); // skip colormap specification and image x/y origin + } + if (stbi__get16le(s) < 1) goto errorEnd; // test width + if (stbi__get16le(s) < 1) goto errorEnd; // test height + sz = stbi__get8(s); // bits per pixel + if ((tga_color_type == 1) && (sz != 8) && (sz != 16)) goto errorEnd; // for colormapped images, bpp is size of an index + if ((sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32)) goto errorEnd; + + res = 1; // if we got this far, everything's good and we can return 1 instead of 0 + +errorEnd: + stbi__rewind(s); + return res; +} + +// read 16bit value and convert to 24bit RGB +static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) +{ + stbi__uint16 px = (stbi__uint16)stbi__get16le(s); + stbi__uint16 fiveBitMask = 31; + // we have 3 channels with 5bits each + int r = (px >> 10) & fiveBitMask; + int g = (px >> 5) & fiveBitMask; + int b = px & fiveBitMask; + // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later + out[0] = (stbi_uc)((r * 255) / 31); + out[1] = (stbi_uc)((g * 255) / 31); + out[2] = (stbi_uc)((b * 255) / 31); + + // some people claim that the most significant bit might be used for alpha + // (possibly if an alpha-bit is set in the "image descriptor byte") + // but that only made 16bit test images completely translucent.. + // so let's treat all 15 and 16bit TGAs as RGB with no alpha. +} + +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp, tga_rgb16 = 0; + int tga_inverted = stbi__get8(s); + // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = { 0 }; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + STBI_NOTUSED(ri); + + // do a tiny bit of precessing + if (tga_image_type >= 8) + { + tga_image_type -= 8; + tga_is_RLE = 1; + } + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // If I'm paletted, then I'll use the number of bits from the palette + if (tga_indexed) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); + else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); + + if (!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency + return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) *comp = tga_comp; + + if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) + return stbi__errpuc("too large", "Corrupt TGA"); + + tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); + if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset); + + if (!tga_indexed && !tga_is_RLE && !tga_rgb16) { + for (i = 0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height - i - 1 : i; + stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } + else { + // do I need to load a palette? + if (tga_indexed) + { + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start); + // load the palette + tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); + } + if (tga_rgb16) { + stbi_uc *pal_entry = tga_palette; + STBI_ASSERT(tga_comp == STBI_rgb); + for (i = 0; i < tga_palette_len; ++i) { + stbi__tga_read_rgb16(s, pal_entry); + pal_entry += tga_comp; + } + } + else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { + STBI_FREE(tga_data); + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + } + // load the data + for (i = 0; i < tga_width * tga_height; ++i) + { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if (tga_is_RLE) + { + if (RLE_count == 0) + { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } + else if (!RLE_repeating) + { + read_next_pixel = 1; + } + } + else + { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if (read_next_pixel) + { + // load however much data we did have + if (tga_indexed) + { + // read in index, then perform the lookup + int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); + if (pal_idx >= tga_palette_len) { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_comp; + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = tga_palette[pal_idx + j]; + } + } + else if (tga_rgb16) { + STBI_ASSERT(tga_comp == STBI_rgb); + stbi__tga_read_rgb16(s, raw_data); + } + else { + // read in the data raw + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i*tga_comp + j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if (tga_inverted) + { + for (j = 0; j * 2 < tga_height; ++j) + { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if (tga_palette != NULL) + { + STBI_FREE(tga_palette); + } + } + + // swap RGB - if the source data was RGB16, it already is in the right order + if (tga_comp >= 3 && !tga_rgb16) + { + unsigned char* tga_pixel = tga_data; + for (i = 0; i < tga_width * tga_height; ++i) + { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + // OK, done + return tga_data; +} +#endif + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s) +{ + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) +{ + int count, nleft, len; + + count = 0; + while ((nleft = pixelCount - count) > 0) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } + else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + if (len > nleft) return 0; // corrupt data + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; + } + } + else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len = 257 - len; + if (len > nleft) return 0; // corrupt data + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + + return 1; +} + +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +{ + int pixelCount; + int channelCount, compression; + int channel, i; + int bitdepth; + int w, h; + stbi_uc *out; + STBI_NOTUSED(ri); + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + stbi__skip(s, stbi__get32be(s)); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s)); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s)); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", "PSD has an unknown compression format"); + + // Check size + if (!stbi__mad3sizes_valid(4, w, h, 0)) + return stbi__errpuc("too large", "Corrupt PSD"); + + // Create the destination image. + + if (!compression && bitdepth == 16 && bpc == 16) { + out = (stbi_uc *)stbi__malloc_mad3(8, w, h, 0); + ri->bits_per_channel = 16; + } + else + out = (stbi_uc *)stbi__malloc(4 * w*h); + + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w*h; + + // Initialize the data to zero. + //memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceeded by a 2-byte data count for each row in the data, + // which we're going to just skip. + stbi__skip(s, h * channelCount * 2); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out + channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } + else { + // Read the RLE data. + if (!stbi__psd_decode_rle(s, p, pixelCount)) { + STBI_FREE(out); + return stbi__errpuc("corrupt", "bad RLE data"); + } + } + } + + } + else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + if (channel >= channelCount) { + // Fill this channel with default data. + if (bitdepth == 16 && bpc == 16) { + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + stbi__uint16 val = channel == 3 ? 65535 : 0; + for (i = 0; i < pixelCount; i++, q += 4) + *q = val; + } + else { + stbi_uc *p = out + channel; + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } + } + else { + if (ri->bits_per_channel == 16) { // output bpc + stbi__uint16 *q = ((stbi__uint16 *)out) + channel; + for (i = 0; i < pixelCount; i++, q += 4) + *q = (stbi__uint16)stbi__get16be(s); + } + else { + stbi_uc *p = out + channel; + if (bitdepth == 16) { // input bpc + for (i = 0; i < pixelCount; i++, p += 4) + *p = (stbi_uc)(stbi__get16be(s) >> 8); + } + else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } + } + } + } + + // remove weird white matte from PSD + if (channelCount >= 4) { + if (ri->bits_per_channel == 16) { + for (i = 0; i < w*h; ++i) { + stbi__uint16 *pixel = (stbi__uint16 *)out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 65535) { + float a = pixel[3] / 65535.0f; + float ra = 1.0f / a; + float inv_a = 65535.0f * (1 - ra); + pixel[0] = (stbi__uint16)(pixel[0] * ra + inv_a); + pixel[1] = (stbi__uint16)(pixel[1] * ra + inv_a); + pixel[2] = (stbi__uint16)(pixel[2] * ra + inv_a); + } + } + } + else { + for (i = 0; i < w*h; ++i) { + unsigned char *pixel = out + 4 * i; + if (pixel[3] != 0 && pixel[3] != 255) { + float a = pixel[3] / 255.0f; + float ra = 1.0f / a; + float inv_a = 255.0f * (1 - ra); + pixel[0] = (unsigned char)(pixel[0] * ra + inv_a); + pixel[1] = (unsigned char)(pixel[1] * ra + inv_a); + pixel[2] = (unsigned char)(pixel[2] * ra + inv_a); + } + } + } + } + + // convert to desired output format + if (req_comp && req_comp != 4) { + if (ri->bits_per_channel == 16) + out = (stbi_uc *)stbi__convert_format16((stbi__uint16 *)out, 4, req_comp, w, h); + else + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + if (comp) *comp = 4; + *y = h; + *x = w; + + return out; +} +#endif + +// ************************************************************************************************* +// Softimage PIC loader +// by Tom Seddon +// +// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format +// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ + +#ifndef STBI_NO_PIC +static int stbi__pic_is4(stbi__context *s, const char *str) +{ + int i; + for (i = 0; i<4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; + + return 1; +} + +static int stbi__pic_test_core(stbi__context *s) +{ + int i; + + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) + return 0; + + for (i = 0; i<84; ++i) + stbi__get8(s); + + if (!stbi__pic_is4(s, "PICT")) + return 0; + + return 1; +} + +typedef struct +{ + stbi_uc size, type, channel; +} stbi__pic_packet; + +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) +{ + int mask = 0x80, i; + + for (i = 0; i<4; ++i, mask >>= 1) { + if (channel & mask) { + if (stbi__at_eof(s)) return stbi__errpuc("bad file", "PIC file too short"); + dest[i] = stbi__get8(s); + } + } + + return dest; +} + +static void stbi__copyval(int channel, stbi_uc *dest, const stbi_uc *src) +{ + int mask = 0x80, i; + + for (i = 0; i<4; ++i, mask >>= 1) + if (channel&mask) + dest[i] = src[i]; +} + +static stbi_uc *stbi__pic_load_core(stbi__context *s, int width, int height, int *comp, stbi_uc *result) +{ + int act_comp = 0, num_packets = 0, y, chained; + stbi__pic_packet packets[10]; + + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; + + if (num_packets == sizeof(packets) / sizeof(packets[0])) + return stbi__errpuc("bad format", "too many packets"); + + packet = &packets[num_packets++]; + + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + + act_comp |= packet->channel; + + if (stbi__at_eof(s)) return stbi__errpuc("bad file", "file too short (reading packets)"); + if (packet->size != 8) return stbi__errpuc("bad format", "packet isn't 8bpp"); + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + + for (y = 0; ytype) { + default: + return stbi__errpuc("bad format", "packet has bad compression type"); + + case 0: {//uncompressed + int x; + + for (x = 0; xchannel, dest)) + return 0; + break; + } + + case 1://Pure RLE + { + int left = width, i; + + while (left>0) { + stbi_uc count, value[4]; + + count = stbi__get8(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file", "file too short (pure read count)"); + + if (count > left) + count = (stbi_uc)left; + + if (!stbi__readval(s, packet->channel, value)) return 0; + + for (i = 0; ichannel, dest, value); + left -= count; + } + } + break; + + case 2: {//Mixed RLE + int left = width; + while (left>0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) return stbi__errpuc("bad file", "file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count == 128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file", "scanline overrun"); + + if (!stbi__readval(s, packet->channel, value)) + return 0; + + for (i = 0; ichannel, dest, value); + } + else { // Raw + ++count; + if (count>left) return stbi__errpuc("bad file", "scanline overrun"); + + for (i = 0; ichannel, dest)) + return 0; + } + left -= count; + } + break; + } + } + } + } + + return result; +} + +static void *stbi__pic_load(stbi__context *s, int *px, int *py, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *result; + int i, x, y, internal_comp; + STBI_NOTUSED(ri); + + if (!comp) comp = &internal_comp; + + for (i = 0; i<92; ++i) + stbi__get8(s); + + x = stbi__get16be(s); + y = stbi__get16be(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file", "file too short (pic header)"); + if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); + + stbi__get32be(s); //skip `ratio' + stbi__get16be(s); //skip `fields' + stbi__get16be(s); //skip `pad' + + // intermediate buffer is RGBA + result = (stbi_uc *)stbi__malloc_mad3(x, y, 4, 0); + memset(result, 0xff, x*y * 4); + + if (!stbi__pic_load_core(s, x, y, comp, result)) { + STBI_FREE(result); + result = 0; + } + *px = x; + *py = y; + if (req_comp == 0) req_comp = *comp; + result = stbi__convert_format(result, 4, req_comp, x, y); + + return result; +} + +static int stbi__pic_test(stbi__context *s) +{ + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; +} +#endif + +// ************************************************************************************************* +// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb + +#ifndef STBI_NO_GIF +typedef struct +{ + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; +} stbi__gif_lzw; + +typedef struct +{ + int w, h; + stbi_uc *out; // output buffer (always 4 components) + stbi_uc *background; // The current "background" as far as a gif is concerned + stbi_uc *history; + int flags, bgindex, ratio, transparent, eflags; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[8192]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; + int delay; +} stbi__gif; + +static int stbi__gif_test_raw(stbi__context *s) +{ + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') return 0; + if (stbi__get8(s) != 'a') return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) +{ + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) +{ + int i; + for (i = 0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) +{ + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + + if (is_info) return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s, g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__gif* g = (stbi__gif*)stbi__malloc(sizeof(stbi__gif)); + if (!stbi__gif_header(s, g, comp, 1)) { + STBI_FREE(g); + stbi__rewind(s); + return 0; + } + if (x) *x = g->w; + if (y) *y = g->h; + STBI_FREE(g); + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) +{ + stbi_uc *p, *c; + int idx; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) return; + + idx = g->cur_x + g->cur_y; + p = &g->out[idx]; + g->history[idx / 4] = 1; + + c = &g->color_table[g->codes[code].suffix * 4]; + if (c[3] > 128) { // don't render transparent pixels; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) +{ + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc)init_code; + g->codes[init_code].suffix = (stbi_uc)init_code; + } + + // support no starting clear code + avail = clear + 2; + oldcode = -1; + + len = 0; + for (;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32)stbi__get8(s) << valid_bits; + valid_bits += 8; + } + else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } + else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s, len); + return g->out; + } + else if (code <= avail) { + if (first) { + return stbi__errpuc("no clear code", "Corrupt GIF"); + } + + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 8192) { + return stbi__errpuc("too many codes", "Corrupt GIF"); + } + + p->prefix = (stbi__int16)oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } + else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + + stbi__out_gif_code(g, (stbi__uint16)code); + + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } + + oldcode = code; + } + else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +// this function is designed to support animated gifs, although stb_image doesn't support it +// two back is the image from two frames ago, used for a very specific disposal format +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) +{ + int dispose; + int first_frame; + int pi; + int pcount; + + // on first frame, any non-written pixels get the background colour (non-transparent) + first_frame = 0; + if (g->out == 0) { + if (!stbi__gif_header(s, g, comp, 0)) return 0; // stbi__g_failure_reason set by stbi__gif_header + g->out = (stbi_uc *)stbi__malloc(4 * g->w * g->h); + g->background = (stbi_uc *)stbi__malloc(4 * g->w * g->h); + g->history = (stbi_uc *)stbi__malloc(g->w * g->h); + if (g->out == 0) return stbi__errpuc("outofmem", "Out of memory"); + + // image is treated as "tranparent" at the start - ie, nothing overwrites the current background; + // background colour is only used for pixels that are not rendered first frame, after that "background" + // color refers to teh color that was there the previous frame. + memset(g->out, 0x00, 4 * g->w * g->h); + memset(g->background, 0x00, 4 * g->w * g->h); // state of the background (starts transparent) + memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame + first_frame = 1; + } + else { + // second frame - how do we dispoase of the previous one? + dispose = (g->eflags & 0x1C) >> 2; + pcount = g->w * g->h; + + if ((dispose == 3) && (two_back == 0)) { + dispose = 2; // if I don't have an image to revert back to, default to the old background + } + + if (dispose == 3) { // use previous graphic + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &two_back[pi * 4], 4); + } + } + } + else if (dispose == 2) { + // restore what was changed last frame to background before that frame; + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy(&g->out[pi * 4], &g->background[pi * 4], 4); + } + } + } + else { + // This is a non-disposal case eithe way, so just + // leave the pixels as is, and they will become the new background + // 1: do not dispose + // 0: not specified. + } + + // background is what out is after the undoing of the previou frame; + memcpy(g->background, g->out, 4 * g->w * g->h); + } + + // clear my history; + memset(g->history, 0x00, g->w * g->h); // pixels that were affected previous frame + + for (;;) { + int tag = stbi__get8(s); + switch (tag) { + case 0x2C: /* Image Descriptor */ + { + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; + + g->lflags = stbi__get8(s); + + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } + else { + g->step = g->line_size; + g->parse = 0; + } + + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s, g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *)g->lpal; + } + else if (g->flags & 0x80) { + g->color_table = (stbi_uc *)g->pal; + } + else + return stbi__errpuc("missing color table", "Corrupt GIF"); + + o = stbi__process_gif_raster(s, g); + if (o == NULL) return NULL; + + // if this was the first frame, + pcount = g->w * g->h; + if (first_frame && (g->bgindex > 0)) { + // if first frame, any pixel not drawn to gets the background color + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi] == 0) { + g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; + memcpy(&g->out[pi * 4], &g->pal[g->bgindex], 4); + } + } + } + + return o; + } + + case 0x21: // Comment Extension. + { + int len; + int ext = stbi__get8(s); + if (ext == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. + + // unset old transparent + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 255; + } + if (g->eflags & 0x01) { + g->transparent = stbi__get8(s); + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 0; + } + } + else { + // don't need transparent + stbi__skip(s, 1); + g->transparent = -1; + } + } + else { + stbi__skip(s, len); + break; + } + } + while ((len = stbi__get8(s)) != 0) { + stbi__skip(s, len); + } + break; + } + + case 0x3B: // gif stream termination code + return (stbi_uc *)s; // using '1' causes warning on some compilers + + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } +} + +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + if (stbi__gif_test(s)) { + int layers = 0; + stbi_uc *u = 0; + stbi_uc *out = 0; + stbi_uc *two_back = 0; + stbi__gif g; + int stride; + memset(&g, 0, sizeof(g)); + if (delays) { + *delays = 0; + } + + do { + u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); + if (u == (stbi_uc *)s) u = 0; // end of animated gif marker + + if (u) { + *x = g.w; + *y = g.h; + ++layers; + stride = g.w * g.h * 4; + + if (out) { + out = (stbi_uc*)STBI_REALLOC(out, layers * stride); + if (delays) { + *delays = (int*)STBI_REALLOC(*delays, sizeof(int) * layers); + } + } + else { + out = (stbi_uc*)stbi__malloc(layers * stride); + if (delays) { + *delays = (int*)stbi__malloc(layers * sizeof(int)); + } + } + memcpy(out + ((layers - 1) * stride), u, stride); + if (layers >= 2) { + two_back = out - 2 * stride; + } + + if (delays) { + (*delays)[layers - 1U] = g.delay; + } + } + } while (u != 0); + + // free temp buffer; + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); + + // do the final conversion after loading everything; + if (req_comp && req_comp != 4) + out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); + + *z = layers; + return out; + } + else { + return stbi__errpuc("not GIF", "Image was not as a gif type."); + } +} + +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + + u = stbi__gif_load_next(s, &g, comp, req_comp, 0); + if (u == (stbi_uc *)s) u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; + + // moved conversion to after successful load so that the same + // can be done for multiple frames. + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } + + // free buffers needed for multiple frame loading; + STBI_FREE(g.history); + STBI_FREE(g.background); + + return u; +} + +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) +{ + return stbi__gif_info_raw(s, x, y, comp); +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int stbi__hdr_test_core(stbi__context *s, const char *signature) +{ + int i; + for (i = 0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + stbi__rewind(s); + return 1; +} + +static int stbi__hdr_test(stbi__context* s) +{ + int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); + stbi__rewind(s); + if (!r) { + r = stbi__hdr_test_core(s, "#?RGBE\n"); + stbi__rewind(s); + } + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) +{ + int len = 0; + char c = '\0'; + + c = (char)stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN - 1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char)stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) +{ + if (input[3] != 0) { + float f1; + // Exponent + f1 = (float)ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) output[1] = 1; + if (req_comp == 4) output[3] = 1; + } + else { + switch (req_comp) { + case 4: output[3] = 1; /* fallthrough */ + case 3: output[0] = output[1] = output[2] = 0; + break; + case 2: output[1] = 1; /* fallthrough */ + case 1: output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1, c2, z; + const char *headerToken; + STBI_NOTUSED(ri); + + // Check identifier + headerToken = stbi__hdr_gettoken(s, buffer); + if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int)strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int)strtol(token, NULL, 10); + + *x = width; + *y = height; + + if (comp) *comp = 3; + if (req_comp == 0) req_comp = 3; + + if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) + return stbi__errpf("too large", "HDR image is too large"); + + // Read data + hdr_data = (float *)stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); + if (!hdr_data) + return stbi__errpf("outofmem", "Out of memory"); + + // Load image data + // image data is stored as some number of sca + if (width < 8 || width >= 32768) { + // Read flat data + for (j = 0; j < height; ++j) { + for (i = 0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } + else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc)c1; + rgbe[1] = (stbi_uc)c2; + rgbe[2] = (stbi_uc)len; + rgbe[3] = (stbi_uc)stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense + } + len <<= 8; + len |= stbi__get8(s); + if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } + if (scanline == NULL) { + scanline = (stbi_uc *)stbi__malloc_mad2(width, 4, 0); + if (!scanline) { + STBI_FREE(hdr_data); + return stbi__errpf("outofmem", "Out of memory"); + } + } + + for (k = 0; k < 4; ++k) { + int nleft; + i = 0; + while ((nleft = width - i) > 0) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } + else { + // Dump + if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } + } + for (i = 0; i < width; ++i) + stbi__hdr_convert(hdr_data + (j*width + i)*req_comp, scanline + i * 4, req_comp); + } + if (scanline) + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int dummy; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (stbi__hdr_test(s) == 0) { + stbi__rewind(s); + return 0; + } + + for (;;) { + token = stbi__hdr_gettoken(s, buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) { + stbi__rewind(s); + return 0; + } + token = stbi__hdr_gettoken(s, buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *y = (int)strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind(s); + return 0; + } + token += 3; + *x = (int)strtol(token, NULL, 10); + *comp = 3; + return 1; +} +#endif // STBI_NO_HDR + +#ifndef STBI_NO_BMP +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) +{ + void *p; + stbi__bmp_data info; + + info.all_a = 255; + p = stbi__bmp_parse_header(s, &info); + stbi__rewind(s); + if (p == NULL) + return 0; + if (x) *x = s->img_x; + if (y) *y = s->img_y; + if (comp) *comp = info.ma ? 4 : 3; + return 1; +} +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) +{ + int channelCount, dummy, depth; + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 8 && depth != 16) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind(s); + return 0; + } + *comp = 4; + return 1; +} + +static int stbi__psd_is16(stbi__context *s) +{ + int channelCount, depth; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind(s); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind(s); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind(s); + return 0; + } + (void)stbi__get32be(s); + (void)stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 16) { + stbi__rewind(s); + return 0; + } + return 1; +} +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) +{ + int act_comp = 0, num_packets = 0, chained, dummy; + stbi__pic_packet packets[10]; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (!stbi__pic_is4(s, "\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind(s); + return 0; + } + if ((*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets == sizeof(packets) / sizeof(packets[0])) + return 0; + + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; + + if (stbi__at_eof(s)) { + stbi__rewind(s); + return 0; + } + if (packet->size != 8) { + stbi__rewind(s); + return 0; + } + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); + + return 1; +} +#endif + +// ************************************************************************************************* +// Portable Gray Map and Portable Pixel Map loader +// by Ken Miller +// +// PGM: http://netpbm.sourceforge.net/doc/pgm.html +// PPM: http://netpbm.sourceforge.net/doc/ppm.html +// +// Known limitations: +// Does not support comments in the header section +// Does not support ASCII image data (formats P2 and P3) +// Does not support 16-bit-per-channel + +#ifndef STBI_NO_PNM + +static int stbi__pnm_test(stbi__context *s) +{ + char p, t; + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + return 1; +} + +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + STBI_NOTUSED(ri); + + if (!stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n)) + return 0; + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + + if (!stbi__mad3sizes_valid(s->img_n, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "PNM too large"); + + out = (stbi_uc *)stbi__malloc_mad3(s->img_n, s->img_x, s->img_y, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + stbi__getn(s, out, s->img_n * s->img_x * s->img_y); + + if (req_comp && req_comp != s->img_n) { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + return out; +} + +static int stbi__pnm_isspace(char c) +{ + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +} + +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) +{ + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char)stbi__get8(s); + + if (stbi__at_eof(s) || *c != '#') + break; + + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r') + *c = (char)stbi__get8(s); + } +} + +static int stbi__pnm_isdigit(char c) +{ + return c >= '0' && c <= '9'; +} + +static int stbi__pnm_getinteger(stbi__context *s, char *c) +{ + int value = 0; + + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value * 10 + (*c - '0'); + *c = (char)stbi__get8(s); + } + + return value; +} + +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) +{ + int maxv, dummy; + char c, p, t; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + stbi__rewind(s); + + // Get identifier + p = (char)stbi__get8(s); + t = (char)stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + + *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + + c = (char)stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); + + *x = stbi__pnm_getinteger(s, &c); // read width + stbi__pnm_skip_whitespace(s, &c); + + *y = stbi__pnm_getinteger(s, &c); // read height + stbi__pnm_skip_whitespace(s, &c); + + maxv = stbi__pnm_getinteger(s, &c); // read max value + + if (maxv > 255) + return stbi__err("max value > 255", "PPM image not 8-bit"); + else + return 1; +} +#endif + +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) +{ +#ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) return 1; +#endif + +#ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) return 1; +#endif + + // test tga last because it's a crappy test! +#ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; +#endif + return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +} + +static int stbi__is_16_main(stbi__context *s) +{ +#ifndef STBI_NO_PNG + if (stbi__png_is16(s)) return 1; +#endif + +#ifndef STBI_NO_PSD + if (stbi__psd_is16(s)) return 1; +#endif + + return 0; +} + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s, x, y, comp); + fseek(f, pos, SEEK_SET); + return r; +} + +STBIDEF int stbi_is_16_bit(char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_is_16_bit_from_file(f); + fclose(f); + return result; +} + +STBIDEF int stbi_is_16_bit_from_file(FILE *f) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__is_16_main(&s); + fseek(f, pos, SEEK_SET); + return r; +} +#endif // !STBI_NO_STDIO + +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__info_main(&s, x, y, comp); +} + +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__info_main(&s, x, y, comp); +} + +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__is_16_main(&s); +} + +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)c, user); + return stbi__is_16_main(&s); +} + +#endif // STB_IMAGE_IMPLEMENTATION + +/* +revision history: +2.19 (2018-02-11) fix warning +2.18 (2018-01-30) fix warnings +2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug +1-bit BMP +*_is_16_bit api +avoid warnings +2.16 (2017-07-23) all functions have 16-bit variants; +STBI_NO_STDIO works again; +compilation fixes; +fix rounding in unpremultiply; +optimize vertical flip; +disable raw_len validation; +documentation fixes +2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; +warning fixes; disable run-time SSE detection on gcc; +uniform handling of optional "return" values; +thread-safe initialization of zlib tables +2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs +2.13 (2016-11-29) add 16-bit API, only supported for PNG right now +2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes +2.11 (2016-04-02) allocate large structures on the stack +remove white matting for transparent PSD +fix reported channel count for PNG & BMP +re-enable SSE2 in non-gcc 64-bit +support RGB-formatted JPEG +read 16-bit PNGs (only as 8-bit) +2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED +2.09 (2016-01-16) allow comments in PNM files +16-bit-per-pixel TGA (not bit-per-component) +info() for TGA could break due to .hdr handling +info() for BMP to shares code instead of sloppy parse +can use STBI_REALLOC_SIZED if allocator doesn't support realloc +code cleanup +2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA +2.07 (2015-09-13) fix compiler warnings +partial animated GIF support +limited 16-bpc PSD support +#ifdef unused functions +bug with < 92 byte PIC,PNM,HDR,TGA +2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value +2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning +2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit +2.03 (2015-04-12) extra corruption checking (mmozeiko) +stbi_set_flip_vertically_on_load (nguillemot) +fix NEON support; fix mingw support +2.02 (2015-01-19) fix incorrect assert, fix warning +2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 +2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG +2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) +progressive JPEG (stb) +PGM/PPM support (Ken Miller) +STBI_MALLOC,STBI_REALLOC,STBI_FREE +GIF bugfix -- seemingly never worked +STBI_NO_*, STBI_ONLY_* +1.48 (2014-12-14) fix incorrectly-named assert() +1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) +optimize PNG (ryg) +fix bug in interlaced PNG with user-specified channel count (stb) +1.46 (2014-08-26) +fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG +1.45 (2014-08-16) +fix MSVC-ARM internal compiler error by wrapping malloc +1.44 (2014-08-07) +various warning fixes from Ronny Chevalier +1.43 (2014-07-15) +fix MSVC-only compiler problem in code changed in 1.42 +1.42 (2014-07-09) +don't define _CRT_SECURE_NO_WARNINGS (affects user code) +fixes to stbi__cleanup_jpeg path +added STBI_ASSERT to avoid requiring assert.h +1.41 (2014-06-25) +fix search&replace from 1.36 that messed up comments/error messages +1.40 (2014-06-22) +fix gcc struct-initialization warning +1.39 (2014-06-15) +fix to TGA optimization when req_comp != number of components in TGA; +fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) +add support for BMP version 5 (more ignored fields) +1.38 (2014-06-06) +suppress MSVC warnings on integer casts truncating values +fix accidental rename of 'skip' field of I/O +1.37 (2014-06-04) +remove duplicate typedef +1.36 (2014-06-03) +convert to header file single-file library +if de-iphone isn't set, load iphone images color-swapped instead of returning NULL +1.35 (2014-05-27) +various warnings +fix broken STBI_SIMD path +fix bug where stbi_load_from_file no longer left file pointer in correct place +fix broken non-easy path for 32-bit BMP (possibly never used) +TGA optimization by Arseny Kapoulkine +1.34 (unknown) +use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case +1.33 (2011-07-14) +make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements +1.32 (2011-07-13) +support for "info" function for all supported filetypes (SpartanJ) +1.31 (2011-06-20) +a few more leak fixes, bug in PNG handling (SpartanJ) +1.30 (2011-06-11) +added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) +removed deprecated format-specific test/load functions +removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway +error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) +fix inefficiency in decoding 32-bit BMP (David Woo) +1.29 (2010-08-16) +various warning fixes from Aurelien Pocheville +1.28 (2010-08-01) +fix bug in GIF palette transparency (SpartanJ) +1.27 (2010-08-01) +cast-to-stbi_uc to fix warnings +1.26 (2010-07-24) +fix bug in file buffering for PNG reported by SpartanJ +1.25 (2010-07-17) +refix trans_data warning (Won Chun) +1.24 (2010-07-12) +perf improvements reading from files on platforms with lock-heavy fgetc() +minor perf improvements for jpeg +deprecated type-specific functions so we'll get feedback if they're needed +attempt to fix trans_data warning (Won Chun) +1.23 fixed bug in iPhone support +1.22 (2010-07-10) +removed image *writing* support +stbi_info support from Jetro Lauha +GIF support from Jean-Marc Lienher +iPhone PNG-extensions from James Brown +warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) +1.21 fix use of 'stbi_uc' in header (reported by jon blow) +1.20 added support for Softimage PIC, by Tom Seddon +1.19 bug in interlaced PNG corruption check (found by ryg) +1.18 (2008-08-02) +fix a threading bug (local mutable static) +1.17 support interlaced PNG +1.16 major bugfix - stbi__convert_format converted one too many pixels +1.15 initialize some fields for thread safety +1.14 fix threadsafe conversion bug +header-file-only version (#define STBI_HEADER_FILE_ONLY before including) +1.13 threadsafe +1.12 const qualifiers in the API +1.11 Support installable IDCT, colorspace conversion routines +1.10 Fixes for 64-bit (don't use "unsigned long") +optimized upsampling by Fabian "ryg" Giesen +1.09 Fix format-conversion for PSD code (bad global variables!) +1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz +1.07 attempt to fix C++ warning/errors again +1.06 attempt to fix C++ warning/errors again +1.05 fix TGA loading to return correct *comp and use good luminance calc +1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free +1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR +1.02 support for (subset of) HDR files, float interface for preferred access to them +1.01 fix bug: possible bug in handling right-side up bmps... not sure +fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all +1.00 interface to zlib that skips zlib header +0.99 correct handling of alpha in palette +0.98 TGA loader by lonesock; dynamically add loaders (untested) +0.97 jpeg errors on too large a file; also catch another malloc failure +0.96 fix detection of invalid v value - particleman@mollyrocket forum +0.95 during header scan, seek to markers in case of padding +0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same +0.93 handle jpegtran output; verbose errors +0.92 read 4,8,16,24,32-bit BMP files of several formats +0.91 output 24-bit Windows 3.0 BMP files +0.90 fix a few more warnings; bump version number to approach 1.0 +0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd +0.60 fix compiling as c++ +0.59 fix warnings: merge Dave Moore's -Wall fixes +0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian +0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available +0.56 fix bug: zlib uncompressed mode len vs. nlen +0.55 fix bug: restart_interval not initialized to 0 +0.54 allow NULL for 'int *comp' +0.53 fix bug in png 3->4; speedup png decoding +0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments +0.51 obey req_comp requests, 1-component jpegs return as 1-component, +on 'test' only check type, not whether we support this variant +0.50 (2006-11-19) +first released version +*/ + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ \ No newline at end of file diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 9048c77861..de209c2f16 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -139,7 +139,7 @@ R_ColorShiftLightingFloats =============== */ -static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) +static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale, bool overbrightBits = true ) { float r, g, b; @@ -149,13 +149,16 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) g = in[1] * scale; b = in[2] * scale; - if ( r > 1.0f || g > 1.0f || b > 1.0f ) + if (!glRefConfig.floatLightmap) { - float high = Q_max (Q_max (r, g), b); + if (r > 1.0f || g > 1.0f || b > 1.0f) + { + float high = Q_max(Q_max(r, g), b); - r /= high; - g /= high; - b /= high; + r /= high; + g /= high; + b /= high; + } } out[0] = r; @@ -164,29 +167,6 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale ) out[3] = in[3]; } - -// Modified from http://graphicrants.blogspot.jp/2009/04/rgbm-color-encoding.html -void ColorToRGBM(const vec3_t color, unsigned char rgbm[4]) -{ - vec3_t sample; - float maxComponent; - - VectorCopy(color, sample); - - maxComponent = MAX(sample[0], sample[1]); - maxComponent = MAX(maxComponent, sample[2]); - maxComponent = CLAMP(maxComponent, 1.0f/255.0f, 1.0f); - - rgbm[3] = (unsigned char) ceil(maxComponent * 255.0f); - maxComponent = 255.0f / rgbm[3]; - - VectorScale(sample, maxComponent, sample); - - rgbm[0] = (unsigned char) (sample[0] * 255); - rgbm[1] = (unsigned char) (sample[1] * 255); - rgbm[2] = (unsigned char) (sample[2] * 255); -} - void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4]) { rgba16f[0] = FloatToHalf(color[0]); @@ -195,7 +175,6 @@ void ColorToRGBA16F(const vec3_t color, unsigned short rgba16f[4]) rgba16f[3] = FloatToHalf(1.0f); } - /* =============== R_LoadLightmaps @@ -209,22 +188,42 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { dsurface_t *surf; int len; byte *image; - int i, j, numLightmaps; + int imageSize; + int i, j, numLightmaps = 0, textureInternalFormat = 0; float maxIntensity = 0; double sumIntensity = 0; + int numColorComponents = 3; + + bool hdr_capable = glRefConfig.floatLightmap && r_hdr->integer; + tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; + + worldData->hdrLighting = qfalse; len = l->filelen; - if ( !len ) { - return; + // test for external lightmaps + if (!len) { + for (i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); + i < surfs->filelen / sizeof(dsurface_t); + i++, surf++) { + for (int j = 0; j < MAXLIGHTMAPS; j++) + { + numLightmaps = MAX(numLightmaps, LittleLong(surf->lightmapNum[j]) + 1); + } + } + buf = NULL; + } + else + { + numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); + buf = fileBase + l->fileofs; } - buf = fileBase + l->fileofs; + + if (numLightmaps == 0) + return; // we are about to upload textures R_IssuePendingRenderCommands(); - - tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; - numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); - + // check for deluxe mapping if (numLightmaps <= 1) { @@ -235,14 +234,14 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.worldDeluxeMapping = qtrue; // Check that none of the deluxe maps are referenced by any of the map surfaces. - for( i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); + for (i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); tr.worldDeluxeMapping && i < surfs->filelen / sizeof(dsurface_t); - i++, surf++ ) { - for ( int j = 0; j < MAXLIGHTMAPS; j++ ) + i++, surf++) { + for (int j = 0; j < MAXLIGHTMAPS; j++) { - int lightmapNum = LittleLong( surf->lightmapNum[j] ); + int lightmapNum = LittleLong(surf->lightmapNum[j]); - if ( lightmapNum >= 0 && (lightmapNum & 1) != 0 ) { + if (lightmapNum >= 0 && (lightmapNum & 1) != 0) { tr.worldDeluxeMapping = qfalse; break; } @@ -250,7 +249,8 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } } - image = (byte *)Z_Malloc(tr.lightmapSize * tr.lightmapSize * 4 * 2, TAG_BSP); + imageSize = tr.lightmapSize * tr.lightmapSize * 4 * 2; + image = (byte *)Z_Malloc(imageSize, TAG_BSP, qfalse); if (tr.worldDeluxeMapping) numLightmaps >>= 1; @@ -284,6 +284,11 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } + if (glRefConfig.floatLightmap) + textureInternalFormat = GL_RGBA16F; + else + textureInternalFormat = GL_RGBA8; + if (r_mergeLightmaps->integer) { for (i = 0; i < tr.numLightmaps; i++) @@ -295,7 +300,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.lightmapAtlasSize[1], IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_RGBA8); + textureInternalFormat); if (tr.worldDeluxeMapping) { @@ -311,7 +316,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } } - for(i = 0; i < numLightmaps; i++) + for (i = 0; i < numLightmaps; i++) { int xoff = 0, yoff = 0; int lightmapnum = i; @@ -327,194 +332,209 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { // if (tr.worldLightmapping) { char filename[MAX_QPATH]; - byte *hdrLightmap = NULL; - int size = 0; + byte *externalLightmap = NULL; + float *hdrL = NULL; + int lightmapWidth = tr.lightmapSize; + int lightmapHeight = tr.lightmapSize; + int bppc; + bool foundLightmap = true; + + if (hdr_capable) + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); + else + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.tga", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); - // look for hdr lightmaps - if (r_hdr->integer) + bppc = 16; + R_LoadHDRImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); + if (!externalLightmap) { - Com_sprintf( filename, sizeof( filename ), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1) ); - //ri.Printf(PRINT_ALL, "looking for %s\n", filename); - - size = ri.FS_ReadFile(filename, (void **)&hdrLightmap); + bppc = 8; + R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); } - if (hdrLightmap) + if (externalLightmap) { - byte *p = hdrLightmap; - //ri.Printf(PRINT_ALL, "found!\n"); - - /* FIXME: don't just skip over this header and actually parse it */ - while (size && !(*p == '\n' && *(p+1) == '\n')) + int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; + if (r_mergeLightmaps->integer && (lightmapWidth != tr.lightmapSize || lightmapHeight != tr.lightmapSize)) { - size--; - p++; + ri.Printf(PRINT_ALL, "Error loading %s: non %dx%d lightmaps require r_mergeLightmaps 0.\n", filename, tr.lightmapSize, tr.lightmapSize); + Z_Free(externalLightmap); + externalLightmap = NULL; + if (!len) + { + tr.numLightmaps = 0; + return; + } } - - if (!size) - ri.Error(ERR_DROP, "Bad header for %s!", filename); - - size -= 2; - p += 2; - - while (size && !(*p == '\n')) + else if (newImageSize > imageSize) { - size--; - p++; + Z_Free(image); + imageSize = newImageSize; + image = (byte *)Z_Malloc(imageSize, TAG_BSP, qfalse); } + numColorComponents = 4; + } + if (!externalLightmap) + { + lightmapWidth = tr.lightmapSize; + lightmapHeight = tr.lightmapSize; + numColorComponents = 3; + } - size--; - p++; - - buf_p = (byte *)p; - -#if 0 // HDRFILE_RGBE - if (size != tr.lightmapSize * tr.lightmapSize * 4) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); -#else // HDRFILE_FLOAT - if (size != tr.lightmapSize * tr.lightmapSize * 12) - ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size); -#endif + foundLightmap = true; + if (externalLightmap) + { + if (bppc > 8) + { + hdrL = (float *)externalLightmap; + worldData->hdrLighting = qtrue; + } + else + { + buf_p = externalLightmap; + } } - else + else if (buf) { if (tr.worldDeluxeMapping) buf_p = buf + (i * 2) * tr.lightmapSize * tr.lightmapSize * 3; else buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3; } + else + { + buf_p = NULL; + foundLightmap = false; + } - for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) + if (foundLightmap) { - if (hdrLightmap) + for (j = 0; j < lightmapWidth * lightmapHeight; j++) { - vec4_t color; - -#if 0 // HDRFILE_RGBE - float exponent = exp2(buf_p[j*4+3] - 128); - - color[0] = buf_p[j*4+0] * exponent; - color[1] = buf_p[j*4+1] * exponent; - color[2] = buf_p[j*4+2] * exponent; -#else // HDRFILE_FLOAT - memcpy(color, &buf_p[j*12], 12); + if (hdrL && hdr_capable) + { + vec4_t color; + int column = (j % lightmapWidth); + int rowIndex = ((lightmapHeight - (int)floor(j / lightmapHeight)) - 1) * lightmapHeight; - color[0] = LittleFloat(color[0]); - color[1] = LittleFloat(color[1]); - color[2] = LittleFloat(color[2]); -#endif - color[3] = 1.0f; + int index = column + rowIndex; - R_ColorShiftLightingFloats(color, color, 1.0f/255.0f); + memcpy(color, &hdrL[index * 3], 12); - if (glRefConfig.floatLightmap) - ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); - else - ColorToRGBM(color, &image[j*4]); - } - else if (glRefConfig.floatLightmap) - { - vec4_t color; + color[3] = 1.0f; - //hack: convert LDR lightmap to HDR one - color[0] = MAX(buf_p[j*3+0], 0.499f); - color[1] = MAX(buf_p[j*3+1], 0.499f); - color[2] = MAX(buf_p[j*3+2], 0.499f); + R_ColorShiftLightingFloats(color, color, 1.0f, false); - // if under an arbitrary value (say 12) grey it out - // this prevents weird splotches in dimly lit areas - if (color[0] + color[1] + color[2] < 12.0f) + ColorToRGBA16F(color, (uint16_t *)(&image[j * 8])); + } + else if (buf_p && glRefConfig.floatLightmap) { - float avg = (color[0] + color[1] + color[2]) * 0.3333f; - color[0] = avg; - color[1] = avg; - color[2] = avg; + vec4_t color; + + //hack: convert LDR lightmap to HDR one + color[0] = MAX(buf_p[j*numColorComponents + 0], 0.499f); + color[1] = MAX(buf_p[j*numColorComponents + 1], 0.499f); + color[2] = MAX(buf_p[j*numColorComponents + 2], 0.499f); + + // if under an arbitrary value (say 12) grey it out + // this prevents weird splotches in dimly lit areas + if (color[0] + color[1] + color[2] < 12.0f) + { + float avg = (color[0] + color[1] + color[2]) * 0.3333f; + color[0] = avg; + color[1] = avg; + color[2] = avg; + } + color[3] = 1.0f; + + R_ColorShiftLightingFloats(color, color, 1.0f / 255.0f); + + color[0] = color[0]; + color[1] = color[1]; + color[2] = color[2]; + + ColorToRGBA16F(color, (unsigned short *)(&image[j * 8])); } - color[3] = 1.0f; + else if (buf_p) + { + if (r_lightmap->integer == 2) + { // color code by intensity as development tool (FIXME: check range) + float r = buf_p[j*numColorComponents + 0]; + float g = buf_p[j*numColorComponents + 1]; + float b = buf_p[j*numColorComponents + 2]; + float intensity; + float out[3] = { 0.0, 0.0, 0.0 }; - R_ColorShiftLightingFloats(color, color, 1.0f/255.0f); + intensity = 0.33f * r + 0.685f * g + 0.063f * b; - ColorToRGBA16F(color, (unsigned short *)(&image[j*8])); - } - else - { - if ( r_lightmap->integer == 2 ) - { // color code by intensity as development tool (FIXME: check range) - float r = buf_p[j*3+0]; - float g = buf_p[j*3+1]; - float b = buf_p[j*3+2]; - float intensity; - float out[3] = {0.0, 0.0, 0.0}; - - intensity = 0.33f * r + 0.685f * g + 0.063f * b; - - if ( intensity > 255 ) - intensity = 1.0f; - else - intensity /= 255.0f; + if (intensity > 255) + intensity = 1.0f; + else + intensity /= 255.0f; - if ( intensity > maxIntensity ) - maxIntensity = intensity; + if (intensity > maxIntensity) + maxIntensity = intensity; - HSVtoRGB( intensity, 1.00, 0.50, out ); + HSVtoRGB(intensity, 1.00, 0.50, out); - image[j*4+0] = out[0] * 255; - image[j*4+1] = out[1] * 255; - image[j*4+2] = out[2] * 255; - image[j*4+3] = 255; + image[j * 4 + 0] = out[0] * 255; + image[j * 4 + 1] = out[1] * 255; + image[j * 4 + 2] = out[2] * 255; + image[j * 4 + 3] = 255; - sumIntensity += intensity; - } - else - { - R_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] ); - image[j*4+3] = 255; + sumIntensity += intensity; + } + else + { + R_ColorShiftLightingBytes(&buf_p[j * numColorComponents], &image[j * 4]); + image[j * 4 + 3] = 255; + } } } - } - if (r_mergeLightmaps->integer) - R_UpdateSubImage( - tr.lightmaps[lightmapnum], - image, - xoff, - yoff, - tr.lightmapSize, - tr.lightmapSize); - else - tr.lightmaps[i] = R_CreateImage( - va("*lightmap%d", i), - image, - tr.lightmapSize, - tr.lightmapSize, - IMGTYPE_COLORALPHA, - IMGFLAG_NOLIGHTSCALE | + if (r_mergeLightmaps->integer) + R_UpdateSubImage( + tr.lightmaps[lightmapnum], + image, + xoff, + yoff, + lightmapWidth, + lightmapHeight); + else + tr.lightmaps[i] = R_CreateImage( + va("*lightmap%d", i), + image, + lightmapWidth, + lightmapHeight, + IMGTYPE_COLORALPHA, + IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_RGBA8); + textureInternalFormat); + } - if (hdrLightmap) - ri.FS_FreeFile(hdrLightmap); - } + if (externalLightmap) + Z_Free(externalLightmap); + } - if (tr.worldDeluxeMapping) + if (tr.worldDeluxeMapping && buf) { buf_p = buf + (i * 2 + 1) * tr.lightmapSize * tr.lightmapSize * 3; - for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ ) { - image[j*4+0] = buf_p[j*3+0]; - image[j*4+1] = buf_p[j*3+1]; - image[j*4+2] = buf_p[j*3+2]; + for (j = 0; j < tr.lightmapSize * tr.lightmapSize; j++) { + image[j * 4 + 0] = buf_p[j * 3 + 0]; + image[j * 4 + 1] = buf_p[j * 3 + 1]; + image[j * 4 + 2] = buf_p[j * 3 + 2]; // make 0,0,0 into 127,127,127 - if ((image[j*4+0] == 0) && (image[j*4+1] == 0) && (image[j*4+2] == 0)) + if ((image[j * 4 + 0] == 0) && (image[j * 4 + 1] == 0) && (image[j * 4 + 2] == 0)) { image[j*4+0] = image[j*4+1] = image[j*4+2] = 127; } - image[j*4+3] = 255; + image[j * 4 + 3] = 255; } if (r_mergeLightmaps->integer) @@ -536,19 +556,19 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.lightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, 0); } } - } + } if ( r_lightmap->integer == 2 ) { ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); } Z_Free(image); -} + } static float FatPackU(float input, int lightmapnum) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 6fdb2bcbca..8716793b86 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1575,9 +1575,6 @@ static int GLSL_LoadGPUProgramLightAll( if (r_dlightMode->integer >= 2) Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); - if (1) - Q_strcat(extradefines, sizeof(extradefines), "#define SWIZZLE_NORMALMAP\n"); - if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, sizeof(extradefines), "#define RGBM_LIGHTMAP\n"); @@ -1891,23 +1888,36 @@ static int GLSL_LoadGPUProgramTonemap( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) { - GLSL_LoadGPUProgramBasic( - builder, - scratchAlloc, - &tr.tonemapShader, - "tonemap", - fallback_tonemapProgram); + Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); + char extradefines[1200]; + const GPUProgramDesc *programDesc = + LoadProgramSource("tonemap", allocator, fallback_tonemapProgram); + const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0; - GLSL_InitUniforms(&tr.tonemapShader); + extradefines[0] = '\0'; + if (!GLSL_LoadGPUShader(builder, &tr.tonemapShader[0], "tonemap", attribs, NO_XFB_VARS, + extradefines, *programDesc)) + { + ri.Error(ERR_FATAL, "Could not load tonemap shader!"); + } - qglUseProgram(tr.tonemapShader.program); - GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_TEXTUREMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.tonemapShader, UNIFORM_LEVELSMAP, TB_LEVELSMAP); - qglUseProgram(0); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LINEAR_LIGHT\n"); + if (!GLSL_LoadGPUShader(builder, &tr.tonemapShader[1], "tonemap", attribs, NO_XFB_VARS, + extradefines, *programDesc)) + { + ri.Error(ERR_FATAL, "Could not load tonemap shader!"); + } - GLSL_FinishGPUShader(&tr.tonemapShader); - - return 1; + for (int i = 0; i < 2; i++) + { + GLSL_InitUniforms(&tr.tonemapShader[i]); + qglUseProgram(tr.tonemapShader[i].program); + GLSL_SetUniformInt(&tr.tonemapShader[i], UNIFORM_TEXTUREMAP, TB_COLORMAP); + GLSL_SetUniformInt(&tr.tonemapShader[i], UNIFORM_LEVELSMAP, TB_LEVELSMAP); + qglUseProgram(0); + GLSL_FinishGPUShader(&tr.tonemapShader[i]); + } + return 2; } static int GLSL_LoadGPUProgramCalcLuminanceLevel( @@ -2351,7 +2361,9 @@ void GLSL_ShutdownGPUShaders(void) GLSL_DeleteGPUShader(&tr.volumeShadowShader); GLSL_DeleteGPUShader(&tr.down4xShader); GLSL_DeleteGPUShader(&tr.bokehShader); - GLSL_DeleteGPUShader(&tr.tonemapShader); + + for (i = 0; i < 2; ++i) + GLSL_DeleteGPUShader(&tr.tonemapShader[i]); for ( i = 0; i < 2; i++) GLSL_DeleteGPUShader(&tr.calclevels4xShader[i]); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 646a07de93..38ed34c85a 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3406,23 +3406,12 @@ void R_SetColorMappings( void ) { g = r_gamma->value; for ( i = 0; i < 256; i++ ) { - int i2; - - if (r_srgb->integer) - { - i2 = 255 * RGBtosRGB(i/255.0f) + 0.5f; - } - else - { - i2 = i; - } - if ( g == 1 ) { - inf = i2; + inf = i; } else { - inf = 255 * pow ( i2/255.0f, 1.0f / g ) + 0.5f; + inf = 255 * pow ( i/255.0f, 1.0f / g ) + 0.5f; } - + inf <<= tr.overbrightBits; if (inf < 0) { inf = 0; } diff --git a/codemp/rd-rend2/tr_image_stb.cpp b/codemp/rd-rend2/tr_image_stb.cpp new file mode 100644 index 0000000000..401b7719db --- /dev/null +++ b/codemp/rd-rend2/tr_image_stb.cpp @@ -0,0 +1,83 @@ +/* +=========================================================================== +Copyright (C) 1999 - 2005, Id Software, Inc. +Copyright (C) 2000 - 2013, Raven Software, Inc. +Copyright (C) 2001 - 2013, Activision, Inc. +Copyright (C) 2005 - 2015, ioquake3 contributors +Copyright (C) 2013 - 2015, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#include "tr_local.h" + +static void* R_LocalMalloc(size_t size) +{ + return Z_Malloc(size, TAG_TEMP_WORKSPACE); +} + +static void* R_LocalReallocSized(void *ptr, size_t old_size, size_t new_size) +{ + void *mem = Z_Malloc(new_size, TAG_TEMP_WORKSPACE, qfalse); + if (ptr) + { + memcpy(mem, ptr, old_size); + Z_Free(ptr); + } + return mem; +} +static void R_LocalFree(void *ptr) +{ + if (ptr) + Z_Free(ptr); +} + +#define STBI_MALLOC R_LocalMalloc +#define STBI_REALLOC_SIZED R_LocalReallocSized +#define STBI_FREE R_LocalFree + +#define STB_IMAGE_IMPLEMENTATION + +#define STBI_TEMP_ON_STACK +#define STBI_ONLY_HDR +#include + +#define IMG_BYTE 0 +#define IMG_FLOAT 1 + +// Loads a HDR image from file. +void R_LoadHDRImage( const char *filename, byte **data, int *width, int *height ) +{ + byte *buf = NULL; + int x, y, n; + int len = ri.FS_ReadFile (filename, (void **)&buf); + if ( len < 0 || buf == NULL ) + { + return; + } + stbi_set_flip_vertically_on_load(0); + *data = (byte *)stbi_loadf_from_memory(buf, len, &x, &y, &n, 3); + + ri.FS_FreeFile(buf); + + if (!data) + ri.Printf(PRINT_DEVELOPER, "R_LoadHDRImage(%s) failed: %s\n", filename, stbi_failure_reason()); + + if (width) + *width = x; + if (height) + *height = y; +} diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 845b71d804..8d34da456d 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -129,8 +129,6 @@ cvar_t *r_forceAutoExposure; cvar_t *r_forceAutoExposureMin; cvar_t *r_forceAutoExposureMax; -cvar_t *r_srgb; - cvar_t *r_depthPrepass; cvar_t *r_ssao; @@ -1480,8 +1478,6 @@ void R_Register( void ) r_cameraExposure = ri.Cvar_Get( "r_cameraExposure", "0", CVAR_CHEAT, "" ); - r_srgb = ri.Cvar_Get( "r_srgb", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE, "" ); r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index b253816dc3..e82307dd0c 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -148,8 +148,6 @@ extern cvar_t *r_forceAutoExposure; extern cvar_t *r_forceAutoExposureMin; extern cvar_t *r_forceAutoExposureMax; -extern cvar_t *r_srgb; - extern cvar_t *r_depthPrepass; extern cvar_t *r_ssao; @@ -971,6 +969,7 @@ typedef struct shader_s { shaderStage_t *stages[MAX_SHADER_STAGES]; void (*optimalStageIteratorFunc)( void ); + qboolean isHDRLit; float clampTime; // time this shader is clamped to float timeOffset; // current time offset for this shader @@ -1890,6 +1889,8 @@ typedef struct { char *entityString; char *entityParsePoint; + + qboolean hdrLighting; } world_t; @@ -2383,7 +2384,7 @@ typedef struct trGlobals_s { shaderProgram_t volumeShadowShader; shaderProgram_t down4xShader; shaderProgram_t bokehShader; - shaderProgram_t tonemapShader; + shaderProgram_t tonemapShader[2]; shaderProgram_t calclevels4xShader[2]; shaderProgram_t shadowmaskShader; shaderProgram_t ssaoShader; @@ -2618,8 +2619,6 @@ extern cvar_t *r_forceAutoExposureMax; extern cvar_t *r_cameraExposure; -extern cvar_t *r_srgb; - extern cvar_t *r_depthPrepass; extern cvar_t *r_ssao; @@ -2810,6 +2809,7 @@ void R_InitFogTable( void ); float R_FogFactor( float s, float t ); void R_InitImagesPool(); void R_InitImages( void ); +void R_LoadHDRImage(const char *filename, byte **data, int *width, int *height); void R_DeleteTextures( void ); int R_SumOfUsedImages( void ); void R_InitSkins( void ); diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index bd3003fb02..831de381d6 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -87,7 +87,9 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in else GL_BindToTMU(tr.fixedLevelsImage, TB_LEVELSMAP); - FBO_Blit(hdrFbo, hdrBox, NULL, ldrFbo, ldrBox, &tr.tonemapShader, color, 0); + bool srgbTransform = tr.world && tr.world->hdrLighting == qtrue; + shaderProgram_t *shader = srgbTransform ? &tr.tonemapShader[1] : &tr.tonemapShader[0]; + FBO_Blit(hdrFbo, hdrBox, NULL, ldrFbo, ldrBox, shader, color, 0); } /* diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index b73a55ec02..dca1bb7cba 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1281,7 +1281,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (r_genNormalMaps->integer) flags |= IMGFLAG_GENNORMALMAP; - if (r_srgb->integer) + if (shader.isHDRLit) flags |= IMGFLAG_SRGB; Q_strncpyz(bufferBaseColorTextureName, token, sizeof(bufferBaseColorTextureName)); @@ -1437,7 +1437,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!shader.noPicMip) flags |= IMGFLAG_PICMIP; - if (r_srgb->integer) + if (shader.isHDRLit) flags |= IMGFLAG_SRGB; if (shader.noTC) @@ -1446,9 +1446,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (r_genNormalMaps->integer) flags |= IMGFLAG_GENNORMALMAP; - if (r_srgb->integer) - flags |= IMGFLAG_SRGB; - stage->bundle[0].image[num] = R_FindImageFile( token, imgtype, flags ); if ( !stage->bundle[0].image[num] ) { @@ -2262,7 +2259,7 @@ static void ParseSkyParms( const char **text ) { if (shader.noTC) imgFlags |= IMGFLAG_NO_COMPRESSION; - if (r_srgb->integer) + if (tr.world && tr.world->hdrLighting) imgFlags |= IMGFLAG_SRGB; // outerbox @@ -4075,6 +4072,25 @@ static qboolean IsShader ( const shader_t *sh, const char *name, const int *ligh return qtrue; } +/* +=============== +R_FindLightmaps +=============== +*/ +static inline const int *R_FindLightmaps(const int *lightmapIndexes) +{ + // don't bother with vertex lighting + if (*lightmapIndexes < 0) + return lightmapIndexes; + + // do the lightmaps exist? + for (int i = 0; i < MAXLIGHTMAPS; i++) + { + if (lightmapIndexes[i] >= tr.numLightmaps || tr.lightmaps[lightmapIndexes[i]] == NULL) + return lightmapsVertex; + } + return lightmapIndexes; +} /* =============== @@ -4125,6 +4141,23 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte lightmapIndexes = lightmapsVertex; } + lightmapIndexes = R_FindLightmaps(lightmapIndexes); + switch (lightmapIndexes[0]) { + case LIGHTMAP_NONE: + case LIGHTMAP_2D: + case LIGHTMAP_WHITEIMAGE: + { + shader.isHDRLit = qfalse; + break; + } + default: + { + + shader.isHDRLit = tr.world ? tr.world->hdrLighting: qfalse; + break; + } + } + COM_StripExtension(name, strippedName, sizeof(strippedName)); hash = generateHashValue(strippedName, FILE_HASH_SIZE); @@ -4176,7 +4209,7 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte flags = IMGFLAG_NONE; - if (r_srgb->integer) + if (shader.isHDRLit == qtrue) flags |= IMGFLAG_SRGB; if (mipRawImage) From 217bf6a873ee5d5260f75410a801dea787c08037 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 10 Aug 2020 16:29:17 +0200 Subject: [PATCH 525/708] Don't scale hdr lightmaps --- codemp/rd-rend2/tr_bsp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index de209c2f16..b3917141d0 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -143,7 +143,8 @@ static void R_ColorShiftLightingFloats(float in[4], float out[4], float scale, b { float r, g, b; - scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); + if (overbrightBits) + scale *= pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); r = in[0] * scale; g = in[1] * scale; From a5097a90ebc7d79d96b8596046e79ff98ad1b31d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 10 Aug 2020 17:40:05 +0200 Subject: [PATCH 526/708] Rename msaa cvar --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 8d34da456d..13ab4b6edc 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1427,7 +1427,7 @@ void R_Register( void ) r_ext_multi_draw_arrays = ri.Cvar_Get( "r_ext_multi_draw_arrays", "1", CVAR_ARCHIVE | CVAR_LATCH, "Unused" ); r_ext_texture_float = ri.Cvar_Get( "r_ext_texture_float", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable floating-point textures" ); r_arb_half_float_pixel = ri.Cvar_Get( "r_arb_half_float_pixel", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable ARB_half_float GL extension" ); - r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_framebuffer_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable framebuffer MSAA" ); + r_ext_framebuffer_multisample = ri.Cvar_Get( "r_ext_multisample", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable framebuffer MSAA" ); r_arb_seamless_cube_map = ri.Cvar_Get( "r_arb_seamless_cube_map", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable seamless cube map filtering GL extension" ); r_arb_vertex_type_2_10_10_10_rev = ri.Cvar_Get( "r_arb_vertex_type_2_10_10_10_rev", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable 1010102 UI data type" ); r_arb_buffer_storage = ri.Cvar_Get( "r_arb_buffer_storage", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable buffer storage GL extension" ); From 6ea4ce2286d7ba040b2c455ee35ceff6dbcc740f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Aug 2020 22:29:29 +0200 Subject: [PATCH 527/708] Fixing hdr vertex colors and lightgrid --- codemp/rd-rend2/tr_bsp.cpp | 55 ++++++++++++++++++++---------------- codemp/rd-rend2/tr_light.cpp | 36 +++++++++-------------- 2 files changed, 43 insertions(+), 48 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b3917141d0..935c10b451 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -791,11 +791,14 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver cv->verts[i].lightmap[j][1] = FatPackV( LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); + float scale = 1.0f / 255.0f; if (hdrVertColors) { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + float *hdrColor = hdrVertColors + (ds->firstVert + i) * 3; + color[0] = hdrColor[0]; + color[1] = hdrColor[1]; + color[2] = hdrColor[2]; + scale = 1.0f; } else { @@ -815,7 +818,7 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver } color[3] = verts[i].color[j][3] / 255.0f; - R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], 1.0f / 255.0f ); + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], scale, hdrVertColors != NULL ); } } @@ -939,11 +942,14 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve points[i].lightmap[j][0] = FatPackU(LittleFloat(verts[i].lightmap[j][0]), ds->lightmapNum[j]); points[i].lightmap[j][1] = FatPackV(LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); + float scale = 1.0f / 255.0f; if (hdrVertColors) { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + float *hdrColor = hdrVertColors + (ds->firstVert + i)*3; + color[0] = hdrColor[0]; + color[1] = hdrColor[1]; + color[2] = hdrColor[2]; + scale = 1.0f; } else { @@ -963,7 +969,7 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve } color[3] = verts[i].color[j][3] / 255.0f; - R_ColorShiftLightingFloats( color, points[i].vertexColors[j], 1.0f / 255.0f ); + R_ColorShiftLightingFloats( color, points[i].vertexColors[j], scale, hdrVertColors != NULL ); } } @@ -1054,11 +1060,14 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * cv->verts[i].lightmap[j][1] = FatPackV( LittleFloat(verts[i].lightmap[j][1]), ds->lightmapNum[j]); + float scale = 1.0f / 255.0f; if (hdrVertColors) { - color[0] = hdrVertColors[(ds->firstVert + i) * 3 ]; - color[1] = hdrVertColors[(ds->firstVert + i) * 3 + 1]; - color[2] = hdrVertColors[(ds->firstVert + i) * 3 + 2]; + float *hdrColor = hdrVertColors + ((ds->firstVert + i) * 3); + color[0] = hdrColor[0]; + color[1] = hdrColor[1]; + color[2] = hdrColor[2]; + scale = 1.0f; } else { @@ -1078,7 +1087,7 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * } color[3] = verts[i].color[j][3] / 255.0f; - R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], 1.0f / 255.0f ); + R_ColorShiftLightingFloats( color, cv->verts[i].vertexColors[j], scale, hdrVertColors != NULL ); } } @@ -2726,25 +2735,21 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { if (hdrLightGrid) { - float lightScale = pow(2.0f, r_mapOverBrightBits->integer - tr.overbrightBits); - - //ri.Printf(PRINT_ALL, "found!\n"); - - if (size != sizeof(float) * 6 * numGridDataElements) + if (size != sizeof(float) * 6 * worldData->lightGridBounds[0] * worldData->lightGridBounds[1] * worldData->lightGridBounds[2]) { - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * numGridDataElements); + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float)) * 6 * worldData->lightGridBounds[0] * worldData->lightGridBounds[1] * worldData->lightGridBounds[2]); } worldData->hdrLightGrid = (float *)ri.Hunk_Alloc(size, h_low); - for (i = 0; i < numGridDataElements ; i++) + for (i = 0; i < worldData->lightGridBounds[0] * worldData->lightGridBounds[1] * worldData->lightGridBounds[2]; i++) { - worldData->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] * lightScale; - worldData->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] * lightScale; - worldData->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] * lightScale; - worldData->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] * lightScale; - worldData->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] * lightScale; - worldData->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] * lightScale; + worldData->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ]; + worldData->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1]; + worldData->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2]; + worldData->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3]; + worldData->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4]; + worldData->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5]; } } diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 80bdf63168..cacb4dabf1 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -136,7 +136,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { int gridStep[3]; vec3_t direction; float totalFactor; - unsigned short *startGridPos; + int startGridPos; if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { // seperate lightOrigins are needed so an object that is @@ -171,13 +171,13 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { gridStep[0] = 1; gridStep[1] = 1 * world->lightGridBounds[0]; gridStep[2] = 1 * world->lightGridBounds[0] * world->lightGridBounds[1]; - startGridPos = world->lightGridArray + (pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2]); + startGridPos = pos[0] * gridStep[0] + pos[1] * gridStep[1] + pos[2] * gridStep[2]; totalFactor = 0; for ( i = 0 ; i < 8 ; i++ ) { float factor; mgrid_t *data; - unsigned short *gridPos; + int gridPos; int lat, lng; vec3_t normal; @@ -197,25 +197,17 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { } } - if (gridPos >= world->lightGridArray + world->numGridArrayElements) + if (gridPos >= world->numGridArrayElements) {//we've gone off the array somehow continue; } - data = world->lightGridData + *gridPos; + data = world->lightGridData + *(world->lightGridArray+gridPos); if ( data->styles[0] == LS_LSNONE ) { continue; // ignore samples in walls } - if (world->hdrLightGrid) - { - float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6; - if (!(hdrData[0]+hdrData[1]+hdrData[2]+hdrData[3]+hdrData[4]+hdrData[5]) ) { - continue; // ignore samples in walls - } - } - totalFactor += factor; #if idppc d0 = data[0]; d1 = data[1]; d2 = data[2]; @@ -231,16 +223,14 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { #else if (world->hdrLightGrid) { - // FIXME: this is hideous - float *hdrData = world->hdrLightGrid + (int)(data - world->lightGridData) / 8 * 6; - - ent->ambientLight[0] += factor * hdrData[0]; - ent->ambientLight[1] += factor * hdrData[1]; - ent->ambientLight[2] += factor * hdrData[2]; - - ent->directedLight[0] += factor * hdrData[3]; - ent->directedLight[1] += factor * hdrData[4]; - ent->directedLight[2] += factor * hdrData[5]; + float *hdrData = world->hdrLightGrid + (gridPos * 6); + ent->ambientLight[0] += factor * hdrData[0] * 255.0f; + ent->ambientLight[1] += factor * hdrData[1] * 255.0f; + ent->ambientLight[2] += factor * hdrData[2] * 255.0f; + + ent->directedLight[0] += factor * hdrData[3] * 255.0f; + ent->directedLight[1] += factor * hdrData[4] * 255.0f; + ent->directedLight[2] += factor * hdrData[5] * 255.0f; } else { From 3f7d8427a3c8cac7d1f66bc65ff99dc928275cd5 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Aug 2020 22:31:11 +0200 Subject: [PATCH 528/708] Fixing normalmap shading Removed SWIZZLE_NORMALMAP earlier, which caused trouble in the shader. --- codemp/rd-rend2/glsl/lightall.glsl | 4 ---- 1 file changed, 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index e896abfd9d..a017c49fe7 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -457,11 +457,7 @@ out vec4 out_Glow; #if defined(USE_PARALLAXMAP) float SampleDepth(sampler2D normalMap, vec2 t) { - #if defined(SWIZZLE_NORMALMAP) return 1.0 - texture(normalMap, t).r; - #else - return 1.0 - texture(normalMap, t).a; - #endif } float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) From 8befd39ec42b22ecca77adbc5d09b4a7a86aeb3c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 27 Aug 2020 16:01:08 +0200 Subject: [PATCH 529/708] Autoload _specGloss and _rmo Just to enable non explicit shaders to use those maps too. --- codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 38ed34c85a..3db2c67ebf 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2622,7 +2622,7 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c Q_strcat(diffuseName, sizeof(diffuseName), "_diffuse"); COM_StripExtension(name, specularName, sizeof(specularName)); - Q_strcat(specularName, sizeof(specularName), "_spec"); + Q_strcat(specularName, sizeof(specularName), "_specGloss"); // // see if the images are already loaded diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index dca1bb7cba..ac6e2b6fcb 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3036,6 +3036,44 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm } } + if (r_specularMapping->integer) + { + image_t *diffuseImg; + if (stage->bundle[TB_SPECULARMAP].image[0]) + { + //ri.Printf(PRINT_ALL, ", specularmap %s", stage->bundle[TB_SPECULARMAP].image[0]->imgName); + } + else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0])) + { + char specularName[MAX_QPATH]; + image_t *specularImg; + int specularFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + + COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); + Q_strcat(specularName, MAX_QPATH, "_specGloss"); + + specularImg = R_FindImageFile(specularName, IMGTYPE_COLORALPHA, specularFlags); + + if (specularImg) + { + stage->bundle[TB_SPECULARMAP] = stage->bundle[0]; + stage->bundle[TB_SPECULARMAP].numImageAnimations = 0; + stage->bundle[TB_SPECULARMAP].image[0] = specularImg; + + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + } + else + { + COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); + Q_strcat(specularName, MAX_QPATH, "_rmo"); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO); + + if (stage->bundle[TB_SPECULARMAP].image[0]) + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + } + } + } + if (tcgen || stage->bundle[0].numTexMods) { defs |= LIGHTDEF_USE_TCGEN_AND_TCMOD; From eba1e858281a5486d72bf4a36a9fbef15878a2e6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 27 Aug 2020 16:02:17 +0200 Subject: [PATCH 530/708] Set some default values at bsp load --- codemp/rd-rend2/tr_bsp.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 935c10b451..031f7f91b1 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3919,6 +3919,12 @@ void RE_LoadWorldMap( const char *name ) { tr.mapLightScale = 1.0f; tr.sunShadowScale = 0.5f; + // set default sun color to be used if it isn't + // overridden by a shader + tr.sunLight[0] = 1.0f; + tr.sunLight[1] = 1.0f; + tr.sunLight[2] = 1.0f; + // set default sun direction to be used if it isn't // overridden by a shader tr.sunDirection[0] = 0.45f; @@ -3932,9 +3938,19 @@ void RE_LoadWorldMap( const char *name ) { tr.autoExposureMinMax[1] = 2.0f; // set default tone mapping settings - tr.toneMinAvgMaxLevel[0] = -8.0f; - tr.toneMinAvgMaxLevel[1] = -2.0f; - tr.toneMinAvgMaxLevel[2] = 0.0f; + if (r_hdr->integer) + { + tr.toneMinAvgMaxLevel[0] = -6.0f; + tr.toneMinAvgMaxLevel[1] = 0.0f; + tr.toneMinAvgMaxLevel[2] = 2.0f; + } + else + { + tr.toneMinAvgMaxLevel[0] = -8.0f; + tr.toneMinAvgMaxLevel[1] = -2.0f; + tr.toneMinAvgMaxLevel[2] = 0.0f; + } + world_t *world = R_LoadBSP(name); if (world == nullptr) From 15ec41765cc0b5601a2c68078aaf387193d7bfce Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 27 Aug 2020 16:41:25 +0200 Subject: [PATCH 531/708] Moving the Sun Light in Texel-Sized Increments --- codemp/rd-rend2/tr_main.cpp | 121 +++++++++++++++++------------------- 1 file changed, 56 insertions(+), 65 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 8f55fb61a8..6867a25349 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2262,8 +2262,6 @@ void R_SetupViewParmsForOrthoRendering( viewParms.frameSceneNum = tr.frameSceneNum; viewParms.frameCount = tr.frameCount; - tr.viewCount++; - R_RotateForViewer(&tr.ori, &viewParms); R_SetupProjectionOrtho(&viewParms, viewBounds); } @@ -2546,7 +2544,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) float splitZNear, splitZFar, splitBias; float viewZNear, viewZFar; vec3_t lightviewBounds[2]; - qboolean lightViewIndependentOfCameraView = qfalse; + qboolean lightViewIndependentOfCameraView = qtrue; if (r_forceSun->integer == 2) { @@ -2659,93 +2657,66 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) // Create bounds for light projection using slice of view projection { - matrix_t lightViewMatrix; - vec4_t point, base, lightViewPoint; - float lx, ly; - - base[3] = 1; - point[3] = 1; - lightViewPoint[3] = 1; - - Matrix16View(lightViewAxis, lightOrigin, lightViewMatrix); - ClearBounds(lightviewBounds[0], lightviewBounds[1]); + vec3_t point, base; + float lx, ly, radius; + vec3_t splitCenter, frustrumPoint0, frustrumPoint7; + // add view near plane lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f); ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f); VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base); - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + VectorCopy(point, frustrumPoint0); - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); - VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(base, lx, fd->viewaxis[1], point); VectorMA(point, -ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorAdd(point, splitCenter, splitCenter); - VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(base, -lx, fd->viewaxis[1], point); VectorMA(point, -ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - + VectorAdd(point, splitCenter, splitCenter); // add view far plane lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f); ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f); VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base); - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(point, ly, fd->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); - VectorMA(base, lx, fd->viewaxis[1], point); + VectorMA(base, lx, fd->viewaxis[1], point); VectorMA(point, -ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); + VectorAdd(point, splitCenter, splitCenter); - VectorMA(base, -lx, fd->viewaxis[1], point); + VectorMA(base, -lx, fd->viewaxis[1], point); VectorMA(point, -ly, fd->viewaxis[2], point); - Matrix16Transform(lightViewMatrix, point, lightViewPoint); - AddPointToBounds(lightViewPoint, lightviewBounds[0], lightviewBounds[1]); - - // Moving the Light in Texel-Sized Increments - // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx - // - float cascadeBound, worldUnitsPerTexel, invWorldUnitsPerTexel; - - cascadeBound = MAX(lightviewBounds[1][0] - lightviewBounds[0][0], lightviewBounds[1][1] - lightviewBounds[0][1]); - cascadeBound = MAX(cascadeBound, lightviewBounds[1][2] - lightviewBounds[0][2]); - worldUnitsPerTexel = cascadeBound / tr.sunShadowFbo[level]->width; - invWorldUnitsPerTexel = 1.0f / worldUnitsPerTexel; + VectorAdd(point, splitCenter, splitCenter); + VectorCopy(point, frustrumPoint7); - VectorScale(lightviewBounds[0], invWorldUnitsPerTexel, lightviewBounds[0]); - lightviewBounds[0][0] = floor(lightviewBounds[0][0]); - lightviewBounds[0][1] = floor(lightviewBounds[0][1]); - lightviewBounds[0][2] = floor(lightviewBounds[0][2]); - VectorScale(lightviewBounds[0], worldUnitsPerTexel, lightviewBounds[0]); + VectorScale(splitCenter, 1.0f / 8.0f, splitCenter); + radius = Distance(frustrumPoint0, frustrumPoint7) / 2.0f; + lightviewBounds[0][0] = -radius; + lightviewBounds[0][1] = -radius; + lightviewBounds[0][2] = -radius; + lightviewBounds[1][0] = radius; + lightviewBounds[1][1] = radius; + lightviewBounds[1][2] = radius; - VectorScale(lightviewBounds[1], invWorldUnitsPerTexel, lightviewBounds[1]); - lightviewBounds[1][0] = floor(lightviewBounds[1][0]); - lightviewBounds[1][1] = floor(lightviewBounds[1][1]); - lightviewBounds[1][2] = floor(lightviewBounds[1][2]); - VectorScale(lightviewBounds[1], worldUnitsPerTexel, lightviewBounds[1]); - - //ri.Printf(PRINT_ALL, "znear %f zfar %f\n", lightviewBounds[0][0], lightviewBounds[1][0]); - //ri.Printf(PRINT_ALL, "fovx %f fovy %f xmin %f xmax %f ymin %f ymax %f\n", fd->fov_x, fd->fov_y, xmin, xmax, ymin, ymax); + VectorCopy(splitCenter, lightOrigin); } orientationr_t orientation = {}; @@ -2759,6 +2730,26 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) orientation, lightviewBounds); + // Moving the Light in Texel-Sized Increments + // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx + float worldUnitsPerTexel, invWorldUnitsPerTexel; + worldUnitsPerTexel = 2.0f * lightviewBounds[1][0] / (float)tr.sunShadowFbo[level]->width; + invWorldUnitsPerTexel = tr.sunShadowFbo[level]->width / (2.0f * lightviewBounds[1][0]); + vec3_t new_view_origin; + new_view_origin[0] = tr.viewParms.world.modelViewMatrix[12]; + new_view_origin[1] = tr.viewParms.world.modelViewMatrix[13]; + new_view_origin[2] = tr.viewParms.world.modelViewMatrix[14]; + + VectorScale(new_view_origin, invWorldUnitsPerTexel, new_view_origin); + new_view_origin[0] = floor(new_view_origin[0]); + new_view_origin[1] = floor(new_view_origin[1]); + new_view_origin[2] = floor(new_view_origin[2]); + VectorScale(new_view_origin, worldUnitsPerTexel, new_view_origin); + + tr.viewParms.world.modelViewMatrix[12] = new_view_origin[0]; + tr.viewParms.world.modelViewMatrix[13] = new_view_origin[1]; + tr.viewParms.world.modelViewMatrix[14] = new_view_origin[2]; + const int firstDrawSurf = tr.refdef.numDrawSurfs; R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); R_SortAndSubmitDrawSurfs( From dc0d180e2ac4a6e4ad1805150987670505b2e2fb Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 Sep 2020 11:14:18 +0200 Subject: [PATCH 532/708] Fix SDL includes --- lib/SDL2/include/SDL_config.h | 257 +++---------------------- lib/SDL2/include/SDL_config.h.cmake | 122 ++++++++---- lib/SDL2/include/SDL_config.h.in | 117 +++++++---- lib/SDL2/include/SDL_config_android.h | 46 +++-- lib/SDL2/include/SDL_config_iphoneos.h | 70 +++++-- lib/SDL2/include/SDL_config_macosx.h | 107 +++++++--- lib/SDL2/include/SDL_config_minimal.h | 5 +- lib/SDL2/include/SDL_config_os2.h | 180 +++++++++++++++++ lib/SDL2/include/SDL_config_pandora.h | 33 ++-- lib/SDL2/include/SDL_config_psp.h | 52 +++-- lib/SDL2/include/SDL_config_windows.h | 89 ++++++--- lib/SDL2/include/SDL_config_winrt.h | 91 +++++---- lib/SDL2/include/SDL_config_wiz.h | 80 +++++--- lib/SDL2/include/SDL_copying.h | 2 +- lib/SDL2/include/SDL_metal.h | 91 +++++++++ lib/SDL2/include/SDL_sensor.h | 251 ++++++++++++++++++++++++ 16 files changed, 1118 insertions(+), 475 deletions(-) create mode 100644 lib/SDL2/include/SDL_config_os2.h create mode 100644 lib/SDL2/include/SDL_metal.h create mode 100644 lib/SDL2/include/SDL_sensor.h diff --git a/lib/SDL2/include/SDL_config.h b/lib/SDL2/include/SDL_config.h index f269bfc04b..3937dbc388 100644 --- a/lib/SDL2/include/SDL_config.h +++ b/lib/SDL2/include/SDL_config.h @@ -19,242 +19,37 @@ 3. This notice may not be removed or altered from any source distribution. */ -#ifndef SDL_config_windows_h_ -#define SDL_config_windows_h_ +#ifndef SDL_config_h_ #define SDL_config_h_ #include "SDL_platform.h" -/* This is a set of defines to configure the SDL features */ - -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 -#elif defined(_MSC_VER) -typedef signed __int8 int8_t; -typedef unsigned __int8 uint8_t; -typedef signed __int16 int16_t; -typedef unsigned __int16 uint16_t; -typedef signed __int32 int32_t; -typedef unsigned __int32 uint32_t; -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; -#ifndef _UINTPTR_T_DEFINED -#ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -#else -typedef unsigned int uintptr_t; -#endif -#define _UINTPTR_T_DEFINED -#endif -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) -#define DWORD_PTR DWORD -#endif -#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) -#define LONG_PTR LONG -#endif -#else /* !__GNUC__ && !_MSC_VER */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -#ifndef _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED_ -typedef unsigned int size_t; -#endif -typedef unsigned int uintptr_t; -#endif /* __GNUC__ || _MSC_VER */ -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - -#ifdef _WIN64 -# define SIZEOF_VOIDP 8 -#else -# define SIZEOF_VOIDP 4 -#endif - -#define HAVE_DDRAW_H 1 -#define HAVE_DINPUT_H 1 -#define HAVE_DSOUND_H 1 -#define HAVE_DXGI_H 1 -#define HAVE_XINPUT_H 1 -#define HAVE_MMDEVICEAPI_H 1 -#define HAVE_AUDIOCLIENT_H 1 - -/* This is disabled by default to avoid C runtime dependencies and manifest requirements */ -#ifdef HAVE_LIBC -/* Useful headers */ -#define STDC_HEADERS 1 -#define HAVE_CTYPE_H 1 -#define HAVE_FLOAT_H 1 -#define HAVE_LIMITS_H 1 -#define HAVE_MATH_H 1 -#define HAVE_SIGNAL_H 1 -#define HAVE_STDIO_H 1 -#define HAVE_STRING_H 1 - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE__STRREV 1 -/* These functions have security warnings, so we won't use them */ -/* #undef HAVE__STRUPR */ -/* #undef HAVE__STRLWR */ -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -/* #undef HAVE_STRTOK_R */ -#if defined(_MSC_VER) -#define HAVE_STRTOK_S 1 -#endif -/* These functions have security warnings, so we won't use them */ -/* #undef HAVE__LTOA */ -/* #undef HAVE__ULTOA */ -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -#define HAVE__STRICMP 1 -#define HAVE__STRNICMP 1 -#define HAVE_ACOS 1 -#define HAVE_ACOSF 1 -#define HAVE_ASIN 1 -#define HAVE_ASINF 1 -#define HAVE_ATAN 1 -#define HAVE_ATANF 1 -#define HAVE_ATAN2 1 -#define HAVE_ATAN2F 1 -#define HAVE_CEILF 1 -#define HAVE__COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_EXP 1 -#define HAVE_EXPF 1 -#define HAVE_FABS 1 -#define HAVE_FABSF 1 -#define HAVE_FLOOR 1 -#define HAVE_FLOORF 1 -#define HAVE_FMOD 1 -#define HAVE_FMODF 1 -#define HAVE_LOG 1 -#define HAVE_LOGF 1 -#define HAVE_LOG10 1 -#define HAVE_LOG10F 1 -#define HAVE_POW 1 -#define HAVE_POWF 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 -#if defined(_MSC_VER) -/* These functions were added with the VC++ 2013 C runtime library */ -#if _MSC_VER >= 1800 -#define HAVE_STRTOLL 1 -#define HAVE_VSSCANF 1 -#define HAVE_SCALBN 1 -#define HAVE_SCALBNF 1 -#endif -/* This function is available with at least the VC++ 2008 C runtime library */ -#if _MSC_VER >= 1400 -#define HAVE__FSEEKI64 1 -#endif -#endif -#if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) -#define HAVE_M_PI 1 -#endif +/** + * \file SDL_config.h + */ + +/* Add any platform that doesn't build using the configure system. */ +#if defined(__WIN32__) +#include "SDL_config_windows.h" +#elif defined(__WINRT__) +#include "SDL_config_winrt.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__IPHONEOS__) +#include "SDL_config_iphoneos.h" +#elif defined(__ANDROID__) +#include "SDL_config_android.h" +#elif defined(__PSP__) +#include "SDL_config_psp.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" #else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#endif - -/* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_WASAPI 1 -#define SDL_AUDIO_DRIVER_DSOUND 1 -#define SDL_AUDIO_DRIVER_WINMM 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable various input drivers */ -#define SDL_JOYSTICK_DINPUT 1 -#define SDL_JOYSTICK_XINPUT 1 -#define SDL_JOYSTICK_HIDAPI 1 -#define SDL_HAPTIC_DINPUT 1 -#define SDL_HAPTIC_XINPUT 1 - -/* Enable the dummy sensor driver */ -#define SDL_SENSOR_DUMMY 1 - -/* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 - -/* Enable various threading systems */ -#define SDL_THREAD_WINDOWS 1 - -/* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 - -/* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -#define SDL_VIDEO_DRIVER_WINDOWS 1 - -#ifndef SDL_VIDEO_RENDER_D3D -#define SDL_VIDEO_RENDER_D3D 1 -#endif -#ifndef SDL_VIDEO_RENDER_D3D11 -#define SDL_VIDEO_RENDER_D3D11 0 -#endif - -/* Enable OpenGL support */ -#ifndef SDL_VIDEO_OPENGL -#define SDL_VIDEO_OPENGL 1 -#endif -#ifndef SDL_VIDEO_OPENGL_WGL -#define SDL_VIDEO_OPENGL_WGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL -#define SDL_VIDEO_RENDER_OGL 1 -#endif -#ifndef SDL_VIDEO_RENDER_OGL_ES2 -#define SDL_VIDEO_RENDER_OGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_ES2 -#define SDL_VIDEO_OPENGL_ES2 1 -#endif -#ifndef SDL_VIDEO_OPENGL_EGL -#define SDL_VIDEO_OPENGL_EGL 1 -#endif - -/* Enable Vulkan support */ -#define SDL_VIDEO_VULKAN 1 - -/* Enable system power support */ -#define SDL_POWER_WINDOWS 1 - -/* Enable filesystem support */ -#define SDL_FILESYSTEM_WINDOWS 1 +/* This is a minimal configuration just to get SDL running on new platforms. */ +#include "SDL_config_minimal.h" +#endif /* platform config */ -/* Enable assembly routines (Win64 doesn't have inline asm) */ -#ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 +#ifdef USING_GENERATED_CONFIG_H +#error Wrong SDL_config.h, check your include path? #endif -#endif /* SDL_config_windows_h_ */ +#endif /* SDL_config_h_ */ diff --git a/lib/SDL2/include/SDL_config.h.cmake b/lib/SDL2/include/SDL_config.h.cmake index c57266c413..d6ea31eacd 100644 --- a/lib/SDL2/include/SDL_config.h.cmake +++ b/lib/SDL2/include/SDL_config.h.cmake @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -47,46 +47,32 @@ #cmakedefine HAVE_GCC_ATOMICS @HAVE_GCC_ATOMICS@ #cmakedefine HAVE_GCC_SYNC_LOCK_TEST_AND_SET @HAVE_GCC_SYNC_LOCK_TEST_AND_SET@ -#cmakedefine HAVE_D3D_H @HAVE_D3D_H@ -#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@ -#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@ -#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@ -#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@ -#cmakedefine HAVE_XAUDIO2_H @HAVE_XAUDIO2_H@ -#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@ -#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ -#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@ -#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@ - /* Comment this if you want to build without any C library requirements */ #cmakedefine HAVE_LIBC 1 #if HAVE_LIBC /* Useful headers */ -#cmakedefine HAVE_ALLOCA_H 1 -#cmakedefine HAVE_SYS_TYPES_H 1 -#cmakedefine HAVE_STDIO_H 1 #cmakedefine STDC_HEADERS 1 -#cmakedefine HAVE_STDLIB_H 1 -#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_ALLOCA_H 1 +#cmakedefine HAVE_CTYPE_H 1 +#cmakedefine HAVE_FLOAT_H 1 +#cmakedefine HAVE_ICONV_H 1 +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_LIMITS_H 1 #cmakedefine HAVE_MALLOC_H 1 +#cmakedefine HAVE_MATH_H 1 #cmakedefine HAVE_MEMORY_H 1 -#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_SIGNAL_H 1 +#cmakedefine HAVE_STDARG_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_STDIO_H 1 +#cmakedefine HAVE_STDLIB_H 1 #cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 #cmakedefine HAVE_WCHAR_H 1 -#cmakedefine HAVE_INTTYPES_H 1 -#cmakedefine HAVE_STDINT_H 1 -#cmakedefine HAVE_CTYPE_H 1 -#cmakedefine HAVE_MATH_H 1 -#cmakedefine HAVE_ICONV_H 1 -#cmakedefine HAVE_SIGNAL_H 1 -#cmakedefine HAVE_ALTIVEC_H 1 #cmakedefine HAVE_PTHREAD_NP_H 1 -#cmakedefine HAVE_LIBUDEV_H 1 -#cmakedefine HAVE_DBUS_DBUS_H 1 -#cmakedefine HAVE_IBUS_IBUS_H 1 -#cmakedefine HAVE_FCITX_FRONTEND_H 1 -#cmakedefine HAVE_LIBSAMPLERATE_H 1 +#cmakedefine HAVE_LIBUNWIND_H 1 /* C library functions */ #cmakedefine HAVE_MALLOC 1 @@ -110,11 +96,13 @@ #cmakedefine HAVE_WCSLEN 1 #cmakedefine HAVE_WCSLCPY 1 #cmakedefine HAVE_WCSLCAT 1 +#cmakedefine HAVE_WCSDUP 1 +#cmakedefine HAVE_WCSSTR 1 #cmakedefine HAVE_WCSCMP 1 +#cmakedefine HAVE_WCSNCMP 1 #cmakedefine HAVE_STRLEN 1 #cmakedefine HAVE_STRLCPY 1 #cmakedefine HAVE_STRLCAT 1 -#cmakedefine HAVE_STRDUP 1 #cmakedefine HAVE__STRREV 1 #cmakedefine HAVE__STRUPR 1 #cmakedefine HAVE__STRLWR 1 @@ -123,6 +111,8 @@ #cmakedefine HAVE_STRCHR 1 #cmakedefine HAVE_STRRCHR 1 #cmakedefine HAVE_STRSTR 1 +#cmakedefine HAVE_STRTOK_R 1 +#cmakedefine HAVE_STRTOK_S 1 #cmakedefine HAVE_ITOA 1 #cmakedefine HAVE__LTOA 1 #cmakedefine HAVE__UITOA 1 @@ -142,22 +132,40 @@ #cmakedefine HAVE_STRCASECMP 1 #cmakedefine HAVE__STRNICMP 1 #cmakedefine HAVE_STRNCASECMP 1 +#cmakedefine HAVE_SSCANF 1 #cmakedefine HAVE_VSSCANF 1 #cmakedefine HAVE_VSNPRINTF 1 #cmakedefine HAVE_M_PI 1 -#cmakedefine HAVE_ATAN 1 -#cmakedefine HAVE_ATAN2 1 #cmakedefine HAVE_ACOS 1 +#cmakedefine HAVE_ACOSF 1 #cmakedefine HAVE_ASIN 1 +#cmakedefine HAVE_ASINF 1 +#cmakedefine HAVE_ATAN 1 +#cmakedefine HAVE_ATANF 1 +#cmakedefine HAVE_ATAN2 1 +#cmakedefine HAVE_ATAN2F 1 #cmakedefine HAVE_CEIL 1 +#cmakedefine HAVE_CEILF 1 #cmakedefine HAVE_COPYSIGN 1 +#cmakedefine HAVE_COPYSIGNF 1 #cmakedefine HAVE_COS 1 #cmakedefine HAVE_COSF 1 +#cmakedefine HAVE_EXP 1 +#cmakedefine HAVE_EXPF 1 #cmakedefine HAVE_FABS 1 +#cmakedefine HAVE_FABSF 1 #cmakedefine HAVE_FLOOR 1 +#cmakedefine HAVE_FLOORF 1 +#cmakedefine HAVE_FMOD 1 +#cmakedefine HAVE_FMODF 1 #cmakedefine HAVE_LOG 1 +#cmakedefine HAVE_LOGF 1 +#cmakedefine HAVE_LOG10 1 +#cmakedefine HAVE_LOG10F 1 #cmakedefine HAVE_POW 1 +#cmakedefine HAVE_POWF 1 #cmakedefine HAVE_SCALBN 1 +#cmakedefine HAVE_SCALBNF 1 #cmakedefine HAVE_SIN 1 #cmakedefine HAVE_SINF 1 #cmakedefine HAVE_SQRT 1 @@ -182,15 +190,39 @@ #cmakedefine HAVE_SEM_TIMEDWAIT 1 #cmakedefine HAVE_GETAUXVAL 1 #cmakedefine HAVE_POLL 1 +#cmakedefine HAVE__EXIT 1 #elif __WIN32__ #cmakedefine HAVE_STDARG_H 1 #cmakedefine HAVE_STDDEF_H 1 +#cmakedefine HAVE_FLOAT_H 1 #else /* We may need some replacement for stdarg.h here */ #include #endif /* HAVE_LIBC */ +#cmakedefine HAVE_ALTIVEC_H 1 +#cmakedefine HAVE_DBUS_DBUS_H 1 +#cmakedefine HAVE_FCITX_FRONTEND_H 1 +#cmakedefine HAVE_IBUS_IBUS_H 1 +#cmakedefine HAVE_IMMINTRIN_H 1 +#cmakedefine HAVE_LIBSAMPLERATE_H 1 +#cmakedefine HAVE_LIBUDEV_H 1 + +#cmakedefine HAVE_D3D_H @HAVE_D3D_H@ +#cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@ +#cmakedefine HAVE_DDRAW_H @HAVE_DDRAW_H@ +#cmakedefine HAVE_DSOUND_H @HAVE_DSOUND_H@ +#cmakedefine HAVE_DINPUT_H @HAVE_DINPUT_H@ +#cmakedefine HAVE_XINPUT_H @HAVE_XINPUT_H@ +#cmakedefine HAVE_DXGI_H @HAVE_DXGI_H@ + +#cmakedefine HAVE_MMDEVICEAPI_H @HAVE_MMDEVICEAPI_H@ +#cmakedefine HAVE_AUDIOCLIENT_H @HAVE_AUDIOCLIENT_H@ + +#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@ +#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@ + /* SDL internal assertion support */ #cmakedefine SDL_DEFAULT_ASSERT_LEVEL @SDL_DEFAULT_ASSERT_LEVEL@ @@ -202,6 +234,7 @@ #cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@ #cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@ #cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@ +#cmakedefine SDL_SENSOR_DISABLED @SDL_SENSOR_DISABLED@ #cmakedefine SDL_LOADSO_DISABLED @SDL_LOADSO_DISABLED@ #cmakedefine SDL_RENDER_DISABLED @SDL_RENDER_DISABLED@ #cmakedefine SDL_THREADS_DISABLED @SDL_THREADS_DISABLED@ @@ -242,7 +275,6 @@ #cmakedefine SDL_AUDIO_DRIVER_SUNAUDIO @SDL_AUDIO_DRIVER_SUNAUDIO@ #cmakedefine SDL_AUDIO_DRIVER_WASAPI @SDL_AUDIO_DRIVER_WASAPI@ #cmakedefine SDL_AUDIO_DRIVER_WINMM @SDL_AUDIO_DRIVER_WINMM@ -#cmakedefine SDL_AUDIO_DRIVER_XAUDIO2 @SDL_AUDIO_DRIVER_XAUDIO2@ /* Enable various input drivers */ #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@ @@ -259,6 +291,7 @@ #cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ #cmakedefine SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H@ +#cmakedefine SDL_JOYSTICK_HIDAPI @SDL_JOYSTICK_HIDAPI@ #cmakedefine SDL_JOYSTICK_EMSCRIPTEN @SDL_JOYSTICK_EMSCRIPTEN@ #cmakedefine SDL_HAPTIC_DUMMY @SDL_HAPTIC_DUMMY@ #cmakedefine SDL_HAPTIC_LINUX @SDL_HAPTIC_LINUX@ @@ -266,6 +299,12 @@ #cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@ #cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@ #cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@ +#cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@ + +/* Enable various sensor drivers */ +#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@ +#cmakedefine SDL_SENSOR_COREMOTION @SDL_SENSOR_COREMOTION@ +#cmakedefine SDL_SENSOR_DUMMY @SDL_SENSOR_DUMMY@ /* Enable various shared object loading systems */ #cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@ @@ -290,9 +329,11 @@ #cmakedefine SDL_VIDEO_DRIVER_ANDROID @SDL_VIDEO_DRIVER_ANDROID@ #cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@ #cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@ +#cmakedefine SDL_VIDEO_DRIVER_UIKIT @SDL_VIDEO_DRIVER_UIKIT@ #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@ #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@ #cmakedefine SDL_VIDEO_DRIVER_DUMMY @SDL_VIDEO_DRIVER_DUMMY@ +#cmakedefine SDL_VIDEO_DRIVER_OFFSCREEN @SDL_VIDEO_DRIVER_OFFSCREEN@ #cmakedefine SDL_VIDEO_DRIVER_WINDOWS @SDL_VIDEO_DRIVER_WINDOWS@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND @SDL_VIDEO_DRIVER_WAYLAND@ #cmakedefine SDL_VIDEO_DRIVER_RPI @SDL_VIDEO_DRIVER_RPI@ @@ -309,9 +350,6 @@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR@ #cmakedefine SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON@ -#cmakedefine SDL_VIDEO_DRIVER_MIR @SDL_VIDEO_DRIVER_MIR@ -#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC @SDL_VIDEO_DRIVER_MIR_DYNAMIC@ -#cmakedefine SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON @SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON@ #cmakedefine SDL_VIDEO_DRIVER_EMSCRIPTEN @SDL_VIDEO_DRIVER_EMSCRIPTEN@ #cmakedefine SDL_VIDEO_DRIVER_X11 @SDL_VIDEO_DRIVER_X11@ #cmakedefine SDL_VIDEO_DRIVER_X11_DYNAMIC @SDL_VIDEO_DRIVER_X11_DYNAMIC@ @@ -341,6 +379,7 @@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES @SDL_VIDEO_RENDER_OGL_ES@ #cmakedefine SDL_VIDEO_RENDER_OGL_ES2 @SDL_VIDEO_RENDER_OGL_ES2@ #cmakedefine SDL_VIDEO_RENDER_DIRECTFB @SDL_VIDEO_RENDER_DIRECTFB@ +#cmakedefine SDL_VIDEO_RENDER_METAL @SDL_VIDEO_RENDER_METAL@ /* Enable OpenGL support */ #cmakedefine SDL_VIDEO_OPENGL @SDL_VIDEO_OPENGL@ @@ -357,11 +396,15 @@ /* Enable Vulkan support */ #cmakedefine SDL_VIDEO_VULKAN @SDL_VIDEO_VULKAN@ +/* Enable Metal support */ +#cmakedefine SDL_VIDEO_METAL @SDL_VIDEO_METAL@ + /* Enable system power support */ #cmakedefine SDL_POWER_ANDROID @SDL_POWER_ANDROID@ #cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@ #cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@ #cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@ +#cmakedefine SDL_POWER_UIKIT @SDL_POWER_UIKIT@ #cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@ #cmakedefine SDL_POWER_EMSCRIPTEN @SDL_POWER_EMSCRIPTEN@ #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@ @@ -378,11 +421,16 @@ /* Enable assembly routines */ #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@ #cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@ +#cmakedefine SDL_ARM_SIMD_BLITTERS @SDL_ARM_SIMD_BLITTERS@ +#cmakedefine SDL_ARM_NEON_BLITTERS @SDL_ARM_NEON_BLITTERS@ /* Enable dynamic libsamplerate support */ #cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@ /* Platform specific definitions */ +#cmakedefine SDL_IPHONE_KEYBOARD @SDL_IPHONE_KEYBOARD@ +#cmakedefine SDL_IPHONE_LAUNCHSCREEN @SDL_IPHONE_LAUNCHSCREEN@ + #if !defined(__WIN32__) # if !defined(_STDINT_H_) && !defined(_STDINT_H) && !defined(HAVE_STDINT_H) && !defined(_HAVE_STDINT_H) typedef unsigned int size_t; diff --git a/lib/SDL2/include/SDL_config.h.in b/lib/SDL2/include/SDL_config.h.in index 8b3d20880b..f769e3cf43 100644 --- a/lib/SDL2/include/SDL_config.h.in +++ b/lib/SDL2/include/SDL_config.h.in @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,7 +33,7 @@ /* Make sure that this isn't included by Visual C++ */ #ifdef _MSC_VER -#error You should run hg revert SDL_config.h +#error You should run hg revert SDL_config.h #endif /* C language features */ @@ -50,43 +50,32 @@ #undef HAVE_GCC_ATOMICS #undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET -#undef HAVE_DDRAW_H -#undef HAVE_DINPUT_H -#undef HAVE_DSOUND_H -#undef HAVE_DXGI_H -#undef HAVE_XINPUT_H -#undef HAVE_XINPUT_GAMEPAD_EX -#undef HAVE_XINPUT_STATE_EX - /* Comment this if you want to build without any C library requirements */ #undef HAVE_LIBC #if HAVE_LIBC /* Useful headers */ -#undef HAVE_ALLOCA_H -#undef HAVE_SYS_TYPES_H -#undef HAVE_STDIO_H #undef STDC_HEADERS -#undef HAVE_STDLIB_H -#undef HAVE_STDARG_H +#undef HAVE_ALLOCA_H +#undef HAVE_CTYPE_H +#undef HAVE_FLOAT_H +#undef HAVE_ICONV_H +#undef HAVE_INTTYPES_H +#undef HAVE_LIMITS_H #undef HAVE_MALLOC_H +#undef HAVE_MATH_H #undef HAVE_MEMORY_H -#undef HAVE_STRING_H +#undef HAVE_SIGNAL_H +#undef HAVE_STDARG_H +#undef HAVE_STDINT_H +#undef HAVE_STDIO_H +#undef HAVE_STDLIB_H #undef HAVE_STRINGS_H +#undef HAVE_STRING_H +#undef HAVE_SYS_TYPES_H #undef HAVE_WCHAR_H -#undef HAVE_INTTYPES_H -#undef HAVE_STDINT_H -#undef HAVE_CTYPE_H -#undef HAVE_MATH_H -#undef HAVE_ICONV_H -#undef HAVE_SIGNAL_H -#undef HAVE_ALTIVEC_H #undef HAVE_PTHREAD_NP_H -#undef HAVE_LIBUDEV_H -#undef HAVE_DBUS_DBUS_H -#undef HAVE_IBUS_IBUS_H -#undef HAVE_FCITX_FRONTEND_H -#undef HAVE_LIBSAMPLERATE_H +#undef HAVE_LIBUNWIND_H /* C library functions */ #undef HAVE_MALLOC @@ -110,11 +99,13 @@ #undef HAVE_WCSLEN #undef HAVE_WCSLCPY #undef HAVE_WCSLCAT +#undef HAVE_WCSDUP +#undef HAVE_WCSSTR #undef HAVE_WCSCMP +#undef HAVE_WCSNCMP #undef HAVE_STRLEN #undef HAVE_STRLCPY #undef HAVE_STRLCAT -#undef HAVE_STRDUP #undef HAVE__STRREV #undef HAVE__STRUPR #undef HAVE__STRLWR @@ -123,6 +114,8 @@ #undef HAVE_STRCHR #undef HAVE_STRRCHR #undef HAVE_STRSTR +#undef HAVE_STRTOK_R +#undef HAVE_STRTOK_S #undef HAVE_ITOA #undef HAVE__LTOA #undef HAVE__UITOA @@ -147,19 +140,36 @@ #undef HAVE_SNPRINTF #undef HAVE_VSNPRINTF #undef HAVE_M_PI -#undef HAVE_ATAN -#undef HAVE_ATAN2 #undef HAVE_ACOS +#undef HAVE_ACOSF #undef HAVE_ASIN +#undef HAVE_ASINF +#undef HAVE_ATAN +#undef HAVE_ATANF +#undef HAVE_ATAN2 +#undef HAVE_ATAN2F #undef HAVE_CEIL +#undef HAVE_CEILF #undef HAVE_COPYSIGN +#undef HAVE_COPYSIGNF #undef HAVE_COS #undef HAVE_COSF +#undef HAVE_EXP +#undef HAVE_EXPF #undef HAVE_FABS +#undef HAVE_FABSF #undef HAVE_FLOOR +#undef HAVE_FLOORF +#undef HAVE_FMOD +#undef HAVE_FMODF #undef HAVE_LOG +#undef HAVE_LOGF +#undef HAVE_LOG10 +#undef HAVE_LOG10F #undef HAVE_POW +#undef HAVE_POWF #undef HAVE_SCALBN +#undef HAVE_SCALBNF #undef HAVE_SIN #undef HAVE_SINF #undef HAVE_SQRT @@ -184,13 +194,32 @@ #undef HAVE_SEM_TIMEDWAIT #undef HAVE_GETAUXVAL #undef HAVE_POLL +#undef HAVE__EXIT #else -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_STDINT_H 1 #endif /* HAVE_LIBC */ +#undef HAVE_ALTIVEC_H +#undef HAVE_DBUS_DBUS_H +#undef HAVE_FCITX_FRONTEND_H +#undef HAVE_IBUS_IBUS_H +#undef HAVE_IMMINTRIN_H +#undef HAVE_LIBSAMPLERATE_H +#undef HAVE_LIBUDEV_H + +#undef HAVE_DDRAW_H +#undef HAVE_DINPUT_H +#undef HAVE_DSOUND_H +#undef HAVE_DXGI_H +#undef HAVE_XINPUT_H +#undef HAVE_MMDEVICEAPI_H +#undef HAVE_AUDIOCLIENT_H +#undef HAVE_XINPUT_GAMEPAD_EX +#undef HAVE_XINPUT_STATE_EX + /* SDL internal assertion support */ #undef SDL_DEFAULT_ASSERT_LEVEL @@ -202,6 +231,7 @@ #undef SDL_FILE_DISABLED #undef SDL_JOYSTICK_DISABLED #undef SDL_HAPTIC_DISABLED +#undef SDL_SENSOR_DISABLED #undef SDL_LOADSO_DISABLED #undef SDL_RENDER_DISABLED #undef SDL_THREADS_DISABLED @@ -243,7 +273,6 @@ #undef SDL_AUDIO_DRIVER_SUNAUDIO #undef SDL_AUDIO_DRIVER_WASAPI #undef SDL_AUDIO_DRIVER_WINMM -#undef SDL_AUDIO_DRIVER_XAUDIO2 /* Enable various input drivers */ #undef SDL_INPUT_LINUXEV @@ -259,13 +288,19 @@ #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H +#undef SDL_JOYSTICK_HIDAPI #undef SDL_JOYSTICK_EMSCRIPTEN #undef SDL_HAPTIC_DUMMY +#undef SDL_HAPTIC_ANDROID #undef SDL_HAPTIC_LINUX #undef SDL_HAPTIC_IOKIT #undef SDL_HAPTIC_DINPUT #undef SDL_HAPTIC_XINPUT +/* Enable various sensor drivers */ +#undef SDL_SENSOR_ANDROID +#undef SDL_SENSOR_DUMMY + /* Enable various shared object loading systems */ #undef SDL_LOADSO_DLOPEN #undef SDL_LOADSO_DUMMY @@ -297,9 +332,6 @@ #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR #undef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON -#undef SDL_VIDEO_DRIVER_MIR -#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC -#undef SDL_VIDEO_DRIVER_MIR_DYNAMIC_XKBCOMMON #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_RPI #undef SDL_VIDEO_DRIVER_KMSDRM @@ -338,6 +370,7 @@ #undef SDL_VIDEO_RENDER_OGL_ES #undef SDL_VIDEO_RENDER_OGL_ES2 #undef SDL_VIDEO_RENDER_DIRECTFB +#undef SDL_VIDEO_RENDER_METAL /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL @@ -354,6 +387,9 @@ /* Enable Vulkan support */ #undef SDL_VIDEO_VULKAN +/* Enable Metal support */ +#undef SDL_VIDEO_METAL + /* Enable system power support */ #undef SDL_POWER_LINUX #undef SDL_POWER_WINDOWS @@ -376,6 +412,8 @@ /* Enable assembly routines */ #undef SDL_ASSEMBLY_ROUTINES #undef SDL_ALTIVEC_BLITTERS +#undef SDL_ARM_SIMD_BLITTERS +#undef SDL_ARM_NEON_BLITTERS /* Enable ime support */ #undef SDL_USE_IME @@ -383,6 +421,9 @@ /* Enable dynamic udev support */ #undef SDL_UDEV_DYNAMIC +/* Enable dynamic libusb support */ +#undef SDL_LIBUSB_DYNAMIC + /* Enable dynamic libsamplerate support */ #undef SDL_LIBSAMPLERATE_DYNAMIC diff --git a/lib/SDL2/include/SDL_config_android.h b/lib/SDL2/include/SDL_config_android.h index 361bad8b77..d057e17644 100644 --- a/lib/SDL2/include/SDL_config_android.h +++ b/lib/SDL2/include/SDL_config_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -35,16 +35,17 @@ #define HAVE_GCC_ATOMICS 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -67,10 +68,10 @@ #define HAVE_STRLEN 1 #define HAVE_STRLCPY 1 #define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 +#define HAVE_STRTOK_R 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOLL 1 @@ -84,20 +85,36 @@ #define HAVE_STRNCASECMP 1 #define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 -#define HAVE_M_PI 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 #define HAVE_ATAN 1 +#define HAVE_ATANF 1 #define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 +#define HAVE_ATAN2F 1 #define HAVE_CEIL 1 +#define HAVE_CEILF 1 #define HAVE_COPYSIGN 1 +#define HAVE_COPYSIGNF 1 #define HAVE_COS 1 #define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 #define HAVE_FABS 1 +#define HAVE_FABSF 1 #define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 #define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 #define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 @@ -108,18 +125,23 @@ #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 #define HAVE_SYSCONF 1 -#define HAVE_CLOCK_GETTIME 1 +#define HAVE_CLOCK_GETTIME 1 #define SIZEOF_VOIDP 4 /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_ANDROID 1 +#define SDL_AUDIO_DRIVER_OPENSLES 1 #define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ #define SDL_JOYSTICK_ANDROID 1 +#define SDL_JOYSTICK_HIDAPI 1 #define SDL_HAPTIC_ANDROID 1 +/* Enable sensor driver */ +#define SDL_SENSOR_ANDROID 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_DLOPEN 1 diff --git a/lib/SDL2/include/SDL_config_iphoneos.h b/lib/SDL2/include/SDL_config_iphoneos.h index deea030466..38929a8b3a 100644 --- a/lib/SDL2/include/SDL_config_iphoneos.h +++ b/lib/SDL2/include/SDL_config_iphoneos.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,16 +33,19 @@ #define HAVE_GCC_ATOMICS 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 +/* The libunwind functions are only available on x86 */ +/* #undef HAVE_LIBUNWIND_H */ /* C library functions */ #define HAVE_MALLOC 1 @@ -65,10 +68,10 @@ #define HAVE_STRLEN 1 #define HAVE_STRLCPY 1 #define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 +#define HAVE_STRTOK_R 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOLL 1 @@ -83,19 +86,36 @@ #define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 #define HAVE_M_PI 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 #define HAVE_ATAN 1 +#define HAVE_ATANF 1 #define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 +#define HAVE_ATAN2F 1 #define HAVE_CEIL 1 +#define HAVE_CEILF 1 #define HAVE_COPYSIGN 1 +#define HAVE_COPYSIGNF 1 #define HAVE_COS 1 #define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 #define HAVE_FABS 1 +#define HAVE_FABSF 1 #define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 #define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 #define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 @@ -118,6 +138,14 @@ /* Enable MFi joystick support */ #define SDL_JOYSTICK_MFI 1 +#define SDL_JOYSTICK_HIDAPI 1 + +#ifdef __TVOS__ +#define SDL_SENSOR_DUMMY 1 +#else +/* Enable the CoreMotion sensor driver */ +#define SDL_SENSOR_COREMOTION 1 +#endif /* Enable Unix style SO loading */ #define SDL_LOADSO_DLOPEN 1 @@ -133,17 +161,29 @@ #define SDL_VIDEO_DRIVER_UIKIT 1 #define SDL_VIDEO_DRIVER_DUMMY 1 -/* enable OpenGL ES */ +/* Enable OpenGL ES */ #define SDL_VIDEO_OPENGL_ES2 1 #define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES2 1 -/* Enable Vulkan support */ -#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM // Only 64-bit devices have Metal -#define SDL_VIDEO_VULKAN 1 +/* Metal supported on 64-bit devices running iOS 8.0 and tvOS 9.0 and newer */ +#if !TARGET_OS_SIMULATOR && !TARGET_CPU_ARM && ((__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 90000)) +#define SDL_PLATFORM_SUPPORTS_METAL 1 #else -#define SDL_VIDEO_VULKAN 0 +#define SDL_PLATFORM_SUPPORTS_METAL 0 +#endif + +#if SDL_PLATFORM_SUPPORTS_METAL +#define SDL_VIDEO_RENDER_METAL 1 +#endif + +#if SDL_PLATFORM_SUPPORTS_METAL +#define SDL_VIDEO_VULKAN 1 +#endif + +#if SDL_PLATFORM_SUPPORTS_METAL +#define SDL_VIDEO_METAL 1 #endif /* Enable system power support */ diff --git a/lib/SDL2/include/SDL_config_macosx.h b/lib/SDL2/include/SDL_config_macosx.h index 9b09899529..114134593c 100644 --- a/lib/SDL2/include/SDL_config_macosx.h +++ b/lib/SDL2/include/SDL_config_macosx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -37,16 +37,19 @@ #endif /* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_LIBUNWIND_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -68,10 +71,10 @@ #define HAVE_STRLEN 1 #define HAVE_STRLCPY 1 #define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 +#define HAVE_STRTOK_R 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOLL 1 @@ -85,15 +88,37 @@ #define HAVE_STRNCASECMP 1 #define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 +#define HAVE_ATAN 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2 1 +#define HAVE_ATAN2F 1 #define HAVE_CEIL 1 +#define HAVE_CEILF 1 #define HAVE_COPYSIGN 1 +#define HAVE_COPYSIGNF 1 #define HAVE_COS 1 #define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 #define HAVE_FABS 1 +#define HAVE_FABSF 1 #define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 #define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 #define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 @@ -105,10 +130,8 @@ #define HAVE_NANOSLEEP 1 #define HAVE_SYSCONF 1 #define HAVE_SYSCTLBYNAME 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 + +#define HAVE_GCC_ATOMICS 1 /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_COREAUDIO 1 @@ -117,8 +140,12 @@ /* Enable various input drivers */ #define SDL_JOYSTICK_IOKIT 1 +#define SDL_JOYSTICK_HIDAPI 1 #define SDL_HAPTIC_IOKIT 1 +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_DLOPEN 1 @@ -133,13 +160,13 @@ #define SDL_VIDEO_DRIVER_COCOA 1 #define SDL_VIDEO_DRIVER_DUMMY 1 #undef SDL_VIDEO_DRIVER_X11 -#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/usr/X11R6/lib/libXi.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC "/opt/X11/lib/libX11.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/opt/X11/lib/libXext.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/opt/X11/lib/libXinerama.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 "/opt/X11/lib/libXi.6.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/opt/X11/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/opt/X11/lib/libXss.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/opt/X11/lib/libXxf86vm.1.dylib" #define SDL_VIDEO_DRIVER_X11_XDBE 1 #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 #define SDL_VIDEO_DRIVER_X11_XRANDR 1 @@ -163,10 +190,35 @@ #define SDL_VIDEO_RENDER_OGL 1 #endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 1 +#endif + +/* Metal only supported on 64-bit architectures with 10.11+ */ +#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) +#define SDL_PLATFORM_SUPPORTS_METAL 1 +#else +#define SDL_PLATFORM_SUPPORTS_METAL 0 +#endif + +#ifndef SDL_VIDEO_RENDER_METAL +#if SDL_PLATFORM_SUPPORTS_METAL +#define SDL_VIDEO_RENDER_METAL 1 +#else +#define SDL_VIDEO_RENDER_METAL 0 +#endif +#endif + /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL #define SDL_VIDEO_OPENGL 1 #endif +#ifndef SDL_VIDEO_OPENGL_ES2 +#define SDL_VIDEO_OPENGL_ES2 1 +#endif +#ifndef SDL_VIDEO_OPENGL_EGL +#define SDL_VIDEO_OPENGL_EGL 1 +#endif #ifndef SDL_VIDEO_OPENGL_CGL #define SDL_VIDEO_OPENGL_CGL 1 #endif @@ -174,12 +226,21 @@ #define SDL_VIDEO_OPENGL_GLX 1 #endif -/* Enable Vulkan support */ -/* Metal/MoltenVK/Vulkan only supported on 64-bit architectures with 10.11+ */ -#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100) +/* Enable Vulkan and Metal support */ +#ifndef SDL_VIDEO_VULKAN +#if SDL_PLATFORM_SUPPORTS_METAL #define SDL_VIDEO_VULKAN 1 #else -#define SDL_VIDEO_VULKAN 0 +#define SDL_VIDEO_VULKAN 0 +#endif +#endif + +#ifndef SDL_VIDEO_METAL +#if SDL_PLATFORM_SUPPORTS_METAL +#define SDL_VIDEO_METAL 1 +#else +#define SDL_VIDEO_METAL 0 +#endif #endif /* Enable system power support */ diff --git a/lib/SDL2/include/SDL_config_minimal.h b/lib/SDL2/include/SDL_config_minimal.h index 31127006c5..b9c39584fc 100644 --- a/lib/SDL2/include/SDL_config_minimal.h +++ b/lib/SDL2/include/SDL_config_minimal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -64,6 +64,9 @@ typedef unsigned long uintptr_t; /* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ #define SDL_HAPTIC_DISABLED 1 +/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ +#define SDL_SENSOR_DISABLED 1 + /* Enable the stub shared object loader (src/loadso/dummy/\*.c) */ #define SDL_LOADSO_DISABLED 1 diff --git a/lib/SDL2/include/SDL_config_os2.h b/lib/SDL2/include/SDL_config_os2.h new file mode 100644 index 0000000000..f5799dce97 --- /dev/null +++ b/lib/SDL2/include/SDL_config_os2.h @@ -0,0 +1,180 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_config_os2_h_ +#define SDL_config_os2_h_ +#define SDL_config_h_ + +#include "SDL_platform.h" + +#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_DISK 1 + +#define SDL_POWER_DISABLED 1 +#define SDL_JOYSTICK_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 +/*#undef SDL_JOYSTICK_HIDAPI */ + +#define SDL_SENSOR_DUMMY 1 +#define SDL_VIDEO_DRIVER_DUMMY 1 + +/* Enable OpenGL support */ +/* #undef SDL_VIDEO_OPENGL */ + +/* Enable Vulkan support */ +/* #undef SDL_VIDEO_VULKAN */ + +#define SDL_LOADSO_DISABLED 1 +#define SDL_THREADS_DISABLED 1 +#define SDL_TIMERS_DISABLED 1 +#define SDL_FILESYSTEM_DUMMY 1 + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 + +/* #undef HAVE_LIBSAMPLERATE_H */ + +/* Enable dynamic libsamplerate support */ +/* #undef SDL_LIBSAMPLERATE_DYNAMIC */ + +#define HAVE_LIBC 1 + +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_WCHAR_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_SIGNAL_H 1 + +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#if defined(__WATCOMC__) +#define HAVE__FSEEKI64 1 +#define HAVE__FTELLI64 1 +#endif +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_SETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_WCSLEN 1 +#define HAVE_WCSLCPY 1 +#define HAVE_WCSLCAT 1 +#define HAVE_WCSCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_INDEX 1 +#define HAVE_RINDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_STRTOK_R */ +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE__I64TOA 1 +#define HAVE__UI64TOA 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_WCSLEN 1 +#define HAVE_WCSLCPY 1 +#define HAVE_WCSLCAT 1 +/* #define HAVE_WCSDUP 1 */ +/* #define wcsdup _wcsdup */ +#define HAVE_WCSSTR 1 +#define HAVE_WCSCMP 1 +#define HAVE_WCSNCMP 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_VSSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 +#define HAVE_ACOS 1 +/* #undef HAVE_ACOSF */ +#define HAVE_ASIN 1 +/* #undef HAVE_ASINF */ +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +/* #undef HAVE_ATAN2F */ +#define HAVE_CEIL 1 +/* #undef HAVE_CEILF */ +/* #undef HAVE_COPYSIGN */ +/* #undef HAVE_COPYSIGNF */ +#define HAVE_COS 1 +/* #undef HAVE_COSF */ +#define HAVE_EXP 1 +/* #undef HAVE_EXPF */ +#define HAVE_FABS 1 +/* #undef HAVE_FABSF */ +#define HAVE_FLOOR 1 +/* #undef HAVE_FLOORF */ +#define HAVE_FMOD 1 +/* #undef HAVE_FMODF */ +#define HAVE_LOG 1 +/* #undef HAVE_LOGF */ +#define HAVE_LOG10 1 +/* #undef HAVE_LOG10F */ +#define HAVE_POW 1 +/* #undef HAVE_POWF */ +#define HAVE_SIN 1 +/* #undef HAVE_SINF */ +/* #undef HAVE_SCALBN */ +/* #undef HAVE_SCALBNF */ +#define HAVE_SQRT 1 +/* #undef HAVE_SQRTF */ +#define HAVE_TAN 1 +/* #undef HAVE_TANF */ + +#endif /* SDL_config_os2_h_ */ diff --git a/lib/SDL2/include/SDL_config_pandora.h b/lib/SDL2/include/SDL_config_pandora.h index ea62fe59ac..bdc64c97c7 100644 --- a/lib/SDL2/include/SDL_config_pandora.h +++ b/lib/SDL2/include/SDL_config_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -36,22 +36,24 @@ #define SDL_BYTEORDER 1234 -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 #define HAVE_ICONV_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MATH_H 1 +#define HAVE_MEMORY_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 + #define HAVE_MALLOC 1 #define HAVE_CALLOC 1 #define HAVE_REALLOC 1 @@ -68,7 +70,6 @@ #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 @@ -89,9 +90,11 @@ #define HAVE_COPYSIGN 1 #define HAVE_COS 1 #define HAVE_COSF 1 +#define HAVE_EXP 1 #define HAVE_FABS 1 #define HAVE_FLOOR 1 #define HAVE_LOG 1 +#define HAVE_LOG10 1 #define HAVE_SCALBN 1 #define HAVE_SIN 1 #define HAVE_SINF 1 @@ -111,6 +114,8 @@ #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 + #define SDL_LOADSO_DLOPEN 1 #define SDL_THREAD_PTHREAD 1 diff --git a/lib/SDL2/include/SDL_config_psp.h b/lib/SDL2/include/SDL_config_psp.h index 28efb4c5c0..0cbb182e04 100644 --- a/lib/SDL2/include/SDL_config_psp.h +++ b/lib/SDL2/include/SDL_config_psp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -33,16 +33,17 @@ #define HAVE_GCC_ATOMICS 1 -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -65,7 +66,6 @@ #define HAVE_STRLEN 1 #define HAVE_STRLCPY 1 #define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 @@ -83,19 +83,36 @@ #define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 #define HAVE_M_PI 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 #define HAVE_ATAN 1 +#define HAVE_ATANF 1 #define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 +#define HAVE_ATAN2F 1 #define HAVE_CEIL 1 +#define HAVE_CEILF 1 #define HAVE_COPYSIGN 1 +#define HAVE_COPYSIGNF 1 #define HAVE_COS 1 #define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 #define HAVE_FABS 1 +#define HAVE_FABSF 1 #define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 #define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 #define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 #define HAVE_SIN 1 #define HAVE_SINF 1 #define HAVE_SQRT 1 @@ -111,22 +128,25 @@ /* PSP isn't that sophisticated */ #define LACKS_SYS_MMAN_H 1 -/* Enable the stub thread support (src/thread/psp/\*.c) */ +/* Enable the PSP thread support (src/thread/psp/\*.c) */ #define SDL_THREAD_PSP 1 -/* Enable the stub timer support (src/timer/psp/\*.c) */ +/* Enable the PSP timer support (src/timer/psp/\*.c) */ #define SDL_TIMERS_PSP 1 -/* Enable the stub joystick driver (src/joystick/psp/\*.c) */ +/* Enable the PSP joystick driver (src/joystick/psp/\*.c) */ #define SDL_JOYSTICK_PSP 1 -/* Enable the stub audio driver (src/audio/psp/\*.c) */ +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + +/* Enable the PSP audio driver (src/audio/psp/\*.c) */ #define SDL_AUDIO_DRIVER_PSP 1 -/* PSP video dirver */ +/* PSP video driver */ #define SDL_VIDEO_DRIVER_PSP 1 -/* PSP render dirver */ +/* PSP render driver */ #define SDL_VIDEO_RENDER_PSP 1 #define SDL_POWER_PSP 1 diff --git a/lib/SDL2/include/SDL_config_windows.h b/lib/SDL2/include/SDL_config_windows.h index 2456c843fe..f269bfc04b 100644 --- a/lib/SDL2/include/SDL_config_windows.h +++ b/lib/SDL2/include/SDL_config_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -82,16 +82,20 @@ typedef unsigned int uintptr_t; #define HAVE_DSOUND_H 1 #define HAVE_DXGI_H 1 #define HAVE_XINPUT_H 1 +#define HAVE_MMDEVICEAPI_H 1 +#define HAVE_AUDIOCLIENT_H 1 /* This is disabled by default to avoid C runtime dependencies and manifest requirements */ #ifdef HAVE_LIBC /* Useful headers */ -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 #define HAVE_CTYPE_H 1 +#define HAVE_FLOAT_H 1 +#define HAVE_LIMITS_H 1 #define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -107,13 +111,19 @@ typedef unsigned int uintptr_t; #define HAVE_MEMCMP 1 #define HAVE_STRLEN 1 #define HAVE__STRREV 1 -#define HAVE__STRUPR 1 -#define HAVE__STRLWR 1 +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 -#define HAVE__LTOA 1 -#define HAVE__ULTOA 1 +/* #undef HAVE_STRTOK_R */ +#if defined(_MSC_VER) +#define HAVE_STRTOK_S 1 +#endif +/* These functions have security warnings, so we won't use them */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__ULTOA */ #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOD 1 @@ -123,28 +133,50 @@ typedef unsigned int uintptr_t; #define HAVE_STRNCMP 1 #define HAVE__STRICMP 1 #define HAVE__STRNICMP 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_ACOS 1 -#define HAVE_ASIN 1 -#define HAVE_CEIL 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 +#define HAVE_ATAN 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2 1 +#define HAVE_ATAN2F 1 +#define HAVE_CEILF 1 +#define HAVE__COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 +#define HAVE_FABS 1 +#define HAVE_FABSF 1 +#define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 +#define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 +#define HAVE_POW 1 +#define HAVE_POWF 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 +#if defined(_MSC_VER) +/* These functions were added with the VC++ 2013 C runtime library */ #if _MSC_VER >= 1800 #define HAVE_STRTOLL 1 #define HAVE_VSSCANF 1 -#define HAVE_COPYSIGN 1 #define HAVE_SCALBN 1 +#define HAVE_SCALBNF 1 +#endif +/* This function is available with at least the VC++ 2008 C runtime library */ +#if _MSC_VER >= 1400 +#define HAVE__FSEEKI64 1 +#endif #endif #if !defined(_MSC_VER) || defined(_USE_MATH_DEFINES) #define HAVE_M_PI 1 @@ -157,7 +189,6 @@ typedef unsigned int uintptr_t; /* Enable various audio drivers */ #define SDL_AUDIO_DRIVER_WASAPI 1 #define SDL_AUDIO_DRIVER_DSOUND 1 -#define SDL_AUDIO_DRIVER_XAUDIO2 0 #define SDL_AUDIO_DRIVER_WINMM 1 #define SDL_AUDIO_DRIVER_DISK 1 #define SDL_AUDIO_DRIVER_DUMMY 1 @@ -165,9 +196,13 @@ typedef unsigned int uintptr_t; /* Enable various input drivers */ #define SDL_JOYSTICK_DINPUT 1 #define SDL_JOYSTICK_XINPUT 1 +#define SDL_JOYSTICK_HIDAPI 1 #define SDL_HAPTIC_DINPUT 1 #define SDL_HAPTIC_XINPUT 1 +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ #define SDL_LOADSO_WINDOWS 1 @@ -185,7 +220,7 @@ typedef unsigned int uintptr_t; #define SDL_VIDEO_RENDER_D3D 1 #endif #ifndef SDL_VIDEO_RENDER_D3D11 -#define SDL_VIDEO_RENDER_D3D11 0 +#define SDL_VIDEO_RENDER_D3D11 0 #endif /* Enable OpenGL support */ diff --git a/lib/SDL2/include/SDL_config_winrt.h b/lib/SDL2/include/SDL_config_winrt.h index 24f9e17f20..fa03389e2d 100644 --- a/lib/SDL2/include/SDL_config_winrt.h +++ b/lib/SDL2/include/SDL_config_winrt.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -44,7 +44,7 @@ #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) #if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) -#define HAVE_STDINT_H 1 +#define HAVE_STDINT_H 1 #elif defined(_MSC_VER) typedef signed __int8 int8_t; typedef unsigned __int8 uint8_t; @@ -97,14 +97,19 @@ typedef unsigned int uintptr_t; #if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP #define HAVE_XINPUT_H 1 #endif + +#define HAVE_MMDEVICEAPI_H 1 +#define HAVE_AUDIOCLIENT_H 1 + #define HAVE_LIBC 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STRING_H 1 #define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 #define HAVE_FLOAT_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MATH_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STRING_H 1 /* C library functions */ #define HAVE_MALLOC 1 @@ -121,13 +126,14 @@ typedef unsigned int uintptr_t; #define HAVE_STRLEN 1 #define HAVE__STRREV 1 #define HAVE__STRUPR 1 -//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead +//#define HAVE__STRLWR 1 // TODO, WinRT: consider using _strlwr_s instead #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 +#define HAVE_STRTOK_S 1 //#define HAVE_ITOA 1 // TODO, WinRT: consider using _itoa_s instead -//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead -//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead +//#define HAVE__LTOA 1 // TODO, WinRT: consider using _ltoa_s instead +//#define HAVE__ULTOA 1 // TODO, WinRT: consider using _ultoa_s instead #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 //#define HAVE_STRTOLL 1 @@ -139,44 +145,63 @@ typedef unsigned int uintptr_t; #define HAVE__STRICMP 1 #define HAVE__STRNICMP 1 #define HAVE_VSNPRINTF 1 -//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead +//#define HAVE_SSCANF 1 // TODO, WinRT: consider using sscanf_s instead #define HAVE_M_PI 1 -#define HAVE_ATAN 1 -#define HAVE_ATAN2 1 -#define HAVE_CEIL 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 +#define HAVE_ATAN 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2 1 +#define HAVE_ATAN2F 1 +#define HAVE_CEIL 1 +#define HAVE_CEILF 1 #define HAVE__COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_POW 1 -//#define HAVE_SCALBN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 +#define HAVE_FABS 1 +#define HAVE_FABSF 1 +#define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 +#define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 +#define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE__SCALB 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 #define HAVE__FSEEKI64 1 /* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_XAUDIO2 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_WASAPI 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP #define SDL_JOYSTICK_DISABLED 1 -#define SDL_HAPTIC_DISABLED 1 +#define SDL_HAPTIC_DISABLED 1 #else #define SDL_JOYSTICK_XINPUT 1 #define SDL_HAPTIC_XINPUT 1 #endif +/* Enable the dummy sensor driver */ +#define SDL_SENSOR_DUMMY 1 + /* Enable various shared object loading systems */ -#define SDL_LOADSO_WINDOWS 1 +#define SDL_LOADSO_WINDOWS 1 /* Enable various threading systems */ #if (NTDDI_VERSION >= NTDDI_WINBLUE) @@ -187,10 +212,10 @@ typedef unsigned int uintptr_t; #endif /* Enable various timer systems */ -#define SDL_TIMER_WINDOWS 1 +#define SDL_TIMER_WINDOWS 1 /* Enable various video drivers */ -#define SDL_VIDEO_DRIVER_WINRT 1 +#define SDL_VIDEO_DRIVER_WINRT 1 #define SDL_VIDEO_DRIVER_DUMMY 1 /* Enable OpenGL ES 2.0 (via a modified ANGLE library) */ @@ -209,7 +234,7 @@ typedef unsigned int uintptr_t; /* Enable assembly routines (Win64 doesn't have inline asm) */ #ifndef _WIN64 -#define SDL_ASSEMBLY_ROUTINES 1 +#define SDL_ASSEMBLY_ROUTINES 1 #endif #endif /* SDL_config_winrt_h_ */ diff --git a/lib/SDL2/include/SDL_config_wiz.h b/lib/SDL2/include/SDL_config_wiz.h index 5bb845a0cc..92b1771e53 100644 --- a/lib/SDL2/include/SDL_config_wiz.h +++ b/lib/SDL2/include/SDL_config_wiz.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -30,22 +30,24 @@ #define SDL_BYTEORDER 1234 -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 #define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 +#define HAVE_ALLOCA_H 1 #define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 #define HAVE_ICONV_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_LIMITS_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MATH_H 1 +#define HAVE_MEMORY_H 1 #define HAVE_SIGNAL_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_STDIO_H 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_STRING_H 1 +#define HAVE_SYS_TYPES_H 1 + #define HAVE_MALLOC 1 #define HAVE_CALLOC 1 #define HAVE_REALLOC 1 @@ -62,10 +64,10 @@ #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_STRLEN 1 -#define HAVE_STRDUP 1 #define HAVE_STRCHR 1 #define HAVE_STRRCHR 1 #define HAVE_STRSTR 1 +#define HAVE_STRTOK_R 1 #define HAVE_STRTOL 1 #define HAVE_STRTOUL 1 #define HAVE_STRTOLL 1 @@ -79,20 +81,42 @@ #define HAVE_VSSCANF 1 #define HAVE_VSNPRINTF 1 #define HAVE_M_PI 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_COSF 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 +#define HAVE_ACOS 1 +#define HAVE_ACOSF 1 +#define HAVE_ASIN 1 +#define HAVE_ASINF 1 +#define HAVE_ATAN 1 +#define HAVE_ATANF 1 +#define HAVE_ATAN2 1 +#define HAVE_ATAN2F 1 +#define HAVE_CEIL 1 +#define HAVE_CEILF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COPYSIGNF 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_EXP 1 +#define HAVE_EXPF 1 +#define HAVE_FABS 1 +#define HAVE_FABSF 1 +#define HAVE_FLOOR 1 +#define HAVE_FLOORF 1 +#define HAVE_FMOD 1 +#define HAVE_FMODF 1 +#define HAVE_LOG 1 +#define HAVE_LOGF 1 +#define HAVE_LOG10 1 +#define HAVE_LOG10F 1 +#define HAVE_POW 1 +#define HAVE_POWF 1 #define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SINF 1 -#define HAVE_SQRT 1 -#define HAVE_SQRTF 1 -#define HAVE_TAN 1 -#define HAVE_TANF 1 +#define HAVE_SCALBNF 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#define HAVE_SQRTF 1 +#define HAVE_TAN 1 +#define HAVE_TANF 1 #define HAVE_SIGACTION 1 #define HAVE_SETJMP 1 #define HAVE_NANOSLEEP 1 @@ -106,6 +130,8 @@ #define SDL_JOYSTICK_LINUX 1 #define SDL_HAPTIC_LINUX 1 +#define SDL_SENSOR_DUMMY 1 + #define SDL_LOADSO_DLOPEN 1 #define SDL_THREAD_PTHREAD 1 diff --git a/lib/SDL2/include/SDL_copying.h b/lib/SDL2/include/SDL_copying.h index 8f60af6b4f..4f8a2bcd49 100644 --- a/lib/SDL2/include/SDL_copying.h +++ b/lib/SDL2/include/SDL_copying.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2017 Sam Lantinga + Copyright (C) 1997-2020 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/lib/SDL2/include/SDL_metal.h b/lib/SDL2/include/SDL_metal.h new file mode 100644 index 0000000000..3b7eb18aa8 --- /dev/null +++ b/lib/SDL2/include/SDL_metal.h @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_metal.h + * + * Header file for functions to creating Metal layers and views on SDL windows. + */ + +#ifndef SDL_metal_h_ +#define SDL_metal_h_ + +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** + * \brief A handle to a CAMetalLayer-backed NSView (macOS) or UIView (iOS/tvOS). + * + * \note This can be cast directly to an NSView or UIView. + */ +typedef void *SDL_MetalView; + +/** + * \name Metal support functions + */ +/* @{ */ + +/** + * \brief Create a CAMetalLayer-backed NSView/UIView and attach it to the + * specified window. + * + * On macOS, this does *not* associate a MTLDevice with the CAMetalLayer on its + * own. It is up to user code to do that. + * + * The returned handle can be casted directly to a NSView or UIView, and the + * CAMetalLayer can be accessed from the view's 'layer' property. + * + * \code + * SDL_MetalView metalview = SDL_Metal_CreateView(window); + * UIView *uiview = (__bridge UIView *)metalview; + * CAMetalLayer *metallayer = (CAMetalLayer *)uiview.layer; + * // [...] + * SDL_Metal_DestroyView(metalview); + * \endcode + * + * \sa SDL_Metal_DestroyView + */ +extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window); + +/** + * \brief Destroy an existing SDL_MetalView object. + * + * This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was + * called after SDL_CreateWindow. + * + * \sa SDL_Metal_CreateView + */ +extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view); + +/* @} *//* Metal support functions */ + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* SDL_metal_h_ */ diff --git a/lib/SDL2/include/SDL_sensor.h b/lib/SDL2/include/SDL_sensor.h new file mode 100644 index 0000000000..5122ee153c --- /dev/null +++ b/lib/SDL2/include/SDL_sensor.h @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2020 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_sensor.h + * + * Include file for SDL sensor event handling + * + */ + +#ifndef SDL_sensor_h_ +#define SDL_sensor_h_ + +#include "SDL_stdinc.h" +#include "SDL_error.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \brief SDL_sensor.h + * + * In order to use these functions, SDL_Init() must have been called + * with the ::SDL_INIT_SENSOR flag. This causes SDL to scan the system + * for sensors, and load appropriate drivers. + */ + +struct _SDL_Sensor; +typedef struct _SDL_Sensor SDL_Sensor; + +/** + * This is a unique ID for a sensor for the time it is connected to the system, + * and is never reused for the lifetime of the application. + * + * The ID value starts at 0 and increments from there. The value -1 is an invalid ID. + */ +typedef Sint32 SDL_SensorID; + +/* The different sensors defined by SDL + * + * Additional sensors may be available, using platform dependent semantics. + * + * Hare are the additional Android sensors: + * https://developer.android.com/reference/android/hardware/SensorEvent.html#values + */ +typedef enum +{ + SDL_SENSOR_INVALID = -1, /**< Returned for an invalid sensor */ + SDL_SENSOR_UNKNOWN, /**< Unknown sensor type */ + SDL_SENSOR_ACCEL, /**< Accelerometer */ + SDL_SENSOR_GYRO /**< Gyroscope */ +} SDL_SensorType; + +/** + * Accelerometer sensor + * + * The accelerometer returns the current acceleration in SI meters per + * second squared. This includes gravity, so a device at rest will have + * an acceleration of SDL_STANDARD_GRAVITY straight down. + * + * values[0]: Acceleration on the x axis + * values[1]: Acceleration on the y axis + * values[2]: Acceleration on the z axis + * + * For phones held in portrait mode, the axes are defined as follows: + * -X ... +X : left ... right + * -Y ... +Y : bottom ... top + * -Z ... +Z : farther ... closer + * + * The axis data is not changed when the phone is rotated. + * + * \sa SDL_GetDisplayOrientation() + */ +#define SDL_STANDARD_GRAVITY 9.80665f + +/** + * Gyroscope sensor + * + * The gyroscope returns the current rate of rotation in radians per second. + * The rotation is positive in the counter-clockwise direction. That is, + * an observer looking from a positive location on one of the axes would + * see positive rotation on that axis when it appeared to be rotating + * counter-clockwise. + * + * values[0]: Angular speed around the x axis + * values[1]: Angular speed around the y axis + * values[2]: Angular speed around the z axis + * + * For phones held in portrait mode, the axes are defined as follows: + * -X ... +X : left ... right + * -Y ... +Y : bottom ... top + * -Z ... +Z : farther ... closer + * + * The axis data is not changed when the phone is rotated. + * + * \sa SDL_GetDisplayOrientation() + */ + +/* Function prototypes */ + +/** + * \brief Count the number of sensors attached to the system right now + */ +extern DECLSPEC int SDLCALL SDL_NumSensors(void); + +/** + * \brief Get the implementation dependent name of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor name, or NULL if device_index is out of range. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorGetDeviceName(int device_index); + +/** + * \brief Get the type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor type, or SDL_SENSOR_INVALID if device_index is out of range. + */ +extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetDeviceType(int device_index); + +/** + * \brief Get the platform dependent type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor platform dependent type, or -1 if device_index is out of range. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetDeviceNonPortableType(int device_index); + +/** + * \brief Get the instance ID of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor instance ID, or -1 if device_index is out of range. + */ +extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetDeviceInstanceID(int device_index); + +/** + * \brief Open a sensor for use. + * + * The index passed as an argument refers to the N'th sensor on the system. + * + * \return A sensor identifier, or NULL if an error occurred. + */ +extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorOpen(int device_index); + +/** + * Return the SDL_Sensor associated with an instance id. + */ +extern DECLSPEC SDL_Sensor *SDLCALL SDL_SensorFromInstanceID(SDL_SensorID instance_id); + +/** + * \brief Get the implementation dependent name of a sensor. + * + * \return The sensor name, or NULL if the sensor is NULL. + */ +extern DECLSPEC const char *SDLCALL SDL_SensorGetName(SDL_Sensor *sensor); + +/** + * \brief Get the type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor type, or SDL_SENSOR_INVALID if the sensor is NULL. + */ +extern DECLSPEC SDL_SensorType SDLCALL SDL_SensorGetType(SDL_Sensor *sensor); + +/** + * \brief Get the platform dependent type of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor platform dependent type, or -1 if the sensor is NULL. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetNonPortableType(SDL_Sensor *sensor); + +/** + * \brief Get the instance ID of a sensor. + * + * This can be called before any sensors are opened. + * + * \return The sensor instance ID, or -1 if the sensor is NULL. + */ +extern DECLSPEC SDL_SensorID SDLCALL SDL_SensorGetInstanceID(SDL_Sensor *sensor); + +/** + * Get the current state of an opened sensor. + * + * The number of values and interpretation of the data is sensor dependent. + * + * \param sensor The sensor to query + * \param data A pointer filled with the current sensor state + * \param num_values The number of values to write to data + * + * \return 0 or -1 if an error occurred. + */ +extern DECLSPEC int SDLCALL SDL_SensorGetData(SDL_Sensor * sensor, float *data, int num_values); + +/** + * Close a sensor previously opened with SDL_SensorOpen() + */ +extern DECLSPEC void SDLCALL SDL_SensorClose(SDL_Sensor * sensor); + +/** + * Update the current state of the open sensors. + * + * This is called automatically by the event loop if sensor events are enabled. + * + * This needs to be called from the thread that initialized the sensor subsystem. + */ +extern DECLSPEC void SDLCALL SDL_SensorUpdate(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* SDL_sensor_h_ */ + +/* vi: set ts=4 sw=4 expandtab: */ From 61050c20d1886d9b5a29d967f1bfe7850b01f46f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 Sep 2020 11:55:54 +0200 Subject: [PATCH 533/708] Fix rend2 compile --- codemp/rd-rend2/tr_ghoul2.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 6ed050f4ee..99715b825d 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -1106,11 +1106,9 @@ void G2_CreateMatrixFromQuaterion(mdxaBone_t *mat, vec4_t quat) static int G2_GetBonePoolIndex( const mdxaHeader_t *pMDXAHeader, int iFrame, int iBone) { const int iOffsetToIndex = (iFrame * pMDXAHeader->numBones * 3) + (iBone * 3); - const mdxaIndex_t *pIndex = - (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); + mdxaIndex_t *pIndex = (mdxaIndex_t *)((byte*)pMDXAHeader + pMDXAHeader->ofsFrames + iOffsetToIndex); - // this will cause problems for big-endian machines... ;-) - return pIndex->iIndex & 0x00FFFFFF; + return (pIndex->iIndex[2] << 16) + (pIndex->iIndex[1] << 8) + (pIndex->iIndex[0]); } /*static inline*/ void UnCompressBone( From 0dc787fd7adaf643cda3f476e45c5168b9232fae Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 14 Sep 2020 11:56:59 +0200 Subject: [PATCH 534/708] Only change tonemap when HDR lighting found --- codemp/rd-rend2/tr_bsp.cpp | 24 +++++++++++------------- codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_shader.cpp | 2 ++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 031f7f91b1..c0fa3cc095 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3938,19 +3938,10 @@ void RE_LoadWorldMap( const char *name ) { tr.autoExposureMinMax[1] = 2.0f; // set default tone mapping settings - if (r_hdr->integer) - { - tr.toneMinAvgMaxLevel[0] = -6.0f; - tr.toneMinAvgMaxLevel[1] = 0.0f; - tr.toneMinAvgMaxLevel[2] = 2.0f; - } - else - { - tr.toneMinAvgMaxLevel[0] = -8.0f; - tr.toneMinAvgMaxLevel[1] = -2.0f; - tr.toneMinAvgMaxLevel[2] = 0.0f; - } - + tr.toneMinAvgMaxLevel[0] = -8.0f; + tr.toneMinAvgMaxLevel[1] = -2.0f; + tr.toneMinAvgMaxLevel[2] = 0.0f; + tr.explicitToneMap = false; world_t *world = R_LoadBSP(name); if (world == nullptr) @@ -3961,6 +3952,13 @@ void RE_LoadWorldMap( const char *name ) { return; } + if (r_hdr->integer && world->hdrLighting && !tr.explicitToneMap) + { + tr.toneMinAvgMaxLevel[0] = -6.0f; + tr.toneMinAvgMaxLevel[1] = 0.0f; + tr.toneMinAvgMaxLevel[2] = 2.0f; + } + tr.worldMapLoaded = qtrue; tr.world = world; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e82307dd0c..53527dc84a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2494,6 +2494,8 @@ typedef struct trGlobals_s { // Specific to Jedi Academy int numBSPModels; int currentLevel; + + bool explicitToneMap; } trGlobals_t; struct glconfigExt_t diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index ac6e2b6fcb..e659504307 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2593,6 +2593,8 @@ static qboolean ParseShader( const char **text ) token = COM_ParseExt( text, qfalse ); tr.autoExposureMinMax[1] = atof( token ); + tr.explicitToneMap = true; + SkipRestOfLine( text ); continue; } From f83754e9c328884cd2a266d604adffd8fce685de Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 22 Sep 2020 00:43:34 +0200 Subject: [PATCH 535/708] HDR fixes and some cleanup --- codemp/rd-rend2/tr_backend.cpp | 15 ++--------- codemp/rd-rend2/tr_bsp.cpp | 19 +++++++------- codemp/rd-rend2/tr_glsl.cpp | 11 -------- codemp/rd-rend2/tr_image.cpp | 6 ++--- codemp/rd-rend2/tr_local.h | 16 +++--------- codemp/rd-rend2/tr_postprocess.cpp | 2 +- codemp/rd-rend2/tr_scene.cpp | 15 ----------- codemp/rd-rend2/tr_shader.cpp | 41 ++++++++++++++++-------------- 8 files changed, 41 insertions(+), 84 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index fdc1e5371f..3b1cdf9d0b 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2154,8 +2154,8 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) !backEnd.colorMask[3]); backEnd.depthFill = qfalse; - - if (tr.msaaResolveFbo) + // Only resolve the main pass depth + if (tr.msaaResolveFbo && backEnd.viewParms.targetFbo == tr.renderFbo) { if (backEnd.viewParms.targetFbo == tr.renderCubeFbo && tr.msaaResolveFbo) { @@ -3325,19 +3325,8 @@ static const void *RB_DrawSurfs(const void *data) { // clear the z buffer, set the modelview, etc RB_BeginDrawingView(); - beginTimedBlockCommand_t cmd2; - cmd2.commandId = RC_BEGIN_TIMED_BLOCK; - cmd2.name = "Update Constants"; - cmd2.timerHandle = tr.numTimedBlocks++; - RB_BeginTimedBlock(&cmd2); - RB_UpdateConstants(cmd->drawSurfs, cmd->numDrawSurfs); - endTimedBlockCommand_t cmd3; - cmd3.commandId = RC_END_TIMED_BLOCK; - cmd3.timerHandle = cmd2.timerHandle; - RB_EndTimedBlock(&cmd3); - RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c0fa3cc095..f1518ae12f 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -196,9 +196,9 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { int numColorComponents = 3; bool hdr_capable = glRefConfig.floatLightmap && r_hdr->integer; - tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; - worldData->hdrLighting = qfalse; + tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; + tr.hdrLighting = qfalse; len = l->filelen; // test for external lightmaps @@ -388,7 +388,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (bppc > 8) { hdrL = (float *)externalLightmap; - worldData->hdrLighting = qtrue; + tr.hdrLighting = qtrue; } else { @@ -3155,6 +3155,7 @@ static void R_RenderAllCubemaps() cubemapFormat = GL_RGBA16F; } + int frontEndMsec, backEndMsec; for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; @@ -3173,20 +3174,20 @@ static void R_RenderAllCubemaps() IMGFLAG_CUBEMAP, cubemapFormat); + RE_BeginFrame(STEREO_CENTER); for (int j = 0; j < 6; j++) { RE_ClearScene(); R_RenderCubemapSide(i, j, qfalse, bounce); R_IssuePendingRenderCommands(); - R_InitNextFrame(); } for (int j = 0; j < 6; j++) { RE_ClearScene(); R_AddConvolveCubemapCmd(&tr.cubemaps[i], j); R_IssuePendingRenderCommands(); - R_InitNextFrame(); } + RE_EndFrame( &frontEndMsec, &backEndMsec ); } } } @@ -3952,9 +3953,9 @@ void RE_LoadWorldMap( const char *name ) { return; } - if (r_hdr->integer && world->hdrLighting && !tr.explicitToneMap) + if (r_hdr->integer && tr.hdrLighting && !tr.explicitToneMap) { - tr.toneMinAvgMaxLevel[0] = -6.0f; + tr.toneMinAvgMaxLevel[0] = -8.0f; tr.toneMinAvgMaxLevel[1] = 0.0f; tr.toneMinAvgMaxLevel[2] = 2.0f; } @@ -3962,11 +3963,11 @@ void RE_LoadWorldMap( const char *name ) { tr.worldMapLoaded = qtrue; tr.world = world; + R_InitWeatherForMap(); + // Render all cubemaps if (r_cubeMapping->integer && tr.numCubemaps) { R_RenderAllCubemaps(); } - - R_InitWeatherForMap(); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 8716793b86..d5d7f82b73 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -328,17 +328,6 @@ static size_t GLSL_GetShaderHeader( AGEN_LIGHTING_SPECULAR, AGEN_PORTAL)); - Q_strcat(dest, size, - va("#ifndef texenv_t\n" - "#define texenv_t\n" - "#define TEXENV_MODULATE %i\n" - "#define TEXENV_ADD %i\n" - "#define TEXENV_REPLACE %i\n" - "#endif\n", - 0x2100/* GL_MODULATE */, - 0x0104/* GL_ADD */, - GL_REPLACE)); - Q_strcat(dest, size, va("#define ALPHA_TEST_GT0 %d\n" "#define ALPHA_TEST_LT128 %d\n" diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 3db2c67ebf..4c90673956 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2726,9 +2726,9 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // diffuse Color = baseColor * (1.0 - metalness) // also gamma correct again // FIXME: AO should be handled in shader because it should only affect the ambient lighting - diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * (1.0f - metalness) * ao)); - diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * (1.0f - metalness) * ao)); - diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * (1.0f - metalness) * ao)); + diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * ao)); + diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * ao)); + diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * ao)); diffusePic[i + 3] = FloatToByte(baseColor[3]); // specular Color = mix(baseSpecular, baseColor, metalness) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 53527dc84a..4c48c9d3b3 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1890,7 +1890,6 @@ typedef struct { char *entityString; char *entityParsePoint; - qboolean hdrLighting; } world_t; @@ -2359,6 +2358,8 @@ typedef struct trGlobals_s { image_t **lightmaps; image_t **deluxemaps; + qboolean hdrLighting; + vec2i_t lightmapAtlasSize; vec2i_t lightmapsPerAtlasSide; @@ -2704,11 +2705,6 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level); void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce); void R_AddMD3Surfaces( trRefEntity_t *e, int entityNum ); -void R_AddNullModelSurfaces( trRefEntity_t *e, int entityNum ); -void R_AddBeamSurfaces( trRefEntity_t *e, int entityNum ); -void R_AddRailSurfaces( trRefEntity_t *e, qboolean isUnderwater ); -void R_AddLightningBoltSurfaces( trRefEntity_t *e ); - void R_AddPolygonSurfaces( const trRefdef_t *refdef ); void R_DecomposeSort( uint32_t sort, int *entityNum, shader_t **shader, int *cubemap, int *postRender ); @@ -2750,10 +2746,8 @@ void GL_CheckErrs( const char *file, int line ); void GL_State( uint32_t stateVector ); void GL_SetProjectionMatrix(matrix_t matrix); void GL_SetModelviewMatrix(matrix_t matrix); -//void GL_TexEnv( int env ); void GL_Cull( int cullType ); void GL_DepthRange( float min, float max ); -void GL_PolygonOffset( qboolean enabled ); void GL_VertexAttribPointers(size_t numAttributes, vertexAttribute_t *attributes); void GL_DrawIndexed(GLenum primitiveType, int numIndices, GLenum indexType, @@ -2782,7 +2776,7 @@ qhandle_t RE_RegisterServerModel( const char *name ); qhandle_t RE_RegisterModel( const char *name ); qhandle_t RE_RegisterServerSkin( const char *name ); qhandle_t RE_RegisterSkin( const char *name ); -void RE_Shutdown( qboolean destroyWindow ); +void RE_Shutdown(qboolean destroyWindow, qboolean restarting); world_t *R_LoadBSP(const char *name, int *bspIndex = nullptr); qboolean R_GetEntityToken( char *buffer, int size ); @@ -2833,7 +2827,6 @@ extern const byte stylesDefault[MAXLIGHTMAPS]; shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte *styles, qboolean mipRawImage ); shader_t *R_GetShaderByHandle( qhandle_t hShader ); -shader_t *R_GetShaderByState( int index, long *cycleTime ); shader_t *R_FindShaderByName( const char *name ); void R_InitShaders( qboolean server ); void R_ShaderList_f( void ); @@ -3000,7 +2993,6 @@ SKIES void R_BuildCloudData( shaderCommands_t *shader ); void R_InitSkyTexCoords( float cloudLayerHeight ); -void R_DrawSkyBox( shaderCommands_t *shader ); void RB_DrawSun( float scale, shader_t *shader ); void RB_ClipSkyPolygons( shaderCommands_t *shader ); @@ -3540,7 +3532,6 @@ void RB_ExecuteRenderCommands( const void *data ); void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); -void R_AddCapShadowmapCmd( int dlight, int cubeSide ); void R_AddConvolveCubemapCmd(cubemap_t *cubemap, int cubeSide); void R_AddPostProcessCmd (void); qhandle_t R_BeginTimedBlockCmd( const char *name ); @@ -3572,7 +3563,6 @@ const mdxaBone_t operator *( const float scale, const mdxaBone_t& rhs ); qboolean R_LoadMDXM( model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); qboolean R_LoadMDXA( model_t *mod, void *buffer, const char *name, qboolean &bAlreadyCached ); -bool LoadTGAPalletteImage( const char *name, byte **pic, int *width, int *height); void RE_InsertModelIntoHash( const char *name, model_t *mod ); void ResetGhoul2RenderableSurfaceHeap(); diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 831de381d6..a07a528390 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -87,7 +87,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in else GL_BindToTMU(tr.fixedLevelsImage, TB_LEVELSMAP); - bool srgbTransform = tr.world && tr.world->hdrLighting == qtrue; + bool srgbTransform = tr.hdrLighting == qtrue; shaderProgram_t *shader = srgbTransform ? &tr.tonemapShader[1] : &tr.tonemapShader[0]; FBO_Blit(hdrFbo, hdrBox, NULL, ldrFbo, ldrBox, shader, color, 0); } diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 29149b2e18..ad5c89da9e 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -517,21 +517,6 @@ void RE_RenderScene( const refdef_t *fd ) { R_EndTimedBlockCmd( timer ); } - // playing with cube maps - // this is where dynamic cubemaps would be rendered - if (0) //(!( fd->rdflags & RDF_NOWORLDMODEL )) - { - int i, j; - - for (i = 0; i < tr.numCubemaps; i++) - { - for (j = 0; j < 6; j++) - { - R_RenderCubemapSide(i, j, qtrue, false); - } - } - } - // setup view parms for the initial view // // set up viewport diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e659504307..fcabfef5ac 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1281,7 +1281,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (r_genNormalMaps->integer) flags |= IMGFLAG_GENNORMALMAP; - if (shader.isHDRLit) + if (shader.isHDRLit == qtrue) flags |= IMGFLAG_SRGB; Q_strncpyz(bufferBaseColorTextureName, token, sizeof(bufferBaseColorTextureName)); @@ -1437,7 +1437,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!shader.noPicMip) flags |= IMGFLAG_PICMIP; - if (shader.isHDRLit) + if (shader.isHDRLit == qtrue) flags |= IMGFLAG_SRGB; if (shader.noTC) @@ -2259,7 +2259,7 @@ static void ParseSkyParms( const char **text ) { if (shader.noTC) imgFlags |= IMGFLAG_NO_COMPRESSION; - if (tr.world && tr.world->hdrLighting) + if (tr.world && tr.hdrLighting == qtrue) imgFlags |= IMGFLAG_SRGB; // outerbox @@ -3049,7 +3049,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm { char specularName[MAX_QPATH]; image_t *specularImg; - int specularFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; + int specularFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP)) | IMGFLAG_NOLIGHTSCALE; COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); Q_strcat(specularName, MAX_QPATH, "_specGloss"); @@ -4182,21 +4182,6 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte } lightmapIndexes = R_FindLightmaps(lightmapIndexes); - switch (lightmapIndexes[0]) { - case LIGHTMAP_NONE: - case LIGHTMAP_2D: - case LIGHTMAP_WHITEIMAGE: - { - shader.isHDRLit = qfalse; - break; - } - default: - { - - shader.isHDRLit = tr.world ? tr.world->hdrLighting: qfalse; - break; - } - } COM_StripExtension(name, strippedName, sizeof(strippedName)); @@ -4221,6 +4206,20 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte Q_strncpyz(shader.name, strippedName, sizeof(shader.name)); Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); Com_Memcpy (shader.styles, styles, sizeof (shader.styles)); + switch (lightmapIndexes[0]) { + case LIGHTMAP_NONE: + case LIGHTMAP_2D: + case LIGHTMAP_WHITEIMAGE: + { + shader.isHDRLit = qfalse; + break; + } + default: + { + shader.isHDRLit = tr.hdrLighting; + break; + } + } // // attempt to define shader from an explicit parameter file @@ -4410,6 +4409,8 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[0].rgbGen = CGEN_EXACT_VERTEX; stages[0].alphaGen = AGEN_SKIP; stages[0].stateBits = GLS_DEFAULT; + + shader.isHDRLit = tr.hdrLighting; } else if ( shader.lightmapIndex[0] == LIGHTMAP_2D ) { // GUI elements stages[0].bundle[0].image[0] = image; @@ -4443,6 +4444,8 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[1].active = qtrue; stages[1].rgbGen = CGEN_IDENTITY; stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + + shader.isHDRLit = tr.hdrLighting; } sh = FinishShader(); From b991201d63a8b2edaa799d83afd7e7329ab3a0ee Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 22 Sep 2020 00:51:40 +0200 Subject: [PATCH 536/708] Fix shader based external lightmaps --- codemp/rd-rend2/tr_bsp.cpp | 3 +++ codemp/rd-rend2/tr_local.h | 2 ++ codemp/rd-rend2/tr_shader.cpp | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f1518ae12f..50dfbb39c8 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3811,6 +3811,9 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) Q_strncpyz(worldData->baseName, COM_SkipPath(worldData->name), sizeof(worldData->name)); COM_StripExtension(worldData->baseName, worldData->baseName, sizeof(worldData->baseName)); + Q_strncpyz(tr.worldName, worldData->name, sizeof(worldData->name)); + COM_StripExtension(tr.worldName, tr.worldName, sizeof(tr.worldName)); + const byte *startMarker = (const byte *)ri.Hunk_Alloc(0, h_low); dheader_t *header = (dheader_t *)buffer.b; fileBase = (byte *)header; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 4c48c9d3b3..25387d713a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -857,6 +857,7 @@ enum AlphaTestType // any change in the LIGHTMAP_* defines here MUST be reflected in // R_FindShader() in tr_bsp.c +#define LIGHTMAP_EXTERNAL -5 #define LIGHTMAP_2D -4 // shader is for 2D rendering #define LIGHTMAP_BY_VERTEX -3 // pre-lit triangle models #define LIGHTMAP_WHITEIMAGE -2 @@ -2290,6 +2291,7 @@ typedef struct trGlobals_s { vec2_t autoExposureMinMax; vec3_t toneMinAvgMaxLevel; world_t *world; + char worldName[MAX_QPATH]; const byte *externalVisData; // from RE_SetWorldVisData, shared with CM_Load diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index fcabfef5ac..1a18daeb8b 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2045,6 +2045,28 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); } + // + // search for shader based external lightmaps that were created by q3map2 + // + if (stage->bundle[0].tcGen == TCGEN_LIGHTMAP && stage->bundle[0].isLightmap == qfalse) + { + const char *filename = { va("%s/lm_", tr.worldName) }; + if (!Q_strncmp(filename, bufferBaseColorTextureName, sizeof(filename))) + { + stage->bundle[0].isLightmap = qtrue; + shader.lightmapIndex[0] = LIGHTMAP_EXTERNAL; + + // shader based external lightmaps can't utilize lightstyles + shader.styles[0] = 0; + shader.styles[1] = 255; + shader.styles[2] = 255; + shader.styles[3] = 255; + + // it obviously receives light, so receive dlights too + shader.surfaceFlags &= ~SURF_NODLIGHT; + } + } + // // if cgen isn't explicitly specified, use either identity or identitylighting // From b1780225138a68b68719b8f769879ea0ddcebab2 Mon Sep 17 00:00:00 2001 From: Lee Date: Wed, 9 Dec 2020 22:20:09 +0000 Subject: [PATCH 537/708] Update lightall.glsl --- codemp/rd-rend2/glsl/lightall.glsl | 114 ++++++++++++++++++++++++++--- 1 file changed, 102 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index a017c49fe7..d70967f607 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -508,21 +508,79 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) } #endif -vec3 CalcFresnel( in vec3 f0, in vec3 f90, in float LH ) +//vec3 CalcFresnel( in vec3 f0, in vec3 f90, in float LH ) +//{ +// return f0 + (f90 - f0) * pow(1.0 - LH, 5.0); +//} + + + +float3 Specular_CharlieSheen(float Roughness, float NoH, float NoV, float NoL, float3 SpecularColor, float cloth) +{ + float D = cloth > 0.f ? D_Ashikhmin(Roughness, NoH) : D_Charlie(Roughness, NoH); + + return (D * V_Neubelt(NoV, NoL)) * SpecularColor; //No fresnel in the documentation. +} + +float3 Fresnel_Schlick(const float3 f0, float f90, float VoH) +{ + // Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering" + return f0 + (f90 - f0) * pow(1.0 - VoH, 5.f); +} + +float Diff_Burley(float roughness, float NoV, float NoL, float LoH) +{ + // Burley 2012, "Physically-Based Shading at Disney" + float f90 = 0.5 + 2.0 * roughness * LoH * LoH; + float lightScatter = Fresnel_Schlick(1.0, f90, NoL); + float viewScatter = Fresnel_Schlick(1.0, f90, NoV); + return lightScatter * viewScatter * (1.0 / PI); +} + +float3 F_Schlick(in vec3 SpecularColor, in float VH) { - return f0 + (f90 - f0) * pow(1.0 - LH, 5.0); + float Fc = Pow5(1 - VH); + return saturate(50.0 * SpecularColor.g) * Fc + (1 - Fc) * SpecularColor; //hacky way to decide if reflectivity is too low (< 2%) } -float CalcGGX( in float NH, in float roughness ) +float D_GGX( in float NH, in float a ) { - float alphaSq = roughness*roughness; + /*float alphaSq = roughness*roughness; float f = (NH * alphaSq - NH) * NH + 1.0; - return alphaSq / (f * f); + return alphaSq / (f * f);*/ + + float a2 = a * a; + float d = (NH * a2 - NH) * NH + 1; + return a2 / (M_PI * d * d); } -float CalcVisibility( in float NL, in float NE, in float roughness ) +float D_Charlie(in float a, in float NH) { - float alphaSq = roughness*roughness; + // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" + float invAlpha = 1.0 / a; + float cos2h = NH * NH; + float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 + return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI); +} + +float V_Neubelt(in float NV, in float NL) +{ + // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" + return 1.0 / (4.0 * (NoL + NoV - NoL * NoV)); +} + +// Appoximation of joint Smith term for GGX +// [Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"] +float V_SmithJointApprox(in float a, in float NV, in float NL) +{ + float Vis_SmithV = NL * (NV * (1 - a) + a); + float Vis_SmithL = NV * (NL * (1 - a) + a); + return 0.5 * rcp(Vis_SmithV + Vis_SmithL); +} + +float CalcVisibility(in float NL, in float NE, in float roughness) +{ + float alphaSq = roughness * roughness; float lambdaE = NL * sqrt((-NE * alphaSq + NE) * NE + alphaSq); float lambdaL = NE * sqrt((-NL * alphaSq + NL) * NL + alphaSq); @@ -537,16 +595,37 @@ vec3 CalcSpecular( in float NL, in float NE, in float LH, + in float VH, in float roughness ) { - vec3 F = CalcFresnel(specular, vec3(1.0), LH); - float D = CalcGGX(NH, roughness); - float V = CalcVisibility(NL, NE, roughness); + //Using #if to define our BRDF's is a good idea. +#if 1 //should define this as the base BRDF + vec3 F = F_Schlick(specular, VH); + float D = D_GGX(NH, roughness); + float V = V_SmithJointApprox(rougness, NE, NL); +#else //and define this as the cloth BRDF + //this cloth model essentially uses the metallic input to help transition from isotropic to anisotropic reflections. + //as cloth is a microfibre structure, cloth like velevet and silk tends to have anisotropy. + vec3 F = specular; //this shading model omits fresnel + float D = D_Charlie(roughness, NH); + float V = V_Neubelt(roughness, NE, NL); +#endif return D * F * V; } +//Energy conserving wrap term. +float WrapLambert(in float NL, in float w) +{ + return clamp((NL + w) / Pow2(1.0 + w), 0.0, 1.0); +} + +vec3 Diffuse_Lambert(in vec3 DiffuseColor) +{ + return DiffuseColor * (1 / M_PI); +} + vec3 CalcDiffuse( in vec3 diffuse, in float NE, @@ -555,7 +634,17 @@ vec3 CalcDiffuse( in float roughness ) { - return diffuse; + //Using #if to define our diffuse's is a good idea. +#if 1 //should define this as the base BRDF + return Diffuse_Lambert(diffuse); +#else //and define this as the cloth diffuse + //this cloth model has a wrapped diffuse, we can be energy conservant here. + vec3 d = Diffuse_Lambert(diffuse); + d *= WrapLambert(NL, 0.5); + // Cheap subsurface scatter + // ideally we should actually have a new colour for subsurface, but for cloth most times it makes sense to just use the diffuse. + d *= clamp(diffuse + NoL, 0.0, 1.0); +#endif } float CalcLightAttenuation(float point, float normDist) @@ -653,8 +742,9 @@ vec3 CalcDynamicLightContribution( float NL = clamp(dot(N, L), 0.0, 1.0); float LH = clamp(dot(L, H), 0.0, 1.0); float NH = clamp(dot(N, H), 0.0, 1.0); + float VH = clamp(dot(E, H), 0.0, 1.0); - vec3 reflectance = diffuse + CalcSpecular(specular, NH, NL, NE, LH, roughness); + vec3 reflectance = diffuse + CalcSpecular(specular, NH, NL, NE, LH, VH, roughness); outColor += light.color * reflectance * attenuation * NL; } From 9e51c2bf8ad592c84d5b05febafdd918537ddfb3 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 10 Dec 2020 00:43:20 +0100 Subject: [PATCH 538/708] Fixing some bads. --- codemp/rd-rend2/glsl/lightall.glsl | 80 ++++++++++++++++-------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index d70967f607..618def5e0a 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -508,39 +508,57 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) } #endif -//vec3 CalcFresnel( in vec3 f0, in vec3 f90, in float LH ) -//{ -// return f0 + (f90 - f0) * pow(1.0 - LH, 5.0); -//} +float D_Charlie(in float a, in float NH) +{ + // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" + float invAlpha = 1.0 / a; + float cos2h = NH * NH; + float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 + return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * M_PI); +} +float V_Neubelt(in float NV, in float NL) +{ + // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" + return 1.0 / (4.0 * (NL + NV - NL * NV)); +} + +float D_Ashikhmin(float roughness, float nh){ + float a2 = roughness * roughness; + float cos2h = nh * nh ; + float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 + float sin4h = sin2h * sin2h; + float cot2 = -cos2h / (a2 * sin2h); + return 1.0 / (M_PI * (4.0 * a2 + 1.0) * sin4h) * (4.0 * exp(cot2) + sin4h); + } -float3 Specular_CharlieSheen(float Roughness, float NoH, float NoV, float NoL, float3 SpecularColor, float cloth) +vec3 Specular_CharlieSheen(float Roughness, float NoH, float NoV, float NoL, vec3 SpecularColor, float cloth) { float D = cloth > 0.f ? D_Ashikhmin(Roughness, NoH) : D_Charlie(Roughness, NoH); return (D * V_Neubelt(NoV, NoL)) * SpecularColor; //No fresnel in the documentation. } -float3 Fresnel_Schlick(const float3 f0, float f90, float VoH) +vec3 Fresnel_Schlick(const vec3 f0, float f90, float VoH) { // Schlick 1994, "An Inexpensive BRDF Model for Physically-Based Rendering" return f0 + (f90 - f0) * pow(1.0 - VoH, 5.f); } -float Diff_Burley(float roughness, float NoV, float NoL, float LoH) +/*float Diff_Burley(float roughness, float NoV, float NoL, float LoH) { // Burley 2012, "Physically-Based Shading at Disney" float f90 = 0.5 + 2.0 * roughness * LoH * LoH; float lightScatter = Fresnel_Schlick(1.0, f90, NoL); float viewScatter = Fresnel_Schlick(1.0, f90, NoV); - return lightScatter * viewScatter * (1.0 / PI); -} + return lightScatter * viewScatter * (1.0 / M_PI); +}*/ -float3 F_Schlick(in vec3 SpecularColor, in float VH) +vec3 F_Schlick(in vec3 SpecularColor, in float VH) { - float Fc = Pow5(1 - VH); - return saturate(50.0 * SpecularColor.g) * Fc + (1 - Fc) * SpecularColor; //hacky way to decide if reflectivity is too low (< 2%) + float Fc = pow(1 - VH, 5); + return clamp(50.0 * SpecularColor.g, 0.0, 1.0) * Fc + (1 - Fc) * SpecularColor; //hacky way to decide if reflectivity is too low (< 2%) } float D_GGX( in float NH, in float a ) @@ -554,28 +572,13 @@ float D_GGX( in float NH, in float a ) return a2 / (M_PI * d * d); } -float D_Charlie(in float a, in float NH) -{ - // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" - float invAlpha = 1.0 / a; - float cos2h = NH * NH; - float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16 - return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI); -} - -float V_Neubelt(in float NV, in float NL) -{ - // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" - return 1.0 / (4.0 * (NoL + NoV - NoL * NoV)); -} - // Appoximation of joint Smith term for GGX // [Heitz 2014, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs"] float V_SmithJointApprox(in float a, in float NV, in float NL) { float Vis_SmithV = NL * (NV * (1 - a) + a); float Vis_SmithL = NV * (NL * (1 - a) + a); - return 0.5 * rcp(Vis_SmithV + Vis_SmithL); + return 0.5 * (1.0 / (Vis_SmithV + Vis_SmithL)); } float CalcVisibility(in float NL, in float NE, in float roughness) @@ -603,13 +606,13 @@ vec3 CalcSpecular( #if 1 //should define this as the base BRDF vec3 F = F_Schlick(specular, VH); float D = D_GGX(NH, roughness); - float V = V_SmithJointApprox(rougness, NE, NL); + float V = V_SmithJointApprox(roughness, NE, NL); #else //and define this as the cloth BRDF //this cloth model essentially uses the metallic input to help transition from isotropic to anisotropic reflections. //as cloth is a microfibre structure, cloth like velevet and silk tends to have anisotropy. vec3 F = specular; //this shading model omits fresnel float D = D_Charlie(roughness, NH); - float V = V_Neubelt(roughness, NE, NL); + float V = V_Neubelt(NE, NL); #endif return D * F * V; @@ -618,7 +621,7 @@ vec3 CalcSpecular( //Energy conserving wrap term. float WrapLambert(in float NL, in float w) { - return clamp((NL + w) / Pow2(1.0 + w), 0.0, 1.0); + return clamp((NL + w) / pow(1.0 + w, 2), 0.0, 1.0); } vec3 Diffuse_Lambert(in vec3 DiffuseColor) @@ -643,7 +646,8 @@ vec3 CalcDiffuse( d *= WrapLambert(NL, 0.5); // Cheap subsurface scatter // ideally we should actually have a new colour for subsurface, but for cloth most times it makes sense to just use the diffuse. - d *= clamp(diffuse + NoL, 0.0, 1.0); + d *= clamp(diffuse + NL, 0.0, 1.0); + return d; #endif } @@ -916,14 +920,14 @@ void main() #if defined(USE_LIGHT_VECTOR) float NH = clamp(dot(N, H), 0.0, 1.0); - - Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness); + float VH = clamp(dot(E, H), 0.0, 1.0); + Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness); #endif #if defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular) float NH = clamp(dot(N, H), 0.0, 1.0); - - Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, roughness) * r_deluxeSpecular; + float VH = clamp(dot(E, H), 0.0, 1.0); + Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness) * r_deluxeSpecular; #endif vec3 reflectance = Fd + Fs; @@ -937,9 +941,9 @@ void main() float NL2 = clamp(dot(N, L2), 0.0, 1.0); float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); float NH2 = clamp(dot(N, H2), 0.0, 1.0); - + float VH2 = clamp(dot(E, H), 0.0, 1.0); reflectance = CalcDiffuse(diffuse.rgb, NE, NL2, L2H2, roughness); - reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, roughness); + reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, VH2, roughness); lightColor = u_PrimaryLightColor * var_Color.rgb; #if defined(USE_SHADOWMAP) From 3959c5d4cf46f2afd204e7fa3039a4cce182dc4f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 10 Dec 2020 11:16:19 +0100 Subject: [PATCH 539/708] Add .shader stage support for cloth brdf --- codemp/rd-rend2/glsl/lightall.glsl | 29 ++++++++++++++++++++++------- codemp/rd-rend2/tr_glsl.cpp | 5 +++++ codemp/rd-rend2/tr_local.h | 4 +++- codemp/rd-rend2/tr_shader.cpp | 10 ++++++++++ 4 files changed, 40 insertions(+), 8 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 618def5e0a..3c5cdd0bea 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -546,6 +546,7 @@ vec3 Fresnel_Schlick(const vec3 f0, float f90, float VoH) return f0 + (f90 - f0) * pow(1.0 - VoH, 5.f); } +// FIXME: Fresnel_Schlick returns vec3, function assumes float -> compile error /*float Diff_Burley(float roughness, float NoV, float NoL, float LoH) { // Burley 2012, "Physically-Based Shading at Disney" @@ -603,7 +604,7 @@ vec3 CalcSpecular( ) { //Using #if to define our BRDF's is a good idea. -#if 1 //should define this as the base BRDF +#if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF vec3 F = F_Schlick(specular, VH); float D = D_GGX(NH, roughness); float V = V_SmithJointApprox(roughness, NE, NL); @@ -626,7 +627,7 @@ float WrapLambert(in float NL, in float w) vec3 Diffuse_Lambert(in vec3 DiffuseColor) { - return DiffuseColor * (1 / M_PI); + return DiffuseColor * (1.0 / M_PI); } vec3 CalcDiffuse( @@ -638,7 +639,7 @@ vec3 CalcDiffuse( ) { //Using #if to define our diffuse's is a good idea. -#if 1 //should define this as the base BRDF +#if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF return Diffuse_Lambert(diffuse); #else //and define this as the cloth diffuse //this cloth model has a wrapped diffuse, we can be energy conservant here. @@ -766,18 +767,32 @@ vec3 CalcIBLContribution( ) { #if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; - vec3 R = reflect(-E, N); // parallax corrected cubemap (cheaper trick) // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ vec3 eyeToCubeCenter = (u_CubeMapInfo.xyz - viewOrigin) * 0.001; vec3 parallax = eyeToCubeCenter + u_CubeMapInfo.w * viewDir * 0.001; - vec3 cubeLightColor = textureLod(u_CubeMap, R - parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; - return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); + #if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF + vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; + return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); + #else //and define this as the cloth brdf + vec3 L = -normalize(R-parallax); + vec3 H = normalize(L + E); + float NL = clamp(dot(N, L), 0.0, 1.0); + float NH = clamp(dot(N, H), 0.0, 1.0); + return cubeLightColor * CalcSpecular( + specular, + NH, + NL, + NE, + 0.0, + 0.0, + roughness + ); + #endif #else return vec3(0.0); #endif diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d5d7f82b73..1157348502 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1640,6 +1640,11 @@ static int GLSL_LoadGPUProgramLightAll( Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } + if (i & LIGHTDEF_USE_CLOTH_BRDF) + { + Q_strcat(extradefines, sizeof(extradefines), "#define USE_CLOTH_BRDF\n"); + } + if (i & LIGHTDEF_USE_VERTEX_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 25387d713a..c4a768bbcf 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -867,6 +867,7 @@ typedef struct { qboolean active; qboolean isDetail; qboolean glow; + qboolean cloth; AlphaTestType alphaTestType; @@ -1182,12 +1183,13 @@ enum LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0040, LIGHTDEF_USE_GLOW_BUFFER = 0x0080, LIGHTDEF_USE_ALPHA_TEST = 0x0100, + LIGHTDEF_USE_CLOTH_BRDF = 0x0200, LIGHTDEF_LIGHTTYPE_MASK = LIGHTDEF_USE_LIGHTMAP | LIGHTDEF_USE_LIGHT_VECTOR | LIGHTDEF_USE_LIGHT_VERTEX, - LIGHTDEF_ALL = 0x01FF, + LIGHTDEF_ALL = 0x03FF, LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 1a18daeb8b..f5aa76514e 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1958,6 +1958,13 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } // + // If this stage is cloth + else if (Q_stricmp(token, "cloth") == 0) + { + stage->cloth = qtrue; + + continue; + } // surfaceSprites ... // else if ( !Q_stricmp( token, "surfacesprites" ) ) @@ -3106,6 +3113,9 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm if (stage->glow) defs |= LIGHTDEF_USE_GLOW_BUFFER; + if (stage->cloth) + defs |= LIGHTDEF_USE_CLOTH_BRDF; + if (stage->alphaTestType != ALPHA_TEST_NONE) defs |= LIGHTDEF_USE_ALPHA_TEST; From 473a35f4313fe18fae0713e0f6b44e019d20a15e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 17 Dec 2020 15:33:02 +0100 Subject: [PATCH 540/708] Splitsum approximation for velvet --- codemp/rd-rend2/glsl/lightall.glsl | 30 ++++--------- codemp/rd-rend2/tr_extramath.cpp | 6 +++ codemp/rd-rend2/tr_extramath.h | 2 +- codemp/rd-rend2/tr_image.cpp | 72 ++++++++++++++++++++++-------- 4 files changed, 69 insertions(+), 41 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 3c5cdd0bea..893fac13ee 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -546,15 +546,14 @@ vec3 Fresnel_Schlick(const vec3 f0, float f90, float VoH) return f0 + (f90 - f0) * pow(1.0 - VoH, 5.f); } -// FIXME: Fresnel_Schlick returns vec3, function assumes float -> compile error -/*float Diff_Burley(float roughness, float NoV, float NoL, float LoH) +vec3 Diff_Burley(float roughness, float NoV, float NoL, float LoH) { // Burley 2012, "Physically-Based Shading at Disney" float f90 = 0.5 + 2.0 * roughness * LoH * LoH; - float lightScatter = Fresnel_Schlick(1.0, f90, NoL); - float viewScatter = Fresnel_Schlick(1.0, f90, NoV); + vec3 lightScatter = Fresnel_Schlick(vec3(1.0), f90, NoL); + vec3 viewScatter = Fresnel_Schlick(vec3(1.0), f90, NoV); return lightScatter * viewScatter * (1.0 / M_PI); -}*/ +} vec3 F_Schlick(in vec3 SpecularColor, in float VH) { @@ -776,22 +775,11 @@ vec3 CalcIBLContribution( vec3 cubeLightColor = textureLod(u_CubeMap, R - parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; #if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF - vec3 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rgb; + vec2 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rg; return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); #else //and define this as the cloth brdf - vec3 L = -normalize(R-parallax); - vec3 H = normalize(L + E); - float NL = clamp(dot(N, L), 0.0, 1.0); - float NH = clamp(dot(N, H), 0.0, 1.0); - return cubeLightColor * CalcSpecular( - specular, - NH, - NL, - NE, - 0.0, - 0.0, - roughness - ); + float EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).b; + return cubeLightColor * EnvBRDF; #endif #else return vec3(0.0); @@ -923,7 +911,7 @@ void main() // energy conservation diffuse.rgb *= vec3(1.0) - specular.rgb; - float roughness = max(1.0 - specular.a, 0.02); + float roughness = mix(1.0, 0.01, specular.a); vec3 H = normalize(L + E); float NE = abs(dot(N, E)) + 1e-5; @@ -939,7 +927,7 @@ void main() Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness); #endif - #if defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular) + #if (defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular)) || defined(USE_LIGHT_VERTEX) float NH = clamp(dot(N, H), 0.0, 1.0); float VH = clamp(dot(E, H), 0.0, 1.0); Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness) * r_deluxeSpecular; diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index ee5bdf9e33..12abaed251 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -258,3 +258,9 @@ float GSmithCorrelated(float roughness, float NdotV, float NdotL) return 0.5f / (visV + visL); } + +float V_Neubelt(float NdotV, float NdotL) +{ + // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" + return 1.0 / (4.0 * (NdotL + NdotV - NdotL * NdotV)); +} diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index 302634bb23..ef84fc8145 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -105,5 +105,5 @@ int NextPowerOfTwo(int in); unsigned short FloatToHalf(float in); uint32_t ReverseBits(uint32_t v); float GSmithCorrelated(float roughness, float ndotv, float ndotl); - +float V_Neubelt(float NdotV, float NdotL); #endif diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 4c90673956..500cb2319b 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1989,6 +1989,10 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei dataFormat = GL_RG; dataType = GL_HALF_FLOAT; break; + case GL_RGB16F: + dataFormat = GL_RGB; + dataType = GL_HALF_FLOAT; + break; case GL_RGBA16F: dataFormat = GL_RGBA; dataType = GL_HALF_FLOAT; @@ -3048,7 +3052,7 @@ static void R_CreateEnvBrdfLUT(void) { if (!r_cubeMapping->integer) return; - uint16_t data[LUT_WIDTH][LUT_HEIGHT][2]; + uint16_t data[LUT_WIDTH][LUT_HEIGHT][3]; unsigned const numSamples = 1024; @@ -3067,43 +3071,73 @@ static void R_CreateEnvBrdfLUT(void) { float scale = 0.0f; float bias = 0.0f; + float velvet = 0.0f; for (unsigned i = 0; i < numSamples; ++i) { float const e1 = (float)i / numSamples; float const e2 = (float)((double)ReverseBits(i) / (double)0x100000000LL); - float const phi = 2.0f * M_PI * e1; - float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (m2 - 1.0f) * e2)); - float const sinTheta = sqrtf(1.0f - cosTheta * cosTheta); - float const hx = sinTheta * cosf(phi); - float const hy = sinTheta * sinf(phi); - float const hz = cosTheta; + // GGX Distribution + { + float const cosTheta = sqrtf((1.0f - e2) / (1.0f + (m2 - 1.0f) * e2)); + float const sinTheta = sqrtf(1.0f - cosTheta * cosTheta); + + float const hx = sinTheta * cosf(phi); + float const hy = sinTheta * sinf(phi); + float const hz = cosTheta; + + float const vdh = vx * hx + vy * hy + vz * hz; + float const lz = 2.0f * vdh * hz - vz; - float const vdh = vx * hx + vy * hy + vz * hz; - float const lz = 2.0f * vdh * hz - vz; + float const NdotL = MAX(lz, 0.0f); + float const NdotH = MAX(hz, 0.0f); + float const VdotH = MAX(vdh, 0.0f); - float const NdotL = MAX(lz, 0.0f); - float const NdotH = MAX(hz, 0.0f); - float const VdotH = MAX(vdh, 0.0f); + if (NdotL > 0.0f) + { + float const visibility = GSmithCorrelated(roughness, NdotV, NdotL); + float const NdotLVisPDF = NdotL * visibility * (4.0f * VdotH / NdotH); + float const fresnel = powf(1.0f - VdotH, 5.0f); - if (NdotL > 0.0f) + scale += NdotLVisPDF * (1.0f - fresnel); + bias += NdotLVisPDF * fresnel; + } + } + + // Charlie Distribution { - float const visibility = GSmithCorrelated(roughness, NdotV, NdotL); - float const NdotLVisPDF = NdotL * visibility * (4.0f * VdotH / NdotH); - float const fresnel = powf(1.0f - VdotH, 5.0f); + float const sinTheta = sqrtf(powf(e2, (2.0f * roughness) / ((2.0f * roughness) + 1.0f))); + float const cosTheta = sqrtf(1.0f - sinTheta * sinTheta); + + float const hx = sinTheta * cosf(phi); + float const hy = sinTheta * sinf(phi); + float const hz = cosTheta; + + float const vdh = vx * hx + vy * hy + vz * hz; + float const lz = 2.0f * vdh * hz - vz; - scale += NdotLVisPDF * (1.0f - fresnel); - bias += NdotLVisPDF * fresnel; + float const NdotL = MAX(lz, 0.0f); + float const NdotH = MAX(hz, 0.0f); + float const VdotH = MAX(vdh, 0.0f); + + if (NdotL > 0.0f) + { + float const velvetV = V_Neubelt(NdotV, NdotL); + float const rcp_pdf = 4.0f * VdotH / NdotH; + velvet += NdotL * velvetV * rcp_pdf; + } } } scale /= numSamples; bias /= numSamples; + velvet /= numSamples; data[y][x][0] = FloatToHalf(scale); data[y][x][1] = FloatToHalf(bias); + data[y][x][2] = FloatToHalf(velvet); } } @@ -3114,7 +3148,7 @@ static void R_CreateEnvBrdfLUT(void) { LUT_HEIGHT, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_RG16F); + GL_RGB16F); } /* From 5509e12d59ae4ccb282ec1a7395fb504689c48f6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 29 Jan 2021 21:32:37 +0100 Subject: [PATCH 541/708] Fix lightstyles It generates a stage per lightstyle, based on a collapsed stage, now. Should also be able to read a deluxe map per lightstyle now. --- codemp/rd-rend2/tr_shade.cpp | 16 ++-- codemp/rd-rend2/tr_shader.cpp | 139 +++++++++++++++++++++------------- 2 files changed, 97 insertions(+), 58 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 213e5e8a62..b30b47ac4a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1499,8 +1499,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // // do multitexture // - bool enableCubeMaps = - (r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) && input->cubemapIndex); + bool enableCubeMaps = ( r_cubeMapping->integer + && !(tr.viewParms.flags & VPF_NOCUBEMAPS) + && input->cubemapIndex + && pStage->rgbGen != CGEN_LIGHTMAPSTYLE ); + bool enableDLights = ( tess.dlightBits + && tess.shader->sort <= SS_OPAQUE + && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY)) + && pStage->rgbGen != CGEN_LIGHTMAPSTYLE ); if ( backEnd.depthFill ) { @@ -1636,10 +1642,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } - - if (tess.dlightBits && - tess.shader->sort <= SS_OPAQUE && - !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY))) + + if ( enableDLights ) uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, tess.dlightBits); else uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, 0); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index f5aa76514e..74a9b8f9e1 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1246,6 +1246,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->bundle[0].image[0] = tr.whiteImage; } else { stage->bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + stage->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; } continue; } @@ -3016,8 +3018,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm if (r_deluxeMapping->integer && tr.worldDeluxeMapping && lightmap) { //ri.Printf(PRINT_ALL, ", deluxemap"); - stage->bundle[TB_DELUXEMAP] = lightmap->bundle[0]; - stage->bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; + stage->bundle[TB_DELUXEMAP] = lightmap->bundle[TB_DELUXEMAP]; } if (r_normalMapping->integer) @@ -3154,38 +3155,6 @@ static qboolean CollapseStagesToGLSL(void) ri.Printf (PRINT_DEVELOPER, "-> %s\n", stage->bundle[0].image[0]->imgName); } - if (!skip) - { - // if 2+ stages and first stage is lightmap, switch them - // this makes it easier for the later bits to process - if (stages[0].active && - stages[0].bundle[0].tcGen >= TCGEN_LIGHTMAP && - stages[0].bundle[0].tcGen <= TCGEN_LIGHTMAP3 && - stages[1].active) - { - int blendBits = stages[1].stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); - - if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) - || blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) - { - int stateBits0 = stages[0].stateBits; - int stateBits1 = stages[1].stateBits; - shaderStage_t swapStage; - - swapStage = stages[0]; - stages[0] = stages[1]; - stages[1] = swapStage; - - stages[0].stateBits = stateBits0; - stages[1].stateBits = stateBits1; - - ri.Printf (PRINT_DEVELOPER, "> Swapped first and second stage.\n"); - ri.Printf (PRINT_DEVELOPER, "-> First stage is now: %s\n", stages[0].bundle[0].image[0]->imgName); - ri.Printf (PRINT_DEVELOPER, "-> Second stage is now: %s\n", stages[1].bundle[0].image[0]->imgName); - } - } - } - if (!skip) { // scan for shaders that aren't supported @@ -3208,7 +3177,8 @@ static qboolean CollapseStagesToGLSL(void) int blendBits = pStage->stateBits & ( GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS ); if (blendBits != (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) - && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) + && blendBits != (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR) + && blendBits != (GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE)) //lightstyle lightmap stages { skip = qtrue; break; @@ -3280,8 +3250,7 @@ static qboolean CollapseStagesToGLSL(void) parallax = qfalse; lightmap = NULL; - - // we have a diffuse map, find matching normal, specular, and lightmap + // we have a diffuse map, find matching lightmap for (j = i + 1; j < MAX_SHADER_STAGES; j++) { shaderStage_t *pStage2 = &stages[j]; @@ -3292,21 +3261,14 @@ static qboolean CollapseStagesToGLSL(void) if (pStage2->glow) continue; - switch(pStage2->type) + if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && + pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && + pStage2->rgbGen != CGEN_EXACT_VERTEX) { - case ST_COLORMAP: - if (pStage2->bundle[0].tcGen >= TCGEN_LIGHTMAP && - pStage2->bundle[0].tcGen <= TCGEN_LIGHTMAP3 && - pStage2->rgbGen != CGEN_EXACT_VERTEX) - { - ri.Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); - lightmap = pStage2; - lightmaps[j] = NULL; - } - break; - - default: - break; + ri.Printf (PRINT_DEVELOPER, "> Setting lightmap for %s to %s\n", pStage->bundle[0].image[0]->imgName, pStage2->bundle[0].image[0]->imgName); + lightmap = pStage2; + lightmaps[j] = NULL; + break; } } @@ -3332,6 +3294,40 @@ static qboolean CollapseStagesToGLSL(void) } CollapseStagesToLightall(diffuse, lightmap, diffuselit, vertexlit, tcgen); + + //find lightstyle stages + if (lightmap != NULL) + { + for (j = i + 2; j < MAX_SHADER_STAGES; j++) + { + shaderStage_t *pStage2 = &stages[j]; + + int blendBits = pStage2->stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS); + + if (blendBits != (GLS_DSTBLEND_ONE | GLS_SRCBLEND_ONE) + || (pStage2->bundle[0].tcGen < TCGEN_LIGHTMAP && pStage2->bundle[0].tcGen > TCGEN_LIGHTMAP3) + || pStage2->rgbGen != CGEN_LIGHTMAPSTYLE) + break; + + //style stage is the previous lightmap stage which is not used anymore + shaderStage_t *styleStage = &stages[j - 1]; + + int style = pStage2->lightmapStyle; + int stateBits = pStage2->stateBits; + textureBundle_t tbLightmap = pStage2->bundle[0]; + textureBundle_t tbDeluxemap = pStage2->bundle[TB_DELUXEMAP]; + + memcpy(styleStage, diffuse, sizeof(shaderStage_t)); + styleStage->lightmapStyle = style; + styleStage->stateBits = stateBits; + styleStage->rgbGen = CGEN_LIGHTMAPSTYLE; + + styleStage->bundle[TB_LIGHTMAP] = tbLightmap; + styleStage->bundle[TB_DELUXEMAP] = tbDeluxemap; + + lightmaps[j] = NULL; + } + } } // deactivate lightmap stages @@ -3383,7 +3379,9 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->adjustColorsForFog) continue; - if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3) + if (pStage->bundle[TB_DIFFUSEMAP].tcGen >= TCGEN_LIGHTMAP + && pStage->bundle[TB_DIFFUSEMAP].tcGen <= TCGEN_LIGHTMAP3 + && pStage->rgbGen != CGEN_LIGHTMAPSTYLE) //don't convert lightstyled lightmap stages { pStage->glslShaderGroup = tr.lightallShader; pStage->glslShaderIndex = LIGHTDEF_USE_LIGHTMAP; @@ -3811,6 +3809,32 @@ static shader_t *FinishShader( void ) { } } + // if 2+ stages and first stage is lightmap, switch them + // this makes it easier for the later bits to process + if (stages[0].active && + stages[0].bundle[0].isLightmap && + stages[1].active) + { + int blendBits = stages[1].stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS); + + if (blendBits == (GLS_DSTBLEND_SRC_COLOR | GLS_SRCBLEND_ZERO) + || blendBits == (GLS_DSTBLEND_ZERO | GLS_SRCBLEND_DST_COLOR)) + { + int stateBits0 = stages[0].stateBits; + int stateBits1 = stages[1].stateBits; + shaderStage_t swapStage; + + swapStage = stages[0]; + stages[0] = stages[1]; + stages[1] = swapStage; + + stages[0].stateBits = stateBits0; + stages[1].stateBits = stateBits1; + + lmStage = 1; + } + } + if (lmStage < MAX_SHADER_STAGES)// && !r_fullbright->value) { int numStyles; @@ -3846,6 +3870,11 @@ static shader_t *FinishShader( void ) { { stages[lmStage+i+1].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[i+1]]; stages[lmStage+i+1].bundle[0].tcGen = (texCoordGen_t)(TCGEN_LIGHTMAP+i+1); + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + { + stages[lmStage+i+1].bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[i+1]]; + stages[lmStage+i+1].bundle[TB_DELUXEMAP].tcGen = (texCoordGen_t)(TCGEN_LIGHTMAP+i+1); + } } stages[lmStage+i+1].rgbGen = CGEN_LIGHTMAPSTYLE; stages[lmStage+i+1].stateBits &= ~(GLS_SRCBLEND_BITS | GLS_DSTBLEND_BITS); @@ -3911,6 +3940,8 @@ static shader_t *FinishShader( void ) { if ( pStage->bundle[0].isLightmap ) { if ( pStage->bundle[0].tcGen == TCGEN_BAD ) { pStage->bundle[0].tcGen = TCGEN_LIGHTMAP; + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + pStage->bundle[TB_DELUXEMAP].tcGen = TCGEN_LIGHTMAP; } hasLightmapStage = qtrue; } else { @@ -4342,6 +4373,8 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte // two pass lightmap stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; stages[0].bundle[0].isLightmap = qtrue; + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + stages[0].bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; stages[0].active = qtrue; stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation // for identitylight @@ -4467,6 +4500,8 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe // two pass lightmap stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; stages[0].bundle[0].isLightmap = qtrue; + if (r_deluxeMapping->integer && tr.worldDeluxeMapping) + stages[0].bundle[TB_DELUXEMAP].image[0] = tr.deluxemaps[shader.lightmapIndex[0]]; stages[0].active = qtrue; stages[0].rgbGen = CGEN_IDENTITY; // lightmaps are scaled on creation // for identitylight From d72bd836bcd4aef75b9f770a94feaa4a859b783f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 29 Jan 2021 23:38:56 +0100 Subject: [PATCH 542/708] Add user controllable parallax bias - parallaxBias can be used per material stage - r_forceParallaxBias can be used for previewing --- codemp/rd-rend2/glsl/lightall.glsl | 17 +++++++++++++---- codemp/rd-rend2/tr_glsl.cpp | 1 + codemp/rd-rend2/tr_init.cpp | 4 ++++ codemp/rd-rend2/tr_local.h | 3 +++ codemp/rd-rend2/tr_shade.cpp | 3 +++ codemp/rd-rend2/tr_shader.cpp | 14 ++++++++++++++ 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 893fac13ee..507f96ac96 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -425,6 +425,7 @@ uniform vec4 u_EnableTextures; uniform vec4 u_NormalScale; uniform vec4 u_SpecularScale; +uniform float u_ParallaxBias; #if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) uniform vec4 u_CubeMapInfo; @@ -460,10 +461,12 @@ float SampleDepth(sampler2D normalMap, vec2 t) return 1.0 - texture(normalMap, t).r; } -float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) +float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, in float parallaxBias) { const int linearSearchSteps = 16; - const int binarySearchSteps = 6; + const int binarySearchSteps = 4; + + vec2 dp = inDp - parallaxBias * ds; // current size of search window float size = 1.0 / float(linearSearchSteps); @@ -504,7 +507,13 @@ float RayIntersectDisplaceMap(vec2 dp, vec2 ds, sampler2D normalMap) depth += size; } - return bestDepth; + vec2 prevTexCoords = dp + ds * (depth-size); + float afterDepth = SampleDepth(normalMap, dp + ds * depth) - depth; + float beforeDepth = SampleDepth(normalMap, prevTexCoords) - depth + size; + float weight = afterDepth / (afterDepth - beforeDepth); + bestDepth -= weight*size; + + return bestDepth - parallaxBias; } #endif @@ -710,7 +719,7 @@ vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) vec3 offsetDir = normalize(E * tangentToWorld); offsetDir.xy *= -u_NormalScale.a / offsetDir.z; - return offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap); + return offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap, u_ParallaxBias); #else return vec2(0.0); #endif diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 1157348502..c889e8659f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -107,6 +107,7 @@ static uniformInfo_t uniformsInfo[] = { "u_VertexLerp" , GLSL_FLOAT, 1 }, { "u_NormalScale", GLSL_VEC4, 1 }, { "u_SpecularScale", GLSL_VEC4, 1 }, + { "u_ParallaxBias", GLSL_FLOAT, 1 }, { "u_ViewInfo", GLSL_VEC4, 1 }, { "u_ViewOrigin", GLSL_VEC3, 1 }, diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 13ab4b6edc..eac44d5c49 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -137,6 +137,7 @@ cvar_t *r_specularMapping; cvar_t *r_deluxeMapping; cvar_t *r_deluxeSpecular; cvar_t *r_parallaxMapping; +cvar_t *r_forceParallaxBias; cvar_t *r_cubeMapping; cvar_t *r_cubeMappingBounces; cvar_t *r_baseNormalX; @@ -1563,6 +1564,9 @@ void R_Register( void ) r_printShaders = ri.Cvar_Get( "r_printShaders", "0", 0, "" ); r_saveFontData = ri.Cvar_Get( "r_saveFontData", "0", 0, "" ); + r_forceParallaxBias = ri.Cvar_Get("r_forceParallaxBias", "0", CVAR_TEMP, ""); + ri.Cvar_CheckRange(r_forceParallaxBias, 0.0f, 1.0f, qfalse); + r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT, "" ); r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT, "" ); r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c4a768bbcf..ddad11520f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -893,6 +893,7 @@ typedef struct { vec4_t normalScale; vec4_t specularScale; + float parallaxBias; surfaceSprite_t *ss; @@ -1332,6 +1333,7 @@ typedef enum UNIFORM_VERTEXLERP, UNIFORM_NORMALSCALE, UNIFORM_SPECULARSCALE, + UNIFORM_PARALLAXBIAS, UNIFORM_VIEWINFO, // znear, zfar, width/2, height/2 UNIFORM_VIEWORIGIN, @@ -2633,6 +2635,7 @@ extern cvar_t *r_normalMapping; extern cvar_t *r_specularMapping; extern cvar_t *r_deluxeMapping; extern cvar_t *r_parallaxMapping; +extern cvar_t *r_forceParallaxBias; extern cvar_t *r_cubeMapping; extern cvar_t *r_cubeMappingBounces; extern cvar_t *r_baseNormalX; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b30b47ac4a..c42e2cc79a 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1492,6 +1492,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); + const float parallaxBias = r_forceParallaxBias->value > 0.0f ? r_forceParallaxBias->value : pStage->parallaxBias; + uniformDataWriter.SetUniformFloat(UNIFORM_PARALLAXBIAS, parallaxBias); + const AlphaTestType alphaTestType = useAlphaTestGE192 ? ALPHA_TEST_GE192 : pStage->alphaTestType; uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, alphaTestType); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 74a9b8f9e1..901f9a3d02 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1643,6 +1643,20 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->normalScale[3] = atof( token ); } // + // parallaxBias + // + else if (!Q_stricmp(token, "parallaxbias")) + { + token = COM_ParseExt(text, qfalse); + if (token[0] == 0) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for parallaxBias in shader '%s'\n", shader.name); + continue; + } + + stage->parallaxBias = atof(token); + } + // // normalScale // or normalScale // or normalScale From 09f10ed1c95160eaa8a6314049030d3f99b2da9e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 29 Jan 2021 23:41:50 +0100 Subject: [PATCH 543/708] Add ORM format and linearRoughness stage keyword --- codemp/rd-rend2/tr_image.cpp | 16 +++++++++++++++- codemp/rd-rend2/tr_local.h | 10 +++++++++- codemp/rd-rend2/tr_shader.cpp | 27 +++++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 500cb2319b..fe62b9c45a 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2610,7 +2610,7 @@ image_t* R_GetLoadedImage(const char *name, int flags) { return NULL; } -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type, int roughnessType) { char diffuseName[MAX_QPATH]; char specularName[MAX_QPATH]; @@ -2693,6 +2693,8 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c case SPEC_RMO: case SPEC_RMOS: roughness = ByteToFloat(rmoPic[i + 0]); + if (roughnessType == ROUGHNESS_PERCEPTUAL) + roughness *= roughness; gloss = (1.0 - roughness) + (0.04 * roughness); metalness = ByteToFloat(rmoPic[i + 1]); ao = ByteToFloat(rmoPic[i + 2]); @@ -2706,8 +2708,20 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c ao += (1.0 - ao) * (1.0 - aoStrength); specular_variance = (type == SPEC_MOSR) ? ByteToFloat(rmoPic[i + 2]) : 1.0f; roughness = ByteToFloat(rmoPic[i + 3]); + if (roughnessType == ROUGHNESS_PERCEPTUAL) + roughness *= roughness; gloss = (1.0 - roughness) + (0.04 * roughness); break; + case SPEC_ORM: + case SPEC_ORMS: + ao = ByteToFloat(rmoPic[i + 0]); + roughness = ByteToFloat(rmoPic[i + 1]); + if (roughnessType == ROUGHNESS_PERCEPTUAL) + roughness *= roughness; + gloss = (1.0 - roughness) + (0.04 * roughness); + metalness = ByteToFloat(rmoPic[i + 2]); + specular_variance = (type == SPEC_ORMS) ? ByteToFloat(rmoPic[i + 3]) : 1.0f; + break; // should never reach this default: specular_variance = 1.0f; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ddad11520f..ca00cb8c9f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -844,6 +844,14 @@ enum specularType SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input SPEC_MOXR, // calculate spec from moxr texture with a specular of 0.04 for dielectric materials SPEC_MOSR, // calculate spec from mosr texture with a specular of 0.0 - 0.08 from input + SPEC_ORM, // calculate spec from orm texture with a specular of 0.04 for dielectric materials + SPEC_ORMS, // calculate spec from orms texture with a specular of 0.0 - 0.08 from input +}; + +enum roughnessType +{ + ROUGHNESS_PERCEPTUAL, + ROUGHNESS_LINEAR, }; enum AlphaTestType @@ -3579,7 +3587,7 @@ void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t di void R_AddDecals( void ); image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type); +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type, int roughnessType); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); const char *RE_ShaderNameFromIndex(int index); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 901f9a3d02..20cbd1b788 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1200,6 +1200,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) char bufferPackedTextureName[MAX_QPATH]; char bufferBaseColorTextureName[MAX_QPATH]; int buildSpecFromPacked = SPEC_NONE; + int roughnessType = ROUGHNESS_PERCEPTUAL; qboolean foundBaseColor = qfalse; stage->active = qtrue; @@ -1406,6 +1407,20 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // + // ormMap || ormsMap + // + else if (!Q_stricmp(token, "ormMap") || !Q_stricmp(token, "ormsMap")) + { + token = COM_ParseExt(text, qfalse); + if (!token[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'ormMap' keyword in shader '%s'\n", shader.name); + return qfalse; + } + buildSpecFromPacked = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; + Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); + } + // // animMap .... // else if ( !Q_stricmp( token, "animMap" ) || !Q_stricmp( token, "clampanimMap" ) || !Q_stricmp( token, "oneshotanimMap" ) ) @@ -1629,6 +1644,14 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, 1.0 - atof(token)); } // + // linearRoughness + // + else if (!Q_stricmp(token, "linearroughness")) + { + roughnessType = ROUGHNESS_LINEAR; + continue; + } + // // parallaxDepth // else if (!Q_stricmp(token, "parallaxdepth")) @@ -2063,7 +2086,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked, roughnessType); VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); } @@ -3112,7 +3135,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm { COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); Q_strcat(specularName, MAX_QPATH, "_rmo"); - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO, ROUGHNESS_PERCEPTUAL); if (stage->bundle[TB_SPECULARMAP].image[0]) VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); From f4e59c4b82c5b45dc9af1fc4effae20f4006ed2b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 29 Jan 2021 23:42:37 +0100 Subject: [PATCH 544/708] Fix dark vanilla lighting --- codemp/rd-rend2/glsl/lightall.glsl | 2 ++ codemp/rd-rend2/tr_bsp.cpp | 32 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 507f96ac96..826abd63e4 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -911,6 +911,8 @@ void main() // light is below the surface ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0); #endif + lightColor *= M_PI; + ambientColor *= M_PI; vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 50dfbb39c8..8cf1cbc1cf 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -424,7 +424,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { color[3] = 1.0f; - R_ColorShiftLightingFloats(color, color, 1.0f, false); + R_ColorShiftLightingFloats(color, color, 1.0f / M_PI, false); ColorToRGBA16F(color, (uint16_t *)(&image[j * 8])); } @@ -795,9 +795,9 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver if (hdrVertColors) { float *hdrColor = hdrVertColors + (ds->firstVert + i) * 3; - color[0] = hdrColor[0]; - color[1] = hdrColor[1]; - color[2] = hdrColor[2]; + color[0] = hdrColor[0] / M_PI; + color[1] = hdrColor[1] / M_PI; + color[2] = hdrColor[2] / M_PI; scale = 1.0f; } else @@ -946,9 +946,9 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve if (hdrVertColors) { float *hdrColor = hdrVertColors + (ds->firstVert + i)*3; - color[0] = hdrColor[0]; - color[1] = hdrColor[1]; - color[2] = hdrColor[2]; + color[0] = hdrColor[0] / M_PI; + color[1] = hdrColor[1] / M_PI; + color[2] = hdrColor[2] / M_PI; scale = 1.0f; } else @@ -1064,9 +1064,9 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * if (hdrVertColors) { float *hdrColor = hdrVertColors + ((ds->firstVert + i) * 3); - color[0] = hdrColor[0]; - color[1] = hdrColor[1]; - color[2] = hdrColor[2]; + color[0] = hdrColor[0] / M_PI; + color[1] = hdrColor[1] / M_PI; + color[2] = hdrColor[2] / M_PI; scale = 1.0f; } else @@ -2744,12 +2744,12 @@ void R_LoadLightGrid( world_t *worldData, lump_t *l ) { for (i = 0; i < worldData->lightGridBounds[0] * worldData->lightGridBounds[1] * worldData->lightGridBounds[2]; i++) { - worldData->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ]; - worldData->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1]; - worldData->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2]; - worldData->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3]; - worldData->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4]; - worldData->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5]; + worldData->hdrLightGrid[i * 6 ] = hdrLightGrid[i * 6 ] / M_PI; + worldData->hdrLightGrid[i * 6 + 1] = hdrLightGrid[i * 6 + 1] / M_PI; + worldData->hdrLightGrid[i * 6 + 2] = hdrLightGrid[i * 6 + 2] / M_PI; + worldData->hdrLightGrid[i * 6 + 3] = hdrLightGrid[i * 6 + 3] / M_PI; + worldData->hdrLightGrid[i * 6 + 4] = hdrLightGrid[i * 6 + 4] / M_PI; + worldData->hdrLightGrid[i * 6 + 5] = hdrLightGrid[i * 6 + 5] / M_PI; } } From cbf8b65f8243d8e345a1b9954fa7d205731404ca Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 31 Jan 2021 02:11:33 +0100 Subject: [PATCH 545/708] Fixing lightstyled surfaces again Now only collapsable shaders swap lightmap and diffuse stage. Support shaders with lighting specular. Excluding them from beeing collapsed doesnt make any sense to me. Fixes a rare case of strange looking lightstyles. Don't collapse environment mapped stages. Never seen anybody using it for materials besides reflections. --- codemp/rd-rend2/tr_shader.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 20cbd1b788..c71eb762d7 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3239,7 +3239,6 @@ static qboolean CollapseStagesToGLSL(void) switch(pStage->alphaGen) { - case AGEN_LIGHTING_SPECULAR: case AGEN_PORTAL: skip = qtrue; break; @@ -3279,6 +3278,10 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->type != ST_COLORMAP) continue; + // skip agen spec stages and environment mapped stages + if (pStage->alphaGen == AGEN_LIGHTING_SPECULAR || pStage->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED) + continue; + // skip lightmaps if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) continue; @@ -3850,7 +3853,8 @@ static shader_t *FinishShader( void ) { // this makes it easier for the later bits to process if (stages[0].active && stages[0].bundle[0].isLightmap && - stages[1].active) + stages[1].active && + shader.numDeforms == 0) //only for shaders that can be collapsed { int blendBits = stages[1].stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS); From 532cb006d584ba8312fe8b2cd101d7cec84a7359 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 12 Feb 2021 10:20:24 +0100 Subject: [PATCH 546/708] Small fixes --- codemp/rd-rend2/glsl/lightall.glsl | 3 +-- codemp/rd-rend2/tr_shade.cpp | 4 +--- codemp/rd-rend2/tr_shader.cpp | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 826abd63e4..add92c53bb 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -779,8 +779,7 @@ vec3 CalcIBLContribution( // parallax corrected cubemap (cheaper trick) // from http://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/ - vec3 eyeToCubeCenter = (u_CubeMapInfo.xyz - viewOrigin) * 0.001; - vec3 parallax = eyeToCubeCenter + u_CubeMapInfo.w * viewDir * 0.001; + vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; vec3 cubeLightColor = textureLod(u_CubeMap, R - parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; #if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c42e2cc79a..c98e065f54 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1636,9 +1636,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddStaticImage(cubemap->image, TB_CUBEMAP); samplerBindingsWriter.AddStaticImage(tr.envBrdfImage, TB_ENVBRDFMAP); - vec[0] = cubemap->origin[0] - backEnd.viewParms.ori.origin[0]; - vec[1] = cubemap->origin[1] - backEnd.viewParms.ori.origin[1]; - vec[2] = cubemap->origin[2] - backEnd.viewParms.ori.origin[2]; + VectorSubtract(cubemap->origin, backEnd.viewParms.ori.origin, vec); vec[3] = 1.0f; VectorScale4(vec, 1.0f / cubemap->parallaxRadius, vec); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c71eb762d7..e984fddc2e 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1200,7 +1200,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) char bufferPackedTextureName[MAX_QPATH]; char bufferBaseColorTextureName[MAX_QPATH]; int buildSpecFromPacked = SPEC_NONE; - int roughnessType = ROUGHNESS_PERCEPTUAL; + int roughnessType = ROUGHNESS_LINEAR; qboolean foundBaseColor = qfalse; stage->active = qtrue; @@ -3135,7 +3135,7 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm { COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); Q_strcat(specularName, MAX_QPATH, "_rmo"); - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO, ROUGHNESS_PERCEPTUAL); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO, ROUGHNESS_LINEAR); if (stage->bundle[TB_SPECULARMAP].image[0]) VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); From 2de18c33a8ad4eded8d351b52ff862f8c368c7f0 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 May 2021 14:47:43 +0200 Subject: [PATCH 547/708] Reworking sun lighting Also fixed a bad in the parallax code --- codemp/rd-rend2/glsl/lightall.glsl | 29 ++----- codemp/rd-rend2/glsl/shadowmask.glsl | 114 ++++++++++++++++++--------- codemp/rd-rend2/tr_glsl.cpp | 4 +- codemp/rd-rend2/tr_image.cpp | 5 ++ codemp/rd-rend2/tr_surface.cpp | 2 +- 5 files changed, 92 insertions(+), 62 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index add92c53bb..563c5f47b6 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -101,10 +101,6 @@ out vec4 var_Bitangent; out vec4 var_LightDir; #endif -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -out vec4 var_PrimaryLightDir; -#endif - vec4 CalcColor(vec3 position) { vec4 color = vec4(1.0); @@ -318,11 +314,6 @@ void main() } var_Color *= disintegration; -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) - var_PrimaryLightDir.xyz = u_PrimaryLightOrigin.xyz - (position * u_PrimaryLightOrigin.w); - var_PrimaryLightDir.w = u_PrimaryLightRadius * u_PrimaryLightRadius; -#endif - #if defined(PER_PIXEL_LIGHTING) var_LightDir = vec4(L, 0.0); #if defined(USE_DELUXEMAP) @@ -446,10 +437,6 @@ in vec4 var_Bitangent; in vec4 var_LightDir; #endif -#if defined(USE_PRIMARY_LIGHT) || defined(USE_SHADOWMAP) -in vec4 var_PrimaryLightDir; -#endif - out vec4 out_Color; out vec4 out_Glow; @@ -464,7 +451,7 @@ float SampleDepth(sampler2D normalMap, vec2 t) float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, in float parallaxBias) { const int linearSearchSteps = 16; - const int binarySearchSteps = 4; + const int binarySearchSteps = 6; vec2 dp = inDp - parallaxBias * ds; @@ -495,7 +482,7 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, for(int i = 0; i < binarySearchSteps; ++i) { size *= 0.5; - + float t = SampleDepth(normalMap, dp + ds * depth); if(depth >= t) @@ -510,8 +497,8 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, vec2 prevTexCoords = dp + ds * (depth-size); float afterDepth = SampleDepth(normalMap, dp + ds * depth) - depth; float beforeDepth = SampleDepth(normalMap, prevTexCoords) - depth + size; - float weight = afterDepth / (afterDepth - beforeDepth); - bestDepth -= weight*size; + float weight = beforeDepth / (beforeDepth - afterDepth); + bestDepth += weight*size; return bestDepth - parallaxBias; } @@ -886,11 +873,11 @@ void main() L /= sqrt(sqrLightDist); #if defined(USE_SHADOWMAP) - vec2 shadowTex = gl_FragCoord.xy * r_FBufScale; + vec2 shadowTex = gl_FragCoord.xy / r_FBufScale; float shadowValue = texture(u_ShadowMap, shadowTex).r; // surfaces not facing the light are always shadowed - vec3 primaryLightDir = normalize(var_PrimaryLightDir.xyz); + vec3 primaryLightDir = normalize(u_PrimaryLightOrigin.xyz); shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) @@ -949,9 +936,9 @@ void main() out_Color.rgb += ambientColor * diffuse.rgb; #if defined(USE_PRIMARY_LIGHT) - vec3 L2 = normalize(var_PrimaryLightDir.xyz); + vec3 L2 = normalize(u_PrimaryLightOrigin.xyz); vec3 H2 = normalize(L2 + E); - float NL2 = clamp(dot(N, L2), 0.0, 1.0); + float NL2 = clamp(min(dot(N, L2), dot(var_Normal.xyz, L2)), 0.0, 1.0); float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); float NH2 = clamp(dot(N, H2), 0.0, 1.0); float VH2 = clamp(dot(E, H), 0.0, 1.0); diff --git a/codemp/rd-rend2/glsl/shadowmask.glsl b/codemp/rd-rend2/glsl/shadowmask.glsl index d05938b24f..1123330ee1 100644 --- a/codemp/rd-rend2/glsl/shadowmask.glsl +++ b/codemp/rd-rend2/glsl/shadowmask.glsl @@ -21,10 +21,10 @@ void main() /*[Fragment]*/ uniform sampler2D u_ScreenDepthMap; -uniform sampler2D u_ShadowMap; +uniform sampler2DShadow u_ShadowMap; #if defined(USE_SHADOW_CASCADE) -uniform sampler2D u_ShadowMap2; -uniform sampler2D u_ShadowMap3; +uniform sampler2DShadow u_ShadowMap2; +uniform sampler2DShadow u_ShadowMap3; #endif uniform mat4 u_ShadowMvp; @@ -62,43 +62,74 @@ float random( const vec2 p ) return mod( 123456789., 1e-7 + 256. * dot(p,r) ); } -float PCF(const sampler2D shadowmap, const vec2 st, const float dist) +const vec2 poissonDisk[16] = vec2[16]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ), + vec2( -0.91588581, 0.45771432 ), + vec2( -0.81544232, -0.87912464 ), + vec2( -0.38277543, 0.27676845 ), + vec2( 0.97484398, 0.75648379 ), + vec2( 0.44323325, -0.97511554 ), + vec2( 0.53742981, -0.47373420 ), + vec2( -0.26496911, -0.41893023 ), + vec2( 0.79197514, 0.19090188 ), + vec2( -0.24188840, 0.99706507 ), + vec2( -0.81409955, 0.91437590 ), + vec2( 0.19984126, 0.78641367 ), + vec2( 0.14383161, -0.14100790 ) +); + +float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist, float PCFScale) { float mult; - float scale = 2.0 / r_shadowMapSize; + float scale = PCFScale / r_shadowMapSize; #if defined(USE_SHADOW_FILTER) float r = random(var_DepthTex.xy); - float sinr = sin(r) * scale; - float cosr = cos(r) * scale; - mat2 rmat = mat2(cosr, sinr, -sinr, cosr); + float sinr = sin(r); + float cosr = cos(r); + mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; - mult = step(dist, texture(shadowmap, st + rmat * vec2(-0.7055767, 0.196515)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(0.3524343, -0.7791386)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(0.2391056, 0.9189604)).r); + mult = texture(shadowmap, vec3(st + rmat * vec2(-0.7055767, 0.196515), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(0.3524343, -0.7791386), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(0.2391056, 0.9189604), dist)); #if defined(USE_SHADOW_FILTER2) - mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.07580382, -0.09224417)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(0.5784913, -0.002528916)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(0.192888, 0.4064181)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.6335801, -0.5247476)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(-0.5579782, 0.7491854)).r); - mult += step(dist, texture(shadowmap, st + rmat * vec2(0.7320465, 0.6317794)).r); + mult += texture(shadowmap, vec3(st + rmat * vec2(-0.07580382, -0.09224417), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(0.5784913, -0.002528916), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(0.192888, 0.4064181), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(-0.6335801, -0.5247476), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(-0.5579782, 0.7491854), dist)); + mult += texture(shadowmap, vec3(st + rmat * vec2(0.7320465, 0.6317794), dist)); mult *= 0.11111; #else mult *= 0.33333; #endif #else - mult = step(dist, texture(shadowmap, st).r); + float r = random(var_DepthTex.xy); + float sinr = sin(r); + float cosr = cos(r); + mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; + + mult = texture(shadowmap, vec3(st, dist)); + for (int i = 0; i < 16; i++) + { + vec2 delta = rmat * poissonDisk[i]; + mult += texture(shadowmap, vec3(st + delta, dist)); + } + mult *= 1.0 / 17.0; #endif return mult; } -float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear) +float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear, float maxErrorFactor) { float sampleZDivW = texture(depthMap, tex).r; - sampleZDivW -= DEPTH_MAX_ERROR; + sampleZDivW += DEPTH_MAX_ERROR; + //sampleZDivW -= maxErrorFactor * fwidth(sampleZDivW); return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } @@ -106,50 +137,57 @@ void main() { float result; - float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x); + float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); float sampleZ = u_ViewInfo.y * depth; vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); - - vec4 shadowpos = u_ShadowMvp * biasPos; - + + const float PCFScale = 1.0; + const float edgeBias = 0.5 - ( 4.0 * PCFScale / r_shadowMapSize ); + float edgefactor = 0.0; + #if defined(USE_SHADOW_CASCADE) const float fadeTo = 1.0; result = fadeTo; #else result = 0.0; #endif - - if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + vec4 shadowpos = u_ShadowMvp * biasPos; + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) { - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z); + vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); + edgefactor = 2.0 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); + result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); } #if defined(USE_SHADOW_CASCADE) else { + depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); + biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); shadowpos = u_ShadowMvp2 * biasPos; - - if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) { - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z); + vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); + edgefactor = 0.5 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); + result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); } else { + depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); + biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); shadowpos = u_ShadowMvp3 * biasPos; - - if (all(lessThanEqual(abs(shadowpos.xyz), vec3(abs(shadowpos.w))))) + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(1.0)))) { - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z); - + result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z, PCFScale); float fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0); result = mix(result, fadeTo, fade); } } } #endif - + out_Color = vec4(vec3(result), 1.0); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c889e8659f..306afb800e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -343,8 +343,8 @@ static size_t GLSL_GetShaderHeader( va("#define MAX_G2_BONES %i\n", MAX_G2_BONES)); - fbufWidthScale = 1.0f / ((float)glConfig.vidWidth); - fbufHeightScale = 1.0f / ((float)glConfig.vidHeight); + fbufWidthScale = (float)glConfig.vidWidth; + fbufHeightScale = (float)glConfig.vidHeight; Q_strcat(dest, size, va("#ifndef r_FBufScale\n" "#define r_FBufScale vec2(%f, %f)\n" diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index fe62b9c45a..26b469b2c0 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3383,6 +3383,11 @@ void R_CreateBuiltinImages( void ) { r_shadowMapSize->integer, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); + GL_Bind(tr.sunShadowDepthImage[x]); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } tr.screenShadowImage = R_CreateImage( diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 5bc1aa620f..6a05be74db 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2137,7 +2137,7 @@ static void RB_SurfaceSkip( void *surf ) { static void RB_SurfaceSprites( srfSprites_t *surf ) { - if ( !r_surfaceSprites->integer ) + if ( !r_surfaceSprites->integer || surf->numSprites == 0) return; RB_EndSurface(); From 34a0ab0446d2ce82eb15a2b5104ae9313e46ebbd Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 19 Aug 2021 13:16:58 +0200 Subject: [PATCH 548/708] Add mikktspace tangent space Reworked parallax a bit, fixed some other issues --- codemp/rd-rend2/CMakeLists.txt | 9 +- codemp/rd-rend2/MikkTSpace/README.md | 4 + codemp/rd-rend2/MikkTSpace/mikktspace.c | 1899 +++++++++++++++++++++++ codemp/rd-rend2/MikkTSpace/mikktspace.h | 145 ++ codemp/rd-rend2/glsl/lightall.glsl | 145 +- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 112 +- codemp/rd-rend2/tr_ghoul2.cpp | 178 +-- codemp/rd-rend2/tr_image.cpp | 25 +- codemp/rd-rend2/tr_light.cpp | 50 +- codemp/rd-rend2/tr_local.h | 27 +- codemp/rd-rend2/tr_main.cpp | 272 ++++ codemp/rd-rend2/tr_model.cpp | 68 +- codemp/rd-rend2/tr_shader.cpp | 23 +- 14 files changed, 2617 insertions(+), 342 deletions(-) create mode 100644 codemp/rd-rend2/MikkTSpace/README.md create mode 100644 codemp/rd-rend2/MikkTSpace/mikktspace.c create mode 100644 codemp/rd-rend2/MikkTSpace/mikktspace.h diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 767540f961..109ae2186b 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -64,14 +64,19 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_vbo.cpp" "${MPDir}/rd-rend2/tr_world.cpp" "${MPDir}/rd-rend2/tr_weather.cpp" - "${MPDir}/rd-rend2/tr_weather.h" - ) + "${MPDir}/rd-rend2/tr_weather.h") source_group("renderer" FILES ${MPRend2Files}) file(GLOB MPRend2GLSLFiles "${MPDir}/rd-rend2/glsl/*.glsl") source_group("renderer\\glsl" FILES ${MPRend2GLSLFiles}) set(MPRend2Files ${MPRend2Files} ${MPRend2GLSLFiles}) +set(MPRend2MikktFiles + "${MPDir}/rd-rend2/MikkTSpace/mikktspace.h" + "${MPDir}/rd-rend2/MikkTSpace/mikktspace.c") +source_group("MikktSpace" FILES ${MPRend2MikktFiles}) +set(MPRend2Files ${MPRend2Files} ${MPRend2MikktFiles}) + set(MPRend2Ghoul2Files "${MPDir}/ghoul2/g2_local.h" "${MPDir}/ghoul2/ghoul2_shared.h" diff --git a/codemp/rd-rend2/MikkTSpace/README.md b/codemp/rd-rend2/MikkTSpace/README.md new file mode 100644 index 0000000000..9fda1559e4 --- /dev/null +++ b/codemp/rd-rend2/MikkTSpace/README.md @@ -0,0 +1,4 @@ +# MikkTSpace +A common standard for tangent space used in baking tools to produce normal maps. + +More information can be found at http://www.mikktspace.com/. diff --git a/codemp/rd-rend2/MikkTSpace/mikktspace.c b/codemp/rd-rend2/MikkTSpace/mikktspace.c new file mode 100644 index 0000000000..0342ae0146 --- /dev/null +++ b/codemp/rd-rend2/MikkTSpace/mikktspace.c @@ -0,0 +1,1899 @@ +/** \file mikktspace/mikktspace.c + * \ingroup mikktspace + */ +/** + * Copyright (C) 2011 by Morten S. Mikkelsen + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#include +#include +#include +#include +#include +#include + +#include "mikktspace.h" + +#define TFALSE 0 +#define TTRUE 1 + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795 +#endif + +#define INTERNAL_RND_SORT_SEED 39871946 + +// internal structure +typedef struct { + float x, y, z; +} SVec3; + +static tbool veq( const SVec3 v1, const SVec3 v2 ) +{ + return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); +} + +static SVec3 vadd( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x + v2.x; + vRes.y = v1.y + v2.y; + vRes.z = v1.z + v2.z; + + return vRes; +} + + +static SVec3 vsub( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x - v2.x; + vRes.y = v1.y - v2.y; + vRes.z = v1.z - v2.z; + + return vRes; +} + +static SVec3 vscale(const float fS, const SVec3 v) +{ + SVec3 vRes; + + vRes.x = fS * v.x; + vRes.y = fS * v.y; + vRes.z = fS * v.z; + + return vRes; +} + +static float LengthSquared( const SVec3 v ) +{ + return v.x*v.x + v.y*v.y + v.z*v.z; +} + +static float Length( const SVec3 v ) +{ + return sqrtf(LengthSquared(v)); +} + +static SVec3 Normalize( const SVec3 v ) +{ + return vscale(1 / Length(v), v); +} + +static float vdot( const SVec3 v1, const SVec3 v2) +{ + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; +} + + +static tbool NotZero(const float fX) +{ + // could possibly use FLT_EPSILON instead + return fabsf(fX) > FLT_MIN; +} + +static tbool VNotZero(const SVec3 v) +{ + // might change this to an epsilon based test + return NotZero(v.x) || NotZero(v.y) || NotZero(v.z); +} + + + +typedef struct { + int iNrFaces; + int * pTriMembers; +} SSubGroup; + +typedef struct { + int iNrFaces; + int * pFaceIndices; + int iVertexRepresentitive; + tbool bOrientPreservering; +} SGroup; + +// +#define MARK_DEGENERATE 1 +#define QUAD_ONE_DEGEN_TRI 2 +#define GROUP_WITH_ANY 4 +#define ORIENT_PRESERVING 8 + + + +typedef struct { + int FaceNeighbors[3]; + SGroup * AssignedGroup[3]; + + // normalized first order face derivatives + SVec3 vOs, vOt; + float fMagS, fMagT; // original magnitudes + + // determines if the current and the next triangle are a quad. + int iOrgFaceNumber; + int iFlag, iTSpacesOffs; + unsigned char vert_num[4]; +} STriInfo; + +typedef struct { + SVec3 vOs; + float fMagS; + SVec3 vOt; + float fMagT; + int iCounter; // this is to average back into quads. + tbool bOrient; +} STSpace; + +static int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn); +static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext); + +static int MakeIndex(const int iFace, const int iVert) +{ + assert(iVert>=0 && iVert<4 && iFace>=0); + return (iFace<<2) | (iVert&0x3); +} + +static void IndexToData(int * piFace, int * piVert, const int iIndexIn) +{ + piVert[0] = iIndexIn&0x3; + piFace[0] = iIndexIn>>2; +} + +static STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) +{ + STSpace ts_res; + + // this if is important. Due to floating point precision + // averaging when ts0==ts1 will cause a slight difference + // which results in tangent space splits later on + if (pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT && + veq(pTS0->vOs,pTS1->vOs) && veq(pTS0->vOt, pTS1->vOt)) + { + ts_res.fMagS = pTS0->fMagS; + ts_res.fMagT = pTS0->fMagT; + ts_res.vOs = pTS0->vOs; + ts_res.vOt = pTS0->vOt; + } + else + { + ts_res.fMagS = 0.5f*(pTS0->fMagS+pTS1->fMagS); + ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT); + ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs); + ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt); + if ( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs); + if ( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt); + } + + return ts_res; +} + + + +static SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index); +static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index); +static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index); + + +// degen triangles +static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris); +static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris); + + +tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext) +{ + return genTangSpace(pContext, 180.0f); +} + +tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold) +{ + // count nr_triangles + int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL; + STriInfo * pTriInfos = NULL; + SGroup * pGroups = NULL; + STSpace * psTspace = NULL; + int iNrTrianglesIn = 0, f=0, t=0, i=0; + int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0; + int iNrActiveGroups = 0, index = 0; + const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext); + tbool bRes = TFALSE; + const float fThresCos = (float) cos((fAngularThreshold*(float)M_PI)/180.0f); + + // verify all call-backs have been set + if ( pContext->m_pInterface->m_getNumFaces==NULL || + pContext->m_pInterface->m_getNumVerticesOfFace==NULL || + pContext->m_pInterface->m_getPosition==NULL || + pContext->m_pInterface->m_getNormal==NULL || + pContext->m_pInterface->m_getTexCoord==NULL ) + return TFALSE; + + // count triangles on supported faces + for (f=0; fm_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts==3) ++iNrTrianglesIn; + else if (verts==4) iNrTrianglesIn += 2; + } + if (iNrTrianglesIn<=0) return TFALSE; + + // allocate memory for an index list + piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn); + pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn); + if (piTriListIn==NULL || pTriInfos==NULL) + { + if (piTriListIn!=NULL) free(piTriListIn); + if (pTriInfos!=NULL) free(pTriInfos); + return TFALSE; + } + + // make an initial triangle --> face index list + iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); + + // make a welded index list of identical positions and attributes (pos, norm, texc) + //printf("gen welded index list begin\n"); + GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn); + //printf("gen welded index list end\n"); + + // Mark all degenerate triangles + iTotTris = iNrTrianglesIn; + iDegenTriangles = 0; + for (t=0; tm_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts!=3 && verts!=4) continue; + + + // I've decided to let degenerate triangles and group-with-anythings + // vary between left/right hand coordinate systems at the vertices. + // All healthy triangles on the other hand are built to always be either or. + + /*// force the coordinate system orientation to be uniform for every face. + // (this is already the case for good triangles but not for + // degenerate ones and those with bGroupWithAnything==true) + bool bOrient = psTspace[index].bOrient; + if (psTspace[index].iCounter == 0) // tspace was not derived from a group + { + // look for a space created in GenerateTSpaces() by iCounter>0 + bool bNotFound = true; + int i=1; + while (i 0) bNotFound=false; + else ++i; + } + if (!bNotFound) bOrient = psTspace[index+i].bOrient; + }*/ + + // set data + for (i=0; ivOs.x, pTSpace->vOs.y, pTSpace->vOs.z}; + float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z}; + if (pContext->m_pInterface->m_setTSpace!=NULL) + pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i); + if (pContext->m_pInterface->m_setTSpaceBasic!=NULL) + pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i); + + ++index; + } + } + + free(psTspace); + + + return TTRUE; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct { + float vert[3]; + int index; +} STmpVert; + +static const int g_iCells = 2048; + +#ifdef _MSC_VER +# define NOINLINE __declspec(noinline) +#else +# define NOINLINE __attribute__ ((noinline)) +#endif + +// it is IMPORTANT that this function is called to evaluate the hash since +// inlining could potentially reorder instructions and generate different +// results for the same effective input value fVal. +static NOINLINE int FindGridCell(const float fMin, const float fMax, const float fVal) +{ + const float fIndex = g_iCells * ((fVal-fMin)/(fMax-fMin)); + const int iIndex = (int)fIndex; + return iIndex < g_iCells ? (iIndex >= 0 ? iIndex : 0) : (g_iCells - 1); +} + +static void MergeVertsFast(int piTriList_in_and_out[], STmpVert pTmpVert[], const SMikkTSpaceContext * pContext, const int iL_in, const int iR_in); +static void MergeVertsSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int pTable[], const int iEntries); +static void GenerateSharedVerticesIndexListSlow(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); + +static void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) +{ + + // Generate bounding box + int * piHashTable=NULL, * piHashCount=NULL, * piHashOffsets=NULL, * piHashCount2=NULL; + STmpVert * pTmpVert = NULL; + int i=0, iChannel=0, k=0, e=0; + int iMaxCount=0; + SVec3 vMin = GetPosition(pContext, 0), vMax = vMin, vDim; + float fMin, fMax; + for (i=1; i<(iNrTrianglesIn*3); i++) + { + const int index = piTriList_in_and_out[i]; + + const SVec3 vP = GetPosition(pContext, index); + if (vMin.x > vP.x) vMin.x = vP.x; + else if (vMax.x < vP.x) vMax.x = vP.x; + if (vMin.y > vP.y) vMin.y = vP.y; + else if (vMax.y < vP.y) vMax.y = vP.y; + if (vMin.z > vP.z) vMin.z = vP.z; + else if (vMax.z < vP.z) vMax.z = vP.z; + } + + vDim = vsub(vMax,vMin); + iChannel = 0; + fMin = vMin.x; fMax=vMax.x; + if (vDim.y>vDim.x && vDim.y>vDim.z) + { + iChannel=1; + fMin = vMin.y; + fMax = vMax.y; + } + else if (vDim.z>vDim.x) + { + iChannel=2; + fMin = vMin.z; + fMax = vMax.z; + } + + // make allocations + piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3); + piHashCount = (int *) malloc(sizeof(int)*g_iCells); + piHashOffsets = (int *) malloc(sizeof(int)*g_iCells); + piHashCount2 = (int *) malloc(sizeof(int)*g_iCells); + + if (piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL) + { + if (piHashTable!=NULL) free(piHashTable); + if (piHashCount!=NULL) free(piHashCount); + if (piHashOffsets!=NULL) free(piHashOffsets); + if (piHashCount2!=NULL) free(piHashCount2); + GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn); + return; + } + memset(piHashCount, 0, sizeof(int)*g_iCells); + memset(piHashCount2, 0, sizeof(int)*g_iCells); + + // count amount of elements in each cell unit + for (i=0; i<(iNrTrianglesIn*3); i++) + { + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z); + const int iCell = FindGridCell(fMin, fMax, fVal); + ++piHashCount[iCell]; + } + + // evaluate start index of each cell. + piHashOffsets[0]=0; + for (k=1; kpTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c]; + if (fvMax[c]dx && dy>dz) channel=1; + else if (dz>dx) channel=2; + + fSep = 0.5f*(fvMax[channel]+fvMin[channel]); + + // stop if all vertices are NaNs + if (!isfinite(fSep)) + return; + + // terminate recursion when the separation/average value + // is no longer strictly between fMin and fMax values. + if (fSep>=fvMax[channel] || fSep<=fvMin[channel]) + { + // complete the weld + for (l=iL_in; l<=iR_in; l++) + { + int i = pTmpVert[l].index; + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const SVec3 vN = GetNormal(pContext, index); + const SVec3 vT = GetTexCoord(pContext, index); + + tbool bNotFound = TTRUE; + int l2=iL_in, i2rec=-1; + while (l20); // at least 2 entries + + // separate (by fSep) all points between iL_in and iR_in in pTmpVert[] + while (iL < iR) + { + tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE; + while ((!bReadyLeftSwap) && iL=iL_in && iL<=iR_in); + bReadyLeftSwap = !(pTmpVert[iL].vert[channel]=iL_in && iR<=iR_in); + bReadyRightSwap = pTmpVert[iR].vert[channel]m_pInterface->m_getNumFaces(pContext); f++) + { + const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f); + if (verts!=3 && verts!=4) continue; + + pTriInfos[iDstTriIndex].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs; + + if (verts==3) + { + unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num; + pVerts[0]=0; pVerts[1]=1; pVerts[2]=2; + piTriList_out[iDstTriIndex*3+0] = MakeIndex(f, 0); + piTriList_out[iDstTriIndex*3+1] = MakeIndex(f, 1); + piTriList_out[iDstTriIndex*3+2] = MakeIndex(f, 2); + ++iDstTriIndex; // next + } + else + { + { + pTriInfos[iDstTriIndex+1].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex+1].iTSpacesOffs = iTSpacesOffs; + } + + { + // need an order independent way to evaluate + // tspace on quads. This is done by splitting + // along the shortest diagonal. + const int i0 = MakeIndex(f, 0); + const int i1 = MakeIndex(f, 1); + const int i2 = MakeIndex(f, 2); + const int i3 = MakeIndex(f, 3); + const SVec3 T0 = GetTexCoord(pContext, i0); + const SVec3 T1 = GetTexCoord(pContext, i1); + const SVec3 T2 = GetTexCoord(pContext, i2); + const SVec3 T3 = GetTexCoord(pContext, i3); + const float distSQ_02 = LengthSquared(vsub(T2,T0)); + const float distSQ_13 = LengthSquared(vsub(T3,T1)); + tbool bQuadDiagIs_02; + if (distSQ_02m_pInterface->m_getPosition(pContext, pos, iF, iI); + res.x=pos[0]; res.y=pos[1]; res.z=pos[2]; + return res; +} + +static SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float norm[3]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getNormal(pContext, norm, iF, iI); + res.x=norm[0]; res.y=norm[1]; res.z=norm[2]; + return res; +} + +static SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float texc[2]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getTexCoord(pContext, texc, iF, iI); + res.x=texc[0]; res.y=texc[1]; res.z=1.0f; + return res; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef union { + struct + { + int i0, i1, f; + }; + int array[3]; +} SEdge; + +static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn); +static void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn); + +// returns the texture area times 2 +static float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) +{ + const SVec3 t1 = GetTexCoord(pContext, indices[0]); + const SVec3 t2 = GetTexCoord(pContext, indices[1]); + const SVec3 t3 = GetTexCoord(pContext, indices[2]); + + const float t21x = t2.x-t1.x; + const float t21y = t2.y-t1.y; + const float t31x = t3.x-t1.x; + const float t31y = t3.y-t1.y; + + const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x; + + return fSignedAreaSTx2<0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2; +} + +static void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) +{ + int f=0, i=0, t=0; + // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function. + + // generate neighbor info list + for (f=0; f0 ? ORIENT_PRESERVING : 0); + + if ( NotZero(fSignedAreaSTx2) ) + { + const float fAbsArea = fabsf(fSignedAreaSTx2); + const float fLenOs = Length(vOs); + const float fLenOt = Length(vOt); + const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f; + if ( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs); + if ( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt); + + // evaluate magnitudes prior to normalization of vOs and vOt + pTriInfos[f].fMagS = fLenOs / fAbsArea; + pTriInfos[f].fMagT = fLenOt / fAbsArea; + + // if this is a good triangle + if ( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT)) + pTriInfos[f].iFlag &= (~GROUP_WITH_ANY); + } + } + + // force otherwise healthy quads to a fixed orientation + while (t<(iNrTrianglesIn-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if (iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + + // bad triangles should already have been removed by + // DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false + if ((bIsDeg_a||bIsDeg_b)==TFALSE) + { + const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + // if this happens the quad has extremely bad mapping!! + if (bOrientA!=bOrientB) + { + //printf("found quad with bad mapping\n"); + tbool bChooseOrientFirstTri = TFALSE; + if ((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE; + else if ( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) ) + bChooseOrientFirstTri = TTRUE; + + // force match + { + const int t0 = bChooseOrientFirstTri ? t : (t+1); + const int t1 = bChooseOrientFirstTri ? (t+1) : t; + pTriInfos[t1].iFlag &= (~ORIENT_PRESERVING); // clear first + pTriInfos[t1].iFlag |= (pTriInfos[t0].iFlag&ORIENT_PRESERVING); // copy bit + } + } + } + t += 2; + } + else + ++t; + } + + // match up edge pairs + { + SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3); + if (pEdges==NULL) + BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn); + else + { + BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn); + + free(pEdges); + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup); +static void AddTriToGroup(SGroup * pGroup, const int iTriIndex); + +static int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn) +{ + const int iNrMaxGroups = iNrTrianglesIn*3; + int iNrActiveGroups = 0; + int iOffset = 0, f=0, i=0; + (void)iNrMaxGroups; /* quiet warnings in non debug mode */ + for (f=0; fiVertexRepresentitive = vert_index; + pTriInfos[f].AssignedGroup[i]->bOrientPreservering = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0; + pTriInfos[f].AssignedGroup[i]->iNrFaces = 0; + pTriInfos[f].AssignedGroup[i]->pFaceIndices = &piGroupTrianglesBuffer[iOffset]; + ++iNrActiveGroups; + + AddTriToGroup(pTriInfos[f].AssignedGroup[i], f); + bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + neigh_indexL = pTriInfos[f].FaceNeighbors[i]; + neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2]; + if (neigh_indexL>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexL, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexL].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + (void)bAnswer, (void)bDiff; /* quiet warnings in non debug mode */ + } + if (neigh_indexR>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexR, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexR].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + (void)bAnswer, (void)bDiff; /* quiet warnings in non debug mode */ + } + + // update offset + iOffset += pTriInfos[f].AssignedGroup[i]->iNrFaces; + // since the groups are disjoint a triangle can never + // belong to more than 3 groups. Subsequently something + // is completely screwed if this assertion ever hits. + assert(iOffset <= iNrMaxGroups); + } + } + } + + return iNrActiveGroups; +} + +static void AddTriToGroup(SGroup * pGroup, const int iTriIndex) +{ + pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex; + ++pGroup->iNrFaces; +} + +static tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], + const int iMyTriIndex, SGroup * pGroup) +{ + STriInfo * pMyTriInfo = &psTriInfos[iMyTriIndex]; + + // track down vertex + const int iVertRep = pGroup->iVertexRepresentitive; + const int * pVerts = &piTriListIn[3*iMyTriIndex+0]; + int i=-1; + if (pVerts[0]==iVertRep) i=0; + else if (pVerts[1]==iVertRep) i=1; + else if (pVerts[2]==iVertRep) i=2; + assert(i>=0 && i<3); + + // early out + if (pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE; + else if (pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE; + if ((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0) + { + // first to group with a group-with-anything triangle + // determines it's orientation. + // This is the only existing order dependency in the code!! + if ( pMyTriInfo->AssignedGroup[0] == NULL && + pMyTriInfo->AssignedGroup[1] == NULL && + pMyTriInfo->AssignedGroup[2] == NULL ) + { + pMyTriInfo->iFlag &= (~ORIENT_PRESERVING); + pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0); + } + } + { + const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + if (bOrient != pGroup->bOrientPreservering) return TFALSE; + } + + AddTriToGroup(pGroup, iMyTriIndex); + pMyTriInfo->AssignedGroup[i] = pGroup; + + { + const int neigh_indexL = pMyTriInfo->FaceNeighbors[i]; + const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2]; + if (neigh_indexL>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup); + if (neigh_indexR>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup); + } + + + + return TTRUE; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2); +static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed); +static STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext * pContext, const int iVertexRepresentitive); + +static tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext) +{ + STSpace * pSubGroupTspace = NULL; + SSubGroup * pUniSubGroups = NULL; + int * pTmpMembers = NULL; + int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0; + for (g=0; giNrFaces; i++) // triangles + { + const int f = pGroup->pFaceIndices[i]; // triangle number + int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0; + SSubGroup tmp_group; + tbool bFound; + SVec3 n, vOs, vOt; + if (pTriInfos[f].AssignedGroup[0]==pGroup) index=0; + else if (pTriInfos[f].AssignedGroup[1]==pGroup) index=1; + else if (pTriInfos[f].AssignedGroup[2]==pGroup) index=2; + assert(index>=0 && index<3); + + iVertIndex = piTriListIn[f*3+index]; + assert(iVertIndex==pGroup->iVertexRepresentitive); + + // is normalized already + n = GetNormal(pContext, iVertIndex); + + // project + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if ( VNotZero(vOs) ) vOs = Normalize(vOs); + if ( VNotZero(vOt) ) vOt = Normalize(vOt); + + // original face number + iOF_1 = pTriInfos[f].iOrgFaceNumber; + + iMembers = 0; + for (j=0; jiNrFaces; j++) + { + const int t = pGroup->pFaceIndices[j]; // triangle number + const int iOF_2 = pTriInfos[t].iOrgFaceNumber; + + // project + SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n)); + SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n)); + if ( VNotZero(vOs2) ) vOs2 = Normalize(vOs2); + if ( VNotZero(vOt2) ) vOt2 = Normalize(vOt2); + + { + const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE; + // make sure triangles which belong to the same quad are joined. + const tbool bSameOrgFace = iOF_1==iOF_2 ? TTRUE : TFALSE; + + const float fCosS = vdot(vOs,vOs2); + const float fCosT = vdot(vOt,vOt2); + + assert(f!=t || bSameOrgFace); // sanity check + if (bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos)) + pTmpMembers[iMembers++] = t; + } + } + + // sort pTmpMembers + tmp_group.iNrFaces = iMembers; + tmp_group.pTriMembers = pTmpMembers; + if (iMembers>1) + { + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + QuickSort(pTmpMembers, 0, iMembers-1, uSeed); + } + + // look for an existing match + bFound = TFALSE; + l=0; + while (liVertexRepresentitive); + ++iUniqueSubGroups; + } + + // output tspace + { + const int iOffs = pTriInfos[f].iTSpacesOffs; + const int iVert = pTriInfos[f].vert_num[index]; + STSpace * pTS_out = &psTspace[iOffs+iVert]; + assert(pTS_out->iCounter<2); + assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering); + if (pTS_out->iCounter==1) + { + *pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]); + pTS_out->iCounter = 2; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + else + { + assert(pTS_out->iCounter==0); + *pTS_out = pSubGroupTspace[l]; + pTS_out->iCounter = 1; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + } + } + + // clean up and offset iUniqueTspaces + for (s=0; s=0 && i<3); + + // project + index = piTriListIn[3*f+i]; + n = GetNormal(pContext, index); + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if ( VNotZero(vOs) ) vOs = Normalize(vOs); + if ( VNotZero(vOt) ) vOt = Normalize(vOt); + + i2 = piTriListIn[3*f + (i<2?(i+1):0)]; + i1 = piTriListIn[3*f + i]; + i0 = piTriListIn[3*f + (i>0?(i-1):2)]; + + p0 = GetPosition(pContext, i0); + p1 = GetPosition(pContext, i1); + p2 = GetPosition(pContext, i2); + v1 = vsub(p0,p1); + v2 = vsub(p2,p1); + + // project + v1 = vsub(v1, vscale(vdot(n,v1),n)); if ( VNotZero(v1) ) v1 = Normalize(v1); + v2 = vsub(v2, vscale(vdot(n,v2),n)); if ( VNotZero(v2) ) v2 = Normalize(v2); + + // weight contribution by the angle + // between the two edge vectors + fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos); + fAngle = (float) acos(fCos); + fMagS = pTriInfos[f].fMagS; + fMagT = pTriInfos[f].fMagT; + + res.vOs=vadd(res.vOs, vscale(fAngle,vOs)); + res.vOt=vadd(res.vOt,vscale(fAngle,vOt)); + res.fMagS+=(fAngle*fMagS); + res.fMagT+=(fAngle*fMagT); + fAngleSum += fAngle; + } + } + + // normalize + if ( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs); + if ( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt); + if (fAngleSum>0) + { + res.fMagS /= fAngleSum; + res.fMagT /= fAngleSum; + } + + return res; +} + +static tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2) +{ + tbool bStillSame=TTRUE; + int i=0; + if (pg1->iNrFaces!=pg2->iNrFaces) return TFALSE; + while (iiNrFaces && bStillSame) + { + bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE; + if (bStillSame) ++i; + } + return bStillSame; +} + +static void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) +{ + int iL, iR, n, index, iMid, iTmp; + + // Random + unsigned int t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL=iLeft; iR=iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL]; + + + do + { + while (pSortBuffer[iL] < iMid) + ++iL; + while (pSortBuffer[iR] > iMid) + --iR; + + if (iL <= iR) + { + iTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = iTmp; + ++iL; --iR; + } + } + while (iL <= iR); + + if (iLeft < iR) + QuickSort(pSortBuffer, iLeft, iR, uSeed); + if (iL < iRight) + QuickSort(pSortBuffer, iL, iRight, uSeed); +} + +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// + +static void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed); +static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in); + +static void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn) +{ + // build array of edges + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + int iEntries=0, iCurStartIndex=-1, f=0, i=0; + for (f=0; f pSortBuffer[iRight].array[channel]) + { + sTmp = pSortBuffer[iLeft]; + pSortBuffer[iLeft] = pSortBuffer[iRight]; + pSortBuffer[iRight] = sTmp; + } + return; + } + + // Random + t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL = iLeft; + iR = iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL].array[channel]; + + do + { + while (pSortBuffer[iL].array[channel] < iMid) + ++iL; + while (pSortBuffer[iR].array[channel] > iMid) + --iR; + + if (iL <= iR) + { + sTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = sTmp; + ++iL; --iR; + } + } + while (iL <= iR); + + if (iLeft < iR) + QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed); + if (iL < iRight) + QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed); +} + +// resolve ordering and edge number +static void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in) +{ + *edgenum_out = -1; + + // test if first index is on the edge + if (indices[0]==i0_in || indices[0]==i1_in) + { + // test if second index is on the edge + if (indices[1]==i0_in || indices[1]==i1_in) + { + edgenum_out[0]=0; // first edge + i0_out[0]=indices[0]; + i1_out[0]=indices[1]; + } + else + { + edgenum_out[0]=2; // third edge + i0_out[0]=indices[2]; + i1_out[0]=indices[0]; + } + } + else + { + // only second and third index is on the edge + edgenum_out[0]=1; // second edge + i0_out[0]=indices[1]; + i1_out[0]=indices[2]; + } +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////// Degenerate triangles //////////////////////////////////// + +static void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris) +{ + int iNextGoodTriangleSearchIndex=-1; + tbool bStillFindingGoodOnes; + + // locate quads with only one good triangle + int t=0; + while (t<(iTotTris-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if (iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + if ((bIsDeg_a^bIsDeg_b)!=0) + { + pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI; + pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI; + } + t += 2; + } + else + ++t; + } + + // reorder list so all degen triangles are moved to the back + // without reordering the good triangles + iNextGoodTriangleSearchIndex = 1; + t=0; + bStillFindingGoodOnes = TTRUE; + while (t (t+1)); + + // swap triangle t0 and t1 + if (!bJustADegenerate) + { + int i=0; + for (i=0; i<3; i++) + { + const int index = piTriList_out[t0*3+i]; + piTriList_out[t0*3+i] = piTriList_out[t1*3+i]; + piTriList_out[t1*3+i] = index; + } + { + const STriInfo tri_info = pTriInfos[t0]; + pTriInfos[t0] = pTriInfos[t1]; + pTriInfos[t1] = tri_info; + } + } + else + bStillFindingGoodOnes = TFALSE; // this is not supposed to happen + } + + if (bStillFindingGoodOnes) ++t; + } + + assert(bStillFindingGoodOnes); // code will still work. + assert(iNrTrianglesIn == t); +} + +static void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris) +{ + int t=0, i=0; + // deal with degenerate triangles + // punishment for degenerate triangles is O(N^2) + for (t=iNrTrianglesIn; t http://image.diku.dk/projects/media/morten.mikkelsen.08.pdf + * Note that though the tangent spaces at the vertices are generated in an order-independent way, + * by this implementation, the interpolated tangent space is still affected by which diagonal is + * chosen to split each quad. A sensible solution is to have your tools pipeline always + * split quads by the shortest diagonal. This choice is order-independent and works with mirroring. + * If these have the same length then compare the diagonals defined by the texture coordinates. + * XNormal which is a tool for baking normal maps allows you to write your own tangent space plugin + * and also quad triangulator plugin. + */ + + +typedef int tbool; +typedef struct SMikkTSpaceContext SMikkTSpaceContext; + +typedef struct { + // Returns the number of faces (triangles/quads) on the mesh to be processed. + int (*m_getNumFaces)(const SMikkTSpaceContext * pContext); + + // Returns the number of vertices on face number iFace + // iFace is a number in the range {0, 1, ..., getNumFaces()-1} + int (*m_getNumVerticesOfFace)(const SMikkTSpaceContext * pContext, const int iFace); + + // returns the position/normal/texcoord of the referenced face of vertex number iVert. + // iVert is in the range {0,1,2} for triangles and {0,1,2,3} for quads. + void (*m_getPosition)(const SMikkTSpaceContext * pContext, float fvPosOut[], const int iFace, const int iVert); + void (*m_getNormal)(const SMikkTSpaceContext * pContext, float fvNormOut[], const int iFace, const int iVert); + void (*m_getTexCoord)(const SMikkTSpaceContext * pContext, float fvTexcOut[], const int iFace, const int iVert); + + // either (or both) of the two setTSpace callbacks can be set. + // The call-back m_setTSpaceBasic() is sufficient for basic normal mapping. + + // This function is used to return the tangent and fSign to the application. + // fvTangent is a unit length vector. + // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. + // bitangent = fSign * cross(vN, tangent); + // Note that the results are returned unindexed. It is possible to generate a new index list + // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results. + // DO NOT! use an already existing index list. + void (*m_setTSpaceBasic)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int iFace, const int iVert); + + // This function is used to return tangent space results to the application. + // fvTangent and fvBiTangent are unit length vectors and fMagS and fMagT are their + // true magnitudes which can be used for relief mapping effects. + // fvBiTangent is the "real" bitangent and thus may not be perpendicular to fvTangent. + // However, both are perpendicular to the vertex normal. + // For normal maps it is sufficient to use the following simplified version of the bitangent which is generated at pixel/vertex level. + // fSign = bIsOrientationPreserving ? 1.0f : (-1.0f); + // bitangent = fSign * cross(vN, tangent); + // Note that the results are returned unindexed. It is possible to generate a new index list + // But averaging/overwriting tangent spaces by using an already existing index list WILL produce INCRORRECT results. + // DO NOT! use an already existing index list. + void (*m_setTSpace)(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fvBiTangent[], const float fMagS, const float fMagT, + const tbool bIsOrientationPreserving, const int iFace, const int iVert); +} SMikkTSpaceInterface; + +struct SMikkTSpaceContext +{ + SMikkTSpaceInterface * m_pInterface; // initialized with callback functions + void * m_pUserData; // pointer to client side mesh data etc. (passed as the first parameter with every interface call) +}; + +// these are both thread safe! +tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext); // Default (recommended) fAngularThreshold is 180 degrees (which means threshold disabled) +tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold); + + +// To avoid visual errors (distortions/unwanted hard edges in lighting), when using sampled normal maps, the +// normal map sampler must use the exact inverse of the pixel shader transformation. +// The most efficient transformation we can possibly do in the pixel shader is +// achieved by using, directly, the "unnormalized" interpolated tangent, bitangent and vertex normal: vT, vB and vN. +// pixel shader (fast transform out) +// vNout = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN ); +// where vNt is the tangent space normal. The normal map sampler must likewise use the +// interpolated and "unnormalized" tangent, bitangent and vertex normal to be compliant with the pixel shader. +// sampler does (exact inverse of pixel shader): +// float3 row0 = cross(vB, vN); +// float3 row1 = cross(vN, vT); +// float3 row2 = cross(vT, vB); +// float fSign = dot(vT, row0)<0 ? -1 : 1; +// vNt = normalize( fSign * float3(dot(vNout,row0), dot(vNout,row1), dot(vNout,row2)) ); +// where vNout is the sampled normal in some chosen 3D space. +// +// Should you choose to reconstruct the bitangent in the pixel shader instead +// of the vertex shader, as explained earlier, then be sure to do this in the normal map sampler also. +// Finally, beware of quad triangulations. If the normal map sampler doesn't use the same triangulation of +// quads as your renderer then problems will occur since the interpolated tangent spaces will differ +// eventhough the vertex level tangent spaces match. This can be solved either by triangulating before +// sampling/exporting or by using the order-independent choice of diagonal for splitting quads suggested earlier. +// However, this must be used both by the sampler and your tools/rendering pipeline. + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 563c5f47b6..6a7fc44d5d 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -94,7 +94,8 @@ out vec3 var_N; #if defined(PER_PIXEL_LIGHTING) out vec4 var_Normal; out vec4 var_Tangent; -out vec4 var_Bitangent; +out vec4 var_ViewDir; +out vec4 var_TangentViewDir; #endif #if defined(PER_PIXEL_LIGHTING) @@ -270,15 +271,11 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); position = (u_ModelMatrix * vec4(position, 1.0)).xyz; - normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz; + normal = normalize(mat3(u_ModelMatrix) * normal); #if defined(PER_PIXEL_LIGHTING) - tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz; + tangent = normalize(mat3(u_ModelMatrix) * tangent); #endif -#if defined(PER_PIXEL_LIGHTING) - vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); -#endif - #if defined(USE_LIGHT_VECTOR) vec3 L = u_LocalLightOrigin.xyz - (position * u_LocalLightOrigin.w); #elif defined(PER_PIXEL_LIGHTING) @@ -294,7 +291,7 @@ void main() { vec3 viewForward = u_ViewForward.xyz; - float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); + float d = clamp(dot(normalize(viewForward), normal), 0.0, 1.0); d = d * d; d = d * d; @@ -307,7 +304,7 @@ void main() #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) float sqrLightDist = dot(L, L); float attenuation = CalcLightAttenuation(u_LocalLightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - float NL = clamp(dot(normalize(normal), L) / sqrt(sqrLightDist), 0.0, 1.0); + float NL = clamp(dot(normal, L) / sqrt(sqrLightDist), 0.0, 1.0); var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; #endif @@ -324,10 +321,16 @@ void main() #if defined(PER_PIXEL_LIGHTING) vec3 viewDir = u_ViewOrigin.xyz - position; + vec2 tcToLm = var_TexCoords.zw - var_TexCoords.xy; + // store view direction in tangent space to save on outs - var_Normal = vec4(normal, viewDir.x); - var_Tangent = vec4(tangent, viewDir.y); - var_Bitangent = vec4(bitangent, viewDir.z); + var_Normal = vec4(normal, tcToLm.x); + var_Tangent = vec4(tangent, (attr_Tangent.w * 2.0 - 1.0)); + var_ViewDir = vec4(viewDir.xyz, tcToLm.y); + + vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); + mat3 TBN = mat3(tangent, bitangent, normal); + var_TangentViewDir = vec4(var_ViewDir.xyz * TBN, 0.0); #endif } @@ -433,7 +436,8 @@ in vec4 var_Color; #if defined(PER_PIXEL_LIGHTING) in vec4 var_Normal; in vec4 var_Tangent; -in vec4 var_Bitangent; +in vec4 var_ViewDir; +in vec4 var_TangentViewDir; in vec4 var_LightDir; #endif @@ -443,15 +447,11 @@ out vec4 out_Glow; #define EPSILON 0.00000001 #if defined(USE_PARALLAXMAP) -float SampleDepth(sampler2D normalMap, vec2 t) -{ - return 1.0 - texture(normalMap, t).r; -} float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, in float parallaxBias) { const int linearSearchSteps = 16; - const int binarySearchSteps = 6; + const int binarySearchSteps = 8; vec2 dp = inDp - parallaxBias * ds; @@ -464,26 +464,33 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, // best match found (starts with last position 1.0) float bestDepth = 1.0; + vec2 dx = dFdx(inDp); + vec2 dy = dFdy(inDp); + // search front to back for first point inside object for(int i = 0; i < linearSearchSteps - 1; ++i) { depth += size; - float t = SampleDepth(normalMap, dp + ds * depth); + // height is flipped before uploaded to the gpu + float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; - if(bestDepth > 0.996) // if no depth found yet - if(depth >= t) - bestDepth = depth; // store best depth + if(depth >= t) + { + bestDepth = depth; // store best depth + break; + } } depth = bestDepth; - + // recurse around first point (depth) for closest match for(int i = 0; i < binarySearchSteps; ++i) { size *= 0.5; - - float t = SampleDepth(normalMap, dp + ds * depth); + + // height is flipped before uploaded to the gpu + float t = textureGrad(normalMap, dp + ds * depth, dx, dy).r; if(depth >= t) { @@ -494,16 +501,30 @@ float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, depth += size; } - vec2 prevTexCoords = dp + ds * (depth-size); - float afterDepth = SampleDepth(normalMap, dp + ds * depth) - depth; - float beforeDepth = SampleDepth(normalMap, prevTexCoords) - depth + size; - float weight = beforeDepth / (beforeDepth - afterDepth); + float beforeDepth = textureGrad(normalMap, dp + ds * (depth-size), dx, dy).r - depth + size; + float afterDepth = textureGrad(normalMap, dp + ds * depth, dx, dy).r - depth; + float deltaDepth = beforeDepth - afterDepth; + float weight = mix(0.0, beforeDepth / deltaDepth , deltaDepth > 0); bestDepth += weight*size; return bestDepth - parallaxBias; } #endif +vec2 GetParallaxOffset(in vec2 texCoords, in vec3 tangentDir) +{ +#if defined(USE_PARALLAXMAP) + ivec2 normalSize = textureSize(u_NormalMap, 0); + vec3 nonSquareScale = mix(vec3(normalSize.y / normalSize.x, 1.0, 1.0), vec3(1.0, normalSize.x / normalSize.y, 1.0), normalSize.y <= normalSize.x); + vec3 offsetDir = normalize(tangentDir * nonSquareScale); + offsetDir.xy *= -u_NormalScale.a / offsetDir.z; + + return offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap, u_ParallaxBias); +#else + return vec2(0.0); +#endif +} + float D_Charlie(in float a, in float NH) { // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF" @@ -700,18 +721,6 @@ float getShadowValue(in vec4 light) } #endif -vec2 GetParallaxOffset(in vec2 texCoords, in vec3 E, in mat3 tangentToWorld ) -{ -#if defined(USE_PARALLAXMAP) - vec3 offsetDir = normalize(E * tangentToWorld); - offsetDir.xy *= -u_NormalScale.a / offsetDir.z; - - return offsetDir.xy * RayIntersectDisplaceMap(texCoords, offsetDir.xy, u_NormalMap, u_ParallaxBias); -#else - return vec2(0.0); -#endif -} - vec3 CalcDynamicLightContribution( in float roughness, in vec3 N, @@ -781,15 +790,16 @@ vec3 CalcIBLContribution( #endif } -vec3 CalcNormal( in vec3 vertexNormal, in vec2 texCoords, in mat3 tangentToWorld ) +vec3 CalcNormal( in vec3 vertexNormal, in vec4 vertexTangent, in vec2 texCoords ) { vec3 N = vertexNormal; #if defined(USE_NORMALMAP) - N.xy = texture(u_NormalMap, texCoords).ag - vec2(0.5); + vec3 biTangent = vertexTangent.w * cross(vertexNormal, vertexTangent.xyz); + N = texture(u_NormalMap, texCoords).agb - vec3(0.5); N.xy *= u_NormalScale.xy; N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); - N = tangentToWorld * N; + N = N.x * vertexTangent.xyz + N.y * biTangent + N.z * vertexNormal; #endif return normalize(N); @@ -800,24 +810,41 @@ void main() vec3 viewDir, lightColor, ambientColor; vec3 L, N, E; + vec2 texCoords = var_TexCoords.xy; + vec2 lmCoords = var_TexCoords.zw; #if defined(PER_PIXEL_LIGHTING) - mat3 tangentToWorld = mat3(var_Tangent.xyz, var_Bitangent.xyz, var_Normal.xyz); - viewDir = vec3(var_Normal.w, var_Tangent.w, var_Bitangent.w); + vec2 tex_offset = GetParallaxOffset(texCoords, var_TangentViewDir.xyz); + texCoords += tex_offset; +#if defined(USE_LIGHTMAP) + //vec2 texDx = dFdx(var_TexCoords.xy); + //vec2 texDy = dFdy(var_TexCoords.xy); + //vec2 lmDx = dFdx(var_TexCoords.zw); + //vec2 lmDy = dFdy(var_TexCoords.zw); + //vec2 lengthScale = sqrt(vec2(dot(lmDx,lmDx) / dot(texDx,texDx), dot(lmDy,lmDy) / dot(texDy,texDy))) * 0.5; + //lmCoords += dot(normalize(lmDx), normalize(texDx)) * tex_offset * lengthScale; + //lmCoords += dot(normalize(lmDx), normalize(texDx)) * tex_offset * lengthScale; + + //vec2 scale1 = mix(vec2(0.0), lmDx / texDx, abs(texDx.x) > EPSILON && abs(texDx.y) > EPSILON); + //vec2 scale2 = mix(vec2(0.0), lmDy / texDy, abs(texDy.x) > EPSILON && abs(texDy.y) > EPSILON); + + //vec2 deltaTex = dFdx(var_TexCoords.xy) - dFdy(var_TexCoords.xy) + EPSILON; + //vec2 deltaLm = dFdx(var_TexCoords.zw) - dFdy(var_TexCoords.zw) ; + //lmCoords += tex_offset * (deltaLm / deltaTex); +#endif +#endif + +#if defined(PER_PIXEL_LIGHTING) + viewDir = var_ViewDir.xyz; E = normalize(viewDir); L = var_LightDir.xyz; #if defined(USE_DELUXEMAP) - L += (texture(u_DeluxeMap, var_TexCoords.zw).xyz - vec3(0.5)) * u_EnableTextures.y; + L += (texture(u_DeluxeMap, lmCoords).xyz - vec3(0.5)) * u_EnableTextures.y; #endif float sqrLightDist = dot(L, L); #endif #if defined(USE_LIGHTMAP) - vec4 lightmapColor = texture(u_LightMap, var_TexCoords.zw); -#endif - - vec2 texCoords = var_TexCoords.xy; -#if defined(PER_PIXEL_LIGHTING) - texCoords += GetParallaxOffset(texCoords, E, tangentToWorld); + vec4 lightmapColor = texture(u_LightMap, lmCoords); #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); @@ -869,7 +896,7 @@ void main() attenuation = 1.0; #endif - N = CalcNormal(var_Normal.xyz, texCoords, tangentToWorld); + N = CalcNormal(var_Normal.xyz, var_Tangent, texCoords); L /= sqrt(sqrLightDist); #if defined(USE_SHADOWMAP) @@ -905,9 +932,6 @@ void main() specular = texture(u_SpecularMap, texCoords); #endif specular *= u_SpecularScale; - - // energy conservation - diffuse.rgb *= vec3(1.0) - specular.rgb; float roughness = mix(1.0, 0.01, specular.a); vec3 H = normalize(L + E); @@ -924,7 +948,7 @@ void main() Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness); #endif - #if (defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP) && defined(r_deluxeSpecular)) || defined(USE_LIGHT_VERTEX) + #if ((defined(USE_LIGHTMAP) && defined(USE_DELUXEMAP)) || defined(USE_LIGHT_VERTEX)) && defined(r_deluxeSpecular) float NH = clamp(dot(N, H), 0.0, 1.0); float VH = clamp(dot(E, H), 0.0, 1.0); Fs = CalcSpecular(specular.rgb, NH, NL, NE, LH, VH, roughness) * r_deluxeSpecular; @@ -970,6 +994,9 @@ void main() #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; #else - out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); + + out_Glow = pow(out_Color, vec4(vec3(1.0 / 2.2), 1.0)) - vec4(0.99, 0.99, 0.99, 0.0); + out_Glow = max(vec4(0.0), out_Glow); + //out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); #endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3b1cdf9d0b..806734b562 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -3077,7 +3077,7 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (tr.viewParms.flags & VPF_NOPOSTPROCESS) + if (cmd->viewParms.flags & VPF_NOPOSTPROCESS) { // do nothing return (const void *)(cmd + 1); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 8cf1cbc1cf..5ffbfe6c4f 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -720,7 +720,7 @@ static shader_t *ShaderForShaderNum( const world_t *worldData, int shaderNum, co ParseFace =============== */ -static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { +static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, packedTangentSpace_t *tangentSpace, float *hdrVertColors, msurface_t *surf, int *indexes ) { int i, j; srfBspSurface_t *cv; glIndex_t *tri; @@ -767,6 +767,8 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver surf->cullinfo.type = CULLINFO_PLANE | CULLINFO_BOX; ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); verts += LittleLong(ds->firstVert); + if (tangentSpace) + tangentSpace += LittleLong(ds->firstVert); for(i = 0; i < numVerts; i++) { vec4_t color; @@ -777,6 +779,14 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver cv->verts[i].normal[j] = LittleFloat(verts[i].normal[j]); } + if (tangentSpace) + { + for (j = 0; j < 4; j++) + cv->verts[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); + } + else + Com_Memset(cv->verts[i].tangent, 0, sizeof(vec4_t)); + AddPointToBounds(cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); for(j = 0; j < 2; j++) @@ -860,20 +870,6 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver surf->cullinfo.plane = cv->cullPlane; surf->data = (surfaceType_t *)cv; - - // Calculate tangent spaces - { - srfVert_t *dv[3]; - - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - dv[0] = &cv->verts[tri[0]]; - dv[1] = &cv->verts[tri[1]]; - dv[2] = &cv->verts[tri[2]]; - - R_CalcTangentVectors(dv); - } - } } @@ -882,7 +878,7 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver ParseMesh =============== */ -static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf ) { +static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, packedTangentSpace_t *tangentSpace, float *hdrVertColors, msurface_t *surf ) { srfBspSurface_t *grid; int i, j; int width, height, numPoints; @@ -921,6 +917,8 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve ri.Error(ERR_DROP, "ParseMesh: bad size"); verts += LittleLong( ds->firstVert ); + if (tangentSpace) + tangentSpace += LittleLong(ds->firstVert); numPoints = width * height; for(i = 0; i < numPoints; i++) { @@ -932,6 +930,14 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve points[i].normal[j] = LittleFloat(verts[i].normal[j]); } + if (tangentSpace) + { + for (j = 0; j < 4; j++) + points[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); + } + else + Com_Memset(points[i].tangent, 0, sizeof(vec4_t)); + for(j = 0; j < 2; j++) { points[i].st[j] = LittleFloat(verts[i].st[j]); @@ -995,7 +1001,7 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve ParseTriSurf =============== */ -static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, float *hdrVertColors, msurface_t *surf, int *indexes ) { +static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t *verts, packedTangentSpace_t *tangentSpace, float *hdrVertColors, msurface_t *surf, int *indexes ) { srfBspSurface_t *cv; glIndex_t *tri; int i, j; @@ -1036,16 +1042,26 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * surf->cullinfo.type = CULLINFO_BOX; ClearBounds(surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); verts += LittleLong(ds->firstVert); - for(i = 0; i < numVerts; i++) + if (tangentSpace) + tangentSpace += LittleLong(ds->firstVert); + for (i = 0; i < numVerts; i++) { vec4_t color; - for(j = 0; j < 3; j++) + for (j = 0; j < 3; j++) { cv->verts[i].xyz[j] = LittleFloat(verts[i].xyz[j]); cv->verts[i].normal[j] = LittleFloat(verts[i].normal[j]); } + if (tangentSpace) + { + for (j = 0; j < 4; j++) + cv->verts[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); + } + else + Com_Memset(cv->verts[i].tangent, 0, sizeof(vec4_t)); + AddPointToBounds( cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1] ); for(j = 0; j < 2; j++) @@ -1118,20 +1134,6 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * ri.Printf(PRINT_WARNING, "Trisurf has bad triangles, originally shader %s %d tris %d verts, now %d tris\n", surf->shader->name, numIndexes / 3, numVerts, numIndexes / 3 - badTriangles); cv->numIndexes -= badTriangles * 3; } - - // Calculate tangent spaces - { - srfVert_t *dv[3]; - - for(i = 0, tri = cv->indexes; i < numIndexes; i += 3, tri += 3) - { - dv[0] = &cv->verts[tri[0]]; - dv[1] = &cv->verts[tri[1]]; - dv[2] = &cv->verts[tri[2]]; - - R_CalcTangentVectors(dv); - } - } } /* @@ -1911,16 +1913,6 @@ static int BSPSurfaceCompare(const void *a, const void *b) return 0; } -struct packedVertex_t -{ - vec3_t position; - uint32_t normal; - uint32_t tangent; - vec2_t texcoords[1 + MAXLIGHTMAPS]; - vec4_t colors[MAXLIGHTMAPS]; - uint32_t lightDirection; -}; - /* =============== R_CreateWorldVBOs @@ -2090,7 +2082,12 @@ static void R_CreateWorldVBOs( world_t *worldData ) VectorCopy (bspSurf->verts[i].xyz, vert.position); vert.normal = R_VboPackNormal (bspSurf->verts[i].normal); - vert.tangent = R_VboPackTangent (bspSurf->verts[i].tangent); + + if (VectorLengthSquared(bspSurf->verts[i].tangent) > 0.001f) + vert.tangent = R_VboPackTangent(bspSurf->verts[i].tangent); + else + vert.tangent = 0u; + VectorCopy2 (bspSurf->verts[i].st, vert.texcoords[0]); for (int j = 0; j < MAXLIGHTMAPS; j++) @@ -2107,6 +2104,8 @@ static void R_CreateWorldVBOs( world_t *worldData ) } } + R_CalcMikkTSpaceBSPSurface(numIndexes/3, verts, indexes); + vbo = R_CreateVBO((byte *)verts, sizeof (packedVertex_t) * numVerts, VBO_USAGE_STATIC); ibo = R_CreateIBO((byte *)indexes, numIndexes * sizeof (glIndex_t), VBO_USAGE_STATIC); @@ -2158,6 +2157,7 @@ static void R_CreateWorldVBOs( world_t *worldData ) ri.Hunk_FreeTempMemory(verts); k++; + ri.Printf(PRINT_ALL, "Finished vbo %i\n", k); } Z_Free(surfacesSorted); @@ -2220,11 +2220,25 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu if (hdrVertColors) { //ri.Printf(PRINT_ALL, "Found!\n"); - if (size != sizeof(float) * 3 * (verts->filelen / sizeof(*dv))) - ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * (verts->filelen / sizeof(*dv)))); + if (size != sizeof(float) * 3 * verts->filelen / sizeof(*dv)) + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)((sizeof(float)) * 3 * verts->filelen / sizeof(*dv))); } } + // load vertex tangent space + packedTangentSpace_t *tangentSpace = NULL; + char filename[MAX_QPATH]; + Com_sprintf(filename, sizeof(filename), "maps/%s.tspace", worldData->baseName); + int size = ri.FS_ReadFile(filename, (void **)&tangentSpace); + + if (tangentSpace) + { + assert(size == (verts->filelen / sizeof(*dv)) * sizeof(float) * 4); + + if (size != sizeof(tangentSpace[0]) * verts->filelen / sizeof(*dv)) + ri.Error(ERR_DROP, "Bad size for %s (%i, expected %i)!", filename, size, (int)(sizeof(float) * 4 * verts->filelen / sizeof(*dv))); + } + // Two passes, allocate surfaces first, then load them full of data // This ensures surfaces are close together to reduce L2 cache misses when using VBOs, @@ -2255,7 +2269,7 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu for ( i = 0 ; i < count ; i++, in++, out++ ) { switch ( LittleLong( in->surfaceType ) ) { case MST_PATCH: - ParseMesh ( worldData, in, dv, hdrVertColors, out ); + ParseMesh ( worldData, in, dv, tangentSpace, hdrVertColors, out ); { srfBspSurface_t *surface = (srfBspSurface_t *)out->data; @@ -2268,11 +2282,11 @@ static void R_LoadSurfaces( world_t *worldData, lump_t *surfs, lump_t *verts, lu numMeshes++; break; case MST_TRIANGLE_SOUP: - ParseTriSurf( worldData, in, dv, hdrVertColors, out, indexes ); + ParseTriSurf( worldData, in, dv, tangentSpace, hdrVertColors, out, indexes ); numTriSurfs++; break; case MST_PLANAR: - ParseFace( worldData, in, dv, hdrVertColors, out, indexes ); + ParseFace( worldData, in, dv, tangentSpace, hdrVertColors, out, indexes ); numFaces++; break; case MST_FLARE: diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 99715b825d..f6dbe54ab4 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4074,15 +4074,11 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & byte *data; int dataSize = 0; - int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights; - int ofs_tangent; + int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents; int stride = 0; int numVerts = 0; int numTriangles = 0; - vec3_t *tangentsf; - vec3_t *bitangentsf; - // +1 to add total vertex count int *baseVertexes = (int *)ri.Hunk_AllocateTempMemory (sizeof (int) * (mdxm->numSurfaces + 1)); int *indexOffsets = (int *)ri.Hunk_AllocateTempMemory (sizeof (int) * mdxm->numSurfaces); @@ -4107,9 +4103,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & baseVertexes[mdxm->numSurfaces] = numVerts; - tangentsf = (vec3_t *)ri.Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts); - bitangentsf = (vec3_t *)ri.Hunk_AllocateTempMemory (sizeof (vec3_t) * numVerts);; - dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); @@ -4141,33 +4134,79 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & stride += sizeof (*weights) * 4; tangents = (uint32_t *)(data + stride); - ofs_tangent = stride; + ofsTangents = stride; stride += sizeof (*tangents); + // Fill in the index buffer and compute tangents + glIndex_t *indices = (glIndex_t *)ri.Hunk_AllocateTempMemory(sizeof(glIndex_t) * numTriangles * 3); + glIndex_t *index = indices; + uint32_t *tangentsf = (uint32_t *)ri.Hunk_AllocateTempMemory(sizeof(uint32_t) * numVerts);; + + surf = (mdxmSurface_t *)((byte *)lod + sizeof(mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t))); + + for (int n = 0; n < mdxm->numSurfaces; n++) + { + mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); + glIndex_t *surf_indices = (glIndex_t *)ri.Hunk_AllocateTempMemory(sizeof(glIndex_t) * surf->numTriangles * 3); + glIndex_t *surf_index = surf_indices; + + for (int k = 0; k < surf->numTriangles; k++, index += 3, surf_index += 3) + { + index[0] = t[k].indexes[0] + baseVertexes[n]; + assert(index[0] >= 0 && index[0] < numVerts); + + index[1] = t[k].indexes[1] + baseVertexes[n]; + assert(index[1] >= 0 && index[1] < numVerts); + + index[2] = t[k].indexes[2] + baseVertexes[n]; + assert(index[2] >= 0 && index[2] < numVerts); + + surf_index[0] = t[k].indexes[0]; + surf_index[1] = t[k].indexes[1]; + surf_index[2] = t[k].indexes[2]; + } + + // Build tangent space + mdxmVertex_t *vertices = (mdxmVertex_t *)((byte *)surf + surf->ofsVerts); + mdxmVertexTexCoord_t *textureCoordinates = (mdxmVertexTexCoord_t *)(vertices + surf->numVerts); + + R_CalcMikkTSpaceGlmSurface( + surf->numTriangles, + vertices, + textureCoordinates, + tangentsf + baseVertexes[n], + surf_indices + ); + + surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); + } + + assert(index == (indices + numTriangles * 3)); + surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); - for ( int n = 0; n < mdxm->numSurfaces; n++ ) + for (int n = 0; n < mdxm->numSurfaces; n++) { // Positions and normals mdxmVertex_t *v = (mdxmVertex_t *)((byte *)surf + surf->ofsVerts); int *boneRef = (int *)((byte *)surf + surf->ofsBoneReferences); - for ( int k = 0; k < surf->numVerts; k++ ) + for (int k = 0; k < surf->numVerts; k++) { - VectorCopy (v[k].vertCoords, *verts); - *normals = R_VboPackNormal (v[k].normal); + VectorCopy(v[k].vertCoords, *verts); + *normals = R_VboPackNormal(v[k].normal); verts = (vec3_t *)((byte *)verts + stride); normals = (uint32_t *)((byte *)normals + stride); } // Weights - for ( int k = 0; k < surf->numVerts; k++ ) + for (int k = 0; k < surf->numVerts; k++) { - int numWeights = G2_GetVertWeights (&v[k]); + int numWeights = G2_GetVertWeights(&v[k]); int lastWeight = 255; int lastInfluence = numWeights - 1; - for ( int w = 0; w < lastInfluence; w++ ) + for (int w = 0; w < lastInfluence; w++) { float weight = G2_GetVertBoneWeightNotSlow(&v[k], w); weights[w] = (byte)(weight * 255.0f); @@ -4185,19 +4224,19 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & bonerefs[lastInfluence] = boneRef[packedIndex]; // Fill in the rest of the info with zeroes. - for ( int w = numWeights; w < 4; w++ ) + for (int w = numWeights; w < 4; w++) { weights[w] = 0; bonerefs[w] = 0; } - + weights += stride; bonerefs += stride; } // Texture coordinates mdxmVertexTexCoord_t *tc = (mdxmVertexTexCoord_t *)(v + surf->numVerts); - for ( int k = 0; k < surf->numVerts; k++ ) + for (int k = 0; k < surf->numVerts; k++) { (*texcoords)[0] = tc[k].texCoords[0]; (*texcoords)[1] = tc[k].texCoords[1]; @@ -4205,69 +4244,9 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & texcoords = (vec2_t *)((byte *)texcoords + stride); } - mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); - for ( int k = 0; k < surf->numTriangles; k++ ) + for (int k = 0; k < surf->numVerts; k++) { - int index[3]; - vec3_t sdir, tdir; - float *v0, *v1, *v2; - float *uv0, *uv1, *uv2; - vec3_t normal = { 0.0f, 0.0f, 0.0f }; - - index[0] = t[k].indexes[0]; - index[1] = t[k].indexes[1]; - index[2] = t[k].indexes[2]; - - v0 = v[index[0]].vertCoords; - v1 = v[index[1]].vertCoords; - v2 = v[index[2]].vertCoords; - - uv0 = tc[index[0]].texCoords; - uv1 = tc[index[1]].texCoords; - uv2 = tc[index[2]].texCoords; - - VectorAdd (normal, v[index[0]].normal, normal); - VectorAdd (normal, v[index[1]].normal, normal); - VectorAdd (normal, v[index[2]].normal, normal); - VectorNormalize (normal); - - R_CalcTexDirs (sdir, tdir, v0, v1, v2, uv0, uv1, uv2); - - for ( int i = 0; i < 3; i++ ) - { - VectorAdd (tangentsf[baseVertexes[n] + index[i]], - sdir, - tangentsf[baseVertexes[n] + index[i]]); - - VectorAdd (bitangentsf[baseVertexes[n] + index[i]], - tdir, - bitangentsf[baseVertexes[n] + index[i]]); - } - } - - // Finally add it to the vertex buffer data - for ( int k = 0; k < surf->numVerts; k++ ) - { - vec3_t sdir, tdir; - - vec3_t& tangent = tangentsf[baseVertexes[n] + k]; - vec3_t& bitangent = bitangentsf[baseVertexes[n] + k]; - vec3_t NxT; - vec4_t T; - - VectorCopy (tangent, sdir); - VectorCopy (bitangent, tdir); - - VectorNormalize (sdir); - VectorNormalize (tdir); - - R_CalcTbnFromNormalAndTexDirs(tangent, bitangent, v[k].normal, sdir, tdir); - - CrossProduct (v[k].normal, tangent, NxT); - VectorCopy (tangent, T); - T[3] = DotProduct (NxT, bitangent) < 0.0f ? -1.0f : 1.0f; - - *tangents = R_VboPackTangent (T); + *tangents = *(tangentsf + baseVertexes[n] + k); tangents = (uint32_t *)((byte *)tangents + stride); } @@ -4281,19 +4260,19 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & { modelName = mdxm->name; } - VBO_t *vbo = R_CreateVBO (data, dataSize, VBO_USAGE_STATIC); + IBO_t *ibo = R_CreateIBO((byte *)indices, sizeof(glIndex_t) * numTriangles * 3, VBO_USAGE_STATIC); ri.Hunk_FreeTempMemory (data); ri.Hunk_FreeTempMemory (tangentsf); - ri.Hunk_FreeTempMemory (bitangentsf); + ri.Hunk_FreeTempMemory (indices); vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofsTexcoords; vbo->offsets[ATTR_INDEX_BONE_INDEXES] = ofsBoneRefs; vbo->offsets[ATTR_INDEX_BONE_WEIGHTS] = ofsWeights; - vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; + vbo->offsets[ATTR_INDEX_TANGENT] = ofsTangents; vbo->strides[ATTR_INDEX_POSITION] = stride; vbo->strides[ATTR_INDEX_NORMAL] = stride; @@ -4309,37 +4288,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->sizes[ATTR_INDEX_BONE_INDEXES] = sizeof(*bonerefs); vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); - // Fill in the index buffer - glIndex_t *indices = (glIndex_t *)ri.Hunk_AllocateTempMemory (sizeof (glIndex_t) * numTriangles * 3); - glIndex_t *index = indices; - - surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); - - for ( int n = 0; n < mdxm->numSurfaces; n++ ) - { - mdxmTriangle_t *t = (mdxmTriangle_t *)((byte *)surf + surf->ofsTriangles); - - for ( int k = 0; k < surf->numTriangles; k++, index += 3 ) - { - index[0] = t[k].indexes[0] + baseVertexes[n]; - assert (index[0] >= 0 && index[0] < numVerts); - - index[1] = t[k].indexes[1] + baseVertexes[n]; - assert (index[1] >= 0 && index[1] < numVerts); - - index[2] = t[k].indexes[2] + baseVertexes[n]; - assert (index[2] >= 0 && index[2] < numVerts); - } - - surf = (mdxmSurface_t *)((byte *)surf + surf->ofsEnd); - } - - assert (index == (indices + numTriangles * 3)); - - IBO_t *ibo = R_CreateIBO ((byte *)indices, sizeof (glIndex_t) * numTriangles * 3, VBO_USAGE_STATIC); - - ri.Hunk_FreeTempMemory (indices); - surf = (mdxmSurface_t *)((byte *)lod + sizeof (mdxmLOD_t) + (mdxm->numSurfaces * sizeof (mdxmLODSurfOffset_t))); for ( int n = 0; n < mdxm->numSurfaces; n++ ) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 26b469b2c0..983a8ce750 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2396,7 +2396,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT if (!internalFormat) { if (image->flags & IMGFLAG_CUBEMAP) - internalFormat = GL_RGBA8; + internalFormat = r_hdr->integer ? GL_RGBA16F : GL_RGBA8; else internalFormat = RawImage_GetFormat(pic, width * height, isLightmap, image->type, image->flags); } @@ -2610,7 +2610,7 @@ image_t* R_GetLoadedImage(const char *name, int flags) { return NULL; } -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type, int roughnessType) +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) { char diffuseName[MAX_QPATH]; char specularName[MAX_QPATH]; @@ -2693,8 +2693,6 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c case SPEC_RMO: case SPEC_RMOS: roughness = ByteToFloat(rmoPic[i + 0]); - if (roughnessType == ROUGHNESS_PERCEPTUAL) - roughness *= roughness; gloss = (1.0 - roughness) + (0.04 * roughness); metalness = ByteToFloat(rmoPic[i + 1]); ao = ByteToFloat(rmoPic[i + 2]); @@ -2708,16 +2706,12 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c ao += (1.0 - ao) * (1.0 - aoStrength); specular_variance = (type == SPEC_MOSR) ? ByteToFloat(rmoPic[i + 2]) : 1.0f; roughness = ByteToFloat(rmoPic[i + 3]); - if (roughnessType == ROUGHNESS_PERCEPTUAL) - roughness *= roughness; gloss = (1.0 - roughness) + (0.04 * roughness); break; case SPEC_ORM: case SPEC_ORMS: ao = ByteToFloat(rmoPic[i + 0]); roughness = ByteToFloat(rmoPic[i + 1]); - if (roughnessType == ROUGHNESS_PERCEPTUAL) - roughness *= roughness; gloss = (1.0 - roughness) + (0.04 * roughness); metalness = ByteToFloat(rmoPic[i + 2]); specular_variance = (type == SPEC_ORMS) ? ByteToFloat(rmoPic[i + 3]) : 1.0f; @@ -2744,9 +2738,9 @@ void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const c // diffuse Color = baseColor * (1.0 - metalness) // also gamma correct again // FIXME: AO should be handled in shader because it should only affect the ambient lighting - diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * ao)); - diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * ao)); - diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * ao)); + diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * ao * (1.0f - metalness))); + diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * ao * (1.0f - metalness))); + diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * ao * (1.0f - metalness))); diffusePic[i + 3] = FloatToByte(baseColor[3]); // specular Color = mix(baseSpecular, baseColor, metalness) @@ -2905,6 +2899,15 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) R_CreateNormalMap( name, pic, width, height, flags ); } + // flip height info, so we don't need to do this in the shader later + if (type == IMGTYPE_NORMALHEIGHT) + { + for (int i = 0; i < width*height; i++) + { + pic[4 * i + 3] = 255 - pic[4 * i + 3]; + } + } + image = R_CreateImage( name, pic, width, height, type, flags, 0 ); Z_Free( pic ); diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index cacb4dabf1..7fe3608378 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -360,29 +360,33 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { VectorCopy( tr.sunDirection, ent->lightDir ); } - // bonus items and view weapons have a fixed minimum add - if ( 1/*!r_hdr->integer*/ ) { - // give everything a minimum light add - ent->ambientLight[0] += tr.identityLight * 32; - ent->ambientLight[1] += tr.identityLight * 32; - ent->ambientLight[2] += tr.identityLight * 32; - } - - if ( ent->e.renderfx & RF_MINLIGHT ) - { //the minlight flag is now for items rotating on their holo thing - if (ent->e.shaderRGBA[0] == 255 && - ent->e.shaderRGBA[1] == 255 && - ent->e.shaderRGBA[2] == 0) - { - ent->ambientLight[0] += tr.identityLight * 255; - ent->ambientLight[1] += tr.identityLight * 255; - ent->ambientLight[2] += tr.identityLight * 0; + // only do min lighting when there is no hdr light data + if (tr.hdrLighting != qtrue) + { + // bonus items and view weapons have a fixed minimum add + if (1/*!r_hdr->integer*/) { + // give everything a minimum light add + ent->ambientLight[0] += tr.identityLight * 32; + ent->ambientLight[1] += tr.identityLight * 32; + ent->ambientLight[2] += tr.identityLight * 32; } - else - { - ent->ambientLight[0] += tr.identityLight * 16; - ent->ambientLight[1] += tr.identityLight * 96; - ent->ambientLight[2] += tr.identityLight * 150; + + if (ent->e.renderfx & RF_MINLIGHT) + { //the minlight flag is now for items rotating on their holo thing + if (ent->e.shaderRGBA[0] == 255 && + ent->e.shaderRGBA[1] == 255 && + ent->e.shaderRGBA[2] == 0) + { + ent->ambientLight[0] += tr.identityLight * 255; + ent->ambientLight[1] += tr.identityLight * 255; + ent->ambientLight[2] += tr.identityLight * 0; + } + else + { + ent->ambientLight[0] += tr.identityLight * 16; + ent->ambientLight[1] += tr.identityLight * 96; + ent->ambientLight[2] += tr.identityLight * 150; + } } } @@ -408,7 +412,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } // clamp ambient - //if ( !r_hdr->integer ) + if (tr.hdrLighting != qtrue) { for ( i = 0 ; i < 3 ; i++ ) { if ( ent->ambientLight[i] > tr.identityLightByte ) { diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ca00cb8c9f..6a342090a2 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -848,12 +848,6 @@ enum specularType SPEC_ORMS, // calculate spec from orms texture with a specular of 0.0 - 0.08 from input }; -enum roughnessType -{ - ROUGHNESS_PERCEPTUAL, - ROUGHNESS_LINEAR, -}; - enum AlphaTestType { ALPHA_TEST_NONE, @@ -2701,6 +2695,21 @@ extern cvar_t *r_debugWeather; //==================================================================== +struct packedVertex_t +{ + vec3_t position; + uint32_t normal; + uint32_t tangent; + vec2_t texcoords[1 + MAXLIGHTMAPS]; + vec4_t colors[MAXLIGHTMAPS]; + uint32_t lightDirection; +}; + +struct packedTangentSpace_t +{ + vec4_t tangentAndSign; +}; + void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ); void R_SetupViewParmsForOrthoRendering( int viewportWidth, @@ -2728,6 +2737,10 @@ void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, int fogIndex, int dlightMap, int postRender, int cubemap ); bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ); +void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glIndex_t *indices); +void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices); +void R_CalcMikkTSpaceGlmSurface(int numSurfaces, mdxmVertex_t *vertices, mdxmVertexTexCoord_t *textureCoordinates, uint32_t *tangents, glIndex_t *indices); + void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, const vec3_t v3, const vec2_t w1, const vec2_t w2, const vec2_t w3); void R_CalcTbnFromNormalAndTexDirs(vec3_t tangent, vec3_t bitangent, vec3_t normal, vec3_t sdir, vec3_t tdir); @@ -3587,7 +3600,7 @@ void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t di void R_AddDecals( void ); image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type, int roughnessType); +void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); const char *RE_ShaderNameFromIndex(int index); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 6867a25349..22b0e24ff6 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include // memcpy #include "ghoul2/g2_local.h" +#include "MikkTSpace/mikktspace.h" trGlobals_t tr; @@ -71,6 +72,277 @@ qboolean R_CompareVert(srfVert_t * v1, srfVert_t * v2, qboolean checkST) return qtrue; } +/* +================ +R_FixMikktVertIndex + +Swaps second index to third and the other way around. +When baking normal maps for models, the mesh importer will swap face indices to change the face orientation. +To generate exactly the same tangents, we have to swap indices to the same order. +Change when mesh importers swaps different indices! +(modelling tool standard is backface culling vs frontface culling in id tech 3) +================ +*/ +int R_FixMikktVertIndex(const int index) +{ + switch (index % 3) + { + case 2: return 1; + case 1: return 2; + default: return index; + } + return index; +} + +struct BspMeshData +{ + int numSurfaces; + packedVertex_t *vertices; + glIndex_t *indices; +}; + +int R_GetNumFaces(const SMikkTSpaceContext * pContext) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + return meshData->numSurfaces; +} + +int R_GetNumVertices(const SMikkTSpaceContext * pContext, const int iFace) +{ + return 3; +} + +void R_GetBSPPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + fvPosOut[0] = vertex.position[0]; + fvPosOut[1] = vertex.position[1]; + fvPosOut[2] = vertex.position[2]; +} + +void R_GetNormalBSPSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + + fvNormOut[0] = ((vertex.normal) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[1] = ((vertex.normal >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[2] = ((vertex.normal >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; +} + +void R_GetBSPTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + fvTexcOut[0] = vertex.texcoords[0][0]; + fvTexcOut[1] = vertex.texcoords[0][1]; +} + +void R_SetBSPTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + if (vertex.tangent == 0u) + vertex.tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); +} + +void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetBSPPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalBSPSurface; + tangentSpaceInterface.m_getTexCoord = R_GetBSPTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetBSPTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + BspMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.vertices = vertices; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + + genTangSpaceDefault(&modelContext); +} + +struct ModelMeshData +{ + int numSurfaces; + vec3_t *verts; + uint32_t *normals; + uint32_t *tangents; + vec2_t *texcoords; + int stride; + glIndex_t *indices; +}; + +void R_GetModelPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + fvPosOut[0] = meshData->verts[index][0]; + fvPosOut[1] = meshData->verts[index][1]; + fvPosOut[2] = meshData->verts[index][2]; +} + +void R_GetNormalModelSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + + fvNormOut[0] = ((meshData->normals[index]) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[1] = ((meshData->normals[index] >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[2] = ((meshData->normals[index] >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; +} + +void R_GetModelTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + fvTexcOut[0] = meshData->texcoords[index][0]; + fvTexcOut[1] = meshData->texcoords[index][1]; +} + +void R_SetModelTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + + uint32_t& tangent = meshData->tangents[index]; + tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); + +} + +void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetModelPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalModelSurface; + tangentSpaceInterface.m_getTexCoord = R_GetModelTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetModelTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + ModelMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.verts = verts; + meshData.normals = normals; + meshData.tangents = tangents; + meshData.texcoords = texcoords; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + genTangSpaceDefault(&modelContext); +} + +struct GlmMeshData +{ + int numSurfaces; + mdxmVertex_t *vertices; + mdxmVertexTexCoord_t *tcs; + uint32_t *tangents; + glIndex_t *indices; +}; + +void R_GetGlmPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertex_t& vertex = meshData->vertices[index]; + fvPosOut[0] = vertex.vertCoords[0]; + fvPosOut[1] = vertex.vertCoords[1]; + fvPosOut[2] = vertex.vertCoords[2]; +} + +void R_GetNormalGlmSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertex_t& vertex = meshData->vertices[index]; + + fvNormOut[0] = vertex.normal[0]; + fvNormOut[1] = vertex.normal[1]; + fvNormOut[2] = vertex.normal[2]; +} + +void R_GetGlmTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertexTexCoord_t& tcs = meshData->tcs[index]; + fvTexcOut[0] = tcs.texCoords[0]; + fvTexcOut[1] = tcs.texCoords[1]; +} + +void R_SetGlmTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + uint32_t& tangent = meshData->tangents[index]; + + tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); +} + +void R_CalcMikkTSpaceGlmSurface(int numSurfaces, mdxmVertex_t *vertices, mdxmVertexTexCoord_t *textureCoordinates, uint32_t *tangents, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetGlmPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalGlmSurface; + tangentSpaceInterface.m_getTexCoord = R_GetGlmTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetGlmTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + GlmMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.vertices = vertices; + meshData.tcs = textureCoordinates; + meshData.tangents = tangents; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + + genTangSpaceDefault(&modelContext); +} + /* ============= R_CalcNormalForTriangle diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index c12f079643..cbf8e355e7 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -823,7 +823,7 @@ R_LoadMD3 */ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modName) { - int f, i, j; + int i, j; md3Header_t *md3Model; md3Frame_t *md3Frame; @@ -1054,59 +1054,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN st->st[1] = LittleFloat(md3st->st[1]); } - // calc tangent spaces - { - for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) - { - VectorClear(v->tangent); - VectorClear(v->bitangent); - } - - for(f = 0; f < mdvModel->numFrames; f++) - { - for(j = 0, tri = surf->indexes; j < surf->numIndexes; j += 3, tri += 3) - { - vec3_t sdir, tdir; - const float *v0, *v1, *v2, *t0, *t1, *t2; - glIndex_t index0, index1, index2; - - index0 = surf->numVerts * f + tri[0]; - index1 = surf->numVerts * f + tri[1]; - index2 = surf->numVerts * f + tri[2]; - - v0 = surf->verts[index0].xyz; - v1 = surf->verts[index1].xyz; - v2 = surf->verts[index2].xyz; - - t0 = surf->st[tri[0]].st; - t1 = surf->st[tri[1]].st; - t2 = surf->st[tri[2]].st; - - R_CalcTexDirs(sdir, tdir, v0, v1, v2, t0, t1, t2); - - VectorAdd(sdir, surf->verts[index0].tangent, surf->verts[index0].tangent); - VectorAdd(sdir, surf->verts[index1].tangent, surf->verts[index1].tangent); - VectorAdd(sdir, surf->verts[index2].tangent, surf->verts[index2].tangent); - VectorAdd(tdir, surf->verts[index0].bitangent, surf->verts[index0].bitangent); - VectorAdd(tdir, surf->verts[index1].bitangent, surf->verts[index1].bitangent); - VectorAdd(tdir, surf->verts[index2].bitangent, surf->verts[index2].bitangent); - } - } - - for(j = 0, v = surf->verts; j < (surf->numVerts * mdvModel->numFrames); j++, v++) - { - vec3_t sdir, tdir; - - VectorCopy(v->tangent, sdir); - VectorCopy(v->bitangent, tdir); - - VectorNormalize(sdir); - VectorNormalize(tdir); - - R_CalcTbnFromNormalAndTexDirs(v->tangent, v->bitangent, v->normal, sdir, tdir); - } - } - // find the next surface md3Surf = (md3Surface_t *) ((byte *) md3Surf + md3Surf->ofsEnd); surf++; @@ -1157,17 +1104,9 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN v = surf->verts; for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) { - vec3_t nxt; - vec4_t tangent; - VectorCopy(v->xyz, verts[j]); - normals[j] = R_VboPackNormal(v->normal); - CrossProduct(v->normal, v->tangent, nxt); - VectorCopy(v->tangent, tangent); - tangent[3] = (DotProduct(nxt, v->bitangent) < 0.0f) ? -1.0f : 1.0f; - - tangents[j] = R_VboPackTangent(tangent); + tangents[j] = 0; } st = surf->st; @@ -1176,6 +1115,9 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN texcoords[j][1] = st->st[1]; } + // If we would support vertex animations, we would need to compute tangents for the other frames too! + R_CalcMikkTSpaceMD3Surface(surf->numIndexes/3, verts, normals, tangents, texcoords, surf->indexes); + vboSurf->surfaceType = SF_VBO_MDVMESH; vboSurf->mdvModel = mdvModel; vboSurf->mdvSurface = surf; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e984fddc2e..47ab1bf448 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1200,7 +1200,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) char bufferPackedTextureName[MAX_QPATH]; char bufferBaseColorTextureName[MAX_QPATH]; int buildSpecFromPacked = SPEC_NONE; - int roughnessType = ROUGHNESS_LINEAR; qboolean foundBaseColor = qfalse; stage->active = qtrue; @@ -1644,14 +1643,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, 1.0 - atof(token)); } // - // linearRoughness - // - else if (!Q_stricmp(token, "linearroughness")) - { - roughnessType = ROUGHNESS_LINEAR; - continue; - } - // // parallaxDepth // else if (!Q_stricmp(token, "parallaxdepth")) @@ -2086,7 +2077,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked, roughnessType); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked); VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); } @@ -3073,7 +3064,6 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm image_t *normalImg; int normalFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_SRGB)) | IMGFLAG_NOLIGHTSCALE; qboolean parallax = qfalse; - // try a normalheight image first COM_StripExtension(diffuseImg->imgName, normalName, sizeof(normalName)); Q_strcat(normalName, sizeof(normalName), "_nh"); @@ -3135,10 +3125,19 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm { COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); Q_strcat(specularName, MAX_QPATH, "_rmo"); - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO, ROUGHNESS_LINEAR); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO); if (stage->bundle[TB_SPECULARMAP].image[0]) VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + else + { + COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); + Q_strcat(specularName, MAX_QPATH, "_orm"); + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_ORM); + + if (stage->bundle[TB_SPECULARMAP].image[0]) + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + } } } } From 5e35029b661819103e33181c871dabaf4baac215 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 19 Aug 2021 13:32:43 +0200 Subject: [PATCH 549/708] Fix for compiler error on linux --- codemp/rd-rend2/glsl/lightall.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 6a7fc44d5d..42a13a8e46 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -515,7 +515,7 @@ vec2 GetParallaxOffset(in vec2 texCoords, in vec3 tangentDir) { #if defined(USE_PARALLAXMAP) ivec2 normalSize = textureSize(u_NormalMap, 0); - vec3 nonSquareScale = mix(vec3(normalSize.y / normalSize.x, 1.0, 1.0), vec3(1.0, normalSize.x / normalSize.y, 1.0), normalSize.y <= normalSize.x); + vec3 nonSquareScale = mix(vec3(normalSize.y / normalSize.x, 1.0, 1.0), vec3(1.0, normalSize.x / normalSize.y, 1.0), float(normalSize.y <= normalSize.x)); vec3 offsetDir = normalize(tangentDir * nonSquareScale); offsetDir.xy *= -u_NormalScale.a / offsetDir.z; From f844afeab4d2701ac118bdd489434719c5ce34e2 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 12 Oct 2021 19:37:29 +0200 Subject: [PATCH 550/708] Some small fixes - rgbGen const now is a float that isn't capped at 1.0 - removed stupid cheap bloom which I accidentally committed - fixed color space of images on hdr lit maps --- codemp/rd-rend2/glsl/lightall.glsl | 8 ++++---- codemp/rd-rend2/tr_bsp.cpp | 14 +------------- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 17 +++++++++-------- codemp/rd-rend2/tr_shade.cpp | 10 +++++----- codemp/rd-rend2/tr_shader.cpp | 29 ++++++++++++++++------------- 6 files changed, 36 insertions(+), 44 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 42a13a8e46..8a7e2b543b 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -882,7 +882,7 @@ void main() #elif defined(USE_LIGHT_VECTOR) lightColor = u_DirectedLight * var_Color.rgb; ambientColor = u_AmbientLight * var_Color.rgb; - attenuation = CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); + attenuation = 1.0; //CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); #if defined(USE_DSHADOWS) if (var_LightDir.w > 0.0) { @@ -995,8 +995,8 @@ void main() out_Glow = out_Color; #else - out_Glow = pow(out_Color, vec4(vec3(1.0 / 2.2), 1.0)) - vec4(0.99, 0.99, 0.99, 0.0); - out_Glow = max(vec4(0.0), out_Glow); - //out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); + //out_Glow = pow(out_Color, vec4(vec3(1.0 / 2.2), 1.0)) - vec4(0.99, 0.99, 0.99, 0.0); + //out_Glow = max(vec4(0.0), out_Glow); + out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); #endif } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5ffbfe6c4f..6de68c96eb 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -745,12 +745,6 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver } numVerts = LittleLong(ds->numVerts); - if (numVerts > MAX_FACE_POINTS) { - ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numVerts); - numVerts = MAX_FACE_POINTS; - surf->shader = tr.defaultShader; - } - numIndexes = LittleLong(ds->numIndexes); //cv = ri.Hunk_Alloc(sizeof(*cv), h_low); @@ -784,8 +778,6 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver for (j = 0; j < 4; j++) cv->verts[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); } - else - Com_Memset(cv->verts[i].tangent, 0, sizeof(vec4_t)); AddPointToBounds(cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1]); @@ -935,8 +927,6 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve for (j = 0; j < 4; j++) points[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); } - else - Com_Memset(points[i].tangent, 0, sizeof(vec4_t)); for(j = 0; j < 2; j++) { @@ -1059,8 +1049,6 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * for (j = 0; j < 4; j++) cv->verts[i].tangent[j] = LittleFloat(tangentSpace[i].tangentAndSign[j]); } - else - Com_Memset(cv->verts[i].tangent, 0, sizeof(vec4_t)); AddPointToBounds( cv->verts[i].xyz, surf->cullinfo.bounds[0], surf->cullinfo.bounds[1] ); @@ -2157,7 +2145,6 @@ static void R_CreateWorldVBOs( world_t *worldData ) ri.Hunk_FreeTempMemory(verts); k++; - ri.Printf(PRINT_ALL, "Finished vbo %i\n", k); } Z_Free(surfacesSorted); @@ -3698,6 +3685,7 @@ static void R_GenerateSurfaceSprites( out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; out->numSprites = sprites.size(); + // FIXME: Use big preallocated vbo/ibo to store all sprites in one vao out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 6a342090a2..fe756c45de 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -881,7 +881,7 @@ typedef struct { waveForm_t alphaWave; alphaGen_t alphaGen; - byte constantColor[4]; // for CGEN_CONST and AGEN_CONST + float constantColor[4]; // for CGEN_CONST and AGEN_CONST uint32_t stateBits; // GLS_xxxx mask diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 22b0e24ff6..3c42015759 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2222,14 +2222,15 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int break; } - R_AddDrawSurf( - &entitySurface, - entityNum, - tr.defaultShader, - 0, - 0, - R_IsPostRenderEntity(ent), - 0 /* cubeMap */ ); + if (tr.currentModel->dataSize > 0) + R_AddDrawSurf( + &entitySurface, + entityNum, + tr.defaultShader, + 0, + 0, + R_IsPostRenderEntity(ent), + 0 /* cubeMap */ ); break; default: ri.Error( ERR_DROP, "R_AddEntitySurfaces: Bad modeltype" ); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index c98e065f54..9f400a863f 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -368,10 +368,10 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t vertColor[3] = 1.0f; break; case CGEN_CONST: - baseColor[0] = pStage->constantColor[0] / 255.0f; - baseColor[1] = pStage->constantColor[1] / 255.0f; - baseColor[2] = pStage->constantColor[2] / 255.0f; - baseColor[3] = pStage->constantColor[3] / 255.0f; + baseColor[0] = pStage->constantColor[0]; + baseColor[1] = pStage->constantColor[1]; + baseColor[2] = pStage->constantColor[2]; + baseColor[3] = pStage->constantColor[3]; break; case CGEN_VERTEX: baseColor[0] = @@ -460,7 +460,7 @@ static void ComputeShaderColors( shaderStage_t *pStage, vec4_t baseColor, vec4_t break; case AGEN_CONST: if ( rgbGen != CGEN_CONST ) { - baseColor[3] = pStage->constantColor[3] / 255.0f; + baseColor[3] = pStage->constantColor[3]; vertColor[3] = 0.0f; } break; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 47ab1bf448..2b1daeb481 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1410,14 +1410,14 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // else if (!Q_stricmp(token, "ormMap") || !Q_stricmp(token, "ormsMap")) { - token = COM_ParseExt(text, qfalse); - if (!token[0]) - { - ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'ormMap' keyword in shader '%s'\n", shader.name); - return qfalse; - } - buildSpecFromPacked = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; - Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); + token = COM_ParseExt(text, qfalse); + if (!token[0]) + { + ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'ormMap' keyword in shader '%s'\n", shader.name); + return qfalse; + } + buildSpecFromPacked = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; + Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // // animMap .... @@ -1773,9 +1773,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) vec3_t color; ParseVector( text, 3, color ); - stage->constantColor[0] = 255 * color[0]; - stage->constantColor[1] = 255 * color[1]; - stage->constantColor[2] = 255 * color[2]; + stage->constantColor[0] = color[0]; + stage->constantColor[1] = color[1]; + stage->constantColor[2] = color[2]; stage->rgbGen = CGEN_CONST; } @@ -1859,7 +1859,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) else if ( !Q_stricmp( token, "const" ) ) { token = COM_ParseExt( text, qfalse ); - stage->constantColor[3] = 255 * atof( token ); + stage->constantColor[3] = atof( token ); stage->alphaGen = AGEN_CONST; } else if ( !Q_stricmp( token, "identity" ) ) @@ -2066,7 +2066,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // if (foundBaseColor && buildSpecFromPacked != SPEC_NONE) { - int flags = IMGFLAG_NONE; + int flags = IMGFLAG_NOLIGHTSCALE; if (!shader.noMipMaps) flags |= IMGFLAG_MIPMAP; @@ -2077,6 +2077,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; + if (shader.isHDRLit == qtrue) + flags |= IMGFLAG_SRGB; + R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked); VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); From b5f26f1e3e0e7b31791806cbf3ac62e3951e4159 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 15 Nov 2021 17:12:10 +0100 Subject: [PATCH 551/708] Put tangent space calculations in its own file --- codemp/rd-rend2/CMakeLists.txt | 1 + codemp/rd-rend2/tr_main.cpp | 279 +------------------------- codemp/rd-rend2/tr_tangentspace.cpp | 294 ++++++++++++++++++++++++++++ 3 files changed, 299 insertions(+), 275 deletions(-) create mode 100644 codemp/rd-rend2/tr_tangentspace.cpp diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 109ae2186b..8494165004 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -61,6 +61,7 @@ set(MPRend2Files "${MPDir}/rd-rend2/tr_sky.cpp" "${MPDir}/rd-rend2/tr_subs.cpp" "${MPDir}/rd-rend2/tr_surface.cpp" + "${MPDir}/rd-rend2/tr_tangentspace.cpp" "${MPDir}/rd-rend2/tr_vbo.cpp" "${MPDir}/rd-rend2/tr_world.cpp" "${MPDir}/rd-rend2/tr_weather.cpp" diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 3c42015759..4e9e811bf3 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include // memcpy #include "ghoul2/g2_local.h" -#include "MikkTSpace/mikktspace.h" trGlobals_t tr; @@ -56,14 +55,14 @@ qboolean R_CompareVert(srfVert_t * v1, srfVert_t * v2, qboolean checkST) { int i; - for(i = 0; i < 3; i++) + for (i = 0; i < 3; i++) { - if(floor(v1->xyz[i] + 0.1) != floor(v2->xyz[i] + 0.1)) + if (floor(v1->xyz[i] + 0.1) != floor(v2->xyz[i] + 0.1)) { return qfalse; } - if(checkST && ((v1->st[0] != v2->st[0]) || (v1->st[1] != v2->st[1]))) + if (checkST && ((v1->st[0] != v2->st[0]) || (v1->st[1] != v2->st[1]))) { return qfalse; } @@ -72,277 +71,6 @@ qboolean R_CompareVert(srfVert_t * v1, srfVert_t * v2, qboolean checkST) return qtrue; } -/* -================ -R_FixMikktVertIndex - -Swaps second index to third and the other way around. -When baking normal maps for models, the mesh importer will swap face indices to change the face orientation. -To generate exactly the same tangents, we have to swap indices to the same order. -Change when mesh importers swaps different indices! -(modelling tool standard is backface culling vs frontface culling in id tech 3) -================ -*/ -int R_FixMikktVertIndex(const int index) -{ - switch (index % 3) - { - case 2: return 1; - case 1: return 2; - default: return index; - } - return index; -} - -struct BspMeshData -{ - int numSurfaces; - packedVertex_t *vertices; - glIndex_t *indices; -}; - -int R_GetNumFaces(const SMikkTSpaceContext * pContext) -{ - BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; - return meshData->numSurfaces; -} - -int R_GetNumVertices(const SMikkTSpaceContext * pContext, const int iFace) -{ - return 3; -} - -void R_GetBSPPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) -{ - BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - packedVertex_t& vertex = meshData->vertices[index]; - fvPosOut[0] = vertex.position[0]; - fvPosOut[1] = vertex.position[1]; - fvPosOut[2] = vertex.position[2]; -} - -void R_GetNormalBSPSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) -{ - BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - packedVertex_t& vertex = meshData->vertices[index]; - - fvNormOut[0] = ((vertex.normal) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[1] = ((vertex.normal >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[2] = ((vertex.normal >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; -} - -void R_GetBSPTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) -{ - BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - packedVertex_t& vertex = meshData->vertices[index]; - fvTexcOut[0] = vertex.texcoords[0][0]; - fvTexcOut[1] = vertex.texcoords[0][1]; -} - -void R_SetBSPTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) -{ - BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - packedVertex_t& vertex = meshData->vertices[index]; - if (vertex.tangent == 0u) - vertex.tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) - | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) - | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) - | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); -} - -void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glIndex_t *indices) -{ - SMikkTSpaceInterface tangentSpaceInterface; - - tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; - tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; - tangentSpaceInterface.m_getPosition = R_GetBSPPosition; - tangentSpaceInterface.m_getNormal = R_GetNormalBSPSurface; - tangentSpaceInterface.m_getTexCoord = R_GetBSPTexCoord; - tangentSpaceInterface.m_setTSpaceBasic = R_SetBSPTSpaceBasic; - tangentSpaceInterface.m_setTSpace = NULL; - - BspMeshData meshData; - meshData.numSurfaces = numSurfaces; - meshData.vertices = vertices; - meshData.indices = indices; - - SMikkTSpaceContext modelContext; - modelContext.m_pUserData = &meshData; - modelContext.m_pInterface = &tangentSpaceInterface; - - genTangSpaceDefault(&modelContext); -} - -struct ModelMeshData -{ - int numSurfaces; - vec3_t *verts; - uint32_t *normals; - uint32_t *tangents; - vec2_t *texcoords; - int stride; - glIndex_t *indices; -}; - -void R_GetModelPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) -{ - ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - fvPosOut[0] = meshData->verts[index][0]; - fvPosOut[1] = meshData->verts[index][1]; - fvPosOut[2] = meshData->verts[index][2]; -} - -void R_GetNormalModelSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) -{ - ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - - fvNormOut[0] = ((meshData->normals[index]) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[1] = ((meshData->normals[index] >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[2] = ((meshData->normals[index] >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; -} - -void R_GetModelTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) -{ - ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - fvTexcOut[0] = meshData->texcoords[index][0]; - fvTexcOut[1] = meshData->texcoords[index][1]; -} - -void R_SetModelTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) -{ - ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - - uint32_t& tangent = meshData->tangents[index]; - tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) - | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) - | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) - | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); - -} - -void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices) -{ - SMikkTSpaceInterface tangentSpaceInterface; - tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; - tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; - tangentSpaceInterface.m_getPosition = R_GetModelPosition; - tangentSpaceInterface.m_getNormal = R_GetNormalModelSurface; - tangentSpaceInterface.m_getTexCoord = R_GetModelTexCoord; - tangentSpaceInterface.m_setTSpaceBasic = R_SetModelTSpaceBasic; - tangentSpaceInterface.m_setTSpace = NULL; - - ModelMeshData meshData; - meshData.numSurfaces = numSurfaces; - meshData.verts = verts; - meshData.normals = normals; - meshData.tangents = tangents; - meshData.texcoords = texcoords; - meshData.indices = indices; - - SMikkTSpaceContext modelContext; - modelContext.m_pUserData = &meshData; - modelContext.m_pInterface = &tangentSpaceInterface; - genTangSpaceDefault(&modelContext); -} - -struct GlmMeshData -{ - int numSurfaces; - mdxmVertex_t *vertices; - mdxmVertexTexCoord_t *tcs; - uint32_t *tangents; - glIndex_t *indices; -}; - -void R_GetGlmPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) -{ - GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - mdxmVertex_t& vertex = meshData->vertices[index]; - fvPosOut[0] = vertex.vertCoords[0]; - fvPosOut[1] = vertex.vertCoords[1]; - fvPosOut[2] = vertex.vertCoords[2]; -} - -void R_GetNormalGlmSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) -{ - GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - mdxmVertex_t& vertex = meshData->vertices[index]; - - fvNormOut[0] = vertex.normal[0]; - fvNormOut[1] = vertex.normal[1]; - fvNormOut[2] = vertex.normal[2]; -} - -void R_GetGlmTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) -{ - GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - mdxmVertexTexCoord_t& tcs = meshData->tcs[index]; - fvTexcOut[0] = tcs.texCoords[0]; - fvTexcOut[1] = tcs.texCoords[1]; -} - -void R_SetGlmTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) -{ - GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; - const int vert_index = R_FixMikktVertIndex(iVert); - glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - uint32_t& tangent = meshData->tangents[index]; - - tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) - | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) - | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) - | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); -} - -void R_CalcMikkTSpaceGlmSurface(int numSurfaces, mdxmVertex_t *vertices, mdxmVertexTexCoord_t *textureCoordinates, uint32_t *tangents, glIndex_t *indices) -{ - SMikkTSpaceInterface tangentSpaceInterface; - - tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; - tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; - tangentSpaceInterface.m_getPosition = R_GetGlmPosition; - tangentSpaceInterface.m_getNormal = R_GetNormalGlmSurface; - tangentSpaceInterface.m_getTexCoord = R_GetGlmTexCoord; - tangentSpaceInterface.m_setTSpaceBasic = R_SetGlmTSpaceBasic; - tangentSpaceInterface.m_setTSpace = NULL; - - GlmMeshData meshData; - meshData.numSurfaces = numSurfaces; - meshData.vertices = vertices; - meshData.tcs = textureCoordinates; - meshData.tangents = tangents; - meshData.indices = indices; - - SMikkTSpaceContext modelContext; - modelContext.m_pUserData = &meshData; - modelContext.m_pInterface = &tangentSpaceInterface; - - genTangSpaceDefault(&modelContext); -} - /* ============= R_CalcNormalForTriangle @@ -2222,6 +1950,7 @@ static void R_AddEntitySurface(const trRefdef_t *refdef, trRefEntity_t *ent, int break; } + // FIX ME: always draw null axis model instead of rejecting the drawcall if (tr.currentModel->dataSize > 0) R_AddDrawSurf( &entitySurface, diff --git a/codemp/rd-rend2/tr_tangentspace.cpp b/codemp/rd-rend2/tr_tangentspace.cpp new file mode 100644 index 0000000000..ae98a67476 --- /dev/null +++ b/codemp/rd-rend2/tr_tangentspace.cpp @@ -0,0 +1,294 @@ +/* +=========================================================================== +Copyright (C) 2016, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#include "tr_local.h" +#include "MikkTSpace/mikktspace.h" + + +/* +================ +R_FixMikktVertIndex + +Swaps second index to third and the other way around. +When baking normal maps for models, the mesh importer will swap face indices to change the face orientation. +To generate exactly the same tangents, we have to swap indices to the same order. +Change when mesh importers swaps different indices! +(modelling tool standard is backface culling vs frontface culling in id tech 3) +================ +*/ +int R_FixMikktVertIndex(const int index) +{ + switch (index % 3) + { + case 2: return 1; + case 1: return 2; + default: return index; + } + return index; +} + +struct BspMeshData +{ + int numSurfaces; + packedVertex_t *vertices; + glIndex_t *indices; +}; + +int R_GetNumFaces(const SMikkTSpaceContext * pContext) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + return meshData->numSurfaces; +} + +int R_GetNumVertices(const SMikkTSpaceContext * pContext, const int iFace) +{ + return 3; +} + +void R_GetBSPPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + fvPosOut[0] = vertex.position[0]; + fvPosOut[1] = vertex.position[1]; + fvPosOut[2] = vertex.position[2]; +} + +void R_GetNormalBSPSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + + fvNormOut[0] = ((vertex.normal) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[1] = ((vertex.normal >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[2] = ((vertex.normal >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; +} + +void R_GetBSPTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + fvTexcOut[0] = vertex.texcoords[0][0]; + fvTexcOut[1] = vertex.texcoords[0][1]; +} + +void R_SetBSPTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + BspMeshData *meshData = (BspMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + packedVertex_t& vertex = meshData->vertices[index]; + if (vertex.tangent == 0u) + vertex.tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); +} + +void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetBSPPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalBSPSurface; + tangentSpaceInterface.m_getTexCoord = R_GetBSPTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetBSPTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + BspMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.vertices = vertices; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + + genTangSpaceDefault(&modelContext); +} + +struct ModelMeshData +{ + int numSurfaces; + vec3_t *verts; + uint32_t *normals; + uint32_t *tangents; + vec2_t *texcoords; + int stride; + glIndex_t *indices; +}; + +void R_GetModelPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + fvPosOut[0] = meshData->verts[index][0]; + fvPosOut[1] = meshData->verts[index][1]; + fvPosOut[2] = meshData->verts[index][2]; +} + +void R_GetNormalModelSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + + fvNormOut[0] = ((meshData->normals[index]) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[1] = ((meshData->normals[index] >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[2] = ((meshData->normals[index] >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; +} + +void R_GetModelTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + fvTexcOut[0] = meshData->texcoords[index][0]; + fvTexcOut[1] = meshData->texcoords[index][1]; +} + +void R_SetModelTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + + uint32_t& tangent = meshData->tangents[index]; + tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); + +} + +void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetModelPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalModelSurface; + tangentSpaceInterface.m_getTexCoord = R_GetModelTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetModelTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + ModelMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.verts = verts; + meshData.normals = normals; + meshData.tangents = tangents; + meshData.texcoords = texcoords; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + genTangSpaceDefault(&modelContext); +} + +struct GlmMeshData +{ + int numSurfaces; + mdxmVertex_t *vertices; + mdxmVertexTexCoord_t *tcs; + uint32_t *tangents; + glIndex_t *indices; +}; + +void R_GetGlmPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertex_t& vertex = meshData->vertices[index]; + fvPosOut[0] = vertex.vertCoords[0]; + fvPosOut[1] = vertex.vertCoords[1]; + fvPosOut[2] = vertex.vertCoords[2]; +} + +void R_GetNormalGlmSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertex_t& vertex = meshData->vertices[index]; + + fvNormOut[0] = vertex.normal[0]; + fvNormOut[1] = vertex.normal[1]; + fvNormOut[2] = vertex.normal[2]; +} + +void R_GetGlmTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + mdxmVertexTexCoord_t& tcs = meshData->tcs[index]; + fvTexcOut[0] = tcs.texCoords[0]; + fvTexcOut[1] = tcs.texCoords[1]; +} + +void R_SetGlmTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) +{ + GlmMeshData *meshData = (GlmMeshData *)pContext->m_pUserData; + const int vert_index = R_FixMikktVertIndex(iVert); + glIndex_t index = meshData->indices[iFace * 3 + vert_index]; + uint32_t& tangent = meshData->tangents[index]; + + tangent = (((uint32_t)(fSign * 1.5f + 2.0f)) << 30) + | (((uint32_t)(fvTangent[2] * 511.5f + 512.0f)) << 20) + | (((uint32_t)(fvTangent[1] * 511.5f + 512.0f)) << 10) + | (((uint32_t)(fvTangent[0] * 511.5f + 512.0f))); +} + +void R_CalcMikkTSpaceGlmSurface(int numSurfaces, mdxmVertex_t *vertices, mdxmVertexTexCoord_t *textureCoordinates, uint32_t *tangents, glIndex_t *indices) +{ + SMikkTSpaceInterface tangentSpaceInterface; + + tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; + tangentSpaceInterface.m_getNumVerticesOfFace = R_GetNumVertices; + tangentSpaceInterface.m_getPosition = R_GetGlmPosition; + tangentSpaceInterface.m_getNormal = R_GetNormalGlmSurface; + tangentSpaceInterface.m_getTexCoord = R_GetGlmTexCoord; + tangentSpaceInterface.m_setTSpaceBasic = R_SetGlmTSpaceBasic; + tangentSpaceInterface.m_setTSpace = NULL; + + GlmMeshData meshData; + meshData.numSurfaces = numSurfaces; + meshData.vertices = vertices; + meshData.tcs = textureCoordinates; + meshData.tangents = tangents; + meshData.indices = indices; + + SMikkTSpaceContext modelContext; + modelContext.m_pUserData = &meshData; + modelContext.m_pInterface = &tangentSpaceInterface; + + genTangSpaceDefault(&modelContext); +} \ No newline at end of file From 45a6e4882f9289c5c2446c8adcb81b6d9bbb21d6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 17 Nov 2021 17:54:24 +0100 Subject: [PATCH 552/708] Fix rendering Cloud Layer --- codemp/rd-rend2/tr_sky.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index ccd6074b85..16e2b640c2 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -699,6 +699,8 @@ void R_BuildCloudData( shaderCommands_t *input ) tess.numIndexes = 0; tess.numVertexes = 0; tess.firstIndex = 0; + tess.useInternalVBO = qtrue; + tess.externalIBO = nullptr; if ( shader->sky.cloudHeight ) { From 8b7f78734db1848d6713daef53c61ac65a18f537 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 18 Nov 2021 18:55:31 +0100 Subject: [PATCH 553/708] Fixing bright ambient term Should have used Fd for multiplying with the ambient before, but it doesnt play well with the cloth shader. So, we simply dont mutiply/divide by pi at all for ambient. --- codemp/rd-rend2/glsl/lightall.glsl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 8a7e2b543b..993eb899ce 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -924,8 +924,16 @@ void main() // light is below the surface ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0); #endif + + // Scale lightColor by PI because we need want to have the same output intensity + // as in vanilla, but we also want correct computation formulas + // Lambiertian Diffuse divides by PI, so multiply light before to get the same intensity + // HDR Lightsources are scaled on upload accordingly lightColor *= M_PI; - ambientColor *= M_PI; + + // Dont scale ambient as we dont compute lambertian diffuse for it + // We dont compute it because cloth diffuse is dependent on NL + // So we just skip this. Reconsider this again when more BRDFS are added vec4 specular = vec4(1.0); #if defined(USE_SPECULARMAP) From 3a37e4549a339f0e5294639bd8f9e64b84434cdf Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 18 Nov 2021 23:27:43 +0100 Subject: [PATCH 554/708] Fixes regarding sky portals The renderer postprocessed the rendered skyportal which led to problems regarding tonemapping and other faulty things because it didnt happen. --- codemp/rd-rend2/tr_backend.cpp | 4 ++++ codemp/rd-rend2/tr_shade.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 806734b562..1b82ff4547 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -3077,6 +3077,10 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); + if (tr.world->skyboxportal && (cmd->refdef.rdflags & RDF_SKYBOXPORTAL)) { + return (const void *)(cmd + 1);; + } + if (cmd->viewParms.flags & VPF_NOPOSTPROCESS) { // do nothing diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9f400a863f..d5d2b82caa 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1899,7 +1899,7 @@ void RB_EndSurface( void ) { return; } - if (tr.world) { + if (tr.world && !backEnd.framePostProcessed) { if (tr.world->skyboxportal) { // world From 09d35f2a14d879bb648875e2c819f460240ff908 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 19 Nov 2021 10:39:43 +0100 Subject: [PATCH 555/708] Some cleanup --- codemp/rd-rend2/glsl/lightall.glsl | 103 ++++++---------- codemp/rd-rend2/tr_backend.cpp | 34 ++---- codemp/rd-rend2/tr_bsp.cpp | 4 +- codemp/rd-rend2/tr_image_stb.cpp | 8 +- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_main.cpp | 2 - codemp/rd-rend2/tr_shade.cpp | 187 +---------------------------- codemp/rd-rend2/tr_sky.cpp | 2 +- codemp/rd-rend2/tr_surface.cpp | 2 +- 9 files changed, 63 insertions(+), 281 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 993eb899ce..70042ad06d 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -302,12 +302,12 @@ void main() var_Color = u_VertColor * attr_Color + u_BaseColor; #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) - float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(u_LocalLightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); - float NL = clamp(dot(normal, L) / sqrt(sqrLightDist), 0.0, 1.0); + float sqrLightDist = dot(L, L); + float attenuation = CalcLightAttenuation(u_LocalLightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); + float NL = clamp(dot(normal, L) / sqrt(sqrLightDist), 0.0, 1.0); - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; -#endif + var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; + #endif } var_Color *= disintegration; @@ -321,14 +321,12 @@ void main() #if defined(PER_PIXEL_LIGHTING) vec3 viewDir = u_ViewOrigin.xyz - position; - vec2 tcToLm = var_TexCoords.zw - var_TexCoords.xy; - // store view direction in tangent space to save on outs - var_Normal = vec4(normal, tcToLm.x); + var_Normal = vec4(normal, 0.0); var_Tangent = vec4(tangent, (attr_Tangent.w * 2.0 - 1.0)); - var_ViewDir = vec4(viewDir.xyz, tcToLm.y); + var_ViewDir = vec4(viewDir.xyz, 0.0); - vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0); + vec3 bitangent = cross(normal, tangent) * var_Tangent.w; mat3 TBN = mat3(tangent, bitangent, normal); var_TangentViewDir = vec4(var_ViewDir.xyz * TBN, 0.0); #endif @@ -638,7 +636,7 @@ vec3 CalcSpecular( //Energy conserving wrap term. float WrapLambert(in float NL, in float w) { - return clamp((NL + w) / pow(1.0 + w, 2), 0.0, 1.0); + return clamp((NL + w) / pow(1.0 + w, 2.0), 0.0, 1.0); } vec3 Diffuse_Lambert(in vec3 DiffuseColor) @@ -713,9 +711,9 @@ float getLightDepth(in vec3 Vec, in float f) return ((NormZComp + 1.0) * 0.5) - DEPTH_MAX_ERROR; } -float getShadowValue(in vec4 light) +float getShadowValue(in vec4 light, in int lightId) { - float distance = getLightDepth(light.xyz, sqrt(light.w)); + float distance = getLightDepth(light.xyz, light.w); //return pcfShadow(u_ShadowMap2, light.xyz, distance); return 1.0; } @@ -746,7 +744,11 @@ vec3 CalcDynamicLightContribution( float attenuation = CalcLightAttenuation(1.0, light.radius * light.radius / sqrLightDist); - L /= sqrt(sqrLightDist); + #if defined(USE_DSHADOWS) + attenuation *= getShadowValue(vec4(L, light.radius), i); + #endif + + L = normalize(L); vec3 H = normalize(L + E); float NL = clamp(dot(N, L), 0.0, 1.0); float LH = clamp(dot(L, H), 0.0, 1.0); @@ -770,7 +772,7 @@ vec3 CalcIBLContribution( in vec3 specular ) { -#if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) +#if defined(PER_PIXEL_LIGHTING) && defined(USE_CUBEMAP) vec3 R = reflect(-E, N); // parallax corrected cubemap (cheaper trick) @@ -778,10 +780,12 @@ vec3 CalcIBLContribution( vec3 parallax = u_CubeMapInfo.xyz + u_CubeMapInfo.w * viewDir; vec3 cubeLightColor = textureLod(u_CubeMap, R - parallax, roughness * ROUGHNESS_MIPS).rgb * u_EnableTextures.w; - #if !defined(USE_CLOTH_BRDF) //should define this as the base BRDF + // Base BRDF + #if !defined(USE_CLOTH_BRDF) vec2 EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).rg; return cubeLightColor * (specular.rgb * EnvBRDF.x + EnvBRDF.y); - #else //and define this as the cloth brdf + // Cloth BRDF + #else float EnvBRDF = texture(u_EnvBrdfMap, vec2(roughness, NE)).b; return cubeLightColor * EnvBRDF; #endif @@ -792,17 +796,16 @@ vec3 CalcIBLContribution( vec3 CalcNormal( in vec3 vertexNormal, in vec4 vertexTangent, in vec2 texCoords ) { - vec3 N = vertexNormal; - #if defined(USE_NORMALMAP) vec3 biTangent = vertexTangent.w * cross(vertexNormal, vertexTangent.xyz); - N = texture(u_NormalMap, texCoords).agb - vec3(0.5); + vec3 N = texture(u_NormalMap, texCoords).agb - vec3(0.5); N.xy *= u_NormalScale.xy; N.z = sqrt(clamp((0.25 - N.x * N.x) - N.y * N.y, 0.0, 1.0)); N = N.x * vertexTangent.xyz + N.y * biTangent + N.z * vertexNormal; -#endif - return normalize(N); +#else + return normalize(vertexNormal); +#endif } void main() @@ -815,36 +818,6 @@ void main() #if defined(PER_PIXEL_LIGHTING) vec2 tex_offset = GetParallaxOffset(texCoords, var_TangentViewDir.xyz); texCoords += tex_offset; -#if defined(USE_LIGHTMAP) - //vec2 texDx = dFdx(var_TexCoords.xy); - //vec2 texDy = dFdy(var_TexCoords.xy); - //vec2 lmDx = dFdx(var_TexCoords.zw); - //vec2 lmDy = dFdy(var_TexCoords.zw); - //vec2 lengthScale = sqrt(vec2(dot(lmDx,lmDx) / dot(texDx,texDx), dot(lmDy,lmDy) / dot(texDy,texDy))) * 0.5; - //lmCoords += dot(normalize(lmDx), normalize(texDx)) * tex_offset * lengthScale; - //lmCoords += dot(normalize(lmDx), normalize(texDx)) * tex_offset * lengthScale; - - //vec2 scale1 = mix(vec2(0.0), lmDx / texDx, abs(texDx.x) > EPSILON && abs(texDx.y) > EPSILON); - //vec2 scale2 = mix(vec2(0.0), lmDy / texDy, abs(texDy.x) > EPSILON && abs(texDy.y) > EPSILON); - - //vec2 deltaTex = dFdx(var_TexCoords.xy) - dFdy(var_TexCoords.xy) + EPSILON; - //vec2 deltaLm = dFdx(var_TexCoords.zw) - dFdy(var_TexCoords.zw) ; - //lmCoords += tex_offset * (deltaLm / deltaTex); -#endif -#endif - -#if defined(PER_PIXEL_LIGHTING) - viewDir = var_ViewDir.xyz; - E = normalize(viewDir); - L = var_LightDir.xyz; - #if defined(USE_DELUXEMAP) - L += (texture(u_DeluxeMap, lmCoords).xyz - vec3(0.5)) * u_EnableTextures.y; - #endif - float sqrLightDist = dot(L, L); -#endif - -#if defined(USE_LIGHTMAP) - vec4 lightmapColor = texture(u_LightMap, lmCoords); #endif vec4 diffuse = texture(u_DiffuseMap, texCoords); @@ -872,6 +845,20 @@ void main() } #endif +#if defined(PER_PIXEL_LIGHTING) + viewDir = var_ViewDir.xyz; + E = normalize(viewDir); + L = var_LightDir.xyz; + #if defined(USE_DELUXEMAP) + L += (texture(u_DeluxeMap, lmCoords).xyz - vec3(0.5)) * u_EnableTextures.y; + #endif + float sqrLightDist = dot(L, L); +#endif + +#if defined(USE_LIGHTMAP) + vec4 lightmapColor = texture(u_LightMap, lmCoords); +#endif + #if defined(PER_PIXEL_LIGHTING) float attenuation; @@ -882,14 +869,7 @@ void main() #elif defined(USE_LIGHT_VECTOR) lightColor = u_DirectedLight * var_Color.rgb; ambientColor = u_AmbientLight * var_Color.rgb; - attenuation = 1.0; //CalcLightAttenuation(float(var_LightDir.w > 0.0), var_LightDir.w / sqrLightDist); - - #if defined(USE_DSHADOWS) - if (var_LightDir.w > 0.0) { - attenuation *= getShadowValue(var_LightDir); - } - #endif - + attenuation = 1.0; #elif defined(USE_LIGHT_VERTEX) lightColor = var_Color.rgb; ambientColor = vec3 (0.0); @@ -1002,9 +982,6 @@ void main() #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; #else - - //out_Glow = pow(out_Color, vec4(vec3(1.0 / 2.2), 1.0)) - vec4(0.99, 0.99, 0.99, 0.0); - //out_Glow = max(vec4(0.0), out_Glow); out_Glow = vec4(0.0, 0.0, 0.0, out_Color.a); #endif } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1b82ff4547..32e7250844 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -971,7 +971,7 @@ SamplerBindingsWriter& SamplerBindingsWriter::AddAnimatedImage( textureBundle_t return AddStaticImage(bundle->image[ index ], unit); } -SamplerBinding *SamplerBindingsWriter::Finish( Allocator& destHeap, int* numBindings ) +SamplerBinding *SamplerBindingsWriter::Finish( Allocator& destHeap, uint32_t* numBindings ) { if ( failed ) { @@ -2157,29 +2157,11 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) // Only resolve the main pass depth if (tr.msaaResolveFbo && backEnd.viewParms.targetFbo == tr.renderFbo) { - if (backEnd.viewParms.targetFbo == tr.renderCubeFbo && tr.msaaResolveFbo) - { - // If we're using multisampling and rendering a cubemap, resolve the depth to correct size first - vec4i_t frameBox; - frameBox[0] = backEnd.viewParms.viewportX; - frameBox[1] = backEnd.viewParms.viewportY; - frameBox[2] = backEnd.viewParms.viewportWidth; - frameBox[3] = backEnd.viewParms.viewportHeight; - FBO_FastBlit( - tr.renderCubeFbo, frameBox, - tr.msaaResolveFbo, frameBox, - GL_DEPTH_BUFFER_BIT, - GL_NEAREST); - } - else - { - // If we're using multisampling, resolve the depth first - FBO_FastBlit( - tr.renderFbo, NULL, - tr.msaaResolveFbo, NULL, - GL_DEPTH_BUFFER_BIT, - GL_NEAREST); - } + FBO_FastBlit( + tr.renderFbo, NULL, + tr.msaaResolveFbo, NULL, + GL_DEPTH_BUFFER_BIT, + GL_NEAREST); } else if (tr.renderFbo == NULL) { @@ -3172,8 +3154,10 @@ const void *RB_PostProcess(const void *data) if (r_drawSunRays->integer) RB_SunRays(NULL, srcBox, NULL, dstBox); - if (1) +#if 0 + if (backEnd.refdef.blurFactor > 0.0f) RB_BokehBlur(NULL, srcBox, NULL, dstBox, backEnd.refdef.blurFactor); +#endif if (r_debugWeather->integer == 2) { diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 6de68c96eb..d45c6774f7 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -516,7 +516,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (externalLightmap) Z_Free(externalLightmap); - } + } if (tr.worldDeluxeMapping && buf) { @@ -562,7 +562,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { 0); } } - } + } if ( r_lightmap->integer == 2 ) { ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) ); diff --git a/codemp/rd-rend2/tr_image_stb.cpp b/codemp/rd-rend2/tr_image_stb.cpp index 401b7719db..03badd5b84 100644 --- a/codemp/rd-rend2/tr_image_stb.cpp +++ b/codemp/rd-rend2/tr_image_stb.cpp @@ -64,7 +64,7 @@ void R_LoadHDRImage( const char *filename, byte **data, int *width, int *height byte *buf = NULL; int x, y, n; int len = ri.FS_ReadFile (filename, (void **)&buf); - if ( len < 0 || buf == NULL ) + if ( len <= 0 || buf == NULL ) { return; } @@ -78,6 +78,12 @@ void R_LoadHDRImage( const char *filename, byte **data, int *width, int *height if (width) *width = x; + else + *width = 0; + if (height) *height = y; + else + *height = 0; + } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fe756c45de..50b103f8f6 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3772,7 +3772,7 @@ class SamplerBindingsWriter SamplerBindingsWriter& AddAnimatedImage( textureBundle_t *bundle, int unit ); - SamplerBinding *Finish( Allocator& destHeap, int* numBindings ); + SamplerBinding *Finish( Allocator& destHeap, uint32_t* numBindings ); private: SamplerBinding scratch[32]; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 4e9e811bf3..652024ee9a 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2116,8 +2116,6 @@ void R_RenderView (viewParms_t *parms) { firstDrawSurf = tr.refdef.numDrawSurfs; - tr.viewCount++; - // set viewParms.world R_RotateForViewer(&tr.ori, &tr.viewParms); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index d5d2b82caa..ff2be351b7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -822,175 +822,6 @@ static UniformBlockBinding GetShaderInstanceBlockUniformBinding( return binding; } -static void ForwardDlight( const shaderCommands_t *input, VertexArraysProperties *vertexArrays ) -{ - if ( !backEnd.refdef.num_dlights ) { - return; - } - - Allocator& frameAllocator = *backEndData->perFrameMemory; - cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); - - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; - GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - - UniformDataWriter uniformDataWriter; - SamplerBindingsWriter samplerBindingsWriter; - - shaderStage_t *pStage = tess.xstages[0]; - int index; - shaderProgram_t *shaderGroup; - uint32_t stateBits = 0; - if ( input->shader->numUnfoggedPasses == 1 && - pStage->glslShaderGroup == tr.lightallShader && - (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK) ) - { - index = pStage->glslShaderIndex; - - stateBits = GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; - shaderGroup = tr.lightallShader; - index &= ~LIGHTDEF_LIGHTTYPE_MASK; - index |= LIGHTDEF_USE_LIGHT_VECTOR; - - if (glState.vertexAnimation) - index |= LIGHTDEF_USE_VERTEX_ANIMATION; - - if (glState.skeletalAnimation) - index |= LIGHTDEF_USE_SKELETAL_ANIMATION; - } - else - { - index = 0; - - stateBits = GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL; - shaderGroup = tr.dlightShader; - if (input->shader->numDeforms && - !ShaderRequiresCPUDeforms(input->shader)) - { - index |= DLIGHTDEF_USE_DEFORM_VERTEXES; - } - } - - shaderProgram_t *sp = shaderGroup + index; - for ( int l = 0 ; l < backEnd.refdef.num_dlights ; l++ ) { - - if ( !( tess.dlightBits & ( 1 << l ) ) ) { - continue; // this surface definately doesn't have any of this light - } - - backEnd.pc.c_lightallDraws++; - - uniformDataWriter.Start(sp); - - { - vec4_t baseColor; - vec4_t vertColor; - - ComputeShaderColors(pStage, baseColor, vertColor, GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE, NULL, NULL); - - uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); - uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); - } - -#if 0 // TODO: Revisit this later, isn't it simply an alphaGen? - if (pStage->alphaGen == AGEN_PORTAL) - { - uniformDataWriter.SetUniformFloat(UNIFORM_PORTALRANGE, tess.shader->portalRange); - } -#endif - - uniformDataWriter.SetUniformInt(UNIFORM_COLORGEN, pStage->rgbGen); - uniformDataWriter.SetUniformInt(UNIFORM_ALPHAGEN, pStage->alphaGen); - - uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, l); - - uniformDataWriter.SetUniformVec4( - UNIFORM_NORMALSCALE, pStage->normalScale); - uniformDataWriter.SetUniformVec4( - UNIFORM_SPECULARSCALE, pStage->specularScale); - - if (pStage->bundle[TB_DIFFUSEMAP].image[0]) - samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP); - - // bind textures that are sampled and used in the glsl shader, and - // bind whiteImage to textures that are sampled but zeroed in the glsl shader - // - // alternatives: - // - use the last bound texture - // -> costs more to sample a higher res texture then throw out the result - // - disable texture sampling in glsl shader with #ifdefs, as before - // -> increases the number of shaders that must be compiled - // - - if (pStage->bundle[TB_NORMALMAP].image[0]) - samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_NORMALMAP], TB_NORMALMAP); - else if (r_normalMapping->integer) - samplerBindingsWriter.AddStaticImage( tr.whiteImage, TB_NORMALMAP ); - - if (pStage->bundle[TB_SPECULARMAP].image[0]) - samplerBindingsWriter.AddAnimatedImage( &pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); - else if (r_specularMapping->integer) - samplerBindingsWriter.AddStaticImage( tr.whiteImage, TB_SPECULARMAP ); - - vec4_t enableTextures = {}; - uniformDataWriter.SetUniformVec4(UNIFORM_ENABLETEXTURES, enableTextures); - - if (r_dlightMode->integer >= 2) - samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[l].image, TB_SHADOWMAP2); - - vec4_t texMatrix; - vec4_t texOffTurb; - ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); - uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); - uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); - - uniformDataWriter.SetUniformInt(UNIFORM_TCGEN0, pStage->bundle[0].tcGen); - uniformDataWriter.SetUniformInt(UNIFORM_TCGEN1, pStage->bundle[1].tcGen); - - CaptureDrawData(input, pStage, 0, 0); - - const GLuint currentFrameUbo = backEndData->currentFrame->ubo; - const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.lightsUboOffset, UNIFORM_BLOCK_LIGHTS }, - GetEntityBlockUniformBinding(backEnd.currentEntity), - GetShaderInstanceBlockUniformBinding( - backEnd.currentEntity, input->shader), - GetBonesBlockUniformBinding(backEnd.currentEntity) - }; - - DrawItem item = {}; - - // include GLS_DEPTHFUNC_EQUAL so alpha tested surfaces don't add light - // where they aren't rendered - item.renderState.stateBits = stateBits; - item.renderState.cullType = cullType; - item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); - item.program = sp; - item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; - item.uniformData = uniformDataWriter.Finish(frameAllocator); - - // FIXME: This is a bit ugly with the casting - item.samplerBindings = samplerBindingsWriter.Finish( - frameAllocator, (int *)&item.numSamplerBindings); - - DrawItemSetVertexAttributes( - item, attribs, vertexArrays->numVertexArrays, frameAllocator); - DrawItemSetUniformBlockBindings( - item, uniformBlockBindings, frameAllocator); - RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - - uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); - RB_AddDrawItem(backEndData->currentPass, key, item); - - backEnd.pc.c_totalIndexes += tess.numIndexes; - backEnd.pc.c_dlightIndexes += tess.numIndexes; - backEnd.pc.c_dlightVertexes += tess.numVertexes; - - RB_BinTriangleCounts(); - } -} - - static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int l; vec3_t origin; @@ -1067,7 +898,7 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( - *backEndData->perFrameMemory, (int *)&item.numSamplerBindings); + *backEndData->perFrameMemory, &item.numSamplerBindings); RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); @@ -1080,8 +911,6 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr } } - - /* =================== RB_FogPass @@ -1670,10 +1499,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays item.program = sp; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; item.uniformData = uniformDataWriter.Finish(frameAllocator); - - // FIXME: This is a bit ugly with the casting item.samplerBindings = samplerBindingsWriter.Finish( - frameAllocator, (int *)&item.numSamplerBindings); + frameAllocator, &item.numSamplerBindings); DrawItemSetVertexAttributes( item, attribs, vertexArrays->numVertexArrays, frameAllocator); @@ -1822,16 +1649,6 @@ void RB_StageIteratorGeneric( void ) RB_ShadowTessEnd( input, &vertexArrays ); } - // - // now do any dynamic lighting needed - // - /*if ( tess.dlightBits && - tess.shader->sort <= SS_OPAQUE && - !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY) ) ) - { - ForwardDlight( input, &vertexArrays ); - }*/ - // // now do fog // diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 16e2b640c2..f2d7b69275 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -464,7 +464,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max item.uniformData = uniformDataWriter.Finish(frameAllocator); item.samplerBindings = samplerBindingsWriter.Finish( - frameAllocator, (int *)&item.numSamplerBindings); + frameAllocator, &item.numSamplerBindings); DrawItemSetVertexAttributes( item, attribs, vertexArrays.numVertexArrays, frameAllocator); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 6a05be74db..6b2e15388f 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2194,7 +2194,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) item.uniformData = uniformDataWriter.Finish(frameAllocator); item.samplerBindings = samplerBindingsWriter.Finish( - frameAllocator, (int *)&item.numSamplerBindings); + frameAllocator, &item.numSamplerBindings); DrawItemSetVertexAttributes( item, surf->attributes, surf->numAttributes, frameAllocator); From 781c6fef094ef4d936bd412571436ff70c92a5e6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 19 Apr 2022 05:08:38 +0200 Subject: [PATCH 556/708] WIP nothing finished, don't use yet --- codemp/rd-rend2/glsl/lightall.glsl | 9 +- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 79 ++++++--- codemp/rd-rend2/glsl/pshadow.glsl | 6 +- codemp/rd-rend2/glsl/shadowmask.glsl | 78 ++++----- codemp/rd-rend2/glsl/tonemap.glsl | 43 ++++- codemp/rd-rend2/qgl.h | 3 + codemp/rd-rend2/tr_backend.cpp | 188 ++++++++++++--------- codemp/rd-rend2/tr_bsp.cpp | 89 +++++++--- codemp/rd-rend2/tr_cmds.cpp | 4 +- codemp/rd-rend2/tr_extensions.cpp | 7 +- codemp/rd-rend2/tr_fbo.cpp | 67 ++++---- codemp/rd-rend2/tr_ghoul2.cpp | 17 +- codemp/rd-rend2/tr_glsl.cpp | 8 +- codemp/rd-rend2/tr_image.cpp | 189 +++++++++++++++++++--- codemp/rd-rend2/tr_light.cpp | 25 ++- codemp/rd-rend2/tr_local.h | 31 ++-- codemp/rd-rend2/tr_main.cpp | 100 ++++++------ codemp/rd-rend2/tr_mesh.cpp | 5 +- codemp/rd-rend2/tr_postprocess.cpp | 5 +- codemp/rd-rend2/tr_shade.cpp | 47 +++++- codemp/rd-rend2/tr_shader.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 5 +- codemp/rd-rend2/tr_world.cpp | 1 + codemp/rd-vanilla/tr_scene.cpp | 2 +- 24 files changed, 694 insertions(+), 318 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 70042ad06d..10223eb50d 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -403,7 +403,7 @@ uniform sampler2D u_SpecularMap; uniform sampler2D u_ShadowMap; #endif -//uniform samplerCubeShadow u_ShadowMap2; +uniform samplerCubeShadow u_ShadowMap2; #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; @@ -674,7 +674,7 @@ float CalcLightAttenuation(float point, float normDist) return clamp(attenuation, 0.0, 1.0); } -#if defined(USE_LIGHT_VECTOR) && !defined(USE_VERTEX_LIGHTING) && defined(USE_DSHADOWS) +#if defined(USE_DSHADOWS) #define DEPTH_MAX_ERROR 0.000000059604644775390625 vec3 sampleOffsetDirections[20] = vec3[] @@ -714,8 +714,7 @@ float getLightDepth(in vec3 Vec, in float f) float getShadowValue(in vec4 light, in int lightId) { float distance = getLightDepth(light.xyz, light.w); - //return pcfShadow(u_ShadowMap2, light.xyz, distance); - return 1.0; + return pcfShadow(u_ShadowMap2, light.xyz, distance); } #endif @@ -902,7 +901,7 @@ void main() // Recover any unused light as ambient, in case attenuation is over 4x or // light is below the surface - ambientColor = clamp(ambientColor - lightColor * surfNL, 0.0, 1.0); + ambientColor = max(ambientColor - lightColor * surfNL, 0.0); #endif // Scale lightColor by PI because we need want to have the same output intensity diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index d2c74af00b..f80b76fc93 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -1,21 +1,43 @@ /*[Vertex]*/ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - -out vec2 var_ScreenTex; +out vec2 var_TexCoords; void main() { vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0); gl_Position = vec4(position, 0.0, 1.0); - vec2 screenCoords = gl_Position.xy; - var_ScreenTex = screenCoords * 0.5 + 0.5; + var_TexCoords = gl_Position.xy; +} + +/*[Geometry]*/ +layout(triangles) in; +layout(triangle_strip, max_vertices = 18) out; + +in vec2 var_TexCoords[]; + +out vec2 var_ScreenTex; +flat out int cubeFace; + +void main() +{ + for (int face = 0; face < 6; ++face) + { + for (int i = 0; i < 3; ++i) + { + gl_Layer = face; + gl_Position = vec4(var_TexCoords[i], -1.0, 1.0); + var_ScreenTex = var_TexCoords[i]; + cubeFace = face; + EmitVertex(); + } + EndPrimitive(); + } } /*[Fragment]*/ uniform vec4 u_ViewInfo; // cubeface, mip_level, max_mip_level, roughness uniform samplerCube u_CubeMap; in vec2 var_ScreenTex; +flat in int cubeFace; out vec4 out_Color; @@ -33,19 +55,26 @@ vec2 hammersley2D(uint i, uint N) { return vec2(float(i)/float(N), radicalInverse_VdC(i)); } +float D_GGX( in float NH, in float a ) +{ + float a2 = a * a; + float d = (NH * a2 - NH) * NH + 1; + return a2 / (M_PI * d * d); +} + vec3 ImportanceSampleGGX(vec2 Xi, float Roughness, vec3 N) { float a = Roughness * Roughness; - float Phi = 2 * M_PI * Xi.x; - float CosTheta = sqrt((1-Xi.y) / (1+(a*a -1) * Xi.y)); - float SinTheta = sqrt( 1 - CosTheta * CosTheta); + float Phi = 2.0 * M_PI * Xi.x; + float CosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a * a - 1.0) * Xi.y)); + float SinTheta = sqrt( 1.0 - CosTheta * CosTheta); vec3 H; H.x = SinTheta * cos( Phi ); H.y = SinTheta * sin( Phi ); H.z = CosTheta; - vec3 UpVector = abs(N.z) < 0.999 ? vec3(0,0,1) : vec3(1,0,0); + vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); vec3 TangentX = normalize(cross(UpVector , N)); vec3 TangentY = cross(N , TangentX); @@ -58,16 +87,27 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) vec3 V = R; vec3 PrefilteredColor = vec3(0.0); float TotalWeight = 0.0; - uint NumSamples = 1024u; + uint NumSamples = 256u; for ( uint i = 0u; i < NumSamples; i++ ) { - vec2 Xi = hammersley2D( i, NumSamples ); - vec3 H = ImportanceSampleGGX( Xi, Roughness, N ); - vec3 L = 2 * dot( V, H ) * H - V; - float NoL = clamp((dot( N, L )),0.0,1.0); - if ( NoL > 0 ) + vec2 Xi = hammersley2D(i, NumSamples); + vec3 H = ImportanceSampleGGX(Xi, Roughness, N); + vec3 L = 2.0 * dot(V, H) * H - V; + float NoL = clamp(dot(N, L), 0.0, 1.0); + if ( NoL > 0.0 ) { - PrefilteredColor += textureLod(u_CubeMap, L, 0.0).rgb * NoL; + float NH = max(dot ( N, H ), 0.0); + float HV = max(dot ( H, V ), 0.0); + float D = D_GGX(NH, Roughness); + float pdf = (D * NH / (4.0 * HV)) + 0.0001; + + const float cubemapSize = 256.0; + float saTexel = 4.0 * M_PI / (6.0 * cubemapSize * cubemapSize); + float saSample = 1.0 / (float(NumSamples) * pdf + 0.0001); + + float mipLevel = Roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); + + PrefilteredColor += textureLod(u_CubeMap, L, mipLevel).rgb * NoL; TotalWeight += NoL; } } @@ -76,8 +116,7 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) void main() { - float cubeFace = u_ViewInfo.x; - vec2 vector = (var_ScreenTex - vec2(0.5)) * 2.0; + vec2 vector = var_ScreenTex; // from http://www.codinglabs.net/article_physically_based_rendering.aspx vec3 normal = normalize(vec3(-vector.x, -vector.y, -1.0)); @@ -96,6 +135,8 @@ void main() float roughness = u_ViewInfo.w; vec3 result = PrefilterEnvMap(roughness, normal); + if (roughness == 0.0) + result = textureLod(u_CubeMap, normal, 0.0).rgb; out_Color = vec4(result, 1.0); } \ No newline at end of file diff --git a/codemp/rd-rend2/glsl/pshadow.glsl b/codemp/rd-rend2/glsl/pshadow.glsl index 680cadf8cd..4fa269c03a 100644 --- a/codemp/rd-rend2/glsl/pshadow.glsl +++ b/codemp/rd-rend2/glsl/pshadow.glsl @@ -17,7 +17,7 @@ void main() } /*[Fragment]*/ -uniform sampler2D u_ShadowMap; +uniform sampler2DArray u_ShadowMap; uniform vec3 u_LightForward; uniform vec3 u_LightUp; uniform vec3 u_LightRight; @@ -83,10 +83,10 @@ void main() float offsetScale = pow(lightDist, 4.0) * TEXTURE_SCALE * 0.00000001; for (int i = 0; i < PCF_SAMPLES; ++i) { - part += float(texture(u_ShadowMap, st + offsetScale * poissonDisc[i]).r != 1.0); + part += float(texture(u_ShadowMap, vec3(st + offsetScale * poissonDisc[i], u_LightOrigin.w)).r != 1.0); } #else - part = float(texture(u_ShadowMap, st).r != 1.0); + part = float(texture(u_ShadowMap, vec3(st, u_LightOrigin.w)).r != 1.0); #endif if (part <= 0.0) diff --git a/codemp/rd-rend2/glsl/shadowmask.glsl b/codemp/rd-rend2/glsl/shadowmask.glsl index 1123330ee1..5e07f156dd 100644 --- a/codemp/rd-rend2/glsl/shadowmask.glsl +++ b/codemp/rd-rend2/glsl/shadowmask.glsl @@ -1,7 +1,4 @@ /*[Vertex]*/ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - uniform vec3 u_ViewForward; uniform vec3 u_ViewLeft; uniform vec3 u_ViewUp; @@ -12,26 +9,21 @@ out vec3 var_ViewDir; void main() { - gl_Position = attr_Position; + vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0); + gl_Position = vec4(position, 0.0, 1.0); vec2 screenCoords = gl_Position.xy / gl_Position.w; - var_DepthTex = attr_TexCoord0.xy; + var_DepthTex = position.xy * .5 + .5; var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; } /*[Fragment]*/ uniform sampler2D u_ScreenDepthMap; -uniform sampler2DShadow u_ShadowMap; -#if defined(USE_SHADOW_CASCADE) -uniform sampler2DShadow u_ShadowMap2; -uniform sampler2DShadow u_ShadowMap3; -#endif +uniform sampler2DArrayShadow u_ShadowMap; uniform mat4 u_ShadowMvp; -#if defined(USE_SHADOW_CASCADE) uniform mat4 u_ShadowMvp2; uniform mat4 u_ShadowMvp3; -#endif uniform vec3 u_ViewOrigin; uniform vec4 u_ViewInfo; // zfar / znear, zfar @@ -41,9 +33,9 @@ in vec3 var_ViewDir; out vec4 out_Color; -// depth is GL_DEPTH_COMPONENT24 -// so the maximum error is 1.0 / 2^24 -#define DEPTH_MAX_ERROR 0.000000059604644775390625 +// depth is GL_DEPTH_COMPONENT16 +// so the maximum error is 1.0 / 2^16 +#define DEPTH_MAX_ERROR 0.0000152587890625 // Input: It uses texture coords as the random number seed. // Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. @@ -81,7 +73,7 @@ const vec2 poissonDisk[16] = vec2[16]( vec2( 0.14383161, -0.14100790 ) ); -float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist, float PCFScale) +float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st, const float dist, float PCFScale) { float mult; float scale = PCFScale / r_shadowMapSize; @@ -92,16 +84,16 @@ float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist, floa float cosr = cos(r); mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; - mult = texture(shadowmap, vec3(st + rmat * vec2(-0.7055767, 0.196515), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(0.3524343, -0.7791386), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(0.2391056, 0.9189604), dist)); + mult = texture(shadowmap, vec4(st + rmat * vec2(-0.7055767, 0.196515), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.3524343, -0.7791386), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.2391056, 0.9189604), layer, dist)); #if defined(USE_SHADOW_FILTER2) - mult += texture(shadowmap, vec3(st + rmat * vec2(-0.07580382, -0.09224417), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(0.5784913, -0.002528916), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(0.192888, 0.4064181), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(-0.6335801, -0.5247476), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(-0.5579782, 0.7491854), dist)); - mult += texture(shadowmap, vec3(st + rmat * vec2(0.7320465, 0.6317794), dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.07580382, -0.09224417), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.5784913, -0.002528916), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.192888, 0.4064181), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.6335801, -0.5247476), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.5579782, 0.7491854), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.7320465, 0.6317794), layer, dist)); mult *= 0.11111; #else @@ -113,11 +105,11 @@ float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist, floa float cosr = cos(r); mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; - mult = texture(shadowmap, vec3(st, dist)); + mult = texture(shadowmap, vec4(st, layer, dist)); for (int i = 0; i < 16; i++) { vec2 delta = rmat * poissonDisk[i]; - mult += texture(shadowmap, vec3(st + delta, dist)); + mult += texture(shadowmap, vec4(st + delta, layer, dist)); } mult *= 1.0 / 17.0; #endif @@ -128,16 +120,16 @@ float PCF(const sampler2DShadow shadowmap, const vec2 st, const float dist, floa float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear, float maxErrorFactor) { float sampleZDivW = texture(depthMap, tex).r; - sampleZDivW += DEPTH_MAX_ERROR; - //sampleZDivW -= maxErrorFactor * fwidth(sampleZDivW); + sampleZDivW -= DEPTH_MAX_ERROR; + sampleZDivW -= maxErrorFactor * fwidth(sampleZDivW); return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); } void main() { - float result; - float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); + + float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 3.0); float sampleZ = u_ViewInfo.y * depth; vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); @@ -145,49 +137,43 @@ void main() const float PCFScale = 1.0; const float edgeBias = 0.5 - ( 4.0 * PCFScale / r_shadowMapSize ); float edgefactor = 0.0; - -#if defined(USE_SHADOW_CASCADE) const float fadeTo = 1.0; - result = fadeTo; -#else - result = 0.0; -#endif + float result = 1.0; + vec4 shadowpos = u_ShadowMvp * biasPos; shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) { vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); edgefactor = 2.0 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); - result = PCF(u_ShadowMap, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); + result = PCF(u_ShadowMap, 0.0, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); } -#if defined(USE_SHADOW_CASCADE) else { - depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); - biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); + //depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 1.5); + //biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); shadowpos = u_ShadowMvp2 * biasPos; shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) { vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); edgefactor = 0.5 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); - result = PCF(u_ShadowMap2, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); + result = PCF(u_ShadowMap, 1.0, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); } else { - depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 0.0); - biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); + //depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 1.0); + //biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); shadowpos = u_ShadowMvp3 * biasPos; shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(1.0)))) { - result = PCF(u_ShadowMap3, shadowpos.xy, shadowpos.z, PCFScale); + result = PCF(u_ShadowMap, 2.0, shadowpos.xy, shadowpos.z, PCFScale); float fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0); result = mix(result, fadeTo, fade); } } } -#endif out_Color = vec4(vec3(result), 1.0); } diff --git a/codemp/rd-rend2/glsl/tonemap.glsl b/codemp/rd-rend2/glsl/tonemap.glsl index dc39403557..6e0f314873 100644 --- a/codemp/rd-rend2/glsl/tonemap.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -47,9 +47,50 @@ vec3 FilmicTonemap(vec3 x) return ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD; //return ((x*(SS*x+LA*LS)+TS*TAN)/(x*(SS*x+LS)+TS*TAD)) - TAN/TAD; +} + +// The ACES code in this file was originally written by Stephen Hill (@self_shadow), who deserves all +// credit for coming up with this fit and implementing it. Buy him a beer next time you see him. :) + +// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT +const mat3 ACESInputMat = mat3 +( + vec3(0.59719, 0.35458, 0.04823), + vec3(0.07600, 0.90834, 0.01566), + vec3(0.02840, 0.13383, 0.83777) +); + +// ODT_SAT => XYZ => D60_2_D65 => sRGB +const mat3 ACESOutputMat = mat3 +( + vec3( 1.60475, -0.53108, -0.07367), + vec3(-0.10208, 1.10813, -0.00605), + vec3(-0.00327, -0.07276, 1.07602) +); + +vec3 RRTAndODTFit(vec3 v) +{ + vec3 a = v * (v + 0.0245786f) - 0.000090537f; + vec3 b = v * (0.983729f * v + 0.4329510f) + 0.238081f; + return a / b; +} + +vec3 ACESFitted(vec3 color) +{ + color = color * ACESInputMat; + + // Apply RRT and ODT + color = RRTAndODTFit(color); + + color = color * ACESOutputMat; + // Clamp to [0, 1] + color = clamp(color, 0.0, 1.0); + + return color; } + void main() { vec4 color = texture(u_TextureMap, var_TexCoords) * u_Color; @@ -66,7 +107,7 @@ void main() color.rgb = FilmicTonemap(color.rgb) * fWhite; #if defined(USE_LINEAR_LIGHT) - color.rgb = LinearTosRGB(color.rgb); + color.rgb = LinearTosRGB(color.rgb); #endif out_Color = clamp(color, 0.0, 1.0); diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 844b94c6fc..69de9d8549 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -410,6 +410,7 @@ extern PFNGLISBUFFERPROC qglIsBuffer; // Texturing extern PFNGLACTIVETEXTUREPROC qglActiveTexture; +extern PFNGLTEXIMAGE3DPROC qglTexImage3D; // Shader objects extern PFNGLCREATESHADERPROC qglCreateShader; @@ -542,6 +543,8 @@ extern PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus; extern PFNGLFRAMEBUFFERTEXTURE1DPROC qglFramebufferTexture1D; extern PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D; extern PFNGLFRAMEBUFFERTEXTURE3DPROC qglFramebufferTexture3D; +extern PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTexture; +extern PFNGLFRAMEBUFFERTEXTURELAYERPROC qglFramebufferTextureLayer; extern PFNGLFRAMEBUFFERRENDERBUFFERPROC qglFramebufferRenderbuffer; extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC qglGetFramebufferAttachmentParameteriv; extern PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC qglRenderbufferStorageMultisample; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 32e7250844..3935594e07 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -62,6 +62,10 @@ void GL_Bind( image_t *image ) { glState.currenttextures[glState.currenttmu] = texnum; if (image && image->flags & IMGFLAG_CUBEMAP) qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); + else if (image->flags & IMGFLAG_3D) + qglBindTexture(GL_TEXTURE_3D, texnum); + else if (image->flags & IMGFLAG_2D_ARRAY) + qglBindTexture(GL_TEXTURE_2D_ARRAY, texnum); else qglBindTexture( GL_TEXTURE_2D, texnum ); } @@ -106,6 +110,10 @@ void GL_BindToTMU( image_t *image, int tmu ) if (image && (image->flags & IMGFLAG_CUBEMAP)) qglBindTexture( GL_TEXTURE_CUBE_MAP, texnum ); + else if (image && (image->flags & IMGFLAG_3D)) + qglBindTexture(GL_TEXTURE_3D, texnum); + else if (image && (image->flags & IMGFLAG_2D_ARRAY)) + qglBindTexture(GL_TEXTURE_2D_ARRAY, texnum); else qglBindTexture( GL_TEXTURE_2D, texnum ); } @@ -546,15 +554,10 @@ void RB_BeginDrawingView (void) { { FBO_Bind(backEnd.viewParms.targetFbo); - // FIXME: hack for cubemap testing - if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + // FIXME: hack for shadows testing + if (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo) { - image_t *cubemap = backEnd.viewParms.targetFboCubemap->image; - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); - } - else if (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo) - { - image_t *cubemap = backEnd.viewParms.targetFboCubemap->image; + image_t *cubemap = tr.shadowCubemaps[0].image; qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); } } @@ -606,9 +609,9 @@ void RB_BeginDrawingView (void) { clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } - + // clear to black for cube maps - if (tr.renderCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.renderCubeFbo) + if (backEnd.viewParms.flags & VPF_CUBEMAPSIDE) { clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); @@ -1258,7 +1261,13 @@ static void RB_SubmitDrawSurfsForDepthFill( R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemapIndex, &postRender); assert(shader != nullptr); - if ( shader == oldShader && entityNum == oldEntityNum ) + if (shader->sort != SS_OPAQUE) + { + // Don't draw yet, let's see what's to come + continue; + } + + if ( shader == oldShader && entityNum == oldEntityNum) { // fast path, same as previous sort backEnd.currentDrawSurfIndex = i; @@ -1273,12 +1282,6 @@ static void RB_SubmitDrawSurfsForDepthFill( if ( shader != oldShader || (entityNum != oldEntityNum && !shader->entityMergable) ) { - if ( shader->sort != SS_OPAQUE ) - { - // Don't draw yet, let's see what's to come - continue; - } - if ( oldShader != nullptr ) { RB_EndSurface(); @@ -1389,6 +1392,10 @@ static void RB_SubmitDrawSurfs( backEnd.currentDrawSurfIndex = i; + // ugly hack for now... + // find better way to pass dlightbits + tess.dlightBits = drawSurf->dlightBits; + // add the triangles for this surface rb_surfaceTable[*drawSurf->surface](drawSurf->surface); } @@ -1957,32 +1964,52 @@ static const void *RB_PrefilterEnvMap(const void *data) { RB_SetGL2D(); - image_t *cubemap = cmd->cubemap->image; + qglBindTexture(GL_TEXTURE_CUBE_MAP, tr.renderCubeImage->texnum); + qglGenerateMipmap(GL_TEXTURE_CUBE_MAP); + qglBindTexture(GL_TEXTURE_CUBE_MAP, 0); - if (!cubemap) - return (const void *)(cmd + 1); - - FBO_Bind(tr.preFilterEnvMapFbo); - GL_BindToTMU(cubemap, TB_CUBEMAP); - - GLSL_BindProgram(&tr.prefilterEnvMapShader); - - int width = cubemap->width; - int height = cubemap->height; + if (!cmd->cubemap->image) + { + GLenum cubemapFormat = GL_RGBA8; + if (r_hdr->integer) + { + cubemapFormat = GL_RGBA16F; + } + // FIX ME: Only allocate needed mip level! + cmd->cubemap->image = R_CreateImage( + va("*cubeMap%d", cmd->cubemapId), + NULL, + CUBE_MAP_SIZE, + CUBE_MAP_SIZE, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE | + IMGFLAG_MIPMAP | + IMGFLAG_CUBEMAP, + cubemapFormat); + } + assert(cmd->cubemap->image); + + int width = cmd->cubemap->image->width; + int height = cmd->cubemap->image->height; float roughnessMips = (float)CUBE_MAP_MIPS - 4.0f; - for (int level = 1; level <= CUBE_MAP_MIPS; level++) + for (int level = 0; level <= (int)roughnessMips; level++) { - width = width / 2; - height = height / 2; + FBO_Bind(tr.filterCubeFbo); + qglFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cmd->cubemap->image->texnum, level); + GL_BindToTMU(tr.renderCubeImage, TB_CUBEMAP); + GLSL_BindProgram(&tr.prefilterEnvMapShader); + qglViewport(0, 0, width, height); qglScissor(0, 0, width, height); vec4_t viewInfo; - VectorSet4(viewInfo, cmd->cubeSide, level, roughnessMips, level / roughnessMips); + VectorSet4(viewInfo, 0, level, roughnessMips, level / roughnessMips); GLSL_SetUniformVec4(&tr.prefilterEnvMapShader, UNIFORM_VIEWINFO, viewInfo); RB_InstantTriangle(); - qglCopyTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + cmd->cubeSide, level, 0, 0, 0, 0, width, height); + width = width / 2; + height = height / 2; } return (const void *)(cmd + 1); @@ -1998,8 +2025,6 @@ static void RB_RenderSunShadows() FBO_t *shadowFbo = tr.screenShadowFbo; - vec4_t quadVerts[4]; - vec2_t texCoords[4]; vec4_t box; FBO_Bind(shadowFbo); @@ -2015,33 +2040,27 @@ static void RB_RenderSunShadows() qglViewport(box[0], box[1], box[2], box[3]); qglScissor(box[0], box[1], box[2], box[3]); - box[0] = backEnd.viewParms.viewportX / (float)glConfig.vidWidth; - box[1] = backEnd.viewParms.viewportY / (float)glConfig.vidHeight; - box[2] = box[0] + backEnd.viewParms.viewportWidth / (float)glConfig.vidWidth; - box[3] = box[1] + backEnd.viewParms.viewportHeight / (float)glConfig.vidHeight; - - texCoords[0][0] = box[0]; texCoords[0][1] = box[3]; - texCoords[1][0] = box[2]; texCoords[1][1] = box[3]; - texCoords[2][0] = box[2]; texCoords[2][1] = box[1]; - texCoords[3][0] = box[0]; texCoords[3][1] = box[1]; - - box[0] = -1.0f; - box[1] = -1.0f; - box[2] = 1.0f; - box[3] = 1.0f; - - VectorSet4(quadVerts[0], box[0], box[3], 0, 1); - VectorSet4(quadVerts[1], box[2], box[3], 0, 1); - VectorSet4(quadVerts[2], box[2], box[1], 0, 1); - VectorSet4(quadVerts[3], box[0], box[1], 0, 1); - GL_State(GLS_DEPTHTEST_DISABLE); GLSL_BindProgram(&tr.shadowmaskShader); - GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); - GL_BindToTMU(tr.sunShadowDepthImage[0], TB_SHADOWMAP); - GL_BindToTMU(tr.sunShadowDepthImage[1], TB_SHADOWMAP2); - GL_BindToTMU(tr.sunShadowDepthImage[2], TB_SHADOWMAP3); + if (tr.renderCubeFbo[0] != NULL && ( + backEnd.viewParms.targetFbo == tr.renderCubeFbo[0] || + backEnd.viewParms.targetFbo == tr.renderCubeFbo[1] || + backEnd.viewParms.targetFbo == tr.renderCubeFbo[2] || + backEnd.viewParms.targetFbo == tr.renderCubeFbo[3] || + backEnd.viewParms.targetFbo == tr.renderCubeFbo[4] || + backEnd.viewParms.targetFbo == tr.renderCubeFbo[5] + ) + ) + { + GL_BindToTMU(tr.renderCubeDepthImage, TB_COLORMAP); + } + else + { + GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); + } + + GL_BindToTMU(tr.sunShadowArrayMap, TB_SHADOWMAP); GLSL_SetUniformMatrix4x4( &tr.shadowmaskShader, @@ -2077,8 +2096,9 @@ static void RB_RenderSunShadows() const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); + RB_InstantTriangle(); - RB_InstantQuad2(quadVerts, texCoords); + GL_BindToTMU(NULL, TB_SHADOWMAP); } static void RB_RenderSSAO() @@ -2087,7 +2107,6 @@ static void RB_RenderSSAO() const float zmin = r_znear->value; const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; - FBO_Bind(tr.quarterFbo[0]); qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); @@ -2271,6 +2290,8 @@ static void RB_UpdateCameraConstants(gpuFrame_t *frame) const float zmax = backEnd.viewParms.zFar; const float zmin = r_znear->value; + // TODO: Add ViewProjection Matrix + CameraBlock cameraBlock = {}; VectorSet4(cameraBlock.viewInfo, zmax / zmin, zmax, 0.0f, 0.0f); VectorCopy(backEnd.refdef.viewaxis[0], cameraBlock.viewForward); @@ -2310,6 +2331,7 @@ static void RB_UpdateLightsConstants(gpuFrame_t *frame) VectorCopy(dlight->color, lightData->color); lightData->radius = dlight->radius; } + // TODO: Add pshadow data tr.lightsUboOffset = RB_AppendConstantsData( frame, &lightsBlock, sizeof(lightsBlock)); @@ -2474,7 +2496,8 @@ int RB_GetEntityShaderUboOffset( return uboOffset.offset; hash = (hash + 1) % mapSize; } - + if (backEnd.frameUBOsInitialized == qfalse) + ri.Printf(PRINT_ALL, "Failed finding Entity Shader UboOffset! BAD\n"); return -1; } @@ -2618,8 +2641,6 @@ static void RB_UpdateShaderEntityConstants( static void RB_UpdateShaderAndEntityConstants( gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) { - bool updatedEntities[MAX_REFENTITIES + 1] = {}; - // Make the map bigger than it needs to be. Eases collisions and iterations // through the map during lookup/insertion. tr.shaderInstanceUboOffsetsMapSize = numDrawSurfs * 2; @@ -2647,17 +2668,24 @@ static void RB_UpdateShaderAndEntityConstants( R_DecomposeSort( drawSurf->sort, &entityNum, &shader, &ignored, &ignored); - if (shader == oldShader && - (entityNum == oldEntityNum || shader->entityMergable)) - { - tr.entityUboOffsets[entityNum] = old_ubo; + if (shader == oldShader && entityNum == oldEntityNum) continue; + + if (backEnd.frameUBOsInitialized == qtrue) + { + // TODO: check if data set already inserted + if (RB_GetEntityShaderUboOffset( + tr.shaderInstanceUboOffsetsMap, + tr.shaderInstanceUboOffsetsMapSize, + entityNum, + shader->index) != -1) + continue; } const trRefEntity_t *refEntity = entityNum == REFENTITYNUM_WORLD ? &tr.worldEntity : &backEnd.refdef.entities[entityNum]; - //FIX ME: find out why this causes trouble! - if (!updatedEntities[entityNum]) + if (shader != oldShader || + (entityNum != oldEntityNum /* && !shader->entityMergable*/)) { EntityBlock entityBlock = {}; @@ -2675,9 +2703,7 @@ static void RB_UpdateShaderAndEntityConstants( tr.entityUboOffsets[entityNum] = RB_AppendConstantsData( frame, &entityBlock, sizeof(entityBlock)); - updatedEntities[entityNum] = true; } - old_ubo = tr.entityUboOffsets[entityNum]; oldShader = shader; oldEntityNum = entityNum; @@ -2701,9 +2727,9 @@ static void RB_UpdateAnimationConstants( const drawSurf_t *drawSurf = drawSurfs + i; if (*drawSurf->surface != SF_MDX) continue; + CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; - RB_TransformBones( - (CRenderableSurface *)drawSurf->surface); + RB_TransformBones(RS); } // now get offsets or add skeletons to ubo @@ -2712,8 +2738,8 @@ static void RB_UpdateAnimationConstants( const drawSurf_t *drawSurf = drawSurfs + i; if (*drawSurf->surface != SF_MDX) continue; - CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; + int currentOffset = RB_GetBoneUboOffset(RS); if (currentOffset < 0) { @@ -2802,9 +2828,12 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_BeginConstantsUpdate(frame); RB_UpdateCameraConstants(frame); - RB_UpdateSceneConstants(frame); - RB_UpdateLightsConstants(frame); - RB_UpdateFogsConstants(frame); + if (backEnd.frameUBOsInitialized == qfalse) + { + RB_UpdateSceneConstants(frame); + RB_UpdateLightsConstants(frame); + RB_UpdateFogsConstants(frame); + } RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); RB_UpdateAnimationConstants(frame, drawSurfs, numDrawSurfs); @@ -2812,6 +2841,8 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_UpdateSpriteConstants(frame, drawSurfs, numDrawSurfs); RB_EndConstantsUpdate(frame); + + backEnd.frameUBOsInitialized = qtrue; } @@ -3038,6 +3069,7 @@ static const void *RB_SwapBuffers( const void *data ) { backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; + backEnd.frameUBOsInitialized = qfalse; return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index d45c6774f7..6a551bb9dc 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3160,34 +3160,19 @@ static void R_RenderAllCubemaps() for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; - for (int i = 0; i < tr.numCubemaps; i++) + // Limit number of Cubemaps per map + int maxCubemaps = MIN(tr.numCubemaps, 128); + for (int i = 0; i < maxCubemaps; i++) { - if (!bounce) - tr.cubemaps[i].image = R_CreateImage( - va("*cubeMap%d", i), - NULL, - CUBE_MAP_SIZE, - CUBE_MAP_SIZE, - IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE | - IMGFLAG_MIPMAP | - IMGFLAG_CUBEMAP, - cubemapFormat); - RE_BeginFrame(STEREO_CENTER); for (int j = 0; j < 6; j++) { - RE_ClearScene(); R_RenderCubemapSide(i, j, qfalse, bounce); - R_IssuePendingRenderCommands(); - } - for (int j = 0; j < 6; j++) - { - RE_ClearScene(); - R_AddConvolveCubemapCmd(&tr.cubemaps[i], j); - R_IssuePendingRenderCommands(); } + + RE_ClearScene(); + R_AddConvolveCubemapCmd(&tr.cubemaps[i], i); + R_IssuePendingRenderCommands(); RE_EndFrame( &frontEndMsec, &backEndMsec ); } } @@ -3838,29 +3823,89 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } // load into heap + int startTime, endTime; + startTime = ri.Milliseconds(); R_LoadEntities(worldData, &header->lumps[LUMP_ENTITIES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadEntities in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadShaders(worldData, &header->lumps[LUMP_SHADERS]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadShaders in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadLightmaps( worldData, &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadLightmaps in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadPlanes(worldData, &header->lumps[LUMP_PLANES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadPlanes in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadFogs( worldData, &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadFogs in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadSurfaces( worldData, &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadSurfaces in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadMarksurfaces(worldData, &header->lumps[LUMP_LEAFSURFACES]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadMarksurfaces in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadNodesAndLeafs(worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadNodesAndLeafs in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadSubmodels(worldData, worldIndex, &header->lumps[LUMP_MODELS]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadSubmodels in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadVisibility(worldData, &header->lumps[LUMP_VISIBILITY]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadVisibility in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadLightGrid in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); + + startTime = ri.Milliseconds(); R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); + endTime = ri.Milliseconds(); + ri.Printf(PRINT_ALL, "R_LoadLightGridArray in %5.2f seconds\n", + (endTime - startTime) / 1000.0f); R_GenerateSurfaceSprites(worldData); diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 8fe70f7872..3787c42686 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -230,7 +230,7 @@ R_AddConvolveCubemapsCmd ============= */ -void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubeSide ) { +void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { convolveCubemapCommand_t *cmd; cmd = (convolveCubemapCommand_t *)R_GetCommandBuffer( sizeof( *cmd )); @@ -240,7 +240,7 @@ void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubeSide ) { cmd->commandId = RC_CONVOLVECUBEMAP; cmd->cubemap = cubemap; - cmd->cubeSide = cubeSide; + cmd->cubemapId = cubemapId; } /* diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index d57cd237f9..565f7127fd 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -73,6 +73,7 @@ PFNGLISBUFFERPROC qglIsBuffer; // Texturing PFNGLACTIVETEXTUREPROC qglActiveTexture; +PFNGLTEXIMAGE3DPROC qglTexImage3D; // Shader objects PFNGLCREATESHADERPROC qglCreateShader; @@ -187,6 +188,8 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC qglCheckFramebufferStatus; PFNGLFRAMEBUFFERTEXTURE1DPROC qglFramebufferTexture1D; PFNGLFRAMEBUFFERTEXTURE2DPROC qglFramebufferTexture2D; PFNGLFRAMEBUFFERTEXTURE3DPROC qglFramebufferTexture3D; +PFNGLFRAMEBUFFERTEXTUREPROC qglFramebufferTexture; +PFNGLFRAMEBUFFERTEXTURELAYERPROC qglFramebufferTextureLayer; PFNGLFRAMEBUFFERRENDERBUFFERPROC qglFramebufferRenderbuffer; PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC qglGetFramebufferAttachmentParameteriv; PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC qglRenderbufferStorageMultisample; @@ -349,7 +352,7 @@ void GLimp_InitCoreFunctions() // Texturing GetGLFunction (qglActiveTexture, "glActiveTexture", qtrue); - + GetGLFunction (qglTexImage3D, "glTexImage3D", qtrue); // Shader objects GetGLFunction (qglCreateShader, "glCreateShader", qtrue); @@ -476,6 +479,8 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglFramebufferTexture1D, "glFramebufferTexture1D", qtrue); GetGLFunction (qglFramebufferTexture2D, "glFramebufferTexture2D", qtrue); GetGLFunction (qglFramebufferTexture3D, "glFramebufferTexture3D", qtrue); + GetGLFunction (qglFramebufferTexture, "glFramebufferTexture", qtrue); + GetGLFunction (qglFramebufferTextureLayer, "glFramebufferTextureLayer", qtrue); GetGLFunction (qglFramebufferRenderbuffer, "glFramebufferRenderbuffer", qtrue); GetGLFunction (qglGetFramebufferAttachmentParameteriv, "glGetFramebufferAttachmentParameteriv", qtrue); GetGLFunction (qglRenderbufferStorageMultisample, "glRenderbufferStorageMultisample", qtrue); diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index b641945903..619903a9a3 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -298,6 +298,7 @@ void FBO_AttachTextureImage(image_t *img, int index) } R_AttachFBOTexture2D(GL_TEXTURE_2D, img->texnum, index); + glState.currentFBO->colorImage[index] = img; glState.currentFBO->colorBuffers[index] = img->texnum; } @@ -461,7 +462,7 @@ void FBO_Init(void) // clear render buffer // this fixes the corrupt screen bug with r_hdr 1 on older hardware FBO_Bind(tr.renderFbo); - qglClearColor( 1, 0, 0.5, 1 ); + qglClearColor( 0.f, 0.f, 0.f, 1 ); qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // glow buffers @@ -494,23 +495,22 @@ void FBO_Init(void) R_CheckFBO(tr.sunRaysFbo); } - // FIXME: Don't use separate color/depth buffers for a shadow buffer #if MAX_DRAWN_PSHADOWS > 0 - if (tr.pshadowMaps[0] != NULL) + if (tr.pshadowArrayMap != NULL) { for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) { tr.pshadowFbos[i] = FBO_Create( - va("_shadowmap%i", i), tr.pshadowMaps[i]->width, - tr.pshadowMaps[i]->height); + va("_shadowmap%i", i), tr.pshadowArrayMap->width, + tr.pshadowArrayMap->height); FBO_Bind(tr.pshadowFbos[i]); - FBO_CreateBuffer(tr.pshadowFbos[i], GL_DEPTH_COMPONENT24, 0, 0); - R_AttachFBOTextureDepth(tr.pshadowMaps[i]->texnum); - FBO_SetupDrawBuffers(); - + qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.pshadowArrayMap->texnum, 0, i); + qglDrawBuffer(GL_NONE); + qglReadBuffer(GL_NONE); R_CheckFBO(tr.pshadowFbos[i]); } + } #endif @@ -530,14 +530,13 @@ void FBO_Init(void) for ( i = 0; i < 3; i++) { tr.sunShadowFbo[i] = FBO_Create( - "_sunshadowmap", tr.sunShadowDepthImage[i]->width, - tr.sunShadowDepthImage[i]->height); + "_sunshadowmap", tr.sunShadowArrayMap->width, + tr.sunShadowArrayMap->height); FBO_Bind(tr.sunShadowFbo[i]); + qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.sunShadowArrayMap->texnum, 0, i); qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); - R_AttachFBOTextureDepth(tr.sunShadowDepthImage[i]->texnum); - FBO_SetupDrawBuffers(); R_CheckFBO(tr.sunShadowFbo[i]); } @@ -627,32 +626,30 @@ void FBO_Init(void) if (tr.renderCubeImage != NULL) { - tr.renderCubeFbo = FBO_Create( - "_renderCubeFbo", tr.renderCubeImage->width, - tr.renderCubeImage->height); - - FBO_Bind(tr.renderCubeFbo); - R_AttachFBOTexture2D( - GL_TEXTURE_CUBE_MAP_POSITIVE_X, tr.renderCubeImage->texnum, 0); - glState.currentFBO->colorImage[0] = tr.renderCubeImage; - glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; - R_AttachFBOTextureDepth(tr.renderDepthImage->texnum); - FBO_SetupDrawBuffers(); + for (i = 0; i < 6; i++) + { + tr.renderCubeFbo[i] = FBO_Create( + "_renderCubeFbo", tr.renderCubeImage->width, + tr.renderCubeImage->height); + FBO_Bind(tr.renderCubeFbo[i]); + R_AttachFBOTexture2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, tr.renderCubeImage->texnum, 0); + glState.currentFBO->colorImage[0] = tr.renderCubeImage; + glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; + R_AttachFBOTextureDepth(tr.renderCubeDepthImage->texnum); - R_CheckFBO(tr.renderCubeFbo); - } + FBO_SetupDrawBuffers(); + R_CheckFBO(tr.renderCubeFbo[i]); + } - if (tr.renderCubeImage != NULL) - { - tr.preFilterEnvMapFbo = FBO_Create( - "_preFilterEnvMapFbo", tr.renderCubeImage->width, + tr.filterCubeFbo = FBO_Create( + "_filterCubeFbo", tr.renderCubeImage->width, tr.renderCubeImage->height); - - FBO_Bind(tr.preFilterEnvMapFbo); - FBO_AttachTextureImage(tr.prefilterEnvMapImage, 0); + FBO_Bind(tr.filterCubeFbo); + qglFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tr.renderCubeImage->texnum, 0); + glState.currentFBO->colorImage[0] = tr.renderCubeImage; + glState.currentFBO->colorBuffers[0] = tr.renderCubeImage->texnum; FBO_SetupDrawBuffers(); - - R_CheckFBO(tr.preFilterEnvMapFbo); + R_CheckFBO(tr.filterCubeFbo); } if (tr.weatherDepthImage != nullptr) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index f6dbe54ab4..108bf0a95b 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2381,7 +2381,13 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum shader = R_GetShaderByHandle( surfInfo->shaderIndex ); } - int cubemapIndex = R_CubemapForPoint (ent->e.origin); + // Get dlightBits and Cubemap + float radius; + // scale the radius if needed + float largestScale = MAX(ent->e.modelScale[0], MAX(ent->e.modelScale[1], ent->e.modelScale[2])); + radius = ent->e.radius * largestScale; + int dlightBits = R_DLightsForPoint(ent->e.origin, radius); + int cubemapIndex = R_CubemapForPoint(ent->e.origin); // don't add third_person objects if not viewing through a portal if ( !RS.personalModel ) @@ -2393,6 +2399,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum assert (newSurf->vboMesh != NULL && RS.surfaceNum == surface->thisSurfaceIndex); newSurf->surfaceData = surface; newSurf->boneCache = RS.boneCache; + newSurf->dlightBits = dlightBits; // render shadows? if (r_shadows->integer == 2 @@ -3456,8 +3463,10 @@ void RB_TransformBones(CRenderableSurface *surf) int RB_GetBoneUboOffset(CRenderableSurface *surf) { - return surf->boneCache->uboOffset; - + if (surf->boneCache) + return surf->boneCache->uboOffset; + else + return -1; } void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset) @@ -3488,6 +3497,8 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); + tess.dlightBits = surf->dlightBits; + tess.useInternalVBO = qfalse; tess.externalIBO = surface->ibo; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 306afb800e..a89cb3c118 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1575,6 +1575,9 @@ static int GLSL_LoadGPUProgramLightAll( if (useFastLight) Q_strcat(extradefines, sizeof(extradefines), "#define USE_FAST_LIGHT\n"); + if (r_dlightMode->integer >= 2) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_DSHADOWS\n"); + switch (lightType) { case LIGHTDEF_USE_LIGHTMAP: @@ -1591,9 +1594,6 @@ static int GLSL_LoadGPUProgramLightAll( case LIGHTDEF_USE_LIGHT_VECTOR: { Q_strcat(extradefines, sizeof(extradefines), "#define USE_LIGHT_VECTOR\n"); - if (r_dlightMode->integer >= 2) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_DSHADOWS\n"); - break; } @@ -1971,8 +1971,6 @@ static int GLSL_LoadGPUProgramShadowMask( if (r_shadowFilter->integer >= 2) Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_CASCADE\n"); - Q_strcat( extradefines, sizeof(extradefines), va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 983a8ce750..abd67543cb 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2362,7 +2362,7 @@ static void R_FreeImage( image_t *imageToFree ) ================ R_CreateImage -This is the only way any image_t are created +This is the only way any 2d image_t are created ================ */ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgType_t type, int flags, int internalFormat ) { @@ -2495,6 +2495,99 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT return image; } +/* +================ +R_CreateImage + +This is the only way any image_t are created +================ +*/ +image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height, int layers, imgType_t type, int flags, int internalFormat) +{ + image_t *image; + long hash; + int glWrapClampMode; + int format; + + if (strlen(name) >= MAX_QPATH) { + ri.Error(ERR_DROP, "R_Create2DImageArray: \"%s\" is too long", name); + } + + image = R_AllocImage(); + qglGenTextures(1, &image->texnum); + + image->type = type; + image->flags = flags | IMGFLAG_2D_ARRAY; + + Q_strncpyz(image->imgName, name, sizeof(image->imgName)); + + image->width = width; + image->height = height; + image->layers = layers; + image->internalFormat = internalFormat; + + if (flags & IMGFLAG_CLAMPTOEDGE) + glWrapClampMode = GL_CLAMP_TO_EDGE; + else + glWrapClampMode = GL_REPEAT; + + switch (internalFormat) + { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + format = GL_DEPTH_COMPONENT; + break; + default: + format = GL_BGRA; + break; + } + + GL_Bind(image); + //qglTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers); + qglTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, format, GL_UNSIGNED_BYTE, NULL); + + switch (internalFormat) + { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: + + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + if (flags & IMGLFAG_SHADOWCOMP) + { + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); + qglTexParameterf(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); + } + else + { + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + } + + break; + default: + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, glWrapClampMode); + qglTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, glWrapClampMode); + break; + } + qglBindTexture(GL_TEXTURE_2D_ARRAY, 0); + GL_SelectTexture(0); + + hash = generateHashValue(name); + image->next = hashTable[hash]; + hashTable[hash] = image; + + return image; +} + void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int height ) { byte *scaledBuffer = NULL; @@ -2864,6 +2957,14 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig } } +void ColorToRGBA16F2(const vec3_t color, unsigned short rgba16f[4]) +{ + rgba16f[0] = FloatToHalf(color[0]); + rgba16f[1] = FloatToHalf(color[1]); + rgba16f[2] = FloatToHalf(color[2]); + rgba16f[3] = FloatToHalf(1.0f); +} + /* =============== R_FindImageFile @@ -2877,6 +2978,8 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) image_t *image; int width, height; byte *pic; + int internalFormat = 0; + int loadFlags = flags; if (!name) { return NULL; @@ -2888,7 +2991,41 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) // // load the pic from disk // - R_LoadImage( name, &pic, &width, &height ); + if (r_hdr->integer && (flags & IMGFLAG_HDR)) + { + char filename[MAX_QPATH]; + Com_sprintf(filename, sizeof(filename), "%s.hdr", name); + byte *hdrPic = NULL; + float *floatBuffer; + R_LoadHDRImage(filename, &hdrPic, &width, &height); + floatBuffer = (float*)hdrPic; + if (hdrPic == NULL) + { + R_LoadImage(name, &pic, &width, &height); + } + else + { + pic = (byte *)Z_Malloc(width*height*4*2, TAG_TEMP_WORKSPACE, qfalse); + for (int i = 0; i < width*height; i++) + { + vec4_t color; + memcpy(color, &floatBuffer[i*3], 12); + color[0] = color[0] / M_PI; + color[1] = color[1] / M_PI; + color[2] = color[2] / M_PI; + color[3] = 1.0f; + ColorToRGBA16F2(color, (uint16_t *)(&pic[i * 8])); + } + internalFormat = GL_RGBA16F; + loadFlags = flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_MIPMAP); + Z_Free(hdrPic); + } + } + else + { + R_LoadImage(name, &pic, &width, &height); + } + if ( pic == NULL ) { return NULL; } @@ -2908,7 +3045,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) } } - image = R_CreateImage( name, pic, width, height, type, flags, 0 ); + image = R_CreateImage( name, pic, width, height, type, loadFlags, internalFormat); Z_Free( pic ); return image; @@ -3368,13 +3505,15 @@ void R_CreateBuiltinImages( void ) { if (r_shadows->integer == 4) { - for (x = 0; x < MAX_DRAWN_PSHADOWS; x++) - { - tr.pshadowMaps[x] = R_CreateImage( - va("*shadowmap%i", x), NULL, PSHADOW_MAP_SIZE, - PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); - } + tr.pshadowArrayMap = R_Create2DImageArray( + va("*pshadowmapArray"), + NULL, + PSHADOW_MAP_SIZE, + PSHADOW_MAP_SIZE, + MAX_DRAWN_PSHADOWS, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + GL_DEPTH_COMPONENT16); } if (r_sunlightMode->integer) @@ -3387,12 +3526,22 @@ void R_CreateBuiltinImages( void ) { IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24); GL_Bind(tr.sunShadowDepthImage[x]); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); } + tr.sunShadowArrayMap = R_Create2DImageArray( + va("*sunShadowmapArray"), + NULL, + r_shadowMapSize->integer, + r_shadowMapSize->integer, + 3, // number of cascades + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + GL_DEPTH_COMPONENT16); + tr.screenShadowImage = R_CreateImage( "*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); @@ -3404,15 +3553,17 @@ void R_CreateBuiltinImages( void ) { "*renderCube", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE | - IMGFLAG_MIPMAP | - IMGFLAG_CUBEMAP, + IMGFLAG_CLAMPTOEDGE | + IMGFLAG_MIPMAP | + IMGFLAG_CUBEMAP, hdrFormat); - tr.prefilterEnvMapImage = R_CreateImage( - "*prefilterEnvMapFbo", NULL, CUBE_MAP_SIZE / 2, CUBE_MAP_SIZE / 2, - IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - hdrFormat); + tr.renderCubeDepthImage = R_CreateImage( + "*renderdepth", NULL, CUBE_MAP_SIZE, CUBE_MAP_SIZE, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, + GL_DEPTH24_STENCIL8); } tr.weatherDepthImage = R_CreateImage( diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 7fe3608378..7ce0de9d26 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -396,7 +396,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { d = VectorLength( ent->directedLight ); VectorScale( ent->lightDir, d, lightDir ); - for ( i = 0 ; i < refdef->num_dlights ; i++ ) { + /*for ( i = 0 ; i < refdef->num_dlights ; i++ ) { dl = &refdef->dlights[i]; VectorSubtract( dl->origin, lightOrigin, dir ); d = VectorNormalize( dir ); @@ -409,7 +409,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { VectorMA( ent->directedLight, d, dl->color, ent->directedLight ); VectorMA( lightDir, d, dir, lightDir ); - } + }*/ // clamp ambient if (tr.hdrLighting != qtrue) @@ -482,6 +482,27 @@ int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *w return qtrue; } +int R_DLightsForPoint(const vec3_t point, const float radius) +{ + int dlightBits = 0; + vec3_t delta; + dlight_t currentDlight; + float distance; + float radiusSum; + for (int i = 0; i < tr.refdef.num_dlights; i++) + { + currentDlight = tr.refdef.dlights[i]; + + VectorSubtract(point, currentDlight.origin, delta); + distance = VectorLength(delta); + radiusSum = radius + currentDlight.radius; + + if (distance < radiusSum) + dlightBits |= 1 << i; + } + return dlightBits; +} + int R_CubemapForPoint( const vec3_t point ) { int cubemapIndex = -1; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 50b103f8f6..f7c1a79bc5 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -311,6 +311,10 @@ typedef enum IMGFLAG_SRGB = 0x0080, IMGFLAG_GENNORMALMAP = 0x0100, IMGFLAG_MUTABLE = 0x0200, + IMGFLAG_HDR = 0x0400, + IMGFLAG_2D_ARRAY = 0x0800, + IMGFLAG_3D = 0x1000, + IMGLFAG_SHADOWCOMP = 0x2000, } imgFlags_t; typedef enum @@ -355,7 +359,7 @@ static const int NO_XFB_VARS = 0; typedef struct image_s { char imgName[MAX_QPATH]; // game path, including extension - int width, height; // source image + int width, height, layers; // source image int uploadWidth, uploadHeight; // after power of two and picmip but not including clamp to MAX_TEXTURE_SIZE GLuint texnum; // gl texture binding @@ -821,12 +825,12 @@ enum TB_COLORMAP2 = 1, TB_NORMALMAP = 2, TB_DELUXEMAP = 3, - TB_SHADOWMAP2 = 3, TB_SPECULARMAP = 4, TB_SHADOWMAP = 5, TB_CUBEMAP = 6, TB_ENVBRDFMAP = 7, - NUM_TEXTURE_BUNDLES = 8 + TB_SHADOWMAP2 = 8, + NUM_TEXTURE_BUNDLES = 9 }; typedef enum @@ -1463,7 +1467,8 @@ enum viewParmFlag_t { VPF_USESUNLIGHT = 0x20, VPF_FARPLANEFRUSTUM = 0x40, // Use far clipping plane VPF_NOCUBEMAPS = 0x80, // Don't render cubemaps - VPF_NOPOSTPROCESS = 0x100 + VPF_NOPOSTPROCESS = 0x100, + VPF_CUBEMAPSIDE = 0x200,// Rendering into a cubemap side }; using viewParmFlags_t = uint32_t; @@ -1481,7 +1486,6 @@ typedef struct { int scissorX, scissorY, scissorWidth, scissorHeight; FBO_t *targetFbo; int targetFboLayer; - cubemap_t *targetFboCubemap; float fovX, fovY; float projectionMatrix[16]; cplane_t frustum[5]; @@ -2252,6 +2256,7 @@ typedef struct { qboolean colorMask[4]; qboolean framePostProcessed; qboolean depthFill; + qboolean frameUBOsInitialized; } backEndState_t; struct EntityShaderUboOffset @@ -2316,18 +2321,19 @@ typedef struct trGlobals_s { image_t *glowImageScaled[6]; image_t *sunRaysImage; image_t *renderDepthImage; - image_t *pshadowMaps[MAX_DRAWN_PSHADOWS]; + image_t *pshadowArrayMap; image_t *textureScratchImage[2]; image_t *quarterImage[2]; image_t *calcLevelsImage; image_t *targetLevelsImage; image_t *fixedLevelsImage; image_t *sunShadowDepthImage[3]; + image_t *sunShadowArrayMap; image_t *screenShadowImage; image_t *screenSsaoImage; image_t *hdrDepthImage; image_t *renderCubeImage; - image_t *prefilterEnvMapImage; + image_t *renderCubeDepthImage; image_t *envBrdfImage; image_t *textureDepthImage; image_t *weatherDepthImage; @@ -2347,8 +2353,8 @@ typedef struct trGlobals_s { FBO_t *screenShadowFbo; FBO_t *screenSsaoFbo; FBO_t *hdrDepthFbo; - FBO_t *renderCubeFbo; - FBO_t *preFilterEnvMapFbo; + FBO_t *renderCubeFbo[6]; + FBO_t *filterCubeFbo; FBO_t *weatherDepthFbo; shader_t *defaultShader; @@ -3009,6 +3015,7 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ); void R_TransformDlights( int count, dlight_t *dl, orientationr_t *ori ); int R_LightForPoint( vec3_t point, vec3_t ambientLight, vec3_t directedLight, vec3_t lightDir ); int R_LightDirForPoint( vec3_t point, vec3_t lightDir, vec3_t normal, world_t *world ); +int R_DLightsForPoint(const vec3_t point, const float radius); int R_CubemapForPoint( const vec3_t point ); /* @@ -3218,6 +3225,8 @@ class CRenderableSurface // tell the renderer to render shadows for this surface qboolean genShadows; + int dlightBits; + int pshadowBits; // pointer to surface data loaded into file - only used by client renderer // DO NOT USE IN GAME SIDE - if there is a vid restart this will be out of @@ -3434,7 +3443,7 @@ typedef struct capShadowmapCommand_s { typedef struct convolveCubemapCommand_s { int commandId; cubemap_t *cubemap; - int cubeSide; + int cubemapId; } convolveCubemapCommand_t; typedef struct postProcessCommand_s { @@ -3560,7 +3569,7 @@ void RB_ExecuteRenderCommands( const void *data ); void R_IssuePendingRenderCommands( void ); void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ); -void R_AddConvolveCubemapCmd(cubemap_t *cubemap, int cubeSide); +void R_AddConvolveCubemapCmd(cubemap_t *cubemap, int cubemapId); void R_AddPostProcessCmd (void); qhandle_t R_BeginTimedBlockCmd( const char *name ); void R_EndTimedBlockCmd( qhandle_t timerHandle ); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 652024ee9a..a52b1cb167 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2206,7 +2206,6 @@ void R_RenderDlightCubemaps(const refdef_t *fd) } shadowParms.targetFbo = tr.shadowCubeFbo; - shadowParms.targetFboCubemap = &tr.shadowCubemaps[i]; shadowParms.targetFboLayer = j; R_RenderView(&shadowParms); @@ -2762,7 +2761,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) tr.refdef.sunShadowMvp[level]); } -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce ) +void R_RenderCubemapSide(int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce) { refdef_t refdef = {}; float oldColorScale = tr.refdef.colorScale; @@ -2770,49 +2769,49 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, VectorCopy(tr.cubemaps[cubemapIndex].origin, refdef.vieworg); refdef.fov_x = 90; refdef.fov_y = 90; - refdef.width = tr.renderCubeFbo->width; - refdef.height = tr.renderCubeFbo->height; + refdef.width = tr.renderCubeFbo[cubemapSide]->width; + refdef.height = tr.renderCubeFbo[cubemapSide]->height; refdef.x = 0; refdef.y = 0; - switch(cubemapSide) + switch (cubemapSide) { - case 0: - // +X - VectorSet(refdef.viewaxis[0], 1, 0, 0); - VectorSet(refdef.viewaxis[1], 0, 0, 1); - VectorSet(refdef.viewaxis[2], 0, -1, 0); - break; - case 1: - // -X - VectorSet(refdef.viewaxis[0], -1, 0, 0); - VectorSet(refdef.viewaxis[1], 0, 0, -1); - VectorSet(refdef.viewaxis[2], 0, -1, 0); - break; - case 2: - // +Y - VectorSet(refdef.viewaxis[0], 0, 1, 0); - VectorSet(refdef.viewaxis[1], -1, 0, 0); - VectorSet(refdef.viewaxis[2], 0, 0, 1); - break; - case 3: - // -Y - VectorSet(refdef.viewaxis[0], 0, -1, 0); - VectorSet(refdef.viewaxis[1], -1, 0, 0); - VectorSet(refdef.viewaxis[2], 0, 0, -1); - break; - case 4: - // +Z - VectorSet(refdef.viewaxis[0], 0, 0, 1); - VectorSet(refdef.viewaxis[1], -1, 0, 0); - VectorSet(refdef.viewaxis[2], 0, -1, 0); - break; - case 5: - // -Z - VectorSet(refdef.viewaxis[0], 0, 0, -1); - VectorSet(refdef.viewaxis[1], 1, 0, 0); - VectorSet(refdef.viewaxis[2], 0, -1, 0); - break; + case 0: + // +X + VectorSet(refdef.viewaxis[0], 1, 0, 0); + VectorSet(refdef.viewaxis[1], 0, 0, 1); + VectorSet(refdef.viewaxis[2], 0, -1, 0); + break; + case 1: + // -X + VectorSet(refdef.viewaxis[0], -1, 0, 0); + VectorSet(refdef.viewaxis[1], 0, 0, -1); + VectorSet(refdef.viewaxis[2], 0, -1, 0); + break; + case 2: + // +Y + VectorSet(refdef.viewaxis[0], 0, 1, 0); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, 0, 1); + break; + case 3: + // -Y + VectorSet(refdef.viewaxis[0], 0, -1, 0); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, 0, -1); + break; + case 4: + // +Z + VectorSet(refdef.viewaxis[0], 0, 0, 1); + VectorSet(refdef.viewaxis[1], -1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, -1, 0); + break; + case 5: + // -Z + VectorSet(refdef.viewaxis[0], 0, 0, -1); + VectorSet(refdef.viewaxis[1], 1, 0, 0); + VectorSet(refdef.viewaxis[2], 0, -1, 0); + break; } if (!subscene) @@ -2830,10 +2829,10 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, tr.refdef.colorScale = 1.0f; viewParms_t parms = {}; - parms.viewportWidth = tr.renderCubeFbo->width; - parms.viewportHeight = tr.renderCubeFbo->height; + parms.viewportWidth = tr.renderCubeFbo[cubemapSide]->width; + parms.viewportHeight = tr.renderCubeFbo[cubemapSide]->height; parms.isMirror = qfalse; - parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; + parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS | VPF_CUBEMAPSIDE; if (!bounce) parms.flags |= VPF_NOCUBEMAPS; @@ -2841,21 +2840,20 @@ void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, parms.fovX = 90; parms.fovY = 90; - VectorCopy( refdef.vieworg, parms.ori.origin ); - VectorCopy( refdef.viewaxis[0], parms.ori.axis[0] ); - VectorCopy( refdef.viewaxis[1], parms.ori.axis[1] ); - VectorCopy( refdef.viewaxis[2], parms.ori.axis[2] ); + VectorCopy(refdef.vieworg, parms.ori.origin); + VectorCopy(refdef.viewaxis[0], parms.ori.axis[0]); + VectorCopy(refdef.viewaxis[1], parms.ori.axis[1]); + VectorCopy(refdef.viewaxis[2], parms.ori.axis[2]); - VectorCopy( refdef.vieworg, parms.pvsOrigin ); + VectorCopy(refdef.vieworg, parms.pvsOrigin); if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer > 0 || tr.sunShadows)) { parms.flags |= VPF_USESUNLIGHT; } - parms.targetFbo = tr.renderCubeFbo; + parms.targetFbo = tr.renderCubeFbo[cubemapSide]; parms.targetFboLayer = cubemapSide; - parms.targetFboCubemap = &tr.cubemaps[cubemapIndex]; R_RenderView(&parms); diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index 149bbc38f4..f66b887a3c 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -346,6 +346,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { fogNum = R_ComputeFogNum( model, ent ); cubemapIndex = R_CubemapForPoint(ent->e.origin); + // FIX ME: not tested! Animated models might be handled incorrecly + int dlightBits = R_DLightsForPoint(ent->e.origin, model->frames[ent->e.frame].radius); // // draw all surfaces @@ -390,7 +392,8 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { { srfVBOMDVMesh_t *vboSurface = &model->vboSurfaces[i]; - R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex ); + R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, dlightBits, R_IsPostRenderEntity(ent), cubemapIndex ); + //R_AddDrawSurf((surfaceType_t *)vboSurface, entityNum, shader, fogNum, qfalse, R_IsPostRenderEntity(ent), cubemapIndex ); } surface++; diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index a07a528390..e383727258 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -49,15 +49,13 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in while (size > 1) { VectorSet4(srcBox, 0, 0, size, size); - //size >>= 2; size >>= 1; VectorSet4(dstBox, 0, 0, size, size); if (size == 1) dstFbo = tr.targetLevelsFbo; - //FBO_Blit(targetFbo, srcBox, NULL, tr.textureScratchFbo[nextScratch], dstBox, &tr.calclevels4xShader[1], NULL, 0); - FBO_FastBlit(srcFbo, srcBox, dstFbo, dstBox, GL_COLOR_BUFFER_BIT, GL_LINEAR); + FBO_Blit(srcFbo, srcBox, NULL, dstFbo, dstBox, &tr.calclevels4xShader[1], NULL, 0); tmp = srcFbo; srcFbo = dstFbo; @@ -71,6 +69,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in color[0] = color[1] = color[2] = 1.0f; + // FIX ME: blend based on time instead of fixed amount color[3] = 0.03f; FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ff2be351b7..9492f195ac 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -860,7 +860,7 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr uniformDataWriter.SetUniformMatrix4x4(UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); VectorCopy(origin, vector); - vector[3] = 1.0f; + vector[3] = (float)l; uniformDataWriter.SetUniformVec4(UNIFORM_LIGHTORIGIN, vector); VectorScale(ps->lightViewAxis[0], 1.0f, vector); @@ -879,7 +879,7 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr uint32_t stateBits = 0; stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL; - samplerBindingsWriter.AddStaticImage(tr.pshadowMaps[l], TB_DIFFUSEMAP); + samplerBindingsWriter.AddStaticImage(tr.pshadowArrayMap, TB_DIFFUSEMAP); CaptureDrawData(input, pStage, 0, 0); @@ -1290,6 +1290,33 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vertColor[3] = 0.0f; } + if (backEnd.currentEntity->e.hModel != NULL) + { + model_t *model = R_GetModelByHandle(backEnd.currentEntity->e.hModel); + if (model->type != MOD_BRUSH) + { + switch (forceRGBGen) + { + case CGEN_EXACT_VERTEX: + case CGEN_EXACT_VERTEX_LIT: + case CGEN_VERTEX: + case CGEN_VERTEX_LIT: + baseColor[0] = + baseColor[1] = + baseColor[2] = + baseColor[3] = tr.identityLight; + + vertColor[0] = + vertColor[1] = + vertColor[2] = + vertColor[3] = 0.0f; + break; + default: + break; + } + } + } + uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); } @@ -1364,10 +1391,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { - if (i == TB_LIGHTMAP) - samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_LIGHTMAP], i); - else + if (i == TB_DIFFUSEMAP) samplerBindingsWriter.AddStaticImage(tr.whiteImage, i); + else + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[i], i); } } else if (r_lightmap->integer == 3 && pStage->bundle[TB_DELUXEMAP].image[0]) @@ -1376,8 +1403,10 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { if (i == TB_LIGHTMAP) samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_DELUXEMAP], i); - else + else if (i == TB_DIFFUSEMAP) samplerBindingsWriter.AddStaticImage(tr.whiteImage, i); + else + samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[i], i); } } else @@ -1473,8 +1502,12 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec4(UNIFORM_CUBEMAPINFO, vec); } - if ( enableDLights ) + if (enableDLights) + { uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, tess.dlightBits); + if (r_dlightMode->integer > 1) + samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[0].image, TB_SHADOWMAP2); + } else uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, 0); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 2b1daeb481..7ca107a4b4 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2321,8 +2321,8 @@ static void ParseSkyParms( const char **text ) { if (shader.noTC) imgFlags |= IMGFLAG_NO_COMPRESSION; - if (tr.world && tr.hdrLighting == qtrue) - imgFlags |= IMGFLAG_SRGB; + if (tr.hdrLighting == qtrue) + imgFlags |= IMGFLAG_SRGB | IMGFLAG_HDR | IMGFLAG_NOLIGHTSCALE; // outerbox token = COM_ParseExt( text, qfalse ); diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 6b2e15388f..bdf4911b64 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2090,6 +2090,9 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) if(!surface->vbo || !surface->ibo) return; + //drawSurf_t drawSurf = + int dlightBits = tess.dlightBits; + //RB_CheckVBOandIBO(surface->vbo, surface->ibo); RB_EndSurface(); RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); @@ -2104,7 +2107,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) tess.numVertexes += surface->numVerts; tess.minIndex = surface->minIndex; tess.maxIndex = surface->maxIndex; - + tess.dlightBits = dlightBits; //mdvModel = surface->mdvModel; //mdvSurface = surface->mdvSurface; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index b022e099be..8654c0aac6 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -347,6 +347,7 @@ static void R_AddWorldSurface( } // check for dlighting + // TODO: check for beeing correctly implemented because problems eg. with elevators ffa3 if ( dlightBits ) { dlightBits = R_DlightSurface( surf, dlightBits ); dlightBits = ( dlightBits != 0 ); diff --git a/codemp/rd-vanilla/tr_scene.cpp b/codemp/rd-vanilla/tr_scene.cpp index 9c0025485a..d1464c9073 100644 --- a/codemp/rd-vanilla/tr_scene.cpp +++ b/codemp/rd-vanilla/tr_scene.cpp @@ -235,7 +235,7 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { #ifdef _DEBUG if (ent->reType == RT_MODEL) { - assert(ent->hModel || ent->ghoul2 || ent->customShader); + //assert(ent->hModel || ent->ghoul2 || ent->customShader); } #endif From d7ad80ced761b22625a2ada36742863c8acdba16 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 9 May 2022 21:57:57 +0200 Subject: [PATCH 557/708] Fix stage collapsing Skipping these will result in wrong shaders. My bad. --- codemp/rd-rend2/tr_shader.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 7ca107a4b4..cd8c34f145 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3242,6 +3242,7 @@ static qboolean CollapseStagesToGLSL(void) switch(pStage->alphaGen) { case AGEN_PORTAL: + case AGEN_LIGHTING_SPECULAR: skip = qtrue; break; default: @@ -3280,10 +3281,6 @@ static qboolean CollapseStagesToGLSL(void) if (pStage->type != ST_COLORMAP) continue; - // skip agen spec stages and environment mapped stages - if (pStage->alphaGen == AGEN_LIGHTING_SPECULAR || pStage->bundle[0].tcGen == TCGEN_ENVIRONMENT_MAPPED) - continue; - // skip lightmaps if (pStage->bundle[0].tcGen >= TCGEN_LIGHTMAP && pStage->bundle[0].tcGen <= TCGEN_LIGHTMAP3) continue; From b5c26280fbcb04b2bd0ad76e895ddcc425d57435 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 1 Jun 2022 15:07:45 +0200 Subject: [PATCH 558/708] Adding dlight shadows back --- codemp/rd-rend2/glsl/lightall.glsl | 87 ++++++++++++++++------- codemp/rd-rend2/glsl/prefilterEnvMap.glsl | 3 +- codemp/rd-rend2/glsl/pshadow.glsl | 1 + codemp/rd-rend2/tr_backend.cpp | 43 ++++------- codemp/rd-rend2/tr_fbo.cpp | 32 +++++---- codemp/rd-rend2/tr_glsl.cpp | 3 +- codemp/rd-rend2/tr_image.cpp | 41 ++++------- codemp/rd-rend2/tr_init.cpp | 6 ++ codemp/rd-rend2/tr_local.h | 19 ++--- codemp/rd-rend2/tr_main.cpp | 66 +++++++++++++---- codemp/rd-rend2/tr_scene.cpp | 23 +++++- codemp/rd-rend2/tr_shade.cpp | 7 +- codemp/rd-rend2/tr_shader.cpp | 17 ++++- codemp/rd-rend2/tr_world.cpp | 12 +--- 14 files changed, 225 insertions(+), 135 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 10223eb50d..e380759488 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -403,7 +403,7 @@ uniform sampler2D u_SpecularMap; uniform sampler2D u_ShadowMap; #endif -uniform samplerCubeShadow u_ShadowMap2; +uniform sampler2DArrayShadow u_ShadowMap2; #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; @@ -675,25 +675,64 @@ float CalcLightAttenuation(float point, float normDist) } #if defined(USE_DSHADOWS) -#define DEPTH_MAX_ERROR 0.000000059604644775390625 +#define DEPTH_MAX_ERROR 0.0000152587890625 -vec3 sampleOffsetDirections[20] = vec3[] +vec2 poissonDiscPolar[9] = vec2[9] ( - vec3(1.0, 1.0, 1.0), vec3(1.0, -1.0, 1.0), vec3(-1.0, -1.0, 1.0), vec3(-1.0, 1.0, 1.0), - vec3(1.0, 1.0, -1.0), vec3(1.0, -1.0, -1.0), vec3(-1.0, -1.0, -1.0), vec3(-1.0, 1.0, -1.0), - vec3(1.0, 1.0, 0.0), vec3(1.0, -1.0, 0.0), vec3(-1.0, -1.0, 0.0), vec3(-1.0, 1.0, 0.0), - vec3(1.0, 0.0, 1.0), vec3(-1.0, 0.0, 1.0), vec3(1.0, 0.0, -1.0), vec3(-1.0, 0.0, -1.0), - vec3(0.0, 1.0, 1.0), vec3(0.0, -1.0, 1.0), vec3(0.0, -1.0, -1.0), vec3(0.0, 1.0, -1.0) - ); +vec2(-0.7055767, 0.196515), vec2(0.3524343, -0.7791386), +vec2(0.2391056, 0.9189604), vec2(-0.07580382, -0.09224417), +vec2(0.5784913, -0.002528916), vec2(0.192888, 0.4064181), +vec2(-0.6335801, -0.5247476), vec2(-0.5579782, 0.7491854), +vec2(0.7320465, 0.6317794) +); + +// based on https://www.gamedev.net/forums/topic/687535-implementing-a-cube-map-lookup-function/5337472/ +vec3 sampleCube(in vec3 v) +{ + vec3 vAbs = abs(v); + float ma = 0.0; + vec2 uv = vec2(0.0); + float faceIndex = 0.0; + if(vAbs.z >= vAbs.x && vAbs.z >= vAbs.y) + { + faceIndex = v.z < 0.0 ? 5.0 : 4.0; + ma = 0.5 / vAbs.z; + uv = vec2(v.z < 0.0 ? -v.x : v.x, -v.y); + } + else if(vAbs.y >= vAbs.x) + { + faceIndex = v.y < 0.0 ? 3.0 : 2.0; + ma = 0.5 / vAbs.y; + uv = vec2(v.x, v.y < 0.0 ? -v.z : v.z); + } + else + { + faceIndex = v.x < 0.0 ? 1.0 : 0.0; + ma = 0.5 / vAbs.x; + uv = vec2(v.x < 0.0 ? v.z : -v.z, -v.y); + } + return vec3(uv * ma + 0.5, faceIndex); +} -float pcfShadow(in samplerCubeShadow depthMap, in vec3 L, in float distance) +float pcfShadow(in sampler2DArrayShadow depthMap, in vec3 L, in float distance, in int lightId) { + const int samples = 9; + const float diskRadius = M_PI / 512.0; + + vec2 polarL = vec2(atan(L.z, L.x), acos(L.y)); float shadow = 0.0; - int samples = 20; - float diskRadius = 0.25; + for (int i = 0; i < samples; ++i) { - shadow += texture(depthMap, vec4(L + sampleOffsetDirections[i] * diskRadius, distance)); + vec2 samplePolar = poissonDiscPolar[i] * diskRadius + polarL; + vec3 sampleVec = vec3(0.0); + sampleVec.x = cos(samplePolar.x) * sin(samplePolar.y); + sampleVec.z = sin(samplePolar.x) * sin(samplePolar.y); + sampleVec.y = cos(samplePolar.y); + + vec3 lookup = sampleCube(sampleVec) + vec3(0.0, 0.0, lightId * 6.0); + + shadow += texture(depthMap, vec4(lookup, distance)); } shadow /= float(samples); return shadow; @@ -708,13 +747,7 @@ float getLightDepth(in vec3 Vec, in float f) float NormZComp = (f + n) / (f - n) - 2 * f*n / (Z* (f - n)); - return ((NormZComp + 1.0) * 0.5) - DEPTH_MAX_ERROR; -} - -float getShadowValue(in vec4 light, in int lightId) -{ - float distance = getLightDepth(light.xyz, light.w); - return pcfShadow(u_ShadowMap2, light.xyz, distance); + return ((NormZComp + 1.0) * 0.5); } #endif @@ -726,7 +759,8 @@ vec3 CalcDynamicLightContribution( in vec3 viewDir, in float NE, in vec3 diffuse, - in vec3 specular + in vec3 specular, + in vec3 vertexNormal ) { vec3 outColor = vec3(0.0); @@ -744,10 +778,15 @@ vec3 CalcDynamicLightContribution( float attenuation = CalcLightAttenuation(1.0, light.radius * light.radius / sqrLightDist); #if defined(USE_DSHADOWS) - attenuation *= getShadowValue(vec4(L, light.radius), i); + vec3 sampleVector = L; + L /= sqrt(sqrLightDist); + sampleVector += L * tan(acos(dot(vertexNormal, -L))); + float distance = getLightDepth(sampleVector, light.radius); + attenuation *= pcfShadow(u_ShadowMap2, L, distance, i); + #else + L /= sqrt(sqrLightDist); #endif - L = normalize(L); vec3 H = normalize(L + E); float NL = clamp(dot(N, L), 0.0, 1.0); float LH = clamp(dot(L, H), 0.0, 1.0); @@ -964,7 +1003,7 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif - out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb); + out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb, var_Normal.xyz); out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb); #else diff --git a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl index f80b76fc93..6df85b582b 100644 --- a/codemp/rd-rend2/glsl/prefilterEnvMap.glsl +++ b/codemp/rd-rend2/glsl/prefilterEnvMap.glsl @@ -101,8 +101,7 @@ vec3 PrefilterEnvMap( float Roughness, vec3 R ) float D = D_GGX(NH, Roughness); float pdf = (D * NH / (4.0 * HV)) + 0.0001; - const float cubemapSize = 256.0; - float saTexel = 4.0 * M_PI / (6.0 * cubemapSize * cubemapSize); + float saTexel = 4.0 * M_PI / (6.0 * CUBEMAP_RESOLUTION * CUBEMAP_RESOLUTION); float saSample = 1.0 / (float(NumSamples) * pdf + 0.0001); float mipLevel = Roughness == 0.0 ? 0.0 : 0.5 * log2(saSample / saTexel); diff --git a/codemp/rd-rend2/glsl/pshadow.glsl b/codemp/rd-rend2/glsl/pshadow.glsl index 4fa269c03a..17a0ccc2e4 100644 --- a/codemp/rd-rend2/glsl/pshadow.glsl +++ b/codemp/rd-rend2/glsl/pshadow.glsl @@ -81,6 +81,7 @@ void main() float part = 0.0; #if defined(USE_PCF) float offsetScale = pow(lightDist, 4.0) * TEXTURE_SCALE * 0.00000001; + offsetScale = max(TEXTURE_SCALE, offsetScale); for (int i = 0; i < PCF_SAMPLES; ++i) { part += float(texture(u_ShadowMap, vec3(st + offsetScale * poissonDisc[i], u_LightOrigin.w)).r != 1.0); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 3935594e07..07f3928e90 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -361,7 +361,6 @@ void GL_State( uint32_t stateBits ) if ( stateBits & GLS_POLYGON_OFFSET_FILL ) { qglEnable( GL_POLYGON_OFFSET_FILL ); - qglPolygonOffset( r_offsetFactor->value, r_offsetUnits->value ); } else { @@ -553,13 +552,6 @@ void RB_BeginDrawingView (void) { else { FBO_Bind(backEnd.viewParms.targetFbo); - - // FIXME: hack for shadows testing - if (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo) - { - image_t *cubemap = tr.shadowCubemaps[0].image; - qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + backEnd.viewParms.targetFboLayer, cubemap->texnum, 0); - } } // @@ -609,13 +601,6 @@ void RB_BeginDrawingView (void) { clearBits |= GL_COLOR_BUFFER_BIT; qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } - - // clear to black for cube maps - if (backEnd.viewParms.flags & VPF_CUBEMAPSIDE) - { - clearBits |= GL_COLOR_BUFFER_BIT; - qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f ); - } qglClear( clearBits ); @@ -653,6 +638,11 @@ void RB_BeginDrawingView (void) { #endif GL_SetModelviewMatrix( s_flipMatrix ); } + + if (backEnd.viewParms.flags & VPF_POINTSHADOW) + qglPolygonOffset(r_shadowOffsetFactor->value, r_shadowOffsetUnits->value); + else + qglPolygonOffset(r_offsetFactor->value, r_offsetUnits->value); } @@ -1992,9 +1982,9 @@ static const void *RB_PrefilterEnvMap(const void *data) { int width = cmd->cubemap->image->width; int height = cmd->cubemap->image->height; - float roughnessMips = (float)CUBE_MAP_MIPS - 4.0f; + float roughnessMips = (float)CUBE_MAP_ROUGHNESS_MIPS; - for (int level = 0; level <= (int)roughnessMips; level++) + for (int level = 0; level <= CUBE_MAP_ROUGHNESS_MIPS; level++) { FBO_Bind(tr.filterCubeFbo); qglFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, cmd->cubemap->image->texnum, level); @@ -2019,8 +2009,8 @@ static const void *RB_PrefilterEnvMap(const void *data) { static void RB_RenderSunShadows() { if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW) || - (backEnd.refdef.rdflags & RDF_NOWORLDMODEL) || - (tr.shadowCubeFbo != NULL && backEnd.viewParms.targetFbo == tr.shadowCubeFbo)) + (backEnd.viewParms.flags & VPF_SHADOWMAP) || + (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) return; FBO_t *shadowFbo = tr.screenShadowFbo; @@ -2060,7 +2050,7 @@ static void RB_RenderSunShadows() GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); } - GL_BindToTMU(tr.sunShadowArrayMap, TB_SHADOWMAP); + GL_BindToTMU(tr.sunShadowArrayImage, TB_SHADOWMAP); GLSL_SetUniformMatrix4x4( &tr.shadowmaskShader, @@ -3126,6 +3116,7 @@ const void *RB_PostProcess(const void *data) dstBox[2] = backEnd.viewParms.viewportWidth; dstBox[3] = backEnd.viewParms.viewportHeight; +#if 0 if (r_ssao->integer) { srcBox[0] = backEnd.viewParms.viewportX * tr.screenSsaoImage->width / (float)glConfig.vidWidth; @@ -3143,6 +3134,7 @@ const void *RB_PostProcess(const void *data) FBO_Blit(tr.screenSsaoFbo, srcBox, NULL, srcFbo, dstBox, NULL, NULL, blendMode); } +#endif if (r_dynamicGlow->integer) { @@ -3196,17 +3188,6 @@ const void *RB_PostProcess(const void *data) FBO_BlitFromTexture(tr.weatherDepthImage, NULL, NULL, NULL, nullptr, NULL, NULL, 0); } - if (0 && r_sunlightMode->integer) - { - vec4i_t dstBox; - VectorSet4(dstBox, 0, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[0], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 128, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[1], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - VectorSet4(dstBox, 256, 0, 128, 128); - FBO_BlitFromTexture(tr.sunShadowDepthImage[2], NULL, NULL, NULL, dstBox, NULL, NULL, 0); - } - if (0) { vec4i_t dstBox; diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index 619903a9a3..d507852bca 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -496,16 +496,16 @@ void FBO_Init(void) } #if MAX_DRAWN_PSHADOWS > 0 - if (tr.pshadowArrayMap != NULL) + if (tr.pshadowArrayImage != NULL) { for( i = 0; i < MAX_DRAWN_PSHADOWS; i++) { tr.pshadowFbos[i] = FBO_Create( - va("_shadowmap%i", i), tr.pshadowArrayMap->width, - tr.pshadowArrayMap->height); + va("_shadowmap%i", i), tr.pshadowArrayImage->width, + tr.pshadowArrayImage->height); FBO_Bind(tr.pshadowFbos[i]); - qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.pshadowArrayMap->texnum, 0, i); + qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.pshadowArrayImage->texnum, 0, i); qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); R_CheckFBO(tr.pshadowFbos[i]); @@ -516,25 +516,27 @@ void FBO_Init(void) if (r_dlightMode->integer >= 2) { - tr.shadowCubeFbo = FBO_Create("_shadowCubeFbo", PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); - - FBO_Bind(tr.shadowCubeFbo); - FBO_CreateBuffer(tr.shadowCubeFbo, GL_DEPTH_COMPONENT24, 0, 0); - FBO_SetupDrawBuffers(); - - R_CheckFBO(tr.shadowCubeFbo); + for (i = 0; i < MAX_DLIGHTS * 6; i++) + { + tr.shadowCubeFbo[i] = FBO_Create(va("_shadowCubeFbo_%i", i), PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE); + FBO_Bind(tr.shadowCubeFbo[i]); + qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.pointShadowArrayImage->texnum, 0, i); + qglDrawBuffer(GL_NONE); + qglReadBuffer(GL_NONE); + R_CheckFBO(tr.shadowCubeFbo[i]); + } } - if (tr.sunShadowDepthImage[0] != NULL) + if (tr.sunShadowArrayImage != NULL) { for ( i = 0; i < 3; i++) { tr.sunShadowFbo[i] = FBO_Create( - "_sunshadowmap", tr.sunShadowArrayMap->width, - tr.sunShadowArrayMap->height); + "_sunshadowmap", tr.sunShadowArrayImage->width, + tr.sunShadowArrayImage->height); FBO_Bind(tr.sunShadowFbo[i]); - qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.sunShadowArrayMap->texnum, 0, i); + qglFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, tr.sunShadowArrayImage->texnum, 0, i); qglDrawBuffer(GL_NONE); qglReadBuffer(GL_NONE); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index a89cb3c118..e96dcdd39e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -354,7 +354,8 @@ static size_t GLSL_GetShaderHeader( if (r_cubeMapping->integer) { - Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%i)\n", CUBE_MAP_MIPS - 4)); + Q_strcat(dest, size, va("#define CUBEMAP_RESOLUTION float(%i)\n", CUBE_MAP_SIZE)); + Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%i)\n", CUBE_MAP_ROUGHNESS_MIPS)); } if (r_deluxeSpecular->value > 0.000001f) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index abd67543cb..2d36e8c52b 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3362,18 +3362,15 @@ void R_CreateBuiltinImages( void ) { if (r_dlightMode->integer >= 2) { - for (x = 0; x < MAX_DLIGHTS; x++) - { - tr.shadowCubemaps[x].image = R_CreateImage( - va("*shadowcubemap%i", x), NULL, DSHADOW_MAP_SIZE, DSHADOW_MAP_SIZE, - IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGFLAG_CUBEMAP, - GL_DEPTH_COMPONENT24); - GL_Bind(tr.shadowCubemaps[x].image); - qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - qglTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - } + tr.pointShadowArrayImage = R_Create2DImageArray( + va("*pointshadowmapImage"), + NULL, + DSHADOW_MAP_SIZE, + DSHADOW_MAP_SIZE, + MAX_DLIGHTS*6, + IMGTYPE_COLORALPHA, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + GL_DEPTH_COMPONENT16); } // with overbright bits active, we need an image which is some fraction of @@ -3505,7 +3502,7 @@ void R_CreateBuiltinImages( void ) { if (r_shadows->integer == 4) { - tr.pshadowArrayMap = R_Create2DImageArray( + tr.pshadowArrayImage = R_Create2DImageArray( va("*pshadowmapArray"), NULL, PSHADOW_MAP_SIZE, @@ -3518,21 +3515,7 @@ void R_CreateBuiltinImages( void ) { if (r_sunlightMode->integer) { - for (x = 0; x < 3; x++) - { - tr.sunShadowDepthImage[x] = R_CreateImage( - va("*sunshadowdepth%i", x), NULL, r_shadowMapSize->integer, - r_shadowMapSize->integer, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_DEPTH_COMPONENT24); - GL_Bind(tr.sunShadowDepthImage[x]); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE); - qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); - } - - tr.sunShadowArrayMap = R_Create2DImageArray( + tr.sunShadowArrayImage = R_Create2DImageArray( va("*sunShadowmapArray"), NULL, r_shadowMapSize->integer, @@ -3544,7 +3527,7 @@ void R_CreateBuiltinImages( void ) { tr.screenShadowImage = R_CreateImage( "*screenShadow", NULL, width, height, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_RGBA8); + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_R8); } if (r_cubeMapping->integer) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index eac44d5c49..05103c07e3 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -190,6 +190,8 @@ cvar_t *r_markcount; cvar_t *r_textureMode; cvar_t *r_offsetFactor; cvar_t *r_offsetUnits; +cvar_t *r_shadowOffsetFactor; +cvar_t *r_shadowOffsetUnits; cvar_t *r_gamma; cvar_t *r_intensity; cvar_t *r_lockpvs; @@ -1597,6 +1599,10 @@ void R_Register( void ) r_clear = ri.Cvar_Get ("r_clear", "0", CVAR_CHEAT, ""); r_offsetFactor = ri.Cvar_Get( "r_offsetfactor", "-1", CVAR_CHEAT, "" ); r_offsetUnits = ri.Cvar_Get( "r_offsetunits", "-2", CVAR_CHEAT, "" ); + + r_shadowOffsetFactor = ri.Cvar_Get("r_shadowOffsetFactor", "1.0", CVAR_CHEAT, ""); + r_shadowOffsetUnits = ri.Cvar_Get("r_shadowOffsetUnits", "1.0", CVAR_CHEAT, ""); + r_drawBuffer = ri.Cvar_Get( "r_drawBuffer", "GL_BACK", CVAR_CHEAT, "" ); r_lockpvs = ri.Cvar_Get ("r_lockpvs", "0", CVAR_CHEAT, ""); r_noportals = ri.Cvar_Get ("r_noportals", "0", CVAR_CHEAT, ""); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index f7c1a79bc5..411c8cb4eb 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -52,7 +52,7 @@ typedef unsigned int glIndex_t; #define SHADERNUM_BITS 14 #define MAX_SHADERS (1<sort != SS_OPAQUE)) + { + return; + } + // instead of checking for overflow, we just mask the index // so it wraps around index = tr.refdef.numDrawSurfs & DRAWSURF_MASK; surf = tr.refdef.drawSurfs + index; - - surf->sort = R_CreateSortKey(entityNum, shader->sortedIndex, cubemap, postRender); - surf->dlightBits = dlightMap; surf->surface = surface; - surf->fogIndex = fogIndex; + if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) && + shader->useSimpleDepthShader == qtrue) + { + surf->sort = R_CreateSortKey(entityNum, tr.defaultShader->sortedIndex, 0, 0); + surf->dlightBits = 0; + surf->fogIndex = 0; + } + else + { + surf->sort = R_CreateSortKey(entityNum, shader->sortedIndex, cubemap, postRender); + surf->dlightBits = dlightMap; + surf->fogIndex = fogIndex; + } + tr.refdef.numDrawSurfs++; } @@ -2039,6 +2055,32 @@ void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { } } + if ((viewParms->flags & VPF_ORTHOGRAPHIC) == 0) + { + // set the projection matrix with the minimum zfar + // now that we have the world bounded + // this needs to be done before entities are + // added, because they use the projection + // matrix for lod calculation + + // dynamically compute far clip plane distance + if (!(tr.viewParms.flags & VPF_SHADOWMAP)) + { + R_SetFarClip(viewParms, refdef); + } + + // we know the size of the clipping volume. Now set the rest of the projection matrix. + R_SetupProjectionZ(viewParms); + } + + R_AddEntitySurfaces(refdef); + + if (!(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) + { + R_AddWeatherSurfaces(); + } +} + /* ================ R_DebugPolygon @@ -2142,8 +2184,8 @@ void R_RenderDlightCubemaps(const refdef_t *fd) int j; // use previous frame to determine visible dlights - if ((1 << i) & bufferDlightMask) - continue; + /*if ((1 << i) & bufferDlightMask) + continue;*/ Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); @@ -2152,12 +2194,12 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.viewportWidth = DSHADOW_MAP_SIZE; shadowParms.viewportHeight = DSHADOW_MAP_SIZE; shadowParms.isPortal = qfalse; - shadowParms.isMirror = qtrue; // because it is + shadowParms.isMirror = qfalse; shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL; + shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL | VPF_POINTSHADOW; shadowParms.zFar = tr.refdef.dlights[i].radius; shadowParms.zNear = 1.0f; @@ -2205,8 +2247,8 @@ void R_RenderDlightCubemaps(const refdef_t *fd) break; } - shadowParms.targetFbo = tr.shadowCubeFbo; - shadowParms.targetFboLayer = j; + shadowParms.targetFbo = tr.shadowCubeFbo[i*6+j]; + shadowParms.targetFboLayer = 0; R_RenderView(&shadowParms); } @@ -2725,7 +2767,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) tr.sunShadowFbo[level]->width, tr.sunShadowFbo[level]->height, tr.sunShadowFbo[level], - VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL, + VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL | VPF_SHADOWCASCADES, orientation, lightviewBounds); @@ -2832,7 +2874,7 @@ void R_RenderCubemapSide(int cubemapIndex, int cubemapSide, qboolean subscene, b parms.viewportWidth = tr.renderCubeFbo[cubemapSide]->width; parms.viewportHeight = tr.renderCubeFbo[cubemapSide]->height; parms.isMirror = qfalse; - parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS | VPF_CUBEMAPSIDE; + parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; if (!bounce) parms.flags |= VPF_NOCUBEMAPS; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index ad5c89da9e..36357dfea4 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -107,6 +107,15 @@ void R_AddPolygonSurfaces( const trRefdef_t *refdef ) { } } + int fogMask = -((refdef->rdflags & RDF_NOFOG) == 0); + + int i; + for (i = 0, poly = refdef->polys; i < refdef->numPolys; i++, poly++) { + shader_t *sh = R_GetShaderByHandle(poly->hShader); + + } +} + /* ===================== RE_AddPolyToScene @@ -257,10 +266,22 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa } dl = &backEndData->dlights[r_numdlights++]; VectorCopy (org, dl->origin); - dl->radius = intensity; + dl->radius = intensity * 20.0f; dl->color[0] = r; dl->color[1] = g; dl->color[2] = b; + + if (r_hdr->integer) + { + float maxValue = MAX(r, MAX(g, b)); + if (maxValue > 1.0f) + { + VectorScale(dl->color, 1.0f / maxValue, dl->color); + dl->radius *= maxValue; + } + dl->radius = MIN(dl->radius, 65535.0f); + } + dl->additive = additive; } diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 9492f195ac..953b2aa66d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -879,7 +879,7 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr uint32_t stateBits = 0; stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA | GLS_DEPTHFUNC_EQUAL; - samplerBindingsWriter.AddStaticImage(tr.pshadowArrayMap, TB_DIFFUSEMAP); + samplerBindingsWriter.AddStaticImage(tr.pshadowArrayImage, TB_DIFFUSEMAP); CaptureDrawData(input, pStage, 0, 0); @@ -1254,6 +1254,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } } + if (backEnd.viewParms.flags & VPF_POINTSHADOW) + stateBits |= GLS_POLYGON_OFFSET_FILL; + sp = SelectShaderProgram(stage, pStage, pStage->glslShaderGroup, useAlphaTestGE192); assert(sp); @@ -1506,7 +1509,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, tess.dlightBits); if (r_dlightMode->integer > 1) - samplerBindingsWriter.AddStaticImage(tr.shadowCubemaps[0].image, TB_SHADOWMAP2); + samplerBindingsWriter.AddStaticImage(tr.pointShadowArrayImage, TB_SHADOWMAP2); } else uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, 0); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index cd8c34f145..a1d1622b72 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4069,7 +4069,6 @@ static shader_t *FinishShader( void ) { //shader.lightmapIndex = LIGHTMAP_NONE; } - // // compute number of passes // @@ -4079,6 +4078,22 @@ static shader_t *FinishShader( void ) { if (stage == 0 && !shader.isSky) shader.sort = SS_FOG; + // determain if the shader can be simplified when beeing rendered to depth + if (shader.sort == SS_OPAQUE && + shader.numDeforms == 0) + { + for (stage = 0; stage < MAX_SHADER_STAGES; stage++) { + shaderStage_t *pStage = &stages[stage]; + + if (!pStage->active) + continue; + + if (pStage->alphaTestType == ALPHA_TEST_NONE) + shader.useSimpleDepthShader = qtrue; + break; + } + } + // determine which stage iterator function is appropriate ComputeStageIteratorFunc(); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 8654c0aac6..88079a39c2 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -68,22 +68,16 @@ static qboolean R_CullSurface( msurface_t *surf, int entityNum ) { return qfalse; } - // don't cull for depth shadow - /* - if ( tr.viewParms.flags & VPF_DEPTHSHADOW ) - { + if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) return qfalse; - } - */ - // shadowmaps draw back surfaces - if ( tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) ) + if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) { if (ct == CT_FRONT_SIDED) { ct = CT_BACK_SIDED; } - else + else if (ct == CT_BACK_SIDED) { ct = CT_FRONT_SIDED; } From 04d94cd4acec7e2cdac3630f4a40279159e3ac27 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 1 Jun 2022 15:09:25 +0200 Subject: [PATCH 559/708] Don't scale dlights Oversight in my last commit. --- codemp/rd-rend2/tr_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 36357dfea4..c3a6001dcb 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -266,7 +266,7 @@ void RE_AddDynamicLightToScene( const vec3_t org, float intensity, float r, floa } dl = &backEndData->dlights[r_numdlights++]; VectorCopy (org, dl->origin); - dl->radius = intensity * 20.0f; + dl->radius = intensity; dl->color[0] = r; dl->color[1] = g; dl->color[2] = b; From 591d7e57f6d27a2efb3a2005688f8fe6cf667b3c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Jun 2022 01:04:12 +0200 Subject: [PATCH 560/708] Another oversight --- codemp/rd-rend2/tr_scene.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index c3a6001dcb..5e38547279 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -107,15 +107,6 @@ void R_AddPolygonSurfaces( const trRefdef_t *refdef ) { } } - int fogMask = -((refdef->rdflags & RDF_NOFOG) == 0); - - int i; - for (i = 0, poly = refdef->polys; i < refdef->numPolys; i++, poly++) { - shader_t *sh = R_GetShaderByHandle(poly->hShader); - - } -} - /* ===================== RE_AddPolyToScene From a10793ac8d557ca07447a71087ae46745e15012f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Jun 2022 15:49:29 +0200 Subject: [PATCH 561/708] Another oversight... --- codemp/rd-rend2/tr_main.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 69a87fe884..9c02daaab2 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2055,32 +2055,6 @@ void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { } } - if ((viewParms->flags & VPF_ORTHOGRAPHIC) == 0) - { - // set the projection matrix with the minimum zfar - // now that we have the world bounded - // this needs to be done before entities are - // added, because they use the projection - // matrix for lod calculation - - // dynamically compute far clip plane distance - if (!(tr.viewParms.flags & VPF_SHADOWMAP)) - { - R_SetFarClip(viewParms, refdef); - } - - // we know the size of the clipping volume. Now set the rest of the projection matrix. - R_SetupProjectionZ(viewParms); - } - - R_AddEntitySurfaces(refdef); - - if (!(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) - { - R_AddWeatherSurfaces(); - } -} - /* ================ R_DebugPolygon From 3960010f17e34768f245f23ba4308f0ecb37a9a6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 11 Aug 2022 18:56:00 +0200 Subject: [PATCH 562/708] Deforms temporary change Mainly to support Szico VII to build his beach map without having to fix this mess properly for now. --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index a1d1622b72..c1dd0a9752 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3174,7 +3174,7 @@ static qboolean CollapseStagesToGLSL(void) ri.Printf (PRINT_DEVELOPER, "Collapsing stages for shader '%s'\n", shader.name); // skip shaders with deforms - if (shader.numDeforms != 0) + if (shader.numDeforms == 1) { skip = qtrue; ri.Printf (PRINT_DEVELOPER, "> Shader has vertex deformations. Aborting stage collapsing\n"); From b411b6e5e8bc085d48bab6174fad27b8be10c846 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 11 Aug 2022 18:57:24 +0200 Subject: [PATCH 563/708] Adding more cvar descriptions --- codemp/rd-rend2/tr_init.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 05103c07e3..6f404673c9 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1465,16 +1465,16 @@ void R_Register( void ) r_externalGLSL = ri.Cvar_Get( "r_externalGLSL", "0", CVAR_LATCH, "" ); - r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_hdr = ri.Cvar_Get( "r_hdr", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable rendering in HDR" ); + r_floatLightmap = ri.Cvar_Get( "r_floatLightmap", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable HDR lightmap support" ); - r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_toneMap = ri.Cvar_Get( "r_toneMap", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable tonemapping" ); r_forceToneMap = ri.Cvar_Get( "r_forceToneMap", "0", CVAR_CHEAT, "" ); r_forceToneMapMin = ri.Cvar_Get( "r_forceToneMapMin", "-8.0", CVAR_CHEAT, "" ); r_forceToneMapAvg = ri.Cvar_Get( "r_forceToneMapAvg", "-2.0", CVAR_CHEAT, "" ); r_forceToneMapMax = ri.Cvar_Get( "r_forceToneMapMax", "0.0", CVAR_CHEAT, "" ); - r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE, "" ); + r_autoExposure = ri.Cvar_Get( "r_autoExposure", "1", CVAR_ARCHIVE, "Disable/enable auto exposure" ); r_forceAutoExposure = ri.Cvar_Get( "r_forceAutoExposure", "0", CVAR_CHEAT, "" ); r_forceAutoExposureMin = ri.Cvar_Get( "r_forceAutoExposureMin", "-2.0", CVAR_CHEAT, "" ); r_forceAutoExposureMax = ri.Cvar_Get( "r_forceAutoExposureMax", "2.0", CVAR_CHEAT, "" ); @@ -1484,13 +1484,13 @@ void R_Register( void ) r_depthPrepass = ri.Cvar_Get( "r_depthPrepass", "1", CVAR_ARCHIVE, "" ); r_ssao = ri.Cvar_Get( "r_ssao", "0", CVAR_LATCH | CVAR_ARCHIVE, "" ); - r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_deluxeSpecular = ri.Cvar_Get("r_deluxeSpecular", "1", CVAR_ARCHIVE | CVAR_LATCH, ""); - r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_cubeMappingBounces = ri.Cvar_Get("r_cubeMappingBounces", "0", CVAR_ARCHIVE | CVAR_LATCH, ""); + r_normalMapping = ri.Cvar_Get( "r_normalMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable normal mapping" ); + r_specularMapping = ri.Cvar_Get( "r_specularMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable specular mapping" ); + r_deluxeMapping = ri.Cvar_Get( "r_deluxeMapping", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable reading deluxemaps when compiled with q3map2" ); + r_deluxeSpecular = ri.Cvar_Get("r_deluxeSpecular", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable/scale the specular response from deluxemaps"); + r_parallaxMapping = ri.Cvar_Get( "r_parallaxMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable parallax mapping" ); + r_cubeMapping = ri.Cvar_Get( "r_cubeMapping", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable cubemapping" ); + r_cubeMappingBounces = ri.Cvar_Get("r_cubeMappingBounces", "0", CVAR_ARCHIVE | CVAR_LATCH, "Renders cubemaps multiple times to get reflections in reflections"); ri.Cvar_CheckRange(r_cubeMappingBounces, 0, 2, qfalse); r_baseNormalX = ri.Cvar_Get( "r_baseNormalX", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_baseNormalY = ri.Cvar_Get( "r_baseNormalY", "1.0", CVAR_ARCHIVE | CVAR_LATCH, "" ); @@ -1498,11 +1498,11 @@ void R_Register( void ) r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_dlightMode = ri.Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); - r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable packing lightmaps into one atlas" ); r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); - r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); + r_genNormalMaps = ri.Cvar_Get( "r_genNormalMaps", "0", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable generating normal maps from diffuse maps" ); r_forceSun = ri.Cvar_Get( "r_forceSun", "0", CVAR_CHEAT, "" ); r_forceSunMapLightScale = ri.Cvar_Get( "r_forceSunMapLightScale", "1.0", CVAR_CHEAT, "" ); From 3abad87aa164ae3b39d80f91d2fb1c6c17882bff Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 11 Aug 2022 18:57:51 +0200 Subject: [PATCH 564/708] Fix crash when cubemapping is disabled --- codemp/rd-rend2/tr_glsl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e96dcdd39e..ab7be87584 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2310,7 +2310,8 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramCalcLuminanceLevel(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramShadowMask(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramSSAO(builder, allocator); - numEtcShaders += GLSL_LoadGPUProgramPrefilterEnvMap(builder, allocator); + if (r_cubeMapping->integer) + numEtcShaders += GLSL_LoadGPUProgramPrefilterEnvMap(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDepthBlur(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramGaussianBlur(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDynamicGlowUpsample(builder, allocator); From f179096f04dc9ac5153d37ce8875ff663d738b07 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 14 Aug 2022 21:09:40 +0200 Subject: [PATCH 565/708] Fixing vertex shader recompiles in runtime Driver complained that vertex shaders needed to be recompiled mid frame because of the OpenGL state. --- codemp/rd-rend2/glsl/generic.glsl | 2 ++ codemp/rd-rend2/glsl/lightall.glsl | 16 ++++++---------- codemp/rd-rend2/tr_ghoul2.cpp | 12 +++++++++++- codemp/rd-rend2/tr_model.cpp | 12 +++++++++++- codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_shader.cpp | 2 +- codemp/rd-rend2/tr_sky.cpp | 5 ++++- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index c272b7e85b..34774c25d6 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -41,6 +41,7 @@ layout(std140) uniform Entity int u_FogIndex; }; +#if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) layout(std140) uniform ShaderInstance { vec4 u_DeformParams0; @@ -50,6 +51,7 @@ layout(std140) uniform ShaderInstance int u_DeformType; int u_DeformFunc; }; +#endif #if defined(USE_SKELETAL_ANIMATION) layout(std140) uniform Bones diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index e380759488..d2787749b1 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -13,7 +13,9 @@ in vec4 attr_Color; in vec3 attr_Position; in vec3 attr_Normal; +#if defined(PER_PIXEL_LIGHTING) in vec4 attr_Tangent; +#endif #if defined(USE_VERTEX_ANIMATION) in vec3 attr_Position2; @@ -37,14 +39,6 @@ layout(std140) uniform Camera vec3 u_ViewUp; }; -layout(std140) uniform Scene -{ - vec4 u_PrimaryLightOrigin; - vec3 u_PrimaryLightAmbient; - vec3 u_PrimaryLightColor; - float u_PrimaryLightRadius; -}; - layout(std140) uniform Entity { mat4 u_ModelMatrix; @@ -226,7 +220,9 @@ void main() #if defined(USE_VERTEX_ANIMATION) vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + #if defined(PER_PIXEL_LIGHTING) vec3 tangent = mix(attr_Tangent.xyz, attr_Tangent2.xyz, u_VertexLerp); + #endif #elif defined(USE_SKELETAL_ANIMATION) mat4x3 influence = GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + @@ -333,7 +329,7 @@ void main() } /*[Fragment]*/ -#if defined(USE_LIGHT) && !defined(USE_VERTEX_LIGHTING) +#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #define PER_PIXEL_LIGHTING #endif layout(std140) uniform Scene @@ -995,7 +991,7 @@ void main() reflectance = CalcDiffuse(diffuse.rgb, NE, NL2, L2H2, roughness); reflectance += CalcSpecular(specular.rgb, NH2, NL2, NE, L2H2, VH2, roughness); - lightColor = u_PrimaryLightColor * var_Color.rgb; + lightColor = u_PrimaryLightColor; #if defined(USE_SHADOWMAP) lightColor *= shadowValue; #endif diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 108bf0a95b..a21241d2b2 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4082,10 +4082,11 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & byte *bonerefs; byte *weights; uint32_t *tangents; + vec4_t *color; byte *data; int dataSize = 0; - int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents; + int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents, ofsColor; int stride = 0; int numVerts = 0; int numTriangles = 0; @@ -4114,6 +4115,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & baseVertexes[mdxm->numSurfaces] = numVerts; + dataSize += 1.0 * sizeof(*color); dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); @@ -4124,6 +4126,10 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Allocate and write to memory data = (byte *)ri.Hunk_AllocateTempMemory (dataSize); + color = (vec4_t *)(data + stride); + ofsColor = stride; + stride += 0; // sizeof(*color); Overwrite for the generic value + verts = (vec3_t *)(data + stride); ofsPosition = stride; stride += sizeof (*verts); @@ -4265,6 +4271,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } assert ((byte *)verts == (data + dataSize)); + VectorSet4(*color, 1.0f, 1.0f, 1.0f, 1.0f); const char *modelName = strrchr (mdxm->name, '/'); if (modelName == NULL) @@ -4278,6 +4285,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & ri.Hunk_FreeTempMemory (tangentsf); ri.Hunk_FreeTempMemory (indices); + vbo->offsets[ATTR_INDEX_COLOR] = ofsColor; vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofsTexcoords; @@ -4285,6 +4293,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->offsets[ATTR_INDEX_BONE_WEIGHTS] = ofsWeights; vbo->offsets[ATTR_INDEX_TANGENT] = ofsTangents; + vbo->strides[ATTR_INDEX_COLOR] = 0; vbo->strides[ATTR_INDEX_POSITION] = stride; vbo->strides[ATTR_INDEX_NORMAL] = stride; vbo->strides[ATTR_INDEX_TEXCOORD0] = stride; @@ -4292,6 +4301,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->strides[ATTR_INDEX_BONE_WEIGHTS] = stride; vbo->strides[ATTR_INDEX_TANGENT] = stride; + vbo->sizes[ATTR_INDEX_COLOR] = sizeof(*color); vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index cbf8e355e7..62bbfb40be 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1073,15 +1073,19 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vec2_t *texcoords; uint32_t *normals; uint32_t *tangents; + vec4_t *color; byte *data; int dataSize; int ofs_xyz, ofs_normal, ofs_st; - int ofs_tangent; + int ofs_tangent, ofs_color; dataSize = 0; + ofs_color = dataSize; + dataSize += 1.0f * sizeof(*color); + ofs_xyz = dataSize; dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*verts); @@ -1096,6 +1100,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN data = (byte *)Z_Malloc(dataSize, TAG_MODEL_MD3); + color = (vec4_t *)(data + ofs_color); verts = (vec3_t *)(data + ofs_xyz); normals = (uint32_t *)(data + ofs_normal); tangents = (uint32_t *)(data + ofs_tangent); @@ -1115,6 +1120,8 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN texcoords[j][1] = st->st[1]; } + VectorSet4(*color, 1.0f, 1.0f, 1.0f, 1.0f); + // If we would support vertex animations, we would need to compute tangents for the other frames too! R_CalcMikkTSpaceMD3Surface(surf->numIndexes/3, verts, normals, tangents, texcoords, surf->indexes); @@ -1129,16 +1136,19 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); + vboSurf->vbo->offsets[ATTR_INDEX_COLOR] = ofs_color; vboSurf->vbo->offsets[ATTR_INDEX_POSITION] = ofs_xyz; vboSurf->vbo->offsets[ATTR_INDEX_NORMAL] = ofs_normal; vboSurf->vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofs_st; vboSurf->vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; + vboSurf->vbo->strides[ATTR_INDEX_COLOR] = 0; // sizeof(*color); This is to overrite the generic color value and to be less prone to attr binding errors vboSurf->vbo->strides[ATTR_INDEX_POSITION] = sizeof(*verts); vboSurf->vbo->strides[ATTR_INDEX_NORMAL] = sizeof(*normals); vboSurf->vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(*st); vboSurf->vbo->strides[ATTR_INDEX_TANGENT] = sizeof(*tangents); + vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*color); vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); vboSurf->vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); vboSurf->vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 953b2aa66d..be68118f02 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -979,7 +979,7 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) if(glState.vertexAnimation) { - vertexAttribs &= ~ATTR_COLOR; + //vertexAttribs &= ~ATTR_COLOR; vertexAttribs |= ATTR_POSITION2; if (vertexAttribs & ATTR_NORMAL) { diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c1dd0a9752..9e8956ee06 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2879,7 +2879,7 @@ static void ComputeVertexAttribs(void) int i, stage; // dlights always need ATTR_NORMAL - shader.vertexAttribs = ATTR_POSITION | ATTR_NORMAL; + shader.vertexAttribs = ATTR_POSITION | ATTR_NORMAL | ATTR_COLOR; if (shader.defaultShader) { diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index f2d7b69275..0293f78dd6 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -362,7 +362,7 @@ static float s_skyTexCoords[SKY_SUBDIVISIONS+1][SKY_SUBDIVISIONS+1][2]; static void DrawSkySide( struct image_s *image, const int mins[2], const int maxs[2] ) { - const uint32_t SKY_BOX_VERTEX_ATTRIBUTES = ATTR_POSITION | ATTR_TEXCOORD0; + const uint32_t SKY_BOX_VERTEX_ATTRIBUTES = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_COLOR | ATTR_NORMAL; int s, t; int firstVertex = tess.numVertexes; int minIndex = tess.minIndex; @@ -384,6 +384,9 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max tess.texCoords[tess.numVertexes][0][0] = s_skyTexCoords[t][s][0]; tess.texCoords[tess.numVertexes][0][1] = s_skyTexCoords[t][s][1]; + VectorSet4(tess.vertexColors[tess.numVertexes], 1.0f, 1.0f, 1.0f, 1.0f); + tess.normal[tess.numVertexes] = 0; + tess.numVertexes++; if(tess.numVertexes >= SHADER_MAX_VERTEXES) From 24a291753c2ab047dbf2fee5fda24e95fc058e90 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 14 Aug 2022 21:10:22 +0200 Subject: [PATCH 566/708] Cleanup HDR Lightmap code --- codemp/rd-rend2/tr_bsp.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 6a551bb9dc..3798953ff3 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -285,7 +285,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low ); } - if (glRefConfig.floatLightmap) + if (hdr_capable) textureInternalFormat = GL_RGBA16F; else textureInternalFormat = GL_RGBA8; @@ -428,7 +428,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { ColorToRGBA16F(color, (uint16_t *)(&image[j * 8])); } - else if (buf_p && glRefConfig.floatLightmap) + else if (buf_p && hdr_capable) { vec4_t color; @@ -450,10 +450,6 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { R_ColorShiftLightingFloats(color, color, 1.0f / 255.0f); - color[0] = color[0]; - color[1] = color[1]; - color[2] = color[2]; - ColorToRGBA16F(color, (unsigned short *)(&image[j * 8])); } else if (buf_p) From c480ff4e0d8b40edfd72d196e47861ada023a024 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 14 Aug 2022 21:10:44 +0200 Subject: [PATCH 567/708] Fixing global fog --- codemp/rd-rend2/tr_backend.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 07f3928e90..eff946ffd5 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2336,12 +2336,15 @@ static void RB_UpdateFogsConstants(gpuFrame_t *frame) } else { - fogsBlock.numFogs = tr.world->numfogs - 1; // Don't reserve fog 0 as 'null' + if (tr.world->globalFog) + fogsBlock.numFogs = 1; + else + fogsBlock.numFogs = tr.world->numfogs - 1; // Don't reserve fog 0 as 'null' } for (int i = 0; i < fogsBlock.numFogs; ++i) { - const fog_t *fog = tr.world->fogs + i + 1; + const fog_t *fog = tr.world->globalFog ? tr.world->globalFog : tr.world->fogs + i + 1; FogsBlock::Fog *fogData = fogsBlock.fogs + i; VectorCopy4(fog->surface, fogData->plane); @@ -2686,7 +2689,7 @@ static void RB_UpdateShaderAndEntityConstants( if (tr.world != nullptr) { if (tr.world->globalFog != nullptr) - entityBlock.fogIndex = tr.world->globalFog - tr.world->fogs - 1; + entityBlock.fogIndex = 0; else if (drawSurf->fogIndex > 0) entityBlock.fogIndex = drawSurf->fogIndex - 1; } From d90412f15e96ebdc34d9a0d1419a3ebeed70a21f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 14 Aug 2022 22:28:00 +0200 Subject: [PATCH 568/708] Fix r_lightmap 1 --- codemp/rd-rend2/tr_shade.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index be68118f02..1c204610e7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1075,7 +1075,7 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { index = stage->glslShaderIndex; - if (r_lightmap->integer && (index & LIGHTDEF_USE_LIGHTMAP)) + if (r_lightmap->integer && (index & LIGHTDEF_USE_LIGHTMAP) && !(index & LIGHTDEF_USE_LIGHT_VERTEX)) { index = LIGHTDEF_USE_LIGHTMAP; } @@ -1307,12 +1307,12 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays baseColor[0] = baseColor[1] = baseColor[2] = - baseColor[3] = tr.identityLight; + baseColor[3] = 0.0f; vertColor[0] = vertColor[1] = vertColor[2] = - vertColor[3] = 0.0f; + vertColor[3] = tr.identityLight; break; default: break; @@ -1390,7 +1390,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && - pStage->bundle[TB_LIGHTMAP].image[0]) + (pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap)) { for (i = 0; i < NUM_TEXTURE_BUNDLES; i++) { From 43e2865b230fcd4df6a176490b206ea2af043c8d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 16 Aug 2022 02:09:13 +0200 Subject: [PATCH 569/708] Add/Fix very basic flare rendering Binds a new static entity ubo. Flare entity ubo should be updated when the projection matrix changes, but it works for basic rendering. Flares in cubemaps should be broken with this. Shader ubo is not bound properly, needs to be implemented. Need to get the shader data upfront when building the frame ubos. Definitly need to get rid of the glReadPixels to get the current depth value, as this creates a sync point. --- codemp/rd-rend2/tr_backend.cpp | 2 + codemp/rd-rend2/tr_bsp.cpp | 20 ++++++ codemp/rd-rend2/tr_flares.cpp | 111 +++++++++++++++++++++------------ codemp/rd-rend2/tr_init.cpp | 22 ++++++- codemp/rd-rend2/tr_local.h | 8 ++- codemp/rd-rend2/tr_shade.cpp | 5 ++ codemp/rd-rend2/tr_shader.cpp | 2 +- 7 files changed, 125 insertions(+), 45 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index eff946ffd5..061be98f0f 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2218,6 +2218,8 @@ static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) // darken down any stencil shadows RB_ShadowFinish(); + + RB_RenderFlares(); } static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSurfs ) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3798953ff3..4177ad3eb7 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1145,6 +1145,26 @@ static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *ve flare = (srfFlare_t *)surf->data; flare->surfaceType = SF_FLARE; + if (surf->shader == tr.defaultShader) + flare->shader = tr.flareShader; + else + flare->shader = surf->shader; + + if (!flare->shader->defaultShader) + { + // Set some default values. Deforms are handled by the flares system itself + flare->shader->cullType = CT_TWO_SIDED; + flare->shader->numDeforms = 0; + for (int index = 0; index < flare->shader->numUnfoggedPasses; index++) + { + flare->shader->stages[index]->adjustColorsForFog = ACFF_NONE; + flare->shader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; + if (flare->shader->stages[index]->alphaGen == AGEN_PORTAL) + flare->portal_ranged = true; + flare->shader->stages[index]->alphaGen = AGEN_VERTEX; + } + } + surf->data = (surfaceType_t *)flare; for ( i = 0 ; i < 3 ; i++ ) { diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index e78b5790f9..c490a048fb 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -136,16 +136,16 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t backEnd.pc.c_flareAdds++; - if(normal && (normal[0] || normal[1] || normal[2])) - { - VectorSubtract( backEnd.viewParms.ori.origin, point, local ); - VectorNormalizeFast(local); - d = DotProduct(local, normal); + //if(normal && (normal[0] || normal[1] || normal[2])) + //{ + // VectorSubtract( backEnd.viewParms.ori.origin, point, local ); + // VectorNormalizeFast(local); + // d = DotProduct(local, normal); - // If the viewer is behind the flare don't add it. - if(d < 0) - return; - } + // // If the viewer is behind the flare don't add it. + // if(d < 0) + // return; + //} // if the point is off the screen, don't bother adding it // calculate screen coordinates and depth @@ -204,7 +204,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t // fade the intensity of the flare down as the // light surface turns away from the viewer - VectorScale( f->color, d, f->color ); + //VectorScale( f->color, d, f->color ); // save info needed to test f->windowX = backEnd.viewParms.viewportX + window[0]; @@ -288,7 +288,8 @@ void RB_TestFlare( flare_t *f ) { FBO_Bind(tr.msaaResolveFbo); } - // read back the z buffer contents + // read back the z buffer contents, which is bad + // TODO: Don't use glReadPixels qglReadPixels( f->windowX, f->windowY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth ); // if we're doing multisample rendering, switch to the old FBO @@ -309,11 +310,14 @@ void RB_TestFlare( flare_t *f ) { } fade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value; } else { - if ( f->visible ) { + // Dont fade out when flare is occluded. Will result in the ability to see + // flares through surfaces on high movement speeds + /*if ( f->visible ) { f->visible = qfalse; f->fadeTime = backEnd.refdef.time - 1; } - fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value; + fade = 1.0f - ( ( backEnd.refdef.time - f->fadeTime ) / 1000.0f ) * r_flareFade->value;*/ + fade = 0.0f; } if ( fade < 0 ) { @@ -391,51 +395,78 @@ void RB_RenderFlare( flare_t *f ) { return; } - iColor[0] = color[0] * fogFactors[0]; - iColor[1] = color[1] * fogFactors[1]; - iColor[2] = color[2] * fogFactors[2]; - - RB_BeginSurface( tr.flareShader, f->fogNum, 0 ); + srfFlare_t *flare = (srfFlare_t *)f->surface; + float alpha = 1.0f; + if (flare->portal_ranged) + { + float len = distance; + len /= flare->shader->portalRange; + + if (len < 0) + { + alpha = 0; + } + else if (len > 1) + { + alpha = 0xff; + } + else + { + alpha = len * 0xff; + } + alpha /= 255.0f; + } + + iColor[0] = (color[0] * fogFactors[0] * alpha) / 255.0f; + iColor[1] = (color[1] * fogFactors[1] * alpha) / 255.0f; + iColor[2] = (color[2] * fogFactors[2] * alpha) / 255.0f; + + backEnd.currentEntity = &backEnd.entityFlare; + RB_BeginSurface( flare->shader, f->fogNum, 0 ); // FIXME: use quadstamp? tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = f->windowY - size; + tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY - size; + tess.xyz[tess.numVertexes][2] = 0.5f; tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; - tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.vertexColors[tess.numVertexes][0] = iColor[0]; + tess.vertexColors[tess.numVertexes][1] = iColor[1]; + tess.vertexColors[tess.numVertexes][2] = iColor[2]; + tess.vertexColors[tess.numVertexes][3] = alpha; tess.numVertexes++; tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = f->windowY + size; + tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY + size; + tess.xyz[tess.numVertexes][2] = 0.5f; tess.texCoords[tess.numVertexes][0][0] = 0; tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; - tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.vertexColors[tess.numVertexes][0] = iColor[0]; + tess.vertexColors[tess.numVertexes][1] = iColor[1]; + tess.vertexColors[tess.numVertexes][2] = iColor[2]; + tess.vertexColors[tess.numVertexes][3] = alpha; tess.numVertexes++; tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = f->windowY + size; + tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY + size; + tess.xyz[tess.numVertexes][2] = 0.5f; tess.texCoords[tess.numVertexes][0][0] = 1; tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; - tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.vertexColors[tess.numVertexes][0] = iColor[0]; + tess.vertexColors[tess.numVertexes][1] = iColor[1]; + tess.vertexColors[tess.numVertexes][2] = iColor[2]; + tess.vertexColors[tess.numVertexes][3] = alpha; tess.numVertexes++; tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = f->windowY - size; + tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY - size; + tess.xyz[tess.numVertexes][2] = 0.5f; tess.texCoords[tess.numVertexes][0][0] = 1; tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = iColor[0] / 255.0f; - tess.vertexColors[tess.numVertexes][1] = iColor[1] / 255.0f; - tess.vertexColors[tess.numVertexes][2] = iColor[2] / 255.0f; - tess.vertexColors[tess.numVertexes][3] = 1.0f; + tess.vertexColors[tess.numVertexes][0] = iColor[0]; + tess.vertexColors[tess.numVertexes][1] = iColor[1]; + tess.vertexColors[tess.numVertexes][2] = iColor[2]; + tess.vertexColors[tess.numVertexes][3] = alpha; tess.numVertexes++; tess.indexes[tess.numIndexes++] = 0; @@ -465,7 +496,6 @@ extend past the portal edge will be overwritten. ================== */ void RB_RenderFlares (void) { -#if 0 flare_t *f; flare_t **prev; qboolean draw; @@ -528,7 +558,7 @@ void RB_RenderFlares (void) { Matrix16Identity(matrix); GL_SetModelviewMatrix(matrix); Matrix16Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth, - backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, + backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, backEnd.viewParms.viewportY, -99999, 99999, matrix ); GL_SetProjectionMatrix(matrix); @@ -542,7 +572,6 @@ void RB_RenderFlares (void) { GL_SetProjectionMatrix(oldprojection); GL_SetModelviewMatrix(oldmodelview); -#endif } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 6f404673c9..2de30277f9 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1574,7 +1574,7 @@ void R_Register( void ) r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0, "" ); r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); - r_flareSize = ri.Cvar_Get ("r_flareSize", "40", CVAR_CHEAT, ""); + r_flareSize = ri.Cvar_Get ("r_flareSize", "4", CVAR_CHEAT, ""); r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT, ""); r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT, ""); @@ -1723,6 +1723,10 @@ static void R_InitBackEndFrameData() static void R_InitStaticConstants() { + + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + const size_t alignedBlockSize = (sizeof(EntityBlock) + alignment) & ~alignment; + EntityBlock entity2DBlock = {}; entity2DBlock.fxVolumetricBase = -1.0f; @@ -1746,6 +1750,22 @@ static void R_InitStaticConstants() tr.entity2DUboOffset = 0; qglBufferSubData( GL_UNIFORM_BUFFER, 0, sizeof(entity2DBlock), &entity2DBlock); + + EntityBlock entityFlareBlock = {}; + entityFlareBlock.fxVolumetricBase = -1.0f; + Matrix16Identity(entityFlareBlock.modelMatrix); + Matrix16Ortho( + 0.0f, + glConfig.vidWidth, + glConfig.vidHeight, + 0.0f, + -99999.0f, + 99999.0f, + entityFlareBlock.modelViewProjectionMatrix); + + tr.entityFlareUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.entityFlareUboOffset, sizeof(entityFlareBlock), &entityFlareBlock); } static void R_ShutdownBackEndFrameData() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 411c8cb4eb..a2ecffcbef 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1586,6 +1586,8 @@ typedef struct srfFlare_s { vec3_t origin; vec3_t normal; vec3_t color; + shader_t *shader; + bool portal_ranged; } srfFlare_t; struct vertexAttribute_t; @@ -2255,7 +2257,8 @@ typedef struct { qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes float color2D[4]; - trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering + trRefEntity_t entity2D; // currentEntity will point at this when doing 2D rendering + trRefEntity_t entityFlare; // currentEntity will point at this when doing flare rendering FBO_t *last2DFBO; qboolean colorMask[4]; @@ -2419,6 +2422,7 @@ typedef struct trGlobals_s { GLuint staticUbo; int entity2DUboOffset; + int entityFlareUboOffset; int cameraUboOffset; @@ -2535,7 +2539,7 @@ extern window_t window; extern cvar_t *r_flareSize; extern cvar_t *r_flareFade; // coefficient for the flare intensity falloff function. -#define FLARE_STDCOEFF "150" +#define FLARE_STDCOEFF "80" extern cvar_t *r_flareCoeff; extern cvar_t *r_railWidth; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 1c204610e7..71d3f2df80 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -751,6 +751,11 @@ static UniformBlockBinding GetEntityBlockUniformBinding( binding.ubo = tr.staticUbo; binding.offset = tr.entity2DUboOffset; } + else if (refEntity == &backEnd.entityFlare) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.entityFlareUboOffset; + } else { binding.ubo = currentFrameUbo; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 9e8956ee06..c9ccecce05 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4993,7 +4993,7 @@ static void CreateInternalShaders( void ) { static void CreateExternalShaders( void ) { tr.projectionShadowShader = R_FindShader( "projectionShadow", lightmapsNone, stylesDefault, qtrue ); - tr.flareShader = R_FindShader( "flareShader", lightmapsNone, stylesDefault, qtrue ); + tr.flareShader = R_FindShader( "gfx/misc/flare", lightmapsNone, stylesDefault, qtrue ); // Hack to make fogging work correctly on flares. Fog colors are calculated // in tr_flare.c already. From 5902a2e6ec9aca8184069525804fdf4aeb54805d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 14 Sep 2022 15:26:33 +0200 Subject: [PATCH 570/708] Fixing more of the flare rendering code --- codemp/rd-rend2/tr_backend.cpp | 6 ++++++ codemp/rd-rend2/tr_bsp.cpp | 4 +++- codemp/rd-rend2/tr_flares.cpp | 20 ++++++++++++-------- codemp/rd-rend2/tr_shade.cpp | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 061be98f0f..21efaa985e 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2677,6 +2677,12 @@ static void RB_UpdateShaderAndEntityConstants( continue; } + if (*drawSurf->surface == SF_FLARE) + { + RB_UpdateShaderEntityConstants(frame, REFENTITYNUM_WORLD, &backEnd.entityFlare, shader); + continue; + } + const trRefEntity_t *refEntity = entityNum == REFENTITYNUM_WORLD ? &tr.worldEntity : &backEnd.refdef.entities[entityNum]; if (shader != oldShader || diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 4177ad3eb7..00b565df3d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1160,8 +1160,10 @@ static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *ve flare->shader->stages[index]->adjustColorsForFog = ACFF_NONE; flare->shader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; if (flare->shader->stages[index]->alphaGen == AGEN_PORTAL) + { flare->portal_ranged = true; - flare->shader->stages[index]->alphaGen = AGEN_VERTEX; + flare->shader->stages[index]->alphaGen = AGEN_VERTEX; + } } } diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index c490a048fb..d1ffdc4be7 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -131,21 +131,21 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t int i; flare_t *f; vec3_t local; - float d = 1; + float d = 1.0f; vec4_t eye, clip, normalized, window; backEnd.pc.c_flareAdds++; - //if(normal && (normal[0] || normal[1] || normal[2])) - //{ - // VectorSubtract( backEnd.viewParms.ori.origin, point, local ); - // VectorNormalizeFast(local); - // d = DotProduct(local, normal); + if(normal && (normal[0] || normal[1] || normal[2])) + { + VectorSubtract( backEnd.viewParms.ori.origin, point, local ); + VectorNormalizeFast(local); + d = DotProduct(local, normal); // // If the viewer is behind the flare don't add it. // if(d < 0) // return; - //} + } // if the point is off the screen, don't bother adding it // calculate screen coordinates and depth @@ -204,7 +204,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t // fade the intensity of the flare down as the // light surface turns away from the viewer - //VectorScale( f->color, d, f->color ); + VectorScale( f->color, d, f->color ); // save info needed to test f->windowX = backEnd.viewParms.viewportX + window[0]; @@ -505,6 +505,10 @@ void RB_RenderFlares (void) { return; } + if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW) || + (backEnd.viewParms.flags & VPF_NOPOSTPROCESS)) + return; + if(r_flareCoeff->modified) { R_SetFlareCoeff(); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 71d3f2df80..931a36ba5d 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -802,7 +802,7 @@ static UniformBlockBinding GetShaderInstanceBlockUniformBinding( binding.ubo = currentFrameUbo; binding.block = UNIFORM_BLOCK_SHADER_INSTANCE; - if (refEntity == &tr.worldEntity) + if (refEntity == &tr.worldEntity || refEntity == &backEnd.entityFlare) { binding.offset = RB_GetEntityShaderUboOffset( tr.shaderInstanceUboOffsetsMap, From b5951dac79386d7445989d9f4f0aa28ce68d0da7 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 14 Sep 2022 18:06:45 +0200 Subject: [PATCH 571/708] Give surface sprites colors --- codemp/rd-rend2/glsl/surface_sprites.glsl | 5 +++++ codemp/rd-rend2/tr_bsp.cpp | 22 +++++++++++++++++++++- codemp/rd-rend2/tr_glsl.cpp | 2 +- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 6a200ddc84..a9023d63f1 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -1,6 +1,7 @@ /*[Vertex]*/ in vec3 attr_Position; in vec3 attr_Normal; +in vec3 attr_Color; uniform mat4 u_ModelViewProjectionMatrix; @@ -26,6 +27,7 @@ layout(std140) uniform SurfaceSprite out vec2 var_TexCoords; out float var_Alpha; +out vec3 var_Color; void main() { @@ -74,6 +76,7 @@ void main() vec4 worldPos = vec4(attr_Position + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; var_TexCoords = texcoords[gl_VertexID]; + var_Color = attr_Color; var_Alpha = 1.0 - fadeScale; } @@ -81,6 +84,7 @@ void main() uniform sampler2D u_DiffuseMap; in vec2 var_TexCoords; +in vec3 var_Color; in float var_Alpha; layout(std140) uniform SurfaceSprite @@ -101,6 +105,7 @@ void main() { const float alphaTestValue = 0.5; out_Color = texture(u_DiffuseMap, var_TexCoords); + out_Color.rgb *= var_Color; out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; #if defined(ALPHA_TEST) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 00b565df3d..f2fac33e1b 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3575,6 +3575,7 @@ struct sprite_t { vec3_t position; vec3_t normal; + vec3_t color; }; static uint32_t UpdateHash( const char *text, uint32_t hash ) @@ -3617,6 +3618,11 @@ static std::vector R_CreateSurfaceSpritesVertexData( VectorCopy(v1->normal, n1); VectorCopy(v2->normal, n2); + vec4_t c0, c1, c2; + VectorCopy(v0->vertexColors[0], c0); + VectorCopy(v1->vertexColors[0], c1); + VectorCopy(v2->vertexColors[0], c2); + const vec2_t p01 = {p1[0] - p0[0], p1[1] - p0[1]}; const vec2_t p02 = {p2[0] - p0[0], p2[1] - p0[1]}; @@ -3651,6 +3657,10 @@ static std::vector R_CreateSurfaceSpritesVertexData( VectorMA(sprite.position, y, p1, sprite.position); VectorMA(sprite.position, z, p2, sprite.position); + VectorMA(sprite.color, x, c0, sprite.color); + VectorMA(sprite.color, y, c1, sprite.color); + VectorMA(sprite.color, z, c2, sprite.color); + // x*x + y*y = 1.0 // => y*y = 1.0 - x*x // => y = -/+sqrt(1.0 - x*x) @@ -3701,7 +3711,7 @@ static void R_GenerateSurfaceSprites( out->shader->stages[0]->glslShaderGroup = tr.spriteShader; out->shader->stages[0]->alphaTestType = stage->alphaTestType; - out->numAttributes = 2; + out->numAttributes = 3; out->attributes = (vertexAttribute_t *)ri.Hunk_Alloc( sizeof(vertexAttribute_t) * out->numAttributes, h_low); @@ -3724,6 +3734,16 @@ static void R_GenerateSurfaceSprites( out->attributes[1].stride = sizeof(sprite_t); out->attributes[1].offset = offsetof(sprite_t, normal); out->attributes[1].stepRate = 1; + + out->attributes[2].vbo = out->vbo; + out->attributes[2].index = ATTR_INDEX_COLOR; + out->attributes[2].numComponents = 3; + out->attributes[2].integerAttribute = qfalse; + out->attributes[2].type = GL_FLOAT; + out->attributes[2].normalize = GL_FALSE; + out->attributes[2].stride = sizeof(sprite_t); + out->attributes[2].offset = offsetof(sprite_t, color); + out->attributes[2].stepRate = 1; } static void R_GenerateSurfaceSprites( const world_t *world ) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ab7be87584..15c98fdd71 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2166,7 +2166,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( char extradefines[1200]; const GPUProgramDesc *programDesc = LoadProgramSource("surface_sprites", allocator, fallback_surface_spritesProgram); - const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL; + const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_COLOR; for ( int i = 0; i < SSDEF_COUNT; ++i ) { extradefines[0] = '\0'; From 238744a14485a2e3bc38570e459c9980cbf213da Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 14 Sep 2022 18:08:39 +0200 Subject: [PATCH 572/708] Allocate less memory for shadow passes --- codemp/rd-rend2/tr_backend.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 21efaa985e..282eeb9d7e 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1454,11 +1454,13 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) each surface corresponds to something which has all of its gpu data uploaded */ + int estimatedShaderStages = (backEnd.viewParms.flags & VPF_DEPTHSHADOW) ? 1 : 4; + // Prepare memory for the current render pass void *allocMark = backEndData->perFrameMemory->Mark(); assert(backEndData->currentPass == nullptr); backEndData->currentPass = RB_CreatePass( - *backEndData->perFrameMemory, numDrawSurfs * 4); + *backEndData->perFrameMemory, numDrawSurfs * estimatedShaderStages); // save original time for entity shader offsets float originalTime = backEnd.refdef.floatTime; From 0aad9f49c62d99f668233017673d4444a8834919 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 15 Sep 2022 01:01:38 +0200 Subject: [PATCH 573/708] Fix vertex layout for ghoul2 models I have accidentally broken the vertex layout when I added the default color override. Now g2 models should render as intended again. --- codemp/rd-rend2/tr_ghoul2.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index a21241d2b2..ed6746b1ea 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4126,32 +4126,31 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Allocate and write to memory data = (byte *)ri.Hunk_AllocateTempMemory (dataSize); - color = (vec4_t *)(data + stride); - ofsColor = stride; - stride += 0; // sizeof(*color); Overwrite for the generic value + color = (vec4_t *)(data); + ofsColor = 0; - verts = (vec3_t *)(data + stride); - ofsPosition = stride; + ofsPosition = stride + sizeof(*color); + verts = (vec3_t *)(data + ofsPosition); stride += sizeof (*verts); - normals = (uint32_t *)(data + stride); - ofsNormals = stride; + ofsNormals = stride + sizeof(*color); + normals = (uint32_t *)(data + ofsNormals); stride += sizeof (*normals); - texcoords = (vec2_t *)(data + stride); - ofsTexcoords = stride; + ofsTexcoords = stride + sizeof(*color); + texcoords = (vec2_t *)(data + ofsTexcoords); stride += sizeof (*texcoords); - bonerefs = data + stride; - ofsBoneRefs = stride; + ofsBoneRefs = stride + sizeof(*color); + bonerefs = data + ofsBoneRefs; stride += sizeof (*bonerefs) * 4; - weights = data + stride; - ofsWeights = stride; + ofsWeights = stride + sizeof(*color); + weights = data + ofsWeights; stride += sizeof (*weights) * 4; - tangents = (uint32_t *)(data + stride); - ofsTangents = stride; + ofsTangents = stride + sizeof(*color); + tangents = (uint32_t *)(data + ofsTangents); stride += sizeof (*tangents); // Fill in the index buffer and compute tangents From e171d39fa127361e7eaa4ed0ccdc40c78d656541 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 21 Sep 2022 20:17:52 +0200 Subject: [PATCH 574/708] Rename lightIndex to lightMask --- codemp/rd-rend2/glsl/dlight.glsl | 227 --------------------------- codemp/rd-rend2/glsl/lightall.glsl | 4 +- codemp/rd-rend2/glsl/shadowfill.glsl | 2 +- codemp/rd-rend2/glsl/tonemap.glsl | 4 +- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_local.h | 2 +- codemp/rd-rend2/tr_shade.cpp | 4 +- 7 files changed, 9 insertions(+), 236 deletions(-) delete mode 100644 codemp/rd-rend2/glsl/dlight.glsl diff --git a/codemp/rd-rend2/glsl/dlight.glsl b/codemp/rd-rend2/glsl/dlight.glsl deleted file mode 100644 index 9cb86e45dc..0000000000 --- a/codemp/rd-rend2/glsl/dlight.glsl +++ /dev/null @@ -1,227 +0,0 @@ -/*[Vertex]*/ -in vec3 attr_Position; -in vec2 attr_TexCoord0; -in vec3 attr_Normal; - -struct Light -{ - vec4 origin; - vec3 color; - float radius; -}; - -layout(std140) uniform Lights -{ - int u_NumLights; - Light u_Lights[32]; -}; - -layout(std140) uniform Entity -{ - mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; - vec4 u_LocalLightOrigin; - vec3 u_AmbientLight; - float u_LocalLightRadius; - vec3 _u_DirectedLight; - float _u_FXVolumetricBase; - vec3 u_ModelLightDir; - float u_VertexLerp; - vec3 u_LocalViewOrigin; -}; - -uniform int u_LightIndex; - -layout(std140) uniform ShaderInstance -{ - vec4 u_DeformParams0; - vec4 u_DeformParams1; - float u_Time; - float u_PortalRange; - int u_DeformType; - int u_DeformFunc; -}; - -out vec3 var_Normal; -out vec4 var_LightDirAndRadiusSq; - -#if defined(USE_DEFORM_VERTEXES) -float GetNoiseValue( float x, float y, float z, float t ) -{ - // Variation on the 'one-liner random function'. - // Not sure if this is still 'correctly' random - return fract( sin( dot( - vec4( x, y, z, t ), - vec4( 12.9898, 78.233, 12.9898, 78.233 ) - )) * 43758.5453 ); -} - -float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) -{ - float value = phase + time * frequency; - - switch ( func ) - { - case WF_SIN: - return sin(value * 2.0 * M_PI); - case WF_SQUARE: - return sign(0.5 - fract(value)); - case WF_TRIANGLE: - return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - case WF_SAWTOOTH: - return fract(value); - case WF_INVERSE_SAWTOOTH: - return 1.0 - fract(value); - default: - return 0.0; - } -} - -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - switch ( u_DeformType ) - { - default: - { - return pos; - } - - case DEFORM_BULGE: - { - float bulgeHeight = u_DeformParams0.y; // amplitude - float bulgeWidth = u_DeformParams0.z; // phase - float bulgeSpeed = u_DeformParams0.w; // frequency - - float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); - - return pos + normal * scale * bulgeHeight; - } - - case DEFORM_WAVE: - { - float base = u_DeformParams0.x; - float amplitude = u_DeformParams0.y; - float phase = u_DeformParams0.z; - float frequency = u_DeformParams0.w; - float spread = u_DeformParams1.x; - - float offset = dot( pos.xyz, vec3( spread ) ); - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); - - return pos + normal * (base + scale * amplitude); - } - - case DEFORM_MOVE: - { - float base = u_DeformParams0.x; - float amplitude = u_DeformParams0.y; - float phase = u_DeformParams0.z; - float frequency = u_DeformParams0.w; - vec3 direction = u_DeformParams1.xyz; - - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); - - return pos + direction * (base + scale * amplitude); - } - - case DEFORM_PROJECTION_SHADOW: - { - vec3 ground = u_DeformParams0.xyz; - float groundDist = u_DeformParams0.w; - vec3 lightDir = u_DeformParams1.xyz; - - float d = dot( lightDir, ground ); - - lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; - d = 1.0 / dot( lightDir, ground ); - - vec3 lightPos = lightDir * d; - - return pos - lightPos * dot( pos, ground ) + groundDist; - } - } -} - -vec3 DeformNormal( const in vec3 position, const in vec3 normal ) -{ - if ( u_DeformType != DEFORM_NORMALS ) - { - return normal; - } - - float amplitude = u_DeformParams0.y; - float frequency = u_DeformParams0.w; - - vec3 outNormal = normal; - const float scale = 0.98; - - outNormal.x += amplitude * GetNoiseValue( - position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - outNormal.y += amplitude * GetNoiseValue( - 100.0 * position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - outNormal.z += amplitude * GetNoiseValue( - 200.0 * position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - return outNormal; -} -#endif - -void main() -{ - vec3 position = attr_Position; - vec3 normal = normalize(attr_Normal * 2.0 - vec3(1.0)); - -#if defined(USE_DEFORM_VERTEXES) - position = DeformPosition(position, normal, attr_TexCoord0.st); - normal = DeformNormal(position, normal); -#endif - - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); - - vec3 positionWS = (u_ModelMatrix * vec4(position, 1.0)).xyz; - Light light = u_Lights[u_LightIndex]; - vec3 L = light.origin.xyz - positionWS; - L = (u_ModelMatrix * vec4(L, 0.0)).xyz; - - var_Normal = normalize((u_ModelMatrix * vec4(normal, 0.0)).xyz); - var_LightDirAndRadiusSq = vec4(L, light.radius * light.radius); -} - -/*[Fragment]*/ -uniform vec3 u_DirectedLight; - -in vec3 var_Normal; -in vec4 var_LightDirAndRadiusSq; - -out vec4 out_Color; - -float CalcLightAttenuation(float normDist) -{ - // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) + 1.0; - return clamp(attenuation, 0.0, 1.0); -} - -void main() -{ - float lightDistSq = dot(var_LightDirAndRadiusSq.xyz, var_LightDirAndRadiusSq.xyz); - vec3 N = normalize(var_Normal); - vec3 L = var_LightDirAndRadiusSq.xyz / sqrt(lightDistSq); - - float attenuation = CalcLightAttenuation(var_LightDirAndRadiusSq.w / lightDistSq); - float NL = clamp(dot(N, L), 0.0, 1.0); - - out_Color = vec4(NL * attenuation * u_DirectedLight, 1.0); -} diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index d2787749b1..f0b8e5213b 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -376,7 +376,7 @@ layout(std140) uniform Lights Light u_Lights[32]; }; -uniform int u_LightIndex; +uniform int u_LightMask; uniform sampler2D u_DiffuseMap; #if defined(USE_LIGHTMAP) @@ -763,7 +763,7 @@ vec3 CalcDynamicLightContribution( vec3 position = viewOrigin - viewDir; for ( int i = 0; i < u_NumLights; i++ ) { - if ( ( u_LightIndex & ( 1 << i ) ) == 0 ) { + if ( ( u_LightMask & ( 1 << i ) ) == 0 ) { continue; } Light light = u_Lights[i]; diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index 13deba9afc..833e511019 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -14,7 +14,7 @@ layout(std140) uniform Entity vec3 u_AmbientLight; float u_LocalLightRadius; vec3 u_DirectedLight; - float _u_FXVolumetricBase; + float u_FXVolumetricBase; vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; diff --git a/codemp/rd-rend2/glsl/tonemap.glsl b/codemp/rd-rend2/glsl/tonemap.glsl index 6e0f314873..58162d7ed2 100644 --- a/codemp/rd-rend2/glsl/tonemap.glsl +++ b/codemp/rd-rend2/glsl/tonemap.glsl @@ -17,8 +17,8 @@ void main() uniform sampler2D u_TextureMap; uniform sampler2D u_LevelsMap; uniform vec4 u_Color; -uniform vec2 u_AutoExposureMinMax; -uniform vec3 u_ToneMinAvgMaxLinear; +uniform vec2 u_AutoExposureMinMax; +uniform vec3 u_ToneMinAvgMaxLinear; in vec2 var_TexCoords; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 15c98fdd71..cd0fb30afc 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -96,7 +96,7 @@ static uniformInfo_t uniformsInfo[] = { "u_AmbientLight", GLSL_VEC3, 1 }, { "u_DirectedLight", GLSL_VEC3, 1 }, { "u_Disintegration", GLSL_VEC4, 1 }, - { "u_LightIndex", GLSL_INT, 1 }, + { "u_LightMask", GLSL_INT, 1 }, { "u_FogColorMask", GLSL_VEC4, 1 }, diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index a2ecffcbef..dc18de737b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1332,7 +1332,7 @@ typedef enum UNIFORM_AMBIENTLIGHT, UNIFORM_DIRECTEDLIGHT, UNIFORM_DISINTEGRATION, - UNIFORM_LIGHTINDEX, + UNIFORM_LIGHTMASK, UNIFORM_FOGCOLORMASK, diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 931a36ba5d..19272caf85 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1512,12 +1512,12 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (enableDLights) { - uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, tess.dlightBits); + uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, tess.dlightBits); if (r_dlightMode->integer > 1) samplerBindingsWriter.AddStaticImage(tr.pointShadowArrayImage, TB_SHADOWMAP2); } else - uniformDataWriter.SetUniformInt(UNIFORM_LIGHTINDEX, 0); + uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, 0); CaptureDrawData(input, pStage, index, stage); From a670fde9d53cb20a0e1d3c86284b478743ac54a0 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 2 Oct 2022 01:17:11 +0200 Subject: [PATCH 575/708] Some cleanup --- codemp/rd-rend2/tr_backend.cpp | 7 +++---- codemp/rd-rend2/tr_glsl.cpp | 4 ---- codemp/rd-rend2/tr_local.h | 7 ------- 3 files changed, 3 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 282eeb9d7e..5ce1598b8d 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1454,13 +1454,13 @@ static void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) each surface corresponds to something which has all of its gpu data uploaded */ - int estimatedShaderStages = (backEnd.viewParms.flags & VPF_DEPTHSHADOW) ? 1 : 4; + int estimatedNumShaderStages = (backEnd.viewParms.flags & VPF_DEPTHSHADOW) ? 1 : 4; // Prepare memory for the current render pass void *allocMark = backEndData->perFrameMemory->Mark(); assert(backEndData->currentPass == nullptr); backEndData->currentPass = RB_CreatePass( - *backEndData->perFrameMemory, numDrawSurfs * estimatedShaderStages); + *backEndData->perFrameMemory, numDrawSurfs * estimatedNumShaderStages); // save original time for entity shader offsets float originalTime = backEnd.refdef.floatTime; @@ -2493,8 +2493,7 @@ int RB_GetEntityShaderUboOffset( return uboOffset.offset; hash = (hash + 1) % mapSize; } - if (backEnd.frameUBOsInitialized == qfalse) - ri.Printf(PRINT_ALL, "Failed finding Entity Shader UboOffset! BAD\n"); + return -1; } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index cd0fb30afc..f02804468e 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2299,7 +2299,6 @@ void GLSL_LoadGPUShaders() numGenShaders += GLSL_LoadGPUProgramGeneric(builder, allocator); numLightShaders += GLSL_LoadGPUProgramLightAll(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramFogPass(builder, allocator); - numEtcShaders += GLSL_LoadGPUProgramDLight(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramTextureColor(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDepthFill(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramPShadow(builder, allocator); @@ -2345,9 +2344,6 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < FOGDEF_COUNT; i++) GLSL_DeleteGPUShader(&tr.fogShader[i]); - for ( i = 0; i < DLIGHTDEF_COUNT; i++) - GLSL_DeleteGPUShader(&tr.dlightShader[i]); - for ( i = 0; i < LIGHTDEF_COUNT; i++) GLSL_DeleteGPUShader(&tr.lightallShader[i]); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index dc18de737b..146ddfd22d 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2398,7 +2398,6 @@ typedef struct trGlobals_s { shaderProgram_t genericShader[GENERICDEF_COUNT]; shaderProgram_t textureColorShader; shaderProgram_t fogShader[FOGDEF_COUNT]; - shaderProgram_t dlightShader[DLIGHTDEF_COUNT]; shaderProgram_t lightallShader[LIGHTDEF_COUNT]; shaderProgram_t shadowmapShader; shaderProgram_t pshadowShader; @@ -3441,12 +3440,6 @@ typedef struct clearDepthCommand_s { int commandId; } clearDepthCommand_t; -typedef struct capShadowmapCommand_s { - int commandId; - int map; - int cubeSide; -} capShadowmapCommand_t; - typedef struct convolveCubemapCommand_s { int commandId; cubemap_t *cubemap; From 662cfd87e22b6a7c8a62e7c45cb8ef02e69882e9 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 2 Oct 2022 01:33:48 +0200 Subject: [PATCH 576/708] Fixes for global fog and some work on surface sprites. I just noticed that maps can have brush fogs + global fog, where global fog is applied when there's no brush fog for a surface. Added a permutation to apply both fogs when a surface has both fogs at the same time (brush fog and global fog). Missing feature for now is the ranged fog for the sniper scope. --- codemp/rd-rend2/glsl/fogpass.glsl | 40 ++++++--- codemp/rd-rend2/glsl/generic.glsl | 13 +-- codemp/rd-rend2/glsl/lightall.glsl | 1 + codemp/rd-rend2/glsl/shadowfill.glsl | 1 - codemp/rd-rend2/glsl/shadowvolume.glsl | 2 - codemp/rd-rend2/glsl/surface_sprites.glsl | 103 +++++++++++++++++++++- codemp/rd-rend2/tr_backend.cpp | 32 ++++--- codemp/rd-rend2/tr_bsp.cpp | 63 +++++++++++-- codemp/rd-rend2/tr_glsl.cpp | 11 ++- codemp/rd-rend2/tr_local.h | 15 +++- codemp/rd-rend2/tr_shade.cpp | 55 ++++++++++-- codemp/rd-rend2/tr_surface.cpp | 14 ++- 12 files changed, 292 insertions(+), 58 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 747307793a..2ac76f3443 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -24,7 +24,6 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; layout(std140) uniform ShaderInstance @@ -225,6 +224,15 @@ void main() uniform int u_AlphaTestType; #endif +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; +}; + struct Fog { vec4 plane; @@ -260,15 +268,16 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; +uniform int u_FogIndex; + in vec3 var_WSPosition; out vec4 out_Color; out vec4 out_Glow; -float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) +vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) { bool inFog = dot(viewOrigin, fog.plane.xyz) - fog.plane.w >= 0.0 || !fog.hasPlane; @@ -283,23 +292,34 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) // fogPlane is inverted in tr_bsp for some reason. float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); + // only use this for objects with potentially two contibuting fogs + #if defined(USE_FALLBACK_GLOBAL_FOG) + bool intersects = (t > 0.0 && t <= 1.0); + if (inFog == intersects) + { + Fog globalFog = u_Fogs[u_globalFogIndex]; + + float distToVertex = length(V); + float distFromIntersection = distToVertex - (t * distToVertex); + float z = globalFog.depthToOpaque * mix(distToVertex, distFromIntersection, intersects); + return vec4(globalFog.color.rgb, 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0)); + } + #endif + float distToVertexFromViewOrigin = length(V); - float distToIntersectionFromViewOrigin = max(t, 0.0) * distToVertexFromViewOrigin; + float distToIntersectionFromViewOrigin = t * distToVertexFromViewOrigin; float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); - float distThroughFog = mix(distToVertexFromViewOrigin, distOutsideFog, !inFog); + float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); + return vec4(fog.color.rgb, 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0)); } void main() { Fog fog = u_Fogs[u_FogIndex]; - float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); - out_Color.rgb = fog.color.rgb; - out_Color.a = fogFactor; - + out_Color = CalcFog(u_ViewOrigin, var_WSPosition, fog); #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 34774c25d6..17ddcbdd2e 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -38,7 +38,6 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; #if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) @@ -460,13 +459,13 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; uniform sampler2D u_DiffuseMap; #if defined(USE_ALPHA_TEST) uniform int u_AlphaTestType; #endif +uniform int u_FogIndex; in vec2 var_DiffuseTex; in vec4 var_Color; @@ -493,15 +492,19 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) // fogPlane is inverted in tr_bsp for some reason. float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); + + bool intersects = (t > 0.0 && t <= 1.0); + if (inFog == intersects) + return 0.0; float distToVertexFromViewOrigin = length(V); - float distToIntersectionFromViewOrigin = max(t, 0.0) * distToVertexFromViewOrigin; + float distToIntersectionFromViewOrigin = t * distToVertexFromViewOrigin; float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); - float distThroughFog = mix(distToVertexFromViewOrigin, distOutsideFog, !inFog); + float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); + return 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0); } #endif diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index f0b8e5213b..66a3c1a359 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -336,6 +336,7 @@ layout(std140) uniform Scene { vec4 u_PrimaryLightOrigin; vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; }; diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index 833e511019..e9ec08eea8 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -18,7 +18,6 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; layout(std140) uniform ShaderInstance diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl index f23f1708dc..ccd2cbf2db 100644 --- a/codemp/rd-rend2/glsl/shadowvolume.glsl +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -19,7 +19,6 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; #if defined(USE_SKELETAL_ANIMATION) @@ -75,7 +74,6 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; - int u_FogIndex; }; in vec3 var_Position[]; diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index a9023d63f1..debeb4596b 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -29,6 +29,10 @@ out vec2 var_TexCoords; out float var_Alpha; out vec3 var_Color; +#if defined(USE_FOG) +out vec3 var_WSPosition; +#endif + void main() { vec3 V = u_ViewOrigin - attr_Position; @@ -78,6 +82,9 @@ void main() var_TexCoords = texcoords[gl_VertexID]; var_Color = attr_Color; var_Alpha = 1.0 - fadeScale; + #if defined(USE_FOG) + var_WSPosition = worldPos.xyz; + #endif } /*[Fragment]*/ @@ -87,6 +94,10 @@ in vec2 var_TexCoords; in vec3 var_Color; in float var_Alpha; +#if defined(USE_FOG) +in vec3 var_WSPosition; +#endif + layout(std140) uniform SurfaceSprite { float u_Width; @@ -98,9 +109,71 @@ layout(std140) uniform SurfaceSprite float u_HeightVariance; }; +#if defined(USE_FOG) +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +struct Fog +{ + vec4 plane; + vec4 color; + float depthToOpaque; + bool hasPlane; +}; + +layout(std140) uniform Fogs +{ + int u_NumFogs; + Fog u_Fogs[16]; +}; + +uniform int u_FogIndex; +#endif + +#if defined(ALPHA_TEST) +uniform int u_AlphaTestType; +#endif + out vec4 out_Color; out vec4 out_Glow; +#if defined(USE_FOG) +float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) +{ + bool inFog = dot(viewOrigin, fog.plane.xyz) - fog.plane.w >= 0.0 || !fog.hasPlane; + + // line: x = o + tv + // plane: (x . n) + d = 0 + // intersects: dot(o + tv, n) + d = 0 + // dot(o + tv, n) = -d + // dot(o, n) + t*dot(n, v) = -d + // t = -(d + dot(o, n)) / dot(n, v) + vec3 V = position - viewOrigin; + + // fogPlane is inverted in tr_bsp for some reason. + float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); + + bool intersects = (t > 0.0 && t <= 1.0); + if (inFog == intersects) + return 0.0; + + float distToVertexFromViewOrigin = length(V); + float distToIntersectionFromViewOrigin = t * distToVertexFromViewOrigin; + + float distOutsideFog = max(distToVertexFromViewOrigin - distToIntersectionFromViewOrigin, 0.0); + float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); + + float z = fog.depthToOpaque * distThroughFog; + return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); +} +#endif + void main() { const float alphaTestValue = 0.5; @@ -109,9 +182,33 @@ void main() out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; #if defined(ALPHA_TEST) - if ( out_Color.a < alphaTestValue ) - discard; + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + if (out_Color.a == 0.0) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_LT128) + { + if (out_Color.a >= 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE128) + { + if (out_Color.a < 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + if (out_Color.a < 0.75) + discard; + } #endif - + +#if defined(USE_FOG) + Fog fog = u_Fogs[u_FogIndex]; + float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); + out_Color.rgb = mix(out_Color.rgb, fog.color.rgb, fogFactor); +#endif + out_Glow = vec4(0.0); } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5ce1598b8d..87bddec4e0 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -602,7 +602,12 @@ void RB_BeginDrawingView (void) { qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); } - qglClear( clearBits ); + // dont clear color if we have a skyportal and it has been rendered + if (tr.world && tr.world->skyboxportal == 1 && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) + clearBits &= ~GL_COLOR_BUFFER_BIT; + + if (clearBits > 0) + qglClear( clearBits ); if (backEnd.viewParms.targetFbo == NULL) { @@ -2302,6 +2307,10 @@ static void RB_UpdateSceneConstants(gpuFrame_t *frame) VectorCopy4(backEnd.refdef.sunDir, sceneBlock.primaryLightOrigin); VectorCopy(backEnd.refdef.sunAmbCol, sceneBlock.primaryLightAmbient); VectorCopy(backEnd.refdef.sunCol, sceneBlock.primaryLightColor); + if (tr.world != nullptr) + sceneBlock.globalFogIndex = tr.world->globalFogIndex - 1; + else + sceneBlock.globalFogIndex = -1; tr.sceneUboOffset = RB_AppendConstantsData( frame, &sceneBlock, sizeof(sceneBlock)); @@ -2340,21 +2349,18 @@ static void RB_UpdateFogsConstants(gpuFrame_t *frame) } else { - if (tr.world->globalFog) - fogsBlock.numFogs = 1; - else - fogsBlock.numFogs = tr.world->numfogs - 1; // Don't reserve fog 0 as 'null' + fogsBlock.numFogs = tr.world->numfogs - 1; // Don't reserve fog 0 as 'null' } for (int i = 0; i < fogsBlock.numFogs; ++i) { - const fog_t *fog = tr.world->globalFog ? tr.world->globalFog : tr.world->fogs + i + 1; + const fog_t *fog = tr.world->fogs + i + 1; FogsBlock::Fog *fogData = fogsBlock.fogs + i; VectorCopy4(fog->surface, fogData->plane); VectorCopy4(fog->color, fogData->color); fogData->depthToOpaque = sqrtf(-logf(1.0f / 255.0f)) / fog->parms.depthForOpaque; - fogData->hasPlane = fog == tr.world->globalFog ? qfalse : fog->hasSurface; + fogData->hasPlane = fog->hasSurface; } tr.fogsUboOffset = RB_AppendConstantsData( @@ -2695,14 +2701,6 @@ static void RB_UpdateShaderAndEntityConstants( RB_UpdateEntityMatrixConstants(entityBlock, refEntity); RB_UpdateEntityModelConstants(entityBlock, refEntity); - if (tr.world != nullptr) - { - if (tr.world->globalFog != nullptr) - entityBlock.fogIndex = 0; - else if (drawSurf->fogIndex > 0) - entityBlock.fogIndex = drawSurf->fogIndex - 1; - } - tr.entityUboOffsets[entityNum] = RB_AppendConstantsData( frame, &entityBlock, sizeof(entityBlock)); } @@ -2832,9 +2830,9 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_UpdateCameraConstants(frame); if (backEnd.frameUBOsInitialized == qfalse) { + RB_UpdateFogsConstants(frame); RB_UpdateSceneConstants(frame); RB_UpdateLightsConstants(frame); - RB_UpdateFogsConstants(frame); } RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); @@ -2844,7 +2842,7 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_EndConstantsUpdate(frame); - backEnd.frameUBOsInitialized = qtrue; + backEnd.frameUBOsInitialized = (backEnd.refdef.rdflags & RDF_SKYBOXPORTAL) ? qfalse : qtrue; } diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f2fac33e1b..8e4e138cdd 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -733,6 +733,10 @@ static void ParseFace( const world_t *worldData, dsurface_t *ds, drawVert_t *ver // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; + if (!surf->fogIndex && worldData->globalFog != nullptr) + { + surf->fogIndex = worldData->globalFogIndex; + } // get shader value surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles); @@ -884,6 +888,10 @@ static void ParseMesh ( const world_t *worldData, dsurface_t *ds, drawVert_t *ve // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; + if (!surf->fogIndex && worldData->globalFog != nullptr) + { + surf->fogIndex = worldData->globalFogIndex; + } // get shader value surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); @@ -1002,6 +1010,10 @@ static void ParseTriSurf( const world_t *worldData, dsurface_t *ds, drawVert_t * // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; + if (!surf->fogIndex && worldData->globalFog != nullptr) + { + surf->fogIndex = worldData->globalFogIndex; + } // get shader surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, realLightmapNum, ds->lightmapStyles, ds->vertexStyles ); @@ -1134,6 +1146,10 @@ static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *ve // get fog volume surf->fogIndex = LittleLong( ds->fogNum ) + 1; + if (!surf->fogIndex && worldData->globalFog != nullptr) + { + surf->fogIndex = worldData->globalFogIndex; + } // get shader surf->shader = ShaderForShaderNum( worldData, ds->shaderNum, lightmapsVertex, ds->lightmapStyles, ds->vertexStyles ); @@ -2599,6 +2615,7 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump worldData->numfogs = count + 1; worldData->fogs = (fog_t *)ri.Hunk_Alloc ( worldData->numfogs*sizeof(*out), h_low); worldData->globalFog = nullptr; + worldData->globalFogIndex = -1; out = worldData->fogs + 1; if ( !count ) { @@ -2627,6 +2644,7 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump firstSide = -1; worldData->globalFog = worldData->fogs + i + 1; + worldData->globalFogIndex = i + 1; } else { @@ -2684,7 +2702,7 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump // set the gradient vector sideNum = LittleLong( fogs->visibleSide ); - out->hasSurface = qtrue; + out->hasSurface = (out->originalBrushNumber == -1) ? qfalse : qtrue; if ( sideNum != -1 ) { planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum ); VectorSubtract( vec3_origin, worldData->planes[ planeNum ].normal, out->surface ); @@ -3595,11 +3613,25 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) static std::vector R_CreateSurfaceSpritesVertexData( const srfBspSurface_t *bspSurf, - float density) + float density, + const shaderStage_t *stage) { const srfVert_t *verts = bspSurf->verts; const glIndex_t *indexes = bspSurf->indexes; + vec4_t color = { 1.0, 1.0, 1.0, 1.0 }; + if (stage->rgbGen == CGEN_CONST) + { + color[0] = stage->constantColor[0]; + color[1] = stage->constantColor[1]; + color[2] = stage->constantColor[2]; + } + bool vertexLit = ( + stage->rgbGen == CGEN_VERTEX || + stage->rgbGen == CGEN_EXACT_VERTEX || + stage->rgbGen == CGEN_VERTEX_LIT || + stage->rgbGen == CGEN_EXACT_VERTEX_LIT); + std::vector sprites; sprites.reserve(10000); for ( int i = 0, numIndexes = bspSurf->numIndexes; i < numIndexes; i += 3 ) @@ -3657,9 +3689,15 @@ static std::vector R_CreateSurfaceSpritesVertexData( VectorMA(sprite.position, y, p1, sprite.position); VectorMA(sprite.position, z, p2, sprite.position); - VectorMA(sprite.color, x, c0, sprite.color); - VectorMA(sprite.color, y, c1, sprite.color); - VectorMA(sprite.color, z, c2, sprite.color); + if (vertexLit) + { + VectorMA(sprite.color, x, c0, sprite.color); + VectorMA(sprite.color, y, c1, sprite.color); + VectorMA(sprite.color, z, c2, sprite.color); + VectorScale(sprite.color, tr.identityLight, sprite.color); + } + else + VectorCopy(color, sprite.color); // x*x + y*y = 1.0 // => y*y = 1.0 - x*x @@ -3682,6 +3720,7 @@ static void R_GenerateSurfaceSprites( const srfBspSurface_t *bspSurf, const shader_t *shader, const shaderStage_t *stage, + const int fogIndex, srfSprites_t *out) { const surfaceSprite_t *surfaceSprite = stage->ss; @@ -3693,11 +3732,12 @@ static void R_GenerateSurfaceSprites( uint16_t indices[] = { 0, 1, 2, 0, 2, 3 }; std::vector sprites = - R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density); + R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density, stage); out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; out->numSprites = sprites.size(); + out->fogIndex = fogIndex; // FIXME: Use big preallocated vbo/ibo to store all sprites in one vao out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); @@ -3709,7 +3749,7 @@ static void R_GenerateSurfaceSprites( bundle, stage->stateBits); out->shader->cullType = shader->cullType; out->shader->stages[0]->glslShaderGroup = tr.spriteShader; - out->shader->stages[0]->alphaTestType = stage->alphaTestType; + out->alphaTestType = stage->alphaTestType; out->numAttributes = 3; out->attributes = (vertexAttribute_t *)ri.Hunk_Alloc( @@ -3778,8 +3818,15 @@ static void R_GenerateSurfaceSprites( const world_t *world ) if ( !stage->ss || stage->ss->type == SURFSPRITE_NONE ) continue; + if (j > 0 && (stage->stateBits & GLS_DEPTHFUNC_EQUAL)) + { + ri.Printf(PRINT_WARNING, "depthFunc equal is not supported on surface sprites in rend2. Skipping stage\n"); + surf->numSurfaceSprites -= 1; + continue; + } + srfSprites_t *sprite = surf->surfaceSprites + surfaceSpriteNum; - R_GenerateSurfaceSprites(bspSurf, shader, stage, sprite); + R_GenerateSurfaceSprites(bspSurf, shader, stage, surf->fogIndex, sprite); ++surfaceSpriteNum; } break; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index f02804468e..727aa026d4 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -97,6 +97,7 @@ static uniformInfo_t uniformsInfo[] = { "u_DirectedLight", GLSL_VEC3, 1 }, { "u_Disintegration", GLSL_VEC4, 1 }, { "u_LightMask", GLSL_INT, 1 }, + { "u_FogIndex", GLSL_INT, 1 }, { "u_FogColorMask", GLSL_VEC4, 1 }, @@ -1480,6 +1481,9 @@ static int GLSL_LoadGPUProgramFogPass( attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; } + if (i & FOGDEF_USE_FALLBACK_GLOBAL_FOG) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_FALLBACK_GLOBAL_FOG\n"); + if (i & FOGDEF_USE_ALPHA_TEST) Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); @@ -2181,6 +2185,10 @@ static int GLSL_LoadGPUProgramSurfaceSprites( Q_strcat(extradefines, sizeof(extradefines), "#define FACE_UP\n"); + if ( i & SSDEF_USE_FOG ) + Q_strcat(extradefines, sizeof(extradefines), + "#define USE_FOG\n"); + if ( i & SSDEF_ALPHA_TEST ) Q_strcat(extradefines, sizeof(extradefines), "#define ALPHA_TEST\n"); @@ -2518,7 +2526,8 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderStage_t *pStage = tess.xstages[stage]; int shaderAttribs = 0; - if (tess.fogNum && pStage->adjustColorsForFog) + if ( tess.fogNum && pStage->adjustColorsForFog && + tess.shader->fogPass ) shaderAttribs |= GENERICDEF_USE_FOG; if ( pStage->alphaTestType != ALPHA_TEST_NONE ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 146ddfd22d..8cecf97d1e 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -710,7 +710,7 @@ struct SceneBlock { vec4_t primaryLightOrigin; vec3_t primaryLightAmbient; - float pad0; + int globalFogIndex; vec3_t primaryLightColor; float primaryLightRadius; }; @@ -758,7 +758,7 @@ struct EntityBlock vec3_t modelLightDir; float vertexLerp; vec3_t localViewOrigin; - int fogIndex; + float pad0; // fogIndex; }; struct ShaderInstanceBlock @@ -1168,8 +1168,9 @@ enum FOGDEF_USE_VERTEX_ANIMATION = 0x0002, FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, FOGDEF_USE_ALPHA_TEST = 0x0008, + FOGDEF_USE_FALLBACK_GLOBAL_FOG = 0x0010, - FOGDEF_ALL = 0x000F, + FOGDEF_ALL = 0x001F, FOGDEF_COUNT = FOGDEF_ALL + 1, }; @@ -1209,8 +1210,9 @@ enum SSDEF_FACE_CAMERA = 0x01, SSDEF_ALPHA_TEST = 0x02, SSDEF_FACE_UP = 0x04, + SSDEF_USE_FOG = 0x08, - SSDEF_ALL = 0x07, + SSDEF_ALL = 0x0F, SSDEF_COUNT = SSDEF_ALL + 1 }; @@ -1333,6 +1335,7 @@ typedef enum UNIFORM_DIRECTEDLIGHT, UNIFORM_DISINTEGRATION, UNIFORM_LIGHTMASK, + UNIFORM_FOGINDEX, UNIFORM_FOGCOLORMASK, @@ -1601,6 +1604,9 @@ struct srfSprites_t VBO_t *vbo; IBO_t *ibo; + int fogIndex; + AlphaTestType alphaTestType; + int numAttributes; vertexAttribute_t *attributes; }; @@ -1884,6 +1890,7 @@ typedef struct { int numfogs; fog_t *fogs; const fog_t *globalFog; + int globalFogIndex; vec3_t lightGridOrigin; vec3_t lightGridSize; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 19272caf85..e4e3b4e888 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -940,15 +940,27 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v else if (glState.skeletalAnimation) shaderBits |= FOGDEF_USE_SKELETAL_ANIMATION; + + if (tr.world && tr.world->globalFog && + input->fogNum != tr.world->globalFogIndex && + input->shader->sort != SS_FOG) + shaderBits |= FOGDEF_USE_FALLBACK_GLOBAL_FOG; shaderProgram_t *sp = tr.fogShader + shaderBits; backEnd.pc.c_fogDraws++; + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(sp); + uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); + uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) stateBits |= GLS_DEPTHFUNC_EQUAL; + if (input->shader->polygonOffset == qtrue) + stateBits |= GLS_POLYGON_OFFSET_FILL; + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, @@ -965,6 +977,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v item.renderState.cullType = cullType; item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; + item.uniformData = uniformDataWriter.Finish(frameAllocator); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; DrawItemSetVertexAttributes( @@ -976,6 +989,41 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v const uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); + + // invert fog planes and render global fog into them + if (input->fogNum != tr.world->globalFogIndex && tr.world->globalFogIndex != -1) + { + // only invert render fog planes + if (input->shader->sort != SS_FOG) + return; + if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) + return; + // well, no idea how to handle this case, it's actually wrong + if (cullType == CT_TWO_SIDED) + return; + if (cullType == CT_FRONT_SIDED) + cullType = CT_BACK_SIDED; + else + cullType = CT_FRONT_SIDED; + UniformDataWriter uniformDataWriterBack; + uniformDataWriterBack.Start(sp); + uniformDataWriterBack.SetUniformInt(UNIFORM_FOGINDEX, tr.world->globalFogIndex - 1); + + DrawItem backItem = {}; + memcpy(&backItem, &item, sizeof(item)); + backItem.renderState.cullType = cullType; + backItem.uniformData = uniformDataWriterBack.Finish(frameAllocator); + + DrawItemSetVertexAttributes( + backItem, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + backItem, uniformBlockBindings, frameAllocator); + + RB_FillDrawCommand(backItem.draw, GL_TRIANGLES, 1, input); + + const uint32_t key = RB_CreateSortKey(backItem, 15, input->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, backItem); + } } static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) @@ -1696,14 +1744,11 @@ void RB_StageIteratorGeneric( void ) const fog_t *fog = nullptr; if ( tr.world ) { - if ( tr.world->globalFog ) - fog = tr.world->globalFog; - else if ( tess.fogNum ) - fog = tr.world->fogs + tess.fogNum; + fog = tr.world->fogs + input->fogNum; } if ( fog && tess.shader->fogPass ) { - RB_FogPass( &tess, &vertexArrays ); + RB_FogPass( input, &vertexArrays ); } } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index bdf4911b64..31e206d809 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2155,12 +2155,15 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) const surfaceSprite_t *ss = surf->sprite; uint32_t shaderFlags = 0; - if ( firstStage->alphaTestType != ALPHA_TEST_NONE ) + if ( surf->alphaTestType != ALPHA_TEST_NONE ) shaderFlags |= SSDEF_ALPHA_TEST; if ( ss->type == SURFSPRITE_ORIENTED ) shaderFlags |= SSDEF_FACE_CAMERA; + if ( surf->fogIndex != -1) + shaderFlags |= SSDEF_USE_FOG; + shaderProgram_t *program = programGroup + shaderFlags; assert(program->uniformBlocks & (1 << UNIFORM_BLOCK_SURFACESPRITE)); @@ -2170,6 +2173,12 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) uniformDataWriter.SetUniformMatrix4x4( UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformInt( + UNIFORM_ALPHA_TEST_TYPE, surf->alphaTestType); + + if (surf->fogIndex != -1) + uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, surf->fogIndex - 1); + Allocator& frameAllocator = *backEndData->perFrameMemory; SamplerBindingsWriter samplerBindingsWriter; @@ -2184,7 +2193,8 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { { currentFrameUbo, offset, UNIFORM_BLOCK_SURFACESPRITE }, - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS } }; DrawItem item = {}; From 316d89b6c28815650a93b2cfd5b3f96e00da0fce Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 2 Oct 2022 01:42:25 +0200 Subject: [PATCH 577/708] Add refraction rendering Refractions are all rendered after tonemapping, so they also need to apply the tonemapping. Missing features are: globally set distortion settings, blue tint second stage for cg_sabertrail 2 --- codemp/rd-rend2/glsl/refraction.glsl | 506 +++++++++++++++++++++++++++ codemp/rd-rend2/tr_backend.cpp | 18 +- codemp/rd-rend2/tr_glsl.cpp | 58 ++- codemp/rd-rend2/tr_local.h | 16 +- codemp/rd-rend2/tr_main.cpp | 6 +- codemp/rd-rend2/tr_shade.cpp | 79 ++++- codemp/rd-rend2/tr_shader.cpp | 7 + 7 files changed, 662 insertions(+), 28 deletions(-) create mode 100644 codemp/rd-rend2/glsl/refraction.glsl diff --git a/codemp/rd-rend2/glsl/refraction.glsl b/codemp/rd-rend2/glsl/refraction.glsl new file mode 100644 index 0000000000..635c29e63c --- /dev/null +++ b/codemp/rd-rend2/glsl/refraction.glsl @@ -0,0 +1,506 @@ +/*[Vertex]*/ +in vec3 attr_Position; +in vec3 attr_Normal; + +#if defined(USE_VERTEX_ANIMATION) +in vec3 attr_Position2; +in vec3 attr_Normal2; +#elif defined(USE_SKELETAL_ANIMATION) +in uvec4 attr_BoneIndexes; +in vec4 attr_BoneWeights; +#endif + +in vec4 attr_Color; +in vec2 attr_TexCoord0; + +#if defined(USE_TCGEN) +in vec2 attr_TexCoord1; +#endif + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; +}; + +#if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) +layout(std140) uniform ShaderInstance +{ + vec4 u_DeformParams0; + vec4 u_DeformParams1; + float u_Time; + float u_PortalRange; + int u_DeformType; + int u_DeformFunc; +}; +#endif + +#if defined(USE_SKELETAL_ANIMATION) +layout(std140) uniform Bones +{ + mat3x4 u_BoneMatrices[MAX_G2_BONES]; +}; +#endif + +#if defined(USE_TCMOD) +uniform vec4 u_DiffuseTexMatrix; +uniform vec4 u_DiffuseTexOffTurb; +#endif + +#if defined(USE_TCGEN) +uniform int u_TCGen0; +uniform vec3 u_TCGen0Vector0; +uniform vec3 u_TCGen0Vector1; +#endif + +uniform vec4 u_BaseColor; +uniform vec4 u_VertColor; +uniform vec4 u_Color; + +#if defined(USE_RGBAGEN) +uniform int u_ColorGen; +uniform int u_AlphaGen; +#endif + +out vec2 var_DiffuseTex; +out vec4 var_Color; +out vec4 var_RefractPosR; +out vec4 var_RefractPosG; +out vec4 var_RefractPosB; + +#if defined(USE_DEFORM_VERTEXES) +float GetNoiseValue( float x, float y, float z, float t ) +{ + // Variation on the 'one-liner random function'. + // Not sure if this is still 'correctly' random + return fract( sin( dot( + vec4( x, y, z, t ), + vec4( 12.9898, 78.233, 12.9898, 78.233 ) + )) * 43758.5453 ); +} + +float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) +{ + float value = phase + time * frequency; + + switch ( func ) + { + case WF_SIN: + return sin(value * 2.0 * M_PI); + case WF_SQUARE: + return sign(0.5 - fract(value)); + case WF_TRIANGLE: + return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; + case WF_SAWTOOTH: + return fract(value); + case WF_INVERSE_SAWTOOTH: + return 1.0 - fract(value); + default: + return 0.0; + } +} + +vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) +{ + switch ( u_DeformType ) + { + default: + { + return pos; + } + + case DEFORM_BULGE: + { + float bulgeHeight = u_DeformParams0.y; // amplitude + float bulgeWidth = u_DeformParams0.z; // phase + float bulgeSpeed = u_DeformParams0.w; // frequency + + float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + + return pos + normal * scale * bulgeHeight; + } + + case DEFORM_BULGE_UNIFORM: + { + float bulgeHeight = u_DeformParams0.y; // amplitude + + return pos + normal * bulgeHeight; + } + + case DEFORM_WAVE: + { + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + float spread = u_DeformParams1.x; + + float offset = dot( pos.xyz, vec3( spread ) ); + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + + return pos + normal * (base + scale * amplitude); + } + + case DEFORM_MOVE: + { + float base = u_DeformParams0.x; + float amplitude = u_DeformParams0.y; + float phase = u_DeformParams0.z; + float frequency = u_DeformParams0.w; + vec3 direction = u_DeformParams1.xyz; + + float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + + return pos + direction * (base + scale * amplitude); + } + } +} + +vec3 DeformNormal( const in vec3 position, const in vec3 normal ) +{ + if ( u_DeformType != DEFORM_NORMALS ) + { + return normal; + } + + float amplitude = u_DeformParams0.y; + float frequency = u_DeformParams0.w; + + vec3 outNormal = normal; + const float scale = 0.98; + + outNormal.x += amplitude * GetNoiseValue( + position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.y += amplitude * GetNoiseValue( + 100.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + outNormal.z += amplitude * GetNoiseValue( + 200.0 * position.x * scale, + position.y * scale, + position.z * scale, + u_Time * frequency ); + + return outNormal; +} +#endif + +#if defined(USE_TCGEN) +vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 TCGenVector1) +{ + vec2 tex = attr_TexCoord0.st; + + if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3) + { + tex = attr_TexCoord1.st; + } + else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) + { + vec3 viewer = normalize(u_LocalViewOrigin - position); + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; + } + else if (TCGen == TCGEN_VECTOR) + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + + return tex; +} +#endif + +#if defined(USE_TCMOD) +vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) +{ + float amplitude = offTurb.z; + float phase = offTurb.w * 2.0 * M_PI; + vec2 st2; + st2.x = st.x * texMatrix.x + (st.y * texMatrix.z + offTurb.x); + st2.y = st.x * texMatrix.y + (st.y * texMatrix.w + offTurb.y); + + vec2 offsetPos = vec2(position.x + position.z, position.y); + + vec2 texOffset = sin(offsetPos * (2.0 * M_PI / 1024.0) + vec2(phase)); + + return st2 + texOffset * amplitude; +} +#endif + +#if defined(USE_RGBAGEN) +vec4 CalcColor(vec3 position, vec3 normal) +{ + vec4 color = u_VertColor * attr_Color + u_BaseColor; + + if (u_ColorGen == CGEN_LIGHTING_DIFFUSE) + { + float incoming = clamp(dot(normal, u_ModelLightDir), 0.0, 1.0); + + color.rgb = clamp(u_DirectedLight * incoming + u_AmbientLight, 0.0, 1.0); + } + + vec3 viewer = u_LocalViewOrigin - position; + + if (u_AlphaGen == AGEN_LIGHTING_SPECULAR) + { + vec3 lightDir = normalize(vec3(-960.0, 1980.0, 96.0) - position); + vec3 reflected = -reflect(lightDir, normal); + + color.a = clamp(dot(reflected, normalize(viewer)), 0.0, 1.0); + color.a *= color.a; + color.a *= color.a; + } + else if (u_AlphaGen == AGEN_PORTAL) + { + color.a = clamp(length(viewer) / u_PortalRange, 0.0, 1.0); + } + + return color; +} +#endif + +#if defined(USE_SKELETAL_ANIMATION) +mat4x3 GetBoneMatrix(uint index) +{ + mat3x4 bone = u_BoneMatrices[index]; + return mat4x3( + bone[0].x, bone[1].x, bone[2].x, + bone[0].y, bone[1].y, bone[2].y, + bone[0].z, bone[1].z, bone[2].z, + bone[0].w, bone[1].w, bone[2].w); +} +#endif + +const float etaR = 1.0 / 1.35; +const float etaG = 1.0 / 1.20; +const float etaB = 1.0 / 1.05; + +void main() +{ +#if defined(USE_VERTEX_ANIMATION) + vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); + vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + normal = normalize(normal - vec3(0.5)); +#elif defined(USE_SKELETAL_ANIMATION) + mat4x3 influence = + GetBoneMatrix(attr_BoneIndexes[0]) * attr_BoneWeights[0] + + GetBoneMatrix(attr_BoneIndexes[1]) * attr_BoneWeights[1] + + GetBoneMatrix(attr_BoneIndexes[2]) * attr_BoneWeights[2] + + GetBoneMatrix(attr_BoneIndexes[3]) * attr_BoneWeights[3]; + + vec3 position = influence * vec4(attr_Position, 1.0); + vec3 normal = normalize(influence * vec4(attr_Normal - vec3(0.5), 0.0)); +#else + vec3 position = attr_Position; + vec3 normal = attr_Normal * 2.0 - vec3(1.0); +#endif + +#if defined(USE_DEFORM_VERTEXES) + position = DeformPosition(position, normal, attr_TexCoord0.st); + normal = DeformNormal( position, normal ); +#endif + + gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + +#if defined(USE_TCGEN) + vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); +#else + vec2 tex = attr_TexCoord0.st; +#endif + +#if defined(USE_TCMOD) + var_DiffuseTex = ModTexCoords(tex, position, u_DiffuseTexMatrix, u_DiffuseTexOffTurb); +#else + var_DiffuseTex = tex; +#endif + + if ( u_FXVolumetricBase >= 0.0 ) + { + vec3 viewForward = u_ViewForward.xyz; + float d = clamp(dot(normalize(viewForward), normalize(normal)), 0.0, 1.0); + d = d * d; + d = d * d; + + var_Color = vec4(u_FXVolumetricBase * (1.0 - d)); + } + else + { +#if defined(USE_RGBAGEN) + var_Color = CalcColor(position, normal); +#else + var_Color = u_VertColor * attr_Color + u_BaseColor; +#endif + } + + vec3 ws_Position = mat3(u_ModelMatrix) * position; + vec3 ws_Normal = normalize(mat3(u_ModelMatrix) * normal); + vec3 ws_ViewDir = (u_ViewForward + u_ViewLeft * -gl_Position.x) + u_ViewUp * gl_Position.y; + + #if defined(USE_TCMOD) + float distance = u_Color.a * clamp(1.0 - distance(tex, var_DiffuseTex), 0.0, 1.0); + #else + float distance = u_Color.a; + #endif + + mat3 inverseModel = inverse(mat3(u_ModelMatrix)); + + vec3 refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaR)); + vec3 new_pos = (distance * refraction_vec) + ws_Position; + var_RefractPosR = vec4(inverseModel * new_pos, 1.0); + var_RefractPosR = u_ModelViewProjectionMatrix * var_RefractPosR; + + refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaG)); + new_pos = (distance * refraction_vec) + ws_Position; + var_RefractPosG = vec4(inverseModel * new_pos, 1.0); + var_RefractPosG = u_ModelViewProjectionMatrix * var_RefractPosG; + + refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaB)); + new_pos = (distance * refraction_vec) + ws_Position; + var_RefractPosB = vec4(inverseModel * new_pos, 1.0); + var_RefractPosB = u_ModelViewProjectionMatrix * var_RefractPosB; +} + + +/*[Fragment]*/ + +layout(std140) uniform Camera +{ + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + +layout(std140) uniform Entity +{ + mat4 u_ModelMatrix; + mat4 u_ModelViewProjectionMatrix; + vec4 u_LocalLightOrigin; + vec3 u_AmbientLight; + float u_LocalLightRadius; + vec3 u_DirectedLight; + float u_FXVolumetricBase; + vec3 u_ModelLightDir; + float u_VertexLerp; + vec3 u_LocalViewOrigin; +}; + +uniform sampler2D u_TextureMap; +uniform sampler2D u_LevelsMap; +uniform sampler2D u_ScreenDepthMap; +uniform vec4 u_Color; +uniform vec2 u_AutoExposureMinMax; +uniform vec3 u_ToneMinAvgMaxLinear; + +#if defined(USE_ALPHA_TEST) +uniform int u_AlphaTestType; +#endif + +in vec2 var_DiffuseTex; +in vec4 var_Color; +in vec4 var_RefractPosR; +in vec4 var_RefractPosG; +in vec4 var_RefractPosB; + +out vec4 out_Color; + +vec3 LinearTosRGB( in vec3 color ) +{ + vec3 lo = 12.92 * color; + vec3 hi = 1.055 * pow(color, vec3(0.4166666)) - 0.055; + return mix(lo, hi, greaterThanEqual(color, vec3(0.0031308))); +} + +vec3 FilmicTonemap(vec3 x) +{ + const float SS = 0.22; // Shoulder Strength + const float LS = 0.30; // Linear Strength + const float LA = 0.10; // Linear Angle + const float TS = 0.20; // Toe Strength + const float TAN = 0.01; // Toe Angle Numerator + const float TAD = 0.30; // Toe Angle Denominator + + vec3 SSxx = SS * x * x; + vec3 LSx = LS * x; + vec3 LALSx = LSx * LA; + + return ((SSxx + LALSx + TS * TAN) / (SSxx + LSx + TS * TAD)) - TAN / TAD; +} + +void main() +{ + vec2 texR = (var_RefractPosR.xy / var_RefractPosR.w) * 0.5 + 0.5; + vec2 texG = (var_RefractPosG.xy / var_RefractPosG.w) * 0.5 + 0.5; + vec2 texB = (var_RefractPosB.xy / var_RefractPosB.w) * 0.5 + 0.5; + + vec4 color; + color.r = texture(u_TextureMap, texR).r; + color.g = texture(u_TextureMap, texG).g; + color.b = texture(u_TextureMap, texB).b; + color.a = var_Color.a; + color.rgb *= var_Color.rgb; + color.rgb *= u_Color.rgb; + + vec3 minAvgMax = texture(u_LevelsMap, texG).rgb; + vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); + float avgLum = exp2(logMinAvgMaxLum.y); + +#if defined(USE_ALPHA_TEST) + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + if (color.a == 0.0) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_LT128) + { + if (color.a >= 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE128) + { + if (color.a < 0.5) + discard; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + if (color.a < 0.75) + discard; + } +#endif + + color.rgb *= u_ToneMinAvgMaxLinear.y / avgLum; + color.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x)); + + vec3 fWhite = 1.0 / FilmicTonemap(vec3(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x)); + color.rgb = FilmicTonemap(color.rgb) * fWhite; + + #if defined(USE_LINEAR_LIGHT) + color.rgb = LinearTosRGB(color.rgb); + #endif + + out_Color = clamp(color, 0.0, 1.0); +} diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 87bddec4e0..87adfa5ce9 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1339,12 +1339,13 @@ static void RB_SubmitDrawSurfs( fogNum = drawSurf->fogIndex; dlighted = drawSurf->dlightBits; - if ( shader == oldShader && + if ( shader == oldShader && fogNum == oldFogNum && postRender == oldPostRender && cubemapIndex == oldCubemapIndex && entityNum == oldEntityNum && - dlighted == oldDlighted ) + dlighted == oldDlighted && + backEnd.framePostProcessed == shader->useDistortion ) { // fast path, same as previous sort backEnd.currentDrawSurfIndex = i; @@ -1385,6 +1386,12 @@ static void RB_SubmitDrawSurfs( oldEntityNum = entityNum; } + qboolean isDistortionShader = (qboolean) + ((shader->useDistortion == qtrue) || (backEnd.currentEntity && backEnd.currentEntity->e.renderfx & RF_DISTORTION)); + + if (backEnd.framePostProcessed != isDistortionShader) + continue; + backEnd.currentDrawSurfIndex = i; // ugly hack for now... @@ -3183,6 +3190,9 @@ const void *RB_PostProcess(const void *data) FBO_Blit(srcFbo, srcBox, NULL, NULL, dstBox, NULL, color, 0); } + + // Copy depth buffer to the backbuffer for depth culling refractive surfaces + FBO_FastBlit(tr.renderFbo, srcBox, NULL, dstBox, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST); } if (r_drawSunRays->integer) @@ -3266,6 +3276,10 @@ const void *RB_PostProcess(const void *data) } backEnd.framePostProcessed = qtrue; + FBO_Bind(NULL); + RB_RenderDrawSurfList( + backEnd.refdef.drawSurfs + backEnd.refdef.fistDrawSurf, + backEnd.refdef.numDrawSurfs - tr.refdef.fistDrawSurf); return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 727aa026d4..38d448f88f 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1502,40 +1502,66 @@ static int GLSL_LoadGPUProgramFogPass( return numPrograms; } -static int GLSL_LoadGPUProgramDLight( +static int GLSL_LoadGPUProgramRefraction( ShaderProgramBuilder& builder, - Allocator& scratchAlloc ) + Allocator& scratchAlloc) { int numPrograms = 0; Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); char extradefines[1200]; const GPUProgramDesc *programDesc = - LoadProgramSource("dlight", allocator, fallback_dlightProgram); - for ( int i = 0; i < DLIGHTDEF_COUNT; i++ ) + LoadProgramSource("refraction", allocator, fallback_refractionProgram); + for (int i = 0; i < REFRACTIONDEF_COUNT; i++) { - uint32_t attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0; + uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0 | ATTR_NORMAL | ATTR_COLOR; extradefines[0] = '\0'; - if (i & DLIGHTDEF_USE_DEFORM_VERTEXES) + if (i & REFRACTIONDEF_USE_DEFORM_VERTEXES) Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); - if (i & DLIGHTDEF_USE_ALPHA_TEST) + if (i & REFRACTIONDEF_USE_TCGEN_AND_TCMOD) + { + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCGEN\n"); + Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); + } + + if (i & REFRACTIONDEF_USE_VERTEX_ANIMATION) + { + Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); + attribs |= ATTR_POSITION2 | ATTR_NORMAL2; + } + + if (i & REFRACTIONDEF_USE_SKELETAL_ANIMATION) + { + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); + attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; + } + + if (i & REFRACTIONDEF_USE_RGBAGEN) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_RGBAGEN\n"); + + if (i & REFRACTIONDEF_USE_ALPHA_TEST) Q_strcat(extradefines, sizeof(extradefines), "#define USE_ALPHA_TEST\n"); - if (!GLSL_LoadGPUShader(builder, &tr.dlightShader[i], "dlight", attribs, NO_XFB_VARS, - extradefines, *programDesc)) + if (i & REFRACTIONDEF_USE_SRGB_TRANSFORM) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_LINEAR_LIGHT\n"); + + if (!GLSL_LoadGPUShader(builder, &tr.refractionShader[i], "refraction", attribs, NO_XFB_VARS, + extradefines, *programDesc)) { - ri.Error(ERR_FATAL, "Could not load dlight shader!"); + ri.Error(ERR_FATAL, "Could not load generic shader!"); } - GLSL_InitUniforms(&tr.dlightShader[i]); + GLSL_InitUniforms(&tr.refractionShader[i]); - qglUseProgram(tr.dlightShader[i].program); - GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + qglUseProgram(tr.refractionShader[i].program); + GLSL_SetUniformInt(&tr.refractionShader[i], UNIFORM_TEXTUREMAP, TB_COLORMAP); + GLSL_SetUniformInt(&tr.refractionShader[i], UNIFORM_LEVELSMAP, TB_LEVELSMAP); + GLSL_SetUniformInt(&tr.refractionShader[i], UNIFORM_SCREENDEPTHMAP, TB_SHADOWMAP); qglUseProgram(0); - GLSL_FinishGPUShader(&tr.dlightShader[i]); + GLSL_FinishGPUShader(&tr.refractionShader[i]); ++numPrograms; } @@ -2307,6 +2333,7 @@ void GLSL_LoadGPUShaders() numGenShaders += GLSL_LoadGPUProgramGeneric(builder, allocator); numLightShaders += GLSL_LoadGPUProgramLightAll(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramFogPass(builder, allocator); + numEtcShaders += GLSL_LoadGPUProgramRefraction(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramTextureColor(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDepthFill(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramPShadow(builder, allocator); @@ -2347,6 +2374,9 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < GENERICDEF_COUNT; i++) GLSL_DeleteGPUShader(&tr.genericShader[i]); + for (i = 0; i < REFRACTIONDEF_COUNT; i++) + GLSL_DeleteGPUShader(&tr.refractionShader[i]); + GLSL_DeleteGPUShader(&tr.textureColorShader); for ( i = 0; i < FOGDEF_COUNT; i++) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8cecf97d1e..ff5cf4604a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -983,6 +983,7 @@ typedef struct shader_s { void (*optimalStageIteratorFunc)( void ); qboolean isHDRLit; qboolean useSimpleDepthShader; + qboolean useDistortion; float clampTime; // time this shader is clamped to float timeOffset; // current time offset for this shader @@ -1176,11 +1177,16 @@ enum enum { - DLIGHTDEF_USE_DEFORM_VERTEXES = 0x0001, - DLIGHTDEF_USE_ALPHA_TEST = 0x0002, + REFRACTIONDEF_USE_DEFORM_VERTEXES = 0x0001, + REFRACTIONDEF_USE_TCGEN_AND_TCMOD = 0x0002, + REFRACTIONDEF_USE_VERTEX_ANIMATION = 0x0004, + REFRACTIONDEF_USE_RGBAGEN = 0x0008, + REFRACTIONDEF_USE_SKELETAL_ANIMATION = 0x0020, + REFRACTIONDEF_USE_ALPHA_TEST = 0x0040, + REFRACTIONDEF_USE_SRGB_TRANSFORM = 0x0080, - DLIGHTDEF_ALL = 0x0003, - DLIGHTDEF_COUNT = DLIGHTDEF_ALL + 1, + REFRACTIONDEF_ALL = 0x00FF, + REFRACTIONDEF_COUNT = REFRACTIONDEF_ALL + 1, }; enum @@ -1431,6 +1437,7 @@ typedef struct { int numPolys; struct srfPoly_s *polys; + int fistDrawSurf; int numDrawSurfs; struct drawSurf_s *drawSurfs; @@ -2403,6 +2410,7 @@ typedef struct trGlobals_s { // shaderProgram_t splashScreenShader; shaderProgram_t genericShader[GENERICDEF_COUNT]; + shaderProgram_t refractionShader[REFRACTIONDEF_COUNT]; shaderProgram_t textureColorShader; shaderProgram_t fogShader[FOGDEF_COUNT]; shaderProgram_t lightallShader[LIGHTDEF_COUNT]; diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 9c02daaab2..35efdcf243 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2118,7 +2118,6 @@ or a mirror / remote location ================ */ void R_RenderView (viewParms_t *parms) { - int firstDrawSurf; if ( parms->viewportWidth <= 0 || parms->viewportHeight <= 0 ) { return; @@ -2130,8 +2129,7 @@ void R_RenderView (viewParms_t *parms) { tr.viewParms.frameSceneNum = tr.frameSceneNum; tr.viewParms.frameCount = tr.frameCount; - firstDrawSurf = tr.refdef.numDrawSurfs; - + tr.refdef.fistDrawSurf = tr.refdef.numDrawSurfs; // set viewParms.world R_RotateForViewer(&tr.ori, &tr.viewParms); @@ -2139,7 +2137,7 @@ void R_RenderView (viewParms_t *parms) { R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); - R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf ); + R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + tr.refdef.fistDrawSurf, tr.refdef.numDrawSurfs - tr.refdef.fistDrawSurf); // draw main system development information (surface outlines, etc) R_DebugGraphics(); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index e4e3b4e888..08709a8b56 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1050,11 +1050,47 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) return vertexAttribs; } -static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stage, shaderProgram_t *glslShaderGroup, bool useAlphaTestGE192 ) +static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stage, shaderProgram_t *glslShaderGroup, bool useAlphaTestGE192, bool forceRefraction ) { uint32_t index; shaderProgram_t *result = nullptr; + if (forceRefraction) + { + index = 0; + if (tess.shader->numDeforms && !ShaderRequiresCPUDeforms(tess.shader)) + { + index |= REFRACTIONDEF_USE_DEFORM_VERTEXES; + } + + if (glState.vertexAnimation) + { + index |= REFRACTIONDEF_USE_VERTEX_ANIMATION; + } + else if (glState.skeletalAnimation) + { + index |= REFRACTIONDEF_USE_SKELETAL_ANIMATION; + } + + if (stage->bundle[0].tcGen != TCGEN_TEXTURE || (stage->bundle[0].numTexMods)) + index |= REFRACTIONDEF_USE_TCGEN_AND_TCMOD; + + if (!useAlphaTestGE192) + { + if (stage->alphaTestType != ALPHA_TEST_NONE) + index |= REFRACTIONDEF_USE_TCGEN_AND_TCMOD | REFRACTIONDEF_USE_ALPHA_TEST; + } + else + { + index |= REFRACTIONDEF_USE_ALPHA_TEST; + } + + if (tr.hdrLighting == qtrue) + index |= REFRACTIONDEF_USE_SRGB_TRANSFORM; + + return &tr.refractionShader[index]; + } + if (backEnd.depthFill) { if (glslShaderGroup == tr.lightallShader) @@ -1250,6 +1286,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays alphaGen_t forceAlphaGen = AGEN_IDENTITY; int index = 0; bool useAlphaTestGE192 = false; + bool forceRefraction = false; vec4_t disintegrationInfo; if ( !pStage ) @@ -1293,6 +1330,13 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays forceRGBGen = CGEN_ENTITY; } + // only force blend on the internal distortion shader + if (input->shader == tr.distortionShader) + stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + + if (input->shader->useDistortion == qtrue || backEnd.currentEntity->e.renderfx & RF_DISTORTION) + forceRefraction = true; + if ( backEnd.currentEntity->e.renderfx & RF_FORCE_ENT_ALPHA ) { stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; @@ -1310,7 +1354,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (backEnd.viewParms.flags & VPF_POINTSHADOW) stateBits |= GLS_POLYGON_OFFSET_FILL; - sp = SelectShaderProgram(stage, pStage, pStage->glslShaderGroup, useAlphaTestGE192); + sp = SelectShaderProgram(stage, pStage, pStage->glslShaderGroup, useAlphaTestGE192, forceRefraction); assert(sp); uniformDataWriter.Start(sp); @@ -1389,6 +1433,18 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (backEnd.currentEntity->e.renderfx & (RF_DISINTEGRATE1 | RF_DISINTEGRATE2)) uniformDataWriter.SetUniformVec4(UNIFORM_DISINTEGRATION, disintegrationInfo); + if (forceRefraction) + { + vec4_t color; + color[0] = + color[1] = + color[2] = powf(2.0f, r_cameraExposure->value); + color[3] = 10.0f; + uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, color); + uniformDataWriter.SetUniformVec2(UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax); + uniformDataWriter.SetUniformVec3(UNIFORM_TONEMINAVGMAXLINEAR, tr.refdef.toneMinAvgMaxLinear); + } + ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); @@ -1423,7 +1479,22 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays && !(tess.shader->surfaceFlags & (SURF_NODLIGHT | SURF_SKY)) && pStage->rgbGen != CGEN_LIGHTMAPSTYLE ); - if ( backEnd.depthFill ) + if (forceRefraction) + { + FBO_t *srcFbo = tr.renderFbo; + if (tr.msaaResolveFbo) + srcFbo = tr.msaaResolveFbo; + + samplerBindingsWriter.AddStaticImage(srcFbo->colorImage[0], TB_COLORMAP); + samplerBindingsWriter.AddStaticImage(tr.renderDepthImage, TB_SHADOWMAP); + qboolean autoExposure = (qboolean)(r_autoExposure->integer || r_forceAutoExposure->integer); + + if (autoExposure) + samplerBindingsWriter.AddStaticImage(tr.calcLevelsImage, TB_LEVELSMAP); + else + samplerBindingsWriter.AddStaticImage(tr.fixedLevelsImage, TB_LEVELSMAP); + } + else if ( backEnd.depthFill ) { if (pStage->alphaTestType == ALPHA_TEST_NONE) samplerBindingsWriter.AddStaticImage(tr.whiteImage, 0); @@ -1583,7 +1654,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays DrawItem item = {}; item.renderState.stateBits = stateBits; - item.renderState.cullType = cullType; + item.renderState.cullType = forceRefraction ? CT_TWO_SIDED : cullType; item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); item.program = sp; item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index c9ccecce05..e07ad00fdf 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -2702,6 +2702,12 @@ static qboolean ParseShader( const char **text ) shader.noPicMip = qtrue; continue; } + // refractive surface + else if ( !Q_stricmp(token, "refractive" ) ) + { + shader.useDistortion = qtrue; + continue; + } // no picmip adjustment else if ( !Q_stricmp( token, "nopicmip" ) ) { @@ -4983,6 +4989,7 @@ static void CreateInternalShaders( void ) { shader.sort = SS_BLEND0; shader.defaultShader = qfalse; tr.distortionShader = FinishShader(); + tr.distortionShader->useDistortion = qtrue; shader.defaultShader = qtrue; // weather shader placeholder From 048e02a6562785e594763996b1e30ddd1f88742d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 2 Oct 2022 12:16:03 +0200 Subject: [PATCH 578/708] Don't instance surface sprites Instancing in this case starves the GPU because instancing only 4 vertices will result in only ~12% GPU utilization. --- codemp/rd-rend2/glsl/surface_sprites.glsl | 6 +++--- codemp/rd-rend2/tr_bsp.cpp | 25 +++++++++++++++++------ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_surface.cpp | 4 ++-- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index debeb4596b..faed83e7a4 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -67,7 +67,7 @@ void main() vec2(0.0, 1.0) ); - vec3 offset = offsets[gl_VertexID]; + vec3 offset = offsets[gl_VertexID % 4]; #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); @@ -79,7 +79,7 @@ void main() vec4 worldPos = vec4(attr_Position + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; - var_TexCoords = texcoords[gl_VertexID]; + var_TexCoords = texcoords[gl_VertexID % 4]; var_Color = attr_Color; var_Alpha = 1.0 - fadeScale; #if defined(USE_FOG) @@ -170,7 +170,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); + return 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0); } #endif diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 8e4e138cdd..69a6c25002 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3710,6 +3710,9 @@ static std::vector R_CreateSurfaceSpritesVertexData( // We have 4 copies for each corner of the quad sprites.push_back(sprite); + sprites.push_back(sprite); + sprites.push_back(sprite); + sprites.push_back(sprite); } } } @@ -3730,19 +3733,29 @@ static void R_GenerateSurfaceSprites( for ( int i = 0; bundle->image[i]; ++i ) hash = UpdateHash(bundle->image[i]->imgName, hash); - uint16_t indices[] = { 0, 1, 2, 0, 2, 3 }; std::vector sprites = R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density, stage); + int numSprites = sprites.size() / 4; + int numIndices = numSprites * 6; + uint16_t *indices = (uint16_t*)Z_Malloc(numIndices * sizeof(uint16_t), TAG_BSP); + for (int i = 0; i < numIndices; i++) + { + const uint16_t face_indices[] = { 0, 1, 2, 0, 2, 3 }; + int vert_index = face_indices[i % 6] + int(i / 6)*4; + indices[i] = vert_index; + } + out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; - out->numSprites = sprites.size(); + out->numSprites = numSprites; + out->numIndices = numIndices; out->fogIndex = fogIndex; // FIXME: Use big preallocated vbo/ibo to store all sprites in one vao out->vbo = R_CreateVBO((byte *)sprites.data(), sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); - out->ibo = R_CreateIBO((byte *)indices, sizeof(indices), VBO_USAGE_STATIC); + out->ibo = R_CreateIBO((byte *)indices, numIndices * sizeof(uint16_t), VBO_USAGE_STATIC); // FIXME: Need a better way to handle this. out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), @@ -3763,7 +3776,7 @@ static void R_GenerateSurfaceSprites( out->attributes[0].normalize = GL_FALSE; out->attributes[0].stride = sizeof(sprite_t); out->attributes[0].offset = offsetof(sprite_t, position); - out->attributes[0].stepRate = 1; + out->attributes[0].stepRate = 0; out->attributes[1].vbo = out->vbo; out->attributes[1].index = ATTR_INDEX_NORMAL; @@ -3773,7 +3786,7 @@ static void R_GenerateSurfaceSprites( out->attributes[1].normalize = GL_FALSE; out->attributes[1].stride = sizeof(sprite_t); out->attributes[1].offset = offsetof(sprite_t, normal); - out->attributes[1].stepRate = 1; + out->attributes[1].stepRate = 0; out->attributes[2].vbo = out->vbo; out->attributes[2].index = ATTR_INDEX_COLOR; @@ -3783,7 +3796,7 @@ static void R_GenerateSurfaceSprites( out->attributes[2].normalize = GL_FALSE; out->attributes[2].stride = sizeof(sprite_t); out->attributes[2].offset = offsetof(sprite_t, color); - out->attributes[2].stepRate = 1; + out->attributes[2].stepRate = 0; } static void R_GenerateSurfaceSprites( const world_t *world ) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index ff5cf4604a..e95adede22 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1608,6 +1608,7 @@ struct srfSprites_t shader_t *shader; const surfaceSprite_t *sprite; int numSprites; + int numIndices; VBO_t *vbo; IBO_t *ibo; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 31e206d809..639d62c26f 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2216,10 +2216,10 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) item.draw.type = DRAW_COMMAND_INDEXED; item.draw.primitiveType = GL_TRIANGLES; - item.draw.numInstances = surf->numSprites; + item.draw.numInstances = 1; item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT; item.draw.params.indexed.firstIndex = 0; - item.draw.params.indexed.numIndices = 6; + item.draw.params.indexed.numIndices = surf->numIndices; tess.externalIBO = surf->ibo; From d668b97043ec063585ac35fd9e56550ec7aa6b6c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 5 Oct 2022 19:44:50 +0200 Subject: [PATCH 579/708] Little oversight regarding fog --- codemp/rd-rend2/glsl/fogpass.glsl | 4 ++-- codemp/rd-rend2/glsl/generic.glsl | 2 +- codemp/rd-rend2/glsl/surface_sprites.glsl | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 2ac76f3443..630845410e 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -302,7 +302,7 @@ vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float distToVertex = length(V); float distFromIntersection = distToVertex - (t * distToVertex); float z = globalFog.depthToOpaque * mix(distToVertex, distFromIntersection, intersects); - return vec4(globalFog.color.rgb, 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0)); + return vec4(globalFog.color.rgb, 1.0 - clamp(exp(-(z * z)), 0.0, 1.0)); } #endif @@ -313,7 +313,7 @@ vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return vec4(fog.color.rgb, 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0)); + return vec4(fog.color.rgb, 1.0 - clamp(exp(-(z * z)), 0.0, 1.0)); } void main() diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 17ddcbdd2e..e06ad74c0f 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -504,7 +504,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0); + return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } #endif diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index faed83e7a4..e229248e89 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -170,7 +170,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float distThroughFog = mix(distOutsideFog, distToVertexFromViewOrigin, inFog); float z = fog.depthToOpaque * distThroughFog; - return 1.0 - clamp(exp2(-(z * z)), 0.0, 1.0); + return 1.0 - clamp(exp(-(z * z)), 0.0, 1.0); } #endif From c6c0b89b2a886e8b157ba99daf89306c8fd89db6 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 6 Oct 2022 05:32:56 +0200 Subject: [PATCH 580/708] Fix glass shattering --- codemp/rd-rend2/tr_init.cpp | 5 +- codemp/rd-rend2/tr_world.cpp | 94 ++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 2de30277f9..efa511fb17 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -2017,7 +2017,8 @@ void RE_SetLightStyle(int style, int color) } } -void stub_RE_GetBModelVerts (int bModel, vec3_t *vec, float *normal) {} +void RE_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal); + void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} static void RE_SetRefractionProperties ( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate ) { } @@ -2131,7 +2132,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { re.GetLightStyle = RE_GetLightStyle; re.SetLightStyle = RE_SetLightStyle; - re.GetBModelVerts = stub_RE_GetBModelVerts; + re.GetBModelVerts = RE_GetBModelVerts; re.SetRangedFog = RE_SetRangedFog; re.SetRefractionProperties = RE_SetRefractionProperties; diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 88079a39c2..005e77fe5d 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -407,6 +407,100 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { } } +float GetQuadArea(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4) +{ + vec3_t vec1, vec2, dis1, dis2; + + // Get area of tri1 + VectorSubtract(v1, v2, vec1); + VectorSubtract(v1, v4, vec2); + CrossProduct(vec1, vec2, dis1); + VectorScale(dis1, 0.25f, dis1); + + // Get area of tri2 + VectorSubtract(v3, v2, vec1); + VectorSubtract(v3, v4, vec2); + CrossProduct(vec1, vec2, dis2); + VectorScale(dis2, 0.25f, dis2); + + // Return addition of disSqr of each tri area + return (dis1[0] * dis1[0] + dis1[1] * dis1[1] + dis1[2] * dis1[2] + + dis2[0] * dis2[0] + dis2[1] * dis2[1] + dis2[2] * dis2[2]); +} + +void RE_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal) +{ + int surf; + srfBspSurface_t *face; + // Not sure if we really need to track the best two candidates + int maxDist[2] = { 0,0 }; + int maxIndx[2] = { 0,0 }; + int dist = 0; + float dot1, dot2; + + model_t *pModel = R_GetModelByHandle(bmodelIndex); + bmodel_t *bmodel = pModel->data.bmodel; + world_t *world = R_GetWorld(bmodel->worldIndex); + + // Loop through all surfaces on the brush and find the best two candidates + for (int i = 0; i < bmodel->numSurfaces; i++) + { + surf = bmodel->firstSurface + i; + face = (srfBspSurface_t *)(world->surfaces + surf)->data; + + // It seems that the safest way to handle this is by finding the area of the faces + dist = GetQuadArea(face->verts[0].xyz, face->verts[1].xyz, face->verts[2].xyz, face->verts[3].xyz); + + // Check against the highest max + if (dist > maxDist[0]) + { + // Shuffle our current maxes down + maxDist[1] = maxDist[0]; + maxIndx[1] = maxIndx[0]; + + maxDist[0] = dist; + maxIndx[0] = i; + } + // Check against the second highest max + else if (dist >= maxDist[1]) + { + // just stomp the old + maxDist[1] = dist; + maxIndx[1] = i; + } + } + + // Hopefully we've found two best case candidates. Now we should see which of these faces the viewer + + surf = bmodel->firstSurface + maxIndx[0]; + face = (srfBspSurface_t *)(world->surfaces + surf)->data; + dot1 = DotProduct(face->cullPlane.normal, tr.refdef.viewaxis[0]); + + surf = bmodel->firstSurface + maxIndx[1]; + face = (srfBspSurface_t *)(world->surfaces + surf)->data; + dot2 = DotProduct(face->cullPlane.normal, tr.refdef.viewaxis[0]); + + if (dot2 < dot1 && dot2 < 0.0f) + { + surf = bmodel->firstSurface + maxIndx[1]; // use the second face + } + else if (dot1 < dot2 && dot1 < 0.0f) + { + surf = bmodel->firstSurface + maxIndx[0]; // use the first face + } + else + { // Possibly only have one face, so may as well use the first face, which also should be the best one + //i = rand() & 1; // ugh, we don't know which to use. I'd hope this would never happen + surf = bmodel->firstSurface + maxIndx[0]; // use the first face + } + face = (srfBspSurface_t *)(world->surfaces + surf)->data; + + for (int t = 0; t < 4; t++) + { + VectorCopy(face->verts[t].xyz, verts[t]); + } +} + void RE_SetRangedFog ( float range ) { tr.rangedFog = range; From 075669d2a08d643af67e69e9c48af5da56efcd8a Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 14 Oct 2022 00:08:05 +0200 Subject: [PATCH 581/708] Work on the weather system Most of the things work just fine. There are some things that are unfinished/unimplemented though. Fading for fog billboards needs to be implemented. Rapidly changing wind directions will lead to missing particles in the viewport for now. Shaders probably should also be more specialized to get some more performance because we can get rid of some ifs in the shaders then. --- codemp/rd-rend2/glsl/fogpass.glsl | 1 + codemp/rd-rend2/glsl/lightall.glsl | 1 + codemp/rd-rend2/glsl/weather.glsl | 83 +- codemp/rd-rend2/glsl/weatherUpdate.glsl | 39 +- codemp/rd-rend2/tr_backend.cpp | 1 + codemp/rd-rend2/tr_glsl.cpp | 6 + codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_init.cpp | 6 +- codemp/rd-rend2/tr_local.h | 6 + codemp/rd-rend2/tr_scene.cpp | 7 + codemp/rd-rend2/tr_weather.cpp | 964 +++++++++++++++++++++--- codemp/rd-rend2/tr_weather.h | 2 + 12 files changed, 999 insertions(+), 119 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 630845410e..9d7dd435fb 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -231,6 +231,7 @@ layout(std140) uniform Scene int u_globalFogIndex; vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; + float u_frameTime; }; struct Fog diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 66a3c1a359..fe01bfe310 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -339,6 +339,7 @@ layout(std140) uniform Scene int u_globalFogIndex; vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; + float u_frameTime; }; layout(std140) uniform Camera diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index aff27e1e05..ef9fe876a5 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,10 +1,15 @@ /*[Vertex]*/ uniform vec2 u_ZoneOffset; +uniform sampler2D u_ShadowMap; +uniform mat4 u_ShadowMvp; +uniform vec4 u_ViewInfo; + in vec3 attr_Position; in vec3 attr_Color; // velocity out vec3 var_Velocity; +out int var_Culled; void main() { @@ -13,6 +18,23 @@ void main() attr_Position.z, 1.0); var_Velocity = attr_Color; + + vec4 velocitiyOffset = u_ViewInfo.y * vec4(-var_Velocity.xy/var_Velocity.z, var_Velocity.z, 0.0); + velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, var_Velocity.z != 0.0); + + vec4 depthPosition = u_ShadowMvp * (gl_Position + velocitiyOffset); + depthPosition.xyz = depthPosition.xyz / depthPosition.w * 0.5 + 0.5; + float depthSample = texture(u_ShadowMap, depthPosition.xy).r; + + //TODO: Do this to the texture instead of sampling the texture 5 times here over and over again + vec2 dx = vec2(0.5 / 1024.0, 0.0); + vec2 dy = vec2(0.0, 0.5 / 1024.0); + depthSample = min(texture(u_ShadowMap, depthPosition.xy + dx).r, depthSample); + depthSample = min(texture(u_ShadowMap, depthPosition.xy - dx).r, depthSample); + depthSample = min(texture(u_ShadowMap, depthPosition.xy - dy).r, depthSample); + depthSample = min(texture(u_ShadowMap, depthPosition.xy + dy).r, depthSample); + + var_Culled = int(depthPosition.z > depthSample); } /*[Geometry]*/ @@ -21,37 +43,66 @@ layout(triangle_strip, max_vertices = 4) out; uniform mat4 u_ModelViewProjectionMatrix; uniform vec3 u_ViewOrigin; +uniform float u_Time; // delta time +uniform vec4 u_ViewInfo; in vec3 var_Velocity[]; +in int var_Culled[]; + +out vec3 var_TexCoordAlpha; void main() { - const vec2 offsets[] = vec2[]( - vec2(-0.5, -7.0), - vec2( 0.5, -7.0), - vec2(-0.5, 7.0), - vec2( 0.5, 7.0) + vec3 offsets[] = vec3[]( + vec3(-u_ViewInfo.x, -u_ViewInfo.y, 0.0), + vec3( u_ViewInfo.x, -u_ViewInfo.y, 0.0), + vec3(-u_ViewInfo.x, u_ViewInfo.y, 0.0), + vec3( u_ViewInfo.x, u_ViewInfo.y, 0.0) ); - vec3 P = gl_in[0].gl_Position.xyz; - vec3 V = u_ViewOrigin - P; - vec2 toCamera = normalize(vec2(V.y, -V.x)); + const vec2 texcoords[] = vec2[]( + vec2(1.0, 1.0), + vec2(0.0, 1.0), + vec2(1.0, 0.0), + vec2(0.0, 0.0) + ); - for (int i = 0; i < 4; ++i) + if (var_Culled[0] == 0) { - vec3 offset = vec3(offsets[i].x * toCamera.xy, offsets[i].y); - vec4 worldPos = vec4(P + offset, 1.0); - gl_Position = u_ModelViewProjectionMatrix * worldPos; - EmitVertex(); - } + vec3 P = gl_in[0].gl_Position.xyz; + vec3 V = u_ViewOrigin - P; + vec2 toCamera = normalize(vec2(V.y, -V.x)); + for (int i = 0; i < 4; ++i) + { + vec3 offset = vec3(offsets[i].x * toCamera.xy, offsets[i].y); + if (var_Velocity[0].z != 0.0) + offset.xy += offset.z * var_Velocity[0].xy / var_Velocity[0].z; + vec4 worldPos = vec4(P + offset, 1.0); + gl_Position = u_ModelViewProjectionMatrix * worldPos; + + // TODO: Fade on distance to viewer + float alpha = 1.0; - EndPrimitive(); + var_TexCoordAlpha = vec3(texcoords[i], alpha); + EmitVertex(); + } + EndPrimitive(); + } } /*[Fragment]*/ +uniform vec4 u_Color; +uniform sampler2D u_DiffuseMap; + +in vec3 var_TexCoordAlpha; out vec4 out_Color; +out vec4 out_Glow; void main() { - out_Color = vec4(0.7, 0.8, 0.7, 0.1); + vec4 textureColor = texture(u_DiffuseMap, var_TexCoordAlpha.xy); + out_Color = textureColor * u_Color * var_TexCoordAlpha.z; + + out_Glow.rgb = vec3(0.0); + out_Glow.a = out_Color.a; } diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 149b1f2471..2604ff0c4a 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -1,8 +1,9 @@ /*[Vertex]*/ -uniform float u_Gravity; -uniform float u_DeltaTime; +uniform float u_Time; // delta time uniform vec2 u_MapZExtents; +uniform vec3 u_EnvForce; +uniform vec4 u_RandomOffset; in vec3 attr_Position; in vec3 attr_Color; @@ -10,20 +11,48 @@ in vec3 attr_Color; out vec3 var_Position; out vec3 var_Velocity; -vec3 NewParticlePosition() +const float CHUNK_EXTENDS = 2000.0; +const float HALF_CHUNK_EXTENDS = CHUNK_EXTENDS * 0.5; + +vec3 NewParticleZPosition() { vec3 position = var_Position; + position.xy += u_RandomOffset.xy; position.z += u_MapZExtents.y - u_MapZExtents.x; + vec2 signs = sign(position.xy); + vec2 absPos = abs(position.xy) + vec2(HALF_CHUNK_EXTENDS); + position.xy = -signs * (HALF_CHUNK_EXTENDS - mod(absPos, CHUNK_EXTENDS)); + + return position; +} + +vec3 NewParticleXYPosition(vec3 in_Position) +{ + vec3 position = in_Position; + position.xy += u_RandomOffset.xy * 10.0; + vec2 signs = sign(position.xy); + vec2 absPos = abs(position.xy) + vec2(HALF_CHUNK_EXTENDS); + position.xy = -signs * (1.5 * CHUNK_EXTENDS - mod(absPos, CHUNK_EXTENDS)); + return position; } void main() { var_Velocity = attr_Color; + var_Velocity = mix(var_Velocity, u_EnvForce, u_Time * 0.002); var_Position = attr_Position; - var_Position.z -= 600.0 * 0.16; + var_Position += var_Velocity * u_Time; if (var_Position.z < u_MapZExtents.x) - var_Position = NewParticlePosition(); + { + var_Position = NewParticleZPosition(); + var_Velocity.xy = u_EnvForce.xy; + } + if (u_EnvForce.z == 0 && any(greaterThan(abs(var_Position).xy, vec2(1.5 * CHUNK_EXTENDS)))) + { + var_Position = NewParticleXYPosition(var_Position); + var_Velocity.xy = u_EnvForce.xy; + } } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 87adfa5ce9..604131d2eb 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2318,6 +2318,7 @@ static void RB_UpdateSceneConstants(gpuFrame_t *frame) sceneBlock.globalFogIndex = tr.world->globalFogIndex - 1; else sceneBlock.globalFogIndex = -1; + sceneBlock.currentTime = backEnd.refdef.time; tr.sceneUboOffset = RB_AppendConstantsData( frame, &sceneBlock, sizeof(sceneBlock)); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 38d448f88f..d295c8431c 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -128,6 +128,8 @@ static uniformInfo_t uniformsInfo[] = { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, { "u_MapZExtents", GLSL_VEC2, 1 }, { "u_ZoneOffset", GLSL_VEC2, 1 }, + { "u_EnvForce", GLSL_VEC3, 1 }, + { "u_RandomOffset", GLSL_VEC4, 1 } }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) @@ -2247,6 +2249,10 @@ static int GLSL_LoadGPUProgramWeather( ATTR_POSITION | ATTR_COLOR); GLSL_InitUniforms(&tr.weatherShader); + qglUseProgram(tr.weatherShader.program); + GLSL_SetUniformInt(&tr.weatherShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP); + GLSL_SetUniformInt(&tr.weatherShader, UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP); + qglUseProgram(0); GLSL_FinishGPUShader(&tr.weatherShader); GLSL_LoadGPUProgramBasic( diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 2d36e8c52b..dc6d067463 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3556,7 +3556,7 @@ void R_CreateBuiltinImages( void ) { 1024, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - GL_DEPTH_COMPONENT24); + GL_DEPTH_COMPONENT16); } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index efa511fb17..a74dc6ad60 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1398,7 +1398,7 @@ static consoleCommand_t commands[] = { { "screenshot_tga", R_ScreenShotTGA_f }, { "gfxinfo", GfxInfo_f }, { "gfxmeminfo", GfxMemInfo_f }, - //{ "r_we", R_WorldEffect_f }, + { "r_we", R_WorldEffect_f }, //{ "imagecacheinfo", RE_RegisterImages_Info_f }, { "modellist", R_Modellist_f }, //{ "modelcacheinfo", RE_RegisterModels_Info_f }, @@ -2018,8 +2018,8 @@ void RE_SetLightStyle(int style, int color) } void RE_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal); +void RE_WorldEffectCommand(const char *cmd); -void stub_RE_WorldEffectCommand ( const char *cmd ){} void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} static void RE_SetRefractionProperties ( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate ) { } @@ -2141,7 +2141,7 @@ Q_EXPORT refexport_t* QDECL GetRefAPI ( int apiVersion, refimport_t *rimp ) { // R_AutomapElevationAdjustment re.InitializeWireframeAutomap = stub_InitializeWireframeAutomap; re.AddWeatherZone = stub_RE_AddWeatherZone; - re.WorldEffectCommand = stub_RE_WorldEffectCommand; + re.WorldEffectCommand = RE_WorldEffectCommand; re.RegisterMedia_LevelLoadBegin = C_LevelLoadBegin; re.RegisterMedia_LevelLoadEnd = C_LevelLoadEnd; re.RegisterMedia_GetLevel = C_GetLevel; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e95adede22..16d601854a 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -713,6 +713,8 @@ struct SceneBlock int globalFogIndex; vec3_t primaryLightColor; float primaryLightRadius; + float currentTime; + float pad0[3]; }; struct LightsBlock @@ -1372,6 +1374,8 @@ typedef enum UNIFORM_FX_VOLUMETRIC_BASE, UNIFORM_MAPZEXTENTS, UNIFORM_ZONEOFFSET, + UNIFORM_ENVFORCE, + UNIFORM_RANDOMOFFSET, UNIFORM_COUNT } uniform_t; @@ -1422,6 +1426,8 @@ typedef struct { qboolean areamaskModified; // qtrue if areamask changed since last scene float floatTime; // tr.refdef.time / 1000.0 + float frameTime; // delta last frame to frame now + float lastTime; // last frame time float blurFactor; diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 5e38547279..76e13f8d92 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -314,6 +314,7 @@ void RE_BeginScene(const refdef_t *fd) tr.refdef.time = fd->time; tr.refdef.rdflags = fd->rdflags; + tr.refdef.frameTime = fd->time - tr.refdef.lastTime; // copy the areamask data over and note if it has changed, which // will force a reset of the visible leafs even if the view hasn't moved @@ -452,6 +453,12 @@ void RE_BeginScene(const refdef_t *fd) { tr.world->skyboxportal = 1; } + else + { + // pasted this from SP + // cdr - only change last time for the real render, not the portal + tr.refdef.lastTime = fd->time; + } // a single frame may have multiple scenes draw inside it -- // a 3D game view, 3D status bar renderings, 3D menus, etc. diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 5d8e3cd45a..a3d26e0d90 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -24,24 +24,78 @@ along with this program; if not, see . #include #include +enum weatherType_t +{ + WEATHER_RAIN, + WEATHER_SNOW, + WEATHER_SPACEDUST, + WEATHER_SAND, + WEATHER_FOG, -struct weatherSystem_t + NUM_WEATHER_TYPES +}; + +const int maxWeatherTypeParticles[NUM_WEATHER_TYPES] = { + 30000, + 10000, + 5000, + 1000, + 1000 +}; + +struct weatherObject_t { VBO_t *lastVBO; VBO_t *vbo; unsigned vboLastUpdateFrame; - int numVertices; + vertexAttribute_t attribsTemplate[2]; + + bool active; + + float gravity; + float fadeDistance; + int particleCount; + image_t *drawImage; + vec4_t color; + vec2_t size; + vec3_t currentVelocity; +}; + +#define MAX_WINDOBJECTS 10 +struct windObject_t +{ + vec3_t currentVelocity; + vec3_t targetVelocity; + vec3_t maxVelocity; + vec3_t minVelocity; + float chanceOfDeadTime; + vec2_t deadTimeMinMax; + int targetVelocityTimeRemaining; +}; + +struct weatherSystem_t +{ + weatherObject_t weatherSlots[NUM_WEATHER_TYPES]; + windObject_t windSlots[MAX_WINDOBJECTS]; + + int activeWeatherTypes = 0; + int activeWindObjects = 0; + bool frozen; srfWeather_t weatherSurface; - vertexAttribute_t attribsTemplate[2]; + + vec3_t constWindDirection; + vec3_t windDirection; + float windSpeed; + + float weatherMVP[16]; }; namespace { - const float CHUNK_SIZE = 2000.0f; - const float HALF_CHUNK_SIZE = CHUNK_SIZE * 0.5f; const int CHUNK_COUNT = 9; // in 3x3 arrangement - const int RAIN_VERTEX_COUNT = 50000; + const float CHUNK_EXTENDS = 2000.f; + const float HALF_CHUNK_EXTENDS = CHUNK_EXTENDS * 0.5f; struct rainVertex_t { @@ -49,19 +103,54 @@ namespace vec3_t velocity; }; - void GenerateRainModel( weatherSystem_t& ws ) + void RB_UpdateWindObject( windObject_t *wo ) { - std::vector rainVertices(RAIN_VERTEX_COUNT * CHUNK_COUNT); + if (wo->targetVelocityTimeRemaining == 0) + { + if (Q_flrand(0.f, 1.f) < wo->chanceOfDeadTime) + { + wo->targetVelocityTimeRemaining = Q_flrand(wo->deadTimeMinMax[0], wo->deadTimeMinMax[1]); + VectorSet(wo->targetVelocity, 0.0f, 0.0f, 0.0f); + } + else + { + wo->targetVelocityTimeRemaining = Q_flrand(1000.f, 2500.f); + VectorSet( + wo->targetVelocity, + Q_flrand(wo->minVelocity[0], wo->maxVelocity[0]), + Q_flrand(wo->minVelocity[1], wo->maxVelocity[1]), + Q_flrand(wo->minVelocity[2], wo->maxVelocity[2])); + } + return; + } + + wo->targetVelocityTimeRemaining--; + vec3_t deltaVelocity; + VectorSubtract(wo->targetVelocity, wo->currentVelocity, deltaVelocity); + float DeltaVelocityLen = VectorNormalize(deltaVelocity); + if (DeltaVelocityLen > 10.f) + { + DeltaVelocityLen = 10.f; + } + VectorScale(deltaVelocity, DeltaVelocityLen, deltaVelocity); + VectorAdd(wo->currentVelocity, deltaVelocity, wo->currentVelocity); + } + + void GenerateRainModel( weatherObject_t& ws, const int maxParticleCount ) + { + const int mapExtentZ = (int)(tr.world->bmodels[0].bounds[1][2] - tr.world->bmodels[0].bounds[0][2]); + const int PARTICLE_COUNT = (int)(maxParticleCount * mapExtentZ / CHUNK_EXTENDS); + std::vector rainVertices(PARTICLE_COUNT * CHUNK_COUNT); for ( int i = 0; i < rainVertices.size(); ++i ) { rainVertex_t& vertex = rainVertices[i]; - vertex.position[0] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); - vertex.position[1] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); - vertex.position[2] = Q_flrand(-HALF_CHUNK_SIZE, HALF_CHUNK_SIZE); - vertex.velocity[0] = Q_flrand(-2.0f, 2.0f); - vertex.velocity[1] = Q_flrand(-2.0f, 2.0f); - vertex.velocity[2] = Q_flrand(-20.0f, 0.0f); + vertex.position[0] = Q_flrand(-HALF_CHUNK_EXTENDS, HALF_CHUNK_EXTENDS); + vertex.position[1] = Q_flrand(-HALF_CHUNK_EXTENDS, HALF_CHUNK_EXTENDS); + vertex.position[2] = Q_flrand(tr.world->bmodels[0].bounds[0][2], tr.world->bmodels[0].bounds[1][2]); + vertex.velocity[0] = 0.0f; //Q_flrand(0.0f, 0.0f); + vertex.velocity[1] = 0.0f; //Q_flrand(0.0f, 0.0f); + vertex.velocity[2] = 0.0f; //Q_flrand(-1.0f, 0.0f); } ws.lastVBO = R_CreateVBO( @@ -106,6 +195,7 @@ namespace vec3_t viewOrigin; VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin); + viewOrigin[2] = tr.world->bmodels[0].bounds[1][2]; ri.Printf(PRINT_ALL, "Rendering weather depth from (%.f %.f %.f)\n", viewOrigin[0], viewOrigin[1], viewOrigin[2]); @@ -122,8 +212,8 @@ namespace RE_ClearScene(); const vec3_t viewBounds[2] = { - { 0.0f, -halfMapSize[0], -halfMapSize[1] }, - { halfMapSize[2] * 2.0f, halfMapSize[0], halfMapSize[1] } + { 0.0f, -halfMapSize[1], -halfMapSize[0] }, + { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } }; ri.Printf( PRINT_ALL, @@ -145,14 +235,23 @@ namespace R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf); + + Matrix16Multiply( + tr.viewParms.projectionMatrix, + tr.viewParms.world.modelViewMatrix, + tr.weatherSystem->weatherMVP); + R_IssuePendingRenderCommands(); R_InitNextFrame(); RE_EndScene(); + + // TODO: Store ViewProjection Mat for depth comparisons } - void RB_SimulateWeather(weatherSystem_t& ws) + void RB_SimulateWeather(weatherObject_t *ws) { - if (ws.vboLastUpdateFrame == backEndData->realFrameNumber) + if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || + tr.weatherSystem->frozen) { // Already simulated for this frame return; @@ -160,21 +259,21 @@ namespace // Intentionally switched. Previous frame's VBO would be in ws.vbo and // this frame's VBO would be ws.lastVBO. - VBO_t *lastRainVBO = ws.vbo; - VBO_t *rainVBO = ws.lastVBO; + VBO_t *lastRainVBO = ws->vbo; + VBO_t *rainVBO = ws->lastVBO; DrawItem item = {}; item.renderState.transformFeedback = true; item.transformFeedbackBuffer = {rainVBO->vertexesVBO, 0, rainVBO->vertexesSize}; item.program = &tr.weatherUpdateShader; - const size_t numAttribs = ARRAY_LEN(ws.attribsTemplate); + const size_t numAttribs = ARRAY_LEN(ws->attribsTemplate); item.numAttributes = numAttribs; item.attributes = ojkAllocArray( *backEndData->perFrameMemory, numAttribs); memcpy( item.attributes, - ws.attribsTemplate, + ws->attribsTemplate, sizeof(*item.attributes) * numAttribs); item.attributes[0].vbo = lastRainVBO; item.attributes[1].vbo = lastRainVBO; @@ -183,32 +282,48 @@ namespace uniformDataWriter.Start(&tr.weatherUpdateShader); const vec2_t mapZExtents = { - -1000.0f, 1000.0f - //tr.world->bmodels[0].bounds[0][2], - //tr.world->bmodels[0].bounds[1][2] + tr.world->bmodels[0].bounds[0][2], + tr.world->bmodels[0].bounds[1][2] + }; + const float frictionInverse = 0.7f; + vec3_t envForce = { + tr.weatherSystem->windDirection[0] * frictionInverse, + tr.weatherSystem->windDirection[1] * frictionInverse, + -ws->gravity + }; + vec4_t randomOffset = { + Q_flrand(-4.0f, 4.0f), + Q_flrand(-4.0f, 4.0f), + Q_flrand(0.0f, 1.0f), + tr.world->bmodels[0].bounds[1][2] - backEnd.viewParms.ori.origin[2] }; uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.frameTime); + uniformDataWriter.SetUniformVec3(UNIFORM_ENVFORCE, envForce); + uniformDataWriter.SetUniformVec4(UNIFORM_RANDOMOFFSET, randomOffset); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; - item.draw.params.arrays.numVertices = RAIN_VERTEX_COUNT * CHUNK_COUNT; + item.draw.params.arrays.numVertices = ws->particleCount * CHUNK_COUNT; // This is a bit dodgy. Push this towards the front of the queue so we // guarantee this happens before the actual drawing - const uint32_t key = RB_CreateSortKey(item, 0, SS_OPAQUE); + const uint32_t key = RB_CreateSortKey(item, 0, SS_ENVIRONMENT); RB_AddDrawItem(backEndData->currentPass, key, item); - ws.vboLastUpdateFrame = backEndData->realFrameNumber; - std::swap(ws.lastVBO, ws.vbo); + ws->vboLastUpdateFrame = backEndData->realFrameNumber; + std::swap(ws->lastVBO, ws->vbo); } } void R_InitWeatherForMap() { - GenerateRainModel(*tr.weatherSystem); + for (int i = 0; i < NUM_WEATHER_TYPES; i++) + if (tr.weatherSystem->weatherSlots[i].active) + GenerateRainModel(tr.weatherSystem->weatherSlots[i], maxWeatherTypeParticles[i]); GenerateDepthMap(); } @@ -218,6 +333,10 @@ void R_InitWeatherSystem() tr.weatherSystem = (weatherSystem_t *)Z_Malloc(sizeof(*tr.weatherSystem), TAG_R_TERRAIN, qtrue); tr.weatherSystem->weatherSurface.surfaceType = SF_WEATHER; + tr.weatherSystem->frozen = false; + tr.weatherSystem->activeWeatherTypes = 0; + tr.weatherSystem->constWindDirection[0] = .0f; + tr.weatherSystem->constWindDirection[1] = .0f; } void R_ShutdownWeatherSystem() @@ -236,22 +355,594 @@ void R_ShutdownWeatherSystem() } } -void R_AddWeatherSurfaces() +/* +=============== +WE_ParseVector +=============== +*/ +qboolean WE_ParseVector(const char **text, int count, float *v) { + char *token; + int i; + + // FIXME: spaces are currently required after parens, should change parseext... + token = COM_ParseExt(text, qfalse); + if (strcmp(token, "(")) { + ri.Printf(PRINT_WARNING, "WARNING: missing parenthesis in weather effect\n"); + return qfalse; + } + + for (i = 0; i < count; i++) { + token = COM_ParseExt(text, qfalse); + if (!token[0]) { + ri.Printf(PRINT_WARNING, "WARNING: missing vector element in weather effect\n"); + return qfalse; + } + v[i] = atof(token); + } + + token = COM_ParseExt(text, qfalse); + if (strcmp(token, ")")) { + ri.Printf(PRINT_WARNING, "WARNING: missing parenthesis in weather effect\n"); + return qfalse; + } + + return qtrue; +} + +void RE_WorldEffectCommand(const char *command) { - assert(tr.weatherSystem); + if (!command) + { + return; + } + + COM_BeginParseSession("RE_WorldEffectCommand"); + + const char *token;//, *origCommand; - if (r_debugWeather->integer) + token = COM_ParseExt(&command, qfalse); + + if (!token) + { + return; + } + + //Die - clean up the whole weather system -rww + if (Q_stricmp(token, "die") == 0) + { + for (int i = 0; i < NUM_WEATHER_TYPES; i++) + tr.weatherSystem->weatherSlots[i].active = false; + tr.weatherSystem->activeWeatherTypes = 0; + tr.weatherSystem->frozen = false; + return; + } + + // Clear - Removes All Particle Clouds And Wind Zones + //---------------------------------------------------- + else if (Q_stricmp(token, "clear") == 0) + { + for (int i = 0; i < NUM_WEATHER_TYPES; i++) + tr.weatherSystem->weatherSlots[i].active = false; + tr.weatherSystem->activeWeatherTypes = 0; + tr.weatherSystem->activeWindObjects = 0; + tr.weatherSystem->frozen = false; + } + + // Freeze / UnFreeze - Stops All Particle Motion Updates + //-------------------------------------------------------- + else if (Q_stricmp(token, "freeze") == 0) + { + tr.weatherSystem->frozen = !tr.weatherSystem->frozen; + } + + //// Add a zone + ////--------------- + //else if (Q_stricmp(token, "zone") == 0) + //{ + // vec3_t mins; + // vec3_t maxs; + // //if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) + // { + // //mOutside.AddWeatherZone(mins, maxs); + // } + //} + + // Basic Wind + //------------ + else if (Q_stricmp(token, "wind") == 0) + { + windObject_t *currentWindObject = &tr.weatherSystem->windSlots[tr.weatherSystem->activeWindObjects]; + currentWindObject->chanceOfDeadTime = 0.3f; + currentWindObject->deadTimeMinMax[0] = 1000.0f; + currentWindObject->deadTimeMinMax[1] = 3000.0f; + currentWindObject->maxVelocity[0] = 1.5f; + currentWindObject->maxVelocity[1] = 1.5f; + currentWindObject->maxVelocity[2] = 0.01f; + currentWindObject->minVelocity[0] = -1.5f; + currentWindObject->minVelocity[1] = -1.5f; + currentWindObject->minVelocity[2] = -0.01f; + currentWindObject->targetVelocityTimeRemaining = 0; + tr.weatherSystem->activeWindObjects++; + } + + // Constant Wind + //--------------- + else if (Q_stricmp(token, "constantwind") == 0) + { + vec3_t parsedWind; + vec3_t defaultWind = { 0.f, 0.8f, 0.f }; + if (!WE_ParseVector(&command, 3, parsedWind)) + VectorAdd( + tr.weatherSystem->constWindDirection, + defaultWind, + tr.weatherSystem->constWindDirection); + else + VectorMA( + tr.weatherSystem->constWindDirection, + 0.001f, + parsedWind, + tr.weatherSystem->constWindDirection); + } + + // Gusting Wind + //-------------- + else if (Q_stricmp(token, "gustingwind") == 0) { - R_AddDrawSurf( - (surfaceType_t *)&tr.weatherSystem->weatherSurface, - REFENTITYNUM_WORLD, - tr.weatherInternalShader, - 0, /* fogIndex */ - qfalse, /* dlightMap */ - qfalse, /* postRender */ - 0 /* cubemapIndex */ - ); + windObject_t *currentWindObject = &tr.weatherSystem->windSlots[tr.weatherSystem->activeWindObjects]; + currentWindObject->chanceOfDeadTime = 0.3f; + currentWindObject->deadTimeMinMax[0] = 2000.0f; + currentWindObject->deadTimeMinMax[1] = 4000.0f; + currentWindObject->maxVelocity[0] = 3.0f; + currentWindObject->maxVelocity[1] = 3.0f; + currentWindObject->maxVelocity[2] = 0.1f; + currentWindObject->minVelocity[0] = -3.0f; + currentWindObject->minVelocity[1] = -3.0f; + currentWindObject->minVelocity[2] = -0.1f; + currentWindObject->targetVelocityTimeRemaining = 0; + tr.weatherSystem->activeWindObjects++; } + + // Create A Rain Storm + //--------------------- + else if (Q_stricmp(token, "lightrain") == 0) + { + /*nCloud.Initialize(500, "gfx/world/rain.jpg", 3); + nCloud.mHeight = 80.0f; + nCloud.mWidth = 1.2f; + nCloud.mGravity = 2000.0f; + nCloud.mFilterMode = 1; + nCloud.mBlendMode = 1; + nCloud.mFade = 100.0f; + nCloud.mColor = 0.5f; + nCloud.mOrientWithVelocity = true; + nCloud.mWaterParticles = true;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_RAIN].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 1000; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 6000.f; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, + 0.5f, + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color); + } + + // Create A Rain Storm + //--------------------- + else if (Q_stricmp(token, "rain") == 0) + { + /*nCloud.Initialize(1000, "gfx/world/rain.jpg", 3); + nCloud.mHeight = 80.0f; + nCloud.mWidth = 1.2f; + nCloud.mGravity = 2000.0f; + nCloud.mFilterMode = 1; + nCloud.mBlendMode = 1; + nCloud.mFade = 100.0f; + nCloud.mColor = 0.5f; + nCloud.mOrientWithVelocity = true; + nCloud.mWaterParticles = true;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_RAIN].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 2000; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 6000.f; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, + 0.5f, + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color); + } + + // Create A Rain Storm + //--------------------- + else if (Q_stricmp(token, "acidrain") == 0) + { + /*nCloud.Initialize(1000, "gfx/world/rain.jpg", 3); + nCloud.mHeight = 80.0f; + nCloud.mWidth = 2.0f; + nCloud.mGravity = 2000.0f; + nCloud.mFilterMode = 1; + nCloud.mBlendMode = 1; + nCloud.mFade = 100.0f; + + nCloud.mColor[0] = 0.34f; + nCloud.mColor[1] = 0.70f; + nCloud.mColor[2] = 0.34f; + nCloud.mColor[3] = 0.70f; + + nCloud.mOrientWithVelocity = true; + nCloud.mWaterParticles = true;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_RAIN].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 2000; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 2.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.34f, 0.7f, 0.34f, 0.7f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, + 0.7f, + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color); + } + + // Create A Rain Storm + //--------------------- + else if (Q_stricmp(token, "heavyrain") == 0) + { + /*nCloud.Initialize(1000, "gfx/world/rain.jpg", 3); + nCloud.mHeight = 80.0f; + nCloud.mWidth = 1.2f; + nCloud.mGravity = 2800.0f; + nCloud.mFilterMode = 1; + nCloud.mBlendMode = 1; + nCloud.mFade = 15.0f; + nCloud.mColor = 0.5f; + nCloud.mOrientWithVelocity = true; + nCloud.mWaterParticles = true;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_RAIN].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 5000; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.8f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, 0.5f, 0.5f, 0.5f, 0.5f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color, + 0.5f, + tr.weatherSystem->weatherSlots[WEATHER_RAIN].color); + } + + // Create A Snow Storm + //--------------------- + else if (Q_stricmp(token, "snow") == 0) + { + /*nCloud.Initialize(1000, "gfx/effects/snowflake1.bmp"); + nCloud.mBlendMode = 1; + nCloud.mRotationChangeNext = 0; + nCloud.mColor = 0.75f; + nCloud.mWaterParticles = true;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_SNOW].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_SNOW].particleCount = 1000; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].active = true; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].gravity = 0.3f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + + tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[0] = 1.5f; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[1] = 1.5f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].drawImage = R_FindImageFile("gfx/effects/snowflake1", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SNOW].color, 0.75f, 0.75f, 0.75f, 0.75f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_SNOW].color, + 0.75f, + tr.weatherSystem->weatherSlots[WEATHER_SNOW].color); + } + + // Create A Some stuff + //--------------------- + else if (Q_stricmp(token, "spacedust") == 0) + { + /*nCloud.Initialize(count, "gfx/effects/snowpuff1.tga"); + nCloud.mHeight = 1.2f; + nCloud.mWidth = 1.2f; + nCloud.mGravity = 0.0f; + nCloud.mBlendMode = 1; + nCloud.mRotationChangeNext = 0; + nCloud.mColor = 0.75f; + nCloud.mWaterParticles = true; + nCloud.mMass.mMax = 30.0f; + nCloud.mMass.mMin = 10.0f; + nCloud.mSpawnRange.mMins[0] = -1500.0f; + nCloud.mSpawnRange.mMins[1] = -1500.0f; + nCloud.mSpawnRange.mMins[2] = -1500.0f; + nCloud.mSpawnRange.mMaxs[0] = 1500.0f; + nCloud.mSpawnRange.mMaxs[1] = 1500.0f; + nCloud.mSpawnRange.mMaxs[2] = 1500.0f;*/ + int count; + token = COM_ParseExt(&command, qfalse); + count = atoi(token); + + if (!tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].particleCount = count; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].active = true; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[0] = 2.5f; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[1] = 2.5f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].drawImage = R_FindImageFile("gfx/effects/snowpuff1", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, 0.75f, 0.75f, 0.75f, 0.75f); + VectorScale( + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color, + 0.75f, + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].color); + } + + // Create A Sand Storm + //--------------------- + else if (Q_stricmp(token, "sand") == 0) + { + /*nCloud.Initialize(400, "gfx/effects/alpha_smoke2b.tga"); + + nCloud.mGravity = 0; + nCloud.mWidth = 70; + nCloud.mHeight = 70; + nCloud.mColor[0] = 0.9f; + nCloud.mColor[1] = 0.6f; + nCloud.mColor[2] = 0.0f; + nCloud.mColor[3] = 0.5f; + nCloud.mFade = 5.0f; + nCloud.mMass.mMax = 30.0f; + nCloud.mMass.mMin = 10.0f; + nCloud.mSpawnRange.mMins[2] = -150; + nCloud.mSpawnRange.mMaxs[2] = 150; + + nCloud.mRotationChangeNext = 0;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_SAND].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_SAND].particleCount = 400; + tr.weatherSystem->weatherSlots[WEATHER_SAND].active = true; + tr.weatherSystem->weatherSlots[WEATHER_SAND].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + + tr.weatherSystem->weatherSlots[WEATHER_SAND].size[0] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_SAND].size[1] = 300.f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_SAND].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_SAND].color, 0.9f, 0.6f, 0.0f, 0.5f); + } + + // Create Blowing Clouds Of Fog + //------------------------------ + else if (Q_stricmp(token, "fog") == 0) + { + /*nCloud.Initialize(60, "gfx/effects/alpha_smoke2b.tga"); + nCloud.mBlendMode = 1; + nCloud.mGravity = 0; + nCloud.mWidth = 70; + nCloud.mHeight = 70; + nCloud.mColor = 0.2f; + nCloud.mFade = 5.0f; + nCloud.mMass.mMax = 30.0f; + nCloud.mMass.mMin = 10.0f; + nCloud.mSpawnRange.mMins[2] = -150; + nCloud.mSpawnRange.mMaxs[2] = 150; + + nCloud.mRotationChangeNext = 0;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_FOG].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 60; + tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; + tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.2f, 0.2f, 0.2f, 0.2f); + VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.2f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); + } + + // Create Heavy Rain Particle Cloud + //----------------------------------- + else if (Q_stricmp(token, "heavyrainfog") == 0) + { + /*nCloud.Initialize(70, "gfx/effects/alpha_smoke2b.tga"); + nCloud.mBlendMode = 1; + nCloud.mGravity = 0; + nCloud.mWidth = 100; + nCloud.mHeight = 100; + nCloud.mColor = 0.3f; + nCloud.mFade = 1.0f; + nCloud.mMass.mMax = 10.0f; + nCloud.mMass.mMin = 5.0f; + + nCloud.mSpawnRange.mMins = -(nCloud.mSpawnPlaneDistance*1.25f); + nCloud.mSpawnRange.mMaxs = (nCloud.mSpawnPlaneDistance*1.25f); + nCloud.mSpawnRange.mMins[2] = -150; + nCloud.mSpawnRange.mMaxs[2] = 150; + + nCloud.mRotationChangeNext = 0;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_FOG].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 70; + tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; + tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.3f, 0.3f, 0.3f, 0.3f); + VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.3f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); + } + + // Create Blowing Clouds Of Fog + //------------------------------ + else if (Q_stricmp(token, "light_fog") == 0) + { + /*nCloud.Initialize(40, "gfx/effects/alpha_smoke2b.tga"); + nCloud.mBlendMode = 1; + nCloud.mGravity = 0; + nCloud.mWidth = 100; + nCloud.mHeight = 100; + nCloud.mColor[0] = 0.19f; + nCloud.mColor[1] = 0.6f; + nCloud.mColor[2] = 0.7f; + nCloud.mColor[3] = 0.12f; + nCloud.mFade = 0.10f; + nCloud.mMass.mMax = 30.0f; + nCloud.mMass.mMin = 10.0f; + nCloud.mSpawnRange.mMins[2] = -150; + nCloud.mSpawnRange.mMaxs[2] = 150; + + nCloud.mRotationChangeNext = 0;*/ + if (!tr.weatherSystem->weatherSlots[WEATHER_FOG].active) + tr.weatherSystem->activeWeatherTypes++; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 70; + tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; + tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + + imgType_t type = IMGTYPE_COLORALPHA; + int flags = IMGFLAG_CLAMPTOEDGE; + tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); + + VectorSet4(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.19f, 0.6f, 0.7f, 0.12f); + VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.12f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); + } + + /*else if (Q_stricmp(token, "outsideshake") == 0) + { + mOutside.mOutsideShake = !mOutside.mOutsideShake; + } + else if (Q_stricmp(token, "outsidepain") == 0) + { + mOutside.mOutsidePain = !mOutside.mOutsidePain; + }*/ + else + { + ri.Printf(PRINT_ALL, "Weather Effect: Please enter a valid command.\n"); + ri.Printf(PRINT_ALL, " die\n"); + ri.Printf(PRINT_ALL, " clear\n"); + ri.Printf(PRINT_ALL, " freeze\n"); + //ri.Printf(PRINT_ALL, " zone (mins) (maxs)\n"); + ri.Printf(PRINT_ALL, " wind\n"); + ri.Printf(PRINT_ALL, " constantwind (velocity)\n"); + ri.Printf(PRINT_ALL, " gustingwind\n"); + //ri.Printf( PRINT_ALL, " windzone (mins) (maxs) (velocity)\n" ); + ri.Printf(PRINT_ALL, " lightrain\n"); + ri.Printf(PRINT_ALL, " rain\n"); + ri.Printf(PRINT_ALL, " acidrain\n"); + ri.Printf(PRINT_ALL, " heavyrain\n"); + ri.Printf(PRINT_ALL, " snow\n"); + ri.Printf(PRINT_ALL, " spacedust\n"); + ri.Printf(PRINT_ALL, " sand\n"); + ri.Printf(PRINT_ALL, " fog\n"); + ri.Printf(PRINT_ALL, " heavyrainfog\n"); + ri.Printf(PRINT_ALL, " light_fog\n"); + //ri.Printf(PRINT_ALL, " outsideshake\n"); // not available in MP + //ri.Printf(PRINT_ALL, " outsidepain\n"); // not available in MP + } +} + +void R_WorldEffect_f(void) +{ + char temp[2048] = { 0 }; + ri.Cmd_ArgsBuffer(temp, sizeof(temp)); + RE_WorldEffectCommand(temp); +} + +void R_AddWeatherSurfaces() +{ + assert(tr.weatherSystem); + + if (tr.weatherSystem->activeWeatherTypes == 0 && + r_debugWeather->integer == 0) + return; + + R_AddDrawSurf( + (surfaceType_t *)&tr.weatherSystem->weatherSurface, + REFENTITYNUM_WORLD, + tr.weatherInternalShader, + 0, /* fogIndex */ + qfalse, /* dlightMap */ + qfalse, /* postRender */ + 0 /* cubemapIndex */ + ); +} + +float lerp(float a, float b, float t) +{ + return a + t * (b - a); } void RB_SurfaceWeather( srfWeather_t *surf ) @@ -263,59 +954,144 @@ void RB_SurfaceWeather( srfWeather_t *surf ) RB_EndSurface(); - RB_SimulateWeather(ws); - - DrawItem item = {}; - - item.renderState.stateBits = - GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - item.renderState.cullType = CT_FRONT_SIDED; - item.renderState.depthRange = { 0.0f, 1.0f }; - item.program = &tr.weatherShader; - - const size_t numAttribs = ARRAY_LEN(ws.attribsTemplate); - item.numAttributes = numAttribs; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, numAttribs); - memcpy( - item.attributes, - ws.attribsTemplate, - sizeof(*item.attributes) * numAttribs); - item.attributes[0].vbo = ws.vbo; - item.attributes[1].vbo = ws.vbo; - - item.draw.type = DRAW_COMMAND_ARRAYS; - item.draw.numInstances = 1; - item.draw.primitiveType = GL_POINTS; - item.draw.params.arrays.numVertices = RAIN_VERTEX_COUNT; - - const float *viewOrigin = backEnd.viewParms.ori.origin; - float centerZoneOffsetX = - std::floor((viewOrigin[0] / CHUNK_SIZE) + 0.5f) * CHUNK_SIZE; - float centerZoneOffsetY = - std::floor((viewOrigin[1] / CHUNK_SIZE) + 0.5f) * CHUNK_SIZE; - int chunkIndex = 0; - for (int y = -1; y <= 1; ++y) + const float numMinZonesX = std::floor((abs(tr.world->bmodels[0].bounds[0][0]) / CHUNK_EXTENDS) + 0.5f); + const float numMinZonesY = std::floor((abs(tr.world->bmodels[0].bounds[0][1]) / CHUNK_EXTENDS) + 0.5f); + + VectorCopy(tr.weatherSystem->constWindDirection, tr.weatherSystem->windDirection); + for (int i = 0; i < tr.weatherSystem->activeWindObjects; i++) + { + windObject_t *windObject = &tr.weatherSystem->windSlots[i]; + RB_UpdateWindObject(windObject); + VectorAdd(windObject->currentVelocity, tr.weatherSystem->windDirection, tr.weatherSystem->windDirection); + } + + for (int weatherType = 0; weatherType < NUM_WEATHER_TYPES; weatherType++) { - for (int x = -1; x <= 1; ++x, ++chunkIndex) + weatherObject_t *weatherObject = &ws.weatherSlots[weatherType]; + if (!weatherObject->active) + continue; + + if (weatherObject->vbo == nullptr) + GenerateRainModel( + tr.weatherSystem->weatherSlots[weatherType], + maxWeatherTypeParticles[weatherType]); + + RB_SimulateWeather(weatherObject); + + vec3_t viewOrigin; + VectorCopy(backEnd.viewParms.ori.origin, viewOrigin); + + const float frictionInverse = 0.7; + vec3_t envForce = { + tr.weatherSystem->windDirection[0] * frictionInverse, + tr.weatherSystem->windDirection[1] * frictionInverse, + -weatherObject->gravity + }; + weatherObject->currentVelocity[0] = lerp( + weatherObject->currentVelocity[0], + envForce[0], + backEnd.refdef.frameTime * 0.0005f); + weatherObject->currentVelocity[1] = lerp( + weatherObject->currentVelocity[1], + envForce[1], + backEnd.refdef.frameTime * 0.0005f); + weatherObject->currentVelocity[2] = lerp( + weatherObject->currentVelocity[2], + envForce[2], + backEnd.refdef.frameTime * 0.0005f); + + if (weatherObject->gravity != 0.0f) { - UniformDataWriter uniformDataWriter; - uniformDataWriter.Start(&tr.weatherShader); - uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3( - UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); - uniformDataWriter.SetUniformVec2( - UNIFORM_ZONEOFFSET, - centerZoneOffsetX + x * CHUNK_SIZE, - centerZoneOffsetY + y * CHUNK_SIZE); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.floatTime); - item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); - - item.draw.params.arrays.firstVertex = RAIN_VERTEX_COUNT * chunkIndex; - - uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); - RB_AddDrawItem(backEndData->currentPass, key, item); + vec3_t windOffsetPerHeight = { + weatherObject->currentVelocity[0], + weatherObject->currentVelocity[1], + 0.0f }; + VectorScale(windOffsetPerHeight, 1.0f / weatherObject->currentVelocity[2], windOffsetPerHeight); + VectorMA( + viewOrigin, + tr.world->bmodels[0].bounds[1][2] - viewOrigin[2], + windOffsetPerHeight, + viewOrigin); + } + + float centerZoneOffsetX = + std::floor((viewOrigin[0] / CHUNK_EXTENDS) + 0.5f); + float centerZoneOffsetY = + std::floor((viewOrigin[1] / CHUNK_EXTENDS) + 0.5f); + + DrawItem item = {}; + + if (weatherType == WEATHER_SAND) + item.renderState.stateBits = + GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + else + item.renderState.stateBits = + GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; + item.renderState.cullType = CT_FRONT_SIDED; + item.renderState.depthRange = { 0.0f, 1.0f }; + item.program = &tr.weatherShader; + + const size_t numAttribs = ARRAY_LEN(weatherObject->attribsTemplate); + item.numAttributes = numAttribs; + item.attributes = ojkAllocArray( + *backEndData->perFrameMemory, numAttribs); + memcpy( + item.attributes, + weatherObject->attribsTemplate, + sizeof(*item.attributes) * numAttribs); + item.attributes[0].vbo = weatherObject->vbo; + item.attributes[1].vbo = weatherObject->vbo; + + item.draw.type = DRAW_COMMAND_ARRAYS; + item.draw.numInstances = 1; + item.draw.primitiveType = GL_POINTS; + item.draw.params.arrays.numVertices = weatherObject->particleCount; + + int chunkIndex = 0; + for (int y = -1; y <= 1; ++y) + { + for (int x = -1; x <= 1; ++x) + { + UniformDataWriter uniformDataWriter; + uniformDataWriter.Start(&tr.weatherShader); + uniformDataWriter.SetUniformMatrix4x4( + UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); + uniformDataWriter.SetUniformVec3( + UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); + uniformDataWriter.SetUniformVec2( + UNIFORM_ZONEOFFSET, + (centerZoneOffsetX + x) * CHUNK_EXTENDS, + (centerZoneOffsetY + y) * CHUNK_EXTENDS); + uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.frameTime); + uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, weatherObject->color); + vec4_t viewInfo = { + weatherObject->size[0], + weatherObject->size[1], + 0.0f, + weatherObject->fadeDistance + }; + uniformDataWriter.SetUniformVec4(UNIFORM_VIEWINFO, viewInfo); + uniformDataWriter.SetUniformMatrix4x4(UNIFORM_SHADOWMVP, tr.weatherSystem->weatherMVP); + item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + + SamplerBindingsWriter samplerBindingsWriter; + samplerBindingsWriter.AddStaticImage(tr.weatherDepthImage, TB_SHADOWMAP); + if (weatherObject->drawImage != NULL) + samplerBindingsWriter.AddStaticImage(weatherObject->drawImage, TB_DIFFUSEMAP); + else + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_DIFFUSEMAP); + + Allocator& frameAllocator = *backEndData->perFrameMemory; + item.samplerBindings = samplerBindingsWriter.Finish( + frameAllocator, &item.numSamplerBindings); + + chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3; + chunkIndex+= (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3; + item.draw.params.arrays.firstVertex = weatherObject->particleCount * chunkIndex; + + uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); + RB_AddDrawItem(backEndData->currentPass, key, item); + } } } } diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index 654aed3c48..991a2cd63a 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -30,3 +30,5 @@ void R_InitWeatherForMap(); void R_AddWeatherSurfaces(); void R_ShutdownWeatherSystem(); void RB_SurfaceWeather( srfWeather_t *surfaceType ); + +void R_WorldEffect_f(void); From d970b62026e302f59fb786efc45441c7cea8ba5b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 14 Oct 2022 00:11:19 +0200 Subject: [PATCH 582/708] Implementing fx surface sprites Basic support for fx surface sprites. Missing handling of global wind. --- codemp/rd-rend2/glsl/surface_sprites.glsl | 98 +++++++++++++++++++---- codemp/rd-rend2/tr_backend.cpp | 12 +-- codemp/rd-rend2/tr_bsp.cpp | 27 ++++++- codemp/rd-rend2/tr_glsl.cpp | 10 ++- codemp/rd-rend2/tr_local.h | 19 +++-- codemp/rd-rend2/tr_surface.cpp | 13 ++- 6 files changed, 146 insertions(+), 33 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index e229248e89..4bc33cd26f 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -1,10 +1,21 @@ /*[Vertex]*/ -in vec3 attr_Position; +in vec4 attr_Position; // x, y, z, random value [0.0, 1.0] in vec3 attr_Normal; in vec3 attr_Color; +in vec4 attr_Position2; // width, height, skew.x, skew.y uniform mat4 u_ModelViewProjectionMatrix; +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; + float u_frameTime; +}; + layout(std140) uniform Camera { vec4 u_ViewInfo; @@ -16,34 +27,47 @@ layout(std140) uniform Camera layout(std140) uniform SurfaceSprite { - float u_Width; - float u_Height; + vec2 u_FxGrow; + float u_FxDuration; float u_FadeStartDistance; float u_FadeEndDistance; float u_FadeScale; - float u_WidthVariance; - float u_HeightVariance; + float u_Wind; + float u_WindIdle; + float u_FxAlphaStart; + float u_FxAlphaEnd; }; out vec2 var_TexCoords; out float var_Alpha; out vec3 var_Color; +#if defined(FX_SPRITE) +out float var_Effectpos; +#endif + #if defined(USE_FOG) out vec3 var_WSPosition; #endif void main() { - vec3 V = u_ViewOrigin - attr_Position; + vec3 V = u_ViewOrigin - attr_Position.xyz; - float width = u_Width * (1.0 + u_WidthVariance*0.5); - float height = u_Height * (1.0 + u_HeightVariance*0.5); + float width = attr_Position2.x; + float height = attr_Position2.y; + vec2 skew = attr_Position2.zw; float distanceToCamera = length(V); float fadeScale = smoothstep(u_FadeStartDistance, u_FadeEndDistance, distanceToCamera); - width += u_FadeScale * fadeScale * u_Width; + width += u_FadeScale * fadeScale * width; + +#if defined(FX_SPRITE) + var_Effectpos = fract((u_frameTime+10000.0*attr_Position.w) / u_FxDuration); + width += var_Effectpos * width * u_FxGrow.x; + height += var_Effectpos * height * u_FxGrow.y; +#endif float halfWidth = width * 0.5; vec3 offsets[] = vec3[]( @@ -52,7 +76,7 @@ void main() vec3( halfWidth, halfWidth, 0.0), vec3(-halfWidth, halfWidth, 0.0), vec3(-halfWidth, -halfWidth, 0.0) -#else +#else vec3( halfWidth, 0.0, 0.0), vec3( halfWidth, 0.0, height), vec3(-halfWidth, 0.0, height), @@ -69,15 +93,27 @@ void main() vec3 offset = offsets[gl_VertexID % 4]; + #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); offset.xy = offset.x*vec2(toCamera.y, -toCamera.x); #elif !defined(FACE_UP) + // Make this sprite face in some direction in direction of the camera + vec2 toCamera = normalize(V.xy); + offset.xy = offset.x * (attr_Normal.xy + 3.0 * vec2(toCamera.y, -toCamera.x)) * 0.25; +#else // Make this sprite face in some direction - offset.xy = offset.x*attr_Normal.xy; + // offset.xy = offset.x * attr_Normal.xy; +#endif + +#if !defined(FACE_UP) && !defined(FX_SPRITE) + offset.xy += mix(skew, vec2(0.0), offset.z == 0.0); + float angle = (attr_Position.x + attr_Position.y) * 0.02 + (u_frameTime * 0.0015); + float windsway = mix(height* u_WindIdle * 0.075, 0.0, offset.z == 0.0); + offset.xy += vec2(cos(angle), sin(angle)) * windsway; #endif - vec4 worldPos = vec4(attr_Position + offset, 1.0); + vec4 worldPos = vec4(attr_Position.xyz + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; var_TexCoords = texcoords[gl_VertexID % 4]; var_Color = attr_Color; @@ -94,19 +130,25 @@ in vec2 var_TexCoords; in vec3 var_Color; in float var_Alpha; +#if defined(FX_SPRITE) +in float var_Effectpos; +#endif + #if defined(USE_FOG) in vec3 var_WSPosition; #endif layout(std140) uniform SurfaceSprite { - float u_Width; - float u_Height; + vec2 u_FxGrow; + float u_FxDuration; float u_FadeStartDistance; float u_FadeEndDistance; float u_FadeScale; - float u_WidthVariance; - float u_HeightVariance; + float u_Wind; + float u_WindIdle; + float u_FxAlphaStart; + float u_FxAlphaEnd; }; #if defined(USE_FOG) @@ -134,6 +176,7 @@ layout(std140) uniform Fogs }; uniform int u_FogIndex; +uniform vec4 u_FogColorMask; #endif #if defined(ALPHA_TEST) @@ -181,6 +224,21 @@ void main() out_Color.rgb *= var_Color; out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; +#if defined(FX_SPRITE) + float fxalpha = u_FxAlphaEnd - u_FxAlphaStart; + if (u_FxAlphaEnd < 0.05) + { + if (var_Effectpos > 0.5) + out_Color.a *= u_FxAlphaStart + (fxalpha * (var_Effectpos - 0.5) * 2.0); + else + out_Color.a *= u_FxAlphaStart + (fxalpha * (0.5 - var_Effectpos) * 2.0); + } + else + { + out_Color.a *= u_FxAlphaStart + (fxalpha * var_Effectpos); + } +#endif + #if defined(ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) { @@ -207,8 +265,16 @@ void main() #if defined(USE_FOG) Fog fog = u_Fogs[u_FogIndex]; float fogFactor = CalcFog(u_ViewOrigin, var_WSPosition, fog); +#if defined(ADDITIVE_BLEND) + out_Color.rgb *= fog.color.rgb * (1.0 - fogFactor); +#else out_Color.rgb = mix(out_Color.rgb, fog.color.rgb, fogFactor); #endif +#endif + +#if defined(ADDITIVE_BLEND) + out_Color.rgb *= out_Color.a; +#endif out_Glow = vec4(0.0); } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 604131d2eb..7dd877a2a9 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2770,14 +2770,16 @@ static void Fill_SpriteBlock( srfSprites_t *surf , SurfaceSpriteBlock *surfaceSp { const surfaceSprite_t *ss = surf->sprite; - surfaceSpriteBlock->width = ss->width; - surfaceSpriteBlock->height = - (ss->facing == SURFSPRITE_FACING_DOWN) ? -ss->height : ss->height; + surfaceSpriteBlock->fxGrow[0] = ss->fxGrow[0]; + surfaceSpriteBlock->fxGrow[1] = ss->fxGrow[1]; + surfaceSpriteBlock->fxDuration = ss->fxDuration; surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; surfaceSpriteBlock->fadeEndDistance = ss->fadeMax; surfaceSpriteBlock->fadeScale = ss->fadeScale; - surfaceSpriteBlock->widthVariance = ss->variance[0]; - surfaceSpriteBlock->heightVariance = ss->variance[1]; + surfaceSpriteBlock->wind = ss->wind; + surfaceSpriteBlock->windIdle = ss->windIdle; + surfaceSpriteBlock->fxAlphaStart = ss->fxAlphaStart; + surfaceSpriteBlock->fxAlphaEnd = ss->fxAlphaEnd; } static void RB_UpdateSpriteConstants( diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 69a6c25002..cabe44578d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3591,9 +3591,11 @@ static void R_CalcVertexLightDirs( world_t *worldData ) struct sprite_t { - vec3_t position; + vec4_t position; vec3_t normal; vec3_t color; + vec2_t widthHeight; + vec2_t skew; }; static uint32_t UpdateHash( const char *text, uint32_t hash ) @@ -3688,6 +3690,7 @@ static std::vector R_CreateSurfaceSpritesVertexData( VectorMA(sprite.position, x, p0, sprite.position); VectorMA(sprite.position, y, p1, sprite.position); VectorMA(sprite.position, z, p2, sprite.position); + sprite.position[3] = flrand(0.0f, 1.0f); if (vertexLit) { @@ -3708,6 +3711,14 @@ static std::vector R_CreateSurfaceSpritesVertexData( VectorSet(sprite.normal, nx, ny, 0.0f); + sprite.widthHeight[0] = stage->ss->width*(1.0f + (stage->ss->variance[0] * flrand(0.0f, 1.0f))); + sprite.widthHeight[1] = stage->ss->height*(1.0f + (stage->ss->variance[1] * flrand(0.0f, 1.0f))); + if (stage->ss->facing == SURFSPRITE_FACING_DOWN) + sprite.widthHeight[1] *= -1.0f; + + sprite.skew[0] = stage->ss->height * stage->ss->vertSkew * flrand(-1.0f, 1.0f); + sprite.skew[1] = stage->ss->height * stage->ss->vertSkew * flrand(-1.0f, 1.0f); + // We have 4 copies for each corner of the quad sprites.push_back(sprite); sprites.push_back(sprite); @@ -3764,13 +3775,13 @@ static void R_GenerateSurfaceSprites( out->shader->stages[0]->glslShaderGroup = tr.spriteShader; out->alphaTestType = stage->alphaTestType; - out->numAttributes = 3; + out->numAttributes = 4; out->attributes = (vertexAttribute_t *)ri.Hunk_Alloc( sizeof(vertexAttribute_t) * out->numAttributes, h_low); out->attributes[0].vbo = out->vbo; out->attributes[0].index = ATTR_INDEX_POSITION; - out->attributes[0].numComponents = 3; + out->attributes[0].numComponents = 4; out->attributes[0].integerAttribute = qfalse; out->attributes[0].type = GL_FLOAT; out->attributes[0].normalize = GL_FALSE; @@ -3797,6 +3808,16 @@ static void R_GenerateSurfaceSprites( out->attributes[2].stride = sizeof(sprite_t); out->attributes[2].offset = offsetof(sprite_t, color); out->attributes[2].stepRate = 0; + + out->attributes[3].vbo = out->vbo; + out->attributes[3].index = ATTR_INDEX_POSITION2; + out->attributes[3].numComponents = 4; // store width,height and skew + out->attributes[3].integerAttribute = qfalse; + out->attributes[3].type = GL_FLOAT; + out->attributes[3].normalize = GL_FALSE; + out->attributes[3].stride = sizeof(sprite_t); + out->attributes[3].offset = offsetof(sprite_t, widthHeight); + out->attributes[3].stepRate = 0; } static void R_GenerateSurfaceSprites( const world_t *world ) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d295c8431c..e103b9869b 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2198,7 +2198,7 @@ static int GLSL_LoadGPUProgramSurfaceSprites( char extradefines[1200]; const GPUProgramDesc *programDesc = LoadProgramSource("surface_sprites", allocator, fallback_surface_spritesProgram); - const uint32_t attribs = ATTR_POSITION | ATTR_NORMAL | ATTR_COLOR; + const uint32_t attribs = ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_COLOR; for ( int i = 0; i < SSDEF_COUNT; ++i ) { extradefines[0] = '\0'; @@ -2213,6 +2213,10 @@ static int GLSL_LoadGPUProgramSurfaceSprites( Q_strcat(extradefines, sizeof(extradefines), "#define FACE_UP\n"); + if (i & SSDEF_FX_SPRITE) + Q_strcat(extradefines, sizeof(extradefines), + "#define FX_SPRITE\n"); + if ( i & SSDEF_USE_FOG ) Q_strcat(extradefines, sizeof(extradefines), "#define USE_FOG\n"); @@ -2221,6 +2225,10 @@ static int GLSL_LoadGPUProgramSurfaceSprites( Q_strcat(extradefines, sizeof(extradefines), "#define ALPHA_TEST\n"); + if (i & SSDEF_ADDITIVE) + Q_strcat(extradefines, sizeof(extradefines), + "#define ADDITIVE_BLEND\n"); + shaderProgram_t *program = tr.spriteShader + i; if (!GLSL_LoadGPUShader(builder, program, "surface_sprites", attribs, NO_XFB_VARS, extradefines, *programDesc)) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 16d601854a..adae0f66ba 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -683,14 +683,16 @@ enum surfaceSpriteOrientation_t struct SurfaceSpriteBlock { - float width; - float height; + vec2_t fxGrow; + float fxDuration; float fadeStartDistance; float fadeEndDistance; float fadeScale; - float widthVariance; - float heightVariance; - float pad0; + float wind; + float windIdle; + float fxAlphaStart; + float fxAlphaEnd; + float pad0[2]; }; struct CameraBlock @@ -1218,9 +1220,12 @@ enum SSDEF_FACE_CAMERA = 0x01, SSDEF_ALPHA_TEST = 0x02, SSDEF_FACE_UP = 0x04, - SSDEF_USE_FOG = 0x08, + SSDEF_FX_SPRITE = 0x08, + SSDEF_USE_FOG = 0x10, + SSDEF_FOG_MODULATE = 0x20, + SSDEF_ADDITIVE = 0x40, - SSDEF_ALL = 0x0F, + SSDEF_ALL = 0x7F, SSDEF_COUNT = SSDEF_ALL + 1 }; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 639d62c26f..03a4ccdc3e 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2161,7 +2161,16 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) if ( ss->type == SURFSPRITE_ORIENTED ) shaderFlags |= SSDEF_FACE_CAMERA; - if ( surf->fogIndex != -1) + if (ss->facing == SURFSPRITE_FACING_UP) + shaderFlags |= SSDEF_FACE_UP; + + if (ss->type == SURFSPRITE_EFFECT || ss->type == SURFSPRITE_WEATHERFX) + shaderFlags |= SSDEF_FX_SPRITE; + + if ((firstStage->stateBits & (GLS_SRCBLEND_BITS|GLS_DSTBLEND_BITS)) == (GLS_SRCBLEND_ONE|GLS_DSTBLEND_ONE)) + shaderFlags |= SSDEF_ADDITIVE; + + if (surf->fogIndex > 0) shaderFlags |= SSDEF_USE_FOG; shaderProgram_t *program = programGroup + shaderFlags; @@ -2170,6 +2179,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) UniformDataWriter uniformDataWriter; uniformDataWriter.Start(program); + // FIXME: Use entity block for this uniformDataWriter.SetUniformMatrix4x4( UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); @@ -2192,6 +2202,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, { currentFrameUbo, offset, UNIFORM_BLOCK_SURFACESPRITE }, { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS } From b9c58e15561f13357be4a5a61ad0493c21cc77f5 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 14 Oct 2022 00:13:21 +0200 Subject: [PATCH 583/708] Remove shadow comparison for pshadows for now, as we currently don't use shadow sampler for them. Setting this will result in UB when shadow sampler aren't used. --- codemp/rd-rend2/tr_image.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index dc6d067463..d698e82572 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3509,7 +3509,7 @@ void R_CreateBuiltinImages( void ) { PSHADOW_MAP_SIZE, MAX_DRAWN_PSHADOWS, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT16); } From 6802ebe8b9f46919f176c39631caffd7a95f1e3f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 14 Oct 2022 23:01:03 +0200 Subject: [PATCH 584/708] Implement ghoul2 sabermarks --- codemp/rd-rend2/CMakeLists.txt | 2 + codemp/rd-rend2/G2_gore_r2.cpp | 45 ++++++++++++ codemp/rd-rend2/G2_gore_r2.h | 48 +++++++++++++ codemp/rd-rend2/G2_misc.cpp | 125 +++++++++++++++------------------ codemp/rd-rend2/tr_ghoul2.cpp | 25 ++++++- codemp/rd-rend2/tr_init.cpp | 46 ++++++++++++ codemp/rd-rend2/tr_local.h | 42 ++++++++++- codemp/rd-rend2/tr_vbo.cpp | 38 ++++++++++ 8 files changed, 299 insertions(+), 72 deletions(-) create mode 100644 codemp/rd-rend2/G2_gore_r2.cpp create mode 100644 codemp/rd-rend2/G2_gore_r2.h diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 8494165004..2ec9be05d2 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -18,6 +18,8 @@ set(MPRend2Files "${MPDir}/rd-rend2/G2_API.cpp" "${MPDir}/rd-rend2/G2_bolts.cpp" "${MPDir}/rd-rend2/G2_bones.cpp" + "${MPDir}/rd-rend2/G2_gore_r2.cpp" + "${MPDir}/rd-rend2/G2_gore_r2.h" "${MPDir}/rd-rend2/G2_misc.cpp" "${MPDir}/rd-rend2/G2_surfaces.cpp" "${MPDir}/rd-rend2/tr_allocator.cpp" diff --git a/codemp/rd-rend2/G2_gore_r2.cpp b/codemp/rd-rend2/G2_gore_r2.cpp new file mode 100644 index 0000000000..260097c9eb --- /dev/null +++ b/codemp/rd-rend2/G2_gore_r2.cpp @@ -0,0 +1,45 @@ +/* +=========================================================================== +Copyright (C) 2000 - 2013, Raven Software, Inc. +Copyright (C) 2001 - 2013, Activision, Inc. +Copyright (C) 2013 - 2015, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#include "G2_gore_r2.h" +#include "../rd-common/tr_common.h" + +R2GoreTextureCoordinates::R2GoreTextureCoordinates() +{ + Com_Memset (tex, 0, sizeof (tex)); +} + +R2GoreTextureCoordinates::~R2GoreTextureCoordinates() +{ + for ( int i = 0; i < MAX_LODS; i++ ) + { + if ( tex[i] ) + { + ri.Z_Free(tex[i]->verts); + tex[i]->verts = NULL; + ri.Z_Free(tex[i]->indexes); + tex[i]->indexes = NULL; + ri.Z_Free(tex[i]); + tex[i] = NULL; + } + } +} diff --git a/codemp/rd-rend2/G2_gore_r2.h b/codemp/rd-rend2/G2_gore_r2.h new file mode 100644 index 0000000000..2ae4abb181 --- /dev/null +++ b/codemp/rd-rend2/G2_gore_r2.h @@ -0,0 +1,48 @@ +/* +=========================================================================== +Copyright (C) 2000 - 2013, Raven Software, Inc. +Copyright (C) 2001 - 2013, Activision, Inc. +Copyright (C) 2013 - 2015, OpenJK contributors + +This file is part of the OpenJK source code. + +OpenJK is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License version 2 as +published by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, see . +=========================================================================== +*/ + +#pragma once + +#include "tr_local.h" + +#ifdef _G2_GORE + +#define MAX_LODS (8) +#define MAX_GORE_VERTS (3000) +#define MAX_GORE_INDECIES (6000) + +//TODO: This needs to be set via a scalability cvar with some reasonable minimum value if pgore is used at all +#define MAX_GORE_RECORDS (500) + +struct R2GoreTextureCoordinates +{ + srfG2GoreSurface_t *tex[MAX_LODS]; + + R2GoreTextureCoordinates(); + ~R2GoreTextureCoordinates(); +}; + +int AllocR2GoreRecord(); +R2GoreTextureCoordinates *FindR2GoreRecord(int tag); +void DeleteR2GoreRecord(int tag); + +#endif diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 2d98e9ef88..0d007e35af 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -7,6 +7,7 @@ #ifdef _G2_GORE #include "ghoul2/G2_gore.h" +#include "G2_gore_r2.h" #define GORE_TAG_UPPER (256) #define GORE_TAG_MASK (~255) @@ -14,43 +15,41 @@ static int CurrentTag=GORE_TAG_UPPER+1; static int CurrentTagUpper=GORE_TAG_UPPER; -static std::map GoreRecords; +static std::map GoreRecords; static std::map,int> GoreTagsTemp; // this is a surface index to gore tag map used only // temporarily during the generation phase so we reuse gore tags per LOD int goreModelIndex; static cvar_t *cg_g2MarksAllModels=NULL; -GoreTextureCoordinates *FindGoreRecord(int tag); +R2GoreTextureCoordinates *FindR2GoreRecord(int tag); static inline void DestroyGoreTexCoordinates(int tag) { - GoreTextureCoordinates *gTC = FindGoreRecord(tag); + R2GoreTextureCoordinates *gTC = FindR2GoreRecord(tag); if (!gTC) { return; } - gTC->~GoreTextureCoordinates(); + gTC->~R2GoreTextureCoordinates(); //I don't know what's going on here, it should call the destructor for //this when it erases the record but sometimes it doesn't. -rww } -//TODO: This needs to be set via a scalability cvar with some reasonable minimum value if pgore is used at all -#define MAX_GORE_RECORDS (500) -int AllocGoreRecord() +int AllocR2GoreRecord() { while (GoreRecords.size()>MAX_GORE_RECORDS) { int tagHigh=(*GoreRecords.begin()).first&GORE_TAG_MASK; - std::map::iterator it; - GoreTextureCoordinates *gTC; + std::map::iterator it; + R2GoreTextureCoordinates *gTC; it = GoreRecords.begin(); gTC = &(*it).second; if (gTC) { - gTC->~GoreTextureCoordinates(); + gTC->~R2GoreTextureCoordinates(); } GoreRecords.erase(GoreRecords.begin()); while (GoreRecords.size()) @@ -64,13 +63,13 @@ int AllocGoreRecord() if (gTC) { - gTC->~GoreTextureCoordinates(); + gTC->~R2GoreTextureCoordinates(); } GoreRecords.erase(GoreRecords.begin()); } } int ret=CurrentTag; - GoreRecords[CurrentTag]=GoreTextureCoordinates(); + GoreRecords[CurrentTag]= R2GoreTextureCoordinates(); CurrentTag++; return ret; } @@ -82,9 +81,9 @@ void ResetGoreTag() CurrentTagUpper+=GORE_TAG_UPPER; } -GoreTextureCoordinates *FindGoreRecord(int tag) +R2GoreTextureCoordinates *FindR2GoreRecord(int tag) { - std::map::iterator i=GoreRecords.find(tag); + std::map::iterator i=GoreRecords.find(tag); if (i!=GoreRecords.end()) { return &(*i).second; @@ -94,10 +93,10 @@ GoreTextureCoordinates *FindGoreRecord(int tag) void *G2_GetGoreRecord(int tag) { - return FindGoreRecord(tag); + return FindR2GoreRecord(tag); } -void DeleteGoreRecord(int tag) +void DeleteR2GoreRecord(int tag) { DestroyGoreTexCoordinates(tag); GoreRecords.erase(tag); @@ -147,7 +146,7 @@ CGoreSet::~CGoreSet() std::multimap::iterator i; for (i=mGoreRecords.begin();i!=mGoreRecords.end();i++) { - DeleteGoreRecord((*i).second.mGoreTag); + DeleteR2GoreRecord((*i).second.mGoreTag); } }; #endif // _SOF2 @@ -765,12 +764,9 @@ struct SVertexTemp } }; -#define MAX_GORE_VERTS (3000) static SVertexTemp GoreVerts[MAX_GORE_VERTS]; static int GoreIndexCopy[MAX_GORE_VERTS]; static int GoreTouch=1; - -#define MAX_GORE_INDECIES (6000) static int GoreIndecies[MAX_GORE_INDECIES]; #define GORE_MARGIN (0.0f) @@ -935,7 +931,7 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu std::map,int>::iterator f=GoreTagsTemp.find(std::pair(goreModelIndex,TS.surfaceNum)); if (f==GoreTagsTemp.end()) // need to generate a record { - newTag=AllocGoreRecord(); + newTag=AllocR2GoreRecord(); CGoreSet *goreSet=0; if (TS.ghoul2info->mGoreSetTag) { @@ -979,66 +975,57 @@ void G2_GorePolys( const mdxmSurface_t *surface, CTraceSurface &TS, const mdxmSu { newTag=(*f).second; } - GoreTextureCoordinates *gore=FindGoreRecord(newTag); + R2GoreTextureCoordinates *gore= FindR2GoreRecord(newTag); if (gore) { - assert(sizeof(float)==sizeof(int)); - // data block format: - unsigned int size= - sizeof(int)+ // num verts - sizeof(int)+ // num tris - sizeof(int)*newNumVerts+ // which verts to copy from original surface - sizeof(float)*4*newNumVerts+ // storgage for deformed verts - sizeof(float)*4*newNumVerts+ // storgage for deformed normal - sizeof(float)*2*newNumVerts+ // texture coordinates - sizeof(int)*newNumTris*3; // new indecies - - int *data=(int *)Z_Malloc ( sizeof(int)*size, TAG_GHOUL2_GORE, qtrue ); - + srfG2GoreSurface_t *goreSurface=(srfG2GoreSurface_t *)Z_Malloc ( sizeof(srfG2GoreSurface_t), TAG_GHOUL2_GORE, qtrue ); if ( gore->tex[TS.lod] ) { + if (gore->tex[TS.lod]->verts) + Z_Free(gore->tex[TS.lod]->verts); + if (gore->tex[TS.lod]->indexes) + Z_Free(gore->tex[TS.lod]->indexes); Z_Free(gore->tex[TS.lod]); } - gore->tex[TS.lod]=(float *)data; - *data++=newNumVerts; - *data++=newNumTris; - - memcpy(data,GoreIndexCopy,sizeof(int)*newNumVerts); - data+=newNumVerts*9; // skip verts and normals - float *fdata=(float *)data; + gore->tex[TS.lod]=(srfG2GoreSurface_t *)goreSurface; + goreSurface->numVerts = newNumVerts; + goreSurface->verts = (g2GoreVert_t *)Z_Malloc(sizeof(g2GoreVert_t)*newNumVerts, TAG_GHOUL2_GORE, qtrue); for (j=0;jverts[j].texCoords[0] = GoreVerts[GoreIndexCopy[j]].tex[0]; + goreSurface->verts[j].texCoords[1] = GoreVerts[GoreIndexCopy[j]].tex[1]; } - data=(int *)fdata; - memcpy(data,GoreIndecies,sizeof(int)*newNumTris*3); - data+=newNumTris*3; - assert((data-(int *)gore->tex[TS.lod])*sizeof(int)==size); - fdata = (float *)data; - // build the entity to gore matrix - VectorCopy(saxis,fdata+0); - VectorCopy(taxis,fdata+4); - VectorCopy(TS.rayEnd,fdata+8); - VectorNormalize(fdata+0); - VectorNormalize(fdata+4); - VectorNormalize(fdata+8); - fdata[3]=-0.5f; // subtract texture center - fdata[7]=-0.5f; - fdata[11]=0.0f; - vec3_t shotOriginInCurrentSpace; // unknown space - TransformPoint(TS.rayStart,shotOriginInCurrentSpace,(mdxaBone_t *)fdata); // dest middle arg - // this will insure the shot origin in our unknown space is now the shot origin, making it a known space - fdata[3]-=shotOriginInCurrentSpace[0]; - fdata[7]-=shotOriginInCurrentSpace[1]; - fdata[11]-=shotOriginInCurrentSpace[2]; - Inverse_Matrix((mdxaBone_t *)fdata,(mdxaBone_t *)(fdata+12)); // dest 2nd arg - data+=24; - -// assert((data - (int *)gore->tex[TS.lod]) * sizeof(int) == size); + + mdxmVertex_t *v = (mdxmVertex_t *)((byte *)surface + surface->ofsVerts); + int *boneRef = (int *)((byte *)surface + surface->ofsBoneReferences); + for (j = 0; j < newNumVerts; j++) + { + mdxmVertex_t currentVert = v[GoreIndexCopy[j]]; + VectorCopy(currentVert.vertCoords, goreSurface->verts[j].position); + goreSurface->verts[j].normal = R_VboPackNormal(currentVert.normal); + + int numWeights = G2_GetVertWeights(¤tVert); + float fTotalWeight = 0.0f; + for (int w = 0; w < numWeights; w++) + { + float weight = G2_GetVertBoneWeight(¤tVert, w, fTotalWeight, numWeights); + goreSurface->verts[j].weights[w] = (byte)(weight * 255.0f); + int packedIndex = G2_GetVertBoneIndex(¤tVert, w); + goreSurface->verts[j].bonerefs[w] = boneRef[packedIndex]; + } + } + + goreSurface->indexes = (glIndex_t *)Z_Malloc(sizeof(glIndex_t)*newNumTris*3, TAG_GHOUL2_GORE, qtrue); + for (j = 0; j < newNumTris * 3; j++) + { + goreSurface->indexes[j] = GoreIndecies[j] + tr.goreVBOCurrentIndex; + } + goreSurface->numIndexes = newNumTris * 3; + + RB_UpdateGoreVBO(goreSurface); } } #else diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index ed6746b1ea..388797bbc3 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -5,7 +5,7 @@ #include "ghoul2/G2.h" #include "ghoul2/g2_local.h" #ifdef _G2_GORE -#include "ghoul2/G2_gore.h" +#include "G2_gore_r2.h" #endif #ifdef _MSC_VER @@ -2428,7 +2428,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum auto kcur = k; k++; - GoreTextureCoordinates *tex = FindGoreRecord(kcur->second.mGoreTag); + R2GoreTextureCoordinates *tex = FindR2GoreRecord(kcur->second.mGoreTag); if (!tex || // it is gone, lets get rid of it (kcur->second.mDeleteTime && curTime >= kcur->second.mDeleteTime)) // out of time @@ -3494,6 +3494,27 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) RB_EndSurface(); RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); + if (surf->alternateTex) + { + R_BindVBO(tr.goreVBO); + R_BindIBO(tr.goreIBO); + + tess.numIndexes = surf->alternateTex->numIndexes; + tess.numVertexes = surf->alternateTex->numVerts; + tess.useInternalVBO = qfalse; + tess.externalIBO = tr.goreIBO; + tess.dlightBits = surf->dlightBits; + tess.minIndex = surf->alternateTex->firstVert; + tess.maxIndex = surf->alternateTex->firstVert + surf->alternateTex->numVerts; + tess.firstIndex = surf->alternateTex->firstIndex; + + glState.skeletalAnimation = qtrue; + RB_EndSurface(); + // So we don't lerp surfaces that shouldn't be lerped + glState.skeletalAnimation = qfalse; + return; + } + R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index a74dc6ad60..511984bfbf 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -28,6 +28,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_weather.h" #include +#ifdef _G2_GORE +#include "G2_gore_r2.h" +#endif + static size_t STATIC_UNIFORM_BUFFER_SIZE = 1 * 1024 * 1024; static size_t FRAME_UNIFORM_BUFFER_SIZE = 8*1024*1024; static size_t FRAME_VERTEX_BUFFER_SIZE = 12*1024*1024; @@ -1721,6 +1725,44 @@ static void R_InitBackEndFrameData() backEndData->currentFrame = backEndData->frames; } +#ifdef _G2_GORE +static void R_InitGoreVao() +{ + tr.goreVBO = R_CreateVBO( + nullptr, + sizeof(g2GoreVert_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS, + VBO_USAGE_DYNAMIC); + tr.goreVBO->offsets[ATTR_INDEX_POSITION] = offsetof(g2GoreVert_t, position); + tr.goreVBO->offsets[ATTR_INDEX_NORMAL] = offsetof(g2GoreVert_t, normal); + tr.goreVBO->offsets[ATTR_INDEX_TEXCOORD0] = offsetof(g2GoreVert_t, texCoords); + tr.goreVBO->offsets[ATTR_INDEX_BONE_INDEXES] = offsetof(g2GoreVert_t, bonerefs); + tr.goreVBO->offsets[ATTR_INDEX_BONE_WEIGHTS] = offsetof(g2GoreVert_t, weights); + tr.goreVBO->offsets[ATTR_INDEX_TANGENT] = offsetof(g2GoreVert_t, tangents); + + tr.goreVBO->strides[ATTR_INDEX_POSITION] = sizeof(g2GoreVert_t); + tr.goreVBO->strides[ATTR_INDEX_NORMAL] = sizeof(g2GoreVert_t); + tr.goreVBO->strides[ATTR_INDEX_TEXCOORD0] = sizeof(g2GoreVert_t); + tr.goreVBO->strides[ATTR_INDEX_BONE_INDEXES] = sizeof(g2GoreVert_t); + tr.goreVBO->strides[ATTR_INDEX_BONE_WEIGHTS] = sizeof(g2GoreVert_t); + tr.goreVBO->strides[ATTR_INDEX_TANGENT] = sizeof(g2GoreVert_t); + + tr.goreVBO->sizes[ATTR_INDEX_POSITION] = sizeof(vec3_t); + tr.goreVBO->sizes[ATTR_INDEX_NORMAL] = sizeof(uint32_t); + tr.goreVBO->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(vec2_t); + tr.goreVBO->sizes[ATTR_INDEX_BONE_WEIGHTS] = sizeof(byte); + tr.goreVBO->sizes[ATTR_INDEX_BONE_INDEXES] = sizeof(byte); + tr.goreVBO->sizes[ATTR_INDEX_TANGENT] = sizeof(uint32_t); + + tr.goreIBO = R_CreateIBO( + nullptr, + sizeof(glIndex_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES, + VBO_USAGE_DYNAMIC); + + tr.goreIBOCurrentIndex = 0; + tr.goreVBOCurrentIndex = 0; +} +#endif + static void R_InitStaticConstants() { @@ -1884,6 +1926,10 @@ void R_Init( void ) { R_InitBackEndFrameData(); R_InitImages(); +#ifdef _G2_GORE + R_InitGoreVao(); +#endif + FBO_Init(); GLSL_LoadGPUShaders(); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index adae0f66ba..fdccd26d88 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1650,6 +1650,36 @@ typedef struct #endif } srfVert_t; +#ifdef _G2_GORE +typedef struct +{ + vec3_t position; + uint32_t normal; + vec2_t texCoords; + byte bonerefs[4]; + byte weights[4]; + uint32_t tangents; +} g2GoreVert_t; + +typedef struct srfG2GoreSurface_s +{ + surfaceType_t surfaceType; + + // indexes + int numIndexes; + glIndex_t *indexes; + + // vertexes + int numVerts; + g2GoreVert_t *verts; + + // BSP VBO offsets + int firstVert; + int firstIndex; + +} srfG2GoreSurface_t; +#endif + // srfBspSurface_t covers SF_GRID, SF_TRIANGLES, SF_POLY, and SF_VBO_MESH typedef struct srfBspSurface_s { @@ -2515,6 +2545,13 @@ typedef struct trGlobals_s { unsigned int iboNames[MAX_IBOS]; IBO_t *ibos[MAX_IBOS]; +#ifdef _G2_GORE + VBO_t *goreVBO; + int goreVBOCurrentIndex; + IBO_t *goreIBO; + int goreIBOCurrentIndex; +#endif + // shader indexes from other modules will be looked up in tr.shaders[] // shader indexes from drawsurfs will be looked up in sortedShaders[] // lower indexed sortedShaders must be rendered first (opaque surfaces before translucent) @@ -3132,6 +3169,9 @@ void R_DestroyGPUBuffers(void); void R_VBOList_f(void); void RB_UpdateVBOs(unsigned int attribBits); +#ifdef _G2_GORE +void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface); +#endif void RB_CommitInternalBufferData(); void RB_BindUniformBlock(GLuint ubo, uniformBlock_t block, int offset); @@ -3268,7 +3308,7 @@ class CRenderableSurface #ifdef _G2_GORE // alternate texture coordinates - float *alternateTex; + srfG2GoreSurface_t *alternateTex; void *goreChain; float scale; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 361a69cde5..8583ed3aa7 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -643,6 +643,44 @@ void RB_UpdateVBOs(unsigned int attribBits) } } +#define MAX_GORE_VERTS (3000) +#define MAX_GORE_INDECIES (6000) +//TODO: This needs to be set via a scalability cvar with some reasonable minimum value if pgore is used at all +#define MAX_GORE_RECORDS (500) + +void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface) +{ + goreSurface->firstVert = tr.goreVBOCurrentIndex; + goreSurface->firstIndex = tr.goreIBOCurrentIndex; + + if (tr.goreVBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS)) + tr.goreVBOCurrentIndex = 0; + + R_BindVBO(tr.goreVBO); + GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; + void *dstPtr = qglMapBufferRange( + GL_ARRAY_BUFFER, + sizeof(g2GoreVert_t) * tr.goreVBOCurrentIndex, + sizeof(g2GoreVert_t) * goreSurface->numVerts, + mapFlags); + memcpy(dstPtr, (byte *)goreSurface->verts, sizeof(g2GoreVert_t)*goreSurface->numVerts); + qglUnmapBuffer(GL_ARRAY_BUFFER); + tr.goreVBOCurrentIndex += goreSurface->numVerts; + + if (tr.goreIBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES)) + tr.goreIBOCurrentIndex = 0; + + R_BindIBO(tr.goreIBO); + void *dst = qglMapBufferRange( + GL_ELEMENT_ARRAY_BUFFER, + sizeof(glIndex_t) * tr.goreIBOCurrentIndex, + sizeof(glIndex_t) * goreSurface->numIndexes, + mapFlags); + memcpy(dst, goreSurface->indexes, sizeof(glIndex_t) * goreSurface->numIndexes); + qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + tr.goreIBOCurrentIndex += goreSurface->numIndexes; +} + void RB_CommitInternalBufferData() { gpuFrame_t *currentFrame = backEndData->currentFrame; From 718ab571f735c5388363600a6de677e88a56c7de Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 15 Oct 2022 01:56:20 +0200 Subject: [PATCH 585/708] Properly set default vertex color for surfaces without color attribute. Also, don't activate vertex attributes that aren't present in the vbo. I initially thought that setting a stride of 0 will prevent OpenGL to fetch advancing data. Turns out, OpenGL will compute/guess the stride when a stride of 0 is provided... --- codemp/rd-rend2/qgl.h | 5 +++++ codemp/rd-rend2/tr_extensions.cpp | 10 ++++++++++ codemp/rd-rend2/tr_ghoul2.cpp | 23 +++++++---------------- codemp/rd-rend2/tr_init.cpp | 3 +++ codemp/rd-rend2/tr_model.cpp | 12 +----------- codemp/rd-rend2/tr_vbo.cpp | 6 ++++-- 6 files changed, 30 insertions(+), 29 deletions(-) diff --git a/codemp/rd-rend2/qgl.h b/codemp/rd-rend2/qgl.h index 69de9d8549..949413610b 100644 --- a/codemp/rd-rend2/qgl.h +++ b/codemp/rd-rend2/qgl.h @@ -382,6 +382,11 @@ extern PFNGLVERTEXATTRIBDIVISORPROC qglVertexAttribDivisor; extern PFNGLENABLEVERTEXATTRIBARRAYPROC qglEnableVertexAttribArray; extern PFNGLDISABLEVERTEXATTRIBARRAYPROC qglDisableVertexAttribArray; +extern PFNGLVERTEXATTRIB1FPROC qglVertexAttrib1f; +extern PFNGLVERTEXATTRIB2FPROC qglVertexAttrib2f; +extern PFNGLVERTEXATTRIB3FPROC qglVertexAttrib3f; +extern PFNGLVERTEXATTRIB4FPROC qglVertexAttrib4f; + // Vertex array objects extern PFNGLGENVERTEXARRAYSPROC qglGenVertexArrays; extern PFNGLDELETEVERTEXARRAYSPROC qglDeleteVertexArrays; diff --git a/codemp/rd-rend2/tr_extensions.cpp b/codemp/rd-rend2/tr_extensions.cpp index 565f7127fd..55bf6c9ffe 100644 --- a/codemp/rd-rend2/tr_extensions.cpp +++ b/codemp/rd-rend2/tr_extensions.cpp @@ -109,6 +109,11 @@ PFNGLGETVERTEXATTRIBIVPROC qglGetVertexAttribiv; PFNGLGETVERTEXATTRIBIIVPROC qglGetVertexAttribIiv; PFNGLGETVERTEXATTRIBIUIVPROC qglGetVertexAttribIuiv; +PFNGLVERTEXATTRIB1FPROC qglVertexAttrib1f; +PFNGLVERTEXATTRIB2FPROC qglVertexAttrib2f; +PFNGLVERTEXATTRIB3FPROC qglVertexAttrib3f; +PFNGLVERTEXATTRIB4FPROC qglVertexAttrib4f; + // Varying variables PFNGLTRANSFORMFEEDBACKVARYINGSPROC qglTransformFeedbackVaryings; PFNGLGETTRANSFORMFEEDBACKVARYINGPROC qglGetTransformFeedbackVarying; @@ -327,6 +332,11 @@ void GLimp_InitCoreFunctions() GetGLFunction (qglDeleteVertexArrays, "glDeleteVertexArrays", qtrue); GetGLFunction (qglBindVertexArray, "glBindVertexArray", qtrue); GetGLFunction (qglIsVertexArray, "glIsVertexArray", qtrue); + + GetGLFunction (qglVertexAttrib1f, "glVertexAttrib1f", qtrue); + GetGLFunction (qglVertexAttrib2f, "glVertexAttrib2f", qtrue); + GetGLFunction (qglVertexAttrib3f, "glVertexAttrib3f", qtrue); + GetGLFunction (qglVertexAttrib4f, "glVertexAttrib4f", qtrue); // Buffer objects qglGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &glRefConfig.uniformBufferOffsetAlignment); diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 388797bbc3..e5471621b6 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -4103,11 +4103,10 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & byte *bonerefs; byte *weights; uint32_t *tangents; - vec4_t *color; byte *data; int dataSize = 0; - int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents, ofsColor; + int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents; int stride = 0; int numVerts = 0; int numTriangles = 0; @@ -4136,7 +4135,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & baseVertexes[mdxm->numSurfaces] = numVerts; - dataSize += 1.0 * sizeof(*color); dataSize += numVerts * sizeof (*verts); dataSize += numVerts * sizeof (*normals); dataSize += numVerts * sizeof (*texcoords); @@ -4147,30 +4145,27 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Allocate and write to memory data = (byte *)ri.Hunk_AllocateTempMemory (dataSize); - color = (vec4_t *)(data); - ofsColor = 0; - - ofsPosition = stride + sizeof(*color); + ofsPosition = stride; verts = (vec3_t *)(data + ofsPosition); stride += sizeof (*verts); - ofsNormals = stride + sizeof(*color); + ofsNormals = stride; normals = (uint32_t *)(data + ofsNormals); stride += sizeof (*normals); - ofsTexcoords = stride + sizeof(*color); + ofsTexcoords = stride; texcoords = (vec2_t *)(data + ofsTexcoords); stride += sizeof (*texcoords); - ofsBoneRefs = stride + sizeof(*color); + ofsBoneRefs = stride; bonerefs = data + ofsBoneRefs; stride += sizeof (*bonerefs) * 4; - ofsWeights = stride + sizeof(*color); + ofsWeights = stride; weights = data + ofsWeights; stride += sizeof (*weights) * 4; - ofsTangents = stride + sizeof(*color); + ofsTangents = stride; tangents = (uint32_t *)(data + ofsTangents); stride += sizeof (*tangents); @@ -4291,7 +4286,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & } assert ((byte *)verts == (data + dataSize)); - VectorSet4(*color, 1.0f, 1.0f, 1.0f, 1.0f); const char *modelName = strrchr (mdxm->name, '/'); if (modelName == NULL) @@ -4305,7 +4299,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & ri.Hunk_FreeTempMemory (tangentsf); ri.Hunk_FreeTempMemory (indices); - vbo->offsets[ATTR_INDEX_COLOR] = ofsColor; vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofsTexcoords; @@ -4313,7 +4306,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->offsets[ATTR_INDEX_BONE_WEIGHTS] = ofsWeights; vbo->offsets[ATTR_INDEX_TANGENT] = ofsTangents; - vbo->strides[ATTR_INDEX_COLOR] = 0; vbo->strides[ATTR_INDEX_POSITION] = stride; vbo->strides[ATTR_INDEX_NORMAL] = stride; vbo->strides[ATTR_INDEX_TEXCOORD0] = stride; @@ -4321,7 +4313,6 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & vbo->strides[ATTR_INDEX_BONE_WEIGHTS] = stride; vbo->strides[ATTR_INDEX_TANGENT] = stride; - vbo->sizes[ATTR_INDEX_COLOR] = sizeof(*color); vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 511984bfbf..9ceb51b4b9 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1211,6 +1211,9 @@ void GL_SetDefaultState( void ) qglStencilFunc(GL_ALWAYS, 0, 0xff); qglStencilOpSeparate(GL_FRONT, GL_KEEP, GL_INCR_WRAP, GL_KEEP); qglStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_KEEP); + + // set default vertex color + qglVertexAttrib4f(ATTR_INDEX_COLOR, 1.0f, 1.0f, 1.0f, 1.0f); } /* diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 62bbfb40be..cbf8e355e7 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1073,19 +1073,15 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vec2_t *texcoords; uint32_t *normals; uint32_t *tangents; - vec4_t *color; byte *data; int dataSize; int ofs_xyz, ofs_normal, ofs_st; - int ofs_tangent, ofs_color; + int ofs_tangent; dataSize = 0; - ofs_color = dataSize; - dataSize += 1.0f * sizeof(*color); - ofs_xyz = dataSize; dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*verts); @@ -1100,7 +1096,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN data = (byte *)Z_Malloc(dataSize, TAG_MODEL_MD3); - color = (vec4_t *)(data + ofs_color); verts = (vec3_t *)(data + ofs_xyz); normals = (uint32_t *)(data + ofs_normal); tangents = (uint32_t *)(data + ofs_tangent); @@ -1120,8 +1115,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN texcoords[j][1] = st->st[1]; } - VectorSet4(*color, 1.0f, 1.0f, 1.0f, 1.0f); - // If we would support vertex animations, we would need to compute tangents for the other frames too! R_CalcMikkTSpaceMD3Surface(surf->numIndexes/3, verts, normals, tangents, texcoords, surf->indexes); @@ -1136,19 +1129,16 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf->vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); - vboSurf->vbo->offsets[ATTR_INDEX_COLOR] = ofs_color; vboSurf->vbo->offsets[ATTR_INDEX_POSITION] = ofs_xyz; vboSurf->vbo->offsets[ATTR_INDEX_NORMAL] = ofs_normal; vboSurf->vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofs_st; vboSurf->vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; - vboSurf->vbo->strides[ATTR_INDEX_COLOR] = 0; // sizeof(*color); This is to overrite the generic color value and to be less prone to attr binding errors vboSurf->vbo->strides[ATTR_INDEX_POSITION] = sizeof(*verts); vboSurf->vbo->strides[ATTR_INDEX_NORMAL] = sizeof(*normals); vboSurf->vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(*st); vboSurf->vbo->strides[ATTR_INDEX_TANGENT] = sizeof(*tangents); - vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*color); vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); vboSurf->vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); vboSurf->vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 8583ed3aa7..905c3185dc 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -519,9 +519,11 @@ void CalculateVertexArraysFromVBO( properties->vertexDataSize = 0; properties->numVertexArrays = 0; - for ( int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1 ) + for (int i = 0, j = 1; i < ATTR_INDEX_MAX; i++, j <<= 1) { - if ( attributes & j ) + if (vbo->sizes[i] == 0) + continue; + if (attributes & j) AddVertexArray( properties, i, From 0d13b36658ee0b30906cf7f5e26648fa0812933b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Oct 2022 17:59:29 +0200 Subject: [PATCH 586/708] Dont allow rgbGen const values > 1.0 when there's no HDR lighting. --- codemp/rd-rend2/tr_shader.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index e07ad00fdf..7eed4df74d 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1776,6 +1776,12 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) stage->constantColor[0] = color[0]; stage->constantColor[1] = color[1]; stage->constantColor[2] = color[2]; + if (tr.hdrLighting == qfalse) + { + stage->constantColor[0] = MIN(color[0], 1.0f); + stage->constantColor[1] = MIN(color[1], 1.0f); + stage->constantColor[2] = MIN(color[2], 1.0f); + } stage->rgbGen = CGEN_CONST; } From 717792dfc659c89aae8e3d86d456a79fb8fec0fc Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Oct 2022 18:04:17 +0200 Subject: [PATCH 587/708] Implement r_showTris 1 for most surfaces. Surface sprites and weather surfaces aren't supported now. --- codemp/rd-rend2/tr_shade.cpp | 163 +++++++++++++++++++++-------------- 1 file changed, 98 insertions(+), 65 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 08709a8b56..86f6a7fd7b 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -130,58 +130,6 @@ void R_BindAnimatedImageToTMU( textureBundle_t *bundle, int tmu ) { GL_BindToTMU( bundle->image[ index ], tmu ); } - -/* -================ -DrawTris - -Draws triangle outlines for debugging -================ -*/ -static void DrawTris (shaderCommands_t *input) { -#if 0 - GL_Bind( tr.whiteImage ); - - GL_State( GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE ); - GL_DepthRange(0.0f, 0.0f); - - { - shaderProgram_t *sp = &tr.textureColorShader; - vec4_t color; - - GLSL_VertexAttribsState(ATTR_POSITION, NULL); - GLSL_BindProgram(sp); - - GLSL_SetUniformMatrix4x4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - VectorSet4(color, 1, 1, 1, 1); - GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color); - - if (input->multiDrawPrimitives) - { - R_DrawMultiElementsVBO(input->multiDrawPrimitives, input->multiDrawMinIndex, input->multiDrawMaxIndex, input->multiDrawNumIndexes, input->multiDrawFirstIndex); - } - else - { - R_DrawElementsVBO(input->numIndexes, input->firstIndex, input->minIndex, input->maxIndex); - } - } - - GL_DepthRange(0.0f, 1.0f); -#endif -} - - -/* -================ -DrawNormals - -Draws vertex normals for debugging -================ -*/ -static void DrawNormals (shaderCommands_t *input) { - //FIXME: implement this -} - /* ============== RB_BeginSurface @@ -827,6 +775,90 @@ static UniformBlockBinding GetShaderInstanceBlockUniformBinding( return binding; } +/* +================ +DrawTris + +Draws triangle outlines for debugging +================ +*/ +static void DrawTris(shaderCommands_t *input, const VertexArraysProperties *vertexArrays) { + + Allocator& frameAllocator = *backEndData->perFrameMemory; + vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; + GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); + { + int index = 0; + + if (input->shader->numDeforms && !ShaderRequiresCPUDeforms(input->shader)) + { + index |= GENERICDEF_USE_DEFORM_VERTEXES; + } + if (glState.vertexAnimation) + { + index |= GENERICDEF_USE_VERTEX_ANIMATION; + } + else if (glState.skeletalAnimation) + { + index |= GENERICDEF_USE_SKELETAL_ANIMATION; + } + + shaderProgram_t *sp = &tr.genericShader[index]; + assert(sp); + UniformDataWriter uniformDataWriter; + SamplerBindingsWriter samplerBindingsWriter; + uniformDataWriter.Start(sp); + + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader), + GetBonesBlockUniformBinding(backEnd.currentEntity) + }; + + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_DIFFUSEMAP); + const vec4_t baseColor = { 1.0f, 1.0f, 1.0f, 1.0f }; + const vec4_t vertColor = { 0.0f, 0.0f, 0.0f, 0.0f }; + uniformDataWriter.SetUniformVec4(UNIFORM_BASECOLOR, baseColor); + uniformDataWriter.SetUniformVec4(UNIFORM_VERTCOLOR, vertColor); + + DrawItem item = {}; + item.renderState.stateBits = GLS_POLYMODE_LINE | GLS_DEPTHMASK_TRUE | GLS_POLYGON_OFFSET_FILL; + item.renderState.cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); + item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); + item.program = sp; + item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + item.uniformData = uniformDataWriter.Finish(frameAllocator); + item.samplerBindings = samplerBindingsWriter.Finish( + frameAllocator, &item.numSamplerBindings); + + DrawItemSetVertexAttributes( + item, attribs, vertexArrays->numVertexArrays, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); + + RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); + + uint32_t key = RB_CreateSortKey(item, 15, 15); + + RB_AddDrawItem(backEndData->currentPass, key, item); + } +} + +/* +================ +DrawNormals + +Draws vertex normals for debugging +================ +*/ +static void DrawNormals(shaderCommands_t *input) { + //FIXME: implement this +} + static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) { int l; vec3_t origin; @@ -907,7 +939,7 @@ static void ProjectPshadowVBOGLSL( const shaderCommands_t *input, const VertexAr RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - uint32_t key = RB_CreateSortKey(item, 14, input->shader->sort); + uint32_t key = RB_CreateSortKey(item, 13, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); backEnd.pc.c_totalIndexes += tess.numIndexes; @@ -987,7 +1019,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - const uint32_t key = RB_CreateSortKey(item, 15, input->shader->sort); + const uint32_t key = RB_CreateSortKey(item, 14, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, item); // invert fog planes and render global fog into them @@ -1021,7 +1053,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v RB_FillDrawCommand(backItem.draw, GL_TRIANGLES, 1, input); - const uint32_t key = RB_CreateSortKey(backItem, 15, input->shader->sort); + const uint32_t key = RB_CreateSortKey(backItem, 14, input->shader->sort); RB_AddDrawItem(backEndData->currentPass, key, backItem); } } @@ -1260,7 +1292,7 @@ void RB_ShadowTessEnd(shaderCommands_t *input, const VertexArraysProperties *ver RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - const uint32_t key = RB_CreateSortKey(item, 15, 15); + const uint32_t key = RB_CreateSortKey(item, 13, 15); RB_AddDrawItem(backEndData->currentPass, key, item); } @@ -1821,6 +1853,16 @@ void RB_StageIteratorGeneric( void ) if ( fog && tess.shader->fogPass ) { RB_FogPass( input, &vertexArrays ); } + + // + // draw debugging stuff + // + if ( r_showtris->integer ) { + DrawTris( input, &vertexArrays ); + } + if ( r_shownormals->integer ) { + DrawNormals( input ); + } } RB_CommitInternalBufferData(); @@ -1904,15 +1946,6 @@ void RB_EndSurface( void ) { // tess.currentStageIteratorFunc(); - // - // draw debugging stuff - // - if ( r_showtris->integer ) { - DrawTris (input); - } - if ( r_shownormals->integer ) { - DrawNormals (input); - } // clear shader so we can tell we don't have any unclosed surfaces tess.numIndexes = 0; tess.numVertexes = 0; From 69b8baee1d029e656bfc710e335710d1578801ed Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 18 Oct 2022 20:00:33 +0200 Subject: [PATCH 588/708] Add missing things to ghoul2 marks even though it seems to be unused by MP. Might be used in SP. Will check that when porting rend2 to SP. --- codemp/rd-rend2/tr_ghoul2.cpp | 47 ++++++++++++++++++++++++++++++++--- codemp/rd-rend2/tr_local.h | 5 +++- codemp/rd-rend2/tr_shade.cpp | 23 ++++++++++++++--- codemp/rd-rend2/tr_vbo.cpp | 19 ++++++-------- 4 files changed, 75 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index e5471621b6..e8761759b1 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -2452,7 +2452,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum float(curTime - kcur->second.mGoreGrowStartTime) / float(magicFactor42); // linear } - +#ifdef REND2_SP_MAYBE if (curTime < kcur->second.mGoreGrowEndTime) { newSurf2->scale = Q_max( @@ -2462,7 +2462,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum kcur->second.mGoreGrowFactor + kcur->second.mGoreGrowOffset)); } - +#endif shader_t *gshader; if (kcur->second.shader) { @@ -2472,7 +2472,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum { gshader = R_GetShaderByHandle(goreShader); } - +#ifdef REND2_SP_MAYBE // Set fade on surf. // Only if we have a fade time set, and let us fade on // rgb if we want -rww @@ -2491,7 +2491,7 @@ void RenderSurfaces( CRenderSurface &RS, const trRefEntity_t *ent, int entityNum } } } - +#endif last->goreChain = newSurf2; last = newSurf2; R_AddDrawSurf( @@ -3508,10 +3508,49 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.maxIndex = surf->alternateTex->firstVert + surf->alternateTex->numVerts; tess.firstIndex = surf->alternateTex->firstIndex; +#ifdef REND2_SP_MAYBE + // UNTESTED CODE + if (surf->scale > 1.0f) + { + tess.scale = true; + tess.texCoords[tess.firstIndex][0][0] = surf->scale; + } + + //now check for fade overrides -rww + if (surf->fade) + { + static int lFade; + if (surf->fade < 1.0) + { + tess.fade = true; + lFade = Q_ftol(254.4f*surf->fade); + tess.svars.colors[tess.firstIndex][0] = + tess.svars.colors[tess.firstIndex][1] = + tess.svars.colors[tess.firstIndex][2] = Q_ftol(1.0f); + tess.svars.colors[tess.firstIndex][3] = lFade; + } + else if (surf->fade > 2.0f && surf->fade < 3.0f) + { //hack to fade out on RGB if desired (don't want to add more to CRenderableSurface) -rww + tess.fade = true; + lFade = Q_ftol(254.4f*(surf->fade - 2.0f)); + if (lFade < tess.svars.colors[tess.firstIndex][0]) + { //don't set it unless the fade is less than the current r value (to avoid brightening suddenly before we start fading) + tess.svars.colors[tess.firstIndex][0] = + tess.svars.colors[tess.firstIndex][1] = + tess.svars.colors[tess.firstIndex][2] = lFade; + } + tess.svars.colors[tess.firstIndex][3] = lFade; + } + } +#endif glState.skeletalAnimation = qtrue; RB_EndSurface(); // So we don't lerp surfaces that shouldn't be lerped glState.skeletalAnimation = qfalse; +#ifdef REND2_SP_MAYBE + tess.scale = false; + tess.fade = false; +#endif return; } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fdccd26d88..bde927c30f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2991,7 +2991,10 @@ struct shaderCommands_s float shaderTime; int fogNum; int cubemapIndex; - +#ifdef REND2_SP_MAYBE + bool scale; // uses texCoords[input->firstIndex] for storage + bool fade; // uses svars.colors[input->firstIndex] for storage +#endif int dlightBits; // or together of all vertexDlightBits int pshadowBits; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 86f6a7fd7b..7d99f413e1 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1406,8 +1406,18 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { vec4_t baseColor; vec4_t vertColor; - - ComputeShaderColors(pStage, baseColor, vertColor, stateBits, &forceRGBGen, &forceAlphaGen); + +#ifdef REND2_SP_MAYBE + // Fade will be set true when rendering some gore surfaces + if (input->fade) + { + VectorCopy4(input->svars.colors[input->firstIndex], baseColor); + VectorScale4(baseColor, 1.0f / 255.0f, baseColor); + VectorSet4(vertColor, 0.0f, 0.0f, 0.0f, 0.0f); + } + else +#endif + ComputeShaderColors(pStage, baseColor, vertColor, stateBits, &forceRGBGen, &forceAlphaGen); if ((backEnd.refdef.colorScale != 1.0f) && !(backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) { @@ -1477,7 +1487,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec3(UNIFORM_TONEMINAVGMAXLINEAR, tr.refdef.toneMinAvgMaxLinear); } - ComputeTexMods( pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb ); +#ifdef REND2_SP_MAYBE + // tess scale will be set true only when theres scaled gore + if (!input->scale) + texMatrix[0] = texMatrix[3] = input->texCoords[input->firstIndex][0][0]; + else +#endif + ComputeTexMods(pStage, TB_DIFFUSEMAP, texMatrix, texOffTurb); + uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXMATRIX, texMatrix); uniformDataWriter.SetUniformVec4(UNIFORM_DIFFUSETEXOFFTURB, texOffTurb); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 905c3185dc..1cf67e76ab 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -659,27 +659,24 @@ void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface) tr.goreVBOCurrentIndex = 0; R_BindVBO(tr.goreVBO); - GLbitfield mapFlags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT; - void *dstPtr = qglMapBufferRange( - GL_ARRAY_BUFFER, + qglBufferSubData( + GL_ARRAY_BUFFER, sizeof(g2GoreVert_t) * tr.goreVBOCurrentIndex, sizeof(g2GoreVert_t) * goreSurface->numVerts, - mapFlags); - memcpy(dstPtr, (byte *)goreSurface->verts, sizeof(g2GoreVert_t)*goreSurface->numVerts); - qglUnmapBuffer(GL_ARRAY_BUFFER); + goreSurface->verts + ); tr.goreVBOCurrentIndex += goreSurface->numVerts; if (tr.goreIBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES)) tr.goreIBOCurrentIndex = 0; R_BindIBO(tr.goreIBO); - void *dst = qglMapBufferRange( - GL_ELEMENT_ARRAY_BUFFER, + qglBufferSubData( + GL_ELEMENT_ARRAY_BUFFER, sizeof(glIndex_t) * tr.goreIBOCurrentIndex, sizeof(glIndex_t) * goreSurface->numIndexes, - mapFlags); - memcpy(dst, goreSurface->indexes, sizeof(glIndex_t) * goreSurface->numIndexes); - qglUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); + goreSurface->indexes + ); tr.goreIBOCurrentIndex += goreSurface->numIndexes; } From 2547427920255782a9498485a0d89d87ea671fed Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 20 Oct 2022 20:21:47 +0200 Subject: [PATCH 589/708] Weather system 1.0 Fixed particle positions for rapidly changing wind situations and added fading for the particles. --- codemp/rd-rend2/glsl/weather.glsl | 10 +- codemp/rd-rend2/glsl/weatherUpdate.glsl | 39 +++--- codemp/rd-rend2/tr_glsl.cpp | 41 +++++- codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_weather.cpp | 170 +++++++++++------------- 5 files changed, 139 insertions(+), 123 deletions(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index ef9fe876a5..4195707959 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -1,5 +1,5 @@ /*[Vertex]*/ -uniform vec2 u_ZoneOffset; +uniform vec2 u_ZoneOffset[9]; uniform sampler2D u_ShadowMap; uniform mat4 u_ShadowMvp; @@ -14,7 +14,7 @@ out int var_Culled; void main() { gl_Position = vec4( - attr_Position.xy + u_ZoneOffset, + attr_Position.xy + u_ZoneOffset[0], attr_Position.z, 1.0); var_Velocity = attr_Color; @@ -80,10 +80,10 @@ void main() vec4 worldPos = vec4(P + offset, 1.0); gl_Position = u_ModelViewProjectionMatrix * worldPos; - // TODO: Fade on distance to viewer - float alpha = 1.0; + float distance = distance(u_ViewOrigin, worldPos.xyz); + float alpha = (u_ViewInfo.w - distance) / u_ViewInfo.w; - var_TexCoordAlpha = vec3(texcoords[i], alpha); + var_TexCoordAlpha = vec3(texcoords[i], clamp(alpha, 0.0, 1.0)); EmitVertex(); } EndPrimitive(); diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 2604ff0c4a..9bf4f5f2fc 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -4,6 +4,9 @@ uniform float u_Time; // delta time uniform vec2 u_MapZExtents; uniform vec3 u_EnvForce; uniform vec4 u_RandomOffset; +uniform vec2 u_ZoneOffset[9]; +uniform int u_ChunkParticles; + in vec3 attr_Position; in vec3 attr_Color; @@ -13,28 +16,14 @@ out vec3 var_Velocity; const float CHUNK_EXTENDS = 2000.0; const float HALF_CHUNK_EXTENDS = CHUNK_EXTENDS * 0.5; +const float THREE_HALF_CHUNK_EXTENDS = 3.0 * HALF_CHUNK_EXTENDS; -vec3 NewParticleZPosition() +vec3 NewParticleZPosition( in vec3 in_position ) { - vec3 position = var_Position; + vec3 position = in_position; position.xy += u_RandomOffset.xy; position.z += u_MapZExtents.y - u_MapZExtents.x; - vec2 signs = sign(position.xy); - vec2 absPos = abs(position.xy) + vec2(HALF_CHUNK_EXTENDS); - position.xy = -signs * (HALF_CHUNK_EXTENDS - mod(absPos, CHUNK_EXTENDS)); - - return position; -} - -vec3 NewParticleXYPosition(vec3 in_Position) -{ - vec3 position = in_Position; - position.xy += u_RandomOffset.xy * 10.0; - vec2 signs = sign(position.xy); - vec2 absPos = abs(position.xy) + vec2(HALF_CHUNK_EXTENDS); - position.xy = -signs * (1.5 * CHUNK_EXTENDS - mod(absPos, CHUNK_EXTENDS)); - return position; } @@ -47,12 +36,20 @@ void main() if (var_Position.z < u_MapZExtents.x) { - var_Position = NewParticleZPosition(); + var_Position = NewParticleZPosition(var_Position); var_Velocity.xy = u_EnvForce.xy; } - if (u_EnvForce.z == 0 && any(greaterThan(abs(var_Position).xy, vec2(1.5 * CHUNK_EXTENDS)))) + + int zone = gl_VertexID / u_ChunkParticles; + vec2 zoneOffset = u_ZoneOffset[zone] * CHUNK_EXTENDS; + vec2 sim_Position = var_Position.xy + zoneOffset; + + if (any(greaterThan(abs(sim_Position).xy, vec2(THREE_HALF_CHUNK_EXTENDS)))) { - var_Position = NewParticleXYPosition(var_Position); - var_Velocity.xy = u_EnvForce.xy; + vec2 signs = sign(sim_Position.xy); + vec2 absPos = abs(sim_Position.xy) + vec2(THREE_HALF_CHUNK_EXTENDS); + sim_Position.xy = -signs * (THREE_HALF_CHUNK_EXTENDS - mod(absPos, 3.0 * CHUNK_EXTENDS)); + + var_Position.xy = sim_Position - zoneOffset; } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e103b9869b..f5bf3ebdb7 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -127,9 +127,10 @@ static uniformInfo_t uniformsInfo[] = { "u_FXVolumetricBase", GLSL_FLOAT, 1 }, { "u_MapZExtents", GLSL_VEC2, 1 }, - { "u_ZoneOffset", GLSL_VEC2, 1 }, + { "u_ZoneOffset", GLSL_VEC2, 9 }, { "u_EnvForce", GLSL_VEC3, 1 }, - { "u_RandomOffset", GLSL_VEC4, 1 } + { "u_RandomOffset", GLSL_VEC4, 1 }, + { "u_ChunkParticles", GLSL_INT, 1 }, }; static void GLSL_PrintProgramInfoLog(GLuint object, qboolean developerOnly) @@ -988,9 +989,8 @@ void GLSL_SetUniforms( shaderProgram_t *program, UniformData *uniformData ) case GLSL_VEC2: { - assert(data->numElements == 1); GLfloat *value = (GLfloat *)(data + 1); - GLSL_SetUniformVec2(program, data->index, value); + GLSL_SetUniformVec2N(program, data->index, value, data->numElements); data = reinterpret_cast(value + data->numElements*2); break; } @@ -1111,6 +1111,39 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t qglUniform2f(uniforms[uniformNum], v[0], v[1]); } +void GLSL_SetUniformVec2N(shaderProgram_t *program, int uniformNum, const float *v, int numVec2s) +{ + GLint *uniforms = program->uniforms; + float *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]); + + if (uniforms[uniformNum] == -1) + return; + + if (uniformsInfo[uniformNum].type != GLSL_VEC2) + { + ri.Printf(PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name); + return; + } + + if (uniformsInfo[uniformNum].size < numVec2s) + { + ri.Printf(PRINT_WARNING, "GLSL_SetUniformVec2N: uniform %i only has %d elements! Tried to set %d\n", + uniformNum, + uniformsInfo[uniformNum].size, + numVec2s); + return; + } + + if (memcmp(compare, v, sizeof(vec2_t) * numVec2s) == 0) + { + return; + } + + memcpy(compare, v, sizeof(vec2_t) * numVec2s); + + qglUniform2fv(uniforms[uniformNum], numVec2s, v); +} + void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v) { GLint *uniforms = program->uniforms; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bde927c30f..8debb2a9ea 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1381,6 +1381,7 @@ typedef enum UNIFORM_ZONEOFFSET, UNIFORM_ENVFORCE, UNIFORM_RANDOMOFFSET, + UNIFORM_CHUNK_PARTICLES, UNIFORM_COUNT } uniform_t; @@ -3219,6 +3220,7 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value); void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value); void GLSL_SetUniformFloatN(shaderProgram_t *program, int uniformNum, const float *v, int numFloats); void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v); +void GLSL_SetUniformVec2N(shaderProgram_t *program, int uniformNum, const float *v, int numVec2s); void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t v); void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t v); void GLSL_SetUniformMatrix4x3(shaderProgram_t *program, int uniformNum, const float *matrix, int numElements = 1); diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index a3d26e0d90..e35dcf2555 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -58,7 +58,6 @@ struct weatherObject_t image_t *drawImage; vec4_t color; vec2_t size; - vec3_t currentVelocity; }; #define MAX_WINDOBJECTS 10 @@ -244,11 +243,9 @@ namespace R_IssuePendingRenderCommands(); R_InitNextFrame(); RE_EndScene(); - - // TODO: Store ViewProjection Mat for depth comparisons } - void RB_SimulateWeather(weatherObject_t *ws) + void RB_SimulateWeather(weatherObject_t *ws, vec2_t *zoneOffsets, int zoneIndex) { if (ws->vboLastUpdateFrame == backEndData->realFrameNumber || tr.weatherSystem->frozen) @@ -301,6 +298,8 @@ namespace uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.frameTime); uniformDataWriter.SetUniformVec3(UNIFORM_ENVFORCE, envForce); uniformDataWriter.SetUniformVec4(UNIFORM_RANDOMOFFSET, randomOffset); + uniformDataWriter.SetUniformVec2(UNIFORM_ZONEOFFSET, (float*)zoneOffsets, 9); + uniformDataWriter.SetUniformInt(UNIFORM_CHUNK_PARTICLES, ws->particleCount); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); @@ -437,15 +436,15 @@ void RE_WorldEffectCommand(const char *command) //// Add a zone ////--------------- - //else if (Q_stricmp(token, "zone") == 0) - //{ - // vec3_t mins; - // vec3_t maxs; - // //if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) - // { - // //mOutside.AddWeatherZone(mins, maxs); - // } - //} + else if (Q_stricmp(token, "zone") == 0) + { + vec3_t mins; + vec3_t maxs; + //if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) + { + ri.Printf(PRINT_DEVELOPER, "Weather zones aren't supported in MP\n"); + } + } // Basic Wind //------------ @@ -599,7 +598,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 2000; tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 6000.0f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 2.0f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; @@ -635,7 +634,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].particleCount = 5000; tr.weatherSystem->weatherSlots[WEATHER_RAIN].active = true; tr.weatherSystem->weatherSlots[WEATHER_RAIN].gravity = 2.8f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 6000.0f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; @@ -666,7 +665,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SNOW].particleCount = 1000; tr.weatherSystem->weatherSlots[WEATHER_SNOW].active = true; tr.weatherSystem->weatherSlots[WEATHER_SNOW].gravity = 0.3f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = -1.0f; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].fadeDistance = 6000.0f; tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[1] = 1.5f; @@ -712,7 +711,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].particleCount = count; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].active = true; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].gravity = 0.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].fadeDistance = 3000.f; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[0] = 2.5f; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[1] = 2.5f; @@ -754,7 +753,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SAND].particleCount = 400; tr.weatherSystem->weatherSlots[WEATHER_SAND].active = true; tr.weatherSystem->weatherSlots[WEATHER_SAND].gravity = 0.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + tr.weatherSystem->weatherSlots[WEATHER_SAND].fadeDistance = 2400.f; tr.weatherSystem->weatherSlots[WEATHER_SAND].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_SAND].size[1] = 300.f; @@ -789,7 +788,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 60; tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].fadeDistance = 2400.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; @@ -828,7 +827,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 70; tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].fadeDistance = 2400.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; @@ -867,7 +866,7 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].particleCount = 70; tr.weatherSystem->weatherSlots[WEATHER_FOG].active = true; tr.weatherSystem->weatherSlots[WEATHER_FOG].gravity = 0.0f; - tr.weatherSystem->weatherSlots[WEATHER_RAIN].fadeDistance = 3500000.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].fadeDistance = 2000.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; @@ -880,37 +879,37 @@ void RE_WorldEffectCommand(const char *command) VectorScale(tr.weatherSystem->weatherSlots[WEATHER_FOG].color, 0.12f, tr.weatherSystem->weatherSlots[WEATHER_FOG].color); } - /*else if (Q_stricmp(token, "outsideshake") == 0) + else if (Q_stricmp(token, "outsideshake") == 0) { - mOutside.mOutsideShake = !mOutside.mOutsideShake; + ri.Printf(PRINT_DEVELOPER, "outsideshake isn't supported in MP\n"); } else if (Q_stricmp(token, "outsidepain") == 0) { - mOutside.mOutsidePain = !mOutside.mOutsidePain; - }*/ + ri.Printf(PRINT_DEVELOPER, "outsidepain isn't supported in MP\n"); + } else { ri.Printf(PRINT_ALL, "Weather Effect: Please enter a valid command.\n"); ri.Printf(PRINT_ALL, " die\n"); ri.Printf(PRINT_ALL, " clear\n"); ri.Printf(PRINT_ALL, " freeze\n"); - //ri.Printf(PRINT_ALL, " zone (mins) (maxs)\n"); + ri.Printf(PRINT_ALL, " zone (mins) (maxs)\n"); ri.Printf(PRINT_ALL, " wind\n"); ri.Printf(PRINT_ALL, " constantwind (velocity)\n"); ri.Printf(PRINT_ALL, " gustingwind\n"); - //ri.Printf( PRINT_ALL, " windzone (mins) (maxs) (velocity)\n" ); + //ri.Printf(PRINT_ALL, " windzone (mins) (maxs) (velocity)\n"); ri.Printf(PRINT_ALL, " lightrain\n"); ri.Printf(PRINT_ALL, " rain\n"); ri.Printf(PRINT_ALL, " acidrain\n"); ri.Printf(PRINT_ALL, " heavyrain\n"); ri.Printf(PRINT_ALL, " snow\n"); - ri.Printf(PRINT_ALL, " spacedust\n"); + ri.Printf(PRINT_ALL, " spacedust (count)\n"); ri.Printf(PRINT_ALL, " sand\n"); ri.Printf(PRINT_ALL, " fog\n"); ri.Printf(PRINT_ALL, " heavyrainfog\n"); ri.Printf(PRINT_ALL, " light_fog\n"); - //ri.Printf(PRINT_ALL, " outsideshake\n"); // not available in MP - //ri.Printf(PRINT_ALL, " outsidepain\n"); // not available in MP + ri.Printf(PRINT_ALL, " outsideshake\n"); // not available in MP + ri.Printf(PRINT_ALL, " outsidepain\n"); // not available in MP } } @@ -940,11 +939,6 @@ void R_AddWeatherSurfaces() ); } -float lerp(float a, float b, float t) -{ - return a + t * (b - a); -} - void RB_SurfaceWeather( srfWeather_t *surf ) { assert(tr.weatherSystem); @@ -956,7 +950,37 @@ void RB_SurfaceWeather( srfWeather_t *surf ) const float numMinZonesX = std::floor((abs(tr.world->bmodels[0].bounds[0][0]) / CHUNK_EXTENDS) + 0.5f); const float numMinZonesY = std::floor((abs(tr.world->bmodels[0].bounds[0][1]) / CHUNK_EXTENDS) + 0.5f); + vec3_t viewOrigin; + VectorCopy(backEnd.viewParms.ori.origin, viewOrigin); + float centerZoneOffsetX = + std::floor((viewOrigin[0] / CHUNK_EXTENDS) + 0.5f); + float centerZoneOffsetY = + std::floor((viewOrigin[1] / CHUNK_EXTENDS) + 0.5f); + vec2_t zoneOffsets[9]; + GLint zoneMapping[9]; + int centerZoneIndex; + { + int chunkIndex = 0; + int currentIndex = 0; + for (int y = -1; y <= 1; ++y) + { + for (int x = -1; x <= 1; ++x, ++currentIndex) + { + chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3; + chunkIndex += (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3; + VectorSet2( + zoneOffsets[chunkIndex], + x, + y); + zoneMapping[currentIndex] = chunkIndex; + if (x == 0 && y == 0) + centerZoneIndex = currentIndex; + } + } + } + + // Get current global wind vector VectorCopy(tr.weatherSystem->constWindDirection, tr.weatherSystem->windDirection); for (int i = 0; i < tr.weatherSystem->activeWindObjects; i++) { @@ -965,6 +989,9 @@ void RB_SurfaceWeather( srfWeather_t *surf ) VectorAdd(windObject->currentVelocity, tr.weatherSystem->windDirection, tr.weatherSystem->windDirection); } + Allocator& frameAllocator = *backEndData->perFrameMemory; + + // Simulate and render all the weather zones for (int weatherType = 0; weatherType < NUM_WEATHER_TYPES; weatherType++) { weatherObject_t *weatherObject = &ws.weatherSlots[weatherType]; @@ -976,58 +1003,23 @@ void RB_SurfaceWeather( srfWeather_t *surf ) tr.weatherSystem->weatherSlots[weatherType], maxWeatherTypeParticles[weatherType]); - RB_SimulateWeather(weatherObject); + RB_SimulateWeather(weatherObject, &zoneOffsets[0], centerZoneIndex); - vec3_t viewOrigin; - VectorCopy(backEnd.viewParms.ori.origin, viewOrigin); - - const float frictionInverse = 0.7; - vec3_t envForce = { - tr.weatherSystem->windDirection[0] * frictionInverse, - tr.weatherSystem->windDirection[1] * frictionInverse, - -weatherObject->gravity + vec4_t viewInfo = { + weatherObject->size[0], + weatherObject->size[1], + 0.0f, + weatherObject->fadeDistance }; - weatherObject->currentVelocity[0] = lerp( - weatherObject->currentVelocity[0], - envForce[0], - backEnd.refdef.frameTime * 0.0005f); - weatherObject->currentVelocity[1] = lerp( - weatherObject->currentVelocity[1], - envForce[1], - backEnd.refdef.frameTime * 0.0005f); - weatherObject->currentVelocity[2] = lerp( - weatherObject->currentVelocity[2], - envForce[2], - backEnd.refdef.frameTime * 0.0005f); - - if (weatherObject->gravity != 0.0f) - { - vec3_t windOffsetPerHeight = { - weatherObject->currentVelocity[0], - weatherObject->currentVelocity[1], - 0.0f }; - VectorScale(windOffsetPerHeight, 1.0f / weatherObject->currentVelocity[2], windOffsetPerHeight); - VectorMA( - viewOrigin, - tr.world->bmodels[0].bounds[1][2] - viewOrigin[2], - windOffsetPerHeight, - viewOrigin); - } - float centerZoneOffsetX = - std::floor((viewOrigin[0] / CHUNK_EXTENDS) + 0.5f); - float centerZoneOffsetY = - std::floor((viewOrigin[1] / CHUNK_EXTENDS) + 0.5f); + int stateBits = weatherType == WEATHER_SAND ? + GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA : + GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; DrawItem item = {}; - if (weatherType == WEATHER_SAND) - item.renderState.stateBits = - GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; - else - item.renderState.stateBits = - GLS_DEPTHFUNC_LESS | GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE; - item.renderState.cullType = CT_FRONT_SIDED; + item.renderState.stateBits = stateBits; + item.renderState.cullType = CT_TWO_SIDED; item.renderState.depthRange = { 0.0f, 1.0f }; item.program = &tr.weatherShader; @@ -1047,10 +1039,11 @@ void RB_SurfaceWeather( srfWeather_t *surf ) item.draw.primitiveType = GL_POINTS; item.draw.params.arrays.numVertices = weatherObject->particleCount; - int chunkIndex = 0; + //TODO: Cull non visable zones + int currentIndex = 0; for (int y = -1; y <= 1; ++y) { - for (int x = -1; x <= 1; ++x) + for (int x = -1; x <= 1; ++x, ++currentIndex) { UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); @@ -1064,12 +1057,6 @@ void RB_SurfaceWeather( srfWeather_t *surf ) (centerZoneOffsetY + y) * CHUNK_EXTENDS); uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.frameTime); uniformDataWriter.SetUniformVec4(UNIFORM_COLOR, weatherObject->color); - vec4_t viewInfo = { - weatherObject->size[0], - weatherObject->size[1], - 0.0f, - weatherObject->fadeDistance - }; uniformDataWriter.SetUniformVec4(UNIFORM_VIEWINFO, viewInfo); uniformDataWriter.SetUniformMatrix4x4(UNIFORM_SHADOWMVP, tr.weatherSystem->weatherMVP); item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); @@ -1081,13 +1068,10 @@ void RB_SurfaceWeather( srfWeather_t *surf ) else samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_DIFFUSEMAP); - Allocator& frameAllocator = *backEndData->perFrameMemory; item.samplerBindings = samplerBindingsWriter.Finish( frameAllocator, &item.numSamplerBindings); - chunkIndex = (int(centerZoneOffsetX + numMinZonesX) + x + 1) % 3; - chunkIndex+= (int(centerZoneOffsetY + numMinZonesY) + y + 1) % 3 * 3; - item.draw.params.arrays.firstVertex = weatherObject->particleCount * chunkIndex; + item.draw.params.arrays.firstVertex = weatherObject->particleCount * zoneMapping[currentIndex]; uint32_t key = RB_CreateSortKey(item, 15, SS_SEE_THROUGH); RB_AddDrawItem(backEndData->currentPass, key, item); From f3f48e85bee96f3088354c0002a61185b2462885 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 20 Oct 2022 22:36:37 +0200 Subject: [PATCH 590/708] Fix generic shader fog modulation --- codemp/rd-rend2/tr_glsl.cpp | 9 +++++---- codemp/rd-rend2/tr_shade.cpp | 1 + codemp/rd-rend2/tr_shader.cpp | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index f5bf3ebdb7..c1704e1d62 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2603,10 +2603,6 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) shaderStage_t *pStage = tess.xstages[stage]; int shaderAttribs = 0; - if ( tess.fogNum && pStage->adjustColorsForFog && - tess.shader->fogPass ) - shaderAttribs |= GENERICDEF_USE_FOG; - if ( pStage->alphaTestType != ALPHA_TEST_NONE ) shaderAttribs |= GENERICDEF_USE_ALPHA_TEST; @@ -2635,6 +2631,11 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) break; } + if (tess.fogNum && + pStage->adjustColorsForFog != ACFF_NONE && + !(shaderAttribs & GENERICDEF_USE_RGBAGEN)) + shaderAttribs |= GENERICDEF_USE_FOG; + if (pStage->bundle[0].tcGen != TCGEN_TEXTURE) { shaderAttribs |= GENERICDEF_USE_TCGEN_AND_TCMOD; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 7d99f413e1..146249c589 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1395,6 +1395,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays vec4_t fogColorMask; ComputeFogColorMask(pStage, fogColorMask); uniformDataWriter.SetUniformVec4(UNIFORM_FOGCOLORMASK, fogColorMask); + uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); } float volumetricBaseValue = -1.0f; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 7eed4df74d..20131aea0a 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3655,6 +3655,24 @@ static shader_t *GeneratePermanentShader( void ) { newShader->fogPass = FP_LE; } + // determain if fog pass can use depth equal or not + if (newShader->fogPass == FP_EQUAL) + { + newShader->fogPass = FP_LE; + for (int stage = 0; stage < MAX_SHADER_STAGES; stage++) { + shaderStage_t *pStage = &stages[stage]; + + if (!pStage->active) + continue; + + if (pStage->stateBits & GLS_DEPTHMASK_TRUE) + { + newShader->fogPass = FP_EQUAL; + break; + } + } + } + tr.shaders[ tr.numShaders ] = newShader; newShader->index = tr.numShaders; From 86a8cb4f360341a32bccec685d829f51763b59bc Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 21 Oct 2022 02:08:27 +0200 Subject: [PATCH 591/708] More fog fixes --- codemp/rd-rend2/glsl/fogpass.glsl | 6 +++++- codemp/rd-rend2/glsl/generic.glsl | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 9d7dd435fb..241179bd60 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -295,7 +295,7 @@ vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) // only use this for objects with potentially two contibuting fogs #if defined(USE_FALLBACK_GLOBAL_FOG) - bool intersects = (t > 0.0 && t <= 1.0); + bool intersects = (t > 0.0 && t < 0.995); if (inFog == intersects) { Fog globalFog = u_Fogs[u_globalFogIndex]; @@ -305,6 +305,10 @@ vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) float z = globalFog.depthToOpaque * mix(distToVertex, distFromIntersection, intersects); return vec4(globalFog.color.rgb, 1.0 - clamp(exp(-(z * z)), 0.0, 1.0)); } + #else + bool intersects = (t > 0.0 && t < 0.995); + if (inFog == intersects) + return vec4(0.0); #endif float distToVertexFromViewOrigin = length(V); diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index e06ad74c0f..3e07fe85e1 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -493,7 +493,7 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) // fogPlane is inverted in tr_bsp for some reason. float t = -(fog.plane.w + dot(viewOrigin, -fog.plane.xyz)) / dot(V, -fog.plane.xyz); - bool intersects = (t > 0.0 && t <= 1.0); + bool intersects = (t > 0.0 && t < 0.995); if (inFog == intersects) return 0.0; From bdcbe3f707def1f51a84b41072afe6e50f6ba545 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 23 Oct 2022 11:59:36 +0200 Subject: [PATCH 592/708] Warn on missing fog shader and set default depthForOpaque value --- codemp/rd-rend2/tr_bsp.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index cabe44578d..f6d7647b87 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -2688,6 +2688,12 @@ static void R_LoadFogs( world_t *worldData, lump_t *l, lump_t *brushesLump, lump // get information from the shader for fog parameters shader = R_FindShader( fogs->shader, lightmapsNone, stylesDefault, qtrue ); + if (shader->defaultShader == qtrue || shader->fogParms.depthForOpaque == 0) + { + ri.Printf(PRINT_WARNING, "Couldn't find proper shader for bsp fog %i %s\n", i, fogs->shader); + shader->fogParms.depthForOpaque = 65535.f; + } + out->parms = shader->fogParms; VectorSet4(out->color, From 9d532c45cc6122df2cf3f29435225b025b93cc7c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 23 Oct 2022 17:15:29 +0200 Subject: [PATCH 593/708] Make sure scene is empty when rendering cubemaps --- codemp/rd-rend2/tr_bsp.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index f6d7647b87..e5cf8d428d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3198,7 +3198,12 @@ static void R_RenderAllCubemaps() cubemapFormat = GL_RGBA16F; } + // Clear everything before rendering cubemaps to make sure only visable surfaces to the cubemap are rendered int frontEndMsec, backEndMsec; + R_IssuePendingRenderCommands(); + RE_ClearScene(); + R_InitNextFrame(); + for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { bool bounce = k != 0; From 956c82d0d3038bd2bc431d0c3dff76492e612347 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Tue, 25 Oct 2022 22:42:36 +0200 Subject: [PATCH 594/708] Apparently a stupid Driver crashed with some maps on load with it. :x --- codemp/rd-rend2/tr_bsp.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e5cf8d428d..e959099c17 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3200,7 +3200,6 @@ static void R_RenderAllCubemaps() // Clear everything before rendering cubemaps to make sure only visable surfaces to the cubemap are rendered int frontEndMsec, backEndMsec; - R_IssuePendingRenderCommands(); RE_ClearScene(); R_InitNextFrame(); From b5069226c5c0f23473f2206000554f11ef9f4758 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 26 Oct 2022 17:01:37 +0200 Subject: [PATCH 595/708] Small things - Issue pending render commands after cueing shadow passes. - Don't render pshadows for ghoul2 ui models - Don't try resolving light or ssao when rendering shadow passes. - Don't pass an ubo offset < 0 because its illegal in opengl. Will remove the check when I fixed the real issue, which is unimplemented ubo block bindings --- codemp/rd-rend2/tr_backend.cpp | 9 ++++++--- codemp/rd-rend2/tr_main.cpp | 1 - codemp/rd-rend2/tr_scene.cpp | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 7dd877a2a9..b7ff858114 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1024,7 +1024,10 @@ static void RB_BindUniformBlocks( for (size_t i = 0; i < numBindings; ++i) { const UniformBlockBinding& binding = bindings[i]; - RB_BindUniformBlock(binding.ubo, binding.block, binding.offset); + if (binding.offset < 0) + RB_BindUniformBlock(binding.ubo, binding.block, 0); + else + RB_BindUniformBlock(binding.ubo, binding.block, binding.offset); } } @@ -2271,12 +2274,12 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu nullptr, 0); } - if ( r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) ) + if ( r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) { RB_RenderSunShadows(); } - if (r_ssao->integer) + if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) { RB_RenderSSAO(); } diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 35efdcf243..a0b7d34a8e 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2315,7 +2315,6 @@ void R_RenderPshadowMaps(const refdef_t *fd) switch (model->type) { case MOD_MDXM: - case MOD_BAD: { if (ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2))) { diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 76e13f8d92..fdbdb5dce9 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -536,6 +536,8 @@ void RE_RenderScene( const refdef_t *fd ) { R_EndTimedBlockCmd( timer ); } + R_IssuePendingRenderCommands(); + // setup view parms for the initial view // // set up viewport From 21a5432590e4aa22499f18257b4acfbe98485bb4 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 15:32:03 +0100 Subject: [PATCH 596/708] Rewrite material system Now favors packed material definitions over spec gloss. Increased number of used mips for convolved cubemaps to get some more precision in the upper gloss values. r_simpleMipMaps now uses opengls internal mip mapping code instead of building everything on the cpu manually. The occlusion layer in packed image formats is now handled properly, as also ssao images. Ssao still needs a major rework though. --- codemp/rd-rend2/glsl/depthblur.glsl | 27 ++- codemp/rd-rend2/glsl/lightall.glsl | 37 +++- codemp/rd-rend2/glsl/ssao.glsl | 25 ++- codemp/rd-rend2/tr_backend.cpp | 52 ++--- codemp/rd-rend2/tr_bsp.cpp | 60 ------ codemp/rd-rend2/tr_glsl.cpp | 16 +- codemp/rd-rend2/tr_image.cpp | 292 +++++++++++++--------------- codemp/rd-rend2/tr_local.h | 44 +++-- codemp/rd-rend2/tr_shade.cpp | 5 +- codemp/rd-rend2/tr_shader.cpp | 120 ++++++------ 10 files changed, 324 insertions(+), 354 deletions(-) diff --git a/codemp/rd-rend2/glsl/depthblur.glsl b/codemp/rd-rend2/glsl/depthblur.glsl index 91b8b6a401..ab32f9c000 100644 --- a/codemp/rd-rend2/glsl/depthblur.glsl +++ b/codemp/rd-rend2/glsl/depthblur.glsl @@ -1,15 +1,22 @@ /*[Vertex]*/ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - out vec2 var_ScreenTex; void main() { - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; + const vec2 positions[] = vec2[3]( + vec2(-1.0f, 1.0f), + vec2(-1.0f, -3.0f), + vec2( 3.0f, 1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_ScreenTex = texcoords[gl_VertexID]; } /*[Fragment]*/ @@ -21,10 +28,10 @@ in vec2 var_ScreenTex; out vec4 out_Color; -//float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033); -float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); +float gauss[5] = float[5](0.30, 0.23, 0.097, 0.024, 0.0033); +//float gauss[4] = float[4](0.40, 0.24, 0.054, 0.0044); //float gauss[3] = float[3](0.60, 0.19, 0.0066); -#define GAUSS_SIZE 4 +#define GAUSS_SIZE 5 float getLinearDepth(sampler2D depthMap, const vec2 tex, const float zFarDivZNear) { diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index fe01bfe310..06b8beb567 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -401,7 +401,13 @@ uniform sampler2D u_SpecularMap; uniform sampler2D u_ShadowMap; #endif +#if defined(USE_SSAO) +uniform sampler2D u_SSAOMap; +#endif + +#if defined(USE_DSHADOWS) uniform sampler2DArrayShadow u_ShadowMap2; +#endif #if defined(USE_CUBEMAP) uniform samplerCube u_CubeMap; @@ -915,9 +921,12 @@ void main() N = CalcNormal(var_Normal.xyz, var_Tangent, texCoords); L /= sqrt(sqrLightDist); + #if defined(USE_SHADOWMAP) || defined(USE_SSAO) + vec2 windowTex = gl_FragCoord.xy / r_FBufScale; + #endif + #if defined(USE_SHADOWMAP) - vec2 shadowTex = gl_FragCoord.xy / r_FBufScale; - float shadowValue = texture(u_ShadowMap, shadowTex).r; + float shadowValue = texture(u_ShadowMap, windowTex).r; // surfaces not facing the light are always shadowed vec3 primaryLightDir = normalize(u_PrimaryLightOrigin.xyz); @@ -951,12 +960,29 @@ void main() // We dont compute it because cloth diffuse is dependent on NL // So we just skip this. Reconsider this again when more BRDFS are added + float AO = 1.0; + #if defined (USE_SSAO) + AO = texture(u_SSAOMap, windowTex).r; + #endif + vec4 specular = vec4(1.0); + float roughness = 0.99; #if defined(USE_SPECULARMAP) + #if !defined(USE_SPECGLOSS) + vec4 ORMS = mix(vec4(1.0, 1.0, 0.0, 0.5), texture(u_SpecularMap, texCoords), u_EnableTextures.z); + + specular.rgb = mix(vec3(0.08) * u_SpecularScale.w, diffuse.rgb, ORMS.z) * ORMS.w; + diffuse.rgb *= vec3(1.0 - ORMS.z); + + roughness = mix(0.01, 1.0, ORMS.y); + AO = min(ORMS.x, AO); + #else specular = texture(u_SpecularMap, texCoords); + specular.rgb *= u_SpecularScale.xyz; + roughness = mix(1.0, 0.01, specular.a * (1.0 - u_SpecularScale.w)); + #endif #endif - specular *= u_SpecularScale; - float roughness = mix(1.0, 0.01, specular.a); + ambientColor *= AO; vec3 H = normalize(L + E); float NE = abs(dot(N, E)) + 1e-5; @@ -1002,8 +1028,7 @@ void main() #endif out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb, var_Normal.xyz); - out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb); - + out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb * AO); #else lightColor = var_Color.rgb; #if defined(USE_LIGHTMAP) diff --git a/codemp/rd-rend2/glsl/ssao.glsl b/codemp/rd-rend2/glsl/ssao.glsl index 0c2923baef..7c5bd26038 100644 --- a/codemp/rd-rend2/glsl/ssao.glsl +++ b/codemp/rd-rend2/glsl/ssao.glsl @@ -1,15 +1,22 @@ /*[Vertex]*/ -in vec4 attr_Position; -in vec4 attr_TexCoord0; - out vec2 var_ScreenTex; void main() { - gl_Position = attr_Position; - var_ScreenTex = attr_TexCoord0.xy; - //vec2 screenCoords = gl_Position.xy / gl_Position.w; - //var_ScreenTex = screenCoords * 0.5 + 0.5; + const vec2 positions[] = vec2[3]( + vec2(-1.0f, -1.0f), + vec2(-1.0f, 3.0f), + vec2( 3.0f, -1.0f) + ); + + const vec2 texcoords[] = vec2[3]( + vec2( 0.0f, 1.0f), + vec2( 0.0f, -1.0f), + vec2( 2.0f, 1.0f) + ); + + gl_Position = vec4(positions[gl_VertexID], 0.0, 1.0); + var_ScreenTex = texcoords[gl_VertexID]; } /*[Fragment]*/ @@ -75,7 +82,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN mat2 rmat = randomRotation(tex); int i; - for (i = 0; i < 3; i++) + for (i = 0; i < 9; i++) { vec2 offset = rmat * poissonDisc[i] * offsetScale; float sampleZ2 = zFar * getLinearDepth(depthMap, tex + offset, zFarDivZNear); @@ -89,7 +96,7 @@ float ambientOcclusion(sampler2D depthMap, const vec2 tex, const float zFarDivZN } } - result *= 0.33333; + result *= 0.11111; return result; } diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index b7ff858114..63e78ddf4c 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2067,7 +2067,7 @@ static void RB_RenderSunShadows() GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); } - GL_BindToTMU(tr.sunShadowArrayImage, TB_SHADOWMAP); + GL_BindToTMU(tr.sunShadowArrayImage, TB_SHADOWMAPARRAY); GLSL_SetUniformMatrix4x4( &tr.shadowmaskShader, @@ -2119,19 +2119,6 @@ static void RB_RenderSSAO() qglViewport(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); qglScissor(0, 0, tr.quarterFbo[0]->width, tr.quarterFbo[0]->height); - vec4_t quadVerts[4] = { - {-1.0f, 1.0f, 0.0f, 1.0f}, - { 1.0f, 1.0f, 0.0f, 1.0f}, - { 1.0f, -1.0f, 0.0f, 1.0f}, - {-1.0f, -1.0f, 0.0f, 1.0f}, - }; - vec2_t texCoords[4] = { - {0.0f, 1.0f}, - {1.0f, 1.0f}, - {1.0f, 0.0f}, - {0.0f, 0.0f}, - }; - GL_State( GLS_DEPTHTEST_DISABLE ); GLSL_BindProgram(&tr.ssaoShader); @@ -2139,7 +2126,8 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); + //RB_InstantQuad2(quadVerts, texCoords); + RB_InstantTriangle(); FBO_Bind(tr.quarterFbo[1]); @@ -2152,7 +2140,8 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); + //RB_InstantQuad2(quadVerts, texCoords); + RB_InstantTriangle(); FBO_Bind(tr.screenSsaoFbo); @@ -2165,7 +2154,8 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); - RB_InstantQuad2(quadVerts, texCoords); + //RB_InstantQuad2(quadVerts, texCoords); + RB_InstantTriangle(); } static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) @@ -2199,6 +2189,20 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) 0, glConfig.vidWidth, glConfig.vidHeight, 0); } + + if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + { + // need the depth in a texture we can do GL_LINEAR sampling on, so + // copy it to an HDR image + FBO_BlitFromTexture( + tr.renderDepthImage, + nullptr, + nullptr, + tr.hdrDepthFbo, + nullptr, + nullptr, + nullptr, 0); + } } static void RB_RenderMainPass( drawSurf_t *drawSurfs, int numDrawSurfs ) @@ -2260,20 +2264,6 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu RB_RenderDepthOnly(drawSurfs, numDrawSurfs); - if (r_ssao->integer) - { - // need the depth in a texture we can do GL_LINEAR sampling on, so - // copy it to an HDR image - FBO_BlitFromTexture( - tr.renderDepthImage, - nullptr, - nullptr, - tr.hdrDepthFbo, - nullptr, - nullptr, - nullptr, 0); - } - if ( r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) { RB_RenderSunShadows(); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e959099c17..6272b4a2dd 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3952,89 +3952,29 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) } // load into heap - int startTime, endTime; - startTime = ri.Milliseconds(); R_LoadEntities(worldData, &header->lumps[LUMP_ENTITIES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadEntities in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadShaders(worldData, &header->lumps[LUMP_SHADERS]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadShaders in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadLightmaps( worldData, &header->lumps[LUMP_LIGHTMAPS], &header->lumps[LUMP_SURFACES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadLightmaps in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadPlanes(worldData, &header->lumps[LUMP_PLANES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadPlanes in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadFogs( worldData, &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadFogs in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadSurfaces( worldData, &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadSurfaces in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadMarksurfaces(worldData, &header->lumps[LUMP_LEAFSURFACES]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadMarksurfaces in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadNodesAndLeafs(worldData, &header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadNodesAndLeafs in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadSubmodels(worldData, worldIndex, &header->lumps[LUMP_MODELS]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadSubmodels in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadVisibility(worldData, &header->lumps[LUMP_VISIBILITY]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadVisibility in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadLightGrid in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); - - startTime = ri.Milliseconds(); R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); - endTime = ri.Milliseconds(); - ri.Printf(PRINT_ALL, "R_LoadLightGridArray in %5.2f seconds\n", - (endTime - startTime) / 1000.0f); R_GenerateSurfaceSprites(worldData); diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index c1704e1d62..e93c080a2a 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -53,6 +53,7 @@ static uniformInfo_t uniformsInfo[] = { "u_NormalMap", GLSL_INT, 1 }, { "u_DeluxeMap", GLSL_INT, 1 }, { "u_SpecularMap", GLSL_INT, 1 }, + { "u_SSAOMap", GLSL_INT, 1 }, { "u_TextureMap", GLSL_INT, 1 }, { "u_LevelsMap", GLSL_INT, 1 }, @@ -64,7 +65,6 @@ static uniformInfo_t uniformsInfo[] = { "u_ShadowMap", GLSL_INT, 1 }, { "u_ShadowMap2", GLSL_INT, 1 }, - { "u_ShadowMap3", GLSL_INT, 1 }, { "u_ShadowMvp", GLSL_MAT4x4, 1 }, { "u_ShadowMvp2", GLSL_MAT4x4, 1 }, @@ -362,6 +362,9 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, va("#define ROUGHNESS_MIPS float(%i)\n", CUBE_MAP_ROUGHNESS_MIPS)); } + if (r_ssao->integer) + Q_strcat(dest, size, "#define USE_SSAO\n"); + if (r_deluxeSpecular->value > 0.000001f) { Q_strcat(dest, size, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); @@ -1685,7 +1688,11 @@ static int GLSL_LoadGPUProgramLightAll( } if (r_specularMapping->integer) + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SPECULARMAP\n"); + if (i & LIGHTDEF_USE_SPEC_GLOSS) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SPECGLOSS\n"); + } if (r_cubeMapping->integer) Q_strcat(extradefines, sizeof(extradefines), "#define USE_CUBEMAP\n"); @@ -1747,9 +1754,10 @@ static int GLSL_LoadGPUProgramLightAll( GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_DELUXEMAP, TB_DELUXEMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SPECULARMAP, TB_SPECULARMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP, TB_SHADOWMAP); - GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_CUBEMAP, TB_CUBEMAP); GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_ENVBRDFMAP, TB_ENVBRDFMAP); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SHADOWMAP2, TB_SHADOWMAPARRAY); + GLSL_SetUniformInt(&tr.lightallShader[i], UNIFORM_SSAOMAP, TB_SSAOMAP); qglUseProgram(0); GLSL_FinishGPUShader(&tr.lightallShader[i]); @@ -2054,9 +2062,7 @@ static int GLSL_LoadGPUProgramShadowMask( qglUseProgram(tr.shadowmaskShader.program); GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAP); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP2, TB_SHADOWMAP2); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP3, TB_SHADOWMAP3); + GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAPARRAY); qglUseProgram(0); GLSL_FinishGPUShader(&tr.shadowmaskShader); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d698e82572..d898402e4b 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1364,6 +1364,9 @@ static void R_MipMapsRGB( byte *in, int inWidth, int inHeight) int outWidth, outHeight; byte *temp; + if ( r_simpleMipMaps->integer ) + return; + outWidth = inWidth >> 1; outHeight = inHeight >> 1; temp = (byte *)ri.Hunk_AllocateTempMemory( outWidth * outHeight * 4 ); @@ -1411,39 +1414,9 @@ static void R_MipMap (byte *in, int width, int height) { byte *out; int row; - if ( !r_simpleMipMaps->integer ) { + if ( !r_simpleMipMaps->integer ) R_MipMap2( in, width, height ); - return; - } - - if ( width == 1 && height == 1 ) { - return; - } - - row = width * 4; - out = in; - width >>= 1; - height >>= 1; - if ( width == 0 || height == 0 ) { - width += height; // get largest - for (i=0 ; i>1; - out[1] = ( in[1] + in[5] )>>1; - out[2] = ( in[2] + in[6] )>>1; - out[3] = ( in[3] + in[7] )>>1; - } - return; - } - - for (i=0 ; i>2; - out[1] = (in[1] + in[5] + in[row+1] + in[row+5])>>2; - out[2] = (in[2] + in[6] + in[row+2] + in[row+6])>>2; - out[3] = (in[3] + in[7] + in[row+3] + in[row+7])>>2; - } - } } @@ -1451,6 +1424,9 @@ static void R_MipMapLuminanceAlpha (const byte *in, byte *out, int width, int he { int i, j, row; + if ( r_simpleMipMaps->integer ) + return; + if ( width == 1 && height == 1 ) { return; } @@ -1489,6 +1465,9 @@ static void R_MipMapNormalHeight (const byte *in, byte *out, int width, int heig int sx = swizzle ? 3 : 0; int sa = swizzle ? 0 : 3; + if ( r_simpleMipMaps->integer ) + return; + if ( width == 1 && height == 1 ) { return; } @@ -2034,7 +2013,7 @@ static void RawImage_UploadTexture( byte *data, int x, int y, int width, int hei } } - if ((flags & IMGFLAG_MIPMAP) && + if ((flags & IMGFLAG_MIPMAP) && (!r_simpleMipMaps->integer) && (data != NULL || !ShouldUseImmutableTextures(flags, internalFormat) )) { // Don't need to generate mipmaps if we are generating an immutable texture and @@ -2189,7 +2168,7 @@ static void Upload32( byte *data, int width, int height, imgType_t type, int fla } Com_Memcpy (scaledBuffer, data, width*height*4); } - else + else if ( !r_simpleMipMaps->integer ) { // use the normal mip-mapping function to go down from here while ( width > scaled_width || height > scaled_height ) { @@ -2420,9 +2399,16 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); int format = GL_BGRA; - if (internalFormat == GL_DEPTH_COMPONENT24) + switch (internalFormat) { + case GL_DEPTH_COMPONENT: + case GL_DEPTH_COMPONENT16: + case GL_DEPTH_COMPONENT24: + case GL_DEPTH_COMPONENT32: format = GL_DEPTH_COMPONENT; + break; + default: + break; } if (image->flags & IMGFLAG_MIPMAP) @@ -2484,6 +2470,9 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, glWrapClampMode ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, glWrapClampMode ); + + if (image->flags & IMGFLAG_MIPMAP && r_simpleMipMaps->integer) + qglGenerateMipmap(GL_TEXTURE_2D); } GL_SelectTexture( 0 ); @@ -2544,6 +2533,7 @@ image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height break; } + GL_SelectTexture(0); GL_Bind(image); //qglTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers); qglTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, format, GL_UNSIGNED_BYTE, NULL); @@ -2637,7 +2627,7 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h } Com_Memcpy (scaledBuffer, data, width*height*4); } - else + else if ( !r_simpleMipMaps->integer ) { // use the normal mip-mapping function to go down from here while ( width > scaled_width || height > scaled_height ) { @@ -2664,6 +2654,10 @@ void R_UpdateSubImage( image_t *image, byte *pic, int x, int y, int width, int h } Com_Memcpy( scaledBuffer, data, width * height * 4 ); } + else if ( !r_simpleMipMaps->integer ) + { + qglGenerateMipmap(GL_TEXTURE_2D); + } if (!(image->flags & IMGFLAG_NOLIGHTSCALE)) R_LightScaleTexture (scaledBuffer, scaled_width, scaled_height, (qboolean)(!(image->flags & IMGFLAG_MIPMAP)) ); @@ -2703,155 +2697,136 @@ image_t* R_GetLoadedImage(const char *name, int flags) { return NULL; } -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type) +void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName, int flags) { - char diffuseName[MAX_QPATH]; - char specularName[MAX_QPATH]; - int width, height, rmoWidth, rmoHeight; - byte *rmoPic, *baseColorPic, *specGlossPic, *diffusePic; + char packedName[MAX_QPATH]; + int packedWidth, packedHeight; + byte *packedPic; image_t *image; - if (!name) { + if (!packedImageName) { return; } - COM_StripExtension(name, diffuseName, sizeof(diffuseName)); - Q_strcat(diffuseName, sizeof(diffuseName), "_diffuse"); - - COM_StripExtension(name, specularName, sizeof(specularName)); - Q_strcat(specularName, sizeof(specularName), "_specGloss"); + COM_StripExtension(packedImageName, packedName, sizeof(packedName)); + Q_strcat(packedName, sizeof(packedName), "_ORMS"); // - // see if the images are already loaded + // see if the image is already loaded // - image = R_GetLoadedImage(diffuseName, flags); + image = R_GetLoadedImage(packedName, flags); if (image != NULL) { - stage->bundle[TB_COLORMAP].image[0] = image; - - image = R_GetLoadedImage(specularName, flags); - if (image != NULL) - { - stage->bundle[TB_SPECULARMAP].image[0] = R_GetLoadedImage(specularName, flags); - ri.Printf(PRINT_DEVELOPER, "WARNING: reused Diffuse and Specular images for %s\n", name); - return; - } - } - - // - // load the pics from disk - // - R_LoadImage(name, &baseColorPic, &width, &height); - if (baseColorPic == NULL) { + stage->bundle[TB_ORMSMAP].image[0] = image; return; } - R_LoadImage(rmoName, &rmoPic, &rmoWidth, &rmoHeight); - if (rmoPic == NULL) { - Z_Free(baseColorPic); + R_LoadImage(packedImageName, &packedPic, &packedWidth, &packedHeight); + if (packedPic == NULL) { return; } - if (width != rmoWidth || height != rmoHeight) + switch (stage->specularType) { - ri.Printf(PRINT_ALL, "WARNING: Can't build Specular Map for %s (different texture sizes for baseColor and rmo)\n", name); - Z_Free(baseColorPic); - Z_Free(rmoPic); - return; + case SPEC_RMOS: + case SPEC_MOSR: + case SPEC_ORMS: + stage->specularScale[3] = 1.0f; // Don't scale base specular + break; + default: + stage->specularScale[3] = 0.5f; // Basespecular is assumed to be 0.04 and shader assumes 0.08 + break; } - specGlossPic = (byte *)Z_Malloc(width * height * 4, TAG_TEMP_WORKSPACE, qfalse); - diffusePic = (byte *)Z_Malloc(width * height * 4, TAG_TEMP_WORKSPACE, qfalse); - - float baseSpecular; + // Don't scale occlusion, roughness and metalness + stage->specularScale[0] = + stage->specularScale[1] = + stage->specularScale[2] = 1.0f; + + GLint swizzle[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; - switch (type) + switch (stage->specularType) { + case SPEC_RMO: + swizzle[0] = GL_BLUE; + swizzle[1] = GL_RED; + swizzle[2] = GL_GREEN; + swizzle[3] = GL_ONE; + break; case SPEC_RMOS: + swizzle[0] = GL_BLUE; + swizzle[1] = GL_RED; + swizzle[2] = GL_GREEN; + swizzle[3] = GL_ALPHA; + break; + case SPEC_MOXR: + swizzle[0] = GL_GREEN; + swizzle[1] = GL_ALPHA; + swizzle[2] = GL_RED; + swizzle[3] = GL_ONE; + break; case SPEC_MOSR: - baseSpecular = 0.08f; + swizzle[0] = GL_GREEN; + swizzle[1] = GL_ALPHA; + swizzle[2] = GL_RED; + swizzle[3] = GL_BLUE; break; + case SPEC_ORM: + case SPEC_ORMS: default: - baseSpecular = 0.04f; break; } - for (int i = 0; i < width * height * 4; i += 4) + stage->bundle[TB_ORMSMAP].image[0] = R_CreateImage(packedName, packedPic, packedWidth, packedHeight, IMGTYPE_COLORALPHA, flags & ~IMGFLAG_SRGB, 0); + glBindTexture(GL_TEXTURE_2D, stage->bundle[TB_ORMSMAP].image[0]->texnum); + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); + Z_Free(packedPic); +} + +image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageName, int flags) +{ + char sdrName[MAX_QPATH]; + int specWidth, specHeight; + byte *specPic; + image_t *image; + + if (!specImageName) + return NULL; + + COM_StripExtension(specImageName, sdrName, sizeof(sdrName)); + Q_strcat(sdrName, sizeof(sdrName), "_SDR"); + + // + // see if the image is already loaded + // + image = R_GetLoadedImage(sdrName, flags); + if (image != NULL) + return image; + + R_LoadImage(specImageName, &specPic, &specWidth, &specHeight); + if (specPic == NULL) + return NULL; + + byte *sdrSpecPic = (byte *)Z_Malloc(specWidth * specHeight * 4, TAG_TEMP_WORKSPACE, qfalse); + vec3_t currentColor; + for (int i = 0; i < specWidth * specHeight * 4; i += 4) { - const float aoStrength = 0.5f; - float roughness, gloss, metalness, specular_variance, ao; + currentColor[0] = ByteToFloat(specPic[i + 0]); + currentColor[1] = ByteToFloat(specPic[i + 1]); + currentColor[2] = ByteToFloat(specPic[i + 2]); - switch (type) - { - case SPEC_RMO: - case SPEC_RMOS: - roughness = ByteToFloat(rmoPic[i + 0]); - gloss = (1.0 - roughness) + (0.04 * roughness); - metalness = ByteToFloat(rmoPic[i + 1]); - ao = ByteToFloat(rmoPic[i + 2]); - ao += (1.0 - ao) * (1.0 - aoStrength); - specular_variance = (type == SPEC_RMOS) ? ByteToFloat(rmoPic[i + 3]) : 1.0f; - break; - case SPEC_MOXR: - case SPEC_MOSR: - metalness = ByteToFloat(rmoPic[i + 0]); - ao = ByteToFloat(rmoPic[i + 1]); - ao += (1.0 - ao) * (1.0 - aoStrength); - specular_variance = (type == SPEC_MOSR) ? ByteToFloat(rmoPic[i + 2]) : 1.0f; - roughness = ByteToFloat(rmoPic[i + 3]); - gloss = (1.0 - roughness) + (0.04 * roughness); - break; - case SPEC_ORM: - case SPEC_ORMS: - ao = ByteToFloat(rmoPic[i + 0]); - roughness = ByteToFloat(rmoPic[i + 1]); - gloss = (1.0 - roughness) + (0.04 * roughness); - metalness = ByteToFloat(rmoPic[i + 2]); - specular_variance = (type == SPEC_ORMS) ? ByteToFloat(rmoPic[i + 3]) : 1.0f; - break; - // should never reach this - default: - specular_variance = 1.0f; - metalness = 0.0f; - gloss = 0.02f; - ao = 1.0f; - break; - } + float ratio = + (sRGBtoRGB(currentColor[0]) + sRGBtoRGB(currentColor[1]) + sRGBtoRGB(currentColor[1])) / + (currentColor[0] + currentColor[1] + currentColor[2]); - vec4_t baseColor; - // remove gamma correction because we want to work in linear space - baseColor[0] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 0])); - baseColor[1] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 1])); - baseColor[2] = sRGBtoRGB(ByteToFloat(baseColorPic[i + 2])); - // don't remove gamma correction in alpha because this is data, not color - baseColor[3] = ByteToFloat(baseColorPic[i + 3]); - - specular_variance *= baseSpecular; - - // diffuse Color = baseColor * (1.0 - metalness) - // also gamma correct again - // FIXME: AO should be handled in shader because it should only affect the ambient lighting - diffusePic[i + 0] = FloatToByte(RGBtosRGB(baseColor[0] * ao * (1.0f - metalness))); - diffusePic[i + 1] = FloatToByte(RGBtosRGB(baseColor[1] * ao * (1.0f - metalness))); - diffusePic[i + 2] = FloatToByte(RGBtosRGB(baseColor[2] * ao * (1.0f - metalness))); - diffusePic[i + 3] = FloatToByte(baseColor[3]); - - // specular Color = mix(baseSpecular, baseColor, metalness) - // also gamma correct again - specGlossPic[i + 0] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[0] * metalness)); - specGlossPic[i + 1] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[1] * metalness)); - specGlossPic[i + 2] = FloatToByte(RGBtosRGB(specular_variance * (1.0f - metalness) + baseColor[2] * metalness)); - // don't remove gamma correction in alpha because this is data, not color - specGlossPic[i + 3] = FloatToByte(gloss); - } - - stage->bundle[TB_COLORMAP].image[0] = R_CreateImage(diffuseName, diffusePic, width, height, IMGTYPE_COLORALPHA, flags, 0); - stage->bundle[TB_SPECULARMAP].image[0] = R_CreateImage(specularName, specGlossPic, width, height, IMGTYPE_COLORALPHA, flags, 0); - - Z_Free(diffusePic); - Z_Free(specGlossPic); - Z_Free(baseColorPic); - Z_Free(rmoPic); + sdrSpecPic[i + 0] = FloatToByte(currentColor[0] * ratio); + sdrSpecPic[i + 1] = FloatToByte(currentColor[1] * ratio); + sdrSpecPic[i + 2] = FloatToByte(currentColor[2] * ratio); + sdrSpecPic[i + 3] = specPic[i + 3]; + } + Z_Free(specPic); + + return R_CreateImage(sdrName, sdrSpecPic, specWidth, specHeight, IMGTYPE_COLORALPHA, flags & ~IMGFLAG_SRGB, 0); } static void R_CreateNormalMap ( const char *name, byte *pic, int width, int height, int flags ) @@ -2991,7 +2966,7 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) // // load the pic from disk // - if (r_hdr->integer && (flags & IMGFLAG_HDR)) + if (r_hdr->integer && (flags & IMGFLAG_HDR || flags & IMGFLAG_HDR_LIGHTMAP)) { char filename[MAX_QPATH]; Com_sprintf(filename, sizeof(filename), "%s.hdr", name); @@ -3003,16 +2978,19 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) { R_LoadImage(name, &pic, &width, &height); } - else + else { pic = (byte *)Z_Malloc(width*height*4*2, TAG_TEMP_WORKSPACE, qfalse); for (int i = 0; i < width*height; i++) { vec4_t color; memcpy(color, &floatBuffer[i*3], 12); - color[0] = color[0] / M_PI; - color[1] = color[1] / M_PI; - color[2] = color[2] / M_PI; + if (flags & IMGFLAG_HDR_LIGHTMAP) + { + color[0] = color[0] / M_PI; + color[1] = color[1] / M_PI; + color[2] = color[2] / M_PI; + } color[3] = 1.0f; ColorToRGBA16F2(color, (uint16_t *)(&pic[i * 8])); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 8debb2a9ea..cc875c2478 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -63,7 +63,7 @@ typedef unsigned int glIndex_t; #define PSHADOW_MAP_SIZE 1024 #define DSHADOW_MAP_SIZE 512 #define CUBE_MAP_MIPS 8 -#define CUBE_MAP_ROUGHNESS_MIPS CUBE_MAP_MIPS-4 +#define CUBE_MAP_ROUGHNESS_MIPS CUBE_MAP_MIPS - 2 #define CUBE_MAP_SIZE (1 << CUBE_MAP_MIPS) /* @@ -315,9 +315,10 @@ typedef enum IMGFLAG_GENNORMALMAP = 0x0100, IMGFLAG_MUTABLE = 0x0200, IMGFLAG_HDR = 0x0400, - IMGFLAG_2D_ARRAY = 0x0800, - IMGFLAG_3D = 0x1000, - IMGLFAG_SHADOWCOMP = 0x2000, + IMGFLAG_HDR_LIGHTMAP = 0x0800, + IMGFLAG_2D_ARRAY = 0x1000, + IMGFLAG_3D = 0x2000, + IMGLFAG_SHADOWCOMP = 0x4000, } imgFlags_t; typedef enum @@ -828,16 +829,17 @@ enum TB_DIFFUSEMAP = 0, TB_LIGHTMAP = 1, TB_LEVELSMAP = 1, - TB_SHADOWMAP3 = 1, TB_COLORMAP2 = 1, TB_NORMALMAP = 2, TB_DELUXEMAP = 3, TB_SPECULARMAP = 4, + TB_ORMSMAP = 4, TB_SHADOWMAP = 5, TB_CUBEMAP = 6, TB_ENVBRDFMAP = 7, - TB_SHADOWMAP2 = 8, - NUM_TEXTURE_BUNDLES = 9 + TB_SHADOWMAPARRAY = 8, + TB_SSAOMAP = 9, + NUM_TEXTURE_BUNDLES = 10 }; typedef enum @@ -848,16 +850,17 @@ typedef enum ST_GLSL } stageType_t; -enum specularType +typedef enum { - SPEC_NONE, // no specular found - SPEC_RMO, // calculate spec from rmo texture with a specular of 0.04 for dielectric materials - SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input - SPEC_MOXR, // calculate spec from moxr texture with a specular of 0.04 for dielectric materials - SPEC_MOSR, // calculate spec from mosr texture with a specular of 0.0 - 0.08 from input - SPEC_ORM, // calculate spec from orm texture with a specular of 0.04 for dielectric materials - SPEC_ORMS, // calculate spec from orms texture with a specular of 0.0 - 0.08 from input -}; + SPEC_NONE, // no specular found + SPEC_SPECGLOSS, // Specular Gloss + SPEC_RMO, // calculate spec from rmo texture with a specular of 0.04 for dielectric materials + SPEC_RMOS, // calculate spec from rmos texture with a specular of 0.0 - 0.08 from input + SPEC_MOXR, // calculate spec from moxr texture with a specular of 0.04 for dielectric materials + SPEC_MOSR, // calculate spec from mosr texture with a specular of 0.0 - 0.08 from input + SPEC_ORM, // calculate spec from orm texture with a specular of 0.04 for dielectric materials + SPEC_ORMS, // calculate spec from orms texture with a specular of 0.0 - 0.08 from input +} specularType_t; enum AlphaTestType { @@ -901,6 +904,7 @@ typedef struct { int lightmapStyle; stageType_t type; + specularType_t specularType; struct shaderProgram_s *glslShaderGroup; int glslShaderIndex; @@ -1206,12 +1210,13 @@ enum LIGHTDEF_USE_GLOW_BUFFER = 0x0080, LIGHTDEF_USE_ALPHA_TEST = 0x0100, LIGHTDEF_USE_CLOTH_BRDF = 0x0200, + LIGHTDEF_USE_SPEC_GLOSS = 0x0400, LIGHTDEF_LIGHTTYPE_MASK = LIGHTDEF_USE_LIGHTMAP | LIGHTDEF_USE_LIGHT_VECTOR | LIGHTDEF_USE_LIGHT_VERTEX, - LIGHTDEF_ALL = 0x03FF, + LIGHTDEF_ALL = 0x07FF, LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; @@ -1304,6 +1309,7 @@ typedef enum UNIFORM_NORMALMAP, UNIFORM_DELUXEMAP, UNIFORM_SPECULARMAP, + UNIFORM_SSAOMAP, UNIFORM_TEXTUREMAP, UNIFORM_LEVELSMAP, @@ -1315,7 +1321,6 @@ typedef enum UNIFORM_SHADOWMAP, UNIFORM_SHADOWMAP2, - UNIFORM_SHADOWMAP3, UNIFORM_SHADOWMVP, UNIFORM_SHADOWMVP2, @@ -3681,7 +3686,8 @@ void RE_AddDecalToScene ( qhandle_t shader, const vec3_t origin, const vec3_t di void R_AddDecals( void ); image_t *R_FindImageFile( const char *name, imgType_t type, int flags ); -void R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(shaderStage_t *stage, const char *name, const char *rmoName, int flags, int type); +void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName, int flags); +image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageName, int flags); qhandle_t RE_RegisterShader( const char *name ); qhandle_t RE_RegisterShaderNoMip( const char *name ); const char *RE_ShaderNameFromIndex(int index); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 146249c589..e11dab8aab 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1637,6 +1637,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SPECULARMAP); } + + if (r_ssao->integer) + samplerBindingsWriter.AddStaticImage(tr.screenSsaoImage, TB_SSAOMAP); } if ( enableCubeMaps ) @@ -1683,7 +1686,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, tess.dlightBits); if (r_dlightMode->integer > 1) - samplerBindingsWriter.AddStaticImage(tr.pointShadowArrayImage, TB_SHADOWMAP2); + samplerBindingsWriter.AddStaticImage(tr.pointShadowArrayImage, TB_SHADOWMAPARRAY); } else uniformDataWriter.SetUniformInt(UNIFORM_LIGHTMASK, 0); diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 20131aea0a..cebba1c1ef 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -112,7 +112,7 @@ static void ClearGlobalShader(void) stages[i].specularScale[0] = stages[i].specularScale[1] = stages[i].specularScale[2] = r_baseSpecular->value; - stages[i].specularScale[3] = 0.1; + stages[i].specularScale[3] = 0.99; } shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; @@ -1199,10 +1199,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) qboolean depthMaskExplicit = qfalse; char bufferPackedTextureName[MAX_QPATH]; char bufferBaseColorTextureName[MAX_QPATH]; - int buildSpecFromPacked = SPEC_NONE; - qboolean foundBaseColor = qfalse; stage->active = qtrue; + stage->specularType = SPEC_NONE; while ( 1 ) { @@ -1294,8 +1293,6 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf( PRINT_WARNING, "WARNING: R_FindImageFile could not find '%s' in shader '%s'\n", token, shader.name ); return qfalse; } - - foundBaseColor = qtrue; } } // @@ -1365,17 +1362,19 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - flags |= IMGFLAG_NOLIGHTSCALE; - - stage->bundle[TB_SPECULARMAP].image[0] = R_FindImageFile(token, type, flags); + // Always srgb to have correct reflectivity + if (shader.isHDRLit == qtrue) + stage->bundle[TB_SPECULARMAP].image[0] = R_FindImageFile(token, type, flags | IMGFLAG_SRGB); + else + stage->bundle[TB_SPECULARMAP].image[0] = R_BuildSDRSpecGlossImage(stage, token, flags); if (!stage->bundle[TB_SPECULARMAP].image[0]) { ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find specMap '%s' in shader '%s'\n", token, shader.name); return qfalse; } - - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + stage->specularType = SPEC_SPECGLOSS; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); } // // rmoMap || rmosMap @@ -1388,7 +1387,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'rmoMap' keyword in shader '%s'\n", shader.name); return qfalse; } - buildSpecFromPacked = !Q_stricmp(token, "rmosMap") ? SPEC_RMOS : SPEC_RMO; + stage->specularType = !Q_stricmp(token, "rmosMap") ? SPEC_RMOS : SPEC_RMO; Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1402,7 +1401,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'moxrMap' keyword in shader '%s'\n", shader.name); return qfalse; } - buildSpecFromPacked = !Q_stricmp(token, "mosrMap") ? SPEC_MOSR : SPEC_MOXR; + stage->specularType = !Q_stricmp(token, "mosrMap") ? SPEC_MOSR : SPEC_MOXR; Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1416,7 +1415,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf(PRINT_WARNING, "WARNING: missing parameter for 'ormMap' keyword in shader '%s'\n", shader.name); return qfalse; } - buildSpecFromPacked = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; + stage->specularType = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1612,7 +1611,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // Change shininess to gloss // FIXME: assumes max exponent of 8192 and min of 1, must change here if altered in lightall_fp.glsl exponent = CLAMP(exponent, 1.0, 8192.0); - stage->specularScale[3] = log(exponent) / log(8192.0); + stage->specularScale[3] = 1.0f - (log(exponent) / log(8192.0)); } // // gloss @@ -1626,7 +1625,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = Com_Clamp( 0.0f, 1.0f, atof( token ) ); + stage->specularScale[3] = Com_Clamp( 0.0f, 1.0f, 1.0 - atof( token ) ); } // // roughness @@ -1640,7 +1639,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, 1.0 - atof(token)); + stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, atof(token)); } // // parallaxDepth @@ -1734,7 +1733,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if ( token[0] == 0 ) { // two values, rgb then gloss - stage->specularScale[3] = stage->specularScale[1]; + stage->specularScale[3] = 1.0 - stage->specularScale[1]; stage->specularScale[1] = stage->specularScale[2] = stage->specularScale[0]; continue; @@ -1749,7 +1748,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = atof( token ); + stage->specularScale[3] = 1.0 - atof( token ); } // // rgbGen @@ -2068,9 +2067,9 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) } // - // build specular and diffuse if albedo and packed textures were found + // load packed textures // - if (foundBaseColor && buildSpecFromPacked != SPEC_NONE) + if (stage->specularType != SPEC_SPECGLOSS && stage->specularType != SPEC_NONE) { int flags = IMGFLAG_NOLIGHTSCALE; @@ -2083,12 +2082,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (shader.noTC) flags |= IMGFLAG_NO_COMPRESSION; - if (shader.isHDRLit == qtrue) - flags |= IMGFLAG_SRGB; - - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, bufferBaseColorTextureName, bufferPackedTextureName, flags, buildSpecFromPacked); - - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + R_LoadPackedMaterialImage(stage, bufferPackedTextureName, flags); } // @@ -2099,6 +2093,13 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) const char *filename = { va("%s/lm_", tr.worldName) }; if (!Q_strncmp(filename, bufferBaseColorTextureName, sizeof(filename))) { + if (shader.isHDRLit) + { + image_t *hdrImage = R_FindImageFile(bufferBaseColorTextureName, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_HDR_LIGHTMAP | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE); + if (hdrImage) + stage->bundle[0].image[0] = hdrImage; + } + stage->bundle[0].isLightmap = qtrue; shader.lightmapIndex[0] = LIGHTMAP_EXTERNAL; @@ -2322,13 +2323,13 @@ static void ParseSkyParms( const char **text ) { static const char *suf[6] = {"rt", "lf", "bk", "ft", "up", "dn"}; char pathname[MAX_QPATH]; int i; - int imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP; + int imgFlags = IMGFLAG_MIPMAP | IMGFLAG_PICMIP | IMGFLAG_CLAMPTOEDGE; if (shader.noTC) imgFlags |= IMGFLAG_NO_COMPRESSION; if (tr.hdrLighting == qtrue) - imgFlags |= IMGFLAG_SRGB | IMGFLAG_HDR | IMGFLAG_NOLIGHTSCALE; + imgFlags |= IMGFLAG_SRGB | IMGFLAG_HDR | IMGFLAG_NOLIGHTSCALE; // srgb or hdr are requested. If hdr is found, the srgb flag will be ignored // outerbox token = COM_ParseExt( text, qfalse ); @@ -2339,7 +2340,7 @@ static void ParseSkyParms( const char **text ) { if ( strcmp( token, "-" ) ) { for (i=0 ; i<6 ; i++) { Com_sprintf( pathname, sizeof(pathname), "%s_%s", token, suf[i] ); - shader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags | IMGFLAG_CLAMPTOEDGE ); + shader.sky.outerbox[i] = R_FindImageFile( ( char * ) pathname, IMGTYPE_COLORALPHA, imgFlags ); if ( !shader.sky.outerbox[i] ) { if ( i ) @@ -3115,43 +3116,52 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm image_t *diffuseImg; if (stage->bundle[TB_SPECULARMAP].image[0]) { - //ri.Printf(PRINT_ALL, ", specularmap %s", stage->bundle[TB_SPECULARMAP].image[0]->imgName); + if (stage->specularType == SPEC_SPECGLOSS) + defs |= LIGHTDEF_USE_SPEC_GLOSS; } - else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0])) + else if ((lightmap || useLightVector || useLightVertex) && (diffuseImg = stage->bundle[TB_DIFFUSEMAP].image[0]) != NULL) { - char specularName[MAX_QPATH]; + char imageName[MAX_QPATH]; image_t *specularImg; - int specularFlags = (diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP)) | IMGFLAG_NOLIGHTSCALE; + int specularFlags = diffuseImg->flags & ~(IMGFLAG_GENNORMALMAP); - COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); - Q_strcat(specularName, MAX_QPATH, "_specGloss"); + COM_StripExtension(diffuseImg->imgName, imageName, MAX_QPATH); + Q_strcat(imageName, MAX_QPATH, "_specGloss"); - specularImg = R_FindImageFile(specularName, IMGTYPE_COLORALPHA, specularFlags); + if (diffuseImg->flags & IMGFLAG_SRGB) + specularImg = R_FindImageFile(imageName, IMGTYPE_COLORALPHA, specularFlags); + else + specularImg = R_BuildSDRSpecGlossImage(stage, imageName, specularFlags); if (specularImg) { stage->bundle[TB_SPECULARMAP] = stage->bundle[0]; stage->bundle[TB_SPECULARMAP].numImageAnimations = 0; stage->bundle[TB_SPECULARMAP].image[0] = specularImg; - - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + stage->specularType = SPEC_SPECGLOSS; + defs |= LIGHTDEF_USE_SPEC_GLOSS; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); } else { - COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); - Q_strcat(specularName, MAX_QPATH, "_rmo"); - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_RMO); - - if (stage->bundle[TB_SPECULARMAP].image[0]) - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); - else + // Data images shouldn't be lightscaled + specularFlags |= IMGFLAG_NOLIGHTSCALE; + COM_StripExtension(diffuseImg->imgName, imageName, MAX_QPATH); + Q_strcat(imageName, MAX_QPATH, "_rmo"); + stage->specularType = SPEC_RMO; + R_LoadPackedMaterialImage(stage, imageName, specularFlags); + + if (!stage->bundle[TB_ORMSMAP].image[0]) { - COM_StripExtension(diffuseImg->imgName, specularName, MAX_QPATH); - Q_strcat(specularName, MAX_QPATH, "_orm"); - R_CreateDiffuseAndSpecMapsFromBaseColorAndRMO(stage, diffuseImg->imgName, specularName, specularFlags, SPEC_ORM); - - if (stage->bundle[TB_SPECULARMAP].image[0]) - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 1.0f); + COM_StripExtension(diffuseImg->imgName, imageName, MAX_QPATH); + Q_strcat(imageName, MAX_QPATH, "_orm"); + stage->specularType = SPEC_ORM; + R_LoadPackedMaterialImage(stage, imageName, specularFlags); + if (!stage->bundle[TB_ORMSMAP].image[0]) + { + stage->specularType = SPEC_SPECGLOSS; + defs |= LIGHTDEF_USE_SPEC_GLOSS; + } } } } @@ -4355,7 +4365,6 @@ shader_t *R_FindShader( const char *name, const int *lightmapIndexes, const byte Com_Memcpy (shader.lightmapIndex, lightmapIndexes, sizeof (shader.lightmapIndex)); Com_Memcpy (shader.styles, styles, sizeof (shader.styles)); switch (lightmapIndexes[0]) { - case LIGHTMAP_NONE: case LIGHTMAP_2D: case LIGHTMAP_WHITEIMAGE: { @@ -4546,6 +4555,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe // // create the default shading commands // + shader.isHDRLit = tr.hdrLighting; if ( shader.lightmapIndex[0] == LIGHTMAP_NONE ) { // dynamic colors at vertexes stages[0].bundle[0].image[0] = image; @@ -4559,8 +4569,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[0].rgbGen = CGEN_EXACT_VERTEX; stages[0].alphaGen = AGEN_SKIP; stages[0].stateBits = GLS_DEFAULT; - - shader.isHDRLit = tr.hdrLighting; } else if ( shader.lightmapIndex[0] == LIGHTMAP_2D ) { // GUI elements stages[0].bundle[0].image[0] = image; @@ -4570,6 +4578,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[0].stateBits = GLS_DEPTHTEST_DISABLE | GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; + shader.isHDRLit = qfalse; } else if ( shader.lightmapIndex[0] == LIGHTMAP_WHITEIMAGE ) { // fullbright level stages[0].bundle[0].image[0] = tr.whiteImage; @@ -4581,6 +4590,7 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[1].active = qtrue; stages[1].rgbGen = CGEN_IDENTITY; stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; + shader.isHDRLit = qfalse; } else { // two pass lightmap stages[0].bundle[0].image[0] = tr.lightmaps[shader.lightmapIndex[0]]; @@ -4596,8 +4606,6 @@ qhandle_t RE_RegisterShaderFromImage(const char *name, const int *lightmapIndexe stages[1].active = qtrue; stages[1].rgbGen = CGEN_IDENTITY; stages[1].stateBits |= GLS_SRCBLEND_DST_COLOR | GLS_DSTBLEND_ZERO; - - shader.isHDRLit = tr.hdrLighting; } sh = FinishShader(); From 616a2933fe78df75627c8dc167538ffc48aa62f8 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 15:32:32 +0100 Subject: [PATCH 597/708] Fixing stupids from last commits --- codemp/rd-rend2/tr_bsp.cpp | 1 + codemp/rd-rend2/tr_image.cpp | 2 +- codemp/rd-rend2/tr_main.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 6272b4a2dd..b51b1a5bf3 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3200,6 +3200,7 @@ static void R_RenderAllCubemaps() // Clear everything before rendering cubemaps to make sure only visable surfaces to the cubemap are rendered int frontEndMsec, backEndMsec; + R_IssuePendingRenderCommands(); RE_ClearScene(); R_InitNextFrame(); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d898402e4b..418d3f06a2 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -3487,7 +3487,7 @@ void R_CreateBuiltinImages( void ) { PSHADOW_MAP_SIZE, MAX_DRAWN_PSHADOWS, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, GL_DEPTH_COMPONENT16); } diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index a0b7d34a8e..35efdcf243 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2315,6 +2315,7 @@ void R_RenderPshadowMaps(const refdef_t *fd) switch (model->type) { case MOD_MDXM: + case MOD_BAD: { if (ent->e.ghoul2 && G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2))) { From af0674c676b4e43dac6ffddf88ceb785cd2040ae Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 15:33:00 +0100 Subject: [PATCH 598/708] Fixes regarding fog (again...) --- codemp/rd-rend2/tr_shade.cpp | 8 +++----- codemp/rd-rend2/tr_shader.cpp | 9 +++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index e11dab8aab..326e459cf4 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1866,14 +1866,12 @@ void RB_StageIteratorGeneric( void ) // now do fog // const fog_t *fog = nullptr; - if ( tr.world ) + if ( tr.world && input->fogNum != 0) { fog = tr.world->fogs + input->fogNum; } - - if ( fog && tess.shader->fogPass ) { - RB_FogPass( input, &vertexArrays ); - } + if (fog && tess.shader->fogPass) + RB_FogPass(input, &vertexArrays); // // draw debugging stuff diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index cebba1c1ef..100a802697 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3663,24 +3663,33 @@ static shader_t *GeneratePermanentShader( void ) { newShader->fogPass = FP_EQUAL; } else if ( shader.contentFlags & CONTENTS_FOG ) { newShader->fogPass = FP_LE; + } else { + newShader->fogPass = FP_NONE; } // determain if fog pass can use depth equal or not if (newShader->fogPass == FP_EQUAL) { newShader->fogPass = FP_LE; + bool allPassesAlpha = true; for (int stage = 0; stage < MAX_SHADER_STAGES; stage++) { shaderStage_t *pStage = &stages[stage]; if (!pStage->active) continue; + if (pStage->adjustColorsForFog != ACFF_MODULATE_ALPHA) + allPassesAlpha = false; + if (pStage->stateBits & GLS_DEPTHMASK_TRUE) { newShader->fogPass = FP_EQUAL; break; } } + + if (allPassesAlpha) + newShader->fogPass = FP_NONE; } tr.shaders[ tr.numShaders ] = newShader; From 2784f0e1291ab688d4419ad637c20171e42a4c0c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 15:33:35 +0100 Subject: [PATCH 599/708] Only update ubos when there's something to update --- codemp/rd-rend2/tr_backend.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 63e78ddf4c..0eaa852ea3 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -3346,11 +3346,14 @@ static const void *RB_DrawSurfs(const void *data) { // clear the z buffer, set the modelview, etc RB_BeginDrawingView(); - RB_UpdateConstants(cmd->drawSurfs, cmd->numDrawSurfs); + if (cmd->numDrawSurfs > 0) + { + RB_UpdateConstants(cmd->drawSurfs, cmd->numDrawSurfs); - RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); + RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); - RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); + RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); + } return (const void *)(cmd + 1); } From 87a08f2b711a7dfeae6d6c472c988c4963aed329 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 16:55:53 +0100 Subject: [PATCH 600/708] Allow $whiteimage to be used as specGloss map --- codemp/rd-rend2/tr_shader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 100a802697..b1239e4213 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -1348,6 +1348,8 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) if (!Q_stricmp(token, "$whiteimage")) { stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; + stage->specularType = SPEC_SPECGLOSS; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); continue; } From fe68e0f375779dedd7e04fc3ebbbb919378bd6ca Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 18:04:24 +0100 Subject: [PATCH 601/708] Don't skip shaders with deprecated shader comments --- codemp/rd-rend2/tr_shader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index b1239e4213..16df82a03f 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4878,6 +4878,14 @@ static void ScanAndLoadShaderFiles( void ) Q_strncpyz(shaderName, token, sizeof(shaderName)); shaderLine = COM_GetCurrentParseLine(); + if (token[0] == '#') + { + ri.Printf(PRINT_WARNING, "WARNING: Deprecated shader comment \"%s\" on line %d in file %s. Ignoring line.\n", + shaderName, shaderLine, filename); + SkipRestOfLine(&p); + continue; + } + token = COM_ParseExt(&p, qtrue); if(token[0] != '{' || token[1] != '\0') { From 9cbe7e5f65e66c752f84f0cbdfa6989e626cee0d Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 2 Nov 2022 18:05:04 +0100 Subject: [PATCH 602/708] [weather] apply friction to down force too --- codemp/rd-rend2/tr_weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index e35dcf2555..272f559229 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -286,7 +286,7 @@ namespace vec3_t envForce = { tr.weatherSystem->windDirection[0] * frictionInverse, tr.weatherSystem->windDirection[1] * frictionInverse, - -ws->gravity + -ws->gravity * frictionInverse }; vec4_t randomOffset = { Q_flrand(-4.0f, 4.0f), From 131f1870ba07e83114022c5abfbbb221a3435c7b Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 12 Nov 2022 13:22:07 +0100 Subject: [PATCH 603/708] Remove ioq3 flare code and replace with vanilla way of rendering them --- codemp/rd-rend2/tr_bsp.cpp | 17 --- codemp/rd-rend2/tr_flares.cpp | 204 +++++++--------------------------- codemp/rd-rend2/tr_glsl.cpp | 3 +- codemp/rd-rend2/tr_init.cpp | 8 -- codemp/rd-rend2/tr_local.h | 10 -- codemp/rd-rend2/tr_shader.cpp | 16 +-- 6 files changed, 44 insertions(+), 214 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b51b1a5bf3..b10f59cff1 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -1166,23 +1166,6 @@ static void ParseFlare( const world_t *worldData, dsurface_t *ds, drawVert_t *ve else flare->shader = surf->shader; - if (!flare->shader->defaultShader) - { - // Set some default values. Deforms are handled by the flares system itself - flare->shader->cullType = CT_TWO_SIDED; - flare->shader->numDeforms = 0; - for (int index = 0; index < flare->shader->numUnfoggedPasses; index++) - { - flare->shader->stages[index]->adjustColorsForFog = ACFF_NONE; - flare->shader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; - if (flare->shader->stages[index]->alphaGen == AGEN_PORTAL) - { - flare->portal_ranged = true; - flare->shader->stages[index]->alphaGen = AGEN_VERTEX; - } - } - } - surf->data = (surfaceType_t *)flare; for ( i = 0 ; i < 3 ; i++ ) { diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index d1ffdc4be7..87439f48ca 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -77,6 +77,7 @@ typedef struct flare_s { vec3_t origin; vec3_t color; + vec3_t normal; } flare_t; #define MAX_FLARES 128 @@ -84,21 +85,6 @@ typedef struct flare_s { flare_t r_flareStructs[MAX_FLARES]; flare_t *r_activeFlares, *r_inactiveFlares; -int flareCoeff; - -/* -================== -R_SetFlareCoeff -================== -*/ -static void R_SetFlareCoeff( void ) { - - if(r_flareCoeff->value == 0.0f) - flareCoeff = atof(FLARE_STDCOEFF); - else - flareCoeff = r_flareCoeff->value; -} - /* ================== R_ClearFlares @@ -115,8 +101,6 @@ void R_ClearFlares( void ) { r_flareStructs[i].next = r_inactiveFlares; r_inactiveFlares = &r_flareStructs[i]; } - - R_SetFlareCoeff(); } @@ -141,10 +125,6 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t VectorSubtract( backEnd.viewParms.ori.origin, point, local ); VectorNormalizeFast(local); d = DotProduct(local, normal); - - // // If the viewer is behind the flare don't add it. - // if(d < 0) - // return; } // if the point is off the screen, don't bother adding it @@ -201,6 +181,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t VectorCopy(point, f->origin); VectorCopy( color, f->color ); + VectorCopy( normal, f->normal); // fade the intensity of the flare down as the // light surface turns away from the viewer @@ -308,7 +289,7 @@ void RB_TestFlare( flare_t *f ) { f->visible = qtrue; f->fadeTime = backEnd.refdef.time - 1; } - fade = ( ( backEnd.refdef.time - f->fadeTime ) /1000.0f ) * r_flareFade->value; + fade = ( ( backEnd.refdef.time - f->fadeTime ) / 500.0f ); } else { // Dont fade out when flare is occluded. Will result in the ability to see // flares through surfaces on high movement speeds @@ -338,143 +319,56 @@ RB_RenderFlare */ void RB_RenderFlare( flare_t *f ) { float size; - vec3_t color; - int iColor[3]; + vec4_t color; float distance, intensity, factor; - byte fogFactors[3] = {255, 255, 255}; backEnd.pc.c_flareRenders++; - // We don't want too big values anyways when dividing by distance. - if(f->eyeZ > -1.0f) - distance = 1.0f; - else - distance = -f->eyeZ; + srfFlare_t *flare = (srfFlare_t *)f->surface; - // calculate the flare size.. - size = backEnd.viewParms.viewportWidth * ( r_flareSize->value/640.0f + 8 / distance ); + backEnd.currentEntity = &tr.worldEntity; + RB_BeginSurface( flare->shader, f->fogNum, 0 ); -/* - * This is an alternative to intensity scaling. It changes the size of the flare on screen instead - * with growing distance. See in the description at the top why this is not the way to go. - // size will change ~ 1/r. - size = backEnd.viewParms.viewportWidth * (r_flareSize->value / (distance * -2.0f)); -*/ + vec3_t dir; + vec3_t left, up; + vec3_t origin; + float d, dist; -/* - * As flare sizes stay nearly constant with increasing distance we must decrease the intensity - * to achieve a reasonable visual result. The intensity is ~ (size^2 / distance^2) which can be - * got by considering the ratio of - * (flaresurface on screen) : (Surface of sphere defined by flare origin and distance from flare) - * An important requirement is: - * intensity <= 1 for all distances. - * - * The formula used here to compute the intensity is as follows: - * intensity = flareCoeff * size^2 / (distance + size*sqrt(flareCoeff))^2 - * As you can see, the intensity will have a max. of 1 when the distance is 0. - * The coefficient flareCoeff will determine the falloff speed with increasing distance. - */ - - factor = distance + size * sqrt((double)flareCoeff); - - intensity = flareCoeff * size * size / (factor * factor); - - VectorScale(f->color, f->drawIntensity * intensity, color); - - // Calculations for fogging - if(tr.world && f->fogNum > 0 && f->fogNum < tr.world->numfogs) - { - tess.numVertexes = 1; - VectorCopy(f->origin, tess.xyz[0]); - tess.fogNum = f->fogNum; - - RB_CalcModulateColorsByFog(fogFactors); - - // We don't need to render the flare if colors are 0 anyways. - if(!(fogFactors[0] || fogFactors[1] || fogFactors[2])) - return; - } + // calculate the xyz locations for the four corners + VectorMA(f->origin, 3, f->normal, origin); + float* snormal = f->normal; - srfFlare_t *flare = (srfFlare_t *)f->surface; - float alpha = 1.0f; - if (flare->portal_ranged) - { - float len = distance; - len /= flare->shader->portalRange; + VectorSubtract(origin, backEnd.viewParms.ori.origin, dir); + dist = VectorNormalize(dir); - if (len < 0) - { - alpha = 0; - } - else if (len > 1) - { - alpha = 0xff; - } - else - { - alpha = len * 0xff; - } - alpha /= 255.0f; + d = -DotProduct(dir, snormal); + if (d < 0) { + d = -d; } - iColor[0] = (color[0] * fogFactors[0] * alpha) / 255.0f; - iColor[1] = (color[1] * fogFactors[1] * alpha) / 255.0f; - iColor[2] = (color[2] * fogFactors[2] * alpha) / 255.0f; + // fade the intensity of the flare down as the + // light surface turns away from the viewer + color[0] = d; + color[1] = d; + color[2] = d; + color[3] = 1.0f; //only gets used if the shader has cgen exact_vertex! - backEnd.currentEntity = &backEnd.entityFlare; - RB_BeginSurface( flare->shader, f->fogNum, 0 ); + float radius = tess.shader->portalRange ? tess.shader->portalRange : 30; + if (dist < 512.0f) + { + radius = radius * dist / 512.0f; + } + if (radius < 5.0f) + { + radius = 5.0f; + } + VectorScale(backEnd.viewParms.ori.axis[1], radius, left); + VectorScale(backEnd.viewParms.ori.axis[2], radius, up); + if (backEnd.viewParms.isMirror) { + VectorSubtract(vec3_origin, left, left); + } - // FIXME: use quadstamp? - tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY - size; - tess.xyz[tess.numVertexes][2] = 0.5f; - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = iColor[0]; - tess.vertexColors[tess.numVertexes][1] = iColor[1]; - tess.vertexColors[tess.numVertexes][2] = iColor[2]; - tess.vertexColors[tess.numVertexes][3] = alpha; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX - size; - tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY + size; - tess.xyz[tess.numVertexes][2] = 0.5f; - tess.texCoords[tess.numVertexes][0][0] = 0; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = iColor[0]; - tess.vertexColors[tess.numVertexes][1] = iColor[1]; - tess.vertexColors[tess.numVertexes][2] = iColor[2]; - tess.vertexColors[tess.numVertexes][3] = alpha; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY + size; - tess.xyz[tess.numVertexes][2] = 0.5f; - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 1; - tess.vertexColors[tess.numVertexes][0] = iColor[0]; - tess.vertexColors[tess.numVertexes][1] = iColor[1]; - tess.vertexColors[tess.numVertexes][2] = iColor[2]; - tess.vertexColors[tess.numVertexes][3] = alpha; - tess.numVertexes++; - - tess.xyz[tess.numVertexes][0] = f->windowX + size; - tess.xyz[tess.numVertexes][1] = backEnd.viewParms.viewportHeight - f->windowY - size; - tess.xyz[tess.numVertexes][2] = 0.5f; - tess.texCoords[tess.numVertexes][0][0] = 1; - tess.texCoords[tess.numVertexes][0][1] = 0; - tess.vertexColors[tess.numVertexes][0] = iColor[0]; - tess.vertexColors[tess.numVertexes][1] = iColor[1]; - tess.vertexColors[tess.numVertexes][2] = iColor[2]; - tess.vertexColors[tess.numVertexes][3] = alpha; - tess.numVertexes++; - - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 1; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 0; - tess.indexes[tess.numIndexes++] = 2; - tess.indexes[tess.numIndexes++] = 3; + RB_AddQuadStamp(origin, left, up, color); RB_EndSurface(); } @@ -509,12 +403,6 @@ void RB_RenderFlares (void) { (backEnd.viewParms.flags & VPF_NOPOSTPROCESS)) return; - if(r_flareCoeff->modified) - { - R_SetFlareCoeff(); - r_flareCoeff->modified = qfalse; - } - // Reset currentEntity to world so that any previously referenced entities // don't have influence on the rendering of these flares (i.e. RF_ renderer flags). backEnd.currentEntity = &tr.worldEntity; @@ -557,15 +445,6 @@ void RB_RenderFlares (void) { return; // none visible } - Matrix16Copy(glState.projection, oldprojection); - Matrix16Copy(glState.modelview, oldmodelview); - Matrix16Identity(matrix); - GL_SetModelviewMatrix(matrix); - Matrix16Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth, - backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight, backEnd.viewParms.viewportY, - -99999, 99999, matrix ); - GL_SetProjectionMatrix(matrix); - for ( f = r_activeFlares ; f ; f = f->next ) { if ( f->frameSceneNum == backEnd.viewParms.frameSceneNum && f->inPortal == backEnd.viewParms.isPortal @@ -573,9 +452,6 @@ void RB_RenderFlares (void) { RB_RenderFlare( f ); } } - - GL_SetProjectionMatrix(oldprojection); - GL_SetModelviewMatrix(oldmodelview); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index e93c080a2a..ce5948f1c9 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2638,8 +2638,7 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) } if (tess.fogNum && - pStage->adjustColorsForFog != ACFF_NONE && - !(shaderAttribs & GENERICDEF_USE_RGBAGEN)) + pStage->adjustColorsForFog != ACFF_NONE) shaderAttribs |= GENERICDEF_USE_FOG; if (pStage->bundle[0].tcGen != TCGEN_TEXTURE) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 9ceb51b4b9..820d98e184 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -52,10 +52,6 @@ window_t window; cvar_t *se_language; -cvar_t *r_flareSize; -cvar_t *r_flareFade; -cvar_t *r_flareCoeff; - cvar_t *r_verbose; cvar_t *r_ignore; @@ -1581,10 +1577,6 @@ void R_Register( void ) r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0, "" ); r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); - r_flareSize = ri.Cvar_Get ("r_flareSize", "4", CVAR_CHEAT, ""); - r_flareFade = ri.Cvar_Get ("r_flareFade", "7", CVAR_CHEAT, ""); - r_flareCoeff = ri.Cvar_Get ("r_flareCoeff", FLARE_STDCOEFF, CVAR_CHEAT, ""); - r_skipBackEnd = ri.Cvar_Get ("r_skipBackEnd", "0", CVAR_CHEAT, ""); r_measureOverdraw = ri.Cvar_Get( "r_measureOverdraw", "0", CVAR_CHEAT, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index cc875c2478..75b4cd6bef 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -76,10 +76,6 @@ In JA, we define these in the tr_local.h, which is much more logical ===================================================== */ -extern cvar_t *r_flareSize; -extern cvar_t *r_flareFade; -extern cvar_t *r_flareCoeff; - extern cvar_t *r_verbose; extern cvar_t *r_ignore; @@ -2605,12 +2601,6 @@ extern window_t window; // // cvars // -extern cvar_t *r_flareSize; -extern cvar_t *r_flareFade; -// coefficient for the flare intensity falloff function. -#define FLARE_STDCOEFF "80" -extern cvar_t *r_flareCoeff; - extern cvar_t *r_railWidth; extern cvar_t *r_railCoreWidth; extern cvar_t *r_railSegmentLength; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 16df82a03f..4cddb303d5 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -4073,6 +4073,9 @@ static shader_t *FinishShader( void ) { // we can't adjust this one correctly, so it won't be exactly correct in fog } + if (pStage->alphaGen == AGEN_PORTAL && pStage->adjustColorsForFog == ACFF_MODULATE_ALPHA) + pStage->adjustColorsForFog = ACFF_NONE; + // don't screw with sort order if this is a portal or environment if ( !shader.sort ) { // see through item, like a grill or grate @@ -5053,19 +5056,6 @@ static void CreateExternalShaders( void ) { tr.projectionShadowShader = R_FindShader( "projectionShadow", lightmapsNone, stylesDefault, qtrue ); tr.flareShader = R_FindShader( "gfx/misc/flare", lightmapsNone, stylesDefault, qtrue ); - // Hack to make fogging work correctly on flares. Fog colors are calculated - // in tr_flare.c already. - if(!tr.flareShader->defaultShader) - { - int index; - - for(index = 0; index < tr.flareShader->numUnfoggedPasses; index++) - { - tr.flareShader->stages[index]->adjustColorsForFog = ACFF_NONE; - tr.flareShader->stages[index]->stateBits |= GLS_DEPTHTEST_DISABLE; - } - } - tr.sunShader = R_FindShader( "sun", lightmapsNone, stylesDefault, qtrue ); tr.sunFlareShader = R_FindShader( "gfx/2d/sunflare", lightmapsNone, stylesDefault, qtrue); From 282843f98e0fc49f2f8b1ee5e2d63cc0d9317ce4 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 22 Jan 2023 22:58:46 +0100 Subject: [PATCH 604/708] Fix refraction shader keyword + some cleanup --- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_image.cpp | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 0eaa852ea3..7a37e6dbcb 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1259,13 +1259,13 @@ static void RB_SubmitDrawSurfsForDepthFill( R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemapIndex, &postRender); assert(shader != nullptr); - if (shader->sort != SS_OPAQUE) + if (shader->sort != SS_OPAQUE || shader->useDistortion) { // Don't draw yet, let's see what's to come continue; } - if ( shader == oldShader && entityNum == oldEntityNum) + if ( shader == oldShader && entityNum == oldEntityNum ) { // fast path, same as previous sort backEnd.currentDrawSurfIndex = i; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 418d3f06a2..b7a5f05d96 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -1410,9 +1410,6 @@ Operates in place, quartering the size of the texture ================ */ static void R_MipMap (byte *in, int width, int height) { - int i, j; - byte *out; - int row; if ( !r_simpleMipMaps->integer ) R_MipMap2( in, width, height ); From 5a4ef95ff6758598aa96352f273dee6e7d0764ff Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 27 Jan 2023 02:36:59 +0100 Subject: [PATCH 605/708] Fix md3 model caching The cached data was overwritten with model data which caused a drop error when a md3 model was already loaded. --- codemp/rd-rend2/tr_model.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index cbf8e355e7..b95114639e 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -861,7 +861,8 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN mod->dataSize += size; //mdvModel = mod->mdv[lod] = (mdvModel_t *)ri.Hunk_Alloc(sizeof(mdvModel_t), h_low); qboolean bAlreadyFound = qfalse; - mdvModel = mod->data.mdv[lod] = (mdvModel_t *)CModelCache->Allocate( size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3 ); + md3Model = (md3Header_t *)CModelCache->Allocate(size, buffer, modName, &bAlreadyFound, TAG_MODEL_MD3); + mdvModel = mod->data.mdv[lod] = (mdvModel_t *)ri.Hunk_Alloc(sizeof(*mdvModel), h_low); // Com_Memcpy(mod->md3[lod], buffer, LittleLong(md3Model->ofsEnd)); if( !bAlreadyFound ) From 9d0860bc1ecc9cc6e3bb19fb9099fd8850201399 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 1 Feb 2023 15:15:35 +0100 Subject: [PATCH 606/708] Don't allow parallax mapping on unlit surfaces Prevents a crash, as no shader permutation is compiled for this case. Might allow parallax mapping on those surfaces later. --- codemp/rd-rend2/tr_shader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 4cddb303d5..62cf29de06 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3072,7 +3072,9 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm image_t *diffuseImg; if (stage->bundle[TB_NORMALMAP].image[0]) { - if (stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT && r_parallaxMapping->integer) + if (stage->bundle[TB_NORMALMAP].image[0]->type == IMGTYPE_NORMALHEIGHT && + r_parallaxMapping->integer && + defs & LIGHTDEF_LIGHTTYPE_MASK) defs |= LIGHTDEF_USE_PARALLAXMAP; //ri.Printf(PRINT_ALL, ", normalmap %s", stage->bundle[TB_NORMALMAP].image[0]->imgName); } From 4a2cdb9fc3e128544b5881485bf0214096d12276 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Wed, 1 Mar 2023 10:41:56 +0100 Subject: [PATCH 607/708] Initial work on weather zones Currently disabled because weatherzones are actually just markers for the vanilla system to speedup creating a point cloud with inside outside flags. This is of no use in the current system. --- codemp/rd-rend2/tr_backend.cpp | 2 +- codemp/rd-rend2/tr_bsp.cpp | 34 +++++++++ codemp/rd-rend2/tr_init.cpp | 2 +- codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_weather.cpp | 125 ++++++++++++++++++++++++++++++--- codemp/rd-rend2/tr_weather.h | 1 + 6 files changed, 155 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 7a37e6dbcb..cea92c6a59 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -606,7 +606,7 @@ void RB_BeginDrawingView (void) { if (tr.world && tr.world->skyboxportal == 1 && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) clearBits &= ~GL_COLOR_BUFFER_BIT; - if (clearBits > 0) + if (clearBits > 0 && !(backEnd.viewParms.flags & VPF_NOCLEAR)) qglClear( clearBits ); if (backEnd.viewParms.targetFbo == NULL) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index b10f59cff1..68675428b7 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3209,6 +3209,39 @@ static void R_RenderAllCubemaps() } +void R_LoadWeatherZones() +{ + char spawnVarChars[2048]; + int numSpawnVars; + char *spawnVars[MAX_SPAWN_VARS][2]; + + while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) + { + vec3_t mins, maxs; + qboolean isWeatherZone = qfalse; + char *model = NULL; + + for (int i = 0; i < numSpawnVars; i++) + { + if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], "misc_weather_zone")) + { + isWeatherZone = qtrue; + } + if (!Q_stricmp(spawnVars[i][0], "model")) + { + model = spawnVars[i][1]; + } + } + + if (isWeatherZone == qtrue && model != NULL) + { + R_ModelBounds(RE_RegisterModel(model), mins, maxs); + R_AddWeatherZone(mins, maxs); + } + } +} + + /* ================= R_MergeLeafSurfaces @@ -4066,6 +4099,7 @@ void RE_LoadWorldMap( const char *name ) { tr.worldMapLoaded = qtrue; tr.world = world; + R_LoadWeatherZones(); R_InitWeatherForMap(); // Render all cubemaps diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 820d98e184..11745315af 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -2061,7 +2061,7 @@ void RE_SetLightStyle(int style, int color) void RE_GetBModelVerts(int bmodelIndex, vec3_t *verts, vec3_t normal); void RE_WorldEffectCommand(const char *cmd); -void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} +void stub_RE_AddWeatherZone ( vec3_t mins, vec3_t maxs ) {} // Intentionally left blank. Rend2 reads the zones manually on bsp load static void RE_SetRefractionProperties ( float distortionAlpha, float distortionStretch, qboolean distortionPrePost, qboolean distortionNegate ) { } void C_LevelLoadBegin(const char *psMapName, ForceReload_e eForceReload) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 75b4cd6bef..51202445b5 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1497,6 +1497,7 @@ enum viewParmFlag_t { VPF_NOPOSTPROCESS = 0x100, VPF_POINTSHADOW = 0x200,// Rendering pointlight shadow VPF_SHADOWCASCADES = 0x400,// Rendering sun shadow cascades + VPF_NOCLEAR = 0x800, }; using viewParmFlags_t = uint32_t; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 272f559229..b4f86620df 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -43,6 +43,9 @@ const int maxWeatherTypeParticles[NUM_WEATHER_TYPES] = { 1000 }; +#define MAX_WINDOBJECTS 10 +#define MAX_WEATHER_ZONES 100 + struct weatherObject_t { VBO_t *lastVBO; @@ -60,7 +63,6 @@ struct weatherObject_t vec2_t size; }; -#define MAX_WINDOBJECTS 10 struct windObject_t { vec3_t currentVelocity; @@ -72,13 +74,21 @@ struct windObject_t int targetVelocityTimeRemaining; }; +struct weatherZone_t +{ + vec3_t mins; + vec3_t maxs; +}; + struct weatherSystem_t { weatherObject_t weatherSlots[NUM_WEATHER_TYPES]; windObject_t windSlots[MAX_WINDOBJECTS]; + weatherZone_t weatherZones[MAX_WEATHER_ZONES]; int activeWeatherTypes = 0; int activeWindObjects = 0; + int numWeatherZones = 0; bool frozen; srfWeather_t weatherSurface; @@ -227,6 +237,97 @@ namespace VPF_DEPTHCLAMP | VPF_DEPTHSHADOW | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL, orientation, viewBounds); + Matrix16Multiply( + tr.viewParms.projectionMatrix, + tr.viewParms.world.modelViewMatrix, + tr.weatherSystem->weatherMVP); + +#ifdef 0 + if (tr.weatherSystem->numWeatherZones > 0) + { + FBO_Bind(tr.weatherDepthFbo); + + qglViewport(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); + qglScissor(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); + + // clear depth to 0, then stomp the depth buffer with the mins of the weather zones + qglClearDepth(0.0f); + qglClear(GL_DEPTH_BUFFER_BIT); + qglClearDepth(1.0f); + + qglEnable(GL_DEPTH_CLAMP); + + GL_State(GLS_DEPTHMASK_TRUE | GLS_DEPTHFUNC_GREATER); + GL_Cull(CT_TWO_SIDED); + vec4_t color = { 0.0f, 0.0f, 0.0f, 1.0f }; + backEnd.currentEntity = &tr.worldEntity; + RB_BeginSurface(tr.defaultShader, 0, 0); + + for (int i = 0; i <= tr.weatherSystem->numWeatherZones; i++) + { + weatherZone_t *currentWeatherZone = &tr.weatherSystem->weatherZones[i]; + { + vec3_t up = { + currentWeatherZone->mins[0] - currentWeatherZone->maxs[0], + 0.0f, + 0.0f }; + vec3_t left = { + 0.0f, + currentWeatherZone->mins[1] - currentWeatherZone->maxs[1], + 0.0f }; + vec3_t zone_origin = { + currentWeatherZone->maxs[0], + currentWeatherZone->maxs[1], + currentWeatherZone->maxs[2] }; + + RB_AddQuadStamp(zone_origin, left, up, color); + } + { + vec3_t up = { + -currentWeatherZone->mins[0] + currentWeatherZone->maxs[0], + 0.0f, + 0.0f }; + vec3_t left = { + 0.0f, + -currentWeatherZone->mins[1] + currentWeatherZone->maxs[1], + 0.0f }; + vec3_t zone_origin = { + currentWeatherZone->mins[0], + currentWeatherZone->mins[1], + currentWeatherZone->mins[2] }; + + RB_AddQuadStamp(zone_origin, left, up, color); + } + } + + RB_UpdateVBOs(ATTR_POSITION); + + GLSL_VertexAttribsState(ATTR_POSITION, NULL); + + GLSL_BindProgram(&tr.textureColorShader); + + GLSL_SetUniformMatrix4x4( + &tr.textureColorShader, + UNIFORM_MODELVIEWPROJECTIONMATRIX, + tr.weatherSystem->weatherMVP); + + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + RB_CommitInternalBufferData(); + + qglDisable(GL_DEPTH_CLAMP); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.minIndex = 0; + tess.maxIndex = 0; + tess.useInternalVBO = qfalse; + } + + if (tr.weatherSystem->numWeatherZones > 0) + tr.viewParms.flags |= VPF_NOCLEAR; +#endif const int firstDrawSurf = tr.refdef.numDrawSurfs; @@ -235,11 +336,6 @@ namespace tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf); - Matrix16Multiply( - tr.viewParms.projectionMatrix, - tr.viewParms.world.modelViewMatrix, - tr.weatherSystem->weatherMVP); - R_IssuePendingRenderCommands(); R_InitNextFrame(); RE_EndScene(); @@ -388,6 +484,19 @@ qboolean WE_ParseVector(const char **text, int count, float *v) { return qtrue; } +void R_AddWeatherZone(vec3_t mins, vec3_t maxs) +{ + if (tr.weatherSystem->numWeatherZones >= MAX_WEATHER_ZONES) + { + ri.Printf(PRINT_WARNING, "Max weather zones hit. Skipping new zone\n"); + return; + } + VectorCopy(mins, tr.weatherSystem->weatherZones[tr.weatherSystem->numWeatherZones].mins); + VectorCopy(maxs, tr.weatherSystem->weatherZones[tr.weatherSystem->numWeatherZones].maxs); + tr.weatherSystem->numWeatherZones++; + ri.Printf(PRINT_ALL, "Weather zone %i added\n", tr.weatherSystem->numWeatherZones); +} + void RE_WorldEffectCommand(const char *command) { if (!command) @@ -440,9 +549,9 @@ void RE_WorldEffectCommand(const char *command) { vec3_t mins; vec3_t maxs; - //if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) + if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) { - ri.Printf(PRINT_DEVELOPER, "Weather zones aren't supported in MP\n"); + R_AddWeatherZone(mins, maxs); } } diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index 991a2cd63a..c0d597b78d 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -28,6 +28,7 @@ struct srfWeather_t; void R_InitWeatherSystem(); void R_InitWeatherForMap(); void R_AddWeatherSurfaces(); +void R_AddWeatherZone(vec3_t mins, vec3_t maxs); void R_ShutdownWeatherSystem(); void RB_SurfaceWeather( srfWeather_t *surfaceType ); From d10a0cd06a3cf2f5dd7e2febf23a2e5fbf8b5234 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 00:14:38 +0100 Subject: [PATCH 608/708] Fix fog on some surfaces with alpha tests --- codemp/rd-rend2/glsl/fogpass.glsl | 23 +++++++++++++++++------ codemp/rd-rend2/tr_glsl.cpp | 6 ++++++ codemp/rd-rend2/tr_shade.cpp | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index 241179bd60..bda61c4bf0 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -44,6 +44,9 @@ layout(std140) uniform Bones #endif out vec3 var_WSPosition; +#if defined(USE_ALPHA_TEST) +out vec2 var_TexCoords; +#endif #if defined(USE_DEFORM_VERTEXES) float GetNoiseValue( float x, float y, float z, float t ) @@ -217,11 +220,15 @@ void main() gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; +#if defined(USE_ALPHA_TEST) + var_TexCoords = attr_TexCoord0; +#endif } /*[Fragment]*/ #if defined(USE_ALPHA_TEST) uniform int u_AlphaTestType; +uniform sampler2D u_DiffuseMap; #endif layout(std140) uniform Scene @@ -274,6 +281,9 @@ layout(std140) uniform Entity uniform int u_FogIndex; in vec3 var_WSPosition; +#if defined(USE_ALPHA_TEST) +in vec2 var_TexCoords; +#endif out vec4 out_Color; out vec4 out_Glow; @@ -323,30 +333,31 @@ vec4 CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) void main() { - Fog fog = u_Fogs[u_FogIndex]; - out_Color = CalcFog(u_ViewOrigin, var_WSPosition, fog); #if defined(USE_ALPHA_TEST) + float alpha = texture(u_DiffuseMap, var_TexCoords).a; if (u_AlphaTestType == ALPHA_TEST_GT0) { - if (out_Color.a == 0.0) + if (alpha == 0.0) discard; } else if (u_AlphaTestType == ALPHA_TEST_LT128) { - if (out_Color.a >= 0.5) + if (alpha >= 0.5) discard; } else if (u_AlphaTestType == ALPHA_TEST_GE128) { - if (out_Color.a < 0.5) + if (alpha < 0.5) discard; } else if (u_AlphaTestType == ALPHA_TEST_GE192) { - if (out_Color.a < 0.75) + if (alpha < 0.75) discard; } #endif + Fog fog = u_Fogs[u_FogIndex]; + out_Color = CalcFog(u_ViewOrigin, var_WSPosition, fog); #if defined(USE_GLOW_BUFFER) out_Glow = out_Color; diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ce5948f1c9..9474f84259 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1532,6 +1532,12 @@ static int GLSL_LoadGPUProgramFogPass( } GLSL_InitUniforms(&tr.fogShader[i]); + + qglUseProgram(tr.fogShader[i].program); + if (i & FOGDEF_USE_ALPHA_TEST) + GLSL_SetUniformInt(&tr.fogShader[i], UNIFORM_DIFFUSEMAP, 0); + qglUseProgram(0); + GLSL_FinishGPUShader(&tr.fogShader[i]); ++numPrograms; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 326e459cf4..4ce6af55fb 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -977,6 +977,9 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v input->fogNum != tr.world->globalFogIndex && input->shader->sort != SS_FOG) shaderBits |= FOGDEF_USE_FALLBACK_GLOBAL_FOG; + + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + shaderBits |= FOGDEF_USE_ALPHA_TEST; shaderProgram_t *sp = tr.fogShader + shaderBits; @@ -985,6 +988,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v UniformDataWriter uniformDataWriter; uniformDataWriter.Start(sp); uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); + uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) @@ -1003,6 +1007,10 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v GetBonesBlockUniformBinding(backEnd.currentEntity) }; + SamplerBindingsWriter samplerBindingsWriter; + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); + Allocator& frameAllocator = *backEndData->perFrameMemory; DrawItem item = {}; item.renderState.stateBits = stateBits; @@ -1011,6 +1019,8 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v item.program = sp; item.uniformData = uniformDataWriter.Finish(frameAllocator); item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; + item.samplerBindings = samplerBindingsWriter.Finish( + frameAllocator, &item.numSamplerBindings); DrawItemSetVertexAttributes( item, attribs, vertexArrays->numVertexArrays, frameAllocator); @@ -1040,11 +1050,17 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v UniformDataWriter uniformDataWriterBack; uniformDataWriterBack.Start(sp); uniformDataWriterBack.SetUniformInt(UNIFORM_FOGINDEX, tr.world->globalFogIndex - 1); + uniformDataWriterBack.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); + SamplerBindingsWriter samplerBindingsWriter; + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); DrawItem backItem = {}; memcpy(&backItem, &item, sizeof(item)); backItem.renderState.cullType = cullType; backItem.uniformData = uniformDataWriterBack.Finish(frameAllocator); + backItem.samplerBindings = samplerBindingsWriter.Finish( + frameAllocator, &item.numSamplerBindings); DrawItemSetVertexAttributes( backItem, attribs, vertexArrays->numVertexArrays, frameAllocator); From 0f61ff2d133e91e2ed6e9995b553580a5840820e Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 00:15:18 +0100 Subject: [PATCH 609/708] Properly disable weatherzone code --- codemp/rd-rend2/tr_weather.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index b4f86620df..ac9d7a11cb 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -242,7 +242,7 @@ namespace tr.viewParms.world.modelViewMatrix, tr.weatherSystem->weatherMVP); -#ifdef 0 +#if 0 if (tr.weatherSystem->numWeatherZones > 0) { FBO_Bind(tr.weatherDepthFbo); From c2e8fbd60546f49880d44ebbdce6480c8c7d9abb Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 00:16:23 +0100 Subject: [PATCH 610/708] Correct hdr fbo format --- codemp/rd-rend2/tr_fbo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index d507852bca..ccef288cc5 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -398,7 +398,7 @@ void FBO_Init(void) hdrFormat = GL_RGBA8; if (r_hdr->integer) { - hdrFormat = GL_RGB16F; + hdrFormat = GL_RGBA16F; } qglGetIntegerv(GL_MAX_SAMPLES, &multisample); From 0a42fb8ad6b6a2e2370aa5b9108fdc5d8491eab0 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 02:23:35 +0100 Subject: [PATCH 611/708] Fix dlighting on brush models --- codemp/rd-rend2/tr_world.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 005e77fe5d..4cfdf81840 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -341,10 +341,12 @@ static void R_AddWorldSurface( } // check for dlighting - // TODO: check for beeing correctly implemented because problems eg. with elevators ffa3 + // TODO: implement dlight culling for non worldspawn surfaces if ( dlightBits ) { - dlightBits = R_DlightSurface( surf, dlightBits ); - dlightBits = ( dlightBits != 0 ); + if (entityNum != REFENTITYNUM_WORLD) + dlightBits = (1 << tr.refdef.num_dlights) - 1; + else + dlightBits = R_DlightSurface( surf, dlightBits ); } // set pshadows From 2ef14a7d762959b59e2652d4a3daebea0a0b7031 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 02:27:31 +0100 Subject: [PATCH 612/708] Get rid of pshadow sampling UB in pshadow shader. Setting a sampler comparison requires shadow sampler type, or else it's undefined behavior. --- codemp/rd-rend2/glsl/pshadow.glsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/glsl/pshadow.glsl b/codemp/rd-rend2/glsl/pshadow.glsl index 17a0ccc2e4..371ce92eed 100644 --- a/codemp/rd-rend2/glsl/pshadow.glsl +++ b/codemp/rd-rend2/glsl/pshadow.glsl @@ -17,7 +17,7 @@ void main() } /*[Fragment]*/ -uniform sampler2DArray u_ShadowMap; +uniform sampler2DArrayShadow u_ShadowMap; uniform vec3 u_LightForward; uniform vec3 u_LightUp; uniform vec3 u_LightRight; @@ -84,10 +84,10 @@ void main() offsetScale = max(TEXTURE_SCALE, offsetScale); for (int i = 0; i < PCF_SAMPLES; ++i) { - part += float(texture(u_ShadowMap, vec3(st + offsetScale * poissonDisc[i], u_LightOrigin.w)).r != 1.0); + part += 1.0 - float(texture(u_ShadowMap, vec4(st + offsetScale * poissonDisc[i], u_LightOrigin.w, 1.0))); } #else - part = float(texture(u_ShadowMap, vec3(st, u_LightOrigin.w)).r != 1.0); + part = 1.0 - float(texture(u_ShadowMap, vec4(st, u_LightOrigin.w, 1.0))); #endif if (part <= 0.0) From 2eb4012d1669640b5b7082272970a357607b7ceb Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 02:30:12 +0100 Subject: [PATCH 613/708] Fix a crash regarding alpha tests on fog stages --- codemp/rd-rend2/tr_shade.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 4ce6af55fb..ad5d19bf13 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -978,8 +978,9 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v input->shader->sort != SS_FOG) shaderBits |= FOGDEF_USE_FALLBACK_GLOBAL_FOG; - if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) - shaderBits |= FOGDEF_USE_ALPHA_TEST; + if (input->numPasses > 0) + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + shaderBits |= FOGDEF_USE_ALPHA_TEST; shaderProgram_t *sp = tr.fogShader + shaderBits; @@ -988,7 +989,8 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v UniformDataWriter uniformDataWriter; uniformDataWriter.Start(sp); uniformDataWriter.SetUniformInt(UNIFORM_FOGINDEX, input->fogNum - 1); - uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); + if (input->numPasses > 0) + uniformDataWriter.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); uint32_t stateBits = GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA; if ( tess.shader->fogPass == FP_EQUAL ) @@ -1008,8 +1010,9 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v }; SamplerBindingsWriter samplerBindingsWriter; - if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) - samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); + if (input->numPasses > 0) + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); Allocator& frameAllocator = *backEndData->perFrameMemory; DrawItem item = {}; @@ -1050,7 +1053,8 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v UniformDataWriter uniformDataWriterBack; uniformDataWriterBack.Start(sp); uniformDataWriterBack.SetUniformInt(UNIFORM_FOGINDEX, tr.world->globalFogIndex - 1); - uniformDataWriterBack.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); + if (input->numPasses > 0) + uniformDataWriterBack.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); SamplerBindingsWriter samplerBindingsWriter; if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); From 3137cbf57bede78ce731776a4f9b0a41afb4bb25 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 03:27:38 +0100 Subject: [PATCH 614/708] Some cleanup --- codemp/rd-rend2/tr_glsl.cpp | 2 +- codemp/rd-rend2/tr_image.cpp | 31 +++++++++++++++---------------- codemp/rd-rend2/tr_light.cpp | 22 ++-------------------- 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 9474f84259..774da59d57 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1594,7 +1594,7 @@ static int GLSL_LoadGPUProgramRefraction( if (!GLSL_LoadGPUShader(builder, &tr.refractionShader[i], "refraction", attribs, NO_XFB_VARS, extradefines, *programDesc)) { - ri.Error(ERR_FATAL, "Could not load generic shader!"); + ri.Error(ERR_FATAL, "Could not load refraction shader!"); } GLSL_InitUniforms(&tr.refractionShader[i]); diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index b7a5f05d96..d59ad77d48 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2483,9 +2483,9 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height, imgT /* ================ -R_CreateImage +R_Create2DImageArray -This is the only way any image_t are created +This is the only way any 2d array sampler image_t are created ================ */ image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height, int layers, imgType_t type, int flags, int internalFormat) @@ -2532,8 +2532,10 @@ image_t *R_Create2DImageArray(const char *name, byte *pic, int width, int height GL_SelectTexture(0); GL_Bind(image); - //qglTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers); - qglTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, format, GL_UNSIGNED_BYTE, NULL); + if (ShouldUseImmutableTextures(image->flags, internalFormat)) + qglTexStorage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers); + else + qglTexImage3D(GL_TEXTURE_2D_ARRAY, 0, internalFormat, width, height, layers, 0, format, GL_UNSIGNED_BYTE, NULL); switch (internalFormat) { @@ -2929,14 +2931,6 @@ static void R_CreateNormalMap ( const char *name, byte *pic, int width, int heig } } -void ColorToRGBA16F2(const vec3_t color, unsigned short rgba16f[4]) -{ - rgba16f[0] = FloatToHalf(color[0]); - rgba16f[1] = FloatToHalf(color[1]); - rgba16f[2] = FloatToHalf(color[2]); - rgba16f[3] = FloatToHalf(1.0f); -} - /* =============== R_FindImageFile @@ -2989,7 +2983,12 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) color[2] = color[2] / M_PI; } color[3] = 1.0f; - ColorToRGBA16F2(color, (uint16_t *)(&pic[i * 8])); + + uint16_t *hdr_color = (uint16_t *)(&pic[i * 8]); + hdr_color[0] = FloatToHalf(color[0]); + hdr_color[1] = FloatToHalf(color[1]); + hdr_color[2] = FloatToHalf(color[2]); + hdr_color[3] = FloatToHalf(1.0f); } internalFormat = GL_RGBA16F; loadFlags = flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_MIPMAP); @@ -3344,7 +3343,7 @@ void R_CreateBuiltinImages( void ) { DSHADOW_MAP_SIZE, MAX_DLIGHTS*6, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP | IMGFLAG_MUTABLE, GL_DEPTH_COMPONENT16); } @@ -3484,7 +3483,7 @@ void R_CreateBuiltinImages( void ) { PSHADOW_MAP_SIZE, MAX_DRAWN_PSHADOWS, IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP | IMGFLAG_MUTABLE, GL_DEPTH_COMPONENT16); } @@ -3497,7 +3496,7 @@ void R_CreateBuiltinImages( void ) { r_shadowMapSize->integer, 3, // number of cascades IMGTYPE_COLORALPHA, - IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP, + IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE | IMGLFAG_SHADOWCOMP | IMGFLAG_MUTABLE, GL_DEPTH_COMPONENT16); tr.screenShadowImage = R_CreateImage( diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 7ce0de9d26..0595d26b93 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -136,7 +136,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { int gridStep[3]; vec3_t direction; float totalFactor; - int startGridPos; + uint32_t startGridPos; if ( ent->e.renderfx & RF_LIGHTING_ORIGIN ) { // seperate lightOrigins are needed so an object that is @@ -177,7 +177,7 @@ static void R_SetupEntityLightingGrid( trRefEntity_t *ent, world_t *world ) { for ( i = 0 ; i < 8 ; i++ ) { float factor; mgrid_t *data; - int gridPos; + uint32_t gridPos; int lat, lng; vec3_t normal; @@ -390,27 +390,9 @@ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { } } - // - // modify the light by dynamic lights - // d = VectorLength( ent->directedLight ); VectorScale( ent->lightDir, d, lightDir ); - /*for ( i = 0 ; i < refdef->num_dlights ; i++ ) { - dl = &refdef->dlights[i]; - VectorSubtract( dl->origin, lightOrigin, dir ); - d = VectorNormalize( dir ); - - power = DLIGHT_AT_RADIUS * ( dl->radius * dl->radius ); - if ( d < DLIGHT_MINIMUM_RADIUS ) { - d = DLIGHT_MINIMUM_RADIUS; - } - d = power / ( d * d ); - - VectorMA( ent->directedLight, d, dl->color, ent->directedLight ); - VectorMA( lightDir, d, dir, lightDir ); - }*/ - // clamp ambient if (tr.hdrLighting != qtrue) { From 39529a5217bfe81ccda4d94391e426ecafeea7be Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 03:40:22 +0100 Subject: [PATCH 615/708] Auto exposure based on frame time Decouples framerate from auto exposure speed. --- codemp/rd-rend2/tr_postprocess.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index e383727258..a39b4a221b 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -69,8 +69,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in color[0] = color[1] = color[2] = 1.0f; - // FIX ME: blend based on time instead of fixed amount - color[3] = 0.03f; + color[3] = 0.001f * backEnd.refdef.frameTime; FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } From e5c6ea6e4f818a82ddd4fa8b75a4885cd20a7061 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 10:53:04 +0100 Subject: [PATCH 616/708] Fix compiling vanilla renderers with disabled gore --- codemp/ghoul2/G2_gore.cpp | 4 ++++ codemp/rd-dedicated/G2_API.cpp | 10 +++++----- codemp/rd-dedicated/G2_misc.cpp | 11 +++++++---- codemp/rd-vanilla/G2_API.cpp | 10 +++++----- codemp/rd-vanilla/G2_misc.cpp | 11 +++++++---- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/codemp/ghoul2/G2_gore.cpp b/codemp/ghoul2/G2_gore.cpp index f821093e91..ecc90dba8d 100644 --- a/codemp/ghoul2/G2_gore.cpp +++ b/codemp/ghoul2/G2_gore.cpp @@ -23,6 +23,8 @@ along with this program; if not, see . #include "G2_gore.h" #include "../rd-common/tr_common.h" +#ifdef _G2_GORE + GoreTextureCoordinates::GoreTextureCoordinates() { Com_Memset (tex, 0, sizeof (tex)); @@ -39,3 +41,5 @@ GoreTextureCoordinates::~GoreTextureCoordinates() } } } + +#endif \ No newline at end of file diff --git a/codemp/rd-dedicated/G2_API.cpp b/codemp/rd-dedicated/G2_API.cpp index c95a0edc69..2555cf05f3 100644 --- a/codemp/rd-dedicated/G2_API.cpp +++ b/codemp/rd-dedicated/G2_API.cpp @@ -2485,6 +2485,11 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) return qtrue; } +int G2API_Ghoul2Size(CGhoul2Info_v &ghoul2) +{ + return ghoul2.size(); +} + //#ifdef _SOF2 #ifdef _G2_GORE void ResetGoreTag(); // put here to reduce coupling @@ -2521,11 +2526,6 @@ void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 ) } } -int G2API_Ghoul2Size ( CGhoul2Info_v &ghoul2 ) -{ - return ghoul2.size(); -} - extern int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod); void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore) { diff --git a/codemp/rd-dedicated/G2_misc.cpp b/codemp/rd-dedicated/G2_misc.cpp index 1bcec8e457..96a58fae32 100644 --- a/codemp/rd-dedicated/G2_misc.cpp +++ b/codemp/rd-dedicated/G2_misc.cpp @@ -26,11 +26,10 @@ along with this program; if not, see . #include "server/server.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" #ifdef _G2_GORE #include "ghoul2/G2_gore.h" -#include "tr_local.h" - #define GORE_TAG_UPPER (256) #define GORE_TAG_MASK (~255) @@ -549,6 +548,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, vec3_t correctScale; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" ); @@ -559,7 +559,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, { firstModelOnly = qtrue; } - +#endif VectorCopy(scale, correctScale); // check for scales of 0 - that's the default I believe @@ -1497,6 +1497,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli shader_t *cust_shader; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" ); @@ -1507,6 +1508,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli { firstModelOnly = qtrue; } +#endif // walk each possible model for this entity and try tracing against it for (i=0; i. #include "server/server.h" #include "ghoul2/g2_local.h" +#include "tr_local.h" #ifdef _G2_GORE #include "ghoul2/G2_gore.h" -#include "tr_local.h" - #define GORE_TAG_UPPER (256) #define GORE_TAG_MASK (~255) @@ -549,6 +548,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, vec3_t correctScale; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" ); @@ -559,7 +559,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, { firstModelOnly = qtrue; } - +#endif VectorCopy(scale, correctScale); // check for scales of 0 - that's the default I believe @@ -1498,6 +1498,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli shader_t *cust_shader; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "" ); @@ -1508,6 +1509,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli { firstModelOnly = qtrue; } +#endif // walk each possible model for this entity and try tracing against it for (i=0; i Date: Thu, 2 Mar 2023 11:03:51 +0100 Subject: [PATCH 617/708] Work on rend2 ghoul2 marks Some cleanup and increasing vbo size to make sure theres no collisions (rendering vs. updating) when updating the vbo. --- codemp/rd-rend2/G2_API.cpp | 10 +++++----- codemp/rd-rend2/G2_gore_r2.cpp | 4 ++++ codemp/rd-rend2/G2_misc.cpp | 8 ++++++-- codemp/rd-rend2/tr_ghoul2.cpp | 2 ++ codemp/rd-rend2/tr_init.cpp | 4 ++-- codemp/rd-rend2/tr_local.h | 6 ++++-- codemp/rd-rend2/tr_vbo.cpp | 14 +++++++------- 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/codemp/rd-rend2/G2_API.cpp b/codemp/rd-rend2/G2_API.cpp index a47a36301b..aa152699c8 100644 --- a/codemp/rd-rend2/G2_API.cpp +++ b/codemp/rd-rend2/G2_API.cpp @@ -2890,6 +2890,11 @@ qboolean G2API_SkinlessModel(CGhoul2Info_v& ghoul2, int modelIndex) return qtrue; } +int G2API_Ghoul2Size(CGhoul2Info_v &ghoul2) +{ + return ghoul2.size(); +} + //#ifdef _SOF2 #ifdef _G2_GORE void ResetGoreTag(); // put here to reduce coupling @@ -2926,11 +2931,6 @@ void G2API_ClearSkinGore ( CGhoul2Info_v &ghoul2 ) } } -int G2API_Ghoul2Size ( CGhoul2Info_v &ghoul2 ) -{ - return ghoul2.size(); -} - extern int G2_DecideTraceLod(CGhoul2Info &ghoul2, int useLod); void G2API_AddSkinGore(CGhoul2Info_v &ghoul2,SSkinGoreData &gore) { diff --git a/codemp/rd-rend2/G2_gore_r2.cpp b/codemp/rd-rend2/G2_gore_r2.cpp index 260097c9eb..f28d367bfa 100644 --- a/codemp/rd-rend2/G2_gore_r2.cpp +++ b/codemp/rd-rend2/G2_gore_r2.cpp @@ -23,6 +23,8 @@ along with this program; if not, see . #include "G2_gore_r2.h" #include "../rd-common/tr_common.h" +#ifdef _G2_GORE + R2GoreTextureCoordinates::R2GoreTextureCoordinates() { Com_Memset (tex, 0, sizeof (tex)); @@ -43,3 +45,5 @@ R2GoreTextureCoordinates::~R2GoreTextureCoordinates() } } } + +#endif diff --git a/codemp/rd-rend2/G2_misc.cpp b/codemp/rd-rend2/G2_misc.cpp index 0d007e35af..ac64001c4e 100644 --- a/codemp/rd-rend2/G2_misc.cpp +++ b/codemp/rd-rend2/G2_misc.cpp @@ -539,6 +539,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, vec3_t correctScale; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); @@ -549,7 +550,7 @@ void G2_TransformModel(CGhoul2Info_v &ghoul2, const int frameNum, vec3_t scale, { firstModelOnly = qtrue; } - +#endif VectorCopy(scale, correctScale); // check for scales of 0 - that's the default I believe @@ -1478,6 +1479,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli shader_t *cust_shader; qboolean firstModelOnly = qfalse; +#ifdef _G2_GORE if ( cg_g2MarksAllModels == NULL ) { cg_g2MarksAllModels = ri.Cvar_Get( "cg_g2MarksAllModels", "0", 0, "Render marks on all G2 models" ); @@ -1488,6 +1490,7 @@ void G2_TraceModels(CGhoul2Info_v &ghoul2, vec3_t rayStart, vec3_t rayEnd, Colli { firstModelOnly = qtrue; } +#endif // walk each possible model for this entity and try tracing against it for (i=0; ialternateTex) { R_BindVBO(tr.goreVBO); @@ -3553,6 +3554,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) #endif return; } +#endif R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 11745315af..32ac4abbde 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1725,7 +1725,7 @@ static void R_InitGoreVao() { tr.goreVBO = R_CreateVBO( nullptr, - sizeof(g2GoreVert_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS, + sizeof(g2GoreVert_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS * MAX_FRAMES, VBO_USAGE_DYNAMIC); tr.goreVBO->offsets[ATTR_INDEX_POSITION] = offsetof(g2GoreVert_t, position); tr.goreVBO->offsets[ATTR_INDEX_NORMAL] = offsetof(g2GoreVert_t, normal); @@ -1750,7 +1750,7 @@ static void R_InitGoreVao() tr.goreIBO = R_CreateIBO( nullptr, - sizeof(glIndex_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES, + sizeof(glIndex_t) * MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES * MAX_FRAMES, VBO_USAGE_DYNAMIC); tr.goreIBOCurrentIndex = 0; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 51202445b5..fd681a1f43 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3325,8 +3325,10 @@ class CRenderableSurface ident = src.ident; boneCache = src.boneCache; surfaceData = src.surfaceData; +#ifdef _G2_GORE alternateTex = src.alternateTex; goreChain = src.goreChain; +#endif vboMesh = src.vboMesh; return *this; @@ -3347,18 +3349,18 @@ class CRenderableSurface { } -#ifdef _G2_GORE void Init() { ident = SF_MDX; boneCache = nullptr; surfaceData = nullptr; +#ifdef _G2_GORE alternateTex = nullptr; goreChain = nullptr; +#endif vboMesh = nullptr; genShadows = qfalse; } -#endif }; void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 1cf67e76ab..333b4bd8f1 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -22,6 +22,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // tr_vbo.c #include "tr_local.h" +#ifdef _G2_GORE +#include "G2_gore_r2.h" +#endif uint32_t R_VboPackTangent(vec4_t v) @@ -645,17 +648,13 @@ void RB_UpdateVBOs(unsigned int attribBits) } } -#define MAX_GORE_VERTS (3000) -#define MAX_GORE_INDECIES (6000) -//TODO: This needs to be set via a scalability cvar with some reasonable minimum value if pgore is used at all -#define MAX_GORE_RECORDS (500) - +#ifdef _G2_GORE void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface) { goreSurface->firstVert = tr.goreVBOCurrentIndex; goreSurface->firstIndex = tr.goreIBOCurrentIndex; - if (tr.goreVBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS)) + if (tr.goreVBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_VERTS * MAX_FRAMES)) tr.goreVBOCurrentIndex = 0; R_BindVBO(tr.goreVBO); @@ -667,7 +666,7 @@ void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface) ); tr.goreVBOCurrentIndex += goreSurface->numVerts; - if (tr.goreIBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES)) + if (tr.goreIBOCurrentIndex + goreSurface->numVerts >= (MAX_LODS * MAX_GORE_RECORDS * MAX_GORE_INDECIES * MAX_FRAMES)) tr.goreIBOCurrentIndex = 0; R_BindIBO(tr.goreIBO); @@ -679,6 +678,7 @@ void RB_UpdateGoreVBO(srfG2GoreSurface_t *goreSurface) ); tr.goreIBOCurrentIndex += goreSurface->numIndexes; } +#endif void RB_CommitInternalBufferData() { From 75e9df7710bb7d8bee36b010690a9f40675ab2e8 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 2 Mar 2023 12:07:08 +0100 Subject: [PATCH 618/708] Add flattened surface sprites type --- codemp/rd-rend2/glsl/surface_sprites.glsl | 6 +++--- codemp/rd-rend2/tr_glsl.cpp | 3 +++ codemp/rd-rend2/tr_local.h | 3 ++- codemp/rd-rend2/tr_surface.cpp | 3 +++ 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 4bc33cd26f..edca0e475d 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -97,13 +97,13 @@ void main() #if defined(FACE_CAMERA) vec2 toCamera = normalize(V.xy); offset.xy = offset.x*vec2(toCamera.y, -toCamera.x); +#elif defined(FACE_FLATTENED) + // Make this sprite face in some direction + offset.xy = offset.x * attr_Normal.xy; #elif !defined(FACE_UP) // Make this sprite face in some direction in direction of the camera vec2 toCamera = normalize(V.xy); offset.xy = offset.x * (attr_Normal.xy + 3.0 * vec2(toCamera.y, -toCamera.x)) * 0.25; -#else - // Make this sprite face in some direction - // offset.xy = offset.x * attr_Normal.xy; #endif #if !defined(FACE_UP) && !defined(FX_SPRITE) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 774da59d57..0b19d34451 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2257,6 +2257,9 @@ static int GLSL_LoadGPUProgramSurfaceSprites( else if ( i & SSDEF_FACE_UP ) Q_strcat(extradefines, sizeof(extradefines), "#define FACE_UP\n"); + else if (i & SSDEF_FLATTENED) + Q_strcat(extradefines, sizeof(extradefines), + "#define FACE_FLATTENED\n"); if (i & SSDEF_FX_SPRITE) Q_strcat(extradefines, sizeof(extradefines), diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index fd681a1f43..bd283dec97 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1225,8 +1225,9 @@ enum SSDEF_USE_FOG = 0x10, SSDEF_FOG_MODULATE = 0x20, SSDEF_ADDITIVE = 0x40, + SSDEF_FLATTENED = 0x80, - SSDEF_ALL = 0x7F, + SSDEF_ALL = 0xFF, SSDEF_COUNT = SSDEF_ALL + 1 }; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 03a4ccdc3e..b8a9a38bba 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2164,6 +2164,9 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) if (ss->facing == SURFSPRITE_FACING_UP) shaderFlags |= SSDEF_FACE_UP; + if (ss->facing == SURFSPRITE_FACING_NORMAL) + shaderFlags |= SSDEF_FLATTENED; + if (ss->type == SURFSPRITE_EFFECT || ss->type == SURFSPRITE_WEATHERFX) shaderFlags |= SSDEF_FX_SPRITE; From 96d9b3c9172184251ff7a765ee892caab7a73bee Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 11 Mar 2023 02:45:27 +0100 Subject: [PATCH 619/708] Pack surface sprites into chunks of 65535 vertices instead of creating one vbo and one ibo per surface sprite stage per every surface. --- codemp/rd-rend2/glsl/surface_sprites.glsl | 13 ++ codemp/rd-rend2/tr_backend.cpp | 5 +- codemp/rd-rend2/tr_bsp.cpp | 145 +++++++++++++++++----- codemp/rd-rend2/tr_local.h | 2 + codemp/rd-rend2/tr_shade.cpp | 2 + codemp/rd-rend2/tr_surface.cpp | 1 + codemp/rd-rend2/tr_vbo.cpp | 2 +- 7 files changed, 137 insertions(+), 33 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index edca0e475d..69db79b25c 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -219,7 +219,20 @@ float CalcFog(in vec3 viewOrigin, in vec3 position, in Fog fog) void main() { +#if defined(ALPHA_TEST) + float alphaTestValue = 0.5; + if (u_AlphaTestType == ALPHA_TEST_GT0) + { + alphaTestValue = 0.0; + } + else if (u_AlphaTestType == ALPHA_TEST_GE192) + { + alphaTestValue = 0.75; + } +#else const float alphaTestValue = 0.5; +#endif + out_Color = texture(u_DiffuseMap, var_TexCoords); out_Color.rgb *= var_Color; out_Color.a *= var_Alpha*(1.0 - alphaTestValue) + alphaTestValue; diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index cea92c6a59..1c34ca4089 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1106,7 +1106,8 @@ static void RB_DrawItems( drawItem.draw.params.indexed.numIndices, drawItem.draw.params.indexed.indexType, drawItem.draw.params.indexed.firstIndex, - drawItem.draw.numInstances, 0); + drawItem.draw.numInstances, + drawItem.draw.params.indexed.baseVertex); break; } @@ -2767,7 +2768,7 @@ static void Fill_SpriteBlock( srfSprites_t *surf , SurfaceSpriteBlock *surfaceSp surfaceSpriteBlock->fxGrow[1] = ss->fxGrow[1]; surfaceSpriteBlock->fxDuration = ss->fxDuration; surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; - surfaceSpriteBlock->fadeEndDistance = ss->fadeMax; + surfaceSpriteBlock->fadeEndDistance = MAX(ss->fadeDist + 250.f, ss->fadeMax); surfaceSpriteBlock->fadeScale = ss->fadeScale; surfaceSpriteBlock->wind = ss->wind; surfaceSpriteBlock->windIdle = ss->windIdle; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 68675428b7..25201f03ce 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3640,10 +3640,54 @@ static uint32_t UpdateHash( const char *text, uint32_t hash ) return (hash ^ (hash >> 10) ^ (hash >> 20)); } -static std::vector R_CreateSurfaceSpritesVertexData( +static uint32_t R_CountSurfaceSprites( const srfBspSurface_t *bspSurf, float density, const shaderStage_t *stage) +{ + uint32_t numStageSprites = 0; + + const srfVert_t *verts = bspSurf->verts; + const glIndex_t *indexes = bspSurf->indexes; + + for (int i = 0, numIndexes = bspSurf->numIndexes; i < numIndexes; i += 3) + { + const srfVert_t *v0 = verts + indexes[i + 0]; + const srfVert_t *v1 = verts + indexes[i + 1]; + const srfVert_t *v2 = verts + indexes[i + 2]; + + vec3_t p0, p1, p2; + VectorCopy(v0->xyz, p0); + VectorCopy(v1->xyz, p1); + VectorCopy(v2->xyz, p2); + + const vec2_t p01 = { p1[0] - p0[0], p1[1] - p0[1] }; + const vec2_t p02 = { p2[0] - p0[0], p2[1] - p0[1] }; + + const float zarea = std::fabs(p02[0] * p01[1] - p02[1] * p01[0]); + if (zarea <= 1.0) + { + // Triangle's area is too small to consider. + continue; + } + + const float step = density * Q_rsqrt(zarea); + for (float a = 0.0f; a < 1.0f; a += step) + { + for (float b = 0.0f, bend = (1.0f - a); b < bend; b += step) + { + numStageSprites += 1; + } + } + } + return numStageSprites; +} + +static int R_CreateSurfaceSpritesVertexData( + const srfBspSurface_t *bspSurf, + float density, + const shaderStage_t *stage, + std::vector *sprites) { const srfVert_t *verts = bspSurf->verts; const glIndex_t *indexes = bspSurf->indexes; @@ -3661,8 +3705,7 @@ static std::vector R_CreateSurfaceSpritesVertexData( stage->rgbGen == CGEN_VERTEX_LIT || stage->rgbGen == CGEN_EXACT_VERTEX_LIT); - std::vector sprites; - sprites.reserve(10000); + int numSprites = 0; for ( int i = 0, numIndexes = bspSurf->numIndexes; i < numIndexes; i += 3 ) { const srfVert_t *v0 = verts + indexes[i + 0]; @@ -3746,15 +3789,15 @@ static std::vector R_CreateSurfaceSpritesVertexData( sprite.skew[0] = stage->ss->height * stage->ss->vertSkew * flrand(-1.0f, 1.0f); sprite.skew[1] = stage->ss->height * stage->ss->vertSkew * flrand(-1.0f, 1.0f); - // We have 4 copies for each corner of the quad - sprites.push_back(sprite); - sprites.push_back(sprite); - sprites.push_back(sprite); - sprites.push_back(sprite); + sprites->push_back(sprite); + sprites->push_back(sprite); + sprites->push_back(sprite); + sprites->push_back(sprite); + ++numSprites; } } } - return sprites; + return numSprites; } static void R_GenerateSurfaceSprites( @@ -3762,7 +3805,8 @@ static void R_GenerateSurfaceSprites( const shader_t *shader, const shaderStage_t *stage, const int fogIndex, - srfSprites_t *out) + srfSprites_t *out, + std::vector *sprites) { const surfaceSprite_t *surfaceSprite = stage->ss; const textureBundle_t *bundle = &stage->bundle[0]; @@ -3771,29 +3815,16 @@ static void R_GenerateSurfaceSprites( for ( int i = 0; bundle->image[i]; ++i ) hash = UpdateHash(bundle->image[i]->imgName, hash); - std::vector sprites = - R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density, stage); - - int numSprites = sprites.size() / 4; - int numIndices = numSprites * 6; - uint16_t *indices = (uint16_t*)Z_Malloc(numIndices * sizeof(uint16_t), TAG_BSP); - for (int i = 0; i < numIndices; i++) - { - const uint16_t face_indices[] = { 0, 1, 2, 0, 2, 3 }; - int vert_index = face_indices[i % 6] + int(i / 6)*4; - indices[i] = vert_index; - } - + out->baseVertex = sprites->size(); out->surfaceType = SF_SPRITES; out->sprite = surfaceSprite; - out->numSprites = numSprites; - out->numIndices = numIndices; + //R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density, stage, sprites); + out->numSprites = R_CreateSurfaceSpritesVertexData(bspSurf, surfaceSprite->density, stage, sprites); + out->numIndices = out->numSprites * 6; out->fogIndex = fogIndex; - // FIXME: Use big preallocated vbo/ibo to store all sprites in one vao - out->vbo = R_CreateVBO((byte *)sprites.data(), - sizeof(sprite_t) * sprites.size(), VBO_USAGE_STATIC); - out->ibo = R_CreateIBO((byte *)indices, numIndices * sizeof(uint16_t), VBO_USAGE_STATIC); + out->vbo = NULL; + out->ibo = NULL; // FIXME: Need a better way to handle this. out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), @@ -3850,6 +3881,25 @@ static void R_GenerateSurfaceSprites( static void R_GenerateSurfaceSprites( const world_t *world ) { msurface_t *surfaces = world->surfaces; + std::vector sprites_data; + sprites_data.reserve(65535); + IBO_t *ibo; + + { + std::vector sprites_index_data; + sprites_index_data.reserve(65535 * 6); + for (int i = 0; i < 65535 * 6; i++) + { + const uint16_t face_indices[] = { 0, 1, 2, 0, 2, 3 }; + int vert_index = face_indices[i % 6] + (int(i / 6) * 4); + sprites_index_data.push_back(vert_index); + } + ibo = R_CreateIBO((byte *)sprites_index_data.data(), sprites_index_data.size() * sizeof(uint16_t), VBO_USAGE_STATIC); + } + + std::vector currentBatch; + currentBatch.reserve(65535); // worst case, theres at least 65535 surfaces with exactly one sprite + for ( int i = 0, numSurfaces = world->numsurfaces; i < numSurfaces; ++i ) { msurface_t *surf = surfaces + i; @@ -3887,7 +3937,29 @@ static void R_GenerateSurfaceSprites( const world_t *world ) } srfSprites_t *sprite = surf->surfaceSprites + surfaceSpriteNum; - R_GenerateSurfaceSprites(bspSurf, shader, stage, surf->fogIndex, sprite); + int numCurrentSurfaceSprites = R_CountSurfaceSprites(bspSurf, stage->ss->density, stage); + if ((sprites_data.size() + numCurrentSurfaceSprites * 4) > 65535) + { + VBO_t *vbo = R_CreateVBO((byte *)sprites_data.data(), + sizeof(sprite_t) * sprites_data.size(), VBO_USAGE_STATIC); + + for (srfSprites_t *sp : currentBatch) + { + sp->vbo = vbo; + sp->ibo = ibo; + sp->attributes[0].vbo = vbo; + sp->attributes[1].vbo = vbo; + sp->attributes[2].vbo = vbo; + sp->attributes[3].vbo = vbo; + } + + sprites_data.clear(); + currentBatch.clear(); + } + + R_GenerateSurfaceSprites(bspSurf, shader, stage, surf->fogIndex, sprite, &sprites_data); + currentBatch.push_back(sprite); + ++surfaceSpriteNum; } break; @@ -3897,6 +3969,19 @@ static void R_GenerateSurfaceSprites( const world_t *world ) break; } } + + VBO_t *vbo = R_CreateVBO((byte *)sprites_data.data(), + sizeof(sprite_t) * sprites_data.size(), VBO_USAGE_STATIC); + + for (srfSprites_t *sp : currentBatch) + { + sp->vbo = vbo; + sp->ibo = ibo; + sp->attributes[0].vbo = vbo; + sp->attributes[1].vbo = vbo; + sp->attributes[2].vbo = vbo; + sp->attributes[3].vbo = vbo; + } } world_t *R_LoadBSP(const char *name, int *bspIndex) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bd283dec97..9e3ea68d37 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1622,6 +1622,7 @@ struct srfSprites_t shader_t *shader; const surfaceSprite_t *sprite; + int baseVertex; int numSprites; int numIndices; VBO_t *vbo; @@ -3742,6 +3743,7 @@ struct DrawCommand GLenum indexType; GLsizei numIndices; glIndex_t firstIndex; + glIndex_t baseVertex; } indexed; struct DrawArrays diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index ad5d19bf13..0e5c6048cd 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -656,6 +656,7 @@ void RB_FillDrawCommand( drawCmd.params.indexed.indexType = GL_INDEX_TYPE; drawCmd.params.indexed.firstIndex = (glIndex_t)(size_t)(input->multiDrawFirstIndex[0]); drawCmd.params.indexed.numIndices = input->multiDrawNumIndexes[0]; + drawCmd.params.indexed.baseVertex = 0; } else { @@ -684,6 +685,7 @@ void RB_FillDrawCommand( drawCmd.params.indexed.indexType = GL_INDEX_TYPE; drawCmd.params.indexed.firstIndex = offset; drawCmd.params.indexed.numIndices = input->numIndexes; + drawCmd.params.indexed.baseVertex = 0; } } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b8a9a38bba..5265438664 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2234,6 +2234,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT; item.draw.params.indexed.firstIndex = 0; item.draw.params.indexed.numIndices = surf->numIndices; + item.draw.params.indexed.baseVertex = surf->baseVertex; tess.externalIBO = surf->ibo; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 333b4bd8f1..898e56a22a 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -183,7 +183,7 @@ void R_BindVBO(VBO_t * vbo) if(!vbo) { //R_BindNullVBO(); - ri.Error(ERR_DROP, "R_BindNullVBO: NULL vbo"); + ri.Error(ERR_DROP, "R_BindVBO: NULL vbo"); return; } From 250509ce0d48ced1e8447a7dc3f878f3c86fae85 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sat, 11 Mar 2023 02:48:20 +0100 Subject: [PATCH 620/708] Fix incorrectly blurred ssao image Needed to flip the depth image that is used for testing ssao and for blurring afterwards. --- codemp/rd-rend2/glsl/ssao.glsl | 6 +++--- codemp/rd-rend2/tr_backend.cpp | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/glsl/ssao.glsl b/codemp/rd-rend2/glsl/ssao.glsl index 7c5bd26038..53aeb67630 100644 --- a/codemp/rd-rend2/glsl/ssao.glsl +++ b/codemp/rd-rend2/glsl/ssao.glsl @@ -4,9 +4,9 @@ out vec2 var_ScreenTex; void main() { const vec2 positions[] = vec2[3]( - vec2(-1.0f, -1.0f), - vec2(-1.0f, 3.0f), - vec2( 3.0f, -1.0f) + vec2(-1.0f, 1.0f), + vec2(-1.0f, -3.0f), + vec2( 3.0f, 1.0f) ); const vec2 texcoords[] = vec2[3]( diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 1c34ca4089..e2c9419b16 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2127,7 +2127,6 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_COLORMAP); GLSL_SetUniformVec4(&tr.ssaoShader, UNIFORM_VIEWINFO, viewInfo); - //RB_InstantQuad2(quadVerts, texCoords); RB_InstantTriangle(); FBO_Bind(tr.quarterFbo[1]); @@ -2141,7 +2140,6 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); GLSL_SetUniformVec4(&tr.depthBlurShader[0], UNIFORM_VIEWINFO, viewInfo); - //RB_InstantQuad2(quadVerts, texCoords); RB_InstantTriangle(); FBO_Bind(tr.screenSsaoFbo); @@ -2155,7 +2153,6 @@ static void RB_RenderSSAO() GL_BindToTMU(tr.hdrDepthImage, TB_LIGHTMAP); GLSL_SetUniformVec4(&tr.depthBlurShader[1], UNIFORM_VIEWINFO, viewInfo); - //RB_InstantQuad2(quadVerts, texCoords); RB_InstantTriangle(); } @@ -2195,9 +2192,11 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) { // need the depth in a texture we can do GL_LINEAR sampling on, so // copy it to an HDR image + vec4i_t srcBox; + VectorSet4(srcBox, 0, tr.renderDepthImage->height, tr.renderDepthImage->width, -tr.renderDepthImage->height); FBO_BlitFromTexture( tr.renderDepthImage, - nullptr, + srcBox, nullptr, tr.hdrDepthFbo, nullptr, From bc393d5780a75595db768a1caaa63302830b174f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 12 Mar 2023 23:39:07 +0100 Subject: [PATCH 621/708] Fix specularScale implementation Now, the keyword works again as intended. When using the metal roughness workflow, specularScale will be --- codemp/rd-rend2/glsl/lightall.glsl | 7 +++--- codemp/rd-rend2/tr_image.cpp | 34 +++++++++++++++--------------- codemp/rd-rend2/tr_shader.cpp | 31 ++++++++++++++++++++------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 06b8beb567..fcf937fa86 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -969,15 +969,16 @@ void main() float roughness = 0.99; #if defined(USE_SPECULARMAP) #if !defined(USE_SPECGLOSS) - vec4 ORMS = mix(vec4(1.0, 1.0, 0.0, 0.5), texture(u_SpecularMap, texCoords), u_EnableTextures.z); + vec4 ORMS = mix(vec4(1.0), texture(u_SpecularMap, texCoords), u_EnableTextures.z); + ORMS.xyzw *= u_SpecularScale.zwxy; - specular.rgb = mix(vec3(0.08) * u_SpecularScale.w, diffuse.rgb, ORMS.z) * ORMS.w; + specular.rgb = mix(vec3(0.08) * ORMS.w, diffuse.rgb, ORMS.z); diffuse.rgb *= vec3(1.0 - ORMS.z); roughness = mix(0.01, 1.0, ORMS.y); AO = min(ORMS.x, AO); #else - specular = texture(u_SpecularMap, texCoords); + specular = mix(vec4(1.0), texture(u_SpecularMap, texCoords), u_EnableTextures.z); specular.rgb *= u_SpecularScale.xyz; roughness = mix(1.0, 0.01, specular.a * (1.0 - u_SpecularScale.w)); #endif diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index d59ad77d48..98254f6881 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2707,19 +2707,6 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName return; } - COM_StripExtension(packedImageName, packedName, sizeof(packedName)); - Q_strcat(packedName, sizeof(packedName), "_ORMS"); - - // - // see if the image is already loaded - // - image = R_GetLoadedImage(packedName, flags); - if (image != NULL) - { - stage->bundle[TB_ORMSMAP].image[0] = image; - return; - } - R_LoadImage(packedImageName, &packedPic, &packedWidth, &packedHeight); if (packedPic == NULL) { return; @@ -2730,17 +2717,30 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName case SPEC_RMOS: case SPEC_MOSR: case SPEC_ORMS: - stage->specularScale[3] = 1.0f; // Don't scale base specular + stage->specularScale[1] = 1.0f; // Don't scale base specular break; default: - stage->specularScale[3] = 0.5f; // Basespecular is assumed to be 0.04 and shader assumes 0.08 + stage->specularScale[1] = 0.5f; // Basespecular is assumed to be 0.04 and shader assumes 0.08 break; } // Don't scale occlusion, roughness and metalness stage->specularScale[0] = - stage->specularScale[1] = - stage->specularScale[2] = 1.0f; + stage->specularScale[2] = + stage->specularScale[3] = 1.0f; + + COM_StripExtension(packedImageName, packedName, sizeof(packedName)); + Q_strcat(packedName, sizeof(packedName), "_ORMS"); + + // + // see if the image is already loaded + // + image = R_GetLoadedImage(packedName, flags); + if (image != NULL) + { + stage->bundle[TB_ORMSMAP].image[0] = image; + return; + } GLint swizzle[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 62cf29de06..47979453cb 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -109,10 +109,10 @@ static void ClearGlobalShader(void) // default normal/specular VectorSet4(stages[i].normalScale, 0.0f, 0.0f, 0.0f, 0.0f); - stages[i].specularScale[0] = + stages[i].specularScale[0] = stages[i].specularScale[1] = stages[i].specularScale[2] = r_baseSpecular->value; - stages[i].specularScale[3] = 0.99; + stages[i].specularScale[3] = 0.99f; } shader.contentFlags = CONTENTS_SOLID | CONTENTS_OPAQUE; @@ -1345,11 +1345,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } + stage->specularType = SPEC_SPECGLOSS; + VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); if (!Q_stricmp(token, "$whiteimage")) { stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; - stage->specularType = SPEC_SPECGLOSS; - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); continue; } @@ -1375,8 +1375,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) ri.Printf(PRINT_WARNING, "WARNING: R_FindImageFile could not find specMap '%s' in shader '%s'\n", token, shader.name); return qfalse; } - stage->specularType = SPEC_SPECGLOSS; - VectorSet4(stage->specularScale, 1.0f, 1.0f, 1.0f, 0.0f); + } // // rmoMap || rmosMap @@ -1390,6 +1389,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } stage->specularType = !Q_stricmp(token, "rmosMap") ? SPEC_RMOS : SPEC_RMO; + if (!Q_stricmp(token, "$whiteimage")) + { + stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; + continue; + } Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1404,6 +1408,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } stage->specularType = !Q_stricmp(token, "mosrMap") ? SPEC_MOSR : SPEC_MOXR; + if (!Q_stricmp(token, "$whiteimage")) + { + stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; + continue; + } Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1418,6 +1427,11 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) return qfalse; } stage->specularType = !Q_stricmp(token, "ormsMap") ? SPEC_ORMS : SPEC_ORM; + if (!Q_stricmp(token, "$whiteimage")) + { + stage->bundle[TB_SPECULARMAP].image[0] = tr.whiteImage; + continue; + } Q_strncpyz(bufferPackedTextureName, token, sizeof(bufferPackedTextureName)); } // @@ -1627,7 +1641,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = Com_Clamp( 0.0f, 1.0f, 1.0 - atof( token ) ); + stage->specularScale[3] = 1.0 - atof( token ); } // // roughness @@ -1641,7 +1655,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) continue; } - stage->specularScale[3] = Com_Clamp(0.0f, 1.0f, atof(token)); + stage->specularScale[3] = atof(token); } // // parallaxDepth @@ -1710,6 +1724,7 @@ static qboolean ParseStage( shaderStage_t *stage, const char **text ) // specularScale // or specularScale // or specularScale + // or specularScale when metal roughness workflow is used // else if (!Q_stricmp(token, "specularscale")) { From dd5ab371a5a49a25163f88b97845307a76330b5c Mon Sep 17 00:00:00 2001 From: SomaZ Date: Sun, 12 Mar 2023 23:57:56 +0100 Subject: [PATCH 622/708] Fix refraction shading with r_hdr 0 --- codemp/rd-rend2/glsl/refraction.glsl | 10 ++++++---- codemp/rd-rend2/tr_glsl.cpp | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/refraction.glsl b/codemp/rd-rend2/glsl/refraction.glsl index 635c29e63c..04a833de79 100644 --- a/codemp/rd-rend2/glsl/refraction.glsl +++ b/codemp/rd-rend2/glsl/refraction.glsl @@ -464,10 +464,6 @@ void main() color.a = var_Color.a; color.rgb *= var_Color.rgb; color.rgb *= u_Color.rgb; - - vec3 minAvgMax = texture(u_LevelsMap, texG).rgb; - vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); - float avgLum = exp2(logMinAvgMaxLum.y); #if defined(USE_ALPHA_TEST) if (u_AlphaTestType == ALPHA_TEST_GT0) @@ -491,6 +487,11 @@ void main() discard; } #endif + +#if defined(USE_TONEMAPPING) + vec3 minAvgMax = texture(u_LevelsMap, texG).rgb; + vec3 logMinAvgMaxLum = clamp(minAvgMax * 20.0 - 10.0, -u_AutoExposureMinMax.y, -u_AutoExposureMinMax.x); + float avgLum = exp2(logMinAvgMaxLum.y); color.rgb *= u_ToneMinAvgMaxLinear.y / avgLum; color.rgb = max(vec3(0.0), color.rgb - vec3(u_ToneMinAvgMaxLinear.x)); @@ -501,6 +502,7 @@ void main() #if defined(USE_LINEAR_LIGHT) color.rgb = LinearTosRGB(color.rgb); #endif +#endif out_Color = clamp(color, 0.0, 1.0); } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 0b19d34451..3cfa51e3fe 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -370,6 +370,9 @@ static size_t GLSL_GetShaderHeader( Q_strcat(dest, size, va("#define r_deluxeSpecular %f\n", r_deluxeSpecular->value)); } + if (r_hdr->integer && (r_toneMap->integer || r_forceToneMap->integer)) + Q_strcat(dest, size, "#define USE_TONEMAPPING\n"); + if (extra) { Q_strcat(dest, size, extra); From af10d8cb51ecc5d49c34c7247d9b0e347017cb45 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 13 Mar 2023 00:22:35 +0100 Subject: [PATCH 623/708] Correct index buffer for surface sprites --- codemp/rd-rend2/tr_bsp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 25201f03ce..28097a2579 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3887,8 +3887,8 @@ static void R_GenerateSurfaceSprites( const world_t *world ) { std::vector sprites_index_data; - sprites_index_data.reserve(65535 * 6); - for (int i = 0; i < 65535 * 6; i++) + sprites_index_data.reserve(98298); + for (int i = 0; i < 98299; i++) { const uint16_t face_indices[] = { 0, 1, 2, 0, 2, 3 }; int vert_index = face_indices[i % 6] + (int(i / 6) * 4); From 72c9bc3bacc34e9f3b10122d1df45e6b325cc006 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Mon, 13 Mar 2023 03:22:02 +0100 Subject: [PATCH 624/708] Add loading additional deluxemaps --- codemp/rd-rend2/tr_bsp.cpp | 64 ++++++++++++++++++++++++++++++++++++-- codemp/rd-rend2/tr_local.h | 1 + 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 28097a2579..e13fc20f41 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -233,7 +233,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { else { tr.worldDeluxeMapping = qtrue; - + tr.worldInternalDeluxeMapping = qtrue; // Check that none of the deluxe maps are referenced by any of the map surfaces. for (i = 0, surf = (dsurface_t *)(fileBase + surfs->fileofs); tr.worldDeluxeMapping && i < surfs->filelen / sizeof(dsurface_t); @@ -244,6 +244,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (lightmapNum >= 0 && (lightmapNum & 1) != 0) { tr.worldDeluxeMapping = qfalse; + tr.worldInternalDeluxeMapping = qfalse; break; } } @@ -558,6 +559,62 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { 0); } } + else if (r_deluxeMapping->integer && !tr.worldDeluxeMapping && !r_mergeLightmaps->integer) + { + char filename[MAX_QPATH]; + byte *externalLightmap = NULL; + int lightmapWidth = tr.lightmapSize; + int lightmapHeight = tr.lightmapSize; + + // try loading additional deluxemaps + Com_sprintf(filename, sizeof(filename), "maps/%s/dm_%04d.tga", worldData->baseName, i); + R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); + if (!externalLightmap) + continue; + + int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; + if (newImageSize > imageSize) + { + Z_Free(image); + imageSize = newImageSize; + image = (byte *)Z_Malloc(imageSize, TAG_BSP, qfalse); + } + + buf_p = externalLightmap; + + for (j = 0; j < lightmapWidth * lightmapHeight; j++) { + image[j * 4 + 0] = buf_p[j * 4 + 0]; + image[j * 4 + 1] = buf_p[j * 4 + 1]; + image[j * 4 + 2] = buf_p[j * 4 + 2]; + + // make 0,0,0 into 127,127,127 + if ((image[j * 4 + 0] == 0) && (image[j * 4 + 1] == 0) && (image[j * 4 + 2] == 0)) + { + image[j * 4 + 0] = + image[j * 4 + 1] = + image[j * 4 + 2] = 127; + } + + image[j * 4 + 3] = 255; + } + + if (!tr.deluxemaps) + tr.deluxemaps = (image_t **)ri.Hunk_Alloc(tr.numLightmaps * sizeof(image_t *), h_low); + + tr.deluxemaps[i] = R_CreateImage( + va("*deluxemap%d", i), + image, + lightmapWidth, + lightmapHeight, + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, + 0); + + Z_Free(externalLightmap); + externalLightmap = NULL; + } } if ( r_lightmap->integer == 2 ) { @@ -565,6 +622,9 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } Z_Free(image); + + if (tr.deluxemaps) + tr.worldDeluxeMapping = qtrue; } @@ -612,7 +672,7 @@ static int FatLightmap(int lightmapnum) if (lightmapnum < 0) return lightmapnum; - if (tr.worldDeluxeMapping) + if (tr.worldInternalDeluxeMapping) lightmapnum >>= 1; if (tr.lightmapAtlasSize[0] > 0) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 9e3ea68d37..d0c227b43f 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2368,6 +2368,7 @@ typedef struct trGlobals_s { qboolean worldMapLoaded; qboolean worldDeluxeMapping; + qboolean worldInternalDeluxeMapping; vec2_t autoExposureMinMax; vec3_t toneMinAvgMaxLevel; world_t *world; From f057162bd7dfb3227d1ca74df0fa7f27bcad2458 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 16 Mar 2023 14:26:12 +0100 Subject: [PATCH 625/708] Don't flip hdr lightmaps Now, hdr lightmaps have the same orientation as usual exterrnal lightmaps --- codemp/rd-rend2/tr_bsp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index e13fc20f41..c4081bf63c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -417,7 +417,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { { vec4_t color; int column = (j % lightmapWidth); - int rowIndex = ((lightmapHeight - (int)floor(j / lightmapHeight)) - 1) * lightmapHeight; + int rowIndex = (int)floor(j / lightmapHeight) * lightmapHeight; int index = column + rowIndex; From 5603b1543c220bce26510fa29658527e5da4bcc2 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 16 Mar 2023 14:29:11 +0100 Subject: [PATCH 626/708] [weather] Implement Inside/Outside brushes --- codemp/rd-rend2/tr_bsp.cpp | 66 ++++--- codemp/rd-rend2/tr_weather.cpp | 314 +++++++++++++++++---------------- codemp/rd-rend2/tr_weather.h | 89 +++++++++- 3 files changed, 290 insertions(+), 179 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c4081bf63c..86eb5267d1 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3269,35 +3269,54 @@ static void R_RenderAllCubemaps() } -void R_LoadWeatherZones() +void R_LoadWeatherZones(world_t *worldData, lump_t *brushesLump, lump_t *sidesLump) { - char spawnVarChars[2048]; - int numSpawnVars; - char *spawnVars[MAX_SPAWN_VARS][2]; + dbrush_t *brushes, *brush; + dbrushside_t *sides; + int brushesCount, sidesCount; - while (R_ParseSpawnVars(spawnVarChars, sizeof(spawnVarChars), &numSpawnVars, spawnVars)) - { - vec3_t mins, maxs; - qboolean isWeatherZone = qfalse; - char *model = NULL; + brushes = (dbrush_t *)(fileBase + brushesLump->fileofs); + if (brushesLump->filelen % sizeof(*brushes)) { + ri.Error(ERR_DROP, "LoadMap: funny lump size in %s", worldData->name); + } + brushesCount = brushesLump->filelen / sizeof(*brushes); - for (int i = 0; i < numSpawnVars; i++) + sides = (dbrushside_t *)(fileBase + sidesLump->fileofs); + if (sidesLump->filelen % sizeof(*sides)) { + ri.Error(ERR_DROP, "LoadMap: funny lump size in %s", worldData->name); + } + sidesCount = sidesLump->filelen / sizeof(*sides); + + tr.weatherSystem->weatherBrushType = WEATHER_BRUSHES_NONE; + + for (int i = 0; i < brushesCount; i++, brushes++) { + dshader_t *currentShader = worldData->shaders + brushes->shaderNum; + int contents = currentShader->contentFlags; + if (!(contents & CONTENTS_INSIDE || contents & CONTENTS_OUTSIDE)) + continue; + + weatherBrushType_t currentBrushType = contents & CONTENTS_OUTSIDE ? WEATHER_BRUSHES_OUTSIDE : WEATHER_BRUSHES_INSIDE; + if (tr.weatherSystem->weatherBrushType == WEATHER_BRUSHES_NONE) + tr.weatherSystem->weatherBrushType = currentBrushType; + + if (tr.weatherSystem->weatherBrushType != currentBrushType) { - if (!Q_stricmp(spawnVars[i][0], "classname") && !Q_stricmp(spawnVars[i][1], "misc_weather_zone")) - { - isWeatherZone = qtrue; - } - if (!Q_stricmp(spawnVars[i][0], "model")) - { - model = spawnVars[i][1]; - } + Com_Error(ERR_DROP, "Weather Effect: Both Indoor and Outdoor brushs encountered in map.\n"); + return; } - if (isWeatherZone == qtrue && model != NULL) + vec4_t planes[64]; + for (int j = 0; j < brushes->numSides; j++) { - R_ModelBounds(RE_RegisterModel(model), mins, maxs); - R_AddWeatherZone(mins, maxs); + int currentSideIndex = brushes->firstSide + j; + int currentPlaneIndex = sides[currentSideIndex].planeNum; + planes[j][0] = worldData->planes[currentPlaneIndex].normal[0]; + planes[j][1] = worldData->planes[currentPlaneIndex].normal[1]; + planes[j][2] = worldData->planes[currentPlaneIndex].normal[2]; + planes[j][3] = worldData->planes[currentPlaneIndex].dist; } + + R_AddWeatherBrush((uint8_t)brushes->numSides, planes); } } @@ -4138,6 +4157,10 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); + R_LoadWeatherZones( + worldData, + &header->lumps[LUMP_BRUSHES], + &header->lumps[LUMP_BRUSHSIDES]); R_GenerateSurfaceSprites(worldData); // determine vertex light directions @@ -4244,7 +4267,6 @@ void RE_LoadWorldMap( const char *name ) { tr.worldMapLoaded = qtrue; tr.world = world; - R_LoadWeatherZones(); R_InitWeatherForMap(); // Render all cubemaps diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index ac9d7a11cb..6cce211ba6 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -19,87 +19,10 @@ along with this program; if not, see . */ #include "tr_weather.h" -#include "tr_local.h" #include #include #include -enum weatherType_t -{ - WEATHER_RAIN, - WEATHER_SNOW, - WEATHER_SPACEDUST, - WEATHER_SAND, - WEATHER_FOG, - - NUM_WEATHER_TYPES -}; - -const int maxWeatherTypeParticles[NUM_WEATHER_TYPES] = { - 30000, - 10000, - 5000, - 1000, - 1000 -}; - -#define MAX_WINDOBJECTS 10 -#define MAX_WEATHER_ZONES 100 - -struct weatherObject_t -{ - VBO_t *lastVBO; - VBO_t *vbo; - unsigned vboLastUpdateFrame; - vertexAttribute_t attribsTemplate[2]; - - bool active; - - float gravity; - float fadeDistance; - int particleCount; - image_t *drawImage; - vec4_t color; - vec2_t size; -}; - -struct windObject_t -{ - vec3_t currentVelocity; - vec3_t targetVelocity; - vec3_t maxVelocity; - vec3_t minVelocity; - float chanceOfDeadTime; - vec2_t deadTimeMinMax; - int targetVelocityTimeRemaining; -}; - -struct weatherZone_t -{ - vec3_t mins; - vec3_t maxs; -}; - -struct weatherSystem_t -{ - weatherObject_t weatherSlots[NUM_WEATHER_TYPES]; - windObject_t windSlots[MAX_WINDOBJECTS]; - weatherZone_t weatherZones[MAX_WEATHER_ZONES]; - - int activeWeatherTypes = 0; - int activeWindObjects = 0; - int numWeatherZones = 0; - bool frozen; - - srfWeather_t weatherSurface; - - vec3_t constWindDirection; - vec3_t windDirection; - float windSpeed; - - float weatherMVP[16]; -}; - namespace { const int CHUNK_COUNT = 9; // in 3x3 arrangement @@ -187,6 +110,18 @@ namespace ws.attribsTemplate[1].vbo = nullptr; } + bool intersectPlane(const vec3_t n, const float dist, const vec3_t l0, const vec3_t l, float &t) + { + // assuming vectors are all normalized + float denom = DotProduct(n, l); + if (denom > 1e-6) { + t = -(DotProduct(l0, n) + dist) / denom; + return (t >= 0); + } + + return false; + } + void GenerateDepthMap() { vec3_t mapSize; @@ -200,7 +135,7 @@ namespace const vec3_t forward = {0.0f, 0.0f, -1.0f}; const vec3_t left = {0.0f, 1.0f, 0.0f}; - const vec3_t up = {1.0f, 0.0f, 0.0f}; + const vec3_t up = {-1.0f, 0.0f, 0.0f}; vec3_t viewOrigin; VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin); @@ -242,92 +177,166 @@ namespace tr.viewParms.world.modelViewMatrix, tr.weatherSystem->weatherMVP); -#if 0 - if (tr.weatherSystem->numWeatherZones > 0) + if (tr.weatherSystem->numWeatherBrushes > 0) { FBO_Bind(tr.weatherDepthFbo); qglViewport(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); qglScissor(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); - // clear depth to 0, then stomp the depth buffer with the mins of the weather zones - qglClearDepth(0.0f); + + if (tr.weatherSystem->weatherBrushType == WEATHER_BRUSHES_OUTSIDE) // used outside brushes + { + qglClearDepth(0.0f); + GL_State(GLS_DEPTHMASK_TRUE | GLS_DEPTHFUNC_GREATER); + } + else // used inside brushes + { + qglClearDepth(1.0f); + GL_State(GLS_DEPTHMASK_TRUE); + } + qglClear(GL_DEPTH_BUFFER_BIT); qglClearDepth(1.0f); - qglEnable(GL_DEPTH_CLAMP); - GL_State(GLS_DEPTHMASK_TRUE | GLS_DEPTHFUNC_GREATER); GL_Cull(CT_TWO_SIDED); vec4_t color = { 0.0f, 0.0f, 0.0f, 1.0f }; backEnd.currentEntity = &tr.worldEntity; - RB_BeginSurface(tr.defaultShader, 0, 0); - - for (int i = 0; i <= tr.weatherSystem->numWeatherZones; i++) + + + vec3_t stepSize = { + abs(mapSize[0]) / tr.weatherDepthFbo->width, + abs(mapSize[1]) / tr.weatherDepthFbo->height, + 0.0, + }; + + vec3_t up = { + stepSize[0] * 0.5f, + 0.0f, + 0.0f + }; + vec3_t left = { + 0.0f, + stepSize[1] * 0.5f, + 0.0f + }; + vec3_t traceVec = { + 0.0f, + 0.0f, + -1.0f + }; + + for (int i = 0; i < tr.weatherSystem->numWeatherBrushes; i++) { - weatherZone_t *currentWeatherZone = &tr.weatherSystem->weatherZones[i]; + RB_BeginSurface(tr.defaultShader, 0, 0); + weatherBrushes_t *currentWeatherBrush = &tr.weatherSystem->weatherBrushes[i]; + + // RBSP brushes actually store their bounding box in the first 6 planes! Nice + vec3_t mins = { + -currentWeatherBrush->planes[0][3], + -currentWeatherBrush->planes[2][3], + -currentWeatherBrush->planes[4][3], + }; + vec3_t maxs = { + currentWeatherBrush->planes[1][3], + currentWeatherBrush->planes[3][3], + currentWeatherBrush->planes[5][3], + }; + + ivec2_t numSteps = { + int((maxs[0] - mins[0]) / stepSize[0]) + 2, + int((maxs[1] - mins[1]) / stepSize[1]) + 2 + }; + + vec2_t rayOrigin = { + tr.world->bmodels[0].bounds[0][0] + (floorf((mins[0] - tr.world->bmodels[0].bounds[0][0]) / stepSize[0]) + 0.5f) * stepSize[0], + tr.world->bmodels[0].bounds[0][1] + (floorf((mins[1] - tr.world->bmodels[0].bounds[0][1]) / stepSize[1]) + 0.5f) * stepSize[1] + }; + + for (int y = 0; y < (int)numSteps[1]; y++) { - vec3_t up = { - currentWeatherZone->mins[0] - currentWeatherZone->maxs[0], - 0.0f, - 0.0f }; - vec3_t left = { - 0.0f, - currentWeatherZone->mins[1] - currentWeatherZone->maxs[1], - 0.0f }; - vec3_t zone_origin = { - currentWeatherZone->maxs[0], - currentWeatherZone->maxs[1], - currentWeatherZone->maxs[2] }; - - RB_AddQuadStamp(zone_origin, left, up, color); - } - { - vec3_t up = { - -currentWeatherZone->mins[0] + currentWeatherZone->maxs[0], - 0.0f, - 0.0f }; - vec3_t left = { - 0.0f, - -currentWeatherZone->mins[1] + currentWeatherZone->maxs[1], - 0.0f }; - vec3_t zone_origin = { - currentWeatherZone->mins[0], - currentWeatherZone->mins[1], - currentWeatherZone->mins[2] }; - - RB_AddQuadStamp(zone_origin, left, up, color); + for (int x = 0; x < (int)numSteps[0]; x++) + { + vec3_t rayPos = { + rayOrigin[0] + x * stepSize[0], + rayOrigin[1] + y * stepSize[1], + tr.world->bmodels[0].bounds[1][2] + }; + + // Find intersection point with the brush + float t = 0.0f; + for (int j = 0; j < currentWeatherBrush->numPlanes; j++) + { + vec3_t plane_normal; + float plane_dist; + if (tr.weatherSystem->weatherBrushType == WEATHER_BRUSHES_OUTSIDE) + { + plane_normal[0] = currentWeatherBrush->planes[j][0]; + plane_normal[1] = currentWeatherBrush->planes[j][1]; + plane_normal[2] = currentWeatherBrush->planes[j][2]; + plane_dist = -currentWeatherBrush->planes[j][3]; + } + else + { + plane_normal[0] = -currentWeatherBrush->planes[j][0]; + plane_normal[1] = -currentWeatherBrush->planes[j][1]; + plane_normal[2] = -currentWeatherBrush->planes[j][2]; + plane_dist = currentWeatherBrush->planes[j][3]; + } + + float dist = 0.0f; + if (intersectPlane(plane_normal, plane_dist, rayPos, traceVec, dist)) + t = MAX(t, dist); + } + + bool hit = true; + rayPos[2] -= t; + + // Now test if the intersected point is actually on the brush + for (int j = 0; j < currentWeatherBrush->numPlanes; j++) + { + vec4_t *plane = ¤tWeatherBrush->planes[j]; + vec3_t normal = { + currentWeatherBrush->planes[j][0], + currentWeatherBrush->planes[j][1], + currentWeatherBrush->planes[j][2] + }; + if (DotProduct(rayPos, normal) > currentWeatherBrush->planes[j][3] + 1e-3) + hit = false; + } + + if (!hit) + continue; + + // Just draw it now + RB_AddQuadStamp(rayPos, left, up, color); + + RB_UpdateVBOs(ATTR_POSITION); + GLSL_VertexAttribsState(ATTR_POSITION, NULL); + GLSL_BindProgram(&tr.textureColorShader); + GLSL_SetUniformMatrix4x4( + &tr.textureColorShader, + UNIFORM_MODELVIEWPROJECTIONMATRIX, + tr.weatherSystem->weatherMVP); + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + RB_CommitInternalBufferData(); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.multiDrawPrimitives = 0; + tess.externalIBO = nullptr; + } } } - RB_UpdateVBOs(ATTR_POSITION); - - GLSL_VertexAttribsState(ATTR_POSITION, NULL); - - GLSL_BindProgram(&tr.textureColorShader); - - GLSL_SetUniformMatrix4x4( - &tr.textureColorShader, - UNIFORM_MODELVIEWPROJECTIONMATRIX, - tr.weatherSystem->weatherMVP); - - R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); - - RB_CommitInternalBufferData(); - qglDisable(GL_DEPTH_CLAMP); - - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; - tess.minIndex = 0; - tess.maxIndex = 0; - tess.useInternalVBO = qfalse; } - if (tr.weatherSystem->numWeatherZones > 0) + if (tr.weatherSystem->numWeatherBrushes > 0) tr.viewParms.flags |= VPF_NOCLEAR; -#endif const int firstDrawSurf = tr.refdef.numDrawSurfs; @@ -484,17 +493,17 @@ qboolean WE_ParseVector(const char **text, int count, float *v) { return qtrue; } -void R_AddWeatherZone(vec3_t mins, vec3_t maxs) +void R_AddWeatherBrush(uint8_t numPlanes, vec4_t *planes) { - if (tr.weatherSystem->numWeatherZones >= MAX_WEATHER_ZONES) + if (tr.weatherSystem->numWeatherBrushes >= (MAX_WEATHER_ZONES * 2)) { - ri.Printf(PRINT_WARNING, "Max weather zones hit. Skipping new zone\n"); + ri.Printf(PRINT_WARNING, "Max weather brushes hit. Skipping new inside/outside brush\n"); return; } - VectorCopy(mins, tr.weatherSystem->weatherZones[tr.weatherSystem->numWeatherZones].mins); - VectorCopy(maxs, tr.weatherSystem->weatherZones[tr.weatherSystem->numWeatherZones].maxs); - tr.weatherSystem->numWeatherZones++; - ri.Printf(PRINT_ALL, "Weather zone %i added\n", tr.weatherSystem->numWeatherZones); + tr.weatherSystem->weatherBrushes[tr.weatherSystem->numWeatherBrushes].numPlanes = numPlanes; + memcpy(tr.weatherSystem->weatherBrushes[tr.weatherSystem->numWeatherBrushes].planes, planes, numPlanes * sizeof(vec4_t)); + + tr.weatherSystem->numWeatherBrushes++; } void RE_WorldEffectCommand(const char *command) @@ -547,12 +556,7 @@ void RE_WorldEffectCommand(const char *command) ////--------------- else if (Q_stricmp(token, "zone") == 0) { - vec3_t mins; - vec3_t maxs; - if (WE_ParseVector(&command, 3, mins) && WE_ParseVector(&command, 3, maxs)) - { - R_AddWeatherZone(mins, maxs); - } + ri.Printf(PRINT_DEVELOPER, "Weather zones aren't used in rend2, but inside/outside brushes\n"); } // Basic Wind diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index c0d597b78d..c2793bf624 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -20,15 +20,100 @@ along with this program; if not, see . #pragma once #include "qcommon/qcommon.h" +#include "tr_local.h" +#define MAX_WINDOBJECTS 10 +#define MAX_WEATHER_ZONES 100 -struct weatherSystem_t; +enum weatherType_t +{ + WEATHER_RAIN, + WEATHER_SNOW, + WEATHER_SPACEDUST, + WEATHER_SAND, + WEATHER_FOG, + + NUM_WEATHER_TYPES +}; + +const int maxWeatherTypeParticles[NUM_WEATHER_TYPES] = { + 30000, + 10000, + 5000, + 1000, + 1000 +}; + +struct weatherObject_t +{ + VBO_t *lastVBO; + VBO_t *vbo; + unsigned vboLastUpdateFrame; + vertexAttribute_t attribsTemplate[2]; + + bool active; + + float gravity; + float fadeDistance; + int particleCount; + image_t *drawImage; + vec4_t color; + vec2_t size; +}; + +struct windObject_t +{ + vec3_t currentVelocity; + vec3_t targetVelocity; + vec3_t maxVelocity; + vec3_t minVelocity; + float chanceOfDeadTime; + vec2_t deadTimeMinMax; + int targetVelocityTimeRemaining; +}; + +struct weatherBrushes_t +{ + uint8_t numPlanes; + vec4_t planes[64]; + +}; + +enum weatherBrushType_t +{ + WEATHER_BRUSHES_NONE, + WEATHER_BRUSHES_OUTSIDE, + WEATHER_BRUSHES_INSIDE, + + NUM_WEATHER_BRUSH_TYPES +}; + +struct weatherSystem_t +{ + weatherObject_t weatherSlots[NUM_WEATHER_TYPES]; + windObject_t windSlots[MAX_WINDOBJECTS]; + weatherBrushes_t weatherBrushes[MAX_WEATHER_ZONES * 2]; + weatherBrushType_t weatherBrushType = WEATHER_BRUSHES_NONE; + + int activeWeatherTypes = 0; + int activeWindObjects = 0; + int numWeatherBrushes = 0; + bool frozen; + + srfWeather_t weatherSurface; + + vec3_t constWindDirection; + vec3_t windDirection; + float windSpeed; + + float weatherMVP[16]; +}; struct srfWeather_t; void R_InitWeatherSystem(); void R_InitWeatherForMap(); void R_AddWeatherSurfaces(); -void R_AddWeatherZone(vec3_t mins, vec3_t maxs); +void R_AddWeatherBrush(uint8_t numPlanes, vec4_t *planes); void R_ShutdownWeatherSystem(); void RB_SurfaceWeather( srfWeather_t *surfaceType ); From 35a6e6e9711e40fdb6633fb547b6b62fbdb64719 Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 16 Mar 2023 14:53:45 +0100 Subject: [PATCH 627/708] [weather] Add velocity skewing factor Prevents snow from being skewed in wind like in vanilla --- codemp/rd-rend2/glsl/weather.glsl | 1 + codemp/rd-rend2/tr_weather.cpp | 22 +++++++++++++++++++++- codemp/rd-rend2/tr_weather.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 4195707959..e8b876aabb 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -21,6 +21,7 @@ void main() vec4 velocitiyOffset = u_ViewInfo.y * vec4(-var_Velocity.xy/var_Velocity.z, var_Velocity.z, 0.0); velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, var_Velocity.z != 0.0); + var_Velocity.z *= u_ViewInfo.z; vec4 depthPosition = u_ShadowMvp * (gl_Position + velocitiyOffset); depthPosition.xyz = depthPosition.xyz / depthPosition.w * 0.5 + 0.5; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 6cce211ba6..2607bf11f6 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -639,6 +639,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); @@ -675,6 +677,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); @@ -716,6 +720,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 2.0f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain.jpg", type, flags); @@ -752,6 +758,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_RAIN].size[1] = 14.0f; + tr.weatherSystem->weatherSlots[WEATHER_RAIN].velocityOrientationScale = 1.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_RAIN].drawImage = R_FindImageFile("gfx/world/rain", type, flags); @@ -783,6 +791,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[0] = 1.5f; tr.weatherSystem->weatherSlots[WEATHER_SNOW].size[1] = 1.5f; + tr.weatherSystem->weatherSlots[WEATHER_SNOW].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_SNOW].drawImage = R_FindImageFile("gfx/effects/snowflake1", type, flags); @@ -829,6 +839,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[0] = 2.5f; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].size[1] = 2.5f; + tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_SPACEDUST].drawImage = R_FindImageFile("gfx/effects/snowpuff1", type, flags); @@ -871,6 +883,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_SAND].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_SAND].size[1] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_SAND].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_SAND].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); @@ -906,6 +920,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); @@ -945,6 +961,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); @@ -984,6 +1002,8 @@ void RE_WorldEffectCommand(const char *command) tr.weatherSystem->weatherSlots[WEATHER_FOG].size[0] = 300.f; tr.weatherSystem->weatherSlots[WEATHER_FOG].size[1] = 300.f; + tr.weatherSystem->weatherSlots[WEATHER_FOG].velocityOrientationScale = 0.0f; + imgType_t type = IMGTYPE_COLORALPHA; int flags = IMGFLAG_CLAMPTOEDGE; tr.weatherSystem->weatherSlots[WEATHER_FOG].drawImage = R_FindImageFile("gfx/effects/alpha_smoke2b", type, flags); @@ -1121,7 +1141,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) vec4_t viewInfo = { weatherObject->size[0], weatherObject->size[1], - 0.0f, + weatherObject->velocityOrientationScale, weatherObject->fadeDistance }; diff --git a/codemp/rd-rend2/tr_weather.h b/codemp/rd-rend2/tr_weather.h index c2793bf624..b03b25275d 100644 --- a/codemp/rd-rend2/tr_weather.h +++ b/codemp/rd-rend2/tr_weather.h @@ -55,6 +55,7 @@ struct weatherObject_t float gravity; float fadeDistance; + float velocityOrientationScale; int particleCount; image_t *drawImage; vec4_t color; From ff90981b025ebc249f455a26aa97d9430be9d7cf Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 16 Mar 2023 16:40:44 +0100 Subject: [PATCH 628/708] Try fixing linux builds --- codemp/rd-rend2/glsl/compact.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/codemp/rd-rend2/glsl/compact.cpp b/codemp/rd-rend2/glsl/compact.cpp index 0421af27e0..89bd5252c6 100644 --- a/codemp/rd-rend2/glsl/compact.cpp +++ b/codemp/rd-rend2/glsl/compact.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "tr_local.h" #include "tr_allocator.h" From 0a6df9a5434eb6603c7f6389286504767b19b1fe Mon Sep 17 00:00:00 2001 From: SomaZ Date: Thu, 16 Mar 2023 21:49:59 +0100 Subject: [PATCH 629/708] Add rend2 release workflow --- .github/workflows/rend2.yml | 347 ++++++++++++++++++++++++++++++++++++ 1 file changed, 347 insertions(+) create mode 100644 .github/workflows/rend2.yml diff --git a/.github/workflows/rend2.yml b/.github/workflows/rend2.yml new file mode 100644 index 0000000000..43a07d9661 --- /dev/null +++ b/.github/workflows/rend2.yml @@ -0,0 +1,347 @@ +name: rend2 + +on: + workflow_dispatch: + push: + branches: [rend2] + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' + pull_request: + branches: [rend2] + paths-ignore: + - '**.md' + - '*.txt' + - '.gitignore' + - 'docs/*' + release: + types: [published] + +jobs: + msvc: + name: Windows ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: windows-2022 + strategy: + matrix: + arch: [x86, x86_64] + build_type: [Debug, Release] + portable: [Portable, Non-Portable] + include: + - arch: x86 + platform: Win32 + - arch: x86_64 + platform: x64 + + steps: + - uses: actions/checkout@v3 + + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Create Build Environment + run: cmake -E make_directory ${{ runner.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ runner.workspace }}/build + run: | + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" + else + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" + fi + cmake $GITHUB_WORKSPACE -A ${{ matrix.platform }} $OPTIONS + + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . --config ${{ matrix.build_type }} + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ runner.workspace }}/build/bin + if-no-files-found: error + + msvcxp: + name: WinXP ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: windows-2022 + strategy: + matrix: + arch: [x86, x86_64] + build_type: [Debug, Release] + portable: [Portable, Non-Portable] + include: + - arch: x86 + platform: Win32 + - arch: x86_64 + platform: x64 + + steps: + - uses: actions/checkout@v3 + + - name: Install v141_xp Toolchain + continue-on-error: true + shell: powershell + run: | + Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" + $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" + $WorkLoads = '--add Microsoft.VisualStudio.Component.WinXP' + $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"", $WorkLoads, '--quiet', '--norestart', '--nocache') + $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden + if ($process.ExitCode -eq 0) { + Write-Host "components have been successfully added" + } else { + Write-Host "components were not installed" + } + - name: Add msbuild to PATH + uses: microsoft/setup-msbuild@v1.1 + + - name: Create Build Environment + run: cmake -E make_directory ${{ runner.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ runner.workspace }}/build + run: | + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" + else + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" + fi + cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS + + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . --config ${{ matrix.build_type }} + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ runner.workspace }}/build + shell: bash + run: | + cmake --install . --config ${{ matrix.build_type }} + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ runner.workspace }}/build/bin + if-no-files-found: error + + ubuntu: + name: Ubuntu ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) + runs-on: ubuntu-22.04 + strategy: + fail-fast: false + matrix: + arch: [x86_64] + build_type: [Debug, Release] + portable: [Non-Portable] + + steps: + - uses: actions/checkout@v3 + + - name: Create Build Environment + run: | + if [ ${{ matrix.arch }} == "x86" ]; then + sudo dpkg --add-architecture i386 + sudo apt-get -qq update + sudo apt-get -y install aptitude + sudo apt-get -y install gcc-multilib g++-multilib ninja-build + sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 + sudo aptitude -y install libglib2.0-dev:i386 libsdl2-dev:i386 + else + sudo apt-get -qq update + sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev + fi + cmake -E make_directory ${{ runner.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ runner.workspace }}/build + run: | + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS="-DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + else + OPTIONS="-DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + fi + + if [ ${{ matrix.arch }} == "x86" ]; then + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake + else + cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS + fi + + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . + + - name: Create binary archive + if: ${{ matrix.build_type == 'Release'}} + working-directory: ${{ runner.workspace }}/install/JediAcademy + shell: bash + run: | + if [ ${{ matrix.arch }} == "x86" ]; then + chmod +x openjk.i386 + else + chmod +x openjk.${{ matrix.arch }} + fi + tar -czvf OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{runner.workspace}}/install/JediAcademy/OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz + if-no-files-found: error + + macos: + name: macOS ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable}}) + runs-on: macos-12 + strategy: + fail-fast: false + matrix: + arch: [x86_64] + build_type: [Debug, Release] + portable: [Non-Portable] + + steps: + - uses: actions/checkout@v3 + + - name: Create Build Environment + run: | + brew install zlib libjpeg libpng sdl2 + cmake -E make_directory ${{ runner.workspace }}/build + + - name: Configure CMake + shell: bash + working-directory: ${{ runner.workspace }}/build + run: | + if [ "${{ matrix.portable }}" == "Portable" ]; then + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + else + OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" + fi + cmake $GITHUB_WORKSPACE $OPTIONS + + - name: Build + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --build . + + - name: Install + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ runner.workspace }}/build + shell: bash + run: cmake --install . + + - name: Create binary archive + if: ${{ matrix.build_type == 'Release' }} + working-directory: ${{ runner.workspace }}/install/JediAcademy + shell: bash + run: | + chmod +x openjk.x86_64.app/Contents/MacOS/openjk.x86_64 + tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * + + - uses: actions/upload-artifact@v3 + if: ${{ matrix.build_type == 'Release' }} + with: + name: OpenJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} + path: ${{ runner.workspace }}/install/JediAcademy/openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz + if-no-files-found: error + + create-latest: + if: github.event_name == 'workflow_dispatch' + needs: [msvc, ubuntu, macos] + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Download Artifacts + uses: actions/download-artifact@v3 + + - name: Create binary archives + run: | + 7z a -r OpenJK-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + 7z a -r OpenJK-windows-x86_64.zip ./OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./OpenJK-linux-x86_64-Release-Non-Portable/* OpenJK-linux-x86_64.tar.gz + mv ./OpenJK-macos-x86_64-Release-Non-Portable/* OpenJK-macos-x86_64.tar.gz + + - name: Create latest build + uses: marvinpinto/action-automatic-releases@latest + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + automatic_release_tag: "latest" + prerelease: false + title: Latest Build + files: | + *.zip + *.tar.gz + + create-release: + if: github.event_name == 'release' + needs: [msvc, ubuntu, macos] + runs-on: ubuntu-22.04 + + strategy: + matrix: + include: + - artifact_dir: OpenJK-windows-x86-Release-Non-Portable/JediAcademy + artifact_name: OpenJK-rend2-windows-x86.zip + zip: true + + - artifact_dir: OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy + artifact_name: OpenJK-rend2-windows-x86_64.zip + zip: true + + - artifact_dir: OpenJK-linux-x86_64-Release-Non-Portable + artifact_name: OpenJK-rend2-linux-x86_64.tar.gz + zip: false + + - artifact_dir: OpenJK-macos-x86_64-Release-Non-Portable + artifact_name: OpenJK-rend2-macos-x86_64.tar.gz + zip: false + + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Download Artifacts + uses: actions/download-artifact@v3 + + - name: Create archive + run: | + if [ "${{ matrix.zip }}" == "true" ]; then + 7z a -r ${{ matrix.artifact_name }} ./${{ matrix.artifact_dir }}/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + else + mv ./${{ matrix.artifact_dir }}/* ${{ matrix.artifact_name }} + fi + + - name: Upload archives + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + overwrite: true + file: ${{ matrix.artifact_name }} From 3495f2064b18ae648e3364e205d7a7173156909f Mon Sep 17 00:00:00 2001 From: SomaZ Date: Fri, 17 Mar 2023 00:10:52 +0100 Subject: [PATCH 630/708] Attempt at fixing Linux x86 builds Many thanks to @Daggolin for finding an error in the cmake config. Co-Authored-By: Daggolin <11301096+daggolin@users.noreply.github.com> --- .github/workflows/rend2.yml | 17 +++++++++++------ codemp/rd-rend2/CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rend2.yml b/.github/workflows/rend2.yml index 43a07d9661..24cbeb9426 100644 --- a/.github/workflows/rend2.yml +++ b/.github/workflows/rend2.yml @@ -145,7 +145,7 @@ jobs: strategy: fail-fast: false matrix: - arch: [x86_64] + arch: [x86, x86_64] build_type: [Debug, Release] portable: [Non-Portable] @@ -282,10 +282,11 @@ jobs: - name: Create binary archives run: | - 7z a -r OpenJK-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - 7z a -r OpenJK-windows-x86_64.zip ./OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - mv ./OpenJK-linux-x86_64-Release-Non-Portable/* OpenJK-linux-x86_64.tar.gz - mv ./OpenJK-macos-x86_64-Release-Non-Portable/* OpenJK-macos-x86_64.tar.gz + 7z a -r OpenJK-rend2-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + 7z a -r OpenJK-rend2-windows-x86_64.zip ./OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' + mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-rend2-linux-x86.tar.gz + mv ./OpenJK-linux-x86_64-Release-Non-Portable/* OpenJK-rend2-linux-x86_64.tar.gz + mv ./OpenJK-macos-x86_64-Release-Non-Portable/* OpenJK-rend2-macos-x86_64.tar.gz - name: Create latest build uses: marvinpinto/action-automatic-releases@latest @@ -293,7 +294,7 @@ jobs: repo_token: ${{ secrets.GITHUB_TOKEN }} automatic_release_tag: "latest" prerelease: false - title: Latest Build + title: Latest rend2 Build files: | *.zip *.tar.gz @@ -314,6 +315,10 @@ jobs: artifact_name: OpenJK-rend2-windows-x86_64.zip zip: true + - artifact_dir: OpenJK-linux-x86-Release-Non-Portable + artifact_name: OpenJK-rend2-linux-x86.tar.gz + zip: false + - artifact_dir: OpenJK-linux-x86_64-Release-Non-Portable artifact_name: OpenJK-rend2-linux-x86_64.tar.gz zip: false diff --git a/codemp/rd-rend2/CMakeLists.txt b/codemp/rd-rend2/CMakeLists.txt index 2ec9be05d2..786cf254fc 100644 --- a/codemp/rd-rend2/CMakeLists.txt +++ b/codemp/rd-rend2/CMakeLists.txt @@ -193,6 +193,7 @@ if (NOT WIN32 AND NOT APPLE) target_compile_definitions(compact_glsl PRIVATE "ARCH_STRING=\"${Architecture}\"") endif() target_include_directories(compact_glsl PRIVATE "${MPRend2IncludeDirectories}") +if (WIN32 OR APPLE) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp @@ -204,3 +205,16 @@ add_custom_command( ${MPRend2GLSLFiles} DEPENDS compact_glsl ${MPRend2GLSLFiles}) +else() +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + COMMAND + ${CMAKE_BINARY_DIR}/compact_glsl + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.cpp + ${CMAKE_CURRENT_BINARY_DIR}/glsl_shaders.h + ${MPRend2GLSLFiles} + DEPENDS + compact_glsl ${MPRend2GLSLFiles}) +endif() From d4e161b9df717ff3319336df413655fc2412e031 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 19 Mar 2023 15:51:49 +0100 Subject: [PATCH 631/708] Attempt at fixing #51 --- codemp/rd-rend2/glsl/surface_sprites.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 69db79b25c..7731ad44f4 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -107,9 +107,10 @@ void main() #endif #if !defined(FACE_UP) && !defined(FX_SPRITE) - offset.xy += mix(skew, vec2(0.0), offset.z == 0.0); + float isLowerVertex = float(offset.z == 0.0); + offset.xy += mix(skew, vec2(0.0), isLowerVertex); float angle = (attr_Position.x + attr_Position.y) * 0.02 + (u_frameTime * 0.0015); - float windsway = mix(height* u_WindIdle * 0.075, 0.0, offset.z == 0.0); + float windsway = mix(height* u_WindIdle * 0.075, 0.0, isLowerVertex); offset.xy += vec2(cos(angle), sin(angle)) * windsway; #endif From 9bf025dd43dcd03c78e64d12511d022b5c5e0d15 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:29:23 +0100 Subject: [PATCH 632/708] Preventing a crash before fatal server error --- codemp/qcommon/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 8cceb640e9..65857da25d 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -291,8 +291,8 @@ void NORETURN QDECL Com_Error( int code, const char *fmt, ... ) { if ( code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT || code == ERR_DROP || code == ERR_NEED_CD ) { throw code; } else { - CL_Shutdown (); SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage)); + CL_Shutdown(); } Com_Shutdown (); From 6fb97cecb8bafa79e39d3e3afdc030cb7e3dd059 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:30:06 +0100 Subject: [PATCH 633/708] Don't load packed images again and again when they are already loaded. --- codemp/rd-rend2/tr_image.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 98254f6881..725e773099 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2707,28 +2707,19 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName return; } - R_LoadImage(packedImageName, &packedPic, &packedWidth, &packedHeight); - if (packedPic == NULL) { - return; - } - + float baseSpecularScale = 1.0f; switch (stage->specularType) { case SPEC_RMOS: case SPEC_MOSR: case SPEC_ORMS: - stage->specularScale[1] = 1.0f; // Don't scale base specular + // Don't scale base specular break; default: - stage->specularScale[1] = 0.5f; // Basespecular is assumed to be 0.04 and shader assumes 0.08 + baseSpecularScale = 0.5f; // Basespecular is assumed to be 0.04 and shader assumes 0.08 break; } - // Don't scale occlusion, roughness and metalness - stage->specularScale[0] = - stage->specularScale[2] = - stage->specularScale[3] = 1.0f; - COM_StripExtension(packedImageName, packedName, sizeof(packedName)); Q_strcat(packedName, sizeof(packedName), "_ORMS"); @@ -2738,9 +2729,26 @@ void R_LoadPackedMaterialImage(shaderStage_t *stage, const char *packedImageName image = R_GetLoadedImage(packedName, flags); if (image != NULL) { + // Don't scale occlusion, roughness and metalness + stage->specularScale[0] = + stage->specularScale[2] = + stage->specularScale[3] = 1.0f; + stage->specularScale[1] = baseSpecularScale; + stage->bundle[TB_ORMSMAP].image[0] = image; return; } + + R_LoadImage(packedImageName, &packedPic, &packedWidth, &packedHeight); + if (packedPic == NULL) { + return; + } + + // Don't scale occlusion, roughness and metalness + stage->specularScale[0] = + stage->specularScale[2] = + stage->specularScale[3] = 1.0f; + stage->specularScale[1] = baseSpecularScale; GLint swizzle[4] = { GL_RED, GL_GREEN, GL_BLUE, GL_ALPHA }; From 8908489bff79537e47d31f1b573d20a547cde7f4 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 19 Mar 2023 23:18:52 +0100 Subject: [PATCH 634/708] Skip glow stages when testing for fog pass --- codemp/rd-rend2/tr_shader.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 47979453cb..6dc4c13564 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3697,6 +3697,9 @@ static shader_t *GeneratePermanentShader( void ) { if (!pStage->active) continue; + if (pStage->glow) + continue; + if (pStage->adjustColorsForFog != ACFF_MODULATE_ALPHA) allPassesAlpha = false; From 65e32a3de8d59f268c535cb72054b593559f681e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 19 Mar 2023 23:43:13 +0100 Subject: [PATCH 635/708] Attempt at fixing #51 Nr.2 --- codemp/rd-rend2/glsl/weather.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index e8b876aabb..993ae8b704 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -20,7 +20,7 @@ void main() var_Velocity = attr_Color; vec4 velocitiyOffset = u_ViewInfo.y * vec4(-var_Velocity.xy/var_Velocity.z, var_Velocity.z, 0.0); - velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, var_Velocity.z != 0.0); + velocitiyOffset.xyz = mix(vec3(0.0), velocitiyOffset.xyz, float(var_Velocity.z != 0.0)); var_Velocity.z *= u_ViewInfo.z; vec4 depthPosition = u_ShadowMvp * (gl_Position + velocitiyOffset); From 01b6b47dcfab79711ed1924ef4a48dd3fc1832f2 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 01:28:24 +0100 Subject: [PATCH 636/708] Attempt at fixing #51 Nr.3 --- codemp/rd-rend2/tr_vbo.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 898e56a22a..5a737640d8 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -96,7 +96,7 @@ VBO_t *R_CreateVBO(byte * vertexes, int vertexesSize, vboUsage_t usage) memset(vbo, 0, sizeof(*vbo)); vbo->vertexesSize = vertexesSize; - vbo->vertexesVBO = tr.vboNames[tr.numVBOs]; + qglGenBuffers(1, &vbo->vertexesVBO); tr.numVBOs++; qglBindBuffer(GL_ARRAY_BUFFER, vbo->vertexesVBO); @@ -143,7 +143,7 @@ IBO_t *R_CreateIBO(byte * indexes, int indexesSize, vboUsage_t usage) ibo = tr.ibos[tr.numIBOs] = (IBO_t *)ri.Hunk_Alloc(sizeof(*ibo), h_low); ibo->indexesSize = indexesSize; - ibo->indexesVBO = tr.iboNames[tr.numIBOs]; + qglGenBuffers(1, &ibo->indexesVBO); tr.numIBOs++; qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo->indexesVBO); @@ -284,8 +284,6 @@ void R_InitGPUBuffers(void) // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is // actually created on first bind. - qglGenBuffers(MAX_IBOS, tr.iboNames); - qglGenBuffers(MAX_VBOS, tr.vboNames); qglGenBuffers(1, &tr.staticUbo); tr.numVBOs = 0; @@ -310,8 +308,26 @@ void R_DestroyGPUBuffers(void) R_BindNullIBO(); qglDeleteBuffers(1, &tr.staticUbo); - qglDeleteBuffers(MAX_IBOS, tr.iboNames); - qglDeleteBuffers(MAX_VBOS, tr.vboNames); + + for (int i = 0; i < tr.numVBOs; i++) + { + VBO_t *vbo = tr.vbos[i]; + + if (vbo->vertexesVBO) + { + qglDeleteBuffers(1, &vbo->vertexesVBO); + } + } + + for (int i = 0; i < tr.numIBOs; i++) + { + IBO_t *ibo = tr.ibos[i]; + + if (ibo->indexesVBO) + { + qglDeleteBuffers(1, &ibo->indexesVBO); + } + } tr.numVBOs = 0; tr.numIBOs = 0; From 240466b445e24bed9124e982962ed9ee4d8894dc Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 02:33:47 +0100 Subject: [PATCH 637/708] Doubled MAX_RENDER_COMMANDS to match Vanilla... ... renderer change. Also skip drawing images when renderer is not initialized. --- codemp/rd-rend2/tr_backend.cpp | 9 +++++++++ codemp/rd-rend2/tr_local.h | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e2c9419b16..f7a5f29063 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1698,6 +1698,9 @@ static const void *RB_StretchPic ( const void *data ) { shader_t *shader; cmd = (const stretchPicCommand_t *)data; + if (!tr.registered) { + return(const void *)(cmd + 1); + } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) @@ -1781,6 +1784,9 @@ static const void *RB_RotatePic ( const void *data ) shader_t *shader; cmd = (const rotatePicCommand_t *)data; + if (!tr.registered) { + return(const void *)(cmd + 1); + } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) @@ -1874,6 +1880,9 @@ static const void *RB_RotatePic2 ( const void *data ) shader_t *shader; cmd = (const rotatePicCommand_t *)data; + if (!tr.registered) { + return(const void *)(cmd + 1); + } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d0c227b43f..c259922504 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2544,11 +2544,9 @@ typedef struct trGlobals_s { FBO_t *fbos[MAX_FBOS]; int numVBOs; - unsigned int vboNames[MAX_VBOS]; VBO_t *vbos[MAX_VBOS]; int numIBOs; - unsigned int iboNames[MAX_IBOS]; IBO_t *ibos[MAX_IBOS]; #ifdef _G2_GORE @@ -3417,7 +3415,7 @@ RENDERER BACK END COMMAND QUEUE ============================================================= */ -#define MAX_RENDER_COMMANDS 0x40000 +#define MAX_RENDER_COMMANDS 0x80000 typedef struct renderCommandList_s { byte cmds[MAX_RENDER_COMMANDS]; From b071edfef5b402d7be364df1c79453c526c0fd28 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 03:21:57 +0100 Subject: [PATCH 638/708] Reset write offsets when rendering a frame fails --- codemp/rd-rend2/tr_cmds.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 3787c42686..8666afdba1 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -493,6 +493,15 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // FIXME: Doesn't this mean the frame will never render? qglDeleteSync( sync ); thisFrame->sync = NULL; + + thisFrame->uboWriteOffset = 0; + + thisFrame->dynamicIboCommitOffset = 0; + thisFrame->dynamicIboWriteOffset = 0; + + thisFrame->dynamicVboCommitOffset = 0; + thisFrame->dynamicVboWriteOffset = 0; + backEndData->perFrameMemory->Reset(); ri.Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); From be41229f1462b9169912c30b01256d728d564df8 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:07:42 +0100 Subject: [PATCH 639/708] Don't try to create surface sprite vbos when not needed --- codemp/rd-rend2/tr_bsp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 86eb5267d1..eee83da149 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -4049,6 +4049,9 @@ static void R_GenerateSurfaceSprites( const world_t *world ) } } + if (sprites_data.size() == 0) + return; + VBO_t *vbo = R_CreateVBO((byte *)sprites_data.data(), sizeof(sprite_t) * sprites_data.size(), VBO_USAGE_STATIC); From 40f8dc1031c757da5dec9d9d0c8d159bd33235fd Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 19:13:25 +0100 Subject: [PATCH 640/708] Make sure there are cubemaps for every map --- codemp/rd-rend2/tr_bsp.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index eee83da149..8243bd594e 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3132,7 +3132,7 @@ void R_LoadEnvironmentJson(const char *baseName) ri.FS_FreeFile(buffer.v); } -void R_LoadCubemapEntities(char *cubemapEntityName) +void R_LoadCubemapEntities(const char *cubemapEntityName) { char spawnVarChars[2048]; int numSpawnVars; @@ -4175,15 +4175,25 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) // Try loading an env.json file first R_LoadEnvironmentJson(worldData->baseName); - if (!tr.numCubemaps) + const int numCubemapEntities = 5; + const char *cubemapEntities[numCubemapEntities] = { - R_LoadCubemapEntities("misc_cubemap"); - } + "misc_cubemap", + "info_player_deathmatch", + "info_player_start", + "info_player_duel", + "info_player_intermission", + }; if (!tr.numCubemaps) { - // use deathmatch spawn points as cubemaps - R_LoadCubemapEntities("info_player_deathmatch"); + for (int i = 0; i < numCubemapEntities; i++) + { + R_LoadCubemapEntities(cubemapEntities[i]); + if (tr.numCubemaps) + break; + } + } if (tr.numCubemaps) From 57bf7d32860f73df8c97cc075a9de59de93b5512 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 22 Mar 2023 21:23:39 +0100 Subject: [PATCH 641/708] Add back r_drawfog --- codemp/rd-rend2/tr_glsl.cpp | 3 ++- codemp/rd-rend2/tr_init.cpp | 2 ++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_surface.cpp | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 3cfa51e3fe..d4686af69d 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -2650,7 +2650,8 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) } if (tess.fogNum && - pStage->adjustColorsForFog != ACFF_NONE) + pStage->adjustColorsForFog != ACFF_NONE && + r_drawfog->integer) shaderAttribs |= GENERICDEF_USE_FOG; if (pStage->bundle[0].tcGen != TCGEN_TEXTURE) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 32ac4abbde..cfd717ec12 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -82,6 +82,7 @@ cvar_t *r_autolodscalevalue; cvar_t *r_norefresh; cvar_t *r_drawentities; cvar_t *r_drawworld; +cvar_t *r_drawfog; cvar_t *r_speeds; cvar_t *r_fullbright; cvar_t *r_novis; @@ -1574,6 +1575,7 @@ void R_Register( void ) r_nocurves = ri.Cvar_Get ("r_nocurves", "0", CVAR_CHEAT, "" ); r_drawworld = ri.Cvar_Get ("r_drawworld", "1", CVAR_CHEAT, "" ); + r_drawfog = ri.Cvar_Get("r_drawfog", "2", CVAR_CHEAT, ""); r_lightmap = ri.Cvar_Get ("r_lightmap", "0", 0, "" ); r_portalOnly = ri.Cvar_Get ("r_portalOnly", "0", CVAR_CHEAT, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c259922504..bba563f167 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -107,6 +107,7 @@ extern cvar_t *r_autolodscalevalue; extern cvar_t *r_norefresh; extern cvar_t *r_drawentities; extern cvar_t *r_drawworld; +extern cvar_t *r_drawfog; extern cvar_t *r_speeds; extern cvar_t *r_fullbright; extern cvar_t *r_novis; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 0e5c6048cd..daeb3b63a3 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1892,7 +1892,7 @@ void RB_StageIteratorGeneric( void ) { fog = tr.world->fogs + input->fogNum; } - if (fog && tess.shader->fogPass) + if (fog && tess.shader->fogPass && r_drawfog->integer) RB_FogPass(input, &vertexArrays); // diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 5265438664..8fa6163420 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2173,7 +2173,7 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) if ((firstStage->stateBits & (GLS_SRCBLEND_BITS|GLS_DSTBLEND_BITS)) == (GLS_SRCBLEND_ONE|GLS_DSTBLEND_ONE)) shaderFlags |= SSDEF_ADDITIVE; - if (surf->fogIndex > 0) + if (surf->fogIndex > 0 && r_drawfog->integer) shaderFlags |= SSDEF_USE_FOG; shaderProgram_t *program = programGroup + shaderFlags; From 7d88a2a3ebedce998699a30aa722ae3a3a9053de Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 23 Mar 2023 02:35:14 +0100 Subject: [PATCH 642/708] Rework shutdown sequence First issue all pending render commands, then make sure all frames are synced, delete sync objects, then all buffers. --- codemp/rd-rend2/tr_init.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index cfd717ec12..2371c98688 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1816,6 +1816,23 @@ static void R_ShutdownBackEndFrameData() { gpuFrame_t *frame = backEndData->frames + i; + if (frame->sync) + { + GLenum result = qglClientWaitSync(frame->sync, 0, 0); + if (result != GL_ALREADY_SIGNALED) + { + static const GLuint64 HALF_SECOND = 500 * 1000 * 1000; + do + { + result = qglClientWaitSync(frame->sync, GL_SYNC_FLUSH_COMMANDS_BIT, HALF_SECOND); + if (result == GL_WAIT_FAILED) + break; + } while (result != GL_ALREADY_SIGNALED && result != GL_CONDITION_SATISFIED); + } + qglDeleteSync(frame->sync); + frame->sync = NULL; + } + qglDeleteBuffers(1, &frame->ubo); if ( glRefConfig.immutableBuffers ) @@ -1970,13 +1987,15 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { for ( size_t i = 0; i < numCommands; i++ ) ri.Cmd_RemoveCommand( commands[i].cmd ); + if (tr.registered) + R_IssuePendingRenderCommands(); + R_ShutdownBackEndFrameData(); R_ShutdownWeatherSystem(); R_ShutdownFonts(); if ( tr.registered ) { - R_IssuePendingRenderCommands(); R_ShutDownQueries(); FBO_Shutdown(); R_DeleteTextures(); From f8da494d16adbcca48128fd8ac0410e35054814b Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 25 Mar 2023 19:59:43 +0100 Subject: [PATCH 643/708] Some more work on sync handling --- codemp/rd-rend2/tr_backend.cpp | 9 --------- codemp/rd-rend2/tr_cmds.cpp | 4 ++-- codemp/rd-rend2/tr_init.cpp | 17 ++++------------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index f7a5f29063..e2c9419b16 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1698,9 +1698,6 @@ static const void *RB_StretchPic ( const void *data ) { shader_t *shader; cmd = (const stretchPicCommand_t *)data; - if (!tr.registered) { - return(const void *)(cmd + 1); - } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) @@ -1784,9 +1781,6 @@ static const void *RB_RotatePic ( const void *data ) shader_t *shader; cmd = (const rotatePicCommand_t *)data; - if (!tr.registered) { - return(const void *)(cmd + 1); - } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) @@ -1880,9 +1874,6 @@ static const void *RB_RotatePic2 ( const void *data ) shader_t *shader; cmd = (const rotatePicCommand_t *)data; - if (!tr.registered) { - return(const void *)(cmd + 1); - } // FIXME: HUGE hack if (!tr.renderFbo || backEnd.framePostProcessed) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 8666afdba1..259d5d11f2 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -490,7 +490,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { result = qglClientWaitSync( sync, GL_SYNC_FLUSH_COMMANDS_BIT, HALF_SECOND); if ( result == GL_WAIT_FAILED ) { - // FIXME: Doesn't this mean the frame will never render? + // This indicates that opengl context was lost, is there a way to recover? qglDeleteSync( sync ); thisFrame->sync = NULL; @@ -504,7 +504,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { backEndData->perFrameMemory->Reset(); - ri.Printf( PRINT_DEVELOPER, S_COLOR_RED "OpenGL: Failed to wait for frame to finish! Aborting frame.\n" ); + ri.Error(ERR_DROP, "OpenGL: Failed to wait for fence. Context lost. (0x%x)\n", qglGetError()); return; } } diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 2371c98688..940618bac6 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1818,17 +1818,6 @@ static void R_ShutdownBackEndFrameData() if (frame->sync) { - GLenum result = qglClientWaitSync(frame->sync, 0, 0); - if (result != GL_ALREADY_SIGNALED) - { - static const GLuint64 HALF_SECOND = 500 * 1000 * 1000; - do - { - result = qglClientWaitSync(frame->sync, GL_SYNC_FLUSH_COMMANDS_BIT, HALF_SECOND); - if (result == GL_WAIT_FAILED) - break; - } while (result != GL_ALREADY_SIGNALED && result != GL_CONDITION_SATISFIED); - } qglDeleteSync(frame->sync); frame->sync = NULL; } @@ -1987,8 +1976,10 @@ void RE_Shutdown( qboolean destroyWindow, qboolean restarting ) { for ( size_t i = 0; i < numCommands; i++ ) ri.Cmd_RemoveCommand( commands[i].cmd ); - if (tr.registered) - R_IssuePendingRenderCommands(); + // Flush here to make sure all the fences are processed + qglFlush(); + + R_IssuePendingRenderCommands(); R_ShutdownBackEndFrameData(); From a0dd4e66d806d50c017ca234393dd838ee0425d8 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 26 Mar 2023 03:48:46 +0200 Subject: [PATCH 644/708] Apply OpenJK vanilla renderer commit to rend2 see: https://github.com/JACoders/OpenJK/commit/f5ab5fab2bc462cd47bbc3e4ab766aab2798d558#diff-fec1078887b3364b0640ddb72c64313c5403db9122dd51bb1466eebeb76ef647 --- codemp/rd-rend2/tr_cmds.cpp | 45 +++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 259d5d11f2..f9873ff619 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -181,15 +181,15 @@ R_GetCommandBuffer make sure there is enough command space ============ */ -void *R_GetCommandBuffer( int bytes ) { +static void *R_GetCommandBufferReserved( int bytes, int reservedBytes ) { renderCommandList_t *cmdList; cmdList = &backEndData->commands; bytes = PAD(bytes, sizeof(void *)); // always leave room for the end of list command - if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) { - if ( bytes > MAX_RENDER_COMMANDS - 4 ) { + if ( cmdList->used + bytes + sizeof(int) + reservedBytes > MAX_RENDER_COMMANDS ) { + if ( bytes > MAX_RENDER_COMMANDS - (int)sizeof(int)) { ri.Error( ERR_FATAL, "R_GetCommandBuffer: bad size %i", bytes ); } // if we run out of room, just start dropping commands @@ -201,6 +201,16 @@ void *R_GetCommandBuffer( int bytes ) { return cmdList->cmds + cmdList->used - bytes; } +/* +============ +R_GetCommandBuffer +make sure there is enough command space +============ +*/ +void *R_GetCommandBuffer(int bytes) { + return R_GetCommandBufferReserved(bytes, PAD(sizeof(swapBuffersCommand_t), sizeof(void *))); +} + /* ============= @@ -211,6 +221,9 @@ R_AddDrawSurfCmd void R_AddDrawSurfCmd( drawSurf_t *drawSurfs, int numDrawSurfs ) { drawSurfsCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (drawSurfsCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -233,6 +246,9 @@ R_AddConvolveCubemapsCmd void R_AddConvolveCubemapCmd( cubemap_t *cubemap , int cubemapId ) { convolveCubemapCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (convolveCubemapCommand_t *)R_GetCommandBuffer( sizeof( *cmd )); if ( !cmd ) { return; @@ -252,6 +268,9 @@ R_PostProcessingCmd void R_AddPostProcessCmd( ) { postProcessCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (postProcessCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -266,6 +285,9 @@ qhandle_t R_BeginTimedBlockCmd( const char *name ) { beginTimedBlockCommand_t *cmd; + if (!tr.registered) { + return (qhandle_t)-1; + } cmd = (beginTimedBlockCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { @@ -288,6 +310,9 @@ void R_EndTimedBlockCmd( qhandle_t timerHandle ) { endTimedBlockCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (endTimedBlockCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { @@ -313,9 +338,9 @@ Passing NULL will set the color to white void RE_SetColor( const float *rgba ) { setColorCommand_t *cmd; - if ( !tr.registered ) { - return; - } + if ( !tr.registered ) { + return; + } cmd = (setColorCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -342,6 +367,9 @@ void RE_RotatePic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { rotatePicCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (rotatePicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -368,6 +396,9 @@ void RE_RotatePic2 ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ) { rotatePicCommand_t *cmd; + if (!tr.registered) { + return; + } cmd = (rotatePicCommand_t *) R_GetCommandBuffer( sizeof( *cmd ) ); if ( !cmd ) { return; @@ -725,7 +756,7 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) { if ( !tr.registered ) { return; } - cmd = (swapBuffersCommand_t *)R_GetCommandBuffer( sizeof( *cmd ) ); + cmd = (swapBuffersCommand_t *)R_GetCommandBufferReserved( sizeof( *cmd ), 0 ); if ( !cmd ) { return; } From 8aada3d9fc81df4b46359d99d5a6c935a885f51f Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 30 Mar 2023 10:36:18 +0200 Subject: [PATCH 645/708] Add loading default external deluxemaps --- codemp/rd-rend2/tr_bsp.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 8243bd594e..27aa31cfc4 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -559,7 +559,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { 0); } } - else if (r_deluxeMapping->integer && !tr.worldDeluxeMapping && !r_mergeLightmaps->integer) + else if (r_deluxeMapping->integer && !r_mergeLightmaps->integer) { char filename[MAX_QPATH]; byte *externalLightmap = NULL; @@ -567,7 +567,11 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { int lightmapHeight = tr.lightmapSize; // try loading additional deluxemaps - Com_sprintf(filename, sizeof(filename), "maps/%s/dm_%04d.tga", worldData->baseName, i); + if (tr.worldDeluxeMapping) + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.tga", worldData->baseName, i * 2 + 1); + else + Com_sprintf(filename, sizeof(filename), "maps/%s/dm_%04d.tga", worldData->baseName, i); + R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); if (!externalLightmap) continue; From 1870d6ab3a7371e120451e0594b51c6afa9f2e6b Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 30 Mar 2023 10:52:44 +0200 Subject: [PATCH 646/708] Some lightall cleanup --- codemp/rd-rend2/glsl/lightall.glsl | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index fcf937fa86..1c6156dba5 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -194,15 +194,6 @@ vec2 ModTexCoords(vec2 st, vec3 position, vec4 texMatrix, vec4 offTurb) } #endif - -float CalcLightAttenuation(in bool isPoint, float normDist) -{ - // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = 1.0 + mix(0.0, 0.5 * normDist - 1.5, isPoint); - return clamp(attenuation, 0.0, 1.0); -} - #if defined(USE_SKELETAL_ANIMATION) mat4x3 GetBoneMatrix(uint index) { @@ -299,10 +290,9 @@ void main() #if defined(USE_LIGHT_VECTOR) && defined(USE_FAST_LIGHT) float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(u_LocalLightOrigin.w, u_LightRadius * u_LightRadius / sqrLightDist); float NL = clamp(dot(normal, L) / sqrt(sqrLightDist), 0.0, 1.0); - var_Color.rgb *= u_DirectedLight * (attenuation * NL) + u_AmbientLight; + var_Color.rgb *= u_DirectedLight * NL + u_AmbientLight; #endif } var_Color *= disintegration; @@ -670,11 +660,10 @@ vec3 CalcDiffuse( #endif } -float CalcLightAttenuation(float point, float normDist) +float CalcLightAttenuation(float normDist) { // zero light at 1.0, approximating q3 style - // also don't attenuate directional light - float attenuation = (0.5 * normDist - 1.5) * point + 1.0; + float attenuation = 0.5 * normDist - 0.5; return clamp(attenuation, 0.0, 1.0); } @@ -779,7 +768,7 @@ vec3 CalcDynamicLightContribution( vec3 L = light.origin.xyz - position; float sqrLightDist = dot(L, L); - float attenuation = CalcLightAttenuation(1.0, light.radius * light.radius / sqrLightDist); + float attenuation = CalcLightAttenuation(light.radius * light.radius / sqrLightDist); #if defined(USE_DSHADOWS) vec3 sampleVector = L; From 1632b6fa75e48ea49344cdb12d578cebe04e6fcb Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 30 Mar 2023 11:00:35 +0200 Subject: [PATCH 647/708] Temporary AMD fix --- codemp/rd-rend2/glsl/lightall.glsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 1c6156dba5..6d031e57bf 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -758,7 +758,8 @@ vec3 CalcDynamicLightContribution( { vec3 outColor = vec3(0.0); vec3 position = viewOrigin - viewDir; - for ( int i = 0; i < u_NumLights; i++ ) + // FIX ME: Make sure a proper UBO is bound instead of using min here! + for ( int i = 0; i < min(u_NumLights, 32); i++ ) { if ( ( u_LightMask & ( 1 << i ) ) == 0 ) { continue; From 65136ccab3d0b84ece7a418a968212250a33909d Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:17:55 +0200 Subject: [PATCH 648/708] Fix bad auto exposure --- codemp/rd-rend2/tr_postprocess.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index a39b4a221b..0eadfadbe7 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -30,13 +30,13 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in if (autoExposure) { - if (lastFrameCount == 0 || tr.frameCount < lastFrameCount || tr.frameCount - lastFrameCount > 5) + if (true) { // determine average log luminance FBO_t *srcFbo, *dstFbo, *tmp; int size = 256; - lastFrameCount = tr.frameCount; + lastFrameCount = backEndData->realFrameNumber; VectorSet4(dstBox, 0, 0, size, size); @@ -69,7 +69,7 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in color[0] = color[1] = color[2] = 1.0f; - color[3] = 0.001f * backEnd.refdef.frameTime; + color[3] = MAX(0.001f * backEnd.refdef.frameTime, 0.0f); FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } From 6275c707182364c34fa668d521c499771e1f3bae Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:19:44 +0200 Subject: [PATCH 649/708] Fix bad auto exposure pt2 Uploaded other unwanted changes -.- --- codemp/rd-rend2/tr_postprocess.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 0eadfadbe7..8ef766e839 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -30,13 +30,13 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in if (autoExposure) { - if (true) + if (lastFrameCount == 0 || tr.frameCount < lastFrameCount || tr.frameCount - lastFrameCount > 5) { // determine average log luminance FBO_t *srcFbo, *dstFbo, *tmp; int size = 256; - lastFrameCount = backEndData->realFrameNumber; + lastFrameCount = tr.frameCount; VectorSet4(dstBox, 0, 0, size, size); From 06b250d8982f4b6ffdbfc9ba802bc1d9745ae4b0 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Mon, 3 Apr 2023 17:23:19 +0200 Subject: [PATCH 650/708] Don't add weather surfaces when theres no world --- codemp/rd-rend2/tr_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 35efdcf243..5e42333955 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2049,7 +2049,7 @@ void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { R_AddEntitySurfaces(refdef); - if ( !(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) ) + if ( !(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) && tr.world) { R_AddWeatherSurfaces(); } From 2aa0682baab66e57556b11a8c0607f2eb5f7369e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 4 Apr 2023 00:12:36 +0200 Subject: [PATCH 651/708] Correctly load all lightmaps with external deluxemaps --- codemp/rd-rend2/tr_bsp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 27aa31cfc4..c93ed1063b 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -249,6 +249,8 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } } } + if (tr.worldDeluxeMapping == qtrue && (!len)) + numLightmaps++; } imageSize = tr.lightmapSize * tr.lightmapSize * 4 * 2; From 03bef72868b50361b93e69fa054d25a1bb9c832a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 4 Apr 2023 01:18:37 +0200 Subject: [PATCH 652/708] Fix in-game menu model rendering When I added refraction rendering, I missed that rendering these menu models happen after the frame has been post-processed. Since most of them don't use a refraction shader, the guard clause simply rejected those. --- codemp/rd-rend2/tr_backend.cpp | 6 ++++-- codemp/rd-rend2/tr_local.h | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e2c9419b16..c79ce8d300 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1349,7 +1349,7 @@ static void RB_SubmitDrawSurfs( cubemapIndex == oldCubemapIndex && entityNum == oldEntityNum && dlighted == oldDlighted && - backEnd.framePostProcessed == shader->useDistortion ) + backEnd.refractionFill == shader->useDistortion ) { // fast path, same as previous sort backEnd.currentDrawSurfIndex = i; @@ -1393,7 +1393,7 @@ static void RB_SubmitDrawSurfs( qboolean isDistortionShader = (qboolean) ((shader->useDistortion == qtrue) || (backEnd.currentEntity && backEnd.currentEntity->e.renderfx & RF_DISTORTION)); - if (backEnd.framePostProcessed != isDistortionShader) + if (backEnd.refractionFill != isDistortionShader) continue; backEnd.currentDrawSurfIndex = i; @@ -3273,9 +3273,11 @@ const void *RB_PostProcess(const void *data) backEnd.framePostProcessed = qtrue; FBO_Bind(NULL); + backEnd.refractionFill = qtrue; RB_RenderDrawSurfList( backEnd.refdef.drawSurfs + backEnd.refdef.fistDrawSurf, backEnd.refdef.numDrawSurfs - tr.refdef.fistDrawSurf); + backEnd.refractionFill = qfalse; return (const void *)(cmd + 1); } diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index bba563f167..d79830c2fb 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2326,6 +2326,7 @@ typedef struct { qboolean colorMask[4]; qboolean framePostProcessed; qboolean depthFill; + qboolean refractionFill; qboolean frameUBOsInitialized; } backEndState_t; From ff0d50ff2c4587e05426cf9c034fa03e2ba34bd5 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 4 Apr 2023 01:26:59 +0200 Subject: [PATCH 653/708] Fix dark menu models when r_ssao 1 --- codemp/rd-rend2/tr_shade.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index daeb3b63a3..178c7431f7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1660,8 +1660,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SPECULARMAP); } - if (r_ssao->integer) + if (r_ssao->integer && tr.world && backEnd.framePostProcessed == qfalse) samplerBindingsWriter.AddStaticImage(tr.screenSsaoImage, TB_SSAOMAP); + else if (r_ssao->integer) + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SSAOMAP); + } if ( enableCubeMaps ) From fc0d4eaf18ebf5abf7bcbc4f310bf3b52c8b9057 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 4 Apr 2023 01:44:53 +0200 Subject: [PATCH 654/708] Just do this properly... --- codemp/rd-rend2/tr_postprocess.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_postprocess.cpp b/codemp/rd-rend2/tr_postprocess.cpp index 8ef766e839..9502cb50e7 100644 --- a/codemp/rd-rend2/tr_postprocess.cpp +++ b/codemp/rd-rend2/tr_postprocess.cpp @@ -69,8 +69,8 @@ void RB_ToneMap(FBO_t *hdrFbo, vec4i_t hdrBox, FBO_t *ldrFbo, vec4i_t ldrBox, in color[0] = color[1] = color[2] = 1.0f; - color[3] = MAX(0.001f * backEnd.refdef.frameTime, 0.0f); + color[3] = Com_Clamp(0.0f, 1.0f, 0.001f * backEnd.refdef.frameTime); FBO_Blit(tr.targetLevelsFbo, srcBox, NULL, tr.calcLevelsFbo, NULL, NULL, color, GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA); } From 1bca5885dfa3ed39b68efc5a9522215e1c532cf8 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 4 Apr 2023 02:03:34 +0200 Subject: [PATCH 655/708] Make sure weather system is initialized properly --- codemp/rd-rend2/tr_weather.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 2607bf11f6..e3e0087b72 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -441,6 +441,9 @@ void R_InitWeatherSystem() tr.weatherSystem->activeWeatherTypes = 0; tr.weatherSystem->constWindDirection[0] = .0f; tr.weatherSystem->constWindDirection[1] = .0f; + + for (int i = 0; i < NUM_WEATHER_TYPES; i++) + tr.weatherSystem->weatherSlots[i].active = false; } void R_ShutdownWeatherSystem() From bb5ef7f7d6eb9f0f92195b849c4eba2357c08ff2 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 16 Apr 2023 18:52:32 +0200 Subject: [PATCH 656/708] Fix flickering in loading screen when cubemaps are enabled. --- codemp/rd-rend2/tr_bsp.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index c93ed1063b..5b624238cd 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3269,7 +3269,17 @@ static void R_RenderAllCubemaps() RE_ClearScene(); R_AddConvolveCubemapCmd(&tr.cubemaps[i], i); R_IssuePendingRenderCommands(); - RE_EndFrame( &frontEndMsec, &backEndMsec ); + + gpuFrame_t *currentFrame = backEndData->currentFrame; + assert(!currentFrame->sync); + currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + backEndData->realFrameNumber++; + ri.WIN_Present(&window); + backEnd.framePostProcessed = qfalse; + backEnd.projection2D = qfalse; + backEnd.frameUBOsInitialized = qfalse; + R_InitNextFrame(); } } } From 517e32dc3ed1a7e80b08d0293945e24c378e5c89 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 16 Apr 2023 18:53:23 +0200 Subject: [PATCH 657/708] Don't load cubemaps for misc_bsp entities for now. Might look into also loading these later on. --- codemp/rd-rend2/tr_bsp.cpp | 3 ++- codemp/rd-rend2/tr_shade.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 5b624238cd..3ada796f3d 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3200,6 +3200,7 @@ void R_LoadCubemapEntities(const char *cubemapEntityName) Q_strncpyz(cubemap->name, name, MAX_QPATH); VectorCopy(origin, cubemap->origin); cubemap->parallaxRadius = parallaxRadius; + cubemap->image = nullptr; numCubemaps++; } } @@ -4186,7 +4187,7 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_CalcVertexLightDirs(worldData); // load cubemaps - if (r_cubeMapping->integer) + if (r_cubeMapping->integer && bspIndex == nullptr) { // Try loading an env.json file first R_LoadEnvironmentJson(worldData->baseName); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 178c7431f7..3c08b3c0c8 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1544,7 +1544,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays // bool enableCubeMaps = ( r_cubeMapping->integer && !(tr.viewParms.flags & VPF_NOCUBEMAPS) - && input->cubemapIndex + && input->cubemapIndex > 0 && pStage->rgbGen != CGEN_LIGHTMAPSTYLE ); bool enableDLights = ( tess.dlightBits && tess.shader->sort <= SS_OPAQUE From 3d86b9e794b56a51a5d99f69f6fd9808ad67f53e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 16 Apr 2023 22:13:10 +0200 Subject: [PATCH 658/708] Fix sunlights shadow glsl define --- codemp/rd-rend2/tr_glsl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index d4686af69d..65cddd02ad 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1640,7 +1640,7 @@ static int GLSL_LoadGPUProgramLightAll( extradefines[0] = '\0'; - if (r_dlightMode->integer >= 2) + if (r_sunlightMode->integer) Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); if (r_hdr->integer && !glRefConfig.floatLightmap) From 7356f06ea4339fb0a412d757e0940f7418d91c6f Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 16 Apr 2023 23:12:36 +0200 Subject: [PATCH 659/708] Fix fov aspect correction in sky portals --- codemp/cgame/cg_view.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/codemp/cgame/cg_view.c b/codemp/cgame/cg_view.c index c1b591ab1c..228024c2c5 100644 --- a/codemp/cgame/cg_view.c +++ b/codemp/cgame/cg_view.c @@ -1780,6 +1780,16 @@ void CG_DrawSkyBoxPortal(const char *cstr) } } + if (cg_fovAspectAdjust.integer) { + // Based on LordHavoc's code for Darkplaces + // http://www.quakeworld.nu/forum/topic/53/what-does-your-qw-look-like/page/30 + const float baseAspect = 0.75f; // 3/4 + const float aspect = (float)cgs.glconfig.vidWidth / (float)cgs.glconfig.vidHeight; + const float desiredFov = fov_x; + + fov_x = atan(tan(desiredFov*M_PI / 360.0f) * baseAspect*aspect)*360.0f / M_PI; + } + x = cg.refdef.width / tan( fov_x / 360 * M_PI ); fov_y = atan2( cg.refdef.height, x ); fov_y = fov_y * 360 / M_PI; From 98370903219d325b26034bfc0c92c3c05e66f40b Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 29 Apr 2023 03:01:11 +0200 Subject: [PATCH 660/708] Fix fog related crash --- codemp/rd-rend2/tr_shade.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 3c08b3c0c8..f30554be95 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1056,10 +1056,12 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v uniformDataWriterBack.Start(sp); uniformDataWriterBack.SetUniformInt(UNIFORM_FOGINDEX, tr.world->globalFogIndex - 1); if (input->numPasses > 0) + { uniformDataWriterBack.SetUniformInt(UNIFORM_ALPHA_TEST_TYPE, input->xstages[0]->alphaTestType); - SamplerBindingsWriter samplerBindingsWriter; - if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) - samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); + SamplerBindingsWriter samplerBindingsWriter; + if (input->xstages[0]->alphaTestType != ALPHA_TEST_NONE) + samplerBindingsWriter.AddStaticImage(input->xstages[0]->bundle[0].image[0], 0); + } DrawItem backItem = {}; memcpy(&backItem, &item, sizeof(item)); From 88e21293abb48c6f3865275682f83ab1503fe3da Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 29 Apr 2023 03:01:37 +0200 Subject: [PATCH 661/708] Crude fix for some glow + fog surfaces --- codemp/rd-rend2/tr_shader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 6dc4c13564..653931ed9e 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3697,7 +3697,7 @@ static shader_t *GeneratePermanentShader( void ) { if (!pStage->active) continue; - if (pStage->glow) + if (pStage->glow && stage > 0) continue; if (pStage->adjustColorsForFog != ACFF_MODULATE_ALPHA) From 05451a3d21d9fcb1fd01905d8a6b6cc9dff9bbdf Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 29 Apr 2023 03:14:06 +0200 Subject: [PATCH 662/708] Cleanup Now rend2 won't upload a model view projection matrix per entity anymore, but only the model matrix. The view projection matrix is now part of the camera ubo. --- codemp/rd-rend2/glsl/fogpass.glsl | 17 ++++- codemp/rd-rend2/glsl/generic.glsl | 7 ++- codemp/rd-rend2/glsl/lightall.glsl | 9 ++- codemp/rd-rend2/glsl/refraction.glsl | 13 ++-- codemp/rd-rend2/glsl/shadowfill.glsl | 14 ++++- codemp/rd-rend2/glsl/shadowvolume.glsl | 42 ++++++++----- codemp/rd-rend2/glsl/surface_sprites.glsl | 7 ++- codemp/rd-rend2/glsl/weather.glsl | 15 +++-- codemp/rd-rend2/glsl/weatherUpdate.glsl | 17 +++-- codemp/rd-rend2/tr_backend.cpp | 77 +++-------------------- codemp/rd-rend2/tr_init.cpp | 49 ++++++++++----- codemp/rd-rend2/tr_local.h | 7 ++- codemp/rd-rend2/tr_shade.cpp | 39 ++++++++++-- codemp/rd-rend2/tr_weather.cpp | 21 +++++-- 14 files changed, 193 insertions(+), 141 deletions(-) diff --git a/codemp/rd-rend2/glsl/fogpass.glsl b/codemp/rd-rend2/glsl/fogpass.glsl index bda61c4bf0..57dcf0ac87 100644 --- a/codemp/rd-rend2/glsl/fogpass.glsl +++ b/codemp/rd-rend2/glsl/fogpass.glsl @@ -12,10 +12,19 @@ in uvec4 attr_BoneIndexes; in vec4 attr_BoneWeights; #endif +layout(std140) uniform Camera +{ + mat4 u_viewProjectionMatrix; + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -217,7 +226,8 @@ void main() normal = DeformNormal( position, normal ); #endif - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + gl_Position = MVP * vec4(position, 1.0); var_WSPosition = (u_ModelMatrix * vec4(position, 1.0)).xyz; #if defined(USE_ALPHA_TEST) @@ -239,6 +249,7 @@ layout(std140) uniform Scene vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; float u_frameTime; + float u_deltaTime; }; struct Fog @@ -257,6 +268,7 @@ layout(std140) uniform Fogs layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -267,7 +279,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 3e07fe85e1..1c669a067f 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -19,6 +19,7 @@ in vec2 attr_TexCoord1; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -29,7 +30,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -383,7 +383,8 @@ void main() normal = DeformNormal( position, normal ); #endif - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + gl_Position = MVP * vec4(position, 1.0); #if defined(USE_TCGEN) vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); @@ -440,6 +441,7 @@ uniform vec4 u_FogColorMask; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -450,7 +452,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 6d031e57bf..e9c0475c8b 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -32,6 +32,7 @@ in vec3 attr_LightDirection; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -42,7 +43,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -255,7 +255,8 @@ void main() vec4 disintegration = CalcColor(position); - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + gl_Position = MVP * vec4(position, 1.0); position = (u_ModelMatrix * vec4(position, 1.0)).xyz; normal = normalize(mat3(u_ModelMatrix) * normal); @@ -322,6 +323,7 @@ void main() #if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT) #define PER_PIXEL_LIGHTING #endif + layout(std140) uniform Scene { vec4 u_PrimaryLightOrigin; @@ -330,10 +332,12 @@ layout(std140) uniform Scene vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; float u_frameTime; + float u_deltaTime; }; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -344,7 +348,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; diff --git a/codemp/rd-rend2/glsl/refraction.glsl b/codemp/rd-rend2/glsl/refraction.glsl index 04a833de79..e2e1327b7d 100644 --- a/codemp/rd-rend2/glsl/refraction.glsl +++ b/codemp/rd-rend2/glsl/refraction.glsl @@ -19,6 +19,7 @@ in vec2 attr_TexCoord1; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -29,7 +30,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -323,7 +323,8 @@ void main() normal = DeformNormal( position, normal ); #endif - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + gl_Position = MVP * vec4(position, 1.0); #if defined(USE_TCGEN) vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1); @@ -370,17 +371,17 @@ void main() vec3 refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaR)); vec3 new_pos = (distance * refraction_vec) + ws_Position; var_RefractPosR = vec4(inverseModel * new_pos, 1.0); - var_RefractPosR = u_ModelViewProjectionMatrix * var_RefractPosR; + var_RefractPosR = MVP * var_RefractPosR; refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaG)); new_pos = (distance * refraction_vec) + ws_Position; var_RefractPosG = vec4(inverseModel * new_pos, 1.0); - var_RefractPosG = u_ModelViewProjectionMatrix * var_RefractPosG; + var_RefractPosG = MVP * var_RefractPosG; refraction_vec = normalize(refract(ws_ViewDir, ws_Normal, etaB)); new_pos = (distance * refraction_vec) + ws_Position; var_RefractPosB = vec4(inverseModel * new_pos, 1.0); - var_RefractPosB = u_ModelViewProjectionMatrix * var_RefractPosB; + var_RefractPosB = MVP * var_RefractPosB; } @@ -388,6 +389,7 @@ void main() layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -398,7 +400,6 @@ layout(std140) uniform Camera layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index e9ec08eea8..c9a1081f69 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -6,10 +6,19 @@ in vec4 attr_TexCoord0; in vec3 attr_Position2; in vec3 attr_Normal2; +layout(std140) uniform Camera +{ + mat4 u_viewProjectionMatrix; + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -167,7 +176,8 @@ void main() normal = normalize(normal - vec3(0.5)); position = DeformPosition(position, normal, attr_TexCoord0.st); - gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0); + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + gl_Position = MVP * vec4(position, 1.0); } /*[Fragment]*/ diff --git a/codemp/rd-rend2/glsl/shadowvolume.glsl b/codemp/rd-rend2/glsl/shadowvolume.glsl index ccd2cbf2db..e0a1dcbb03 100644 --- a/codemp/rd-rend2/glsl/shadowvolume.glsl +++ b/codemp/rd-rend2/glsl/shadowvolume.glsl @@ -10,7 +10,6 @@ in vec4 attr_BoneWeights; layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -62,10 +61,19 @@ void main() layout(triangles) in; layout(triangle_strip, max_vertices = 18) out; +layout(std140) uniform Camera +{ + mat4 u_viewProjectionMatrix; + vec4 u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + layout(std140) uniform Entity { mat4 u_ModelMatrix; - mat4 u_ModelViewProjectionMatrix; vec4 u_LocalLightOrigin; vec3 u_AmbientLight; float u_LocalLightRadius; @@ -78,15 +86,15 @@ layout(std140) uniform Entity in vec3 var_Position[]; -void quad(vec3 first, vec3 second, vec3 L) +void quad(in vec3 first, in vec3 second, in vec3 L, in mat4 MVP) { - gl_Position = u_ModelViewProjectionMatrix * vec4(first, 1.0); + gl_Position = MVP * vec4(first, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(first - L, 1.0); + gl_Position = MVP * vec4(first - L, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(second, 1.0); + gl_Position = MVP * vec4(second, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(second - L, 1.0); + gl_Position = MVP * vec4(second - L, 1.0); EmitVertex(); EndPrimitive(); } @@ -96,29 +104,31 @@ void main() vec3 BmA = var_Position[1].xyz - var_Position[0].xyz; vec3 CmA = var_Position[2].xyz - var_Position[0].xyz; + mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; + if (dot(cross(BmA,CmA), -u_ModelLightDir.xyz) > 0.0) { vec3 L = u_ModelLightDir.xyz*u_LocalLightRadius; // front cap - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[0].xyz, 1.0); + gl_Position = MVP * vec4(var_Position[0].xyz, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[1].xyz, 1.0); + gl_Position = MVP * vec4(var_Position[1].xyz, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[2].xyz, 1.0); + gl_Position = MVP * vec4(var_Position[2].xyz, 1.0); EmitVertex(); EndPrimitive(); // sides - quad(var_Position[0], var_Position[1], L); - quad(var_Position[1], var_Position[2], L); - quad(var_Position[2], var_Position[0], L); + quad(var_Position[0], var_Position[1], L, MVP); + quad(var_Position[1], var_Position[2], L, MVP); + quad(var_Position[2], var_Position[0], L, MVP); // back cap - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[2].xyz - L, 1.0); + gl_Position = MVP * vec4(var_Position[2].xyz - L, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[1].xyz - L, 1.0); + gl_Position = MVP * vec4(var_Position[1].xyz - L, 1.0); EmitVertex(); - gl_Position = u_ModelViewProjectionMatrix * vec4(var_Position[0].xyz - L, 1.0); + gl_Position = MVP * vec4(var_Position[0].xyz - L, 1.0); EmitVertex(); EndPrimitive(); } diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 7731ad44f4..904809a33e 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -4,8 +4,6 @@ in vec3 attr_Normal; in vec3 attr_Color; in vec4 attr_Position2; // width, height, skew.x, skew.y -uniform mat4 u_ModelViewProjectionMatrix; - layout(std140) uniform Scene { vec4 u_PrimaryLightOrigin; @@ -14,10 +12,12 @@ layout(std140) uniform Scene vec3 u_PrimaryLightColor; float u_PrimaryLightRadius; float u_frameTime; + float u_deltaTime; }; layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; @@ -115,7 +115,7 @@ void main() #endif vec4 worldPos = vec4(attr_Position.xyz + offset, 1.0); - gl_Position = u_ModelViewProjectionMatrix * worldPos; + gl_Position = u_viewProjectionMatrix * worldPos; var_TexCoords = texcoords[gl_VertexID % 4]; var_Color = attr_Color; var_Alpha = 1.0 - fadeScale; @@ -155,6 +155,7 @@ layout(std140) uniform SurfaceSprite #if defined(USE_FOG) layout(std140) uniform Camera { + mat4 u_viewProjectionMatrix; vec4 u_ViewInfo; vec3 u_ViewOrigin; vec3 u_ViewForward; diff --git a/codemp/rd-rend2/glsl/weather.glsl b/codemp/rd-rend2/glsl/weather.glsl index 993ae8b704..0c6eef6372 100644 --- a/codemp/rd-rend2/glsl/weather.glsl +++ b/codemp/rd-rend2/glsl/weather.glsl @@ -42,9 +42,16 @@ void main() layout(points) in; layout(triangle_strip, max_vertices = 4) out; -uniform mat4 u_ModelViewProjectionMatrix; -uniform vec3 u_ViewOrigin; -uniform float u_Time; // delta time +layout(std140) uniform Camera +{ + mat4 u_viewProjectionMatrix; + vec4 _u_ViewInfo; + vec3 u_ViewOrigin; + vec3 u_ViewForward; + vec3 u_ViewLeft; + vec3 u_ViewUp; +}; + uniform vec4 u_ViewInfo; in vec3 var_Velocity[]; @@ -79,7 +86,7 @@ void main() if (var_Velocity[0].z != 0.0) offset.xy += offset.z * var_Velocity[0].xy / var_Velocity[0].z; vec4 worldPos = vec4(P + offset, 1.0); - gl_Position = u_ModelViewProjectionMatrix * worldPos; + gl_Position = u_viewProjectionMatrix * worldPos; float distance = distance(u_ViewOrigin, worldPos.xyz); float alpha = (u_ViewInfo.w - distance) / u_ViewInfo.w; diff --git a/codemp/rd-rend2/glsl/weatherUpdate.glsl b/codemp/rd-rend2/glsl/weatherUpdate.glsl index 9bf4f5f2fc..677cfdf6d5 100644 --- a/codemp/rd-rend2/glsl/weatherUpdate.glsl +++ b/codemp/rd-rend2/glsl/weatherUpdate.glsl @@ -1,13 +1,22 @@ /*[Vertex]*/ -uniform float u_Time; // delta time +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; + float u_frameTime; + float u_deltaTime; +}; + uniform vec2 u_MapZExtents; uniform vec3 u_EnvForce; uniform vec4 u_RandomOffset; uniform vec2 u_ZoneOffset[9]; uniform int u_ChunkParticles; - in vec3 attr_Position; in vec3 attr_Color; @@ -30,9 +39,9 @@ vec3 NewParticleZPosition( in vec3 in_position ) void main() { var_Velocity = attr_Color; - var_Velocity = mix(var_Velocity, u_EnvForce, u_Time * 0.002); + var_Velocity = mix(var_Velocity, u_EnvForce, u_deltaTime * 0.002); var_Position = attr_Position; - var_Position += var_Velocity * u_Time; + var_Position += var_Velocity * u_deltaTime; if (var_Position.z < u_MapZExtents.x) { diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index c79ce8d300..e382d6e3b2 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1174,14 +1174,6 @@ static void RB_PrepareForEntity( int entityNum, int *oldDepthRange, float origin if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; - // we have to reset the shaderTime as well otherwise image animations start - // from the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; - - // set up the transformation matrix - R_RotateForEntity( backEnd.currentEntity, &backEnd.viewParms, &backEnd.ori ); - if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { // No depth at all, very rare but some things for seeing through walls depthRange = 2; @@ -1192,49 +1184,12 @@ static void RB_PrepareForEntity( int entityNum, int *oldDepthRange, float origin } } else { backEnd.currentEntity = &tr.worldEntity; - backEnd.refdef.floatTime = originalTime; - backEnd.ori = backEnd.viewParms.world; - - // we have to reset the shaderTime as well otherwise image animations on - // the world (like water) continue with the wrong frame - tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; } - GL_SetModelviewMatrix( backEnd.ori.modelViewMatrix ); - - // change depthrange. Also change projection matrix so first person weapon + // change depthrange // does not look like coming out of the screen. if ( *oldDepthRange != depthRange ) { - switch ( depthRange ) - { - default: - case 0: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - GL_SetProjectionMatrix(backEnd.viewParms.projectionMatrix); - } - break; - - case 1: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - - case 2: - if ( backEnd.viewParms.stereoFrame != STEREO_CENTER ) - { - viewParms_t temp = backEnd.viewParms; - R_SetupProjection(&temp, r_znear->value, 0, qfalse); - GL_SetProjectionMatrix(temp.projectionMatrix); - } - break; - } - *oldDepthRange = depthRange; } } @@ -2289,9 +2244,11 @@ static void RB_UpdateCameraConstants(gpuFrame_t *frame) const float zmax = backEnd.viewParms.zFar; const float zmin = r_znear->value; - // TODO: Add ViewProjection Matrix - CameraBlock cameraBlock = {}; + Matrix16Multiply( + backEnd.viewParms.projectionMatrix, + backEnd.viewParms.world.modelViewMatrix, + cameraBlock.viewProjectionMatrix); VectorSet4(cameraBlock.viewInfo, zmax / zmin, zmax, 0.0f, 0.0f); VectorCopy(backEnd.refdef.viewaxis[0], cameraBlock.viewForward); VectorCopy(backEnd.refdef.viewaxis[1], cameraBlock.viewLeft); @@ -2312,6 +2269,7 @@ static void RB_UpdateSceneConstants(gpuFrame_t *frame) else sceneBlock.globalFogIndex = -1; sceneBlock.currentTime = backEnd.refdef.time; + sceneBlock.frameTime = backEnd.refdef.frameTime; tr.sceneUboOffset = RB_AppendConstantsData( frame, &sceneBlock, sizeof(sceneBlock)); @@ -2414,11 +2372,6 @@ static void RB_UpdateEntityMatrixConstants( Matrix16Copy(ori.modelViewMatrix, modelViewMatrix); VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); - - Matrix16Multiply( - backEnd.viewParms.projectionMatrix, - modelViewMatrix, - entityBlock.modelViewProjectionMatrix); } static void RB_UpdateEntityModelConstants( @@ -2442,19 +2395,7 @@ static void RB_UpdateSkyEntityConstants(gpuFrame_t *frame) EntityBlock skyEntityBlock = {}; skyEntityBlock.fxVolumetricBase = -1.0f; - matrix_t translation; - Matrix16Translation(backEnd.viewParms.ori.origin, translation); - - matrix_t modelViewMatrix; - Matrix16Multiply( - backEnd.viewParms.world.modelViewMatrix, - translation, - modelViewMatrix); - Matrix16Multiply( - backEnd.viewParms.projectionMatrix, - modelViewMatrix, - skyEntityBlock.modelViewProjectionMatrix); - + Matrix16Translation(backEnd.viewParms.ori.origin, skyEntityBlock.modelMatrix); tr.skyEntityUboOffset = RB_AppendConstantsData( frame, &skyEntityBlock, sizeof(skyEntityBlock)); } @@ -2627,8 +2568,8 @@ static void RB_UpdateShaderEntityConstants( shaderInstanceBlock.portalRange = shader->portalRange; shaderInstanceBlock.time = backEnd.refdef.floatTime - shader->timeOffset; - if (entityNum == REFENTITYNUM_WORLD) - shaderInstanceBlock.time -= refEntity->e.shaderTime; + if (entityNum != REFENTITYNUM_WORLD) + shaderInstanceBlock.time = backEnd.refdef.floatTime - refEntity->e.shaderTime; const int uboOffset = RB_AppendConstantsData( frame, &shaderInstanceBlock, sizeof(shaderInstanceBlock)); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 940618bac6..f50f87f683 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1762,14 +1762,27 @@ static void R_InitGoreVao() static void R_InitStaticConstants() { - const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; - const size_t alignedBlockSize = (sizeof(EntityBlock) + alignment) & ~alignment; + size_t alignedBlockSize = 0; + + qglBindBuffer(GL_UNIFORM_BUFFER, tr.staticUbo); + qglBufferData( + GL_UNIFORM_BUFFER, + STATIC_UNIFORM_BUFFER_SIZE, + nullptr, + GL_STATIC_DRAW); + // Setup static 2d camera data EntityBlock entity2DBlock = {}; entity2DBlock.fxVolumetricBase = -1.0f; - Matrix16Identity(entity2DBlock.modelMatrix); + tr.entity2DUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, 0, sizeof(entity2DBlock), &entity2DBlock); + alignedBlockSize += (sizeof(EntityBlock) + alignment) & ~alignment; + + // Setup static 2d camera data + CameraBlock a2DCameraBlock = {}; Matrix16Ortho( 0.0f, 640.0f, @@ -1777,22 +1790,25 @@ static void R_InitStaticConstants() 0.0f, 0.0f, 1.0f, - entity2DBlock.modelViewProjectionMatrix); + a2DCameraBlock.viewProjectionMatrix); - qglBindBuffer(GL_UNIFORM_BUFFER, tr.staticUbo); - qglBufferData( - GL_UNIFORM_BUFFER, - STATIC_UNIFORM_BUFFER_SIZE, - nullptr, - GL_STATIC_DRAW); - - tr.entity2DUboOffset = 0; + tr.camera2DUboOffset = alignedBlockSize; qglBufferSubData( - GL_UNIFORM_BUFFER, 0, sizeof(entity2DBlock), &entity2DBlock); + GL_UNIFORM_BUFFER, tr.camera2DUboOffset, sizeof(a2DCameraBlock), &a2DCameraBlock); + alignedBlockSize += (sizeof(CameraBlock) + alignment) & ~alignment; + // Setup static flare entity data EntityBlock entityFlareBlock = {}; entityFlareBlock.fxVolumetricBase = -1.0f; Matrix16Identity(entityFlareBlock.modelMatrix); + + tr.entityFlareUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.entityFlareUboOffset, sizeof(entityFlareBlock), &entityFlareBlock); + alignedBlockSize += (sizeof(EntityBlock) + alignment) & ~alignment; + + // Setup static flare camera data + CameraBlock flareCameraBlock = {}; Matrix16Ortho( 0.0f, glConfig.vidWidth, @@ -1800,11 +1816,12 @@ static void R_InitStaticConstants() 0.0f, -99999.0f, 99999.0f, - entityFlareBlock.modelViewProjectionMatrix); + flareCameraBlock.viewProjectionMatrix); - tr.entityFlareUboOffset = alignedBlockSize; + tr.cameraFlareUboOffset = alignedBlockSize; qglBufferSubData( - GL_UNIFORM_BUFFER, tr.entityFlareUboOffset, sizeof(entityFlareBlock), &entityFlareBlock); + GL_UNIFORM_BUFFER, tr.cameraFlareUboOffset, sizeof(flareCameraBlock), &flareCameraBlock); + //alignedBlockSize += (sizeof(CameraBlock) + alignment) & ~alignment; // un-comment if you add more blocks to the static ubo } static void R_ShutdownBackEndFrameData() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d79830c2fb..1de535f201 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -695,6 +695,7 @@ struct SurfaceSpriteBlock struct CameraBlock { + matrix_t viewProjectionMatrix; vec4_t viewInfo; vec3_t viewOrigin; float pad0; @@ -714,7 +715,8 @@ struct SceneBlock vec3_t primaryLightColor; float primaryLightRadius; float currentTime; - float pad0[3]; + float frameTime; + float pad0[2]; }; struct LightsBlock @@ -751,7 +753,6 @@ struct FogsBlock struct EntityBlock { matrix_t modelMatrix; - matrix_t modelViewProjectionMatrix; vec4_t lightOrigin; vec3_t ambientLight; float lightRadius; @@ -2486,7 +2487,9 @@ typedef struct trGlobals_s { GLuint staticUbo; int entity2DUboOffset; + int camera2DUboOffset; int entityFlareUboOffset; + int cameraFlareUboOffset; int cameraUboOffset; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index f30554be95..44ad375fd9 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -689,6 +689,31 @@ void RB_FillDrawCommand( } } +static UniformBlockBinding GetCameraBlockUniformBinding( + const trRefEntity_t *refEntity) +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.block = UNIFORM_BLOCK_CAMERA; + + if (refEntity == &backEnd.entity2D) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.camera2DUboOffset; + } + else if (refEntity == &backEnd.entityFlare) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.cameraFlareUboOffset; + } + else + { + binding.ubo = currentFrameUbo; + binding.offset = tr.cameraUboOffset; + } + return binding; +} + static UniformBlockBinding GetEntityBlockUniformBinding( const trRefEntity_t *refEntity) { @@ -813,7 +838,7 @@ static void DrawTris(shaderCommands_t *input, const VertexArraysProperties *vert const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + GetCameraBlockUniformBinding(backEnd.currentEntity), { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, GetEntityBlockUniformBinding(backEnd.currentEntity), GetShaderInstanceBlockUniformBinding( @@ -1003,7 +1028,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + GetCameraBlockUniformBinding(backEnd.currentEntity), { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, GetEntityBlockUniformBinding(backEnd.currentEntity), GetShaderInstanceBlockUniformBinding( @@ -1297,6 +1322,7 @@ void RB_ShadowTessEnd(shaderCommands_t *input, const VertexArraysProperties *ver int stateBits = GLS_DEPTHFUNC_LESS | GLS_STENCILTEST_ENABLE | GLS_COLORMASK_BITS; const UniformBlockBinding uniformBlockBindings[] = { + GetCameraBlockUniformBinding(backEnd.currentEntity), GetEntityBlockUniformBinding(backEnd.currentEntity), GetBonesBlockUniformBinding(backEnd.currentEntity) }; @@ -1722,7 +1748,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + GetCameraBlockUniformBinding(backEnd.currentEntity), { currentFrameUbo, tr.lightsUboOffset, UNIFORM_BLOCK_LIGHTS }, { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, @@ -1774,9 +1800,10 @@ static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysPrope GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); const UniformBlockBinding uniformBlockBindings[] = { - GetEntityBlockUniformBinding(backEnd.currentEntity), - GetShaderInstanceBlockUniformBinding( - backEnd.currentEntity, input->shader) + GetCameraBlockUniformBinding(backEnd.currentEntity), + GetEntityBlockUniformBinding(backEnd.currentEntity), + GetShaderInstanceBlockUniformBinding( + backEnd.currentEntity, input->shader) }; DrawItem item = {}; diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index e3e0087b72..0b1d8a3722 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -364,6 +364,8 @@ namespace VBO_t *lastRainVBO = ws->vbo; VBO_t *rainVBO = ws->lastVBO; + Allocator& frameAllocator = *backEndData->perFrameMemory; + DrawItem item = {}; item.renderState.transformFeedback = true; item.transformFeedbackBuffer = {rainVBO->vertexesVBO, 0, rainVBO->vertexesSize}; @@ -400,7 +402,6 @@ namespace tr.world->bmodels[0].bounds[1][2] - backEnd.viewParms.ori.origin[2] }; uniformDataWriter.SetUniformVec2(UNIFORM_MAPZEXTENTS, mapZExtents); - uniformDataWriter.SetUniformFloat(UNIFORM_TIME, backEnd.refdef.frameTime); uniformDataWriter.SetUniformVec3(UNIFORM_ENVFORCE, envForce); uniformDataWriter.SetUniformVec4(UNIFORM_RANDOMOFFSET, randomOffset); uniformDataWriter.SetUniformVec2(UNIFORM_ZONEOFFSET, (float*)zoneOffsets, 9); @@ -408,6 +409,13 @@ namespace item.uniformData = uniformDataWriter.Finish(*backEndData->perFrameMemory); + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE } + }; + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); + item.draw.type = DRAW_COMMAND_ARRAYS; item.draw.numInstances = 1; item.draw.primitiveType = GL_POINTS; @@ -1181,12 +1189,15 @@ void RB_SurfaceWeather( srfWeather_t *surf ) { for (int x = -1; x <= 1; ++x, ++currentIndex) { + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const UniformBlockBinding uniformBlockBindings[] = { + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } + }; + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); + UniformDataWriter uniformDataWriter; uniformDataWriter.Start(&tr.weatherShader); - uniformDataWriter.SetUniformMatrix4x4( - UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection); - uniformDataWriter.SetUniformVec3( - UNIFORM_VIEWORIGIN, backEnd.viewParms.ori.origin); uniformDataWriter.SetUniformVec2( UNIFORM_ZONEOFFSET, (centerZoneOffsetX + x) * CHUNK_EXTENDS, From db905123168ac9b4d5c083380c58694d74431428 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 30 Apr 2023 01:17:23 +0200 Subject: [PATCH 663/708] More cleanup --- codemp/rd-rend2/tr_backend.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e382d6e3b2..e70bffd098 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1167,30 +1167,15 @@ static Pass *RB_CreatePass( Allocator& allocator, int capacity ) return pass; } -static void RB_PrepareForEntity( int entityNum, int *oldDepthRange, float originalTime ) +static void RB_PrepareForEntity( int entityNum ) { - int depthRange = 0; - if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; - if ( backEnd.currentEntity->e.renderfx & RF_NODEPTH ) { - // No depth at all, very rare but some things for seeing through walls - depthRange = 2; - } - else if ( backEnd.currentEntity->e.renderfx & RF_DEPTHHACK ) { - // hack the depth range to prevent view model from poking into walls - depthRange = 1; - } - } else { - backEnd.currentEntity = &tr.worldEntity; } - - // change depthrange - // does not look like coming out of the screen. - if ( *oldDepthRange != depthRange ) + else { - *oldDepthRange = depthRange; + backEnd.currentEntity = &tr.worldEntity; } } @@ -1251,7 +1236,7 @@ static void RB_SubmitDrawSurfsForDepthFill( // change the modelview matrix if needed if ( entityNum != oldEntityNum ) { - RB_PrepareForEntity(entityNum, &oldDepthRange, originalTime); + RB_PrepareForEntity(entityNum); oldEntityNum = entityNum; } @@ -1341,7 +1326,7 @@ static void RB_SubmitDrawSurfs( if ( entityNum != oldEntityNum ) { - RB_PrepareForEntity(entityNum, &oldDepthRange, originalTime); + RB_PrepareForEntity(entityNum); oldEntityNum = entityNum; } From d9d854eac47d99485d93116ac6797d884857789d Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 3 May 2023 22:35:16 +0200 Subject: [PATCH 664/708] More cleanup --- codemp/rd-rend2/tr_bsp.cpp | 1 - codemp/rd-rend2/tr_image.cpp | 13 +++++-------- codemp/rd-rend2/tr_image_stb.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 3ada796f3d..73b7d851a3 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3276,7 +3276,6 @@ static void R_RenderAllCubemaps() currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); backEndData->realFrameNumber++; - ri.WIN_Present(&window); backEnd.framePostProcessed = qfalse; backEnd.projection2D = qfalse; backEnd.frameUBOsInitialized = qfalse; diff --git a/codemp/rd-rend2/tr_image.cpp b/codemp/rd-rend2/tr_image.cpp index 725e773099..b2ae7ec4af 100644 --- a/codemp/rd-rend2/tr_image.cpp +++ b/codemp/rd-rend2/tr_image.cpp @@ -2814,7 +2814,7 @@ image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageNam if (specPic == NULL) return NULL; - byte *sdrSpecPic = (byte *)Z_Malloc(specWidth * specHeight * 4, TAG_TEMP_WORKSPACE, qfalse); + byte *sdrSpecPic = (byte *)ri.Hunk_AllocateTempMemory(sizeof(unsigned) * specWidth * specHeight); vec3_t currentColor; for (int i = 0; i < specWidth * specHeight * 4; i += 4) { @@ -2831,7 +2831,7 @@ image_t *R_BuildSDRSpecGlossImage(shaderStage_t *stage, const char *specImageNam sdrSpecPic[i + 2] = FloatToByte(currentColor[2] * ratio); sdrSpecPic[i + 3] = specPic[i + 3]; } - Z_Free(specPic); + ri.Hunk_FreeTempMemory(specPic); return R_CreateImage(sdrName, sdrSpecPic, specWidth, specHeight, IMGTYPE_COLORALPHA, flags & ~IMGFLAG_SRGB, 0); } @@ -2969,20 +2969,18 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) { char filename[MAX_QPATH]; Com_sprintf(filename, sizeof(filename), "%s.hdr", name); - byte *hdrPic = NULL; float *floatBuffer; - R_LoadHDRImage(filename, &hdrPic, &width, &height); - floatBuffer = (float*)hdrPic; - if (hdrPic == NULL) + R_LoadHDRImage(filename, &pic, &width, &height); + if (pic == NULL) { R_LoadImage(name, &pic, &width, &height); } else { - pic = (byte *)Z_Malloc(width*height*4*2, TAG_TEMP_WORKSPACE, qfalse); for (int i = 0; i < width*height; i++) { vec4_t color; + floatBuffer = (float*)pic; memcpy(color, &floatBuffer[i*3], 12); if (flags & IMGFLAG_HDR_LIGHTMAP) { @@ -3000,7 +2998,6 @@ image_t *R_FindImageFile( const char *name, imgType_t type, int flags ) } internalFormat = GL_RGBA16F; loadFlags = flags & ~(IMGFLAG_GENNORMALMAP | IMGFLAG_MIPMAP); - Z_Free(hdrPic); } } else diff --git a/codemp/rd-rend2/tr_image_stb.cpp b/codemp/rd-rend2/tr_image_stb.cpp index 03badd5b84..17a2baae20 100644 --- a/codemp/rd-rend2/tr_image_stb.cpp +++ b/codemp/rd-rend2/tr_image_stb.cpp @@ -26,23 +26,23 @@ along with this program; if not, see . static void* R_LocalMalloc(size_t size) { - return Z_Malloc(size, TAG_TEMP_WORKSPACE); + return ri.Hunk_AllocateTempMemory(size); } static void* R_LocalReallocSized(void *ptr, size_t old_size, size_t new_size) { - void *mem = Z_Malloc(new_size, TAG_TEMP_WORKSPACE, qfalse); + void *mem = ri.Hunk_AllocateTempMemory(new_size); if (ptr) { memcpy(mem, ptr, old_size); - Z_Free(ptr); + ri.Hunk_FreeTempMemory(ptr); } return mem; } static void R_LocalFree(void *ptr) { if (ptr) - Z_Free(ptr); + ri.Hunk_FreeTempMemory(ptr); } #define STBI_MALLOC R_LocalMalloc From 33dff6555ecd563612adfd7d62209d39611b83ae Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 3 May 2023 23:52:48 +0200 Subject: [PATCH 665/708] Remove r_mergeLightmaps and always atlas internal lightmaps --- codemp/rd-rend2/tr_bsp.cpp | 126 +++++++++++++++++++++++++----------- codemp/rd-rend2/tr_init.cpp | 2 - codemp/rd-rend2/tr_local.h | 3 +- 3 files changed, 91 insertions(+), 40 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 73b7d851a3..2bab1dbc63 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -199,6 +199,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.lightmapSize = DEFAULT_LIGHTMAP_SIZE; tr.hdrLighting = qfalse; + tr.worldInternalLightmapping = qfalse; len = l->filelen; // test for external lightmaps @@ -217,11 +218,29 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { { numLightmaps = len / (tr.lightmapSize * tr.lightmapSize * 3); buf = fileBase + l->fileofs; + tr.worldInternalLightmapping = qtrue; } if (numLightmaps == 0) return; + // test for hdr lighting + if (hdr_capable && tr.worldInternalLightmapping) + { + char filename[MAX_QPATH]; + byte *externalLightmap = NULL; + int lightmapWidth = tr.lightmapSize; + int lightmapHeight = tr.lightmapSize; + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.hdr", worldData->baseName, 0); + R_LoadHDRImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); + if (externalLightmap != NULL) + { + tr.worldInternalLightmapping = qfalse; + ri.Hunk_FreeTempMemory(externalLightmap); + } + + } + // we are about to upload textures R_IssuePendingRenderCommands(); @@ -259,7 +278,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (tr.worldDeluxeMapping) numLightmaps >>= 1; - if (r_mergeLightmaps->integer) + if (tr.worldInternalLightmapping) { const int targetLightmapsPerX = (int)ceilf(sqrtf(numLightmaps)); @@ -293,7 +312,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { else textureInternalFormat = GL_RGBA8; - if (r_mergeLightmaps->integer) + if (tr.worldInternalLightmapping) { for (i = 0; i < tr.numLightmaps; i++) { @@ -326,7 +345,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { int lightmapnum = i; // expand the 24 bit on-disk to 32 bit - if (r_mergeLightmaps->integer) + if (tr.worldInternalLightmapping) { xoff = (i % tr.lightmapsPerAtlasSide[0]) * tr.lightmapSize; yoff = (i / tr.lightmapsPerAtlasSide[0]) * tr.lightmapSize; @@ -343,32 +362,31 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { int bppc; bool foundLightmap = true; - if (hdr_capable) - Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); - else - Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.tga", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); - - bppc = 16; - R_LoadHDRImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); - if (!externalLightmap) + if (!tr.worldInternalLightmapping) { - bppc = 8; - R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); - } + if (hdr_capable) + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.hdr", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); + else + Com_sprintf(filename, sizeof(filename), "maps/%s/lm_%04d.tga", worldData->baseName, i * (tr.worldDeluxeMapping ? 2 : 1)); + bppc = 16; + R_LoadHDRImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); + if (!externalLightmap) + { + bppc = 8; + R_LoadImage(filename, &externalLightmap, &lightmapWidth, &lightmapHeight); + } + } + if (externalLightmap) { int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; - if (r_mergeLightmaps->integer && (lightmapWidth != tr.lightmapSize || lightmapHeight != tr.lightmapSize)) + if (tr.worldInternalLightmapping && (lightmapWidth != tr.lightmapSize || lightmapHeight != tr.lightmapSize)) { - ri.Printf(PRINT_ALL, "Error loading %s: non %dx%d lightmaps require r_mergeLightmaps 0.\n", filename, tr.lightmapSize, tr.lightmapSize); + ri.Printf(PRINT_ALL, "Error loading %s: non %dx%d lightmaps\n", filename, tr.lightmapSize, tr.lightmapSize); Z_Free(externalLightmap); externalLightmap = NULL; - if (!len) - { - tr.numLightmaps = 0; - return; - } + continue; } else if (newImageSize > imageSize) { @@ -492,7 +510,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } } - if (r_mergeLightmaps->integer) + if (tr.worldInternalLightmapping) R_UpdateSubImage( tr.lightmaps[lightmapnum], image, @@ -537,7 +555,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { image[j * 4 + 3] = 255; } - if (r_mergeLightmaps->integer) + if (tr.worldInternalLightmapping) { R_UpdateSubImage( tr.deluxemaps[lightmapnum], @@ -561,7 +579,7 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { 0); } } - else if (r_deluxeMapping->integer && !r_mergeLightmaps->integer) + else if (r_deluxeMapping->integer) { char filename[MAX_QPATH]; byte *externalLightmap = NULL; @@ -578,6 +596,14 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { if (!externalLightmap) continue; + if (tr.worldInternalLightmapping && (lightmapWidth != tr.lightmapSize || lightmapHeight != tr.lightmapSize)) + { + ri.Printf(PRINT_ALL, "Error loading %s: non %dx%d deluxemaps\n", filename, tr.lightmapSize, tr.lightmapSize); + Z_Free(externalLightmap); + externalLightmap = NULL; + continue; + } + int newImageSize = lightmapWidth * lightmapHeight * 4 * 2; if (newImageSize > imageSize) { @@ -605,18 +631,46 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { } if (!tr.deluxemaps) + { tr.deluxemaps = (image_t **)ri.Hunk_Alloc(tr.numLightmaps * sizeof(image_t *), h_low); + if (tr.worldInternalLightmapping) + { + { + tr.deluxemaps[lightmapnum] = R_CreateImage( + va("_fatdeluxemap%d", i), + NULL, + tr.lightmapAtlasSize[0], + tr.lightmapAtlasSize[1], + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + 0); + } + } + } - tr.deluxemaps[i] = R_CreateImage( - va("*deluxemap%d", i), - image, - lightmapWidth, - lightmapHeight, - IMGTYPE_DELUXE, - IMGFLAG_NOLIGHTSCALE | - IMGFLAG_NO_COMPRESSION | - IMGFLAG_CLAMPTOEDGE, - 0); + if (tr.worldInternalLightmapping) + { + R_UpdateSubImage( + tr.deluxemaps[lightmapnum], + image, + xoff, + yoff, + lightmapWidth, + lightmapHeight); + } + else + { + tr.deluxemaps[i] = R_CreateImage( + va("*deluxemap%d", i), + image, + lightmapWidth, + lightmapHeight, + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | + IMGFLAG_NO_COMPRESSION | + IMGFLAG_CLAMPTOEDGE, + 0); + } Z_Free(externalLightmap); externalLightmap = NULL; @@ -639,7 +693,7 @@ static float FatPackU(float input, int lightmapnum) if (lightmapnum < 0) return input; - if (tr.worldDeluxeMapping) + if (tr.worldInternalDeluxeMapping) lightmapnum >>= 1; if (tr.lightmapAtlasSize[0] > 0) @@ -658,7 +712,7 @@ static float FatPackV(float input, int lightmapnum) if (lightmapnum < 0) return input; - if (tr.worldDeluxeMapping) + if (tr.worldInternalDeluxeMapping) lightmapnum >>= 1; if (tr.lightmapAtlasSize[1] > 0) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index f50f87f683..5ab07883df 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -145,7 +145,6 @@ cvar_t *r_baseNormalX; cvar_t *r_baseNormalY; cvar_t *r_baseParallax; cvar_t *r_baseSpecular; -cvar_t *r_mergeLightmaps; cvar_t *r_dlightMode; cvar_t *r_pshadowDist; cvar_t *r_imageUpsample; @@ -1502,7 +1501,6 @@ void R_Register( void ) r_baseSpecular = ri.Cvar_Get( "r_baseSpecular", "0.04", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_dlightMode = ri.Cvar_Get( "r_dlightMode", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_pshadowDist = ri.Cvar_Get( "r_pshadowDist", "128", CVAR_ARCHIVE, "" ); - r_mergeLightmaps = ri.Cvar_Get( "r_mergeLightmaps", "1", CVAR_ARCHIVE | CVAR_LATCH, "Disable/enable packing lightmaps into one atlas" ); r_imageUpsample = ri.Cvar_Get( "r_imageUpsample", "0", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleMaxSize = ri.Cvar_Get( "r_imageUpsampleMaxSize", "1024", CVAR_ARCHIVE | CVAR_LATCH, "" ); r_imageUpsampleType = ri.Cvar_Get( "r_imageUpsampleType", "1", CVAR_ARCHIVE | CVAR_LATCH, "" ); diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 1de535f201..3e01d9c789 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -155,7 +155,6 @@ extern cvar_t *r_deluxeMapping; extern cvar_t *r_deluxeSpecular; extern cvar_t *r_parallaxMapping; extern cvar_t *r_normalAmbient; -extern cvar_t *r_mergeLightmaps; extern cvar_t *r_dlightMode; extern cvar_t *r_pshadowDist; extern cvar_t *r_imageUpsample; @@ -2370,6 +2369,7 @@ typedef struct trGlobals_s { GLuint globalVao; qboolean worldMapLoaded; + qboolean worldInternalLightmapping; // qtrue indicates lightmap atlasing qboolean worldDeluxeMapping; qboolean worldInternalDeluxeMapping; vec2_t autoExposureMinMax; @@ -2726,7 +2726,6 @@ extern cvar_t *r_baseSpecular; extern cvar_t *r_dlightMode; extern cvar_t *r_pshadowDist; extern cvar_t *r_recalcMD3Normals; -extern cvar_t *r_mergeLightmaps; extern cvar_t *r_imageUpsample; extern cvar_t *r_imageUpsampleMaxSize; extern cvar_t *r_imageUpsampleType; From f039000782cba15c37d05a0b3bc723fa196d96e1 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 4 May 2023 21:15:06 +0200 Subject: [PATCH 666/708] Don't render ssao in skyportals --- codemp/rd-rend2/tr_backend.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index e70bffd098..9f03b89929 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2128,7 +2128,9 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) glConfig.vidHeight, 0); } - if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + if (r_ssao->integer && + !(backEnd.viewParms.flags & VPF_DEPTHSHADOW) && + !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) { // need the depth in a texture we can do GL_LINEAR sampling on, so // copy it to an HDR image @@ -2209,7 +2211,9 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu RB_RenderSunShadows(); } - if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) + if (r_ssao->integer && + !(backEnd.viewParms.flags & VPF_DEPTHSHADOW) && + !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) { RB_RenderSSAO(); } From 63bc85a50d8ecb5f78c64a273f6a91fee03c957f Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 4 May 2023 21:58:19 +0200 Subject: [PATCH 667/708] Explicitly set camera ubo for sky draws Missed setting this, so it happened that the wrong/old camera ubo was bound in skyportal views. --- codemp/rd-rend2/tr_sky.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 0293f78dd6..1e1ba1fb6f 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -456,7 +456,8 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.skyEntityUboOffset, UNIFORM_BLOCK_ENTITY } + { currentFrameUbo, tr.skyEntityUboOffset, UNIFORM_BLOCK_ENTITY }, + { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } }; DrawItem item = {}; From 1f3703aaa66932ad3e232317112dfb8b98056c4e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Fri, 5 May 2023 01:36:17 +0200 Subject: [PATCH 668/708] Flip normals for backfacing triangles Idea taken from: https://github.com/ioquake/ioq3/commit/bc8737d707595aebd7cc11d6d5a5d65ede750f59 --- codemp/rd-rend2/glsl/lightall.glsl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index e9c0475c8b..638035c4df 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -911,7 +911,8 @@ void main() attenuation = 1.0; #endif - N = CalcNormal(var_Normal.xyz, var_Tangent, texCoords); + vec3 vertexNormal = mix(var_Normal.xyz, -var_Normal.xyz, float(gl_FrontFacing)); + N = CalcNormal(vertexNormal, var_Tangent, texCoords); L /= sqrt(sqrLightDist); #if defined(USE_SHADOWMAP) || defined(USE_SSAO) @@ -932,7 +933,7 @@ void main() #if defined(USE_LIGHTMAP) || defined(USE_LIGHT_VERTEX) ambientColor = lightColor; - float surfNL = clamp(dot(var_Normal.xyz, L), 0.0, 1.0); + float surfNL = clamp(dot(vertexNormal, L), 0.0, 1.0); // Scale the incoming light to compensate for the baked-in light angle // attenuation. @@ -1006,7 +1007,7 @@ void main() #if defined(USE_PRIMARY_LIGHT) vec3 L2 = normalize(u_PrimaryLightOrigin.xyz); vec3 H2 = normalize(L2 + E); - float NL2 = clamp(min(dot(N, L2), dot(var_Normal.xyz, L2)), 0.0, 1.0); + float NL2 = clamp(min(dot(N, L2), dot(vertexNormal, L2)), 0.0, 1.0); float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); float NH2 = clamp(dot(N, H2), 0.0, 1.0); float VH2 = clamp(dot(E, H), 0.0, 1.0); @@ -1021,7 +1022,7 @@ void main() out_Color.rgb += lightColor * reflectance * NL2; #endif - out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb, var_Normal.xyz); + out_Color.rgb += CalcDynamicLightContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, diffuse.rgb, specular.rgb, vertexNormal); out_Color.rgb += CalcIBLContribution(roughness, N, E, u_ViewOrigin, viewDir, NE, specular.rgb * AO); #else lightColor = var_Color.rgb; From c6fb4d287c4fbba5548718c4d84715f685d4a637 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Fri, 5 May 2023 01:38:14 +0200 Subject: [PATCH 669/708] Use metalness workflow as default and set specularScale accordingly. Fixes bad shading on models with "alphaGen lightingSpecular" shader stages --- codemp/rd-rend2/tr_shader.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 653931ed9e..2796c958b5 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3178,8 +3178,10 @@ static void CollapseStagesToLightall(shaderStage_t *stage, shaderStage_t *lightm R_LoadPackedMaterialImage(stage, imageName, specularFlags); if (!stage->bundle[TB_ORMSMAP].image[0]) { - stage->specularType = SPEC_SPECGLOSS; - defs |= LIGHTDEF_USE_SPEC_GLOSS; + stage->specularScale[0] = 0.0f; + stage->specularScale[2] = + stage->specularScale[3] = 1.0f; + stage->specularScale[1] = 0.5f; } } } @@ -3427,6 +3429,19 @@ static qboolean CollapseStagesToGLSL(void) } } + if (skip) + { + // set default specular scale for skipped shaders that will use metalness workflow by default + for (i = 0; i < MAX_SHADER_STAGES; i++) + { + shaderStage_t *pStage = &stages[i]; + pStage->specularScale[0] = 0.0f; + pStage->specularScale[2] = + pStage->specularScale[3] = 1.0f; + pStage->specularScale[1] = 0.5f; + } + } + // remove inactive stages numStages = 0; for (i = 0; i < MAX_SHADER_STAGES; i++) From 253533558c60ecdb914387231101877a741e2a4b Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 6 May 2023 15:37:04 +0200 Subject: [PATCH 670/708] Use correct luma for auto exposure Wondering where this weird luma vector comes from and how it was picked in the first place. --- codemp/rd-rend2/glsl/calclevels4x.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/calclevels4x.glsl b/codemp/rd-rend2/glsl/calclevels4x.glsl index be67b479e6..4c9252230e 100644 --- a/codemp/rd-rend2/glsl/calclevels4x.glsl +++ b/codemp/rd-rend2/glsl/calclevels4x.glsl @@ -21,7 +21,7 @@ in vec2 var_TexCoords; out vec4 out_Color; -const vec3 LUMINANCE_VECTOR = vec3(0.2125, 0.7154, 0.0721); //vec3(0.299, 0.587, 0.114); +const vec3 LUMINANCE_VECTOR = vec3(0.299, 0.587, 0.114); vec3 GetValues(vec2 offset, vec3 current) { From f3a4183822b1d05d76509ec83276ed850bf6b9a6 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 6 May 2023 17:03:26 +0200 Subject: [PATCH 671/708] Disable vertex animation support It isn't used in the vanilla game and has always been broken in rend2. Fixed it in gl2, but since MP doesn't support entities with vertex animations, just don't bother. Also alot of cleanup. --- codemp/rd-rend2/glsl/shadowfill.glsl | 7 +- codemp/rd-rend2/tr_bsp.cpp | 19 ++--- codemp/rd-rend2/tr_glsl.cpp | 54 +++++++------- codemp/rd-rend2/tr_local.h | 105 ++++++++++++++++----------- codemp/rd-rend2/tr_shade.cpp | 33 +++++---- 5 files changed, 119 insertions(+), 99 deletions(-) diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl index c9a1081f69..c2f370e5db 100644 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ b/codemp/rd-rend2/glsl/shadowfill.glsl @@ -3,9 +3,6 @@ in vec3 attr_Position; in vec3 attr_Normal; in vec4 attr_TexCoord0; -in vec3 attr_Position2; -in vec3 attr_Normal2; - layout(std140) uniform Camera { mat4 u_viewProjectionMatrix; @@ -171,8 +168,8 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) void main() { - vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp); - vec3 normal = mix(attr_Normal, attr_Normal2, u_VertexLerp); + vec3 position = attr_Position; + vec3 normal = attr_Normal; normal = normalize(normal - vec3(0.5)); position = DeformPosition(position, normal, attr_TexCoord0.st); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 2bab1dbc63..79786c803c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -238,7 +238,6 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.worldInternalLightmapping = qfalse; ri.Hunk_FreeTempMemory(externalLightmap); } - } // we are about to upload textures @@ -635,16 +634,14 @@ static void R_LoadLightmaps( world_t *worldData, lump_t *l, lump_t *surfs ) { tr.deluxemaps = (image_t **)ri.Hunk_Alloc(tr.numLightmaps * sizeof(image_t *), h_low); if (tr.worldInternalLightmapping) { - { - tr.deluxemaps[lightmapnum] = R_CreateImage( - va("_fatdeluxemap%d", i), - NULL, - tr.lightmapAtlasSize[0], - tr.lightmapAtlasSize[1], - IMGTYPE_DELUXE, - IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, - 0); - } + tr.deluxemaps[lightmapnum] = R_CreateImage( + va("_fatdeluxemap%d", i), + NULL, + tr.lightmapAtlasSize[0], + tr.lightmapAtlasSize[1], + IMGTYPE_DELUXE, + IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, + 0); } } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index 65cddd02ad..ee58f96f2d 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -553,7 +553,6 @@ static void GLSL_BindShaderInterface( shaderProgram_t *program ) "attr_Tangent", // ATTR_INDEX_TANGENT "attr_Normal", // ATTR_INDEX_NORMAL "attr_Color", // ATTR_INDEX_COLOR - "attr_PaintColor", // ATTR_INDEX_PAINTCOLOR "attr_LightDirection", // ATTR_INDEX_LIGHTDIRECTION "attr_BoneIndexes", // ATTR_INDEX_BONE_INDEXES "attr_BoneWeights", // ATTR_INDEX_BONE_WEIGHTS @@ -1304,19 +1303,21 @@ void GLSL_DeleteGPUShader(shaderProgram_t *program) static bool GLSL_IsValidPermutationForGeneric (int shaderCaps) { +#ifdef REND2_SP if ( (shaderCaps & GENERICDEF_USE_VERTEX_ANIMATION) && (shaderCaps & GENERICDEF_USE_SKELETAL_ANIMATION) ) return false; - +#endif // REND2_SP return true; } static bool GLSL_IsValidPermutationForFog (int shaderCaps) { +#ifdef REND2_SP if ( (shaderCaps & FOGDEF_USE_VERTEX_ANIMATION) && (shaderCaps & FOGDEF_USE_SKELETAL_ANIMATION) ) return false; - +#endif // REND2_SP return true; } @@ -1328,13 +1329,11 @@ static bool GLSL_IsValidPermutationForLight (int lightType, int shaderCaps) if (!lightType && (shaderCaps & LIGHTDEF_USE_PARALLAXMAP)) return false; - if (!lightType && (shaderCaps & LIGHTDEF_USE_SHADOWMAP)) - return false; - +#ifdef REND2_SP if ( (shaderCaps & LIGHTDEF_USE_SKELETAL_ANIMATION) && (shaderCaps & LIGHTDEF_USE_VERTEX_ANIMATION) ) return false; - +#endif // REND2_SP return true; } @@ -1443,13 +1442,13 @@ static int GLSL_LoadGPUProgramGeneric( Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCGEN\n"); Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } - +#ifdef REND2_SP if (i & GENERICDEF_USE_VERTEX_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; } - +#endif // REND2_SP if (i & GENERICDEF_USE_SKELETAL_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); @@ -1499,23 +1498,26 @@ static int GLSL_LoadGPUProgramFogPass( char extradefines[1200]; const GPUProgramDesc *programDesc = LoadProgramSource("fogpass", allocator, fallback_fogpassProgram); - for ( int i = 0; i < FOGDEF_COUNT; i++ ) + for (int i = 0; i < FOGDEF_COUNT; i++) { - if (!GLSL_IsValidPermutationForFog (i)) + if (!GLSL_IsValidPermutationForFog(i)) { continue; } uint32_t attribs = - (ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0); + (ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0); extradefines[0] = '\0'; if (i & FOGDEF_USE_DEFORM_VERTEXES) Q_strcat(extradefines, sizeof(extradefines), "#define USE_DEFORM_VERTEXES\n"); - +#ifdef REND2_SP if (i & FOGDEF_USE_VERTEX_ANIMATION) + { Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); - + attribs |= ATTR_POSITION2 | ATTR_NORMAL2 + } +#endif // REND2_SP if (i & FOGDEF_USE_SKELETAL_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); @@ -1572,13 +1574,13 @@ static int GLSL_LoadGPUProgramRefraction( Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCGEN\n"); Q_strcat(extradefines, sizeof(extradefines), "#define USE_TCMOD\n"); } - +#ifdef REND2_SP if (i & REFRACTIONDEF_USE_VERTEX_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); attribs |= ATTR_POSITION2 | ATTR_NORMAL2; } - +#endif // REND2_SP if (i & REFRACTIONDEF_USE_SKELETAL_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); @@ -1640,9 +1642,6 @@ static int GLSL_LoadGPUProgramLightAll( extradefines[0] = '\0'; - if (r_sunlightMode->integer) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); - if (r_hdr->integer && !glRefConfig.floatLightmap) Q_strcat(extradefines, sizeof(extradefines), "#define RGBM_LIGHTMAP\n"); @@ -1707,7 +1706,7 @@ static int GLSL_LoadGPUProgramLightAll( Q_strcat(extradefines, sizeof(extradefines), "#define USE_CUBEMAP\n"); } - if (i & LIGHTDEF_USE_SHADOWMAP) + if (r_sunlightMode->integer) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOWMAP\n"); @@ -1727,7 +1726,7 @@ static int GLSL_LoadGPUProgramLightAll( { Q_strcat(extradefines, sizeof(extradefines), "#define USE_CLOTH_BRDF\n"); } - +#ifdef REND2_SP if (i & LIGHTDEF_USE_VERTEX_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_VERTEX_ANIMATION\n"); @@ -1736,7 +1735,9 @@ static int GLSL_LoadGPUProgramLightAll( if (r_normalMapping->integer) attribs |= ATTR_TANGENT2; } - else if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) + else +#endif // REND2_SP + if (i & LIGHTDEF_USE_SKELETAL_ANIMATION) { Q_strcat(extradefines, sizeof(extradefines), "#define USE_SKELETAL_ANIMATION\n"); attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS; @@ -1858,7 +1859,7 @@ static int GLSL_LoadGPUProgramDepthFill( &tr.shadowmapShader, "shadowfill", fallback_shadowfillProgram, - ATTR_POSITION | ATTR_POSITION2 | ATTR_NORMAL | ATTR_NORMAL2 | ATTR_TEXCOORD0); + ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0); GLSL_InitUniforms(&tr.shadowmapShader); GLSL_FinishGPUShader(&tr.shadowmapShader); @@ -2576,13 +2577,14 @@ void GL_VertexArraysToAttribs( { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // tangent { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal { 4, GL_FALSE, GL_FLOAT, GL_FALSE }, // color - { 0, GL_FALSE, GL_NONE, GL_FALSE }, // paint color { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // light direction { 4, GL_TRUE, GL_UNSIGNED_BYTE, GL_FALSE }, // bone indices { 4, GL_FALSE, GL_UNSIGNED_BYTE, GL_TRUE }, // bone weights +#ifdef REND2_SP { 3, GL_FALSE, GL_FLOAT, GL_FALSE }, // pos2 { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // tangent2 { 4, GL_FALSE, GL_UNSIGNED_INT_2_10_10_10_REV, GL_TRUE }, // normal2 +#endif // REND2_SP }; for ( int i = 0; i < vertexArrays->numVertexArrays; i++ ) @@ -2663,12 +2665,12 @@ shaderProgram_t *GLSL_GetGenericShaderProgram(int stage) { shaderAttribs |= GENERICDEF_USE_DEFORM_VERTEXES; } - +#ifdef REND2_SP if (glState.vertexAnimation) { shaderAttribs |= GENERICDEF_USE_VERTEX_ANIMATION; } - +#endif // REND2_SP if (glState.skeletalAnimation) { shaderAttribs |= GENERICDEF_USE_SKELETAL_ANIMATION; diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 3e01d9c789..88015cdf4b 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -335,15 +335,16 @@ enum ATTR_INDEX_TANGENT, ATTR_INDEX_NORMAL, ATTR_INDEX_COLOR, - ATTR_INDEX_PAINTCOLOR, ATTR_INDEX_LIGHTDIRECTION, ATTR_INDEX_BONE_INDEXES, ATTR_INDEX_BONE_WEIGHTS, - // GPU vertex animations + // GPU vertex animations and some extra sprite info ATTR_INDEX_POSITION2, +#ifdef REND2_SP ATTR_INDEX_TANGENT2, ATTR_INDEX_NORMAL2, +#endif // REND2_SP ATTR_INDEX_MAX }; @@ -1124,15 +1125,16 @@ enum ATTR_TANGENT = 0x0040, ATTR_NORMAL = 0x0080, ATTR_COLOR = 0x0100, - ATTR_PAINTCOLOR = 0x0200, - ATTR_LIGHTDIRECTION = 0x0400, - ATTR_BONE_INDEXES = 0x0800, - ATTR_BONE_WEIGHTS = 0x1000, + ATTR_LIGHTDIRECTION = 0x0200, + ATTR_BONE_INDEXES = 0x0400, + ATTR_BONE_WEIGHTS = 0x0800, - // for .md3 interpolation - ATTR_POSITION2 = 0x2000, - ATTR_TANGENT2 = 0x4000, - ATTR_NORMAL2 = 0x8000, + // for .md3 interpolation and some sprite data + ATTR_POSITION2 = 0x1000, +#ifdef REND2_SP + ATTR_TANGENT2 = 0x2000, + ATTR_NORMAL2 = 0x4000, +#endif // REND2_SP ATTR_DEFAULT = ATTR_POSITION, ATTR_BITS = ATTR_POSITION | @@ -1144,54 +1146,68 @@ enum ATTR_TANGENT | ATTR_NORMAL | ATTR_COLOR | - ATTR_PAINTCOLOR | ATTR_LIGHTDIRECTION | ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS | - ATTR_POSITION2 | + ATTR_POSITION2 +#ifdef REND2_SP + | ATTR_TANGENT2 | ATTR_NORMAL2 +#endif // REND2_SP }; enum { GENERICDEF_USE_DEFORM_VERTEXES = 0x0001, GENERICDEF_USE_TCGEN_AND_TCMOD = 0x0002, - GENERICDEF_USE_VERTEX_ANIMATION = 0x0004, - GENERICDEF_USE_FOG = 0x0008, - GENERICDEF_USE_RGBAGEN = 0x0010, - GENERICDEF_USE_SKELETAL_ANIMATION = 0x0020, - GENERICDEF_USE_GLOW_BUFFER = 0x0040, - GENERICDEF_USE_ALPHA_TEST = 0x0080, - - GENERICDEF_ALL = 0x00FF, + GENERICDEF_USE_FOG = 0x0004, + GENERICDEF_USE_RGBAGEN = 0x0008, + GENERICDEF_USE_SKELETAL_ANIMATION = 0x0010, + GENERICDEF_USE_GLOW_BUFFER = 0x0020, + GENERICDEF_USE_ALPHA_TEST = 0x0040, +#ifdef REND2_SP + GENERICDEF_USE_VERTEX_ANIMATION = 0x0080, + GENERICDEF_ALL = 0x00FF, +#else + GENERICDEF_ALL = 0x007F, +#endif // REND2_SP + GENERICDEF_COUNT = GENERICDEF_ALL + 1, }; enum { FOGDEF_USE_DEFORM_VERTEXES = 0x0001, - FOGDEF_USE_VERTEX_ANIMATION = 0x0002, - FOGDEF_USE_SKELETAL_ANIMATION = 0x0004, - FOGDEF_USE_ALPHA_TEST = 0x0008, - FOGDEF_USE_FALLBACK_GLOBAL_FOG = 0x0010, + FOGDEF_USE_SKELETAL_ANIMATION = 0x0002, + FOGDEF_USE_ALPHA_TEST = 0x0004, + FOGDEF_USE_FALLBACK_GLOBAL_FOG = 0x0008, +#ifdef REND2_SP + FOGDEF_USE_VERTEX_ANIMATION = 0x0010, + FOGDEF_ALL = 0x001F, +#else + FOGDEF_ALL = 0x000F, +#endif // REND2_SP - FOGDEF_ALL = 0x001F, FOGDEF_COUNT = FOGDEF_ALL + 1, }; enum { - REFRACTIONDEF_USE_DEFORM_VERTEXES = 0x0001, - REFRACTIONDEF_USE_TCGEN_AND_TCMOD = 0x0002, - REFRACTIONDEF_USE_VERTEX_ANIMATION = 0x0004, - REFRACTIONDEF_USE_RGBAGEN = 0x0008, - REFRACTIONDEF_USE_SKELETAL_ANIMATION = 0x0020, - REFRACTIONDEF_USE_ALPHA_TEST = 0x0040, - REFRACTIONDEF_USE_SRGB_TRANSFORM = 0x0080, + REFRACTIONDEF_USE_DEFORM_VERTEXES = 0x0001, + REFRACTIONDEF_USE_TCGEN_AND_TCMOD = 0x0002, + REFRACTIONDEF_USE_RGBAGEN = 0x0004, + REFRACTIONDEF_USE_SKELETAL_ANIMATION = 0x0008, + REFRACTIONDEF_USE_ALPHA_TEST = 0x0010, + REFRACTIONDEF_USE_SRGB_TRANSFORM = 0x0020, +#ifdef REND2_SP + REFRACTIONDEF_USE_VERTEX_ANIMATION = 0x0040, + REFRACTIONDEF_ALL = 0x007F, +#else + REFRACTIONDEF_ALL = 0x003F, +#endif // REND2_SP - REFRACTIONDEF_ALL = 0x00FF, - REFRACTIONDEF_COUNT = REFRACTIONDEF_ALL + 1, + REFRACTIONDEF_COUNT = REFRACTIONDEF_ALL + 1, }; enum @@ -1201,19 +1217,24 @@ enum LIGHTDEF_USE_LIGHT_VERTEX = 0x0003, LIGHTDEF_USE_TCGEN_AND_TCMOD = 0x0004, LIGHTDEF_USE_PARALLAXMAP = 0x0008, - LIGHTDEF_USE_SHADOWMAP = 0x0010, - LIGHTDEF_USE_VERTEX_ANIMATION = 0x0020, - LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0040, - LIGHTDEF_USE_GLOW_BUFFER = 0x0080, - LIGHTDEF_USE_ALPHA_TEST = 0x0100, - LIGHTDEF_USE_CLOTH_BRDF = 0x0200, - LIGHTDEF_USE_SPEC_GLOSS = 0x0400, +// LIGHTDEF_USE_SHADOWMAP = 0x0010, + LIGHTDEF_USE_SKELETAL_ANIMATION = 0x0010, + LIGHTDEF_USE_GLOW_BUFFER = 0x0020, + LIGHTDEF_USE_ALPHA_TEST = 0x0040, + LIGHTDEF_USE_CLOTH_BRDF = 0x0080, + LIGHTDEF_USE_SPEC_GLOSS = 0x0100, LIGHTDEF_LIGHTTYPE_MASK = LIGHTDEF_USE_LIGHTMAP | LIGHTDEF_USE_LIGHT_VECTOR | LIGHTDEF_USE_LIGHT_VERTEX, - LIGHTDEF_ALL = 0x07FF, +#ifdef REND2_SP + LIGHTDEF_USE_VERTEX_ANIMATION = 0x0200, + LIGHTDEF_ALL = 0x03FF, +#else + LIGHTDEF_ALL = 0x01FF, +#endif // REND2_SP + LIGHTDEF_COUNT = LIGHTDEF_ALL + 1 }; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 44ad375fd9..0087037638 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -821,10 +821,12 @@ static void DrawTris(shaderCommands_t *input, const VertexArraysProperties *vert { index |= GENERICDEF_USE_DEFORM_VERTEXES; } +#ifdef REND2_SP if (glState.vertexAnimation) { index |= GENERICDEF_USE_VERTEX_ANIMATION; } +#endif // REND2_SP else if (glState.skeletalAnimation) { index |= GENERICDEF_USE_SKELETAL_ANIMATION; @@ -993,10 +995,10 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v if (input->shader->numDeforms && !ShaderRequiresCPUDeforms(input->shader)) shaderBits |= FOGDEF_USE_DEFORM_VERTEXES; - +#ifdef REND2_SP if (glState.vertexAnimation) shaderBits |= FOGDEF_USE_VERTEX_ANIMATION; - +#endif // REND2_SP else if (glState.skeletalAnimation) shaderBits |= FOGDEF_USE_SKELETAL_ANIMATION; @@ -1110,7 +1112,7 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) { unsigned int vertexAttribs = shader->vertexAttribs; - +#ifdef REND2_SP if(glState.vertexAnimation) { //vertexAttribs &= ~ATTR_COLOR; @@ -1121,7 +1123,7 @@ static unsigned int RB_CalcShaderVertexAttribs( const shader_t *shader ) vertexAttribs |= ATTR_TANGENT2; } } - +#endif // REND2_SP if (glState.skeletalAnimation) { vertexAttribs |= ATTR_BONE_WEIGHTS; @@ -1143,11 +1145,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { index |= REFRACTIONDEF_USE_DEFORM_VERTEXES; } - +#ifdef REND2_SP if (glState.vertexAnimation) { index |= REFRACTIONDEF_USE_VERTEX_ANIMATION; } +#endif // REND2_SP else if (glState.skeletalAnimation) { index |= REFRACTIONDEF_USE_SKELETAL_ANIMATION; @@ -1180,11 +1183,14 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { +#ifdef REND2_SP if (glState.vertexAnimation) { index |= LIGHTDEF_USE_VERTEX_ANIMATION; } - else if (glState.skeletalAnimation) + else +#endif // REND2_SP + if (glState.skeletalAnimation) { index |= LIGHTDEF_USE_SKELETAL_ANIMATION; } @@ -1211,11 +1217,12 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { index |= GENERICDEF_USE_DEFORM_VERTEXES; } - +#ifdef REND2_SP if (glState.vertexAnimation) { index |= GENERICDEF_USE_VERTEX_ANIMATION; } +#endif // REND2_SP else if (glState.skeletalAnimation) { index |= GENERICDEF_USE_SKELETAL_ANIMATION; @@ -1253,24 +1260,18 @@ static shaderProgram_t *SelectShaderProgram( int stageIndex, shaderStage_t *stag { if (backEnd.currentEntity && backEnd.currentEntity != &tr.worldEntity) { +#ifdef REND2_SP if (glState.vertexAnimation) { index |= LIGHTDEF_USE_VERTEX_ANIMATION; } - +#endif // REND2_SP if (glState.skeletalAnimation) { index |= LIGHTDEF_USE_SKELETAL_ANIMATION; } } - if (r_sunlightMode->integer && - (backEnd.viewParms.flags & VPF_USESUNLIGHT) && - (index & LIGHTDEF_LIGHTTYPE_MASK)) - { - index |= LIGHTDEF_USE_SHADOWMAP; - } - if ( !useAlphaTestGE192 ) { if (stage->alphaTestType != ALPHA_TEST_NONE) @@ -1612,6 +1613,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays { samplerBindingsWriter.AddStaticImage(tr.screenShadowImage, TB_SHADOWMAP); } + else + samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SHADOWMAP); if ((r_lightmap->integer == 1 || r_lightmap->integer == 2) && (pStage->bundle[0].isLightmap || pStage->bundle[1].isLightmap)) From 46bbfc773b0e86cc6414f665648e79bd0671ee30 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 10 May 2023 11:16:04 +0200 Subject: [PATCH 672/708] Revert removing setting shader times Some calculations still need them to be set correctly... --- codemp/rd-rend2/tr_backend.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 9f03b89929..5ab89e06ad 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1167,16 +1167,24 @@ static Pass *RB_CreatePass( Allocator& allocator, int capacity ) return pass; } -static void RB_PrepareForEntity( int entityNum ) +static void RB_PrepareForEntity( int entityNum, float originalTime ) { if ( entityNum != REFENTITYNUM_WORLD ) { backEnd.currentEntity = &backEnd.refdef.entities[entityNum]; + + backEnd.refdef.floatTime = originalTime - backEnd.currentEntity->e.shaderTime; } else { backEnd.currentEntity = &tr.worldEntity; + + backEnd.refdef.floatTime = originalTime; } + + // we have to reset the shaderTime as well otherwise image animations on + // the world (like water) continue with the wrong frame + tess.shaderTime = backEnd.refdef.floatTime - tess.shader->timeOffset; } static void RB_SubmitDrawSurfsForDepthFill( @@ -1236,7 +1244,7 @@ static void RB_SubmitDrawSurfsForDepthFill( // change the modelview matrix if needed if ( entityNum != oldEntityNum ) { - RB_PrepareForEntity(entityNum); + RB_PrepareForEntity(entityNum, originalTime); oldEntityNum = entityNum; } @@ -1326,7 +1334,7 @@ static void RB_SubmitDrawSurfs( if ( entityNum != oldEntityNum ) { - RB_PrepareForEntity(entityNum); + RB_PrepareForEntity(entityNum, originalTime); oldEntityNum = entityNum; } From 90d5d919b1e549f2bcfc85d731e85fe8d72e0ad1 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 10 May 2023 13:50:15 +0200 Subject: [PATCH 673/708] Correct shader time ubo --- codemp/rd-rend2/tr_backend.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 5ab89e06ad..62a7bf0035 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2566,7 +2566,7 @@ static void RB_UpdateShaderEntityConstants( shaderInstanceBlock.time = backEnd.refdef.floatTime - shader->timeOffset; if (entityNum != REFENTITYNUM_WORLD) - shaderInstanceBlock.time = backEnd.refdef.floatTime - refEntity->e.shaderTime; + shaderInstanceBlock.time -= refEntity->e.shaderTime; const int uboOffset = RB_AppendConstantsData( frame, &shaderInstanceBlock, sizeof(shaderInstanceBlock)); From 370265f275eab9c0e011d1d6f7bae30c5f72f768 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 10 May 2023 15:41:30 +0200 Subject: [PATCH 674/708] Fix remaining lightsyles issues If a shader can't be collapsed, the renderer uses generic shaders. Those couldn't handle the texture coordinates for lightstyles. --- codemp/rd-rend2/glsl/generic.glsl | 47 ++++++++++++++++++++++--------- codemp/rd-rend2/tr_shader.cpp | 6 ++-- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index 1c669a067f..f66caa832a 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -15,6 +15,9 @@ in vec2 attr_TexCoord0; #if defined(USE_TCGEN) in vec2 attr_TexCoord1; +in vec2 attr_TexCoord2; +in vec2 attr_TexCoord3; +in vec2 attr_TexCoord4; #endif layout(std140) uniform Camera @@ -245,20 +248,38 @@ vec2 GenTexCoords(int TCGen, vec3 position, vec3 normal, vec3 TCGenVector0, vec3 { vec2 tex = attr_TexCoord0.st; - if (TCGen >= TCGEN_LIGHTMAP && TCGen <= TCGEN_LIGHTMAP3) + switch (TCGen) { - tex = attr_TexCoord1.st; - } - else if (TCGen == TCGEN_ENVIRONMENT_MAPPED) - { - vec3 viewer = normalize(u_LocalViewOrigin - position); - vec2 ref = reflect(viewer, normal).yz; - tex.s = ref.x * -0.5 + 0.5; - tex.t = ref.y * 0.5 + 0.5; - } - else if (TCGen == TCGEN_VECTOR) - { - tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + case TCGEN_LIGHTMAP: + tex = attr_TexCoord1; + break; + + case TCGEN_LIGHTMAP1: + tex = attr_TexCoord2; + break; + + case TCGEN_LIGHTMAP2: + tex = attr_TexCoord3; + break; + + case TCGEN_LIGHTMAP3: + tex = attr_TexCoord4; + break; + + case TCGEN_ENVIRONMENT_MAPPED: + { + vec3 viewer = normalize(u_LocalViewOrigin - position); + vec2 ref = reflect(viewer, normal).yz; + tex.s = ref.x * -0.5 + 0.5; + tex.t = ref.y * 0.5 + 0.5; + } + break; + + case TCGEN_VECTOR: + { + tex = vec2(dot(position, TCGenVector0), dot(position, TCGenVector1)); + } + break; } return tex; diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index 2796c958b5..dd03dc3a62 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3462,7 +3462,7 @@ static qboolean CollapseStagesToGLSL(void) // convert any remaining lightmap stages to a lighting pass with a white texture // only do this with r_sunlightMode non-zero, as it's only for correct shadows. - if (r_sunlightMode->integer && shader.numDeforms == 0) + if (r_sunlightMode->integer && shader.numDeforms != 1) { for (i = 0; i < MAX_SHADER_STAGES; i++) { @@ -3489,7 +3489,7 @@ static qboolean CollapseStagesToGLSL(void) } // convert any remaining lightingdiffuse stages to a lighting pass - if (shader.numDeforms == 0) + if (shader.numDeforms != 1) { for (i = 0; i < MAX_SHADER_STAGES; i++) { @@ -3939,7 +3939,7 @@ static shader_t *FinishShader( void ) { if (stages[0].active && stages[0].bundle[0].isLightmap && stages[1].active && - shader.numDeforms == 0) //only for shaders that can be collapsed + shader.numDeforms != 1) { int blendBits = stages[1].stateBits & (GLS_DSTBLEND_BITS | GLS_SRCBLEND_BITS); From c4c87fb022d26648d47dbb3971fe38841c7d4c7e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 10 May 2023 17:32:59 +0200 Subject: [PATCH 675/708] More cleanup --- codemp/rd-rend2/glsl/lightall.glsl | 5 ++--- codemp/rd-rend2/tr_shade.cpp | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 638035c4df..6f7df20ccc 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -83,7 +83,6 @@ uniform int u_ColorGen; out vec4 var_TexCoords; out vec4 var_Color; -out vec3 var_N; #if defined(PER_PIXEL_LIGHTING) out vec4 var_Normal; @@ -963,7 +962,7 @@ void main() float roughness = 0.99; #if defined(USE_SPECULARMAP) #if !defined(USE_SPECGLOSS) - vec4 ORMS = mix(vec4(1.0), texture(u_SpecularMap, texCoords), u_EnableTextures.z); + vec4 ORMS = texture(u_SpecularMap, texCoords); ORMS.xyzw *= u_SpecularScale.zwxy; specular.rgb = mix(vec3(0.08) * ORMS.w, diffuse.rgb, ORMS.z); @@ -972,7 +971,7 @@ void main() roughness = mix(0.01, 1.0, ORMS.y); AO = min(ORMS.x, AO); #else - specular = mix(vec4(1.0), texture(u_SpecularMap, texCoords), u_EnableTextures.z); + specular = texture(u_SpecularMap, texCoords); specular.rgb *= u_SpecularScale.xyz; roughness = mix(1.0, 0.01, specular.a * (1.0 - u_SpecularScale.w)); #endif diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 0087037638..b172323d0f 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1684,7 +1684,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays if (pStage->bundle[TB_SPECULARMAP].image[0]) { samplerBindingsWriter.AddAnimatedImage(&pStage->bundle[TB_SPECULARMAP], TB_SPECULARMAP); - enableTextures[2] = 1.0f; } else if (r_specularMapping->integer) { From a8131e1ae672a9c289144851fde8d77459483c95 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 18 May 2023 20:14:21 +0200 Subject: [PATCH 676/708] Store md3 surfaces in one vbo per mesh instead of creating a vbo per surface. --- codemp/rd-rend2/tr_model.cpp | 171 +++++++++++++++++++++++------------ 1 file changed, 115 insertions(+), 56 deletions(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index b95114639e..d82f39155e 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1068,87 +1068,146 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN vboSurf = mdvModel->vboSurfaces; surf = mdvModel->surfaces; - for (i = 0; i < mdvModel->numSurfaces; i++, vboSurf++, surf++) + + vec3_t *verts; + uint32_t *normals; + vec2_t *texcoords; + uint32_t *tangents; + + byte *data; + int dataSize = 0; + int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents; + int stride = 0; + int numVerts = 0; + int numIndexes = 0; + + // +1 to add total vertex count + int *baseVertexes = (int *)ri.Hunk_AllocateTempMemory(sizeof(int) * (mdvModel->numSurfaces + 1)); + int *indexOffsets = (int *)ri.Hunk_AllocateTempMemory(sizeof(int) * mdvModel->numSurfaces); + + // Calculate the required size of the vertex buffer. + for (int n = 0; n < mdvModel->numSurfaces; n++, surf++) { - vec3_t *verts; - vec2_t *texcoords; - uint32_t *normals; - uint32_t *tangents; + baseVertexes[n] = numVerts; + indexOffsets[n] = numIndexes; - byte *data; - int dataSize; + numVerts += surf->numVerts; + numIndexes += surf->numIndexes; + } - int ofs_xyz, ofs_normal, ofs_st; - int ofs_tangent; + ri.Printf(PRINT_ALL, "Verts %i Indexes %i\n", numVerts, numIndexes); - dataSize = 0; + baseVertexes[mdvModel->numSurfaces] = numVerts; - ofs_xyz = dataSize; - dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*verts); + dataSize += numVerts * sizeof(*verts); + dataSize += numVerts * sizeof(*normals); + dataSize += numVerts * sizeof(*texcoords); + dataSize += numVerts * sizeof(*tangents); - ofs_normal = dataSize; - dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*normals); + // Allocate and write to memory + data = (byte *)ri.Hunk_AllocateTempMemory(dataSize); - ofs_tangent = dataSize; - dataSize += surf->numVerts * mdvModel->numFrames * sizeof(*tangents); + ofsPosition = stride; + verts = (vec3_t *)(data + ofsPosition); + stride += sizeof(*verts); - ofs_st = dataSize; - dataSize += surf->numVerts * sizeof(*texcoords); + ofsNormals = stride; + normals = (uint32_t *)(data + ofsNormals); + stride += sizeof(*normals); - data = (byte *)Z_Malloc(dataSize, TAG_MODEL_MD3); + ofsTexcoords = stride; + texcoords = (vec2_t *)(data + ofsTexcoords); + stride += sizeof(*texcoords); + + ofsTangents = stride; + tangents = (uint32_t *)(data + ofsTangents); + stride += sizeof(*tangents); + + // Fill in the index buffer and compute tangents + glIndex_t *indices = (glIndex_t *)ri.Hunk_AllocateTempMemory(sizeof(glIndex_t) * numIndexes); + glIndex_t *index = indices; + + surf = mdvModel->surfaces; + for (i = 0; i < mdvModel->numSurfaces; i++, surf++) + { + uint32_t *tangentsf = (uint32_t *)ri.Hunk_AllocateTempMemory(sizeof(uint32_t) * surf->numVerts); + R_CalcMikkTSpaceMD3Surface( + surf->numIndexes / 3, + surf->verts, + tangentsf, + surf->st, + surf->indexes); + + for (int k = 0; k < surf->numIndexes; k++) + { + *index = surf->indexes[k] + baseVertexes[i]; + assert(*index >= 0 && *index < numVerts); + index++; + } - verts = (vec3_t *)(data + ofs_xyz); - normals = (uint32_t *)(data + ofs_normal); - tangents = (uint32_t *)(data + ofs_tangent); - texcoords = (vec2_t *)(data + ofs_st); - v = surf->verts; - for ( j = 0; j < surf->numVerts * mdvModel->numFrames ; j++, v++ ) + for (j = 0; j < surf->numVerts; j++, v++) { - VectorCopy(v->xyz, verts[j]); - normals[j] = R_VboPackNormal(v->normal); - tangents[j] = 0; + VectorCopy(v->xyz, *verts); + *normals = R_VboPackNormal(v->normal); + *tangents = tangentsf[j]; + + verts = (vec3_t *)((byte *)verts + stride); + normals = (uint32_t *)((byte *)normals + stride); + tangents = (uint32_t *)((byte *)tangents + stride); } + ri.Hunk_FreeTempMemory(tangentsf); st = surf->st; - for ( j = 0 ; j < surf->numVerts ; j++, st++ ) { - texcoords[j][0] = st->st[0]; - texcoords[j][1] = st->st[1]; + for (j = 0; j < surf->numVerts; j++, st++) { + (*texcoords)[0] = st->st[0]; + (*texcoords)[1] = st->st[1]; + + texcoords = (vec2_t *)((byte *)texcoords + stride); } + } - // If we would support vertex animations, we would need to compute tangents for the other frames too! - R_CalcMikkTSpaceMD3Surface(surf->numIndexes/3, verts, normals, tangents, texcoords, surf->indexes); + assert((byte *)verts == (data + dataSize)); - vboSurf->surfaceType = SF_VBO_MDVMESH; - vboSurf->mdvModel = mdvModel; - vboSurf->mdvSurface = surf; - vboSurf->numIndexes = surf->numIndexes; - vboSurf->numVerts = surf->numVerts; - - vboSurf->minIndex = 0; - vboSurf->maxIndex = surf->numVerts; + VBO_t *vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); + IBO_t *ibo = R_CreateIBO((byte *)indices, sizeof(glIndex_t) * numIndexes, VBO_USAGE_STATIC); - vboSurf->vbo = R_CreateVBO(data, dataSize, VBO_USAGE_STATIC); + ri.Hunk_FreeTempMemory(data); + ri.Hunk_FreeTempMemory(indices); - vboSurf->vbo->offsets[ATTR_INDEX_POSITION] = ofs_xyz; - vboSurf->vbo->offsets[ATTR_INDEX_NORMAL] = ofs_normal; - vboSurf->vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofs_st; - vboSurf->vbo->offsets[ATTR_INDEX_TANGENT] = ofs_tangent; + vbo->offsets[ATTR_INDEX_POSITION] = ofsPosition; + vbo->offsets[ATTR_INDEX_NORMAL] = ofsNormals; + vbo->offsets[ATTR_INDEX_TEXCOORD0] = ofsTexcoords; + vbo->offsets[ATTR_INDEX_TANGENT] = ofsTangents; - vboSurf->vbo->strides[ATTR_INDEX_POSITION] = sizeof(*verts); - vboSurf->vbo->strides[ATTR_INDEX_NORMAL] = sizeof(*normals); - vboSurf->vbo->strides[ATTR_INDEX_TEXCOORD0] = sizeof(*st); - vboSurf->vbo->strides[ATTR_INDEX_TANGENT] = sizeof(*tangents); + vbo->strides[ATTR_INDEX_POSITION] = stride; + vbo->strides[ATTR_INDEX_NORMAL] = stride; + vbo->strides[ATTR_INDEX_TEXCOORD0] = stride; + vbo->strides[ATTR_INDEX_TANGENT] = stride; - vboSurf->vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); - vboSurf->vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); - vboSurf->vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); - vboSurf->vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); + vbo->sizes[ATTR_INDEX_POSITION] = sizeof(*verts); + vbo->sizes[ATTR_INDEX_NORMAL] = sizeof(*normals); + vbo->sizes[ATTR_INDEX_TEXCOORD0] = sizeof(*texcoords); + vbo->sizes[ATTR_INDEX_TANGENT] = sizeof(*tangents); - Z_Free(data); + surf = mdvModel->surfaces; + for (i = 0; i < mdvModel->numSurfaces; i++, surf++, vboSurf++) + { + vboSurf->surfaceType = SF_VBO_MDVMESH; + vboSurf->mdvModel = mdvModel; + vboSurf->mdvSurface = surf; + vboSurf->vbo = vbo; + vboSurf->ibo = ibo; - vboSurf->ibo = R_CreateIBO ((byte *)surf->indexes, sizeof (glIndex_t) * surf->numIndexes, VBO_USAGE_STATIC); + vboSurf->indexOffset = indexOffsets[i]; + vboSurf->minIndex = baseVertexes[i]; + vboSurf->maxIndex = baseVertexes[i + 1] - 1; + vboSurf->numVerts = surf->numVerts; + vboSurf->numIndexes = surf->numIndexes; } + + ri.Hunk_FreeTempMemory(indexOffsets); + ri.Hunk_FreeTempMemory(baseVertexes); } return qtrue; From def172f7fea16fdb1ebf4f34f8b5d58b8af8650d Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 18 May 2023 20:16:21 +0200 Subject: [PATCH 677/708] Merge md3 surfaces pt 2 --- codemp/rd-rend2/tr_local.h | 3 +- codemp/rd-rend2/tr_surface.cpp | 98 ++++++++++++++++++++++------- codemp/rd-rend2/tr_tangentspace.cpp | 25 ++++---- 3 files changed, 89 insertions(+), 37 deletions(-) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 88015cdf4b..169d54a942 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -1808,6 +1808,7 @@ typedef struct srfVBOMDVMesh_s struct mdvSurface_s *mdvSurface; // backEnd stats + int indexOffset; int numIndexes; int numVerts; glIndex_t minIndex; @@ -2837,7 +2838,7 @@ void R_AddDrawSurf( surfaceType_t *surface, int entityNum, shader_t *shader, bool R_IsPostRenderEntity ( const trRefEntity_t *refEntity ); void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glIndex_t *indices); -void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices); +void R_CalcMikkTSpaceMD3Surface(int numSurfaces, mdvVertex_t *verts, uint32_t *tangents, mdvSt_t *texcoords, glIndex_t *indices); void R_CalcMikkTSpaceGlmSurface(int numSurfaces, mdxmVertex_t *vertices, mdxmVertexTexCoord_t *textureCoordinates, uint32_t *tangents, glIndex_t *indices); void R_CalcTexDirs(vec3_t sdir, vec3_t tdir, const vec3_t v1, const vec3_t v2, diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 8fa6163420..6c1c19c337 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2084,55 +2084,109 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) //mdvModel_t *mdvModel; //mdvSurface_t *mdvSurface; refEntity_t *refEnt; + int i, mergeForward, mergeBack; + GLvoid *firstIndexOffset, *lastIndexOffset; GLimp_LogComment("--- RB_SurfaceVBOMDVMesh ---\n"); if(!surface->vbo || !surface->ibo) return; + if (glState.currentVBO != surface->vbo) + { + RB_EndSurface(); + } + //drawSurf_t drawSurf = int dlightBits = tess.dlightBits; - //RB_CheckVBOandIBO(surface->vbo, surface->ibo); - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); - R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); tess.useInternalVBO = qfalse; tess.externalIBO = surface->ibo; - tess.numIndexes += surface->numIndexes; - tess.numVertexes += surface->numVerts; - tess.minIndex = surface->minIndex; - tess.maxIndex = surface->maxIndex; tess.dlightBits = dlightBits; - //mdvModel = surface->mdvModel; - //mdvSurface = surface->mdvSurface; - refEnt = &backEnd.currentEntity->e; + // merge this into any existing multidraw primitives + mergeForward = -1; + mergeBack = -1; + firstIndexOffset = BUFFER_OFFSET(surface->indexOffset * sizeof(glIndex_t)); + lastIndexOffset = BUFFER_OFFSET(surface->numIndexes * sizeof(glIndex_t)); - if ( refEnt->oldframe || refEnt->frame ) + if (r_mergeMultidraws->integer) { - if(refEnt->oldframe == refEnt->frame) + i = 0; + + if (r_mergeMultidraws->integer == 1) { - glState.vertexAttribsInterpolation = 0; + // lazy merge, only check the last primitive + if (tess.multiDrawPrimitives) + { + i = tess.multiDrawPrimitives - 1; + } } - else + + for (; i < tess.multiDrawPrimitives; i++) { - glState.vertexAttribsInterpolation = refEnt->backlerp; + if (tess.multiDrawLastIndex[i] == firstIndexOffset) + { + mergeBack = i; + } + + if (lastIndexOffset == tess.multiDrawFirstIndex[i]) + { + mergeForward = i; + } } + } - glState.vertexAttribsOldFrame = refEnt->oldframe; - glState.vertexAttribsNewFrame = refEnt->frame; - glState.vertexAnimation = qtrue; + if (mergeBack != -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[mergeBack] += surface->numIndexes; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], surface->minIndex); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], surface->maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack == -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeForward] += surface->numIndexes; + tess.multiDrawFirstIndex[mergeForward] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], surface->minIndex); + tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], surface->maxIndex); + backEnd.pc.c_multidrawsMerged++; } + else if (mergeBack != -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeBack] += surface->numIndexes + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], surface->minIndex)); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], surface->maxIndex)); + tess.multiDrawPrimitives--; - RB_EndSurface(); + if (mergeForward != tess.multiDrawPrimitives) + { + tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives]; + tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives]; + } + backEnd.pc.c_multidrawsMerged += 2; + } + else if (mergeBack == -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = surface->numIndexes; + tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[tess.multiDrawPrimitives] = (glIndex_t *)lastIndexOffset; + tess.multiDrawMinIndex[tess.multiDrawPrimitives] = surface->minIndex; + tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = surface->maxIndex; + tess.multiDrawPrimitives++; + } - // So we don't lerp surfaces that shouldn't be lerped - glState.vertexAnimation = qfalse; + backEnd.pc.c_multidraws++; + + tess.numIndexes += surface->numIndexes; + tess.numVertexes += surface->numVerts; } static void RB_SurfaceSkip( void *surf ) { diff --git a/codemp/rd-rend2/tr_tangentspace.cpp b/codemp/rd-rend2/tr_tangentspace.cpp index ae98a67476..0c523784e6 100644 --- a/codemp/rd-rend2/tr_tangentspace.cpp +++ b/codemp/rd-rend2/tr_tangentspace.cpp @@ -135,11 +135,9 @@ void R_CalcMikkTSpaceBSPSurface(int numSurfaces, packedVertex_t *vertices, glInd struct ModelMeshData { int numSurfaces; - vec3_t *verts; - uint32_t *normals; + mdvVertex_t *verts; uint32_t *tangents; - vec2_t *texcoords; - int stride; + mdvSt_t *texcoords; glIndex_t *indices; }; @@ -148,9 +146,9 @@ void R_GetModelPosition(const SMikkTSpaceContext * pContext, float *fvPosOut, co ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; const int vert_index = R_FixMikktVertIndex(iVert); glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - fvPosOut[0] = meshData->verts[index][0]; - fvPosOut[1] = meshData->verts[index][1]; - fvPosOut[2] = meshData->verts[index][2]; + fvPosOut[0] = meshData->verts[index].xyz[0]; + fvPosOut[1] = meshData->verts[index].xyz[1]; + fvPosOut[2] = meshData->verts[index].xyz[2]; } void R_GetNormalModelSurface(const SMikkTSpaceContext * pContext, float *fvNormOut, const int iFace, const int iVert) @@ -159,9 +157,9 @@ void R_GetNormalModelSurface(const SMikkTSpaceContext * pContext, float *fvNormO const int vert_index = R_FixMikktVertIndex(iVert); glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - fvNormOut[0] = ((meshData->normals[index]) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[1] = ((meshData->normals[index] >> 10) & 0x3ff) * 1.0f / 511.5f - 1.0f; - fvNormOut[2] = ((meshData->normals[index] >> 20) & 0x3ff) * 1.0f / 511.5f - 1.0f; + fvNormOut[0] = meshData->verts[index].normal[0]; + fvNormOut[1] = meshData->verts[index].normal[1]; + fvNormOut[2] = meshData->verts[index].normal[2]; } void R_GetModelTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, const int iFace, const int iVert) @@ -169,8 +167,8 @@ void R_GetModelTexCoord(const SMikkTSpaceContext * pContext, float *fvTexcOut, c ModelMeshData *meshData = (ModelMeshData *)pContext->m_pUserData; const int vert_index = R_FixMikktVertIndex(iVert); glIndex_t index = meshData->indices[iFace * 3 + vert_index]; - fvTexcOut[0] = meshData->texcoords[index][0]; - fvTexcOut[1] = meshData->texcoords[index][1]; + fvTexcOut[0] = meshData->texcoords[index].st[0]; + fvTexcOut[1] = meshData->texcoords[index].st[1]; } void R_SetModelTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvTangent, const float fSign, const int iFace, const int iVert) @@ -187,7 +185,7 @@ void R_SetModelTSpaceBasic(const SMikkTSpaceContext * pContext, const float *fvT } -void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normals, uint32_t *tangents, vec2_t *texcoords, glIndex_t *indices) +void R_CalcMikkTSpaceMD3Surface(int numSurfaces, mdvVertex_t *verts, uint32_t *tangents, mdvSt_t *texcoords, glIndex_t *indices) { SMikkTSpaceInterface tangentSpaceInterface; tangentSpaceInterface.m_getNumFaces = R_GetNumFaces; @@ -201,7 +199,6 @@ void R_CalcMikkTSpaceMD3Surface(int numSurfaces, vec3_t *verts, uint32_t *normal ModelMeshData meshData; meshData.numSurfaces = numSurfaces; meshData.verts = verts; - meshData.normals = normals; meshData.tangents = tangents; meshData.texcoords = texcoords; meshData.indices = indices; From daf2d2903bb949dedaba7191e1c1a1243306e33b Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Thu, 18 May 2023 20:52:53 +0200 Subject: [PATCH 678/708] Merge ghoul2 draws per shader --- codemp/rd-rend2/tr_backend.cpp | 22 ++++++ codemp/rd-rend2/tr_ghoul2.cpp | 134 ++++++++++++++++++++++++--------- codemp/rd-rend2/tr_shade.cpp | 3 + 3 files changed, 125 insertions(+), 34 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 62a7bf0035..8acc520afc 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -1196,6 +1196,7 @@ static void RB_SubmitDrawSurfsForDepthFill( int oldEntityNum = -1; int oldSort = -1; int oldDepthRange = 0; + CBoneCache *oldBoneCache = nullptr; drawSurf_t *drawSurf = drawSurfs; for ( int i = 0; i < numDrawSurfs; i++, drawSurf++ ) @@ -1214,6 +1215,16 @@ static void RB_SubmitDrawSurfsForDepthFill( continue; } + if (*drawSurf->surface == SF_MDX) + { + if (((CRenderableSurface*)drawSurf->surface)->boneCache != oldBoneCache) + { + RB_EndSurface(); + RB_BeginSurface(shader, 0, 0); + oldBoneCache = ((CRenderableSurface*)drawSurf->surface)->boneCache; + } + } + if ( shader == oldShader && entityNum == oldEntityNum ) { // fast path, same as previous sort @@ -1275,6 +1286,7 @@ static void RB_SubmitDrawSurfs( int oldDlighted = 0; int oldPostRender = 0; int oldCubemapIndex = -1; + CBoneCache *oldBoneCache = nullptr; drawSurf_t *drawSurf = drawSurfs; for ( int i = 0; i < numDrawSurfs; i++, drawSurf++ ) @@ -1291,6 +1303,16 @@ static void RB_SubmitDrawSurfs( fogNum = drawSurf->fogIndex; dlighted = drawSurf->dlightBits; + if (*drawSurf->surface == SF_MDX) + { + if (((CRenderableSurface*)drawSurf->surface)->boneCache != oldBoneCache) + { + RB_EndSurface(); + RB_BeginSurface(shader, fogNum, cubemapIndex); + oldBoneCache = ((CRenderableSurface*)drawSurf->surface)->boneCache; + } + } + if ( shader == oldShader && fogNum == oldFogNum && postRender == oldPostRender && diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 95225fab28..729dea8e30 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3491,23 +3491,24 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) return; } - RB_EndSurface(); - RB_BeginSurface(tess.shader, tess.fogNum, tess.cubemapIndex); + int numIndexes = surface->numIndexes; + int numVertexes = surface->numVertexes; + int minIndex = surface->minIndex; + int maxIndex = surface->maxIndex; + int indexOffset = surface->indexOffset; #ifdef _G2_GORE if (surf->alternateTex) { R_BindVBO(tr.goreVBO); R_BindIBO(tr.goreIBO); - - tess.numIndexes = surf->alternateTex->numIndexes; - tess.numVertexes = surf->alternateTex->numVerts; - tess.useInternalVBO = qfalse; tess.externalIBO = tr.goreIBO; - tess.dlightBits = surf->dlightBits; - tess.minIndex = surf->alternateTex->firstVert; - tess.maxIndex = surf->alternateTex->firstVert + surf->alternateTex->numVerts; - tess.firstIndex = surf->alternateTex->firstIndex; + + numIndexes = surf->alternateTex->numIndexes; + numVertexes = surf->alternateTex->numVerts; + minIndex = surf->alternateTex->firstVert; + maxIndex = surf->alternateTex->firstVert + surf->alternateTex->numVerts; + indexOffset = surf->alternateTex->firstIndex; #ifdef REND2_SP_MAYBE // UNTESTED CODE @@ -3543,41 +3544,106 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.svars.colors[tess.firstIndex][3] = lFade; } } -#endif - glState.skeletalAnimation = qtrue; - RB_EndSurface(); - // So we don't lerp surfaces that shouldn't be lerped - glState.skeletalAnimation = qfalse; -#ifdef REND2_SP_MAYBE tess.scale = false; tess.fade = false; #endif - return; + } else { +#endif + + R_BindVBO(surface->vbo); + R_BindIBO(surface->ibo); + tess.externalIBO = surface->ibo; + + glState.genShadows = surf->genShadows; +#ifdef _G2_GORE } #endif + int i, mergeForward, mergeBack; + GLvoid *firstIndexOffset, *lastIndexOffset; - R_BindVBO(surface->vbo); - R_BindIBO(surface->ibo); + // merge this into any existing multidraw primitives + mergeForward = -1; + mergeBack = -1; + firstIndexOffset = BUFFER_OFFSET(indexOffset * sizeof(glIndex_t)); + lastIndexOffset = BUFFER_OFFSET((indexOffset + numIndexes) * sizeof(glIndex_t)); - tess.dlightBits = surf->dlightBits; + if (r_mergeMultidraws->integer) + { + i = 0; - tess.useInternalVBO = qfalse; - tess.externalIBO = surface->ibo; + if (r_mergeMultidraws->integer == 1) + { + // lazy merge, only check the last primitive + if (tess.multiDrawPrimitives) + { + i = tess.multiDrawPrimitives - 1; + } + } - tess.numIndexes += surface->numIndexes; - tess.numVertexes += surface->numVertexes; - tess.minIndex = surface->minIndex; - tess.maxIndex = surface->maxIndex; - tess.firstIndex = surface->indexOffset; + for (; i < tess.multiDrawPrimitives; i++) + { + if (tess.multiDrawLastIndex[i] == firstIndexOffset) + { + mergeBack = i; + } - glState.genShadows = surf->genShadows; - glState.skeletalAnimation = qtrue; + if (lastIndexOffset == tess.multiDrawFirstIndex[i]) + { + mergeForward = i; + } + } + } + + if (mergeBack != -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack == -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeForward] += numIndexes; + tess.multiDrawFirstIndex[mergeForward] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex); + tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex); + backEnd.pc.c_multidrawsMerged++; + } + else if (mergeBack != -1 && mergeForward != -1) + { + tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward]; + tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack]; + tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex)); + tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex)); + tess.multiDrawPrimitives--; - RB_EndSurface(); + if (mergeForward != tess.multiDrawPrimitives) + { + tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives]; + tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives]; + } + backEnd.pc.c_multidrawsMerged += 2; + } + else if (mergeBack == -1 && mergeForward == -1) + { + tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes; + tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = (glIndex_t *)firstIndexOffset; + tess.multiDrawLastIndex[tess.multiDrawPrimitives] = (glIndex_t *)lastIndexOffset; + tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex; + tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex; + tess.multiDrawPrimitives++; + } - // So we don't lerp surfaces that shouldn't be lerped - glState.skeletalAnimation = qfalse; - glState.genShadows = qfalse; + backEnd.pc.c_multidraws++; + + tess.numIndexes += numIndexes; + tess.numVertexes += numVertexes; + tess.useInternalVBO = qfalse; + tess.dlightBits = surf->dlightBits; + + glState.skeletalAnimation = qtrue; } /* @@ -4213,7 +4279,7 @@ qboolean R_LoadMDXM(model_t *mod, void *buffer, const char *mod_name, qboolean & // Fill in the index buffer and compute tangents glIndex_t *indices = (glIndex_t *)ri.Hunk_AllocateTempMemory(sizeof(glIndex_t) * numTriangles * 3); glIndex_t *index = indices; - uint32_t *tangentsf = (uint32_t *)ri.Hunk_AllocateTempMemory(sizeof(uint32_t) * numVerts);; + uint32_t *tangentsf = (uint32_t *)ri.Hunk_AllocateTempMemory(sizeof(uint32_t) * numVerts); surf = (mdxmSurface_t *)((byte *)lod + sizeof(mdxmLOD_t) + (mdxm->numSurfaces * sizeof(mdxmLODSurfOffset_t))); diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index b172323d0f..764825d984 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -2027,6 +2027,9 @@ void RB_EndSurface( void ) { tess.firstIndex = 0; tess.multiDrawPrimitives = 0; tess.externalIBO = nullptr; + glState.vertexAnimation = qfalse; + glState.skeletalAnimation = qfalse; + glState.genShadows = qfalse; GLimp_LogComment( "----------\n" ); } From dbc3a71e1bf3319bcb68e917e00b1aec954507de Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 20 May 2023 00:51:10 +0200 Subject: [PATCH 679/708] Try fixing x86 ubuntu builds --- .github/workflows/build.yml | 2 +- .github/workflows/rend2.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a1d035730d..ec8385bef6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -159,7 +159,7 @@ jobs: sudo apt-get -qq update sudo apt-get -y install aptitude sudo apt-get -y install gcc-multilib g++-multilib ninja-build - sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 + sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgcc-s1:i386 sudo aptitude -y install libglib2.0-dev:i386 libsdl2-dev:i386 else sudo apt-get -qq update diff --git a/.github/workflows/rend2.yml b/.github/workflows/rend2.yml index 24cbeb9426..3f925d2f7e 100644 --- a/.github/workflows/rend2.yml +++ b/.github/workflows/rend2.yml @@ -159,7 +159,7 @@ jobs: sudo apt-get -qq update sudo apt-get -y install aptitude sudo apt-get -y install gcc-multilib g++-multilib ninja-build - sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 + sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgcc-s1:i386 sudo aptitude -y install libglib2.0-dev:i386 libsdl2-dev:i386 else sudo apt-get -qq update From e4d62d3615ef939cc029f3f948099b050b90f979 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 20 May 2023 01:00:24 +0200 Subject: [PATCH 680/708] Only modulate sun shadows when there's a shadowmap --- codemp/rd-rend2/glsl/lightall.glsl | 3 ++- codemp/rd-rend2/tr_shade.cpp | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 6f7df20ccc..87cc70adb4 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -926,7 +926,8 @@ void main() shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) - lightColor = mix(u_PrimaryLightAmbient * lightColor, lightColor, shadowValue); + vec3 ambientScale = mix(vec3(1.0), u_PrimaryLightAmbient, u_EnableTextures.z); + lightColor = mix(ambientScale * lightColor, lightColor, shadowValue); #endif #endif diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 764825d984..396a2743c2 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -1612,6 +1612,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { samplerBindingsWriter.AddStaticImage(tr.screenShadowImage, TB_SHADOWMAP); + enableTextures[2] = 1.0f; } else samplerBindingsWriter.AddStaticImage(tr.whiteImage, TB_SHADOWMAP); From e2416545d2d45592c174c932b9e5b9bc80cb9c23 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 20 May 2023 01:01:00 +0200 Subject: [PATCH 681/708] Mini cleanup --- codemp/rd-rend2/tr_model.cpp | 3 --- codemp/rd-rend2/tr_weather.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index d82f39155e..7d97209749 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1094,9 +1094,6 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN numVerts += surf->numVerts; numIndexes += surf->numIndexes; } - - ri.Printf(PRINT_ALL, "Verts %i Indexes %i\n", numVerts, numIndexes); - baseVertexes[mdvModel->numSurfaces] = numVerts; dataSize += numVerts * sizeof(*verts); diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 0b1d8a3722..8030ca7a3f 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -183,7 +183,6 @@ namespace qglViewport(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); qglScissor(0, 0, tr.weatherDepthFbo->width, tr.weatherDepthFbo->height); - if (tr.weatherSystem->weatherBrushType == WEATHER_BRUSHES_OUTSIDE) // used outside brushes { @@ -203,7 +202,6 @@ namespace GL_Cull(CT_TWO_SIDED); vec4_t color = { 0.0f, 0.0f, 0.0f, 1.0f }; backEnd.currentEntity = &tr.worldEntity; - vec3_t stepSize = { abs(mapSize[0]) / tr.weatherDepthFbo->width, From 08681e4cfd447707b0df892a8c348df937dee142 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 00:57:48 +0200 Subject: [PATCH 682/708] Don't upload bone matrices multiple times per frame --- codemp/rd-rend2/tr_backend.cpp | 4 ++-- codemp/rd-rend2/tr_ghoul2.cpp | 10 ++++++++-- codemp/rd-rend2/tr_local.h | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 8acc520afc..8ea40d3caa 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2690,7 +2690,7 @@ static void RB_UpdateAnimationConstants( continue; CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; - RB_TransformBones(RS); + RB_TransformBones(RS, backEndData->realFrameNumber); } // now get offsets or add skeletons to ubo @@ -2710,7 +2710,7 @@ static void RB_UpdateAnimationConstants( tr.animationBoneUboOffsets[i] = RB_AppendConstantsData( frame, &bonesBlock, sizeof(bonesBlock)); - RB_SetBoneUboOffset(RS, tr.animationBoneUboOffsets[i]); + RB_SetBoneUboOffset(RS, tr.animationBoneUboOffsets[i], backEndData->realFrameNumber); } else { diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 729dea8e30..4701ba6899 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -416,6 +416,7 @@ class CBoneCache // GPU Data mat3x4_t boneMatrices[MAX_G2_BONES]; int uboOffset; + int uboGPUFrame; CBoneCache( const model_t *amod, const mdxaHeader_t *aheader ) : header(aheader) @@ -430,6 +431,7 @@ class CBoneCache , mUnsquash(false) , mSmoothFactor(0.0f) , uboOffset(-1) + , uboGPUFrame(-1) { assert(amod); assert(aheader); @@ -3443,8 +3445,11 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } -void RB_TransformBones(CRenderableSurface *surf) +void RB_TransformBones(CRenderableSurface *surf, int currentFrameNum) { + if (surf->boneCache->uboGPUFrame == currentFrameNum) + return; + const mdxmSurface_t *surfData = surf->surfaceData; const int *boneReferences = (const int *)((const byte *)surfData + surfData->ofsBoneReferences); @@ -3469,9 +3474,10 @@ int RB_GetBoneUboOffset(CRenderableSurface *surf) return -1; } -void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset) +void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset, int currentFrameNum) { surf->boneCache->uboOffset = offset; + surf->boneCache->uboGPUFrame = currentFrameNum; } void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices) diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index 169d54a942..d14178aaf4 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -3392,9 +3392,9 @@ class CRenderableSurface void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); void RB_SurfaceGhoul( CRenderableSurface *surf ); -void RB_TransformBones(CRenderableSurface *surf); +void RB_TransformBones(CRenderableSurface *surf, int currentFrameNum); int RB_GetBoneUboOffset(CRenderableSurface *surf); -void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset); +void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset, int currentFrameNum); void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices); /* Ghoul2 Insert End From a2f4bbb406e16a5a618c951e63b2730a92a60820 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 01:54:45 +0200 Subject: [PATCH 683/708] Reset numDrawSurfs after each dlight shadow render --- codemp/rd-rend2/tr_main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 5e42333955..e83a5cf6b3 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2223,6 +2223,10 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.targetFboLayer = 0; R_RenderView(&shadowParms); + + R_IssuePendingRenderCommands(); + + tr.refdef.numDrawSurfs = 0; } } } From 7d0956d69bb1eadfa4b10fbb64224a916aecbabd Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 04:18:13 +0200 Subject: [PATCH 684/708] Fix rendering weather brushes When there were too many weather brushes, we exceeded the frames tess memory. This lead to skipping parts of the inside or outside brushes. --- codemp/rd-rend2/tr_weather.cpp | 70 +++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 8030ca7a3f..5f4a106eb2 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -177,6 +177,8 @@ namespace tr.viewParms.world.modelViewMatrix, tr.weatherSystem->weatherMVP); + R_IssuePendingRenderCommands(); + if (tr.weatherSystem->numWeatherBrushes > 0) { FBO_Bind(tr.weatherDepthFbo); @@ -227,7 +229,7 @@ namespace for (int i = 0; i < tr.weatherSystem->numWeatherBrushes; i++) { - RB_BeginSurface(tr.defaultShader, 0, 0); + RE_BeginFrame(STEREO_CENTER); weatherBrushes_t *currentWeatherBrush = &tr.weatherSystem->weatherBrushes[i]; // RBSP brushes actually store their bounding box in the first 6 planes! Nice @@ -307,29 +309,59 @@ namespace if (!hit) continue; - // Just draw it now + // Just draw it when batch is full + if (tess.numVertexes + 4 >= SHADER_MAX_VERTEXES || tess.numIndexes + 6 >= SHADER_MAX_INDEXES) + { + RB_UpdateVBOs(ATTR_POSITION); + GLSL_VertexAttribsState(ATTR_POSITION, NULL); + GLSL_BindProgram(&tr.textureColorShader); + GLSL_SetUniformMatrix4x4( + &tr.textureColorShader, + UNIFORM_MODELVIEWPROJECTIONMATRIX, + tr.weatherSystem->weatherMVP); + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + RB_CommitInternalBufferData(); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.multiDrawPrimitives = 0; + tess.externalIBO = nullptr; + } + RB_AddQuadStamp(rayPos, left, up, color); - - RB_UpdateVBOs(ATTR_POSITION); - GLSL_VertexAttribsState(ATTR_POSITION, NULL); - GLSL_BindProgram(&tr.textureColorShader); - GLSL_SetUniformMatrix4x4( - &tr.textureColorShader, - UNIFORM_MODELVIEWPROJECTIONMATRIX, - tr.weatherSystem->weatherMVP); - R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); - - RB_CommitInternalBufferData(); - - tess.numIndexes = 0; - tess.numVertexes = 0; - tess.firstIndex = 0; - tess.multiDrawPrimitives = 0; - tess.externalIBO = nullptr; } } + + gpuFrame_t *currentFrame = backEndData->currentFrame; + assert(!currentFrame->sync); + currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + backEndData->realFrameNumber++; + backEnd.framePostProcessed = qfalse; + backEnd.projection2D = qfalse; + backEnd.frameUBOsInitialized = qfalse; } + // draw remaining quads + RB_UpdateVBOs(ATTR_POSITION); + GLSL_VertexAttribsState(ATTR_POSITION, NULL); + GLSL_BindProgram(&tr.textureColorShader); + GLSL_SetUniformMatrix4x4( + &tr.textureColorShader, + UNIFORM_MODELVIEWPROJECTIONMATRIX, + tr.weatherSystem->weatherMVP); + R_DrawElementsVBO(tess.numIndexes, tess.firstIndex, tess.minIndex, tess.maxIndex); + + RB_CommitInternalBufferData(); + + tess.numIndexes = 0; + tess.numVertexes = 0; + tess.firstIndex = 0; + tess.multiDrawPrimitives = 0; + tess.externalIBO = nullptr; + qglDisable(GL_DEPTH_CLAMP); } From 9f7ec62a78a87368e057a1cccf5d9b699493dc73 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 12:09:32 +0200 Subject: [PATCH 685/708] Clear depth buffer before rendering the splash screen --- codemp/rd-rend2/tr_init.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 5ab07883df..beb7f53e81 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -280,6 +280,7 @@ static void R_Splash() qglViewport( 0, 0, glConfig.vidWidth, glConfig.vidHeight ); qglClearBufferfv(GL_COLOR, 0, black); + qglClear(GL_DEPTH_BUFFER_BIT); GLSL_InitSplashScreenShader(); @@ -291,7 +292,7 @@ static void R_Splash() GL_State(GLS_DEPTHTEST_DISABLE); GLSL_BindProgram(&tr.splashScreenShader); - qglDrawArrays(GL_TRIANGLES, 0, 3); + RB_InstantTriangle(); ri.WIN_Present(&window); } From 86282be573c0da8d39f71799f65fc24aadee92ee Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 13:12:11 +0200 Subject: [PATCH 686/708] Mini cleanup --- codemp/rd-rend2/tr_backend.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 8ea40d3caa..6156cab6dc 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2376,7 +2376,6 @@ static void RB_UpdateEntityMatrixConstants( EntityBlock& entityBlock, const trRefEntity_t *refEntity) { - matrix_t modelViewMatrix; orientationr_t ori; if (refEntity == &tr.worldEntity) { @@ -2389,7 +2388,6 @@ static void RB_UpdateEntityMatrixConstants( Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); } - Matrix16Copy(ori.modelViewMatrix, modelViewMatrix); VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); } From a727f57bd9bd04ed2a6420f9419bd7c1b72d98a7 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 13:45:05 +0200 Subject: [PATCH 687/708] Make sure there is always a valid ubo bind for the lights, scene and fogs ubos. --- codemp/rd-rend2/tr_cmds.cpp | 4 +++ codemp/rd-rend2/tr_init.cpp | 30 +++++++++++++++- codemp/rd-rend2/tr_local.h | 4 ++- codemp/rd-rend2/tr_shade.cpp | 70 +++++++++++++++++++++++++++++++----- 4 files changed, 98 insertions(+), 10 deletions(-) diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index f9873ff619..3daea6e7ce 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -564,6 +564,10 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { tr.frameCount++; tr.frameSceneNum = 0; + tr.fogsUboOffset = -1; + tr.lightsUboOffset = -1; + tr.sceneUboOffset = -1; + // // do overdraw measurement // diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index beb7f53e81..031f24242a 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1820,7 +1820,35 @@ static void R_InitStaticConstants() tr.cameraFlareUboOffset = alignedBlockSize; qglBufferSubData( GL_UNIFORM_BUFFER, tr.cameraFlareUboOffset, sizeof(flareCameraBlock), &flareCameraBlock); - //alignedBlockSize += (sizeof(CameraBlock) + alignment) & ~alignment; // un-comment if you add more blocks to the static ubo + alignedBlockSize += (sizeof(CameraBlock) + alignment) & ~alignment; + + // Setup default light block + LightsBlock lightsBlock = {}; + lightsBlock.numLights = 0; + + tr.defaultLightsUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.defaultLightsUboOffset, sizeof(lightsBlock), &lightsBlock); + alignedBlockSize += (sizeof(LightsBlock) + alignment) & ~alignment; + + // Setup default scene block + SceneBlock sceneBlock = {}; + sceneBlock.globalFogIndex = -1; + sceneBlock.currentTime = 0.1f; + sceneBlock.frameTime = 0.1f; + + tr.defaultSceneUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.defaultSceneUboOffset, sizeof(sceneBlock), &sceneBlock); + alignedBlockSize += (sizeof(SceneBlock) + alignment) & ~alignment; + + // Setup default fogs block + FogsBlock fogsBlock = {}; + fogsBlock.numFogs = 0; + tr.defaultFogsUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.defaultFogsUboOffset, sizeof(fogsBlock), &fogsBlock); + alignedBlockSize += (sizeof(FogsBlock) + alignment) & ~alignment; } static void R_ShutdownBackEndFrameData() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index d14178aaf4..c442f178e1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2512,9 +2512,11 @@ typedef struct trGlobals_s { int camera2DUboOffset; int entityFlareUboOffset; int cameraFlareUboOffset; + int defaultLightsUboOffset; + int defaultSceneUboOffset; + int defaultFogsUboOffset; int cameraUboOffset; - int sceneUboOffset; int lightsUboOffset; int fogsUboOffset; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 396a2743c2..373a17c651 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -714,6 +714,63 @@ static UniformBlockBinding GetCameraBlockUniformBinding( return binding; } +static UniformBlockBinding GetLightsBlockUniformBinding() +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.block = UNIFORM_BLOCK_LIGHTS; + + if (tr.lightsUboOffset == -1) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.defaultLightsUboOffset; + } + else + { + binding.ubo = currentFrameUbo; + binding.offset = tr.lightsUboOffset; + } + return binding; +} + +static UniformBlockBinding GetSceneBlockUniformBinding() +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.block = UNIFORM_BLOCK_SCENE; + + if (tr.sceneUboOffset == -1) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.defaultSceneUboOffset; + } + else + { + binding.ubo = currentFrameUbo; + binding.offset = tr.sceneUboOffset; + } + return binding; +} + +static UniformBlockBinding GetFogsBlockUniformBinding() +{ + const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + UniformBlockBinding binding = {}; + binding.block = UNIFORM_BLOCK_FOGS; + + if (tr.sceneUboOffset == -1) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.defaultFogsUboOffset; + } + else + { + binding.ubo = currentFrameUbo; + binding.offset = tr.fogsUboOffset; + } + return binding; +} + static UniformBlockBinding GetEntityBlockUniformBinding( const trRefEntity_t *refEntity) { @@ -838,10 +895,9 @@ static void DrawTris(shaderCommands_t *input, const VertexArraysProperties *vert SamplerBindingsWriter samplerBindingsWriter; uniformDataWriter.Start(sp); - const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { GetCameraBlockUniformBinding(backEnd.currentEntity), - { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, + GetSceneBlockUniformBinding(), GetEntityBlockUniformBinding(backEnd.currentEntity), GetShaderInstanceBlockUniformBinding( backEnd.currentEntity, input->shader), @@ -1028,10 +1084,9 @@ static void RB_FogPass( shaderCommands_t *input, const VertexArraysProperties *v if (input->shader->polygonOffset == qtrue) stateBits |= GLS_POLYGON_OFFSET_FILL; - const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { GetCameraBlockUniformBinding(backEnd.currentEntity), - { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, + GetFogsBlockUniformBinding(), GetEntityBlockUniformBinding(backEnd.currentEntity), GetShaderInstanceBlockUniformBinding( backEnd.currentEntity, input->shader), @@ -1749,12 +1804,11 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays CaptureDrawData(input, pStage, index, stage); - const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { GetCameraBlockUniformBinding(backEnd.currentEntity), - { currentFrameUbo, tr.lightsUboOffset, UNIFORM_BLOCK_LIGHTS }, - { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, - { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS }, + GetLightsBlockUniformBinding(), + GetSceneBlockUniformBinding(), + GetFogsBlockUniformBinding(), GetEntityBlockUniformBinding(backEnd.currentEntity), GetShaderInstanceBlockUniformBinding( backEnd.currentEntity, input->shader), From 3d859c6ee33707dd641e043c507698edc1045b30 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 13:54:32 +0200 Subject: [PATCH 688/708] Remove min() from light loop in lightall shader --- codemp/rd-rend2/glsl/lightall.glsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 87cc70adb4..0636d5ed73 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -760,8 +760,8 @@ vec3 CalcDynamicLightContribution( { vec3 outColor = vec3(0.0); vec3 position = viewOrigin - viewDir; - // FIX ME: Make sure a proper UBO is bound instead of using min here! - for ( int i = 0; i < min(u_NumLights, 32); i++ ) + + for ( int i = 0; i < u_NumLights; i++ ) { if ( ( u_LightMask & ( 1 << i ) ) == 0 ) { continue; From 57434fbe4dcaceaeaf3d58a8e284f25a593f3c31 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 14:49:09 +0200 Subject: [PATCH 689/708] Remove unused variables --- codemp/rd-rend2/tr_bsp.cpp | 3 +-- codemp/rd-rend2/tr_flares.cpp | 3 --- codemp/rd-rend2/tr_light.cpp | 3 --- codemp/rd-rend2/tr_model.cpp | 2 +- codemp/rd-rend2/tr_surface.cpp | 3 --- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 79786c803c..9495ff1c36 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3300,7 +3300,6 @@ static void R_RenderAllCubemaps() } // Clear everything before rendering cubemaps to make sure only visable surfaces to the cubemap are rendered - int frontEndMsec, backEndMsec; R_IssuePendingRenderCommands(); RE_ClearScene(); R_InitNextFrame(); @@ -3338,7 +3337,7 @@ static void R_RenderAllCubemaps() void R_LoadWeatherZones(world_t *worldData, lump_t *brushesLump, lump_t *sidesLump) { - dbrush_t *brushes, *brush; + dbrush_t *brushes; dbrushside_t *sides; int brushesCount, sidesCount; diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 87439f48ca..6446db9edd 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -318,9 +318,7 @@ RB_RenderFlare ================== */ void RB_RenderFlare( flare_t *f ) { - float size; vec4_t color; - float distance, intensity, factor; backEnd.pc.c_flareRenders++; @@ -393,7 +391,6 @@ void RB_RenderFlares (void) { flare_t *f; flare_t **prev; qboolean draw; - matrix_t oldmodelview, oldprojection, matrix; if ( !r_flares->integer ) { return; diff --git a/codemp/rd-rend2/tr_light.cpp b/codemp/rd-rend2/tr_light.cpp index 0595d26b93..4716956cf4 100644 --- a/codemp/rd-rend2/tr_light.cpp +++ b/codemp/rd-rend2/tr_light.cpp @@ -323,9 +323,6 @@ by the Calc_* functions */ void R_SetupEntityLighting( const trRefdef_t *refdef, trRefEntity_t *ent ) { int i; - dlight_t *dl; - float power; - vec3_t dir; float d; vec3_t lightDir; vec3_t lightOrigin; diff --git a/codemp/rd-rend2/tr_model.cpp b/codemp/rd-rend2/tr_model.cpp index 7d97209749..0f9d746110 100644 --- a/codemp/rd-rend2/tr_model.cpp +++ b/codemp/rd-rend2/tr_model.cpp @@ -1076,7 +1076,7 @@ static qboolean R_LoadMD3(model_t * mod, int lod, void *buffer, const char *modN byte *data; int dataSize = 0; - int ofsPosition, ofsNormals, ofsTexcoords, ofsBoneRefs, ofsWeights, ofsTangents; + int ofsPosition, ofsNormals, ofsTexcoords, ofsTangents; int stride = 0; int numVerts = 0; int numIndexes = 0; diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index 6c1c19c337..b1d53fc116 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2081,9 +2081,6 @@ static void RB_SurfaceVBOMesh(srfBspSurface_t * srf) void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) { - //mdvModel_t *mdvModel; - //mdvSurface_t *mdvSurface; - refEntity_t *refEnt; int i, mergeForward, mergeBack; GLvoid *firstIndexOffset, *lastIndexOffset; From da2200fd4ace8c4aa0c9e71ae42dcbe3f10f4884 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 14:50:13 +0200 Subject: [PATCH 690/708] Remove PR noise Preparations for merging with main --- code/qcommon/.cm_local.h.un~ | Bin 1073 -> 0 bytes codemp/game/NPC_move.c | 1 + codemp/game/bg_public.h | 1 + codemp/game/surfaceflags.h | 4 ---- codemp/qcommon/.cm_load.cpp.un~ | Bin 591 -> 0 bytes codemp/qcommon/.cm_local.h.un~ | Bin 1075 -> 0 bytes codemp/qcommon/cm_local.h | 4 ++-- codemp/qcommon/common.cpp | 2 +- 8 files changed, 5 insertions(+), 7 deletions(-) delete mode 100644 code/qcommon/.cm_local.h.un~ delete mode 100644 codemp/qcommon/.cm_load.cpp.un~ delete mode 100644 codemp/qcommon/.cm_local.h.un~ diff --git a/code/qcommon/.cm_local.h.un~ b/code/qcommon/.cm_local.h.un~ deleted file mode 100644 index 5b1a62445816b9e1548ccabd024043b6aaa55fa6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1073 zcmWH`%$*;a=aT=FfvMHF>M4#8Au!%fa2B|CNLUhu#g~=28ARGRIddRI}FAK zMj1Oa2Z5u^2q*yyel{SR-4+6XOi9knypn>FqWBWdw9KO75}(w>G^e7{;tXq`q!>t& slan*AG#4(OS`3l_0ck8+gG-Cj5|dLwO8D#`Kp{7=xFog6wDI{W0L0NvNdN!< diff --git a/codemp/game/NPC_move.c b/codemp/game/NPC_move.c index baddac0f3d..5809909167 100644 --- a/codemp/game/NPC_move.c +++ b/codemp/game/NPC_move.c @@ -142,6 +142,7 @@ static void NPC_LadderMove( vec3_t dir ) NPC_GetMoveInformation ------------------------- */ + static QINLINE qboolean NPC_GetMoveInformation( vec3_t dir, float *distance ) { //NOTENOTE: Use path stacks! diff --git a/codemp/game/bg_public.h b/codemp/game/bg_public.h index 731c56f6e8..e3da414b2f 100644 --- a/codemp/game/bg_public.h +++ b/codemp/game/bg_public.h @@ -497,6 +497,7 @@ typedef struct pmove_s { int tracemask; // collide against these types of surfaces int debugLevel; // if set, diagnostic output will be printed qboolean noFootsteps; // if the game is setup for no footsteps by the server + qboolean gauntletHit; // true if a gauntlet attack would actually hit something int framecount; diff --git a/codemp/game/surfaceflags.h b/codemp/game/surfaceflags.h index b32c41f3a1..e2782a1b54 100644 --- a/codemp/game/surfaceflags.h +++ b/codemp/game/surfaceflags.h @@ -99,10 +99,6 @@ along with this program; if not, see . #define SURF_UNUSED40000000 (0x40000000u) // #define SURF_UNUSED80000000 (0x80000000u) // -// NEW for rend2 -#define SURF_LIGHTFILTER 0x04000000 // filter light going through the object -#define SURF_ALPHASHADOW 0x08000000 // test light on a per-pixel basis - #define MATERIAL_BITS 5 #define MATERIAL_MASK 0x1f // mask to get the material type diff --git a/codemp/qcommon/.cm_load.cpp.un~ b/codemp/qcommon/.cm_load.cpp.un~ deleted file mode 100644 index 34989e8ca40ffaddd205532442c8019ddfac6054..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 591 zcmWH`%$*;a=aT=Ff$6q>!Lr*O5{;H`6O{#dSyM$Tm`}c{KD{pRfQYfJ?e$9x3@p(M zsDKg31z`|?vBCVXR|!Ha5Rv!`5P1|5D8&*06ZsDWaARPCqcqVWz~YZk$`XuVGlap| zz~~T!M#onPV9@(Pf*%~8pjhIufdB;$S4S7H3ZRkj2x0-MVB`c6?6wd9HI~l~0u*u+ Ni%U|AOdFrC0ssj12J?kQ6|fKw$<30~qH&5P(Hs0;4pQLjV{Zis0yA zVE8HlG+Q5tVZjfI3LYB>Q1EbdbTMrNM;S;Q8Gz!}1ST*VWw4MSlLmz(3skQq5<3jW z21c0*GzWpB%or#E3w|~ro81-yfJ`aQf|8DqT&*t)WkHWqSE3FYoM$c wXJ%drCnslKX)atmwHPD=0y5b22A3A4B_^kW)bQCsfI@C!aY<^CY2))%0IO0`L;wH) diff --git a/codemp/qcommon/cm_local.h b/codemp/qcommon/cm_local.h index f97497695e..235fecec96 100644 --- a/codemp/qcommon/cm_local.h +++ b/codemp/qcommon/cm_local.h @@ -45,10 +45,10 @@ typedef struct cLeaf_s { int cluster; int area; - ptrdiff_t firstLeafBrush; + ptrdiff_t firstLeafBrush; int numLeafBrushes; - ptrdiff_t firstLeafSurface; + ptrdiff_t firstLeafSurface; int numLeafSurfaces; } cLeaf_t; diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 65857da25d..088649479c 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -291,8 +291,8 @@ void NORETURN QDECL Com_Error( int code, const char *fmt, ... ) { if ( code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT || code == ERR_DROP || code == ERR_NEED_CD ) { throw code; } else { - SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage)); CL_Shutdown(); + SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage)); } Com_Shutdown (); From f152ed9675117de640b7ce467faa9f10b82a38f3 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 14:53:04 +0200 Subject: [PATCH 691/708] Remove PR noise 2 --- codemp/qcommon/common.cpp | 2 +- codemp/qcommon/q_shared.c | 27 --------------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/codemp/qcommon/common.cpp b/codemp/qcommon/common.cpp index 088649479c..8cceb640e9 100644 --- a/codemp/qcommon/common.cpp +++ b/codemp/qcommon/common.cpp @@ -291,7 +291,7 @@ void NORETURN QDECL Com_Error( int code, const char *fmt, ... ) { if ( code == ERR_DISCONNECT || code == ERR_SERVERDISCONNECT || code == ERR_DROP || code == ERR_NEED_CD ) { throw code; } else { - CL_Shutdown(); + CL_Shutdown (); SV_Shutdown (va("Server fatal crashed: %s\n", com_errorMessage)); } diff --git a/codemp/qcommon/q_shared.c b/codemp/qcommon/q_shared.c index 73f677a2a6..74e3ccaff4 100644 --- a/codemp/qcommon/q_shared.c +++ b/codemp/qcommon/q_shared.c @@ -548,33 +548,6 @@ qboolean SkipBracedSection (const char **program, int depth) { return (qboolean)( depth == 0 ); } -/* -================= -SkipBracedSection - -The next token should be an open brace or set depth to 1 if already parsed it. -Skips until a matching close brace is found. -Internal brace depths are properly skipped. -================= -*/ -qboolean SkipBracedSection_Depth (const char **program, int depth) { - char *token; - - do { - token = COM_ParseExt( program, qtrue ); - if( token[1] == 0 ) { - if( token[0] == '{' ) { - depth++; - } - else if( token[0] == '}' ) { - depth--; - } - } - } while( depth && *program ); - - return (qboolean)( depth == 0 ); -} - /* ================= SkipRestOfLine From 722066ef62c4e7ab5544b44c6439b82d1ddac88a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 15:28:26 +0200 Subject: [PATCH 692/708] Remove PR noise 3 --- codemp/rd-common/tr_font.cpp | 9 --------- codemp/rd-common/tr_font.h | 3 --- 2 files changed, 12 deletions(-) diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index c8821cae5d..e4571855fd 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -1793,15 +1793,6 @@ void R_ReloadFonts_f(void) } } -void R_InitFreeType(void) { -#ifdef BUILD_FREETYPE - if (FT_Init_FreeType( &ftLibrary )) { - ri.Printf(PRINT_WARNING, "R_InitFreeType: Unable to initialize FreeType.\n"); - } -#endif - // I DONT DO NOTHING -} - void R_DoneFreeType(void) { #ifdef BUILD_FREETYPE diff --git a/codemp/rd-common/tr_font.h b/codemp/rd-common/tr_font.h index 3bca11488e..d8e073d7d8 100644 --- a/codemp/rd-common/tr_font.h +++ b/codemp/rd-common/tr_font.h @@ -50,7 +50,4 @@ unsigned int AnyLanguage_ReadCharFromString( const char *psText, int *piAdvanceC qboolean Language_IsAsian(void); qboolean Language_UsesSpaces(void); -void R_InitFreeType(void); -void R_DoneFreeType(void); - // end From 685b9554e9b1840256321a732e25ca5f2a15b16d Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 15:29:50 +0200 Subject: [PATCH 693/708] Remove PR noise 4 Missed this one... --- codemp/rd-common/tr_font.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/codemp/rd-common/tr_font.cpp b/codemp/rd-common/tr_font.cpp index e4571855fd..0e80477085 100644 --- a/codemp/rd-common/tr_font.cpp +++ b/codemp/rd-common/tr_font.cpp @@ -1794,15 +1794,4 @@ void R_ReloadFonts_f(void) } -void R_DoneFreeType(void) { -#ifdef BUILD_FREETYPE - if (ftLibrary) { - FT_Done_FreeType( ftLibrary ); - ftLibrary = NULL; - } -#endif - // I DONT DO NOTHING -} - - // end From 23800c9e5bd98c4a0555f85d9d5856b1518ab896 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 15:34:54 +0200 Subject: [PATCH 694/708] Remove PR noise 5 --- codemp/rd-vanilla/tr_scene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-vanilla/tr_scene.cpp b/codemp/rd-vanilla/tr_scene.cpp index d1464c9073..9c0025485a 100644 --- a/codemp/rd-vanilla/tr_scene.cpp +++ b/codemp/rd-vanilla/tr_scene.cpp @@ -235,7 +235,7 @@ void RE_AddRefEntityToScene( const refEntity_t *ent ) { #ifdef _DEBUG if (ent->reType == RT_MODEL) { - //assert(ent->hModel || ent->ghoul2 || ent->customShader); + assert(ent->hModel || ent->ghoul2 || ent->customShader); } #endif From d027a07ae7c7e0e7cf893db79bc227d40c71eaa1 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Tue, 23 May 2023 15:42:43 +0200 Subject: [PATCH 695/708] Remove PR noise 6 --- codemp/rd-vanilla/tr_local.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/codemp/rd-vanilla/tr_local.h b/codemp/rd-vanilla/tr_local.h index 93f17246a2..6f9504d682 100644 --- a/codemp/rd-vanilla/tr_local.h +++ b/codemp/rd-vanilla/tr_local.h @@ -44,8 +44,6 @@ typedef unsigned int glIndex_t; #define MAX_STATES_PER_SHADER 32 #define MAX_STATE_NAME 32 -extern glconfig_t glConfig; - typedef enum { DLIGHT_VERTICAL = 0, From 274542e0971cbb80a4c6d298375be63ce77f59f7 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 24 May 2023 01:18:24 +0200 Subject: [PATCH 696/708] Don't upload shader instance ubo blocks if not needed --- codemp/rd-rend2/tr_backend.cpp | 12 +++++++++++- codemp/rd-rend2/tr_init.cpp | 7 +++++++ codemp/rd-rend2/tr_local.h | 1 + codemp/rd-rend2/tr_shade.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index 6156cab6dc..d84074dc89 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2574,6 +2574,16 @@ static void RB_UpdateShaderEntityConstants( const trRefEntity_t *refEntity, const shader_t *shader) { + if (shader->numDeforms != 1 && !shader->portalRange) + { + RB_InsertEntityShaderUboOffset( + tr.shaderInstanceUboOffsetsMap, + tr.shaderInstanceUboOffsetsMapSize, + entityNum, + shader->index, + -1); + return; + } ShaderInstanceBlock shaderInstanceBlock = {}; ComputeDeformValues( refEntity, @@ -2788,7 +2798,6 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) gpuFrame_t *frame = backEndData->currentFrame; RB_BeginConstantsUpdate(frame); - RB_UpdateCameraConstants(frame); if (backEnd.frameUBOsInitialized == qfalse) { RB_UpdateFogsConstants(frame); @@ -2796,6 +2805,7 @@ static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) RB_UpdateLightsConstants(frame); } + RB_UpdateCameraConstants(frame); RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); RB_UpdateAnimationConstants(frame, drawSurfs, numDrawSurfs); diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 031f24242a..cf52fa91ac 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1849,6 +1849,13 @@ static void R_InitStaticConstants() qglBufferSubData( GL_UNIFORM_BUFFER, tr.defaultFogsUboOffset, sizeof(fogsBlock), &fogsBlock); alignedBlockSize += (sizeof(FogsBlock) + alignment) & ~alignment; + + // Setup default shader instance block + ShaderInstanceBlock shaderInstanceBlock = {}; + tr.defaultShaderInstanceUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, tr.defaultShaderInstanceUboOffset, sizeof(shaderInstanceBlock), &shaderInstanceBlock); + alignedBlockSize += (sizeof(ShaderInstanceBlock) + alignment) & ~alignment; } static void R_ShutdownBackEndFrameData() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index c442f178e1..e7f31945f1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -2515,6 +2515,7 @@ typedef struct trGlobals_s { int defaultLightsUboOffset; int defaultSceneUboOffset; int defaultFogsUboOffset; + int defaultShaderInstanceUboOffset; int cameraUboOffset; int sceneUboOffset; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 373a17c651..851ef89e64 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -856,6 +856,12 @@ static UniformBlockBinding GetShaderInstanceBlockUniformBinding( shader->index); } + if (binding.offset == -1) + { + binding.ubo = tr.staticUbo; + binding.offset = tr.defaultShaderInstanceUboOffset; + } + return binding; } From af9e01906fd6ece9a08389c7c26644d63c2ce5cf Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 24 May 2023 03:32:12 +0200 Subject: [PATCH 697/708] Cleanup cubemap rendering code --- codemp/rd-rend2/tr_bsp.cpp | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 9495ff1c36..4417f8b130 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3293,16 +3293,14 @@ static void R_AssignCubemapsToWorldSurfaces(world_t *worldData) static void R_RenderAllCubemaps() { + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + GLenum cubemapFormat = GL_RGBA8; if (r_hdr->integer) { cubemapFormat = GL_RGBA16F; } - - // Clear everything before rendering cubemaps to make sure only visable surfaces to the cubemap are rendered - R_IssuePendingRenderCommands(); - RE_ClearScene(); - R_InitNextFrame(); for (int k = 0; k <= r_cubeMappingBounces->integer; k++) { @@ -3311,25 +3309,26 @@ static void R_RenderAllCubemaps() int maxCubemaps = MIN(tr.numCubemaps, 128); for (int i = 0; i < maxCubemaps; i++) { - RE_BeginFrame(STEREO_CENTER); for (int j = 0; j < 6; j++) { + RE_BeginFrame(STEREO_CENTER); + R_RenderCubemapSide(i, j, qfalse, bounce); + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + + gpuFrame_t *currentFrame = backEndData->currentFrame; + assert(!currentFrame->sync); + currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + backEndData->realFrameNumber++; + backEnd.framePostProcessed = qfalse; + backEnd.projection2D = qfalse; + backEnd.frameUBOsInitialized = qfalse; } - RE_ClearScene(); R_AddConvolveCubemapCmd(&tr.cubemaps[i], i); R_IssuePendingRenderCommands(); - - gpuFrame_t *currentFrame = backEndData->currentFrame; - assert(!currentFrame->sync); - currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - - backEndData->realFrameNumber++; - backEnd.framePostProcessed = qfalse; - backEnd.projection2D = qfalse; - backEnd.frameUBOsInitialized = qfalse; - R_InitNextFrame(); } } } From 323f230523b9bf14b41fff14f6018299cb3898c5 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 28 May 2023 01:56:02 +0200 Subject: [PATCH 698/708] Properly track glState.currentGlobalUBO and some additional cleanup. --- codemp/rd-rend2/tr_backend.cpp | 13 ++------- codemp/rd-rend2/tr_cmds.cpp | 1 + codemp/rd-rend2/tr_extramath.cpp | 2 +- codemp/rd-rend2/tr_extramath.h | 2 +- codemp/rd-rend2/tr_main.cpp | 47 +++++++++++++++----------------- codemp/rd-rend2/tr_shade.cpp | 2 +- codemp/rd-rend2/tr_vbo.cpp | 1 + 7 files changed, 29 insertions(+), 39 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index d84074dc89..b9be8b3aa0 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2377,17 +2377,8 @@ static void RB_UpdateEntityMatrixConstants( const trRefEntity_t *refEntity) { orientationr_t ori; - if (refEntity == &tr.worldEntity) - { - ori = backEnd.viewParms.world; - Matrix16Identity(entityBlock.modelMatrix); - } - else - { - R_RotateForEntity(refEntity, &backEnd.viewParms, &ori); - Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); - } - + R_RotateForEntity(refEntity, &backEnd.viewParms, &ori); + Matrix16Copy(ori.modelMatrix, entityBlock.modelMatrix); VectorCopy(ori.viewOrigin, entityBlock.localViewOrigin); } diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index 3daea6e7ce..d707e290fd 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -550,6 +550,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { // Resets resources qglBindBuffer(GL_UNIFORM_BUFFER, thisFrame->ubo); + glState.currentGlobalUBO = thisFrame->ubo; thisFrame->uboWriteOffset = 0; thisFrame->dynamicIboCommitOffset = 0; diff --git a/codemp/rd-rend2/tr_extramath.cpp b/codemp/rd-rend2/tr_extramath.cpp index 12abaed251..76cf7c5cb5 100644 --- a/codemp/rd-rend2/tr_extramath.cpp +++ b/codemp/rd-rend2/tr_extramath.cpp @@ -97,7 +97,7 @@ void Matrix16Dump( const matrix_t in ) ri.Printf(PRINT_ALL, "%3.5f %3.5f %3.5f %3.5f\n", in[ 3], in[ 7], in[11], in[15]); } -void Matrix16Translation( vec3_t vec, matrix_t out ) +void Matrix16Translation(const vec3_t vec, matrix_t out ) { out[ 0] = 1.0f; out[ 4] = 0.0f; out[ 8] = 0.0f; out[12] = vec[0]; out[ 1] = 0.0f; out[ 5] = 1.0f; out[ 9] = 0.0f; out[13] = vec[1]; diff --git a/codemp/rd-rend2/tr_extramath.h b/codemp/rd-rend2/tr_extramath.h index ef84fc8145..55607ab267 100644 --- a/codemp/rd-rend2/tr_extramath.h +++ b/codemp/rd-rend2/tr_extramath.h @@ -38,7 +38,7 @@ void Matrix16Multiply( const matrix_t in1, const matrix_t in2, matrix_t out ); void Matrix16Transform( const matrix_t in1, const vec4_t in2, vec4_t out ); qboolean Matrix16Compare(const matrix_t a, const matrix_t b); void Matrix16Dump( const matrix_t in ); -void Matrix16Translation( vec3_t vec, matrix_t out ); +void Matrix16Translation( const vec3_t vec, matrix_t out ); void Matrix16Ortho( float left, float right, float bottom, float top, float znear, float zfar, matrix_t out ); void Matrix16View(vec3_t axes[3], vec3_t origin, matrix_t out); void Matrix16SimpleInverse( const matrix_t in, matrix_t out); diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index e83a5cf6b3..a578800eef 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -703,12 +703,12 @@ Called by both the front end and the back end ================= */ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, - orientationr_t *ori ) { - float glMatrix[16]; + orientationr_t *ori ) +{ vec3_t delta; float axisLength; - if ( ent->e.reType != RT_MODEL ) { + if ( ent->e.reType != RT_MODEL || ent == &tr.worldEntity ) { *ori = viewParms->world; return; } @@ -719,28 +719,25 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms, VectorCopy( ent->e.axis[1], ori->axis[1] ); VectorCopy( ent->e.axis[2], ori->axis[2] ); - glMatrix[0] = ori->axis[0][0]; - glMatrix[4] = ori->axis[1][0]; - glMatrix[8] = ori->axis[2][0]; - glMatrix[12] = ori->origin[0]; - - glMatrix[1] = ori->axis[0][1]; - glMatrix[5] = ori->axis[1][1]; - glMatrix[9] = ori->axis[2][1]; - glMatrix[13] = ori->origin[1]; - - glMatrix[2] = ori->axis[0][2]; - glMatrix[6] = ori->axis[1][2]; - glMatrix[10] = ori->axis[2][2]; - glMatrix[14] = ori->origin[2]; - - glMatrix[3] = 0; - glMatrix[7] = 0; - glMatrix[11] = 0; - glMatrix[15] = 1; - - Matrix16Copy(glMatrix, ori->modelMatrix); - myGlMultMatrix( glMatrix, viewParms->world.modelViewMatrix, ori->modelViewMatrix ); + ori->modelMatrix[0] = ori->axis[0][0]; + ori->modelMatrix[4] = ori->axis[1][0]; + ori->modelMatrix[8] = ori->axis[2][0]; + ori->modelMatrix[12] = ori->origin[0]; + + ori->modelMatrix[1] = ori->axis[0][1]; + ori->modelMatrix[5] = ori->axis[1][1]; + ori->modelMatrix[9] = ori->axis[2][1]; + ori->modelMatrix[13] = ori->origin[1]; + + ori->modelMatrix[2] = ori->axis[0][2]; + ori->modelMatrix[6] = ori->axis[1][2]; + ori->modelMatrix[10] = ori->axis[2][2]; + ori->modelMatrix[14] = ori->origin[2]; + + ori->modelMatrix[3] = 0; + ori->modelMatrix[7] = 0; + ori->modelMatrix[11] = 0; + ori->modelMatrix[15] = 1; // calculate the viewer origin in the model's space // needed for fog, specular, and environment mapping diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 851ef89e64..91e0b48b38 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -758,7 +758,7 @@ static UniformBlockBinding GetFogsBlockUniformBinding() UniformBlockBinding binding = {}; binding.block = UNIFORM_BLOCK_FOGS; - if (tr.sceneUboOffset == -1) + if (tr.fogsUboOffset == -1) { binding.ubo = tr.staticUbo; binding.offset = tr.defaultFogsUboOffset; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index 5a737640d8..d34d4a622b 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -717,6 +717,7 @@ void RB_BindUniformBlock(GLuint ubo, uniformBlock_t block, int offset) { qglBindBufferRange( GL_UNIFORM_BUFFER, blockInfo->slot, ubo, offset, blockInfo->size); + glState.currentGlobalUBO = ubo; currentBinding->buffer = ubo; currentBinding->offset = offset; From a4eace288f1f21a98475715731beaba6d74d569e Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 28 May 2023 03:48:12 +0200 Subject: [PATCH 699/708] Disable viewport scissor for mirrors for now It's currently buggy, especially when the portal surface is very close to the viewer. Might replace this with rendering a stencil first. --- codemp/rd-rend2/tr_main.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index a578800eef..1597530f69 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -1555,16 +1555,16 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms.flags |= VPF_NOVIEWMODEL; // Calculate window coordinates of this surface to get tight fitting scissor rectangle - int minRectX = INT_MAX; - int minRectY = INT_MAX; - int maxRectX = 0; - int maxRectY = 0; - int viewportWidth = oldParms.viewportWidth; int viewportHeight = oldParms.viewportHeight; float viewportCenterX = oldParms.viewportX + 0.5f * viewportWidth; float viewportCenterY = oldParms.viewportY + 0.5f * viewportHeight; + /*int minRectX = INT_MAX; + int minRectY = INT_MAX; + int maxRectX = 0; + int maxRectY = 0; + for ( int i = 0; i < numVertices; i++ ) { float ndcX; @@ -1613,7 +1613,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms.scissorX = minRectX; newParms.scissorY = minRectY; newParms.scissorWidth = maxRectX - minRectX; - newParms.scissorHeight = maxRectY - minRectY; + newParms.scissorHeight = maxRectY - minRectY;*/ R_MirrorPoint (oldParms.ori.origin, &surface, &camera, newParms.ori.origin ); From f1f78a0262ae8b2a576833fcb8f049350d2f3f92 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 28 May 2023 15:28:10 +0200 Subject: [PATCH 700/708] Fix r_forceSun 2 Since we upload scene data before rendering the sun shadow maps we need to alter all the related data before upload. --- codemp/rd-rend2/tr_main.cpp | 37 +----------------------------------- codemp/rd-rend2/tr_scene.cpp | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 1597530f69..fa6a3a2e88 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2552,7 +2552,6 @@ static float CalcSplit(float n, float f, float i, float m) void R_RenderSunShadowMaps(const refdef_t *fd, int level) { - vec4_t lightDir, lightCol; vec3_t lightViewAxis[3]; vec3_t lightOrigin; float splitZNear, splitZFar, splitBias; @@ -2560,39 +2559,6 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) vec3_t lightviewBounds[2]; qboolean lightViewIndependentOfCameraView = qtrue; - if (r_forceSun->integer == 2) - { - int scale = 32768; - float angle = (fd->time % scale) / (float)scale * M_PI; - lightDir[0] = cos(angle); - lightDir[1] = sin(35.0f * M_PI / 180.0f); - lightDir[2] = sin(angle) * cos(35.0f * M_PI / 180.0f); - lightDir[3] = 0.0f; - - if (1) //((fd->time % (scale * 2)) < scale) - { - lightCol[0] = - lightCol[1] = - lightCol[2] = CLAMP(sin(angle) * 2.0f, 0.0f, 1.0f) * 2.0f; - lightCol[3] = 1.0f; - } - else - { - lightCol[0] = - lightCol[1] = - lightCol[2] = CLAMP(sin(angle) * 2.0f * 0.1f, 0.0f, 0.1f); - lightCol[3] = 1.0f; - } - - VectorCopy4(lightDir, tr.refdef.sunDir); - VectorCopy4(lightCol, tr.refdef.sunCol); - VectorScale4(lightCol, 0.2f, tr.refdef.sunAmbCol); - } - else - { - VectorCopy4(tr.refdef.sunDir, lightDir); - } - viewZNear = r_shadowCascadeZNear->value; viewZFar = r_shadowCascadeZFar->value; splitBias = r_shadowCascadeZBias->value; @@ -2622,9 +2588,8 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level) VectorCopy(fd->vieworg, lightOrigin); - // Make up a projection - VectorScale(lightDir, -1.0f, lightViewAxis[0]); + VectorScale(tr.refdef.sunDir, -1.0f, lightViewAxis[0]); if (lightViewIndependentOfCameraView) { diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index fdbdb5dce9..45ffc8730e 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -374,6 +374,26 @@ void RE_BeginScene(const refdef_t *fd) VectorScale(tr.sunLight, scale * tr.sunShadowScale, tr.refdef.sunAmbCol); } } + + if (r_forceSun->integer == 2) + { + vec4_t lightDir, lightCol; + int scale = 32768; + float angle = (fd->time % scale) / (float)scale * M_PI; + lightDir[0] = cos(angle); + lightDir[1] = sin(35.0f * M_PI / 180.0f); + lightDir[2] = sin(angle) * cos(35.0f * M_PI / 180.0f); + lightDir[3] = 0.0f; + + lightCol[0] = + lightCol[1] = + lightCol[2] = CLAMP(sin(angle) * 2.0f, 0.0f, 1.0f) * 2.0f; + lightCol[3] = 1.0f; + + VectorCopy4(lightDir, tr.refdef.sunDir); + VectorCopy4(lightCol, tr.refdef.sunCol); + VectorScale4(lightCol, 0.2f, tr.refdef.sunAmbCol); + } } if (r_forceAutoExposure->integer) From d349b68e41ed6ad4e1e33efc5023016f622beefc Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 21 Jun 2023 21:07:18 +0200 Subject: [PATCH 701/708] WIP Scene handling rewrite Rend2 will now gather all uniform buffer data before rendering anything. Also merges skyportal draws into the main pass rendering. Cleaned up alot of old code on the way Broken: - DEFORM_PROJECTION_SHADOW - Weather top down occlusion rendering TODO: - Merge shadow draws into single draw commits - Check R_NewFrameSync() usage - Reduce bsp tree traversal when building the different views - make R_RecursiveWorldNode and R_MarkLeaves static again --- codemp/rd-rend2/glsl/generic.glsl | 60 +- codemp/rd-rend2/glsl/lightall.glsl | 166 ++- codemp/rd-rend2/glsl/refraction.glsl | 25 +- codemp/rd-rend2/glsl/shadowfill.glsl | 185 ---- codemp/rd-rend2/glsl/shadowmask.glsl | 179 ---- codemp/rd-rend2/glsl/surface_sprites.glsl | 6 +- codemp/rd-rend2/tr_animation.cpp | 8 +- codemp/rd-rend2/tr_backend.cpp | 524 +++------- codemp/rd-rend2/tr_bsp.cpp | 108 +- codemp/rd-rend2/tr_cmds.cpp | 12 + codemp/rd-rend2/tr_fbo.cpp | 3 +- codemp/rd-rend2/tr_flares.cpp | 3 +- codemp/rd-rend2/tr_ghoul2.cpp | 132 ++- codemp/rd-rend2/tr_glsl.cpp | 78 +- codemp/rd-rend2/tr_init.cpp | 6 + codemp/rd-rend2/tr_local.h | 143 +-- codemp/rd-rend2/tr_main.cpp | 1139 ++++++++++++--------- codemp/rd-rend2/tr_mesh.cpp | 9 +- codemp/rd-rend2/tr_model_iqm.cpp | 7 - codemp/rd-rend2/tr_scene.cpp | 112 +- codemp/rd-rend2/tr_shade.cpp | 97 +- codemp/rd-rend2/tr_shader.cpp | 2 + codemp/rd-rend2/tr_sky.cpp | 4 +- codemp/rd-rend2/tr_surface.cpp | 14 +- codemp/rd-rend2/tr_vbo.cpp | 35 + codemp/rd-rend2/tr_weather.cpp | 59 +- codemp/rd-rend2/tr_world.cpp | 48 +- 27 files changed, 1463 insertions(+), 1701 deletions(-) delete mode 100644 codemp/rd-rend2/glsl/shadowfill.glsl delete mode 100644 codemp/rd-rend2/glsl/shadowmask.glsl diff --git a/codemp/rd-rend2/glsl/generic.glsl b/codemp/rd-rend2/glsl/generic.glsl index f66caa832a..f249657e89 100644 --- a/codemp/rd-rend2/glsl/generic.glsl +++ b/codemp/rd-rend2/glsl/generic.glsl @@ -20,6 +20,17 @@ in vec2 attr_TexCoord3; in vec2 attr_TexCoord4; #endif +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; + float u_frameTime; + float u_deltaTime; +}; + layout(std140) uniform Camera { mat4 u_viewProjectionMatrix; @@ -41,6 +52,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; #if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) @@ -123,6 +135,23 @@ float CalculateDeformScale( in int func, in float time, in float phase, in float vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) { +#if defined(USE_RGBAGEN) + if (u_ColorGen == CGEN_DISINTEGRATION_2) + { + vec3 delta = u_Disintegration.xyz - pos; + float sqrDistance = dot(delta, delta); + vec3 normalScale = vec3(-0.01); + if ( sqrDistance < u_Disintegration.w ) + { + normalScale = vec3(2.0, 2.0, 0.5); + } + else if ( sqrDistance < u_Disintegration.w + 50 ) + { + normalScale = vec3(1.0, 1.0, 0.0); + } + return pos + normal * normalScale; + } +#endif switch ( u_DeformType ) { default: @@ -136,7 +165,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float bulgeWidth = u_DeformParams0.z; // phase float bulgeSpeed = u_DeformParams0.w; // frequency - float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + float scale = CalculateDeformScale( WF_SIN, (u_entityTime + u_frameTime + u_Time), bulgeWidth * st.x, bulgeSpeed ); return pos + normal * scale * bulgeHeight; } @@ -157,7 +186,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + float scale = CalculateDeformScale( u_DeformFunc, (u_entityTime + u_frameTime + u_Time), phase + offset, frequency ); return pos + normal * (base + scale * amplitude); } @@ -170,7 +199,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float frequency = u_DeformParams0.w; vec3 direction = u_DeformParams1.xyz; - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + float scale = CalculateDeformScale( u_DeformFunc, (u_entityTime + u_frameTime + u_Time), phase, frequency ); return pos + direction * (base + scale * amplitude); } @@ -190,21 +219,9 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) return pos - lightPos * dot( pos, ground ) + groundDist; } - case DEFORM_DISINTEGRATION: - { - vec3 delta = u_Disintegration.xyz - pos; - float sqrDistance = dot(delta, delta); - vec3 normalScale = vec3(-0.01); - if ( sqrDistance < u_Disintegration.w ) - { - normalScale = vec3(2.0, 2.0, 0.5); - } - else if ( sqrDistance < u_Disintegration.w + 50 ) - { - normalScale = vec3(1.0, 1.0, 0.0); - } - return pos + normal * normalScale; - } + //case DEFORM_DISINTEGRATION: + //{ + //} } } @@ -225,19 +242,19 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); outNormal.y += amplitude * GetNoiseValue( 100.0 * position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); outNormal.z += amplitude * GetNoiseValue( 200.0 * position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); return outNormal; } @@ -481,6 +498,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; uniform sampler2D u_DiffuseMap; diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 0636d5ed73..9effcb0dc7 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -51,6 +51,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; #if defined(USE_SKELETAL_ANIMATION) @@ -355,6 +356,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; struct Light @@ -366,6 +368,9 @@ struct Light layout(std140) uniform Lights { + uniform mat4 u_ShadowMvp; + uniform mat4 u_ShadowMvp2; + uniform mat4 u_ShadowMvp3; int u_NumLights; Light u_Lights[32]; }; @@ -390,7 +395,7 @@ uniform sampler2D u_SpecularMap; #endif #if defined(USE_SHADOWMAP) -uniform sampler2D u_ShadowMap; +uniform sampler2DArrayShadow u_ShadowMap; #endif #if defined(USE_SSAO) @@ -438,6 +443,147 @@ in vec4 var_LightDir; out vec4 out_Color; out vec4 out_Glow; +// depth is GL_DEPTH_COMPONENT16 +// so the maximum error is 1.0 / 2^16 +#define DEPTH_MAX_ERROR 0.0000152587890625 + +// Input: It uses texture coords as the random number seed. +// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. +// Author: Michael Pohoreski +// Copyright: Copyleft 2012 :-) +// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader + +float random( const vec2 p ) +{ + // We need irrationals for pseudo randomness. + // Most (all?) known transcendental numbers will (generally) work. + const vec2 r = vec2( + 23.1406926327792690, // e^pi (Gelfond's constant) + 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) + //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); + return mod( 123456789., 1e-7 + 256. * dot(p,r) ); +} + +const vec2 poissonDisk[16] = vec2[16]( + vec2( -0.94201624, -0.39906216 ), + vec2( 0.94558609, -0.76890725 ), + vec2( -0.094184101, -0.92938870 ), + vec2( 0.34495938, 0.29387760 ), + vec2( -0.91588581, 0.45771432 ), + vec2( -0.81544232, -0.87912464 ), + vec2( -0.38277543, 0.27676845 ), + vec2( 0.97484398, 0.75648379 ), + vec2( 0.44323325, -0.97511554 ), + vec2( 0.53742981, -0.47373420 ), + vec2( -0.26496911, -0.41893023 ), + vec2( 0.79197514, 0.19090188 ), + vec2( -0.24188840, 0.99706507 ), + vec2( -0.81409955, 0.91437590 ), + vec2( 0.19984126, 0.78641367 ), + vec2( 0.14383161, -0.14100790 ) +); + +float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st, const float dist, float PCFScale) +{ + float mult; + float scale = PCFScale / r_shadowMapSize; + +#if defined(USE_SHADOW_FILTER) + float r = random(gl_FragCoord.xy / r_FBufScale); + float sinr = sin(r); + float cosr = cos(r); + mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; + + mult = texture(shadowmap, vec4(st + rmat * vec2(-0.7055767, 0.196515), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.3524343, -0.7791386), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.2391056, 0.9189604), layer, dist)); + #if defined(USE_SHADOW_FILTER2) + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.07580382, -0.09224417), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.5784913, -0.002528916), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.192888, 0.4064181), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.6335801, -0.5247476), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(-0.5579782, 0.7491854), layer, dist)); + mult += texture(shadowmap, vec4(st + rmat * vec2(0.7320465, 0.6317794), layer, dist)); + + mult *= 0.11111; + #else + mult *= 0.33333; + #endif +#else + float r = random(gl_FragCoord.xy / r_FBufScale); + float sinr = sin(r); + float cosr = cos(r); + mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; + + mult = texture(shadowmap, vec4(st, layer, dist)); + for (int i = 0; i < 16; i++) + { + vec2 delta = rmat * poissonDisk[i]; + mult += texture(shadowmap, vec4(st + delta, layer, dist)); + } + mult *= 1.0 / 17.0; +#endif + + return mult; +} + +float sunShadow(in vec3 viewOrigin, in vec3 viewDir, in vec3 biasOffset) +{ + vec4 biasPos = vec4(viewOrigin - viewDir + biasOffset, 1.0); + float cameraDistance = length(viewDir); + + const float PCFScale = 1.5; + const float edgeBias = 0.5 - ( 4.0 * PCFScale / r_shadowMapSize ); + float edgefactor = 0.0; + const float fadeTo = 1.0; + float result = 1.0; + + vec4 shadowpos = u_ShadowMvp * biasPos; + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) + { + vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); + edgefactor = 2.0 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); + result = PCF(u_ShadowMap, + 0.0, + shadowpos.xy, + shadowpos.z, + PCFScale + edgefactor); + } + else + { + shadowpos = u_ShadowMvp2 * (biasPos + vec4(biasOffset, 0.0)); + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) + { + vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); + edgefactor = 0.5 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); + result = PCF(u_ShadowMap, + 1.0, + shadowpos.xy, + shadowpos.z, + PCFScale + edgefactor); + } + else + { + shadowpos = u_ShadowMvp3 * (biasPos + vec4(biasOffset, 0.0)); + shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; + if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(1.0)))) + { + result = PCF(u_ShadowMap, + 2.0, + shadowpos.xy, + shadowpos.z, + PCFScale); + float fade = clamp(cameraDistance / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0); + result = mix(result, fadeTo, fade); + } + } + } + + return result; +} + #define EPSILON 0.00000001 #if defined(USE_PARALLAXMAP) @@ -910,20 +1056,19 @@ void main() attenuation = 1.0; #endif - vec3 vertexNormal = mix(var_Normal.xyz, -var_Normal.xyz, float(gl_FrontFacing)); + vec3 vertexNormal = mix(var_Normal.xyz, -var_Normal.xyz, float(gl_FrontFacing)) * u_NormalScale.z; N = CalcNormal(vertexNormal, var_Tangent, texCoords); L /= sqrt(sqrLightDist); - #if defined(USE_SHADOWMAP) || defined(USE_SSAO) - vec2 windowTex = gl_FragCoord.xy / r_FBufScale; - #endif - #if defined(USE_SHADOWMAP) - float shadowValue = texture(u_ShadowMap, windowTex).r; + vec3 primaryLightDir = normalize(u_PrimaryLightOrigin.xyz); + float NPL = clamp(dot(N, primaryLightDir), -1.0, 1.0); + vec3 normalBias = vertexNormal * (1.0 - NPL); + float shadowValue = sunShadow(u_ViewOrigin, viewDir, normalBias) * NPL; // surfaces not facing the light are always shadowed - vec3 primaryLightDir = normalize(u_PrimaryLightOrigin.xyz); - shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); + + //shadowValue = mix(0.0, shadowValue, dot(N, primaryLightDir) > 0.0); #if defined(SHADOWMAP_MODULATE) vec3 ambientScale = mix(vec3(1.0), u_PrimaryLightAmbient, u_EnableTextures.z); @@ -956,6 +1101,7 @@ void main() float AO = 1.0; #if defined (USE_SSAO) + vec2 windowTex = gl_FragCoord.xy / r_FBufScale; AO = texture(u_SSAOMap, windowTex).r; #endif @@ -1007,7 +1153,7 @@ void main() #if defined(USE_PRIMARY_LIGHT) vec3 L2 = normalize(u_PrimaryLightOrigin.xyz); vec3 H2 = normalize(L2 + E); - float NL2 = clamp(min(dot(N, L2), dot(vertexNormal, L2)), 0.0, 1.0); + float NL2 = clamp(dot(N, L2), 0.0, 1.0); float L2H2 = clamp(dot(L2, H2), 0.0, 1.0); float NH2 = clamp(dot(N, H2), 0.0, 1.0); float VH2 = clamp(dot(E, H), 0.0, 1.0); diff --git a/codemp/rd-rend2/glsl/refraction.glsl b/codemp/rd-rend2/glsl/refraction.glsl index e2e1327b7d..dfee37f149 100644 --- a/codemp/rd-rend2/glsl/refraction.glsl +++ b/codemp/rd-rend2/glsl/refraction.glsl @@ -17,6 +17,17 @@ in vec2 attr_TexCoord0; in vec2 attr_TexCoord1; #endif +layout(std140) uniform Scene +{ + vec4 u_PrimaryLightOrigin; + vec3 u_PrimaryLightAmbient; + int u_globalFogIndex; + vec3 u_PrimaryLightColor; + float u_PrimaryLightRadius; + float u_frameTime; + float u_deltaTime; +}; + layout(std140) uniform Camera { mat4 u_viewProjectionMatrix; @@ -38,6 +49,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; #if defined(USE_DEFORM_VERTEXES) || defined(USE_RGBAGEN) @@ -132,7 +144,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float bulgeWidth = u_DeformParams0.z; // phase float bulgeSpeed = u_DeformParams0.w; // frequency - float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); + float scale = CalculateDeformScale( WF_SIN, (u_entityTime + u_frameTime + u_Time), bulgeWidth * st.x, bulgeSpeed ); return pos + normal * scale * bulgeHeight; } @@ -153,7 +165,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float spread = u_DeformParams1.x; float offset = dot( pos.xyz, vec3( spread ) ); - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); + float scale = CalculateDeformScale( u_DeformFunc, (u_entityTime + u_frameTime + u_Time), phase + offset, frequency ); return pos + normal * (base + scale * amplitude); } @@ -166,7 +178,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) float frequency = u_DeformParams0.w; vec3 direction = u_DeformParams1.xyz; - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); + float scale = CalculateDeformScale( u_DeformFunc, (u_entityTime + u_frameTime + u_Time), phase, frequency ); return pos + direction * (base + scale * amplitude); } @@ -190,19 +202,19 @@ vec3 DeformNormal( const in vec3 position, const in vec3 normal ) position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); outNormal.y += amplitude * GetNoiseValue( 100.0 * position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); outNormal.z += amplitude * GetNoiseValue( 200.0 * position.x * scale, position.y * scale, position.z * scale, - u_Time * frequency ); + (u_entityTime + u_frameTime + u_Time) * frequency ); return outNormal; } @@ -408,6 +420,7 @@ layout(std140) uniform Entity vec3 u_ModelLightDir; float u_VertexLerp; vec3 u_LocalViewOrigin; + float u_entityTime; }; uniform sampler2D u_TextureMap; diff --git a/codemp/rd-rend2/glsl/shadowfill.glsl b/codemp/rd-rend2/glsl/shadowfill.glsl deleted file mode 100644 index c2f370e5db..0000000000 --- a/codemp/rd-rend2/glsl/shadowfill.glsl +++ /dev/null @@ -1,185 +0,0 @@ -/*[Vertex]*/ -in vec3 attr_Position; -in vec3 attr_Normal; -in vec4 attr_TexCoord0; - -layout(std140) uniform Camera -{ - mat4 u_viewProjectionMatrix; - vec4 u_ViewInfo; - vec3 u_ViewOrigin; - vec3 u_ViewForward; - vec3 u_ViewLeft; - vec3 u_ViewUp; -}; - -layout(std140) uniform Entity -{ - mat4 u_ModelMatrix; - vec4 u_LocalLightOrigin; - vec3 u_AmbientLight; - float u_LocalLightRadius; - vec3 u_DirectedLight; - float u_FXVolumetricBase; - vec3 u_ModelLightDir; - float u_VertexLerp; - vec3 u_LocalViewOrigin; -}; - -layout(std140) uniform ShaderInstance -{ - vec4 u_DeformParams0; - vec4 u_DeformParams1; - float u_Time; - float u_PortalRange; - int u_DeformType; - int u_DeformFunc; -}; - -float GetNoiseValue( float x, float y, float z, float t ) -{ - // Variation on the 'one-liner random function'. - // Not sure if this is still 'correctly' random - return fract( sin( dot( - vec4( x, y, z, t ), - vec4( 12.9898, 78.233, 12.9898, 78.233 ) - )) * 43758.5453 ); -} - -float CalculateDeformScale( in int func, in float time, in float phase, in float frequency ) -{ - float value = phase + time * frequency; - - switch ( func ) - { - case WF_SIN: - return sin(value * 2.0 * M_PI); - case WF_SQUARE: - return sign(0.5 - fract(value)); - case WF_TRIANGLE: - return abs(fract(value + 0.75) - 0.5) * 4.0 - 1.0; - case WF_SAWTOOTH: - return fract(value); - case WF_INVERSE_SAWTOOTH: - return 1.0 - fract(value); - default: - return 0.0; - } -} - -vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st) -{ - switch ( u_DeformType ) - { - default: - { - return pos; - } - - case DEFORM_BULGE: - { - float bulgeHeight = u_DeformParams0.y; // amplitude - float bulgeWidth = u_DeformParams0.z; // phase - float bulgeSpeed = u_DeformParams0.w; // frequency - - float scale = CalculateDeformScale( WF_SIN, u_Time, bulgeWidth * st.x, bulgeSpeed ); - - return pos + normal * scale * bulgeHeight; - } - - case DEFORM_WAVE: - { - float base = u_DeformParams0.x; - float amplitude = u_DeformParams0.y; - float phase = u_DeformParams0.z; - float frequency = u_DeformParams0.w; - float spread = u_DeformParams1.x; - - float offset = dot( pos.xyz, vec3( spread ) ); - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase + offset, frequency ); - - return pos + normal * (base + scale * amplitude); - } - - case DEFORM_MOVE: - { - float base = u_DeformParams0.x; - float amplitude = u_DeformParams0.y; - float phase = u_DeformParams0.z; - float frequency = u_DeformParams0.w; - vec3 direction = u_DeformParams1.xyz; - - float scale = CalculateDeformScale( u_DeformFunc, u_Time, phase, frequency ); - - return pos + direction * (base + scale * amplitude); - } - - case DEFORM_PROJECTION_SHADOW: - { - vec3 ground = u_DeformParams0.xyz; - float groundDist = u_DeformParams0.w; - vec3 lightDir = u_DeformParams1.xyz; - - float d = dot( lightDir, ground ); - - lightDir = lightDir * max( 0.5 - d, 0.0 ) + ground; - d = 1.0 / dot( lightDir, ground ); - - vec3 lightPos = lightDir * d; - - return pos - lightPos * dot( pos, ground ) + groundDist; - } - } -} - -vec3 DeformNormal( const in vec3 position, const in vec3 normal ) -{ - if ( u_DeformType != DEFORM_NORMALS ) - { - return normal; - } - - float amplitude = u_DeformParams0.y; - float frequency = u_DeformParams0.w; - - vec3 outNormal = normal; - const float scale = 0.98; - - outNormal.x += amplitude * GetNoiseValue( - position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - outNormal.y += amplitude * GetNoiseValue( - 100.0 * position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - outNormal.z += amplitude * GetNoiseValue( - 200.0 * position.x * scale, - position.y * scale, - position.z * scale, - u_Time * frequency ); - - return outNormal; -} - -void main() -{ - vec3 position = attr_Position; - vec3 normal = attr_Normal; - normal = normalize(normal - vec3(0.5)); - - position = DeformPosition(position, normal, attr_TexCoord0.st); - mat4 MVP = u_viewProjectionMatrix * u_ModelMatrix; - gl_Position = MVP * vec4(position, 1.0); -} - -/*[Fragment]*/ -out vec4 out_Color; -void main() -{ - out_Color = vec4(0.0, 0.0, 0.0, 1.0); -} diff --git a/codemp/rd-rend2/glsl/shadowmask.glsl b/codemp/rd-rend2/glsl/shadowmask.glsl deleted file mode 100644 index 5e07f156dd..0000000000 --- a/codemp/rd-rend2/glsl/shadowmask.glsl +++ /dev/null @@ -1,179 +0,0 @@ -/*[Vertex]*/ -uniform vec3 u_ViewForward; -uniform vec3 u_ViewLeft; -uniform vec3 u_ViewUp; -uniform vec4 u_ViewInfo; // zfar / znear - -out vec2 var_DepthTex; -out vec3 var_ViewDir; - -void main() -{ - vec2 position = vec2(2.0 * float(gl_VertexID & 2) - 1.0, 4.0 * float(gl_VertexID & 1) - 1.0); - gl_Position = vec4(position, 0.0, 1.0); - vec2 screenCoords = gl_Position.xy / gl_Position.w; - var_DepthTex = position.xy * .5 + .5; - var_ViewDir = u_ViewForward + u_ViewLeft * -screenCoords.x + u_ViewUp * screenCoords.y; -} - -/*[Fragment]*/ -uniform sampler2D u_ScreenDepthMap; - -uniform sampler2DArrayShadow u_ShadowMap; - -uniform mat4 u_ShadowMvp; -uniform mat4 u_ShadowMvp2; -uniform mat4 u_ShadowMvp3; - -uniform vec3 u_ViewOrigin; -uniform vec4 u_ViewInfo; // zfar / znear, zfar - -in vec2 var_DepthTex; -in vec3 var_ViewDir; - -out vec4 out_Color; - -// depth is GL_DEPTH_COMPONENT16 -// so the maximum error is 1.0 / 2^16 -#define DEPTH_MAX_ERROR 0.0000152587890625 - -// Input: It uses texture coords as the random number seed. -// Output: Random number: [0,1), that is between 0.0 and 0.999999... inclusive. -// Author: Michael Pohoreski -// Copyright: Copyleft 2012 :-) -// Source: http://stackoverflow.com/questions/5149544/can-i-generate-a-random-number-inside-a-pixel-shader - -float random( const vec2 p ) -{ - // We need irrationals for pseudo randomness. - // Most (all?) known transcendental numbers will (generally) work. - const vec2 r = vec2( - 23.1406926327792690, // e^pi (Gelfond's constant) - 2.6651441426902251); // 2^sqrt(2) (Gelfond-Schneider constant) - //return fract( cos( mod( 123456789., 1e-7 + 256. * dot(p,r) ) ) ); - return mod( 123456789., 1e-7 + 256. * dot(p,r) ); -} - -const vec2 poissonDisk[16] = vec2[16]( - vec2( -0.94201624, -0.39906216 ), - vec2( 0.94558609, -0.76890725 ), - vec2( -0.094184101, -0.92938870 ), - vec2( 0.34495938, 0.29387760 ), - vec2( -0.91588581, 0.45771432 ), - vec2( -0.81544232, -0.87912464 ), - vec2( -0.38277543, 0.27676845 ), - vec2( 0.97484398, 0.75648379 ), - vec2( 0.44323325, -0.97511554 ), - vec2( 0.53742981, -0.47373420 ), - vec2( -0.26496911, -0.41893023 ), - vec2( 0.79197514, 0.19090188 ), - vec2( -0.24188840, 0.99706507 ), - vec2( -0.81409955, 0.91437590 ), - vec2( 0.19984126, 0.78641367 ), - vec2( 0.14383161, -0.14100790 ) -); - -float PCF(const sampler2DArrayShadow shadowmap, const float layer, const vec2 st, const float dist, float PCFScale) -{ - float mult; - float scale = PCFScale / r_shadowMapSize; - -#if defined(USE_SHADOW_FILTER) - float r = random(var_DepthTex.xy); - float sinr = sin(r); - float cosr = cos(r); - mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; - - mult = texture(shadowmap, vec4(st + rmat * vec2(-0.7055767, 0.196515), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(0.3524343, -0.7791386), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(0.2391056, 0.9189604), layer, dist)); - #if defined(USE_SHADOW_FILTER2) - mult += texture(shadowmap, vec4(st + rmat * vec2(-0.07580382, -0.09224417), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(0.5784913, -0.002528916), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(0.192888, 0.4064181), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(-0.6335801, -0.5247476), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(-0.5579782, 0.7491854), layer, dist)); - mult += texture(shadowmap, vec4(st + rmat * vec2(0.7320465, 0.6317794), layer, dist)); - - mult *= 0.11111; - #else - mult *= 0.33333; - #endif -#else - float r = random(var_DepthTex.xy); - float sinr = sin(r); - float cosr = cos(r); - mat2 rmat = mat2(cosr, sinr, -sinr, cosr) * scale; - - mult = texture(shadowmap, vec4(st, layer, dist)); - for (int i = 0; i < 16; i++) - { - vec2 delta = rmat * poissonDisk[i]; - mult += texture(shadowmap, vec4(st + delta, layer, dist)); - } - mult *= 1.0 / 17.0; -#endif - - return mult; -} - -float getLinearDepth(sampler2D depthMap, vec2 tex, float zFarDivZNear, float maxErrorFactor) -{ - float sampleZDivW = texture(depthMap, tex).r; - sampleZDivW -= DEPTH_MAX_ERROR; - sampleZDivW -= maxErrorFactor * fwidth(sampleZDivW); - return 1.0 / mix(zFarDivZNear, 1.0, sampleZDivW); -} - -void main() -{ - - - float depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 3.0); - float sampleZ = u_ViewInfo.y * depth; - - vec4 biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); - - const float PCFScale = 1.0; - const float edgeBias = 0.5 - ( 4.0 * PCFScale / r_shadowMapSize ); - float edgefactor = 0.0; - const float fadeTo = 1.0; - float result = 1.0; - - vec4 shadowpos = u_ShadowMvp * biasPos; - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) - { - vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); - edgefactor = 2.0 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); - result = PCF(u_ShadowMap, 0.0, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); - } - else - { - //depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 1.5); - //biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); - shadowpos = u_ShadowMvp2 * biasPos; - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(edgeBias)))) - { - vec3 dCoords = smoothstep(0.3, 0.45, abs(shadowpos.xyz - vec3(0.5))); - edgefactor = 0.5 * PCFScale * clamp(dCoords.x + dCoords.y + dCoords.z, 0.0, 1.0); - result = PCF(u_ShadowMap, 1.0, shadowpos.xy, shadowpos.z, PCFScale + edgefactor); - } - else - { - //depth = getLinearDepth(u_ScreenDepthMap, var_DepthTex, u_ViewInfo.x, 1.0); - //biasPos = vec4(u_ViewOrigin + var_ViewDir * (depth - 0.5 / u_ViewInfo.x), 1.0); - shadowpos = u_ShadowMvp3 * biasPos; - shadowpos.xyz = shadowpos.xyz / shadowpos.w * 0.5 + 0.5; - if (all(lessThanEqual(abs(shadowpos.xyz - vec3(0.5)), vec3(1.0)))) - { - result = PCF(u_ShadowMap, 2.0, shadowpos.xy, shadowpos.z, PCFScale); - float fade = clamp(sampleZ / r_shadowCascadeZFar * 10.0 - 9.0, 0.0, 1.0); - result = mix(result, fadeTo, fade); - } - } - } - - out_Color = vec4(vec3(result), 1.0); -} diff --git a/codemp/rd-rend2/glsl/surface_sprites.glsl b/codemp/rd-rend2/glsl/surface_sprites.glsl index 904809a33e..338f7a421e 100644 --- a/codemp/rd-rend2/glsl/surface_sprites.glsl +++ b/codemp/rd-rend2/glsl/surface_sprites.glsl @@ -64,7 +64,8 @@ void main() width += u_FadeScale * fadeScale * width; #if defined(FX_SPRITE) - var_Effectpos = fract((u_frameTime+10000.0*attr_Position.w) / u_FxDuration); + float sprite_time = u_frameTime * 1000.0; + var_Effectpos = fract((sprite_time+10000.0*attr_Position.w) / u_FxDuration); width += var_Effectpos * width * u_FxGrow.x; height += var_Effectpos * height * u_FxGrow.y; #endif @@ -109,7 +110,8 @@ void main() #if !defined(FACE_UP) && !defined(FX_SPRITE) float isLowerVertex = float(offset.z == 0.0); offset.xy += mix(skew, vec2(0.0), isLowerVertex); - float angle = (attr_Position.x + attr_Position.y) * 0.02 + (u_frameTime * 0.0015); + float sprite_time = u_frameTime * 1000.0; + float angle = (attr_Position.x + attr_Position.y) * 0.02 + (sprite_time * 0.0015); float windsway = mix(height* u_WindIdle * 0.075, 0.0, isLowerVertex); offset.xy += vec2(cos(angle), sin(angle)) * windsway; #endif diff --git a/codemp/rd-rend2/tr_animation.cpp b/codemp/rd-rend2/tr_animation.cpp index 029b54272d..b1ca5e95f8 100644 --- a/codemp/rd-rend2/tr_animation.cpp +++ b/codemp/rd-rend2/tr_animation.cpp @@ -196,7 +196,7 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { personalModel = (qboolean)( (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || - (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); + (tr.viewParms.flags & VPF_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { @@ -243,12 +243,6 @@ void R_MDRAddAnimSurfaces( trRefEntity_t *ent, int entityNum ) { { lod = (mdrLOD_t *) ((byte *) lod + lod->ofsEnd); } - - // set up lighting - if ( !personalModel || r_shadows->integer > 1 ) - { - R_SetupEntityLighting( &tr.refdef, ent ); - } // fogNum? fogNum = R_MDRComputeFogNum( header, ent ); diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index b9be8b3aa0..fee052422e 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -595,15 +595,8 @@ void RB_BeginDrawingView (void) { } } - // clear to white for shadow maps - if (backEnd.viewParms.flags & VPF_SHADOWMAP) - { - clearBits |= GL_COLOR_BUFFER_BIT; - qglClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); - } - // dont clear color if we have a skyportal and it has been rendered - if (tr.world && tr.world->skyboxportal == 1 && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) + if (tr.world && tr.world->skyboxportal == 1 && !(tr.viewParms.isSkyPortal)) clearBits &= ~GL_COLOR_BUFFER_BIT; if (clearBits > 0 && !(backEnd.viewParms.flags & VPF_NOCLEAR)) @@ -1209,6 +1202,9 @@ static void RB_SubmitDrawSurfsForDepthFill( R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemapIndex, &postRender); assert(shader != nullptr); + if (shader->useSimpleDepthShader == qtrue) + shader = tr.defaultShader; + if (shader->sort != SS_OPAQUE || shader->useDistortion) { // Don't draw yet, let's see what's to come @@ -1222,13 +1218,13 @@ static void RB_SubmitDrawSurfsForDepthFill( RB_EndSurface(); RB_BeginSurface(shader, 0, 0); oldBoneCache = ((CRenderableSurface*)drawSurf->surface)->boneCache; + tr.animationBoneUboOffset = RB_GetBoneUboOffset((CRenderableSurface*)drawSurf->surface); } } if ( shader == oldShader && entityNum == oldEntityNum ) { // fast path, same as previous sort - backEnd.currentDrawSurfIndex = i; rb_surfaceTable[*drawSurf->surface](drawSurf->surface); continue; } @@ -1259,8 +1255,6 @@ static void RB_SubmitDrawSurfsForDepthFill( oldEntityNum = entityNum; } - backEnd.currentDrawSurfIndex = i; - // add the triangles for this surface assert(drawSurf->surface != nullptr); rb_surfaceTable[*drawSurf->surface](drawSurf->surface); @@ -1310,6 +1304,7 @@ static void RB_SubmitDrawSurfs( RB_EndSurface(); RB_BeginSurface(shader, fogNum, cubemapIndex); oldBoneCache = ((CRenderableSurface*)drawSurf->surface)->boneCache; + tr.animationBoneUboOffset = RB_GetBoneUboOffset((CRenderableSurface*)drawSurf->surface); } } @@ -1322,7 +1317,6 @@ static void RB_SubmitDrawSurfs( backEnd.refractionFill == shader->useDistortion ) { // fast path, same as previous sort - backEnd.currentDrawSurfIndex = i; rb_surfaceTable[*drawSurf->surface](drawSurf->surface); continue; } @@ -1366,8 +1360,6 @@ static void RB_SubmitDrawSurfs( if (backEnd.refractionFill != isDistortionShader) continue; - backEnd.currentDrawSurfIndex = i; - // ugly hack for now... // find better way to pass dlightbits tess.dlightBits = drawSurf->dlightBits; @@ -1994,91 +1986,6 @@ static const void *RB_PrefilterEnvMap(const void *data) { } -static void RB_RenderSunShadows() -{ - if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW) || - (backEnd.viewParms.flags & VPF_SHADOWMAP) || - (backEnd.refdef.rdflags & RDF_NOWORLDMODEL)) - return; - - FBO_t *shadowFbo = tr.screenShadowFbo; - - vec4_t box; - - FBO_Bind(shadowFbo); - - const float viewportScaleX = shadowFbo->width / glConfig.vidWidth; - const float viewportScaleY = shadowFbo->height / glConfig.vidHeight; - - box[0] = backEnd.viewParms.viewportX * viewportScaleX; - box[1] = backEnd.viewParms.viewportY * viewportScaleY; - box[2] = backEnd.viewParms.viewportWidth * viewportScaleX; - box[3] = backEnd.viewParms.viewportHeight * viewportScaleY; - - qglViewport(box[0], box[1], box[2], box[3]); - qglScissor(box[0], box[1], box[2], box[3]); - - GL_State(GLS_DEPTHTEST_DISABLE); - GLSL_BindProgram(&tr.shadowmaskShader); - - if (tr.renderCubeFbo[0] != NULL && ( - backEnd.viewParms.targetFbo == tr.renderCubeFbo[0] || - backEnd.viewParms.targetFbo == tr.renderCubeFbo[1] || - backEnd.viewParms.targetFbo == tr.renderCubeFbo[2] || - backEnd.viewParms.targetFbo == tr.renderCubeFbo[3] || - backEnd.viewParms.targetFbo == tr.renderCubeFbo[4] || - backEnd.viewParms.targetFbo == tr.renderCubeFbo[5] - ) - ) - { - GL_BindToTMU(tr.renderCubeDepthImage, TB_COLORMAP); - } - else - { - GL_BindToTMU(tr.renderDepthImage, TB_COLORMAP); - } - - GL_BindToTMU(tr.sunShadowArrayImage, TB_SHADOWMAPARRAY); - - GLSL_SetUniformMatrix4x4( - &tr.shadowmaskShader, - UNIFORM_SHADOWMVP, - backEnd.refdef.sunShadowMvp[0]); - GLSL_SetUniformMatrix4x4( - &tr.shadowmaskShader, - UNIFORM_SHADOWMVP2, - backEnd.refdef.sunShadowMvp[1]); - GLSL_SetUniformMatrix4x4( - &tr.shadowmaskShader, - UNIFORM_SHADOWMVP3, - backEnd.refdef.sunShadowMvp[2]); - GLSL_SetUniformVec3( - &tr.shadowmaskShader, - UNIFORM_VIEWORIGIN, - backEnd.refdef.vieworg); - - const float zmax = backEnd.viewParms.zFar; - const float ymax = zmax * tanf(backEnd.viewParms.fovY * M_PI / 360.0f); - const float xmax = zmax * tanf(backEnd.viewParms.fovX * M_PI / 360.0f); - - const float zmin = r_znear->value; - - vec3_t viewBasis[3]; - VectorScale(backEnd.refdef.viewaxis[0], zmax, viewBasis[0]); - VectorScale(backEnd.refdef.viewaxis[1], xmax, viewBasis[1]); - VectorScale(backEnd.refdef.viewaxis[2], ymax, viewBasis[2]); - - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWFORWARD, viewBasis[0]); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWLEFT, viewBasis[1]); - GLSL_SetUniformVec3(&tr.shadowmaskShader, UNIFORM_VIEWUP, viewBasis[2]); - - const vec4_t viewInfo = { zmax / zmin, zmax, 0.0f, 0.0f }; - GLSL_SetUniformVec4(&tr.shadowmaskShader, UNIFORM_VIEWINFO, viewInfo); - RB_InstantTriangle(); - - GL_BindToTMU(NULL, TB_SHADOWMAP); -} - static void RB_RenderSSAO() { const float zmax = backEnd.viewParms.zFar; @@ -2160,7 +2067,7 @@ static void RB_RenderDepthOnly( drawSurf_t *drawSurfs, int numDrawSurfs ) if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW) && - !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) + !(tr.viewParms.isSkyPortal)) { // need the depth in a texture we can do GL_LINEAR sampling on, so // copy it to an HDR image @@ -2236,14 +2143,9 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu RB_RenderDepthOnly(drawSurfs, numDrawSurfs); - if ( r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW)) - { - RB_RenderSunShadows(); - } - if (r_ssao->integer && !(backEnd.viewParms.flags & VPF_DEPTHSHADOW) && - !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) + !(tr.viewParms.isSkyPortal)) { RB_RenderSSAO(); } @@ -2260,47 +2162,69 @@ static void RB_RenderAllDepthRelatedPasses( drawSurf_t *drawSurfs, int numDrawSu static void RB_UpdateCameraConstants(gpuFrame_t *frame) { - const float zmax = backEnd.viewParms.zFar; - const float zmin = r_znear->value; + for (int i = 0; i < tr.numCachedViewParms; i++) + { + const float zmax = tr.cachedViewParms[i].zFar; + const float zmin = tr.cachedViewParms[i].zNear; + + const float ymax = zmax * tanf(backEnd.viewParms.fovY * M_PI / 360.0f); + const float xmax = zmax * tanf(backEnd.viewParms.fovX * M_PI / 360.0f); + + vec3_t viewBasis[3]; + + VectorNormalize(tr.cachedViewParms[i].ori.axis[0]); + VectorNormalize(tr.cachedViewParms[i].ori.axis[1]); + VectorNormalize(tr.cachedViewParms[i].ori.axis[2]); + + VectorScale(tr.cachedViewParms[i].ori.axis[0], zmax, viewBasis[0]); + VectorScale(tr.cachedViewParms[i].ori.axis[1], xmax, viewBasis[1]); + VectorScale(tr.cachedViewParms[i].ori.axis[2], ymax, viewBasis[2]); + + CameraBlock cameraBlock = {}; + Matrix16Multiply( + tr.cachedViewParms[i].projectionMatrix, + tr.cachedViewParms[i].world.modelViewMatrix, + cameraBlock.viewProjectionMatrix); + VectorSet4(cameraBlock.viewInfo, zmax / zmin, zmax, 0.0f, 0.0f); + VectorCopy(viewBasis[0], cameraBlock.viewForward); + VectorCopy(viewBasis[1], cameraBlock.viewLeft); + VectorCopy(viewBasis[2], cameraBlock.viewUp); + VectorCopy(tr.cachedViewParms[i].ori.origin, cameraBlock.viewOrigin); - CameraBlock cameraBlock = {}; - Matrix16Multiply( - backEnd.viewParms.projectionMatrix, - backEnd.viewParms.world.modelViewMatrix, - cameraBlock.viewProjectionMatrix); - VectorSet4(cameraBlock.viewInfo, zmax / zmin, zmax, 0.0f, 0.0f); - VectorCopy(backEnd.refdef.viewaxis[0], cameraBlock.viewForward); - VectorCopy(backEnd.refdef.viewaxis[1], cameraBlock.viewLeft); - VectorCopy(backEnd.refdef.viewaxis[2], cameraBlock.viewUp); - VectorCopy(backEnd.refdef.vieworg, cameraBlock.viewOrigin); - tr.cameraUboOffset = RB_AppendConstantsData( - frame, &cameraBlock, sizeof(cameraBlock)); + tr.cameraUboOffsets[tr.cachedViewParms[i].currentViewParm] = RB_AppendConstantsData( + frame, &cameraBlock, sizeof(cameraBlock)); + } } -static void RB_UpdateSceneConstants(gpuFrame_t *frame) +static void RB_UpdateSceneConstants(gpuFrame_t *frame, const trRefdef_t *refdef) { SceneBlock sceneBlock = {}; - VectorCopy4(backEnd.refdef.sunDir, sceneBlock.primaryLightOrigin); - VectorCopy(backEnd.refdef.sunAmbCol, sceneBlock.primaryLightAmbient); - VectorCopy(backEnd.refdef.sunCol, sceneBlock.primaryLightColor); + VectorCopy4(refdef->sunDir, sceneBlock.primaryLightOrigin); + VectorCopy(refdef->sunAmbCol, sceneBlock.primaryLightAmbient); + VectorCopy(refdef->sunCol, sceneBlock.primaryLightColor); if (tr.world != nullptr) sceneBlock.globalFogIndex = tr.world->globalFogIndex - 1; else sceneBlock.globalFogIndex = -1; - sceneBlock.currentTime = backEnd.refdef.time; - sceneBlock.frameTime = backEnd.refdef.frameTime; + sceneBlock.currentTime = refdef->floatTime; + sceneBlock.frameTime = refdef->frameTime; tr.sceneUboOffset = RB_AppendConstantsData( frame, &sceneBlock, sizeof(sceneBlock)); } -static void RB_UpdateLightsConstants(gpuFrame_t *frame) +static void RB_UpdateLightsConstants(gpuFrame_t *frame, const trRefdef_t *refdef) { LightsBlock lightsBlock = {}; - lightsBlock.numLights = backEnd.refdef.num_dlights; + + memcpy(lightsBlock.shadowVP1, refdef->sunShadowMvp[0], sizeof(matrix_t)); + memcpy(lightsBlock.shadowVP2, refdef->sunShadowMvp[1], sizeof(matrix_t)); + memcpy(lightsBlock.shadowVP3, refdef->sunShadowMvp[2], sizeof(matrix_t)); + + lightsBlock.numLights = MIN(refdef->num_dlights, MAX_DLIGHTS); for (int i = 0; i < lightsBlock.numLights; ++i) { - const dlight_t *dlight = backEnd.refdef.dlights + i; + const dlight_t *dlight = refdef->dlights + i; LightsBlock::Light *lightData = lightsBlock.lights + i; VectorSet4( @@ -2396,65 +2320,27 @@ static void RB_UpdateEntityModelConstants( if (refEntity->e.oldframe || refEntity->e.frame) if (refEntity->e.oldframe != refEntity->e.frame) entityBlock.vertexLerp = refEntity->e.backlerp; + + entityBlock.entityTime = 0.0f; + if (refEntity != &tr.worldEntity) + entityBlock.entityTime = -refEntity->e.shaderTime; } -static void RB_UpdateSkyEntityConstants(gpuFrame_t *frame) +static void RB_UpdateSkyEntityConstants(gpuFrame_t *frame, const trRefdef_t *refdef) { EntityBlock skyEntityBlock = {}; skyEntityBlock.fxVolumetricBase = -1.0f; - Matrix16Translation(backEnd.viewParms.ori.origin, skyEntityBlock.modelMatrix); + if (tr.world && tr.world->skyboxportal) + Matrix16Translation(tr.skyPortalParms.ori.origin, skyEntityBlock.modelMatrix); + else + Matrix16Translation(refdef->vieworg, skyEntityBlock.modelMatrix); tr.skyEntityUboOffset = RB_AppendConstantsData( frame, &skyEntityBlock, sizeof(skyEntityBlock)); } -static uint32_t RB_HashEntityShaderKey(int entityNum, int shaderNum) -{ - uint32_t hash = 0; - hash += entityNum; - hash += shaderNum * 119; - return (hash ^ (hash >> 10) ^ (hash >> 20)); -} - -void RB_InsertEntityShaderUboOffset( - EntityShaderUboOffset *offsetMap, - int mapSize, - int entityNum, - int shaderNum, - int uboOffset) -{ - int hash = RB_HashEntityShaderKey(entityNum, shaderNum) % mapSize; - while (offsetMap[hash].inuse) - hash = (hash + 1) % mapSize; - - EntityShaderUboOffset& offset = offsetMap[hash]; - offset.inuse = true; - offset.entityNum = entityNum; - offset.shaderNum = shaderNum; - offset.offset = uboOffset; -} - -int RB_GetEntityShaderUboOffset( - EntityShaderUboOffset *offsetMap, - int mapSize, - int entityNum, - int shaderNum) -{ - int hash = RB_HashEntityShaderKey(entityNum, shaderNum) % mapSize; - while (offsetMap[hash].inuse) - { - const EntityShaderUboOffset& uboOffset = offsetMap[hash]; - if (uboOffset.entityNum == entityNum && - uboOffset.shaderNum == shaderNum) - return uboOffset.offset; - hash = (hash + 1) % mapSize; - } - - return -1; -} - static void ComputeDeformValues( - const trRefEntity_t *refEntity, + //const trRefEntity_t *refEntity, const shader_t *shader, deform_t *type, genFunc_t *waveFunc, @@ -2465,11 +2351,12 @@ static void ComputeDeformValues( *type = DEFORM_NONE; *waveFunc = GF_NONE; - if (refEntity->e.renderfx & RF_DISINTEGRATE2) + // Handled via the CGEN_DISINTEGRATION_2 color gen, as both just happen at the same time + /*if (refEntity->e.renderfx & RF_DISINTEGRATE2) { *type = DEFORM_DISINTEGRATION; return; - } + }*/ if (!ShaderRequiresCPUDeforms(shader)) { @@ -2535,7 +2422,7 @@ static void ComputeDeformValues( case DEFORM_PROJECTION_SHADOW: *type = DEFORM_PROJECTION_SHADOW; - + /* deformParams0[0] = backEnd.ori.axis[0][2]; deformParams0[1] = backEnd.ori.axis[1][2]; deformParams0[2] = backEnd.ori.axis[2][2]; @@ -2549,7 +2436,7 @@ static void ComputeDeformValues( deformParams1[0] = lightDir[0]; deformParams1[1] = lightDir[1]; - deformParams1[2] = lightDir[2]; + deformParams1[2] = lightDir[2];*/ break; default: @@ -2558,258 +2445,101 @@ static void ComputeDeformValues( } } - -static void RB_UpdateShaderEntityConstants( - gpuFrame_t *frame, - const int entityNum, - const trRefEntity_t *refEntity, - const shader_t *shader) +void RB_AddShaderToShaderInstanceUBO(shader_t *shader) { if (shader->numDeforms != 1 && !shader->portalRange) { - RB_InsertEntityShaderUboOffset( - tr.shaderInstanceUboOffsetsMap, - tr.shaderInstanceUboOffsetsMapSize, - entityNum, - shader->index, - -1); + shader->ShaderInstanceUboOffset = -1; return; } + ShaderInstanceBlock shaderInstanceBlock = {}; ComputeDeformValues( - refEntity, shader, (deform_t *)&shaderInstanceBlock.deformType, (genFunc_t *)&shaderInstanceBlock.deformFunc, shaderInstanceBlock.deformParams0, shaderInstanceBlock.deformParams1); shaderInstanceBlock.portalRange = shader->portalRange; - shaderInstanceBlock.time = - backEnd.refdef.floatTime - shader->timeOffset; - if (entityNum != REFENTITYNUM_WORLD) - shaderInstanceBlock.time -= refEntity->e.shaderTime; - - const int uboOffset = RB_AppendConstantsData( - frame, &shaderInstanceBlock, sizeof(shaderInstanceBlock)); + shaderInstanceBlock.time = -shader->timeOffset; - RB_InsertEntityShaderUboOffset( - tr.shaderInstanceUboOffsetsMap, - tr.shaderInstanceUboOffsetsMapSize, - entityNum, - shader->index, - uboOffset); + shader->ShaderInstanceUboOffset = RB_AddShaderInstanceBlock((void*)&shaderInstanceBlock); } -static void RB_UpdateShaderAndEntityConstants( - gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) +static void RB_UpdateEntityConstants( + gpuFrame_t *frame, const trRefdef_t *refdef) { - // Make the map bigger than it needs to be. Eases collisions and iterations - // through the map during lookup/insertion. - tr.shaderInstanceUboOffsetsMapSize = numDrawSurfs * 2; - tr.shaderInstanceUboOffsetsMap = ojkAllocArray( - *backEndData->perFrameMemory, - tr.shaderInstanceUboOffsetsMapSize); - memset(tr.entityUboOffsets, 0, sizeof(tr.entityUboOffsets)); - memset( - tr.shaderInstanceUboOffsetsMap, 0, - sizeof(EntityShaderUboOffset) * tr.shaderInstanceUboOffsetsMapSize); - - int old_ubo = 0; - shader_t *oldShader = nullptr; - int oldEntityNum = -1; - - for (int i = 0; i < numDrawSurfs; ++i) + for (int i = 0; i < refdef->num_entities; i++) { - const drawSurf_t *drawSurf = drawSurfs + i; - - shader_t *shader; - int ignored; - int entityNum; - - R_DecomposeSort( - drawSurf->sort, &entityNum, &shader, &ignored, &ignored); + trRefEntity_t *ent = &refdef->entities[i]; - if (shader == oldShader && entityNum == oldEntityNum) - continue; + R_SetupEntityLighting(refdef, ent); - if (backEnd.frameUBOsInitialized == qtrue) - { - // TODO: check if data set already inserted - if (RB_GetEntityShaderUboOffset( - tr.shaderInstanceUboOffsetsMap, - tr.shaderInstanceUboOffsetsMapSize, - entityNum, - shader->index) != -1) - continue; - } + EntityBlock entityBlock = {}; + RB_UpdateEntityLightConstants(entityBlock, ent); + RB_UpdateEntityMatrixConstants(entityBlock, ent); + RB_UpdateEntityModelConstants(entityBlock, ent); - if (*drawSurf->surface == SF_FLARE) - { - RB_UpdateShaderEntityConstants(frame, REFENTITYNUM_WORLD, &backEnd.entityFlare, shader); - continue; - } - - const trRefEntity_t *refEntity = entityNum == REFENTITYNUM_WORLD ? &tr.worldEntity : &backEnd.refdef.entities[entityNum]; - - if (shader != oldShader || - (entityNum != oldEntityNum /* && !shader->entityMergable*/)) - { - EntityBlock entityBlock = {}; - - RB_UpdateEntityLightConstants(entityBlock, refEntity); - RB_UpdateEntityMatrixConstants(entityBlock, refEntity); - RB_UpdateEntityModelConstants(entityBlock, refEntity); + tr.entityUboOffsets[i] = RB_AppendConstantsData( + frame, &entityBlock, sizeof(entityBlock)); + } - tr.entityUboOffsets[entityNum] = RB_AppendConstantsData( - frame, &entityBlock, sizeof(entityBlock)); - } - old_ubo = tr.entityUboOffsets[entityNum]; - oldShader = shader; - oldEntityNum = entityNum; + const trRefEntity_t *ent = &tr.worldEntity; + EntityBlock entityBlock = {}; + RB_UpdateEntityLightConstants(entityBlock, ent); + RB_UpdateEntityMatrixConstants(entityBlock, ent); + RB_UpdateEntityModelConstants(entityBlock, ent); - RB_UpdateShaderEntityConstants(frame, entityNum, refEntity, shader); - } + tr.entityUboOffsets[REFENTITYNUM_WORLD] = RB_AppendConstantsData( + frame, &entityBlock, sizeof(entityBlock)); - RB_UpdateSkyEntityConstants(frame); + RB_UpdateSkyEntityConstants(frame, refdef); } -static void RB_UpdateAnimationConstants( - gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) +static void RB_UpdateGhoul2Constants(gpuFrame_t *frame, const trRefdef_t *refdef) { - tr.animationBoneUboOffsets = ojkAllocArray( - *backEndData->perFrameMemory, numDrawSurfs); - memset(tr.animationBoneUboOffsets, 0, sizeof(int) * numDrawSurfs); - - // transform all bones for this frame - for (int i = 0; i < numDrawSurfs; ++i) + for (int i = 0; i < refdef->num_entities; i++) { - const drawSurf_t *drawSurf = drawSurfs + i; - if (*drawSurf->surface != SF_MDX) + const trRefEntity_t *ent = &refdef->entities[i]; + if (ent->e.reType != RT_MODEL) continue; - CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; - RB_TransformBones(RS, backEndData->realFrameNumber); - } - - // now get offsets or add skeletons to ubo - for (int i = 0; i < numDrawSurfs; ++i) - { - const drawSurf_t *drawSurf = drawSurfs + i; - if (*drawSurf->surface != SF_MDX) + model_t *model = R_GetModelByHandle(ent->e.hModel); + if (!model) continue; - CRenderableSurface *RS = (CRenderableSurface *)drawSurf->surface; - - int currentOffset = RB_GetBoneUboOffset(RS); - if (currentOffset < 0) - { - SkeletonBoneMatricesBlock bonesBlock = {}; - RB_FillBoneBlock(RS, bonesBlock.matrices); - tr.animationBoneUboOffsets[i] = RB_AppendConstantsData( - frame, &bonesBlock, sizeof(bonesBlock)); - - RB_SetBoneUboOffset(RS, tr.animationBoneUboOffsets[i], backEndData->realFrameNumber); - } - else + switch (model->type) + { + case MOD_MDXM: + case MOD_BAD: { - tr.animationBoneUboOffsets[i] = currentOffset; + // Transform Bones and upload them + RB_TransformBones(ent, refdef, backEndData->realFrameNumber, frame); } - } -} - -static void Fill_SpriteBlock( srfSprites_t *surf , SurfaceSpriteBlock *surfaceSpriteBlock) -{ - const surfaceSprite_t *ss = surf->sprite; - - surfaceSpriteBlock->fxGrow[0] = ss->fxGrow[0]; - surfaceSpriteBlock->fxGrow[1] = ss->fxGrow[1]; - surfaceSpriteBlock->fxDuration = ss->fxDuration; - surfaceSpriteBlock->fadeStartDistance = ss->fadeDist; - surfaceSpriteBlock->fadeEndDistance = MAX(ss->fadeDist + 250.f, ss->fadeMax); - surfaceSpriteBlock->fadeScale = ss->fadeScale; - surfaceSpriteBlock->wind = ss->wind; - surfaceSpriteBlock->windIdle = ss->windIdle; - surfaceSpriteBlock->fxAlphaStart = ss->fxAlphaStart; - surfaceSpriteBlock->fxAlphaEnd = ss->fxAlphaEnd; -} - -static void RB_UpdateSpriteConstants( - gpuFrame_t *frame, const drawSurf_t *drawSurfs, int numDrawSurfs) -{ - if (!r_surfaceSprites->integer) - return; + break; - // FIX ME: horrible idea to reuse the hashing - tr.surfaceSpriteInstanceUboOffsetsMap = ojkAllocArray( - *backEndData->perFrameMemory, - 64); - memset( - tr.surfaceSpriteInstanceUboOffsetsMap, 0, - sizeof(EntityShaderUboOffset) * 64); - - shader_t *oldShader = nullptr; - - // get all the spriteData - for (int i = 0; i < numDrawSurfs; ++i) - { - const drawSurf_t *drawSurf = drawSurfs + i; - if (*drawSurf->surface != SF_SPRITES) - continue; - - shader_t *shader; - int ignored; - int entityNum; - - R_DecomposeSort( - drawSurf->sort, &entityNum, &shader, &ignored, &ignored); - - if (oldShader == shader) - continue; - - SurfaceSpriteBlock surfaceSpriteBlock = {}; - Fill_SpriteBlock((srfSprites_t*)drawSurf->surface, &surfaceSpriteBlock); - - const int uboOffset = RB_AppendConstantsData( - frame, &surfaceSpriteBlock, sizeof(surfaceSpriteBlock)); - - RB_InsertEntityShaderUboOffset( - tr.surfaceSpriteInstanceUboOffsetsMap, - 64, - REFENTITYNUM_WORLD, - shader->index, - uboOffset); - - oldShader = shader; + default: + break; + } } } -static void RB_UpdateConstants(const drawSurf_t *drawSurfs, int numDrawSurfs) +void RB_UpdateConstants(const trRefdef_t *refdef) { gpuFrame_t *frame = backEndData->currentFrame; RB_BeginConstantsUpdate(frame); - if (backEnd.frameUBOsInitialized == qfalse) - { - RB_UpdateFogsConstants(frame); - RB_UpdateSceneConstants(frame); - RB_UpdateLightsConstants(frame); - } - RB_UpdateCameraConstants(frame); - RB_UpdateShaderAndEntityConstants(frame, drawSurfs, numDrawSurfs); - RB_UpdateAnimationConstants(frame, drawSurfs, numDrawSurfs); - - RB_UpdateSpriteConstants(frame, drawSurfs, numDrawSurfs); + RB_UpdateSceneConstants(frame, refdef); + RB_UpdateLightsConstants(frame, refdef); + RB_UpdateFogsConstants(frame); + RB_UpdateGhoul2Constants(frame, refdef); + RB_UpdateEntityConstants(frame, refdef); RB_EndConstantsUpdate(frame); - - backEnd.frameUBOsInitialized = (backEnd.refdef.rdflags & RDF_SKYBOXPORTAL) ? qfalse : qtrue; } - - - /* ============= RB_DrawBuffer @@ -3017,22 +2747,12 @@ static const void *RB_SwapBuffers( const void *data ) { } } - int frameNumber = backEndData->realFrameNumber; - gpuFrame_t *currentFrame = backEndData->currentFrame; - - assert( !currentFrame->sync ); - currentFrame->sync = qglFenceSync( GL_SYNC_GPU_COMMANDS_COMPLETE, 0 ); - - backEndData->realFrameNumber = frameNumber + 1; + R_NewFrameSync(); GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" ); ri.WIN_Present( &window ); - backEnd.framePostProcessed = qfalse; - backEnd.projection2D = qfalse; - backEnd.frameUBOsInitialized = qfalse; - return (const void *)(cmd + 1); } @@ -3053,16 +2773,6 @@ const void *RB_PostProcess(const void *data) if(tess.numIndexes) RB_EndSurface(); - if (tr.world->skyboxportal && (cmd->refdef.rdflags & RDF_SKYBOXPORTAL)) { - return (const void *)(cmd + 1);; - } - - if (cmd->viewParms.flags & VPF_NOPOSTPROCESS) - { - // do nothing - return (const void *)(cmd + 1); - } - if (cmd) { backEnd.refdef = cmd->refdef; @@ -3309,8 +3019,6 @@ static const void *RB_DrawSurfs(const void *data) { if (cmd->numDrawSurfs > 0) { - RB_UpdateConstants(cmd->drawSurfs, cmd->numDrawSurfs); - RB_RenderAllDepthRelatedPasses(cmd->drawSurfs, cmd->numDrawSurfs); RB_RenderMainPass(cmd->drawSurfs, cmd->numDrawSurfs); diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index 4417f8b130..ea9dc9e92c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3295,6 +3295,7 @@ static void R_RenderAllCubemaps() { R_IssuePendingRenderCommands(); R_InitNextFrame(); + R_NewFrameSync(); GLenum cubemapFormat = GL_RGBA8; if (r_hdr->integer) @@ -3311,20 +3312,7 @@ static void R_RenderAllCubemaps() { for (int j = 0; j < 6; j++) { - RE_BeginFrame(STEREO_CENTER); - - R_RenderCubemapSide(i, j, qfalse, bounce); - R_IssuePendingRenderCommands(); - R_InitNextFrame(); - - gpuFrame_t *currentFrame = backEndData->currentFrame; - assert(!currentFrame->sync); - currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - - backEndData->realFrameNumber++; - backEnd.framePostProcessed = qfalse; - backEnd.projection2D = qfalse; - backEnd.frameUBOsInitialized = qfalse; + R_RenderCubemapSide(i, j, bounce); } R_AddConvolveCubemapCmd(&tr.cubemaps[i], i); @@ -3973,6 +3961,8 @@ static void R_GenerateSurfaceSprites( // FIXME: Need a better way to handle this. out->shader = R_CreateShaderFromTextureBundle(va("*ss_%08x\n", hash), bundle, stage->stateBits); + out->shader->spriteUbo = shader->spriteUbo; + out->shader->cullType = shader->cullType; out->shader->stages[0]->glslShaderGroup = tr.spriteShader; out->alphaTestType = stage->alphaTestType; @@ -4022,13 +4012,85 @@ static void R_GenerateSurfaceSprites( out->attributes[3].stepRate = 0; } -static void R_GenerateSurfaceSprites( const world_t *world ) +static void R_GenerateSurfaceSprites( const world_t *world, int worldIndex ) { + int numSpriteStages = 0; + for (int i = 0; i < tr.numShaders; i++) + { + const shader_t *shader = tr.shaders[i]; + if (shader->spriteUbo != NULL) + continue; + + numSpriteStages += shader->numSurfaceSpriteStages; + } + + if (numSpriteStages == 0) + return; + + //TODO: put into backend + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + size_t spriteAlignedBlockSize = (sizeof(SurfaceSpriteBlock) + alignment) & ~alignment; + + if (glState.currentGlobalUBO != tr.spriteUbos[worldIndex]) + { + qglBindBuffer(GL_UNIFORM_BUFFER, tr.spriteUbos[worldIndex]); + glState.currentGlobalUBO = tr.spriteUbos[worldIndex]; + } + qglBufferData( + GL_UNIFORM_BUFFER, + numSpriteStages * spriteAlignedBlockSize, + nullptr, + GL_STATIC_DRAW); + + size_t alignedBlockSize = 0; + for (int i = 0; i < tr.numShaders; i++) + { + shader_t *shader = tr.shaders[i]; + if (!shader->numSurfaceSpriteStages) + continue; + + shader->spriteUbo = tr.spriteUbos[worldIndex]; + + for (int j = 0, numStages = shader->numUnfoggedPasses; + j < numStages; ++j) + { + const shaderStage_t *stage = shader->stages[j]; + if (!stage) + break; + + if (!stage->ss || stage->ss->type == SURFSPRITE_NONE) + continue; + + if (j > 0 && (stage->stateBits & GLS_DEPTHFUNC_EQUAL)) + { + continue; + } + + SurfaceSpriteBlock surfaceSpriteBlock = {}; + surfaceSprite_t *ss = stage->ss; + + surfaceSpriteBlock.fxGrow[0] = ss->fxGrow[0]; + surfaceSpriteBlock.fxGrow[1] = ss->fxGrow[1]; + surfaceSpriteBlock.fxDuration = ss->fxDuration; + surfaceSpriteBlock.fadeStartDistance = ss->fadeDist; + surfaceSpriteBlock.fadeEndDistance = MAX(ss->fadeDist + 250.f, ss->fadeMax); + surfaceSpriteBlock.fadeScale = ss->fadeScale; + surfaceSpriteBlock.wind = ss->wind; + surfaceSpriteBlock.windIdle = ss->windIdle; + surfaceSpriteBlock.fxAlphaStart = ss->fxAlphaStart; + surfaceSpriteBlock.fxAlphaEnd = ss->fxAlphaEnd; + + ss->spriteUboOffset = alignedBlockSize; + qglBufferSubData( + GL_UNIFORM_BUFFER, ss->spriteUboOffset, sizeof(SurfaceSpriteBlock), &surfaceSpriteBlock); + alignedBlockSize += spriteAlignedBlockSize; + } + } + msurface_t *surfaces = world->surfaces; std::vector sprites_data; sprites_data.reserve(65535); IBO_t *ibo; - { std::vector sprites_index_data; sprites_index_data.reserve(98298); @@ -4225,15 +4287,17 @@ world_t *R_LoadBSP(const char *name, int *bspIndex) R_LoadLightGrid(worldData, &header->lumps[LUMP_LIGHTGRID]); R_LoadLightGridArray(worldData, &header->lumps[LUMP_LIGHTARRAY]); - R_LoadWeatherZones( - worldData, - &header->lumps[LUMP_BRUSHES], - &header->lumps[LUMP_BRUSHSIDES]); - R_GenerateSurfaceSprites(worldData); - // determine vertex light directions R_CalcVertexLightDirs(worldData); + if (bspIndex == nullptr) + R_LoadWeatherZones( + worldData, + &header->lumps[LUMP_BRUSHES], + &header->lumps[LUMP_BRUSHSIDES]); + + R_GenerateSurfaceSprites(worldData, worldIndex + 1); + // load cubemaps if (r_cubeMapping->integer && bspIndex == nullptr) { diff --git a/codemp/rd-rend2/tr_cmds.cpp b/codemp/rd-rend2/tr_cmds.cpp index d707e290fd..12027fdb05 100644 --- a/codemp/rd-rend2/tr_cmds.cpp +++ b/codemp/rd-rend2/tr_cmds.cpp @@ -747,6 +747,18 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) { tr.refdef.stereoFrame = stereoFrame; } +void R_NewFrameSync() +{ + gpuFrame_t *currentFrame = backEndData->currentFrame; + + assert(!currentFrame->sync); + currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); + + backEndData->realFrameNumber++; + backEnd.framePostProcessed = qfalse; + backEnd.projection2D = qfalse; +} + /* ============= diff --git a/codemp/rd-rend2/tr_fbo.cpp b/codemp/rd-rend2/tr_fbo.cpp index ccef288cc5..9a7e4f97a6 100644 --- a/codemp/rd-rend2/tr_fbo.cpp +++ b/codemp/rd-rend2/tr_fbo.cpp @@ -532,7 +532,8 @@ void FBO_Init(void) for ( i = 0; i < 3; i++) { tr.sunShadowFbo[i] = FBO_Create( - "_sunshadowmap", tr.sunShadowArrayImage->width, + va("_sunshadowmap%i", i), + tr.sunShadowArrayImage->width, tr.sunShadowArrayImage->height); FBO_Bind(tr.sunShadowFbo[i]); diff --git a/codemp/rd-rend2/tr_flares.cpp b/codemp/rd-rend2/tr_flares.cpp index 6446db9edd..be6d4120e1 100644 --- a/codemp/rd-rend2/tr_flares.cpp +++ b/codemp/rd-rend2/tr_flares.cpp @@ -396,8 +396,7 @@ void RB_RenderFlares (void) { return; } - if ((backEnd.viewParms.flags & VPF_DEPTHSHADOW) || - (backEnd.viewParms.flags & VPF_NOPOSTPROCESS)) + if (backEnd.viewParms.flags & VPF_DEPTHSHADOW) return; // Reset currentEntity to world so that any previously referenced entities diff --git a/codemp/rd-rend2/tr_ghoul2.cpp b/codemp/rd-rend2/tr_ghoul2.cpp index 4701ba6899..716191a08a 100644 --- a/codemp/rd-rend2/tr_ghoul2.cpp +++ b/codemp/rd-rend2/tr_ghoul2.cpp @@ -3180,27 +3180,17 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) } HackadelicOnClient = true; - - // are any of these models setting a new origin? - mdxaBone_t rootMatrix; - RootMatrix(ghoul2, currentTime, ent->e.modelScale, rootMatrix); // don't add third_person objects if not in a portal qboolean personalModel = (qboolean)( (ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal || - (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); + (tr.viewParms.flags & VPF_DEPTHSHADOW))); int modelList[256]; assert(ghoul2.size() < ARRAY_LEN(modelList)); modelList[255] = 548; - // set up lighting now that we know we aren't culled - if ( !personalModel || r_shadows->integer > 1 ) - { - R_SetupEntityLighting(&tr.refdef, ent); - } - // see if we are in a fog volume int fogNum = R_GComputeFogNum(ent); @@ -3216,9 +3206,6 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) } #endif - // construct a world matrix for this entity - G2_GenerateWorldMatrix(ent->e.angles, ent->e.origin); - // walk each possible model for this entity and try rendering it out for (int j = 0; j < modelCount; ++j ) { @@ -3260,20 +3247,6 @@ void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ) } } - if ( j && g2Info.mModelBoltLink != -1 ) - { - int boltMod = (g2Info.mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; - int boltNum = (g2Info.mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; - - mdxaBone_t bolt; - G2_GetBoltMatrixLow(ghoul2[boltMod], boltNum, ent->e.modelScale, bolt); - G2_TransformGhoulBones(g2Info.mBlist, bolt, g2Info, currentTime); - } - else - { - G2_TransformGhoulBones(g2Info.mBlist, rootMatrix, g2Info,currentTime); - } - int whichLod = G2_ComputeLOD( ent, g2Info.currentModel, g2Info.mLodBias ); G2_FindOverrideSurface(-1, g2Info.mSlist); //reset the quick surface override lookup; @@ -3445,25 +3418,102 @@ static inline float G2_GetVertBoneWeightNotSlow( const mdxmVertex_t *pVert, cons return fBoneWeight; } -void RB_TransformBones(CRenderableSurface *surf, int currentFrameNum) +void RB_TransformBones(const trRefEntity_t *ent, const trRefdef_t *refdef, int currentFrameNum, gpuFrame_t *frame) { - if (surf->boneCache->uboGPUFrame == currentFrameNum) + if (!ent->e.ghoul2 || !G2API_HaveWeGhoul2Models(*((CGhoul2Info_v *)ent->e.ghoul2))) + return; + + CGhoul2Info_v &ghoul2 = *((CGhoul2Info_v *)ent->e.ghoul2); + + if (!ghoul2.IsValid()) + return; + + // if we don't want server ghoul2 models and this is one, or we just don't + // want ghoul2 models at all, then return + if (r_noServerGhoul2->integer) + { return; + } + + if (!G2_SetupModelPointers(ghoul2)) + { + return; + } + + int currentTime = G2API_GetTime(refdef->time); + + HackadelicOnClient = true; + + mdxaBone_t rootMatrix; + RootMatrix(ghoul2, currentTime, ent->e.modelScale, rootMatrix); - const mdxmSurface_t *surfData = surf->surfaceData; - const int *boneReferences = - (const int *)((const byte *)surfData + surfData->ofsBoneReferences); + int modelList[256]; + assert(ghoul2.size() < ARRAY_LEN(modelList)); + modelList[255] = 548; - for (int i = 0; i < surfData->numBoneReferences; ++i) + // order sort the ghoul 2 models so bolt ons get bolted to the right model + int modelCount; + G2_Sort_Models(ghoul2, modelList, ARRAY_LEN(modelList), &modelCount); + assert(modelList[255] == 548); + + // construct a world matrix for this entity + G2_GenerateWorldMatrix(ent->e.angles, ent->e.origin); + + // walk each possible model for this entity and try transforming all bones + for (int j = 0; j < modelCount; ++j) { - int boneIndex = boneReferences[i]; - const mdxaBone_t& bone = surf->boneCache->EvalRender(boneReferences[i]); + CGhoul2Info& g2Info = ghoul2[modelList[j]]; + + if (!g2Info.mValid) + { + continue; + } + + if ((g2Info.mFlags & (GHOUL2_NOMODEL | GHOUL2_NORENDER)) != 0) + { + continue; + } + + if (j && g2Info.mModelBoltLink != -1) + { + int boltMod = (g2Info.mModelBoltLink >> MODEL_SHIFT) & MODEL_AND; + int boltNum = (g2Info.mModelBoltLink >> BOLT_SHIFT) & BOLT_AND; + + mdxaBone_t bolt; + G2_GetBoltMatrixLow(ghoul2[boltMod], boltNum, ent->e.modelScale, bolt); + G2_TransformGhoulBones(g2Info.mBlist, bolt, g2Info, currentTime); + } + else + { + G2_TransformGhoulBones(g2Info.mBlist, rootMatrix, g2Info, currentTime); + } + + CBoneCache *bc = g2Info.mBoneCache; + if (bc->uboGPUFrame == currentFrameNum) + return; + + for (int bone = 0; bone < (int)bc->mBones.size(); bone++) + { + const mdxaBone_t& b = bc->EvalRender(bone); + Com_Memcpy( + bc->boneMatrices + bone, + &b.matrix[0][0], + sizeof(mat3x4_t)); + } + bc->uboOffset = -1; + + SkeletonBoneMatricesBlock bonesBlock = {}; Com_Memcpy( - surf->boneCache->boneMatrices + boneIndex, - &bone.matrix[0][0], - sizeof(mat3x4_t)); + bonesBlock.matrices, + bc->boneMatrices, + sizeof(mat3x4_t) * bc->mBones.size()); + + int uboOffset = RB_AppendConstantsData( + frame, &bonesBlock, sizeof(mat3x4_t) * bc->mBones.size()); + + bc->uboOffset = uboOffset; + bc->uboGPUFrame = currentFrameNum; } - surf->boneCache->uboOffset = -1; } int RB_GetBoneUboOffset(CRenderableSurface *surf) @@ -3647,7 +3697,7 @@ void RB_SurfaceGhoul( CRenderableSurface *surf ) tess.numIndexes += numIndexes; tess.numVertexes += numVertexes; tess.useInternalVBO = qfalse; - tess.dlightBits = surf->dlightBits; + tess.dlightBits |= surf->dlightBits; glState.skeletalAnimation = qtrue; } diff --git a/codemp/rd-rend2/tr_glsl.cpp b/codemp/rd-rend2/tr_glsl.cpp index ee58f96f2d..5a3201fa52 100644 --- a/codemp/rd-rend2/tr_glsl.cpp +++ b/codemp/rd-rend2/tr_glsl.cpp @@ -1714,6 +1714,19 @@ static int GLSL_LoadGPUProgramLightAll( Q_strcat(extradefines, sizeof(extradefines), "#define SHADOWMAP_MODULATE\n"); else if (r_sunlightMode->integer == 2) Q_strcat(extradefines, sizeof(extradefines), "#define USE_PRIMARY_LIGHT\n"); + + if (r_shadowFilter->integer >= 1) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER\n"); + + if (r_shadowFilter->integer >= 2) + Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); + + Q_strcat( + extradefines, sizeof(extradefines), + va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); + Q_strcat( + extradefines, sizeof(extradefines), + va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); } if (i & LIGHTDEF_USE_TCGEN_AND_TCMOD) @@ -1849,24 +1862,6 @@ static int GLSL_LoadGPUProgramTextureColor( return 1; } -static int GLSL_LoadGPUProgramDepthFill( - ShaderProgramBuilder& builder, - Allocator& scratchAlloc ) -{ - GLSL_LoadGPUProgramBasic( - builder, - scratchAlloc, - &tr.shadowmapShader, - "shadowfill", - fallback_shadowfillProgram, - ATTR_POSITION | ATTR_NORMAL | ATTR_TEXCOORD0); - - GLSL_InitUniforms(&tr.shadowmapShader); - GLSL_FinishGPUShader(&tr.shadowmapShader); - - return 1; -} - static int GLSL_LoadGPUProgramPShadow( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) @@ -2037,49 +2032,6 @@ static int GLSL_LoadGPUProgramCalcLuminanceLevel( return numPrograms; } -static int GLSL_LoadGPUProgramShadowMask( - ShaderProgramBuilder& builder, - Allocator& scratchAlloc ) -{ - Allocator allocator(scratchAlloc.Base(), scratchAlloc.GetSize()); - - char extradefines[1200]; - const GPUProgramDesc *programDesc = - LoadProgramSource("shadowmask", allocator, fallback_shadowmaskProgram); - const uint32_t attribs = ATTR_POSITION | ATTR_TEXCOORD0; - extradefines[0] = '\0'; - - if (r_shadowFilter->integer >= 1) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER\n"); - - if (r_shadowFilter->integer >= 2) - Q_strcat(extradefines, sizeof(extradefines), "#define USE_SHADOW_FILTER2\n"); - - Q_strcat( - extradefines, sizeof(extradefines), - va("#define r_shadowMapSize %d\n", r_shadowMapSize->integer)); - Q_strcat( - extradefines, sizeof(extradefines), - va("#define r_shadowCascadeZFar %f\n", r_shadowCascadeZFar->value)); - - if (!GLSL_LoadGPUShader(builder, &tr.shadowmaskShader, "shadowmask", attribs, NO_XFB_VARS, - extradefines, *programDesc)) - { - ri.Error(ERR_FATAL, "Could not load shadowmask shader!"); - } - - GLSL_InitUniforms(&tr.shadowmaskShader); - - qglUseProgram(tr.shadowmaskShader.program); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP); - GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SHADOWMAP, TB_SHADOWMAPARRAY); - qglUseProgram(0); - - GLSL_FinishGPUShader(&tr.shadowmaskShader); - - return 1; -} - static int GLSL_LoadGPUProgramSSAO( ShaderProgramBuilder& builder, Allocator& scratchAlloc ) @@ -2401,14 +2353,12 @@ void GLSL_LoadGPUShaders() numEtcShaders += GLSL_LoadGPUProgramFogPass(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramRefraction(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramTextureColor(builder, allocator); - numEtcShaders += GLSL_LoadGPUProgramDepthFill(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramPShadow(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramVShadow(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramDownscale4x(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramBokeh(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramTonemap(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramCalcLuminanceLevel(builder, allocator); - numEtcShaders += GLSL_LoadGPUProgramShadowMask(builder, allocator); numEtcShaders += GLSL_LoadGPUProgramSSAO(builder, allocator); if (r_cubeMapping->integer) numEtcShaders += GLSL_LoadGPUProgramPrefilterEnvMap(builder, allocator); @@ -2451,7 +2401,6 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < LIGHTDEF_COUNT; i++) GLSL_DeleteGPUShader(&tr.lightallShader[i]); - GLSL_DeleteGPUShader(&tr.shadowmapShader); GLSL_DeleteGPUShader(&tr.pshadowShader); GLSL_DeleteGPUShader(&tr.volumeShadowShader); GLSL_DeleteGPUShader(&tr.down4xShader); @@ -2463,7 +2412,6 @@ void GLSL_ShutdownGPUShaders(void) for ( i = 0; i < 2; i++) GLSL_DeleteGPUShader(&tr.calclevels4xShader[i]); - GLSL_DeleteGPUShader(&tr.shadowmaskShader); GLSL_DeleteGPUShader(&tr.ssaoShader); for ( i = 0; i < 2; i++) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index cf52fa91ac..821742c669 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -1680,6 +1680,7 @@ static void R_InitBackEndFrameData() frame->uboWriteOffset = 0; frame->uboSize = FRAME_UNIFORM_BUFFER_SIZE; qglBindBuffer(GL_UNIFORM_BUFFER, frame->ubo); + glState.currentGlobalUBO = frame->ubo; // TODO: persistently mapped UBOs qglBufferData(GL_UNIFORM_BUFFER, FRAME_UNIFORM_BUFFER_SIZE, @@ -1856,6 +1857,11 @@ static void R_InitStaticConstants() qglBufferSubData( GL_UNIFORM_BUFFER, tr.defaultShaderInstanceUboOffset, sizeof(shaderInstanceBlock), &shaderInstanceBlock); alignedBlockSize += (sizeof(ShaderInstanceBlock) + alignment) & ~alignment; + + qglBindBuffer(GL_UNIFORM_BUFFER, NULL); + glState.currentGlobalUBO = -1; + + GL_CheckErrors(); } static void R_ShutdownBackEndFrameData() diff --git a/codemp/rd-rend2/tr_local.h b/codemp/rd-rend2/tr_local.h index e7f31945f1..52e53503c1 100644 --- a/codemp/rd-rend2/tr_local.h +++ b/codemp/rd-rend2/tr_local.h @@ -728,6 +728,10 @@ struct LightsBlock float radius; }; + matrix_t shadowVP1; + matrix_t shadowVP2; + matrix_t shadowVP3; + int numLights; float pad0[3]; @@ -761,7 +765,7 @@ struct EntityBlock vec3_t modelLightDir; float vertexLerp; vec3_t localViewOrigin; - float pad0; // fogIndex; + float entityTime; }; struct ShaderInstanceBlock @@ -772,7 +776,6 @@ struct ShaderInstanceBlock float portalRange; int deformType; int deformFunc; - //float pad1; }; struct SkeletonBoneMatricesBlock @@ -800,6 +803,8 @@ struct surfaceSprite_t vec2_t variance; vec2_t fxGrow; surfaceSpriteOrientation_t facing; + + int spriteUboOffset; }; #define MAX_IMAGE_ANIMATIONS (32) @@ -984,6 +989,9 @@ typedef struct shader_s { int numUnfoggedPasses; int numSurfaceSpriteStages; + GLuint spriteUbo; + int ShaderInstanceUboOffset; + shaderStage_t *stages[MAX_SHADER_STAGES]; void (*optimalStageIteratorFunc)( void ); @@ -991,10 +999,10 @@ typedef struct shader_s { qboolean useSimpleDepthShader; qboolean useDistortion; - float clampTime; // time this shader is clamped to - float timeOffset; // current time offset for this shader + float clampTime; // time this shader is clamped to + float timeOffset; // current time offset for this shader - struct shader_s *remappedShader; // current shader this one is remapped too + struct shader_s *remappedShader; // current shader this one is remapped too struct shader_s *next; } shader_t; @@ -1477,7 +1485,6 @@ typedef struct { int numDrawSurfs; struct drawSurf_s *drawSurfs; - unsigned int dlightMask; int num_pshadows; struct pshadow_s *pshadows; @@ -1510,41 +1517,52 @@ typedef struct { enum viewParmFlag_t { VPF_NOVIEWMODEL = 0x01, // Don't render the view model - VPF_SHADOWMAP = 0x02, // Rendering to shadow map - VPF_DEPTHSHADOW = 0x04, // Rendering depth-only - VPF_DEPTHCLAMP = 0x08, // Perform depth clamping when rendering z pass - VPF_ORTHOGRAPHIC = 0x10, // Use orthographic projection - VPF_USESUNLIGHT = 0x20, - VPF_FARPLANEFRUSTUM = 0x40, // Use far clipping plane - VPF_NOCUBEMAPS = 0x80, // Don't render cubemaps - VPF_NOPOSTPROCESS = 0x100, - VPF_POINTSHADOW = 0x200,// Rendering pointlight shadow - VPF_SHADOWCASCADES = 0x400,// Rendering sun shadow cascades - VPF_NOCLEAR = 0x800, + VPF_DEPTHSHADOW = 0x02, // Rendering depth-only + VPF_DEPTHCLAMP = 0x04, // Perform depth clamping when rendering z pass + VPF_ORTHOGRAPHIC = 0x08, // Use orthographic projection + VPF_USESUNLIGHT = 0x10, + VPF_FARPLANEFRUSTUM = 0x20, // Use far clipping plane + VPF_NOCUBEMAPS = 0x40, // Don't render cubemaps + VPF_POINTSHADOW = 0x80,// Rendering pointlight shadow + VPF_SHADOWCASCADES = 0x100,// Rendering sun shadow cascades + VPF_NOCLEAR = 0x200, }; using viewParmFlags_t = uint32_t; +enum viewParmType_t { + VPT_SKYPORTAL, + VPT_SUN_SHADOWS, + VPT_PLAYER_SHADOWS, + VPT_POINT_SHADOWS, + VPT_PORTAL, + VPT_MAIN, + VPT_ALL +}; + typedef struct { orientationr_t ori; orientationr_t world; - vec3_t pvsOrigin; // may be different than or.origin for portals - qboolean isPortal; // true if this view is through a portal - qboolean isMirror; // the portal is a mirror, invert the face culling - int flags; - int frameSceneNum; // copied from tr.frameSceneNum - int frameCount; // copied from tr.frameCount - cplane_t portalPlane; // clip anything behind this if mirroring - int viewportX, viewportY, viewportWidth, viewportHeight; - int scissorX, scissorY, scissorWidth, scissorHeight; - FBO_t *targetFbo; - int targetFboLayer; - float fovX, fovY; - float projectionMatrix[16]; - cplane_t frustum[5]; - vec3_t visBounds[2]; - float zFar; - float zNear; + vec3_t pvsOrigin; // may be different than or.origin for portals + qboolean isPortal; // true if this view is through a portal + qboolean isMirror; // the portal is a mirror, invert the face culling + qboolean isSkyPortal; + int flags; + int frameSceneNum; // copied from tr.frameSceneNum + int frameCount; // copied from tr.frameCount + cplane_t portalPlane; // clip anything behind this if mirroring + int viewportX, viewportY, viewportWidth, viewportHeight; + int scissorX, scissorY, scissorWidth, scissorHeight; + FBO_t *targetFbo; + int targetFboLayer; + float fovX, fovY; + float projectionMatrix[16]; + cplane_t frustum[5]; + vec3_t visBounds[2]; + float zFar; + float zNear; stereoFrame_t stereoFrame; + int currentViewParm; + viewParmType_t viewParmType; } viewParms_t; @@ -1987,7 +2005,7 @@ typedef struct { int numClusters; int clusterBytes; const byte *vis; // may be passed in by CM_LoadMap to save space - byte *novis; // clusterBytes of 0xff (everything is visible) + byte *novis; // clusterBytes of 0xff (everything is visible) char *entityString; char *entityParsePoint; @@ -2336,7 +2354,6 @@ typedef struct { orientationr_t ori; backEndCounters_t pc; trRefEntity_t *currentEntity; - int currentDrawSurfIndex; qboolean skyRenderedThisView; // flag for drawing sun qboolean projection2D; // if qtrue, drawstretchpic doesn't need to change modes @@ -2349,17 +2366,8 @@ typedef struct { qboolean framePostProcessed; qboolean depthFill; qboolean refractionFill; - qboolean frameUBOsInitialized; } backEndState_t; -struct EntityShaderUboOffset -{ - bool inuse; - int entityNum; - int shaderNum; - int offset; -}; - /* ** trGlobals_t ** @@ -2487,14 +2495,12 @@ typedef struct trGlobals_s { shaderProgram_t textureColorShader; shaderProgram_t fogShader[FOGDEF_COUNT]; shaderProgram_t lightallShader[LIGHTDEF_COUNT]; - shaderProgram_t shadowmapShader; shaderProgram_t pshadowShader; shaderProgram_t volumeShadowShader; shaderProgram_t down4xShader; shaderProgram_t bokehShader; shaderProgram_t tonemapShader[2]; shaderProgram_t calclevels4xShader[2]; - shaderProgram_t shadowmaskShader; shaderProgram_t ssaoShader; shaderProgram_t depthBlurShader[2]; shaderProgram_t testcubeShader; @@ -2508,6 +2514,9 @@ typedef struct trGlobals_s { shaderProgram_t weatherShader; GLuint staticUbo; + GLuint spriteUbos[MAX_SUB_BSP + 1]; + GLuint shaderInstanceUbo; + int shaderInstanceUboWriteOffset; int entity2DUboOffset; int camera2DUboOffset; int entityFlareUboOffset; @@ -2517,22 +2526,23 @@ typedef struct trGlobals_s { int defaultFogsUboOffset; int defaultShaderInstanceUboOffset; - int cameraUboOffset; + int cameraUboOffsets[3 + MAX_DLIGHTS * 6 + 3 + MAX_DRAWN_PSHADOWS]; int sceneUboOffset; int lightsUboOffset; int fogsUboOffset; int skyEntityUboOffset; - int entityUboOffsets[MAX_REFENTITIES + 1]; - int surfaceSpriteUboOffsets[64]; //FIX ME: maybe not fixed size? - EntityShaderUboOffset *surfaceSpriteInstanceUboOffsetsMap; - - int *animationBoneUboOffsets; - EntityShaderUboOffset *shaderInstanceUboOffsetsMap; - int shaderInstanceUboOffsetsMapSize; + int entityUboOffsets[REFENTITYNUM_WORLD + 1]; + int animationBoneUboOffset; // ----------------------------------------- viewParms_t viewParms; + viewParms_t cachedViewParms[3 + MAX_DLIGHTS * 6 + 3 + MAX_DRAWN_PSHADOWS]; + int numCachedViewParms; + + viewParms_t skyPortalParms; + byte skyPortalAreaMask[MAX_MAP_AREA_BYTES]; + int skyPortalEntities; float identityLight; // 1.0 / ( 1 << overbrightBits ) int identityLightByte; // identityLight * 255 @@ -2827,9 +2837,9 @@ void R_SwapBuffers( int ); void R_RenderView( viewParms_t *parms ); void R_RenderDlightCubemaps(const refdef_t *fd); -void R_RenderPshadowMaps(const refdef_t *fd); -void R_RenderSunShadowMaps(const refdef_t *fd, int level); -void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce); +void R_SetupPshadowMaps(const refdef_t *fd); +void R_RenderCubemapSide( int cubemapIndex, int cubemapSide, bool bounce); +void R_GatherFrameViews(trRefdef_t *refdef); void R_AddMD3Surfaces( trRefEntity_t *e, int entityNum ); void R_AddPolygonSurfaces( const trRefdef_t *refdef ); @@ -2899,7 +2909,7 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte * void RE_UploadCinematic (int cols, int rows, const byte *data, int client, qboolean dirty); void RE_SetRangedFog ( float range ); -void RE_BeginFrame( stereoFrame_t stereoFrame ); + void RE_BeginRegistration( glconfig_t *glconfig ); void RE_LoadWorldMap( const char *mapname ); void RE_SetWorldVisData( const byte *vis ); @@ -3082,9 +3092,11 @@ WORLD MAP ============================================================ */ - +world_t *R_GetWorld(int worldIndex); void R_AddBrushModelSurfaces( trRefEntity_t *e, int entityNum ); void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ); +void R_MarkLeaves(void); +void R_RecursiveWorldNode(mnode_t *node, int planeBits, int dlightBits, int pshadowBits); qboolean R_inPVS( const vec3_t p1, const vec3_t p2, byte *mask ); @@ -3206,6 +3218,9 @@ void RB_CommitInternalBufferData(); void RB_BindUniformBlock(GLuint ubo, uniformBlock_t block, int offset); int RB_BindAndUpdateFrameUniformBlock(uniformBlock_t block, void *data); +void RB_AddShaderToShaderInstanceUBO(shader_t *shader); +int RB_AddShaderInstanceBlock(void *data); +void RB_UpdateConstants(const trRefdef_t *refdef); void RB_BeginConstantsUpdate(struct gpuFrame_t *frame); void RB_EndConstantsUpdate(const struct gpuFrame_t *frame); int RB_AppendConstantsData(struct gpuFrame_t *frame, const void *data, size_t dataSize); @@ -3395,7 +3410,7 @@ class CRenderableSurface void R_AddGhoulSurfaces( trRefEntity_t *ent, int entityNum ); void RB_SurfaceGhoul( CRenderableSurface *surf ); -void RB_TransformBones(CRenderableSurface *surf, int currentFrameNum); +void RB_TransformBones(const trRefEntity_t *ent, const trRefdef_t *refdef, int currentFrameNum, gpuFrame_t *frame); int RB_GetBoneUboOffset(CRenderableSurface *surf); void RB_SetBoneUboOffset(CRenderableSurface *surf, int offset, int currentFrameNum); void RB_FillBoneBlock(CRenderableSurface *surf, mat3x4_t *outMatrices); @@ -3680,6 +3695,7 @@ void RE_StretchPic ( float x, float y, float w, float h, float s1, float t1, flo void RE_RotatePic ( float x, float y, float w, float h, float s1, float t1, float s2, float t2, float a, qhandle_t hShader ); void RE_RotatePic2 ( float x, float y, float w, float h, float s1, float t1, float s2, float t2,float a, qhandle_t hShader ); void RE_BeginFrame( stereoFrame_t stereoFrame ); +void R_NewFrameSync(); void RE_EndFrame( int *frontEndMsec, int *backEndMsec ); void RE_TakeVideoFrame( int width, int height, byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg ); @@ -3902,9 +3918,4 @@ uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); void RB_AddDrawItem( Pass *pass, uint32_t sortKey, const DrawItem& drawItem ); DepthRange RB_GetDepthRange( const trRefEntity_t *re, const shader_t *shader ); -int RB_GetEntityShaderUboOffset( - EntityShaderUboOffset *offsetMap, - int mapSize, - int entityNum, - int shaderNum); #endif //TR_LOCAL_H diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index fa6a3a2e88..588a272a3d 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -805,8 +805,6 @@ static void R_RotateForViewer(orientationr_t *ori, viewParms_t *viewParms) // to OpenGL's coordinate system (looking down -Z) myGlMultMatrix(viewerMatrix, s_flipMatrix, ori->modelViewMatrix); Matrix16Identity(ori->modelMatrix); - - viewParms->world = *ori; } /* @@ -819,15 +817,18 @@ static void R_SetFarClip( viewParms_t *viewParms, const trRefdef_t *refdef ) // if not rendering the world (icons, menus, etc) // set a 2k far clip plane - if ( refdef->rdflags & RDF_NOWORLDMODEL ) { - // override the zfar then - if ( refdef->rdflags & RDF_AUTOMAP ) - viewParms->zFar = 32768.0f; - else - viewParms->zFar = 2048.0f; - return; + if (refdef != NULL) + { + if (refdef->rdflags & RDF_NOWORLDMODEL) { + // override the zfar then + if (refdef->rdflags & RDF_AUTOMAP) + viewParms->zFar = 32768.0f; + else + viewParms->zFar = 2048.0f; + return; + } } - + // // set far clipping planes dynamically // @@ -1058,9 +1059,7 @@ void R_SetupProjectionZ(viewParms_t *dest) dest->projectionMatrix[6] = c[1]; dest->projectionMatrix[10] = c[2] + 1.0f; dest->projectionMatrix[14] = c[3]; - } - } /* @@ -1224,7 +1223,7 @@ be moving and rotating. Returns qtrue if it should be mirrored ================= */ -qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, +qboolean R_GetPortalOrientations(const msurface_t *surf, int entityNum, orientation_t *surface, orientation_t *camera, vec3_t pvsOrigin, qboolean *mirror ) { int i; @@ -1234,7 +1233,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, vec3_t transformed; // create plane axis for the portal we are seeing - R_PlaneForSurface( drawSurf->surface, &originalPlane ); + R_PlaneForSurface( surf->data, &originalPlane ); // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) { @@ -1342,7 +1341,7 @@ qboolean R_GetPortalOrientations( drawSurf_t *drawSurf, int entityNum, return qfalse; } -static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) +static qboolean IsMirror( const msurface_t *surface, int entityNum ) { int i; cplane_t originalPlane, plane; @@ -1350,7 +1349,7 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) float d; // create plane axis for the portal we are seeing - R_PlaneForSurface( drawSurf->surface, &originalPlane ); + R_PlaneForSurface( surface->data, &originalPlane ); // rotate the plane if necessary if ( entityNum != REFENTITYNUM_WORLD ) @@ -1402,26 +1401,19 @@ static qboolean IsMirror( const drawSurf_t *drawSurf, int entityNum ) ** ** Determines if a surface is completely offscreen. */ -static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128], int *numVertices ) { +static qboolean SurfIsOffscreen( const msurface_t *surface, int entityNum, vec4_t clipDest[128], int *numVertices ) { float shortest = 100000000; - int entityNum; int numTriangles; - shader_t *shader; - int fogNum; - int cubemap; - int postRender; vec4_t clip, eye; int i; unsigned int pointOr = 0; unsigned int pointAnd = (unsigned int)~0; - R_RotateForViewer(&tr.ori, &tr.viewParms); - - R_DecomposeSort(drawSurf->sort, &entityNum, &shader, &cubemap, &postRender); - fogNum = drawSurf->fogIndex; + // TODO: Check if set properly here already + //R_RotateForViewer(&tr.viewParms.world, &tr.viewParms); - RB_BeginSurface( shader, fogNum, cubemap ); - rb_surfaceTable[ *drawSurf->surface ]( drawSurf->surface ); + RB_BeginSurface(surface->shader, 0, 0 ); + rb_surfaceTable[ *surface->data ](surface->data); if ( tess.numVertexes > 128 ) { @@ -1437,7 +1429,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 int j; unsigned int pointFlags = 0; - R_TransformModelToClip( tess.xyz[i], tr.ori.modelViewMatrix, tr.viewParms.projectionMatrix, eye, clip ); + R_TransformModelToClip( tess.xyz[i], tr.viewParms.world.modelViewMatrix, tr.viewParms.projectionMatrix, eye, clip ); VectorCopy4(clip, clipDest[i]); for ( j = 0; j < 3; j++ ) @@ -1496,7 +1488,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128 // mirrors can early out at this point, since we don't do a fade over distance // with them (although we could) - if ( IsMirror( drawSurf, entityNum ) ) + if ( IsMirror( surface, entityNum) ) { return qfalse; } @@ -1516,12 +1508,12 @@ R_MirrorViewBySurface Returns qtrue if another view has been rendered ======================== */ -qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { +qboolean R_MirrorViewBySurface (msurface_t *surface, int entityNum) { vec4_t clipDest[128]; int numVertices; viewParms_t newParms; viewParms_t oldParms; - orientation_t surface, camera; + orientation_t surfaceOri, camera; // don't recursively mirror if (tr.viewParms.isPortal) { @@ -1534,7 +1526,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { } // trivially reject portal/mirror - if ( SurfIsOffscreen( drawSurf, clipDest, &numVertices ) ) { + if ( SurfIsOffscreen(surface, entityNum, clipDest, &numVertices ) ) { return qfalse; } @@ -1546,7 +1538,7 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms.zFar = 0.0f; newParms.zNear = r_znear->value; newParms.flags &= ~VPF_FARPLANEFRUSTUM; - if ( !R_GetPortalOrientations( drawSurf, entityNum, &surface, &camera, + if ( !R_GetPortalOrientations(surface, entityNum, &surfaceOri, &camera, newParms.pvsOrigin, &newParms.isMirror ) ) { return qfalse; // bad portal, no portalentity } @@ -1615,23 +1607,39 @@ qboolean R_MirrorViewBySurface (drawSurf_t *drawSurf, int entityNum) { newParms.scissorWidth = maxRectX - minRectX; newParms.scissorHeight = maxRectY - minRectY;*/ - R_MirrorPoint (oldParms.ori.origin, &surface, &camera, newParms.ori.origin ); + R_MirrorPoint (oldParms.ori.origin, &surfaceOri, &camera, newParms.ori.origin ); VectorSubtract( vec3_origin, camera.axis[0], newParms.portalPlane.normal ); newParms.portalPlane.dist = DotProduct( camera.origin, newParms.portalPlane.normal ); - R_MirrorVector (oldParms.ori.axis[0], &surface, &camera, newParms.ori.axis[0]); - R_MirrorVector (oldParms.ori.axis[1], &surface, &camera, newParms.ori.axis[1]); - R_MirrorVector (oldParms.ori.axis[2], &surface, &camera, newParms.ori.axis[2]); + R_MirrorVector (oldParms.ori.axis[0], &surfaceOri, &camera, newParms.ori.axis[0]); + R_MirrorVector (oldParms.ori.axis[1], &surfaceOri, &camera, newParms.ori.axis[1]); + R_MirrorVector (oldParms.ori.axis[2], &surfaceOri, &camera, newParms.ori.axis[2]); // OPTIMIZE further: restrict the viewport and set up the view and projection // matrices so they only draw into the tightest screen-space aligned box required // to fill the restricted viewport. - // render the mirror view - R_RenderView (&newParms); + tr.viewCount++; + tr.viewParms = newParms; + R_RotateForViewer(&tr.viewParms.world, &tr.viewParms); + R_SetupProjection(&tr.viewParms, tr.viewParms.zNear, tr.viewParms.zFar, qtrue); - tr.viewParms = oldParms; + R_MarkLeaves(); + + // clear out the visible min/max + ClearBounds(tr.viewParms.visBounds[0], tr.viewParms.visBounds[1]); + int planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + // set vis bounds + R_RecursiveWorldNode(tr.world->nodes, planeBits, 0, 0); + R_SetFarClip(&tr.viewParms, nullptr); + R_SetupProjectionZ(&tr.viewParms); + + // render the mirror view + tr.viewParms.currentViewParm = tr.numCachedViewParms; + tr.viewParms.viewParmType = VPT_PORTAL; + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; return qtrue; } @@ -1789,7 +1797,7 @@ void R_AddDrawSurf( return; } - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) && + if (tr.viewParms.flags & VPF_DEPTHSHADOW && (postRender == qtrue || shader->sort != SS_OPAQUE)) { return; @@ -1801,7 +1809,7 @@ void R_AddDrawSurf( surf = tr.refdef.drawSurfs + index; surf->surface = surface; - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW) && + if (tr.viewParms.flags & VPF_DEPTHSHADOW && shader->useSimpleDepthShader == qtrue) { surf->sort = R_CreateSortKey(entityNum, tr.defaultShader->sortedIndex, 0, 0); @@ -1825,52 +1833,16 @@ R_SortAndSubmitDrawSurfs */ void R_SortAndSubmitDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { // it is possible for some views to not have any surfaces - if ( numDrawSurfs >= 1 ) - { - // if we overflowed MAX_DRAWSURFS, the drawsurfs - // wrapped around in the buffer and we will be missing - // the first surfaces, not the last ones - if ( numDrawSurfs > MAX_DRAWSURFS ) { - numDrawSurfs = MAX_DRAWSURFS; - } - - R_RadixSort( drawSurfs, numDrawSurfs ); - - // skip pass through drawing if rendering a shadow map - if (!(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW))) - { - // FIXME: Don't do this at submit time. Determine what surfaces are mirrors - // at RE_RenderScene or earlier. - - // check for any pass through drawing, which - // may cause another view to be rendered first - for ( int i = 0 ; i < numDrawSurfs ; i++ ) { - int entityNum; - shader_t *shader; - int postRender; - int cubemap; - - R_DecomposeSort( (drawSurfs+i)->sort, &entityNum, &shader, &cubemap, &postRender ); - if ( shader->sort > SS_PORTAL ) { - break; - } + if (numDrawSurfs < 1) + return; - // no shader should ever have this sort type - if ( shader->sort == SS_BAD ) { - ri.Error (ERR_DROP, "Shader '%s'with sort == SS_BAD", shader->name ); - } + // if we overflowed MAX_DRAWSURFS, the drawsurfs + // wrapped around in the buffer and we will be missing + // the first surfaces, not the last ones + if ( numDrawSurfs > MAX_DRAWSURFS ) + numDrawSurfs = MAX_DRAWSURFS; - // if the mirror was completely clipped away, we may need to check another surface - if ( R_MirrorViewBySurface( (drawSurfs+i), entityNum) ) { - // this is a debug option to see exactly what is being mirrored - if ( r_portalOnly->integer ) { - return; - } - break; // only one mirror view at a time - } - } - } - } + R_RadixSort( drawSurfs, numDrawSurfs ); R_AddDrawSurfCmd( drawSurfs, numDrawSurfs ); } @@ -2008,7 +1980,23 @@ static void R_AddEntitySurfaces(const trRefdef_t *refdef) return; } - for (int i = 0; i < refdef->num_entities; i++) + int entityStart = 0; + int numEntities = refdef->num_entities; + if (tr.world && tr.world->skyboxportal) + { + if (tr.viewParms.isSkyPortal) + { + // Stop after skyportal entities + numEntities = tr.skyPortalEntities; + } + else + { + // Skip skyportal entities + entityStart = tr.skyPortalEntities; + } + } + + for (int i = entityStart; i < numEntities; i++) { trRefEntity_t *ent = refdef->entities + i; R_AddEntitySurface(refdef, ent, i); @@ -2022,31 +2010,23 @@ R_GenerateDrawSurfs ==================== */ void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { - R_AddWorldSurfaces(viewParms, refdef); - R_AddPolygonSurfaces(refdef); - - if ((viewParms->flags & VPF_ORTHOGRAPHIC) == 0) + // TODO: Get rid of this + if (viewParms->viewParmType == VPT_PLAYER_SHADOWS) { - // set the projection matrix with the minimum zfar - // now that we have the world bounded - // this needs to be done before entities are - // added, because they use the projection - // matrix for lod calculation - - // dynamically compute far clip plane distance - if (!(tr.viewParms.flags & VPF_SHADOWMAP)) - { - R_SetFarClip(viewParms, refdef); - } - - // we know the size of the clipping volume. Now set the rest of the projection matrix. - R_SetupProjectionZ(viewParms); + int entityNum = viewParms->targetFboLayer; + trRefEntity_t *ent = refdef->entities + entityNum; + R_AddEntitySurface(refdef, ent, entityNum); + return; } + R_AddWorldSurfaces(viewParms, refdef); + R_AddEntitySurfaces(refdef); - if ( !(tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) && tr.world) + R_AddPolygonSurfaces(refdef); + + if ( !(tr.viewParms.flags & VPF_DEPTHSHADOW) && tr.world) { R_AddWeatherSurfaces(); } @@ -2127,10 +2107,6 @@ void R_RenderView (viewParms_t *parms) { tr.viewParms.frameCount = tr.frameCount; tr.refdef.fistDrawSurf = tr.refdef.numDrawSurfs; - // set viewParms.world - R_RotateForViewer(&tr.ori, &tr.viewParms); - - R_SetupProjection(&tr.viewParms, tr.viewParms.zNear, tr.viewParms.zFar, qtrue); R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); @@ -2145,17 +2121,11 @@ void R_RenderDlightCubemaps(const refdef_t *fd) { int i; - unsigned int bufferDlightMask = tr.refdef.dlightMask; - for (i = 0; i < tr.refdef.num_dlights; i++) { viewParms_t shadowParms; int j; - // use previous frame to determine visible dlights - /*if ((1 << i) & bufferDlightMask) - continue;*/ - Com_Memset( &shadowParms, 0, sizeof( shadowParms ) ); shadowParms.viewportX = 0; @@ -2168,7 +2138,7 @@ void R_RenderDlightCubemaps(const refdef_t *fd) shadowParms.fovX = 90; shadowParms.fovY = 90; - shadowParms.flags = VPF_SHADOWMAP | VPF_DEPTHSHADOW | VPF_NOVIEWMODEL | VPF_POINTSHADOW; + shadowParms.flags = VPF_DEPTHSHADOW | VPF_NOVIEWMODEL | VPF_POINTSHADOW; shadowParms.zFar = tr.refdef.dlights[i].radius; shadowParms.zNear = 1.0f; @@ -2276,19 +2246,19 @@ void R_SetupViewParmsForOrthoRendering( viewParms.frameSceneNum = tr.frameSceneNum; viewParms.frameCount = tr.frameCount; - R_RotateForViewer(&tr.ori, &viewParms); + R_RotateForViewer(&viewParms.world, &viewParms); R_SetupProjectionOrtho(&viewParms, viewBounds); } -void R_RenderPshadowMaps(const refdef_t *fd) +void R_SetupPshadowMaps(trRefdef_t *refdef) { viewParms_t shadowParms; int i; // first, make a list of shadows - for ( i = 0; i < tr.refdef.num_entities; i++) + for ( i = 0; i < refdef->num_entities; i++) { - trRefEntity_t *ent = &tr.refdef.entities[i]; + trRefEntity_t *ent = &refdef->entities[i]; if((ent->e.renderfx & (RF_FIRST_PERSON | RF_NOSHADOW))) continue; @@ -2341,8 +2311,8 @@ void R_RenderPshadowMaps(const refdef_t *fd) continue; // Cull entities that are behind the viewer by more than lightRadius - VectorSubtract(ent->e.lightingOrigin, fd->vieworg, diff); - if (DotProduct(diff, fd->viewaxis[0]) < -r_pshadowDist->value) + VectorSubtract(ent->e.lightingOrigin, refdef->vieworg, diff); + if (DotProduct(diff, refdef->viewaxis[0]) < -r_pshadowDist->value) continue; memset(&shadow, 0, sizeof(shadow)); @@ -2360,35 +2330,35 @@ void R_RenderPshadowMaps(const refdef_t *fd) { pshadow_t swap; - if (j + 1 > tr.refdef.num_pshadows) + if (j + 1 > refdef->num_pshadows) { - tr.refdef.num_pshadows = j + 1; - tr.refdef.pshadows[j] = shadow; + refdef->num_pshadows = j + 1; + refdef->pshadows[j] = shadow; break; } // sort shadows by distance from camera divided by radius // FIXME: sort better - if (tr.refdef.pshadows[j].sort <= shadow.sort) + if (refdef->pshadows[j].sort <= shadow.sort) continue; - swap = tr.refdef.pshadows[j]; - tr.refdef.pshadows[j] = shadow; + swap = refdef->pshadows[j]; + refdef->pshadows[j] = shadow; shadow = swap; } } } // cap number of drawn pshadows - if (tr.refdef.num_pshadows > MAX_DRAWN_PSHADOWS) + if (refdef->num_pshadows > MAX_DRAWN_PSHADOWS) { - tr.refdef.num_pshadows = MAX_DRAWN_PSHADOWS; + refdef->num_pshadows = MAX_DRAWN_PSHADOWS; } // next, fill up the rest of the shadow info - for ( i = 0; i < tr.refdef.num_pshadows; i++) + for ( i = 0; i < refdef->num_pshadows; i++) { - pshadow_t *shadow = &tr.refdef.pshadows[i]; + pshadow_t *shadow = &refdef->pshadows[i]; vec3_t up; vec3_t ambientLight, directedLight, lightDir; @@ -2430,318 +2400,9 @@ void R_RenderPshadowMaps(const refdef_t *fd) shadow->cullPlane.type = PLANE_NON_AXIAL; SetPlaneSignbits(&shadow->cullPlane); } - - // next, render shadowmaps - for ( i = 0; i < tr.refdef.num_pshadows; i++) - { - pshadow_t *shadow = &tr.refdef.pshadows[i]; - int j; - - Com_Memset(&shadowParms, 0, sizeof(shadowParms)); - - shadowParms.viewportX = 0; - shadowParms.viewportY = 0; - shadowParms.viewportWidth = PSHADOW_MAP_SIZE; - shadowParms.viewportHeight = PSHADOW_MAP_SIZE; - shadowParms.isPortal = qfalse; - shadowParms.isMirror = qfalse; - - shadowParms.fovX = 90; - shadowParms.fovY = 90; - - shadowParms.targetFbo = tr.pshadowFbos[i]; - - shadowParms.flags = (viewParmFlags_t)(VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); - shadowParms.zFar = shadow->lightRadius; - - VectorCopy(shadow->lightOrigin, shadowParms.ori.origin); - - VectorCopy(shadow->lightViewAxis[0], shadowParms.ori.axis[0]); - VectorCopy(shadow->lightViewAxis[1], shadowParms.ori.axis[1]); - VectorCopy(shadow->lightViewAxis[2], shadowParms.ori.axis[2]); - - { - tr.viewCount++; - - tr.viewParms = shadowParms; - tr.viewParms.frameSceneNum = tr.frameSceneNum; - tr.viewParms.frameCount = tr.frameCount; - - // set viewParms.world - R_RotateForViewer(&tr.ori, &tr.viewParms); - - { - float xmin, xmax, ymin, ymax, znear, zfar; - viewParms_t *dest = &tr.viewParms; - vec3_t pop; - - xmin = ymin = -shadow->viewRadius; - xmax = ymax = shadow->viewRadius; - znear = 0; - zfar = shadow->lightRadius; - - dest->projectionMatrix[0] = 2 / (xmax - xmin); - dest->projectionMatrix[4] = 0; - dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); - dest->projectionMatrix[12] = 0; - - dest->projectionMatrix[1] = 0; - dest->projectionMatrix[5] = 2 / (ymax - ymin); - dest->projectionMatrix[9] = (ymax + ymin) / (ymax - ymin); // normally 0 - dest->projectionMatrix[13] = 0; - - dest->projectionMatrix[2] = 0; - dest->projectionMatrix[6] = 0; - dest->projectionMatrix[10] = 2 / (zfar - znear); - dest->projectionMatrix[14] = 0; - - dest->projectionMatrix[3] = 0; - dest->projectionMatrix[7] = 0; - dest->projectionMatrix[11] = 0; - dest->projectionMatrix[15] = 1; - - VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); - dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); - - VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); - dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); - - VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); - dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); - - VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); - VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); - dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); - - VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); - VectorMA(dest->ori.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); - dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); - - for (j = 0; j < 5; j++) - { - dest->frustum[j].type = PLANE_NON_AXIAL; - SetPlaneSignbits(&dest->frustum[j]); - } - - dest->flags |= VPF_FARPLANEFRUSTUM; - } - - const int firstDrawSurf = tr.refdef.numDrawSurfs; - for (int j = 0; j < shadow->numEntities; j++) - { - int entityNum = shadow->entityNums[j]; - trRefEntity_t *ent = tr.refdef.entities + entityNum; - R_AddEntitySurface(&tr.refdef, ent, entityNum); - } - - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); - } - } -} - -static float CalcSplit(float n, float f, float i, float m) -{ - return (n * pow(f / n, i / m) + (f - n) * i / m) / 2.0f; -} - - -void R_RenderSunShadowMaps(const refdef_t *fd, int level) -{ - vec3_t lightViewAxis[3]; - vec3_t lightOrigin; - float splitZNear, splitZFar, splitBias; - float viewZNear, viewZFar; - vec3_t lightviewBounds[2]; - qboolean lightViewIndependentOfCameraView = qtrue; - - viewZNear = r_shadowCascadeZNear->value; - viewZFar = r_shadowCascadeZFar->value; - splitBias = r_shadowCascadeZBias->value; - - switch(level) - { - case 0: - default: - //splitZNear = r_znear->value; - //splitZFar = 256; - splitZNear = viewZNear; - splitZFar = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; - break; - case 1: - splitZNear = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; - splitZFar = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; - //splitZNear = 256; - //splitZFar = 896; - break; - case 2: - splitZNear = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; - splitZFar = viewZFar; - //splitZNear = 896; - //splitZFar = 3072; - break; - } - - VectorCopy(fd->vieworg, lightOrigin); - - // Make up a projection - VectorScale(tr.refdef.sunDir, -1.0f, lightViewAxis[0]); - - if (lightViewIndependentOfCameraView) - { - // Use world up as light view up - VectorSet(lightViewAxis[2], 0, 0, 1); - } - else if (level == 0) - { - // Level 0 tries to use a diamond texture orientation relative to camera view - // Use halfway between camera view forward and left for light view up - VectorAdd(fd->viewaxis[0], fd->viewaxis[1], lightViewAxis[2]); - } - else - { - // Use camera view up as light view up - VectorCopy(fd->viewaxis[2], lightViewAxis[2]); - } - - // Check if too close to parallel to light direction - if (fabs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) - { - if (lightViewIndependentOfCameraView) - { - // Use world left as light view up - VectorSet(lightViewAxis[2], 0, 1, 0); - } - else if (level == 0) - { - // Level 0 tries to use a diamond texture orientation relative to camera view - // Use halfway between camera view forward and up for light view up - VectorAdd(fd->viewaxis[0], fd->viewaxis[2], lightViewAxis[2]); - } - else - { - // Use camera view left as light view up - VectorCopy(fd->viewaxis[1], lightViewAxis[2]); - } - } - - // clean axes - CrossProduct(lightViewAxis[2], lightViewAxis[0], lightViewAxis[1]); - VectorNormalize(lightViewAxis[1]); - CrossProduct(lightViewAxis[0], lightViewAxis[1], lightViewAxis[2]); - - // Create bounds for light projection using slice of view projection - { - ClearBounds(lightviewBounds[0], lightviewBounds[1]); - - vec3_t point, base; - float lx, ly, radius; - vec3_t splitCenter, frustrumPoint0, frustrumPoint7; - - // add view near plane - lx = splitZNear * tan(fd->fov_x * M_PI / 360.0f); - ly = splitZNear * tan(fd->fov_y * M_PI / 360.0f); - VectorMA(fd->vieworg, splitZNear, fd->viewaxis[0], base); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - VectorCopy(point, frustrumPoint0); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - // add view far plane - lx = splitZFar * tan(fd->fov_x * M_PI / 360.0f); - ly = splitZFar * tan(fd->fov_y * M_PI / 360.0f); - VectorMA(fd->vieworg, splitZFar, fd->viewaxis[0], base); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - VectorMA(base, lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - - VectorMA(base, -lx, fd->viewaxis[1], point); - VectorMA(point, -ly, fd->viewaxis[2], point); - VectorAdd(point, splitCenter, splitCenter); - VectorCopy(point, frustrumPoint7); - - VectorScale(splitCenter, 1.0f / 8.0f, splitCenter); - radius = Distance(frustrumPoint0, frustrumPoint7) / 2.0f; - lightviewBounds[0][0] = -radius; - lightviewBounds[0][1] = -radius; - lightviewBounds[0][2] = -radius; - lightviewBounds[1][0] = radius; - lightviewBounds[1][1] = radius; - lightviewBounds[1][2] = radius; - - VectorCopy(splitCenter, lightOrigin); - } - - orientationr_t orientation = {}; - R_SetOrientationOriginAndAxis(orientation, lightOrigin, lightViewAxis); - - R_SetupViewParmsForOrthoRendering( - tr.sunShadowFbo[level]->width, - tr.sunShadowFbo[level]->height, - tr.sunShadowFbo[level], - VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL | VPF_SHADOWCASCADES, - orientation, - lightviewBounds); - - // Moving the Light in Texel-Sized Increments - // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx - float worldUnitsPerTexel, invWorldUnitsPerTexel; - worldUnitsPerTexel = 2.0f * lightviewBounds[1][0] / (float)tr.sunShadowFbo[level]->width; - invWorldUnitsPerTexel = tr.sunShadowFbo[level]->width / (2.0f * lightviewBounds[1][0]); - vec3_t new_view_origin; - new_view_origin[0] = tr.viewParms.world.modelViewMatrix[12]; - new_view_origin[1] = tr.viewParms.world.modelViewMatrix[13]; - new_view_origin[2] = tr.viewParms.world.modelViewMatrix[14]; - - VectorScale(new_view_origin, invWorldUnitsPerTexel, new_view_origin); - new_view_origin[0] = floor(new_view_origin[0]); - new_view_origin[1] = floor(new_view_origin[1]); - new_view_origin[2] = floor(new_view_origin[2]); - VectorScale(new_view_origin, worldUnitsPerTexel, new_view_origin); - - tr.viewParms.world.modelViewMatrix[12] = new_view_origin[0]; - tr.viewParms.world.modelViewMatrix[13] = new_view_origin[1]; - tr.viewParms.world.modelViewMatrix[14] = new_view_origin[2]; - - const int firstDrawSurf = tr.refdef.numDrawSurfs; - R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); - - Matrix16Multiply( - tr.viewParms.projectionMatrix, - tr.viewParms.world.modelViewMatrix, - tr.refdef.sunShadowMvp[level]); } -void R_RenderCubemapSide(int cubemapIndex, int cubemapSide, qboolean subscene, bool bounce) +void R_RenderCubemapSide(int cubemapIndex, int cubemapSide, bool bounce) { refdef_t refdef = {}; float oldColorScale = tr.refdef.colorScale; @@ -2794,55 +2455,583 @@ void R_RenderCubemapSide(int cubemapIndex, int cubemapSide, qboolean subscene, b break; } - if (!subscene) + RE_BeginFrame(STEREO_CENTER); + + RE_BeginScene(&refdef); + + tr.refdef.colorScale = 1.0f; + + for (int i = 0; i < tr.numCachedViewParms; i++) { - RE_BeginScene(&refdef); + if (!tr.cachedViewParms[i].targetFbo) + { + tr.cachedViewParms[i].targetFbo = tr.renderCubeFbo[cubemapSide]; + tr.cachedViewParms[i].targetFboLayer = 0; + tr.cachedViewParms[i].flags |= VPF_NOVIEWMODEL; + if (!bounce) + tr.cachedViewParms[i].flags |= VPF_NOCUBEMAPS; + } + R_RenderView(&tr.cachedViewParms[i]); + R_IssuePendingRenderCommands(); + tr.refdef.numDrawSurfs = 0; } - if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer > 0 || tr.sunShadows)) + RE_EndScene(); + + R_NewFrameSync(); +} + +void R_SetupViewParms(const trRefdef_t *refdef) +{ + tr.viewCount++; + Com_Memset(&tr.viewParms, 0, sizeof(viewParms_t)); + tr.viewParms.viewportX = refdef->x; + + // Shoud be just refef->y but this flips the menu orientation for models, so its actually needed like this + if (!tr.world) + tr.viewParms.viewportY = glConfig.vidHeight - (refdef->y + refdef->height); + else + tr.viewParms.viewportY = refdef->y; + + tr.viewParms.viewportWidth = refdef->width; + tr.viewParms.viewportHeight = refdef->height; + tr.viewParms.zNear = r_znear->value; + + tr.viewParms.fovX = refdef->fov_x; + tr.viewParms.fovY = refdef->fov_y; + + VectorCopy(refdef->vieworg, tr.viewParms.ori.origin); + VectorCopy(refdef->viewaxis[0], tr.viewParms.ori.axis[0]); + VectorCopy(refdef->viewaxis[1], tr.viewParms.ori.axis[1]); + VectorCopy(refdef->viewaxis[2], tr.viewParms.ori.axis[2]); + + VectorCopy(refdef->vieworg, tr.viewParms.pvsOrigin); + + R_RotateForViewer(&tr.viewParms.world, &tr.viewParms); + R_SetupProjection(&tr.viewParms, tr.viewParms.zNear, tr.viewParms.zFar, qtrue); + + if (tr.world) { - R_RenderSunShadowMaps(&refdef, 0); - R_RenderSunShadowMaps(&refdef, 1); - R_RenderSunShadowMaps(&refdef, 2); + R_MarkLeaves(); + + // clear out the visible min/max + ClearBounds(tr.viewParms.visBounds[0], tr.viewParms.visBounds[1]); + int planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + // set vis bounds + R_RecursiveWorldNode(tr.world->nodes, planeBits, 0, 0); } - tr.refdef.colorScale = 1.0f; + R_SetFarClip(&tr.viewParms, refdef); + R_SetupProjectionZ(&tr.viewParms); +} + +qboolean R_AddPortalView(const trRefdef_t *refdef) +{ + if (!tr.world) + return qfalse; - viewParms_t parms = {}; - parms.viewportWidth = tr.renderCubeFbo[cubemapSide]->width; - parms.viewportHeight = tr.renderCubeFbo[cubemapSide]->height; - parms.isMirror = qfalse; - parms.flags = VPF_NOVIEWMODEL | VPF_NOPOSTPROCESS; - if (!bounce) - parms.flags |= VPF_NOCUBEMAPS; + for (int i = 0; i < tr.world->numWorldSurfaces; i++) + { + if (tr.world->surfacesViewCount[i] != tr.viewCount) + continue; - parms.zNear = r_znear->value; - parms.fovX = 90; - parms.fovY = 90; + msurface_t *surface = tr.world->surfaces + i; + if (surface->shader->sort != SS_PORTAL) { + continue; + } - VectorCopy(refdef.vieworg, parms.ori.origin); - VectorCopy(refdef.viewaxis[0], parms.ori.axis[0]); - VectorCopy(refdef.viewaxis[1], parms.ori.axis[1]); - VectorCopy(refdef.viewaxis[2], parms.ori.axis[2]); + // if the mirror was completely clipped away, we may need to check another surface + if (R_MirrorViewBySurface(surface, REFENTITYNUM_WORLD)) { + return qtrue; // only one mirror view at a time + } + } - VectorCopy(refdef.vieworg, parms.pvsOrigin); + for (int i = 0; i < tr.world->numMergedSurfaces; i++) + { + if (tr.world->mergedSurfacesViewCount[i] != tr.viewCount) + continue; - if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer > 0 || tr.sunShadows)) + msurface_t *surface = tr.world->mergedSurfaces + i; + if (surface->shader->sort != SS_PORTAL) { + continue; + } + + // if the mirror was completely clipped away, we may need to check another surface + if (R_MirrorViewBySurface(surface, REFENTITYNUM_WORLD)) { + return qtrue; // only one mirror view at a time + } + } + + for (int i = 0; i < refdef->num_entities; i++) { - parms.flags |= VPF_USESUNLIGHT; + trRefEntity_t *ent = &refdef->entities[i]; + switch (ent->e.reType) { + case RT_PORTALSURFACE: + break; // don't draw anything + case RT_SPRITE: + case RT_BEAM: + case RT_ORIENTED_QUAD: + case RT_ELECTRICITY: + case RT_LINE: + case RT_ORIENTEDLINE: + case RT_CYLINDER: + case RT_SABER_GLOW: + break; + + case RT_MODEL: + + // we must set up parts of tr.ori for model culling + R_RotateForEntity(ent, &tr.viewParms, &tr.ori); + + tr.currentModel = R_GetModelByHandle(ent->e.hModel); + if (!tr.currentModel) { + continue; + } + else { + switch (tr.currentModel->type) { + case MOD_BRUSH: + { + //R_AddBrushModelSurfaces(ent, i); + bmodel_t *bmodel = tr.currentModel->data.bmodel; + world_t *world = R_GetWorld(bmodel->worldIndex); + for (int j = 0; j < bmodel->numSurfaces; j++) { + int surf = bmodel->firstSurface + j; + + // TODO: use pvs of misc_bsp models + msurface_t *surface = world->surfaces + surf; + if (surface->shader->sort != SS_PORTAL) { + continue; + } + + // if the mirror was completely clipped away, we may need to check another surface + if (R_MirrorViewBySurface(surface, i)) { + return qtrue; // only one mirror view at a time + } + } + } + break; + case MOD_MESH: + case MOD_MDR: + case MOD_IQM: + case MOD_MDXM: + case MOD_BAD: + default: + break; + } + } + break; + case RT_ENT_CHAIN: + break; + default: + break; + } } - parms.targetFbo = tr.renderCubeFbo[cubemapSide]; - parms.targetFboLayer = cubemapSide; + return qfalse; +} - R_RenderView(&parms); +static float CalcSplit(float n, float f, float i, float m) +{ + return (n * pow(f / n, i / m) + (f - n) * i / m) / 2.0f; +} - if (subscene) +void R_GatherFrameViews(trRefdef_t *refdef) +{ + int mainFlags = 0; + // skyportal view + if (tr.world && tr.world->skyboxportal) { - tr.refdef.colorScale = oldColorScale; + tr.viewCount++; + tr.viewParms = tr.skyPortalParms; + R_RotateForViewer(&tr.viewParms.world, &tr.viewParms); + R_SetupProjection(&tr.viewParms, tr.viewParms.zNear, tr.viewParms.zFar, qtrue); + + VectorCopy(tr.skyPortalParms.pvsOrigin, tr.viewParms.pvsOrigin); + R_MarkLeaves(); + + // clear out the visible min/max + ClearBounds(tr.viewParms.visBounds[0], tr.viewParms.visBounds[1]); + int planeBits = (tr.viewParms.flags & VPF_FARPLANEFRUSTUM) ? 31 : 15; + // set vis bounds + R_RecursiveWorldNode(tr.world->nodes, planeBits, 0, 0); + R_SetFarClip(&tr.viewParms, refdef); + R_SetupProjectionZ(&tr.viewParms); + + tr.viewParms.currentViewParm = tr.numCachedViewParms; + tr.viewParms.viewParmType = VPT_SKYPORTAL; + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; } - else + + VectorCopy(refdef->vieworg, tr.viewParms.pvsOrigin); + if (tr.world) + R_MarkLeaves(); + + if (!(refdef->rdflags & RDF_NOWORLDMODEL)) + { + // dlight shadowmaps + if (refdef->num_dlights && r_dlightMode->integer >= 2) + { + for (int i = 0; i < refdef->num_dlights; i++) + { + viewParms_t shadowParms; + int j; + + Com_Memset(&shadowParms, 0, sizeof(shadowParms)); + + shadowParms.viewportX = 0; + shadowParms.viewportY = 0; + shadowParms.viewportWidth = DSHADOW_MAP_SIZE; + shadowParms.viewportHeight = DSHADOW_MAP_SIZE; + shadowParms.isPortal = qfalse; + shadowParms.isMirror = qfalse; + + shadowParms.fovX = 90; + shadowParms.fovY = 90; + + shadowParms.flags = VPF_DEPTHSHADOW | VPF_NOVIEWMODEL | VPF_POINTSHADOW; + shadowParms.zFar = refdef->dlights[i].radius; + shadowParms.zNear = 1.0f; + + VectorCopy(refdef->dlights[i].origin, shadowParms.ori.origin); + + for (j = 0; j < 6; j++) + { + switch (j) + { + case 0: + // -X + VectorSet(shadowParms.ori.axis[0], -1, 0, 0); + VectorSet(shadowParms.ori.axis[1], 0, 0, -1); + VectorSet(shadowParms.ori.axis[2], 0, 1, 0); + break; + case 1: + // +X + VectorSet(shadowParms.ori.axis[0], 1, 0, 0); + VectorSet(shadowParms.ori.axis[1], 0, 0, 1); + VectorSet(shadowParms.ori.axis[2], 0, 1, 0); + break; + case 2: + // -Y + VectorSet(shadowParms.ori.axis[0], 0, -1, 0); + VectorSet(shadowParms.ori.axis[1], 1, 0, 0); + VectorSet(shadowParms.ori.axis[2], 0, 0, -1); + break; + case 3: + // +Y + VectorSet(shadowParms.ori.axis[0], 0, 1, 0); + VectorSet(shadowParms.ori.axis[1], 1, 0, 0); + VectorSet(shadowParms.ori.axis[2], 0, 0, 1); + break; + case 4: + // -Z + VectorSet(shadowParms.ori.axis[0], 0, 0, -1); + VectorSet(shadowParms.ori.axis[1], 1, 0, 0); + VectorSet(shadowParms.ori.axis[2], 0, 1, 0); + break; + case 5: + // +Z + VectorSet(shadowParms.ori.axis[0], 0, 0, 1); + VectorSet(shadowParms.ori.axis[1], -1, 0, 0); + VectorSet(shadowParms.ori.axis[2], 0, 1, 0); + break; + } + + shadowParms.targetFbo = tr.shadowCubeFbo[i * 6 + j]; + shadowParms.targetFboLayer = 0; + + shadowParms.currentViewParm = tr.numCachedViewParms; + shadowParms.viewParmType = VPT_POINT_SHADOWS; + + R_RotateForViewer(&shadowParms.world, &shadowParms); + R_SetupProjection(&shadowParms, shadowParms.zNear, shadowParms.zFar, qtrue); + R_SetupProjectionZ(&shadowParms); + + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &shadowParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; + } + } + } + + // pshadow shadowmaps + if (r_shadows->integer == 4) + { + R_SetupPshadowMaps(refdef); + + for (int i = 0; i < tr.refdef.num_pshadows; i++) + { + pshadow_t *shadow = &tr.refdef.pshadows[i]; + + tr.viewParms.viewportX = 0; + tr.viewParms.viewportY = 0; + tr.viewParms.viewportWidth = PSHADOW_MAP_SIZE; + tr.viewParms.viewportHeight = PSHADOW_MAP_SIZE; + tr.viewParms.isPortal = qfalse; + tr.viewParms.isMirror = qfalse; + + tr.viewParms.fovX = 90; + tr.viewParms.fovY = 90; + + tr.viewParms.targetFbo = tr.pshadowFbos[i]; + tr.viewParms.targetFboLayer = shadow->entityNums[0]; + + tr.viewParms.flags = (viewParmFlags_t)(VPF_DEPTHSHADOW | VPF_NOVIEWMODEL); + tr.viewParms.viewParmType = VPT_PLAYER_SHADOWS; + tr.viewParms.zFar = shadow->lightRadius; + + VectorCopy(shadow->lightOrigin, tr.viewParms.ori.origin); + + VectorCopy(shadow->lightViewAxis[0], tr.viewParms.ori.axis[0]); + VectorCopy(shadow->lightViewAxis[1], tr.viewParms.ori.axis[1]); + VectorCopy(shadow->lightViewAxis[2], tr.viewParms.ori.axis[2]); + + { + tr.viewCount++; + tr.viewParms.frameSceneNum = tr.frameSceneNum; + tr.viewParms.frameCount = tr.frameCount; + + // set viewParms.world + R_RotateForViewer(&tr.viewParms.world, &tr.viewParms); + + { + float xmin, xmax, ymin, ymax, znear, zfar; + viewParms_t *dest = &tr.viewParms; + vec3_t pop; + + xmin = ymin = -shadow->viewRadius; + xmax = ymax = shadow->viewRadius; + znear = 0; + zfar = shadow->lightRadius; + + dest->projectionMatrix[0] = 2 / (xmax - xmin); + dest->projectionMatrix[4] = 0; + dest->projectionMatrix[8] = (xmax + xmin) / (xmax - xmin); + dest->projectionMatrix[12] = 0; + + dest->projectionMatrix[1] = 0; + dest->projectionMatrix[5] = 2 / (ymax - ymin); + dest->projectionMatrix[9] = (ymax + ymin) / (ymax - ymin); // normally 0 + dest->projectionMatrix[13] = 0; + + dest->projectionMatrix[2] = 0; + dest->projectionMatrix[6] = 0; + dest->projectionMatrix[10] = 2 / (zfar - znear); + dest->projectionMatrix[14] = 0; + + dest->projectionMatrix[3] = 0; + dest->projectionMatrix[7] = 0; + dest->projectionMatrix[11] = 0; + dest->projectionMatrix[15] = 1; + + VectorScale(dest->ori.axis[1], 1.0f, dest->frustum[0].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[0].normal, pop); + dest->frustum[0].dist = DotProduct(pop, dest->frustum[0].normal); + + VectorScale(dest->ori.axis[1], -1.0f, dest->frustum[1].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[1].normal, pop); + dest->frustum[1].dist = DotProduct(pop, dest->frustum[1].normal); + + VectorScale(dest->ori.axis[2], 1.0f, dest->frustum[2].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[2].normal, pop); + dest->frustum[2].dist = DotProduct(pop, dest->frustum[2].normal); + + VectorScale(dest->ori.axis[2], -1.0f, dest->frustum[3].normal); + VectorMA(dest->ori.origin, -shadow->viewRadius, dest->frustum[3].normal, pop); + dest->frustum[3].dist = DotProduct(pop, dest->frustum[3].normal); + + VectorScale(dest->ori.axis[0], -1.0f, dest->frustum[4].normal); + VectorMA(dest->ori.origin, -shadow->lightRadius, dest->frustum[4].normal, pop); + dest->frustum[4].dist = DotProduct(pop, dest->frustum[4].normal); + + for (int j = 0; j < 5; j++) + { + dest->frustum[j].type = PLANE_NON_AXIAL; + SetPlaneSignbits(&dest->frustum[j]); + } + + dest->flags |= VPF_FARPLANEFRUSTUM; + } + + tr.viewParms.currentViewParm = tr.numCachedViewParms; + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; + } + } + + } + + // sun shadowmaps + if (r_sunlightMode->integer && r_depthPrepass->value && (r_forceSun->integer || tr.sunShadows)) + { + vec3_t lightViewAxis[3]; + vec3_t lightOrigin; + float splitZNear, splitZFar, splitBias; + float viewZNear, viewZFar; + vec3_t lightviewBounds[2]; + + viewZNear = r_shadowCascadeZNear->value; + viewZFar = r_shadowCascadeZFar->value; + splitBias = r_shadowCascadeZBias->value; + + for (int level = 0; level < 3; level++) + { + switch (level) + { + case 0: + default: + splitZNear = viewZNear; + splitZFar = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; + break; + case 1: + splitZNear = CalcSplit(viewZNear, viewZFar, 1, 3) + splitBias; + splitZFar = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; + break; + case 2: + splitZNear = CalcSplit(viewZNear, viewZFar, 2, 3) + splitBias; + splitZFar = viewZFar; + break; + } + + VectorCopy(refdef->vieworg, lightOrigin); + // Make up a projection + VectorScale(refdef->sunDir, -1.0f, lightViewAxis[0]); + // Use world up as light view up + VectorSet(lightViewAxis[2], 0, 0, 1); + + // Check if too close to parallel to light direction + if (fabs(DotProduct(lightViewAxis[2], lightViewAxis[0])) > 0.9f) + { + // Use world left as light view up + VectorSet(lightViewAxis[2], 0, 1, 0); + } + + // clean axes + CrossProduct(lightViewAxis[2], lightViewAxis[0], lightViewAxis[1]); + VectorNormalize(lightViewAxis[1]); + CrossProduct(lightViewAxis[0], lightViewAxis[1], lightViewAxis[2]); + + // Create bounds for light projection using slice of view projection + { + ClearBounds(lightviewBounds[0], lightviewBounds[1]); + + vec3_t point, base; + float lx, ly, radius; + vec3_t splitCenter, frustrumPoint0, frustrumPoint7; + + VectorSet(splitCenter, 0.f, 0.f, 0.f); + + // add view near plane + lx = splitZNear * tan(refdef->fov_x * M_PI / 360.0f); + ly = splitZNear * tan(refdef->fov_y * M_PI / 360.0f); + VectorMA(refdef->vieworg, splitZNear, refdef->viewaxis[0], base); + + VectorMA(base, lx, refdef->viewaxis[1], point); + VectorMA(point, ly, refdef->viewaxis[2], point); + VectorCopy(point, frustrumPoint0); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, -lx, refdef->viewaxis[1], point); + VectorMA(point, ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, lx, refdef->viewaxis[1], point); + VectorMA(point, -ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, -lx, refdef->viewaxis[1], point); + VectorMA(point, -ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + // add view far plane + lx = splitZFar * tan(refdef->fov_x * M_PI / 360.0f); + ly = splitZFar * tan(refdef->fov_y * M_PI / 360.0f); + VectorMA(refdef->vieworg, splitZFar, refdef->viewaxis[0], base); + + VectorMA(base, lx, refdef->viewaxis[1], point); + VectorMA(point, ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, -lx, refdef->viewaxis[1], point); + VectorMA(point, ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, lx, refdef->viewaxis[1], point); + VectorMA(point, -ly, refdef->viewaxis[2], point); + VectorAdd(point, splitCenter, splitCenter); + + VectorMA(base, -lx, refdef->viewaxis[1], point); + VectorMA(point, -ly, refdef->viewaxis[2], point); + VectorCopy(point, frustrumPoint7); + VectorAdd(point, splitCenter, splitCenter); + + VectorScale(splitCenter, 1.0f / 8.0f, splitCenter); + radius = Distance(frustrumPoint0, frustrumPoint7) / 2.0f; + lightviewBounds[0][0] = -radius; + lightviewBounds[0][1] = -radius; + lightviewBounds[0][2] = -radius; + lightviewBounds[1][0] = radius; + lightviewBounds[1][1] = radius; + lightviewBounds[1][2] = radius; + + VectorCopy(splitCenter, lightOrigin); + } + + orientationr_t orientation = {}; + R_SetOrientationOriginAndAxis(orientation, lightOrigin, lightViewAxis); + + R_SetupViewParmsForOrthoRendering( + tr.sunShadowFbo[level]->width, + tr.sunShadowFbo[level]->height, + tr.sunShadowFbo[level], + VPF_DEPTHSHADOW | VPF_DEPTHCLAMP | VPF_ORTHOGRAPHIC | VPF_NOVIEWMODEL | VPF_SHADOWCASCADES, + orientation, + lightviewBounds); + + // Moving the Light in Texel-Sized Increments + // from http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324%28v=vs.85%29.aspx + static float worldUnitsPerTexel = 2.0f * lightviewBounds[1][0] / (float)tr.sunShadowFbo[level]->width; + static float invWorldUnitsPerTexel = tr.sunShadowFbo[level]->width / (2.0f * lightviewBounds[1][0]); + + tr.viewParms.world.modelViewMatrix[12] = floorf(tr.viewParms.world.modelViewMatrix[12] * invWorldUnitsPerTexel); + tr.viewParms.world.modelViewMatrix[13] = floorf(tr.viewParms.world.modelViewMatrix[13] * invWorldUnitsPerTexel); + tr.viewParms.world.modelViewMatrix[14] = floorf(tr.viewParms.world.modelViewMatrix[14] * invWorldUnitsPerTexel); + + tr.viewParms.world.modelViewMatrix[12] *= worldUnitsPerTexel; + tr.viewParms.world.modelViewMatrix[13] *= worldUnitsPerTexel; + tr.viewParms.world.modelViewMatrix[14] *= worldUnitsPerTexel; + + Matrix16Multiply( + tr.viewParms.projectionMatrix, + tr.viewParms.world.modelViewMatrix, + refdef->sunShadowMvp[level]); + + tr.viewParms.currentViewParm = tr.numCachedViewParms; + tr.viewParms.viewParmType = VPT_SUN_SHADOWS; + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; + } + mainFlags |= VPF_USESUNLIGHT; + } + } + + // main view { - RE_EndScene(); + R_SetupViewParms(refdef); + if (R_AddPortalView(refdef)) + { + // this is a debug option to see exactly what is being mirrored + if (r_portalOnly->integer) + return; + + R_SetupViewParms(refdef); + } + + tr.viewParms.stereoFrame = STEREO_CENTER; // FIXME + tr.viewParms.flags = mainFlags; + + tr.viewParms.currentViewParm = tr.numCachedViewParms; + tr.viewParms.viewParmType = VPT_MAIN; + Com_Memcpy(&tr.cachedViewParms[tr.numCachedViewParms], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms++; } } diff --git a/codemp/rd-rend2/tr_mesh.cpp b/codemp/rd-rend2/tr_mesh.cpp index f66b887a3c..4b93f07377 100644 --- a/codemp/rd-rend2/tr_mesh.cpp +++ b/codemp/rd-rend2/tr_mesh.cpp @@ -293,7 +293,7 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { // don't add third_person objects if not in a portal personalModel = (qboolean)((ent->e.renderfx & RF_THIRD_PERSON) && !(tr.viewParms.isPortal - || (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)))); + || (tr.viewParms.flags & VPF_DEPTHSHADOW))); if ( ent->e.renderfx & RF_WRAP_FRAMES ) { ent->e.frame %= tr.currentModel->data.mdv[0]->numFrames; @@ -333,13 +333,6 @@ void R_AddMD3Surfaces( trRefEntity_t *ent, int entityNum ) { return; } - // - // set up lighting now that we know we aren't culled - // - if ( !personalModel || r_shadows->integer > 1 ) { - R_SetupEntityLighting( &tr.refdef, ent ); - } - // // see if we are in a fog volume // diff --git a/codemp/rd-rend2/tr_model_iqm.cpp b/codemp/rd-rend2/tr_model_iqm.cpp index f161cbb4f9..7639ac1b2d 100644 --- a/codemp/rd-rend2/tr_model_iqm.cpp +++ b/codemp/rd-rend2/tr_model_iqm.cpp @@ -882,13 +882,6 @@ void R_AddIQMSurfaces( trRefEntity_t *ent, int entityNum ) { return; } - // - // set up lighting now that we know we aren't culled - // - if ( !personalModel || r_shadows->integer > 1 ) { - R_SetupEntityLighting( &tr.refdef, ent ); - } - // // see if we are in a fog volume // diff --git a/codemp/rd-rend2/tr_scene.cpp b/codemp/rd-rend2/tr_scene.cpp index 45ffc8730e..b62dca2004 100644 --- a/codemp/rd-rend2/tr_scene.cpp +++ b/codemp/rd-rend2/tr_scene.cpp @@ -341,7 +341,7 @@ void RE_BeginScene(const refdef_t *fd) tr.refdef.sunAmbCol[3] = 1.0f; VectorCopy(tr.sunDirection, tr.refdef.sunDir); - if ( (tr.refdef.rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) ){ + if ( (fd->rdflags & RDF_NOWORLDMODEL) || !(r_depthPrepass->value) ){ tr.refdef.colorScale = 1.0f; VectorSet(tr.refdef.sunCol, 0, 0, 0); VectorSet(tr.refdef.sunAmbCol, 0, 0, 0); @@ -453,7 +453,7 @@ void RE_BeginScene(const refdef_t *fd) // Add the decals here because decals add polys and we need to ensure // that the polys are added before the the renderer is prepared - if ( !(tr.refdef.rdflags & RDF_NOWORLDMODEL) ) + if ( !(fd->rdflags & RDF_NOWORLDMODEL) ) R_AddDecals(); tr.refdef.numPolys = r_numpolys - r_firstScenePoly; @@ -472,6 +472,9 @@ void RE_BeginScene(const refdef_t *fd) if (fd->rdflags & RDF_SKYBOXPORTAL) { tr.world->skyboxportal = 1; + + // Don't update constants yet. Store everything and render everything next scene + return; } else { @@ -487,6 +490,10 @@ void RE_BeginScene(const refdef_t *fd) // each scene / view. tr.frameSceneNum++; tr.sceneCount++; + + //ri.Printf(PRINT_ALL, "RE_BeginScene Frame: %i, skyportal: %i, entities: %i\n", backEndData->realFrameNumber, int(tr.world->skyboxportal && (tr.refdef.rdflags & RDF_SKYBOXPORTAL)), tr.refdef.num_entities); + R_GatherFrameViews(&tr.refdef); + RB_UpdateConstants(&tr.refdef); } void RE_EndScene() @@ -496,6 +503,8 @@ void RE_EndScene() r_firstSceneEntity = r_numentities; r_firstSceneDlight = r_numdlights; r_firstScenePoly = r_numpolys; + tr.skyPortalEntities = 0; + tr.numCachedViewParms = 0; } /* @@ -509,8 +518,8 @@ Rendering a scene may require multiple views to be rendered to handle mirrors, @@@@@@@@@@@@@@@@@@@@@ */ -void RE_RenderScene( const refdef_t *fd ) { - viewParms_t parms; +void RE_RenderScene( const refdef_t *fd ) +{ int startTime; if ( !tr.registered ) { @@ -530,69 +539,48 @@ void RE_RenderScene( const refdef_t *fd ) { RE_BeginScene(fd); - // SmileTheory: playing with shadow mapping - if (!( fd->rdflags & RDF_NOWORLDMODEL ) && tr.refdef.num_dlights && r_dlightMode->integer >= 2) - { - qhandle_t timer = R_BeginTimedBlockCmd( "Dlight cubemaps" ); - R_RenderDlightCubemaps(fd); - R_EndTimedBlockCmd( timer ); - } - - /* playing with more shadows */ - if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_shadows->integer == 4) - { - qhandle_t timer = R_BeginTimedBlockCmd( "PShadow Maps" ); - R_RenderPshadowMaps(fd); - R_EndTimedBlockCmd( timer ); - } - - // playing with even more shadows - if(r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) + // Store skyportal info and don't render yet + if (tr.refdef.rdflags & RDF_SKYBOXPORTAL) { - qhandle_t timer = R_BeginTimedBlockCmd( "Shadow cascades" ); - R_RenderSunShadowMaps(fd, 0); - R_RenderSunShadowMaps(fd, 1); - R_RenderSunShadowMaps(fd, 2); - R_EndTimedBlockCmd( timer ); + viewParms_t parms; + Com_Memset(&parms, 0, sizeof(parms)); + parms.viewportX = fd->x; + parms.viewportY = glConfig.vidHeight - (fd->y + fd->height); + parms.viewportWidth = fd->width; + parms.viewportHeight = fd->height; + parms.isPortal = qfalse; + parms.isSkyPortal = qfalse; + parms.zNear = r_znear->value; + + parms.fovX = fd->fov_x; + parms.fovY = fd->fov_y; + + parms.stereoFrame = tr.refdef.stereoFrame; + + VectorCopy(fd->vieworg, parms.ori.origin); + VectorCopy(fd->viewaxis[0], parms.ori.axis[0]); + VectorCopy(fd->viewaxis[1], parms.ori.axis[1]); + VectorCopy(fd->viewaxis[2], parms.ori.axis[2]); + + VectorCopy(fd->vieworg, parms.pvsOrigin); + + parms.isSkyPortal = qtrue; + Com_Memcpy(&tr.skyPortalParms, &parms, sizeof(viewParms_t)); + Com_Memcpy(tr.skyPortalAreaMask, tr.refdef.areamask, sizeof(tr.refdef.areamask)); + tr.skyPortalEntities = tr.refdef.num_entities; + return; } - R_IssuePendingRenderCommands(); - - // setup view parms for the initial view - // - // set up viewport - // The refdef takes 0-at-the-top y coordinates, so - // convert to GL's 0-at-the-bottom space - // - Com_Memset( &parms, 0, sizeof( parms ) ); - parms.viewportX = tr.refdef.x; - parms.viewportY = glConfig.vidHeight - ( tr.refdef.y + tr.refdef.height ); - parms.viewportWidth = tr.refdef.width; - parms.viewportHeight = tr.refdef.height; - parms.isPortal = qfalse; - parms.zNear = r_znear->value; - - parms.fovX = tr.refdef.fov_x; - parms.fovY = tr.refdef.fov_y; - - parms.stereoFrame = tr.refdef.stereoFrame; - - VectorCopy( fd->vieworg, parms.ori.origin ); - VectorCopy( fd->viewaxis[0], parms.ori.axis[0] ); - VectorCopy( fd->viewaxis[1], parms.ori.axis[1] ); - VectorCopy( fd->viewaxis[2], parms.ori.axis[2] ); - - VectorCopy( fd->vieworg, parms.pvsOrigin ); - - if(!( fd->rdflags & RDF_NOWORLDMODEL ) && r_depthPrepass->value && ((r_forceSun->integer) || tr.sunShadows)) + // Render all the passes + for (int i = 0; i < tr.numCachedViewParms; i++) { - parms.flags = VPF_USESUNLIGHT; + qhandle_t timer = R_BeginTimedBlockCmd(va("Render Pass %i", i)); + tr.refdef.numDrawSurfs = 0; + R_RenderView(&tr.cachedViewParms[i]); + R_IssuePendingRenderCommands(); + R_EndTimedBlockCmd(timer); } - qhandle_t timer = R_BeginTimedBlockCmd( "Main Render" ); - R_RenderView( &parms ); - R_EndTimedBlockCmd( timer ); - if(!( fd->rdflags & RDF_NOWORLDMODEL )) { qhandle_t timer = R_BeginTimedBlockCmd( "Post processing" ); @@ -600,6 +588,8 @@ void RE_RenderScene( const refdef_t *fd ) { R_EndTimedBlockCmd( timer ); } + R_IssuePendingRenderCommands(); + RE_EndScene(); tr.frontEndMsec += ri.Milliseconds() - startTime; diff --git a/codemp/rd-rend2/tr_shade.cpp b/codemp/rd-rend2/tr_shade.cpp index 91e0b48b38..bc65a71cb7 100644 --- a/codemp/rd-rend2/tr_shade.cpp +++ b/codemp/rd-rend2/tr_shade.cpp @@ -163,7 +163,7 @@ void RB_BeginSurface( shader_t *shader, int fogNum, int cubemapIndex ) { tess.shaderTime = tess.shader->clampTime; } - if (backEnd.viewParms.flags & VPF_SHADOWMAP) + if (backEnd.viewParms.flags & VPF_DEPTHSHADOW) { tess.currentStageIteratorFunc = RB_StageIteratorGeneric; } @@ -709,7 +709,7 @@ static UniformBlockBinding GetCameraBlockUniformBinding( else { binding.ubo = currentFrameUbo; - binding.offset = tr.cameraUboOffset; + binding.offset = tr.cameraUboOffsets[backEnd.viewParms.currentViewParm]; } return binding; } @@ -791,7 +791,7 @@ static UniformBlockBinding GetEntityBlockUniformBinding( else { binding.ubo = currentFrameUbo; - if (refEntity == &tr.worldEntity) + if (!refEntity || refEntity == &tr.worldEntity) { binding.offset = tr.entityUboOffsets[REFENTITYNUM_WORLD]; } @@ -819,8 +819,7 @@ static UniformBlockBinding GetBonesBlockUniformBinding( binding.offset = 0; else { - const int drawSurfNum = backEnd.currentDrawSurfIndex; - binding.offset = tr.animationBoneUboOffsets[drawSurfNum]; + binding.offset = tr.animationBoneUboOffset; } return binding; @@ -831,37 +830,18 @@ static UniformBlockBinding GetShaderInstanceBlockUniformBinding( { const GLuint currentFrameUbo = backEndData->currentFrame->ubo; UniformBlockBinding binding = {}; - binding.ubo = currentFrameUbo; + binding.ubo = tr.shaderInstanceUbo; binding.block = UNIFORM_BLOCK_SHADER_INSTANCE; - if (refEntity == &tr.worldEntity || refEntity == &backEnd.entityFlare) - { - binding.offset = RB_GetEntityShaderUboOffset( - tr.shaderInstanceUboOffsetsMap, - tr.shaderInstanceUboOffsetsMapSize, - REFENTITYNUM_WORLD, - shader->index); - } - else if (refEntity == &backEnd.entity2D) - { - binding.offset = 0; // FIXME: FIX THIS! - } - else - { - const int refEntityNum = refEntity - backEnd.refdef.entities; - binding.offset = RB_GetEntityShaderUboOffset( - tr.shaderInstanceUboOffsetsMap, - tr.shaderInstanceUboOffsetsMapSize, - refEntityNum, - shader->index); - } - - if (binding.offset == -1) + if (shader->ShaderInstanceUboOffset == -1) { binding.ubo = tr.staticUbo; binding.offset = tr.defaultShaderInstanceUboOffset; + return binding; } + binding.offset = shader->ShaderInstanceUboOffset; + return binding; } @@ -1619,7 +1599,14 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays uniformDataWriter.SetUniformVec3(UNIFORM_TCGEN0VECTOR1, pStage->bundle[0].tcGenVectors[1]); } - uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, pStage->normalScale); + vec4_t normalScale = { + pStage->normalScale[0], + pStage->normalScale[1], + backEnd.viewParms.isPortal ? -1.0f : 1.0f, + pStage->normalScale[3] + }; + + uniformDataWriter.SetUniformVec4(UNIFORM_NORMALSCALE, normalScale); uniformDataWriter.SetUniformVec4(UNIFORM_SPECULARSCALE, pStage->specularScale); const float parallaxBias = r_forceParallaxBias->value > 0.0f ? r_forceParallaxBias->value : pStage->parallaxBias; @@ -1672,7 +1659,7 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK)) { - samplerBindingsWriter.AddStaticImage(tr.screenShadowImage, TB_SHADOWMAP); + samplerBindingsWriter.AddStaticImage(tr.sunShadowArrayImage, TB_SHADOWMAP); enableTextures[2] = 1.0f; } else @@ -1853,45 +1840,6 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input, const VertexArrays } } - -static void RB_RenderShadowmap( shaderCommands_t *input, const VertexArraysProperties *vertexArrays ) -{ - Allocator& frameAllocator = *backEndData->perFrameMemory; - cullType_t cullType = RB_GetCullType(&backEnd.viewParms, backEnd.currentEntity, input->shader->cullType); - - vertexAttribute_t attribs[ATTR_INDEX_MAX] = {}; - GL_VertexArraysToAttribs(attribs, ARRAY_LEN(attribs), vertexArrays); - - const UniformBlockBinding uniformBlockBindings[] = { - GetCameraBlockUniformBinding(backEnd.currentEntity), - GetEntityBlockUniformBinding(backEnd.currentEntity), - GetShaderInstanceBlockUniformBinding( - backEnd.currentEntity, input->shader) - }; - - DrawItem item = {}; - item.renderState.depthRange = RB_GetDepthRange(backEnd.currentEntity, input->shader); - item.renderState.cullType = cullType; - item.program = &tr.shadowmapShader; - item.ibo = input->externalIBO ? input->externalIBO : backEndData->currentFrame->dynamicIbo; - - item.numAttributes = vertexArrays->numVertexArrays; - item.attributes = ojkAllocArray( - *backEndData->perFrameMemory, vertexArrays->numVertexArrays); - memcpy(item.attributes, attribs, sizeof(*item.attributes)*vertexArrays->numVertexArrays); - - DrawItemSetVertexAttributes( - item, attribs, vertexArrays->numVertexArrays, frameAllocator); - DrawItemSetUniformBlockBindings( - item, uniformBlockBindings, frameAllocator); - - RB_FillDrawCommand(item.draw, GL_TRIANGLES, 1, input); - - // FIXME: Use depth to object - uint32_t key = 0; - RB_AddDrawItem(backEndData->currentPass, key, item); -} - /* ** RB_StageIteratorGeneric */ @@ -1949,13 +1897,6 @@ void RB_StageIteratorGeneric( void ) { RB_IterateStagesGeneric( input, &vertexArrays ); } - else if (backEnd.viewParms.flags & VPF_SHADOWMAP) - { - if ( input->shader->sort == SS_OPAQUE ) - { - RB_RenderShadowmap(input, &vertexArrays); - } - } else { RB_IterateStagesGeneric( input, &vertexArrays ); @@ -2055,7 +1996,7 @@ void RB_EndSurface( void ) { if (tr.world->skyboxportal) { // world - if (!(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL) && (tess.currentStageIteratorFunc == RB_StageIteratorSky)) + if (!(tr.viewParms.isSkyPortal) && (tess.currentStageIteratorFunc == RB_StageIteratorSky)) { // don't process these tris at all return; } diff --git a/codemp/rd-rend2/tr_shader.cpp b/codemp/rd-rend2/tr_shader.cpp index dd03dc3a62..c3f8e2c470 100644 --- a/codemp/rd-rend2/tr_shader.cpp +++ b/codemp/rd-rend2/tr_shader.cpp @@ -3751,6 +3751,8 @@ static shader_t *GeneratePermanentShader( void ) { } } + RB_AddShaderToShaderInstanceUBO(newShader); + SortNewShader(); hash = generateHashValue(newShader->name, FILE_HASH_SIZE); diff --git a/codemp/rd-rend2/tr_sky.cpp b/codemp/rd-rend2/tr_sky.cpp index 1e1ba1fb6f..98a60c6058 100644 --- a/codemp/rd-rend2/tr_sky.cpp +++ b/codemp/rd-rend2/tr_sky.cpp @@ -457,7 +457,7 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { { currentFrameUbo, tr.skyEntityUboOffset, UNIFORM_BLOCK_ENTITY }, - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } + { currentFrameUbo, tr.cameraUboOffsets[tr.viewParms.currentViewParm], UNIFORM_BLOCK_CAMERA } }; DrawItem item = {}; @@ -840,7 +840,7 @@ void RB_StageIteratorSky( void ) { return; } - if (tr.world->skyboxportal && !(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL)) { + if (tr.world->skyboxportal && !(tr.viewParms.isSkyPortal)) { return; } diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index b1d53fc116..ce29b21156 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2095,7 +2095,6 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) } //drawSurf_t drawSurf = - int dlightBits = tess.dlightBits; R_BindVBO(surface->vbo); R_BindIBO(surface->ibo); @@ -2103,7 +2102,7 @@ void RB_SurfaceVBOMDVMesh(srfVBOMDVMesh_t * surface) tess.useInternalVBO = qfalse; tess.externalIBO = surface->ibo; - tess.dlightBits = dlightBits; + // tess.dlightBits is already set in the renderloop // merge this into any existing multidraw primitives mergeForward = -1; @@ -2248,17 +2247,12 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) SamplerBindingsWriter samplerBindingsWriter; samplerBindingsWriter.AddAnimatedImage(&firstStage->bundle[0], TB_COLORMAP); - int offset = RB_GetEntityShaderUboOffset( - tr.surfaceSpriteInstanceUboOffsetsMap, - 64, - REFENTITYNUM_WORLD, - shader->index); - const GLuint currentFrameUbo = backEndData->currentFrame->ubo; + const GLuint currentSpriteUbo = shader->spriteUbo; const UniformBlockBinding uniformBlockBindings[] = { + { currentSpriteUbo, ss->spriteUboOffset, UNIFORM_BLOCK_SURFACESPRITE }, { currentFrameUbo, tr.sceneUboOffset, UNIFORM_BLOCK_SCENE }, - { currentFrameUbo, offset, UNIFORM_BLOCK_SURFACESPRITE }, - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA }, + { currentFrameUbo, tr.cameraUboOffsets[tr.viewParms.currentViewParm], UNIFORM_BLOCK_CAMERA }, { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS } }; diff --git a/codemp/rd-rend2/tr_vbo.cpp b/codemp/rd-rend2/tr_vbo.cpp index d34d4a622b..4025bd31d5 100644 --- a/codemp/rd-rend2/tr_vbo.cpp +++ b/codemp/rd-rend2/tr_vbo.cpp @@ -285,6 +285,20 @@ void R_InitGPUBuffers(void) // glGenBuffers only allocates the IDs for these buffers. The 'buffer object' is // actually created on first bind. qglGenBuffers(1, &tr.staticUbo); + qglGenBuffers(MAX_SUB_BSP + 1, tr.spriteUbos); + qglGenBuffers(1, &tr.shaderInstanceUbo); + + // Allocate/create ShaderInstanceBlock ubo + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + const size_t alignedBlockSize = (sizeof(ShaderInstanceBlock) + alignment) & ~alignment; + + qglBindBuffer(GL_UNIFORM_BUFFER, tr.shaderInstanceUbo); + glState.currentGlobalUBO = tr.shaderInstanceUbo; + qglBufferData( + GL_UNIFORM_BUFFER, + MAX_SHADERS * alignedBlockSize, + nullptr, + GL_STATIC_DRAW); tr.numVBOs = 0; tr.numIBOs = 0; @@ -308,6 +322,8 @@ void R_DestroyGPUBuffers(void) R_BindNullIBO(); qglDeleteBuffers(1, &tr.staticUbo); + qglDeleteBuffers(MAX_SUB_BSP + 1, tr.spriteUbos); + qglDeleteBuffers(1, &tr.shaderInstanceUbo); for (int i = 0; i < tr.numVBOs; i++) { @@ -743,6 +759,25 @@ int RB_BindAndUpdateFrameUniformBlock(uniformBlock_t block, void *data) return offset; } +int RB_AddShaderInstanceBlock(void *data) +{ + if (glState.currentGlobalUBO != tr.shaderInstanceUbo) + { + qglBindBuffer(GL_UNIFORM_BUFFER, tr.shaderInstanceUbo); + glState.currentGlobalUBO = tr.shaderInstanceUbo; + } + const size_t writeOffset = tr.shaderInstanceUboWriteOffset; + + qglBufferSubData(GL_UNIFORM_BUFFER, + tr.shaderInstanceUboWriteOffset, sizeof(ShaderInstanceBlock), data); + + const int alignment = glRefConfig.uniformBufferOffsetAlignment - 1; + const size_t alignedBlockSize = (sizeof(ShaderInstanceBlock) + alignment) & ~alignment; + tr.shaderInstanceUboWriteOffset += alignedBlockSize; + + return writeOffset; +} + void RB_BeginConstantsUpdate(gpuFrame_t *frame) { if (glState.currentGlobalUBO != frame->ubo) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 5f4a106eb2..3669cb3ce1 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -124,6 +124,11 @@ namespace void GenerateDepthMap() { + R_IssuePendingRenderCommands(); + R_InitNextFrame(); + R_NewFrameSync(); + RE_BeginFrame(STEREO_CENTER); + vec3_t mapSize; vec3_t halfMapSize; VectorSubtract( @@ -152,9 +157,9 @@ namespace for (int i = 0; i < 3; ++i) VectorCopy(orientation.axis[i], refdef.viewaxis[i]); - RE_BeginScene(&refdef); - RE_ClearScene(); - + tr.refdef.rdflags = tr.refdef.rdflags & ~RDF_SKYBOXPORTAL; + tr.skyPortalEntities = 0; + const vec3_t viewBounds[2] = { { 0.0f, -halfMapSize[1], -halfMapSize[0] }, { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } @@ -177,8 +182,6 @@ namespace tr.viewParms.world.modelViewMatrix, tr.weatherSystem->weatherMVP); - R_IssuePendingRenderCommands(); - if (tr.weatherSystem->numWeatherBrushes > 0) { FBO_Bind(tr.weatherDepthFbo); @@ -333,15 +336,7 @@ namespace RB_AddQuadStamp(rayPos, left, up, color); } } - - gpuFrame_t *currentFrame = backEndData->currentFrame; - assert(!currentFrame->sync); - currentFrame->sync = qglFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - - backEndData->realFrameNumber++; - backEnd.framePostProcessed = qfalse; - backEnd.projection2D = qfalse; - backEnd.frameUBOsInitialized = qfalse; + R_NewFrameSync(); } // draw remaining quads @@ -370,14 +365,44 @@ namespace const int firstDrawSurf = tr.refdef.numDrawSurfs; + tr.refdef.x = refdef.x; + tr.refdef.y = refdef.y; + tr.refdef.width = refdef.width; + tr.refdef.height = refdef.height; + tr.refdef.fov_x = refdef.fov_x; + tr.refdef.fov_y = refdef.fov_y; + + VectorCopy(refdef.vieworg, tr.refdef.vieworg); + VectorCopy(refdef.viewaxis[0], tr.refdef.viewaxis[0]); + VectorCopy(refdef.viewaxis[1], tr.refdef.viewaxis[1]); + VectorCopy(refdef.viewaxis[2], tr.refdef.viewaxis[2]); + + tr.refdef.numDrawSurfs = 0; + tr.refdef.drawSurfs = backEndData->drawSurfs; + + tr.refdef.num_entities = 0; + tr.refdef.entities = backEndData->entities; + + tr.refdef.num_dlights = 0; + tr.refdef.dlights = backEndData->dlights; + + tr.viewParms.currentViewParm = 0; + Com_Memcpy(&tr.cachedViewParms[0], &tr.viewParms, sizeof(viewParms_t)); + tr.numCachedViewParms = 1; + + RB_UpdateConstants(&tr.refdef); + R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); R_SortAndSubmitDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf); R_IssuePendingRenderCommands(); - R_InitNextFrame(); + tr.refdef.numDrawSurfs = 0; + RE_EndScene(); + + R_NewFrameSync(); } void RB_SimulateWeather(weatherObject_t *ws, vec2_t *zoneOffsets, int zoneIndex) @@ -386,7 +411,7 @@ namespace tr.weatherSystem->frozen) { // Already simulated for this frame - return; + //return; } // Intentionally switched. Previous frame's VBO would be in ws.vbo and @@ -1221,7 +1246,7 @@ void RB_SurfaceWeather( srfWeather_t *surf ) { const GLuint currentFrameUbo = backEndData->currentFrame->ubo; const UniformBlockBinding uniformBlockBindings[] = { - { currentFrameUbo, tr.cameraUboOffset, UNIFORM_BLOCK_CAMERA } + { currentFrameUbo, tr.cameraUboOffsets[tr.viewParms.currentViewParm], UNIFORM_BLOCK_CAMERA } }; DrawItemSetUniformBlockBindings( item, uniformBlockBindings, frameAllocator); diff --git a/codemp/rd-rend2/tr_world.cpp b/codemp/rd-rend2/tr_world.cpp index 4cfdf81840..0204652440 100644 --- a/codemp/rd-rend2/tr_world.cpp +++ b/codemp/rd-rend2/tr_world.cpp @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "tr_local.h" -static world_t *R_GetWorld(int worldIndex) +world_t *R_GetWorld(int worldIndex) { if (worldIndex == -1) { @@ -68,10 +68,7 @@ static qboolean R_CullSurface( msurface_t *surf, int entityNum ) { return qfalse; } - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) - return qfalse; - - if (tr.viewParms.flags & (VPF_SHADOWMAP | VPF_DEPTHSHADOW)) + if (tr.viewParms.flags & (VPF_DEPTHSHADOW) && tr.viewParms.flags & (VPF_SHADOWCASCADES)) { if (ct == CT_FRONT_SIDED) { @@ -350,7 +347,7 @@ static void R_AddWorldSurface( } // set pshadows - if ( pshadowBits && r_shadows->integer == 4 ) { + if ( pshadowBits ) { R_PshadowSurface( surf, pshadowBits ); } @@ -394,13 +391,13 @@ void R_AddBrushModelSurfaces ( trRefEntity_t *ent, int entityNum ) { return; } - R_SetupEntityLighting( &tr.refdef, ent ); - R_DlightBmodel( bmodel, ent ); + if (!(tr.viewParms.flags & VPF_DEPTHSHADOW)) + R_DlightBmodel( bmodel, ent ); + world_t *world = R_GetWorld(bmodel->worldIndex); for ( int i = 0 ; i < bmodel->numSurfaces ; i++ ) { int surf = bmodel->firstSurface + i; - world_t *world = R_GetWorld(bmodel->worldIndex); - + if (world->surfacesViewCount[surf] != tr.viewCount) { world->surfacesViewCount[surf] = tr.viewCount; @@ -523,7 +520,7 @@ void RE_SetRangedFog ( float range ) R_RecursiveWorldNode ================ */ -static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) +void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, int pshadowBits ) { do { int newDlights[2]; @@ -708,7 +705,6 @@ static void R_RecursiveWorldNode( mnode_t *node, int planeBits, int dlightBits, view++; } } - } @@ -787,7 +783,7 @@ Mark the leaves and nodes that are in the PVS for the current cluster =============== */ -static void R_MarkLeaves( void ) +void R_MarkLeaves( void ) { // lockpvs lets designers walk around to determine the // extent of the current pvs @@ -837,7 +833,7 @@ static void R_MarkLeaves( void ) const byte *vis = R_ClusterPVS(tr.visClusters[tr.visIndex]); int i; - for (i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++) { + for (i = 0, leaf = (tr.world->nodes + tr.world->numDecisionNodes); i < (tr.world->numnodes - tr.world->numDecisionNodes); i++, leaf++) { cluster = leaf->cluster; if ( cluster < 0 || cluster >= tr.world->numClusters ) { continue; @@ -848,8 +844,11 @@ static void R_MarkLeaves( void ) continue; } + // Handle skyportal draws + byte *areamask = tr.viewParms.isSkyPortal == qtrue ? tr.skyPortalAreaMask : tr.refdef.areamask; + // check for door connection - if ( (tr.refdef.areamask[leaf->area>>3] & (1<<(leaf->area&7)) ) ) { + if ( (areamask[leaf->area>>3] & (1<<(leaf->area&7)) ) ) { continue; // not visible } @@ -901,22 +900,19 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { dlightBits = 0; pshadowBits = 0; } - else if ( !(viewParms->flags & VPF_SHADOWMAP) ) - { - dlightBits = ( 1 << refdef->num_dlights ) - 1; - pshadowBits = ( 1 << refdef->num_pshadows ) - 1; - } else { - dlightBits = ( 1 << refdef->num_dlights ) - 1; - pshadowBits = 0; + dlightBits = (1 << refdef->num_dlights) - 1; + if (r_shadows->integer == 4) + pshadowBits = (1 << refdef->num_pshadows) - 1; + else + pshadowBits = 0; } R_RecursiveWorldNode(tr.world->nodes, planeBits, dlightBits, pshadowBits); // now add all the potentially visible surfaces - // also mask invisible dlights for next frame - refdef->dlightMask = 0; + R_RotateForEntity(&tr.worldEntity, &tr.viewParms, &tr.ori); for (int i = 0; i < tr.world->numWorldSurfaces; i++) { @@ -929,7 +925,6 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { REFENTITYNUM_WORLD, tr.world->surfacesDlightBits[i], tr.world->surfacesPshadowBits[i]); - refdef->dlightMask |= tr.world->surfacesDlightBits[i]; } for (int i = 0; i < tr.world->numMergedSurfaces; i++) @@ -943,8 +938,5 @@ void R_AddWorldSurfaces( viewParms_t *viewParms, trRefdef_t *refdef ) { REFENTITYNUM_WORLD, tr.world->mergedSurfacesDlightBits[i], tr.world->mergedSurfacesPshadowBits[i]); - refdef->dlightMask |= tr.world->mergedSurfacesDlightBits[i]; } - - refdef->dlightMask = ~refdef->dlightMask; } From 9df2102805ac6458de79cb4a8abdf30ce79dd845 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:31:45 +0200 Subject: [PATCH 702/708] Fix weather TD occlusion Weather top down occlusion rendering now working again and correct usage of R_NewFrameSync(). --- codemp/rd-rend2/tr_backend.cpp | 1 + codemp/rd-rend2/tr_bsp.cpp | 1 - codemp/rd-rend2/tr_weather.cpp | 43 +++++++--------------------------- 3 files changed, 10 insertions(+), 35 deletions(-) diff --git a/codemp/rd-rend2/tr_backend.cpp b/codemp/rd-rend2/tr_backend.cpp index fee052422e..65c19308ff 100644 --- a/codemp/rd-rend2/tr_backend.cpp +++ b/codemp/rd-rend2/tr_backend.cpp @@ -2164,6 +2164,7 @@ static void RB_UpdateCameraConstants(gpuFrame_t *frame) { for (int i = 0; i < tr.numCachedViewParms; i++) { + backEnd.viewParms = tr.cachedViewParms[i]; const float zmax = tr.cachedViewParms[i].zFar; const float zmin = tr.cachedViewParms[i].zNear; diff --git a/codemp/rd-rend2/tr_bsp.cpp b/codemp/rd-rend2/tr_bsp.cpp index ea9dc9e92c..a573fe316c 100644 --- a/codemp/rd-rend2/tr_bsp.cpp +++ b/codemp/rd-rend2/tr_bsp.cpp @@ -3295,7 +3295,6 @@ static void R_RenderAllCubemaps() { R_IssuePendingRenderCommands(); R_InitNextFrame(); - R_NewFrameSync(); GLenum cubemapFormat = GL_RGBA8; if (r_hdr->integer) diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index 3669cb3ce1..aa6d4a1027 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -126,7 +126,6 @@ namespace { R_IssuePendingRenderCommands(); R_InitNextFrame(); - R_NewFrameSync(); RE_BeginFrame(STEREO_CENTER); vec3_t mapSize; @@ -146,29 +145,13 @@ namespace VectorMA(tr.world->bmodels[0].bounds[1], 0.5f, mapSize, viewOrigin); viewOrigin[2] = tr.world->bmodels[0].bounds[1][2]; - ri.Printf(PRINT_ALL, "Rendering weather depth from (%.f %.f %.f)\n", - viewOrigin[0], viewOrigin[1], viewOrigin[2]); - orientationr_t orientation; R_SetOrientationOriginAndAxis(orientation, viewOrigin, forward, left, up); - - refdef_t refdef = {}; - VectorCopy(orientation.origin, refdef.vieworg); - for (int i = 0; i < 3; ++i) - VectorCopy(orientation.axis[i], refdef.viewaxis[i]); - - tr.refdef.rdflags = tr.refdef.rdflags & ~RDF_SKYBOXPORTAL; - tr.skyPortalEntities = 0; const vec3_t viewBounds[2] = { { 0.0f, -halfMapSize[1], -halfMapSize[0] }, { halfMapSize[2] * 2.0f, halfMapSize[1], halfMapSize[0] } }; - ri.Printf( - PRINT_ALL, - "Weather view bounds (%f %f %f) (%f %f %f)\n", - viewBounds[0][0], viewBounds[0][1], viewBounds[0][2], - viewBounds[1][0], viewBounds[1][1], viewBounds[1][2]); R_SetupViewParmsForOrthoRendering( tr.weatherDepthFbo->width, @@ -360,23 +343,11 @@ namespace qglDisable(GL_DEPTH_CLAMP); } + RE_BeginFrame(STEREO_CENTER); + if (tr.weatherSystem->numWeatherBrushes > 0) tr.viewParms.flags |= VPF_NOCLEAR; - const int firstDrawSurf = tr.refdef.numDrawSurfs; - - tr.refdef.x = refdef.x; - tr.refdef.y = refdef.y; - tr.refdef.width = refdef.width; - tr.refdef.height = refdef.height; - tr.refdef.fov_x = refdef.fov_x; - tr.refdef.fov_y = refdef.fov_y; - - VectorCopy(refdef.vieworg, tr.refdef.vieworg); - VectorCopy(refdef.viewaxis[0], tr.refdef.viewaxis[0]); - VectorCopy(refdef.viewaxis[1], tr.refdef.viewaxis[1]); - VectorCopy(refdef.viewaxis[2], tr.refdef.viewaxis[2]); - tr.refdef.numDrawSurfs = 0; tr.refdef.drawSurfs = backEndData->drawSurfs; @@ -386,6 +357,11 @@ namespace tr.refdef.num_dlights = 0; tr.refdef.dlights = backEndData->dlights; + tr.refdef.fistDrawSurf = 0; + + tr.skyPortalEntities = 0; + + tr.viewParms.targetFbo = tr.weatherDepthFbo; tr.viewParms.currentViewParm = 0; Com_Memcpy(&tr.cachedViewParms[0], &tr.viewParms, sizeof(viewParms_t)); tr.numCachedViewParms = 1; @@ -393,12 +369,11 @@ namespace RB_UpdateConstants(&tr.refdef); R_GenerateDrawSurfs(&tr.viewParms, &tr.refdef); - R_SortAndSubmitDrawSurfs( - tr.refdef.drawSurfs + firstDrawSurf, - tr.refdef.numDrawSurfs - firstDrawSurf); + R_SortAndSubmitDrawSurfs(tr.refdef.drawSurfs, tr.refdef.numDrawSurfs); R_IssuePendingRenderCommands(); tr.refdef.numDrawSurfs = 0; + tr.numCachedViewParms = 0; RE_EndScene(); From 5ff53904687877ce6767292473c6efb10a370512 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 2 Jul 2023 20:53:04 +0200 Subject: [PATCH 703/708] Render weather only in portal and main views --- codemp/rd-rend2/tr_main.cpp | 2 +- codemp/rd-rend2/tr_weather.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codemp/rd-rend2/tr_main.cpp b/codemp/rd-rend2/tr_main.cpp index 588a272a3d..17c5c736a9 100644 --- a/codemp/rd-rend2/tr_main.cpp +++ b/codemp/rd-rend2/tr_main.cpp @@ -2026,7 +2026,7 @@ void R_GenerateDrawSurfs( viewParms_t *viewParms, trRefdef_t *refdef ) { R_AddPolygonSurfaces(refdef); - if ( !(tr.viewParms.flags & VPF_DEPTHSHADOW) && tr.world) + if ( tr.viewParms.viewParmType > VPT_POINT_SHADOWS && tr.world ) { R_AddWeatherSurfaces(); } diff --git a/codemp/rd-rend2/tr_weather.cpp b/codemp/rd-rend2/tr_weather.cpp index aa6d4a1027..f3a5620673 100644 --- a/codemp/rd-rend2/tr_weather.cpp +++ b/codemp/rd-rend2/tr_weather.cpp @@ -386,7 +386,7 @@ namespace tr.weatherSystem->frozen) { // Already simulated for this frame - //return; + return; } // Intentionally switched. Previous frame's VBO would be in ws.vbo and From 0237769df3e255c3088cb0769d34cb1ac46c4ee9 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sun, 2 Jul 2023 21:08:06 +0200 Subject: [PATCH 704/708] Fix shader compile when r_sunlightmode == 0 --- codemp/rd-rend2/glsl/lightall.glsl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/codemp/rd-rend2/glsl/lightall.glsl b/codemp/rd-rend2/glsl/lightall.glsl index 9effcb0dc7..759bbc8144 100644 --- a/codemp/rd-rend2/glsl/lightall.glsl +++ b/codemp/rd-rend2/glsl/lightall.glsl @@ -443,6 +443,7 @@ in vec4 var_LightDir; out vec4 out_Color; out vec4 out_Glow; +#if defined(USE_SHADOWMAP) // depth is GL_DEPTH_COMPONENT16 // so the maximum error is 1.0 / 2^16 #define DEPTH_MAX_ERROR 0.0000152587890625 @@ -583,11 +584,9 @@ float sunShadow(in vec3 viewOrigin, in vec3 viewDir, in vec3 biasOffset) return result; } - -#define EPSILON 0.00000001 +#endif #if defined(USE_PARALLAXMAP) - float RayIntersectDisplaceMap(in vec2 inDp, in vec2 ds, in sampler2D normalMap, in float parallaxBias) { const int linearSearchSteps = 16; From 4f5ca201e39f2b19d126ab619ec3db117373acd1 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:17:57 +0200 Subject: [PATCH 705/708] Remove rend2 github action --- .github/workflows/rend2.yml | 352 ------------------------------------ 1 file changed, 352 deletions(-) delete mode 100644 .github/workflows/rend2.yml diff --git a/.github/workflows/rend2.yml b/.github/workflows/rend2.yml deleted file mode 100644 index 3f925d2f7e..0000000000 --- a/.github/workflows/rend2.yml +++ /dev/null @@ -1,352 +0,0 @@ -name: rend2 - -on: - workflow_dispatch: - push: - branches: [rend2] - paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' - pull_request: - branches: [rend2] - paths-ignore: - - '**.md' - - '*.txt' - - '.gitignore' - - 'docs/*' - release: - types: [published] - -jobs: - msvc: - name: Windows ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) - runs-on: windows-2022 - strategy: - matrix: - arch: [x86, x86_64] - build_type: [Debug, Release] - portable: [Portable, Non-Portable] - include: - - arch: x86 - platform: Win32 - - arch: x86_64 - platform: x64 - - steps: - - uses: actions/checkout@v3 - - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - - - name: Create Build Environment - run: cmake -E make_directory ${{ runner.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ runner.workspace }}/build - run: | - if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" - else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" - fi - cmake $GITHUB_WORKSPACE -A ${{ matrix.platform }} $OPTIONS - - - name: Build - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --build . --config ${{ matrix.build_type }} - - - name: Install - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --install . --config ${{ matrix.build_type }} - - - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} - with: - name: OpenJK-windows-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{ runner.workspace }}/build/bin - if-no-files-found: error - - msvcxp: - name: WinXP ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) - runs-on: windows-2022 - strategy: - matrix: - arch: [x86, x86_64] - build_type: [Debug, Release] - portable: [Portable, Non-Portable] - include: - - arch: x86 - platform: Win32 - - arch: x86_64 - platform: x64 - - steps: - - uses: actions/checkout@v3 - - - name: Install v141_xp Toolchain - continue-on-error: true - shell: powershell - run: | - Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" - $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" - $WorkLoads = '--add Microsoft.VisualStudio.Component.WinXP' - $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"", $WorkLoads, '--quiet', '--norestart', '--nocache') - $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden - if ($process.ExitCode -eq 0) { - Write-Host "components have been successfully added" - } else { - Write-Host "components were not installed" - } - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.1 - - - name: Create Build Environment - run: cmake -E make_directory ${{ runner.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ runner.workspace }}/build - run: | - if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=bin" - else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=bin" - fi - cmake $GITHUB_WORKSPACE -T v141_xp -A ${{ matrix.platform }} $OPTIONS - - - name: Build - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --build . --config ${{ matrix.build_type }} - - - name: Install - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build - shell: bash - run: | - cmake --install . --config ${{ matrix.build_type }} - - - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} - with: - name: OpenJK-windowsxp-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{ runner.workspace }}/build/bin - if-no-files-found: error - - ubuntu: - name: Ubuntu ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable }}) - runs-on: ubuntu-22.04 - strategy: - fail-fast: false - matrix: - arch: [x86, x86_64] - build_type: [Debug, Release] - portable: [Non-Portable] - - steps: - - uses: actions/checkout@v3 - - - name: Create Build Environment - run: | - if [ ${{ matrix.arch }} == "x86" ]; then - sudo dpkg --add-architecture i386 - sudo apt-get -qq update - sudo apt-get -y install aptitude - sudo apt-get -y install gcc-multilib g++-multilib ninja-build - sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgcc-s1:i386 - sudo aptitude -y install libglib2.0-dev:i386 libsdl2-dev:i386 - else - sudo apt-get -qq update - sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libsdl2-dev - fi - cmake -E make_directory ${{ runner.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ runner.workspace }}/build - run: | - if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" - else - OPTIONS="-DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" - fi - - if [ ${{ matrix.arch }} == "x86" ]; then - cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS -DCMAKE_TOOLCHAIN_FILE=cmake/Toolchains/linux-i686.cmake - else - cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} $OPTIONS - fi - - - name: Build - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --build . - - - name: Install - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --install . - - - name: Create binary archive - if: ${{ matrix.build_type == 'Release'}} - working-directory: ${{ runner.workspace }}/install/JediAcademy - shell: bash - run: | - if [ ${{ matrix.arch }} == "x86" ]; then - chmod +x openjk.i386 - else - chmod +x openjk.${{ matrix.arch }} - fi - tar -czvf OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - - - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} - with: - name: OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{runner.workspace}}/install/JediAcademy/OpenJK-linux-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz - if-no-files-found: error - - macos: - name: macOS ${{ matrix.arch }} ${{ matrix.build_type }} (${{ matrix.portable}}) - runs-on: macos-12 - strategy: - fail-fast: false - matrix: - arch: [x86_64] - build_type: [Debug, Release] - portable: [Non-Portable] - - steps: - - uses: actions/checkout@v3 - - - name: Create Build Environment - run: | - brew install zlib libjpeg libpng sdl2 - cmake -E make_directory ${{ runner.workspace }}/build - - - name: Configure CMake - shell: bash - working-directory: ${{ runner.workspace }}/build - run: | - if [ "${{ matrix.portable }}" == "Portable" ]; then - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=ON -DBuildPortableVersion=ON -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" - else - OPTIONS="-DCMAKE_BUILD_TYPE=${{ runner.build_type }} -DUseInternalLibs=OFF -DBuildPortableVersion=OFF -DCMAKE_INSTALL_PREFIX=${{ runner.workspace }}/install" - fi - cmake $GITHUB_WORKSPACE $OPTIONS - - - name: Build - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --build . - - - name: Install - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/build - shell: bash - run: cmake --install . - - - name: Create binary archive - if: ${{ matrix.build_type == 'Release' }} - working-directory: ${{ runner.workspace }}/install/JediAcademy - shell: bash - run: | - chmod +x openjk.x86_64.app/Contents/MacOS/openjk.x86_64 - tar -czvf openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz * - - - uses: actions/upload-artifact@v3 - if: ${{ matrix.build_type == 'Release' }} - with: - name: OpenJK-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }} - path: ${{ runner.workspace }}/install/JediAcademy/openjk-macos-${{ matrix.arch }}-${{ matrix.build_type }}-${{ matrix.portable }}.tar.gz - if-no-files-found: error - - create-latest: - if: github.event_name == 'workflow_dispatch' - needs: [msvc, ubuntu, macos] - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download Artifacts - uses: actions/download-artifact@v3 - - - name: Create binary archives - run: | - 7z a -r OpenJK-rend2-windows-x86.zip ./OpenJK-windows-x86-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - 7z a -r OpenJK-rend2-windows-x86_64.zip ./OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - mv ./OpenJK-linux-x86-Release-Non-Portable/* OpenJK-rend2-linux-x86.tar.gz - mv ./OpenJK-linux-x86_64-Release-Non-Portable/* OpenJK-rend2-linux-x86_64.tar.gz - mv ./OpenJK-macos-x86_64-Release-Non-Portable/* OpenJK-rend2-macos-x86_64.tar.gz - - - name: Create latest build - uses: marvinpinto/action-automatic-releases@latest - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - automatic_release_tag: "latest" - prerelease: false - title: Latest rend2 Build - files: | - *.zip - *.tar.gz - - create-release: - if: github.event_name == 'release' - needs: [msvc, ubuntu, macos] - runs-on: ubuntu-22.04 - - strategy: - matrix: - include: - - artifact_dir: OpenJK-windows-x86-Release-Non-Portable/JediAcademy - artifact_name: OpenJK-rend2-windows-x86.zip - zip: true - - - artifact_dir: OpenJK-windows-x86_64-Release-Non-Portable/JediAcademy - artifact_name: OpenJK-rend2-windows-x86_64.zip - zip: true - - - artifact_dir: OpenJK-linux-x86-Release-Non-Portable - artifact_name: OpenJK-rend2-linux-x86.tar.gz - zip: false - - - artifact_dir: OpenJK-linux-x86_64-Release-Non-Portable - artifact_name: OpenJK-rend2-linux-x86_64.tar.gz - zip: false - - - artifact_dir: OpenJK-macos-x86_64-Release-Non-Portable - artifact_name: OpenJK-rend2-macos-x86_64.tar.gz - zip: false - - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Download Artifacts - uses: actions/download-artifact@v3 - - - name: Create archive - run: | - if [ "${{ matrix.zip }}" == "true" ]; then - 7z a -r ${{ matrix.artifact_name }} ./${{ matrix.artifact_dir }}/* '-x!msvcp*.*' '-x!vcruntime*.*' '-x!concrt*.*' - else - mv ./${{ matrix.artifact_dir }}/* ${{ matrix.artifact_name }} - fi - - - name: Upload archives - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - tag: ${{ github.ref }} - overwrite: true - file: ${{ matrix.artifact_name }} From ac26d131d52932ebc8f0462af03c5cf28a9eaf0a Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:55:02 +0200 Subject: [PATCH 706/708] Dependency update Looks like this was resolved, so its not needed anymore for x86 linux builds? --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec8385bef6..a1d035730d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -159,7 +159,7 @@ jobs: sudo apt-get -qq update sudo apt-get -y install aptitude sudo apt-get -y install gcc-multilib g++-multilib ninja-build - sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgcc-s1:i386 + sudo apt-get -y install --allow-downgrades libpcre2-8-0:i386 libjpeg-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 sudo aptitude -y install libglib2.0-dev:i386 libsdl2-dev:i386 else sudo apt-get -qq update From c4d39a1ba80f9c9fb031e34e001930e981e49240 Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 30 Sep 2023 14:56:18 +0200 Subject: [PATCH 707/708] Draw all sprites even if they exceed the usual bucket size --- codemp/rd-rend2/tr_surface.cpp | 65 +++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 25 deletions(-) diff --git a/codemp/rd-rend2/tr_surface.cpp b/codemp/rd-rend2/tr_surface.cpp index ce29b21156..fc3255a5ed 100644 --- a/codemp/rd-rend2/tr_surface.cpp +++ b/codemp/rd-rend2/tr_surface.cpp @@ -2256,36 +2256,51 @@ static void RB_SurfaceSprites( srfSprites_t *surf ) { currentFrameUbo, tr.fogsUboOffset, UNIFORM_BLOCK_FOGS } }; - DrawItem item = {}; - item.renderState.stateBits = firstStage->stateBits; - item.renderState.cullType = CT_TWO_SIDED; - item.renderState.depthRange = DepthRange{0.0f, 1.0f}; - item.program = program; - item.ibo = surf->ibo; - - item.uniformData = uniformDataWriter.Finish(frameAllocator); + uint32_t numBindings; + UniformData *spriteUniformData = uniformDataWriter.Finish(frameAllocator); + SamplerBinding *spriteSamplerBinding = samplerBindingsWriter.Finish( + frameAllocator, &numBindings); + + int numDrawIndicesUndrawn = surf->numIndices; + int baseVertex = surf->baseVertex; + while (numDrawIndicesUndrawn > 5) + { + int drawIndices = numDrawIndicesUndrawn > 98298 ? 98298 : numDrawIndicesUndrawn; + + DrawItem item = {}; + item.renderState.stateBits = firstStage->stateBits; + item.renderState.cullType = CT_TWO_SIDED; + item.renderState.depthRange = DepthRange{ 0.0f, 1.0f }; + item.program = program; + item.ibo = surf->ibo; - item.samplerBindings = samplerBindingsWriter.Finish( - frameAllocator, &item.numSamplerBindings); + item.uniformData = spriteUniformData; - DrawItemSetVertexAttributes( - item, surf->attributes, surf->numAttributes, frameAllocator); - DrawItemSetUniformBlockBindings( - item, uniformBlockBindings, frameAllocator); + item.samplerBindings = spriteSamplerBinding; + item.numSamplerBindings = numBindings; - item.draw.type = DRAW_COMMAND_INDEXED; - item.draw.primitiveType = GL_TRIANGLES; - item.draw.numInstances = 1; - item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT; - item.draw.params.indexed.firstIndex = 0; - item.draw.params.indexed.numIndices = surf->numIndices; - item.draw.params.indexed.baseVertex = surf->baseVertex; + DrawItemSetVertexAttributes( + item, surf->attributes, surf->numAttributes, frameAllocator); + DrawItemSetUniformBlockBindings( + item, uniformBlockBindings, frameAllocator); - tess.externalIBO = surf->ibo; + item.draw.type = DRAW_COMMAND_INDEXED; + item.draw.primitiveType = GL_TRIANGLES; + item.draw.numInstances = 1; + item.draw.params.indexed.indexType = GL_UNSIGNED_SHORT; + item.draw.params.indexed.firstIndex = 0; + item.draw.params.indexed.numIndices = drawIndices; + item.draw.params.indexed.baseVertex = baseVertex; - uint32_t RB_CreateSortKey( const DrawItem& item, int stage, int layer ); - uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort); - RB_AddDrawItem(backEndData->currentPass, key, item); + tess.externalIBO = surf->ibo; + + uint32_t RB_CreateSortKey(const DrawItem& item, int stage, int layer); + uint32_t key = RB_CreateSortKey(item, 0, surf->shader->sort); + RB_AddDrawItem(backEndData->currentPass, key, item); + + numDrawIndicesUndrawn -= drawIndices; + baseVertex += ((98298 / 6) * 4); + } } void (*rb_surfaceTable[SF_NUM_SURFACE_TYPES])( void *) = { From 3544f148c59453cb726336896e1b4a2fcaef4bfa Mon Sep 17 00:00:00 2001 From: SomaZ <17459161+SomaZ@users.noreply.github.com> Date: Sat, 30 Sep 2023 15:00:22 +0200 Subject: [PATCH 708/708] [MP] fix off-by-one in TruncateGLExtensionsString which affects mods not derived from OJK (#1175) see: https://github.com/JACoders/OpenJK/commit/26b871955051d6c4b12e583557b08153431df38e --- codemp/rd-rend2/tr_init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemp/rd-rend2/tr_init.cpp b/codemp/rd-rend2/tr_init.cpp index 821742c669..490eda6664 100644 --- a/codemp/rd-rend2/tr_init.cpp +++ b/codemp/rd-rend2/tr_init.cpp @@ -429,7 +429,7 @@ static const char *TruncateGLExtensionsString (const char *extensionsString, int char *truncatedExtensions; - while ( (q = strchr (p, ' ')) != NULL && numExtensions <= maxExtensions ) + while ( (q = strchr (p, ' ')) != NULL && numExtensions < maxExtensions ) { p = q + 1; numExtensions++;